|
|
@@ -266,7 +266,7 @@ jsmpeg.prototype.forwardRSize = 0;
|
|
266
|
266
|
jsmpeg.prototype.forwardF = 0;
|
|
267
|
267
|
|
|
268
|
268
|
|
|
269
|
|
-jsmpeg.prototype.decodePicture = function() {
|
|
|
269
|
+jsmpeg.prototype.decodePicture = function() {
|
|
270
|
270
|
this.buffer.advance(10); // skip temporalReference
|
|
271
|
271
|
this.pictureCodingType = this.buffer.getBits(3);
|
|
272
|
272
|
this.buffer.advance(16); // skip vbv_delay
|
|
|
@@ -894,14 +894,14 @@ jsmpeg.prototype.decodeBlock = function(block) {
|
|
894
|
894
|
}
|
|
895
|
895
|
|
|
896
|
896
|
n = 0;
|
|
|
897
|
+
|
|
|
898
|
+ var blockData = this.blockData;
|
|
897
|
899
|
if( this.macroblockIntra ) {
|
|
|
900
|
+ var mult = 0;
|
|
898
|
901
|
// Overwrite (no prediction)
|
|
899
|
902
|
for( var i = 0; i < 8; i++ ) {
|
|
900
|
903
|
for( var j = 0; j < 8; j++ ) {
|
|
901
|
|
- var value = this.blockData[n];
|
|
902
|
|
- n++;
|
|
903
|
|
- destArray[destIndex] = value;
|
|
904
|
|
- destIndex++;
|
|
|
904
|
+ destArray[destIndex++] = blockData[n++];
|
|
905
|
905
|
}
|
|
906
|
906
|
destIndex += scan;
|
|
907
|
907
|
}
|
|
|
@@ -910,10 +910,7 @@ jsmpeg.prototype.decodeBlock = function(block) {
|
|
910
|
910
|
// Add data to the predicted macroblock
|
|
911
|
911
|
for( var i = 0; i < 8; i++ ) {
|
|
912
|
912
|
for( var j = 0; j < 8; j++ ) {
|
|
913
|
|
- var value = this.blockData[n] + destArray[destIndex];
|
|
914
|
|
- n++;
|
|
915
|
|
- destArray[destIndex] = value;
|
|
916
|
|
- destIndex++;
|
|
|
913
|
+ destArray[destIndex++] += blockData[n++];
|
|
917
|
914
|
}
|
|
918
|
915
|
destIndex += scan;
|
|
919
|
916
|
}
|
|
|
@@ -1687,18 +1684,6 @@ var MACROBLOCK_TYPE_TABLES = [
|
|
1687
|
1684
|
// ----------------------------------------------------------------------------
|
|
1688
|
1685
|
// Bit Reader
|
|
1689
|
1686
|
|
|
1690
|
|
-var BIT_MASK = new Uint32Array([
|
|
1691
|
|
- 0x00000000, 0x00000001, 0x00000003, 0x00000007,
|
|
1692
|
|
- 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
|
|
1693
|
|
- 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
|
|
1694
|
|
- 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
|
|
1695
|
|
- 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
|
|
1696
|
|
- 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
|
|
1697
|
|
- 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
|
|
1698
|
|
- 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
|
|
1699
|
|
- 0xffffffff
|
|
1700
|
|
-]);
|
|
1701
|
|
-
|
|
1702
|
1687
|
var BitReader = function(arrayBuffer) {
|
|
1703
|
1688
|
this.bytes = new Uint8Array(arrayBuffer);
|
|
1704
|
1689
|
this.length = this.bytes.length;
|
|
|
@@ -1739,26 +1724,26 @@ BitReader.prototype.nextBits = function(count) {
|
|
1739
|
1724
|
room = (8 - this.index % 8);
|
|
1740
|
1725
|
|
|
1741
|
1726
|
if( room >= count ) {
|
|
1742
|
|
- return (this.bytes[byteOffset] >> (room - count)) & BIT_MASK[count];
|
|
|
1727
|
+ return (this.bytes[byteOffset] >> (room - count)) & (0xff >> (8-count));
|
|
1743
|
1728
|
}
|
|
1744
|
1729
|
|
|
1745
|
1730
|
var
|
|
1746
|
1731
|
leftover = (this.index + count) % 8, // Leftover bits in last byte
|
|
1747
|
1732
|
end = (this.index + count -1) >> 3,
|
|
1748
|
|
- value = this.bytes[byteOffset] & BIT_MASK[room]; // Fill out first byte
|
|
|
1733
|
+ value = this.bytes[byteOffset] & (0xff >> (8-room)); // Fill out first byte
|
|
1749
|
1734
|
|
|
1750
|
1735
|
for( byteOffset++; byteOffset < end; byteOffset++ ) {
|
|
1751
|
1736
|
value <<= 8; // Shift and
|
|
1752
|
|
- value |= this.bytes[byteOffset] & BIT_MASK[8]; // Put next byte
|
|
|
1737
|
+ value |= this.bytes[byteOffset]; // Put next byte
|
|
1753
|
1738
|
}
|
|
1754
|
1739
|
|
|
1755
|
1740
|
if (leftover > 0) {
|
|
1756
|
1741
|
value <<= leftover; // Make room for remaining bits
|
|
1757
|
|
- value |= (this.bytes[byteOffset] >> (8 - leftover)) & BIT_MASK[leftover];
|
|
|
1742
|
+ value |= (this.bytes[byteOffset] >> (8 - leftover));
|
|
1758
|
1743
|
}
|
|
1759
|
1744
|
else {
|
|
1760
|
1745
|
value <<= 8;
|
|
1761
|
|
- value |= this.bytes[byteOffset] & BIT_MASK[8];
|
|
|
1746
|
+ value |= this.bytes[byteOffset];
|
|
1762
|
1747
|
}
|
|
1763
|
1748
|
|
|
1764
|
1749
|
return value;
|