Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 0/5] Encode checks
@ 2025-07-11 18:00 ffmpegagent
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 1/5] avcodec/av1dec, libdav1d, wbmpdec: Avoid direct access to GetByteContext Andreas Rheinhardt
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ffmpegagent @ 2025-07-11 18:00 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: mkver

Mostly removal of dead encode checks.

Andreas Rheinhardt (5):
  avcodec/av1dec,libdav1d,wbmpdec: Avoid direct access to GetByteContext
  avcodec/encode: Simplify pixel format validity check
  avcodec/encode: Ignore coded_{width,height}
  avcodec/encode: Remove dead code
  avcodec/encode: Remove redundant av_image_check_size2()

 libavcodec/av1dec.c   |  2 +-
 libavcodec/encode.c   | 28 ++++++----------------------
 libavcodec/libdav1d.c |  2 +-
 libavcodec/wbmpdec.c  |  3 ++-
 4 files changed, 10 insertions(+), 25 deletions(-)


base-commit: 3ce348063c9433e33a5cb1ac79ac1efa37c21621
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-107%2Fmkver%2Fencode_checks-v1
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-107/mkver/encode_checks-v1
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/107
-- 
ffmpeg-codebot
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 1/5] avcodec/av1dec, libdav1d, wbmpdec: Avoid direct access to GetByteContext
  2025-07-11 18:00 [FFmpeg-devel] [PATCH 0/5] Encode checks ffmpegagent
@ 2025-07-11 18:00 ` Andreas Rheinhardt
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 2/5] avcodec/encode: Simplify pixel format validity check Andreas Rheinhardt
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2025-07-11 18:00 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/av1dec.c   | 2 +-
 libavcodec/libdav1d.c | 2 +-
 libavcodec/wbmpdec.c  | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 8ff1bf394c..dcbe4ef2ce 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -1024,7 +1024,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
             provider_oriented_code != 0x800)
             break;
 
-        ret = ff_dovi_rpu_parse(&s->dovi, gb.buffer, gb.buffer_end - gb.buffer,
+        ret = ff_dovi_rpu_parse(&s->dovi, gb.buffer, bytestream2_get_bytes_left(&gb),
                                 avctx->err_recognition);
         if (ret < 0) {
             av_log(avctx, AV_LOG_WARNING, "Error parsing DOVI OBU.\n");
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index f4cbc927b5..f24d00ca38 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -576,7 +576,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
                 provider_oriented_code != 0x800)
                 break;
 
-            res = ff_dovi_rpu_parse(&dav1d->dovi, gb.buffer, gb.buffer_end - gb.buffer,
+            res = ff_dovi_rpu_parse(&dav1d->dovi, gb.buffer, bytestream2_get_bytes_left(&gb),
                                     c->err_recognition);
             if (res < 0) {
                 av_log(c, AV_LOG_WARNING, "Error parsing DOVI OBU.\n");
diff --git a/libavcodec/wbmpdec.c b/libavcodec/wbmpdec.c
index 50c729047d..5a61510a88 100644
--- a/libavcodec/wbmpdec.c
+++ b/libavcodec/wbmpdec.c
@@ -72,7 +72,8 @@ static int wbmp_decode_frame(AVCodecContext *avctx, AVFrame *p,
     if (p->linesize[0] == (width + 7) / 8)
         bytestream2_get_buffer(&gb, p->data[0], height * ((width + 7) / 8));
     else
-        readbits(p->data[0], width, height, p->linesize[0], gb.buffer, gb.buffer_end - gb.buffer);
+        readbits(p->data[0], width, height, p->linesize[0],
+                 gb.buffer, bytestream2_get_bytes_left(&gb));
 
     *got_frame   = 1;
 
-- 
ffmpeg-codebot

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 2/5] avcodec/encode: Simplify pixel format validity check
  2025-07-11 18:00 [FFmpeg-devel] [PATCH 0/5] Encode checks ffmpegagent
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 1/5] avcodec/av1dec, libdav1d, wbmpdec: Avoid direct access to GetByteContext Andreas Rheinhardt
@ 2025-07-11 18:00 ` Andreas Rheinhardt
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 3/5] avcodec/encode: Ignore coded_{width, height} Andreas Rheinhardt
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2025-07-11 18:00 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/encode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 38833c566c..b9782a0581 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -551,7 +551,7 @@ static int encode_preinit_video(AVCodecContext *avctx)
     const enum AVPixelFormat *pix_fmts;
     int ret, i, num_pix_fmts;
 
-    if (!av_get_pix_fmt_name(avctx->pix_fmt)) {
+    if (!pixdesc) {
         av_log(avctx, AV_LOG_ERROR, "Invalid video pixel format: %d\n",
                avctx->pix_fmt);
         return AVERROR(EINVAL);
-- 
ffmpeg-codebot

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 3/5] avcodec/encode: Ignore coded_{width, height}
  2025-07-11 18:00 [FFmpeg-devel] [PATCH 0/5] Encode checks ffmpegagent
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 1/5] avcodec/av1dec, libdav1d, wbmpdec: Avoid direct access to GetByteContext Andreas Rheinhardt
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 2/5] avcodec/encode: Simplify pixel format validity check Andreas Rheinhardt
@ 2025-07-11 18:00 ` Andreas Rheinhardt
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 4/5] avcodec/encode: Remove dead code Andreas Rheinhardt
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 5/5] avcodec/encode: Remove redundant av_image_check_size2() Andreas Rheinhardt
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2025-07-11 18:00 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

It is supposed to be unused by encoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/encode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index b9782a0581..0308c73630 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -818,8 +818,8 @@ int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
     case AVMEDIA_TYPE_VIDEO:
         frame->format = avctx->pix_fmt;
         if (frame->width <= 0 || frame->height <= 0) {
-            frame->width  = FFMAX(avctx->width,  avctx->coded_width);
-            frame->height = FFMAX(avctx->height, avctx->coded_height);
+            frame->width  = avctx->width;
+            frame->height = avctx->height;
         }
 
         break;
-- 
ffmpeg-codebot

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 4/5] avcodec/encode: Remove dead code
  2025-07-11 18:00 [FFmpeg-devel] [PATCH 0/5] Encode checks ffmpegagent
                   ` (2 preceding siblings ...)
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 3/5] avcodec/encode: Ignore coded_{width, height} Andreas Rheinhardt
@ 2025-07-11 18:00 ` Andreas Rheinhardt
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 5/5] avcodec/encode: Remove redundant av_image_check_size2() Andreas Rheinhardt
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2025-07-11 18:00 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

Can be readded if needed (likely never).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/encode.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 0308c73630..2f789c5b7a 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -814,24 +814,12 @@ int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
 {
     int ret;
 
-    switch (avctx->codec->type) {
-    case AVMEDIA_TYPE_VIDEO:
-        frame->format = avctx->pix_fmt;
-        if (frame->width <= 0 || frame->height <= 0) {
-            frame->width  = avctx->width;
-            frame->height = avctx->height;
-        }
+    av_assert1(avctx->codec_type == AVMEDIA_TYPE_VIDEO);
 
-        break;
-    case AVMEDIA_TYPE_AUDIO:
-        frame->sample_rate = avctx->sample_rate;
-        frame->format      = avctx->sample_fmt;
-        if (!frame->ch_layout.nb_channels) {
-            ret = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout);
-            if (ret < 0)
-                return ret;
-        }
-        break;
+    frame->format = avctx->pix_fmt;
+    if (frame->width <= 0 || frame->height <= 0) {
+        frame->width  = avctx->width;
+        frame->height = avctx->height;
     }
 
     ret = avcodec_default_get_buffer2(avctx, frame, 0);
-- 
ffmpeg-codebot

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 5/5] avcodec/encode: Remove redundant av_image_check_size2()
  2025-07-11 18:00 [FFmpeg-devel] [PATCH 0/5] Encode checks ffmpegagent
                   ` (3 preceding siblings ...)
  2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 4/5] avcodec/encode: Remove dead code Andreas Rheinhardt
@ 2025-07-11 18:00 ` Andreas Rheinhardt
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2025-07-11 18:00 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

The dimensions have already been checked during init.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/encode.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 2f789c5b7a..c12cb1aa09 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -18,12 +18,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/emms.h"
 #include "libavutil/frame.h"
-#include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
@@ -357,8 +355,6 @@ static int encode_receive_packet_internal(AVCodecContext *avctx, AVPacket *avpkt
     if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
         if ((avctx->flags & AV_CODEC_FLAG_PASS1) && avctx->stats_out)
             avctx->stats_out[0] = '\0';
-        if (av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx))
-            return AVERROR(EINVAL);
     }
 
     if (ffcodec(avctx->codec)->cb_type == FF_CODEC_CB_TYPE_RECEIVE_PACKET) {
-- 
ffmpeg-codebot
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-07-11 18:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-11 18:00 [FFmpeg-devel] [PATCH 0/5] Encode checks ffmpegagent
2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 1/5] avcodec/av1dec, libdav1d, wbmpdec: Avoid direct access to GetByteContext Andreas Rheinhardt
2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 2/5] avcodec/encode: Simplify pixel format validity check Andreas Rheinhardt
2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 3/5] avcodec/encode: Ignore coded_{width, height} Andreas Rheinhardt
2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 4/5] avcodec/encode: Remove dead code Andreas Rheinhardt
2025-07-11 18:00 ` [FFmpeg-devel] [PATCH 5/5] avcodec/encode: Remove redundant av_image_check_size2() Andreas Rheinhardt

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