PR #20844 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20844
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20844.patch


>From f484ee7b5a72b46abb2636ac6c40c6aa16ce0c1a Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Wed, 5 Nov 2025 14:53:12 +0100
Subject: [PATCH 1/4] avcodec/libaomenc: Avoid av_unused

pict_type is always used since 5e0eac3d4566839598f6d6fe5d77770023d6713a;
ctx in set_pix_fmt() seems to have been always unused.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/libaomenc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index e9b15fd7bd..82d5513e3d 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -484,7 +484,6 @@ static int set_pix_fmt(AVCodecContext *avctx, 
aom_codec_caps_t codec_caps,
                        struct aom_codec_enc_cfg *enccfg, aom_codec_flags_t 
*flags,
                        aom_img_fmt_t *img_fmt)
 {
-    av_unused AOMContext *ctx = avctx->priv_data;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
     enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth;
     switch (avctx->pix_fmt) {
@@ -1090,7 +1089,7 @@ static int storeframe(AVCodecContext *avctx, struct 
FrameListData *cx_frame,
                       AVPacket *pkt)
 {
     AOMContext *ctx = avctx->priv_data;
-    av_unused int pict_type;
+    enum AVPictureType pict_type;
     int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0);
     if (ret < 0) {
         av_log(avctx, AV_LOG_ERROR,
-- 
2.49.1


>From 03cadd9fc8cc4175c56cfee2011c71fea68a2c31 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Wed, 5 Nov 2025 15:07:25 +0100
Subject: [PATCH 2/4] avcodec/libx265: Remove stray
 FF_ENABLE_DEPRECATION_WARNINGS

Forgotten in 7d07723db5c18bb762f8eeb2a844a677986b8dcc.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/libx265.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index d897707dd7..4816085cf8 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -293,7 +293,6 @@ static av_cold int libx265_encode_init(AVCodecContext 
*avctx)
     } else {
         ctx->params->fpsNum      = avctx->time_base.den;
         ctx->params->fpsDenom    = avctx->time_base.num;
-FF_ENABLE_DEPRECATION_WARNINGS
     }
     ctx->params->sourceWidth     = avctx->width;
     ctx->params->sourceHeight    = avctx->height;
-- 
2.49.1


>From 8370502db1903c876fcde3ac230bd8ed51d84a19 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Wed, 5 Nov 2025 15:29:48 +0100
Subject: [PATCH 3/4] avcodec/packet: Move ff_side_data_set_encoder_stats() to
 encode.c

And rename it to ff_encode_add_stats_side_data() and move its
declaration to encode.h. Also constify the error pointee.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/dnxhdenc.c        |  3 +--
 libavcodec/encode.c          | 26 ++++++++++++++++++++++++++
 libavcodec/encode.h          |  3 +++
 libavcodec/libaomenc.c       |  6 ++----
 libavcodec/libkvazaar.c      |  4 +---
 libavcodec/liboapvenc.c      |  3 +--
 libavcodec/libsvtav1.c       |  3 +--
 libavcodec/libvpxenc.c       |  5 ++---
 libavcodec/libx264.c         |  4 ++--
 libavcodec/libx265.c         |  3 +--
 libavcodec/libxavs.c         |  4 +---
 libavcodec/libxeve.c         |  7 +------
 libavcodec/libxvid.c         |  3 +--
 libavcodec/mpegvideo_enc.c   |  9 ++++-----
 libavcodec/nvenc.c           |  3 +--
 libavcodec/packet.c          | 26 --------------------------
 libavcodec/packet_internal.h |  2 --
 libavcodec/qsvenc.c          |  4 +---
 libavcodec/snowenc.c         |  9 ++++-----
 libavcodec/svq1enc.c         |  3 +--
 20 files changed, 54 insertions(+), 76 deletions(-)

diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 7a5978c137..edb58ba25f 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -38,7 +38,6 @@
 #include "mpegvideo.h"
 #include "mpegvideoenc.h"
 #include "pixblockdsp.h"
-#include "packet_internal.h"
 #include "profiles.h"
 #include "dnxhdenc.h"
 
@@ -1300,7 +1299,7 @@ encode_coding_unit:
         goto encode_coding_unit;
     }
 
-    ff_side_data_set_encoder_stats(pkt, ctx->qscale * FF_QP2LAMBDA, NULL, 0, 
AV_PICTURE_TYPE_I);
+    ff_encode_add_stats_side_data(pkt, ctx->qscale * FF_QP2LAMBDA, NULL, 0, 
AV_PICTURE_TYPE_I);
 
     *got_packet = 1;
     return 0;
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 1eca5e38c1..d8f2cc52b0 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -23,6 +23,7 @@
 #include "libavutil/emms.h"
 #include "libavutil/frame.h"
 #include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/samplefmt.h"
@@ -914,6 +915,31 @@ AVCPBProperties 
*ff_encode_add_cpb_side_data(AVCodecContext *avctx)
     return props;
 }
 
+int ff_encode_add_stats_side_data(AVPacket *pkt, int quality, const int64_t 
error[],
+                                  int error_count, int pict_type)
+{
+    uint8_t *side_data;
+    size_t side_data_size;
+
+    side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, 
&side_data_size);
+    if (!side_data) {
+        side_data_size = 4+4+8*error_count;
+        side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_STATS,
+                                            side_data_size);
+    }
+
+    if (!side_data || side_data_size < 4+4+8*error_count)
+        return AVERROR(ENOMEM);
+
+    AV_WL32(side_data, quality);
+    side_data[4] = pict_type;
+    side_data[5] = error_count;
+    for (int i = 0; i < error_count; ++i)
+        AV_WL64(side_data+8 + 8*i , error[i]);
+
+    return 0;
+}
+
 int ff_check_codec_matrices(AVCodecContext *avctx, unsigned types, uint16_t 
min, uint16_t max)
 {
     uint16_t  *matrices[] = {avctx->intra_matrix, avctx->inter_matrix, 
avctx->chroma_intra_matrix};
diff --git a/libavcodec/encode.h b/libavcodec/encode.h
index 656da135d2..ea6336625a 100644
--- a/libavcodec/encode.h
+++ b/libavcodec/encode.h
@@ -84,6 +84,9 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket 
*avpkt,
  */
 AVCPBProperties *ff_encode_add_cpb_side_data(AVCodecContext *avctx);
 
+int ff_encode_add_stats_side_data(AVPacket *pkt, int quality, const int64_t 
error[],
+                                  int error_count, int pict_type);
+
 /**
  * Rescale from sample rate to AVCodecContext.time_base.
  */
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 82d5513e3d..9fb97e74ff 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -31,7 +31,6 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/base64.h"
-#include "libavutil/common.h"
 #include "libavutil/cpu.h"
 #include "libavutil/hdr_dynamic_metadata.h"
 #include "libavutil/imgutils.h"
@@ -50,7 +49,6 @@
 #include "internal.h"
 #include "itut35.h"
 #include "libaom.h"
-#include "packet_internal.h"
 #include "profiles.h"
 
 /*
@@ -1109,8 +1107,8 @@ static int storeframe(AVCodecContext *avctx, struct 
FrameListData *cx_frame,
         pict_type = AV_PICTURE_TYPE_P;
     }
 
-    ff_side_data_set_encoder_stats(pkt, 0, cx_frame->sse + 1,
-                                   cx_frame->have_sse ? 3 : 0, pict_type);
+    ff_encode_add_stats_side_data(pkt, 0, cx_frame->sse + 1,
+                                  cx_frame->have_sse ? 3 : 0, pict_type);
 
     if (cx_frame->have_sse) {
         int i;
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 78f0a94321..30cec6a1fd 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -29,7 +29,6 @@
 #include "libavutil/dict.h"
 #include "libavutil/error.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/internal.h"
 #include "libavutil/log.h"
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
@@ -38,7 +37,6 @@
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "encode.h"
-#include "packet_internal.h"
 
 typedef struct LibkvazaarContext {
     const AVClass *class;
@@ -283,7 +281,7 @@ static int libkvazaar_encode(AVCodecContext *avctx,
             return AVERROR_EXTERNAL;
         }
 
-        ff_side_data_set_encoder_stats(avpkt, frame_info.qp * FF_QP2LAMBDA, 
NULL, 0, pict_type);
+        ff_encode_add_stats_side_data(avpkt, frame_info.qp * FF_QP2LAMBDA, 
NULL, 0, pict_type);
 
         *got_packet_ptr = 1;
     }
diff --git a/libavcodec/liboapvenc.c b/libavcodec/liboapvenc.c
index 8e71fb54fe..84bd175ef6 100644
--- a/libavcodec/liboapvenc.c
+++ b/libavcodec/liboapvenc.c
@@ -38,7 +38,6 @@
 #include "apv.h"
 #include "codec_internal.h"
 #include "encode.h"
-#include "packet_internal.h"
 #include "profiles.h"
 
 #define MAX_BS_BUF   (128 * 1024 * 1024)
@@ -409,7 +408,7 @@ static int liboapve_encode(AVCodecContext *avctx, AVPacket 
*avpkt,
         avpkt->flags |= AV_PKT_FLAG_KEY;
 
         if (cdsc->param[FRM_IDX].qp)
-            ff_side_data_set_encoder_stats(avpkt, cdsc->param[FRM_IDX].qp * 
FF_QP2LAMBDA, NULL, 0, AV_PICTURE_TYPE_I);
+            ff_encode_add_stats_side_data(avpkt, cdsc->param[FRM_IDX].qp * 
FF_QP2LAMBDA, NULL, 0, AV_PICTURE_TYPE_I);
 
         *got_packet = 1;
     }
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 4a249a0032..6fa18bd85f 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -38,7 +38,6 @@
 #include "codec_internal.h"
 #include "dovi_rpu.h"
 #include "encode.h"
-#include "packet_internal.h"
 #include "avcodec.h"
 #include "profiles.h"
 
@@ -660,7 +659,7 @@ static int eb_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
         svt_enc->eos_flag = EOS_RECEIVED;
 #endif
 
-    ff_side_data_set_encoder_stats(pkt, headerPtr->qp * FF_QP2LAMBDA, NULL, 0, 
pict_type);
+    ff_encode_add_stats_side_data(pkt, headerPtr->qp * FF_QP2LAMBDA, NULL, 0, 
pict_type);
 
     svt_av1_enc_release_out_buffer(&headerPtr);
 
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 406333d45f..8572d877a2 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -36,7 +36,6 @@
 #include "libavutil/avassert.h"
 #include "libavutil/mem.h"
 #include "libvpx.h"
-#include "packet_internal.h"
 #include "profiles.h"
 #include "libavutil/avstring.h"
 #include "libavutil/base64.h"
@@ -1343,8 +1342,8 @@ static int storeframe(AVCodecContext *avctx, struct 
FrameListData *cx_frame,
     ret = vpx_codec_control(&ctx->encoder, VP8E_GET_LAST_QUANTIZER_64, 
&quality);
     if (ret != VPX_CODEC_OK)
         quality = 0;
-    ff_side_data_set_encoder_stats(pkt, quality * FF_QP2LAMBDA, cx_frame->sse 
+ 1,
-                                   cx_frame->have_sse ? 3 : 0, pict_type);
+    ff_encode_add_stats_side_data(pkt, quality * FF_QP2LAMBDA, cx_frame->sse + 
1,
+                                  cx_frame->have_sse ? 3 : 0, pict_type);
 
     if (cx_frame->have_sse) {
         /* Beware of the Y/U/V/all order! */
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 58c03a77ad..6478b36dd3 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -728,8 +728,8 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, 
const AVFrame *frame,
             errors = sse;
         }
 
-        ff_side_data_set_encoder_stats(pkt, (pic_out.i_qpplus1 - 1) * 
FF_QP2LAMBDA,
-                                       errors, error_count, pict_type);
+        ff_encode_add_stats_side_data(pkt, (pic_out.i_qpplus1 - 1) * 
FF_QP2LAMBDA,
+                                      errors, error_count, pict_type);
 
         if (wallclock)
             ff_side_data_set_prft(pkt, wallclock);
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 4816085cf8..463291b427 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -38,7 +38,6 @@
 #include "codec_internal.h"
 #include "dovi_rpu.h"
 #include "encode.h"
-#include "packet_internal.h"
 #include "atsc_a53.h"
 #include "sei.h"
 
@@ -894,7 +893,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 #endif
         pkt->flags |= AV_PKT_FLAG_DISPOSABLE;
 
-    ff_side_data_set_encoder_stats(pkt, x265pic_out->frameData.qp * 
FF_QP2LAMBDA, NULL, 0, pict_type);
+    ff_encode_add_stats_side_data(pkt, x265pic_out->frameData.qp * 
FF_QP2LAMBDA, NULL, 0, pict_type);
 
     if (x265pic_out->userData) {
         int idx = (int)(intptr_t)x265pic_out->userData - 1;
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 2fb87dc7a4..cd5b7e1bb2 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -20,7 +20,6 @@
  */
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include <stdint.h>
@@ -29,7 +28,6 @@
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "encode.h"
-#include "packet_internal.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
@@ -201,7 +199,7 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt,
         pkt->flags |= AV_PKT_FLAG_KEY;
     }
 
-    ff_side_data_set_encoder_stats(pkt, (pic_out.i_qpplus1 - 1) * 
FF_QP2LAMBDA, NULL, 0, pict_type);
+    ff_encode_add_stats_side_data(pkt, (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA, 
NULL, 0, pict_type);
 
     x4->out_frame_count++;
     *got_packet = ret;
diff --git a/libavcodec/libxeve.c b/libavcodec/libxeve.c
index 63c2e1981b..ac98d0ffe8 100644
--- a/libavcodec/libxeve.c
+++ b/libavcodec/libxeve.c
@@ -22,7 +22,6 @@
  */
 
 #include <float.h>
-#include <stdlib.h>
 
 #include <xeve.h>
 
@@ -32,13 +31,9 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
-#include "libavutil/time.h"
 #include "libavutil/cpu.h"
-#include "libavutil/avstring.h"
 
 #include "avcodec.h"
-#include "internal.h"
-#include "packet_internal.h"
 #include "codec_internal.h"
 #include "profiles.h"
 #include "encode.h"
@@ -504,7 +499,7 @@ static int libxeve_encode(AVCodecContext *avctx, AVPacket 
*avpkt,
                     return AVERROR_INVALIDDATA;
                 }
 
-                ff_side_data_set_encoder_stats(avpkt, xectx->stat.qp * 
FF_QP2LAMBDA, NULL, 0, av_pic_type);
+                ff_encode_add_stats_side_data(avpkt, xectx->stat.qp * 
FF_QP2LAMBDA, NULL, 0, av_pic_type);
 
                 *got_packet = 1;
             }
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index b85bb425c1..a432500e8e 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -41,7 +41,6 @@
 #include "codec_internal.h"
 #include "encode.h"
 #include "mpegutils.h"
-#include "packet_internal.h"
 
 #if HAVE_UNISTD_H
 #include <unistd.h>
@@ -831,7 +830,7 @@ static int xvid_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
         else
             pict_type = AV_PICTURE_TYPE_I;
 
-        ff_side_data_set_encoder_stats(pkt, xvid_enc_stats.quant * 
FF_QP2LAMBDA, NULL, 0, pict_type);
+        ff_encode_add_stats_side_data(pkt, xvid_enc_stats.quant * 
FF_QP2LAMBDA, NULL, 0, pict_type);
 
         if (xvid_enc_frame.out_flags & XVID_KEYFRAME) {
             pkt->flags  |= AV_PKT_FLAG_KEY;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 9f5da254bf..ce0ee4bb68 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -74,7 +74,6 @@
 #include "internal.h"
 #include "bytestream.h"
 #include "rv10enc.h"
-#include "packet_internal.h"
 #include "libavutil/refstruct.h"
 #include <limits.h>
 #include "sp5x.h"
@@ -2040,10 +2039,10 @@ vbv_retry:
 
         for (int i = 0; i < MPV_MAX_PLANES; i++)
             avctx->error[i] += s->encoding_error[i];
-        ff_side_data_set_encoder_stats(pkt, s->c.cur_pic.ptr->f->quality,
-                                       s->encoding_error,
-                                       (avctx->flags&AV_CODEC_FLAG_PSNR) ? 
MPV_MAX_PLANES : 0,
-                                       s->c.pict_type);
+        ff_encode_add_stats_side_data(pkt, s->c.cur_pic.ptr->f->quality,
+                                      s->encoding_error,
+                                      (avctx->flags&AV_CODEC_FLAG_PSNR) ? 
MPV_MAX_PLANES : 0,
+                                      s->c.pict_type);
 
         if (avctx->flags & AV_CODEC_FLAG_PASS1)
             assert(put_bits_count(&s->pb) == m->header_bits + s->mv_bits +
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index d81be00314..1811ef9525 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -43,7 +43,6 @@
 #include "codec_desc.h"
 #include "encode.h"
 #include "internal.h"
-#include "packet_internal.h"
 
 #define CHECK_CU(x) FF_CUDA_CHECK_DL(avctx, dl_fn->cuda_dl, x)
 
@@ -2789,7 +2788,7 @@ static int process_output_surface(AVCodecContext *avctx, 
AVPacket *pkt, NvencSur
         goto error;
     }
 
-    ff_side_data_set_encoder_stats(pkt,
+    ff_encode_add_stats_side_data(pkt,
         (lock_params.frameAvgQP - 1) * FF_QP2LAMBDA, NULL, 0, pict_type);
 
     res = nvenc_set_timestamp(avctx, &lock_params, pkt);
diff --git a/libavcodec/packet.c b/libavcodec/packet.c
index 4736b1fef2..348159f7f7 100644
--- a/libavcodec/packet.c
+++ b/libavcodec/packet.c
@@ -24,7 +24,6 @@
 #include "libavutil/avassert.h"
 #include "libavutil/avutil.h"
 #include "libavutil/container_fifo.h"
-#include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/mem.h"
 #include "libavutil/rational.h"
@@ -620,31 +619,6 @@ void avpriv_packet_list_free(PacketList *pkt_buf)
     pkt_buf->head = pkt_buf->tail = NULL;
 }
 
-int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, 
int error_count, int pict_type)
-{
-    uint8_t *side_data;
-    size_t side_data_size;
-    int i;
-
-    side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, 
&side_data_size);
-    if (!side_data) {
-        side_data_size = 4+4+8*error_count;
-        side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_STATS,
-                                            side_data_size);
-    }
-
-    if (!side_data || side_data_size < 4+4+8*error_count)
-        return AVERROR(ENOMEM);
-
-    AV_WL32(side_data   , quality  );
-    side_data[4] = pict_type;
-    side_data[5] = error_count;
-    for (i = 0; i<error_count; i++)
-        AV_WL64(side_data+8 + 8*i , error[i]);
-
-    return 0;
-}
-
 int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
 {
     AVProducerReferenceTime *prft;
diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h
index 9c0f4fead5..02471ed6df 100644
--- a/libavcodec/packet_internal.h
+++ b/libavcodec/packet_internal.h
@@ -70,8 +70,6 @@ int avpriv_packet_list_get(PacketList *list, AVPacket *pkt);
  */
 void avpriv_packet_list_free(PacketList *list);
 
-int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, 
int error_count, int pict_type);
-
 int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp);
 
 #endif // AVCODEC_PACKET_INTERNAL_H
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 318a99e2a1..fc1b8795d8 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -37,8 +37,6 @@
 
 #include "avcodec.h"
 #include "encode.h"
-#include "internal.h"
-#include "packet_internal.h"
 #include "qsv.h"
 #include "qsv_internal.h"
 #include "qsvenc.h"
@@ -2689,7 +2687,7 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
         if (avctx->codec_id == AV_CODEC_ID_H264) {
             enc_buf = qpkt.bs->ExtParam;
             enc_info = (mfxExtAVCEncodedFrameInfo *)(*enc_buf);
-            ff_side_data_set_encoder_stats(&qpkt.pkt,
+            ff_encode_add_stats_side_data(&qpkt.pkt,
                 enc_info->QP * FF_QP2LAMBDA, NULL, 0, pict_type);
             av_freep(&enc_info);
             av_freep(&enc_buf);
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 238b78539b..68c2bb2ebc 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -30,7 +30,6 @@
 #include "encode.h"
 #include "internal.h" //For AVCodecInternal.recon_frame
 #include "me_cmp.h"
-#include "packet_internal.h"
 #include "qpeldsp.h"
 #include "snow_dwt.h"
 #include "snow.h"
@@ -2060,10 +2059,10 @@ redo_frame:
 
     emms_c();
 
-    ff_side_data_set_encoder_stats(pkt, s->current_picture->quality,
-                                   enc->encoding_error,
-                                   (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? 
SNOW_MAX_PLANES : 0,
-                                   s->current_picture->pict_type);
+    ff_encode_add_stats_side_data(pkt, s->current_picture->quality,
+                                  enc->encoding_error,
+                                  (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? 
SNOW_MAX_PLANES : 0,
+                                  s->current_picture->pict_type);
     if (s->avctx->flags & AV_CODEC_FLAG_RECON_FRAME) {
         av_frame_replace(avci->recon_frame, s->current_picture);
     }
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index ed3dca9025..4855bed188 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -38,7 +38,6 @@
 #include "h263enc.h"
 #include "internal.h"
 #include "mpegutils.h"
-#include "packet_internal.h"
 #include "put_bits.h"
 #include "svq1.h"
 #include "svq1encdsp.h"
@@ -645,7 +644,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
         s->pict_type = AV_PICTURE_TYPE_I;
     s->quality = pict->quality;
 
-    ff_side_data_set_encoder_stats(pkt, pict->quality, NULL, 0, s->pict_type);
+    ff_encode_add_stats_side_data(pkt, pict->quality, NULL, 0, s->pict_type);
 
     init_put_bits(&pb, pkt->data, pkt->size);
     svq1_write_header(s, &pb, s->pict_type);
-- 
2.49.1


>From c5ba7cdf0890ff00abcf4f539d57a974980d0a99 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Wed, 5 Nov 2025 15:59:01 +0100
Subject: [PATCH 4/4] avcodec/encode: Use enum AVPictureType in
 ff_encode_add_stats_side_data

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/encode.c     | 2 +-
 libavcodec/encode.h     | 2 +-
 libavcodec/libkvazaar.c | 2 +-
 libavcodec/libsvtav1.c  | 3 ++-
 libavcodec/libvpxenc.c  | 2 +-
 libavcodec/libx264.c    | 2 +-
 libavcodec/libx265.c    | 2 +-
 libavcodec/libxavs.c    | 2 +-
 libavcodec/libxeve.c    | 3 +--
 libavcodec/libxvid.c    | 2 +-
 libavcodec/mpegvideo.h  | 2 +-
 11 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index d8f2cc52b0..6e0620a36e 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -916,7 +916,7 @@ AVCPBProperties *ff_encode_add_cpb_side_data(AVCodecContext 
*avctx)
 }
 
 int ff_encode_add_stats_side_data(AVPacket *pkt, int quality, const int64_t 
error[],
-                                  int error_count, int pict_type)
+                                  int error_count, enum AVPictureType 
pict_type)
 {
     uint8_t *side_data;
     size_t side_data_size;
diff --git a/libavcodec/encode.h b/libavcodec/encode.h
index ea6336625a..82bd3c9431 100644
--- a/libavcodec/encode.h
+++ b/libavcodec/encode.h
@@ -85,7 +85,7 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket 
*avpkt,
 AVCPBProperties *ff_encode_add_cpb_side_data(AVCodecContext *avctx);
 
 int ff_encode_add_stats_side_data(AVPacket *pkt, int quality, const int64_t 
error[],
-                                  int error_count, int pict_type);
+                                  int error_count, enum AVPictureType 
pict_type);
 
 /**
  * Rescale from sample rate to AVCodecContext.time_base.
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 30cec6a1fd..908c7a0383 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -172,7 +172,6 @@ static int libkvazaar_encode(AVCodecContext *avctx,
     kvz_data_chunk *data_out = NULL;
     uint32_t len_out = 0;
     int retval = 0;
-    int pict_type;
 
     *got_packet_ptr = 0;
 
@@ -266,6 +265,7 @@ static int libkvazaar_encode(AVCodecContext *avctx,
             avpkt->flags |= AV_PKT_FLAG_KEY;
         }
 
+        enum AVPictureType pict_type;
         switch (frame_info.slice_type) {
         case KVZ_SLICE_I:
             pict_type = AV_PICTURE_TYPE_I;
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 6fa18bd85f..0e3e748b8d 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -590,7 +590,7 @@ static int eb_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
     AVFrame *frame = svt_enc->frame;
     EbErrorType svt_ret;
     AVBufferRef *ref;
-    int ret = 0, pict_type;
+    int ret = 0;
 
     if (svt_enc->eos_flag == EOS_RECEIVED)
         return AVERROR_EOF;
@@ -636,6 +636,7 @@ static int eb_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
     pkt->pts  = headerPtr->pts;
     pkt->dts  = headerPtr->dts;
 
+    enum AVPictureType pict_type;
     switch (headerPtr->pic_type) {
     case EB_AV1_KEY_PICTURE:
         pkt->flags |= AV_PKT_FLAG_KEY;
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 8572d877a2..05c34a6857 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1323,7 +1323,7 @@ static int storeframe(AVCodecContext *avctx, struct 
FrameListData *cx_frame,
     VPxContext *ctx = avctx->priv_data;
     int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0);
     uint8_t *side_data;
-    int pict_type;
+    enum AVPictureType pict_type;
     int quality;
 
     if (ret < 0)
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 6478b36dd3..b688d4f321 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -613,7 +613,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, 
const AVFrame *frame,
     x264_nal_t *nal;
     int nnal, ret;
     x264_picture_t pic_out = {0}, *pic_in;
-    int pict_type;
+    enum AVPictureType pict_type;
     int64_t wallclock = 0;
     X264Opaque *out_opaque;
 
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 463291b427..2b83a91d00 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -693,7 +693,6 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
     x265_nal *nal;
     x265_sei *sei;
     uint8_t *dst;
-    int pict_type;
     int payload = 0;
     int nnal;
     int ret;
@@ -869,6 +868,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
     pkt->pts = x265pic_out->pts;
     pkt->dts = x265pic_out->dts;
 
+    enum AVPictureType pict_type;
     switch (x265pic_out->sliceType) {
     case X265_TYPE_IDR:
     case X265_TYPE_I:
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index cd5b7e1bb2..e4db12a692 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -126,7 +126,6 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt,
     xavs_nal_t *nal;
     int nnal, i, ret;
     xavs_picture_t pic_out;
-    int pict_type;
 
     x4->pic.img.i_csp   = XAVS_CSP_I420;
     x4->pic.img.i_plane = 3;
@@ -177,6 +176,7 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt,
     } else
         pkt->dts = pkt->pts;
 
+    enum AVPictureType pict_type;
     switch (pic_out.i_type) {
     case XAVS_TYPE_IDR:
     case XAVS_TYPE_I:
diff --git a/libavcodec/libxeve.c b/libavcodec/libxeve.c
index ac98d0ffe8..e87aa25f20 100644
--- a/libavcodec/libxeve.c
+++ b/libavcodec/libxeve.c
@@ -467,8 +467,6 @@ static int libxeve_encode(AVCodecContext *avctx, AVPacket 
*avpkt,
             *got_packet = 0;
             return 0;
         } else if (ret == XEVE_OK) {
-            int av_pic_type;
-
             if (xectx->stat.write > 0) {
 
                 ret = ff_get_encode_buffer(avctx, avpkt, xectx->stat.write, 0);
@@ -483,6 +481,7 @@ static int libxeve_encode(AVCodecContext *avctx, AVPacket 
*avpkt,
                 avpkt->pts = xectx->bitb.ts[XEVE_TS_PTS];
                 avpkt->dts = xectx->bitb.ts[XEVE_TS_DTS];
 
+                enum AVPictureType av_pic_type;
                 switch(xectx->stat.stype) {
                 case XEVE_ST_I:
                     av_pic_type = AV_PICTURE_TYPE_I;
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index a432500e8e..94c521313b 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -817,7 +817,7 @@ static int xvid_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
     }
 
     if (xerr > 0) {
-        int pict_type;
+        enum AVPictureType pict_type;
 
         *got_packet = 1;
 
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 4a30986eac..a04166efa8 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -154,7 +154,7 @@ typedef struct MpegEncContext {
 
     int qscale;                 ///< QP
     int chroma_qscale;          ///< chroma QP
-    int pict_type;              ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, 
AV_PICTURE_TYPE_B, ...
+    enum AVPictureType pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, 
AV_PICTURE_TYPE_B, ...
     int droppable;
 
     BlockDSPContext bdsp;
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to