62 AVD3D11FrameDescriptor *avFrameDesc =
63 static_cast<AVD3D11FrameDescriptor *>(av_mallocz(
sizeof(AVD3D11FrameDescriptor)));
64 avFrameDesc->index = 0;
65 avFrameDesc->texture = tex.Get();
67 return av_buffer_create(
reinterpret_cast<uint8_t *>(avFrameDesc),
68 sizeof(AVD3D11FrameDescriptor *), [](
void *opaque, uint8_t *data) {
69 static_cast<ID3D11Texture2D *>(opaque)->Release();
76 const int poolIndex = getAvFramePoolIndex(src);
77 const ComPtr<ID3D11Texture2D> poolTex = getAvFrameTexture(src);
79 D3D11_TEXTURE2D_DESC texDesc{};
80 poolTex->GetDesc(&texDesc);
82 texDesc.ArraySize = 1;
83 texDesc.MiscFlags = 0;
84 texDesc.BindFlags = 0;
86 ComPtr<ID3D11Texture2D> destTex;
87 if (hwDevCtx->device->CreateTexture2D(&texDesc,
nullptr, &destTex) != S_OK) {
88 qCCritical(qLcMediaFFmpegHWAccel) <<
"Unable to copy frame from decoder pool";
92 hwDevCtx->device_context->CopySubresourceRegion(destTex.Get(), 0, 0, 0, 0, poolTex.Get(),
359 if (!src || !src->hw_frames_ctx || src->format != AV_PIX_FMT_D3D11)
362 const AVHWDeviceContext *avDevCtx = avFrameDeviceContext(src.get());
363 if (!avDevCtx || avDevCtx->type != AV_HWDEVICE_TYPE_D3D11VA)
366 AVFrameUPtr dest = makeAVFrame();
367 if (av_frame_copy_props(dest.get(), src.get()) != 0) {
368 qCCritical(qLcMediaFFmpegHWAccel) <<
"Unable to copy frame from decoder pool";
372 const AVD3D11VADeviceContext *hwDevCtx = getHwDeviceContext(avDevCtx);
373 ComPtr<ID3D11Texture2D> destTex;
375 hwDevCtx->lock(hwDevCtx->lock_ctx);
376 destTex = copyTexture(hwDevCtx, src.get());
377 hwDevCtx->unlock(hwDevCtx->lock_ctx);
383 dest->buf[0] = wrapTextureAsBuffer(destTex);
384 dest->data[0] =
reinterpret_cast<uint8_t *>(destTex.Detach());
385 dest->data[1] =
reinterpret_cast<uint8_t *>(0);
387 dest->width = src->width;
388 dest->height = src->height;
389 dest->format = src->format;
390 dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);