diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-04-12 19:58:16 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-04-13 00:36:57 +0200 |
commit | cc0a4fa6304ce0f608a058dc80e3e1f5d7bcfe6a (patch) | |
tree | a899834a88862832f6dbe1d330fa8e1a76a9a1f5 | |
parent | 300dd79c3d764a5d38b914bb0f36ba195422068e (diff) | |
download | ffmpeg-cc0a4fa6304ce0f608a058dc80e3e1f5d7bcfe6a.tar.gz |
avcodec/vbn(dec|enc): Avoid always-false checks
Do this by switching to bytestream2_(get|put)_le32u() from
bytestream2_(get|put)_le32(); it has after all already been checked
that the packet contains at least a full header, making all
the implicit checks in bytestream2_(get|put)_le32() dead code.
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | libavcodec/vbndec.c | 20 | ||||
-rw-r--r-- | libavcodec/vbnenc.c | 22 |
2 files changed, 21 insertions, 21 deletions
diff --git a/libavcodec/vbndec.c b/libavcodec/vbndec.c index 56bfb1d544..a6046c766a 100644 --- a/libavcodec/vbndec.c +++ b/libavcodec/vbndec.c @@ -71,20 +71,20 @@ static int vbn_decode_frame(AVCodecContext *avctx, return AVERROR_INVALIDDATA; } - if (bytestream2_get_le32(gb) != VBN_MAGIC || - bytestream2_get_le32(gb) != VBN_MAJOR || - bytestream2_get_le32(gb) != VBN_MINOR) { + if (bytestream2_get_le32u(gb) != VBN_MAGIC || + bytestream2_get_le32u(gb) != VBN_MAJOR || + bytestream2_get_le32u(gb) != VBN_MINOR) { av_log(avctx, AV_LOG_ERROR, "Invalid VBN header\n"); return AVERROR_INVALIDDATA; } - width = bytestream2_get_le32(gb); - height = bytestream2_get_le32(gb); - components = bytestream2_get_le32(gb); - format = bytestream2_get_le32(gb); - pix_fmt = bytestream2_get_le32(gb); - bytestream2_get_le32(gb); // mipmaps - data_size = bytestream2_get_le32(gb); + width = bytestream2_get_le32u(gb); + height = bytestream2_get_le32u(gb); + components = bytestream2_get_le32u(gb); + format = bytestream2_get_le32u(gb); + pix_fmt = bytestream2_get_le32u(gb); + bytestream2_get_le32u(gb); // mipmaps + data_size = bytestream2_get_le32u(gb); bytestream2_seek(gb, VBN_HEADER_SIZE, SEEK_SET); compression = format & 0xffffff00; diff --git a/libavcodec/vbnenc.c b/libavcodec/vbnenc.c index 03d36ccc86..ec04566a32 100644 --- a/libavcodec/vbnenc.c +++ b/libavcodec/vbnenc.c @@ -97,18 +97,18 @@ static int vbn_encode(AVCodecContext *avctx, AVPacket *pkt, memset(pkt->data, 0, VBN_HEADER_SIZE); bytestream2_init_writer(pb, pkt->data, pkt_size); - bytestream2_put_le32(pb, VBN_MAGIC); - bytestream2_put_le32(pb, VBN_MAJOR); - bytestream2_put_le32(pb, VBN_MINOR); - bytestream2_put_le32(pb, frame->width); - bytestream2_put_le32(pb, frame->height); - bytestream2_put_le32(pb, frame->format == AV_PIX_FMT_RGBA ? 4 : 3); - bytestream2_put_le32(pb, ctx->format); - bytestream2_put_le32(pb, frame->format == AV_PIX_FMT_RGBA ? VBN_PIX_RGBA : VBN_PIX_RGB); - bytestream2_put_le32(pb, 0); // mipmaps - bytestream2_put_le32(pb, pkt_size - VBN_HEADER_SIZE); + bytestream2_put_le32u(pb, VBN_MAGIC); + bytestream2_put_le32u(pb, VBN_MAJOR); + bytestream2_put_le32u(pb, VBN_MINOR); + bytestream2_put_le32u(pb, frame->width); + bytestream2_put_le32u(pb, frame->height); + bytestream2_put_le32u(pb, frame->format == AV_PIX_FMT_RGBA ? 4 : 3); + bytestream2_put_le32u(pb, ctx->format); + bytestream2_put_le32u(pb, frame->format == AV_PIX_FMT_RGBA ? VBN_PIX_RGBA : VBN_PIX_RGB); + bytestream2_put_le32u(pb, 0); // mipmaps + bytestream2_put_le32u(pb, pkt_size - VBN_HEADER_SIZE); bytestream2_seek_p(pb, 64, SEEK_SET); - bytestream2_put_le32(pb, pkt_size - VBN_HEADER_SIZE); + bytestream2_put_le32u(pb, pkt_size - VBN_HEADER_SIZE); if (ctx->format == VBN_FORMAT_DXT1 || ctx->format == VBN_FORMAT_DXT5) { ctx->enc.frame_data.in = (frame->height - 1) * frame->linesize[0] + frame->data[0]; |