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

Method readMoreInput

java/org/brotli/dec/BitReader.java:60–89  ·  view source on GitHub ↗

Fills up the input buffer. Should not be called if there are at least 36 bytes present after current position. After encountering the end of the input stream, 64 additional zero bytes are copied to the buffer.

(State s)

Source from the content-addressed store, hash-verified

58 * buffer.
59 */
60 static int readMoreInput(State s) {
61 if (s.endOfStreamReached != 0) {
62 if (halfAvailable(s) >= -2) {
63 return BROTLI_OK;
64 }
65 return Utils.makeError(s, BROTLI_ERROR_TRUNCATED_INPUT);
66 }
67 final int readOffset = s.halfOffset << LOG_HALF_SIZE;
68 int bytesInBuffer = CAPACITY - readOffset;
69 // Move unused bytes to the head of the buffer.
70 Utils.copyBytesWithin(s.byteBuffer, 0, readOffset, CAPACITY);
71 s.halfOffset = 0;
72 while (bytesInBuffer < CAPACITY) {
73 final int spaceLeft = CAPACITY - bytesInBuffer;
74 final int len = Utils.readInput(s, s.byteBuffer, bytesInBuffer, spaceLeft);
75 if (len < BROTLI_ERROR) {
76 return len;
77 }
78 // EOF is -1 in Java, but 0 in C#.
79 if (len <= 0) {
80 s.endOfStreamReached = 1;
81 s.tailBytes = bytesInBuffer;
82 bytesInBuffer += HALF_SIZE - 1;
83 break;
84 }
85 bytesInBuffer += len;
86 }
87 bytesToNibbles(s, bytesInBuffer);
88 return BROTLI_OK;
89 }
90
91 static int checkHealth(State s, int endOfStream) {
92 if (s.endOfStreamReached == 0) {

Callers 7

prepareMethod · 0.95
readHuffmanCodeMethod · 0.95
decodeContextMapMethod · 0.95
decompressMethod · 0.95

Calls 5

halfAvailableMethod · 0.95
makeErrorMethod · 0.95
copyBytesWithinMethod · 0.95
readInputMethod · 0.95
bytesToNibblesMethod · 0.95

Tested by

no test coverage detected