From 945ac7638e9d7fb6365ef30126e26ddd426784b7 Mon Sep 17 00:00:00 2001
From: Jerome Martinez <jerome@mediaarea.net>
Date: Wed, 9 Apr 2025 00:04:55 +0200
Subject: [PATCH] avcodec/ffv1enc: avoid repeating the same warning forever

---
 libavcodec/ffv1.h    | 1 +
 libavcodec/ffv1enc.c | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index 9472f9c958..ee0a1a7858 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -151,6 +151,7 @@ typedef struct FFV1Context {
     int flt;
     int remap_mode;
     int remap_optimizer;
+    int maxsize_warned;
 
     int use32bit;
 
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 35a1ae16d4..0fb6caecee 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -1749,7 +1749,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     maxsize = ff_ffv1_encode_buffer_size(avctx);
 
     if (maxsize > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 32) {
-        av_log(avctx, AV_LOG_WARNING, "Cannot allocate worst case packet size, the encoding could fail\n");
+        FFV1Context *f = avctx->priv_data;
+        if (!f->maxsize_warned) {
+            av_log(avctx, AV_LOG_WARNING, "Cannot allocate worst case packet size, the encoding could fail\n");
+            f->maxsize_warned++;
+        }
         maxsize = INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 32;
     }
 
-- 
2.46.0.windows.1