[vlc-devel] [PATCH 3/7] libvlc: handle the input colorimetry on the surface callbacks

Steve Lhomme robux4 at ycbcr.xyz
Tue May 7 11:39:51 CEST 2019


---
 include/vlc/libvlc_media_player.h | 44 +++++++++++++++++++++++++++++++
 lib/media_player.c                | 28 ++++++++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 3b117be2a4..cbeb7231a9 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.
  *
@@ -609,12 +645,20 @@ 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_direct3d_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;
 
 /** Update the rendering output setup.
diff --git a/lib/media_player.c b/lib/media_player.c
index d51aea9576..24f8b6fcd8 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -2082,3 +2082,31 @@ int libvlc_media_player_get_role(libvlc_media_player_t *mp)
     free(str);
     return ret;
 }
+
+#include <vlc_vout_display.h>
+
+/* make sure surface structures from libvlc can be passed as such to vlc
+   otherwise we will need wrappers between what libvlc understands and what vlc uses */
+
+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