123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683 |
- JSMpeg.Decoder.MPEG1Video = (function(){ "use strict";
- var MPEG1 = function(options) {
- JSMpeg.Decoder.Base.call(this, options);
- this.onDecodeCallback = options.onVideoDecode;
- var bufferSize = options.videoBufferSize || 512*1024;
- var bufferMode = options.streaming
- ? JSMpeg.BitBuffer.MODE.EVICT
- : JSMpeg.BitBuffer.MODE.EXPAND;
- this.bits = new JSMpeg.BitBuffer(bufferSize, bufferMode);
- this.customIntraQuantMatrix = new Uint8Array(64);
- this.customNonIntraQuantMatrix = new Uint8Array(64);
- this.blockData = new Int32Array(64);
- this.currentFrame = 0;
- this.decodeFirstFrame = options.decodeFirstFrame !== false;
- };
- MPEG1.prototype = Object.create(JSMpeg.Decoder.Base.prototype);
- MPEG1.prototype.constructor = MPEG1;
- MPEG1.prototype.write = function(pts, buffers) {
- JSMpeg.Decoder.Base.prototype.write.call(this, pts, buffers);
- if (!this.hasSequenceHeader) {
- if (this.bits.findStartCode(MPEG1.START.SEQUENCE) === -1) {
- return false;
- }
- this.decodeSequenceHeader();
- if (this.decodeFirstFrame) {
- this.decode();
- }
- }
- };
- MPEG1.prototype.decode = function() {
- var startTime = JSMpeg.Now();
-
- if (!this.hasSequenceHeader) {
- return false;
- }
- if (this.bits.findStartCode(MPEG1.START.PICTURE) === -1) {
- var bufferedBytes = this.bits.byteLength - (this.bits.index >> 3);
- return false;
- }
- this.decodePicture();
- this.advanceDecodedTime(1/this.frameRate);
- var elapsedTime = JSMpeg.Now() - startTime;
- if (this.onDecodeCallback) {
- this.onDecodeCallback(this, elapsedTime);
- }
- return true;
- };
- MPEG1.prototype.readHuffman = function(codeTable) {
- var state = 0;
- do {
- state = codeTable[state + this.bits.read(1)];
- } while (state >= 0 && codeTable[state] !== 0);
- return codeTable[state+2];
- };
- MPEG1.prototype.frameRate = 30;
- MPEG1.prototype.decodeSequenceHeader = function() {
- var newWidth = this.bits.read(12),
- newHeight = this.bits.read(12);
-
- this.bits.skip(4);
- this.frameRate = MPEG1.PICTURE_RATE[this.bits.read(4)];
-
- this.bits.skip(18 + 1 + 10 + 1);
- if (newWidth !== this.width || newHeight !== this.height) {
- this.width = newWidth;
- this.height = newHeight;
- this.initBuffers();
- if (this.destination) {
- this.destination.resize(newWidth, newHeight);
- }
- }
- if (this.bits.read(1)) {
- for (var i = 0; i < 64; i++) {
- this.customIntraQuantMatrix[MPEG1.ZIG_ZAG[i]] = this.bits.read(8);
- }
- this.intraQuantMatrix = this.customIntraQuantMatrix;
- }
- if (this.bits.read(1)) {
- for (var i = 0; i < 64; i++) {
- var idx = MPEG1.ZIG_ZAG[i];
- this.customNonIntraQuantMatrix[idx] = this.bits.read(8);
- }
- this.nonIntraQuantMatrix = this.customNonIntraQuantMatrix;
- }
- this.hasSequenceHeader = true;
- };
- MPEG1.prototype.initBuffers = function() {
- this.intraQuantMatrix = MPEG1.DEFAULT_INTRA_QUANT_MATRIX;
- this.nonIntraQuantMatrix = MPEG1.DEFAULT_NON_INTRA_QUANT_MATRIX;
- this.mbWidth = (this.width + 15) >> 4;
- this.mbHeight = (this.height + 15) >> 4;
- this.mbSize = this.mbWidth * this.mbHeight;
- this.codedWidth = this.mbWidth << 4;
- this.codedHeight = this.mbHeight << 4;
- this.codedSize = this.codedWidth * this.codedHeight;
- this.halfWidth = this.mbWidth << 3;
- this.halfHeight = this.mbHeight << 3;
-
- this.currentY = new Uint8ClampedArray(this.codedSize);
- this.currentY32 = new Uint32Array(this.currentY.buffer);
- this.currentCr = new Uint8ClampedArray(this.codedSize >> 2);
- this.currentCr32 = new Uint32Array(this.currentCr.buffer);
- this.currentCb = new Uint8ClampedArray(this.codedSize >> 2);
- this.currentCb32 = new Uint32Array(this.currentCb.buffer);
- this.forwardY = new Uint8ClampedArray(this.codedSize);
- this.forwardY32 = new Uint32Array(this.forwardY.buffer);
- this.forwardCr = new Uint8ClampedArray(this.codedSize >> 2);
- this.forwardCr32 = new Uint32Array(this.forwardCr.buffer);
- this.forwardCb = new Uint8ClampedArray(this.codedSize >> 2);
- this.forwardCb32 = new Uint32Array(this.forwardCb.buffer);
- };
- MPEG1.prototype.currentY = null;
- MPEG1.prototype.currentCr = null;
- MPEG1.prototype.currentCb = null;
- MPEG1.prototype.pictureType = 0;
- MPEG1.prototype.forwardY = null;
- MPEG1.prototype.forwardCr = null;
- MPEG1.prototype.forwardCb = null;
- MPEG1.prototype.fullPelForward = false;
- MPEG1.prototype.forwardFCode = 0;
- MPEG1.prototype.forwardRSize = 0;
- MPEG1.prototype.forwardF = 0;
- MPEG1.prototype.decodePicture = function(skipOutput) {
- this.currentFrame++;
- this.bits.skip(10);
- this.pictureType = this.bits.read(3);
- this.bits.skip(16);
-
- if (this.pictureType <= 0 || this.pictureType >= MPEG1.PICTURE_TYPE.B) {
- return;
- }
-
- if (this.pictureType === MPEG1.PICTURE_TYPE.PREDICTIVE) {
- this.fullPelForward = this.bits.read(1);
- this.forwardFCode = this.bits.read(3);
- if (this.forwardFCode === 0) {
-
- return;
- }
- this.forwardRSize = this.forwardFCode - 1;
- this.forwardF = 1 << this.forwardRSize;
- }
- var code = 0;
- do {
- code = this.bits.findNextStartCode();
- } while (code === MPEG1.START.EXTENSION || code === MPEG1.START.USER_DATA );
- while (code >= MPEG1.START.SLICE_FIRST && code <= MPEG1.START.SLICE_LAST) {
- this.decodeSlice(code & 0x000000FF);
- code = this.bits.findNextStartCode();
- }
- if (code !== -1) {
-
-
- this.bits.rewind(32);
- }
-
- if (this.destination) {
- this.destination.render(this.currentY, this.currentCr, this.currentCb, true);
- }
-
- if (
- this.pictureType === MPEG1.PICTURE_TYPE.INTRA ||
- this.pictureType === MPEG1.PICTURE_TYPE.PREDICTIVE
- ) {
- var
- tmpY = this.forwardY,
- tmpY32 = this.forwardY32,
- tmpCr = this.forwardCr,
- tmpCr32 = this.forwardCr32,
- tmpCb = this.forwardCb,
- tmpCb32 = this.forwardCb32;
- this.forwardY = this.currentY;
- this.forwardY32 = this.currentY32;
- this.forwardCr = this.currentCr;
- this.forwardCr32 = this.currentCr32;
- this.forwardCb = this.currentCb;
- this.forwardCb32 = this.currentCb32;
- this.currentY = tmpY;
- this.currentY32 = tmpY32;
- this.currentCr = tmpCr;
- this.currentCr32 = tmpCr32;
- this.currentCb = tmpCb;
- this.currentCb32 = tmpCb32;
- }
- };
- MPEG1.prototype.quantizerScale = 0;
- MPEG1.prototype.sliceBegin = false;
- MPEG1.prototype.decodeSlice = function(slice) {
- this.sliceBegin = true;
- this.macroblockAddress = (slice - 1) * this.mbWidth - 1;
-
- this.motionFwH = this.motionFwHPrev = 0;
- this.motionFwV = this.motionFwVPrev = 0;
- this.dcPredictorY = 128;
- this.dcPredictorCr = 128;
- this.dcPredictorCb = 128;
- this.quantizerScale = this.bits.read(5);
-
- while (this.bits.read(1)) {
- this.bits.skip(8);
- }
- do {
- this.decodeMacroblock();
- } while (!this.bits.nextBytesAreStartCode());
- };
- MPEG1.prototype.macroblockAddress = 0;
- MPEG1.prototype.mbRow = 0;
- MPEG1.prototype.mbCol = 0;
- MPEG1.prototype.macroblockType = 0;
- MPEG1.prototype.macroblockIntra = false;
- MPEG1.prototype.macroblockMotFw = false;
- MPEG1.prototype.motionFwH = 0;
- MPEG1.prototype.motionFwV = 0;
- MPEG1.prototype.motionFwHPrev = 0;
- MPEG1.prototype.motionFwVPrev = 0;
- MPEG1.prototype.decodeMacroblock = function() {
-
- var
- increment = 0,
- t = this.readHuffman(MPEG1.MACROBLOCK_ADDRESS_INCREMENT);
- while (t === 34) {
-
- t = this.readHuffman(MPEG1.MACROBLOCK_ADDRESS_INCREMENT);
- }
- while (t === 35) {
-
- increment += 33;
- t = this.readHuffman(MPEG1.MACROBLOCK_ADDRESS_INCREMENT);
- }
- increment += t;
-
- if (this.sliceBegin) {
-
-
- this.sliceBegin = false;
- this.macroblockAddress += increment;
- }
- else {
- if (this.macroblockAddress + increment >= this.mbSize) {
-
- return;
- }
- if (increment > 1) {
-
- this.dcPredictorY = 128;
- this.dcPredictorCr = 128;
- this.dcPredictorCb = 128;
-
- if (this.pictureType === MPEG1.PICTURE_TYPE.PREDICTIVE) {
- this.motionFwH = this.motionFwHPrev = 0;
- this.motionFwV = this.motionFwVPrev = 0;
- }
- }
-
- while (increment > 1) {
- this.macroblockAddress++;
- this.mbRow = (this.macroblockAddress / this.mbWidth)|0;
- this.mbCol = this.macroblockAddress % this.mbWidth;
- this.copyMacroblock(
- this.motionFwH, this.motionFwV,
- this.forwardY, this.forwardCr, this.forwardCb
- );
- increment--;
- }
- this.macroblockAddress++;
- }
- this.mbRow = (this.macroblockAddress / this.mbWidth)|0;
- this.mbCol = this.macroblockAddress % this.mbWidth;
-
- var mbTable = MPEG1.MACROBLOCK_TYPE[this.pictureType];
- this.macroblockType = this.readHuffman(mbTable);
- this.macroblockIntra = (this.macroblockType & 0x01);
- this.macroblockMotFw = (this.macroblockType & 0x08);
-
- if ((this.macroblockType & 0x10) !== 0) {
- this.quantizerScale = this.bits.read(5);
- }
- if (this.macroblockIntra) {
-
- this.motionFwH = this.motionFwHPrev = 0;
- this.motionFwV = this.motionFwVPrev = 0;
- }
- else {
-
- this.dcPredictorY = 128;
- this.dcPredictorCr = 128;
- this.dcPredictorCb = 128;
- this.decodeMotionVectors();
- this.copyMacroblock(
- this.motionFwH, this.motionFwV,
- this.forwardY, this.forwardCr, this.forwardCb
- );
- }
-
- var cbp = ((this.macroblockType & 0x02) !== 0)
- ? this.readHuffman(MPEG1.CODE_BLOCK_PATTERN)
- : (this.macroblockIntra ? 0x3f : 0);
- for (var block = 0, mask = 0x20; block < 6; block++) {
- if ((cbp & mask) !== 0) {
- this.decodeBlock(block);
- }
- mask >>= 1;
- }
- };
- MPEG1.prototype.decodeMotionVectors = function() {
- var code, d, r = 0;
-
- if (this.macroblockMotFw) {
-
- code = this.readHuffman(MPEG1.MOTION);
- if ((code !== 0) && (this.forwardF !== 1)) {
- r = this.bits.read(this.forwardRSize);
- d = ((Math.abs(code) - 1) << this.forwardRSize) + r + 1;
- if (code < 0) {
- d = -d;
- }
- }
- else {
- d = code;
- }
- this.motionFwHPrev += d;
- if (this.motionFwHPrev > (this.forwardF << 4) - 1) {
- this.motionFwHPrev -= this.forwardF << 5;
- }
- else if (this.motionFwHPrev < ((-this.forwardF) << 4)) {
- this.motionFwHPrev += this.forwardF << 5;
- }
- this.motionFwH = this.motionFwHPrev;
- if (this.fullPelForward) {
- this.motionFwH <<= 1;
- }
-
- code = this.readHuffman(MPEG1.MOTION);
- if ((code !== 0) && (this.forwardF !== 1)) {
- r = this.bits.read(this.forwardRSize);
- d = ((Math.abs(code) - 1) << this.forwardRSize) + r + 1;
- if (code < 0) {
- d = -d;
- }
- }
- else {
- d = code;
- }
- this.motionFwVPrev += d;
- if (this.motionFwVPrev > (this.forwardF << 4) - 1) {
- this.motionFwVPrev -= this.forwardF << 5;
- }
- else if (this.motionFwVPrev < ((-this.forwardF) << 4)) {
- this.motionFwVPrev += this.forwardF << 5;
- }
- this.motionFwV = this.motionFwVPrev;
- if (this.fullPelForward) {
- this.motionFwV <<= 1;
- }
- }
- else if (this.pictureType === MPEG1.PICTURE_TYPE.PREDICTIVE) {
-
- this.motionFwH = this.motionFwHPrev = 0;
- this.motionFwV = this.motionFwVPrev = 0;
- }
- };
- MPEG1.prototype.copyMacroblock = function(motionH, motionV, sY, sCr, sCb) {
- var
- width, scan,
- H, V, oddH, oddV,
- src, dest, last;
-
- var dY = this.currentY32,
- dCb = this.currentCb32,
- dCr = this.currentCr32;
-
- width = this.codedWidth;
- scan = width - 16;
- H = motionH >> 1;
- V = motionV >> 1;
- oddH = (motionH & 1) === 1;
- oddV = (motionV & 1) === 1;
- src = ((this.mbRow << 4) + V) * width + (this.mbCol << 4) + H;
- dest = (this.mbRow * width + this.mbCol) << 2;
- last = dest + (width << 2);
- var x, y1, y2, y;
- if (oddH) {
- if (oddV) {
- while (dest < last) {
- y1 = sY[src] + sY[src+width]; src++;
- for (x = 0; x < 4; x++) {
- y2 = sY[src] + sY[src+width]; src++;
- y = (((y1 + y2 + 2) >> 2) & 0xff);
- y1 = sY[src] + sY[src+width]; src++;
- y |= (((y1 + y2 + 2) << 6) & 0xff00);
- y2 = sY[src] + sY[src+width]; src++;
- y |= (((y1 + y2 + 2) << 14) & 0xff0000);
- y1 = sY[src] + sY[src+width]; src++;
- y |= (((y1 + y2 + 2) << 22) & 0xff000000);
- dY[dest++] = y;
- }
- dest += scan >> 2; src += scan-1;
- }
- }
- else {
- while (dest < last) {
- y1 = sY[src++];
- for (x = 0; x < 4; x++) {
- y2 = sY[src++];
- y = (((y1 + y2 + 1) >> 1) & 0xff);
- y1 = sY[src++];
- y |= (((y1 + y2 + 1) << 7) & 0xff00);
- y2 = sY[src++];
- y |= (((y1 + y2 + 1) << 15) & 0xff0000);
- y1 = sY[src++];
- y |= (((y1 + y2 + 1) << 23) & 0xff000000);
- dY[dest++] = y;
- }
- dest += scan >> 2; src += scan-1;
- }
- }
- }
- else {
- if (oddV) {
- while (dest < last) {
- for (x = 0; x < 4; x++) {
- y = (((sY[src] + sY[src+width] + 1) >> 1) & 0xff); src++;
- y |= (((sY[src] + sY[src+width] + 1) << 7) & 0xff00); src++;
- y |= (((sY[src] + sY[src+width] + 1) << 15) & 0xff0000); src++;
- y |= (((sY[src] + sY[src+width] + 1) << 23) & 0xff000000); src++;
- dY[dest++] = y;
- }
- dest += scan >> 2; src += scan;
- }
- }
- else {
- while (dest < last) {
- for (x = 0; x < 4; x++) {
- y = sY[src]; src++;
- y |= sY[src] << 8; src++;
- y |= sY[src] << 16; src++;
- y |= sY[src] << 24; src++;
- dY[dest++] = y;
- }
- dest += scan >> 2; src += scan;
- }
- }
- }
-
- width = this.halfWidth;
- scan = width - 8;
- H = (motionH/2) >> 1;
- V = (motionV/2) >> 1;
- oddH = ((motionH/2) & 1) === 1;
- oddV = ((motionV/2) & 1) === 1;
- src = ((this.mbRow << 3) + V) * width + (this.mbCol << 3) + H;
- dest = (this.mbRow * width + this.mbCol) << 1;
- last = dest + (width << 1);
- var cr1, cr2, cr,
- cb1, cb2, cb;
- if (oddH) {
- if (oddV) {
- while (dest < last) {
- cr1 = sCr[src] + sCr[src+width];
- cb1 = sCb[src] + sCb[src+width];
- src++;
- for (x = 0; x < 2; x++) {
- cr2 = sCr[src] + sCr[src+width];
- cb2 = sCb[src] + sCb[src+width]; src++;
- cr = (((cr1 + cr2 + 2) >> 2) & 0xff);
- cb = (((cb1 + cb2 + 2) >> 2) & 0xff);
- cr1 = sCr[src] + sCr[src+width];
- cb1 = sCb[src] + sCb[src+width]; src++;
- cr |= (((cr1 + cr2 + 2) << 6) & 0xff00);
- cb |= (((cb1 + cb2 + 2) << 6) & 0xff00);
- cr2 = sCr[src] + sCr[src+width];
- cb2 = sCb[src] + sCb[src+width]; src++;
- cr |= (((cr1 + cr2 + 2) << 14) & 0xff0000);
- cb |= (((cb1 + cb2 + 2) << 14) & 0xff0000);
- cr1 = sCr[src] + sCr[src+width];
- cb1 = sCb[src] + sCb[src+width]; src++;
- cr |= (((cr1 + cr2 + 2) << 22) & 0xff000000);
- cb |= (((cb1 + cb2 + 2) << 22) & 0xff000000);
- dCr[dest] = cr;
- dCb[dest] = cb;
- dest++;
- }
- dest += scan >> 2; src += scan-1;
- }
- }
- else {
- while (dest < last) {
- cr1 = sCr[src];
- cb1 = sCb[src];
- src++;
- for (x = 0; x < 2; x++) {
- cr2 = sCr[src];
- cb2 = sCb[src++];
- cr = (((cr1 + cr2 + 1) >> 1) & 0xff);
- cb = (((cb1 + cb2 + 1) >> 1) & 0xff);
- cr1 = sCr[src];
- cb1 = sCb[src++];
- cr |= (((cr1 + cr2 + 1) << 7) & 0xff00);
- cb |= (((cb1 + cb2 + 1) << 7) & 0xff00);
- cr2 = sCr[src];
- cb2 = sCb[src++];
- cr |= (((cr1 + cr2 + 1) << 15) & 0xff0000);
- cb |= (((cb1 + cb2 + 1) << 15) & 0xff0000);
- cr1 = sCr[src];
- cb1 = sCb[src++];
- cr |= (((cr1 + cr2 + 1) << 23) & 0xff000000);
- cb |= (((cb1 + cb2 + 1) << 23) & 0xff000000);
- dCr[dest] = cr;
- dCb[dest] = cb;
- dest++;
- }
- dest += scan >> 2; src += scan-1;
- }
- }
- }
- else {
- if (oddV) {
- while (dest < last) {
- for (x = 0; x < 2; x++) {
- cr = (((sCr[src] + sCr[src+width] + 1) >> 1) & 0xff);
- cb = (((sCb[src] + sCb[src+width] + 1) >> 1) & 0xff); src++;
- cr |= (((sCr[src] + sCr[src+width] + 1) << 7) & 0xff00);
- cb |= (((sCb[src] + sCb[src+width] + 1) << 7) & 0xff00); src++;
- cr |= (((sCr[src] + sCr[src+width] + 1) << 15) & 0xff0000);
- cb |= (((sCb[src] + sCb[src+width] + 1) << 15) & 0xff0000); src++;
- cr |= (((sCr[src] + sCr[src+width] + 1) << 23) & 0xff000000);
- cb |= (((sCb[src] + sCb[src+width] + 1) << 23) & 0xff000000); src++;
- dCr[dest] = cr;
- dCb[dest] = cb;
- dest++;
- }
- dest += scan >> 2; src += scan;
- }
- }
- else {
- while (dest < last) {
- for (x = 0; x < 2; x++) {
- cr = sCr[src];
- cb = sCb[src]; src++;
- cr |= sCr[src] << 8;
- cb |= sCb[src] << 8; src++;
- cr |= sCr[src] << 16;
- cb |= sCb[src] << 16; src++;
- cr |= sCr[src] << 24;
- cb |= sCb[src] << 24; src++;
- dCr[dest] = cr;
- dCb[dest] = cb;
- dest++;
- }
- dest += scan >> 2; src += scan;
- }
- }
- }
- };
- MPEG1.prototype.dcPredictorY = 0;
- MPEG1.prototype.dcPredictorCr = 0;
- MPEG1.prototype.dcPredictorCb = 0;
- MPEG1.prototype.blockData = null;
- MPEG1.prototype.decodeBlock = function(block) {
- var
- n = 0,
- quantMatrix;
-
- if (this.macroblockIntra) {
- var
- predictor,
- dctSize;
-
- if (block < 4) {
- predictor = this.dcPredictorY;
- dctSize = this.readHuffman(MPEG1.DCT_DC_SIZE_LUMINANCE);
- }
- else {
- predictor = (block === 4 ? this.dcPredictorCr : this.dcPredictorCb);
- dctSize = this.readHuffman(MPEG1.DCT_DC_SIZE_CHROMINANCE);
- }
-
- if (dctSize > 0) {
- var differential = this.bits.read(dctSize);
- if ((differential & (1 << (dctSize - 1))) !== 0) {
- this.blockData[0] = predictor + differential;
- }
- else {
- this.blockData[0] = predictor + ((-1 << dctSize)|(differential+1));
- }
- }
- else {
- this.blockData[0] = predictor;
- }
-
- if (block < 4) {
- this.dcPredictorY = this.blockData[0];
- }
- else if (block === 4) {
- this.dcPredictorCr = this.blockData[0];
- }
- else {
- this.dcPredictorCb = this.blockData[0];
- }
-
- this.blockData[0] <<= (3 + 5);
- quantMatrix = this.intraQuantMatrix;
- n = 1;
- }
- else {
- quantMatrix = this.nonIntraQuantMatrix;
- }
-
- var level = 0;
- while (true) {
- var
- run = 0,
- coeff = this.readHuffman(MPEG1.DCT_COEFF);
- if ((coeff === 0x0001) && (n > 0) && (this.bits.read(1) === 0)) {
-
- break;
- }
- if (coeff === 0xffff) {
-
- run = this.bits.read(6);
- level = this.bits.read(8);
- if (level === 0) {
- level = this.bits.read(8);
- }
- else if (level === 128) {
- level = this.bits.read(8) - 256;
- }
- else if (level > 128) {
- level = level - 256;
- }
- }
- else {
- run = coeff >> 8;
- level = coeff & 0xff;
- if (this.bits.read(1)) {
- level = -level;
- }
- }
- n += run;
- var dezigZagged = MPEG1.ZIG_ZAG[n];
- n++;
-
- level <<= 1;
- if (!this.macroblockIntra) {
- level += (level < 0 ? -1 : 1);
- }
- level = (level * this.quantizerScale * quantMatrix[dezigZagged]) >> 4;
- if ((level & 1) === 0) {
- level -= level > 0 ? 1 : -1;
- }
- if (level > 2047) {
- level = 2047;
- }
- else if (level < -2048) {
- level = -2048;
- }
-
- this.blockData[dezigZagged] = level * MPEG1.PREMULTIPLIER_MATRIX[dezigZagged];
- }
-
- var
- destArray,
- destIndex,
- scan;
- if (block < 4) {
- destArray = this.currentY;
- scan = this.codedWidth - 8;
- destIndex = (this.mbRow * this.codedWidth + this.mbCol) << 4;
- if ((block & 1) !== 0) {
- destIndex += 8;
- }
- if ((block & 2) !== 0) {
- destIndex += this.codedWidth << 3;
- }
- }
- else {
- destArray = (block === 4) ? this.currentCb : this.currentCr;
- scan = (this.codedWidth >> 1) - 8;
- destIndex = ((this.mbRow * this.codedWidth) << 2) + (this.mbCol << 3);
- }
- if (this.macroblockIntra) {
-
- if (n === 1) {
- MPEG1.CopyValueToDestination((this.blockData[0] + 128) >> 8, destArray, destIndex, scan);
- this.blockData[0] = 0;
- }
- else {
- MPEG1.IDCT(this.blockData);
- MPEG1.CopyBlockToDestination(this.blockData, destArray, destIndex, scan);
- JSMpeg.Fill(this.blockData, 0);
- }
- }
- else {
-
- if (n === 1) {
- MPEG1.AddValueToDestination((this.blockData[0] + 128) >> 8, destArray, destIndex, scan);
- this.blockData[0] = 0;
- }
- else {
- MPEG1.IDCT(this.blockData);
- MPEG1.AddBlockToDestination(this.blockData, destArray, destIndex, scan);
- JSMpeg.Fill(this.blockData, 0);
- }
- }
- n = 0;
- };
- MPEG1.CopyBlockToDestination = function(block, dest, index, scan) {
- for (var n = 0; n < 64; n += 8, index += scan+8) {
- dest[index+0] = block[n+0];
- dest[index+1] = block[n+1];
- dest[index+2] = block[n+2];
- dest[index+3] = block[n+3];
- dest[index+4] = block[n+4];
- dest[index+5] = block[n+5];
- dest[index+6] = block[n+6];
- dest[index+7] = block[n+7];
- }
- };
- MPEG1.AddBlockToDestination = function(block, dest, index, scan) {
- for (var n = 0; n < 64; n += 8, index += scan+8) {
- dest[index+0] += block[n+0];
- dest[index+1] += block[n+1];
- dest[index+2] += block[n+2];
- dest[index+3] += block[n+3];
- dest[index+4] += block[n+4];
- dest[index+5] += block[n+5];
- dest[index+6] += block[n+6];
- dest[index+7] += block[n+7];
- }
- };
- MPEG1.CopyValueToDestination = function(value, dest, index, scan) {
- for (var n = 0; n < 64; n += 8, index += scan+8) {
- dest[index+0] = value;
- dest[index+1] = value;
- dest[index+2] = value;
- dest[index+3] = value;
- dest[index+4] = value;
- dest[index+5] = value;
- dest[index+6] = value;
- dest[index+7] = value;
- }
- };
- MPEG1.AddValueToDestination = function(value, dest, index, scan) {
- for (var n = 0; n < 64; n += 8, index += scan+8) {
- dest[index+0] += value;
- dest[index+1] += value;
- dest[index+2] += value;
- dest[index+3] += value;
- dest[index+4] += value;
- dest[index+5] += value;
- dest[index+6] += value;
- dest[index+7] += value;
- }
- };
- MPEG1.IDCT = function(block) {
-
-
- var
- b1, b3, b4, b6, b7, tmp1, tmp2, m0,
- x0, x1, x2, x3, x4, y3, y4, y5, y6, y7;
-
- for (var i = 0; i < 8; ++i) {
- b1 = block[4*8+i];
- b3 = block[2*8+i] + block[6*8+i];
- b4 = block[5*8+i] - block[3*8+i];
- tmp1 = block[1*8+i] + block[7*8+i];
- tmp2 = block[3*8+i] + block[5*8+i];
- b6 = block[1*8+i] - block[7*8+i];
- b7 = tmp1 + tmp2;
- m0 = block[0*8+i];
- x4 = ((b6*473 - b4*196 + 128) >> 8) - b7;
- x0 = x4 - (((tmp1 - tmp2)*362 + 128) >> 8);
- x1 = m0 - b1;
- x2 = (((block[2*8+i] - block[6*8+i])*362 + 128) >> 8) - b3;
- x3 = m0 + b1;
- y3 = x1 + x2;
- y4 = x3 + b3;
- y5 = x1 - x2;
- y6 = x3 - b3;
- y7 = -x0 - ((b4*473 + b6*196 + 128) >> 8);
- block[0*8+i] = b7 + y4;
- block[1*8+i] = x4 + y3;
- block[2*8+i] = y5 - x0;
- block[3*8+i] = y6 - y7;
- block[4*8+i] = y6 + y7;
- block[5*8+i] = x0 + y5;
- block[6*8+i] = y3 - x4;
- block[7*8+i] = y4 - b7;
- }
-
- for (var i = 0; i < 64; i += 8) {
- b1 = block[4+i];
- b3 = block[2+i] + block[6+i];
- b4 = block[5+i] - block[3+i];
- tmp1 = block[1+i] + block[7+i];
- tmp2 = block[3+i] + block[5+i];
- b6 = block[1+i] - block[7+i];
- b7 = tmp1 + tmp2;
- m0 = block[0+i];
- x4 = ((b6*473 - b4*196 + 128) >> 8) - b7;
- x0 = x4 - (((tmp1 - tmp2)*362 + 128) >> 8);
- x1 = m0 - b1;
- x2 = (((block[2+i] - block[6+i])*362 + 128) >> 8) - b3;
- x3 = m0 + b1;
- y3 = x1 + x2;
- y4 = x3 + b3;
- y5 = x1 - x2;
- y6 = x3 - b3;
- y7 = -x0 - ((b4*473 + b6*196 + 128) >> 8);
- block[0+i] = (b7 + y4 + 128) >> 8;
- block[1+i] = (x4 + y3 + 128) >> 8;
- block[2+i] = (y5 - x0 + 128) >> 8;
- block[3+i] = (y6 - y7 + 128) >> 8;
- block[4+i] = (y6 + y7 + 128) >> 8;
- block[5+i] = (x0 + y5 + 128) >> 8;
- block[6+i] = (y3 - x4 + 128) >> 8;
- block[7+i] = (y4 - b7 + 128) >> 8;
- }
- };
- MPEG1.PICTURE_RATE = [
- 0.000, 23.976, 24.000, 25.000, 29.970, 30.000, 50.000, 59.940,
- 60.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000
- ];
- MPEG1.ZIG_ZAG = new Uint8Array([
- 0, 1, 8, 16, 9, 2, 3, 10,
- 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34,
- 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36,
- 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46,
- 53, 60, 61, 54, 47, 55, 62, 63
- ]);
- MPEG1.DEFAULT_INTRA_QUANT_MATRIX = new Uint8Array([
- 8, 16, 19, 22, 26, 27, 29, 34,
- 16, 16, 22, 24, 27, 29, 34, 37,
- 19, 22, 26, 27, 29, 34, 34, 38,
- 22, 22, 26, 27, 29, 34, 37, 40,
- 22, 26, 27, 29, 32, 35, 40, 48,
- 26, 27, 29, 32, 35, 40, 48, 58,
- 26, 27, 29, 34, 38, 46, 56, 69,
- 27, 29, 35, 38, 46, 56, 69, 83
- ]);
- MPEG1.DEFAULT_NON_INTRA_QUANT_MATRIX = new Uint8Array([
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16
- ]);
- MPEG1.PREMULTIPLIER_MATRIX = new Uint8Array([
- 32, 44, 42, 38, 32, 25, 17, 9,
- 44, 62, 58, 52, 44, 35, 24, 12,
- 42, 58, 55, 49, 42, 33, 23, 12,
- 38, 52, 49, 44, 38, 30, 20, 10,
- 32, 44, 42, 38, 32, 25, 17, 9,
- 25, 35, 33, 30, 25, 20, 14, 7,
- 17, 24, 23, 20, 17, 14, 9, 5,
- 9, 12, 12, 10, 9, 7, 5, 2
- ]);
- MPEG1.MACROBLOCK_ADDRESS_INCREMENT = new Int16Array([
- 1*3, 2*3, 0,
- 3*3, 4*3, 0,
- 0, 0, 1,
- 5*3, 6*3, 0,
- 7*3, 8*3, 0,
- 9*3, 10*3, 0,
- 11*3, 12*3, 0,
- 0, 0, 3,
- 0, 0, 2,
- 13*3, 14*3, 0,
- 15*3, 16*3, 0,
- 0, 0, 5,
- 0, 0, 4,
- 17*3, 18*3, 0,
- 19*3, 20*3, 0,
- 0, 0, 7,
- 0, 0, 6,
- 21*3, 22*3, 0,
- 23*3, 24*3, 0,
- 25*3, 26*3, 0,
- 27*3, 28*3, 0,
- -1, 29*3, 0,
- -1, 30*3, 0,
- 31*3, 32*3, 0,
- 33*3, 34*3, 0,
- 35*3, 36*3, 0,
- 37*3, 38*3, 0,
- 0, 0, 9,
- 0, 0, 8,
- 39*3, 40*3, 0,
- 41*3, 42*3, 0,
- 43*3, 44*3, 0,
- 45*3, 46*3, 0,
- 0, 0, 15,
- 0, 0, 14,
- 0, 0, 13,
- 0, 0, 12,
- 0, 0, 11,
- 0, 0, 10,
- 47*3, -1, 0,
- -1, 48*3, 0,
- 49*3, 50*3, 0,
- 51*3, 52*3, 0,
- 53*3, 54*3, 0,
- 55*3, 56*3, 0,
- 57*3, 58*3, 0,
- 59*3, 60*3, 0,
- 61*3, -1, 0,
- -1, 62*3, 0,
- 63*3, 64*3, 0,
- 65*3, 66*3, 0,
- 67*3, 68*3, 0,
- 69*3, 70*3, 0,
- 71*3, 72*3, 0,
- 73*3, 74*3, 0,
- 0, 0, 21,
- 0, 0, 20,
- 0, 0, 19,
- 0, 0, 18,
- 0, 0, 17,
- 0, 0, 16,
- 0, 0, 35,
- 0, 0, 34,
- 0, 0, 33,
- 0, 0, 32,
- 0, 0, 31,
- 0, 0, 30,
- 0, 0, 29,
- 0, 0, 28,
- 0, 0, 27,
- 0, 0, 26,
- 0, 0, 25,
- 0, 0, 24,
- 0, 0, 23,
- 0, 0, 22
- ]);
- MPEG1.MACROBLOCK_TYPE_INTRA = new Int8Array([
- 1*3, 2*3, 0,
- -1, 3*3, 0,
- 0, 0, 0x01,
- 0, 0, 0x11
- ]);
- MPEG1.MACROBLOCK_TYPE_PREDICTIVE = new Int8Array([
- 1*3, 2*3, 0,
- 3*3, 4*3, 0,
- 0, 0, 0x0a,
- 5*3, 6*3, 0,
- 0, 0, 0x02,
- 7*3, 8*3, 0,
- 0, 0, 0x08,
- 9*3, 10*3, 0,
- 11*3, 12*3, 0,
- -1, 13*3, 0,
- 0, 0, 0x12,
- 0, 0, 0x1a,
- 0, 0, 0x01,
- 0, 0, 0x11
- ]);
- MPEG1.MACROBLOCK_TYPE_B = new Int8Array([
- 1*3, 2*3, 0,
- 3*3, 5*3, 0,
- 4*3, 6*3, 0,
- 8*3, 7*3, 0,
- 0, 0, 0x0c,
- 9*3, 10*3, 0,
- 0, 0, 0x0e,
- 13*3, 14*3, 0,
- 12*3, 11*3, 0,
- 0, 0, 0x04,
- 0, 0, 0x06,
- 18*3, 16*3, 0,
- 15*3, 17*3, 0,
- 0, 0, 0x08,
- 0, 0, 0x0a,
- -1, 19*3, 0,
- 0, 0, 0x01,
- 20*3, 21*3, 0,
- 0, 0, 0x1e,
- 0, 0, 0x11,
- 0, 0, 0x16,
- 0, 0, 0x1a
- ]);
- MPEG1.MACROBLOCK_TYPE = [
- null,
- MPEG1.MACROBLOCK_TYPE_INTRA,
- MPEG1.MACROBLOCK_TYPE_PREDICTIVE,
- MPEG1.MACROBLOCK_TYPE_B
- ];
- MPEG1.CODE_BLOCK_PATTERN = new Int16Array([
- 2*3, 1*3, 0,
- 3*3, 6*3, 0,
- 4*3, 5*3, 0,
- 8*3, 11*3, 0,
- 12*3, 13*3, 0,
- 9*3, 7*3, 0,
- 10*3, 14*3, 0,
- 20*3, 19*3, 0,
- 18*3, 16*3, 0,
- 23*3, 17*3, 0,
- 27*3, 25*3, 0,
- 21*3, 28*3, 0,
- 15*3, 22*3, 0,
- 24*3, 26*3, 0,
- 0, 0, 60,
- 35*3, 40*3, 0,
- 44*3, 48*3, 0,
- 38*3, 36*3, 0,
- 42*3, 47*3, 0,
- 29*3, 31*3, 0,
- 39*3, 32*3, 0,
- 0, 0, 32,
- 45*3, 46*3, 0,
- 33*3, 41*3, 0,
- 43*3, 34*3, 0,
- 0, 0, 4,
- 30*3, 37*3, 0,
- 0, 0, 8,
- 0, 0, 16,
- 0, 0, 44,
- 50*3, 56*3, 0,
- 0, 0, 28,
- 0, 0, 52,
- 0, 0, 62,
- 61*3, 59*3, 0,
- 52*3, 60*3, 0,
- 0, 0, 1,
- 55*3, 54*3, 0,
- 0, 0, 61,
- 0, 0, 56,
- 57*3, 58*3, 0,
- 0, 0, 2,
- 0, 0, 40,
- 51*3, 62*3, 0,
- 0, 0, 48,
- 64*3, 63*3, 0,
- 49*3, 53*3, 0,
- 0, 0, 20,
- 0, 0, 12,
- 80*3, 83*3, 0,
- 0, 0, 63,
- 77*3, 75*3, 0,
- 65*3, 73*3, 0,
- 84*3, 66*3, 0,
- 0, 0, 24,
- 0, 0, 36,
- 0, 0, 3,
- 69*3, 87*3, 0,
- 81*3, 79*3, 0,
- 68*3, 71*3, 0,
- 70*3, 78*3, 0,
- 67*3, 76*3, 0,
- 72*3, 74*3, 0,
- 86*3, 85*3, 0,
- 88*3, 82*3, 0,
- -1, 94*3, 0,
- 95*3, 97*3, 0,
- 0, 0, 33,
- 0, 0, 9,
- 106*3, 110*3, 0,
- 102*3, 116*3, 0,
- 0, 0, 5,
- 0, 0, 10,
- 93*3, 89*3, 0,
- 0, 0, 6,
- 0, 0, 18,
- 0, 0, 17,
- 0, 0, 34,
- 113*3, 119*3, 0,
- 103*3, 104*3, 0,
- 90*3, 92*3, 0,
- 109*3, 107*3, 0,
- 117*3, 118*3, 0,
- 101*3, 99*3, 0,
- 98*3, 96*3, 0,
- 100*3, 91*3, 0,
- 114*3, 115*3, 0,
- 105*3, 108*3, 0,
- 112*3, 111*3, 0,
- 121*3, 125*3, 0,
- 0, 0, 41,
- 0, 0, 14,
- 0, 0, 21,
- 124*3, 122*3, 0,
- 120*3, 123*3, 0,
- 0, 0, 11,
- 0, 0, 19,
- 0, 0, 7,
- 0, 0, 35,
- 0, 0, 13,
- 0, 0, 50,
- 0, 0, 49,
- 0, 0, 58,
- 0, 0, 37,
- 0, 0, 25,
- 0, 0, 45,
- 0, 0, 57,
- 0, 0, 26,
- 0, 0, 29,
- 0, 0, 38,
- 0, 0, 53,
- 0, 0, 23,
- 0, 0, 43,
- 0, 0, 46,
- 0, 0, 42,
- 0, 0, 22,
- 0, 0, 54,
- 0, 0, 51,
- 0, 0, 15,
- 0, 0, 30,
- 0, 0, 39,
- 0, 0, 47,
- 0, 0, 55,
- 0, 0, 27,
- 0, 0, 59,
- 0, 0, 31
- ]);
- MPEG1.MOTION = new Int16Array([
- 1*3, 2*3, 0,
- 4*3, 3*3, 0,
- 0, 0, 0,
- 6*3, 5*3, 0,
- 8*3, 7*3, 0,
- 0, 0, -1,
- 0, 0, 1,
- 9*3, 10*3, 0,
- 12*3, 11*3, 0,
- 0, 0, 2,
- 0, 0, -2,
- 14*3, 15*3, 0,
- 16*3, 13*3, 0,
- 20*3, 18*3, 0,
- 0, 0, 3,
- 0, 0, -3,
- 17*3, 19*3, 0,
- -1, 23*3, 0,
- 27*3, 25*3, 0,
- 26*3, 21*3, 0,
- 24*3, 22*3, 0,
- 32*3, 28*3, 0,
- 29*3, 31*3, 0,
- -1, 33*3, 0,
- 36*3, 35*3, 0,
- 0, 0, -4,
- 30*3, 34*3, 0,
- 0, 0, 4,
- 0, 0, -7,
- 0, 0, 5,
- 37*3, 41*3, 0,
- 0, 0, -5,
- 0, 0, 7,
- 38*3, 40*3, 0,
- 42*3, 39*3, 0,
- 0, 0, -6,
- 0, 0, 6,
- 51*3, 54*3, 0,
- 50*3, 49*3, 0,
- 45*3, 46*3, 0,
- 52*3, 47*3, 0,
- 43*3, 53*3, 0,
- 44*3, 48*3, 0,
- 0, 0, 10,
- 0, 0, 9,
- 0, 0, 8,
- 0, 0, -8,
- 57*3, 66*3, 0,
- 0, 0, -9,
- 60*3, 64*3, 0,
- 56*3, 61*3, 0,
- 55*3, 62*3, 0,
- 58*3, 63*3, 0,
- 0, 0, -10,
- 59*3, 65*3, 0,
- 0, 0, 12,
- 0, 0, 16,
- 0, 0, 13,
- 0, 0, 14,
- 0, 0, 11,
- 0, 0, 15,
- 0, 0, -16,
- 0, 0, -12,
- 0, 0, -14,
- 0, 0, -15,
- 0, 0, -11,
- 0, 0, -13
- ]);
- MPEG1.DCT_DC_SIZE_LUMINANCE = new Int8Array([
- 2*3, 1*3, 0,
- 6*3, 5*3, 0,
- 3*3, 4*3, 0,
- 0, 0, 1,
- 0, 0, 2,
- 9*3, 8*3, 0,
- 7*3, 10*3, 0,
- 0, 0, 0,
- 12*3, 11*3, 0,
- 0, 0, 4,
- 0, 0, 3,
- 13*3, 14*3, 0,
- 0, 0, 5,
- 0, 0, 6,
- 16*3, 15*3, 0,
- 17*3, -1, 0,
- 0, 0, 7,
- 0, 0, 8
- ]);
- MPEG1.DCT_DC_SIZE_CHROMINANCE = new Int8Array([
- 2*3, 1*3, 0,
- 4*3, 3*3, 0,
- 6*3, 5*3, 0,
- 8*3, 7*3, 0,
- 0, 0, 2,
- 0, 0, 1,
- 0, 0, 0,
- 10*3, 9*3, 0,
- 0, 0, 3,
- 12*3, 11*3, 0,
- 0, 0, 4,
- 14*3, 13*3, 0,
- 0, 0, 5,
- 16*3, 15*3, 0,
- 0, 0, 6,
- 17*3, -1, 0,
- 0, 0, 7,
- 0, 0, 8
- ]);
- MPEG1.DCT_COEFF = new Int32Array([
- 1*3, 2*3, 0,
- 4*3, 3*3, 0,
- 0, 0, 0x0001,
- 7*3, 8*3, 0,
- 6*3, 5*3, 0,
- 13*3, 9*3, 0,
- 11*3, 10*3, 0,
- 14*3, 12*3, 0,
- 0, 0, 0x0101,
- 20*3, 22*3, 0,
- 18*3, 21*3, 0,
- 16*3, 19*3, 0,
- 0, 0, 0x0201,
- 17*3, 15*3, 0,
- 0, 0, 0x0002,
- 0, 0, 0x0003,
- 27*3, 25*3, 0,
- 29*3, 31*3, 0,
- 24*3, 26*3, 0,
- 32*3, 30*3, 0,
- 0, 0, 0x0401,
- 23*3, 28*3, 0,
- 0, 0, 0x0301,
- 0, 0, 0x0102,
- 0, 0, 0x0701,
- 0, 0, 0xffff,
- 0, 0, 0x0601,
- 37*3, 36*3, 0,
- 0, 0, 0x0501,
- 35*3, 34*3, 0,
- 39*3, 38*3, 0,
- 33*3, 42*3, 0,
- 40*3, 41*3, 0,
- 52*3, 50*3, 0,
- 54*3, 53*3, 0,
- 48*3, 49*3, 0,
- 43*3, 45*3, 0,
- 46*3, 44*3, 0,
- 0, 0, 0x0801,
- 0, 0, 0x0004,
- 0, 0, 0x0202,
- 0, 0, 0x0901,
- 51*3, 47*3, 0,
- 55*3, 57*3, 0,
- 60*3, 56*3, 0,
- 59*3, 58*3, 0,
- 61*3, 62*3, 0,
- 0, 0, 0x0a01,
- 0, 0, 0x0d01,
- 0, 0, 0x0006,
- 0, 0, 0x0103,
- 0, 0, 0x0005,
- 0, 0, 0x0302,
- 0, 0, 0x0b01,
- 0, 0, 0x0c01,
- 76*3, 75*3, 0,
- 67*3, 70*3, 0,
- 73*3, 71*3, 0,
- 78*3, 74*3, 0,
- 72*3, 77*3, 0,
- 69*3, 64*3, 0,
- 68*3, 63*3, 0,
- 66*3, 65*3, 0,
- 81*3, 87*3, 0,
- 91*3, 80*3, 0,
- 82*3, 79*3, 0,
- 83*3, 86*3, 0,
- 93*3, 92*3, 0,
- 84*3, 85*3, 0,
- 90*3, 94*3, 0,
- 88*3, 89*3, 0,
- 0, 0, 0x0203,
- 0, 0, 0x0104,
- 0, 0, 0x0007,
- 0, 0, 0x0402,
- 0, 0, 0x0502,
- 0, 0, 0x1001,
- 0, 0, 0x0f01,
- 0, 0, 0x0e01,
- 105*3, 107*3, 0,
- 111*3, 114*3, 0,
- 104*3, 97*3, 0,
- 125*3, 119*3, 0,
- 96*3, 98*3, 0,
- -1, 123*3, 0,
- 95*3, 101*3, 0,
- 106*3, 121*3, 0,
- 99*3, 102*3, 0,
- 113*3, 103*3, 0,
- 112*3, 116*3, 0,
- 110*3, 100*3, 0,
- 124*3, 115*3, 0,
- 117*3, 122*3, 0,
- 109*3, 118*3, 0,
- 120*3, 108*3, 0,
- 127*3, 136*3, 0,
- 139*3, 140*3, 0,
- 130*3, 126*3, 0,
- 145*3, 146*3, 0,
- 128*3, 129*3, 0,
- 0, 0, 0x0802,
- 132*3, 134*3, 0,
- 155*3, 154*3, 0,
- 0, 0, 0x0008,
- 137*3, 133*3, 0,
- 143*3, 144*3, 0,
- 151*3, 138*3, 0,
- 142*3, 141*3, 0,
- 0, 0, 0x000a,
- 0, 0, 0x0009,
- 0, 0, 0x000b,
- 0, 0, 0x1501,
- 0, 0, 0x0602,
- 0, 0, 0x0303,
- 0, 0, 0x1401,
- 0, 0, 0x0702,
- 0, 0, 0x1101,
- 0, 0, 0x1201,
- 0, 0, 0x1301,
- 148*3, 152*3, 0,
- 0, 0, 0x0403,
- 153*3, 150*3, 0,
- 0, 0, 0x0105,
- 131*3, 135*3, 0,
- 0, 0, 0x0204,
- 149*3, 147*3, 0,
- 172*3, 173*3, 0,
- 162*3, 158*3, 0,
- 170*3, 161*3, 0,
- 168*3, 166*3, 0,
- 157*3, 179*3, 0,
- 169*3, 167*3, 0,
- 174*3, 171*3, 0,
- 178*3, 177*3, 0,
- 156*3, 159*3, 0,
- 164*3, 165*3, 0,
- 183*3, 182*3, 0,
- 175*3, 176*3, 0,
- 0, 0, 0x0107,
- 0, 0, 0x0a02,
- 0, 0, 0x0902,
- 0, 0, 0x1601,
- 0, 0, 0x1701,
- 0, 0, 0x1901,
- 0, 0, 0x1801,
- 0, 0, 0x0503,
- 0, 0, 0x0304,
- 0, 0, 0x000d,
- 0, 0, 0x000c,
- 0, 0, 0x000e,
- 0, 0, 0x000f,
- 0, 0, 0x0205,
- 0, 0, 0x1a01,
- 0, 0, 0x0106,
- 180*3, 181*3, 0,
- 160*3, 163*3, 0,
- 196*3, 199*3, 0,
- 0, 0, 0x001b,
- 203*3, 185*3, 0,
- 202*3, 201*3, 0,
- 0, 0, 0x0013,
- 0, 0, 0x0016,
- 197*3, 207*3, 0,
- 0, 0, 0x0012,
- 191*3, 192*3, 0,
- 188*3, 190*3, 0,
- 0, 0, 0x0014,
- 184*3, 194*3, 0,
- 0, 0, 0x0015,
- 186*3, 193*3, 0,
- 0, 0, 0x0017,
- 204*3, 198*3, 0,
- 0, 0, 0x0019,
- 0, 0, 0x0018,
- 200*3, 205*3, 0,
- 0, 0, 0x001f,
- 0, 0, 0x001e,
- 0, 0, 0x001c,
- 0, 0, 0x001d,
- 0, 0, 0x001a,
- 0, 0, 0x0011,
- 0, 0, 0x0010,
- 189*3, 206*3, 0,
- 187*3, 195*3, 0,
- 218*3, 211*3, 0,
- 0, 0, 0x0025,
- 215*3, 216*3, 0,
- 0, 0, 0x0024,
- 210*3, 212*3, 0,
- 0, 0, 0x0022,
- 213*3, 209*3, 0,
- 221*3, 222*3, 0,
- 219*3, 208*3, 0,
- 217*3, 214*3, 0,
- 223*3, 220*3, 0,
- 0, 0, 0x0023,
- 0, 0, 0x010b,
- 0, 0, 0x0028,
- 0, 0, 0x010c,
- 0, 0, 0x010a,
- 0, 0, 0x0020,
- 0, 0, 0x0108,
- 0, 0, 0x0109,
- 0, 0, 0x0026,
- 0, 0, 0x010d,
- 0, 0, 0x010e,
- 0, 0, 0x0021,
- 0, 0, 0x0027,
- 0, 0, 0x1f01,
- 0, 0, 0x1b01,
- 0, 0, 0x1e01,
- 0, 0, 0x1002,
- 0, 0, 0x1d01,
- 0, 0, 0x1c01,
- 0, 0, 0x010f,
- 0, 0, 0x0112,
- 0, 0, 0x0111,
- 0, 0, 0x0110,
- 0, 0, 0x0603,
- 0, 0, 0x0b02,
- 0, 0, 0x0e02,
- 0, 0, 0x0d02,
- 0, 0, 0x0c02,
- 0, 0, 0x0f02
- ]);
- MPEG1.PICTURE_TYPE = {
- INTRA: 1,
- PREDICTIVE: 2,
- B: 3
- };
- MPEG1.START = {
- SEQUENCE: 0xB3,
- SLICE_FIRST: 0x01,
- SLICE_LAST: 0xAF,
- PICTURE: 0x00,
- EXTENSION: 0xB5,
- USER_DATA: 0xB2
- };
- return MPEG1;
- })();
|