[vlc-commits] [Git][videolan/vlc][master] 3 commits: mft: keep the decoder D3D format
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Thu Apr 7 21:00:16 UTC 2022
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
fa2c2019 by Steve Lhomme at 2022-04-07T20:44:36+00:00
mft: keep the decoder D3D format
- - - - -
69151eff by Steve Lhomme at 2022-04-07T20:44:36+00:00
mft: support hardware decoders outputing separate textures
Modern DXVA decoders are not tied to a single Texture with all slices.
We have to allocate the Shader Resource View (SRV) each time.
- - - - -
217857f0 by Steve Lhomme at 2022-04-07T20:44:36+00:00
mft: add support for AV1 decoding
It requires the free AV1 extension to be installed.
https://www.microsoft.com/en-us/p/av1-video-extension/9mvzqvxjbq9v
- - - - -
1 changed file:
- modules/codec/mft.cpp
Changes:
=====================================
modules/codec/mft.cpp
=====================================
@@ -91,6 +91,7 @@ public:
// Direct3D
vlc_video_context *vctx_out = nullptr;
+ const d3d_format_t *cfg = nullptr;
HRESULT (WINAPI *fptr_MFCreateDXGIDeviceManager)(UINT *resetToken, IMFDXGIDeviceManager **ppDeviceManager) = nullptr;
UINT dxgi_token = 0;
ComPtr<IMFDXGIDeviceManager> dxgi_manager;
@@ -258,6 +259,8 @@ typedef struct
const GUID *guid;
} pair_format_guid;
+DEFINE_MEDIATYPE_GUID (vlc_MFVideoFormat_AV1, FCC('AV01'));
+
/*
* We need this table since the FOURCC used for GUID is not the same
* as the FOURCC used by VLC, for instance h264 vs H264.
@@ -273,6 +276,7 @@ static const pair_format_guid video_format_table[] =
{ VLC_CODEC_WMV2, &MFVideoFormat_WMV2 },
{ VLC_CODEC_WMV3, &MFVideoFormat_WMV3 },
{ VLC_CODEC_VC1, &MFVideoFormat_WVC1 },
+ { VLC_CODEC_AV1, &vlc_MFVideoFormat_AV1 },
{ 0, NULL }
};
@@ -913,11 +917,12 @@ static int ProcessOutputStream(decoder_t *p_dec, DWORD stream_id, bool & keep_re
if (SUCCEEDED(hr))
{
ID3D11Texture2D *d3d11Res;
- void *pv;
- hr = spDXGIBuffer->GetResource(__uuidof(d3d11Res), &pv);
+ hr = spDXGIBuffer->GetResource(IID_PPV_ARGS(&d3d11Res));
if (SUCCEEDED(hr))
{
- d3d11Res = static_cast<ID3D11Texture2D *>(pv);
+ D3D11_TEXTURE2D_DESC desc;
+ d3d11Res->GetDesc(&desc);
+
hr = spDXGIBuffer->GetSubresourceIndex(&sliceIndex);
if (!p_sys->vctx_out)
{
@@ -925,9 +930,6 @@ static int ProcessOutputStream(decoder_t *p_dec, DWORD stream_id, bool & keep_re
d3d11_decoder_device_t *dev_sys = GetD3D11OpaqueDevice(dec_dev);
if (dev_sys != NULL)
{
- D3D11_TEXTURE2D_DESC desc;
- d3d11Res->GetDesc(&desc);
-
p_sys->vctx_out = D3D11CreateVideoContext( dec_dev, desc.Format );
vlc_decoder_device_Release(dec_dev);
if (unlikely(p_sys->vctx_out == NULL))
@@ -939,20 +941,19 @@ static int ProcessOutputStream(decoder_t *p_dec, DWORD stream_id, bool & keep_re
p_dec->fmt_out.video.i_width = desc.Width;
p_dec->fmt_out.video.i_height = desc.Height;
- const d3d_format_t *cfg = nullptr;
for (const d3d_format_t *output_format = DxgiGetRenderFormatList();
output_format->name != NULL; ++output_format)
{
if (output_format->formatTexture == desc.Format &&
is_d3d11_opaque(output_format->fourcc))
{
- cfg = output_format;
+ p_sys->cfg = output_format;
break;
}
}
- p_dec->fmt_out.i_codec = cfg->fourcc;
- p_dec->fmt_out.video.i_chroma = cfg->fourcc;
+ p_dec->fmt_out.i_codec = p_sys->cfg->fourcc;
+ p_dec->fmt_out.video.i_chroma = p_sys->cfg->fourcc;
// pre allocate all the SRV for that texture
for (size_t slice=0; slice < desc.ArraySize; slice++)
@@ -961,7 +962,8 @@ static int ProcessOutputStream(decoder_t *p_dec, DWORD stream_id, bool & keep_re
d3d11Res, d3d11Res, d3d11Res, d3d11Res
};
- if (D3D11_AllocateResourceView(p_dec, dev_sys->d3d_dev.d3ddevice, cfg, tex, slice, p_sys->cachedSRV[slice]) != VLC_SUCCESS)
+ if (D3D11_AllocateResourceView(p_dec, dev_sys->d3d_dev.d3ddevice, p_sys->cfg,
+ tex, slice, p_sys->cachedSRV[slice]) != VLC_SUCCESS)
{
d3d11Res->Release();
goto error;
@@ -970,6 +972,29 @@ static int ProcessOutputStream(decoder_t *p_dec, DWORD stream_id, bool & keep_re
p_sys->cached_tex = d3d11Res;
}
}
+ else if (desc.ArraySize == 1)
+ {
+ assert(sliceIndex == 0);
+
+ d3d11_decoder_device_t *dev_sys = GetD3D11OpaqueContext(p_sys->vctx_out);
+
+ ID3D11Texture2D *tex[DXGI_MAX_SHADER_VIEW] = {
+ d3d11Res, d3d11Res, d3d11Res, d3d11Res
+ };
+
+ for (size_t j=0; j < ARRAY_SIZE(p_sys->cachedSRV[sliceIndex]); j++)
+ {
+ if (p_sys->cachedSRV[sliceIndex][j] != nullptr)
+ p_sys->cachedSRV[sliceIndex][j]->Release();
+ }
+
+ if (D3D11_AllocateResourceView(p_dec, dev_sys->d3d_dev.d3ddevice, p_sys->cfg,
+ tex, sliceIndex, p_sys->cachedSRV[sliceIndex]) != VLC_SUCCESS)
+ {
+ d3d11Res->Release();
+ goto error;
+ }
+ }
else if (p_sys->cached_tex.Get() != d3d11Res)
{
msg_Err(p_dec, "separate texture not supported");
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2608eb5c82d82c209126d5d1af0dcfe48b6b9cee...217857f033ce104a2115d00e32798f1837172f6f
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2608eb5c82d82c209126d5d1af0dcfe48b6b9cee...217857f033ce104a2115d00e32798f1837172f6f
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list