[vlc-commits] [Git][videolan/vlc][master] 2 commits: opengl: remove obsolete comment

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Nov 26 16:45:15 UTC 2022



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


Commits:
17564eaf by Romain Vimont at 2022-11-26T16:27:32+00:00
opengl: remove obsolete comment

The renderer is not the only filter anymore if an upscaler and/or a
downscaler is set.

- - - - -
7a914bfc by Romain Vimont at 2022-11-26T16:27:32+00:00
opengl: extract interop and filters creation

This removes the filter initialization complexity from
vout_display_opengl_New().

Note: this commit is more understandable with:

    git show --histogram

- - - - -


1 changed file:

- modules/video_output/opengl/vout_helper.c


Changes:

=====================================
modules/video_output/opengl/vout_helper.c
=====================================
@@ -95,63 +95,24 @@ ResizeFormatToGLMaxTexSize(video_format_t *fmt, unsigned int max_tex_size)
     }
 }
 
-vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
-                                               const vlc_fourcc_t **subpicture_chromas,
-                                               vlc_gl_t *gl,
-                                               const vlc_viewpoint_t *viewpoint,
-                                               vlc_video_context *context)
+static struct vlc_gl_filters *
+CreateFilters(vlc_gl_t *gl, const struct vlc_gl_api *api,
+              struct vlc_gl_interop *interop,
+              struct vlc_gl_renderer **out_renderer)
 {
-    vout_display_opengl_t *vgl = calloc(1, sizeof(*vgl));
-    if (!vgl)
-        return NULL;
-
-    vgl->gl = gl;
-
-    int ret = vlc_gl_api_Init(&vgl->api, gl);
-    if (ret != VLC_SUCCESS)
-        goto free_vgl;
-
-    const struct vlc_gl_api *api = &vgl->api;
-    const opengl_vtable_t *vt = &api->vt;
-
-#if !defined(USE_OPENGL_ES2)
-    const unsigned char *ogl_version = vt->GetString(GL_VERSION);
-    bool supports_shaders = strverscmp((const char *)ogl_version, "2.0") >= 0;
-    if (!supports_shaders)
-    {
-        msg_Err(gl, "shaders not supported, bailing out");
-        goto free_vgl;
-    }
-#endif
-
-    /* Resize the format if it is greater than the maximum texture size
-     * supported by the hardware */
-    GLint       max_tex_size;
-    vt->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_tex_size);
-
-    if ((GLint)fmt->i_width > max_tex_size ||
-        (GLint)fmt->i_height > max_tex_size)
-        ResizeFormatToGLMaxTexSize(fmt, max_tex_size);
-
-    vgl->interop = vlc_gl_interop_New(gl, context, fmt);
-    if (!vgl->interop)
-    {
-        msg_Err(gl, "Could not create interop");
-        goto free_vgl;
-    }
-    GL_ASSERT_NOERROR(vt);
-
-    vgl->filters = vlc_gl_filters_New(gl, api, vgl->interop);
-    if (!vgl->filters)
+    struct vlc_gl_filters *filters = vlc_gl_filters_New(gl, api, interop);
+    if (!filters)
     {
         msg_Err(gl, "Could not create filters");
-        goto delete_interop;
+        return NULL;
     }
-    GL_ASSERT_NOERROR(vt);
+
+    const opengl_vtable_t *vt = &api->vt;
+    const video_format_t *fmt_in = &interop->fmt_in;
 
     int upscaler = var_InheritInteger(gl, "gl-upscaler");
     int downscaler = var_InheritInteger(gl, "gl-downscaler");
-    int has_dovi = fmt->dovi.rpu_present && !fmt->dovi.el_present; /* can't handle EL yet */
+    int has_dovi = fmt_in->dovi.rpu_present && !fmt_in->dovi.el_present; /* can't handle EL yet */
 
     if (upscaler || downscaler || has_dovi)
     {
@@ -173,7 +134,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
         };
 
         struct vlc_gl_filter *scale_filter =
-            vlc_gl_filters_Append(vgl->filters, "pl_scale", &cfg);
+            vlc_gl_filters_Append(filters, "pl_scale", &cfg);
         if (!scale_filter)
         {
             if (upscaler)
@@ -185,26 +146,85 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
         }
     }
 
-    /* The renderer is the only filter, for now */
     struct vlc_gl_filter *renderer_filter =
-        vlc_gl_filters_Append(vgl->filters, "renderer", NULL);
+        vlc_gl_filters_Append(filters, "renderer", NULL);
     if (!renderer_filter)
     {
         msg_Warn(gl, "Could not create renderer for %4.4s",
-                 (const char *) &fmt->i_chroma);
-        goto delete_filters;
+                 (const char *) &fmt_in->i_chroma);
+        goto error;
     }
     GL_ASSERT_NOERROR(vt);
 
+    int ret = vlc_gl_filters_InitFramebuffers(filters);
+    if (ret != VLC_SUCCESS)
+    {
+        msg_Err(gl, "Could not init filters framebuffers");
+        goto error;
+    }
+
     /* The renderer is a special filter: we need its concrete instance to
      * forward SetViewpoint() */
-    vgl->renderer = renderer_filter->sys;
+    *out_renderer = renderer_filter->sys;
+
+    return filters;
+
+error:
+    vlc_gl_filters_Delete(filters);
+    return NULL;
+}
+
+vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
+                                               const vlc_fourcc_t **subpicture_chromas,
+                                               vlc_gl_t *gl,
+                                               const vlc_viewpoint_t *viewpoint,
+                                               vlc_video_context *context)
+{
+    vout_display_opengl_t *vgl = calloc(1, sizeof(*vgl));
+    if (!vgl)
+        return NULL;
+
+    vgl->gl = gl;
 
-    ret = vlc_gl_filters_InitFramebuffers(vgl->filters);
+    int ret = vlc_gl_api_Init(&vgl->api, gl);
     if (ret != VLC_SUCCESS)
+        goto free_vgl;
+
+    const struct vlc_gl_api *api = &vgl->api;
+    const opengl_vtable_t *vt = &api->vt;
+
+#if !defined(USE_OPENGL_ES2)
+    const unsigned char *ogl_version = vt->GetString(GL_VERSION);
+    bool supports_shaders = strverscmp((const char *)ogl_version, "2.0") >= 0;
+    if (!supports_shaders)
     {
-        msg_Err(gl, "Could not init filters framebuffers");
-        goto delete_filters;
+        msg_Err(gl, "shaders not supported, bailing out");
+        goto free_vgl;
+    }
+#endif
+
+    /* Resize the format if it is greater than the maximum texture size
+     * supported by the hardware */
+    GLint       max_tex_size;
+    vt->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_tex_size);
+
+    if ((GLint)fmt->i_width > max_tex_size ||
+        (GLint)fmt->i_height > max_tex_size)
+        ResizeFormatToGLMaxTexSize(fmt, max_tex_size);
+
+    vgl->interop = vlc_gl_interop_New(gl, context, fmt);
+    if (!vgl->interop)
+    {
+        msg_Err(gl, "Could not create interop");
+        goto free_vgl;
+    }
+    GL_ASSERT_NOERROR(vt);
+
+    vgl->filters = CreateFilters(gl, api, vgl->interop, &vgl->renderer);
+    if (!vgl->filters)
+    {
+        msg_Err(gl, "Could not create filters");
+        goto delete_interop;
     }
     GL_ASSERT_NOERROR(vt);
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/84140d6bde72fe989b168fd12f011bd76b22cbc4...7a914bfc9449d6564c5113d66af4b3834e4045f1

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/84140d6bde72fe989b168fd12f011bd76b22cbc4...7a914bfc9449d6564c5113d66af4b3834e4045f1
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