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

Alexandre Janniaux ajanni at videolabs.io
Mon Jun 29 15:49:36 CEST 2020


Hi,

On Thu, Jun 25, 2020 at 02:22:52PM +0200, Romain Vimont wrote:
> 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.
> ---
>  modules/video_output/opengl/renderer.c | 14 +++++++-------
>  modules/video_output/opengl/sampler.c  |  4 +++-
>  modules/video_output/opengl/sampler.h  |  2 +-
>  3 files changed, 11 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..0b58ffb0f6 100644
> --- a/modules/video_output/opengl/sampler.c
> +++ b/modules/video_output/opengl/sampler.c
> @@ -953,7 +953,9 @@ vlc_gl_sampler_New(struct vlc_gl_interop *interop)
>      priv->gl = interop->gl;
>      priv->vt = interop->vt;
>
> -    sampler->fmt = &interop->fmt_out;
> +    sampler->fmt = interop->fmt_out;

This doesn't look like a correct video_format copy.

> +    /* this is the only allocated field, and we don't need it */
> +    sampler->fmt.p_palette = NULL;
>
>      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
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list