[FFmpeg-cvslog] avcodec/hq_hqa: Remove implicit always-false checks
Andreas Rheinhardt
git at videolan.org
Sun Apr 13 10:01:13 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Apr 9 22:06:11 2025 +0200| [16943876f87783e3c15b8bbbb609bf8c8f530f45] | committer: Andreas Rheinhardt
avcodec/hq_hqa: Remove implicit always-false checks
This decoder has explicit checks.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=16943876f87783e3c15b8bbbb609bf8c8f530f45
---
libavcodec/hq_hqa.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c
index 0baec67136..fd0c47cb28 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++) {
@@ -264,14 +264,13 @@ static int hqa_decode_frame(HQContext *ctx, AVFrame *pic, GetByteContext *gbc, s
const int num_slices = 8;
uint32_t slice_off[9];
int i, slice, ret;
- int width, height, quant;
const uint8_t *src = gbc->buffer;
if (bytestream2_get_bytes_left(gbc) < 8 + 4*(num_slices + 1))
return AVERROR_INVALIDDATA;
- width = bytestream2_get_be16(gbc);
- height = bytestream2_get_be16(gbc);
+ int width = bytestream2_get_be16u(gbc);
+ int height = bytestream2_get_be16u(gbc);
ret = ff_set_dimensions(ctx->avctx, width, height);
if (ret < 0)
@@ -284,8 +283,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);
+ int 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 +297,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 ||
@@ -324,10 +323,8 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, AVFrame *pic,
{
HQContext *ctx = avctx->priv_data;
GetByteContext gbc0, *const gbc = &gbc0;
- uint32_t info_tag;
unsigned int data_size;
int ret;
- unsigned tag;
bytestream2_init(gbc, avpkt->data, avpkt->size);
if (bytestream2_get_bytes_left(gbc) < 4 + 4) {
@@ -335,18 +332,17 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, AVFrame *pic,
return AVERROR_INVALIDDATA;
}
- info_tag = bytestream2_peek_le32(gbc);
+ uint32_t 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);
+ int 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 +354,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);
+ unsigned 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')) {
More information about the ffmpeg-cvslog
mailing list