diff mbox series

[FFmpeg-devel,v4,19/21] vaapi_encode_h265: Use common handling for HDR metadata

Message ID 20200223234124.17689-19-sw@jkqxz.net
State New
Headers show
Series [FFmpeg-devel,v4,01/21] cbs: Mention all codecs in unit type comment
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Mark Thompson Feb. 23, 2020, 11:41 p.m. UTC
---
 libavcodec/vaapi_encode_h265.c | 45 +++++-----------------------------
 1 file changed, 6 insertions(+), 39 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 538862a9d5..443139dfdb 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -750,39 +750,10 @@  static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
             AVMasteringDisplayMetadata *mdm =
                 (AVMasteringDisplayMetadata *)sd->data;
 
-            // SEI is needed when both the primaries and luminance are set
+            // Only needed when both primaries and luminance are set.
             if (mdm->has_primaries && mdm->has_luminance) {
-                H265RawSEIMasteringDisplayColourVolume *mdcv =
-                    &priv->sei_mastering_display;
-                const int mapping[3] = {1, 2, 0};
-                const int chroma_den = 50000;
-                const int luma_den   = 10000;
-
-                for (i = 0; i < 3; i++) {
-                    const int j = mapping[i];
-                    mdcv->display_primaries_x[i] =
-                        FFMIN(lrint(chroma_den *
-                                    av_q2d(mdm->display_primaries[j][0])),
-                              chroma_den);
-                    mdcv->display_primaries_y[i] =
-                        FFMIN(lrint(chroma_den *
-                                    av_q2d(mdm->display_primaries[j][1])),
-                              chroma_den);
-                }
-
-                mdcv->white_point_x =
-                    FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[0])),
-                          chroma_den);
-                mdcv->white_point_y =
-                    FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[1])),
-                          chroma_den);
-
-                mdcv->max_display_mastering_luminance =
-                    lrint(luma_den * av_q2d(mdm->max_luminance));
-                mdcv->min_display_mastering_luminance =
-                    FFMIN(lrint(luma_den * av_q2d(mdm->min_luminance)),
-                          mdcv->max_display_mastering_luminance);
-
+                ff_cbs_h265_fill_sei_mastering_display(
+                    &priv->sei_mastering_display, mdm);
                 priv->sei_needed |= SEI_MASTERING_DISPLAY;
             }
         }
@@ -795,13 +766,9 @@  static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
                                    AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
 
         if (sd) {
-            AVContentLightMetadata *clm =
-                (AVContentLightMetadata *)sd->data;
-            H265RawSEIContentLightLevelInfo *clli =
-                &priv->sei_content_light_level;
-
-            clli->max_content_light_level     = FFMIN(clm->MaxCLL,  65535);
-            clli->max_pic_average_light_level = FFMIN(clm->MaxFALL, 65535);
+            ff_cbs_h265_fill_sei_content_light_level(
+                &priv->sei_content_light_level,
+                (const AVContentLightMetadata*)sd->data);
 
             priv->sei_needed |= SEI_CONTENT_LIGHT_LEVEL;
         }