summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-25 10:22:10 +0200
committerwm4 <wm4@nowhere>2015-09-25 10:22:10 +0200
commit456366b63b3f29c736593817ef055701250a7eb1 (patch)
tree4c6d9b71b304a225e98b56691bd6689586267b4f /video
parentec356d3efe73e9505d4db4bdf046629ea66b237a (diff)
downloadmpv-456366b63b3f29c736593817ef055701250a7eb1.tar.bz2
mpv-456366b63b3f29c736593817ef055701250a7eb1.tar.xz
vo_opengl: vaapi: use dummy image to determine plane layout
Reduces the amount of hardcoded assumptions about the layout drastically. (Now adding yuv420 support would be just adjusting an if, if you ignore the other problems, such as determining the hw format at all early enough.)
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/hwdec_vaegl.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/video/out/opengl/hwdec_vaegl.c b/video/out/opengl/hwdec_vaegl.c
index ff04c1a065..23992a1e0a 100644
--- a/video/out/opengl/hwdec_vaegl.c
+++ b/video/out/opengl/hwdec_vaegl.c
@@ -195,23 +195,22 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image,
if (!CHECK_VA_STATUS(p, "vaAcquireBufferHandle()"))
goto err;
- int num_planes = 2;
- int plane_sizes[2] = {1, 2};
- int plane_xs[2] = {0, 1};
- int plane_ys[2] = {0, 1};
+ struct mp_image layout = {0};
+ mp_image_set_params(&layout, &hw_image->params);
+ mp_image_setfmt(&layout, mpfmt);
// (it would be nice if we could use EGL_IMAGE_INTERNAL_FORMAT_EXT)
int drm_fmts[4] = {MP_FOURCC('R', '8', ' ', ' '),
MP_FOURCC('G', 'R', '8', '8'),
0, 0};
- for (int n = 0; n < num_planes; n++) {
- int attribs[20];
+ for (int n = 0; n < layout.num_planes; n++) {
+ int attribs[20] = {EGL_NONE};
int num_attribs = 0;
- ADD_ATTRIB(EGL_LINUX_DRM_FOURCC_EXT, drm_fmts[plane_sizes[n] - 1]);
- ADD_ATTRIB(EGL_WIDTH, mp_chroma_div_up(hw_image->w, plane_xs[n]));
- ADD_ATTRIB(EGL_HEIGHT, mp_chroma_div_up(hw_image->h, plane_ys[n]));
+ ADD_ATTRIB(EGL_LINUX_DRM_FOURCC_EXT, drm_fmts[layout.fmt.bytes[n] - 1]);
+ ADD_ATTRIB(EGL_WIDTH, mp_image_plane_w(&layout, n));
+ ADD_ATTRIB(EGL_HEIGHT, mp_image_plane_h(&layout, n));
ADD_ATTRIB(EGL_DMA_BUF_PLANE0_FD_EXT, buffer_info.handle);
ADD_ATTRIB(EGL_DMA_BUF_PLANE0_OFFSET_EXT, va_image->offsets[n]);
ADD_ATTRIB(EGL_DMA_BUF_PLANE0_PITCH_EXT, va_image->pitches[n]);