summaryrefslogtreecommitdiffstats
path: root/video
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
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')
-rw-r--r--video/out/gl_common.c11
-rw-r--r--video/out/gl_common.h1
-rw-r--r--video/out/gl_header_fixes.h12
-rw-r--r--video/out/gl_video.c25
4 files changed, 47 insertions, 2 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c
index 8ab2c8ec10..e868b07559 100644
--- a/video/out/gl_common.c
+++ b/video/out/gl_common.c
@@ -462,6 +462,16 @@ struct gl_functions gl_functions[] = {
{0}
},
},
+ // Apple Packed YUV Formats
+ // For gl_hwdec_vda.c
+ // http://www.opengl.org/registry/specs/APPLE/rgb_422.txt
+ {
+ .extension = "GL_APPLE_rgb_422",
+ .provides = MPGL_CAP_APPLE_RGB_422,
+ .functions = (struct gl_function[]) {
+ {0}
+ },
+ },
};
#undef FN_OFFS
@@ -659,6 +669,7 @@ int glFmt2bpp(GLenum format, GLenum type)
case GL_ALPHA:
return component_size;
case GL_YCBCR_MESA:
+ case GL_RGB_422_APPLE:
return 2;
case GL_RGB:
case GL_BGR:
diff --git a/video/out/gl_common.h b/video/out/gl_common.h
index c19ec7f73d..3c8d1aaa98 100644
--- a/video/out/gl_common.h
+++ b/video/out/gl_common.h
@@ -88,6 +88,7 @@ enum {
MPGL_CAP_FLOAT_TEX = (1 << 9),
MPGL_CAP_TEX_RG = (1 << 10), // GL_ARB_texture_rg / GL 3.x
MPGL_CAP_VDPAU = (1 << 11), // GL_NV_vdpau_interop
+ MPGL_CAP_APPLE_RGB_422 = (1 << 12), // GL_APPLE_rgb_422
MPGL_CAP_NO_SW = (1 << 30), // used to block sw. renderers
};
diff --git a/video/out/gl_header_fixes.h b/video/out/gl_header_fixes.h
index 88e8dd5e58..902116ace4 100644
--- a/video/out/gl_header_fixes.h
+++ b/video/out/gl_header_fixes.h
@@ -249,6 +249,18 @@
#endif
#endif
+#ifndef GL_RGB_422_APPLE
+#define GL_RGB_422_APPLE 0x8A1F
+#endif
+
+#ifndef UNSIGNED_SHORT_8_8_APPLE
+#define UNSIGNED_SHORT_8_8_APPLE 0x85BA
+#endif
+
+#ifndef UNSIGNED_SHORT_8_8_APPLE
+#define UNSIGNED_SHORT_8_8_APPLE 0x85BB
+#endif
+
#ifndef GL_NV_vdpau_interop
#define GLvdpauSurfaceNV GLintptr
#endif
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;