| 1666 | } |
| 1667 | |
| 1668 | static int d3d12va_encode_create_recon_frames(AVCodecContext *avctx) |
| 1669 | { |
| 1670 | FFHWBaseEncodeContext *base_ctx = avctx->priv_data; |
| 1671 | D3D12VAEncodeContext *ctx = avctx->priv_data; |
| 1672 | AVD3D12VAFramesContext *hwctx; |
| 1673 | enum AVPixelFormat recon_format; |
| 1674 | int err; |
| 1675 | |
| 1676 | err = ff_hw_base_get_recon_format(base_ctx, NULL, &recon_format); |
| 1677 | if (err < 0) |
| 1678 | return err; |
| 1679 | |
| 1680 | base_ctx->recon_frames_ref = av_hwframe_ctx_alloc(base_ctx->device_ref); |
| 1681 | if (!base_ctx->recon_frames_ref) |
| 1682 | return AVERROR(ENOMEM); |
| 1683 | |
| 1684 | base_ctx->recon_frames = (AVHWFramesContext *)base_ctx->recon_frames_ref->data; |
| 1685 | hwctx = (AVD3D12VAFramesContext *)base_ctx->recon_frames->hwctx; |
| 1686 | |
| 1687 | base_ctx->recon_frames->format = AV_PIX_FMT_D3D12; |
| 1688 | base_ctx->recon_frames->sw_format = recon_format; |
| 1689 | base_ctx->recon_frames->width = base_ctx->surface_width; |
| 1690 | base_ctx->recon_frames->height = base_ctx->surface_height; |
| 1691 | |
| 1692 | hwctx->resource_flags = D3D12_RESOURCE_FLAG_VIDEO_ENCODE_REFERENCE_ONLY | |
| 1693 | D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; |
| 1694 | if (ctx->is_texture_array) { |
| 1695 | base_ctx->recon_frames->initial_pool_size = MAX_DPB_SIZE + 1; |
| 1696 | hwctx->flags |= AV_D3D12VA_FRAME_FLAG_TEXTURE_ARRAY; |
| 1697 | } |
| 1698 | |
| 1699 | err = av_hwframe_ctx_init(base_ctx->recon_frames_ref); |
| 1700 | if (err < 0) { |
| 1701 | av_log(avctx, AV_LOG_ERROR, "Failed to initialise reconstructed " |
| 1702 | "frame context: %d.\n", err); |
| 1703 | return err; |
| 1704 | } |
| 1705 | |
| 1706 | return 0; |
| 1707 | } |
| 1708 | |
| 1709 | static const FFHWEncodePictureOperation d3d12va_type = { |
| 1710 | .priv_size = sizeof(D3D12VAEncodePicture), |
no test coverage detected