diff mbox series

[FFmpeg-devel,v0,11/14] ffmpeg: pass first video AVFrame's side data to encoder

Message ID 20230320233408.134255-12-jeebjp@gmail.com
State New
Headers show
Series encoder AVCodecContext configuration side data | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Jan Ekström March 20, 2023, 11:34 p.m. UTC
This enables further configuration of output based on the results
of input decoding and filtering in a similar manner as the color
information.
---
 fftools/ffmpeg.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d721a5e721..e12d6ce25d 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3113,11 +3113,23 @@  static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
                                                  av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
 
         if (frame) {
+            int ret = AVERROR_BUG;
+
             enc_ctx->color_range            = frame->color_range;
             enc_ctx->color_primaries        = frame->color_primaries;
             enc_ctx->color_trc              = frame->color_trc;
             enc_ctx->colorspace             = frame->colorspace;
             enc_ctx->chroma_sample_location = frame->chroma_location;
+
+            if ((ret = avcodec_configure_side_data(enc_ctx,
+                                                   (const AVFrameSideDataSet){
+                                                       .side_data    = frame->side_data,
+                                                       .nb_side_data = frame->nb_side_data
+                                                   })) < 0) {
+                av_log(NULL, AV_LOG_ERROR, "failed to configure video encoder: %s!\n",
+                       av_err2str(ret));
+                return ret;
+            }
         }
 
         enc_ctx->framerate = ost->frame_rate;