[vlc-devel] [PATCH 5/8] libvlc: add support for HDR10 metadata during the rendering start

Steve Lhomme robux4 at ycbcr.xyz
Mon May 6 15:01:34 CEST 2019


---
 include/vlc/libvlc_media_player.h | 16 +++++++++++++++-
 include/vlc_vout_display.h        | 14 +++++++++++++-
 lib/media_player.c                | 11 +++++++++++
 3 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 8443154203..c3551ea575 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -673,10 +673,24 @@ typedef struct
  */
 typedef bool( *libvlc_video_surface_update_output_cb )( void *opaque, const libvlc_video_surface_cfg_t *cfg, libvlc_video_output_cfg_t *output );
 
+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;
+
 /** Tell the host the rendering is about to start/has finished.
  *
  * \param opaque private pointer passed to the @a libvlc_video_surface_set_callbacks() [IN]
  * \param enter true if the rendering is about to start, false if it's finished
+ * \param hdr10 libvlc_video_surface_hdr10_metadata_t* or NULL
  * \return true on success
  * \version LibVLC 4.0.0 or later
  *
@@ -720,7 +734,7 @@ typedef bool( *libvlc_video_surface_update_output_cb )( void *opaque, const libv
  * - RSSetViewports()
  * - DrawIndexed()
  */
-typedef bool( *libvlc_video_surface_start_rendering_cb )( void *opaque, bool enter );
+typedef bool( *libvlc_video_surface_start_rendering_cb )( void *opaque, bool enter, const libvlc_video_surface_hdr10_metadata_t *hdr10 );
 
 
 /**
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 102b73e3ec..1f8f9fa713 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 */
@@ -489,7 +501,7 @@ typedef bool( *vlc_video_surface_device_setup_cb )( void *opaque, const vlc_vide
 typedef void( *vlc_video_surface_device_cleanup_cb )( void *opaque );
 typedef bool( *vlc_video_surface_update_output_cb )( void *opaque, const vlc_video_surface_cfg_t *cfg, video_surface_output_cfg_t *output );
 typedef void( *vlc_video_swap_cb )( void* opaque );
-typedef bool( *vlc_video_surface_start_rendering_cb )( void *opaque, bool enter );
+typedef bool( *vlc_video_surface_start_rendering_cb )( void *opaque, bool enter, const vlc_video_surface_hdr10_metadata_t *hdr10 );
 
 /** @} */
 #endif /* VLC_VOUT_DISPLAY_H */
diff --git a/lib/media_player.c b/lib/media_player.c
index c2580e8eb4..373e639bab 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