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@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: "Kacper Michajłow" <kasper93@gmail.com>
Subject: [FFmpeg-devel] [PATCH 3/6] tools/target_dec_fuzzer: suppress Wdeclaration-after-statement
Date: Sun,  6 Apr 2025 02:39:20 +0200
Message-ID: <20250406003923.238-4-kasper93@gmail.com> (raw)
In-Reply-To: <20250406003923.238-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 | 41 +++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index de0419430f..a15f1a3f9c 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -166,6 +166,12 @@ static int fuzz_get_buffer2(AVCodecContext *ctx, AVFrame *frame, int flags)
     }
 }
 
+#define DECODER_SYMBOL0(CODEC) ff_##CODEC##_decoder
+#define DECODER_SYMBOL(CODEC) DECODER_SYMBOL0(CODEC)
+
+extern FFCodec DECODER_SYMBOL(FFMPEG_DECODER);
+extern FFCodec DECODER_SYMBOL(mjpeg);
+
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     uint64_t maxpixels_per_frame = 4096 * 4096;
     uint64_t maxpixels;
@@ -185,16 +191,19 @@ 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
-#define DECODER_SYMBOL0(CODEC) ff_##CODEC##_decoder
-#define DECODER_SYMBOL(CODEC) DECODER_SYMBOL0(CODEC)
-        extern FFCodec DECODER_SYMBOL(FFMPEG_DECODER);
         codec_list[0] = &DECODER_SYMBOL(FFMPEG_DECODER);
 
 #if defined(FFMPEG_DECODER_tiff) || defined(FFMPEG_DECODER_tdsc)
-        extern FFCodec DECODER_SYMBOL(mjpeg);
         codec_list[1] = &DECODER_SYMBOL(mjpeg);
 #endif
 
@@ -341,8 +350,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");
 
@@ -472,7 +481,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) {
         avcodec_free_context(&ctx);
         av_free(parser_avctx);
@@ -484,11 +493,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 +570,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 +589,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".

  parent reply	other threads:[~2025-04-06  0:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-06  0:39 [FFmpeg-devel] [PATCH 0/6] Minor fixes and for fuzzing targets Kacper Michajłow
2025-04-06  0:39 ` [FFmpeg-devel] [PATCH 1/6] tools/Makefile: add identifier macros for specific " Kacper Michajłow
2025-04-06  0:39 ` [FFmpeg-devel] [PATCH 2/6] tools/target_dec_fuzzer: fix tiff/tdsc check Kacper Michajłow
2025-04-06  0:39 ` Kacper Michajłow [this message]
2025-04-06  0:39 ` [FFmpeg-devel] [PATCH 4/6] tools/target_dec_fuzzer: suppress Wunused-function Kacper Michajłow
2025-04-06  0:39 ` [FFmpeg-devel] [PATCH 5/6] tools/target_dem_fuzzer: make fuzz data pointer constant Kacper Michajłow
2025-04-06  0:39 ` [FFmpeg-devel] [PATCH 6/6] 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=20250406003923.238-4-kasper93@gmail.com \
    --to=kasper93@gmail.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