[vlc-commits] [Git][videolan/vlc][master] 3 commits: libplacebo: set initial framebuffer size on init

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Mar 18 19:46:54 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
a13bd62d by Niklas Haas at 2022-03-18T19:26:44+00:00
libplacebo: set initial framebuffer size on init

Needed for OpenGL, to avoid printing an error on the first frame, before
the `control()` function is called.

Also allows us to bail out early on swapchain initialization errors.

- - - - -
4dda6c6a by Niklas Haas at 2022-03-18T19:26:44+00:00
libplacebo: clarify option wording

These options are only *overrides* of the detected values. This needs to
be made clear to the user - e.g. setting this to PQ will *not* put the
display into PQ mode.

- - - - -
e33c274d by Niklas Haas at 2022-03-18T19:26:44+00:00
libplacebo: support HDR output modes

Technically, this just requires forwarding the colorspace and HDR
metadata information to the libplacebo swapchain.

In practice, this does nothing at all on OpenGL, and for Vulkan it only
works with implementations that provide VK_KHR_swapchain_colorspace and
VK_EXT_hdr_metadata, which in practice means "Windows, Wayland and DRM
only", although we don't support DRM or wayland (yet) so it really just
means "Windows only".

We provide only a very short list of valid configurations, because
anything else is severely limited in practice.

- - - - -


2 changed files:

- modules/video_output/libplacebo/display.c
- modules/video_output/libplacebo/utils.h


Changes:

=====================================
modules/video_output/libplacebo/display.c
=====================================
@@ -96,6 +96,7 @@ static void PictureDisplay(vout_display_t *, picture_t *);
 static int Control(vout_display_t *, int);
 static void Close(vout_display_t *);
 static void UpdateParams(vout_display_t *);
+static void UpdateColorspaceHint(vout_display_t *, const video_format_t *);
 
 static const struct vlc_display_operations ops = {
     .close = Close,
@@ -127,6 +128,15 @@ static int Open(vout_display_t *vd,
     if (vlc_placebo_MakeCurrent(sys->pl) != VLC_SUCCESS)
         goto error;
 
+    // Set colorsapce hint *before* first swapchain resize
+    UpdateColorspaceHint(vd, fmt);
+
+    // Set initial framebuffer size
+    int width = (int) vd->cfg->display.width;
+    int height = (int) vd->cfg->display.height;
+    if (!pl_swapchain_resize(sys->pl->swapchain, &width, &height))
+        goto error;
+
     const struct pl_gpu *gpu = sys->pl->gpu;
     sys->renderer = pl_renderer_create(sys->pl->ctx, gpu);
     if (!sys->renderer)
@@ -459,6 +469,53 @@ static void PictureDisplay(vout_display_t *vd, picture_t *pic)
     }
 }
 
+static void UpdateColorspaceHint(vout_display_t *vd, const video_format_t *fmt)
+{
+#if PL_API_VER >= 155
+
+    vout_display_sys_t *sys = vd->sys;
+    struct pl_swapchain_colors hint = {0};
+
+    switch (var_InheritBool(vd, "pl-output-hint")) {
+    case OUTPUT_AUTO: ;
+        const struct pl_color_space csp = vlc_placebo_ColorSpace(fmt);
+        hint.primaries = csp.primaries;
+        hint.transfer = csp.transfer;
+        hint.hdr = (struct pl_hdr_metadata) {
+            .prim.green.x   = fmt->mastering.primaries[0] / 50000.0f,
+            .prim.green.y   = fmt->mastering.primaries[1] / 50000.0f,
+            .prim.blue.x    = fmt->mastering.primaries[2] / 50000.0f,
+            .prim.blue.y    = fmt->mastering.primaries[3] / 50000.0f,
+            .prim.red.x     = fmt->mastering.primaries[4] / 50000.0f,
+            .prim.red.y     = fmt->mastering.primaries[5] / 50000.0f,
+            .prim.white.x   = fmt->mastering.white_point[0] / 50000.0f,
+            .prim.white.y   = fmt->mastering.white_point[1] / 50000.0f,
+            .max_luma       = fmt->mastering.max_luminance / 10000.0f,
+            .min_luma       = fmt->mastering.min_luminance / 10000.0f,
+            .max_cll        = fmt->lighting.MaxCLL,
+            .max_fall       = fmt->lighting.MaxFALL,
+        };
+        break;
+    case OUTPUT_SDR:
+        break;
+    case OUTPUT_HDR10:
+        hint.primaries = PL_COLOR_PRIM_BT_2020;
+        hint.transfer = PL_COLOR_TRC_PQ;
+        break;
+    case OUTPUT_HLG:
+        hint.primaries = PL_COLOR_PRIM_BT_2020;
+        hint.transfer = PL_COLOR_TRC_HLG;
+        break;
+    }
+
+    pl_swapchain_colorspace_hint(sys->pl->swapchain, &hint);
+
+#else // PL_API_VER
+    VLC_UNUSED(vd);
+    VLC_UNUSED(fmt);
+#endif
+}
+
 static int Control(vout_display_t *vd, int query)
 {
     vout_display_sys_t *sys = vd->sys;
@@ -648,6 +705,10 @@ vlc_module_begin ()
             DEBAND_GRAIN_TEXT, DEBAND_GRAIN_LONGTEXT)
 
     set_section("Colorspace conversion", NULL)
+#if PL_API_VER >= 155
+    add_integer("pl-output-hint", true, OUTPUT_HINT_TEXT, OUTPUT_HINT_LONGTEXT)
+            change_integer_list(output_values, output_text)
+#endif
     add_integer("pl-intent", pl_color_map_default_params.intent,
             RENDER_INTENT_TEXT, RENDER_INTENT_LONGTEXT)
             change_integer_list(intent_values, intent_text)


=====================================
modules/video_output/libplacebo/utils.h
=====================================
@@ -75,8 +75,8 @@ static const char * const intent_text[] = {
     "Saturation",
 };
 
-#define PRIM_TEXT "Display primaries"
-#define PRIM_LONGTEXT "The primaries associated with the output display"
+#define PRIM_TEXT "Override detected display primaries"
+#define PRIM_LONGTEXT "Override the auto-detected display primaries."
 
 static const int prim_values[] = {
     PL_COLOR_PRIM_UNKNOWN,
@@ -100,7 +100,7 @@ static const int prim_values[] = {
 };
 
 static const char * const prim_text[] = {
-    "Automatic / Unknown primaries",
+    "Automatic (no override)",
     "ITU-R Rec. BT.601 (525-line = NTSC, SMPTE-C)",
     "ITU-R Rec. BT.601 (625-line = PAL, SECAM)",
     "ITU-R Rec. BT.709 (HD), also sRGB",
@@ -120,8 +120,8 @@ static const char * const prim_text[] = {
 #endif
 };
 
-#define TRC_TEXT "Display gamma / transfer function"
-#define TRC_LONGTEXT "The gamma/transfer function associated with the output display"
+#define TRC_TEXT "Override detected display gamma"
+#define TRC_LONGTEXT "Override the auto-detected display gamma / transfer function."
 
 static const int trc_values[] = {
     PL_COLOR_TRC_UNKNOWN,
@@ -140,7 +140,7 @@ static const int trc_values[] = {
 };
 
 static const char * const trc_text[] = {
-    "Automatic / Unknown gamma",
+    "Automatic (no override)",
     "ITU-R Rec. BT.1886 (CRT emulation + OOTF)",
     "IEC 61966-2-4 sRGB (CRT emulation)",
     "Linear light content",
@@ -191,6 +191,30 @@ static const char * const lut_mode_text[] = {
 #define USER_SHADER_FILE_TEXT "Custom shader"
 #define USER_SHADER_FILE_LONGTEXT "Path to a file containing a custom user shader, in mpv .hook format."
 
+enum {
+    OUTPUT_AUTO,
+    OUTPUT_SDR,
+    OUTPUT_HDR10,
+    OUTPUT_HLG,
+};
+
+static const int output_values[] = {
+    OUTPUT_AUTO,
+    OUTPUT_SDR,
+    OUTPUT_HDR10,
+    OUTPUT_HLG,
+};
+
+static const char * const output_text[] = {
+    "Automatic (passthrough)",
+    "Standard gamut SDR",
+    "HDR10 (BT.2020+PQ)",
+    "BT.2020+HLG",
+};
+
+#define OUTPUT_HINT_TEXT "Display output colorspace"
+#define OUTPUT_HINT_LONGTEXT "Determines what colorspace to try configuring the display to. Note that the HDR modes require a compatible driver and display."
+
 #define TONEMAPPING_TEXT "Tone-mapping algorithm"
 #define TONEMAPPING_LONGTEXT "Algorithm to use when converting from wide gamut to standard gamut, or from HDR to SDR."
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b9bc4b7b5bdfd5b71afc5db5ee10c9eb98fead76...e33c274d9471ae4e5eebcff6023626fcd83b7980

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b9bc4b7b5bdfd5b71afc5db5ee10c9eb98fead76...e33c274d9471ae4e5eebcff6023626fcd83b7980
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list