@@ -3778,8 +3778,8 @@ function parseDEFLATE(stream) {
37783778
37793779 while ( ! finalBlock ) {
37803780 // Read header
3781- finalBlock = stream . readBits ( 1 ) ;
3782- const blockType = stream . readBits ( 2 ) ;
3781+ finalBlock = stream . readBits ( 1 , "le" ) ;
3782+ const blockType = stream . readBits ( 2 , "le" ) ;
37833783
37843784 if ( blockType === 0 ) {
37853785 /* No compression */
@@ -3798,16 +3798,16 @@ function parseDEFLATE(stream) {
37983798 /* Dynamic Huffman */
37993799
38003800 // Read the number of liternal and length codes
3801- const hlit = stream . readBits ( 5 ) + 257 ;
3801+ const hlit = stream . readBits ( 5 , "le" ) + 257 ;
38023802 // Read the number of distance codes
3803- const hdist = stream . readBits ( 5 ) + 1 ;
3803+ const hdist = stream . readBits ( 5 , "le" ) + 1 ;
38043804 // Read the number of code lengths
3805- const hclen = stream . readBits ( 4 ) + 4 ;
3805+ const hclen = stream . readBits ( 4 , "le" ) + 4 ;
38063806
38073807 // Parse code lengths
38083808 const codeLengths = new Uint8Array ( huffmanOrder . length ) ;
38093809 for ( let i = 0 ; i < hclen ; i ++ ) {
3810- codeLengths [ huffmanOrder [ i ] ] = stream . readBits ( 3 ) ;
3810+ codeLengths [ huffmanOrder [ i ] ] = stream . readBits ( 3 , "le" ) ;
38113811 }
38123812
38133813 // Parse length table
@@ -3819,16 +3819,16 @@ function parseDEFLATE(stream) {
38193819 code = readHuffmanCode ( stream , codeLengthsTable ) ;
38203820 switch ( code ) {
38213821 case 16 :
3822- repeat = 3 + stream . readBits ( 2 ) ;
3822+ repeat = 3 + stream . readBits ( 2 , "le" ) ;
38233823 while ( repeat -- ) lengthTable [ i ++ ] = prev ;
38243824 break ;
38253825 case 17 :
3826- repeat = 3 + stream . readBits ( 3 ) ;
3826+ repeat = 3 + stream . readBits ( 3 , "le" ) ;
38273827 while ( repeat -- ) lengthTable [ i ++ ] = 0 ;
38283828 prev = 0 ;
38293829 break ;
38303830 case 18 :
3831- repeat = 11 + stream . readBits ( 7 ) ;
3831+ repeat = 11 + stream . readBits ( 7 , "le" ) ;
38323832 while ( repeat -- ) lengthTable [ i ++ ] = 0 ;
38333833 prev = 0 ;
38343834 break ;
@@ -3886,11 +3886,11 @@ function parseHuffmanBlock(stream, litTab, distTab) {
38863886 if ( code < 256 ) continue ;
38873887
38883888 // Length code
3889- stream . readBits ( lengthExtraTable [ code - 257 ] ) ;
3889+ stream . readBits ( lengthExtraTable [ code - 257 ] , "le" ) ;
38903890
38913891 // Dist code
38923892 code = readHuffmanCode ( stream , distTab ) ;
3893- stream . readBits ( distanceExtraTable [ code ] ) ;
3893+ stream . readBits ( distanceExtraTable [ code ] , "le" ) ;
38943894 }
38953895}
38963896
@@ -3948,7 +3948,7 @@ function readHuffmanCode(stream, table) {
39483948 const [ codeTable , maxCodeLength ] = table ;
39493949
39503950 // Read max length
3951- const bitsBuf = stream . readBits ( maxCodeLength ) ;
3951+ const bitsBuf = stream . readBits ( maxCodeLength , "le" ) ;
39523952 const codeWithLength = codeTable [ bitsBuf & ( ( 1 << maxCodeLength ) - 1 ) ] ;
39533953 const codeLength = codeWithLength >>> 16 ;
39543954
0 commit comments