|
|
@@ -38,6 +38,8 @@ var jsmpeg = window.jsmpeg = function( url, opts ) {
|
|
38
|
38
|
this.customIntraQuantMatrix = new Uint8Array(64);
|
|
39
|
39
|
this.customNonIntraQuantMatrix = new Uint8Array(64);
|
|
40
|
40
|
this.blockData = new Int32Array(64);
|
|
|
41
|
+ this.zeroBlockData = new Int32Array(64);
|
|
|
42
|
+ this.fillArray(this.zeroBlockData, 0);
|
|
41
|
43
|
|
|
42
|
44
|
this.canvasContext = this.canvas.getContext('2d');
|
|
43
|
45
|
|
|
|
@@ -692,31 +694,27 @@ jsmpeg.prototype.YCbCrToRGBA = function() {
|
|
692
|
694
|
g = ((cb * 88) >> 8) - 44 + ((cr * 183) >> 8) - 91;
|
|
693
|
695
|
b = (cb + ((cb * 198) >> 8)) - 227;
|
|
694
|
696
|
|
|
695
|
|
- // Line 1
|
|
696
|
|
- y = pY[yIndex1++];
|
|
697
|
|
- pRGBA[rgbaIndex1] = y + r;
|
|
698
|
|
- pRGBA[rgbaIndex1+1] = y - g;
|
|
699
|
|
- pRGBA[rgbaIndex1+2] = y + b;
|
|
700
|
|
- rgbaIndex1 += 4;
|
|
701
|
|
-
|
|
702
|
|
- y = pY[yIndex1++];
|
|
703
|
|
- pRGBA[rgbaIndex1] = y + r;
|
|
704
|
|
- pRGBA[rgbaIndex1+1] = y - g;
|
|
705
|
|
- pRGBA[rgbaIndex1+2] = y + b;
|
|
706
|
|
- rgbaIndex1 += 4;
|
|
707
|
|
-
|
|
708
|
|
- // Line 2
|
|
709
|
|
- y = pY[yIndex2++];
|
|
710
|
|
- pRGBA[rgbaIndex2] = y + r;
|
|
711
|
|
- pRGBA[rgbaIndex2+1] = y - g;
|
|
712
|
|
- pRGBA[rgbaIndex2+2] = y + b;
|
|
713
|
|
- rgbaIndex2 += 4;
|
|
714
|
|
-
|
|
715
|
|
- y = pY[yIndex2++];
|
|
716
|
|
- pRGBA[rgbaIndex2] = y + r;
|
|
717
|
|
- pRGBA[rgbaIndex2+1] = y - g;
|
|
718
|
|
- pRGBA[rgbaIndex2+2] = y + b;
|
|
719
|
|
- rgbaIndex2 += 4;
|
|
|
697
|
+ // Line 1
|
|
|
698
|
+ var y1 = pY[yIndex1++];
|
|
|
699
|
+ var y2 = pY[yIndex1++];
|
|
|
700
|
+ pRGBA[rgbaIndex1] = y1 + r;
|
|
|
701
|
+ pRGBA[rgbaIndex1+1] = y1 - g;
|
|
|
702
|
+ pRGBA[rgbaIndex1+2] = y1 + b;
|
|
|
703
|
+ pRGBA[rgbaIndex1+4] = y2 + r;
|
|
|
704
|
+ pRGBA[rgbaIndex1+5] = y2 - g;
|
|
|
705
|
+ pRGBA[rgbaIndex1+6] = y2 + b;
|
|
|
706
|
+ rgbaIndex1 += 8;
|
|
|
707
|
+
|
|
|
708
|
+ // Line 2
|
|
|
709
|
+ var y3 = pY[yIndex2++];
|
|
|
710
|
+ var y4 = pY[yIndex2++];
|
|
|
711
|
+ pRGBA[rgbaIndex2] = y3 + r;
|
|
|
712
|
+ pRGBA[rgbaIndex2+1] = y3 - g;
|
|
|
713
|
+ pRGBA[rgbaIndex2+2] = y3 + b;
|
|
|
714
|
+ pRGBA[rgbaIndex2+4] = y4 + r;
|
|
|
715
|
+ pRGBA[rgbaIndex2+5] = y4 - g;
|
|
|
716
|
+ pRGBA[rgbaIndex2+6] = y4 + b;
|
|
|
717
|
+ rgbaIndex2 += 8;
|
|
720
|
718
|
}
|
|
721
|
719
|
|
|
722
|
720
|
yIndex1 += yNext2Lines;
|
|
|
@@ -1211,7 +1209,7 @@ jsmpeg.prototype.decodeBlock = function(block) {
|
|
1211
|
1209
|
quantMatrix;
|
|
1212
|
1210
|
|
|
1213
|
1211
|
// Clear preverious data
|
|
1214
|
|
- this.fillArray(this.blockData, 0);
|
|
|
1212
|
+ this.blockData.set(this.zeroBlockData);
|
|
1215
|
1213
|
|
|
1216
|
1214
|
// Decode DC coefficient of intra-coded blocks
|
|
1217
|
1215
|
if( this.macroblockIntra ) {
|
|
|
@@ -1370,20 +1368,30 @@ jsmpeg.prototype.decodeBlock = function(block) {
|
|
1370
|
1368
|
|
|
1371
|
1369
|
jsmpeg.prototype.copyBlockToDestination = function(blockData, destArray, destIndex, scan) {
|
|
1372
|
1370
|
var n = 0;
|
|
1373
|
|
- for( var i = 0; i < 8; i++ ) {
|
|
1374
|
|
- for( var j = 0; j < 8; j++ ) {
|
|
1375
|
|
- destArray[destIndex++] = blockData[n++];
|
|
1376
|
|
- }
|
|
|
1371
|
+ while(n < 64) {
|
|
|
1372
|
+ destArray[destIndex++] = blockData[n++];
|
|
|
1373
|
+ destArray[destIndex++] = blockData[n++];
|
|
|
1374
|
+ destArray[destIndex++] = blockData[n++];
|
|
|
1375
|
+ destArray[destIndex++] = blockData[n++];
|
|
|
1376
|
+ destArray[destIndex++] = blockData[n++];
|
|
|
1377
|
+ destArray[destIndex++] = blockData[n++];
|
|
|
1378
|
+ destArray[destIndex++] = blockData[n++];
|
|
|
1379
|
+ destArray[destIndex++] = blockData[n++];
|
|
1377
|
1380
|
destIndex += scan;
|
|
1378
|
1381
|
}
|
|
1379
|
1382
|
};
|
|
1380
|
1383
|
|
|
1381
|
1384
|
jsmpeg.prototype.addBlockToDestination = function(blockData, destArray, destIndex, scan) {
|
|
1382
|
1385
|
var n = 0;
|
|
1383
|
|
- for( var i = 0; i < 8; i++ ) {
|
|
1384
|
|
- for( var j = 0; j < 8; j++ ) {
|
|
1385
|
|
- destArray[destIndex++] += blockData[n++];
|
|
1386
|
|
- }
|
|
|
1386
|
+ while(n < 64) {
|
|
|
1387
|
+ destArray[destIndex++] += blockData[n++];
|
|
|
1388
|
+ destArray[destIndex++] += blockData[n++];
|
|
|
1389
|
+ destArray[destIndex++] += blockData[n++];
|
|
|
1390
|
+ destArray[destIndex++] += blockData[n++];
|
|
|
1391
|
+ destArray[destIndex++] += blockData[n++];
|
|
|
1392
|
+ destArray[destIndex++] += blockData[n++];
|
|
|
1393
|
+ destArray[destIndex++] += blockData[n++];
|
|
|
1394
|
+ destArray[destIndex++] += blockData[n++];
|
|
1387
|
1395
|
destIndex += scan;
|
|
1388
|
1396
|
}
|
|
1389
|
1397
|
};
|