1(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 2exports.MP3Demuxer = require('./src/demuxer'); 3exports.MP3Decoder = require('./src/decoder'); 4 5},{"./src/decoder":2,"./src/demuxer":3}],2:[function(require,module,exports){ 6var AV = (window.AV); 7var MP3FrameHeader = require('./header'); 8var MP3Stream = require('./stream'); 9var MP3Frame = require('./frame'); 10var MP3Synth = require('./synth'); 11var Layer1 = require('./layer1'); 12var Layer2 = require('./layer2'); 13var Layer3 = require('./layer3'); 14 15var MP3Decoder = AV.Decoder.extend(function() { 16 AV.Decoder.register('mp3', this); 17 18 this.prototype.init = function() { 19 this.mp3_stream = new MP3Stream(this.bitstream); 20 this.frame = new MP3Frame(); 21 this.synth = new MP3Synth(); 22 this.seeking = false; 23 }; 24 25 this.prototype.readChunk = function() { 26 var stream = this.mp3_stream; 27 var frame = this.frame; 28 var synth = this.synth; 29 30 // if we just seeked, we may start getting errors involving the frame reservoir, 31 // so keep going until we successfully decode a frame 32 if (this.seeking) { 33 while (true) { 34 try { 35 frame.decode(stream); 36 break; 37 } catch (err) { 38 if (err instanceof AV.UnderflowError) 39 throw err; 40 } 41 } 42 43 this.seeking = false; 44 } else { 45 frame.decode(stream); 46 } 47 48 synth.frame(frame); 49 50 // interleave samples 51 var data = synth.pcm.samples, 52 channels = synth.pcm.channels, 53 len = synth.pcm.length, 54 output = new Float32Array(len * channels), 55 j = 0; 56 57 for (var k = 0; k < len; k++) { 58 for (var i = 0; i < channels; i++) { 59 output[j++] = data[i][k]; 60 } 61 } 62 63 return output; 64 }; 65 66 this.prototype.seek = function(timestamp) { 67 var offset; 68 69 // if there was a Xing or VBRI tag with a seek table, use that 70 // otherwise guesstimate based on CBR bitrate 71 if (this.demuxer.seekPoints.length > 0) { 72 timestamp = this._super(timestamp); 73 offset = this.stream.offset; 74 } else { 75 offset = timestamp * this.format.bitrate / 8 / this.format.sampleRate; 76 } 77 78 this.mp3_stream.reset(offset); 79 80 // try to find 3 consecutive valid frame headers in a row 81 for (var i = 0; i < 4096; i++) { 82 var pos = offset + i; 83 for (var j = 0; j < 3; j++) { 84 this.mp3_stream.reset(pos); 85 86 try { 87 var header = MP3FrameHeader.decode(this.mp3_stream); 88 } catch (e) { 89 break; 90 } 91 92 // skip the rest of the frame 93 var size = header.framesize(); 94 if (size == null) 95 break; 96 97 pos += size; 98 } 99 100 // check if we're done 101 if (j === 3) 102 break; 103 } 104 105 // if we didn't find 3 frames, just try the first one and hope for the best 106 if (j !== 3) 107 i = 0; 108 109 this.mp3_stream.reset(offset + i); 110 111 // if we guesstimated, update the timestamp to another estimate of where we actually seeked to 112 if (this.demuxer.seekPoints.length === 0) 113 timestamp = this.stream.offset / (this.format.bitrate / 8) * this.format.sampleRate; 114 115 this.seeking = true; 116 return timestamp; 117 }; 118}); 119 120module.exports = MP3Decoder; 121 122},{"./frame":4,"./header":5,"./layer1":9,"./layer2":10,"./layer3":11,"./stream":12,"./synth":13}],3:[function(require,module,exports){ 123var AV = (window.AV); 124var ID3v23Stream = require('./id3').ID3v23Stream; 125var ID3v22Stream = require('./id3').ID3v22Stream; 126var MP3FrameHeader = require('./header'); 127var MP3Stream = require('./stream'); 128 129var MP3Demuxer = AV.Demuxer.extend(function() { 130 AV.Demuxer.register(this); 131 132 this.probe = function(stream) { 133 var off = stream.offset; 134 135 // skip id3 metadata if it exists 136 var id3header = MP3Demuxer.getID3v2Header(stream); 137 if (id3header) 138 stream.advance(10 + id3header.length); 139 140 // attempt to read the header of the first audio frame 141 var s = new MP3Stream(new AV.Bitstream(stream)); 142 var header = null; 143 144 try { 145 header = MP3FrameHeader.decode(s); 146 } catch (e) {}; 147 148 // go back to the beginning, for other probes 149 stream.seek(off); 150 151 return !!header; 152 }; 153 154 this.getID3v2Header = function(stream) { 155 if (stream.peekString(0, 3) == 'ID3') { 156 stream = AV.Stream.fromBuffer(stream.peekBuffer(0, 10)); 157 stream.advance(3); // 'ID3' 158 159 var major = stream.readUInt8(); 160 var minor = stream.readUInt8(); 161 var flags = stream.readUInt8(); 162 var bytes = stream.readBuffer(4).data; 163 var length = (bytes[0] << 21) | (bytes[1] << 14) | (bytes[2] << 7) | bytes[3]; 164 165 return { 166 version: '2.' + major + '.' + minor, 167 major: major, 168 minor: minor, 169 flags: flags, 170 length: length 171 }; 172 } 173 174 return null; 175 }; 176 177 const XING_OFFSETS = [[32, 17], [17, 9]]; 178 this.prototype.parseDuration = function(header) { 179 var stream = this.stream; 180 var frames; 181 182 var offset = stream.offset; 183 if (!header || header.layer !== 3) 184 return false; 185 186 // Check for Xing/Info tag 187 stream.advance(XING_OFFSETS[header.flags & MP3FrameHeader.FLAGS.LSF_EXT ? 1 : 0][header.nchannels() === 1 ? 1 : 0]); 188 var tag = stream.readString(4); 189 if (tag === 'Xing' || tag === 'Info') { 190 var flags = stream.readUInt32(); 191 if (flags & 1) 192 frames = stream.readUInt32(); 193 194 if (flags & 2) 195 var size = stream.readUInt32(); 196 197 if (flags & 4 && frames && size) { 198 for (var i = 0; i < 100; i++) { 199 var b = stream.readUInt8(); 200 var pos = b / 256 * size | 0; 201 var time = i / 100 * (frames * header.nbsamples() * 32) | 0; 202 this.addSeekPoint(pos, time); 203 } 204 } 205 206 if (flags & 8) 207 stream.advance(4); 208 209 } else { 210 // Check for VBRI tag (always 32 bytes after end of mpegaudio header) 211 stream.seek(offset + 4 + 32); 212 tag = stream.readString(4); 213 if (tag == 'VBRI' && stream.readUInt16() === 1) { // Check tag version 214 stream.advance(4); // skip delay and quality 215 stream.advance(4); // skip size 216 frames = stream.readUInt32(); 217 218 var entries = stream.readUInt16(); 219 var scale = stream.readUInt16(); 220 var bytesPerEntry = stream.readUInt16(); 221 var framesPerEntry = stream.readUInt16(); 222 var fn = 'readUInt' + (bytesPerEntry * 8); 223 224 var pos = 0; 225 for (var i = 0; i < entries; i++) { 226 this.addSeekPoint(pos, framesPerEntry * i); 227 pos += stream[fn](); 228 } 229 } 230 } 231 232 if (!frames) 233 return false; 234 235 this.emit('duration', (frames * header.nbsamples() * 32) / header.samplerate * 1000 | 0); 236 return true; 237 }; 238 239 this.prototype.readChunk = function() { 240 var stream = this.stream; 241 242 if (!this.sentInfo) { 243 // read id3 metadata if it exists 244 var id3header = MP3Demuxer.getID3v2Header(stream); 245 if (id3header) { 246 stream.advance(10); 247 248 if (id3header.major > 2) { 249 var id3 = new ID3v23Stream(id3header, stream); 250 } else { 251 var id3 = new ID3v22Stream(id3header, stream); 252 } 253 254 this.emit('metadata', id3.read()); 255 } 256 257 // read the header of the first audio frame 258 var off = stream.offset; 259 var s = new MP3Stream(new AV.Bitstream(stream)); 260 261 var header = MP3FrameHeader.decode(s); 262 if (!header) 263 return this.emit('error', 'Could not find first frame.'); 264 265 this.emit('format', { 266 formatID: 'mp3', 267 sampleRate: header.samplerate, 268 channelsPerFrame: header.nchannels(), 269 bitrate: header.bitrate, 270 floatingPoint: true 271 }); 272 273 var sentDuration = this.parseDuration(header); 274 stream.advance(off - stream.offset); 275 276 // if there were no Xing/VBRI tags, guesstimate the duration based on data size and bitrate 277 this.dataSize = 0; 278 if (!sentDuration) { 279 this.on('end', function() { 280 this.emit('duration', this.dataSize * 8 / header.bitrate * 1000 | 0); 281 }); 282 } 283 284 this.sentInfo = true; 285 } 286 287 while (stream.available(1)) { 288 var buffer = stream.readSingleBuffer(stream.remainingBytes()); 289 this.dataSize += buffer.length; 290 this.emit('data', buffer); 291 } 292 }; 293}); 294 295module.exports = MP3Demuxer; 296 297},{"./header":5,"./id3":7,"./stream":12}],4:[function(require,module,exports){ 298var MP3FrameHeader = require('./header'); 299var utils = require('./utils'); 300 301function MP3Frame() { 302 this.header = null; // MPEG audio header 303 this.options = 0; // decoding options (from stream) 304 this.sbsample = utils.makeArray([2, 36, 32]); // synthesis subband filter samples 305 this.overlap = utils.makeArray([2, 32, 18]); // Layer III block overlap data 306 this.decoders = []; 307} 308 309// included layer decoders are registered here 310MP3Frame.layers = []; 311 312MP3Frame.prototype.decode = function(stream) { 313 if (!this.header || !(this.header.flags & MP3FrameHeader.FLAGS.INCOMPLETE)) 314 this.header = MP3FrameHeader.decode(stream); 315 316 this.header.flags &= ~MP3FrameHeader.FLAGS.INCOMPLETE; 317 318 // make an instance of the decoder for this layer if needed 319 var decoder = this.decoders[this.header.layer - 1]; 320 if (!decoder) { 321 var Layer = MP3Frame.layers[this.header.layer]; 322 if (!Layer) 323 throw new Error("Layer " + this.header.layer + " is not supported."); 324 325 decoder = this.decoders[this.header.layer - 1] = new Layer(); 326 } 327 328 decoder.decode(stream, this); 329}; 330 331module.exports = MP3Frame; 332 333},{"./header":5,"./utils":15}],5:[function(require,module,exports){ 334var AV = (window.AV); 335 336function MP3FrameHeader() { 337 this.layer = 0; // audio layer (1, 2, or 3) 338 this.mode = 0; // channel mode (see above) 339 this.mode_extension = 0; // additional mode info 340 this.emphasis = 0; // de-emphasis to use (see above) 341 342 this.bitrate = 0; // stream bitrate (bps) 343 this.samplerate = 0; // sampling frequency (Hz) 344 345 this.crc_check = 0; // frame CRC accumulator 346 this.crc_target = 0; // final target CRC checksum 347 348 this.flags = 0; // flags (see above) 349 this.private_bits = 0; // private bits 350} 351 352const BITRATES = [ 353 // MPEG-1 354 [ 0, 32000, 64000, 96000, 128000, 160000, 192000, 224000, // Layer I 355 256000, 288000, 320000, 352000, 384000, 416000, 448000 ], 356 [ 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, // Layer II 357 128000, 160000, 192000, 224000, 256000, 320000, 384000 ], 358 [ 0, 32000, 40000, 48000, 56000, 64000, 80000, 96000, // Layer III 359 112000, 128000, 160000, 192000, 224000, 256000, 320000 ], 360 361 // MPEG-2 LSF 362 [ 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, // Layer I 363 128000, 144000, 160000, 176000, 192000, 224000, 256000 ], 364 [ 0, 8000, 16000, 24000, 32000, 40000, 48000, 56000, // Layers 365 64000, 80000, 96000, 112000, 128000, 144000, 160000 ] // II & III 366]; 367 368const SAMPLERATES = [ 369 44100, 48000, 32000 370]; 371 372MP3FrameHeader.FLAGS = { 373 NPRIVATE_III: 0x0007, // number of Layer III private bits 374 INCOMPLETE : 0x0008, // header but not data is decoded 375 376 PROTECTION : 0x0010, // frame has CRC protection 377 COPYRIGHT : 0x0020, // frame is copyright 378 ORIGINAL : 0x0040, // frame is original (else copy) 379 PADDING : 0x0080, // frame has additional slot 380 381 I_STEREO : 0x0100, // uses intensity joint stereo 382 MS_STEREO : 0x0200, // uses middle/side joint stereo 383 FREEFORMAT : 0x0400, // uses free format bitrate 384 385 LSF_EXT : 0x1000, // lower sampling freq. extension 386 MC_EXT : 0x2000, // multichannel audio extension 387 MPEG_2_5_EXT: 0x4000 // MPEG 2.5 (unofficial) extension 388}; 389 390const PRIVATE = { 391 HEADER : 0x0100, // header private bit 392 III : 0x001f // Layer III private bits (up to 5) 393}; 394 395MP3FrameHeader.MODE = { 396 SINGLE_CHANNEL: 0, // single channel 397 DUAL_CHANNEL : 1, // dual channel 398 JOINT_STEREO : 2, // joint (MS/intensity) stereo 399 STEREO : 3 // normal LR stereo 400}; 401 402const EMPHASIS = { 403 NONE : 0, // no emphasis 404 _50_15_US : 1, // 50/15 microseconds emphasis 405 CCITT_J_17: 3, // CCITT J.17 emphasis 406 RESERVED : 2 // unknown emphasis 407}; 408 409MP3FrameHeader.BUFFER_GUARD = 8; 410MP3FrameHeader.BUFFER_MDLEN = (511 + 2048 + MP3FrameHeader.BUFFER_GUARD); 411 412MP3FrameHeader.prototype.copy = function() { 413 var clone = new MP3FrameHeader(); 414 var keys = Object.keys(this); 415 416 for (var key in keys) { 417 clone[key] = this[key]; 418 } 419 420 return clone; 421} 422 423MP3FrameHeader.prototype.nchannels = function () { 424 return this.mode === 0 ? 1 : 2; 425}; 426 427MP3FrameHeader.prototype.nbsamples = function() { 428 return (this.layer === 1 ? 12 : ((this.layer === 3 && (this.flags & MP3FrameHeader.FLAGS.LSF_EXT)) ? 18 : 36)); 429}; 430 431MP3FrameHeader.prototype.framesize = function() { 432 if (this.bitrate === 0) 433 return null; 434 435 var padding = (this.flags & MP3FrameHeader.FLAGS.PADDING ? 1 : 0); 436 switch (this.layer) { 437 case 1: 438 var size = (this.bitrate * 12) / this.samplerate | 0; 439 return (size + padding) * 4; 440 441 case 2: 442 var size = (this.bitrate * 144) / this.samplerate | 0; 443 return size + padding; 444 445 case 3: 446 default: 447 var lsf = this.flags & MP3FrameHeader.FLAGS.LSF_EXT ? 1 : 0; 448 var size = (this.bitrate * 144) / (this.samplerate << lsf) | 0; 449 return size + padding; 450 } 451}; 452 453MP3FrameHeader.prototype.decode = function(stream) { 454 this.flags = 0; 455 this.private_bits = 0; 456 457 // syncword 458 stream.advance(11); 459 460 // MPEG 2.5 indicator (really part of syncword) 461 if (stream.read(1) === 0) 462 this.flags |= MP3FrameHeader.FLAGS.MPEG_2_5_EXT; 463 464 // ID 465 if (stream.read(1) === 0) { 466 this.flags |= MP3FrameHeader.FLAGS.LSF_EXT; 467 } else if (this.flags & MP3FrameHeader.FLAGS.MPEG_2_5_EXT) { 468 throw new AV.UnderflowError(); // LOSTSYNC 469 } 470 471 // layer 472 this.layer = 4 - stream.read(2); 473 474 if (this.layer === 4) 475 throw new Error('Invalid layer'); 476 477 // protection_bit 478 if (stream.read(1) === 0) 479 this.flags |= MP3FrameHeader.FLAGS.PROTECTION; 480 481 // bitrate_index 482 var index = stream.read(4); 483 if (index === 15) 484 throw new Error('Invalid bitrate'); 485 486 if (this.flags & MP3FrameHeader.FLAGS.LSF_EXT) { 487 this.bitrate = BITRATES[3 + (this.layer >> 1)][index]; 488 } else { 489 this.bitrate = BITRATES[this.layer - 1][index]; 490 } 491 492 // sampling_frequency 493 index = stream.read(2); 494 if (index === 3) 495 throw new Error('Invalid sampling frequency'); 496 497 this.samplerate = SAMPLERATES[index]; 498 499 if (this.flags & MP3FrameHeader.FLAGS.LSF_EXT) { 500 this.samplerate /= 2; 501 502 if (this.flags & MP3FrameHeader.FLAGS.MPEG_2_5_EXT) 503 this.samplerate /= 2; 504 } 505 506 // padding_bit 507 if (stream.read(1)) 508 this.flags |= MP3FrameHeader.FLAGS.PADDING; 509 510 // private_bit 511 if (stream.read(1)) 512 this.private_bits |= PRIVATE.HEADER; 513 514 // mode 515 this.mode = 3 - stream.read(2); 516 517 // mode_extension 518 this.mode_extension = stream.read(2); 519 520 // copyright 521 if (stream.read(1)) 522 this.flags |= MP3FrameHeader.FLAGS.COPYRIGHT; 523 524 // original/copy 525 if (stream.read(1)) 526 this.flags |= MP3FrameHeader.FLAGS.ORIGINAL; 527 528 // emphasis 529 this.emphasis = stream.read(2); 530 531 // crc_check 532 if (this.flags & MP3FrameHeader.FLAGS.PROTECTION) 533 this.crc_target = stream.read(16); 534}; 535 536MP3FrameHeader.decode = function(stream) { 537 // synchronize 538 var ptr = stream.next_frame; 539 var syncing = true; 540 var header = null; 541 542 while (syncing) { 543 syncing = false; 544 545 if (stream.sync) { 546 if (!stream.available(MP3FrameHeader.BUFFER_GUARD)) { 547 stream.next_frame = ptr; 548 throw new AV.UnderflowError(); 549 } else if (!(stream.getU8(ptr) === 0xff && (stream.getU8(ptr + 1) & 0xe0) === 0xe0)) { 550 // mark point where frame sync word was expected 551 stream.this_frame = ptr; 552 stream.next_frame = ptr + 1; 553 throw new AV.UnderflowError(); // LOSTSYNC 554 } 555 } else { 556 stream.seek(ptr * 8); 557 if (!stream.doSync()) 558 throw new AV.UnderflowError(); 559 560 ptr = stream.nextByte(); 561 } 562 563 // begin processing 564 stream.this_frame = ptr; 565 stream.next_frame = ptr + 1; // possibly bogus sync word 566 567 stream.seek(stream.this_frame * 8); 568 569 header = new MP3FrameHeader(); 570 header.decode(stream); 571 572 if (header.bitrate === 0) { 573 if (stream.freerate === 0 || !stream.sync || (header.layer === 3 && stream.freerate > 640000)) 574 MP3FrameHeader.free_bitrate(stream, header); 575 576 header.bitrate = stream.freerate; 577 header.flags |= MP3FrameHeader.FLAGS.FREEFORMAT; 578 } 579 580 // calculate beginning of next frame 581 var pad_slot = (header.flags & MP3FrameHeader.FLAGS.PADDING) ? 1 : 0; 582 583 if (header.layer === 1) { 584 var N = (((12 * header.bitrate / header.samplerate) << 0) + pad_slot) * 4; 585 } else { 586 var slots_per_frame = (header.layer === 3 && (header.flags & MP3FrameHeader.FLAGS.LSF_EXT)) ? 72 : 144; 587 var N = ((slots_per_frame * header.bitrate / header.samplerate) << 0) + pad_slot; 588 } 589 590 // verify there is enough data left in buffer to decode this frame 591 if (!stream.available(N + MP3FrameHeader.BUFFER_GUARD)) { 592 stream.next_frame = stream.this_frame; 593 throw new AV.UnderflowError(); 594 } 595 596 stream.next_frame = stream.this_frame + N; 597 598 if (!stream.sync) { 599 // check that a valid frame header follows this frame 600 ptr = stream.next_frame; 601 602 if (!(stream.getU8(ptr) === 0xff && (stream.getU8(ptr + 1) & 0xe0) === 0xe0)) { 603 ptr = stream.next_frame = stream.this_frame + 1; 604 605 // emulating 'goto sync' 606 syncing = true; 607 continue; 608 } 609 610 stream.sync = true; 611 } 612 } 613 614 header.flags |= MP3FrameHeader.FLAGS.INCOMPLETE; 615 return header; 616}; 617 618MP3FrameHeader.free_bitrate = function(stream, header) { 619 var pad_slot = header.flags & MP3FrameHeader.FLAGS.PADDING ? 1 : 0, 620 slots_per_frame = header.layer === 3 && header.flags & MP3FrameHeader.FLAGS.LSF_EXT ? 72 : 144; 621 622 var start = stream.offset(); 623 var rate = 0; 624 625 while (stream.doSync()) { 626 var peek_header = header.copy(); 627 var peek_stream = stream.copy(); 628 629 if (peek_header.decode(peek_stream) && peek_header.layer === header.layer && peek_header.samplerate === header.samplerate) { 630 var N = stream.nextByte() - stream.this_frame; 631 632 if (header.layer === 1) { 633 rate = header.samplerate * (N - 4 * pad_slot + 4) / 48 / 1000 | 0; 634 } else { 635 rate = header.samplerate * (N - pad_slot + 1) / slots_per_frame / 1000 | 0; 636 } 637 638 if (rate >= 8) 639 break; 640 } 641 642 stream.advance(8); 643 } 644 645 stream.seek(start); 646 647 if (rate < 8 || (header.layer === 3 && rate > 640)) 648 throw new AV.UnderflowError(); // LOSTSYNC 649 650 stream.freerate = rate * 1000; 651}; 652 653module.exports = MP3FrameHeader; 654 655},{}],6:[function(require,module,exports){ 656/* 657 * These are the Huffman code words for Layer III. 658 * The data for these tables are derived from Table B.7 of ISO/IEC 11172-3. 659 * 660 * These tables support decoding up to 4 Huffman code bits at a time. 661 */ 662 663var PTR = function(offs, bits) { 664 return { 665 final: 0, 666 ptr: { 667 bits: bits, 668 offset: offs 669 } 670 }; 671}; 672 673var huffquad_V = function (v, w, x, y, hlen) { 674 return { 675 final: 1, 676 value: { 677 v: v, 678 w: w, 679 x: x, 680 y: y, 681 hlen: hlen 682 } 683 }; 684}; 685 686const hufftabA = [ 687 /* 0000 */ PTR(16, 2), 688 /* 0001 */ PTR(20, 2), 689 /* 0010 */ PTR(24, 1), 690 /* 0011 */ PTR(26, 1), 691 /* 0100 */ huffquad_V(0, 0, 1, 0, 4), 692 /* 0101 */ huffquad_V(0, 0, 0, 1, 4), 693 /* 0110 */ huffquad_V(0, 1, 0, 0, 4), 694 /* 0111 */ huffquad_V(1, 0, 0, 0, 4), 695 /* 1000 */ huffquad_V(0, 0, 0, 0, 1), 696 /* 1001 */ huffquad_V(0, 0, 0, 0, 1), 697 /* 1010 */ huffquad_V(0, 0, 0, 0, 1), 698 /* 1011 */ huffquad_V(0, 0, 0, 0, 1), 699 /* 1100 */ huffquad_V(0, 0, 0, 0, 1), 700 /* 1101 */ huffquad_V(0, 0, 0, 0, 1), 701 /* 1110 */ huffquad_V(0, 0, 0, 0, 1), 702 /* 1111 */ huffquad_V(0, 0, 0, 0, 1), 703 704 /* 0000 ... */ 705 /* 00 */ huffquad_V(1, 0, 1, 1, 2), /* 16 */ 706 /* 01 */ huffquad_V(1, 1, 1, 1, 2), 707 /* 10 */ huffquad_V(1, 1, 0, 1, 2), 708 /* 11 */ huffquad_V(1, 1, 1, 0, 2), 709 710 /* 0001 ... */ 711 /* 00 */ huffquad_V(0, 1, 1, 1, 2), /* 20 */ 712 /* 01 */ huffquad_V(0, 1, 0, 1, 2), 713 /* 10 */ huffquad_V(1, 0, 0, 1, 1), 714 /* 11 */ huffquad_V(1, 0, 0, 1, 1), 715 716 /* 0010 ... */ 717 /* 0 */ huffquad_V(0, 1, 1, 0, 1), /* 24 */ 718 /* 1 */ huffquad_V(0, 0, 1, 1, 1), 719 720 /* 0011 ... */ 721 /* 0 */ huffquad_V(1, 0, 1, 0, 1), /* 26 */ 722 /* 1 */ huffquad_V(1, 1, 0, 0, 1) 723]; 724 725const hufftabB = [ 726 /* 0000 */ huffquad_V(1, 1, 1, 1, 4), 727 /* 0001 */ huffquad_V(1, 1, 1, 0, 4), 728 /* 0010 */ huffquad_V(1, 1, 0, 1, 4), 729 /* 0011 */ huffquad_V(1, 1, 0, 0, 4), 730 /* 0100 */ huffquad_V(1, 0, 1, 1, 4), 731 /* 0101 */ huffquad_V(1, 0, 1, 0, 4), 732 /* 0110 */ huffquad_V(1, 0, 0, 1, 4), 733 /* 0111 */ huffquad_V(1, 0, 0, 0, 4), 734 /* 1000 */ huffquad_V(0, 1, 1, 1, 4), 735 /* 1001 */ huffquad_V(0, 1, 1, 0, 4), 736 /* 1010 */ huffquad_V(0, 1, 0, 1, 4), 737 /* 1011 */ huffquad_V(0, 1, 0, 0, 4), 738 /* 1100 */ huffquad_V(0, 0, 1, 1, 4), 739 /* 1101 */ huffquad_V(0, 0, 1, 0, 4), 740 /* 1110 */ huffquad_V(0, 0, 0, 1, 4), 741 /* 1111 */ huffquad_V(0, 0, 0, 0, 4) 742]; 743 744var V = function (x, y, hlen) { 745 return { 746 final: 1, 747 value: { 748 x: x, 749 y: y, 750 hlen: hlen 751 } 752 }; 753}; 754 755const hufftab0 = [ 756 /* */ V(0, 0, 0) 757]; 758 759const hufftab1 = [ 760 /* 000 */ V(1, 1, 3), 761 /* 001 */ V(0, 1, 3), 762 /* 010 */ V(1, 0, 2), 763 /* 011 */ V(1, 0, 2), 764 /* 100 */ V(0, 0, 1), 765 /* 101 */ V(0, 0, 1), 766 /* 110 */ V(0, 0, 1), 767 /* 111 */ V(0, 0, 1) 768]; 769 770const hufftab2 = [ 771 /* 000 */ PTR(8, 3), 772 /* 001 */ V(1, 1, 3), 773 /* 010 */ V(0, 1, 3), 774 /* 011 */ V(1, 0, 3), 775 /* 100 */ V(0, 0, 1), 776 /* 101 */ V(0, 0, 1), 777 /* 110 */ V(0, 0, 1), 778 /* 111 */ V(0, 0, 1), 779 780 /* 000 ... */ 781 /* 000 */ V(2, 2, 3), /* 8 */ 782 /* 001 */ V(0, 2, 3), 783 /* 010 */ V(1, 2, 2), 784 /* 011 */ V(1, 2, 2), 785 /* 100 */ V(2, 1, 2), 786 /* 101 */ V(2, 1, 2), 787 /* 110 */ V(2, 0, 2), 788 /* 111 */ V(2, 0, 2) 789]; 790 791const hufftab3 = [ 792 /* 000 */ PTR(8, 3), 793 /* 001 */ V(1, 0, 3), 794 /* 010 */ V(1, 1, 2), 795 /* 011 */ V(1, 1, 2), 796 /* 100 */ V(0, 1, 2), 797 /* 101 */ V(0, 1, 2), 798 /* 110 */ V(0, 0, 2), 799 /* 111 */ V(0, 0, 2), 800 801 /* 000 ... */ 802 /* 000 */ V(2, 2, 3), /* 8 */ 803 /* 001 */ V(0, 2, 3), 804 /* 010 */ V(1, 2, 2), 805 /* 011 */ V(1, 2, 2), 806 /* 100 */ V(2, 1, 2), 807 /* 101 */ V(2, 1, 2), 808 /* 110 */ V(2, 0, 2), 809 /* 111 */ V(2, 0, 2) 810]; 811 812const hufftab5 = [ 813 /* 000 */ PTR(8, 4), 814 /* 001 */ V(1, 1, 3), 815 /* 010 */ V(0, 1, 3), 816 /* 011 */ V(1, 0, 3), 817 /* 100 */ V(0, 0, 1), 818 /* 101 */ V(0, 0, 1), 819 /* 110 */ V(0, 0, 1), 820 /* 111 */ V(0, 0, 1), 821 822 /* 000 ... */ 823 /* 0000 */ PTR(24, 1), /* 8 */ 824 /* 0001 */ V(3, 2, 4), 825 /* 0010 */ V(3, 1, 3), 826 /* 0011 */ V(3, 1, 3), 827 /* 0100 */ V(1, 3, 4), 828 /* 0101 */ V(0, 3, 4), 829 /* 0110 */ V(3, 0, 4), 830 /* 0111 */ V(2, 2, 4), 831 /* 1000 */ V(1, 2, 3), 832 /* 1001 */ V(1, 2, 3), 833 /* 1010 */ V(2, 1, 3), 834 /* 1011 */ V(2, 1, 3), 835 /* 1100 */ V(0, 2, 3), 836 /* 1101 */ V(0, 2, 3), 837 /* 1110 */ V(2, 0, 3), 838 /* 1111 */ V(2, 0, 3), 839 840 /* 000 0000 ... */ 841 /* 0 */ V(3, 3, 1), /* 24 */ 842 /* 1 */ V(2, 3, 1) 843]; 844 845const hufftab6 = [ 846 /* 0000 */ PTR(16, 3), 847 /* 0001 */ PTR(24, 1), 848 /* 0010 */ PTR(26, 1), 849 /* 0011 */ V(1, 2, 4), 850 /* 0100 */ V(2, 1, 4), 851 /* 0101 */ V(2, 0, 4), 852 /* 0110 */ V(0, 1, 3), 853 /* 0111 */ V(0, 1, 3), 854 /* 1000 */ V(1, 1, 2), 855 /* 1001 */ V(1, 1, 2), 856 /* 1010 */ V(1, 1, 2), 857 /* 1011 */ V(1, 1, 2), 858 /* 1100 */ V(1, 0, 3), 859 /* 1101 */ V(1, 0, 3), 860 /* 1110 */ V(0, 0, 3), 861 /* 1111 */ V(0, 0, 3), 862 863 /* 0000 ... */ 864 /* 000 */ V(3, 3, 3), /* 16 */ 865 /* 001 */ V(0, 3, 3), 866 /* 010 */ V(2, 3, 2), 867 /* 011 */ V(2, 3, 2), 868 /* 100 */ V(3, 2, 2), 869 /* 101 */ V(3, 2, 2), 870 /* 110 */ V(3, 0, 2), 871 /* 111 */ V(3, 0, 2), 872 873 /* 0001 ... */ 874 /* 0 */ V(1, 3, 1), /* 24 */ 875 /* 1 */ V(3, 1, 1), 876 877 /* 0010 ... */ 878 /* 0 */ V(2, 2, 1), /* 26 */ 879 /* 1 */ V(0, 2, 1) 880]; 881 882const hufftab7 = [ 883 /* 0000 */ PTR(16, 4), 884 /* 0001 */ PTR(32, 4), 885 /* 0010 */ PTR(48, 2), 886 /* 0011 */ V(1, 1, 4), 887 /* 0100 */ V(0, 1, 3), 888 /* 0101 */ V(0, 1, 3), 889 /* 0110 */ V(1, 0, 3), 890 /* 0111 */ V(1, 0, 3), 891 /* 1000 */ V(0, 0, 1), 892 /* 1001 */ V(0, 0, 1), 893 /* 1010 */ V(0, 0, 1), 894 /* 1011 */ V(0, 0, 1), 895 /* 1100 */ V(0, 0, 1), 896 /* 1101 */ V(0, 0, 1), 897 /* 1110 */ V(0, 0, 1), 898 /* 1111 */ V(0, 0, 1), 899 900 /* 0000 ... */ 901 /* 0000 */ PTR(52, 2), /* 16 */ 902 /* 0001 */ PTR(56, 1), 903 /* 0010 */ PTR(58, 1), 904 /* 0011 */ V(1, 5, 4), 905 /* 0100 */ V(5, 1, 4), 906 /* 0101 */ PTR(60, 1), 907 /* 0110 */ V(5, 0, 4), 908 /* 0111 */ PTR(62, 1), 909 /* 1000 */ V(2, 4, 4), 910 /* 1001 */ V(4, 2, 4), 911 /* 1010 */ V(1, 4, 3), 912 /* 1011 */ V(1, 4, 3), 913 /* 1100 */ V(4, 1, 3), 914 /* 1101 */ V(4, 1, 3), 915 /* 1110 */ V(4, 0, 3), 916 /* 1111 */ V(4, 0, 3), 917 918 /* 0001 ... */ 919 /* 0000 */ V(0, 4, 4), /* 32 */ 920 /* 0001 */ V(2, 3, 4), 921 /* 0010 */ V(3, 2, 4), 922 /* 0011 */ V(0, 3, 4), 923 /* 0100 */ V(1, 3, 3), 924 /* 0101 */ V(1, 3, 3), 925 /* 0110 */ V(3, 1, 3), 926 /* 0111 */ V(3, 1, 3), 927 /* 1000 */ V(3, 0, 3), 928 /* 1001 */ V(3, 0, 3), 929 /* 1010 */ V(2, 2, 3), 930 /* 1011 */ V(2, 2, 3), 931 /* 1100 */ V(1, 2, 2), 932 /* 1101 */ V(1, 2, 2), 933 /* 1110 */ V(1, 2, 2), 934 /* 1111 */ V(1, 2, 2), 935 936 /* 0010 ... */ 937 /* 00 */ V(2, 1, 1), /* 48 */ 938 /* 01 */ V(2, 1, 1), 939 /* 10 */ V(0, 2, 2), 940 /* 11 */ V(2, 0, 2), 941 942 /* 0000 0000 ... */ 943 /* 00 */ V(5, 5, 2), /* 52 */ 944 /* 01 */ V(4, 5, 2), 945 /* 10 */ V(5, 4, 2), 946 /* 11 */ V(5, 3, 2), 947 948 /* 0000 0001 ... */ 949 /* 0 */ V(3, 5, 1), /* 56 */ 950 /* 1 */ V(4, 4, 1), 951 952 /* 0000 0010 ... */ 953 /* 0 */ V(2, 5, 1), /* 58 */ 954 /* 1 */ V(5, 2, 1), 955 956 /* 0000 0101 ... */ 957 /* 0 */ V(0, 5, 1), /* 60 */ 958 /* 1 */ V(3, 4, 1), 959 960 /* 0000 0111 ... */ 961 /* 0 */ V(4, 3, 1), /* 62 */ 962 /* 1 */ V(3, 3, 1) 963]; 964 965const hufftab8 = [ 966 /* 0000 */ PTR(16, 4), 967 /* 0001 */ PTR(32, 4), 968 /* 0010 */ V(1, 2, 4), 969 /* 0011 */ V(2, 1, 4), 970 /* 0100 */ V(1, 1, 2), 971 /* 0101 */ V(1, 1, 2), 972 /* 0110 */ V(1, 1, 2), 973 /* 0111 */ V(1, 1, 2), 974 /* 1000 */ V(0, 1, 3), 975 /* 1001 */ V(0, 1, 3), 976 /* 1010 */ V(1, 0, 3), 977 /* 1011 */ V(1, 0, 3), 978 /* 1100 */ V(0, 0, 2), 979 /* 1101 */ V(0, 0, 2), 980 /* 1110 */ V(0, 0, 2), 981 /* 1111 */ V(0, 0, 2), 982 983 /* 0000 ... */ 984 /* 0000 */ PTR(48, 3), /* 16 */ 985 /* 0001 */ PTR(56, 2), 986 /* 0010 */ PTR(60, 1), 987 /* 0011 */ V(1, 5, 4), 988 /* 0100 */ V(5, 1, 4), 989 /* 0101 */ PTR(62, 1), 990 /* 0110 */ PTR(64, 1), 991 /* 0111 */ V(2, 4, 4), 992 /* 1000 */ V(4, 2, 4), 993 /* 1001 */ V(1, 4, 4), 994 /* 1010 */ V(4, 1, 3), 995 /* 1011 */ V(4, 1, 3), 996 /* 1100 */ V(0, 4, 4), 997 /* 1101 */ V(4, 0, 4), 998 /* 1110 */ V(2, 3, 4), 999 /* 1111 */ V(3, 2, 4), 1000 1001 /* 0001 ... */ 1002 /* 0000 */ V(1, 3, 4), /* 32 */ 1003 /* 0001 */ V(3, 1, 4), 1004 /* 0010 */ V(0, 3, 4), 1005 /* 0011 */ V(3, 0, 4), 1006 /* 0100 */ V(2, 2, 2), 1007 /* 0101 */ V(2, 2, 2), 1008 /* 0110 */ V(2, 2, 2), 1009 /* 0111 */ V(2, 2, 2), 1010 /* 1000 */ V(0, 2, 2), 1011 /* 1001 */ V(0, 2, 2), 1012 /* 1010 */ V(0, 2, 2), 1013 /* 1011 */ V(0, 2, 2), 1014 /* 1100 */ V(2, 0, 2), 1015 /* 1101 */ V(2, 0, 2), 1016 /* 1110 */ V(2, 0, 2), 1017 /* 1111 */ V(2, 0, 2), 1018 1019 /* 0000 0000 ... */ 1020 /* 000 */ V(5, 5, 3), /* 48 */ 1021 /* 001 */ V(5, 4, 3), 1022 /* 010 */ V(4, 5, 2), 1023 /* 011 */ V(4, 5, 2), 1024 /* 100 */ V(5, 3, 1), 1025 /* 101 */ V(5, 3, 1), 1026 /* 110 */ V(5, 3, 1), 1027 /* 111 */ V(5, 3, 1), 1028 1029 /* 0000 0001 ... */ 1030 /* 00 */ V(3, 5, 2), /* 56 */ 1031 /* 01 */ V(4, 4, 2), 1032 /* 10 */ V(2, 5, 1), 1033 /* 11 */ V(2, 5, 1), 1034 1035 /* 0000 0010 ... */ 1036 /* 0 */ V(5, 2, 1), /* 60 */ 1037 /* 1 */ V(0, 5, 1), 1038 1039 /* 0000 0101 ... */ 1040 /* 0 */ V(3, 4, 1), /* 62 */ 1041 /* 1 */ V(4, 3, 1), 1042 1043 /* 0000 0110 ... */ 1044 /* 0 */ V(5, 0, 1), /* 64 */ 1045 /* 1 */ V(3, 3, 1) 1046]; 1047 1048const hufftab9 = [ 1049 /* 0000 */ PTR(16, 4), 1050 /* 0001 */ PTR(32, 3), 1051 /* 0010 */ PTR(40, 2), 1052 /* 0011 */ PTR(44, 2), 1053 /* 0100 */ PTR(48, 1), 1054 /* 0101 */ V(1, 2, 4), 1055 /* 0110 */ V(2, 1, 4), 1056 /* 0111 */ V(2, 0, 4), 1057 /* 1000 */ V(1, 1, 3), 1058 /* 1001 */ V(1, 1, 3), 1059 /* 1010 */ V(0, 1, 3), 1060 /* 1011 */ V(0, 1, 3), 1061 /* 1100 */ V(1, 0, 3), 1062 /* 1101 */ V(1, 0, 3), 1063 /* 1110 */ V(0, 0, 3), 1064 /* 1111 */ V(0, 0, 3), 1065 1066 /* 0000 ... */ 1067 /* 0000 */ PTR(50, 1), /* 16 */ 1068 /* 0001 */ V(3, 5, 4), 1069 /* 0010 */ V(5, 3, 4), 1070 /* 0011 */ PTR(52, 1), 1071 /* 0100 */ V(4, 4, 4), 1072 /* 0101 */ V(2, 5, 4), 1073 /* 0110 */ V(5, 2, 4), 1074 /* 0111 */ V(1, 5, 4), 1075 /* 1000 */ V(5, 1, 3), 1076 /* 1001 */ V(5, 1, 3), 1077 /* 1010 */ V(3, 4, 3), 1078 /* 1011 */ V(3, 4, 3), 1079 /* 1100 */ V(4, 3, 3), 1080 /* 1101 */ V(4, 3, 3), 1081 /* 1110 */ V(5, 0, 4), 1082 /* 1111 */ V(0, 4, 4), 1083 1084 /* 0001 ... */ 1085 /* 000 */ V(2, 4, 3), /* 32 */ 1086 /* 001 */ V(4, 2, 3), 1087 /* 010 */ V(3, 3, 3), 1088 /* 011 */ V(4, 0, 3), 1089 /* 100 */ V(1, 4, 2), 1090 /* 101 */ V(1, 4, 2), 1091 /* 110 */ V(4, 1, 2), 1092 /* 111 */ V(4, 1, 2), 1093 1094 /* 0010 ... */ 1095 /* 00 */ V(2, 3, 2), /* 40 */ 1096 /* 01 */ V(3, 2, 2), 1097 /* 10 */ V(1, 3, 1), 1098 /* 11 */ V(1, 3, 1), 1099 1100 /* 0011 ... */ 1101 /* 00 */ V(3, 1, 1), /* 44 */ 1102 /* 01 */ V(3, 1, 1), 1103 /* 10 */ V(0, 3, 2), 1104 /* 11 */ V(3, 0, 2), 1105 1106 /* 0100 ... */ 1107 /* 0 */ V(2, 2, 1), /* 48 */ 1108 /* 1 */ V(0, 2, 1), 1109 1110 /* 0000 0000 ... */ 1111 /* 0 */ V(5, 5, 1), /* 50 */ 1112 /* 1 */ V(4, 5, 1), 1113 1114 /* 0000 0011 ... */ 1115 /* 0 */ V(5, 4, 1), /* 52 */ 1116 /* 1 */ V(0, 5, 1) 1117]; 1118 1119const hufftab10 = [ 1120 /* 0000 */ PTR(16, 4), 1121 /* 0001 */ PTR(32, 4), 1122 /* 0010 */ PTR(48, 2), 1123 /* 0011 */ V(1, 1, 4), 1124 /* 0100 */ V(0, 1, 3), 1125 /* 0101 */ V(0, 1, 3), 1126 /* 0110 */ V(1, 0, 3), 1127 /* 0111 */ V(1, 0, 3), 1128 /* 1000 */ V(0, 0, 1), 1129 /* 1001 */ V(0, 0, 1), 1130 /* 1010 */ V(0, 0, 1), 1131 /* 1011 */ V(0, 0, 1), 1132 /* 1100 */ V(0, 0, 1), 1133 /* 1101 */ V(0, 0, 1), 1134 /* 1110 */ V(0, 0, 1), 1135 /* 1111 */ V(0, 0, 1), 1136 1137 /* 0000 ... */ 1138 /* 0000 */ PTR(52, 3), /* 16 */ 1139 /* 0001 */ PTR(60, 2), 1140 /* 0010 */ PTR(64, 3), 1141 /* 0011 */ PTR(72, 1), 1142 /* 0100 */ PTR(74, 2), 1143 /* 0101 */ PTR(78, 2), 1144 /* 0110 */ PTR(82, 2), 1145 /* 0111 */ V(1, 7, 4), 1146 /* 1000 */ V(7, 1, 4), 1147 /* 1001 */ PTR(86, 1), 1148 /* 1010 */ PTR(88, 2), 1149 /* 1011 */ PTR(92, 2), 1150 /* 1100 */ V(1, 6, 4), 1151 /* 1101 */ V(6, 1, 4), 1152 /* 1110 */ V(6, 0, 4), 1153 /* 1111 */ PTR(96, 1), 1154 1155 /* 0001 ... */ 1156 /* 0000 */ PTR(98, 1), /* 32 */ 1157 /* 0001 */ PTR(100, 1), 1158 /* 0010 */ V(1, 4, 4), 1159 /* 0011 */ V(4, 1, 4), 1160 /* 0100 */ V(4, 0, 4), 1161 /* 0101 */ V(2, 3, 4), 1162 /* 0110 */ V(3, 2, 4), 1163 /* 0111 */ V(0, 3, 4), 1164 /* 1000 */ V(1, 3, 3), 1165 /* 1001 */ V(1, 3, 3), 1166 /* 1010 */ V(3, 1, 3), 1167 /* 1011 */ V(3, 1, 3), 1168 /* 1100 */ V(3, 0, 3), 1169 /* 1101 */ V(3, 0, 3), 1170 /* 1110 */ V(2, 2, 3), 1171 /* 1111 */ V(2, 2, 3), 1172 1173 /* 0010 ... */ 1174 /* 00 */ V(1, 2, 2), /* 48 */ 1175 /* 01 */ V(2, 1, 2), 1176 /* 10 */ V(0, 2, 2), 1177 /* 11 */ V(2, 0, 2), 1178 1179 /* 0000 0000 ... */ 1180 /* 000 */ V(7, 7, 3), /* 52 */ 1181 /* 001 */ V(6, 7, 3), 1182 /* 010 */ V(7, 6, 3), 1183 /* 011 */ V(5, 7, 3), 1184 /* 100 */ V(7, 5, 3), 1185 /* 101 */ V(6, 6, 3), 1186 /* 110 */ V(4, 7, 2), 1187 /* 111 */ V(4, 7, 2), 1188 1189 /* 0000 0001 ... */ 1190 /* 00 */ V(7, 4, 2), /* 60 */ 1191 /* 01 */ V(5, 6, 2), 1192 /* 10 */ V(6, 5, 2), 1193 /* 11 */ V(3, 7, 2), 1194 1195 /* 0000 0010 ... */ 1196 /* 000 */ V(7, 3, 2), /* 64 */ 1197 /* 001 */ V(7, 3, 2), 1198 /* 010 */ V(4, 6, 2), 1199 /* 011 */ V(4, 6, 2), 1200 /* 100 */ V(5, 5, 3), 1201 /* 101 */ V(5, 4, 3), 1202 /* 110 */ V(6, 3, 2), 1203 /* 111 */ V(6, 3, 2), 1204 1205 /* 0000 0011 ... */ 1206 /* 0 */ V(2, 7, 1), /* 72 */ 1207 /* 1 */ V(7, 2, 1), 1208 1209 /* 0000 0100 ... */ 1210 /* 00 */ V(6, 4, 2), /* 74 */ 1211 /* 01 */ V(0, 7, 2), 1212 /* 10 */ V(7, 0, 1), 1213 /* 11 */ V(7, 0, 1), 1214 1215 /* 0000 0101 ... */ 1216 /* 00 */ V(6, 2, 1), /* 78 */ 1217 /* 01 */ V(6, 2, 1), 1218 /* 10 */ V(4, 5, 2), 1219 /* 11 */ V(3, 5, 2), 1220 1221 /* 0000 0110 ... */ 1222 /* 00 */ V(0, 6, 1), /* 82 */ 1223 /* 01 */ V(0, 6, 1), 1224 /* 10 */ V(5, 3, 2), 1225 /* 11 */ V(4, 4, 2), 1226 1227 /* 0000 1001 ... */ 1228 /* 0 */ V(3, 6, 1), /* 86 */ 1229 /* 1 */ V(2, 6, 1), 1230 1231 /* 0000 1010 ... */ 1232 /* 00 */ V(2, 5, 2), /* 88 */ 1233 /* 01 */ V(5, 2, 2), 1234 /* 10 */ V(1, 5, 1), 1235 /* 11 */ V(1, 5, 1), 1236 1237 /* 0000 1011 ... */ 1238 /* 00 */ V(5, 1, 1), /* 92 */ 1239 /* 01 */ V(5, 1, 1), 1240 /* 10 */ V(3, 4, 2), 1241 /* 11 */ V(4, 3, 2), 1242 1243 /* 0000 1111 ... */ 1244 /* 0 */ V(0, 5, 1), /* 96 */ 1245 /* 1 */ V(5, 0, 1), 1246 1247 /* 0001 0000 ... */ 1248 /* 0 */ V(2, 4, 1), /* 98 */ 1249 /* 1 */ V(4, 2, 1), 1250 1251 /* 0001 0001 ... */ 1252 /* 0 */ V(3, 3, 1), /* 100 */ 1253 /* 1 */ V(0, 4, 1) 1254]; 1255 1256const hufftab11 = [ 1257 /* 0000 */ PTR(16, 4), 1258 /* 0001 */ PTR(32, 4), 1259 /* 0010 */ PTR(48, 4), 1260 /* 0011 */ PTR(64, 3), 1261 /* 0100 */ V(1, 2, 4), 1262 /* 0101 */ PTR(72, 1), 1263 /* 0110 */ V(1, 1, 3), 1264 /* 0111 */ V(1, 1, 3), 1265 /* 1000 */ V(0, 1, 3), 1266 /* 1001 */ V(0, 1, 3), 1267 /* 1010 */ V(1, 0, 3), 1268 /* 1011 */ V(1, 0, 3), 1269 /* 1100 */ V(0, 0, 2), 1270 /* 1101 */ V(0, 0, 2), 1271 /* 1110 */ V(0, 0, 2), 1272 /* 1111 */ V(0, 0, 2), 1273 1274 /* 0000 ... */ 1275 /* 0000 */ PTR(74, 2), /* 16 */ 1276 /* 0001 */ PTR(78, 3), 1277 /* 0010 */ PTR(86, 2), 1278 /* 0011 */ PTR(90, 1), 1279 /* 0100 */ PTR(92, 2), 1280 /* 0101 */ V(2, 7, 4), 1281 /* 0110 */ V(7, 2, 4), 1282 /* 0111 */ PTR(96, 1), 1283 /* 1000 */ V(7, 1, 3), 1284 /* 1001 */ V(7, 1, 3), 1285 /* 1010 */ V(1, 7, 4), 1286 /* 1011 */ V(7, 0, 4), 1287 /* 1100 */ V(3, 6, 4), 1288 /* 1101 */ V(6, 3, 4), 1289 /* 1110 */ V(6, 0, 4), 1290 /* 1111 */ PTR(98, 1), 1291 1292 /* 0001 ... */ 1293 /* 0000 */ PTR(100, 1), /* 32 */ 1294 /* 0001 */ V(1, 5, 4), 1295 /* 0010 */ V(6, 2, 3), 1296 /* 0011 */ V(6, 2, 3), 1297 /* 0100 */ V(2, 6, 4), 1298 /* 0101 */ V(0, 6, 4), 1299 /* 0110 */ V(1, 6, 3), 1300 /* 0111 */ V(1, 6, 3), 1301 /* 1000 */ V(6, 1, 3), 1302 /* 1001 */ V(6, 1, 3), 1303 /* 1010 */ V(5, 1, 4), 1304 /* 1011 */ V(3, 4, 4), 1305 /* 1100 */ V(5, 0, 4), 1306 /* 1101 */ PTR(102, 1), 1307 /* 1110 */ V(2, 4, 4), 1308 /* 1111 */ V(4, 2, 4), 1309 1310 /* 0010 ... */ 1311 /* 0000 */ V(1, 4, 4), /* 48 */ 1312 /* 0001 */ V(4, 1, 4), 1313 /* 0010 */ V(0, 4, 4), 1314 /* 0011 */ V(4, 0, 4), 1315 /* 0100 */ V(2, 3, 3), 1316 /* 0101 */ V(2, 3, 3), 1317 /* 0110 */ V(3, 2, 3), 1318 /* 0111 */ V(3, 2, 3), 1319 /* 1000 */ V(1, 3, 2), 1320 /* 1001 */ V(1, 3, 2), 1321 /* 1010 */ V(1, 3, 2), 1322 /* 1011 */ V(1, 3, 2), 1323 /* 1100 */ V(3, 1, 2), 1324 /* 1101 */ V(3, 1, 2), 1325 /* 1110 */ V(3, 1, 2), 1326 /* 1111 */ V(3, 1, 2), 1327 1328 /* 0011 ... */ 1329 /* 000 */ V(0, 3, 3), /* 64 */ 1330 /* 001 */ V(3, 0, 3), 1331 /* 010 */ V(2, 2, 2), 1332 /* 011 */ V(2, 2, 2), 1333 /* 100 */ V(2, 1, 1), 1334 /* 101 */ V(2, 1, 1), 1335 /* 110 */ V(2, 1, 1), 1336 /* 111 */ V(2, 1, 1), 1337 1338 /* 0101 ... */ 1339 /* 0 */ V(0, 2, 1), /* 72 */ 1340 /* 1 */ V(2, 0, 1), 1341 1342 /* 0000 0000 ... */ 1343 /* 00 */ V(7, 7, 2), /* 74 */ 1344 /* 01 */ V(6, 7, 2), 1345 /* 10 */ V(7, 6, 2), 1346 /* 11 */ V(7, 5, 2), 1347 1348 /* 0000 0001 ... */ 1349 /* 000 */ V(6, 6, 2), /* 78 */ 1350 /* 001 */ V(6, 6, 2), 1351 /* 010 */ V(4, 7, 2), 1352 /* 011 */ V(4, 7, 2), 1353 /* 100 */ V(7, 4, 2), 1354 /* 101 */ V(7, 4, 2), 1355 /* 110 */ V(5, 7, 3), 1356 /* 111 */ V(5, 5, 3), 1357 1358 /* 0000 0010 ... */ 1359 /* 00 */ V(5, 6, 2), /* 86 */ 1360 /* 01 */ V(6, 5, 2), 1361 /* 10 */ V(3, 7, 1), 1362 /* 11 */ V(3, 7, 1), 1363 1364 /* 0000 0011 ... */ 1365 /* 0 */ V(7, 3, 1), /* 90 */ 1366 /* 1 */ V(4, 6, 1), 1367 1368 /* 0000 0100 ... */ 1369 /* 00 */ V(4, 5, 2), /* 92 */ 1370 /* 01 */ V(5, 4, 2), 1371 /* 10 */ V(3, 5, 2), 1372 /* 11 */ V(5, 3, 2), 1373 1374 /* 0000 0111 ... */ 1375 /* 0 */ V(6, 4, 1), /* 96 */ 1376 /* 1 */ V(0, 7, 1), 1377 1378 /* 0000 1111 ... */ 1379 /* 0 */ V(4, 4, 1), /* 98 */ 1380 /* 1 */ V(2, 5, 1), 1381 1382 /* 0001 0000 ... */ 1383 /* 0 */ V(5, 2, 1), /* 100 */ 1384 /* 1 */ V(0, 5, 1), 1385 1386 /* 0001 1101 ... */ 1387 /* 0 */ V(4, 3, 1), /* 102 */ 1388 /* 1 */ V(3, 3, 1) 1389]; 1390 1391const hufftab12 = [ 1392 /* 0000 */ PTR(16, 4), 1393 /* 0001 */ PTR(32, 4), 1394 /* 0010 */ PTR(48, 4), 1395 /* 0011 */ PTR(64, 2), 1396 /* 0100 */ PTR(68, 3), 1397 /* 0101 */ PTR(76, 1), 1398 /* 0110 */ V(1, 2, 4), 1399 /* 0111 */ V(2, 1, 4), 1400 /* 1000 */ PTR(78, 1), 1401 /* 1001 */ V(0, 0, 4), 1402 /* 1010 */ V(1, 1, 3), 1403 /* 1011 */ V(1, 1, 3), 1404 /* 1100 */ V(0, 1, 3), 1405 /* 1101 */ V(0, 1, 3), 1406 /* 1110 */ V(1, 0, 3), 1407 /* 1111 */ V(1, 0, 3), 1408 1409 /* 0000 ... */ 1410 /* 0000 */ PTR(80, 2), /* 16 */ 1411 /* 0001 */ PTR(84, 1), 1412 /* 0010 */ PTR(86, 1), 1413 /* 0011 */ PTR(88, 1), 1414 /* 0100 */ V(5, 6, 4), 1415 /* 0101 */ V(3, 7, 4), 1416 /* 0110 */ PTR(90, 1), 1417 /* 0111 */ V(2, 7, 4), 1418 /* 1000 */ V(7, 2, 4), 1419 /* 1001 */ V(4, 6, 4), 1420 /* 1010 */ V(6, 4, 4), 1421 /* 1011 */ V(1, 7, 4), 1422 /* 1100 */ V(7, 1, 4), 1423 /* 1101 */ PTR(92, 1), 1424 /* 1110 */ V(3, 6, 4), 1425 /* 1111 */ V(6, 3, 4), 1426 1427 /* 0001 ... */ 1428 /* 0000 */ V(4, 5, 4), /* 32 */ 1429 /* 0001 */ V(5, 4, 4), 1430 /* 0010 */ V(4, 4, 4), 1431 /* 0011 */ PTR(94, 1), 1432 /* 0100 */ V(2, 6, 3), 1433 /* 0101 */ V(2, 6, 3), 1434 /* 0110 */ V(6, 2, 3), 1435 /* 0111 */ V(6, 2, 3), 1436 /* 1000 */ V(6, 1, 3), 1437 /* 1001 */ V(6, 1, 3), 1438 /* 1010 */ V(1, 6, 4), 1439 /* 1011 */ V(6, 0, 4), 1440 /* 1100 */ V(3, 5, 4), 1441 /* 1101 */ V(5, 3, 4), 1442 /* 1110 */ V(2, 5, 4), 1443 /* 1111 */ V(5, 2, 4), 1444 1445 /* 0010 ... */ 1446 /* 0000 */ V(1, 5, 3), /* 48 */ 1447 /* 0001 */ V(1, 5, 3), 1448 /* 0010 */ V(5, 1, 3), 1449 /* 0011 */ V(5, 1, 3), 1450 /* 0100 */ V(3, 4, 3), 1451 /* 0101 */ V(3, 4, 3), 1452 /* 0110 */ V(4, 3, 3), 1453 /* 0111 */ V(4, 3, 3), 1454 /* 1000 */ V(5, 0, 4), 1455 /* 1001 */ V(0, 4, 4), 1456 /* 1010 */ V(2, 4, 3), 1457 /* 1011 */ V(2, 4, 3), 1458 /* 1100 */ V(4, 2, 3), 1459 /* 1101 */ V(4, 2, 3), 1460 /* 1110 */ V(1, 4, 3), 1461 /* 1111 */ V(1, 4, 3), 1462 1463 /* 0011 ... */ 1464 /* 00 */ V(3, 3, 2), /* 64 */ 1465 /* 01 */ V(4, 1, 2), 1466 /* 10 */ V(2, 3, 2), 1467 /* 11 */ V(3, 2, 2), 1468 1469 /* 0100 ... */ 1470 /* 000 */ V(4, 0, 3), /* 68 */ 1471 /* 001 */ V(0, 3, 3), 1472 /* 010 */ V(3, 0, 2), 1473 /* 011 */ V(3, 0, 2), 1474 /* 100 */ V(1, 3, 1), 1475 /* 101 */ V(1, 3, 1), 1476 /* 110 */ V(1, 3, 1), 1477 /* 111 */ V(1, 3, 1), 1478 1479 /* 0101 ... */ 1480 /* 0 */ V(3, 1, 1), /* 76 */ 1481 /* 1 */ V(2, 2, 1), 1482 1483 /* 1000 ... */ 1484 /* 0 */ V(0, 2, 1), /* 78 */ 1485 /* 1 */ V(2, 0, 1), 1486 1487 /* 0000 0000 ... */ 1488 /* 00 */ V(7, 7, 2), /* 80 */ 1489 /* 01 */ V(6, 7, 2), 1490 /* 10 */ V(7, 6, 1), 1491 /* 11 */ V(7, 6, 1), 1492 1493 /* 0000 0001 ... */ 1494 /* 0 */ V(5, 7, 1), /* 84 */ 1495 /* 1 */ V(7, 5, 1), 1496 1497 /* 0000 0010 ... */ 1498 /* 0 */ V(6, 6, 1), /* 86 */ 1499 /* 1 */ V(4, 7, 1), 1500 1501 /* 0000 0011 ... */ 1502 /* 0 */ V(7, 4, 1), /* 88 */ 1503 /* 1 */ V(6, 5, 1), 1504 1505 /* 0000 0110 ... */ 1506 /* 0 */ V(7, 3, 1), /* 90 */ 1507 /* 1 */ V(5, 5, 1), 1508 1509 /* 0000 1101 ... */ 1510 /* 0 */ V(0, 7, 1), /* 92 */ 1511 /* 1 */ V(7, 0, 1), 1512 1513 /* 0001 0011 ... */ 1514 /* 0 */ V(0, 6, 1), /* 94 */ 1515 /* 1 */ V(0, 5, 1) 1516]; 1517 1518const hufftab13 = [ 1519 /* 0000 */ PTR(16, 4), 1520 /* 0001 */ PTR(32, 4), 1521 /* 0010 */ PTR(48, 4), 1522 /* 0011 */ PTR(64, 2), 1523 /* 0100 */ V(1, 1, 4), 1524 /* 0101 */ V(0, 1, 4), 1525 /* 0110 */ V(1, 0, 3), 1526 /* 0111 */ V(1, 0, 3), 1527 /* 1000 */ V(0, 0, 1), 1528 /* 1001 */ V(0, 0, 1), 1529 /* 1010 */ V(0, 0, 1), 1530 /* 1011 */ V(0, 0, 1), 1531 /* 1100 */ V(0, 0, 1), 1532 /* 1101 */ V(0, 0, 1), 1533 /* 1110 */ V(0, 0, 1), 1534 /* 1111 */ V(0, 0, 1), 1535 1536 /* 0000 ... */ 1537 /* 0000 */ PTR(68, 4), /* 16 */ 1538 /* 0001 */ PTR(84, 4), 1539 /* 0010 */ PTR(100, 4), 1540 /* 0011 */ PTR(116, 4), 1541 /* 0100 */ PTR(132, 4), 1542 /* 0101 */ PTR(148, 4), 1543 /* 0110 */ PTR(164, 3), 1544 /* 0111 */ PTR(172, 3), 1545 /* 1000 */ PTR(180, 3), 1546 /* 1001 */ PTR(188, 3), 1547 /* 1010 */ PTR(196, 3), 1548 /* 1011 */ PTR(204, 3), 1549 /* 1100 */ PTR(212, 1), 1550 /* 1101 */ PTR(214, 2), 1551 /* 1110 */ PTR(218, 3), 1552 /* 1111 */ PTR(226, 1), 1553 1554 /* 0001 ... */ 1555 /* 0000 */ PTR(228, 2), /* 32 */ 1556 /* 0001 */ PTR(232, 2), 1557 /* 0010 */ PTR(236, 2), 1558 /* 0011 */ PTR(240, 2), 1559 /* 0100 */ V(8, 1, 4), 1560 /* 0101 */ PTR(244, 1), 1561 /* 0110 */ PTR(246, 1), 1562 /* 0111 */ PTR(248, 1), 1563 /* 1000 */ PTR(250, 2), 1564 /* 1001 */ PTR(254, 1), 1565 /* 1010 */ V(1, 5, 4), 1566 /* 1011 */ V(5, 1, 4), 1567 /* 1100 */ PTR(256, 1), 1568 /* 1101 */ PTR(258, 1), 1569 /* 1110 */ PTR(260, 1), 1570 /* 1111 */ V(1, 4, 4), 1571 1572 /* 0010 ... */ 1573 /* 0000 */ V(4, 1, 3), /* 48 */ 1574 /* 0001 */ V(4, 1, 3), 1575 /* 0010 */ V(0, 4, 4), 1576 /* 0011 */ V(4, 0, 4), 1577 /* 0100 */ V(2, 3, 4), 1578 /* 0101 */ V(3, 2, 4), 1579 /* 0110 */ V(1, 3, 3), 1580 /* 0111 */ V(1, 3, 3), 1581 /* 1000 */ V(3, 1, 3), 1582 /* 1001 */ V(3, 1, 3), 1583 /* 1010 */ V(0, 3, 3), 1584 /* 1011 */ V(0, 3, 3), 1585 /* 1100 */ V(3, 0, 3), 1586 /* 1101 */ V(3, 0, 3), 1587 /* 1110 */ V(2, 2, 3), 1588 /* 1111 */ V(2, 2, 3), 1589 1590 /* 0011 ... */ 1591 /* 00 */ V(1, 2, 2), /* 64 */ 1592 /* 01 */ V(2, 1, 2), 1593 /* 10 */ V(0, 2, 2), 1594 /* 11 */ V(2, 0, 2), 1595 1596 /* 0000 0000 ... */ 1597 /* 0000 */ PTR(262, 4), /* 68 */ 1598 /* 0001 */ PTR(278, 4), 1599 /* 0010 */ PTR(294, 4), 1600 /* 0011 */ PTR(310, 3), 1601 /* 0100 */ PTR(318, 2), 1602 /* 0101 */ PTR(322, 2), 1603 /* 0110 */ PTR(326, 3), 1604 /* 0111 */ PTR(334, 2), 1605 /* 1000 */ PTR(338, 1), 1606 /* 1001 */ PTR(340, 2), 1607 /* 1010 */ PTR(344, 2), 1608 /* 1011 */ PTR(348, 2), 1609 /* 1100 */ PTR(352, 2), 1610 /* 1101 */ PTR(356, 2), 1611 /* 1110 */ V(1, 15, 4), 1612 /* 1111 */ V(15, 1, 4), 1613 1614 /* 0000 0001 ... */ 1615 /* 0000 */ V(15, 0, 4), /* 84 */ 1616 /* 0001 */ PTR(360, 1), 1617 /* 0010 */ PTR(362, 1), 1618 /* 0011 */ PTR(364, 1), 1619 /* 0100 */ V(14, 2, 4), 1620 /* 0101 */ PTR(366, 1), 1621 /* 0110 */ V(1, 14, 4), 1622 /* 0111 */ V(14, 1, 4), 1623 /* 1000 */ PTR(368, 1), 1624 /* 1001 */ PTR(370, 1), 1625 /* 1010 */ PTR(372, 1), 1626 /* 1011 */ PTR(374, 1), 1627 /* 1100 */ PTR(376, 1), 1628 /* 1101 */ PTR(378, 1), 1629 /* 1110 */ V(12, 6, 4), 1630 /* 1111 */ V(3, 13, 4), 1631 1632 /* 0000 0010 ... */ 1633 /* 0000 */ PTR(380, 1), /* 100 */ 1634 /* 0001 */ V(2, 13, 4), 1635 /* 0010 */ V(13, 2, 4), 1636 /* 0011 */ V(1, 13, 4), 1637 /* 0100 */ V(11, 7, 4), 1638 /* 0101 */ PTR(382, 1), 1639 /* 0110 */ PTR(384, 1), 1640 /* 0111 */ V(12, 3, 4), 1641 /* 1000 */ PTR(386, 1), 1642 /* 1001 */ V(4, 11, 4), 1643 /* 1010 */ V(13, 1, 3), 1644 /* 1011 */ V(13, 1, 3), 1645 /* 1100 */ V(0, 13, 4), 1646 /* 1101 */ V(13, 0, 4), 1647 /* 1110 */ V(8, 10, 4), 1648 /* 1111 */ V(10, 8, 4), 1649 1650 /* 0000 0011 ... */ 1651 /* 0000 */ V(4, 12, 4), /* 116 */ 1652 /* 0001 */ V(12, 4, 4), 1653 /* 0010 */ V(6, 11, 4), 1654 /* 0011 */ V(11, 6, 4), 1655 /* 0100 */ V(3, 12, 3), 1656 /* 0101 */ V(3, 12, 3), 1657 /* 0110 */ V(2, 12, 3), 1658 /* 0111 */ V(2, 12, 3), 1659 /* 1000 */ V(12, 2, 3), 1660 /* 1001 */ V(12, 2, 3), 1661 /* 1010 */ V(5, 11, 3), 1662 /* 1011 */ V(5, 11, 3), 1663 /* 1100 */ V(11, 5, 4), 1664 /* 1101 */ V(8, 9, 4), 1665 /* 1110 */ V(1, 12, 3), 1666 /* 1111 */ V(1, 12, 3), 1667 1668 /* 0000 0100 ... */ 1669 /* 0000 */ V(12, 1, 3), /* 132 */ 1670 /* 0001 */ V(12, 1, 3), 1671 /* 0010 */ V(9, 8, 4), 1672 /* 0011 */ V(0, 12, 4), 1673 /* 0100 */ V(12, 0, 3), 1674 /* 0101 */ V(12, 0, 3), 1675 /* 0110 */ V(11, 4, 4), 1676 /* 0111 */ V(6, 10, 4), 1677 /* 1000 */ V(10, 6, 4), 1678 /* 1001 */ V(7, 9, 4), 1679 /* 1010 */ V(3, 11, 3), 1680 /* 1011 */ V(3, 11, 3), 1681 /* 1100 */ V(11, 3, 3), 1682 /* 1101 */ V(11, 3, 3), 1683 /* 1110 */ V(8, 8, 4), 1684 /* 1111 */ V(5, 10, 4), 1685 1686 /* 0000 0101 ... */ 1687 /* 0000 */ V(2, 11, 3), /* 148 */ 1688 /* 0001 */ V(2, 11, 3), 1689 /* 0010 */ V(10, 5, 4), 1690 /* 0011 */ V(6, 9, 4), 1691 /* 0100 */ V(10, 4, 3), 1692 /* 0101 */ V(10, 4, 3), 1693 /* 0110 */ V(7, 8, 4), 1694 /* 0111 */ V(8, 7, 4), 1695 /* 1000 */ V(9, 4, 3), 1696 /* 1001 */ V(9, 4, 3), 1697 /* 1010 */ V(7, 7, 4), 1698 /* 1011 */ V(7, 6, 4), 1699 /* 1100 */ V(11, 2, 2), 1700 /* 1101 */ V(11, 2, 2), 1701 /* 1110 */ V(11, 2, 2), 1702 /* 1111 */ V(11, 2, 2), 1703 1704 /* 0000 0110 ... */ 1705 /* 000 */ V(1, 11, 2), /* 164 */ 1706 /* 001 */ V(1, 11, 2), 1707 /* 010 */ V(11, 1, 2), 1708 /* 011 */ V(11, 1, 2), 1709 /* 100 */ V(0, 11, 3), 1710 /* 101 */ V(11, 0, 3), 1711 /* 110 */ V(9, 6, 3), 1712 /* 111 */ V(4, 10, 3), 1713 1714 /* 0000 0111 ... */ 1715 /* 000 */ V(3, 10, 3), /* 172 */ 1716 /* 001 */ V(10, 3, 3), 1717 /* 010 */ V(5, 9, 3), 1718 /* 011 */ V(9, 5, 3), 1719 /* 100 */ V(2, 10, 2), 1720 /* 101 */ V(2, 10, 2), 1721 /* 110 */ V(10, 2, 2), 1722 /* 111 */ V(10, 2, 2), 1723 1724 /* 0000 1000 ... */ 1725 /* 000 */ V(1, 10, 2), /* 180 */ 1726 /* 001 */ V(1, 10, 2), 1727 /* 010 */ V(10, 1, 2), 1728 /* 011 */ V(10, 1, 2), 1729 /* 100 */ V(0, 10, 3), 1730 /* 101 */ V(6, 8, 3), 1731 /* 110 */ V(10, 0, 2), 1732 /* 111 */ V(10, 0, 2), 1733 1734 /* 0000 1001 ... */ 1735 /* 000 */ V(8, 6, 3), /* 188 */ 1736 /* 001 */ V(4, 9, 3), 1737 /* 010 */ V(9, 3, 2), 1738 /* 011 */ V(9, 3, 2), 1739 /* 100 */ V(3, 9, 3), 1740 /* 101 */ V(5, 8, 3), 1741 /* 110 */ V(8, 5, 3), 1742 /* 111 */ V(6, 7, 3), 1743 1744 /* 0000 1010 ... */ 1745 /* 000 */ V(2, 9, 2), /* 196 */ 1746 /* 001 */ V(2, 9, 2), 1747 /* 010 */ V(9, 2, 2), 1748 /* 011 */ V(9, 2, 2), 1749 /* 100 */ V(5, 7, 3), 1750 /* 101 */ V(7, 5, 3), 1751 /* 110 */ V(3, 8, 2), 1752 /* 111 */ V(3, 8, 2), 1753 1754 /* 0000 1011 ... */ 1755 /* 000 */ V(8, 3, 2), /* 204 */ 1756 /* 001 */ V(8, 3, 2), 1757 /* 010 */ V(6, 6, 3), 1758 /* 011 */ V(4, 7, 3), 1759 /* 100 */ V(7, 4, 3), 1760 /* 101 */ V(5, 6, 3), 1761 /* 110 */ V(6, 5, 3), 1762 /* 111 */ V(7, 3, 3), 1763 1764 /* 0000 1100 ... */ 1765 /* 0 */ V(1, 9, 1), /* 212 */ 1766 /* 1 */ V(9, 1, 1), 1767 1768 /* 0000 1101 ... */ 1769 /* 00 */ V(0, 9, 2), /* 214 */ 1770 /* 01 */ V(9, 0, 2), 1771 /* 10 */ V(4, 8, 2), 1772 /* 11 */ V(8, 4, 2), 1773 1774 /* 0000 1110 ... */ 1775 /* 000 */ V(7, 2, 2), /* 218 */ 1776 /* 001 */ V(7, 2, 2), 1777 /* 010 */ V(4, 6, 3), 1778 /* 011 */ V(6, 4, 3), 1779 /* 100 */ V(2, 8, 1), 1780 /* 101 */ V(2, 8, 1), 1781 /* 110 */ V(2, 8, 1), 1782 /* 111 */ V(2, 8, 1), 1783 1784 /* 0000 1111 ... */ 1785 /* 0 */ V(8, 2, 1), /* 226 */ 1786 /* 1 */ V(1, 8, 1), 1787 1788 /* 0001 0000 ... */ 1789 /* 00 */ V(3, 7, 2), /* 228 */ 1790 /* 01 */ V(2, 7, 2), 1791 /* 10 */ V(1, 7, 1), 1792 /* 11 */ V(1, 7, 1), 1793 1794 /* 0001 0001 ... */ 1795 /* 00 */ V(7, 1, 1), /* 232 */ 1796 /* 01 */ V(7, 1, 1), 1797 /* 10 */ V(5, 5, 2), 1798 /* 11 */ V(0, 7, 2), 1799 1800 /* 0001 0010 ... */ 1801 /* 00 */ V(7, 0, 2), /* 236 */ 1802 /* 01 */ V(3, 6, 2), 1803 /* 10 */ V(6, 3, 2), 1804 /* 11 */ V(4, 5, 2), 1805 1806 /* 0001 0011 ... */ 1807 /* 00 */ V(5, 4, 2), /* 240 */ 1808 /* 01 */ V(2, 6, 2), 1809 /* 10 */ V(6, 2, 2), 1810 /* 11 */ V(3, 5, 2), 1811 1812 /* 0001 0101 ... */ 1813 /* 0 */ V(0, 8, 1), /* 244 */ 1814 /* 1 */ V(8, 0, 1), 1815 1816 /* 0001 0110 ... */ 1817 /* 0 */ V(1, 6, 1), /* 246 */ 1818 /* 1 */ V(6, 1, 1), 1819 1820 /* 0001 0111 ... */ 1821 /* 0 */ V(0, 6, 1), /* 248 */ 1822 /* 1 */ V(6, 0, 1), 1823 1824 /* 0001 1000 ... */ 1825 /* 00 */ V(5, 3, 2), /* 250 */ 1826 /* 01 */ V(4, 4, 2), 1827 /* 10 */ V(2, 5, 1), 1828 /* 11 */ V(2, 5, 1), 1829 1830 /* 0001 1001 ... */ 1831 /* 0 */ V(5, 2, 1), /* 254 */ 1832 /* 1 */ V(0, 5, 1), 1833 1834 /* 0001 1100 ... */ 1835 /* 0 */ V(3, 4, 1), /* 256 */ 1836 /* 1 */ V(4, 3, 1), 1837 1838 /* 0001 1101 ... */ 1839 /* 0 */ V(5, 0, 1), /* 258 */ 1840 /* 1 */ V(2, 4, 1), 1841 1842 /* 0001 1110 ... */ 1843 /* 0 */ V(4, 2, 1), /* 260 */ 1844 /* 1 */ V(3, 3, 1), 1845 1846 /* 0000 0000 0000 ... */ 1847 /* 0000 */ PTR(388, 3), /* 262 */ 1848 /* 0001 */ V(15, 15, 4), 1849 /* 0010 */ V(14, 15, 4), 1850 /* 0011 */ V(13, 15, 4), 1851 /* 0100 */ V(14, 14, 4), 1852 /* 0101 */ V(12, 15, 4), 1853 /* 0110 */ V(13, 14, 4), 1854 /* 0111 */ V(11, 15, 4), 1855 /* 1000 */ V(15, 11, 4), 1856 /* 1001 */ V(12, 14, 4), 1857 /* 1010 */ V(13, 12, 4), 1858 /* 1011 */ PTR(396, 1), 1859 /* 1100 */ V(14, 12, 3), 1860 /* 1101 */ V(14, 12, 3), 1861 /* 1110 */ V(13, 13, 3), 1862 /* 1111 */ V(13, 13, 3), 1863 1864 /* 0000 0000 0001 ... */ 1865 /* 0000 */ V(15, 10, 4), /* 278 */ 1866 /* 0001 */ V(12, 13, 4), 1867 /* 0010 */ V(11, 14, 3), 1868 /* 0011 */ V(11, 14, 3), 1869 /* 0100 */ V(14, 11, 3), 1870 /* 0101 */ V(14, 11, 3), 1871 /* 0110 */ V(9, 15, 3), 1872 /* 0111 */ V(9, 15, 3), 1873 /* 1000 */ V(15, 9, 3), 1874 /* 1001 */ V(15, 9, 3), 1875 /* 1010 */ V(14, 10, 3), 1876 /* 1011 */ V(14, 10, 3), 1877 /* 1100 */ V(11, 13, 3), 1878 /* 1101 */ V(11, 13, 3), 1879 /* 1110 */ V(13, 11, 3), 1880 /* 1111 */ V(13, 11, 3), 1881 1882 /* 0000 0000 0010 ... */ 1883 /* 0000 */ V(8, 15, 3), /* 294 */ 1884 /* 0001 */ V(8, 15, 3), 1885 /* 0010 */ V(15, 8, 3), 1886 /* 0011 */ V(15, 8, 3), 1887 /* 0100 */ V(12, 12, 3), 1888 /* 0101 */ V(12, 12, 3), 1889 /* 0110 */ V(10, 14, 4), 1890 /* 0111 */ V(9, 14, 4), 1891 /* 1000 */ V(8, 14, 3), 1892 /* 1001 */ V(8, 14, 3), 1893 /* 1010 */ V(7, 15, 4), 1894 /* 1011 */ V(7, 14, 4), 1895 /* 1100 */ V(15, 7, 2), 1896 /* 1101 */ V(15, 7, 2), 1897 /* 1110 */ V(15, 7, 2), 1898 /* 1111 */ V(15, 7, 2), 1899 1900 /* 0000 0000 0011 ... */ 1901 /* 000 */ V(13, 10, 2), /* 310 */ 1902 /* 001 */ V(13, 10, 2), 1903 /* 010 */ V(10, 13, 3), 1904 /* 011 */ V(11, 12, 3), 1905 /* 100 */ V(12, 11, 3), 1906 /* 101 */ V(15, 6, 3), 1907 /* 110 */ V(6, 15, 2), 1908 /* 111 */ V(6, 15, 2), 1909 1910 /* 0000 0000 0100 ... */ 1911 /* 00 */ V(14, 8, 2), /* 318 */ 1912 /* 01 */ V(5, 15, 2), 1913 /* 10 */ V(9, 13, 2), 1914 /* 11 */ V(13, 9, 2), 1915 1916 /* 0000 0000 0101 ... */ 1917 /* 00 */ V(15, 5, 2), /* 322 */ 1918 /* 01 */ V(14, 7, 2), 1919 /* 10 */ V(10, 12, 2), 1920 /* 11 */ V(11, 11, 2), 1921 1922 /* 0000 0000 0110 ... */ 1923 /* 000 */ V(4, 15, 2), /* 326 */ 1924 /* 001 */ V(4, 15, 2), 1925 /* 010 */ V(15, 4, 2), 1926 /* 011 */ V(15, 4, 2), 1927 /* 100 */ V(12, 10, 3), 1928 /* 101 */ V(14, 6, 3), 1929 /* 110 */ V(15, 3, 2), 1930 /* 111 */ V(15, 3, 2), 1931 1932 /* 0000 0000 0111 ... */ 1933 /* 00 */ V(3, 15, 1), /* 334 */ 1934 /* 01 */ V(3, 15, 1), 1935 /* 10 */ V(8, 13, 2), 1936 /* 11 */ V(13, 8, 2), 1937 1938 /* 0000 0000 1000 ... */ 1939 /* 0 */ V(2, 15, 1), /* 338 */ 1940 /* 1 */ V(15, 2, 1), 1941 1942 /* 0000 0000 1001 ... */ 1943 /* 00 */ V(6, 14, 2), /* 340 */ 1944 /* 01 */ V(9, 12, 2), 1945 /* 10 */ V(0, 15, 1), 1946 /* 11 */ V(0, 15, 1), 1947 1948 /* 0000 0000 1010 ... */ 1949 /* 00 */ V(12, 9, 2), /* 344 */ 1950 /* 01 */ V(5, 14, 2), 1951 /* 10 */ V(10, 11, 1), 1952 /* 11 */ V(10, 11, 1), 1953 1954 /* 0000 0000 1011 ... */ 1955 /* 00 */ V(7, 13, 2), /* 348 */ 1956 /* 01 */ V(13, 7, 2), 1957 /* 10 */ V(4, 14, 1), 1958 /* 11 */ V(4, 14, 1), 1959 1960 /* 0000 0000 1100 ... */ 1961 /* 00 */ V(12, 8, 2), /* 352 */ 1962 /* 01 */ V(13, 6, 2), 1963 /* 10 */ V(3, 14, 1), 1964 /* 11 */ V(3, 14, 1), 1965 1966 /* 0000 0000 1101 ... */ 1967 /* 00 */ V(11, 9, 1), /* 356 */ 1968 /* 01 */ V(11, 9, 1), 1969 /* 10 */ V(9, 11, 2), 1970 /* 11 */ V(10, 10, 2), 1971 1972 /* 0000 0001 0001 ... */ 1973 /* 0 */ V(11, 10, 1), /* 360 */ 1974 /* 1 */ V(14, 5, 1), 1975 1976 /* 0000 0001 0010 ... */ 1977 /* 0 */ V(14, 4, 1), /* 362 */ 1978 /* 1 */ V(8, 12, 1), 1979 1980 /* 0000 0001 0011 ... */ 1981 /* 0 */ V(6, 13, 1), /* 364 */ 1982 /* 1 */ V(14, 3, 1), 1983 1984 /* 0000 0001 0101 ... */ 1985 /* 0 */ V(2, 14, 1), /* 366 */ 1986 /* 1 */ V(0, 14, 1), 1987 1988 /* 0000 0001 1000 ... */ 1989 /* 0 */ V(14, 0, 1), /* 368 */ 1990 /* 1 */ V(5, 13, 1), 1991 1992 /* 0000 0001 1001 ... */ 1993 /* 0 */ V(13, 5, 1), /* 370 */ 1994 /* 1 */ V(7, 12, 1), 1995 1996 /* 0000 0001 1010 ... */ 1997 /* 0 */ V(12, 7, 1), /* 372 */ 1998 /* 1 */ V(4, 13, 1), 1999 2000 /* 0000 0001 1011 ... */ 2001 /* 0 */ V(8, 11, 1), /* 374 */ 2002 /* 1 */ V(11, 8, 1), 2003 2004 /* 0000 0001 1100 ... */ 2005 /* 0 */ V(13, 4, 1), /* 376 */ 2006 /* 1 */ V(9, 10, 1), 2007 2008 /* 0000 0001 1101 ... */ 2009 /* 0 */ V(10, 9, 1), /* 378 */ 2010 /* 1 */ V(6, 12, 1), 2011 2012 /* 0000 0010 0000 ... */ 2013 /* 0 */ V(13, 3, 1), /* 380 */ 2014 /* 1 */ V(7, 11, 1), 2015 2016 /* 0000 0010 0101 ... */ 2017 /* 0 */ V(5, 12, 1), /* 382 */ 2018 /* 1 */ V(12, 5, 1), 2019 2020 /* 0000 0010 0110 ... */ 2021 /* 0 */ V(9, 9, 1), /* 384 */ 2022 /* 1 */ V(7, 10, 1), 2023 2024 /* 0000 0010 1000 ... */ 2025 /* 0 */ V(10, 7, 1), /* 386 */ 2026 /* 1 */ V(9, 7, 1), 2027 2028 /* 0000 0000 0000 0000 ... */ 2029 /* 000 */ V(15, 14, 3), /* 388 */ 2030 /* 001 */ V(15, 12, 3), 2031 /* 010 */ V(15, 13, 2), 2032 /* 011 */ V(15, 13, 2), 2033 /* 100 */ V(14, 13, 1), 2034 /* 101 */ V(14, 13, 1), 2035 /* 110 */ V(14, 13, 1), 2036 /* 111 */ V(14, 13, 1), 2037 2038 /* 0000 0000 0000 1011 ... */ 2039 /* 0 */ V(10, 15, 1), /* 396 */ 2040 /* 1 */ V(14, 9, 1) 2041]; 2042 2043const hufftab15 = [ 2044 /* 0000 */ PTR(16, 4), 2045 /* 0001 */ PTR(32, 4), 2046 /* 0010 */ PTR(48, 4), 2047 /* 0011 */ PTR(64, 4), 2048 /* 0100 */ PTR(80, 4), 2049 /* 0101 */ PTR(96, 3), 2050 /* 0110 */ PTR(104, 3), 2051 /* 0111 */ PTR(112, 2), 2052 /* 1000 */ PTR(116, 1), 2053 /* 1001 */ PTR(118, 1), 2054 /* 1010 */ V(1, 1, 3), 2055 /* 1011 */ V(1, 1, 3), 2056 /* 1100 */ V(0, 1, 4), 2057 /* 1101 */ V(1, 0, 4), 2058 /* 1110 */ V(0, 0, 3), 2059 /* 1111 */ V(0, 0, 3), 2060 2061 /* 0000 ... */ 2062 /* 0000 */ PTR(120, 4), /* 16 */ 2063 /* 0001 */ PTR(136, 4), 2064 /* 0010 */ PTR(152, 4), 2065 /* 0011 */ PTR(168, 4), 2066 /* 0100 */ PTR(184, 4), 2067 /* 0101 */ PTR(200, 3), 2068 /* 0110 */ PTR(208, 3), 2069 /* 0111 */ PTR(216, 4), 2070 /* 1000 */ PTR(232, 3), 2071 /* 1001 */ PTR(240, 3), 2072 /* 1010 */ PTR(248, 3), 2073 /* 1011 */ PTR(256, 3), 2074 /* 1100 */ PTR(264, 2), 2075 /* 1101 */ PTR(268, 3), 2076 /* 1110 */ PTR(276, 3), 2077 /* 1111 */ PTR(284, 2), 2078 2079 /* 0001 ... */ 2080 /* 0000 */ PTR(288, 2), /* 32 */ 2081 /* 0001 */ PTR(292, 2), 2082 /* 0010 */ PTR(296, 2), 2083 /* 0011 */ PTR(300, 2), 2084 /* 0100 */ PTR(304, 2), 2085 /* 0101 */ PTR(308, 2), 2086 /* 0110 */ PTR(312, 2), 2087 /* 0111 */ PTR(316, 2), 2088 /* 1000 */ PTR(320, 1), 2089 /* 1001 */ PTR(322, 1), 2090 /* 1010 */ PTR(324, 1), 2091 /* 1011 */ PTR(326, 2), 2092 /* 1100 */ PTR(330, 1), 2093 /* 1101 */ PTR(332, 1), 2094 /* 1110 */ PTR(334, 2), 2095 /* 1111 */ PTR(338, 1), 2096 2097 /* 0010 ... */ 2098 /* 0000 */ PTR(340, 1), /* 48 */ 2099 /* 0001 */ PTR(342, 1), 2100 /* 0010 */ V(9, 1, 4), 2101 /* 0011 */ PTR(344, 1), 2102 /* 0100 */ PTR(346, 1), 2103 /* 0101 */ PTR(348, 1), 2104 /* 0110 */ PTR(350, 1), 2105 /* 0111 */ PTR(352, 1), 2106 /* 1000 */ V(2, 8, 4), 2107 /* 1001 */ V(8, 2, 4), 2108 /* 1010 */ V(1, 8, 4), 2109 /* 1011 */ V(8, 1, 4), 2110 /* 1100 */ PTR(354, 1), 2111 /* 1101 */ PTR(356, 1), 2112 /* 1110 */ PTR(358, 1), 2113 /* 1111 */ PTR(360, 1), 2114 2115 /* 0011 ... */ 2116 /* 0000 */ V(2, 7, 4), /* 64 */ 2117 /* 0001 */ V(7, 2, 4), 2118 /* 0010 */ V(6, 4, 4), 2119 /* 0011 */ V(1, 7, 4), 2120 /* 0100 */ V(5, 5, 4), 2121 /* 0101 */ V(7, 1, 4), 2122 /* 0110 */ PTR(362, 1), 2123 /* 0111 */ V(3, 6, 4), 2124 /* 1000 */ V(6, 3, 4), 2125 /* 1001 */ V(4, 5, 4), 2126 /* 1010 */ V(5, 4, 4), 2127 /* 1011 */ V(2, 6, 4), 2128 /* 1100 */ V(6, 2, 4), 2129 /* 1101 */ V(1, 6, 4), 2130 /* 1110 */ PTR(364, 1), 2131 /* 1111 */ V(3, 5, 4), 2132 2133 /* 0100 ... */ 2134 /* 0000 */ V(6, 1, 3), /* 80 */ 2135 /* 0001 */ V(6, 1, 3), 2136 /* 0010 */ V(5, 3, 4), 2137 /* 0011 */ V(4, 4, 4), 2138 /* 0100 */ V(2, 5, 3), 2139 /* 0101 */ V(2, 5, 3), 2140 /* 0110 */ V(5, 2, 3), 2141 /* 0111 */ V(5, 2, 3), 2142 /* 1000 */ V(1, 5, 3), 2143 /* 1001 */ V(1, 5, 3), 2144 /* 1010 */ V(5, 1, 3), 2145 /* 1011 */ V(5, 1, 3), 2146 /* 1100 */ V(0, 5, 4), 2147 /* 1101 */ V(5, 0, 4), 2148 /* 1110 */ V(3, 4, 3), 2149 /* 1111 */ V(3, 4, 3), 2150 2151 /* 0101 ... */ 2152 /* 000 */ V(4, 3, 3), /* 96 */ 2153 /* 001 */ V(2, 4, 3), 2154 /* 010 */ V(4, 2, 3), 2155 /* 011 */ V(3, 3, 3), 2156 /* 100 */ V(4, 1, 2), 2157 /* 101 */ V(4, 1, 2), 2158 /* 110 */ V(1, 4, 3), 2159 /* 111 */ V(0, 4, 3), 2160 2161 /* 0110 ... */ 2162 /* 000 */ V(2, 3, 2), /* 104 */ 2163 /* 001 */ V(2, 3, 2), 2164 /* 010 */ V(3, 2, 2), 2165 /* 011 */ V(3, 2, 2), 2166 /* 100 */ V(4, 0, 3), 2167 /* 101 */ V(0, 3, 3), 2168 /* 110 */ V(1, 3, 2), 2169 /* 111 */ V(1, 3, 2), 2170 2171 /* 0111 ... */ 2172 /* 00 */ V(3, 1, 2), /* 112 */ 2173 /* 01 */ V(3, 0, 2), 2174 /* 10 */ V(2, 2, 1), 2175 /* 11 */ V(2, 2, 1), 2176 2177 /* 1000 ... */ 2178 /* 0 */ V(1, 2, 1), /* 116 */ 2179 /* 1 */ V(2, 1, 1), 2180 2181 /* 1001 ... */ 2182 /* 0 */ V(0, 2, 1), /* 118 */ 2183 /* 1 */ V(2, 0, 1), 2184 2185 /* 0000 0000 ... */ 2186 /* 0000 */ PTR(366, 1), /* 120 */ 2187 /* 0001 */ PTR(368, 1), 2188 /* 0010 */ V(14, 14, 4), 2189 /* 0011 */ PTR(370, 1), 2190 /* 0100 */ PTR(372, 1), 2191 /* 0101 */ PTR(374, 1), 2192 /* 0110 */ V(15, 11, 4), 2193 /* 0111 */ PTR(376, 1), 2194 /* 1000 */ V(13, 13, 4), 2195 /* 1001 */ V(10, 15, 4), 2196 /* 1010 */ V(15, 10, 4), 2197 /* 1011 */ V(11, 14, 4), 2198 /* 1100 */ V(14, 11, 4), 2199 /* 1101 */ V(12, 13, 4), 2200 /* 1110 */ V(13, 12, 4), 2201 /* 1111 */ V(9, 15, 4), 2202 2203 /* 0000 0001 ... */ 2204 /* 0000 */ V(15, 9, 4), /* 136 */ 2205 /* 0001 */ V(14, 10, 4), 2206 /* 0010 */ V(11, 13, 4), 2207 /* 0011 */ V(13, 11, 4), 2208 /* 0100 */ V(8, 15, 4), 2209 /* 0101 */ V(15, 8, 4), 2210 /* 0110 */ V(12, 12, 4), 2211 /* 0111 */ V(9, 14, 4), 2212 /* 1000 */ V(14, 9, 4), 2213 /* 1001 */ V(7, 15, 4), 2214 /* 1010 */ V(15, 7, 4), 2215 /* 1011 */ V(10, 13, 4), 2216 /* 1100 */ V(13, 10, 4), 2217 /* 1101 */ V(11, 12, 4), 2218 /* 1110 */ V(6, 15, 4), 2219 /* 1111 */ PTR(378, 1), 2220 2221 /* 0000 0010 ... */ 2222 /* 0000 */ V(12, 11, 3), /* 152 */ 2223 /* 0001 */ V(12, 11, 3), 2224 /* 0010 */ V(15, 6, 3), 2225 /* 0011 */ V(15, 6, 3), 2226 /* 0100 */ V(8, 14, 4), 2227 /* 0101 */ V(14, 8, 4), 2228 /* 0110 */ V(5, 15, 4), 2229 /* 0111 */ V(9, 13, 4), 2230 /* 1000 */ V(15, 5, 3), 2231 /* 1001 */ V(15, 5, 3), 2232 /* 1010 */ V(7, 14, 3), 2233 /* 1011 */ V(7, 14, 3), 2234 /* 1100 */ V(14, 7, 3), 2235 /* 1101 */ V(14, 7, 3), 2236 /* 1110 */ V(10, 12, 3), 2237 /* 1111 */ V(10, 12, 3), 2238 2239 /* 0000 0011 ... */ 2240 /* 0000 */ V(12, 10, 3), /* 168 */ 2241 /* 0001 */ V(12, 10, 3), 2242 /* 0010 */ V(11, 11, 3), 2243 /* 0011 */ V(11, 11, 3), 2244 /* 0100 */ V(13, 9, 4), 2245 /* 0101 */ V(8, 13, 4), 2246 /* 0110 */ V(4, 15, 3), 2247 /* 0111 */ V(4, 15, 3), 2248 /* 1000 */ V(15, 4, 3), 2249 /* 1001 */ V(15, 4, 3), 2250 /* 1010 */ V(3, 15, 3), 2251 /* 1011 */ V(3, 15, 3), 2252 /* 1100 */ V(15, 3, 3), 2253 /* 1101 */ V(15, 3, 3), 2254 /* 1110 */ V(13, 8, 3), 2255 /* 1111 */ V(13, 8, 3), 2256 2257 /* 0000 0100 ... */ 2258 /* 0000 */ V(14, 6, 3), /* 184 */ 2259 /* 0001 */ V(14, 6, 3), 2260 /* 0010 */ V(2, 15, 3), 2261 /* 0011 */ V(2, 15, 3), 2262 /* 0100 */ V(15, 2, 3), 2263 /* 0101 */ V(15, 2, 3), 2264 /* 0110 */ V(6, 14, 4), 2265 /* 0111 */ V(15, 0, 4), 2266 /* 1000 */ V(1, 15, 3), 2267 /* 1001 */ V(1, 15, 3), 2268 /* 1010 */ V(15, 1, 3), 2269 /* 1011 */ V(15, 1, 3), 2270 /* 1100 */ V(9, 12, 3), 2271 /* 1101 */ V(9, 12, 3), 2272 /* 1110 */ V(12, 9, 3), 2273 /* 1111 */ V(12, 9, 3), 2274 2275 /* 0000 0101 ... */ 2276 /* 000 */ V(5, 14, 3), /* 200 */ 2277 /* 001 */ V(10, 11, 3), 2278 /* 010 */ V(11, 10, 3), 2279 /* 011 */ V(14, 5, 3), 2280 /* 100 */ V(7, 13, 3), 2281 /* 101 */ V(13, 7, 3), 2282 /* 110 */ V(4, 14, 3), 2283 /* 111 */ V(14, 4, 3), 2284 2285 /* 0000 0110 ... */ 2286 /* 000 */ V(8, 12, 3), /* 208 */ 2287 /* 001 */ V(12, 8, 3), 2288 /* 010 */ V(3, 14, 3), 2289 /* 011 */ V(6, 13, 3), 2290 /* 100 */ V(13, 6, 3), 2291 /* 101 */ V(14, 3, 3), 2292 /* 110 */ V(9, 11, 3), 2293 /* 111 */ V(11, 9, 3), 2294 2295 /* 0000 0111 ... */ 2296 /* 0000 */ V(2, 14, 3), /* 216 */ 2297 /* 0001 */ V(2, 14, 3), 2298 /* 0010 */ V(10, 10, 3), 2299 /* 0011 */ V(10, 10, 3), 2300 /* 0100 */ V(14, 2, 3), 2301 /* 0101 */ V(14, 2, 3), 2302 /* 0110 */ V(1, 14, 3), 2303 /* 0111 */ V(1, 14, 3), 2304 /* 1000 */ V(14, 1, 3), 2305 /* 1001 */ V(14, 1, 3), 2306 /* 1010 */ V(0, 14, 4), 2307 /* 1011 */ V(14, 0, 4), 2308 /* 1100 */ V(5, 13, 3), 2309 /* 1101 */ V(5, 13, 3), 2310 /* 1110 */ V(13, 5, 3), 2311 /* 1111 */ V(13, 5, 3), 2312 2313 /* 0000 1000 ... */ 2314 /* 000 */ V(7, 12, 3), /* 232 */ 2315 /* 001 */ V(12, 7, 3), 2316 /* 010 */ V(4, 13, 3), 2317 /* 011 */ V(8, 11, 3), 2318 /* 100 */ V(13, 4, 2), 2319 /* 101 */ V(13, 4, 2), 2320 /* 110 */ V(11, 8, 3), 2321 /* 111 */ V(9, 10, 3), 2322 2323 /* 0000 1001 ... */ 2324 /* 000 */ V(10, 9, 3), /* 240 */ 2325 /* 001 */ V(6, 12, 3), 2326 /* 010 */ V(12, 6, 3), 2327 /* 011 */ V(3, 13, 3), 2328 /* 100 */ V(13, 3, 2), 2329 /* 101 */ V(13, 3, 2), 2330 /* 110 */ V(13, 2, 2), 2331 /* 111 */ V(13, 2, 2), 2332 2333 /* 0000 1010 ... */ 2334 /* 000 */ V(2, 13, 3), /* 248 */ 2335 /* 001 */ V(0, 13, 3), 2336 /* 010 */ V(1, 13, 2), 2337 /* 011 */ V(1, 13, 2), 2338 /* 100 */ V(7, 11, 2), 2339 /* 101 */ V(7, 11, 2), 2340 /* 110 */ V(11, 7, 2), 2341 /* 111 */ V(11, 7, 2), 2342 2343 /* 0000 1011 ... */ 2344 /* 000 */ V(13, 1, 2), /* 256 */ 2345 /* 001 */ V(13, 1, 2), 2346 /* 010 */ V(5, 12, 3), 2347 /* 011 */ V(13, 0, 3), 2348 /* 100 */ V(12, 5, 2), 2349 /* 101 */ V(12, 5, 2), 2350 /* 110 */ V(8, 10, 2), 2351 /* 111 */ V(8, 10, 2), 2352 2353 /* 0000 1100 ... */ 2354 /* 00 */ V(10, 8, 2), /* 264 */ 2355 /* 01 */ V(4, 12, 2), 2356 /* 10 */ V(12, 4, 2), 2357 /* 11 */ V(6, 11, 2), 2358 2359 /* 0000 1101 ... */ 2360 /* 000 */ V(11, 6, 2), /* 268 */ 2361 /* 001 */ V(11, 6, 2), 2362 /* 010 */ V(9, 9, 3), 2363 /* 011 */ V(0, 12, 3), 2364 /* 100 */ V(3, 12, 2), 2365 /* 101 */ V(3, 12, 2), 2366 /* 110 */ V(12, 3, 2), 2367 /* 111 */ V(12, 3, 2), 2368 2369 /* 0000 1110 ... */ 2370 /* 000 */ V(7, 10, 2), /* 276 */ 2371 /* 001 */ V(7, 10, 2), 2372 /* 010 */ V(10, 7, 2), 2373 /* 011 */ V(10, 7, 2), 2374 /* 100 */ V(10, 6, 2), 2375 /* 101 */ V(10, 6, 2), 2376 /* 110 */ V(12, 0, 3), 2377 /* 111 */ V(0, 11, 3), 2378 2379 /* 0000 1111 ... */ 2380 /* 00 */ V(12, 2, 1), /* 284 */ 2381 /* 01 */ V(12, 2, 1), 2382 /* 10 */ V(2, 12, 2), 2383 /* 11 */ V(5, 11, 2), 2384 2385 /* 0001 0000 ... */ 2386 /* 00 */ V(11, 5, 2), /* 288 */ 2387 /* 01 */ V(1, 12, 2), 2388 /* 10 */ V(8, 9, 2), 2389 /* 11 */ V(9, 8, 2), 2390 2391 /* 0001 0001 ... */ 2392 /* 00 */ V(12, 1, 2), /* 292 */ 2393 /* 01 */ V(4, 11, 2), 2394 /* 10 */ V(11, 4, 2), 2395 /* 11 */ V(6, 10, 2), 2396 2397 /* 0001 0010 ... */ 2398 /* 00 */ V(3, 11, 2), /* 296 */ 2399 /* 01 */ V(7, 9, 2), 2400 /* 10 */ V(11, 3, 1), 2401 /* 11 */ V(11, 3, 1), 2402 2403 /* 0001 0011 ... */ 2404 /* 00 */ V(9, 7, 2), /* 300 */ 2405 /* 01 */ V(8, 8, 2), 2406 /* 10 */ V(2, 11, 2), 2407 /* 11 */ V(5, 10, 2), 2408 2409 /* 0001 0100 ... */ 2410 /* 00 */ V(11, 2, 1), /* 304 */ 2411 /* 01 */ V(11, 2, 1), 2412 /* 10 */ V(10, 5, 2), 2413 /* 11 */ V(1, 11, 2), 2414 2415 /* 0001 0101 ... */ 2416 /* 00 */ V(11, 1, 1), /* 308 */ 2417 /* 01 */ V(11, 1, 1), 2418 /* 10 */ V(11, 0, 2), 2419 /* 11 */ V(6, 9, 2), 2420 2421 /* 0001 0110 ... */ 2422 /* 00 */ V(9, 6, 2), /* 312 */ 2423 /* 01 */ V(4, 10, 2), 2424 /* 10 */ V(10, 4, 2), 2425 /* 11 */ V(7, 8, 2), 2426 2427 /* 0001 0111 ... */ 2428 /* 00 */ V(8, 7, 2), /* 316 */ 2429 /* 01 */ V(3, 10, 2), 2430 /* 10 */ V(10, 3, 1), 2431 /* 11 */ V(10, 3, 1), 2432 2433 /* 0001 1000 ... */ 2434 /* 0 */ V(5, 9, 1), /* 320 */ 2435 /* 1 */ V(9, 5, 1), 2436 2437 /* 0001 1001 ... */ 2438 /* 0 */ V(2, 10, 1), /* 322 */ 2439 /* 1 */ V(10, 2, 1), 2440 2441 /* 0001 1010 ... */ 2442 /* 0 */ V(1, 10, 1), /* 324 */ 2443 /* 1 */ V(10, 1, 1), 2444 2445 /* 0001 1011 ... */ 2446 /* 00 */ V(0, 10, 2), /* 326 */ 2447 /* 01 */ V(10, 0, 2), 2448 /* 10 */ V(6, 8, 1), 2449 /* 11 */ V(6, 8, 1), 2450 2451 /* 0001 1100 ... */ 2452 /* 0 */ V(8, 6, 1), /* 330 */ 2453 /* 1 */ V(4, 9, 1), 2454 2455 /* 0001 1101 ... */ 2456 /* 0 */ V(9, 4, 1), /* 332 */ 2457 /* 1 */ V(3, 9, 1), 2458 2459 /* 0001 1110 ... */ 2460 /* 00 */ V(9, 3, 1), /* 334 */ 2461 /* 01 */ V(9, 3, 1), 2462 /* 10 */ V(7, 7, 2), 2463 /* 11 */ V(0, 9, 2), 2464 2465 /* 0001 1111 ... */ 2466 /* 0 */ V(5, 8, 1), /* 338 */ 2467 /* 1 */ V(8, 5, 1), 2468 2469 /* 0010 0000 ... */ 2470 /* 0 */ V(2, 9, 1), /* 340 */ 2471 /* 1 */ V(6, 7, 1), 2472 2473 /* 0010 0001 ... */ 2474 /* 0 */ V(7, 6, 1), /* 342 */ 2475 /* 1 */ V(9, 2, 1), 2476 2477 /* 0010 0011 ... */ 2478 /* 0 */ V(1, 9, 1), /* 344 */ 2479 /* 1 */ V(9, 0, 1), 2480 2481 /* 0010 0100 ... */ 2482 /* 0 */ V(4, 8, 1), /* 346 */ 2483 /* 1 */ V(8, 4, 1), 2484 2485 /* 0010 0101 ... */ 2486 /* 0 */ V(5, 7, 1), /* 348 */ 2487 /* 1 */ V(7, 5, 1), 2488 2489 /* 0010 0110 ... */ 2490 /* 0 */ V(3, 8, 1), /* 350 */ 2491 /* 1 */ V(8, 3, 1), 2492 2493 /* 0010 0111 ... */ 2494 /* 0 */ V(6, 6, 1), /* 352 */ 2495 /* 1 */ V(4, 7, 1), 2496 2497 /* 0010 1100 ... */ 2498 /* 0 */ V(7, 4, 1), /* 354 */ 2499 /* 1 */ V(0, 8, 1), 2500 2501 /* 0010 1101 ... */ 2502 /* 0 */ V(8, 0, 1), /* 356 */ 2503 /* 1 */ V(5, 6, 1), 2504 2505 /* 0010 1110 ... */ 2506 /* 0 */ V(6, 5, 1), /* 358 */ 2507 /* 1 */ V(3, 7, 1), 2508 2509 /* 0010 1111 ... */ 2510 /* 0 */ V(7, 3, 1), /* 360 */ 2511 /* 1 */ V(4, 6, 1), 2512 2513 /* 0011 0110 ... */ 2514 /* 0 */ V(0, 7, 1), /* 362 */ 2515 /* 1 */ V(7, 0, 1), 2516 2517 /* 0011 1110 ... */ 2518 /* 0 */ V(0, 6, 1), /* 364 */ 2519 /* 1 */ V(6, 0, 1), 2520 2521 /* 0000 0000 0000 ... */ 2522 /* 0 */ V(15, 15, 1), /* 366 */ 2523 /* 1 */ V(14, 15, 1), 2524 2525 /* 0000 0000 0001 ... */ 2526 /* 0 */ V(15, 14, 1), /* 368 */ 2527 /* 1 */ V(13, 15, 1), 2528 2529 /* 0000 0000 0011 ... */ 2530 /* 0 */ V(15, 13, 1), /* 370 */ 2531 /* 1 */ V(12, 15, 1), 2532 2533 /* 0000 0000 0100 ... */ 2534 /* 0 */ V(15, 12, 1), /* 372 */ 2535 /* 1 */ V(13, 14, 1), 2536 2537 /* 0000 0000 0101 ... */ 2538 /* 0 */ V(14, 13, 1), /* 374 */ 2539 /* 1 */ V(11, 15, 1), 2540 2541 /* 0000 0000 0111 ... */ 2542 /* 0 */ V(12, 14, 1), /* 376 */ 2543 /* 1 */ V(14, 12, 1), 2544 2545 /* 0000 0001 1111 ... */ 2546 /* 0 */ V(10, 14, 1), /* 378 */ 2547 /* 1 */ V(0, 15, 1) 2548]; 2549 2550const hufftab16 = [ 2551 /* 0000 */ PTR(16, 4), 2552 /* 0001 */ PTR(32, 4), 2553 /* 0010 */ PTR(48, 4), 2554 /* 0011 */ PTR(64, 2), 2555 /* 0100 */ V(1, 1, 4), 2556 /* 0101 */ V(0, 1, 4), 2557 /* 0110 */ V(1, 0, 3), 2558 /* 0111 */ V(1, 0, 3), 2559 /* 1000 */ V(0, 0, 1), 2560 /* 1001 */ V(0, 0, 1), 2561 /* 1010 */ V(0, 0, 1), 2562 /* 1011 */ V(0, 0, 1), 2563 /* 1100 */ V(0, 0, 1), 2564 /* 1101 */ V(0, 0, 1), 2565 /* 1110 */ V(0, 0, 1), 2566 /* 1111 */ V(0, 0, 1), 2567 2568 /* 0000 ... */ 2569 /* 0000 */ PTR(68, 3), /* 16 */ 2570 /* 0001 */ PTR(76, 3), 2571 /* 0010 */ PTR(84, 2), 2572 /* 0011 */ V(15, 15, 4), 2573 /* 0100 */ PTR(88, 2), 2574 /* 0101 */ PTR(92, 1), 2575 /* 0110 */ PTR(94, 4), 2576 /* 0111 */ V(15, 2, 4), 2577 /* 1000 */ PTR(110, 1), 2578 /* 1001 */ V(1, 15, 4), 2579 /* 1010 */ V(15, 1, 4), 2580 /* 1011 */ PTR(112, 4), 2581 /* 1100 */ PTR(128, 4), 2582 /* 1101 */ PTR(144, 4), 2583 /* 1110 */ PTR(160, 4), 2584 /* 1111 */ PTR(176, 4), 2585 2586 /* 0001 ... */ 2587 /* 0000 */ PTR(192, 4), /* 32 */ 2588 /* 0001 */ PTR(208, 3), 2589 /* 0010 */ PTR(216, 3), 2590 /* 0011 */ PTR(224, 3), 2591 /* 0100 */ PTR(232, 3), 2592 /* 0101 */ PTR(240, 3), 2593 /* 0110 */ PTR(248, 3), 2594 /* 0111 */ PTR(256, 3), 2595 /* 1000 */ PTR(264, 2), 2596 /* 1001 */ PTR(268, 2), 2597 /* 1010 */ PTR(272, 1), 2598 /* 1011 */ PTR(274, 2), 2599 /* 1100 */ PTR(278, 2), 2600 /* 1101 */ PTR(282, 1), 2601 /* 1110 */ V(5, 1, 4), 2602 /* 1111 */ PTR(284, 1), 2603 2604 /* 0010 ... */ 2605 /* 0000 */ PTR(286, 1), /* 48 */ 2606 /* 0001 */ PTR(288, 1), 2607 /* 0010 */ PTR(290, 1), 2608 /* 0011 */ V(1, 4, 4), 2609 /* 0100 */ V(4, 1, 4), 2610 /* 0101 */ PTR(292, 1), 2611 /* 0110 */ V(2, 3, 4), 2612 /* 0111 */ V(3, 2, 4), 2613 /* 1000 */ V(1, 3, 3), 2614 /* 1001 */ V(1, 3, 3), 2615 /* 1010 */ V(3, 1, 3), 2616 /* 1011 */ V(3, 1, 3), 2617 /* 1100 */ V(0, 3, 4), 2618 /* 1101 */ V(3, 0, 4), 2619 /* 1110 */ V(2, 2, 3), 2620 /* 1111 */ V(2, 2, 3), 2621 2622 /* 0011 ... */ 2623 /* 00 */ V(1, 2, 2), /* 64 */ 2624 /* 01 */ V(2, 1, 2), 2625 /* 10 */ V(0, 2, 2), 2626 /* 11 */ V(2, 0, 2), 2627 2628 /* 0000 0000 ... */ 2629 /* 000 */ V(14, 15, 3), /* 68 */ 2630 /* 001 */ V(15, 14, 3), 2631 /* 010 */ V(13, 15, 3), 2632 /* 011 */ V(15, 13, 3), 2633 /* 100 */ V(12, 15, 3), 2634 /* 101 */ V(15, 12, 3), 2635 /* 110 */ V(11, 15, 3), 2636 /* 111 */ V(15, 11, 3), 2637 2638 /* 0000 0001 ... */ 2639 /* 000 */ V(10, 15, 2), /* 76 */ 2640 /* 001 */ V(10, 15, 2), 2641 /* 010 */ V(15, 10, 3), 2642 /* 011 */ V(9, 15, 3), 2643 /* 100 */ V(15, 9, 3), 2644 /* 101 */ V(15, 8, 3), 2645 /* 110 */ V(8, 15, 2), 2646 /* 111 */ V(8, 15, 2), 2647 2648 /* 0000 0010 ... */ 2649 /* 00 */ V(7, 15, 2), /* 84 */ 2650 /* 01 */ V(15, 7, 2), 2651 /* 10 */ V(6, 15, 2), 2652 /* 11 */ V(15, 6, 2), 2653 2654 /* 0000 0100 ... */ 2655 /* 00 */ V(5, 15, 2), /* 88 */ 2656 /* 01 */ V(15, 5, 2), 2657 /* 10 */ V(4, 15, 1), 2658 /* 11 */ V(4, 15, 1), 2659 2660 /* 0000 0101 ... */ 2661 /* 0 */ V(15, 4, 1), /* 92 */ 2662 /* 1 */ V(15, 3, 1), 2663 2664 /* 0000 0110 ... */ 2665 /* 0000 */ V(15, 0, 1), /* 94 */ 2666 /* 0001 */ V(15, 0, 1), 2667 /* 0010 */ V(15, 0, 1), 2668 /* 0011 */ V(15, 0, 1), 2669 /* 0100 */ V(15, 0, 1), 2670 /* 0101 */ V(15, 0, 1), 2671 /* 0110 */ V(15, 0, 1), 2672 /* 0111 */ V(15, 0, 1), 2673 /* 1000 */ V(3, 15, 2), 2674 /* 1001 */ V(3, 15, 2), 2675 /* 1010 */ V(3, 15, 2), 2676 /* 1011 */ V(3, 15, 2), 2677 /* 1100 */ PTR(294, 4), 2678 /* 1101 */ PTR(310, 3), 2679 /* 1110 */ PTR(318, 3), 2680 /* 1111 */ PTR(326, 3), 2681 2682 /* 0000 1000 ... */ 2683 /* 0 */ V(2, 15, 1), /* 110 */ 2684 /* 1 */ V(0, 15, 1), 2685 2686 /* 0000 1011 ... */ 2687 /* 0000 */ PTR(334, 2), /* 112 */ 2688 /* 0001 */ PTR(338, 2), 2689 /* 0010 */ PTR(342, 2), 2690 /* 0011 */ PTR(346, 1), 2691 /* 0100 */ PTR(348, 2), 2692 /* 0101 */ PTR(352, 2), 2693 /* 0110 */ PTR(356, 1), 2694 /* 0111 */ PTR(358, 2), 2695 /* 1000 */ PTR(362, 2), 2696 /* 1001 */ PTR(366, 2), 2697 /* 1010 */ PTR(370, 2), 2698 /* 1011 */ V(14, 3, 4), 2699 /* 1100 */ PTR(374, 1), 2700 /* 1101 */ PTR(376, 1), 2701 /* 1110 */ PTR(378, 1), 2702 /* 1111 */ PTR(380, 1), 2703 2704 /* 0000 1100 ... */ 2705 /* 0000 */ PTR(382, 1), /* 128 */ 2706 /* 0001 */ PTR(384, 1), 2707 /* 0010 */ PTR(386, 1), 2708 /* 0011 */ V(0, 13, 4), 2709 /* 0100 */ PTR(388, 1), 2710 /* 0101 */ PTR(390, 1), 2711 /* 0110 */ PTR(392, 1), 2712 /* 0111 */ V(3, 12, 4), 2713 /* 1000 */ PTR(394, 1), 2714 /* 1001 */ V(1, 12, 4), 2715 /* 1010 */ V(12, 0, 4), 2716 /* 1011 */ PTR(396, 1), 2717 /* 1100 */ V(14, 2, 3), 2718 /* 1101 */ V(14, 2, 3), 2719 /* 1110 */ V(2, 14, 4), 2720 /* 1111 */ V(1, 14, 4), 2721 2722 /* 0000 1101 ... */ 2723 /* 0000 */ V(13, 3, 4), /* 144 */ 2724 /* 0001 */ V(2, 13, 4), 2725 /* 0010 */ V(13, 2, 4), 2726 /* 0011 */ V(13, 1, 4), 2727 /* 0100 */ V(3, 11, 4), 2728 /* 0101 */ PTR(398, 1), 2729 /* 0110 */ V(1, 13, 3), 2730 /* 0111 */ V(1, 13, 3), 2731 /* 1000 */ V(12, 4, 4), 2732 /* 1001 */ V(6, 11, 4), 2733 /* 1010 */ V(12, 3, 4), 2734 /* 1011 */ V(10, 7, 4), 2735 /* 1100 */ V(2, 12, 3), 2736 /* 1101 */ V(2, 12, 3), 2737 /* 1110 */ V(12, 2, 4), 2738 /* 1111 */ V(11, 5, 4), 2739 2740 /* 0000 1110 ... */ 2741 /* 0000 */ V(12, 1, 4), /* 160 */ 2742 /* 0001 */ V(0, 12, 4), 2743 /* 0010 */ V(4, 11, 4), 2744 /* 0011 */ V(11, 4, 4), 2745 /* 0100 */ V(6, 10, 4), 2746 /* 0101 */ V(10, 6, 4), 2747 /* 0110 */ V(11, 3, 3), 2748 /* 0111 */ V(11, 3, 3), 2749 /* 1000 */ V(5, 10, 4), 2750 /* 1001 */ V(10, 5, 4), 2751 /* 1010 */ V(2, 11, 3), 2752 /* 1011 */ V(2, 11, 3), 2753 /* 1100 */ V(11, 2, 3), 2754 /* 1101 */ V(11, 2, 3), 2755 /* 1110 */ V(1, 11, 3), 2756 /* 1111 */ V(1, 11, 3), 2757 2758 /* 0000 1111 ... */ 2759 /* 0000 */ V(11, 1, 3), /* 176 */ 2760 /* 0001 */ V(11, 1, 3), 2761 /* 0010 */ V(0, 11, 4), 2762 /* 0011 */ V(11, 0, 4), 2763 /* 0100 */ V(6, 9, 4), 2764 /* 0101 */ V(9, 6, 4), 2765 /* 0110 */ V(4, 10, 4), 2766 /* 0111 */ V(10, 4, 4), 2767 /* 1000 */ V(7, 8, 4), 2768 /* 1001 */ V(8, 7, 4), 2769 /* 1010 */ V(10, 3, 3), 2770 /* 1011 */ V(10, 3, 3), 2771 /* 1100 */ V(3, 10, 4), 2772 /* 1101 */ V(5, 9, 4), 2773 /* 1110 */ V(2, 10, 3), 2774 /* 1111 */ V(2, 10, 3), 2775 2776 /* 0001 0000 ... */ 2777 /* 0000 */ V(9, 5, 4), /* 192 */ 2778 /* 0001 */ V(6, 8, 4), 2779 /* 0010 */ V(10, 1, 3), 2780 /* 0011 */ V(10, 1, 3), 2781 /* 0100 */ V(8, 6, 4), 2782 /* 0101 */ V(7, 7, 4), 2783 /* 0110 */ V(9, 4, 3), 2784 /* 0111 */ V(9, 4, 3), 2785 /* 1000 */ V(4, 9, 4), 2786 /* 1001 */ V(5, 7, 4), 2787 /* 1010 */ V(6, 7, 3), 2788 /* 1011 */ V(6, 7, 3), 2789 /* 1100 */ V(10, 2, 2), 2790 /* 1101 */ V(10, 2, 2), 2791 /* 1110 */ V(10, 2, 2), 2792 /* 1111 */ V(10, 2, 2), 2793 2794 /* 0001 0001 ... */ 2795 /* 000 */ V(1, 10, 2), /* 208 */ 2796 /* 001 */ V(1, 10, 2), 2797 /* 010 */ V(0, 10, 3), 2798 /* 011 */ V(10, 0, 3), 2799 /* 100 */ V(3, 9, 3), 2800 /* 101 */ V(9, 3, 3), 2801 /* 110 */ V(5, 8, 3), 2802 /* 111 */ V(8, 5, 3), 2803 2804 /* 0001 0010 ... */ 2805 /* 000 */ V(2, 9, 2), /* 216 */ 2806 /* 001 */ V(2, 9, 2), 2807 /* 010 */ V(9, 2, 2), 2808 /* 011 */ V(9, 2, 2), 2809 /* 100 */ V(7, 6, 3), 2810 /* 101 */ V(0, 9, 3), 2811 /* 110 */ V(1, 9, 2), 2812 /* 111 */ V(1, 9, 2), 2813 2814 /* 0001 0011 ... */ 2815 /* 000 */ V(9, 1, 2), /* 224 */ 2816 /* 001 */ V(9, 1, 2), 2817 /* 010 */ V(9, 0, 3), 2818 /* 011 */ V(4, 8, 3), 2819 /* 100 */ V(8, 4, 3), 2820 /* 101 */ V(7, 5, 3), 2821 /* 110 */ V(3, 8, 3), 2822 /* 111 */ V(8, 3, 3), 2823 2824 /* 0001 0100 ... */ 2825 /* 000 */ V(6, 6, 3), /* 232 */ 2826 /* 001 */ V(2, 8, 3), 2827 /* 010 */ V(8, 2, 2), 2828 /* 011 */ V(8, 2, 2), 2829 /* 100 */ V(4, 7, 3), 2830 /* 101 */ V(7, 4, 3), 2831 /* 110 */ V(1, 8, 2), 2832 /* 111 */ V(1, 8, 2), 2833 2834 /* 0001 0101 ... */ 2835 /* 000 */ V(8, 1, 2), /* 240 */ 2836 /* 001 */ V(8, 1, 2), 2837 /* 010 */ V(8, 0, 2), 2838 /* 011 */ V(8, 0, 2), 2839 /* 100 */ V(0, 8, 3), 2840 /* 101 */ V(5, 6, 3), 2841 /* 110 */ V(3, 7, 2), 2842 /* 111 */ V(3, 7, 2), 2843 2844 /* 0001 0110 ... */ 2845 /* 000 */ V(7, 3, 2), /* 248 */ 2846 /* 001 */ V(7, 3, 2), 2847 /* 010 */ V(6, 5, 3), 2848 /* 011 */ V(4, 6, 3), 2849 /* 100 */ V(2, 7, 2), 2850 /* 101 */ V(2, 7, 2), 2851 /* 110 */ V(7, 2, 2), 2852 /* 111 */ V(7, 2, 2), 2853 2854 /* 0001 0111 ... */ 2855 /* 000 */ V(6, 4, 3), /* 256 */ 2856 /* 001 */ V(5, 5, 3), 2857 /* 010 */ V(0, 7, 2), 2858 /* 011 */ V(0, 7, 2), 2859 /* 100 */ V(1, 7, 1), 2860 /* 101 */ V(1, 7, 1), 2861 /* 110 */ V(1, 7, 1), 2862 /* 111 */ V(1, 7, 1), 2863 2864 /* 0001 1000 ... */ 2865 /* 00 */ V(7, 1, 1), /* 264 */ 2866 /* 01 */ V(7, 1, 1), 2867 /* 10 */ V(7, 0, 2), 2868 /* 11 */ V(3, 6, 2), 2869 2870 /* 0001 1001 ... */ 2871 /* 00 */ V(6, 3, 2), /* 268 */ 2872 /* 01 */ V(4, 5, 2), 2873 /* 10 */ V(5, 4, 2), 2874 /* 11 */ V(2, 6, 2), 2875 2876 /* 0001 1010 ... */ 2877 /* 0 */ V(6, 2, 1), /* 272 */ 2878 /* 1 */ V(1, 6, 1), 2879 2880 /* 0001 1011 ... */ 2881 /* 00 */ V(6, 1, 1), /* 274 */ 2882 /* 01 */ V(6, 1, 1), 2883 /* 10 */ V(0, 6, 2), 2884 /* 11 */ V(6, 0, 2), 2885 2886 /* 0001 1100 ... */ 2887 /* 00 */ V(5, 3, 1), /* 278 */ 2888 /* 01 */ V(5, 3, 1), 2889 /* 10 */ V(3, 5, 2), 2890 /* 11 */ V(4, 4, 2), 2891 2892 /* 0001 1101 ... */ 2893 /* 0 */ V(2, 5, 1), /* 282 */ 2894 /* 1 */ V(5, 2, 1), 2895 2896 /* 0001 1111 ... */ 2897 /* 0 */ V(1, 5, 1), /* 284 */ 2898 /* 1 */ V(0, 5, 1), 2899 2900 /* 0010 0000 ... */ 2901 /* 0 */ V(3, 4, 1), /* 286 */ 2902 /* 1 */ V(4, 3, 1), 2903 2904 /* 0010 0001 ... */ 2905 /* 0 */ V(5, 0, 1), /* 288 */ 2906 /* 1 */ V(2, 4, 1), 2907 2908 /* 0010 0010 ... */ 2909 /* 0 */ V(4, 2, 1), /* 290 */ 2910 /* 1 */ V(3, 3, 1), 2911 2912 /* 0010 0101 ... */ 2913 /* 0 */ V(0, 4, 1), /* 292 */ 2914 /* 1 */ V(4, 0, 1), 2915 2916 /* 0000 0110 1100 ... */ 2917 /* 0000 */ V(12, 14, 4), /* 294 */ 2918 /* 0001 */ PTR(400, 1), 2919 /* 0010 */ V(13, 14, 3), 2920 /* 0011 */ V(13, 14, 3), 2921 /* 0100 */ V(14, 9, 3), 2922 /* 0101 */ V(14, 9, 3), 2923 /* 0110 */ V(14, 10, 4), 2924 /* 0111 */ V(13, 9, 4), 2925 /* 1000 */ V(14, 14, 2), 2926 /* 1001 */ V(14, 14, 2), 2927 /* 1010 */ V(14, 14, 2), 2928 /* 1011 */ V(14, 14, 2), 2929 /* 1100 */ V(14, 13, 3), 2930 /* 1101 */ V(14, 13, 3), 2931 /* 1110 */ V(14, 11, 3), 2932 /* 1111 */ V(14, 11, 3), 2933 2934 /* 0000 0110 1101 ... */ 2935 /* 000 */ V(11, 14, 2), /* 310 */ 2936 /* 001 */ V(11, 14, 2), 2937 /* 010 */ V(12, 13, 2), 2938 /* 011 */ V(12, 13, 2), 2939 /* 100 */ V(13, 12, 3), 2940 /* 101 */ V(13, 11, 3), 2941 /* 110 */ V(10, 14, 2), 2942 /* 111 */ V(10, 14, 2), 2943 2944 /* 0000 0110 1110 ... */ 2945 /* 000 */ V(12, 12, 2), /* 318 */ 2946 /* 001 */ V(12, 12, 2), 2947 /* 010 */ V(10, 13, 3), 2948 /* 011 */ V(13, 10, 3), 2949 /* 100 */ V(7, 14, 3), 2950 /* 101 */ V(10, 12, 3), 2951 /* 110 */ V(12, 10, 2), 2952 /* 111 */ V(12, 10, 2), 2953 2954 /* 0000 0110 1111 ... */ 2955 /* 000 */ V(12, 9, 3), /* 326 */ 2956 /* 001 */ V(7, 13, 3), 2957 /* 010 */ V(5, 14, 2), 2958 /* 011 */ V(5, 14, 2), 2959 /* 100 */ V(11, 13, 1), 2960 /* 101 */ V(11, 13, 1), 2961 /* 110 */ V(11, 13, 1), 2962 /* 111 */ V(11, 13, 1), 2963 2964 /* 0000 1011 0000 ... */ 2965 /* 00 */ V(9, 14, 1), /* 334 */ 2966 /* 01 */ V(9, 14, 1), 2967 /* 10 */ V(11, 12, 2), 2968 /* 11 */ V(12, 11, 2), 2969 2970 /* 0000 1011 0001 ... */ 2971 /* 00 */ V(8, 14, 2), /* 338 */ 2972 /* 01 */ V(14, 8, 2), 2973 /* 10 */ V(9, 13, 2), 2974 /* 11 */ V(14, 7, 2), 2975 2976 /* 0000 1011 0010 ... */ 2977 /* 00 */ V(11, 11, 2), /* 342 */ 2978 /* 01 */ V(8, 13, 2), 2979 /* 10 */ V(13, 8, 2), 2980 /* 11 */ V(6, 14, 2), 2981 2982 /* 0000 1011 0011 ... */ 2983 /* 0 */ V(14, 6, 1), /* 346 */ 2984 /* 1 */ V(9, 12, 1), 2985 2986 /* 0000 1011 0100 ... */ 2987 /* 00 */ V(10, 11, 2), /* 348 */ 2988 /* 01 */ V(11, 10, 2), 2989 /* 10 */ V(14, 5, 2), 2990 /* 11 */ V(13, 7, 2), 2991 2992 /* 0000 1011 0101 ... */ 2993 /* 00 */ V(4, 14, 1), /* 352 */ 2994 /* 01 */ V(4, 14, 1), 2995 /* 10 */ V(14, 4, 2), 2996 /* 11 */ V(8, 12, 2), 2997 2998 /* 0000 1011 0110 ... */ 2999 /* 0 */ V(12, 8, 1), /* 356 */ 3000 /* 1 */ V(3, 14, 1), 3001 3002 /* 0000 1011 0111 ... */ 3003 /* 00 */ V(6, 13, 1), /* 358 */ 3004 /* 01 */ V(6, 13, 1), 3005 /* 10 */ V(13, 6, 2), 3006 /* 11 */ V(9, 11, 2), 3007 3008 /* 0000 1011 1000 ... */ 3009 /* 00 */ V(11, 9, 2), /* 362 */ 3010 /* 01 */ V(10, 10, 2), 3011 /* 10 */ V(14, 1, 1), 3012 /* 11 */ V(14, 1, 1), 3013 3014 /* 0000 1011 1001 ... */ 3015 /* 00 */ V(13, 4, 1), /* 366 */ 3016 /* 01 */ V(13, 4, 1), 3017 /* 10 */ V(11, 8, 2), 3018 /* 11 */ V(10, 9, 2), 3019 3020 /* 0000 1011 1010 ... */ 3021 /* 00 */ V(7, 11, 1), /* 370 */ 3022 /* 01 */ V(7, 11, 1), 3023 /* 10 */ V(11, 7, 2), 3024 /* 11 */ V(13, 0, 2), 3025 3026 /* 0000 1011 1100 ... */ 3027 /* 0 */ V(0, 14, 1), /* 374 */ 3028 /* 1 */ V(14, 0, 1), 3029 3030 /* 0000 1011 1101 ... */ 3031 /* 0 */ V(5, 13, 1), /* 376 */ 3032 /* 1 */ V(13, 5, 1), 3033 3034 /* 0000 1011 1110 ... */ 3035 /* 0 */ V(7, 12, 1), /* 378 */ 3036 /* 1 */ V(12, 7, 1), 3037 3038 /* 0000 1011 1111 ... */ 3039 /* 0 */ V(4, 13, 1), /* 380 */ 3040 /* 1 */ V(8, 11, 1), 3041 3042 /* 0000 1100 0000 ... */ 3043 /* 0 */ V(9, 10, 1), /* 382 */ 3044 /* 1 */ V(6, 12, 1), 3045 3046 /* 0000 1100 0001 ... */ 3047 /* 0 */ V(12, 6, 1), /* 384 */ 3048 /* 1 */ V(3, 13, 1), 3049 3050 /* 0000 1100 0010 ... */ 3051 /* 0 */ V(5, 12, 1), /* 386 */ 3052 /* 1 */ V(12, 5, 1), 3053 3054 /* 0000 1100 0100 ... */ 3055 /* 0 */ V(8, 10, 1), /* 388 */ 3056 /* 1 */ V(10, 8, 1), 3057 3058 /* 0000 1100 0101 ... */ 3059 /* 0 */ V(9, 9, 1), /* 390 */ 3060 /* 1 */ V(4, 12, 1), 3061 3062 /* 0000 1100 0110 ... */ 3063 /* 0 */ V(11, 6, 1), /* 392 */ 3064 /* 1 */ V(7, 10, 1), 3065 3066 /* 0000 1100 1000 ... */ 3067 /* 0 */ V(5, 11, 1), /* 394 */ 3068 /* 1 */ V(8, 9, 1), 3069 3070 /* 0000 1100 1011 ... */ 3071 /* 0 */ V(9, 8, 1), /* 396 */ 3072 /* 1 */ V(7, 9, 1), 3073 3074 /* 0000 1101 0101 ... */ 3075 /* 0 */ V(9, 7, 1), /* 398 */ 3076 /* 1 */ V(8, 8, 1), 3077 3078 /* 0000 0110 1100 0001 ... */ 3079 /* 0 */ V(14, 12, 1), /* 400 */ 3080 /* 1 */ V(13, 13, 1) 3081]; 3082 3083const hufftab24 = [ 3084 /* 0000 */ PTR(16, 4), 3085 /* 0001 */ PTR(32, 4), 3086 /* 0010 */ PTR(48, 4), 3087 /* 0011 */ V(15, 15, 4), 3088 /* 0100 */ PTR(64, 4), 3089 /* 0101 */ PTR(80, 4), 3090 /* 0110 */ PTR(96, 4), 3091 /* 0111 */ PTR(112, 4), 3092 /* 1000 */ PTR(128, 4), 3093 /* 1001 */ PTR(144, 4), 3094 /* 1010 */ PTR(160, 3), 3095 /* 1011 */ PTR(168, 2), 3096 /* 1100 */ V(1, 1, 4), 3097 /* 1101 */ V(0, 1, 4), 3098 /* 1110 */ V(1, 0, 4), 3099 /* 1111 */ V(0, 0, 4), 3100 3101 /* 0000 ... */ 3102 /* 0000 */ V(14, 15, 4), /* 16 */ 3103 /* 0001 */ V(15, 14, 4), 3104 /* 0010 */ V(13, 15, 4), 3105 /* 0011 */ V(15, 13, 4), 3106 /* 0100 */ V(12, 15, 4), 3107 /* 0101 */ V(15, 12, 4), 3108 /* 0110 */ V(11, 15, 4), 3109 /* 0111 */ V(15, 11, 4), 3110 /* 1000 */ V(15, 10, 3), 3111 /* 1001 */ V(15, 10, 3), 3112 /* 1010 */ V(10, 15, 4), 3113 /* 1011 */ V(9, 15, 4), 3114 /* 1100 */ V(15, 9, 3), 3115 /* 1101 */ V(15, 9, 3), 3116 /* 1110 */ V(15, 8, 3), 3117 /* 1111 */ V(15, 8, 3), 3118 3119 /* 0001 ... */ 3120 /* 0000 */ V(8, 15, 4), /* 32 */ 3121 /* 0001 */ V(7, 15, 4), 3122 /* 0010 */ V(15, 7, 3), 3123 /* 0011 */ V(15, 7, 3), 3124 /* 0100 */ V(6, 15, 3), 3125 /* 0101 */ V(6, 15, 3), 3126 /* 0110 */ V(15, 6, 3), 3127 /* 0111 */ V(15, 6, 3), 3128 /* 1000 */ V(5, 15, 3), 3129 /* 1001 */ V(5, 15, 3), 3130 /* 1010 */ V(15, 5, 3), 3131 /* 1011 */ V(15, 5, 3), 3132 /* 1100 */ V(4, 15, 3), 3133 /* 1101 */ V(4, 15, 3), 3134 /* 1110 */ V(15, 4, 3), 3135 /* 1111 */ V(15, 4, 3), 3136 3137 /* 0010 ... */ 3138 /* 0000 */ V(3, 15, 3), /* 48 */ 3139 /* 0001 */ V(3, 15, 3), 3140 /* 0010 */ V(15, 3, 3), 3141 /* 0011 */ V(15, 3, 3), 3142 /* 0100 */ V(2, 15, 3), 3143 /* 0101 */ V(2, 15, 3), 3144 /* 0110 */ V(15, 2, 3), 3145 /* 0111 */ V(15, 2, 3), 3146 /* 1000 */ V(15, 1, 3), 3147 /* 1001 */ V(15, 1, 3), 3148 /* 1010 */ V(1, 15, 4), 3149 /* 1011 */ V(15, 0, 4), 3150 /* 1100 */ PTR(172, 3), 3151 /* 1101 */ PTR(180, 3), 3152 /* 1110 */ PTR(188, 3), 3153 /* 1111 */ PTR(196, 3), 3154 3155 /* 0100 ... */ 3156 /* 0000 */ PTR(204, 4), /* 64 */ 3157 /* 0001 */ PTR(220, 3), 3158 /* 0010 */ PTR(228, 3), 3159 /* 0011 */ PTR(236, 3), 3160 /* 0100 */ PTR(244, 2), 3161 /* 0101 */ PTR(248, 2), 3162 /* 0110 */ PTR(252, 2), 3163 /* 0111 */ PTR(256, 2), 3164 /* 1000 */ PTR(260, 2), 3165 /* 1001 */ PTR(264, 2), 3166 /* 1010 */ PTR(268, 2), 3167 /* 1011 */ PTR(272, 2), 3168 /* 1100 */ PTR(276, 2), 3169 /* 1101 */ PTR(280, 3), 3170 /* 1110 */ PTR(288, 2), 3171 /* 1111 */ PTR(292, 2), 3172 3173 /* 0101 ... */ 3174 /* 0000 */ PTR(296, 2), /* 80 */ 3175 /* 0001 */ PTR(300, 3), 3176 /* 0010 */ PTR(308, 2), 3177 /* 0011 */ PTR(312, 3), 3178 /* 0100 */ PTR(320, 1), 3179 /* 0101 */ PTR(322, 2), 3180 /* 0110 */ PTR(326, 2), 3181 /* 0111 */ PTR(330, 1), 3182 /* 1000 */ PTR(332, 2), 3183 /* 1001 */ PTR(336, 1), 3184 /* 1010 */ PTR(338, 1), 3185 /* 1011 */ PTR(340, 1), 3186 /* 1100 */ PTR(342, 1), 3187 /* 1101 */ PTR(344, 1), 3188 /* 1110 */ PTR(346, 1), 3189 /* 1111 */ PTR(348, 1), 3190 3191 /* 0110 ... */ 3192 /* 0000 */ PTR(350, 1), /* 96 */ 3193 /* 0001 */ PTR(352, 1), 3194 /* 0010 */ PTR(354, 1), 3195 /* 0011 */ PTR(356, 1), 3196 /* 0100 */ PTR(358, 1), 3197 /* 0101 */ PTR(360, 1), 3198 /* 0110 */ PTR(362, 1), 3199 /* 0111 */ PTR(364, 1), 3200 /* 1000 */ PTR(366, 1), 3201 /* 1001 */ PTR(368, 1), 3202 /* 1010 */ PTR(370, 2), 3203 /* 1011 */ PTR(374, 1), 3204 /* 1100 */ PTR(376, 2), 3205 /* 1101 */ V(7, 3, 4), 3206 /* 1110 */ PTR(380, 1), 3207 /* 1111 */ V(7, 2, 4), 3208 3209 /* 0111 ... */ 3210 /* 0000 */ V(4, 6, 4), /* 112 */ 3211 /* 0001 */ V(6, 4, 4), 3212 /* 0010 */ V(5, 5, 4), 3213 /* 0011 */ V(7, 1, 4), 3214 /* 0100 */ V(3, 6, 4), 3215 /* 0101 */ V(6, 3, 4), 3216 /* 0110 */ V(4, 5, 4), 3217 /* 0111 */ V(5, 4, 4), 3218 /* 1000 */ V(2, 6, 4), 3219 /* 1001 */ V(6, 2, 4), 3220 /* 1010 */ V(1, 6, 4), 3221 /* 1011 */ V(6, 1, 4), 3222 /* 1100 */ PTR(382, 1), 3223 /* 1101 */ V(3, 5, 4), 3224 /* 1110 */ V(5, 3, 4), 3225 /* 1111 */ V(4, 4, 4), 3226 3227 /* 1000 ... */ 3228 /* 0000 */ V(2, 5, 4), /* 128 */ 3229 /* 0001 */ V(5, 2, 4), 3230 /* 0010 */ V(1, 5, 4), 3231 /* 0011 */ PTR(384, 1), 3232 /* 0100 */ V(5, 1, 3), 3233 /* 0101 */ V(5, 1, 3), 3234 /* 0110 */ V(3, 4, 4), 3235 /* 0111 */ V(4, 3, 4), 3236 /* 1000 */ V(2, 4, 3), 3237 /* 1001 */ V(2, 4, 3), 3238 /* 1010 */ V(4, 2, 3), 3239 /* 1011 */ V(4, 2, 3), 3240 /* 1100 */ V(3, 3, 3), 3241 /* 1101 */ V(3, 3, 3), 3242 /* 1110 */ V(1, 4, 3), 3243 /* 1111 */ V(1, 4, 3), 3244 3245 /* 1001 ... */ 3246 /* 0000 */ V(4, 1, 3), /* 144 */ 3247 /* 0001 */ V(4, 1, 3), 3248 /* 0010 */ V(0, 4, 4), 3249 /* 0011 */ V(4, 0, 4), 3250 /* 0100 */ V(2, 3, 3), 3251 /* 0101 */ V(2, 3, 3), 3252 /* 0110 */ V(3, 2, 3), 3253 /* 0111 */ V(3, 2, 3), 3254 /* 1000 */ V(1, 3, 2), 3255 /* 1001 */ V(1, 3, 2), 3256 /* 1010 */ V(1, 3, 2), 3257 /* 1011 */ V(1, 3, 2), 3258 /* 1100 */ V(3, 1, 2), 3259 /* 1101 */ V(3, 1, 2), 3260 /* 1110 */ V(3, 1, 2), 3261 /* 1111 */ V(3, 1, 2), 3262 3263 /* 1010 ... */ 3264 /* 000 */ V(0, 3, 3), /* 160 */ 3265 /* 001 */ V(3, 0, 3), 3266 /* 010 */ V(2, 2, 2), 3267 /* 011 */ V(2, 2, 2), 3268 /* 100 */ V(1, 2, 1), 3269 /* 101 */ V(1, 2, 1), 3270 /* 110 */ V(1, 2, 1), 3271 /* 111 */ V(1, 2, 1), 3272 3273 /* 1011 ... */ 3274 /* 00 */ V(2, 1, 1), /* 168 */ 3275 /* 01 */ V(2, 1, 1), 3276 /* 10 */ V(0, 2, 2), 3277 /* 11 */ V(2, 0, 2), 3278 3279 /* 0010 1100 ... */ 3280 /* 000 */ V(0, 15, 1), /* 172 */ 3281 /* 001 */ V(0, 15, 1), 3282 /* 010 */ V(0, 15, 1), 3283 /* 011 */ V(0, 15, 1), 3284 /* 100 */ V(14, 14, 3), 3285 /* 101 */ V(13, 14, 3), 3286 /* 110 */ V(14, 13, 3), 3287 /* 111 */ V(12, 14, 3), 3288 3289 /* 0010 1101 ... */ 3290 /* 000 */ V(14, 12, 3), /* 180 */ 3291 /* 001 */ V(13, 13, 3), 3292 /* 010 */ V(11, 14, 3), 3293 /* 011 */ V(14, 11, 3), 3294 /* 100 */ V(12, 13, 3), 3295 /* 101 */ V(13, 12, 3), 3296 /* 110 */ V(10, 14, 3), 3297 /* 111 */ V(14, 10, 3), 3298 3299 /* 0010 1110 ... */ 3300 /* 000 */ V(11, 13, 3), /* 188 */ 3301 /* 001 */ V(13, 11, 3), 3302 /* 010 */ V(12, 12, 3), 3303 /* 011 */ V(9, 14, 3), 3304 /* 100 */ V(14, 9, 3), 3305 /* 101 */ V(10, 13, 3), 3306 /* 110 */ V(13, 10, 3), 3307 /* 111 */ V(11, 12, 3), 3308 3309 /* 0010 1111 ... */ 3310 /* 000 */ V(12, 11, 3), /* 196 */ 3311 /* 001 */ V(8, 14, 3), 3312 /* 010 */ V(14, 8, 3), 3313 /* 011 */ V(9, 13, 3), 3314 /* 100 */ V(13, 9, 3), 3315 /* 101 */ V(7, 14, 3), 3316 /* 110 */ V(14, 7, 3), 3317 /* 111 */ V(10, 12, 3), 3318 3319 /* 0100 0000 ... */ 3320 /* 0000 */ V(12, 10, 3), /* 204 */ 3321 /* 0001 */ V(12, 10, 3), 3322 /* 0010 */ V(11, 11, 3), 3323 /* 0011 */ V(11, 11, 3), 3324 /* 0100 */ V(8, 13, 3), 3325 /* 0101 */ V(8, 13, 3), 3326 /* 0110 */ V(13, 8, 3), 3327 /* 0111 */ V(13, 8, 3), 3328 /* 1000 */ V(0, 14, 4), 3329 /* 1001 */ V(14, 0, 4), 3330 /* 1010 */ V(0, 13, 3), 3331 /* 1011 */ V(0, 13, 3), 3332 /* 1100 */ V(14, 6, 2), 3333 /* 1101 */ V(14, 6, 2), 3334 /* 1110 */ V(14, 6, 2), 3335 /* 1111 */ V(14, 6, 2), 3336 3337 /* 0100 0001 ... */ 3338 /* 000 */ V(6, 14, 3), /* 220 */ 3339 /* 001 */ V(9, 12, 3), 3340 /* 010 */ V(12, 9, 2), 3341 /* 011 */ V(12, 9, 2), 3342 /* 100 */ V(5, 14, 2), 3343 /* 101 */ V(5, 14, 2), 3344 /* 110 */ V(11, 10, 2), 3345 /* 111 */ V(11, 10, 2), 3346 3347 /* 0100 0010 ... */ 3348 /* 000 */ V(14, 5, 2), /* 228 */ 3349 /* 001 */ V(14, 5, 2), 3350 /* 010 */ V(10, 11, 3), 3351 /* 011 */ V(7, 13, 3), 3352 /* 100 */ V(13, 7, 2), 3353 /* 101 */ V(13, 7, 2), 3354 /* 110 */ V(14, 4, 2), 3355 /* 111 */ V(14, 4, 2), 3356 3357 /* 0100 0011 ... */ 3358 /* 000 */ V(8, 12, 2), /* 236 */ 3359 /* 001 */ V(8, 12, 2), 3360 /* 010 */ V(12, 8, 2), 3361 /* 011 */ V(12, 8, 2), 3362 /* 100 */ V(4, 14, 3), 3363 /* 101 */ V(2, 14, 3), 3364 /* 110 */ V(3, 14, 2), 3365 /* 111 */ V(3, 14, 2), 3366 3367 /* 0100 0100 ... */ 3368 /* 00 */ V(6, 13, 2), /* 244 */ 3369 /* 01 */ V(13, 6, 2), 3370 /* 10 */ V(14, 3, 2), 3371 /* 11 */ V(9, 11, 2), 3372 3373 /* 0100 0101 ... */ 3374 /* 00 */ V(11, 9, 2), /* 248 */ 3375 /* 01 */ V(10, 10, 2), 3376 /* 10 */ V(14, 2, 2), 3377 /* 11 */ V(1, 14, 2), 3378 3379 /* 0100 0110 ... */ 3380 /* 00 */ V(14, 1, 2), /* 252 */ 3381 /* 01 */ V(5, 13, 2), 3382 /* 10 */ V(13, 5, 2), 3383 /* 11 */ V(7, 12, 2), 3384 3385 /* 0100 0111 ... */ 3386 /* 00 */ V(12, 7, 2), /* 256 */ 3387 /* 01 */ V(4, 13, 2), 3388 /* 10 */ V(8, 11, 2), 3389 /* 11 */ V(11, 8, 2), 3390 3391 /* 0100 1000 ... */ 3392 /* 00 */ V(13, 4, 2), /* 260 */ 3393 /* 01 */ V(9, 10, 2), 3394 /* 10 */ V(10, 9, 2), 3395 /* 11 */ V(6, 12, 2), 3396 3397 /* 0100 1001 ... */ 3398 /* 00 */ V(12, 6, 2), /* 264 */ 3399 /* 01 */ V(3, 13, 2), 3400 /* 10 */ V(13, 3, 2), 3401 /* 11 */ V(2, 13, 2), 3402 3403 /* 0100 1010 ... */ 3404 /* 00 */ V(13, 2, 2), /* 268 */ 3405 /* 01 */ V(1, 13, 2), 3406 /* 10 */ V(7, 11, 2), 3407 /* 11 */ V(11, 7, 2), 3408 3409 /* 0100 1011 ... */ 3410 /* 00 */ V(13, 1, 2), /* 272 */ 3411 /* 01 */ V(5, 12, 2), 3412 /* 10 */ V(12, 5, 2), 3413 /* 11 */ V(8, 10, 2), 3414 3415 /* 0100 1100 ... */ 3416 /* 00 */ V(10, 8, 2), /* 276 */ 3417 /* 01 */ V(9, 9, 2), 3418 /* 10 */ V(4, 12, 2), 3419 /* 11 */ V(12, 4, 2), 3420 3421 /* 0100 1101 ... */ 3422 /* 000 */ V(6, 11, 2), /* 280 */ 3423 /* 001 */ V(6, 11, 2), 3424 /* 010 */ V(11, 6, 2), 3425 /* 011 */ V(11, 6, 2), 3426 /* 100 */ V(13, 0, 3), 3427 /* 101 */ V(0, 12, 3), 3428 /* 110 */ V(3, 12, 2), 3429 /* 111 */ V(3, 12, 2), 3430 3431 /* 0100 1110 ... */ 3432 /* 00 */ V(12, 3, 2), /* 288 */ 3433 /* 01 */ V(7, 10, 2), 3434 /* 10 */ V(10, 7, 2), 3435 /* 11 */ V(2, 12, 2), 3436 3437 /* 0100 1111 ... */ 3438 /* 00 */ V(12, 2, 2), /* 292 */ 3439 /* 01 */ V(5, 11, 2), 3440 /* 10 */ V(11, 5, 2), 3441 /* 11 */ V(1, 12, 2), 3442 3443 /* 0101 0000 ... */ 3444 /* 00 */ V(8, 9, 2), /* 296 */ 3445 /* 01 */ V(9, 8, 2), 3446 /* 10 */ V(12, 1, 2), 3447 /* 11 */ V(4, 11, 2), 3448 3449 /* 0101 0001 ... */ 3450 /* 000 */ V(12, 0, 3), /* 300 */ 3451 /* 001 */ V(0, 11, 3), 3452 /* 010 */ V(3, 11, 2), 3453 /* 011 */ V(3, 11, 2), 3454 /* 100 */ V(11, 0, 3), 3455 /* 101 */ V(0, 10, 3), 3456 /* 110 */ V(1, 10, 2), 3457 /* 111 */ V(1, 10, 2), 3458 3459 /* 0101 0010 ... */ 3460 /* 00 */ V(11, 4, 1), /* 308 */ 3461 /* 01 */ V(11, 4, 1), 3462 /* 10 */ V(6, 10, 2), 3463 /* 11 */ V(10, 6, 2), 3464 3465 /* 0101 0011 ... */ 3466 /* 000 */ V(7, 9, 2), /* 312 */ 3467 /* 001 */ V(7, 9, 2), 3468 /* 010 */ V(9, 7, 2), 3469 /* 011 */ V(9, 7, 2), 3470 /* 100 */ V(10, 0, 3), 3471 /* 101 */ V(0, 9, 3), 3472 /* 110 */ V(9, 0, 2), 3473 /* 111 */ V(9, 0, 2), 3474 3475 /* 0101 0100 ... */ 3476 /* 0 */ V(11, 3, 1), /* 320 */ 3477 /* 1 */ V(8, 8, 1), 3478 3479 /* 0101 0101 ... */ 3480 /* 00 */ V(2, 11, 2), /* 322 */ 3481 /* 01 */ V(5, 10, 2), 3482 /* 10 */ V(11, 2, 1), 3483 /* 11 */ V(11, 2, 1), 3484 3485 /* 0101 0110 ... */ 3486 /* 00 */ V(10, 5, 2), /* 326 */ 3487 /* 01 */ V(1, 11, 2), 3488 /* 10 */ V(11, 1, 2), 3489 /* 11 */ V(6, 9, 2), 3490 3491 /* 0101 0111 ... */ 3492 /* 0 */ V(9, 6, 1), /* 330 */ 3493 /* 1 */ V(10, 4, 1), 3494 3495 /* 0101 1000 ... */ 3496 /* 00 */ V(4, 10, 2), /* 332 */ 3497 /* 01 */ V(7, 8, 2), 3498 /* 10 */ V(8, 7, 1), 3499 /* 11 */ V(8, 7, 1), 3500 3501 /* 0101 1001 ... */ 3502 /* 0 */ V(3, 10, 1), /* 336 */ 3503 /* 1 */ V(10, 3, 1), 3504 3505 /* 0101 1010 ... */ 3506 /* 0 */ V(5, 9, 1), /* 338 */ 3507 /* 1 */ V(9, 5, 1), 3508 3509 /* 0101 1011 ... */ 3510 /* 0 */ V(2, 10, 1), /* 340 */ 3511 /* 1 */ V(10, 2, 1), 3512 3513 /* 0101 1100 ... */ 3514 /* 0 */ V(10, 1, 1), /* 342 */ 3515 /* 1 */ V(6, 8, 1), 3516 3517 /* 0101 1101 ... */ 3518 /* 0 */ V(8, 6, 1), /* 344 */ 3519 /* 1 */ V(7, 7, 1), 3520 3521 /* 0101 1110 ... */ 3522 /* 0 */ V(4, 9, 1), /* 346 */ 3523 /* 1 */ V(9, 4, 1), 3524 3525 /* 0101 1111 ... */ 3526 /* 0 */ V(3, 9, 1), /* 348 */ 3527 /* 1 */ V(9, 3, 1), 3528 3529 /* 0110 0000 ... */ 3530 /* 0 */ V(5, 8, 1), /* 350 */ 3531 /* 1 */ V(8, 5, 1), 3532 3533 /* 0110 0001 ... */ 3534 /* 0 */ V(2, 9, 1), /* 352 */ 3535 /* 1 */ V(6, 7, 1), 3536 3537 /* 0110 0010 ... */ 3538 /* 0 */ V(7, 6, 1), /* 354 */ 3539 /* 1 */ V(9, 2, 1), 3540 3541 /* 0110 0011 ... */ 3542 /* 0 */ V(1, 9, 1), /* 356 */ 3543 /* 1 */ V(9, 1, 1), 3544 3545 /* 0110 0100 ... */ 3546 /* 0 */ V(4, 8, 1), /* 358 */ 3547 /* 1 */ V(8, 4, 1), 3548 3549 /* 0110 0101 ... */ 3550 /* 0 */ V(5, 7, 1), /* 360 */ 3551 /* 1 */ V(7, 5, 1), 3552 3553 /* 0110 0110 ... */ 3554 /* 0 */ V(3, 8, 1), /* 362 */ 3555 /* 1 */ V(8, 3, 1), 3556 3557 /* 0110 0111 ... */ 3558 /* 0 */ V(6, 6, 1), /* 364 */ 3559 /* 1 */ V(2, 8, 1), 3560 3561 /* 0110 1000 ... */ 3562 /* 0 */ V(8, 2, 1), /* 366 */ 3563 /* 1 */ V(1, 8, 1), 3564 3565 /* 0110 1001 ... */ 3566 /* 0 */ V(4, 7, 1), /* 368 */ 3567 /* 1 */ V(7, 4, 1), 3568 3569 /* 0110 1010 ... */ 3570 /* 00 */ V(8, 1, 1), /* 370 */ 3571 /* 01 */ V(8, 1, 1), 3572 /* 10 */ V(0, 8, 2), 3573 /* 11 */ V(8, 0, 2), 3574 3575 /* 0110 1011 ... */ 3576 /* 0 */ V(5, 6, 1), /* 374 */ 3577 /* 1 */ V(6, 5, 1), 3578 3579 /* 0110 1100 ... */ 3580 /* 00 */ V(1, 7, 1), /* 376 */ 3581 /* 01 */ V(1, 7, 1), 3582 /* 10 */ V(0, 7, 2), 3583 /* 11 */ V(7, 0, 2), 3584 3585 /* 0110 1110 ... */ 3586 /* 0 */ V(3, 7, 1), /* 380 */ 3587 /* 1 */ V(2, 7, 1), 3588 3589 /* 0111 1100 ... */ 3590 /* 0 */ V(0, 6, 1), /* 382 */ 3591 /* 1 */ V(6, 0, 1), 3592 3593 /* 1000 0011 ... */ 3594 /* 0 */ V(0, 5, 1), /* 384 */ 3595 /* 1 */ V(5, 0, 1) 3596]; 3597 3598/* hufftable constructor */ 3599function MP3Hufftable(table, linbits, startbits) { 3600 this.table = table; 3601 this.linbits = linbits; 3602 this.startbits = startbits; 3603}; 3604 3605/* external tables */ 3606exports.huff_quad_table = [ hufftabA, hufftabB ]; 3607exports.huff_pair_table = [ 3608 /* 0 */ new MP3Hufftable(hufftab0, 0, 0), 3609 /* 1 */ new MP3Hufftable(hufftab1, 0, 3), 3610 /* 2 */ new MP3Hufftable(hufftab2, 0, 3), 3611 /* 3 */ new MP3Hufftable(hufftab3, 0, 3), 3612 /* 4 */ null, //new MP3Hufftable(0 /* not used */), 3613 /* 5 */ new MP3Hufftable(hufftab5, 0, 3), 3614 /* 6 */ new MP3Hufftable(hufftab6, 0, 4), 3615 /* 7 */ new MP3Hufftable(hufftab7, 0, 4), 3616 /* 8 */ new MP3Hufftable(hufftab8, 0, 4), 3617 /* 9 */ new MP3Hufftable(hufftab9, 0, 4), 3618 /* 10 */ new MP3Hufftable(hufftab10, 0, 4), 3619 /* 11 */ new MP3Hufftable(hufftab11, 0, 4), 3620 /* 12 */ new MP3Hufftable(hufftab12, 0, 4), 3621 /* 13 */ new MP3Hufftable(hufftab13, 0, 4), 3622 /* 14 */ null, //new MP3Hufftable(0 /* not used */), 3623 /* 15 */ new MP3Hufftable(hufftab15, 0, 4), 3624 /* 16 */ new MP3Hufftable(hufftab16, 1, 4), 3625 /* 17 */ new MP3Hufftable(hufftab16, 2, 4), 3626 /* 18 */ new MP3Hufftable(hufftab16, 3, 4), 3627 /* 19 */ new MP3Hufftable(hufftab16, 4, 4), 3628 /* 20 */ new MP3Hufftable(hufftab16, 6, 4), 3629 /* 21 */ new MP3Hufftable(hufftab16, 8, 4), 3630 /* 22 */ new MP3Hufftable(hufftab16, 10, 4), 3631 /* 23 */ new MP3Hufftable(hufftab16, 13, 4), 3632 /* 24 */ new MP3Hufftable(hufftab24, 4, 4), 3633 /* 25 */ new MP3Hufftable(hufftab24, 5, 4), 3634 /* 26 */ new MP3Hufftable(hufftab24, 6, 4), 3635 /* 27 */ new MP3Hufftable(hufftab24, 7, 4), 3636 /* 28 */ new MP3Hufftable(hufftab24, 8, 4), 3637 /* 29 */ new MP3Hufftable(hufftab24, 9, 4), 3638 /* 30 */ new MP3Hufftable(hufftab24, 11, 4), 3639 /* 31 */ new MP3Hufftable(hufftab24, 13, 4) 3640]; 3641 3642},{}],7:[function(require,module,exports){ 3643var AV = (window.AV); 3644 3645const ENCODINGS = ['latin1', 'utf16-bom', 'utf16-be', 'utf8']; 3646 3647var ID3Stream = AV.Base.extend({ 3648 constructor: function(header, stream) { 3649 this.header = header; 3650 this.stream = stream; 3651 this.offset = 0; 3652 }, 3653 3654 read: function() { 3655 if (!this.data) { 3656 this.data = {}; 3657 3658 // read all frames 3659 var frame; 3660 while (frame = this.readFrame()) { 3661 // if we already have an instance of this key, add it to an array 3662 if (frame.key in this.data) { 3663 if (!Array.isArray(this.data[frame.key])) 3664 this.data[frame.key] = [this.data[frame.key]]; 3665 3666 this.data[frame.key].push(frame.value); 3667 } else { 3668 this.data[frame.key] = frame.value; 3669 } 3670 } 3671 } 3672 3673 return this.data; 3674 }, 3675 3676 readFrame: function() { 3677 if (this.offset >= this.header.length) 3678 return null; 3679 3680 // get the header 3681 var header = this.readHeader(); 3682 var decoder = header.identifier; 3683 3684 if (header.identifier.charCodeAt(0) === 0) { 3685 this.offset += this.header.length + 1; 3686 return null; 3687 } 3688 3689 // map common frame names to a single type 3690 if (!this.frameTypes[decoder]) { 3691 for (var key in this.map) { 3692 if (this.map[key].indexOf(decoder) !== -1) { 3693 decoder = key; 3694 break; 3695 } 3696 } 3697 } 3698 3699 if (this.frameTypes[decoder]) { 3700 // decode the frame 3701 var frame = this.decodeFrame(header, this.frameTypes[decoder]), 3702 keys = Object.keys(frame); 3703 3704 // if it only returned one key, use that as the value 3705 if (keys.length === 1) 3706 frame = frame[keys[0]]; 3707 3708 var result = { 3709 value: frame 3710 }; 3711 3712 } else { 3713 // No frame type found, treat it as binary 3714 var result = { 3715 value: this.stream.readBuffer(Math.min(header.length, this.header.length - this.offset)) 3716 }; 3717 } 3718 3719 result.key = this.names[header.identifier] ? this.names[header.identifier] : header.identifier; 3720 3721 // special sauce for cover art, which should just be a buffer 3722 if (result.key === 'coverArt') 3723 result.value = result.value.data; 3724 3725 this.offset += 10 + header.length; 3726 return result; 3727 }, 3728 3729 decodeFrame: function(header, fields) { 3730 var stream = this.stream, 3731 start = stream.offset; 3732 3733 var encoding = 0, ret = {}; 3734 var len = Object.keys(fields).length, i = 0; 3735 3736 for (var key in fields) { 3737 var type = fields[key]; 3738 var rest = header.length - (stream.offset - start); 3739 i++; 3740 3741 // check for special field names 3742 switch (key) { 3743 case 'encoding': 3744 encoding = stream.readUInt8(); 3745 continue; 3746 3747 case 'language': 3748 ret.language = stream.readString(3); 3749 continue; 3750 } 3751 3752 // check types 3753 switch (type) { 3754 case 'latin1': 3755 ret[key] = stream.readString(i === len ? rest : null, 'latin1'); 3756 break; 3757 3758 case 'string': 3759 ret[key] = stream.readString(i === len ? rest : null, ENCODINGS[encoding]); 3760 break; 3761 3762 case 'binary': 3763 ret[key] = stream.readBuffer(rest) 3764 break; 3765 3766 case 'int16': 3767 ret[key] = stream.readInt16(); 3768 break; 3769 3770 case 'int8': 3771 ret[key] = stream.readInt8(); 3772 break; 3773 3774 case 'int24': 3775 ret[key] = stream.readInt24(); 3776 break; 3777 3778 case 'int32': 3779 ret[key] = stream.readInt32(); 3780 break; 3781 3782 case 'int32+': 3783 ret[key] = stream.readInt32(); 3784 if (rest > 4) 3785 throw new Error('Seriously dude? Stop playing this song and get a life!'); 3786 3787 break; 3788 3789 case 'date': 3790 var val = stream.readString(8); 3791 ret[key] = new Date(val.slice(0, 4), val.slice(4, 6) - 1, val.slice(6, 8)); 3792 break; 3793 3794 case 'frame_id': 3795 ret[key] = stream.readString(4); 3796 break; 3797 3798 default: 3799 throw new Error('Unknown key type ' + type); 3800 } 3801 } 3802 3803 // Just in case something went wrong... 3804 var rest = header.length - (stream.offset - start); 3805 if (rest > 0) 3806 stream.advance(rest); 3807 3808 return ret; 3809 } 3810}); 3811 3812// ID3 v2.3 and v2.4 support 3813exports.ID3v23Stream = ID3Stream.extend({ 3814 readHeader: function() { 3815 var identifier = this.stream.readString(4); 3816 var length = 0; 3817 3818 if (this.header.major === 4) { 3819 for (var i = 0; i < 4; i++) 3820 length = (length << 7) + (this.stream.readUInt8() & 0x7f); 3821 } else { 3822 length = this.stream.readUInt32(); 3823 } 3824 3825 return { 3826 identifier: identifier, 3827 length: length, 3828 flags: this.stream.readUInt16() 3829 }; 3830 }, 3831 3832 map: { 3833 text: [ 3834 // Identification Frames 3835 'TIT1', 'TIT2', 'TIT3', 'TALB', 'TOAL', 'TRCK', 'TPOS', 'TSST', 'TSRC', 3836 3837 // Involved Persons Frames 3838 'TPE1', 'TPE2', 'TPE3', 'TPE4', 'TOPE', 'TEXT', 'TOLY', 'TCOM', 'TMCL', 'TIPL', 'TENC', 3839 3840 // Derived and Subjective Properties Frames 3841 'TBPM', 'TLEN', 'TKEY', 'TLAN', 'TCON', 'TFLT', 'TMED', 'TMOO', 3842 3843 // Rights and Licence Frames 3844 'TCOP', 'TPRO', 'TPUB', 'TOWN', 'TRSN', 'TRSO', 3845 3846 // Other Text Frames 3847 'TOFN', 'TDLY', 'TDEN', 'TDOR', 'TDRC', 'TDRL', 'TDTG', 'TSSE', 'TSOA', 'TSOP', 'TSOT', 3848 3849 // Deprecated Text Frames 3850 'TDAT', 'TIME', 'TORY', 'TRDA', 'TSIZ', 'TYER', 3851 3852 // Non-standard iTunes Frames 3853 'TCMP', 'TSO2', 'TSOC' 3854 ], 3855 3856 url: [ 3857 'WCOM', 'WCOP', 'WOAF', 'WOAR', 'WOAS', 'WORS', 'WPAY', 'WPUB' 3858 ] 3859 }, 3860 3861 frameTypes: { 3862 text: { 3863 encoding: 1, 3864 value: 'string' 3865 }, 3866 3867 url: { 3868 value: 'latin1' 3869 }, 3870 3871 TXXX: { 3872 encoding: 1, 3873 description: 'string', 3874 value: 'string' 3875 }, 3876 3877 WXXX: { 3878 encoding: 1, 3879 description: 'string', 3880 value: 'latin1', 3881 }, 3882 3883 USLT: { 3884 encoding: 1, 3885 language: 1, 3886 description: 'string', 3887 value: 'string' 3888 }, 3889 3890 COMM: { 3891 encoding: 1, 3892 language: 1, 3893 description: 'string', 3894 value: 'string' 3895 }, 3896 3897 APIC: { 3898 encoding: 1, 3899 mime: 'latin1', 3900 type: 'int8', 3901 description: 'string', 3902 data: 'binary' 3903 }, 3904 3905 UFID: { 3906 owner: 'latin1', 3907 identifier: 'binary' 3908 }, 3909 3910 MCDI: { 3911 value: 'binary' 3912 }, 3913 3914 PRIV: { 3915 owner: 'latin1', 3916 value: 'binary' 3917 }, 3918 3919 GEOB: { 3920 encoding: 1, 3921 mime: 'latin1', 3922 filename: 'string', 3923 description: 'string', 3924 data: 'binary' 3925 }, 3926 3927 PCNT: { 3928 value: 'int32+' 3929 }, 3930 3931 POPM: { 3932 email: 'latin1', 3933 rating: 'int8', 3934 counter: 'int32+' 3935 }, 3936 3937 AENC: { 3938 owner: 'latin1', 3939 previewStart: 'int16', 3940 previewLength: 'int16', 3941 encryptionInfo: 'binary' 3942 }, 3943 3944 ETCO: { 3945 format: 'int8', 3946 data: 'binary' // TODO 3947 }, 3948 3949 MLLT: { 3950 framesBetweenReference: 'int16', 3951 bytesBetweenReference: 'int24', 3952 millisecondsBetweenReference: 'int24', 3953 bitsForBytesDeviation: 'int8', 3954 bitsForMillisecondsDev: 'int8', 3955 data: 'binary' // TODO 3956 }, 3957 3958 SYTC: { 3959 format: 'int8', 3960 tempoData: 'binary' // TODO 3961 }, 3962 3963 SYLT: { 3964 encoding: 1, 3965 language: 1, 3966 format: 'int8', 3967 contentType: 'int8', 3968 description: 'string', 3969 data: 'binary' // TODO 3970 }, 3971 3972 RVA2: { 3973 identification: 'latin1', 3974 data: 'binary' // TODO 3975 }, 3976 3977 EQU2: { 3978 interpolationMethod: 'int8', 3979 identification: 'latin1', 3980 data: 'binary' // TODO 3981 }, 3982 3983 RVRB: { 3984 left: 'int16', 3985 right: 'int16', 3986 bouncesLeft: 'int8', 3987 bouncesRight: 'int8', 3988 feedbackLL: 'int8', 3989 feedbackLR: 'int8', 3990 feedbackRR: 'int8', 3991 feedbackRL: 'int8', 3992 premixLR: 'int8', 3993 premixRL: 'int8' 3994 }, 3995 3996 RBUF: { 3997 size: 'int24', 3998 flag: 'int8', 3999 offset: 'int32' 4000 }, 4001 4002 LINK: { 4003 identifier: 'frame_id', 4004 url: 'latin1', 4005 data: 'binary' // TODO stringlist? 4006 }, 4007 4008 POSS: { 4009 format: 'int8', 4010 position: 'binary' // TODO 4011 }, 4012 4013 USER: { 4014 encoding: 1, 4015 language: 1, 4016 value: 'string' 4017 }, 4018 4019 OWNE: { 4020 encoding: 1, 4021 price: 'latin1', 4022 purchaseDate: 'date', 4023 seller: 'string' 4024 }, 4025 4026 COMR: { 4027 encoding: 1, 4028 price: 'latin1', 4029 validUntil: 'date', 4030 contactURL: 'latin1', 4031 receivedAs: 'int8', 4032 seller: 'string', 4033 description: 'string', 4034 logoMime: 'latin1', 4035 logo: 'binary' 4036 }, 4037 4038 ENCR: { 4039 owner: 'latin1', 4040 methodSymbol: 'int8', 4041 data: 'binary' 4042 }, 4043 4044 GRID: { 4045 owner: 'latin1', 4046 groupSymbol: 'int8', 4047 data: 'binary' 4048 }, 4049 4050 SIGN: { 4051 groupSymbol: 'int8', 4052 signature: 'binary' 4053 }, 4054 4055 SEEK: { 4056 value: 'int32' 4057 }, 4058 4059 ASPI: { 4060 dataStart: 'int32', 4061 dataLength: 'int32', 4062 numPoints: 'int16', 4063 bitsPerPoint: 'int8', 4064 data: 'binary' // TODO 4065 }, 4066 4067 // Deprecated ID3 v2.3 frames 4068 IPLS: { 4069 encoding: 1, 4070 value: 'string' // list? 4071 }, 4072 4073 RVAD: { 4074 adjustment: 'int8', 4075 bits: 'int8', 4076 data: 'binary' // TODO 4077 }, 4078 4079 EQUA: { 4080 adjustmentBits: 'int8', 4081 data: 'binary' // TODO 4082 } 4083 }, 4084 4085 names: { 4086 // Identification Frames 4087 'TIT1': 'grouping', 4088 'TIT2': 'title', 4089 'TIT3': 'subtitle', 4090 'TALB': 'album', 4091 'TOAL': 'originalAlbumTitle', 4092 'TRCK': 'trackNumber', 4093 'TPOS': 'diskNumber', 4094 'TSST': 'setSubtitle', 4095 'TSRC': 'ISRC', 4096 4097 // Involved Persons Frames 4098 'TPE1': 'artist', 4099 'TPE2': 'albumArtist', 4100 'TPE3': 'conductor', 4101 'TPE4': 'modifiedBy', 4102 'TOPE': 'originalArtist', 4103 'TEXT': 'lyricist', 4104 'TOLY': 'originalLyricist', 4105 'TCOM': 'composer', 4106 'TMCL': 'musicianCreditsList', 4107 'TIPL': 'involvedPeopleList', 4108 'TENC': 'encodedBy', 4109 4110 // Derived and Subjective Properties Frames 4111 'TBPM': 'tempo', 4112 'TLEN': 'length', 4113 'TKEY': 'initialKey', 4114 'TLAN': 'language', 4115 'TCON': 'genre', 4116 'TFLT': 'fileType', 4117 'TMED': 'mediaType', 4118 'TMOO': 'mood', 4119 4120 // Rights and Licence Frames 4121 'TCOP': 'copyright', 4122 'TPRO': 'producedNotice', 4123 'TPUB': 'publisher', 4124 'TOWN': 'fileOwner', 4125 'TRSN': 'internetRadioStationName', 4126 'TRSO': 'internetRadioStationOwner', 4127 4128 // Other Text Frames 4129 'TOFN': 'originalFilename', 4130 'TDLY': 'playlistDelay', 4131 'TDEN': 'encodingTime', 4132 'TDOR': 'originalReleaseTime', 4133 'TDRC': 'recordingTime', 4134 'TDRL': 'releaseTime', 4135 'TDTG': 'taggingTime', 4136 'TSSE': 'encodedWith', 4137 'TSOA': 'albumSortOrder', 4138 'TSOP': 'performerSortOrder', 4139 'TSOT': 'titleSortOrder', 4140 4141 // User defined text information 4142 'TXXX': 'userText', 4143 4144 // Unsynchronised lyrics/text transcription 4145 'USLT': 'lyrics', 4146 4147 // Attached Picture Frame 4148 'APIC': 'coverArt', 4149 4150 // Unique Identifier Frame 4151 'UFID': 'uniqueIdentifier', 4152 4153 // Music CD Identifier Frame 4154 'MCDI': 'CDIdentifier', 4155 4156 // Comment Frame 4157 'COMM': 'comments', 4158 4159 // URL link frames 4160 'WCOM': 'commercialInformation', 4161 'WCOP': 'copyrightInformation', 4162 'WOAF': 'officialAudioFileWebpage', 4163 'WOAR': 'officialArtistWebpage', 4164 'WOAS': 'officialAudioSourceWebpage', 4165 'WORS': 'officialInternetRadioStationHomepage', 4166 'WPAY': 'payment', 4167 'WPUB': 'officialPublisherWebpage', 4168 4169 // User Defined URL Link Frame 4170 'WXXX': 'url', 4171 4172 'PRIV': 'private', 4173 'GEOB': 'generalEncapsulatedObject', 4174 'PCNT': 'playCount', 4175 'POPM': 'rating', 4176 'AENC': 'audioEncryption', 4177 'ETCO': 'eventTimingCodes', 4178 'MLLT': 'MPEGLocationLookupTable', 4179 'SYTC': 'synchronisedTempoCodes', 4180 'SYLT': 'synchronisedLyrics', 4181 'RVA2': 'volumeAdjustment', 4182 'EQU2': 'equalization', 4183 'RVRB': 'reverb', 4184 'RBUF': 'recommendedBufferSize', 4185 'LINK': 'link', 4186 'POSS': 'positionSynchronisation', 4187 'USER': 'termsOfUse', 4188 'OWNE': 'ownership', 4189 'COMR': 'commercial', 4190 'ENCR': 'encryption', 4191 'GRID': 'groupIdentifier', 4192 'SIGN': 'signature', 4193 'SEEK': 'seek', 4194 'ASPI': 'audioSeekPointIndex', 4195 4196 // Deprecated ID3 v2.3 frames 4197 'TDAT': 'date', 4198 'TIME': 'time', 4199 'TORY': 'originalReleaseYear', 4200 'TRDA': 'recordingDates', 4201 'TSIZ': 'size', 4202 'TYER': 'year', 4203 'IPLS': 'involvedPeopleList', 4204 'RVAD': 'volumeAdjustment', 4205 'EQUA': 'equalization', 4206 4207 // Non-standard iTunes frames 4208 'TCMP': 'compilation', 4209 'TSO2': 'albumArtistSortOrder', 4210 'TSOC': 'composerSortOrder' 4211 } 4212}); 4213 4214// ID3 v2.2 support 4215exports.ID3v22Stream = exports.ID3v23Stream.extend({ 4216 readHeader: function() { 4217 var id = this.stream.readString(3); 4218 4219 if (this.frameReplacements[id] && !this.frameTypes[id]) 4220 this.frameTypes[id] = this.frameReplacements[id]; 4221 4222 return { 4223 identifier: this.replacements[id] || id, 4224 length: this.stream.readUInt24() 4225 }; 4226 }, 4227 4228 // map 3 char ID3 v2.2 names to 4 char ID3 v2.3/4 names 4229 replacements: { 4230 'UFI': 'UFID', 4231 'TT1': 'TIT1', 4232 'TT2': 'TIT2', 4233 'TT3': 'TIT3', 4234 'TP1': 'TPE1', 4235 'TP2': 'TPE2', 4236 'TP3': 'TPE3', 4237 'TP4': 'TPE4', 4238 'TCM': 'TCOM', 4239 'TXT': 'TEXT', 4240 'TLA': 'TLAN', 4241 'TCO': 'TCON', 4242 'TAL': 'TALB', 4243 'TPA': 'TPOS', 4244 'TRK': 'TRCK', 4245 'TRC': 'TSRC', 4246 'TYE': 'TYER', 4247 'TDA': 'TDAT', 4248 'TIM': 'TIME', 4249 'TRD': 'TRDA', 4250 'TMT': 'TMED', 4251 'TFT': 'TFLT', 4252 'TBP': 'TBPM', 4253 'TCR': 'TCOP', 4254 'TPB': 'TPUB', 4255 'TEN': 'TENC', 4256 'TSS': 'TSSE', 4257 'TOF': 'TOFN', 4258 'TLE': 'TLEN', 4259 'TSI': 'TSIZ', 4260 'TDY': 'TDLY', 4261 'TKE': 'TKEY', 4262 'TOT': 'TOAL', 4263 'TOA': 'TOPE', 4264 'TOL': 'TOLY', 4265 'TOR': 'TORY', 4266 'TXX': 'TXXX', 4267 4268 'WAF': 'WOAF', 4269 'WAR': 'WOAR', 4270 'WAS': 'WOAS', 4271 'WCM': 'WCOM', 4272 'WCP': 'WCOP', 4273 'WPB': 'WPUB', 4274 'WXX': 'WXXX', 4275 4276 'IPL': 'IPLS', 4277 'MCI': 'MCDI', 4278 'ETC': 'ETCO', 4279 'MLL': 'MLLT', 4280 'STC': 'SYTC', 4281 'ULT': 'USLT', 4282 'SLT': 'SYLT', 4283 'COM': 'COMM', 4284 'RVA': 'RVAD', 4285 'EQU': 'EQUA', 4286 'REV': 'RVRB', 4287 4288 'GEO': 'GEOB', 4289 'CNT': 'PCNT', 4290 'POP': 'POPM', 4291 'BUF': 'RBUF', 4292 'CRA': 'AENC', 4293 'LNK': 'LINK', 4294 4295 // iTunes stuff 4296 'TST': 'TSOT', 4297 'TSP': 'TSOP', 4298 'TSA': 'TSOA', 4299 'TCP': 'TCMP', 4300 'TS2': 'TSO2', 4301 'TSC': 'TSOC' 4302 }, 4303 4304 // replacements for ID3 v2.3/4 frames 4305 frameReplacements: { 4306 PIC: { 4307 encoding: 1, 4308 format: 'int24', 4309 type: 'int8', 4310 description: 'string', 4311 data: 'binary' 4312 }, 4313 4314 CRM: { 4315 owner: 'latin1', 4316 description: 'latin1', 4317 data: 'binary' 4318 } 4319 } 4320}); 4321},{}],8:[function(require,module,exports){ 4322function IMDCT() { 4323 this.tmp_imdct36 = new Float64Array(18); 4324 this.tmp_dctIV = new Float64Array(18); 4325 this.tmp_sdctII = new Float64Array(9); 4326} 4327 4328// perform X[18]->x[36] IMDCT using Szu-Wei Lee's fast algorithm 4329IMDCT.prototype.imdct36 = function(x, y) { 4330 var tmp = this.tmp_imdct36; 4331 4332 /* DCT-IV */ 4333 this.dctIV(x, tmp); 4334 4335 // convert 18-point DCT-IV to 36-point IMDCT 4336 for (var i = 0; i < 9; ++i) { 4337 y[i] = tmp[9 + i]; 4338 } 4339 for (var i = 9; i < 27; ++i) { 4340 y[i] = -tmp[36 - (9 + i) - 1]; 4341 } 4342 for (var i = 27; i < 36; ++i) { 4343 y[i] = -tmp[i - 27]; 4344 } 4345}; 4346 4347var dctIV_scale = []; 4348for(i = 0; i < 18; i++) { 4349 dctIV_scale[i] = 2 * Math.cos(Math.PI * (2 * i + 1) / (4 * 18)); 4350} 4351 4352IMDCT.prototype.dctIV = function(y, X) { 4353 var tmp = this.tmp_dctIV; 4354 4355 // scaling 4356 for (var i = 0; i < 18; ++i) { 4357 tmp[i] = y[i] * dctIV_scale[i]; 4358 } 4359 4360 // SDCT-II 4361 this.sdctII(tmp, X); 4362 4363 // scale reduction and output accumulation 4364 X[0] /= 2; 4365 for (var i = 1; i < 18; ++i) { 4366 X[i] = X[i] / 2 - X[i - 1]; 4367 } 4368}; 4369 4370var sdctII_scale = []; 4371for (var i = 0; i < 9; ++i) { 4372 sdctII_scale[i] = 2 * Math.cos(Math.PI * (2 * i + 1) / (2 * 18)); 4373} 4374 4375IMDCT.prototype.sdctII = function(x, X) { 4376 // divide the 18-point SDCT-II into two 9-point SDCT-IIs 4377 var tmp = this.tmp_sdctII; 4378 4379 // even input butterfly 4380 for (var i = 0; i < 9; ++i) { 4381 tmp[i] = x[i] + x[18 - i - 1]; 4382 } 4383 4384 fastsdct(tmp, X, 0); 4385 4386 // odd input butterfly and scaling 4387 for (var i = 0; i < 9; ++i) { 4388 tmp[i] = (x[i] - x[18 - i - 1]) * sdctII_scale[i]; 4389 } 4390 4391 fastsdct(tmp, X, 1); 4392 4393 // output accumulation 4394 for (var i = 3; i < 18; i += 2) { 4395 X[i] -= X[i - 2]; 4396 } 4397}; 4398 4399var c0 = 2 * Math.cos( 1 * Math.PI / 18); 4400var c1 = 2 * Math.cos( 3 * Math.PI / 18); 4401var c2 = 2 * Math.cos( 4 * Math.PI / 18); 4402var c3 = 2 * Math.cos( 5 * Math.PI / 18); 4403var c4 = 2 * Math.cos( 7 * Math.PI / 18); 4404var c5 = 2 * Math.cos( 8 * Math.PI / 18); 4405var c6 = 2 * Math.cos(16 * Math.PI / 18); 4406 4407function fastsdct(x, y, offset) { 4408 var a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12; 4409 var a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25; 4410 var m0, m1, m2, m3, m4, m5, m6, m7; 4411 4412 a0 = x[3] + x[5]; 4413 a1 = x[3] - x[5]; 4414 a2 = x[6] + x[2]; 4415 a3 = x[6] - x[2]; 4416 a4 = x[1] + x[7]; 4417 a5 = x[1] - x[7]; 4418 a6 = x[8] + x[0]; 4419 a7 = x[8] - x[0]; 4420 4421 a8 = a0 + a2; 4422 a9 = a0 - a2; 4423 a10 = a0 - a6; 4424 a11 = a2 - a6; 4425 a12 = a8 + a6; 4426 a13 = a1 - a3; 4427 a14 = a13 + a7; 4428 a15 = a3 + a7; 4429 a16 = a1 - a7; 4430 a17 = a1 + a3; 4431 4432 m0 = a17 * -c3; 4433 m1 = a16 * -c0; 4434 m2 = a15 * -c4; 4435 m3 = a14 * -c1; 4436 m4 = a5 * -c1; 4437 m5 = a11 * -c6; 4438 m6 = a10 * -c5; 4439 m7 = a9 * -c2; 4440 4441 a18 = x[4] + a4; 4442 a19 = 2 * x[4] - a4; 4443 a20 = a19 + m5; 4444 a21 = a19 - m5; 4445 a22 = a19 + m6; 4446 a23 = m4 + m2; 4447 a24 = m4 - m2; 4448 a25 = m4 + m1; 4449 4450 // output to every other slot for convenience 4451 y[offset + 0] = a18 + a12; 4452 y[offset + 2] = m0 - a25; 4453 y[offset + 4] = m7 - a20; 4454 y[offset + 6] = m3; 4455 y[offset + 8] = a21 - m6; 4456 y[offset + 10] = a24 - m1; 4457 y[offset + 12] = a12 - 2 * a18; 4458 y[offset + 14] = a23 + m0; 4459 y[offset + 16] = a22 + m7; 4460} 4461 4462IMDCT.S = [ 4463 /* 0 */ [ 0.608761429, 4464 -0.923879533, 4465 -0.130526192, 4466 0.991444861, 4467 -0.382683432, 4468 -0.793353340 ], 4469 4470 /* 6 */ [ -0.793353340, 4471 0.382683432, 4472 0.991444861, 4473 0.130526192, 4474 -0.923879533, 4475 -0.608761429 ], 4476 4477 /* 1 */ [ 0.382683432, 4478 -0.923879533, 4479 0.923879533, 4480 -0.382683432, 4481 -0.382683432, 4482 0.923879533 ], 4483 4484 /* 7 */ [ -0.923879533, 4485 -0.382683432, 4486 0.382683432, 4487 0.923879533, 4488 0.923879533, 4489 0.382683432 ], 4490 4491 /* 2 */ [ 0.130526192, 4492 -0.382683432, 4493 0.608761429, 4494 -0.793353340, 4495 0.923879533, 4496 -0.991444861 ], 4497 4498 /* 8 */ [ -0.991444861, 4499 -0.923879533, 4500 -0.793353340, 4501 -0.608761429, 4502 -0.382683432, 4503 -0.130526192 ] 4504]; 4505 4506module.exports = IMDCT; 4507 4508},{}],9:[function(require,module,exports){ 4509var tables = require('./tables'); 4510var MP3FrameHeader = require('./header'); 4511var MP3Frame = require('./frame'); 4512var utils = require('./utils'); 4513 4514function Layer1() { 4515 this.allocation = utils.makeArray([2, 32], Uint8Array); 4516 this.scalefactor = utils.makeArray([2, 32], Uint8Array); 4517} 4518 4519MP3Frame.layers[1] = Layer1; 4520 4521// linear scaling table 4522const LINEAR_TABLE = new Float32Array([ 4523 1.33333333333333, 1.14285714285714, 1.06666666666667, 4524 1.03225806451613, 1.01587301587302, 1.00787401574803, 4525 1.00392156862745, 1.00195694716243, 1.00097751710655, 4526 1.00048851978505, 1.00024420024420, 1.00012208521548, 4527 1.00006103888177, 1.00003051850948 4528]); 4529 4530Layer1.prototype.decode = function(stream, frame) { 4531 var header = frame.header; 4532 var nch = header.nchannels(); 4533 4534 var bound = 32; 4535 if (header.mode === MP3FrameHeader.MODE.JOINT_STEREO) { 4536 header.flags |= MP3FrameHeader.FLAGS.I_STEREO; 4537 bound = 4 + header.mode_extension * 4; 4538 } 4539 4540 if (header.flags & MP3FrameHeader.FLAGS.PROTECTION) { 4541 // TODO: crc check 4542 } 4543 4544 // decode bit allocations 4545 var allocation = this.allocation; 4546 for (var sb = 0; sb < bound; sb++) { 4547 for (var ch = 0; ch < nch; ch++) { 4548 var nb = stream.read(4); 4549 if (nb === 15) 4550 throw new Error("forbidden bit allocation value"); 4551 4552 allocation[ch][sb] = nb ? nb + 1 : 0; 4553 } 4554 } 4555 4556 for (var sb = bound; sb < 32; sb++) { 4557 var nb = stream.read(4); 4558 if (nb === 15) 4559 throw new Error("forbidden bit allocation value"); 4560 4561 allocation[0][sb] = 4562 allocation[1][sb] = nb ? nb + 1 : 0; 4563 } 4564 4565 // decode scalefactors 4566 var scalefactor = this.scalefactor; 4567 for (var sb = 0; sb < 32; sb++) { 4568 for (var ch = 0; ch < nch; ch++) { 4569 if (allocation[ch][sb]) { 4570 scalefactor[ch][sb] = stream.read(6); 4571 4572 /* 4573 * Scalefactor index 63 does not appear in Table B.1 of 4574 * ISO/IEC 11172-3. Nonetheless, other implementations accept it, 4575 * so we do as well 4576 */ 4577 } 4578 } 4579 } 4580 4581 // decode samples 4582 for (var s = 0; s < 12; s++) { 4583 for (var sb = 0; sb < bound; sb++) { 4584 for (var ch = 0; ch < nch; ch++) { 4585 var nb = allocation[ch][sb]; 4586 frame.sbsample[ch][s][sb] = nb ? this.sample(stream, nb) * tables.SF_TABLE[scalefactor[ch][sb]] : 0; 4587 } 4588 } 4589 4590 for (var sb = bound; sb < 32; sb++) { 4591 var nb = allocation[0][sb]; 4592 if (nb) { 4593 var sample = this.sample(stream, nb); 4594 4595 for (var ch = 0; ch < nch; ch++) { 4596 frame.sbsample[ch][s][sb] = sample * tables.SF_TABLE[scalefactor[ch][sb]]; 4597 } 4598 } else { 4599 for (var ch = 0; ch < nch; ch++) { 4600 frame.sbsample[ch][s][sb] = 0; 4601 } 4602 } 4603 } 4604 } 4605}; 4606 4607Layer1.prototype.sample = function(stream, nb) { 4608 var sample = stream.read(nb); 4609 4610 // invert most significant bit, and form a 2's complement sample 4611 sample ^= 1 << (nb - 1); 4612 sample |= -(sample & (1 << (nb - 1))); 4613 sample /= (1 << (nb - 1)); 4614 4615 // requantize the sample 4616 // s'' = (2^nb / (2^nb - 1)) * (s''' + 2^(-nb + 1)) 4617 sample += 1 >> (nb - 1); 4618 return sample * LINEAR_TABLE[nb - 2]; 4619}; 4620 4621module.exports = Layer1; 4622 4623},{"./frame":4,"./header":5,"./tables":14,"./utils":15}],10:[function(require,module,exports){ 4624var tables = require('./tables'); 4625var MP3FrameHeader = require('./header'); 4626var MP3Frame = require('./frame'); 4627var utils = require('./utils'); 4628 4629function Layer2() { 4630 this.samples = new Float64Array(3); 4631 this.allocation = utils.makeArray([2, 32], Uint8Array); 4632 this.scfsi = utils.makeArray([2, 32], Uint8Array); 4633 this.scalefactor = utils.makeArray([2, 32, 3], Uint8Array); 4634} 4635 4636MP3Frame.layers[2] = Layer2; 4637 4638// possible quantization per subband table 4639const SBQUANT = [ 4640 // ISO/IEC 11172-3 Table B.2a 4641 { sblimit: 27, offsets: 4642 [ 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 ] }, 4643 4644 // ISO/IEC 11172-3 Table B.2b 4645 { sblimit: 30, offsets: 4646 [ 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0 ] }, 4647 4648 // ISO/IEC 11172-3 Table B.2c 4649 { sblimit: 8, offsets: 4650 [ 5, 5, 2, 2, 2, 2, 2, 2 ] }, 4651 4652 // ISO/IEC 11172-3 Table B.2d 4653 { sblimit: 12, offsets: 4654 [ 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ] }, 4655 4656 // ISO/IEC 13818-3 Table B.1 4657 { sblimit: 30, offsets: 4658 [ 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] } 4659]; 4660 4661// bit allocation table 4662const BITALLOC = [ 4663 { nbal: 2, offset: 0 }, // 0 4664 { nbal: 2, offset: 3 }, // 1 4665 { nbal: 3, offset: 3 }, // 2 4666 { nbal: 3, offset: 1 }, // 3 4667 { nbal: 4, offset: 2 }, // 4 4668 { nbal: 4, offset: 3 }, // 5 4669 { nbal: 4, offset: 4 }, // 6 4670 { nbal: 4, offset: 5 } // 7 4671]; 4672 4673// offsets into quantization class table 4674const OFFSETS = [ 4675 [ 0, 1, 16 ], // 0 4676 [ 0, 1, 2, 3, 4, 5, 16 ], // 1 4677 [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ], // 2 4678 [ 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ], // 3 4679 [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16 ], // 4 4680 [ 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] // 5 4681]; 4682 4683 4684 4685/* 4686 * These are the Layer II classes of quantization. 4687 * The table is derived from Table B.4 of ISO/IEC 11172-3. 4688 */ 4689const QC_TABLE = [ 4690 { nlevels: 3, group: 2, bits: 5, C: 1.33333333333, D: 0.50000000000 }, 4691 { nlevels: 5, group: 3, bits: 7, C: 1.60000000000, D: 0.50000000000 }, 4692 { nlevels: 7, group: 0, bits: 3, C: 1.14285714286, D: 0.25000000000 }, 4693 { nlevels: 9, group: 4, bits: 10, C: 1.77777777777, D: 0.50000000000 }, 4694 { nlevels: 15, group: 0, bits: 4, C: 1.06666666666, D: 0.12500000000 }, 4695 { nlevels: 31, group: 0, bits: 5, C: 1.03225806452, D: 0.06250000000 }, 4696 { nlevels: 63, group: 0, bits: 6, C: 1.01587301587, D: 0.03125000000 }, 4697 { nlevels: 127, group: 0, bits: 7, C: 1.00787401575, D: 0.01562500000 }, 4698 { nlevels: 255, group: 0, bits: 8, C: 1.00392156863, D: 0.00781250000 }, 4699 { nlevels: 511, group: 0, bits: 9, C: 1.00195694716, D: 0.00390625000 }, 4700 { nlevels: 1023, group: 0, bits: 10, C: 1.00097751711, D: 0.00195312500 }, 4701 { nlevels: 2047, group: 0, bits: 11, C: 1.00048851979, D: 0.00097656250 }, 4702 { nlevels: 4095, group: 0, bits: 12, C: 1.00024420024, D: 0.00048828125 }, 4703 { nlevels: 8191, group: 0, bits: 13, C: 1.00012208522, D: 0.00024414063 }, 4704 { nlevels: 16383, group: 0, bits: 14, C: 1.00006103888, D: 0.00012207031 }, 4705 { nlevels: 32767, group: 0, bits: 15, C: 1.00003051851, D: 0.00006103516 }, 4706 { nlevels: 65535, group: 0, bits: 16, C: 1.00001525902, D: 0.00003051758 } 4707]; 4708 4709Layer2.prototype.decode = function(stream, frame) { 4710 var header = frame.header; 4711 var nch = header.nchannels(); 4712 var index; 4713 4714 if (header.flags & MP3FrameHeader.FLAGS.LSF_EXT) { 4715 index = 4; 4716 } else if (header.flags & MP3FrameHeader.FLAGS.FREEFORMAT) { 4717 index = header.samplerate === 48000 ? 0 : 1; 4718 } else { 4719 var bitrate_per_channel = header.bitrate; 4720 4721 if (nch === 2) { 4722 bitrate_per_channel /= 2; 4723 4724 /* 4725 * ISO/IEC 11172-3 allows only single channel mode for 32, 48, 56, and 4726 * 80 kbps bitrates in Layer II, but some encoders ignore this 4727 * restriction, so we ignore it as well. 4728 */ 4729 } else { 4730 /* 4731 * ISO/IEC 11172-3 does not allow single channel mode for 224, 256, 4732 * 320, or 384 kbps bitrates in Layer II. 4733 */ 4734 if (bitrate_per_channel > 192000) 4735 throw new Error('bad bitrate/mode combination'); 4736 } 4737 4738 if (bitrate_per_channel <= 48000) 4739 index = header.samplerate === 32000 ? 3 : 2; 4740 else if (bitrate_per_channel <= 80000) 4741 index = 0; 4742 else 4743 index = header.samplerate === 48000 ? 0 : 1; 4744 } 4745 4746 var sblimit = SBQUANT[index].sblimit; 4747 var offsets = SBQUANT[index].offsets; 4748 4749 var bound = 32; 4750 if (header.mode === MP3FrameHeader.MODE.JOINT_STEREO) { 4751 header.flags |= MP3FrameHeader.FLAGS.I_STEREO; 4752 bound = 4 + header.mode_extension * 4; 4753 } 4754 4755 if (bound > sblimit) 4756 bound = sblimit; 4757 4758 // decode bit allocations 4759 var allocation = this.allocation; 4760 for (var sb = 0; sb < bound; sb++) { 4761 var nbal = BITALLOC[offsets[sb]].nbal; 4762 4763 for (var ch = 0; ch < nch; ch++) 4764 allocation[ch][sb] = stream.read(nbal); 4765 } 4766 4767 for (var sb = bound; sb < sblimit; sb++) { 4768 var nbal = BITALLOC[offsets[sb]].nbal; 4769 4770 allocation[0][sb] = 4771 allocation[1][sb] = stream.read(nbal); 4772 } 4773 4774 // decode scalefactor selection info 4775 var scfsi = this.scfsi; 4776 for (var sb = 0; sb < sblimit; sb++) { 4777 for (var ch = 0; ch < nch; ch++) { 4778 if (allocation[ch][sb]) 4779 scfsi[ch][sb] = stream.read(2); 4780 } 4781 } 4782 4783 if (header.flags & MP3FrameHeader.FLAGS.PROTECTION) { 4784 // TODO: crc check 4785 } 4786 4787 // decode scalefactors 4788 var scalefactor = this.scalefactor; 4789 for (var sb = 0; sb < sblimit; sb++) { 4790 for (var ch = 0; ch < nch; ch++) { 4791 if (allocation[ch][sb]) { 4792 scalefactor[ch][sb][0] = stream.read(6); 4793 4794 switch (scfsi[ch][sb]) { 4795 case 2: 4796 scalefactor[ch][sb][2] = 4797 scalefactor[ch][sb][1] = scalefactor[ch][sb][0]; 4798 break; 4799 4800 case 0: 4801 scalefactor[ch][sb][1] = stream.read(6); 4802 // fall through 4803 4804 case 1: 4805 case 3: 4806 scalefactor[ch][sb][2] = stream.read(6); 4807 } 4808 4809 if (scfsi[ch][sb] & 1) 4810 scalefactor[ch][sb][1] = scalefactor[ch][sb][scfsi[ch][sb] - 1]; 4811 4812 /* 4813 * Scalefactor index 63 does not appear in Table B.1 of 4814 * ISO/IEC 11172-3. Nonetheless, other implementations accept it, 4815 * so we do as well. 4816 */ 4817 } 4818 } 4819 } 4820 4821 // decode samples 4822 for (var gr = 0; gr < 12; gr++) { 4823 // normal 4824 for (var sb = 0; sb < bound; sb++) { 4825 for (var ch = 0; ch < nch; ch++) { 4826 if (index = allocation[ch][sb]) { 4827 index = OFFSETS[BITALLOC[offsets[sb]].offset][index - 1]; 4828 this.decodeSamples(stream, QC_TABLE[index]); 4829 4830 var scale = tables.SF_TABLE[scalefactor[ch][sb][gr >> 2]]; 4831 for (var s = 0; s < 3; s++) { 4832 frame.sbsample[ch][3 * gr + s][sb] = this.samples[s] * scale; 4833 } 4834 } else { 4835 for (var s = 0; s < 3; s++) { 4836 frame.sbsample[ch][3 * gr + s][sb] = 0; 4837 } 4838 } 4839 } 4840 } 4841 4842 // joint stereo 4843 for (var sb = bound; sb < sblimit; sb++) { 4844 if (index = allocation[0][sb]) { 4845 index = OFFSETS[BITALLOC[offsets[sb]].offset][index - 1]; 4846 this.decodeSamples(stream, QC_TABLE[index]); 4847 4848 for (var ch = 0; ch < nch; ch++) { 4849 var scale = tables.SF_TABLE[scalefactor[ch][sb][gr >> 2]]; 4850 for (var s = 0; s < 3; s++) { 4851 frame.sbsample[ch][3 * gr + s][sb] = this.samples[s] * scale; 4852 } 4853 } 4854 } else { 4855 for (var ch = 0; ch < nch; ch++) { 4856 for (var s = 0; s < 3; s++) { 4857 frame.sbsample[ch][3 * gr + s][sb] = 0; 4858 } 4859 } 4860 } 4861 } 4862 4863 // the rest 4864 for (var ch = 0; ch < nch; ch++) { 4865 for (var s = 0; s < 3; s++) { 4866 for (var sb = sblimit; sb < 32; sb++) { 4867 frame.sbsample[ch][3 * gr + s][sb] = 0; 4868 } 4869 } 4870 } 4871 } 4872}; 4873 4874Layer2.prototype.decodeSamples = function(stream, quantclass) { 4875 var sample = this.samples; 4876 var nb = quantclass.group; 4877 4878 if (nb) { 4879 // degrouping 4880 var c = stream.read(quantclass.bits); 4881 var nlevels = quantclass.nlevels; 4882 4883 for (var s = 0; s < 3; s++) { 4884 sample[s] = c % nlevels; 4885 c = c / nlevels | 0; 4886 } 4887 } else { 4888 nb = quantclass.bits; 4889 for (var s = 0; s < 3; s++) { 4890 sample[s] = stream.read(nb); 4891 } 4892 } 4893 4894 for (var s = 0; s < 3; s++) { 4895 // invert most significant bit, and form a 2's complement sample 4896 var requantized = sample[s] ^ (1 << (nb - 1)); 4897 requantized |= -(requantized & (1 << (nb - 1))); 4898 requantized /= (1 << (nb - 1)); 4899 4900 // requantize the sample 4901 sample[s] = (requantized + quantclass.D) * quantclass.C; 4902 } 4903}; 4904 4905module.exports = Layer2; 4906 4907},{"./frame":4,"./header":5,"./tables":14,"./utils":15}],11:[function(require,module,exports){ 4908var AV = (window.AV); 4909var tables = require('./tables'); 4910var MP3FrameHeader = require('./header'); 4911var MP3Frame = require('./frame'); 4912var huffman = require('./huffman'); 4913var IMDCT = require('./imdct'); 4914var utils = require('./utils'); 4915 4916function MP3SideInfo() { 4917 this.main_data_begin = null; 4918 this.private_bits = null; 4919 this.gr = [new MP3Granule(), new MP3Granule()]; 4920 this.scfsi = new Uint8Array(2); 4921} 4922 4923function MP3Granule() { 4924 this.ch = [new MP3Channel(), new MP3Channel()]; 4925} 4926 4927function MP3Channel() { 4928 // from side info 4929 this.part2_3_length = null; 4930 this.big_values = null; 4931 this.global_gain = null; 4932 this.scalefac_compress = null; 4933 4934 this.flags = null; 4935 this.block_type = null; 4936 this.table_select = new Uint8Array(3); 4937 this.subblock_gain = new Uint8Array(3); 4938 this.region0_count = null; 4939 this.region1_count = null; 4940 4941 // from main_data 4942 this.scalefac = new Uint8Array(39); 4943} 4944 4945function Layer3() { 4946 this.imdct = new IMDCT(); 4947 this.si = new MP3SideInfo(); 4948 4949 // preallocate reusable typed arrays for performance 4950 this.xr = [new Float64Array(576), new Float64Array(576)]; 4951 this._exponents = new Int32Array(39); 4952 this.reqcache = new Float64Array(16); 4953 this.modes = new Int16Array(39); 4954 this.output = new Float64Array(36); 4955 4956 this.tmp = utils.makeArray([32, 3, 6]); 4957 this.tmp2 = new Float64Array(32 * 3 * 6); 4958} 4959 4960MP3Frame.layers[3] = Layer3; 4961 4962Layer3.prototype.decode = function(stream, frame) { 4963 var header = frame.header; 4964 var next_md_begin = 0; 4965 var md_len = 0; 4966 4967 var nch = header.nchannels(); 4968 var si_len = (header.flags & MP3FrameHeader.FLAGS.LSF_EXT) ? (nch === 1 ? 9 : 17) : (nch === 1 ? 17 : 32); 4969 4970 // check frame sanity 4971 if (stream.next_frame - stream.nextByte() < si_len) { 4972 stream.md_len = 0; 4973 throw new Error('Bad frame length'); 4974 } 4975 4976 // check CRC word 4977 if (header.flags & MP3FrameHeader.FLAGS.PROTECTION) { 4978 // TODO: crc check 4979 } 4980 4981 // decode frame side information 4982 var sideInfo = this.sideInfo(stream, nch, header.flags & MP3FrameHeader.FLAGS.LSF_EXT); 4983 var si = sideInfo.si; 4984 var data_bitlen = sideInfo.data_bitlen; 4985 var priv_bitlen = sideInfo.priv_bitlen; 4986 4987 header.flags |= priv_bitlen; 4988 header.private_bits |= si.private_bits; 4989 4990 // find main_data of next frame 4991 var peek = stream.copy(); 4992 peek.seek(stream.next_frame * 8); 4993 4994 var nextHeader = peek.read(16); 4995 if ((nextHeader & 0xffe6) === 0xffe2) { // syncword | layer 4996 if ((nextHeader & 1) === 0) // protection bit 4997 peek.advance(16); // crc check 4998 4999 peek.advance(16); // skip the rest of the header 5000 next_md_begin = peek.read((nextHeader & 8) ? 9 : 8); 5001 } 5002 5003 // find main_data of this frame 5004 var frame_space = stream.next_frame - stream.nextByte(); 5005 5006 if (next_md_begin > si.main_data_begin + frame_space) 5007 next_md_begin = 0; 5008 5009 var md_len = si.main_data_begin + frame_space - next_md_begin; 5010 var frame_used = 0; 5011 var ptr; 5012 5013 if (si.main_data_begin === 0) { 5014 ptr = stream.stream; 5015 stream.md_len = 0; 5016 frame_used = md_len; 5017 } else { 5018 if (si.main_data_begin > stream.md_len) { 5019 throw new Error('bad main_data_begin pointer'); 5020 } else { 5021 var old_md_len = stream.md_len; 5022 5023 if (md_len > si.main_data_begin) { 5024 if (stream.md_len + md_len - si.main_data_begin > MP3FrameHeader.BUFFER_MDLEN) { 5025 throw new Error("Assertion failed: (stream.md_len + md_len - si.main_data_begin <= MAD_MP3FrameHeader.BUFFER_MDLEN)"); 5026 } 5027 5028 frame_used = md_len - si.main_data_begin; 5029 this.memcpy(stream.main_data, stream.md_len, stream.stream.stream, stream.nextByte(), frame_used); 5030 stream.md_len += frame_used; 5031 } 5032 5033 ptr = new AV.Bitstream(AV.Stream.fromBuffer(new AV.Buffer(stream.main_data))); 5034 ptr.advance((old_md_len - si.main_data_begin) * 8); 5035 } 5036 } 5037 5038 var frame_free = frame_space - frame_used; 5039 5040 // decode main_data 5041 this.decodeMainData(ptr, frame, si, nch); 5042 5043 // preload main_data buffer with up to 511 bytes for next frame(s) 5044 if (frame_free >= next_md_begin) { 5045 this.memcpy(stream.main_data, 0, stream.stream.stream, stream.next_frame - next_md_begin, next_md_begin); 5046 stream.md_len = next_md_begin; 5047 } else { 5048 if (md_len < si.main_data_begin) { 5049 var extra = si.main_data_begin - md_len; 5050 if (extra + frame_free > next_md_begin) 5051 extra = next_md_begin - frame_free; 5052 5053 if (extra < stream.md_len) { 5054 this.memcpy(stream.main_data, 0, stream.main_data, stream.md_len - extra, extra); 5055 stream.md_len = extra; 5056 } 5057 } else { 5058 stream.md_len = 0; 5059 } 5060 5061 this.memcpy(stream.main_data, stream.md_len, stream.stream.stream, stream.next_frame - frame_free, frame_free); 5062 stream.md_len += frame_free; 5063 } 5064}; 5065 5066Layer3.prototype.memcpy = function(dst, dstOffset, pSrc, srcOffset, length) { 5067 var subarr; 5068 if (pSrc.subarray) 5069 subarr = pSrc.subarray(srcOffset, srcOffset + length); 5070 else 5071 subarr = pSrc.peekBuffer(srcOffset - pSrc.offset, length).data; 5072 5073 // oh my, memcpy actually exists in JavaScript? 5074 dst.set(subarr, dstOffset); 5075 return dst; 5076}; 5077 5078Layer3.prototype.sideInfo = function(stream, nch, lsf) { 5079 var si = this.si; 5080 var data_bitlen = 0; 5081 var priv_bitlen = lsf ? ((nch === 1) ? 1 : 2) : ((nch === 1) ? 5 : 3); 5082 5083 si.main_data_begin = stream.read(lsf ? 8 : 9); 5084 si.private_bits = stream.read(priv_bitlen); 5085 5086 var ngr = 1; 5087 if (!lsf) { 5088 ngr = 2; 5089 for (var ch = 0; ch < nch; ++ch) 5090 si.scfsi[ch] = stream.read(4); 5091 } 5092 5093 for (var gr = 0; gr < ngr; gr++) { 5094 var granule = si.gr[gr]; 5095 5096 for (var ch = 0; ch < nch; ch++) { 5097 var channel = granule.ch[ch]; 5098 5099 channel.part2_3_length = stream.read(12); 5100 channel.big_values = stream.read(9); 5101 channel.global_gain = stream.read(8); 5102 channel.scalefac_compress = stream.read(lsf ? 9 : 4); 5103 5104 data_bitlen += channel.part2_3_length; 5105 5106 if (channel.big_values > 288) 5107 throw new Error('bad big_values count'); 5108 5109 channel.flags = 0; 5110 5111 // window_switching_flag 5112 if (stream.read(1)) { 5113 channel.block_type = stream.read(2); 5114 5115 if (channel.block_type === 0) 5116 throw new Error('reserved block_type'); 5117 5118 if (!lsf && channel.block_type === 2 && si.scfsi[ch]) 5119 throw new Error('bad scalefactor selection info'); 5120 5121 channel.region0_count = 7; 5122 channel.region1_count = 36; 5123 5124 if (stream.read(1)) 5125 channel.flags |= tables.MIXED_BLOCK_FLAG; 5126 else if (channel.block_type === 2) 5127 channel.region0_count = 8; 5128 5129 for (var i = 0; i < 2; i++) 5130 channel.table_select[i] = stream.read(5); 5131 5132 for (var i = 0; i < 3; i++) 5133 channel.subblock_gain[i] = stream.read(3); 5134 } else { 5135 channel.block_type = 0; 5136 5137 for (var i = 0; i < 3; i++) 5138 channel.table_select[i] = stream.read(5); 5139 5140 channel.region0_count = stream.read(4); 5141 channel.region1_count = stream.read(3); 5142 } 5143 5144 // [preflag,] scalefac_scale, count1table_select 5145 channel.flags |= stream.read(lsf ? 2 : 3); 5146 } 5147 } 5148 5149 return { 5150 si: si, 5151 data_bitlen: data_bitlen, 5152 priv_bitlen: priv_bitlen 5153 }; 5154}; 5155 5156Layer3.prototype.decodeMainData = function(stream, frame, si, nch) { 5157 var header = frame.header; 5158 var sfreq = header.samplerate; 5159 5160 if (header.flags & MP3FrameHeader.FLAGS.MPEG_2_5_EXT) 5161 sfreq *= 2; 5162 5163 // 48000 => 0, 44100 => 1, 32000 => 2, 5164 // 24000 => 3, 22050 => 4, 16000 => 5 5165 var sfreqi = ((sfreq >> 7) & 0x000f) + ((sfreq >> 15) & 0x0001) - 8; 5166 5167 if (header.flags & MP3FrameHeader.FLAGS.MPEG_2_5_EXT) 5168 sfreqi += 3; 5169 5170 // scalefactors, Huffman decoding, requantization 5171 var ngr = (header.flags & MP3FrameHeader.FLAGS.LSF_EXT) ? 1 : 2; 5172 var xr = this.xr; 5173 5174 for (var gr = 0; gr < ngr; ++gr) { 5175 var granule = si.gr[gr]; 5176 var sfbwidth = []; 5177 var l = 0; 5178 5179 for (var ch = 0; ch < nch; ++ch) { 5180 var channel = granule.ch[ch]; 5181 var part2_length; 5182 5183 sfbwidth[ch] = tables.SFBWIDTH_TABLE[sfreqi].l; 5184 if (channel.block_type === 2) { 5185 sfbwidth[ch] = (channel.flags & tables.MIXED_BLOCK_FLAG) ? tables.SFBWIDTH_TABLE[sfreqi].m : tables.SFBWIDTH_TABLE[sfreqi].s; 5186 } 5187 5188 if (header.flags & MP3FrameHeader.FLAGS.LSF_EXT) { 5189 part2_length = this.scalefactors_lsf(stream, channel, ch === 0 ? 0 : si.gr[1].ch[1], header.mode_extension); 5190 } else { 5191 part2_length = this.scalefactors(stream, channel, si.gr[0].ch[ch], gr === 0 ? 0 : si.scfsi[ch]); 5192 } 5193 5194 this.huffmanDecode(stream, xr[ch], channel, sfbwidth[ch], part2_length); 5195 } 5196 5197 // joint stereo processing 5198 if (header.mode === MP3FrameHeader.MODE.JOINT_STEREO && header.mode_extension !== 0) 5199 this.stereo(xr, si.gr, gr, header, sfbwidth[0]); 5200 5201 // reordering, alias reduction, IMDCT, overlap-add, frequency inversion 5202 for (var ch = 0; ch < nch; ch++) { 5203 var channel = granule.ch[ch]; 5204 var sample = frame.sbsample[ch].slice(18 * gr); 5205 5206 var sb, l = 0, i, sblimit; 5207 var output = this.output; 5208 5209 if (channel.block_type === 2) { 5210 this.reorder(xr[ch], channel, sfbwidth[ch]); 5211 5212 /* 5213 * According to ISO/IEC 11172-3, "Alias reduction is not applied for 5214 * granules with block_type === 2 (short block)." However, other 5215 * sources suggest alias reduction should indeed be performed on the 5216 * lower two subbands of mixed blocks. Most other implementations do 5217 * this, so by default we will too. 5218 */ 5219 if (channel.flags & tables.MIXED_BLOCK_FLAG) 5220 this.aliasreduce(xr[ch], 36); 5221 } else { 5222 this.aliasreduce(xr[ch], 576); 5223 } 5224 5225 // subbands 0-1 5226 if (channel.block_type !== 2 || (channel.flags & tables.MIXED_BLOCK_FLAG)) { 5227 var block_type = channel.block_type; 5228 if (channel.flags & tables.MIXED_BLOCK_FLAG) 5229 block_type = 0; 5230 5231 // long blocks 5232 for (var sb = 0; sb < 2; ++sb, l += 18) { 5233 this.imdct_l(xr[ch].subarray(l, l + 18), output, block_type); 5234 this.overlap(output, frame.overlap[ch][sb], sample, sb); 5235 } 5236 } else { 5237 // short blocks 5238 for (var sb = 0; sb < 2; ++sb, l += 18) { 5239 this.imdct_s(xr[ch].subarray(l, l + 18), output); 5240 this.overlap(output, frame.overlap[ch][sb], sample, sb); 5241 } 5242 } 5243 5244 this.freqinver(sample, 1); 5245 5246 // (nonzero) subbands 2-31 5247 var i = 576; 5248 while (i > 36 && xr[ch][i - 1] === 0) { 5249 --i; 5250 } 5251 5252 sblimit = 32 - (((576 - i) / 18) << 0); 5253 5254 if (channel.block_type !== 2) { 5255 // long blocks 5256 for (var sb = 2; sb < sblimit; ++sb, l += 18) { 5257 this.imdct_l(xr[ch].subarray(l, l + 18), output, channel.block_type); 5258 this.overlap(output, frame.overlap[ch][sb], sample, sb); 5259 5260 if (sb & 1) 5261 this.freqinver(sample, sb); 5262 } 5263 } else { 5264 // short blocks 5265 for (var sb = 2; sb < sblimit; ++sb, l += 18) { 5266 this.imdct_s(xr[ch].subarray(l, l + 18), output); 5267 this.overlap(output, frame.overlap[ch][sb], sample, sb); 5268 5269 if (sb & 1) 5270 this.freqinver(sample, sb); 5271 } 5272 } 5273 5274 // remaining (zero) subbands 5275 for (var sb = sblimit; sb < 32; ++sb) { 5276 this.overlap_z(frame.overlap[ch][sb], sample, sb); 5277 5278 if (sb & 1) 5279 this.freqinver(sample, sb); 5280 } 5281 } 5282 } 5283}; 5284 5285Layer3.prototype.scalefactors = function(stream, channel, gr0ch, scfsi) { 5286 var start = stream.offset(); 5287 var slen1 = tables.SFLEN_TABLE[channel.scalefac_compress].slen1; 5288 var slen2 = tables.SFLEN_TABLE[channel.scalefac_compress].slen2; 5289 var sfbi; 5290 5291 if (channel.block_type === 2) { 5292 sfbi = 0; 5293 5294 var nsfb = (channel.flags & tables.MIXED_BLOCK_FLAG) ? 8 + 3 * 3 : 6 * 3; 5295 while (nsfb--) 5296 channel.scalefac[sfbi++] = stream.read(slen1); 5297 5298 nsfb = 6 * 3; 5299 while (nsfb--) 5300 channel.scalefac[sfbi++] = stream.read(slen2); 5301 5302 nsfb = 1 * 3; 5303 while (nsfb--) 5304 channel.scalefac[sfbi++] = 0; 5305 } else { 5306 if (scfsi & 0x8) { 5307 for (var sfbi = 0; sfbi < 6; ++sfbi) 5308 channel.scalefac[sfbi] = gr0ch.scalefac[sfbi]; 5309 } else { 5310 for (var sfbi = 0; sfbi < 6; ++sfbi) 5311 channel.scalefac[sfbi] = stream.read(slen1); 5312 } 5313 5314 if (scfsi & 0x4) { 5315 for (var sfbi = 6; sfbi < 11; ++sfbi) 5316 channel.scalefac[sfbi] = gr0ch.scalefac[sfbi]; 5317 } else { 5318 for (var sfbi = 6; sfbi < 11; ++sfbi) 5319 channel.scalefac[sfbi] = stream.read(slen1); 5320 } 5321 5322 if (scfsi & 0x2) { 5323 for (var sfbi = 11; sfbi < 16; ++sfbi) 5324 channel.scalefac[sfbi] = gr0ch.scalefac[sfbi]; 5325 } else { 5326 for (var sfbi = 11; sfbi < 16; ++sfbi) 5327 channel.scalefac[sfbi] = stream.read(slen2); 5328 } 5329 5330 if (scfsi & 0x1) { 5331 for (var sfbi = 16; sfbi < 21; ++sfbi) 5332 channel.scalefac[sfbi] = gr0ch.scalefac[sfbi]; 5333 } else { 5334 for (var sfbi = 16; sfbi < 21; ++sfbi) 5335 channel.scalefac[sfbi] = stream.read(slen2); 5336 } 5337 5338 channel.scalefac[21] = 0; 5339 } 5340 5341 return stream.offset() - start; 5342}; 5343 5344Layer3.prototype.scalefactors_lsf = function(stream, channel, gr1ch, mode_extension) { 5345 var start = stream.offset(); 5346 var scalefac_compress = channel.scalefac_compress; 5347 var index = channel.block_type === 2 ? (channel.flags & tables.MIXED_BLOCK_FLAG ? 2 : 1) : 0; 5348 var slen = new Int32Array(4); 5349 var nsfb; 5350 5351 if (!((mode_extension & tables.I_STEREO) && gr1ch)) { 5352 if (scalefac_compress < 400) { 5353 slen[0] = (scalefac_compress >>> 4) / 5; 5354 slen[1] = (scalefac_compress >>> 4) % 5; 5355 slen[2] = (scalefac_compress % 16) >>> 2; 5356 slen[3] = scalefac_compress % 4; 5357 5358 nsfb = tables.NSFB_TABLE[0][index]; 5359 } else if (scalefac_compress < 500) { 5360 scalefac_compress -= 400; 5361 5362 slen[0] = (scalefac_compress >>> 2) / 5; 5363 slen[1] = (scalefac_compress >>> 2) % 5; 5364 slen[2] = scalefac_compress % 4; 5365 slen[3] = 0; 5366 5367 nsfb = tables.NSFB_TABLE[1][index]; 5368 } else { 5369 scalefac_compress -= 500; 5370 5371 slen[0] = scalefac_compress / 3; 5372 slen[1] = scalefac_compress % 3; 5373 slen[2] = 0; 5374 slen[3] = 0; 5375 5376 channel.flags |= tables.PREFLAG; 5377 nsfb = tables.NSFB_TABLE[2][index]; 5378 } 5379 5380 var n = 0; 5381 for (var part = 0; part < 4; part++) { 5382 for (var i = 0; i < nsfb[part]; i++) { 5383 channel.scalefac[n++] = stream.read(slen[part]); 5384 } 5385 } 5386 5387 while (n < 39) { 5388 channel.scalefac[n++] = 0; 5389 } 5390 } else { // (mode_extension & tables.I_STEREO) && gr1ch (i.e. ch == 1) 5391 scalefac_compress >>>= 1; 5392 5393 if (scalefac_compress < 180) { 5394 slen[0] = scalefac_compress / 36; 5395 slen[1] = (scalefac_compress % 36) / 6; 5396 slen[2] = (scalefac_compress % 36) % 6; 5397 slen[3] = 0; 5398 5399 nsfb = tables.NSFB_TABLE[3][index]; 5400 } else if (scalefac_compress < 244) { 5401 scalefac_compress -= 180; 5402 5403 slen[0] = (scalefac_compress % 64) >>> 4; 5404 slen[1] = (scalefac_compress % 16) >>> 2; 5405 slen[2] = scalefac_compress % 4; 5406 slen[3] = 0; 5407 5408 nsfb = tables.NSFB_TABLE[4][index]; 5409 } else { 5410 scalefac_compress -= 244; 5411 5412 slen[0] = scalefac_compress / 3; 5413 slen[1] = scalefac_compress % 3; 5414 slen[2] = 0; 5415 slen[3] = 0; 5416 5417 nsfb = tables.NSFB_TABLE[5][index]; 5418 } 5419 5420 var n = 0; 5421 for (var part = 0; part < 4; ++part) { 5422 var max = (1 << slen[part]) - 1; 5423 for (var i = 0; i < nsfb[part]; ++i) { 5424 var is_pos = stream.read(slen[part]); 5425 5426 channel.scalefac[n] = is_pos; 5427 gr1ch.scalefac[n++] = is_pos === max ? 1 : 0; 5428 } 5429 } 5430 5431 while (n < 39) { 5432 channel.scalefac[n] = 0; 5433 gr1ch.scalefac[n++] = 0; // apparently not illegal 5434 } 5435 } 5436 5437 return stream.offset() - start; 5438}; 5439 5440Layer3.prototype.huffmanDecode = function(stream, xr, channel, sfbwidth, part2_length) { 5441 var exponents = this._exponents; 5442 var sfbwidthptr = 0; 5443 5444 var bits_left = channel.part2_3_length - part2_length; 5445 if (bits_left < 0) 5446 throw new Error('bad audio data length'); 5447 5448 this.exponents(channel, sfbwidth, exponents); 5449 5450 var peek = stream.copy(); 5451 stream.advance(bits_left); 5452 5453 /* align bit reads to byte boundaries */ 5454 var cachesz = 8 - peek.bitPosition; 5455 cachesz += ((32 - 1 - 24) + (24 - cachesz)) & ~7; 5456 5457 var bitcache = peek.read(cachesz); 5458 bits_left -= cachesz; 5459 5460 var xrptr = 0; 5461 5462 // big_values 5463 var region = 0; 5464 var reqcache = this.reqcache; 5465 5466 var sfbound = xrptr + sfbwidth[sfbwidthptr++]; 5467 var rcount = channel.region0_count + 1; 5468 5469 var entry = huffman.huff_pair_table[channel.table_select[region]]; 5470 var table = entry.table; 5471 var linbits = entry.linbits; 5472 var startbits = entry.startbits; 5473 5474 if (typeof table === 'undefined') 5475 throw new Error('bad Huffman table select'); 5476 5477 var expptr = 0; 5478 var exp = exponents[expptr++]; 5479 var reqhits = 0; 5480 var big_values = channel.big_values; 5481 5482 while (big_values-- && cachesz + bits_left > 0) { 5483 if (xrptr === sfbound) { 5484 sfbound += sfbwidth[sfbwidthptr++]; 5485 5486 // change table if region boundary 5487 if (--rcount === 0) { 5488 if (region === 0) 5489 rcount = channel.region1_count + 1; 5490 else 5491 rcount = 0; // all remaining 5492 5493 entry = huffman.huff_pair_table[channel.table_select[++region]]; 5494 table = entry.table; 5495 linbits = entry.linbits; 5496 startbits = entry.startbits; 5497 5498 if (typeof table === 'undefined') 5499 throw new Error('bad Huffman table select'); 5500 } 5501 5502 if (exp !== exponents[expptr]) { 5503 exp = exponents[expptr]; 5504 reqhits = 0; 5505 } 5506 5507 ++expptr; 5508 } 5509 5510 if (cachesz < 21) { 5511 var bits = ((32 - 1 - 21) + (21 - cachesz)) & ~7; 5512 bitcache = (bitcache << bits) | peek.read(bits); 5513 cachesz += bits; 5514 bits_left -= bits; 5515 } 5516 5517 var clumpsz = startbits; 5518 var pair = table[ (((bitcache) >> ((cachesz) - (clumpsz))) & ((1 << (clumpsz)) - 1))]; 5519 5520 while (!pair.final) { 5521 cachesz -= clumpsz; 5522 clumpsz = pair.ptr.bits; 5523 pair = table[pair.ptr.offset + (((bitcache) >> ((cachesz) - (clumpsz))) & ((1 << (clumpsz)) - 1))]; 5524 } 5525 5526 cachesz -= pair.value.hlen; 5527 5528 if (linbits) { 5529 var value = pair.value.x; 5530 var x_final = false; 5531 5532 switch (value) { 5533 case 0: 5534 xr[xrptr] = 0; 5535 break; 5536 5537 case 15: 5538 if (cachesz < linbits + 2) { 5539 bitcache = (bitcache << 16) | peek.read(16); 5540 cachesz += 16; 5541 bits_left -= 16; 5542 } 5543 5544 value += (((bitcache) >> ((cachesz) - (linbits))) & ((1 << (linbits)) - 1)); 5545 cachesz -= linbits; 5546 5547 requantized = this.requantize(value, exp); 5548 x_final = true; // simulating goto, yay 5549 break; 5550 5551 default: 5552 if (reqhits & (1 << value)) { 5553 requantized = reqcache[value]; 5554 } else { 5555 reqhits |= (1 << value); 5556 requantized = reqcache[value] = this.requantize(value, exp); 5557 } 5558 5559 x_final = true; 5560 } 5561 5562 if(x_final) { 5563 xr[xrptr] = ((bitcache) & (1 << ((cachesz--) - 1))) ? -requantized : requantized; 5564 } 5565 5566 value = pair.value.y; 5567 var y_final = false; 5568 5569 switch (value) { 5570 case 0: 5571 xr[xrptr + 1] = 0; 5572 break; 5573 5574 case 15: 5575 if (cachesz < linbits + 1) { 5576 bitcache = (bitcache << 16) | peek.read(16); 5577 cachesz += 16; 5578 bits_left -= 16; 5579 } 5580 5581 value += (((bitcache) >> ((cachesz) - (linbits))) & ((1 << (linbits)) - 1)); 5582 cachesz -= linbits; 5583 5584 requantized = this.requantize(value, exp); 5585 y_final = true; 5586 break; // simulating goto, yayzor 5587 5588 default: 5589 if (reqhits & (1 << value)) { 5590 requantized = reqcache[value]; 5591 } else { 5592 reqhits |= (1 << value); 5593 reqcache[value] = this.requantize(value, exp); 5594 requantized = reqcache[value]; 5595 } 5596 5597 y_final = true; 5598 } 5599 5600 if(y_final) { 5601 xr[xrptr + 1] = ((bitcache) & (1 << ((cachesz--) - 1))) ? -requantized : requantized; 5602 } 5603 5604 } else { 5605 var value = pair.value.x; 5606 5607 if (value === 0) { 5608 xr[xrptr] = 0; 5609 } else { 5610 if (reqhits & (1 << value)) 5611 requantized = reqcache[value]; 5612 else { 5613 reqhits |= (1 << value); 5614 requantized = reqcache[value] = this.requantize(value, exp); 5615 } 5616 5617 xr[xrptr] = ((bitcache) & (1 << ((cachesz--) - 1))) ? -requantized : requantized; 5618 } 5619 5620 value = pair.value.y; 5621 5622 if (value === 0) { 5623 xr[xrptr + 1] = 0; 5624 } else { 5625 if (reqhits & (1 << value)) 5626 requantized = reqcache[value]; 5627 else { 5628 reqhits |= (1 << value); 5629 requantized = reqcache[value] = this.requantize(value, exp); 5630 } 5631 5632 xr[xrptr + 1] = ((bitcache) & (1 << ((cachesz--) - 1))) ? -requantized : requantized; 5633 } 5634 } 5635 5636 xrptr += 2; 5637 } 5638 5639 if (cachesz + bits_left < 0) 5640 throw new Error('Huffman data overrun'); 5641 5642 // count1 5643 var table = huffman.huff_quad_table[channel.flags & tables.COUNT1TABLE_SELECT]; 5644 var requantized = this.requantize(1, exp); 5645 5646 while (cachesz + bits_left > 0 && xrptr <= 572) { 5647 if (cachesz < 10) { 5648 bitcache = (bitcache << 16) | peek.read(16); 5649 cachesz += 16; 5650 bits_left -= 16; 5651 } 5652 5653 var quad = table[(((bitcache) >> ((cachesz) - (4))) & ((1 << (4)) - 1))]; 5654 5655 // quad tables guaranteed to have at most one extra lookup 5656 if (!quad.final) { 5657 cachesz -= 4; 5658 quad = table[quad.ptr.offset + (((bitcache) >> ((cachesz) - (quad.ptr.bits))) & ((1 << (quad.ptr.bits)) - 1))]; 5659 } 5660 5661 cachesz -= quad.value.hlen; 5662 5663 if (xrptr === sfbound) { 5664 sfbound += sfbwidth[sfbwidthptr++]; 5665 5666 if (exp !== exponents[expptr]) { 5667 exp = exponents[expptr]; 5668 requantized = this.requantize(1, exp); 5669 } 5670 5671 ++expptr; 5672 } 5673 5674 // v (0..1) 5675 xr[xrptr] = quad.value.v ? (((bitcache) & (1 << ((cachesz--) - 1))) ? -requantized : requantized) : 0; 5676 5677 // w (0..1) 5678 xr[xrptr + 1] = quad.value.w ? (((bitcache) & (1 << ((cachesz--) - 1))) ? -requantized : requantized) : 0; 5679 5680 xrptr += 2; 5681 if (xrptr === sfbound) { 5682 sfbound += sfbwidth[sfbwidthptr++]; 5683 5684 if (exp !== exponents[expptr]) { 5685 exp = exponents[expptr]; 5686 requantized = this.requantize(1, exp); 5687 } 5688 5689 ++expptr; 5690 } 5691 5692 // x (0..1) 5693 xr[xrptr] = quad.value.x ? (((bitcache) & (1 << ((cachesz--) - 1))) ? -requantized : requantized) : 0; 5694 5695 // y (0..1) 5696 xr[xrptr + 1] = quad.value.y ? (((bitcache) & (1 << ((cachesz--) - 1))) ? -requantized : requantized) : 0; 5697 5698 xrptr += 2; 5699 5700 if (cachesz + bits_left < 0) { 5701 // technically the bitstream is misformatted, but apparently 5702 // some encoders are just a bit sloppy with stuffing bits 5703 xrptr -= 4; 5704 } 5705 } 5706 5707 if (-bits_left > MP3FrameHeader.BUFFER_GUARD * 8) { 5708 throw new Error("assertion failed: (-bits_left <= MP3FrameHeader.BUFFER_GUARD * CHAR_BIT)"); 5709 } 5710 5711 // rzero 5712 while (xrptr < 576) { 5713 xr[xrptr] = 0; 5714 xr[xrptr + 1] = 0; 5715 xrptr += 2; 5716 } 5717}; 5718 5719Layer3.prototype.requantize = function(value, exp) { 5720 // usual (x >> 0) tricks to make sure frac and exp stay integers 5721 var frac = (exp % 4) >> 0; // assumes sign(frac) === sign(exp) 5722 exp = (exp / 4) >> 0; 5723 5724 var requantized = Math.pow(value, 4.0 / 3.0); 5725 requantized *= Math.pow(2.0, (exp / 4.0)); 5726 5727 if (frac) { 5728 requantized *= Math.pow(2.0, (frac / 4.0)); 5729 } 5730 5731 if (exp < 0) { 5732 requantized /= Math.pow(2.0, -exp * (3.0 / 4.0)); 5733 } 5734 5735 return requantized; 5736}; 5737 5738Layer3.prototype.exponents = function(channel, sfbwidth, exponents) { 5739 var gain = channel.global_gain - 210; 5740 var scalefac_multiplier = (channel.flags & tables.SCALEFAC_SCALE) ? 2 : 1; 5741 5742 if (channel.block_type === 2) { 5743 var sfbi = 0, l = 0; 5744 5745 if (channel.flags & tables.MIXED_BLOCK_FLAG) { 5746 var premask = (channel.flags & tables.PREFLAG) ? ~0 : 0; 5747 5748 // long block subbands 0-1 5749 while (l < 36) { 5750 exponents[sfbi] = gain - ((channel.scalefac[sfbi] + (tables.PRETAB[sfbi] & premask)) << scalefac_multiplier); 5751 l += sfbwidth[sfbi++]; 5752 } 5753 } 5754 5755 // this is probably wrong for 8000 Hz short/mixed blocks 5756 var gain0 = gain - 8 * channel.subblock_gain[0]; 5757 var gain1 = gain - 8 * channel.subblock_gain[1]; 5758 var gain2 = gain - 8 * channel.subblock_gain[2]; 5759 5760 while (l < 576) { 5761 exponents[sfbi + 0] = gain0 - (channel.scalefac[sfbi + 0] << scalefac_multiplier); 5762 exponents[sfbi + 1] = gain1 - (channel.scalefac[sfbi + 1] << scalefac_multiplier); 5763 exponents[sfbi + 2] = gain2 - (channel.scalefac[sfbi + 2] << scalefac_multiplier); 5764 5765 l += 3 * sfbwidth[sfbi]; 5766 sfbi += 3; 5767 } 5768 } else { 5769 if (channel.flags & tables.PREFLAG) { 5770 for (var sfbi = 0; sfbi < 22; sfbi++) { 5771 exponents[sfbi] = gain - ((channel.scalefac[sfbi] + tables.PRETAB[sfbi]) << scalefac_multiplier); 5772 } 5773 } else { 5774 for (var sfbi = 0; sfbi < 22; sfbi++) { 5775 exponents[sfbi] = gain - (channel.scalefac[sfbi] << scalefac_multiplier); 5776 } 5777 } 5778 } 5779}; 5780 5781Layer3.prototype.stereo = function(xr, granules, gr, header, sfbwidth) { 5782 var granule = granules[gr]; 5783 var modes = this.modes; 5784 var sfbi, l, n, i; 5785 5786 if (granule.ch[0].block_type !== granule.ch[1].block_type || (granule.ch[0].flags & tables.MIXED_BLOCK_FLAG) !== (granule.ch[1].flags & tables.MIXED_BLOCK_FLAG)) 5787 throw new Error('incompatible stereo block_type'); 5788 5789 for (var i = 0; i < 39; i++) 5790 modes[i] = header.mode_extension; 5791 5792 // intensity stereo 5793 if (header.mode_extension & tables.I_STEREO) { 5794 var right_ch = granule.ch[1]; 5795 var right_xr = xr[1]; 5796 5797 header.flags |= MP3FrameHeader.FLAGS.tables.I_STEREO; 5798 5799 // first determine which scalefactor bands are to be processed 5800 if (right_ch.block_type === 2) { 5801 var lower, start, max, bound = new Uint32Array(3), w; 5802 5803 lower = start = max = bound[0] = bound[1] = bound[2] = 0; 5804 sfbi = l = 0; 5805 5806 if (right_ch.flags & tables.MIXED_BLOCK_FLAG) { 5807 while (l < 36) { 5808 n = sfbwidth[sfbi++]; 5809 5810 for (var i = 0; i < n; ++i) { 5811 if (right_xr[i]) { 5812 lower = sfbi; 5813 break; 5814 } 5815 } 5816 5817 right_xr += n; 5818 l += n; 5819 } 5820 5821 start = sfbi; 5822 } 5823 5824 var w = 0; 5825 while (l < 576) { 5826 n = sfbwidth[sfbi++]; 5827 5828 for (i = 0; i < n; ++i) { 5829 if (right_xr[i]) { 5830 max = bound[w] = sfbi; 5831 break; 5832 } 5833 } 5834 5835 right_xr += n; 5836 l += n; 5837 w = (w + 1) % 3; 5838 } 5839 5840 if (max) 5841 lower = start; 5842 5843 // long blocks 5844 for (i = 0; i < lower; ++i) 5845 modes[i] = header.mode_extension & ~tables.I_STEREO; 5846 5847 // short blocks 5848 w = 0; 5849 for (i = start; i < max; ++i) { 5850 if (i < bound[w]) 5851 modes[i] = header.mode_extension & ~tables.I_STEREO; 5852 5853 w = (w + 1) % 3; 5854 } 5855 } else { 5856 var bound = 0; 5857 for (sfbi = l = 0; l < 576; l += n) { 5858 n = sfbwidth[sfbi++]; 5859 5860 for (i = 0; i < n; ++i) { 5861 if (right_xr[i]) { 5862 bound = sfbi; 5863 break; 5864 } 5865 } 5866 5867 right_xr += n; 5868 } 5869 5870 for (i = 0; i < bound; ++i) 5871 modes[i] = header.mode_extension & ~tables.I_STEREO; 5872 } 5873 5874 // now do the actual processing 5875 if (header.flags & MP3FrameHeader.FLAGS.LSF_EXT) { 5876 var illegal_pos = granules[gr + 1].ch[1].scalefac; 5877 5878 // intensity_scale 5879 var lsf_scale = IS_Ltables.SF_TABLE[right_ch.scalefac_compress & 0x1]; 5880 5881 for (sfbi = l = 0; l < 576; ++sfbi, l += n) { 5882 n = sfbwidth[sfbi]; 5883 5884 if (!(modes[sfbi] & tables.I_STEREO)) 5885 continue; 5886 5887 if (illegal_pos[sfbi]) { 5888 modes[sfbi] &= ~tables.I_STEREO; 5889 continue; 5890 } 5891 5892 is_pos = right_ch.scalefac[sfbi]; 5893 5894 for (i = 0; i < n; ++i) { 5895 var left = xr[0][l + i]; 5896 5897 if (is_pos === 0) { 5898 xr[1][l + i] = left; 5899 } else { 5900 var opposite = left * lsf_scale[(is_pos - 1) / 2]; 5901 5902 if (is_pos & 1) { 5903 xr[0][l + i] = opposite; 5904 xr[1][l + i] = left; 5905 } 5906 else { 5907 xr[1][l + i] = opposite; 5908 } 5909 } 5910 } 5911 } 5912 } else { 5913 for (sfbi = l = 0; l < 576; ++sfbi, l += n) { 5914 n = sfbwidth[sfbi]; 5915 5916 if (!(modes[sfbi] & tables.I_STEREO)) 5917 continue; 5918 5919 is_pos = right_ch.scalefac[sfbi]; 5920 5921 if (is_pos >= 7) { // illegal intensity position 5922 modes[sfbi] &= ~tables.I_STEREO; 5923 continue; 5924 } 5925 5926 for (i = 0; i < n; ++i) { 5927 var left = xr[0][l + i]; 5928 xr[0][l + i] = left * tables.IS_TABLE[is_pos]; 5929 xr[1][l + i] = left * tables.IS_TABLE[6 - is_pos]; 5930 } 5931 } 5932 } 5933 } 5934 5935 // middle/side stereo 5936 if (header.mode_extension & tables.MS_STEREO) { 5937 header.flags |= tables.MS_STEREO; 5938 5939 var invsqrt2 = tables.ROOT_TABLE[3 + -2]; 5940 5941 for (sfbi = l = 0; l < 576; ++sfbi, l += n) { 5942 n = sfbwidth[sfbi]; 5943 5944 if (modes[sfbi] !== tables.MS_STEREO) 5945 continue; 5946 5947 for (i = 0; i < n; ++i) { 5948 var m = xr[0][l + i]; 5949 var s = xr[1][l + i]; 5950 5951 xr[0][l + i] = (m + s) * invsqrt2; // l = (m + s) / sqrt(2) 5952 xr[1][l + i] = (m - s) * invsqrt2; // r = (m - s) / sqrt(2) 5953 } 5954 } 5955 } 5956}; 5957 5958Layer3.prototype.aliasreduce = function(xr, lines) { 5959 for (var xrPointer = 18; xrPointer < lines; xrPointer += 18) { 5960 for (var i = 0; i < 8; ++i) { 5961 var a = xr[xrPointer - i - 1]; 5962 var b = xr[xrPointer + i]; 5963 5964 xr[xrPointer - i - 1] = a * tables.CS[i] - b * tables.CA[i]; 5965 xr[xrPointer + i] = b * tables.CS[i] + a * tables.CA[i]; 5966 } 5967 } 5968}; 5969 5970// perform IMDCT and windowing for long blocks 5971Layer3.prototype.imdct_l = function (X, z, block_type) { 5972 // IMDCT 5973 this.imdct.imdct36(X, z); 5974 5975 // windowing 5976 switch (block_type) { 5977 case 0: // normal window 5978 for (var i = 0; i < 36; ++i) z[i] = z[i] * tables.WINDOW_L[i]; 5979 break; 5980 5981 case 1: // start block 5982 for (var i = 0; i < 18; ++i) z[i] = z[i] * tables.WINDOW_L[i]; 5983 for (var i = 24; i < 30; ++i) z[i] = z[i] * tables.WINDOW_S[i - 18]; 5984 for (var i = 30; i < 36; ++i) z[i] = 0; 5985 break; 5986 5987 case 3: // stop block 5988 for (var i = 0; i < 6; ++i) z[i] = 0; 5989 for (var i = 6; i < 12; ++i) z[i] = z[i] * tables.WINDOW_S[i - 6]; 5990 for (var i = 18; i < 36; ++i) z[i] = z[i] * tables.WINDOW_L[i]; 5991 break; 5992 } 5993}; 5994 5995/* 5996 * perform IMDCT and windowing for short blocks 5997 */ 5998Layer3.prototype.imdct_s = function (X, z) { 5999 var yptr = 0; 6000 var wptr; 6001 var Xptr = 0; 6002 6003 var y = new Float64Array(36); 6004 var hi, lo; 6005 6006 // IMDCT 6007 for (var w = 0; w < 3; ++w) { 6008 var sptr = 0; 6009 6010 for (var i = 0; i < 3; ++i) { 6011 lo = X[Xptr + 0] * IMDCT.S[sptr][0] + 6012 X[Xptr + 1] * IMDCT.S[sptr][1] + 6013 X[Xptr + 2] * IMDCT.S[sptr][2] + 6014 X[Xptr + 3] * IMDCT.S[sptr][3] + 6015 X[Xptr + 4] * IMDCT.S[sptr][4] + 6016 X[Xptr + 5] * IMDCT.S[sptr][5]; 6017 6018 6019 y[yptr + i + 0] = lo; 6020 y[yptr + 5 - i] = -y[yptr + i + 0]; 6021 6022 ++sptr; 6023 6024 lo = X[Xptr + 0] * IMDCT.S[sptr][0] + 6025 X[Xptr + 1] * IMDCT.S[sptr][1] + 6026 X[Xptr + 2] * IMDCT.S[sptr][2] + 6027 X[Xptr + 3] * IMDCT.S[sptr][3] + 6028 X[Xptr + 4] * IMDCT.S[sptr][4] + 6029 X[Xptr + 5] * IMDCT.S[sptr][5]; 6030 6031 y[yptr + i + 6] = lo; 6032 y[yptr + 11 - i] = y[yptr + i + 6]; 6033 6034 ++sptr; 6035 } 6036 6037 yptr += 12; 6038 Xptr += 6; 6039 } 6040 6041 // windowing, overlapping and concatenation 6042 yptr = 0; 6043 var wptr = 0; 6044 6045 for (var i = 0; i < 6; ++i) { 6046 z[i + 0] = 0; 6047 z[i + 6] = y[yptr + 0 + 0] * tables.WINDOW_S[wptr + 0]; 6048 6049 lo = y[yptr + 0 + 6] * tables.WINDOW_S[wptr + 6] + 6050 y[yptr + 12 + 0] * tables.WINDOW_S[wptr + 0]; 6051 6052 z[i + 12] = lo; 6053 6054 lo = y[yptr + 12 + 6] * tables.WINDOW_S[wptr + 6] + 6055 y[yptr + 24 + 0] * tables.WINDOW_S[wptr + 0]; 6056 6057 z[i + 18] = lo; 6058 z[i + 24] = y[yptr + 24 + 6] * tables.WINDOW_S[wptr + 6]; 6059 z[i + 30] = 0; 6060 6061 ++yptr; 6062 ++wptr; 6063 } 6064}; 6065 6066Layer3.prototype.overlap = function (output, overlap, sample, sb) { 6067 for (var i = 0; i < 18; ++i) { 6068 sample[i][sb] = output[i] + overlap[i]; 6069 overlap[i] = output[i + 18]; 6070 } 6071}; 6072 6073Layer3.prototype.freqinver = function (sample, sb) { 6074 for (var i = 1; i < 18; i += 2) 6075 sample[i][sb] = -sample[i][sb]; 6076}; 6077 6078Layer3.prototype.overlap_z = function (overlap, sample, sb) { 6079 for (var i = 0; i < 18; ++i) { 6080 sample[i][sb] = overlap[i]; 6081 overlap[i] = 0; 6082 } 6083}; 6084 6085Layer3.prototype.reorder = function (xr, channel, sfbwidth) { 6086 var sfbwidthPointer = 0; 6087 var tmp = this.tmp; 6088 var sbw = new Uint32Array(3); 6089 var sw = new Uint32Array(3); 6090 6091 // this is probably wrong for 8000 Hz mixed blocks 6092 6093 var sb = 0; 6094 if (channel.flags & tables.MIXED_BLOCK_FLAG) { 6095 var sb = 2; 6096 6097 var l = 0; 6098 while (l < 36) 6099 l += sfbwidth[sfbwidthPointer++]; 6100 } 6101 6102 for (var w = 0; w < 3; ++w) { 6103 sbw[w] = sb; 6104 sw[w] = 0; 6105 } 6106 6107 f = sfbwidth[sfbwidthPointer++]; 6108 w = 0; 6109 6110 for (var l = 18 * sb; l < 576; ++l) { 6111 if (f-- === 0) { 6112 f = sfbwidth[sfbwidthPointer++] - 1; 6113 w = (w + 1) % 3; 6114 } 6115 6116 tmp[sbw[w]][w][sw[w]++] = xr[l]; 6117 6118 if (sw[w] === 6) { 6119 sw[w] = 0; 6120 ++sbw[w]; 6121 } 6122 } 6123 6124 var tmp2 = this.tmp2; 6125 var ptr = 0; 6126 6127 for (var i = 0; i < 32; i++) { 6128 for (var j = 0; j < 3; j++) { 6129 for (var k = 0; k < 6; k++) { 6130 tmp2[ptr++] = tmp[i][j][k]; 6131 } 6132 } 6133 } 6134 6135 var len = (576 - 18 * sb); 6136 for (var i = 0; i < len; i++) { 6137 xr[18 * sb + i] = tmp2[sb + i]; 6138 } 6139}; 6140 6141module.exports = Layer3; 6142 6143},{"./frame":4,"./header":5,"./huffman":6,"./imdct":8,"./tables":14,"./utils":15}],12:[function(require,module,exports){ 6144var AV = (window.AV); 6145var MP3FrameHeader = require('./header'); 6146 6147function MP3Stream(stream) { 6148 this.stream = stream; // actual bitstream 6149 this.sync = false; // stream sync found 6150 this.freerate = 0; // free bitrate (fixed) 6151 this.this_frame = stream.stream.offset; // start of current frame 6152 this.next_frame = stream.stream.offset; // start of next frame 6153 6154 this.main_data = new Uint8Array(MP3FrameHeader.BUFFER_MDLEN); // actual audio data 6155 this.md_len = 0; // length of main data 6156 6157 // copy methods from actual stream 6158 for (var key in stream) { 6159 if (typeof stream[key] === 'function') 6160 this[key] = stream[key].bind(stream); 6161 } 6162} 6163 6164MP3Stream.prototype.getU8 = function(offset) { 6165 var stream = this.stream.stream; 6166 return stream.peekUInt8(offset - stream.offset); 6167}; 6168 6169MP3Stream.prototype.nextByte = function() { 6170 var stream = this.stream; 6171 return stream.bitPosition === 0 ? stream.stream.offset : stream.stream.offset + 1; 6172}; 6173 6174MP3Stream.prototype.doSync = function() { 6175 var stream = this.stream.stream; 6176 this.align(); 6177 6178 while (this.available(16) && !(stream.peekUInt8(0) === 0xff && (stream.peekUInt8(1) & 0xe0) === 0xe0)) { 6179 this.advance(8); 6180 } 6181 6182 if (!this.available(MP3FrameHeader.BUFFER_GUARD)) 6183 return false; 6184 6185 return true; 6186}; 6187 6188MP3Stream.prototype.reset = function(byteOffset) { 6189 this.seek(byteOffset * 8); 6190 this.next_frame = byteOffset; 6191 this.sync = true; 6192}; 6193 6194module.exports = MP3Stream; 6195 6196},{"./header":5}],13:[function(require,module,exports){ 6197var utils = require('./utils'); 6198 6199function MP3Synth() { 6200 this.filter = utils.makeArray([2, 2, 2, 16, 8]); // polyphase filterbank outputs 6201 this.phase = 0; 6202 6203 this.pcm = { 6204 samplerate: 0, 6205 channels: 0, 6206 length: 0, 6207 samples: [new Float64Array(1152), new Float64Array(1152)] 6208 }; 6209} 6210 6211/* costab[i] = cos(PI / (2 * 32) * i) */ 6212const costab1 = 0.998795456; 6213const costab2 = 0.995184727; 6214const costab3 = 0.989176510; 6215const costab4 = 0.980785280; 6216const costab5 = 0.970031253; 6217const costab6 = 0.956940336; 6218const costab7 = 0.941544065; 6219const costab8 = 0.923879533; 6220const costab9 = 0.903989293; 6221const costab10 = 0.881921264; 6222const costab11 = 0.857728610; 6223const costab12 = 0.831469612; 6224const costab13 = 0.803207531; 6225const costab14 = 0.773010453; 6226const costab15 = 0.740951125; 6227const costab16 = 0.707106781; 6228const costab17 = 0.671558955; 6229const costab18 = 0.634393284; 6230const costab19 = 0.595699304; 6231const costab20 = 0.555570233; 6232const costab21 = 0.514102744; 6233const costab22 = 0.471396737; 6234const costab23 = 0.427555093; 6235const costab24 = 0.382683432; 6236const costab25 = 0.336889853; 6237const costab26 = 0.290284677; 6238const costab27 = 0.242980180; 6239const costab28 = 0.195090322; 6240const costab29 = 0.146730474; 6241const costab30 = 0.098017140; 6242const costab31 = 0.049067674; 6243 6244/* 6245 * NAME: dct32() 6246 * DESCRIPTION: perform fast in[32].out[32] DCT 6247 */ 6248MP3Synth.dct32 = function (_in, slot, lo, hi) { 6249 var t0, t1, t2, t3, t4, t5, t6, t7; 6250 var t8, t9, t10, t11, t12, t13, t14, t15; 6251 var t16, t17, t18, t19, t20, t21, t22, t23; 6252 var t24, t25, t26, t27, t28, t29, t30, t31; 6253 var t32, t33, t34, t35, t36, t37, t38, t39; 6254 var t40, t41, t42, t43, t44, t45, t46, t47; 6255 var t48, t49, t50, t51, t52, t53, t54, t55; 6256 var t56, t57, t58, t59, t60, t61, t62, t63; 6257 var t64, t65, t66, t67, t68, t69, t70, t71; 6258 var t72, t73, t74, t75, t76, t77, t78, t79; 6259 var t80, t81, t82, t83, t84, t85, t86, t87; 6260 var t88, t89, t90, t91, t92, t93, t94, t95; 6261 var t96, t97, t98, t99, t100, t101, t102, t103; 6262 var t104, t105, t106, t107, t108, t109, t110, t111; 6263 var t112, t113, t114, t115, t116, t117, t118, t119; 6264 var t120, t121, t122, t123, t124, t125, t126, t127; 6265 var t128, t129, t130, t131, t132, t133, t134, t135; 6266 var t136, t137, t138, t139, t140, t141, t142, t143; 6267 var t144, t145, t146, t147, t148, t149, t150, t151; 6268 var t152, t153, t154, t155, t156, t157, t158, t159; 6269 var t160, t161, t162, t163, t164, t165, t166, t167; 6270 var t168, t169, t170, t171, t172, t173, t174, t175; 6271 var t176; 6272 6273 t0 = _in[0] + _in[31]; t16 = ((_in[0] - _in[31]) * (costab1)); 6274 t1 = _in[15] + _in[16]; t17 = ((_in[15] - _in[16]) * (costab31)); 6275 6276 t41 = t16 + t17; 6277 t59 = ((t16 - t17) * (costab2)); 6278 t33 = t0 + t1; 6279 t50 = ((t0 - t1) * ( costab2)); 6280 6281 t2 = _in[7] + _in[24]; t18 = ((_in[7] - _in[24]) * (costab15)); 6282 t3 = _in[8] + _in[23]; t19 = ((_in[8] - _in[23]) * (costab17)); 6283 6284 t42 = t18 + t19; 6285 t60 = ((t18 - t19) * (costab30)); 6286 t34 = t2 + t3; 6287 t51 = ((t2 - t3) * ( costab30)); 6288 6289 t4 = _in[3] + _in[28]; t20 = ((_in[3] - _in[28]) * (costab7)); 6290 t5 = _in[12] + _in[19]; t21 = ((_in[12] - _in[19]) * (costab25)); 6291 6292 t43 = t20 + t21; 6293 t61 = ((t20 - t21) * (costab14)); 6294 t35 = t4 + t5; 6295 t52 = ((t4 - t5) * ( costab14)); 6296 6297 t6 = _in[4] + _in[27]; t22 = ((_in[4] - _in[27]) * (costab9)); 6298 t7 = _in[11] + _in[20]; t23 = ((_in[11] - _in[20]) * (costab23)); 6299 6300 t44 = t22 + t23; 6301 t62 = ((t22 - t23) * (costab18)); 6302 t36 = t6 + t7; 6303 t53 = ((t6 - t7) * ( costab18)); 6304 6305 t8 = _in[1] + _in[30]; t24 = ((_in[1] - _in[30]) * (costab3)); 6306 t9 = _in[14] + _in[17]; t25 = ((_in[14] - _in[17]) * (costab29)); 6307 6308 t45 = t24 + t25; 6309 t63 = ((t24 - t25) * (costab6)); 6310 t37 = t8 + t9; 6311 t54 = ((t8 - t9) * ( costab6)); 6312 6313 t10 = _in[6] + _in[25]; t26 = ((_in[6] - _in[25]) * (costab13)); 6314 t11 = _in[9] + _in[22]; t27 = ((_in[9] - _in[22]) * (costab19)); 6315 6316 t46 = t26 + t27; 6317 t64 = ((t26 - t27) * (costab26)); 6318 t38 = t10 + t11; 6319 t55 = ((t10 - t11) * (costab26)); 6320 6321 t12 = _in[2] + _in[29]; t28 = ((_in[2] - _in[29]) * (costab5)); 6322 t13 = _in[13] + _in[18]; t29 = ((_in[13] - _in[18]) * (costab27)); 6323 6324 t47 = t28 + t29; 6325 t65 = ((t28 - t29) * (costab10)); 6326 t39 = t12 + t13; 6327 t56 = ((t12 - t13) * (costab10)); 6328 6329 t14 = _in[5] + _in[26]; t30 = ((_in[5] - _in[26]) * (costab11)); 6330 t15 = _in[10] + _in[21]; t31 = ((_in[10] - _in[21]) * (costab21)); 6331 6332 t48 = t30 + t31; 6333 t66 = ((t30 - t31) * (costab22)); 6334 t40 = t14 + t15; 6335 t57 = ((t14 - t15) * (costab22)); 6336 6337 t69 = t33 + t34; t89 = ((t33 - t34) * (costab4)); 6338 t70 = t35 + t36; t90 = ((t35 - t36) * (costab28)); 6339 t71 = t37 + t38; t91 = ((t37 - t38) * (costab12)); 6340 t72 = t39 + t40; t92 = ((t39 - t40) * (costab20)); 6341 t73 = t41 + t42; t94 = ((t41 - t42) * (costab4)); 6342 t74 = t43 + t44; t95 = ((t43 - t44) * (costab28)); 6343 t75 = t45 + t46; t96 = ((t45 - t46) * (costab12)); 6344 t76 = t47 + t48; t97 = ((t47 - t48) * (costab20)); 6345 6346 t78 = t50 + t51; t100 = ((t50 - t51) * (costab4)); 6347 t79 = t52 + t53; t101 = ((t52 - t53) * (costab28)); 6348 t80 = t54 + t55; t102 = ((t54 - t55) * (costab12)); 6349 t81 = t56 + t57; t103 = ((t56 - t57) * (costab20)); 6350 6351 t83 = t59 + t60; t106 = ((t59 - t60) * (costab4)); 6352 t84 = t61 + t62; t107 = ((t61 - t62) * (costab28)); 6353 t85 = t63 + t64; t108 = ((t63 - t64) * (costab12)); 6354 t86 = t65 + t66; t109 = ((t65 - t66) * (costab20)); 6355 6356 t113 = t69 + t70; 6357 t114 = t71 + t72; 6358 6359 /* 0 */ hi[15][slot] = t113 + t114; 6360 /* 16 */ lo[ 0][slot] = ((t113 - t114) * (costab16)); 6361 6362 t115 = t73 + t74; 6363 t116 = t75 + t76; 6364 6365 t32 = t115 + t116; 6366 6367 /* 1 */ hi[14][slot] = t32; 6368 6369 t118 = t78 + t79; 6370 t119 = t80 + t81; 6371 6372 t58 = t118 + t119; 6373 6374 /* 2 */ hi[13][slot] = t58; 6375 6376 t121 = t83 + t84; 6377 t122 = t85 + t86; 6378 6379 t67 = t121 + t122; 6380 6381 t49 = (t67 * 2) - t32; 6382 6383 /* 3 */ hi[12][slot] = t49; 6384 6385 t125 = t89 + t90; 6386 t126 = t91 + t92; 6387 6388 t93 = t125 + t126; 6389 6390 /* 4 */ hi[11][slot] = t93; 6391 6392 t128 = t94 + t95; 6393 t129 = t96 + t97; 6394 6395 t98 = t128 + t129; 6396 6397 t68 = (t98 * 2) - t49; 6398 6399 /* 5 */ hi[10][slot] = t68; 6400 6401 t132 = t100 + t101; 6402 t133 = t102 + t103; 6403 6404 t104 = t132 + t133; 6405 6406 t82 = (t104 * 2) - t58; 6407 6408 /* 6 */ hi[ 9][slot] = t82; 6409 6410 t136 = t106 + t107; 6411 t137 = t108 + t109; 6412 6413 t110 = t136 + t137; 6414 6415 t87 = (t110 * 2) - t67; 6416 6417 t77 = (t87 * 2) - t68; 6418 6419 /* 7 */ hi[ 8][slot] = t77; 6420 6421 t141 = ((t69 - t70) * (costab8)); 6422 t142 = ((t71 - t72) * (costab24)); 6423 t143 = t141 + t142; 6424 6425 /* 8 */ hi[ 7][slot] = t143; 6426 /* 24 */ lo[ 8][slot] = 6427 (((t141 - t142) * (costab16) * 2)) - t143; 6428 6429 t144 = ((t73 - t74) * (costab8)); 6430 t145 = ((t75 - t76) * (costab24)); 6431 t146 = t144 + t145; 6432 6433 t88 = (t146 * 2) - t77; 6434 6435 /* 9 */ hi[ 6][slot] = t88; 6436 6437 t148 = ((t78 - t79) * (costab8)); 6438 t149 = ((t80 - t81) * (costab24)); 6439 t150 = t148 + t149; 6440 6441 t105 = (t150 * 2) - t82; 6442 6443 /* 10 */ hi[ 5][slot] = t105; 6444 6445 t152 = ((t83 - t84) * (costab8)); 6446 t153 = ((t85 - t86) * (costab24)); 6447 t154 = t152 + t153; 6448 6449 t111 = (t154 * 2) - t87; 6450 6451 t99 = (t111 * 2) - t88; 6452 6453 /* 11 */ hi[ 4][slot] = t99; 6454 6455 t157 = ((t89 - t90) * (costab8)); 6456 t158 = ((t91 - t92) * (costab24)); 6457 t159 = t157 + t158; 6458 6459 t127 = (t159 * 2) - t93; 6460 6461 /* 12 */ hi[ 3][slot] = t127; 6462 6463 t160 = (((t125 - t126) * (costab16) * 2)) - t127; 6464 6465 /* 20 */ lo[ 4][slot] = t160; 6466 /* 28 */ lo[12][slot] = 6467 (((((t157 - t158) * (costab16) * 2) - t159) * 2)) - t160; 6468 6469 t161 = ((t94 - t95) * (costab8)); 6470 t162 = ((t96 - t97) * (costab24)); 6471 t163 = t161 + t162; 6472 6473 t130 = (t163 * 2) - t98; 6474 6475 t112 = (t130 * 2) - t99; 6476 6477 /* 13 */ hi[ 2][slot] = t112; 6478 6479 t164 = (((t128 - t129) * (costab16) * 2)) - t130; 6480 6481 t166 = ((t100 - t101) * (costab8)); 6482 t167 = ((t102 - t103) * (costab24)); 6483 t168 = t166 + t167; 6484 6485 t134 = (t168 * 2) - t104; 6486 6487 t120 = (t134 * 2) - t105; 6488 6489 /* 14 */ hi[ 1][slot] = t120; 6490 6491 t135 = (((t118 - t119) * (costab16) * 2)) - t120; 6492 6493 /* 18 */ lo[ 2][slot] = t135; 6494 6495 t169 = (((t132 - t133) * (costab16) * 2)) - t134; 6496 6497 t151 = (t169 * 2) - t135; 6498 6499 /* 22 */ lo[ 6][slot] = t151; 6500 6501 t170 = (((((t148 - t149) * (costab16) * 2) - t150) * 2)) - t151; 6502 6503 /* 26 */ lo[10][slot] = t170; 6504 /* 30 */ lo[14][slot] = 6505 (((((((t166 - t167) * (costab16)) * 2 - 6506 t168) * 2) - t169) * 2) - t170); 6507 6508 t171 = ((t106 - t107) * (costab8)); 6509 t172 = ((t108 - t109) * (costab24)); 6510 t173 = t171 + t172; 6511 6512 t138 = (t173 * 2) - t110; 6513 t123 = (t138 * 2) - t111; 6514 t139 = (((t121 - t122) * (costab16) * 2)) - t123; 6515 t117 = (t123 * 2) - t112; 6516 6517 /* 15 */ hi[ 0][slot] = t117; 6518 6519 t124 = (((t115 - t116) * (costab16) * 2)) - t117; 6520 6521 /* 17 */ lo[ 1][slot] = t124; 6522 6523 t131 = (t139 * 2) - t124; 6524 6525 /* 19 */ lo[ 3][slot] = t131; 6526 6527 t140 = (t164 * 2) - t131; 6528 6529 /* 21 */ lo[ 5][slot] = t140; 6530 6531 t174 = (((t136 - t137) * (costab16) * 2)) - t138; 6532 t155 = (t174 * 2) - t139; 6533 t147 = (t155 * 2) - t140; 6534 6535 /* 23 */ lo[ 7][slot] = t147; 6536 6537 t156 = (((((t144 - t145) * (costab16) * 2) - t146) * 2)) - t147; 6538 6539 /* 25 */ lo[ 9][slot] = t156; 6540 6541 t175 = (((((t152 - t153) * (costab16) * 2) - t154) * 2)) - t155; 6542 t165 = (t175 * 2) - t156; 6543 6544 /* 27 */ lo[11][slot] = t165; 6545 6546 t176 = (((((((t161 - t162) * (costab16) * 2)) - 6547 t163) * 2) - t164) * 2) - t165; 6548 6549 /* 29 */ lo[13][slot] = t176; 6550 /* 31 */ lo[15][slot] = 6551 (((((((((t171 - t172) * (costab16)) * 2 - 6552 t173) * 2) - t174) * 2) - t175) * 2) - t176); 6553 6554 /* 6555 * Totals: 6556 * 80 multiplies 6557 * 80 additions 6558 * 119 subtractions 6559 * 49 shifts (not counting SSO) 6560 */ 6561}; 6562 6563/* 6564 * These are the coefficients for the subband synthesis window. This is a 6565 * reordered version of Table B.3 from ISO/IEC 11172-3. 6566 */ 6567const D = [ 6568 [ 0.000000000, /* 0 */ 6569 -0.000442505, 6570 0.003250122, 6571 -0.007003784, 6572 0.031082153, 6573 -0.078628540, 6574 0.100311279, 6575 -0.572036743, 6576 1.144989014, 6577 0.572036743, 6578 0.100311279, 6579 0.078628540, 6580 0.031082153, 6581 0.007003784, 6582 0.003250122, 6583 0.000442505, 6584 6585 0.000000000, 6586 -0.000442505, 6587 0.003250122, 6588 -0.007003784, 6589 0.031082153, 6590 -0.078628540, 6591 0.100311279, 6592 -0.572036743, 6593 1.144989014, 6594 0.572036743, 6595 0.100311279, 6596 0.078628540, 6597 0.031082153, 6598 0.007003784, 6599 0.003250122, 6600 0.000442505 ], 6601 6602 [ -0.000015259, /* 1 */ 6603 -0.000473022, 6604 0.003326416, 6605 -0.007919312, 6606 0.030517578, 6607 -0.084182739, 6608 0.090927124, 6609 -0.600219727, 6610 1.144287109, 6611 0.543823242, 6612 0.108856201, 6613 0.073059082, 6614 0.031478882, 6615 0.006118774, 6616 0.003173828, 6617 0.000396729, 6618 6619 -0.000015259, 6620 -0.000473022, 6621 0.003326416, 6622 -0.007919312, 6623 0.030517578, 6624 -0.084182739, 6625 0.090927124, 6626 -0.600219727, 6627 1.144287109, 6628 0.543823242, 6629 0.108856201, 6630 0.073059082, 6631 0.031478882, 6632 0.006118774, 6633 0.003173828, 6634 0.000396729 ], 6635 6636 [ -0.000015259, /* 2 */ 6637 -0.000534058, 6638 0.003387451, 6639 -0.008865356, 6640 0.029785156, 6641 -0.089706421, 6642 0.080688477, 6643 -0.628295898, 6644 1.142211914, 6645 0.515609741, 6646 0.116577148, 6647 0.067520142, 6648 0.031738281, 6649 0.005294800, 6650 0.003082275, 6651 0.000366211, 6652 6653 -0.000015259, 6654 -0.000534058, 6655 0.003387451, 6656 -0.008865356, 6657 0.029785156, 6658 -0.089706421, 6659 0.080688477, 6660 -0.628295898, 6661 1.142211914, 6662 0.515609741, 6663 0.116577148, 6664 0.067520142, 6665 0.031738281, 6666 0.005294800, 6667 0.003082275, 6668 0.000366211 ], 6669 6670 [ -0.000015259, /* 3 */ 6671 -0.000579834, 6672 0.003433228, 6673 -0.009841919, 6674 0.028884888, 6675 -0.095169067, 6676 0.069595337, 6677 -0.656219482, 6678 1.138763428, 6679 0.487472534, 6680 0.123474121, 6681 0.061996460, 6682 0.031845093, 6683 0.004486084, 6684 0.002990723, 6685 0.000320435, 6686 6687 -0.000015259, 6688 -0.000579834, 6689 0.003433228, 6690 -0.009841919, 6691 0.028884888, 6692 -0.095169067, 6693 0.069595337, 6694 -0.656219482, 6695 1.138763428, 6696 0.487472534, 6697 0.123474121, 6698 0.061996460, 6699 0.031845093, 6700 0.004486084, 6701 0.002990723, 6702 0.000320435 ], 6703 6704 [ -0.000015259, /* 4 */ 6705 -0.000625610, 6706 0.003463745, 6707 -0.010848999, 6708 0.027801514, 6709 -0.100540161, 6710 0.057617187, 6711 -0.683914185, 6712 1.133926392, 6713 0.459472656, 6714 0.129577637, 6715 0.056533813, 6716 0.031814575, 6717 0.003723145, 6718 0.002899170, 6719 0.000289917, 6720 6721 -0.000015259, 6722 -0.000625610, 6723 0.003463745, 6724 -0.010848999, 6725 0.027801514, 6726 -0.100540161, 6727 0.057617187, 6728 -0.683914185, 6729 1.133926392, 6730 0.459472656, 6731 0.129577637, 6732 0.056533813, 6733 0.031814575, 6734 0.003723145, 6735 0.002899170, 6736 0.000289917 ], 6737 6738 [ -0.000015259, /* 5 */ 6739 -0.000686646, 6740 0.003479004, 6741 -0.011886597, 6742 0.026535034, 6743 -0.105819702, 6744 0.044784546, 6745 -0.711318970, 6746 1.127746582, 6747 0.431655884, 6748 0.134887695, 6749 0.051132202, 6750 0.031661987, 6751 0.003005981, 6752 0.002792358, 6753 0.000259399, 6754 6755 -0.000015259, 6756 -0.000686646, 6757 0.003479004, 6758 -0.011886597, 6759 0.026535034, 6760 -0.105819702, 6761 0.044784546, 6762 -0.711318970, 6763 1.127746582, 6764 0.431655884, 6765 0.134887695, 6766 0.051132202, 6767 0.031661987, 6768 0.003005981, 6769 0.002792358, 6770 0.000259399 ], 6771 6772 [ -0.000015259, /* 6 */ 6773 -0.000747681, 6774 0.003479004, 6775 -0.012939453, 6776 0.025085449, 6777 -0.110946655, 6778 0.031082153, 6779 -0.738372803, 6780 1.120223999, 6781 0.404083252, 6782 0.139450073, 6783 0.045837402, 6784 0.031387329, 6785 0.002334595, 6786 0.002685547, 6787 0.000244141, 6788 6789 -0.000015259, 6790 -0.000747681, 6791 0.003479004, 6792 -0.012939453, 6793 0.025085449, 6794 -0.110946655, 6795 0.031082153, 6796 -0.738372803, 6797 1.120223999, 6798 0.404083252, 6799 0.139450073, 6800 0.045837402, 6801 0.031387329, 6802 0.002334595, 6803 0.002685547, 6804 0.000244141 ], 6805 6806 [ -0.000030518, /* 7 */ 6807 -0.000808716, 6808 0.003463745, 6809 -0.014022827, 6810 0.023422241, 6811 -0.115921021, 6812 0.016510010, 6813 -0.765029907, 6814 1.111373901, 6815 0.376800537, 6816 0.143264771, 6817 0.040634155, 6818 0.031005859, 6819 0.001693726, 6820 0.002578735, 6821 0.000213623, 6822 6823 -0.000030518, 6824 -0.000808716, 6825 0.003463745, 6826 -0.014022827, 6827 0.023422241, 6828 -0.115921021, 6829 0.016510010, 6830 -0.765029907, 6831 1.111373901, 6832 0.376800537, 6833 0.143264771, 6834 0.040634155, 6835 0.031005859, 6836 0.001693726, 6837 0.002578735, 6838 0.000213623 ], 6839 6840 [ -0.000030518, /* 8 */ 6841 -0.000885010, 6842 0.003417969, 6843 -0.015121460, 6844 0.021575928, 6845 -0.120697021, 6846 0.001068115, 6847 -0.791213989, 6848 1.101211548, 6849 0.349868774, 6850 0.146362305, 6851 0.035552979, 6852 0.030532837, 6853 0.001098633, 6854 0.002456665, 6855 0.000198364, 6856 6857 -0.000030518, 6858 -0.000885010, 6859 0.003417969, 6860 -0.015121460, 6861 0.021575928, 6862 -0.120697021, 6863 0.001068115, 6864 -0.791213989, 6865 1.101211548, 6866 0.349868774, 6867 0.146362305, 6868 0.035552979, 6869 0.030532837, 6870 0.001098633, 6871 0.002456665, 6872 0.000198364 ], 6873 6874 [ -0.000030518, /* 9 */ 6875 -0.000961304, 6876 0.003372192, 6877 -0.016235352, 6878 0.019531250, 6879 -0.125259399, 6880 -0.015228271, 6881 -0.816864014, 6882 1.089782715, 6883 0.323318481, 6884 0.148773193, 6885 0.030609131, 6886 0.029937744, 6887 0.000549316, 6888 0.002349854, 6889 0.000167847, 6890 6891 -0.000030518, 6892 -0.000961304, 6893 0.003372192, 6894 -0.016235352, 6895 0.019531250, 6896 -0.125259399, 6897 -0.015228271, 6898 -0.816864014, 6899 1.089782715, 6900 0.323318481, 6901 0.148773193, 6902 0.030609131, 6903 0.029937744, 6904 0.000549316, 6905 0.002349854, 6906 0.000167847 ], 6907 6908 [ -0.000030518, /* 10 */ 6909 -0.001037598, 6910 0.003280640, 6911 -0.017349243, 6912 0.017257690, 6913 -0.129562378, 6914 -0.032379150, 6915 -0.841949463, 6916 1.077117920, 6917 0.297210693, 6918 0.150497437, 6919 0.025817871, 6920 0.029281616, 6921 0.000030518, 6922 0.002243042, 6923 0.000152588, 6924 6925 -0.000030518, 6926 -0.001037598, 6927 0.003280640, 6928 -0.017349243, 6929 0.017257690, 6930 -0.129562378, 6931 -0.032379150, 6932 -0.841949463, 6933 1.077117920, 6934 0.297210693, 6935 0.150497437, 6936 0.025817871, 6937 0.029281616, 6938 0.000030518, 6939 0.002243042, 6940 0.000152588 ], 6941 6942 [ -0.000045776, /* 11 */ 6943 -0.001113892, 6944 0.003173828, 6945 -0.018463135, 6946 0.014801025, 6947 -0.133590698, 6948 -0.050354004, 6949 -0.866363525, 6950 1.063217163, 6951 0.271591187, 6952 0.151596069, 6953 0.021179199, 6954 0.028533936, 6955 -0.000442505, 6956 0.002120972, 6957 0.000137329, 6958 6959 -0.000045776, 6960 -0.001113892, 6961 0.003173828, 6962 -0.018463135, 6963 0.014801025, 6964 -0.133590698, 6965 -0.050354004, 6966 -0.866363525, 6967 1.063217163, 6968 0.271591187, 6969 0.151596069, 6970 0.021179199, 6971 0.028533936, 6972 -0.000442505, 6973 0.002120972, 6974 0.000137329 ], 6975 6976 [ -0.000045776, /* 12 */ 6977 -0.001205444, 6978 0.003051758, 6979 -0.019577026, 6980 0.012115479, 6981 -0.137298584, 6982 -0.069168091, 6983 -0.890090942, 6984 1.048156738, 6985 0.246505737, 6986 0.152069092, 6987 0.016708374, 6988 0.027725220, 6989 -0.000869751, 6990 0.002014160, 6991 0.000122070, 6992 6993 -0.000045776, 6994 -0.001205444, 6995 0.003051758, 6996 -0.019577026, 6997 0.012115479, 6998 -0.137298584, 6999 -0.069168091, 7000 -0.890090942, 7001 1.048156738, 7002 0.246505737, 7003 0.152069092, 7004 0.016708374, 7005 0.027725220, 7006 -0.000869751, 7007 0.002014160, 7008 0.000122070 ], 7009 7010 [ -0.000061035, /* 13 */ 7011 -0.001296997, 7012 0.002883911, 7013 -0.020690918, 7014 0.009231567, 7015 -0.140670776, 7016 -0.088775635, 7017 -0.913055420, 7018 1.031936646, 7019 0.221984863, 7020 0.151962280, 7021 0.012420654, 7022 0.026840210, 7023 -0.001266479, 7024 0.001907349, 7025 0.000106812, 7026 7027 -0.000061035, 7028 -0.001296997, 7029 0.002883911, 7030 -0.020690918, 7031 0.009231567, 7032 -0.140670776, 7033 -0.088775635, 7034 -0.913055420, 7035 1.031936646, 7036 0.221984863, 7037 0.151962280, 7038 0.012420654, 7039 0.026840210, 7040 -0.001266479, 7041 0.001907349, 7042 0.000106812 ], 7043 7044 [ -0.000061035, /* 14 */ 7045 -0.001388550, 7046 0.002700806, 7047 -0.021789551, 7048 0.006134033, 7049 -0.143676758, 7050 -0.109161377, 7051 -0.935195923, 7052 1.014617920, 7053 0.198059082, 7054 0.151306152, 7055 0.008316040, 7056 0.025909424, 7057 -0.001617432, 7058 0.001785278, 7059 0.000106812, 7060 7061 -0.000061035, 7062 -0.001388550, 7063 0.002700806, 7064 -0.021789551, 7065 0.006134033, 7066 -0.143676758, 7067 -0.109161377, 7068 -0.935195923, 7069 1.014617920, 7070 0.198059082, 7071 0.151306152, 7072 0.008316040, 7073 0.025909424, 7074 -0.001617432, 7075 0.001785278, 7076 0.000106812 ], 7077 7078 [ -0.000076294, /* 15 */ 7079 -0.001480103, 7080 0.002487183, 7081 -0.022857666, 7082 0.002822876, 7083 -0.146255493, 7084 -0.130310059, 7085 -0.956481934, 7086 0.996246338, 7087 0.174789429, 7088 0.150115967, 7089 0.004394531, 7090 0.024932861, 7091 -0.001937866, 7092 0.001693726, 7093 0.000091553, 7094 7095 -0.000076294, 7096 -0.001480103, 7097 0.002487183, 7098 -0.022857666, 7099 0.002822876, 7100 -0.146255493, 7101 -0.130310059, 7102 -0.956481934, 7103 0.996246338, 7104 0.174789429, 7105 0.150115967, 7106 0.004394531, 7107 0.024932861, 7108 -0.001937866, 7109 0.001693726, 7110 0.000091553 ], 7111 7112 [ -0.000076294, /* 16 */ 7113 -0.001586914, 7114 0.002227783, 7115 -0.023910522, 7116 -0.000686646, 7117 -0.148422241, 7118 -0.152206421, 7119 -0.976852417, 7120 0.976852417, 7121 0.152206421, 7122 0.148422241, 7123 0.000686646, 7124 0.023910522, 7125 -0.002227783, 7126 0.001586914, 7127 0.000076294, 7128 7129 -0.000076294, 7130 -0.001586914, 7131 0.002227783, 7132 -0.023910522, 7133 -0.000686646, 7134 -0.148422241, 7135 -0.152206421, 7136 -0.976852417, 7137 0.976852417, 7138 0.152206421, 7139 0.148422241, 7140 0.000686646, 7141 0.023910522, 7142 -0.002227783, 7143 0.001586914, 7144 0.000076294 ] 7145]; 7146 7147/* 7148 * perform full frequency PCM synthesis 7149 */ 7150MP3Synth.prototype.full = function(frame, nch, ns) { 7151 var Dptr, hi, lo, ptr; 7152 7153 for (var ch = 0; ch < nch; ++ch) { 7154 var sbsample = frame.sbsample[ch]; 7155 var filter = this.filter[ch]; 7156 var phase = this.phase; 7157 var pcm = this.pcm.samples[ch]; 7158 var pcm1Ptr = 0; 7159 var pcm2Ptr = 0; 7160 7161 for (var s = 0; s < ns; ++s) { 7162 MP3Synth.dct32(sbsample[s], phase >> 1, filter[0][phase & 1], filter[1][phase & 1]); 7163 7164 var pe = phase & ~1; 7165 var po = ((phase - 1) & 0xf) | 1; 7166 7167 /* calculate 32 samples */ 7168 var fe = filter[0][ phase & 1]; 7169 var fx = filter[0][~phase & 1]; 7170 var fo = filter[1][~phase & 1]; 7171 7172 var fePtr = 0; 7173 var fxPtr = 0; 7174 var foPtr = 0; 7175 7176 Dptr = 0; 7177 7178 ptr = D[Dptr]; 7179 _fx = fx[fxPtr]; 7180 _fe = fe[fePtr]; 7181 7182 lo = _fx[0] * ptr[po + 0]; 7183 lo += _fx[1] * ptr[po + 14]; 7184 lo += _fx[2] * ptr[po + 12]; 7185 lo += _fx[3] * ptr[po + 10]; 7186 lo += _fx[4] * ptr[po + 8]; 7187 lo += _fx[5] * ptr[po + 6]; 7188 lo += _fx[6] * ptr[po + 4]; 7189 lo += _fx[7] * ptr[po + 2]; 7190 lo = -lo; 7191 7192 lo += _fe[0] * ptr[pe + 0]; 7193 lo += _fe[1] * ptr[pe + 14]; 7194 lo += _fe[2] * ptr[pe + 12]; 7195 lo += _fe[3] * ptr[pe + 10]; 7196 lo += _fe[4] * ptr[pe + 8]; 7197 lo += _fe[5] * ptr[pe + 6]; 7198 lo += _fe[6] * ptr[pe + 4]; 7199 lo += _fe[7] * ptr[pe + 2]; 7200 7201 pcm[pcm1Ptr++] = lo; 7202 pcm2Ptr = pcm1Ptr + 30; 7203 7204 for (var sb = 1; sb < 16; ++sb) { 7205 ++fePtr; 7206 ++Dptr; 7207 7208 /* D[32 - sb][i] === -D[sb][31 - i] */ 7209 7210 ptr = D[Dptr]; 7211 _fo = fo[foPtr]; 7212 _fe = fe[fePtr]; 7213 7214 lo = _fo[0] * ptr[po + 0]; 7215 lo += _fo[1] * ptr[po + 14]; 7216 lo += _fo[2] * ptr[po + 12]; 7217 lo += _fo[3] * ptr[po + 10]; 7218 lo += _fo[4] * ptr[po + 8]; 7219 lo += _fo[5] * ptr[po + 6]; 7220 lo += _fo[6] * ptr[po + 4]; 7221 lo += _fo[7] * ptr[po + 2]; 7222 lo = -lo; 7223 7224 lo += _fe[7] * ptr[pe + 2]; 7225 lo += _fe[6] * ptr[pe + 4]; 7226 lo += _fe[5] * ptr[pe + 6]; 7227 lo += _fe[4] * ptr[pe + 8]; 7228 lo += _fe[3] * ptr[pe + 10]; 7229 lo += _fe[2] * ptr[pe + 12]; 7230 lo += _fe[1] * ptr[pe + 14]; 7231 lo += _fe[0] * ptr[pe + 0]; 7232 7233 pcm[pcm1Ptr++] = lo; 7234 7235 lo = _fe[0] * ptr[-pe + 31 - 16]; 7236 lo += _fe[1] * ptr[-pe + 31 - 14]; 7237 lo += _fe[2] * ptr[-pe + 31 - 12]; 7238 lo += _fe[3] * ptr[-pe + 31 - 10]; 7239 lo += _fe[4] * ptr[-pe + 31 - 8]; 7240 lo += _fe[5] * ptr[-pe + 31 - 6]; 7241 lo += _fe[6] * ptr[-pe + 31 - 4]; 7242 lo += _fe[7] * ptr[-pe + 31 - 2]; 7243 7244 lo += _fo[7] * ptr[-po + 31 - 2]; 7245 lo += _fo[6] * ptr[-po + 31 - 4]; 7246 lo += _fo[5] * ptr[-po + 31 - 6]; 7247 lo += _fo[4] * ptr[-po + 31 - 8]; 7248 lo += _fo[3] * ptr[-po + 31 - 10]; 7249 lo += _fo[2] * ptr[-po + 31 - 12]; 7250 lo += _fo[1] * ptr[-po + 31 - 14]; 7251 lo += _fo[0] * ptr[-po + 31 - 16]; 7252 7253 pcm[pcm2Ptr--] = lo; 7254 ++foPtr; 7255 } 7256 7257 ++Dptr; 7258 7259 ptr = D[Dptr]; 7260 _fo = fo[foPtr]; 7261 7262 lo = _fo[0] * ptr[po + 0]; 7263 lo += _fo[1] * ptr[po + 14]; 7264 lo += _fo[2] * ptr[po + 12]; 7265 lo += _fo[3] * ptr[po + 10]; 7266 lo += _fo[4] * ptr[po + 8]; 7267 lo += _fo[5] * ptr[po + 6]; 7268 lo += _fo[6] * ptr[po + 4]; 7269 lo += _fo[7] * ptr[po + 2]; 7270 7271 pcm[pcm1Ptr] = -lo; 7272 pcm1Ptr += 16; 7273 phase = (phase + 1) % 16; 7274 } 7275 } 7276}; 7277 7278// TODO: synth.half() 7279 7280/* 7281 * NAME: synth.frame() 7282 * DESCRIPTION: perform PCM synthesis of frame subband samples 7283 */ 7284MP3Synth.prototype.frame = function (frame) { 7285 var nch = frame.header.nchannels(); 7286 var ns = frame.header.nbsamples(); 7287 7288 this.pcm.samplerate = frame.header.samplerate; 7289 this.pcm.channels = nch; 7290 this.pcm.length = 32 * ns; 7291 7292 /* 7293 if (frame.options & Mad.Option.HALFSAMPLERATE) { 7294 this.pcm.samplerate /= 2; 7295 this.pcm.length /= 2; 7296 7297 throw new Error("HALFSAMPLERATE is not supported. What do you think? As if I have the time for this"); 7298 } 7299 */ 7300 7301 this.full(frame, nch, ns); 7302 this.phase = (this.phase + ns) % 16; 7303}; 7304 7305module.exports = MP3Synth; 7306 7307},{"./utils":15}],14:[function(require,module,exports){ 7308/* 7309 * These are the scalefactor values for Layer I and Layer II. 7310 * The values are from Table B.1 of ISO/IEC 11172-3. 7311 * 7312 * Strictly speaking, Table B.1 has only 63 entries (0-62), thus a strict 7313 * interpretation of ISO/IEC 11172-3 would suggest that a scalefactor index of 7314 * 63 is invalid. However, for better compatibility with current practices, we 7315 * add a 64th entry. 7316 */ 7317exports.SF_TABLE = new Float32Array([ 7318 2.000000000000, 1.587401051968, 1.259921049895, 1.000000000000, 7319 0.793700525984, 0.629960524947, 0.500000000000, 0.396850262992, 7320 0.314980262474, 0.250000000000, 0.198425131496, 0.157490131237, 7321 0.125000000000, 0.099212565748, 0.078745065618, 0.062500000000, 7322 0.049606282874, 0.039372532809, 0.031250000000, 0.024803141437, 7323 0.019686266405, 0.015625000000, 0.012401570719, 0.009843133202, 7324 0.007812500000, 0.006200785359, 0.004921566601, 0.003906250000, 7325 0.003100392680, 0.002460783301, 0.001953125000, 0.001550196340, 7326 0.001230391650, 0.000976562500, 0.000775098170, 0.000615195825, 7327 0.000488281250, 0.000387549085, 0.000307597913, 0.000244140625, 7328 0.000193774542, 0.000153798956, 0.000122070313, 0.000096887271, 7329 0.000076899478, 0.000061035156, 0.000048443636, 0.000038449739, 7330 0.000030517578, 0.000024221818, 0.000019224870, 0.000015258789, 7331 0.000012110909, 0.000009612435, 0.000007629395, 0.000006055454, 7332 0.000004806217, 0.000003814697, 0.000003027727, 0.000002403109, 7333 0.000001907349, 0.000001513864, 0.000001201554, 0.000000000000 7334]); 7335 7336/* 7337 * MPEG-1 scalefactor band widths 7338 * derived from Table B.8 of ISO/IEC 11172-3 7339 */ 7340const SFB_48000_LONG = new Uint8Array([ 7341 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10, 7342 12, 16, 18, 22, 28, 34, 40, 46, 54, 54, 192 7343]); 7344 7345const SFB_44100_LONG = new Uint8Array([ 7346 4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10, 7347 12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158 7348]); 7349 7350const SFB_32000_LONG = new Uint8Array([ 7351 4, 4, 4, 4, 4, 4, 6, 6, 8, 10, 12, 7352 16, 20, 24, 30, 38, 46, 56, 68, 84, 102, 26 7353]); 7354 7355const SFB_48000_SHORT = new Uint8Array([ 7356 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 7357 6, 6, 6, 6, 6, 10, 10, 10, 12, 12, 12, 14, 14, 7358 14, 16, 16, 16, 20, 20, 20, 26, 26, 26, 66, 66, 66 7359]); 7360 7361const SFB_44100_SHORT = new Uint8Array([ 7362 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 7363 6, 6, 8, 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, 7364 14, 18, 18, 18, 22, 22, 22, 30, 30, 30, 56, 56, 56 7365]); 7366 7367const SFB_32000_SHORT = new Uint8Array([ 7368 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 7369 6, 6, 8, 8, 8, 12, 12, 12, 16, 16, 16, 20, 20, 7370 20, 26, 26, 26, 34, 34, 34, 42, 42, 42, 12, 12, 12 7371]); 7372 7373const SFB_48000_MIXED = new Uint8Array([ 7374 /* long */ 4, 4, 4, 4, 4, 4, 6, 6, 7375 /* short */ 4, 4, 4, 6, 6, 6, 6, 6, 6, 10, 7376 10, 10, 12, 12, 12, 14, 14, 14, 16, 16, 7377 16, 20, 20, 20, 26, 26, 26, 66, 66, 66 7378]); 7379 7380const SFB_44100_MIXED = new Uint8Array([ 7381 /* long */ 4, 4, 4, 4, 4, 4, 6, 6, 7382 /* short */ 4, 4, 4, 6, 6, 6, 8, 8, 8, 10, 7383 10, 10, 12, 12, 12, 14, 14, 14, 18, 18, 7384 18, 22, 22, 22, 30, 30, 30, 56, 56, 56 7385]); 7386 7387const SFB_32000_MIXED = new Uint8Array([ 7388 /* long */ 4, 4, 4, 4, 4, 4, 6, 6, 7389 /* short */ 4, 4, 4, 6, 6, 6, 8, 8, 8, 12, 7390 12, 12, 16, 16, 16, 20, 20, 20, 26, 26, 7391 26, 34, 34, 34, 42, 42, 42, 12, 12, 12 7392]); 7393 7394/* 7395 * MPEG-2 scalefactor band widths 7396 * derived from Table B.2 of ISO/IEC 13818-3 7397 */ 7398const SFB_24000_LONG = new Uint8Array([ 7399 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 7400 18, 22, 26, 32, 38, 46, 54, 62, 70, 76, 36 7401]); 7402 7403const SFB_22050_LONG = new Uint8Array([ 7404 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 7405 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54 7406]); 7407 7408const SFB_16000_LONG = SFB_22050_LONG; 7409 7410const SFB_24000_SHORT = new Uint8Array([ 7411 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 7412 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, 14, 18, 18, 7413 18, 24, 24, 24, 32, 32, 32, 44, 44, 44, 12, 12, 12 7414]); 7415 7416const SFB_22050_SHORT = new Uint8Array([ 7417 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7418 6, 6, 8, 8, 8, 10, 10, 10, 14, 14, 14, 18, 18, 7419 18, 26, 26, 26, 32, 32, 32, 42, 42, 42, 18, 18, 18 7420]); 7421 7422const SFB_16000_SHORT = new Uint8Array([ 7423 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 7424 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, 14, 18, 18, 7425 18, 24, 24, 24, 30, 30, 30, 40, 40, 40, 18, 18, 18 7426]); 7427 7428const SFB_24000_MIXED = new Uint8Array([ 7429 /* long */ 6, 6, 6, 6, 6, 6, 7430 /* short */ 6, 6, 6, 8, 8, 8, 10, 10, 10, 12, 7431 12, 12, 14, 14, 14, 18, 18, 18, 24, 24, 7432 24, 32, 32, 32, 44, 44, 44, 12, 12, 12 7433]); 7434 7435const SFB_22050_MIXED = new Uint8Array([ 7436 /* long */ 6, 6, 6, 6, 6, 6, 7437 /* short */ 6, 6, 6, 6, 6, 6, 8, 8, 8, 10, 7438 10, 10, 14, 14, 14, 18, 18, 18, 26, 26, 7439 26, 32, 32, 32, 42, 42, 42, 18, 18, 18 7440]); 7441 7442const SFB_16000_MIXED = new Uint8Array([ 7443 /* long */ 6, 6, 6, 6, 6, 6, 7444 /* short */ 6, 6, 6, 8, 8, 8, 10, 10, 10, 12, 7445 12, 12, 14, 14, 14, 18, 18, 18, 24, 24, 7446 24, 30, 30, 30, 40, 40, 40, 18, 18, 18 7447]); 7448 7449/* 7450 * MPEG 2.5 scalefactor band widths 7451 * derived from public sources 7452 */ 7453const SFB_12000_LONG = SFB_16000_LONG; 7454const SFB_11025_LONG = SFB_12000_LONG; 7455 7456const SFB_8000_LONG = new Uint8Array([ 7457 12, 12, 12, 12, 12, 12, 16, 20, 24, 28, 32, 7458 40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2 7459]); 7460 7461const SFB_12000_SHORT = SFB_16000_SHORT; 7462const SFB_11025_SHORT = SFB_12000_SHORT; 7463 7464const SFB_8000_SHORT = new Uint8Array([ 7465 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 16, 7466 16, 16, 20, 20, 20, 24, 24, 24, 28, 28, 28, 36, 36, 7467 36, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26 7468]); 7469 7470const SFB_12000_MIXED = SFB_16000_MIXED; 7471const SFB_11025_MIXED = SFB_12000_MIXED; 7472 7473/* the 8000 Hz short block scalefactor bands do not break after 7474 the first 36 frequency lines, so this is probably wrong */ 7475const SFB_8000_MIXED = new Uint8Array([ 7476 /* long */ 12, 12, 12, 7477 /* short */ 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16, 7478 20, 20, 20, 24, 24, 24, 28, 28, 28, 36, 36, 36, 7479 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26 7480]); 7481 7482exports.SFBWIDTH_TABLE = [ 7483 { l: SFB_48000_LONG, s: SFB_48000_SHORT, m: SFB_48000_MIXED }, 7484 { l: SFB_44100_LONG, s: SFB_44100_SHORT, m: SFB_44100_MIXED }, 7485 { l: SFB_32000_LONG, s: SFB_32000_SHORT, m: SFB_32000_MIXED }, 7486 { l: SFB_24000_LONG, s: SFB_24000_SHORT, m: SFB_24000_MIXED }, 7487 { l: SFB_22050_LONG, s: SFB_22050_SHORT, m: SFB_22050_MIXED }, 7488 { l: SFB_16000_LONG, s: SFB_16000_SHORT, m: SFB_16000_MIXED }, 7489 { l: SFB_12000_LONG, s: SFB_12000_SHORT, m: SFB_12000_MIXED }, 7490 { l: SFB_11025_LONG, s: SFB_11025_SHORT, m: SFB_11025_MIXED }, 7491 { l: SFB_8000_LONG, s: SFB_8000_SHORT, m: SFB_8000_MIXED } 7492]; 7493 7494exports.PRETAB = new Uint8Array([ 7495 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 7496]); 7497 7498/* 7499 * fractional powers of two 7500 * used for requantization and joint stereo decoding 7501 * 7502 * ROOT_TABLE[3 + x] = 2^(x/4) 7503 */ 7504exports.ROOT_TABLE = new Float32Array([ 7505 /* 2^(-3/4) */ 0.59460355750136, 7506 /* 2^(-2/4) */ 0.70710678118655, 7507 /* 2^(-1/4) */ 0.84089641525371, 7508 /* 2^( 0/4) */ 1.00000000000000, 7509 /* 2^(+1/4) */ 1.18920711500272, 7510 /* 2^(+2/4) */ 1.41421356237310, 7511 /* 2^(+3/4) */ 1.68179283050743 7512]); 7513 7514exports.CS = new Float32Array([ 7515 +0.857492926 , +0.881741997, 7516 +0.949628649 , +0.983314592, 7517 +0.995517816 , +0.999160558, 7518 +0.999899195 , +0.999993155 7519]); 7520 7521exports.CA = new Float32Array([ 7522 -0.514495755, -0.471731969, 7523 -0.313377454, -0.181913200, 7524 -0.094574193, -0.040965583, 7525 -0.014198569, -0.003699975 7526]); 7527 7528exports.COUNT1TABLE_SELECT = 0x01; 7529exports.SCALEFAC_SCALE = 0x02; 7530exports.PREFLAG = 0x04; 7531exports.MIXED_BLOCK_FLAG = 0x08; 7532 7533exports.I_STEREO = 0x1; 7534exports.MS_STEREO = 0x2; 7535 7536/* 7537 * windowing coefficients for long blocks 7538 * derived from section 2.4.3.4.10.3 of ISO/IEC 11172-3 7539 * 7540 * WINDOW_L[i] = sin((PI / 36) * (i + 1/2)) 7541 */ 7542exports.WINDOW_L = new Float32Array([ 7543 0.043619387, 0.130526192, 7544 0.216439614, 0.300705800, 7545 0.382683432, 0.461748613, 7546 0.537299608, 0.608761429, 7547 0.675590208, 0.737277337, 7548 0.793353340, 0.843391446, 7549 7550 0.887010833, 0.923879533, 7551 0.953716951, 0.976296007, 7552 0.991444861, 0.999048222, 7553 0.999048222, 0.991444861, 7554 0.976296007, 0.953716951, 7555 0.923879533, 0.887010833, 7556 7557 0.843391446, 0.793353340, 7558 0.737277337, 0.675590208, 7559 0.608761429, 0.537299608, 7560 0.461748613, 0.382683432, 7561 0.300705800, 0.216439614, 7562 0.130526192, 0.043619387 7563]); 7564 7565/* 7566 * windowing coefficients for short blocks 7567 * derived from section 2.4.3.4.10.3 of ISO/IEC 11172-3 7568 * 7569 * WINDOW_S[i] = sin((PI / 12) * (i + 1/2)) 7570 */ 7571exports.WINDOW_S = new Float32Array([ 7572 0.130526192, 0.382683432, 7573 0.608761429, 0.793353340, 7574 0.923879533, 0.991444861, 7575 0.991444861, 0.923879533, 7576 0.793353340, 0.608761429, 7577 0.382683432, 0.130526192 7578]); 7579 7580/* 7581 * coefficients for intensity stereo processing 7582 * derived from section 2.4.3.4.9.3 of ISO/IEC 11172-3 7583 * 7584 * is_ratio[i] = tan(i * (PI / 12)) 7585 * IS_TABLE[i] = is_ratio[i] / (1 + is_ratio[i]) 7586 */ 7587exports.IS_TABLE = new Float32Array([ 7588 0.000000000, 7589 0.211324865, 7590 0.366025404, 7591 0.500000000, 7592 0.633974596, 7593 0.788675135, 7594 1.000000000 7595]); 7596 7597/* 7598 * coefficients for LSF intensity stereo processing 7599 * derived from section 2.4.3.2 of ISO/IEC 13818-3 7600 * 7601 * IS_LSF_TABLE[0][i] = (1 / sqrt(sqrt(2)))^(i + 1) 7602 * IS_LSF_TABLE[1][i] = (1 / sqrt(2)) ^(i + 1) 7603 */ 7604exports.IS_LSF_TABLE = [ 7605 new Float32Array([ 7606 0.840896415, 7607 0.707106781, 7608 0.594603558, 7609 0.500000000, 7610 0.420448208, 7611 0.353553391, 7612 0.297301779, 7613 0.250000000, 7614 0.210224104, 7615 0.176776695, 7616 0.148650889, 7617 0.125000000, 7618 0.105112052, 7619 0.088388348, 7620 0.074325445 7621 ]), 7622 new Float32Array([ 7623 0.707106781, 7624 0.500000000, 7625 0.353553391, 7626 0.250000000, 7627 0.176776695, 7628 0.125000000, 7629 0.088388348, 7630 0.062500000, 7631 0.044194174, 7632 0.031250000, 7633 0.022097087, 7634 0.015625000, 7635 0.011048543, 7636 0.007812500, 7637 0.005524272 7638 ]) 7639]; 7640 7641/* 7642 * scalefactor bit lengths 7643 * derived from section 2.4.2.7 of ISO/IEC 11172-3 7644 */ 7645exports.SFLEN_TABLE = [ 7646 { slen1: 0, slen2: 0 }, { slen1: 0, slen2: 1 }, { slen1: 0, slen2: 2 }, { slen1: 0, slen2: 3 }, 7647 { slen1: 3, slen2: 0 }, { slen1: 1, slen2: 1 }, { slen1: 1, slen2: 2 }, { slen1: 1, slen2: 3 }, 7648 { slen1: 2, slen2: 1 }, { slen1: 2, slen2: 2 }, { slen1: 2, slen2: 3 }, { slen1: 3, slen2: 1 }, 7649 { slen1: 3, slen2: 2 }, { slen1: 3, slen2: 3 }, { slen1: 4, slen2: 2 }, { slen1: 4, slen2: 3 } 7650]; 7651 7652/* 7653 * number of LSF scalefactor band values 7654 * derived from section 2.4.3.2 of ISO/IEC 13818-3 7655 */ 7656exports.NSFB_TABLE = [ 7657 [ [ 6, 5, 5, 5 ], 7658 [ 9, 9, 9, 9 ], 7659 [ 6, 9, 9, 9 ] ], 7660 7661 [ [ 6, 5, 7, 3 ], 7662 [ 9, 9, 12, 6 ], 7663 [ 6, 9, 12, 6 ] ], 7664 7665 [ [ 11, 10, 0, 0 ], 7666 [ 18, 18, 0, 0 ], 7667 [ 15, 18, 0, 0 ] ], 7668 7669 [ [ 7, 7, 7, 0 ], 7670 [ 12, 12, 12, 0 ], 7671 [ 6, 15, 12, 0 ] ], 7672 7673 [ [ 6, 6, 6, 3 ], 7674 [ 12, 9, 9, 6 ], 7675 [ 6, 12, 9, 6 ] ], 7676 7677 [ [ 8, 8, 5, 0 ], 7678 [ 15, 12, 9, 0 ], 7679 [ 6, 18, 9, 0 ] ] 7680]; 7681 7682},{}],15:[function(require,module,exports){ 7683/** 7684 * Makes a multidimensional array 7685 */ 7686exports.makeArray = function(lengths, Type) { 7687 if (!Type) Type = Float64Array; 7688 7689 if (lengths.length === 1) { 7690 return new Type(lengths[0]); 7691 } 7692 7693 var ret = [], 7694 len = lengths[0]; 7695 7696 for (var j = 0; j < len; j++) { 7697 ret[j] = exports.makeArray(lengths.slice(1), Type); 7698 } 7699 7700 return ret; 7701}; 7702 7703},{}]},{},[1]) 7704 7705 7706//# sourceMappingURL=mp3.js.map