| 1724 | } |
| 1725 | |
| 1726 | int ff_d3d12va_encode_init(AVCodecContext *avctx) |
| 1727 | { |
| 1728 | FFHWBaseEncodeContext *base_ctx = avctx->priv_data; |
| 1729 | D3D12VAEncodeContext *ctx = avctx->priv_data; |
| 1730 | D3D12_FEATURE_DATA_VIDEO_FEATURE_AREA_SUPPORT support = { 0 }; |
| 1731 | D3D12_FEATURE_DATA_FORMAT_INFO format_info = { 0 }; |
| 1732 | int err; |
| 1733 | HRESULT hr; |
| 1734 | |
| 1735 | err = ff_hw_base_encode_init(avctx, base_ctx); |
| 1736 | if (err < 0) |
| 1737 | goto fail; |
| 1738 | |
| 1739 | base_ctx->op = &d3d12va_type; |
| 1740 | |
| 1741 | ctx->hwctx = base_ctx->device->hwctx; |
| 1742 | |
| 1743 | ctx->resolution.Width = base_ctx->input_frames->width; |
| 1744 | ctx->resolution.Height = base_ctx->input_frames->height; |
| 1745 | |
| 1746 | hr = ID3D12Device_QueryInterface(ctx->hwctx->device, &IID_ID3D12Device3, (void **)&ctx->device3); |
| 1747 | if (FAILED(hr)) { |
| 1748 | av_log(avctx, AV_LOG_ERROR, "ID3D12Device3 interface is not supported.\n"); |
| 1749 | err = AVERROR_UNKNOWN; |
| 1750 | goto fail; |
| 1751 | } |
| 1752 | |
| 1753 | hr = ID3D12Device3_QueryInterface(ctx->device3, &IID_ID3D12VideoDevice3, (void **)&ctx->video_device3); |
| 1754 | if (FAILED(hr)) { |
| 1755 | av_log(avctx, AV_LOG_ERROR, "ID3D12VideoDevice3 interface is not supported.\n"); |
| 1756 | err = AVERROR_UNKNOWN; |
| 1757 | goto fail; |
| 1758 | } |
| 1759 | |
| 1760 | if (FAILED(ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, D3D12_FEATURE_VIDEO_FEATURE_AREA_SUPPORT, |
| 1761 | &support, sizeof(support))) && !support.VideoEncodeSupport) { |
| 1762 | av_log(avctx, AV_LOG_ERROR, "D3D12 video device has no video encoder support.\n"); |
| 1763 | err = AVERROR(EINVAL); |
| 1764 | goto fail; |
| 1765 | } |
| 1766 | |
| 1767 | format_info.Format = ((AVD3D12VAFramesContext *)base_ctx->input_frames->hwctx)->format; |
| 1768 | if (FAILED(ID3D12VideoDevice_CheckFeatureSupport(ctx->hwctx->device, D3D12_FEATURE_FORMAT_INFO, |
| 1769 | &format_info, sizeof(format_info)))) { |
| 1770 | av_log(avctx, AV_LOG_ERROR, "Failed to query format plane count: %#lx\n", hr); |
| 1771 | err = AVERROR_EXTERNAL; |
| 1772 | goto fail; |
| 1773 | } |
| 1774 | ctx->plane_count = format_info.PlaneCount; |
| 1775 | |
| 1776 | err = d3d12va_encode_set_profile(avctx); |
| 1777 | if (err < 0) |
| 1778 | goto fail; |
| 1779 | |
| 1780 | if (ctx->codec->set_tile) { |
| 1781 | err = ctx->codec->set_tile(avctx); |
| 1782 | if (err < 0) |
| 1783 | goto fail; |
no test coverage detected