From 1638fa7b4663e4ad46ccd9750debba730222ea2a Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Mon, 6 May 2019 21:25:45 -0700 Subject: vo/gpu: hwdec_vdpau: Support direct mode for 4:4:4 content New releases of VDPAU support decoding 4:4:4 content, and that comes back as NV24 when using 'direct mode' in OpenGL Interop. That means we need to be a little bit smarter about how we set up the OpenGL textures. --- video/fmt-conversion.c | 1 + video/img_format.h | 3 +++ video/out/opengl/hwdec_vdpau.c | 19 +++++++++++++++---- wscript | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/video/fmt-conversion.c b/video/fmt-conversion.c index d803ac0aa1..6e298d0057 100644 --- a/video/fmt-conversion.c +++ b/video/fmt-conversion.c @@ -35,6 +35,7 @@ static const struct { {IMGFMT_RGB24, AV_PIX_FMT_RGB24}, {IMGFMT_UYVY, AV_PIX_FMT_UYVY422}, {IMGFMT_NV12, AV_PIX_FMT_NV12}, + {IMGFMT_NV24, AV_PIX_FMT_NV24}, {IMGFMT_Y8, AV_PIX_FMT_GRAY8}, {IMGFMT_Y16, AV_PIX_FMT_GRAY16}, {IMGFMT_420P, AV_PIX_FMT_YUV420P}, diff --git a/video/img_format.h b/video/img_format.h index c316afa94d..1b5e97a8d3 100644 --- a/video/img_format.h +++ b/video/img_format.h @@ -163,6 +163,9 @@ enum mp_imgfmt { // Like IMGFMT_NV12, but with 10 bits per component (and 6 bits of padding) IMGFMT_P010, + // Like IMGFMT_NV12, but for 4:4:4 + IMGFMT_NV24, + // RGB/BGR Formats // Byte accessed (low address to high address) diff --git a/video/out/opengl/hwdec_vdpau.c b/video/out/opengl/hwdec_vdpau.c index 603a70eb93..f865978f5b 100644 --- a/video/out/opengl/hwdec_vdpau.c +++ b/video/out/opengl/hwdec_vdpau.c @@ -42,6 +42,7 @@ struct priv { GLvdpauSurfaceNV vdpgl_surface; VdpOutputSurface vdp_surface; struct mp_vdpau_mixer *mixer; + struct ra_imgfmt_desc direct_desc; bool direct_mode; bool mapped; }; @@ -162,13 +163,21 @@ static int mapper_init(struct ra_hwdec_mapper *mapper) p->vdpgl_initialized = true; p->direct_mode = mapper->dst_params.hw_subfmt == IMGFMT_NV12 || - mapper->dst_params.hw_subfmt == IMGFMT_420P; + mapper->dst_params.hw_subfmt == IMGFMT_NV24 || + mapper->dst_params.hw_subfmt == IMGFMT_420P || + mapper->dst_params.hw_subfmt == IMGFMT_444P; mapper->vdpau_fields = p->direct_mode; gl->GenTextures(4, p->gl_textures); if (p->direct_mode) { - mapper->dst_params.imgfmt = IMGFMT_NV12; + int imgfmt = mapper->dst_params.hw_subfmt; + if (!ra_get_imgfmt_desc(mapper->ra, imgfmt, &p->direct_desc)) { + MP_ERR(mapper, "Unsupported format: %s\n", mp_imgfmt_to_name(imgfmt)); + return -1; + } + mapper->dst_params.imgfmt = p->direct_desc.chroma_w == 1 ? + IMGFMT_NV24 : IMGFMT_NV12; mapper->dst_params.hw_subfmt = 0; for (int n = 0; n < 4; n++) { @@ -250,11 +259,13 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) for (int n = 0; n < 4; n++) { bool chroma = n >= 2; + int w_scale = chroma ? p->direct_desc.chroma_w : 1; + int h_scale = chroma ? p->direct_desc.chroma_h * 2 : 2; struct ra_tex_params params = { .dimensions = 2, - .w = s_w / (chroma ? 2 : 1), - .h = s_h / (chroma ? 4 : 2), + .w = s_w / w_scale, + .h = s_h / h_scale, .d = 1, .format = ra_find_unorm_format(mapper->ra, 1, chroma ? 2 : 1), .render_src = true, diff --git a/wscript b/wscript index f4a410985c..733faa86c9 100644 --- a/wscript +++ b/wscript @@ -418,7 +418,7 @@ iconv support use --disable-iconv.", ] ffmpeg_pkg_config_checks = [ - 'libavutil', '>= 56.12.100', + 'libavutil', '>= 56.27.100', 'libavcodec', '>= 58.16.100', 'libavformat', '>= 58.9.100', 'libswscale', '>= 5.0.101', -- cgit v1.2.3