diff mbox series

[FFmpeg-devel,v9,09/14] avcodec: add frame side data array to AVCodecContext

Message ID 20240317200100.152097-10-jeebjp@gmail.com
State New
Headers show
Series [FFmpeg-devel,v9,01/14] avutil/frame: split side data list wiping out to non-AVFrame function | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Jan Ekström March 17, 2024, 8 p.m. UTC
This allows configuring an encoder by using AVFrameSideData.
---
 libavcodec/avcodec.h | 12 ++++++++++++
 libavcodec/options.c |  2 ++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 554501aa44..550df0e589 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2062,6 +2062,18 @@  typedef struct AVCodecContext {
      * Number of entries in side_data_prefer_packet.
      */
     unsigned nb_side_data_prefer_packet;
+
+    /**
+     * Array containing static side data, such as HDR10 CLL / MDCV structures.
+     * Side data entries should be allocated by usage of helpers defined in
+     * libavutil/frame.h.
+     *
+     * - encoding: may be set by user before calling avcodec_open2() for
+     *             encoder configuration.
+     * - decoding: unused
+     */
+    AVFrameSideData  **encoder_side_data;
+    int             nb_encoder_side_data;
 } AVCodecContext;
 
 /**
diff --git a/libavcodec/options.c b/libavcodec/options.c
index dcc67e497a..dd5c697da3 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -176,6 +176,8 @@  void avcodec_free_context(AVCodecContext **pavctx)
     av_freep(&avctx->inter_matrix);
     av_freep(&avctx->rc_override);
     av_channel_layout_uninit(&avctx->ch_layout);
+    av_frame_side_data_free(
+        &avctx->encoder_side_data, &avctx->nb_encoder_side_data);
 
     av_freep(pavctx);
 }