From d45fbecbb5d8ba2c782cc419fa386f78b9473d82 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 7 Aug 2017 19:18:58 +0200 Subject: vo_opengl: add another ra_format field to exclude insane formats Generic description of pixel formats is hard. In this case, the Apple special format for packed YUV could have been interpreted as a RGB format with funny packing. --- video/out/opengl/ra.c | 5 +++-- video/out/opengl/ra.h | 2 ++ video/out/opengl/ra_gl.c | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/video/out/opengl/ra.c b/video/out/opengl/ra.c index 0ad70eeb47..7982beab7c 100644 --- a/video/out/opengl/ra.c +++ b/video/out/opengl/ra.c @@ -82,10 +82,11 @@ struct ra_renderpass_params *ra_render_pass_params_copy(void *ta_parent, // Return whether this is a tightly packed format with no external padding and -// with the same bit size/depth in all components. +// with the same bit size/depth in all components, and the shader returns +// components in the same order as in memory. static bool ra_format_is_regular(const struct ra_format *fmt) { - if (!fmt->pixel_size || !fmt->num_components) + if (!fmt->pixel_size || !fmt->num_components || !fmt->ordered) return false; for (int n = 1; n < fmt->num_components; n++) { if (fmt->component_size[n] != fmt->component_size[0] || diff --git a/video/out/opengl/ra.h b/video/out/opengl/ra.h index a6c2461d89..47fa465d99 100644 --- a/video/out/opengl/ra.h +++ b/video/out/opengl/ra.h @@ -60,6 +60,8 @@ struct ra_format { const char *name; // symbolic name for user interaction/debugging void *priv; enum ra_ctype ctype; // data type of each component + bool ordered; // components are sequential in memory, and returned + // by the shader in memory order int num_components; // component count, 0 if not applicable, max. 4 int component_size[4]; // in bits, all entries 0 if not applicable int component_depth[4]; // bits in use for each component, 0 if not applicable diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c index da6f5e92d1..f0b47c795e 100644 --- a/video/out/opengl/ra_gl.c +++ b/video/out/opengl/ra_gl.c @@ -55,6 +55,7 @@ static int ra_init_gl(struct ra *ra, GL *gl) .priv = (void *)gl_fmt, .ctype = gl_format_type(gl_fmt), .num_components = gl_format_components(gl_fmt->format), + .ordered = gl_fmt->format != GL_RGB_422_APPLE, .pixel_size = gl_bytes_per_pixel(gl_fmt->format, gl_fmt->type), .luminance_alpha = gl_fmt->format == GL_LUMINANCE_ALPHA, .linear_filter = gl_fmt->flags & F_TF, -- cgit v1.2.3