On Tue, Dec 05, 2023 at 02:46:44PM +0800, Tong Wu wrote: > From: Wu Jianhua > > 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 > Signed-off-by: Tong Wu > --- [...] > +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 [...] -- 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