summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-13 22:31:27 +0200
committerwm4 <wm4@nowhere>2016-05-13 22:35:42 +0200
commit3858d37b61995d7462bb5592173af1c24c6af167 (patch)
tree7551821405cb6ae1b1abd892ad2308fc3e1cfeb3
parent09e07e92c59d30a0a468a1035d19f50aca07caa9 (diff)
downloadmpv-3858d37b61995d7462bb5592173af1c24c6af167.tar.bz2
mpv-3858d37b61995d7462bb5592173af1c24c6af167.tar.xz
vo_opengl: partially fix 0bgr format support
Fixes broken colors with --vf=format=0bgr (but only if deband is disabled). 0bgr means the first byte is padding, while the following three bytes are bgr. From the vo_opengl perspective, it has 4 physical components with 3 logical components. copy_img_tex() simply copied 3 components from the physical representation, which means the last component (r) was sliced off. Fix this by not using p->color_swizzle for packed formats, and instead let packed formats set the per-plane swizzle in texplane.swizzle. The latter applies the swizzle as part of operation in copy_img_tex(), which essentially moves physical to logical representations. Unfortunately, debanding (and thus with opengl-hq defaults) is still broken.
-rw-r--r--video/out/opengl/video.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 1116d994d1..30ac790fa9 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -2814,6 +2814,7 @@ static bool init_format(struct gl_video *p, int fmt, bool test_only)
const struct gl_format *plane_format[4] = {0};
char color_swizzle[5] = "";
+ const struct packed_fmt_entry *packed_format = {0};
// YUV/planar formats
if (desc.flags & (MP_IMGFLAG_YUV_P | MP_IMGFLAG_RGB_P)) {
@@ -2852,7 +2853,7 @@ static bool init_format(struct gl_video *p, int fmt, bool test_only)
if (e->fmt == fmt) {
int n_comp = desc.bytes[0] / e->component_size;
plane_format[0] = gl_find_unorm_format(gl, e->component_size, n_comp);
- packed_fmt_swizzle(color_swizzle, e);
+ packed_format = e;
goto supported;
}
}
@@ -2899,8 +2900,11 @@ supported:
plane->gl_internal_format = format->internal_format;
plane->gl_type = format->type;
plane->use_integer = use_integer;
+ snprintf(plane->swizzle, sizeof(plane->swizzle), "rgba");
+ if (packed_format)
+ packed_fmt_swizzle(plane->swizzle, packed_format);
if (plane->gl_format == GL_LUMINANCE_ALPHA)
- snprintf(plane->swizzle, sizeof(plane->swizzle), "raaa");
+ MPSWAP(char, plane->swizzle[1], plane->swizzle[3]);
}
init_image_desc(p, fmt);