66 AVD3D11FrameDescriptor *avFrameDesc =
67 static_cast<AVD3D11FrameDescriptor *>(av_mallocz(
sizeof(AVD3D11FrameDescriptor)));
68 avFrameDesc->index = 0;
69 avFrameDesc->texture = tex.Get();
71 return av_buffer_create(
reinterpret_cast<uint8_t *>(avFrameDesc),
77 const int poolIndex = getAvFramePoolIndex(src);
78 const ComPtr<ID3D11Texture2D> poolTex = getAvFrameTexture(src);
80 D3D11_TEXTURE2D_DESC texDesc{};
81 poolTex->GetDesc(&texDesc);
83 texDesc.ArraySize = 1;
84 texDesc.MiscFlags = 0;
85 texDesc.BindFlags = 0;
87 ComPtr<ID3D11Texture2D> destTex;
88 if (hwDevCtx->device->CreateTexture2D(&texDesc,
nullptr, &destTex) != S_OK) {
89 qCCritical(qLcMediaFFmpegHWAccel) <<
"Unable to copy frame from decoder pool";
93 hwDevCtx->device_context->CopySubresourceRegion(destTex.Get(), 0, 0, 0, 0, poolTex.Get(),
355 if (!src || !src->hw_frames_ctx || src->format != AV_PIX_FMT_D3D11)
358 const AVHWDeviceContext *avDevCtx = avFrameDeviceContext(src.get());
359 if (!avDevCtx || avDevCtx->type != AV_HWDEVICE_TYPE_D3D11VA)
362 AVFrameUPtr dest = makeAVFrame();
363 if (av_frame_copy_props(dest.get(), src.get()) != 0) {
364 qCCritical(qLcMediaFFmpegHWAccel) <<
"Unable to copy frame from decoder pool";
368 const AVD3D11VADeviceContext *hwDevCtx = getHwDeviceContext(avDevCtx);
369 ComPtr<ID3D11Texture2D> destTex;
371 hwDevCtx->lock(hwDevCtx->lock_ctx);
372 destTex = copyTexture(hwDevCtx, src.get());
373 hwDevCtx->unlock(hwDevCtx->lock_ctx);
376 dest->buf[0] = wrapTextureAsBuffer(destTex);
377 dest->data[0] =
reinterpret_cast<uint8_t *>(destTex.Detach());
378 dest->data[1] =
reinterpret_cast<uint8_t *>(0);
380 dest->width = src->width;
381 dest->height = src->height;
382 dest->format = src->format;
383 dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);