Lines Matching refs:s
43 function decodeWindowBits(s) { argument
44 if (s.bitOffset >= 16) {
45 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
46 s.bitOffset -= 16;
48 if (readFewBits(s, 1) == 0) {
51 var /** !number */ n = readFewBits(s, 3);
55 n = readFewBits(s, 3);
66 function initState(s, input) { argument
67 if (s.runningState != 0) {
70 s.blockTrees = new Int32Array(6480);
71 s.input = input;
72 initBitReader(s);
73 var /** !number */ windowBits = decodeWindowBits(s);
77 s.maxRingBufferSize = 1 << windowBits;
78 s.maxBackwardDistance = s.maxRingBufferSize - 16;
79 s.runningState = 1;
85 function close(s) { argument
86 if (s.runningState == 0) {
89 if (s.runningState == 10) {
92 s.runningState = 10;
93 if (s.input != null) {
94 closeInput(s.input);
95 s.input = null;
102 function decodeVarLenUnsignedByte(s) { argument
103 if (s.bitOffset >= 16) {
104 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
105 s.bitOffset -= 16;
107 if (readFewBits(s, 1) != 0) {
108 var /** !number */ n = readFewBits(s, 3);
112 return readFewBits(s, n) + (1 << n);
121 function decodeMetaBlockLength(s) { argument
122 if (s.bitOffset >= 16) {
123 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
124 s.bitOffset -= 16;
126 s.inputEnd = readFewBits(s, 1);
127 s.metaBlockLength = 0;
128 s.isUncompressed = 0;
129 s.isMetadata = 0;
130 if ((s.inputEnd != 0) && readFewBits(s, 1) != 0) {
133 var /** !number */ sizeNibbles = readFewBits(s, 2) + 4;
135 s.isMetadata = 1;
136 if (readFewBits(s, 1) != 0) {
139 var /** !number */ sizeBytes = readFewBits(s, 2);
144 if (s.bitOffset >= 16) {
145 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
146 s.bitOffset -= 16;
148 var /** !number */ bits = readFewBits(s, 8);
152 s.metaBlockLength |= bits << (i * 8);
156 if (s.bitOffset >= 16) {
157 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
158 s.bitOffset -= 16;
160 var /** !number */ bits = readFewBits(s, 4);
164 s.metaBlockLength |= bits << (i * 4);
167 s.metaBlockLength++;
168 if (s.inputEnd == 0) {
169 s.isUncompressed = readFewBits(s, 1);
178 function readSymbol(table, offset, s) { argument
179 var /** !number */ val = (s.accumulator32 >>> s.bitOffset);
184 s.bitOffset += bits;
190 s.bitOffset += ((table[offset] >> 16) + 8);
199 function readBlockLength(table, offset, s) { argument
200 if (s.bitOffset >= 16) {
201 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
202 s.bitOffset -= 16;
204 var /** !number */ code = readSymbol(table, offset, s);
206 if (s.bitOffset >= 16) {
207 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
208 s.bitOffset -= 16;
210 return BLOCK_LENGTH_OFFSET[code] + ((n <= 16) ? readFewBits(s, n) : readManyBits(s, n));
263 function readHuffmanCodeLengths(codeLengthCodeLengths, numSymbols, codeLengths, s) { argument
272 if (s.halfOffset > 2030) {
273 doReadMoreInput(s);
275 if (s.bitOffset >= 16) {
276 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
277 s.bitOffset -= 16;
279 var /** !number */ p = (s.accumulator32 >>> s.bitOffset) & 31;
280 s.bitOffset += table[p] >> 16;
304 if (s.bitOffset >= 16) {
305 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
306 s.bitOffset -= 16;
308 repeat += readFewBits(s, extraBits) + 3;
348 function readHuffmanCode(alphabetSize, table, offset, s) { argument
351 if (s.halfOffset > 2030) {
352 doReadMoreInput(s);
355 if (s.bitOffset >= 16) {
356 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
357 s.bitOffset -= 16;
359 simpleCodeOrSkip = readFewBits(s, 2);
364 var /** !number */ numSymbols = readFewBits(s, 2) + 1;
370 if (s.bitOffset >= 16) {
371 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
372 s.bitOffset -= 16;
374 symbols[i] = readFewBits(s, maxBits) % alphabetSize;
383 if (readFewBits(s, 1) == 1) {
400 if (s.bitOffset >= 16) {
401 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
402 s.bitOffset -= 16;
404 var /** !number */ p = (s.accumulator32 >>> s.bitOffset) & 15;
405 s.bitOffset += FIXED_TABLE[p] >> 16;
416 readHuffmanCodeLengths(codeLengthCodeLengths, alphabetSize, codeLengths, s);
429 function decodeContextMap(contextMapSize, contextMap, s) { argument
430 if (s.halfOffset > 2030) {
431 doReadMoreInput(s);
433 var /** !number */ numTrees = decodeVarLenUnsignedByte(s) + 1;
438 if (s.bitOffset >= 16) {
439 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
440 s.bitOffset -= 16;
442 var /** !number */ useRleForZeros = readFewBits(s, 1);
445 maxRunLengthPrefix = readFewBits(s, 4) + 1;
448 readHuffmanCode(numTrees + maxRunLengthPrefix, table, 0, s);
450 if (s.halfOffset > 2030) {
451 doReadMoreInput(s);
453 if (s.bitOffset >= 16) {
454 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
455 s.bitOffset -= 16;
457 var /** !number */ code = readSymbol(table, 0, s);
462 if (s.bitOffset >= 16) {
463 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
464 s.bitOffset -= 16;
466 var /** !number */ reps = (1 << code) + readFewBits(s, code);
480 if (s.bitOffset >= 16) {
481 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
482 s.bitOffset -= 16;
484 if (readFewBits(s, 1) == 1) {
495 function decodeBlockTypeAndLength(s, treeType, numBlockTypes) { argument
496 var /** !Int32Array */ ringBuffers = s.rings;
498 if (s.bitOffset >= 16) {
499 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
500 s.bitOffset -= 16;
502 var /** !number */ blockType = readSymbol(s.blockTrees, treeType * 1080, s);
503 var /** !number */ result = readBlockLength(s.blockTrees, (treeType + 3) * 1080, s);
522 function decodeLiteralBlockSwitch(s) { argument
523 s.literalBlockLength = decodeBlockTypeAndLength(s, 0, s.numLiteralBlockTypes);
524 var /** !number */ literalBlockType = s.rings[5];
525 s.contextMapSlice = literalBlockType << 6;
526 s.literalTreeIndex = s.contextMap[s.contextMapSlice] & 0xFF;
527 s.literalTree = s.hGroup0[s.literalTreeIndex];
528 var /** !number */ contextMode = s.contextModes[literalBlockType];
529 s.contextLookupOffset1 = contextMode << 9;
530 s.contextLookupOffset2 = s.contextLookupOffset1 + 256;
536 function decodeCommandBlockSwitch(s) { argument
537 s.commandBlockLength = decodeBlockTypeAndLength(s, 1, s.numCommandBlockTypes);
538 s.treeCommandOffset = s.hGroup1[s.rings[7]];
544 function decodeDistanceBlockSwitch(s) { argument
545 s.distanceBlockLength = decodeBlockTypeAndLength(s, 2, s.numDistanceBlockTypes);
546 s.distContextMapSlice = s.rings[9] << 2;
552 function maybeReallocateRingBuffer(s) { argument
553 var /** !number */ newSize = s.maxRingBufferSize;
554 if (newSize > s.expectedTotalSize) {
555 var /** !number */ minimalNewSize = s.expectedTotalSize;
559 if ((s.inputEnd == 0) && newSize < 16384 && s.maxRingBufferSize >= 16384) {
563 if (newSize <= s.ringBufferSize) {
568 if (s.ringBuffer.length != 0) {
569 newBuffer.set(s.ringBuffer.subarray(0, 0 + s.ringBufferSize), 0);
571 s.ringBuffer = newBuffer;
572 s.ringBufferSize = newSize;
578 function readNextMetablockHeader(s) { argument
579 if (s.inputEnd != 0) {
580 s.nextRunningState = 9;
581 s.runningState = 11;
584 s.hGroup0 = new Int32Array(0);
585 s.hGroup1 = new Int32Array(0);
586 s.hGroup2 = new Int32Array(0);
587 if (s.halfOffset > 2030) {
588 doReadMoreInput(s);
590 decodeMetaBlockLength(s);
591 if ((s.metaBlockLength == 0) && (s.isMetadata == 0)) {
594 if ((s.isUncompressed != 0) || (s.isMetadata != 0)) {
595 jumpToByteBoundary(s);
596 s.runningState = (s.isMetadata != 0) ? 4 : 5;
598 s.runningState = 2;
600 if (s.isMetadata != 0) {
603 s.expectedTotalSize += s.metaBlockLength;
604 if (s.expectedTotalSize > 1 << 30) {
605 s.expectedTotalSize = 1 << 30;
607 if (s.ringBufferSize < s.maxRingBufferSize) {
608 maybeReallocateRingBuffer(s);
617 function readMetablockPartition(s, treeType, numBlockTypes) { argument
621 readHuffmanCode(numBlockTypes + 2, s.blockTrees, treeType * 1080, s);
622 readHuffmanCode(26, s.blockTrees, (treeType + 3) * 1080, s);
623 return readBlockLength(s.blockTrees, (treeType + 3) * 1080, s);
629 function readMetablockHuffmanCodesAndContextMaps(s) { argument
630 s.numLiteralBlockTypes = decodeVarLenUnsignedByte(s) + 1;
631 s.literalBlockLength = readMetablockPartition(s, 0, s.numLiteralBlockTypes);
632 s.numCommandBlockTypes = decodeVarLenUnsignedByte(s) + 1;
633 s.commandBlockLength = readMetablockPartition(s, 1, s.numCommandBlockTypes);
634 s.numDistanceBlockTypes = decodeVarLenUnsignedByte(s) + 1;
635 s.distanceBlockLength = readMetablockPartition(s, 2, s.numDistanceBlockTypes);
636 if (s.halfOffset > 2030) {
637 doReadMoreInput(s);
639 if (s.bitOffset >= 16) {
640 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
641 s.bitOffset -= 16;
643 s.distancePostfixBits = readFewBits(s, 2);
644 s.numDirectDistanceCodes = 16 + (readFewBits(s, 4) << s.distancePostfixBits);
645 s.distancePostfixMask = (1 << s.distancePostfixBits) - 1;
646 var /** !number */ numDistanceCodes = s.numDirectDistanceCodes + (48 << s.distancePostfixBits);
647 s.contextModes = new Int8Array(s.numLiteralBlockTypes);
648 for (var /** !number */ i = 0; i < s.numLiteralBlockTypes; ) {
649 var /** !number */ limit = min(i + 96, s.numLiteralBlockTypes);
651 if (s.bitOffset >= 16) {
652 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
653 s.bitOffset -= 16;
655 s.contextModes[i] = (readFewBits(s, 2));
657 if (s.halfOffset > 2030) {
658 doReadMoreInput(s);
661 s.contextMap = new Int8Array(s.numLiteralBlockTypes << 6);
662 …var /** !number */ numLiteralTrees = decodeContextMap(s.numLiteralBlockTypes << 6, s.contextMap, s…
663 s.trivialLiteralContext = 1;
664 for (var /** !number */ j = 0; j < s.numLiteralBlockTypes << 6; j++) {
665 if (s.contextMap[j] != j >> 6) {
666 s.trivialLiteralContext = 0;
670 s.distContextMap = new Int8Array(s.numDistanceBlockTypes << 2);
671 …var /** !number */ numDistTrees = decodeContextMap(s.numDistanceBlockTypes << 2, s.distContextMap,…
672 s.hGroup0 = decodeHuffmanTreeGroup(256, numLiteralTrees, s);
673 s.hGroup1 = decodeHuffmanTreeGroup(704, s.numCommandBlockTypes, s);
674 s.hGroup2 = decodeHuffmanTreeGroup(numDistanceCodes, numDistTrees, s);
675 s.contextMapSlice = 0;
676 s.distContextMapSlice = 0;
677 s.contextLookupOffset1 = (s.contextModes[0]) << 9;
678 s.contextLookupOffset2 = s.contextLookupOffset1 + 256;
679 s.literalTreeIndex = 0;
680 s.literalTree = s.hGroup0[0];
681 s.treeCommandOffset = s.hGroup1[0];
682 s.rings[4] = 1;
683 s.rings[5] = 0;
684 s.rings[6] = 1;
685 s.rings[7] = 0;
686 s.rings[8] = 1;
687 s.rings[9] = 0;
693 function copyUncompressedData(s) { argument
694 var /** !Int8Array */ ringBuffer = s.ringBuffer;
695 if (s.metaBlockLength <= 0) {
696 reload(s);
697 s.runningState = 1;
700 var /** !number */ chunkLength = min(s.ringBufferSize - s.pos, s.metaBlockLength);
701 copyBytes(s, ringBuffer, s.pos, chunkLength);
702 s.metaBlockLength -= chunkLength;
703 s.pos += chunkLength;
704 if (s.pos == s.ringBufferSize) {
705 s.nextRunningState = 5;
706 s.runningState = 11;
709 reload(s);
710 s.runningState = 1;
716 function writeRingBuffer(s) { argument
717 …var /** !number */ toWrite = min(s.outputLength - s.outputUsed, s.ringBufferBytesReady - s.ringBuf…
719 …s.output.set(s.ringBuffer.subarray(s.ringBufferBytesWritten, s.ringBufferBytesWritten + toWrite), …
720 s.outputUsed += toWrite;
721 s.ringBufferBytesWritten += toWrite;
723 if (s.outputUsed < s.outputLength) {
735 function decodeHuffmanTreeGroup(alphabetSize, n, s) { argument
740 readHuffmanCode(alphabetSize, group, next, s);
749 function calculateFence(s) { argument
750 var /** !number */ result = s.ringBufferSize;
751 if (s.isEager != 0) {
752 result = min(result, s.ringBufferBytesWritten + s.outputLength - s.outputUsed);
760 function decompress(s) { argument
761 if (s.runningState == 0) {
764 if (s.runningState == 10) {
767 var /** !number */ fence = calculateFence(s);
768 var /** !number */ ringBufferMask = s.ringBufferSize - 1;
769 var /** !Int8Array */ ringBuffer = s.ringBuffer;
770 while (s.runningState != 9) {
771 switch(s.runningState) {
773 if (s.metaBlockLength < 0) {
776 readNextMetablockHeader(s);
777 fence = calculateFence(s);
778 ringBufferMask = s.ringBufferSize - 1;
779 ringBuffer = s.ringBuffer;
782 readMetablockHuffmanCodesAndContextMaps(s);
783 s.runningState = 3;
785 if (s.metaBlockLength <= 0) {
786 s.runningState = 1;
789 if (s.halfOffset > 2030) {
790 doReadMoreInput(s);
792 if (s.commandBlockLength == 0) {
793 decodeCommandBlockSwitch(s);
795 s.commandBlockLength--;
796 if (s.bitOffset >= 16) {
797 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
798 s.bitOffset -= 16;
800 var /** !number */ cmdCode = readSymbol(s.hGroup1, s.treeCommandOffset, s);
802 s.distanceCode = 0;
805 s.distanceCode = -1;
808 if (s.bitOffset >= 16) {
809 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
810 s.bitOffset -= 16;
813 …* !number */ insertExtra = ((insertBits <= 16) ? readFewBits(s, insertBits) : readManyBits(s, inse…
814 s.insertLength = INSERT_LENGTH_OFFSET[insertCode] + insertExtra;
816 if (s.bitOffset >= 16) {
817 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
818 s.bitOffset -= 16;
821 …ar /** !number */ copyExtra = ((copyBits <= 16) ? readFewBits(s, copyBits) : readManyBits(s, copyB…
822 s.copyLength = COPY_LENGTH_OFFSET[copyCode] + copyExtra;
823 s.j = 0;
824 s.runningState = 6;
826 if (s.trivialLiteralContext != 0) {
827 while (s.j < s.insertLength) {
828 if (s.halfOffset > 2030) {
829 doReadMoreInput(s);
831 if (s.literalBlockLength == 0) {
832 decodeLiteralBlockSwitch(s);
834 s.literalBlockLength--;
835 if (s.bitOffset >= 16) {
836 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
837 s.bitOffset -= 16;
839 ringBuffer[s.pos] = readSymbol(s.hGroup0, s.literalTree, s);
840 s.pos++;
841 s.j++;
842 if (s.pos >= fence) {
843 s.nextRunningState = 6;
844 s.runningState = 11;
849 var /** !number */ prevByte1 = ringBuffer[(s.pos - 1) & ringBufferMask] & 0xFF;
850 var /** !number */ prevByte2 = ringBuffer[(s.pos - 2) & ringBufferMask] & 0xFF;
851 while (s.j < s.insertLength) {
852 if (s.halfOffset > 2030) {
853 doReadMoreInput(s);
855 if (s.literalBlockLength == 0) {
856 decodeLiteralBlockSwitch(s);
858 …** !number */ literalTreeIndex = s.contextMap[s.contextMapSlice + (LOOKUP[s.contextLookupOffset1 +…
859 s.literalBlockLength--;
861 if (s.bitOffset >= 16) {
862 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
863 s.bitOffset -= 16;
865 prevByte1 = readSymbol(s.hGroup0, s.hGroup0[literalTreeIndex], s);
866 ringBuffer[s.pos] = prevByte1;
867 s.pos++;
868 s.j++;
869 if (s.pos >= fence) {
870 s.nextRunningState = 6;
871 s.runningState = 11;
876 if (s.runningState != 6) {
879 s.metaBlockLength -= s.insertLength;
880 if (s.metaBlockLength <= 0) {
881 s.runningState = 3;
884 if (s.distanceCode < 0) {
885 if (s.halfOffset > 2030) {
886 doReadMoreInput(s);
888 if (s.distanceBlockLength == 0) {
889 decodeDistanceBlockSwitch(s);
891 s.distanceBlockLength--;
892 if (s.bitOffset >= 16) {
893 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
894 s.bitOffset -= 16;
896 …s.distanceCode = readSymbol(s.hGroup2, s.hGroup2[s.distContextMap[s.distContextMapSlice + (s.copyL…
897 if (s.distanceCode >= s.numDirectDistanceCodes) {
898 s.distanceCode -= s.numDirectDistanceCodes;
899 var /** !number */ postfix = s.distanceCode & s.distancePostfixMask;
900 s.distanceCode >>>= s.distancePostfixBits;
901 var /** !number */ n = (s.distanceCode >>> 1) + 1;
902 var /** !number */ offset = ((2 + (s.distanceCode & 1)) << n) - 4;
903 if (s.bitOffset >= 16) {
904 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
905 s.bitOffset -= 16;
907 … var /** !number */ distanceExtra = ((n <= 16) ? readFewBits(s, n) : readManyBits(s, n));
908 …s.distanceCode = s.numDirectDistanceCodes + postfix + ((offset + distanceExtra) << s.distancePostf…
911 s.distance = translateShortCodes(s.distanceCode, s.rings, s.distRbIdx);
912 if (s.distance < 0) {
915 if (s.maxDistance != s.maxBackwardDistance && s.pos < s.maxBackwardDistance) {
916 s.maxDistance = s.pos;
918 s.maxDistance = s.maxBackwardDistance;
920 if (s.distance > s.maxDistance) {
921 s.runningState = 8;
924 if (s.distanceCode > 0) {
925 s.rings[s.distRbIdx & 3] = s.distance;
926 s.distRbIdx++;
928 if (s.copyLength > s.metaBlockLength) {
931 s.j = 0;
932 s.runningState = 7;
934 var /** !number */ src = (s.pos - s.distance) & ringBufferMask;
935 var /** !number */ dst = s.pos;
936 var /** !number */ copyLength = s.copyLength - s.j;
950 s.j += copyLength;
951 s.metaBlockLength -= copyLength;
952 s.pos += copyLength;
954 for (; s.j < s.copyLength; ) {
955 ringBuffer[s.pos] = ringBuffer[(s.pos - s.distance) & ringBufferMask];
956 s.metaBlockLength--;
957 s.pos++;
958 s.j++;
959 if (s.pos >= fence) {
960 s.nextRunningState = 7;
961 s.runningState = 11;
966 if (s.runningState == 7) {
967 s.runningState = 3;
971 if (s.copyLength >= 4 && s.copyLength <= 24) {
972 var /** !number */ offset = DICTIONARY_OFFSETS_BY_LENGTH[s.copyLength];
973 var /** !number */ wordId = s.distance - s.maxDistance - 1;
974 var /** !number */ shift = DICTIONARY_SIZE_BITS_BY_LENGTH[s.copyLength];
978 offset += wordIdx * s.copyLength;
980 …ar /** !number */ len = transformDictionaryWord(ringBuffer, s.pos, DICTIONARY_DATA, offset, s.copy…
981 s.pos += len;
982 s.metaBlockLength -= len;
983 if (s.pos >= fence) {
984 s.nextRunningState = 3;
985 s.runningState = 11;
994 s.runningState = 3;
997 while (s.metaBlockLength > 0) {
998 if (s.halfOffset > 2030) {
999 doReadMoreInput(s);
1001 if (s.bitOffset >= 16) {
1002 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
1003 s.bitOffset -= 16;
1005 readFewBits(s, 8);
1006 s.metaBlockLength--;
1008 s.runningState = 1;
1011 copyUncompressedData(s);
1014 s.ringBufferBytesReady = min(s.pos, s.ringBufferSize);
1015 s.runningState = 12;
1017 if (writeRingBuffer(s) == 0) {
1020 if (s.pos >= s.maxBackwardDistance) {
1021 s.maxDistance = s.maxBackwardDistance;
1023 if (s.pos >= s.ringBufferSize) {
1024 if (s.pos > s.ringBufferSize) {
1025 ringBuffer.copyWithin(0, s.ringBufferSize, s.pos);
1027 s.pos &= ringBufferMask;
1028 s.ringBufferBytesWritten = 0;
1030 s.runningState = s.nextRunningState;
1033 throw "Unexpected state " + s.runningState;
1036 if (s.runningState == 9) {
1037 if (s.metaBlockLength < 0) {
1040 jumpToByteBoundary(s);
1041 checkHealth(s, 1);
1244 function doReadMoreInput(s) { argument
1245 if (s.endOfStreamReached != 0) {
1246 if (halfAvailable(s) >= -2) {
1251 var /** !number */ readOffset = s.halfOffset << 1;
1253 s.byteBuffer.copyWithin(0, readOffset, 4096);
1254 s.halfOffset = 0;
1257 var /** !number */ len = readInput(s.input, s.byteBuffer, bytesInBuffer, spaceLeft);
1259 s.endOfStreamReached = 1;
1260 s.tailBytes = bytesInBuffer;
1266 bytesToNibbles(s, bytesInBuffer);
1273 function checkHealth(s, endOfStream) { argument
1274 if (s.endOfStreamReached == 0) {
1277 var /** !number */ byteOffset = (s.halfOffset << 1) + ((s.bitOffset + 7) >> 3) - 4;
1278 if (byteOffset > s.tailBytes) {
1281 if ((endOfStream != 0) && (byteOffset != s.tailBytes)) {
1290 function readFewBits(s, n) { argument
1291 var /** !number */ val = (s.accumulator32 >>> s.bitOffset) & ((1 << n) - 1);
1292 s.bitOffset += n;
1300 function readManyBits(s, n) { argument
1301 var /** !number */ low = readFewBits(s, 16);
1302 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
1303 s.bitOffset -= 16;
1304 return low | (readFewBits(s, n - 16) << 16);
1310 function initBitReader(s) { argument
1311 s.byteBuffer = new Int8Array(4160);
1312 s.accumulator32 = 0;
1313 s.shortBuffer = new Int16Array(2080);
1314 s.bitOffset = 32;
1315 s.halfOffset = 2048;
1316 s.endOfStreamReached = 0;
1317 prepare(s);
1323 function prepare(s) { argument
1324 if (s.halfOffset > 2030) {
1325 doReadMoreInput(s);
1327 checkHealth(s, 0);
1328 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
1329 s.bitOffset -= 16;
1330 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
1331 s.bitOffset -= 16;
1337 function reload(s) { argument
1338 if (s.bitOffset == 32) {
1339 prepare(s);
1346 function jumpToByteBoundary(s) { argument
1347 var /** !number */ padding = (32 - s.bitOffset) & 7;
1349 var /** !number */ paddingBits = readFewBits(s, padding);
1359 function halfAvailable(s) { argument
1361 if (s.endOfStreamReached != 0) {
1362 limit = (s.tailBytes + 1) >> 1;
1364 return limit - s.halfOffset;
1373 function copyBytes(s, data, offset, length) { argument
1374 if ((s.bitOffset & 7) != 0) {
1377 while ((s.bitOffset != 32) && (length != 0)) {
1378 data[offset++] = (s.accumulator32 >>> s.bitOffset);
1379 s.bitOffset += 8;
1385 var /** !number */ copyNibbles = min(halfAvailable(s), length >> 1);
1387 var /** !number */ readOffset = s.halfOffset << 1;
1389 data.set(s.byteBuffer.subarray(readOffset, readOffset + delta), offset);
1392 s.halfOffset += copyNibbles;
1397 if (halfAvailable(s) > 0) {
1398 if (s.bitOffset >= 16) {
1399 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
1400 s.bitOffset -= 16;
1403 data[offset++] = (s.accumulator32 >>> s.bitOffset);
1404 s.bitOffset += 8;
1407 checkHealth(s, 0);
1411 var /** !number */ len = readInput(s.input, data, offset, length);
1424 function bytesToNibbles(s, byteLen) { argument
1425 var /** !Int8Array */ byteBuffer = s.byteBuffer;
1427 var /** !Int16Array */ shortBuffer = s.shortBuffer;
1696 var /** !State */ s = new State();
1697 initState(s, new InputStream(bytes));
1703 s.output = chunk;
1704 s.outputOffset = 0;
1705 s.outputLength = 16384;
1706 s.outputUsed = 0;
1707 decompress(s);
1708 totalOutput += s.outputUsed;
1709 if (s.outputUsed < 16384) break;
1711 close(s);