[vlc-commits] [Git][videolan/vlc][master] 7 commits: fourcc: add VLC_CODEC_V308 to YUV list

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jan 31 13:19:57 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
d1783a0d by Alexandre Janniaux at 2025-01-31T12:59:25+00:00
fourcc: add VLC_CODEC_V308 to YUV list

A new YUV list is created to avoid adding the new chroma to YUV
fallbacks.

- - - - -
cd4b6803 by Alexandre Janniaux at 2025-01-31T12:59:25+00:00
fourcc: add chroma description for VLC_CODEC_V308

- - - - -
bc92c807 by Alexandre Janniaux at 2025-01-31T12:59:25+00:00
opengl: renderer: fix error return type on OOM

- - - - -
a6cf9502 by Alexandre Janniaux at 2025-01-31T12:59:25+00:00
opengl: sampler: add logs when sampler fails

When a filter could not load because of a sampler creation failure,
there were no messages indicating that it came from the sampler, nor
information on what failed in the sampler.

- - - - -
8aa3e762 by Alexandre Janniaux at 2025-01-31T12:59:25+00:00
opengl: renderer: add logs in case of linking failure

- - - - -
798e2179 by Alexandre Janniaux at 2025-01-31T12:59:25+00:00
opengl: sampler: add support for GL_EXT_YUV_target

GL_EXT_YUV_target[^1] provides a way to access an external texture
without applying a conversion to RGBA texture, which can be used to
supply our own matrices for conversion.

This can be used to workaround bogus RGBA conversion for some devices
and can help integrating better with deinterlacing, or in general plane
filtering, and some YUV pipeline like encoding.

[^1]: https://registry.khronos.org/OpenGL/extensions/EXT/EXT_YUV_target.txt

- - - - -
e5963be1 by Alexandre Janniaux at 2025-01-31T12:59:25+00:00
opengl: interop_android: add support for GL_EXT_YUV_target

- - - - -


4 changed files:

- modules/video_output/opengl/interop_android.c
- modules/video_output/opengl/renderer.c
- modules/video_output/opengl/sampler.c
- src/misc/fourcc.c


Changes:

=====================================
modules/video_output/opengl/interop_android.c
=====================================
@@ -238,8 +238,22 @@ Open(struct vlc_gl_interop *interop)
     interop->ops = &ops;
 
     interop->tex_target = GL_TEXTURE_EXTERNAL_OES;
-    interop->fmt_out.i_chroma = VLC_CODEC_RGBA;
-    interop->fmt_out.space = COLOR_SPACE_UNDEF;
+    if (vlc_gl_HasExtension(&extension_vt, "GL_EXT_YUV_target"))
+    {
+        msg_Warn(&interop->obj, "GL_EXT_YUV_target is available,"
+                " using it.");
+        /* We represent as Packed YUV 4:4:4 since there is a single
+         * texture target available. */
+        interop->fmt_out.i_chroma = VLC_CODEC_V308;
+        interop->fmt_out.space = interop->fmt_in.space;
+        interop->fmt_out.primaries = interop->fmt_in.primaries;
+        interop->fmt_out.transfer = interop->fmt_in.transfer;
+    }
+    else
+    {
+        interop->fmt_out.i_chroma = VLC_CODEC_RGBA;
+        interop->fmt_out.space = COLOR_SPACE_UNDEF;
+    }
 
     interop->tex_count = 1;
     interop->texs[0] = (struct vlc_gl_tex_cfg) {


=====================================
modules/video_output/opengl/renderer.c
=====================================
@@ -806,13 +806,16 @@ vlc_gl_renderer_Open(struct vlc_gl_filter *filter,
     struct vlc_gl_sampler *sampler =
         vlc_gl_sampler_New(filter->gl, filter->api, glfmt, false);
     if (!sampler)
+    {
+        msg_Dbg(&filter->obj, "Could not create sampler for renderer");
         return VLC_EGENERIC;
+    }
 
     struct vlc_gl_renderer *renderer = calloc(1, sizeof(*renderer));
     if (!renderer)
     {
         vlc_gl_sampler_Delete(sampler);
-        return VLC_EGENERIC;
+        return VLC_ENOMEM;
     }
 
     static const struct vlc_gl_filter_ops filter_ops = {
@@ -844,6 +847,7 @@ vlc_gl_renderer_Open(struct vlc_gl_filter *filter,
     int ret = opengl_link_program(filter);
     if (ret != VLC_SUCCESS)
     {
+        msg_Dbg(&filter->obj, "Could not link shaders");
         free(renderer);
         return ret;
     }


=====================================
modules/video_output/opengl/sampler.c
=====================================
@@ -525,6 +525,10 @@ opengl_init_swizzle(struct vlc_gl_sampler *sampler,
                 swizzle_per_tex[0] = "r";
                 swizzle_per_tex[1] = "ag";
                 break;
+            case VLC_CODEC_V308:
+                swizzle_per_tex[0] = "rgb";
+                assert(sampler->glfmt.tex_count == 1);
+                break;
             default:
                 assert(!"missing chroma");
                 return VLC_EGENERIC;
@@ -543,10 +547,12 @@ GetNames(struct vlc_gl_sampler *sampler, GLenum tex_target,
         (priv->gl->api_type == VLC_OPENGL && priv->glsl_version >= 130) ||
         (priv->gl->api_type == VLC_OPENGL_ES2 && priv->glsl_version >= 300);
 
+    const bool is_yuv = vlc_fourcc_IsYUV(sampler->glfmt.fmt.i_chroma);
+
     switch (tex_target)
     {
         case GL_TEXTURE_EXTERNAL_OES:
-            *glsl_sampler = "samplerExternalOES";
+            *glsl_sampler = is_yuv ? "__samplerExternal2DY2YEXT" : "samplerExternalOES";
             *texture = has_texture_func ? "texture" : "texture2D";
             break;
         case GL_TEXTURE_2D:
@@ -566,14 +572,21 @@ static int
 InitShaderExtensions(struct vlc_gl_sampler *sampler, GLenum tex_target)
 {
     struct vlc_gl_sampler_priv *priv = PRIV(sampler);
+    const bool is_yuv = vlc_fourcc_IsYUV(sampler->glfmt.fmt.i_chroma);
 
     const char *image_external = priv->glsl_version >= 300
         ? "#extension GL_OES_EGL_image_external_essl3 : require\n"
         : "#extension GL_OES_EGL_image_external : require\n";
 
+    const char *ext_yuv_target =
+        "#extension GL_EXT_YUV_target : require\n";
+
     if (tex_target == GL_TEXTURE_EXTERNAL_OES)
     {
-        sampler->shader.extensions = strdup(image_external);
+        if (is_yuv)
+            sampler->shader.extensions = strdup(ext_yuv_target);
+        else
+            sampler->shader.extensions = strdup(image_external);
         if (!sampler->shader.extensions)
             return VLC_EGENERIC;
     }
@@ -740,7 +753,10 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, bool expose_planes)
 
     const vlc_chroma_description_t *desc = vlc_fourcc_GetChromaDescription(chroma);
     if (desc == NULL)
+    {
+        msg_Dbg(priv->gl, "opengl sampler: unknown chroma description %4.4s", (const char *)&chroma);
         return VLC_EGENERIC;
+    }
 
     unsigned tex_count = glfmt->tex_count;
 
@@ -755,10 +771,16 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, bool expose_planes)
     {
         ret = sampler_yuv_base_init(sampler, desc, yuv_space);
         if (ret != VLC_SUCCESS)
+        {
+            msg_Dbg(priv->gl, "opengl sampler: could not initialize YUV shaders for %4.4s", (const char *)&chroma);
             return ret;
+        }
         ret = opengl_init_swizzle(sampler, swizzle_per_tex, desc);
         if (ret != VLC_SUCCESS)
+        {
+            msg_Dbg(priv->gl, "opengl sampler: could not determine swizzle for %4.4s", (const char *)&chroma);
             return ret;
+        }
     }
 
     const char *glsl_sampler, *lookup;
@@ -1092,6 +1114,7 @@ vlc_gl_sampler_New(struct vlc_gl_t *gl, const struct vlc_gl_api *api,
     priv->pl_opengl = pl_opengl_create(priv->pl_log, &gl_params);
     if (!priv->pl_opengl)
     {
+        msg_Dbg(gl, "opengl sampler: could not initialize libplacebo");
         vlc_gl_sampler_Delete(sampler);
         return NULL;
     }
@@ -1109,7 +1132,10 @@ vlc_gl_sampler_New(struct vlc_gl_t *gl, const struct vlc_gl_api *api,
 
     int ret = opengl_fragment_shader_init(sampler, expose_planes);
     if (ret != VLC_SUCCESS)
+    {
+        msg_Dbg(gl, "opengl sampler: could not initialize shaders");
         goto error;
+    }
 
     return sampler;
 


=====================================
src/misc/fourcc.c
=====================================
@@ -554,6 +554,10 @@ static const vlc_fourcc_t p_list_YUV[] = {
     0,
 };
 
+static const vlc_fourcc_t p_list_YUV_no_fallback[] = {
+    VLC_CODEC_V308,
+};
+
 /* */
 static const vlc_fourcc_t p_RGB32_fallback[] = {
     VLC_CODEC_XRGB,
@@ -664,6 +668,12 @@ bool vlc_fourcc_IsYUV(vlc_fourcc_t fcc)
         if( p_list_YUV[i] == fcc )
             return true;
     }
+
+    for (size_t i = 0; i < ARRAY_SIZE(p_list_YUV_no_fallback); i++)
+    {
+        if (p_list_YUV_no_fallback[i] == fcc)
+            return true;
+    }
     return false;
 }
 
@@ -768,6 +778,7 @@ static const vlc_chroma_description_t p_list_chroma_description[] = {
     { VLC_CODEC_P012,                  SEMIPLANAR(2, 2, 12) },
     { VLC_CODEC_P016,                  SEMIPLANAR(2, 2, 16) },
 
+    { VLC_CODEC_V308,                  PACKED_FMT(1, 24) },
     { VLC_CODEC_YUYV,                  PACKED_FMT(2, 16) },
     { VLC_CODEC_YVYU,                  PACKED_FMT(2, 16) },
     { VLC_CODEC_UYVY,                  PACKED_FMT(2, 16) },



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/55c7b75f6ecdceb548747339b4f350854753a9e4...e5963be10462f81faef6027622855f913e22e502

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/55c7b75f6ecdceb548747339b4f350854753a9e4...e5963be10462f81faef6027622855f913e22e502
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