static DWORD get_dxfmt_cb(struct lavc_ctx *s, const GUID *guid, int depth) { DWORD ret = 0; struct priv *p = s->hwdec_priv; D3DFORMAT *formats = NULL; UINT n_formats = 0; HRESULT hr = IDirectXVideoDecoderService_GetDecoderRenderTargets( p->decoder_service, guid, &n_formats, &formats); if (FAILED(hr)) { MP_ERR(p, "Callback failed to get render targets for decoder %s: %s", d3d_decoder_guid_to_desc(guid), mp_HRESULT_to_str(hr)); return 0; } for (int i = 0; i < MP_ARRAY_SIZE(d3d9_formats); i++) { const struct d3d9_format *d3d9_fmt = &d3d9_formats[i]; if (d3d9_fmt->depth < depth) continue; for (UINT j = 0; j < n_formats; j++) { if (formats[i] == d3d9_fmt->format) { ret = formats[i]; MP_VERBOSE(p, "Selecting %s %s\n", d3d_decoder_guid_to_desc(guid), mp_tag_str(ret)); goto done; } } } done: CoTaskMemFree(formats); return ret; }
static void dump_decoder_info(struct lavc_ctx *s, GUID *device_guids, UINT n_guids) { struct priv *p = s->hwdec_priv; MP_VERBOSE(p, "%u decoder devices:\n", (unsigned)n_guids); for (UINT i = 0; i < n_guids; i++) { GUID *guid = &device_guids[i]; char *description = d3d_decoder_guid_to_desc(guid); D3DFORMAT *formats = NULL; UINT n_formats = 0; HRESULT hr = IDirectXVideoDecoderService_GetDecoderRenderTargets( p->decoder_service, guid, &n_formats, &formats); if (FAILED(hr)) { MP_ERR(p, "Failed to get render targets for decoder %s:%s\n", description, mp_HRESULT_to_str(hr)); } char fmts[256] = {0}; for (UINT j = 0; j < n_formats; j++) { mp_snprintf_cat(fmts, sizeof(fmts), " %s", mp_tag_str(formats[j])); } CoTaskMemFree(formats); MP_VERBOSE(p, "%s %s\n", description, fmts); } }
static void dump_decoder_info(struct lavc_ctx *s, const GUID *guid) { struct priv *p = s->hwdec_priv; char fmts[256] = {0}; for (int i = 0; i < MP_ARRAY_SIZE(d3d11_formats); i++) { const struct d3d_decoded_format *format = &d3d11_formats[i]; if (d3d11_format_supported(s, guid, format)) mp_snprintf_cat(fmts, sizeof(fmts), " %s", format->name); } MP_VERBOSE(p, "%s %s\n", d3d_decoder_guid_to_desc(guid), fmts); }
static bool d3d11_format_supported(struct lavc_ctx *s, const GUID *guid, const struct d3d_decoded_format *format) { struct priv *p = s->hwdec_priv; BOOL is_supported = FALSE; HRESULT hr = ID3D11VideoDevice_CheckVideoDecoderFormat( p->video_dev, guid, format->dxfmt, &is_supported); if (FAILED(hr)) { MP_ERR(p, "Check decoder output format %s for decoder %s: %s\n", format->name, d3d_decoder_guid_to_desc(guid), mp_HRESULT_to_str(hr)); } return is_supported; }
static DWORD get_dxfmt_cb(struct lavc_ctx *s, const GUID *guid, int depth) { struct priv *p = s->hwdec_priv; for (int i = 0; i < MP_ARRAY_SIZE(d3d11_formats); i++) { const struct d3d11_format *format = &d3d11_formats[i]; if (depth <= format->depth && d3d11_format_supported(s, guid, format)) { MP_VERBOSE(p, "Selecting %s %s\n", d3d_decoder_guid_to_desc(guid), format->name); return format->format; } } return 0; }
static bool dxva2_format_supported(struct lavc_ctx *s, const GUID *guid, const struct d3d_decoded_format *format) { bool ret = false; struct priv *p = s->hwdec_priv; D3DFORMAT *formats = NULL; UINT n_formats = 0; HRESULT hr = IDirectXVideoDecoderService_GetDecoderRenderTargets( p->decoder_service, guid, &n_formats, &formats); if (FAILED(hr)) { MP_ERR(p, "Callback failed to get render targets for decoder %s: %s", d3d_decoder_guid_to_desc(guid), mp_HRESULT_to_str(hr)); return 0; } for (int i = 0; i < n_formats; i++) { ret = formats[i] == format->dxfmt; if (ret) break; } CoTaskMemFree(formats); return ret; }