summaryrefslogtreecommitdiffstats
path: root/video/out/gl_video.c
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-11-13 21:52:34 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-12-02 09:03:30 +0100
commit36eebc231e0ad94f31ed27f43e52b439a77a2560 (patch)
tree30839c97536c4e6811ad66d698a39fa20b37c4ef /video/out/gl_video.c
parentcb45ea371fb8ff9fd62026dcf060587864c56586 (diff)
downloadmpv-36eebc231e0ad94f31ed27f43e52b439a77a2560.tar.bz2
mpv-36eebc231e0ad94f31ed27f43e52b439a77a2560.tar.xz
gl_video: support packed YUV formats with Apple extensions
This adds support for packed YUV formats (YUVY and UYVY) using the extension GL_APPLE_rgb_422. While supporting this formats on their own is not that important (considering most video is planar YUV) they are used for interoperability with IOSurfaces. Next commit will use this formats to render VDA hardware decoded frames through IOSurface and OpenGL interoperability.
Diffstat (limited to 'video/out/gl_video.c')
-rw-r--r--video/out/gl_video.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 4c901965fa..57dec29759 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -170,7 +170,7 @@ struct gl_video {
struct mp_imgfmt_desc image_desc;
- bool is_yuv, is_rgb;
+ bool is_yuv, is_rgb, is_packed_yuv;
bool is_linear_rgb;
bool has_alpha;
char color_swizzle[5];
@@ -238,6 +238,12 @@ static const struct fmt_entry gl_byte_formats[] = {
{0, GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT}, // 4 x 16
};
+static const struct fmt_entry gl_apple_formats[] = {
+ {IMGFMT_UYVY, GL_RGB, GL_RGB_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE},
+ {IMGFMT_YUYV, GL_RGB, GL_RGB_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE},
+ {0}
+};
+
struct packed_fmt_entry {
int fmt;
int8_t component_size;
@@ -872,7 +878,8 @@ static void compile_shaders(struct gl_video *p)
if (p->color_swizzle[0])
shader_def(&header_conv, "USE_COLOR_SWIZZLE", p->color_swizzle);
shader_def_opt(&header_conv, "USE_SWAP_UV", p->image_format == IMGFMT_NV21);
- shader_def_opt(&header_conv, "USE_YGRAY", p->is_yuv && p->plane_count == 1);
+ shader_def_opt(&header_conv, "USE_YGRAY", p->is_yuv && !p->is_packed_yuv
+ && p->plane_count == 1);
shader_def_opt(&header_conv, "USE_INPUT_GAMMA", convert_input_gamma);
shader_def_opt(&header_conv, "USE_COLORMATRIX", !p->is_rgb);
shader_def_opt(&header_conv, "USE_CONV_GAMMA", convert_input_to_linear);
@@ -2058,6 +2065,20 @@ static bool init_format(int fmt, struct gl_video *init)
}
}
+ // Packed YUV Apple formats
+ if (init->gl->mpgl_caps & MPGL_CAP_APPLE_RGB_422) {
+ for (const struct fmt_entry *e = gl_apple_formats; e->mp_format; e++) {
+ if (e->mp_format == fmt) {
+ init->is_packed_yuv = true;
+ supported = true;
+ snprintf(init->color_swizzle, sizeof(init->color_swizzle),
+ "gbra");
+ plane_format[0] = e;
+ break;
+ }
+ }
+ }
+
if (!supported)
return false;