diff options
Diffstat (limited to 'src/decoder/DecoderBuffer.cxx')
-rw-r--r-- | src/decoder/DecoderBuffer.cxx | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/decoder/DecoderBuffer.cxx b/src/decoder/DecoderBuffer.cxx index e26a702b7..7902e6e89 100644 --- a/src/decoder/DecoderBuffer.cxx +++ b/src/decoder/DecoderBuffer.cxx @@ -165,23 +165,14 @@ decoder_buffer_consume(DecoderBuffer *buffer, size_t nbytes) bool decoder_buffer_skip(DecoderBuffer *buffer, size_t nbytes) { - bool success; + const size_t available = decoder_buffer_available(buffer); + if (available >= nbytes) { + decoder_buffer_consume(buffer, nbytes); + return true; + } - /* this could probably be optimized by seeking */ + decoder_buffer_clear(buffer); + nbytes -= available; - while (true) { - auto data = decoder_buffer_read(buffer); - if (!data.IsEmpty()) { - if (data.size > nbytes) - data.size = nbytes; - decoder_buffer_consume(buffer, data.size); - nbytes -= data.size; - if (nbytes == 0) - return true; - } - - success = decoder_buffer_fill(buffer); - if (!success) - return false; - } + return decoder_skip(buffer->decoder, *buffer->is, nbytes); } |