From 523a870a07d5c55cfca3ffa9e6a9e02b4891b531 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Date: Wed, 9 Apr 2025 22:06:11 +0200 Subject: [PATCH 09/10] avcodec/hq_hqa: Remove implicit always-false checks This decoder has explicit checks. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/hq_hqa.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c index 26493b1e1c..cc3bdc5894 100644 --- a/libavcodec/hq_hqa.c +++ b/libavcodec/hq_hqa.c @@ -165,7 +165,7 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic, GetByteContext *gbc, /* Offsets are stored from CUV position, so adjust them accordingly. */ for (i = 0; i < profile->num_slices + 1; i++) - slice_off[i] = bytestream2_get_be24(gbc) - 4; + slice_off[i] = bytestream2_get_be24u(gbc) - 4; next_off = 0; for (slice = 0; slice < profile->num_slices; slice++) { @@ -270,8 +270,8 @@ static int hqa_decode_frame(HQContext *ctx, AVFrame *pic, GetByteContext *gbc, s if (bytestream2_get_bytes_left(gbc) < 8 + 4*(num_slices + 1)) return AVERROR_INVALIDDATA; - width = bytestream2_get_be16(gbc); - height = bytestream2_get_be16(gbc); + width = bytestream2_get_be16u(gbc); + height = bytestream2_get_be16u(gbc); ret = ff_set_dimensions(ctx->avctx, width, height); if (ret < 0) @@ -284,8 +284,8 @@ static int hqa_decode_frame(HQContext *ctx, AVFrame *pic, GetByteContext *gbc, s av_log(ctx->avctx, AV_LOG_VERBOSE, "HQA Profile\n"); - quant = bytestream2_get_byte(gbc); - bytestream2_skip(gbc, 3); + quant = bytestream2_get_byteu(gbc); + bytestream2_skipu(gbc, 3); if (quant >= NUM_HQ_QUANTS) { av_log(ctx->avctx, AV_LOG_ERROR, "Invalid quantization matrix %d.\n", quant); @@ -298,7 +298,7 @@ static int hqa_decode_frame(HQContext *ctx, AVFrame *pic, GetByteContext *gbc, s /* Offsets are stored from HQA1 position, so adjust them accordingly. */ for (i = 0; i < num_slices + 1; i++) - slice_off[i] = bytestream2_get_be32(gbc) - 4; + slice_off[i] = bytestream2_get_be32u(gbc) - 4; for (slice = 0; slice < num_slices; slice++) { if (slice_off[slice] < (num_slices + 1) * 3 || @@ -335,18 +335,18 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, AVFrame *pic, return AVERROR_INVALIDDATA; } - info_tag = bytestream2_peek_le32(gbc); + info_tag = bytestream2_peek_le32u(gbc); if (info_tag == MKTAG('I', 'N', 'F', 'O')) { int info_size; - bytestream2_skip(gbc, 4); - info_size = bytestream2_get_le32(gbc); + bytestream2_skipu(gbc, 4); + info_size = bytestream2_get_le32u(gbc); if (info_size < 0 || bytestream2_get_bytes_left(gbc) < info_size) { av_log(avctx, AV_LOG_ERROR, "Invalid INFO size (%d).\n", info_size); return AVERROR_INVALIDDATA; } ff_canopus_parse_info_tag(avctx, gbc->buffer, info_size); - bytestream2_skip(gbc, info_size); + bytestream2_skipu(gbc, info_size); } data_size = bytestream2_get_bytes_left(gbc); @@ -358,7 +358,7 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, AVFrame *pic, /* HQ defines dimensions and number of slices, and thus slice traversal * order. HQA has no size constraint and a fixed number of slices, so it * needs a separate scheme for it. */ - tag = bytestream2_get_le32(gbc); + tag = bytestream2_get_le32u(gbc); if ((tag & 0x00FFFFFF) == (MKTAG('U', 'V', 'C', ' ') & 0x00FFFFFF)) { ret = hq_decode_frame(ctx, pic, gbc, tag >> 24, data_size); } else if (tag == MKTAG('H', 'Q', 'A', '1')) { -- 2.45.2