Opened 5 months ago

Closed 3 months ago

#10759 closed defect (fixed)

Bug in new D3D12 decoder.

Reported by: Aleksoid1978 Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: D3D12
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Aleksoid1978)

Affected only MPEG2/VC1/VP9 decoders.
At decoding start - call assert(0) at d3d12va_decode.c -> ff_d3d12va_get_surface_index() line 83
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/d3d12va_decode.c#L83

Result - output is broken/jerky.

Attachments (3)

d3d12va_vp9.diff (433 bytes ) - added by Aleksoid1978 5 months ago.
Possible solution for VP9
d3d12va_vc1.diff (825 bytes ) - added by Aleksoid1978 4 months ago.
0001-D3D12-VC-1-decoder-add-support-for-D3D12_VIDEO_DECOD.patch (1.2 KB ) - added by Aleksoid1978 4 months ago.

Download all attachments as: .zip

Change History (23)

comment:1 by Aleksoid1978, 5 months ago

Description: modified (diff)

by Aleksoid1978, 5 months ago

Attachment: d3d12va_vp9.diff added

Possible solution for VP9

comment:2 by Aleksoid1978, 5 months ago

Description: modified (diff)

comment:3 by Aleksoid1978, 5 months ago

Version: unspecifiedgit-master

comment:4 by Aleksoid1978, 5 months ago

Here is MPEG2 and VC1 affected samples:
https://disk.yandex.ru/d/jd8XFMIdNpu3rA

comment:5 by Aleksoid1978, 5 months ago

How to test/reproduce:
ffmpeg.exe -hwaccel d3d12va -i 720p.mpg broken.mkv
ffmpeg.exe -hwaccel d3d11va -i 720p.mpg good.mkv
ffmpeg.exe -i 720p.mpg good.mkv

comment:8 by Aleksoid1978, 4 months ago

Confirm - it's fix issue.

comment:9 by Balling, 4 months ago

Deleted

Last edited 3 months ago by Balling (previous) (diff)

comment:10 by v0lt, 4 months ago

The D3D12 decoder does not work with AMD integrated graphics.

I get this error on AMD Vega 8:

[h264 @ 0000026c50a058c0] D3D12 decoder doesn't support on this device
[h264 @ 0000026c50a058c0] Failed setup for format d3d12: hwaccel initialisation returned error.

People are also reporting problems with the AMD Radeon 780M.

comment:11 by Balling, 4 months ago

The D3D12 decoder does not work with AMD integrated graphics.

This is Nvidia novel APIs. Both for encoder and decoder. D3d11 is old.

in reply to:  11 comment:12 by v0lt, 4 months ago

Replying to Balling:

The D3D12 decoder does not work with AMD integrated graphics.

This is Nvidia novel APIs. Both for encoder and decoder. D3d11 is old.

The D3D12 decoder is available for Intel, AMD and Nvidia.
I checked, interfaces are available for adapters from all manufacturers.
https://gist.github.com/v0lt/48477eb96075b23c8aeebc3cfe8240a3

But tests with FFmpeg show the following:
Nvidia GTX 950 - works
Intel UHD 750 - works, except VC-1
AMD Vega 8 - does not work

comment:13 by v0lt, 4 months ago

We found out that AMD Vega 8 does not support D3D12_VIDEO_DECODE_TIER_2.

comment:14 by v0lt, 4 months ago

If I understand the spec correctly, if someone reworks the D3D12 decoder support for D3D12_VIDEO_DECODE_TIER_1, then it should work for D3D12_VIDEO_DECODE_TIER_2. I don't know how difficult it is to do.

comment:15 by Aleksoid1978, 4 months ago

Another fix for the VC-1 decoder.
The fact is that there are 2 guides (as well as DXVA2 and D3D11):
D3D12_VIDEO_DECODE_PROFILE_VC1 and D3D12_VIDEO_DECODE_PROFILE_VC1_D2010.

Intel for D3D12 only supports D3D12_VIDEO_DECODE_PROFILE_VC1_D2010.

by Aleksoid1978, 4 months ago

Attachment: d3d12va_vc1.diff added

in reply to:  15 comment:16 by TongWu, 4 months ago

Replying to Aleksoid1978:

Another fix for the VC-1 decoder.
The fact is that there are 2 guides (as well as DXVA2 and D3D11):
D3D12_VIDEO_DECODE_PROFILE_VC1 and D3D12_VIDEO_DECODE_PROFILE_VC1_D2010.

Intel for D3D12 only supports D3D12_VIDEO_DECODE_PROFILE_VC1_D2010.

I can help you submit the patch if you want. Could you add your sign-off info in your patch? Thx.

comment:17 by v0lt, 4 months ago

About VC1_D2010.
http://download.microsoft.com/download/5/d/c/5dc91455-0a8c-4d57-8975-0afe1cfaf0dd/DXVA_WMV.pdf

The VC1_D2010 profile, also known as VC1_VLD2010, has the same functionality and specification as the VC1_D profile. Support for this profile serves only as a positive indication that the accelerator has been designed with awareness of the modifications specified in the August 2010 version of this specification.

The following GUID is defined for this profile.
DEFINE_GUID(DXVA_ModeVC1_D2010,0x1b81beA4,
0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);

Hardware accelerator drivers that expose support for this profile must not also expose the previously specified VC1_D GUID, unless the accelerator works properly with existing software decoders that use VC1_D and that do not incorporate the corrections added to the August 2010 version of this specification.

I think what this means is that VC1_D2010 (and all other synonyms for DXVA2, D3D11, D3D12) should be given higher priority than VC1_D.

comment:20 by Aleksoid1978, 3 months ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.