Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Kacper Michajłow" <kasper93-at-gmail.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: "Kacper Michajłow" <kasper93@gmail.com>
Subject: [FFmpeg-devel] [PATCH v2 1/4] tools/target_dec_fuzzer: move things to suppress Wdeclaration-after-statement
Date: Fri,  6 Jun 2025 19:20:32 +0200
Message-ID: <20250606172035.1047-2-kasper93@gmail.com> (raw)
In-Reply-To: <20250606172035.1047-1-kasper93@gmail.com>

To avoid spam in log, each fuzzer is built separately so it's amplified
a lot.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
---
 tools/target_dec_fuzzer.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index dfff167f78..7afb23619e 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -187,6 +187,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     uint64_t keyframes = 0;
     uint64_t flushpattern = -1;
     AVDictionary *opts = NULL;
+    AVCodecContext* ctx;
+    AVCodecContext* parser_avctx;
+    AVFrame *frame;
+    AVPacket *avpkt;
+    AVPacket *parsepkt;
+    int res;
+    int got_frame;
 
     if (!c) {
 #ifdef FFMPEG_DECODER
@@ -339,8 +346,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     maxsamples_per_frame = FFMIN(maxsamples_per_frame, maxsamples);
     maxpixels_per_frame  = FFMIN(maxpixels_per_frame , maxpixels);
 
-    AVCodecContext* ctx = avcodec_alloc_context3(&c->p);
-    AVCodecContext* parser_avctx = avcodec_alloc_context3(NULL);
+    ctx = avcodec_alloc_context3(&c->p);
+    parser_avctx = avcodec_alloc_context3(NULL);
     if (!ctx || !parser_avctx)
         error("Failed memory allocation");
 
@@ -470,7 +477,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
             ctx->width = ctx->height = 0;
     }
 
-    int res = avcodec_open2(ctx, &c->p, &opts);
+    res = avcodec_open2(ctx, &c->p, &opts);
     if (res < 0) {
         av_assert0(res != AVERROR_BUG);
         avcodec_free_context(&ctx);
@@ -483,11 +490,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     parser_avctx->extradata_size = ctx->extradata_size;
     parser_avctx->extradata      = ctx->extradata ? av_memdup(ctx->extradata, ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE) : NULL;
 
-
-    int got_frame;
-    AVFrame *frame = av_frame_alloc();
-    AVPacket *avpkt = av_packet_alloc();
-    AVPacket *parsepkt = av_packet_alloc();
+    frame = av_frame_alloc();
+    avpkt = av_packet_alloc();
+    parsepkt = av_packet_alloc();
     if (!frame || !avpkt || !parsepkt)
         error("Failed memory allocation");
 
@@ -563,7 +568,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
           // Iterate through all data
           while (decode_more && it++ < maxiteration) {
             av_frame_unref(frame);
-            int ret = decode_handler(ctx, frame, &got_frame, avpkt);
+            res = decode_handler(ctx, frame, &got_frame, avpkt);
 
             ec_pixels += (ctx->width + 32LL) * (ctx->height + 32LL);
             if (it > 20 || ec_pixels > 4 * ctx->max_pixels) {
@@ -582,15 +587,15 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
             if (nb_samples > maxsamples)
                 goto maximums_reached;
 
-            if (ret <= 0 || ret > avpkt->size)
+            if (res <= 0 || res > avpkt->size)
                break;
 
             if (ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
-                avpkt->data += ret;
-                avpkt->size -= ret;
+                avpkt->data += res;
+                avpkt->size -= res;
                 decode_more = avpkt->size > 0;
             } else
-                decode_more = ret >= 0;
+                decode_more = res >= 0;
           }
           av_packet_unref(avpkt);
         }
-- 
2.49.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".

  reply	other threads:[~2025-06-06 17:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06 17:20 [FFmpeg-devel] [PATCH v2 0/4] Minor fixes and for fuzzing targets Kacper Michajłow
2025-06-06 17:20 ` Kacper Michajłow [this message]
2025-06-06 21:49   ` [FFmpeg-devel] [PATCH v2 1/4] tools/target_dec_fuzzer: move things to suppress Wdeclaration-after-statement Michael Niedermayer
2025-06-07 13:46     ` Kacper Michajlow
2025-06-06 17:20 ` [FFmpeg-devel] [PATCH v2 2/4] tools/target_dec_fuzzer: suppress Wunused-function Kacper Michajłow
2025-06-07 12:30   ` Michael Niedermayer
2025-06-06 17:20 ` [FFmpeg-devel] [PATCH v2 3/4] tools/target_dem_fuzzer: make fuzz data pointer constant Kacper Michajłow
2025-06-06 17:20 ` [FFmpeg-devel] [PATCH v2 4/4] tools/target_dem_fuzzer: remove unused fuzz_tag Kacper Michajłow

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=20250606172035.1047-2-kasper93@gmail.com \
    --to=kasper93-at-gmail.com@ffmpeg.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=kasper93@gmail.com \
    /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