mirror of
https://github.com/google/brotli.git
synced 2024-11-08 21:30:04 +00:00
Update (#470)
* condense generated `static_dict_lut.h` * implement BrotliInputStream.close()
This commit is contained in:
parent
5db62dcc9d
commit
396309a529
@ -1336,7 +1336,6 @@ void BrotliStoreSyncMetaBlock(size_t* BROTLI_RESTRICT storage_ix,
|
||||
JumpToByteBoundary(storage_ix, storage);
|
||||
}
|
||||
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
17031
enc/static_dict_lut.h
17031
enc/static_dict_lut.h
File diff suppressed because it is too large
Load Diff
@ -159,6 +159,14 @@ class BitReader {
|
||||
fillBitWindow(br);
|
||||
}
|
||||
|
||||
static void close(BitReader br) throws IOException {
|
||||
InputStream is = br.input;
|
||||
br.input = null;
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
static void jumpToByteBoundry(BitReader br) {
|
||||
int padding = (64 - br.bitOffset) & 7;
|
||||
if (padding != 0) {
|
||||
|
@ -104,6 +104,14 @@ public class BrotliInputStream extends InputStream {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
State.close(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -7,6 +7,7 @@
|
||||
package org.brotli.dec;
|
||||
|
||||
import static org.brotli.dec.RunningState.BLOCK_START;
|
||||
import static org.brotli.dec.RunningState.CLOSED;
|
||||
import static org.brotli.dec.RunningState.COMPRESSED_BLOCK_START;
|
||||
import static org.brotli.dec.RunningState.COPY_LOOP;
|
||||
import static org.brotli.dec.RunningState.COPY_UNCOMPRESSED;
|
||||
@ -582,6 +583,9 @@ public final class Decode {
|
||||
if (state.runningState == UNINITIALIZED) {
|
||||
throw new IllegalStateException("Can't decompress until initialized");
|
||||
}
|
||||
if (state.runningState == CLOSED) {
|
||||
throw new IllegalStateException("Can't decompress after close");
|
||||
}
|
||||
final BitReader br = state.br;
|
||||
int ringBufferMask = state.ringBufferSize - 1;
|
||||
byte[] ringBuffer = state.ringBuffer;
|
||||
|
@ -21,5 +21,6 @@ enum RunningState {
|
||||
COPY_WRAP_BUFFER,
|
||||
TRANSFORM,
|
||||
FINISHED,
|
||||
CLOSED,
|
||||
WRITE
|
||||
}
|
||||
|
@ -7,8 +7,10 @@
|
||||
package org.brotli.dec;
|
||||
|
||||
import static org.brotli.dec.RunningState.BLOCK_START;
|
||||
import static org.brotli.dec.RunningState.CLOSED;
|
||||
import static org.brotli.dec.RunningState.UNINITIALIZED;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
final class State {
|
||||
@ -93,7 +95,7 @@ final class State {
|
||||
*/
|
||||
static void setInput(State state, InputStream input) {
|
||||
if (state.runningState != UNINITIALIZED) {
|
||||
throw new IllegalStateException("State is MUST be uninitialized");
|
||||
throw new IllegalStateException("State MUST be uninitialized");
|
||||
}
|
||||
BitReader.init(state.br, input);
|
||||
int windowBits = decodeWindowBits(state.br);
|
||||
@ -104,4 +106,15 @@ final class State {
|
||||
state.maxBackwardDistance = state.maxRingBufferSize - 16;
|
||||
state.runningState = BLOCK_START;
|
||||
}
|
||||
|
||||
static void close(State state) throws IOException {
|
||||
if (state.runningState == UNINITIALIZED) {
|
||||
throw new IllegalStateException("State MUST be initialized");
|
||||
}
|
||||
if (state.runningState == CLOSED) {
|
||||
return;
|
||||
}
|
||||
state.runningState = CLOSED;
|
||||
BitReader.close(state.br);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user