Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/vbn(dec|enc): Avoid always-false checks
Date: Tue, 12 Apr 2022 21:25:19 +0200
Message-ID: <AS8PR01MB794416830AAE6191D11996B58FED9@AS8PR01MB7944.eurprd01.prod.exchangelabs.com> (raw)
In-Reply-To: <AS8PR01MB7944B16EA54AE2AE468332218FED9@AS8PR01MB7944.eurprd01.prod.exchangelabs.com>

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.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/vbndec.c | 20 ++++++++++----------
 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];
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-04-12 19:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 19:23 [FFmpeg-devel] [PATCH 1/5] avcodec/vbn(dec|enc): Remove empty close function Andreas Rheinhardt
2022-04-12 19:25 ` [FFmpeg-devel] [PATCH 2/5] avcodec/vbn(dec|enc): Avoid leaving stale pointers in context Andreas Rheinhardt
2022-04-12 19:25 ` Andreas Rheinhardt [this message]
2022-04-12 19:25 ` [FFmpeg-devel] [PATCH 4/5] avcodec/vbnenc: Add AV_CODEC_CAP_DR1 Andreas Rheinhardt
2022-04-12 19:25 ` [FFmpeg-devel] [PATCH 5/5] avcodec/mss12: Constify slice context->parent context pointer Andreas Rheinhardt
2022-04-12 19:29   ` Paul B Mahol
2022-04-12 19:27 ` [FFmpeg-devel] [PATCH 1/5] avcodec/vbn(dec|enc): Remove empty close function Paul B Mahol
2022-04-12 22:08 ` Marton Balint

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8PR01MB794416830AAE6191D11996B58FED9@AS8PR01MB7944.eurprd01.prod.exchangelabs.com \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git