[vlc-commits] [Git][videolan/vlc][master] 3 commits: vdpau/display: do not hard-code SPU formats

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon Jun 6 13:31:27 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
d15fb555 by Rémi Denis-Courmont at 2022-06-06T13:08:43+00:00
vdpau/display: do not hard-code SPU formats

Allocate an array so that we can vary the content per instance.

- - - - -
81603e36 by Rémi Denis-Courmont at 2022-06-06T13:08:43+00:00
vdpau/display: check SPU pixel format

Up to this point, only one format was exposed so this did not matter.

- - - - -
69d2e555 by Rémi Denis-Courmont at 2022-06-06T13:08:43+00:00
vdpau/display: test B8G8R8A8 SPU format

This also fixes a corner-case bug where whe format exposed on big
endian was not the one being tested.

- - - - -


1 changed file:

- modules/hw/vdpau/display.c


Changes:

=====================================
modules/hw/vdpau/display.c
=====================================
@@ -62,6 +62,8 @@ typedef struct vout_display_sys_t
 
     unsigned width;
     unsigned height;
+
+    vlc_fourcc_t spu_formats[3];
 } vout_display_sys_t;
 
 static void RenderRegion(vout_display_t *vd, VdpOutputSurface target,
@@ -70,12 +72,25 @@ static void RenderRegion(vout_display_t *vd, VdpOutputSurface target,
 {
     vout_display_sys_t *sys = vd->sys;
     VdpBitmapSurface surface;
+    VdpRGBAFormat fmt;
+    VdpStatus err;
+
+    switch (reg->fmt.i_chroma) {
 #ifdef WORDS_BIGENDIAN
-    VdpRGBAFormat fmt = VDP_RGBA_FORMAT_B8G8R8A8;
+        case VLC_CODEC_ARGB:
+            fmt = VDP_RGBA_FORMAT_B8G8R8A8;
+            break;
 #else
-    VdpRGBAFormat fmt = VDP_RGBA_FORMAT_R8G8B8A8;
+        case VLC_CODEC_RGBA:
+            fmt = VDP_RGBA_FORMAT_R8G8B8A8;
+            break;
+        case VLC_CODEC_BGRA:
+            fmt = VDP_RGBA_FORMAT_B8G8R8A8;
+            break;
 #endif
-    VdpStatus err;
+        default:
+            vlc_assert_unreachable();
+    }
 
     /* Create GPU surface for sub-picture */
     err = vdp_bitmap_surface_create(sys->vdp, sys->device, fmt,
@@ -407,29 +422,6 @@ static int Open(vout_display_t *vd,
         xcb_map_window(sys->conn, sys->window);
     }
 
-    /* Check bitmap capabilities (for SPU) */
-    const vlc_fourcc_t *spu_chromas = NULL;
-    {
-#ifdef WORDS_BIGENDIAN
-        static const vlc_fourcc_t subpicture_chromas[] = { VLC_CODEC_ARGB, 0 };
-#else
-        static const vlc_fourcc_t subpicture_chromas[] = { VLC_CODEC_RGBA, 0 };
-#endif
-        uint32_t w, h;
-        VdpBool ok;
-
-        err = vdp_bitmap_surface_query_capabilities(sys->vdp, sys->device,
-                                        VDP_RGBA_FORMAT_R8G8B8A8, &ok, &w, &h);
-        if (err != VDP_STATUS_OK)
-        {
-            msg_Err(vd, "%s capabilities query failure: %s", "output surface",
-                    vdp_get_error_string(sys->vdp, err));
-            ok = VDP_FALSE;
-        }
-        if (ok)
-            spu_chromas = subpicture_chromas;
-    }
-
     /* Initialize VDPAU queue */
     err = vdp_presentation_queue_target_create_x11(sys->vdp, sys->device,
                                                    sys->window, &sys->target);
@@ -450,10 +442,41 @@ static int Open(vout_display_t *vd,
         goto error;
     }
 
+    /* Check bitmap capabilities (for SPU) */
+    {
+        uint32_t w, h;
+        VdpBool ok;
+        unsigned int n = 0;
+
+#ifdef WORDS_BIGENDIAN
+        err = vdp_bitmap_surface_query_capabilities(sys->vdp, sys->device,
+                                                    VDP_RGBA_FORMAT_R8G8B8A8,
+                                                    &ok, &w, &h);
+        if (err == VDP_STATUS_OK && ok == VDP_TRUE)
+            sys->spu_formats[n++] = VLC_CODEC_RGBA;
+        if (n > 0) {
+            sys->spu_formats[n] = 0;
+            vd->info.subpicture_chromas = sys->spu_formats;
+        }
+#endif
+        err = vdp_bitmap_surface_query_capabilities(sys->vdp, sys->device,
+                                                    VDP_RGBA_FORMAT_B8G8R8A8,
+                                                    &ok, &w, &h);
+        if (err == VDP_STATUS_OK && ok == VDP_TRUE)
+#ifdef WORDS_BIGENDIAN
+            sys->spu_formats[n++] = VLC_CODEC_ARGB;
+#else
+            sys->spu_formats[n++] = VLC_CODEC_BGRA;
+#endif
+        if (n > 0) {
+            sys->spu_formats[n] = 0;
+            vd->info.subpicture_chromas = sys->spu_formats;
+        }
+    }
+
     /* */
     sys->current = NULL;
     vd->sys = sys;
-    vd->info.subpicture_chromas = spu_chromas;
     *fmtp = fmt;
 
     vd->ops = &ops;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7a91ac6c3a010243ee1ea1987c7d7a40b569fb5b...69d2e555a9a2bb67a55192bcdbf65dd46432f7f0

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7a91ac6c3a010243ee1ea1987c7d7a40b569fb5b...69d2e555a9a2bb67a55192bcdbf65dd46432f7f0
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