[FFmpeg-devel] [PATCH 3/3] lavc/vaapi_encode_av1: insert HDR_CLL metadata if have

Xiang, Haihao haihao.xiang at intel.com
Mon Apr 15 05:07:54 EEST 2024


From: Haihao Xiang <haihao.xiang at intel.com>

Only look for HDR_CLL on key frame on the output.

Signed-off-by: Haihao Xiang <haihao.xiang at intel.com>
---
 libavcodec/vaapi_encode_av1.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libavcodec/vaapi_encode_av1.c b/libavcodec/vaapi_encode_av1.c
index 4077d21202..b868f5b66a 100644
--- a/libavcodec/vaapi_encode_av1.c
+++ b/libavcodec/vaapi_encode_av1.c
@@ -707,6 +707,21 @@ static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx,
                                mdm->min_luminance.den);
             }
         }
+
+        sd = av_frame_get_side_data(pic->input_image,
+                                    AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
+        if (sd) {
+            AVContentLightMetadata *cllm = (AVContentLightMetadata *)sd->data;
+            AV1RawOBU               *obu = &priv->mh[priv->nb_mh++];
+            AV1RawMetadata           *md = &obu->obu.metadata;
+            AV1RawMetadataHDRCLL    *cll = &md->metadata.hdr_cll;
+
+            memset(obu, 0, sizeof(*obu));
+            obu->header.obu_type = AV1_OBU_METADATA;
+            md->metadata_type    = AV1_METADATA_TYPE_HDR_CLL;
+            cll->max_cll         = cllm->MaxCLL;
+            cll->max_fall        = cllm->MaxFALL;
+        }
     }
 
 end:
-- 
2.34.1



More information about the ffmpeg-devel mailing list