[vlc-devel] [PATCH v3 05/22] opengl: store video format in sampler

Romain Vimont rom1v at videolabs.io
Mon Jul 6 12:46:58 CEST 2020


The sampler just referenced the interop format.

In order to support samplers without interop (when the input picture
comes from a previous OpenGL filter), store the input format in the
sampler.

Co-authored-by: Alexandre Janniaux <ajanni at videolabs.io>
---
 modules/video_output/opengl/renderer.c | 14 +++++++-------
 modules/video_output/opengl/sampler.c  |  6 +++++-
 modules/video_output/opengl/sampler.h  |  2 +-
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index aef1fb1234..2d8cf56e29 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -208,7 +208,7 @@ BuildVertexShader(struct vlc_gl_filter *filter)
 
     if (renderer->dump_shaders)
         msg_Dbg(filter, "\n=== Vertex shader for fourcc: %4.4s ===\n%s\n",
-                (const char *) &renderer->sampler->fmt->i_chroma, code);
+                (const char *) &renderer->sampler->fmt.i_chroma, code);
     return code;
 }
 
@@ -238,8 +238,8 @@ BuildFragmentShader(struct vlc_gl_filter *filter)
 
     if (renderer->dump_shaders)
         msg_Dbg(filter, "\n=== Fragment shader for fourcc: %4.4s, colorspace: %d ===\n%s\n",
-                        (const char *) &sampler->fmt->i_chroma,
-                        sampler->fmt->space, code);
+                        (const char *) &sampler->fmt.i_chroma,
+                        sampler->fmt.space, code);
 
     return code;
 }
@@ -338,7 +338,7 @@ vlc_gl_renderer_Open(struct vlc_gl_filter *filter,
     (void) config;
 
     const opengl_vtable_t *vt = &filter->api->vt;
-    const video_format_t *fmt = sampler->fmt;
+    const video_format_t *fmt = &sampler->fmt;
 
     struct vlc_gl_renderer *renderer = calloc(1, sizeof(*renderer));
     if (!renderer)
@@ -439,7 +439,7 @@ vlc_gl_renderer_SetViewpoint(struct vlc_gl_renderer *renderer,
         UpdateFOVy(renderer);
         UpdateZ(renderer);
     }
-    const video_format_t *fmt = renderer->sampler->fmt;
+    const video_format_t *fmt = &renderer->sampler->fmt;
     getViewpointMatrixes(renderer, fmt->projection_mode);
 
     return VLC_SUCCESS;
@@ -456,7 +456,7 @@ vlc_gl_renderer_SetWindowAspectRatio(struct vlc_gl_renderer *renderer,
     UpdateFOVy(renderer);
     UpdateZ(renderer);
 
-    const video_format_t *fmt = renderer->sampler->fmt;
+    const video_format_t *fmt = &renderer->sampler->fmt;
     getViewpointMatrixes(renderer, fmt->projection_mode);
 }
 
@@ -701,7 +701,7 @@ static int BuildRectangle(GLfloat **vertexCoord, GLfloat **textureCoord, unsigne
 static int SetupCoords(struct vlc_gl_renderer *renderer)
 {
     const opengl_vtable_t *vt = renderer->vt;
-    const video_format_t *fmt = renderer->sampler->fmt;
+    const video_format_t *fmt = &renderer->sampler->fmt;
 
     GLfloat *vertexCoord, *textureCoord;
     GLushort *indices;
diff --git a/modules/video_output/opengl/sampler.c b/modules/video_output/opengl/sampler.c
index 4cfeada6ba..219cac3aec 100644
--- a/modules/video_output/opengl/sampler.c
+++ b/modules/video_output/opengl/sampler.c
@@ -953,7 +953,11 @@ vlc_gl_sampler_New(struct vlc_gl_interop *interop)
     priv->gl = interop->gl;
     priv->vt = interop->vt;
 
-    sampler->fmt = &interop->fmt_out;
+    /* Formats with palette are not supported. This also allows to copy
+     * video_format_t without possibility of failure. */
+    assert(!sampler->fmt.p_palette);
+
+    sampler->fmt = interop->fmt_out;
 
     sampler->shader.extensions = NULL;
     sampler->shader.body = NULL;
diff --git a/modules/video_output/opengl/sampler.h b/modules/video_output/opengl/sampler.h
index b8439b004b..c3ddfd7204 100644
--- a/modules/video_output/opengl/sampler.h
+++ b/modules/video_output/opengl/sampler.h
@@ -51,7 +51,7 @@
  */
 struct vlc_gl_sampler {
     /* Input format */
-    const video_format_t *fmt;
+    video_format_t fmt;
 
     struct {
         /**
-- 
2.27.0



More information about the vlc-devel mailing list