diff options
author | Peter Ross <pross@xvid.org> | 2021-09-18 19:55:22 +1000 |
---|---|---|
committer | Peter Ross <pross@xvid.org> | 2021-09-28 21:23:26 +1000 |
commit | e40593c0505a3ee143b8ac949af1bb70becafb21 (patch) | |
tree | 80b2244ac77dbd2c093ab2309bb50cb29518d95a | |
parent | b007e8968f2072b9e8076d0ab474ad944fc07ade (diff) | |
download | ffmpeg-e40593c0505a3ee143b8ac949af1bb70becafb21.tar.gz |
avcodec/siren: don't reduce getbitcontext size by checksum_bits at initialisation
this allows the checksum calculation routine to also use getbitcontext
Signed-off-by: Peter Ross <pross@xvid.org>
-rw-r--r-- | libavcodec/siren.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libavcodec/siren.c b/libavcodec/siren.c index 27ee356c44..0ecf0fcafc 100644 --- a/libavcodec/siren.c +++ b/libavcodec/siren.c @@ -594,7 +594,7 @@ static int decode_vector(SirenContext *s, int number_of_regions, for (i = 0; i < number_of_vectors[category]; i++) { index = 0; do { - if (get_bits_left(gb) <= 0) { + if (get_bits_left(gb) - s->checksum_bits <= 0) { error = 1; break; } @@ -614,7 +614,7 @@ static int decode_vector(SirenContext *s, int number_of_regions, index >>= index_table[category]; if (decoded_value) { - if (get_bits_left(gb) <= 0) { + if (get_bits_left(gb) - s->checksum_bits <= 0) { error = 1; break; } @@ -697,7 +697,7 @@ static int decode_vector(SirenContext *s, int number_of_regions, } } - return error == 1 ? AVERROR_INVALIDDATA : get_bits_left(gb); + return error == 1 ? AVERROR_INVALIDDATA : (get_bits_left(gb) - s->checksum_bits); } static int siren_decode(AVCodecContext *avctx, void *data, @@ -716,7 +716,7 @@ static int siren_decode(AVCodecContext *avctx, void *data, if (avpkt->size < bits_per_frame / 8) return AVERROR_INVALIDDATA; - if ((ret = init_get_bits(gb, avpkt->data, bits_per_frame - s->checksum_bits)) < 0) + if ((ret = init_get_bits(gb, avpkt->data, bits_per_frame)) < 0) return ret; } else if ((ret = init_get_bits8(gb, avpkt->data, avpkt->size)) < 0) @@ -730,7 +730,7 @@ static int siren_decode(AVCodecContext *avctx, void *data, rate_control = get_bits(gb, 4); - ret = categorize_regions(s->number_of_regions, get_bits_left(gb), + ret = categorize_regions(s->number_of_regions, get_bits_left(gb) - s->checksum_bits, s->absolute_region_power_index, s->power_categories, s->category_balance); if (ret < 0) @@ -745,11 +745,11 @@ static int siren_decode(AVCodecContext *avctx, void *data, if (ret < 0 && !s->microsoft) return ret; - if (get_bits_left(gb) > 0) { + if (get_bits_left(gb) - s->checksum_bits > 0) { do { frame_error |= !get_bits1(gb); - } while (get_bits_left(gb) > 0); - } else if (get_bits_left(gb) < 0 && + } while (get_bits_left(gb) - s->checksum_bits > 0); + } else if (get_bits_left(gb) - s->checksum_bits < 0 && rate_control + 1 < s->rate_control_possibilities) { frame_error = 1; } |