diff options
author | wm4 <wm4@nowhere> | 2016-04-29 23:13:24 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-04-29 23:24:28 +0200 |
commit | 016eab220971ecd3d4509bb4936cb579e9b4a7c3 (patch) | |
tree | 551629d12713b3e9c03d34d04c91692e8aa88af1 /video/decode/d3d.c | |
parent | bda111018c2440e0af70b462d24c757beb37b11f (diff) | |
download | mpv-016eab220971ecd3d4509bb4936cb579e9b4a7c3.tar.bz2 mpv-016eab220971ecd3d4509bb4936cb579e9b4a7c3.tar.xz |
d3d11va, dxva2: simplify decoder selection
In particular, this moves the depth test to common code.
Should be functionally equivalent, except that for DXVA2, the
IDirectXVideoDecoderService_GetDecoderRenderTargets API is called
more often potentially.
Diffstat (limited to 'video/decode/d3d.c')
-rw-r--r-- | video/decode/d3d.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/video/decode/d3d.c b/video/decode/d3d.c index 7a47ad2aa7..e55ca22073 100644 --- a/video/decode/d3d.c +++ b/video/decode/d3d.c @@ -132,7 +132,9 @@ static bool mode_supported(const struct d3dva_mode *mode, struct d3d_decoder_fmt d3d_select_decoder_mode( struct lavc_ctx *s, const GUID *device_guids, UINT n_guids, - DWORD (*get_dxfmt_cb)(struct lavc_ctx *s, const GUID *guid, int depth)) + const struct d3d_decoded_format *formats, int n_formats, + bool (*test_fmt_cb)(struct lavc_ctx *s, const GUID *guid, + const struct d3d_decoded_format *fmt)) { struct d3d_decoder_fmt fmt = { .guid = &GUID_NULL, @@ -146,7 +148,6 @@ struct d3d_decoder_fmt d3d_select_decoder_mode( return fmt; int depth = IMGFMT_RGB_DEPTH(sw_img_fmt); - int mpfmt_decoded = depth <= 8 ? IMGFMT_NV12 : IMGFMT_P010; for (int i = 0; i < MP_ARRAY_SIZE(d3dva_modes); i++) { const struct d3dva_mode *mode = &d3dva_modes[i]; @@ -154,12 +155,24 @@ struct d3d_decoder_fmt d3d_select_decoder_mode( profile_compatible(mode, s->avctx->profile) && mode_supported(mode, device_guids, n_guids)) { - DWORD dxfmt_decoded = get_dxfmt_cb(s, mode->guid, depth); - if (dxfmt_decoded) { - fmt.guid = mode->guid; - fmt.mpfmt_decoded = mpfmt_decoded; - fmt.dxfmt_decoded = dxfmt_decoded; - return fmt; + for (int n = 0; n < n_formats; n++) { + const struct d3d_decoded_format *format = &formats[n]; + + if (depth <= format->depth && test_fmt_cb(s, mode->guid, format)) + { + MP_VERBOSE(s, "Selecting %s ", + d3d_decoder_guid_to_desc(mode->guid)); + if (format->dxfmt >= (1 << 16)) { + MP_VERBOSE(s, "%s\n", mp_tag_str(format->dxfmt)); + } else { + MP_VERBOSE(s, "%d\n", (int)format->dxfmt); + } + + fmt.guid = mode->guid; + fmt.mpfmt_decoded = format->mpfmt; + fmt.dxfmt_decoded = format->dxfmt; + return fmt; + } } } } |