[vlc-devel] [RFC v2 5/8] libvlc: add support for HDR10 metadata during the START_RENDERING

Steve Lhomme robux4 at ycbcr.xyz
Thu May 2 15:28:48 CEST 2019


---
 include/vlc/libvlc_media_player.h | 15 ++++++++++++++-
 include/vlc_vout_display.h        | 17 +++++++++++++++--
 lib/media_player.c                | 11 +++++++++++
 3 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 9380a585f2..bde07e271e 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -637,6 +637,19 @@ typedef struct
 } libvlc_video_output_cfg_t;
 
 
+typedef struct
+{
+    /* similar to SMPTE ST 2086 mastering display color volume */
+    uint16_t RedPrimary[2];
+    uint16_t GreenPrimary[2];
+    uint16_t BluePrimary[2];
+    uint16_t WhitePoint[2];
+    unsigned int MaxMasteringLuminance;
+    unsigned int MinMasteringLuminance;
+    uint16_t MaxContentLightLevel;
+    uint16_t MaxFrameAverageLightLevel;
+} libvlc_video_surface_hdr10_metadata_t;
+
 /**
  * List of control passed to the @a libvlc_video_control_cb callback
  */
@@ -679,7 +692,7 @@ typedef enum libvlc_video_callback_control_t {
 
     /** Tell the host the rendering is about to start.
      *
-     * \ref input ignored
+     * \ref input libvlc_video_surface_hdr10_metadata_t* or NULL
      * \ref output ignored
      *
      * Between \ref LIBVLC_VIDEO_START_RENDERING and \ref LIBVLC_VIDEO_FINISHED_RENDERING
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 25e480fdf5..b08a35d9e7 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -476,6 +476,18 @@ typedef struct
     video_transfer_func_t   transfer;
 } vlc_video_surface_cfg_t; /* must match libvlc_video_surface_cfg_t */
 
+typedef struct
+{
+    uint16_t RedPrimary[2];
+    uint16_t GreenPrimary[2];
+    uint16_t BluePrimary[2];
+    uint16_t WhitePoint[2];
+    unsigned int MaxMasteringLuminance;
+    unsigned int MinMasteringLuminance;
+    uint16_t MaxContentLightLevel;
+    uint16_t MaxFrameAverageLightLevel;
+} vlc_video_surface_hdr10_metadata_t; /* must match libvlc_video_surface_hdr10_metadata_t */
+
 typedef struct
 {
     intptr_t          surface_format; /* DXGI_FORMAT for D3D11, D3DFORMAT for D3D9 */
@@ -526,9 +538,10 @@ static inline void vlc_video_surface_swap(void *opaque, vlc_video_surface_contro
     ctrl(opaque, VLC_VIDEO_SURFACE_SWAP, 0, NULL);
 }
 
-static inline bool vlc_video_surface_start_rendering(void *opaque, vlc_video_surface_control ctrl)
+static inline bool vlc_video_surface_start_rendering(void *opaque, vlc_video_surface_control ctrl,
+                                                     const vlc_video_surface_hdr10_metadata_t *hdr10)
 {
-    return ctrl(opaque, VLC_VIDEO_SURFACE_START_RENDERING, 0, NULL) == 0;
+    return ctrl(opaque, VLC_VIDEO_SURFACE_START_RENDERING, hdr10, NULL) == 0;
 }
 
 static inline void vlc_video_surface_finished_rendering(void *opaque, vlc_video_surface_control ctrl)
diff --git a/lib/media_player.c b/lib/media_player.c
index 1dd33396a6..26ad3d53eb 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -2135,3 +2135,14 @@ static_assert(libvlc_video_primaries_BT601_525 == COLOR_PRIMARIES_BT601_525 &&
               libvlc_video_primaries_DCI_P3    == COLOR_PRIMARIES_DCI_P3 &&
               libvlc_video_primaries_BT470_M   == COLOR_PRIMARIES_BT470_M
               , "libvlc video color primaries mismatch");
+
+static_assert(sizeof(vlc_video_surface_hdr10_metadata_t) == sizeof(libvlc_video_surface_hdr10_metadata_t) &&
+              offsetof(vlc_video_surface_hdr10_metadata_t, RedPrimary)   == offsetof(libvlc_video_surface_hdr10_metadata_t, RedPrimary) &&
+              offsetof(vlc_video_surface_hdr10_metadata_t, GreenPrimary) == offsetof(libvlc_video_surface_hdr10_metadata_t, GreenPrimary) &&
+              offsetof(vlc_video_surface_hdr10_metadata_t, BluePrimary)  == offsetof(libvlc_video_surface_hdr10_metadata_t, BluePrimary) &&
+              offsetof(vlc_video_surface_hdr10_metadata_t, WhitePoint)    == offsetof(libvlc_video_surface_hdr10_metadata_t, WhitePoint) &&
+              offsetof(vlc_video_surface_hdr10_metadata_t, MaxMasteringLuminance) == offsetof(libvlc_video_surface_hdr10_metadata_t, MaxMasteringLuminance) &&
+              offsetof(vlc_video_surface_hdr10_metadata_t, MinMasteringLuminance) == offsetof(libvlc_video_surface_hdr10_metadata_t, MinMasteringLuminance) &&
+              offsetof(vlc_video_surface_hdr10_metadata_t, MaxContentLightLevel) == offsetof(libvlc_video_surface_hdr10_metadata_t, MaxContentLightLevel) &&
+              offsetof(vlc_video_surface_hdr10_metadata_t, MaxFrameAverageLightLevel)== offsetof(libvlc_video_surface_hdr10_metadata_t, MaxFrameAverageLightLevel)
+              , "video surface hdr10 metadata mismatch");
-- 
2.17.1



More information about the vlc-devel mailing list