68 AVD3D11FrameDescriptor *avFrameDesc =
69 static_cast<AVD3D11FrameDescriptor *>(av_mallocz(
sizeof(AVD3D11FrameDescriptor)));
70 avFrameDesc->index = 0;
71 avFrameDesc->texture = tex.Get();
73 return av_buffer_create(
reinterpret_cast<uint8_t *>(avFrameDesc),
79 const int poolIndex = getAvFramePoolIndex(src);
80 const ComPtr<ID3D11Texture2D> poolTex = getAvFrameTexture(src);
82 D3D11_TEXTURE2D_DESC texDesc{};
83 poolTex->GetDesc(&texDesc);
85 texDesc.ArraySize = 1;
86 texDesc.MiscFlags = 0;
87 texDesc.BindFlags = 0;
89 ComPtr<ID3D11Texture2D> destTex;
90 if (hwDevCtx->device->CreateTexture2D(&texDesc,
nullptr, &destTex) != S_OK) {
91 qCCritical(qLcMediaFFmpegHWAccel) <<
"Unable to copy frame from decoder pool";
95 hwDevCtx->device_context->CopySubresourceRegion(destTex.Get(), 0, 0, 0, 0, poolTex.Get(),
357 if (!src || !src->hw_frames_ctx || src->format != AV_PIX_FMT_D3D11)
360 const AVHWDeviceContext *avDevCtx = avFrameDeviceContext(src.get());
361 if (!avDevCtx || avDevCtx->type != AV_HWDEVICE_TYPE_D3D11VA)
364 AVFrameUPtr dest = makeAVFrame();
365 if (av_frame_copy_props(dest.get(), src.get()) != 0) {
366 qCCritical(qLcMediaFFmpegHWAccel) <<
"Unable to copy frame from decoder pool";
370 const AVD3D11VADeviceContext *hwDevCtx = getHwDeviceContext(avDevCtx);
371 ComPtr<ID3D11Texture2D> destTex;
373 hwDevCtx->lock(hwDevCtx->lock_ctx);
374 destTex = copyTexture(hwDevCtx, src.get());
375 hwDevCtx->unlock(hwDevCtx->lock_ctx);
378 dest->buf[0] = wrapTextureAsBuffer(destTex);
379 dest->data[0] =
reinterpret_cast<uint8_t *>(destTex.Detach());
380 dest->data[1] =
reinterpret_cast<uint8_t *>(0);
382 dest->width = src->width;
383 dest->height = src->height;
384 dest->format = src->format;
385 dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);