From b433c66eb3318bfe8156aea4d161e96c040080d7 Mon Sep 17 00:00:00 2001 From: Mathis Rosenhauer <rosenhauer@dkrz.de> Date: Mon, 3 Apr 2023 17:17:24 +0200 Subject: [PATCH] decode: seek to RSI --- src/decode.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/decode.c b/src/decode.c index ef89e36..efb08c2 100644 --- a/src/decode.c +++ b/src/decode.c @@ -825,3 +825,30 @@ int aec_buffer_decode(struct aec_stream *strm) aec_decode_end(strm); return status; } + +int aec_buffer_seek(struct aec_stream *strm, + size_t byte_offset, + unsigned char bit_offset) +{ + struct internal_state *state = strm->state; + + if (bit_offset > 7) + return AEC_CONF_ERROR; + + if (strm->avail_in < byte_offset) + return AEC_MEM_ERROR; + + strm->next_in += byte_offset; + strm->avail_in -= byte_offset; + + if (bit_offset > 0) { + if (strm->avail_in < 1) + return AEC_MEM_ERROR; + + state->acc = (uint64_t)strm->next_in[0]; + state->bitp = 8 - bit_offset; + strm->next_in++; + strm->avail_in--; + } + return AEC_OK; +} -- GitLab