| 1373 | } |
| 1374 | |
| 1375 | static int d3d12va_encode_init_intra_refresh(AVCodecContext *avctx) |
| 1376 | { |
| 1377 | FFHWBaseEncodeContext *base_ctx = avctx->priv_data; |
| 1378 | D3D12VAEncodeContext *ctx = avctx->priv_data; |
| 1379 | |
| 1380 | if (ctx->intra_refresh.Mode == D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_NONE) |
| 1381 | return 0; |
| 1382 | |
| 1383 | // Check for SDK API availability |
| 1384 | #if CONFIG_D3D12_INTRA_REFRESH |
| 1385 | HRESULT hr; |
| 1386 | D3D12_VIDEO_ENCODER_LEVEL_SETTING level = { 0 }; |
| 1387 | D3D12_VIDEO_ENCODER_LEVELS_H264 h264_level = { 0 }; |
| 1388 | D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC hevc_level = { 0 }; |
| 1389 | #if CONFIG_AV1_D3D12VA_ENCODER |
| 1390 | D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS av1_level = { 0 }; |
| 1391 | #endif |
| 1392 | |
| 1393 | switch (ctx->codec->d3d12_codec) { |
| 1394 | case D3D12_VIDEO_ENCODER_CODEC_H264: |
| 1395 | level.DataSize = sizeof(D3D12_VIDEO_ENCODER_LEVELS_H264); |
| 1396 | level.pH264LevelSetting = &h264_level; |
| 1397 | break; |
| 1398 | case D3D12_VIDEO_ENCODER_CODEC_HEVC: |
| 1399 | level.DataSize = sizeof(D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC); |
| 1400 | level.pHEVCLevelSetting = &hevc_level; |
| 1401 | break; |
| 1402 | #if CONFIG_AV1_D3D12VA_ENCODER |
| 1403 | case D3D12_VIDEO_ENCODER_CODEC_AV1: |
| 1404 | level.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS); |
| 1405 | level.pAV1LevelSetting = &av1_level; |
| 1406 | break; |
| 1407 | #endif |
| 1408 | default: |
| 1409 | av_assert0(0); |
| 1410 | } |
| 1411 | |
| 1412 | D3D12_FEATURE_DATA_VIDEO_ENCODER_INTRA_REFRESH_MODE intra_refresh_support = { |
| 1413 | .NodeIndex = 0, |
| 1414 | .Codec = ctx->codec->d3d12_codec, |
| 1415 | .Profile = ctx->profile->d3d12_profile, |
| 1416 | .Level = level, |
| 1417 | .IntraRefreshMode = ctx->intra_refresh.Mode, |
| 1418 | }; |
| 1419 | |
| 1420 | hr = ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, |
| 1421 | D3D12_FEATURE_VIDEO_ENCODER_INTRA_REFRESH_MODE, |
| 1422 | &intra_refresh_support, sizeof(intra_refresh_support)); |
| 1423 | |
| 1424 | if (FAILED(hr) || !intra_refresh_support.IsSupported) { |
| 1425 | av_log(avctx, AV_LOG_ERROR, "Requested intra refresh mode not supported by driver.\n"); |
| 1426 | return AVERROR(ENOTSUP); |
| 1427 | } |
| 1428 | #else |
| 1429 | // Older SDK - validation will occur in init_sequence_params via D3D12_FEATURE_VIDEO_ENCODER_SUPPORT |
| 1430 | av_log(avctx, AV_LOG_VERBOSE, "Intra refresh explicit check not available in this SDK.\n" |
| 1431 | "Support will be validated during encoder initialization.\n"); |
| 1432 | #endif |
no test coverage detected