[FFmpeg-devel] [PATCH v12 2/9] avcodec: add D3D12VA hardware accelerated H264 decoding
Wu, Tong1
tong1.wu at intel.com
Mon Dec 25 04:07:43 EET 2023
>From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
>Michael Niedermayer
>Sent: Monday, December 25, 2023 7:07 AM
>To: FFmpeg development discussions and patches <ffmpeg-
>devel at ffmpeg.org>
>Subject: Re: [FFmpeg-devel] [PATCH v12 2/9] avcodec: add D3D12VA hardware
>accelerated H264 decoding
>
>On Tue, Dec 05, 2023 at 02:46:44PM +0800, Tong Wu wrote:
>> From: Wu Jianhua <toqsxw at outlook.com>
>>
>> The implementation is based on:
>> https://learn.microsoft.com/en-us/windows/win32/medfound/direct3d-12-
>video-overview
>>
>> With the Direct3D 12 video decoding support, we can render or process
>> the decoded images by the pixel shaders or compute shaders directly
>> without the extra copy overhead, which is beneficial especially if you
>> are trying to render or post-process a 4K or 8K video.
>>
>> The command below is how to enable d3d12va:
>> ffmpeg -hwaccel d3d12va -i input.mp4 output.mp4
>>
>> Signed-off-by: Wu Jianhua <toqsxw at outlook.com>
>> Signed-off-by: Tong Wu <tong1.wu at intel.com>
>> ---
>[...]
>> +unsigned ff_d3d12va_get_surface_index(const AVCodecContext *avctx,
>> + D3D12VADecodeContext *ctx, const AVFrame *frame,
>> + int curr)
>> +{
>> + AVD3D12VAFrame *f;
>> + ID3D12Resource *res;
>> + unsigned i;
>> +
>> + f = (AVD3D12VAFrame *)frame->data[0];
>> + if (!f)
>> + goto fail;
>> +
>> + res = f->texture;
>> + if (!res)
>> + goto fail;
>> +
>> + if (!curr) {
>> + for (i = 0; i < ctx->max_num_ref; i++) {
>> + if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
>> + ctx->used_mask |= 1 << i;
>> + return i;
>> + }
>> + }
>> + } else {
>> + for (i = 0; i < ctx->max_num_ref; i++) {
>> + if (!((ctx->used_mask >> i) & 0x1)) {
>> + ctx->ref_resources[i] = res;
>> + return i;
>> + }
>> + }
>> + }
>> +
>> +fail:
>> + assert(0);
>
>this should probably be some av_assert*
>
>thx
Thanks, will send a patch to fix later.
>
>[...]
>--
>Michael GnuPG fingerprint:
>9FF2128B147EF6730BADF133611EC787040B0FAB
>
>If the United States is serious about tackling the national security threats
>related to an insecure 5G network, it needs to rethink the extent to which it
>values corporate profits and government espionage over security.-Bruce
>Schneier
More information about the ffmpeg-devel
mailing list