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(),
354 if (!src || !src->hw_frames_ctx || src->format != AV_PIX_FMT_D3D11)
357 const AVHWDeviceContext *avDevCtx = avFrameDeviceContext(src.get());
358 if (!avDevCtx || avDevCtx->type != AV_HWDEVICE_TYPE_D3D11VA)
361 AVFrameUPtr dest = makeAVFrame();
362 if (av_frame_copy_props(dest.get(), src.get()) != 0) {
363 qCCritical(qLcMediaFFmpegHWAccel) <<
"Unable to copy frame from decoder pool";
367 const AVD3D11VADeviceContext *hwDevCtx = getHwDeviceContext(avDevCtx);
368 ComPtr<ID3D11Texture2D> destTex;
370 hwDevCtx->lock(hwDevCtx->lock_ctx);
371 destTex = copyTexture(hwDevCtx, src.get());
372 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);