Dominic Szablewski 12 gadus atpakaļ
vecāks
revīzija
985088de53
1 mainītis faili ar 11 papildinājumiem un 26 dzēšanām
  1. 11 26
      jsmpg.js

+ 11 - 26
jsmpg.js Parādīt failu

266
 jsmpeg.prototype.forwardF = 0;
266
 jsmpeg.prototype.forwardF = 0;
267
 
267
 
268
 
268
 
269
-jsmpeg.prototype.decodePicture = function() {	
269
+jsmpeg.prototype.decodePicture = function() {
270
 	this.buffer.advance(10); // skip temporalReference
270
 	this.buffer.advance(10); // skip temporalReference
271
 	this.pictureCodingType = this.buffer.getBits(3);
271
 	this.pictureCodingType = this.buffer.getBits(3);
272
 	this.buffer.advance(16); // skip vbv_delay
272
 	this.buffer.advance(16); // skip vbv_delay
894
 	}
894
 	}
895
 	
895
 	
896
 	n = 0;
896
 	n = 0;
897
+	
898
+	var blockData = this.blockData;
897
 	if( this.macroblockIntra ) {
899
 	if( this.macroblockIntra ) {
900
+		var mult = 0;
898
 		// Overwrite (no prediction)
901
 		// Overwrite (no prediction)
899
 		for( var i = 0; i < 8; i++ ) {
902
 		for( var i = 0; i < 8; i++ ) {
900
 			for( var j = 0; j < 8; j++ ) {
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
 			destIndex += scan;
906
 			destIndex += scan;
907
 		}
907
 		}
910
 		// Add data to the predicted macroblock
910
 		// Add data to the predicted macroblock
911
 		for( var i = 0; i < 8; i++ ) {
911
 		for( var i = 0; i < 8; i++ ) {
912
 			for( var j = 0; j < 8; j++ ) {
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
 			destIndex += scan;
915
 			destIndex += scan;
919
 		}
916
 		}
1687
 // ----------------------------------------------------------------------------
1684
 // ----------------------------------------------------------------------------
1688
 // Bit Reader 
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
 var BitReader = function(arrayBuffer) {
1687
 var BitReader = function(arrayBuffer) {
1703
 	this.bytes = new Uint8Array(arrayBuffer);
1688
 	this.bytes = new Uint8Array(arrayBuffer);
1704
 	this.length = this.bytes.length;
1689
 	this.length = this.bytes.length;
1739
 		room = (8 - this.index % 8);
1724
 		room = (8 - this.index % 8);
1740
 
1725
 
1741
 	if( room >= count ) {
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
 	var 
1730
 	var 
1746
 		leftover = (this.index + count) % 8, // Leftover bits in last byte
1731
 		leftover = (this.index + count) % 8, // Leftover bits in last byte
1747
 		end = (this.index + count -1) >> 3,
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
 	for( byteOffset++; byteOffset < end; byteOffset++ ) {
1735
 	for( byteOffset++; byteOffset < end; byteOffset++ ) {
1751
 		value <<= 8; // Shift and
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
 	if (leftover > 0) {
1740
 	if (leftover > 0) {
1756
 		value <<= leftover; // Make room for remaining bits
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
 	else {
1744
 	else {
1760
 		value <<= 8;
1745
 		value <<= 8;
1761
-		value |= this.bytes[byteOffset] & BIT_MASK[8];
1746
+		value |= this.bytes[byteOffset];
1762
 	}
1747
 	}
1763
 	
1748
 	
1764
 	return value;
1749
 	return value;