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.
This commit is contained in:
Philip Langdale 2019-05-06 21:25:45 -07:00 committed by sfan5
parent 13e14d95e1
commit 1638fa7b46
4 changed files with 20 additions and 5 deletions

View File

@ -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},

View File

@ -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)

View File

@ -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,

View File

@ -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',