MCPcopy Create free account
hub / github.com/Nevcairiel/LAVFilters / FindVideoServiceConversion

Method FindVideoServiceConversion

decoder/LAVVideo/decoders/d3d11va.cpp:921–995  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

919}
920
921STDMETHODIMP CDecD3D11::FindVideoServiceConversion(AVCodecID codec, int profile, int level, DXGI_FORMAT &surface_format,
922 GUID *input)
923{
924 AVD3D11VADeviceContext *pDeviceContext = (AVD3D11VADeviceContext *)((AVHWDeviceContext *)m_pDevCtx->data)->hwctx;
925 HRESULT hr = S_OK;
926
927 UINT nProfiles = pDeviceContext->video_device->GetVideoDecoderProfileCount();
928 GUID *guid_list = (GUID *)av_malloc_array(nProfiles, sizeof(*guid_list));
929
930 m_bP016ToP010Fallback = false;
931
932 DbgLog((LOG_TRACE, 10, L"-> Enumerating supported D3D11 modes (count: %d)", nProfiles));
933 for (UINT i = 0; i < nProfiles; i++)
934 {
935 hr = pDeviceContext->video_device->GetVideoDecoderProfile(i, &guid_list[i]);
936 if (FAILED(hr))
937 {
938 DbgLog((LOG_ERROR, 10, L"Error retrieving decoder profile"));
939 av_free(guid_list);
940 return hr;
941 }
942
943#ifdef DEBUG
944 const dxva_mode_t *mode = get_dxva_mode_from_guid(&guid_list[i]);
945 if (mode)
946 {
947 DbgLog((LOG_TRACE, 10, L" -> %S", mode->name));
948 }
949 else
950 {
951 DbgLog((LOG_TRACE, 10, L" -> Unknown GUID (%s)", WStringFromGUID(guid_list[i]).c_str()));
952 }
953#endif
954 }
955
956 /* Iterate over our priority list */
957 for (unsigned i = 0; dxva_modes[i].name; i++)
958 {
959 const dxva_mode_t *mode = &dxva_modes[i];
960 if (!check_dxva_mode_compatibility(mode, codec, profile, level, (surface_format == DXGI_FORMAT_NV12)))
961 continue;
962
963 BOOL supported = FALSE;
964 for (UINT g = 0; !supported && g < nProfiles; g++)
965 {
966 supported = IsEqualGUID(*mode->guid, guid_list[g]);
967 }
968 if (!supported)
969 continue;
970
971 DbgLog((LOG_TRACE, 10, L"-> Trying to use '%S'", mode->name));
972 hr = pDeviceContext->video_device->CheckVideoDecoderFormat(mode->guid, surface_format, &supported);
973 // some high bitdepth decoders only accept P010, despite the memory layout otherwise being identical
974 if (SUCCEEDED(hr) && !supported && surface_format == DXGI_FORMAT_P016)
975 {
976 hr = pDeviceContext->video_device->CheckVideoDecoderFormat(mode->guid, DXGI_FORMAT_P010, &supported);
977
978 if (SUCCEEDED(hr) && supported)

Callers

nothing calls this directly

Calls 4

get_dxva_mode_from_guidFunction · 0.85
WStringFromGUIDFunction · 0.85
SUCCEEDEDFunction · 0.85

Tested by

no test coverage detected