diff mbox series

[FFmpeg-devel,06/13] avcodec/h264dec: export LCEVC metadata as frame side data

Message ID 20240831163114.4197-6-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,01/13,v3] avutil/frame: add an LCEVC enhancement data payload side data type | 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

James Almer Aug. 31, 2024, 4:31 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 configure               | 2 +-
 libavcodec/h264_slice.c | 8 ++++++++
 libavcodec/h264dec.c    | 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/configure b/configure
index 261ab6252e..84f63bbb87 100755
--- a/configure
+++ b/configure
@@ -2970,7 +2970,7 @@  h263i_decoder_select="h263_decoder"
 h263p_decoder_select="h263_decoder"
 h263p_encoder_select="h263_encoder"
 h264_decoder_select="cabac golomb h264chroma h264dsp h264parse h264pred h264qpel h264_sei videodsp"
-h264_decoder_suggest="error_resilience"
+h264_decoder_suggest="error_resilience liblcevc_dec"
 hap_decoder_select="snappy texturedsp"
 hap_encoder_deps="libsnappy"
 hap_encoder_select="texturedspenc"
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index a66b75ca80..89172dc05a 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -518,6 +518,14 @@  static int h264_frame_start(H264Context *h)
 
     pic->needs_fg = h->sei.common.film_grain_characteristics.present && !h->avctx->hwaccel &&
         !(h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN);
+    if (CONFIG_LIBLCEVC_DEC && h->sei.common.lcevc.info && !h->avctx->hwaccel &&
+        !(h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) {
+        HEVCSEILCEVC *lcevc = &h->sei.common.lcevc;
+        ret = ff_frame_new_side_data_from_buf(h->avctx, pic->f,
+                                              AV_FRAME_DATA_LCEVC, &lcevc->info);
+        if (ret < 0)
+            return ret;
+    }
 
     if ((ret = alloc_picture(h, pic)) < 0)
         return ret;
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 0154fe17b6..976b21c30e 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -904,6 +904,8 @@  static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
 
     if (!(h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN))
         av_frame_remove_side_data(dst, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
+    if (!CONFIG_LIBLCEVC_DEC && !(h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS))
+        av_frame_remove_side_data(dst, AV_FRAME_DATA_LCEVC);
 
     return 0;
 fail: