[vlc-devel] [RFC 3/6] libvlc: handle the input colorimetry on the surface callbacks
Steve Lhomme
robux4 at ycbcr.xyz
Tue Apr 30 11:34:35 CEST 2019
---
include/vlc/libvlc_media_player.h | 58 ++++++++++++++++++++++++++++---
lib/media_player.c | 50 ++++++++++++++++++++++----
2 files changed, 98 insertions(+), 10 deletions(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 507aee73d3..b33e365358 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.
*
@@ -571,11 +607,25 @@ typedef enum libvlc_video_rendering_t {
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 */
+ 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_callback_setup_t;
+typedef struct
+{
+ intptr_t param1; /** the rendering DXGI_FORMAT for \ref libvlc_video_rendering_direct3d11 */
+ 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
*/
@@ -605,7 +655,7 @@ typedef enum libvlc_video_callback_control_t {
/** Update the rendering output setup.
*
* \ref input const libvlc_video_callback_setup_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/lib/media_player.c b/lib/media_player.c
index ebcaeeeabc..32c6289222 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -2083,9 +2083,47 @@ static_assert(VLC_VIDEO_SURFACE_DEVICE_SETUP == LIBVLC_VIDEO_DEVICE_SETUP
VLC_VIDEO_SURFACE_UPDATE_OUTPUT == LIBVLC_VIDEO_UPDATE_OUTPUT &&
VLC_VIDEO_SURFACE_SWAP == LIBVLC_VIDEO_SWAP &&
VLC_VIDEO_SURFACE_START_RENDERING == LIBVLC_VIDEO_START_RENDERING &&
- VLC_VIDEO_SURFACE_FINISHED_RENDERING == LIBVLC_VIDEO_FINISHED_RENDERING &&
- sizeof(vlc_video_surface_cfg_t) == sizeof(libvlc_video_callback_setup_t) &&
- offsetof(vlc_video_surface_cfg_t, width) == offsetof(libvlc_video_callback_setup_t, width) &&
- offsetof(vlc_video_surface_cfg_t, height) == offsetof(libvlc_video_callback_setup_t, height) &&
- offsetof(vlc_video_surface_cfg_t, bitdepth) == offsetof(libvlc_video_callback_setup_t, bitdepth)
- , "video surface mismatch");
+ VLC_VIDEO_SURFACE_FINISHED_RENDERING == LIBVLC_VIDEO_FINISHED_RENDERING
+ , "video surface callback IDs mismatch");
+
+/* make sure surface structures from libvlc can be passed as such to vlc */
+static_assert(sizeof(vlc_video_surface_cfg_t) == sizeof(libvlc_video_callback_setup_t) &&
+ offsetof(vlc_video_surface_cfg_t, width) == offsetof(libvlc_video_callback_setup_t, width) &&
+ offsetof(vlc_video_surface_cfg_t, height) == offsetof(libvlc_video_callback_setup_t, height) &&
+ offsetof(vlc_video_surface_cfg_t, bitdepth) == offsetof(libvlc_video_callback_setup_t, bitdepth) &&
+ offsetof(vlc_video_surface_cfg_t, full_range) == offsetof(libvlc_video_callback_setup_t, full_range) &&
+ offsetof(vlc_video_surface_cfg_t, primaries) == offsetof(libvlc_video_callback_setup_t, primaries) &&
+ offsetof(vlc_video_surface_cfg_t, colorspace)== offsetof(libvlc_video_callback_setup_t, colorspace) &&
+ offsetof(vlc_video_surface_cfg_t, transfer) == offsetof(libvlc_video_callback_setup_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, param1) == offsetof(libvlc_video_output_cfg_t, param1) &&
+ 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