MCPcopy
hub / github.com/google/brotli / readComplexHuffmanCode

Function readComplexHuffmanCode

js/decode.ts:422–453  ·  view source on GitHub ↗
(alphabetSizeLimit: number, skip: number, tableGroup: Int32Array, tableIdx: number, s: State)

Source from the content-addressed store, hash-verified

420 return buildHuffmanTable(tableGroup, tableIdx, 8, codeLengths, alphabetSizeLimit);
421}
422function readComplexHuffmanCode(alphabetSizeLimit: number, skip: number, tableGroup: Int32Array, tableIdx: number, s: State): number {
423 const codeLengths = new Int32Array(alphabetSizeLimit);
424 const codeLengthCodeLengths = new Int32Array(18);
425 let space = 32;
426 let numCodes = 0;
427 for (let i: number = skip; i < 18; ++i) {
428 const codeLenIdx: number = CODE_LENGTH_CODE_ORDER[i];
429 if (s.bitOffset >= 16) {
430 s.accumulator32 = (s.shortBuffer[s.halfOffset++] << 16) | (s.accumulator32 >>> 16);
431 s.bitOffset -= 16;
432 }
433 const p: number = (s.accumulator32 >>> s.bitOffset) & 15;
434 s.bitOffset += FIXED_TABLE[p] >> 16;
435 const v: number = FIXED_TABLE[p] & 0xFFFF;
436 codeLengthCodeLengths[codeLenIdx] = v;
437 if (v !== 0) {
438 space -= 32 >> v;
439 numCodes++;
440 if (space <= 0) {
441 break;
442 }
443 }
444 }
445 if (space !== 0 && numCodes !== 1) {
446 return makeError(s, -4);
447 }
448 const result: number = readHuffmanCodeLengths(codeLengthCodeLengths, alphabetSizeLimit, codeLengths, s);
449 if (result < 0) {
450 return result;
451 }
452 return buildHuffmanTable(tableGroup, tableIdx, 8, codeLengths, alphabetSizeLimit);
453}
454function readHuffmanCode(alphabetSizeMax: number, alphabetSizeLimit: number, tableGroup: Int32Array, tableIdx: number, s: State): number {
455 if (s.halfOffset > 2030) {
456 const result: number = readMoreInput(s);

Callers 1

readHuffmanCodeFunction · 0.70

Calls 3

makeErrorFunction · 0.70
readHuffmanCodeLengthsFunction · 0.70
buildHuffmanTableFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…