diff options
author | Eugene Kliuchnikov <eustas@google.com> | 2016-10-19 20:03:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-19 20:03:43 +0200 |
commit | 058a113dd9c1ba710d680c7742f84ced05098b87 (patch) | |
tree | fa78e4a728622850d7a41da638096399f9f61bd0 | |
parent | 1b364aeb42a0919e7c08646aa4f2f50e28d69fa5 (diff) | |
parent | 8bcaabb0d1c5b7941303f84f4c69176643e00a05 (diff) | |
download | brotli-058a113dd9c1ba710d680c7742f84ced05098b87.zip brotli-058a113dd9c1ba710d680c7742f84ced05098b87.tar.gz brotli-058a113dd9c1ba710d680c7742f84ced05098b87.tar.bz2 |
Merge pull request #451 from eustas/flush
Fix "take output" flush workflow.
-rw-r--r-- | enc/encode.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/enc/encode.c b/enc/encode.c index 7b4b94d..fe77a98 100644 --- a/enc/encode.c +++ b/enc/encode.c @@ -1368,6 +1368,14 @@ static BROTLI_BOOL InjectFlushOrPushOutput(BrotliEncoderState* s, return BROTLI_FALSE; } +static void CheckFlushComplete(BrotliEncoderState* s) { + if (s->stream_state_ == BROTLI_STREAM_FLUSH_REQUESTED && + s->available_out_ == 0) { + s->stream_state_ = BROTLI_STREAM_PROCESSING; + s->next_out_ = 0; + } +} + static BROTLI_BOOL BrotliEncoderCompressStreamFast( BrotliEncoderState* s, BrotliEncoderOperation op, size_t* available_in, const uint8_t** next_in, size_t* available_out, uint8_t** next_out, @@ -1479,11 +1487,7 @@ static BROTLI_BOOL BrotliEncoderCompressStreamFast( } BROTLI_FREE(m, tmp_command_buf); BROTLI_FREE(m, tmp_literal_buf); - if (s->stream_state_ == BROTLI_STREAM_FLUSH_REQUESTED && - s->available_out_ == 0) { - s->stream_state_ = BROTLI_STREAM_PROCESSING; - s->next_out_ = 0; - } + CheckFlushComplete(s); return BROTLI_TRUE; } @@ -1620,11 +1624,7 @@ BROTLI_BOOL BrotliEncoderCompressStream( } break; } - if (s->stream_state_ == BROTLI_STREAM_FLUSH_REQUESTED && - s->available_out_ == 0) { - s->stream_state_ = BROTLI_STREAM_PROCESSING; - s->next_out_ = 0; - } + CheckFlushComplete(s); return BROTLI_TRUE; } @@ -1647,6 +1647,7 @@ const uint8_t* BrotliEncoderTakeOutput(BrotliEncoderState* s, size_t* size) { s->next_out_ += consumed_size; s->available_out_ -= consumed_size; s->total_out_ += consumed_size; + CheckFlushComplete(s); *size = consumed_size; } else { *size = 0; |