[vlc-commits] [Git][videolan/vlc][master] 3 commits: opengl: interop: factor fixup code

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Tue Sep 21 09:33:17 UTC 2021



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


Commits:
9be3c05c by Alexandre Janniaux at 2021-09-21T09:13:33+00:00
opengl: interop: factor fixup code

The code will be common to the cases where we found a valid chroma for
the OpenGL interop.

- - - - -
a0881b7e by Alexandre Janniaux at 2021-09-21T09:13:33+00:00
opengl: interop: check original chroma for OpenGL

Checking only fallbacks means that VLC_CODEC_BGRA will typically be
reinterpreted as VLC_CODEC_RBG32 and will not display correctly.

It might be a regression from previous change refactoring the interop
code, and the resulting chroma issue is a regression from
b79c2b224910d6987a3284ecaafeb4abb32a9a69 which removed the converter
for RGB fallbacks and the following change in vout_helper
c5ea9b76f2917a4028b70e47086c9f6e626b51b6 which reintroduce the
conversion without taking care of converters for RGB.

- - - - -
005c246e by Alexandre Janniaux at 2021-09-21T09:13:33+00:00
opengl: interop: forward interop SW chroma

If a fallback chroma is used instead of the original chroma, we need to
trigger the insertion of a video converter to adapt to this new chroma.

Forgotten from c5ea9b76f2917a4028b70e47086c9f6e626b51b6.

Regression from b79c2b224910d6987a3284ecaafeb4abb32a9a69 which removed
the converter for RGB fallbacks and the following change in vout_helper
c5ea9b76f2917a4028b70e47086c9f6e626b51b6 which reintroduce the
conversion without taking care of converters for RGB.

The proper way to avoid the insertion of converters is to add support
for the formats in the interop.c instead of using RGB fallbacks.

- - - - -


1 changed file:

- modules/video_output/opengl/interop_sw.c


Changes:

=====================================
modules/video_output/opengl/interop_sw.c
=====================================
@@ -325,31 +325,44 @@ opengl_interop_generic_init(struct vlc_gl_interop *interop, bool allow_dr)
     /* The pictures are uploaded upside-down */
     video_format_TransformBy(&interop->fmt_out, TRANSFORM_VFLIP);
 
-    int ret = VLC_EGENERIC;
+    /* Check whether the given chroma is translatable to OpenGL. */
+    vlc_fourcc_t i_chroma = interop->fmt_in.i_chroma;
+    int ret = opengl_interop_init(interop, GL_TEXTURE_2D, i_chroma, space);
+    if (ret == VLC_SUCCESS)
+        goto interop_init;
+
+    /* Check whether any fallback for the chroma is translatable to OpenGL. */
     while (*list)
     {
         ret = opengl_interop_init(interop, GL_TEXTURE_2D, *list, space);
         if (ret == VLC_SUCCESS)
         {
-            if (interop->fmt_out.i_chroma == VLC_CODEC_RGB32)
-            {
+            i_chroma = *list;
+            goto interop_init;
+        }
+        list++;
+    }
+
+    return VLC_EGENERIC;
+
+interop_init:
+    /* We found a chroma with matching parameters for OpenGL. The interop can
+     * be created. */
+
+    // TODO: video_format_FixRgb is not fixing the mask we assign here
+    if (i_chroma == VLC_CODEC_RGB32)
+    {
 #if defined(WORDS_BIGENDIAN)
-                interop->fmt_out.i_rmask  = 0xff000000;
-                interop->fmt_out.i_gmask  = 0x00ff0000;
-                interop->fmt_out.i_bmask  = 0x0000ff00;
+        interop->fmt_out.i_rmask  = 0xff000000;
+        interop->fmt_out.i_gmask  = 0x00ff0000;
+        interop->fmt_out.i_bmask  = 0x0000ff00;
 #else
-                interop->fmt_out.i_rmask  = 0x000000ff;
-                interop->fmt_out.i_gmask  = 0x0000ff00;
-                interop->fmt_out.i_bmask  = 0x00ff0000;
+        interop->fmt_out.i_rmask  = 0x000000ff;
+        interop->fmt_out.i_gmask  = 0x0000ff00;
+        interop->fmt_out.i_bmask  = 0x00ff0000;
 #endif
-                video_format_FixRgb(&interop->fmt_out);
-            }
-            break;
-        }
-        list++;
+        video_format_FixRgb(&interop->fmt_out);
     }
-    if (ret != VLC_SUCCESS)
-        return ret;
 
     struct priv *priv = interop->priv = calloc(1, sizeof(struct priv));
     if (unlikely(priv == NULL))
@@ -361,6 +374,7 @@ opengl_interop_generic_init(struct vlc_gl_interop *interop, bool allow_dr)
         .close = opengl_interop_generic_deinit,
     };
     interop->ops = &ops;
+    interop->fmt_in.i_chroma = i_chroma;
 
     /* OpenGL or OpenGL ES2 with GL_EXT_unpack_subimage ext */
     priv->has_unpack_subimage =



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d79194dc45f272bc915929cbde873f21abc47bb4...005c246ef063a623cff8fa8279ab3061e533117a

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




More information about the vlc-commits mailing list