From 27bc881cd860e6cf3ad360f2f8cb24a21cbcd981 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 7 Jan 2016 16:28:19 +0100 Subject: vo_opengl: generic semi-planar support Should take care of the planned FFmpeg AV_PIX_FMT_P010 addition. (This will eventually be needed when doing HEVC Main 10 decoding with DXVA2 copyback.) --- video/out/opengl/video.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 3600dda8c4..24618937d8 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -1880,9 +1880,7 @@ static void pass_render_frame_dumb(struct gl_video *p, int fbo) gl_transform_rect(transform, &p->pass_tex[3].src); GLSL(vec4 color = texture(texture0, texcoord0);) - if (p->image_params.imgfmt == IMGFMT_NV12 || - p->image_params.imgfmt == IMGFMT_NV21) - { + if (p->image_desc.flags & MP_IMGFLAG_YUV_NV) { GLSL(color.gb = texture(texture1, texcoord1).RG;) } else if (p->plane_count >= 3) { GLSL(color.g = texture(texture1, texcoord1).r;) @@ -2659,12 +2657,15 @@ static bool init_format(int fmt, struct gl_video *init) } // YUV/half-packed - if (fmt == IMGFMT_NV12 || fmt == IMGFMT_NV21) { - plane_format[0] = find_tex_format(gl, 1, 1); - plane_format[1] = find_tex_format(gl, 1, 2); - if (fmt == IMGFMT_NV21) - snprintf(init->color_swizzle, sizeof(init->color_swizzle), "rbga"); - goto supported; + if (desc.flags & MP_IMGFLAG_YUV_NV) { + int bits = desc.component_bits; + if ((desc.flags & MP_IMGFLAG_NE) && bits >= 8 && bits <= 16) { + plane_format[0] = find_tex_format(gl, (bits + 7) / 8, 1); + plane_format[1] = find_tex_format(gl, (bits + 7) / 8, 2); + if (desc.flags & MP_IMGFLAG_YUV_NV_SWAP) + snprintf(init->color_swizzle, sizeof(init->color_swizzle), "rbga"); + goto supported; + } } // XYZ (same organization as RGB packed, but requires conversion matrix) -- cgit v1.2.3