[vlc-devel] [RFC v2 4/8] libvlc: handle the input colorimetry on the surface callbacks

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


---
 include/vlc/libvlc_media_player.h | 53 ++++++++++++++++++++++++++++++-
 include/vlc_vout_display.h        |  8 +++++
 lib/media_player.c                | 37 ++++++++++++++++++++-
 3 files changed, 96 insertions(+), 2 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 5e6cd81fbc..9380a585f2 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -289,6 +289,42 @@ LIBVLC_API void libvlc_media_player_stop ( libvlc_media_player_t *p_mi );
 LIBVLC_API int libvlc_media_player_set_renderer( libvlc_media_player_t *p_mi,
                                                  libvlc_renderer_item_t *p_item );
 
+/**
+ * Enumeration of the Video color primaries.
+ */
+typedef enum libvlc_video_color_primaries_t {
+    libvlc_video_primaries_BT601_525 = 1,
+    libvlc_video_primaries_BT601_625 = 2,
+    libvlc_video_primaries_BT709     = 3,
+    libvlc_video_primaries_BT2020    = 4,
+    libvlc_video_primaries_DCI_P3    = 5,
+    libvlc_video_primaries_BT470_M   = 6,
+} libvlc_video_color_primaries_t;
+
+/**
+ * Enumeration of the Video color spaces.
+ */
+typedef enum libvlc_video_color_space_t {
+    libvlc_video_colorspace_BT601  = 1,
+    libvlc_video_colorspace_BT709  = 2,
+    libvlc_video_colorspace_BT2020 = 3,
+} libvlc_video_color_space_t;
+
+/**
+ * Enumeration of the Video transfer functions.
+ */
+typedef enum libvlc_video_transfer_func_t {
+    libvlc_video_transfer_func_LINEAR     = 1,
+    libvlc_video_transfer_func_SRGB       = 2,
+    libvlc_video_transfer_func_BT470_BG   = 3,
+    libvlc_video_transfer_func_BT470_M    = 4,
+    libvlc_video_transfer_func_BT709      = 5,
+    libvlc_video_transfer_func_PQ         = 6,
+    libvlc_video_transfer_func_SMPTE_240  = 7,
+    libvlc_video_transfer_func_HLG        = 8,
+} libvlc_video_transfer_func_t;
+
+
 /**
  * Callback prototype to allocate and lock a picture buffer.
  *
@@ -584,8 +620,23 @@ typedef struct
     unsigned width;                        /** rendering video width in pixel */
     unsigned height;                      /** rendering video height in pixel */
     unsigned bitdepth;      /** rendering video bit depth in bits per channel */
+    bool full_range;          /** video is full range or studio/limited range */
+    libvlc_video_color_space_t colorspace;              /** video color space */
+    libvlc_video_color_primaries_t primaries;       /** video color primaries */
+    libvlc_video_transfer_func_t transfer;        /** video transfer function */
 } libvlc_video_surface_cfg_t;
 
+typedef struct
+{
+    intptr_t surface_format;  /** the rendering DXGI_FORMAT for \ref libvlc_video_rendering_direct3d11,
+                                  D3DFORMAT for \ref libvlc_video_rendering_direct3d9 */
+    bool full_range;          /** video is full range or studio/limited range */
+    libvlc_video_color_space_t colorspace;              /** video color space */
+    libvlc_video_color_primaries_t primaries;       /** video color primaries */
+    libvlc_video_transfer_func_t transfer;        /** video transfer function */
+} libvlc_video_output_cfg_t;
+
+
 /**
  * List of control passed to the @a libvlc_video_control_cb callback
  */
@@ -615,7 +666,7 @@ typedef enum libvlc_video_callback_control_t {
     /** Update the rendering output setup.
      *
      * \ref input const libvlc_video_surface_cfg_t* with the new setup
-     * \ref output ignored
+     * \ref output libvlc_video_output_cfg_t* filled with how the rendering is setup
      */
     LIBVLC_VIDEO_UPDATE_OUTPUT,
 
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 7916d3027c..25e480fdf5 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -470,11 +470,19 @@ typedef struct
 {
     unsigned width, height;
     unsigned bitdepth; /* bits per channel */
+    bool                    full_range;
+    video_color_space_t     colorspace;
+    video_color_primaries_t primaries;
+    video_transfer_func_t   transfer;
 } vlc_video_surface_cfg_t; /* must match libvlc_video_surface_cfg_t */
 
 typedef struct
 {
     intptr_t          surface_format; /* DXGI_FORMAT for D3D11, D3DFORMAT for D3D9 */
+    bool                    full_range;
+    video_color_space_t     colorspace;
+    video_color_primaries_t primaries;
+    video_transfer_func_t   transfer;
 } video_surface_output_cfg_t; /* must match libvlc_video_surface_cfg_t */
 
 typedef enum
diff --git a/lib/media_player.c b/lib/media_player.c
index 888b3e2cc5..1dd33396a6 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -2098,5 +2098,40 @@ static_assert(sizeof(vlc_video_surface_device_setup_t)            == sizeof(libv
 static_assert(sizeof(vlc_video_surface_cfg_t)              == sizeof(libvlc_video_surface_cfg_t) &&
               offsetof(vlc_video_surface_cfg_t, width)     == offsetof(libvlc_video_surface_cfg_t, width) &&
               offsetof(vlc_video_surface_cfg_t, height)    == offsetof(libvlc_video_surface_cfg_t, height) &&
-              offsetof(vlc_video_surface_cfg_t, bitdepth)  == offsetof(libvlc_video_surface_cfg_t, bitdepth)
+              offsetof(vlc_video_surface_cfg_t, bitdepth)  == offsetof(libvlc_video_surface_cfg_t, bitdepth) &&
+              offsetof(vlc_video_surface_cfg_t, full_range) == offsetof(libvlc_video_surface_cfg_t, full_range) &&
+              offsetof(vlc_video_surface_cfg_t, primaries) == offsetof(libvlc_video_surface_cfg_t, primaries) &&
+              offsetof(vlc_video_surface_cfg_t, colorspace)== offsetof(libvlc_video_surface_cfg_t, colorspace) &&
+              offsetof(vlc_video_surface_cfg_t, transfer)  == offsetof(libvlc_video_surface_cfg_t, transfer)
               , "video surface setup mismatch");
+
+static_assert(sizeof(video_surface_output_cfg_t)               == sizeof(libvlc_video_output_cfg_t) &&
+              offsetof(video_surface_output_cfg_t, surface_format) == offsetof(libvlc_video_output_cfg_t, surface_format) &&
+              offsetof(video_surface_output_cfg_t, full_range) == offsetof(libvlc_video_output_cfg_t, full_range) &&
+              offsetof(video_surface_output_cfg_t, colorspace) == offsetof(libvlc_video_output_cfg_t, colorspace) &&
+              offsetof(video_surface_output_cfg_t, primaries)  == offsetof(libvlc_video_output_cfg_t, primaries) &&
+              offsetof(video_surface_output_cfg_t, transfer)   == offsetof(libvlc_video_output_cfg_t, transfer)
+              , "video surface configuration mismatch");
+
+static_assert(libvlc_video_colorspace_BT601  == COLOR_SPACE_BT601 &&
+              libvlc_video_colorspace_BT709  == COLOR_SPACE_BT709 &&
+              libvlc_video_colorspace_BT2020 == COLOR_SPACE_BT2020
+              , "libvlc video colorspace mismatch");
+
+static_assert(libvlc_video_transfer_func_LINEAR       == TRANSFER_FUNC_LINEAR &&
+              libvlc_video_transfer_func_SRGB         == TRANSFER_FUNC_SRGB &&
+              libvlc_video_transfer_func_BT470_BG     == TRANSFER_FUNC_BT470_BG &&
+              libvlc_video_transfer_func_BT470_M      == TRANSFER_FUNC_BT470_M &&
+              libvlc_video_transfer_func_BT709        == TRANSFER_FUNC_BT709 &&
+              libvlc_video_transfer_func_PQ           == TRANSFER_FUNC_SMPTE_ST2084 &&
+              libvlc_video_transfer_func_SMPTE_240    == TRANSFER_FUNC_SMPTE_240 &&
+              libvlc_video_transfer_func_HLG          == TRANSFER_FUNC_HLG
+              , "libvlc video transfer function mismatch");
+
+static_assert(libvlc_video_primaries_BT601_525 == COLOR_PRIMARIES_BT601_525 &&
+              libvlc_video_primaries_BT601_625 == COLOR_PRIMARIES_BT601_625 &&
+              libvlc_video_primaries_BT709     == COLOR_PRIMARIES_BT709 &&
+              libvlc_video_primaries_BT2020    == COLOR_PRIMARIES_BT2020 &&
+              libvlc_video_primaries_DCI_P3    == COLOR_PRIMARIES_DCI_P3 &&
+              libvlc_video_primaries_BT470_M   == COLOR_PRIMARIES_BT470_M
+              , "libvlc video color primaries mismatch");
-- 
2.17.1



More information about the vlc-devel mailing list