This is an automated email from the git hooks/post-receive script.
Git pushed a commit to branch master
in repository ffmpeg.
The following commit(s) were added to refs/heads/master by this push:
new 3773831c21 avcodec/d3d12va_encode: Add H264/HEVC constrained intra
prediction parameter support
3773831c21 is described below
commit 3773831c211ecef2d35098ac5d2c913800f2dbc7
Author: Ling, Edison <[email protected]>
AuthorDate: Fri Jun 5 10:04:23 2026 -0400
Commit: Tong Wu <[email protected]>
CommitDate: Sat Jun 13 11:21:14 2026 +0000
avcodec/d3d12va_encode: Add H264/HEVC constrained intra prediction
parameter support
Add parameter `constrained_intra_pred` for users to enable constrained
intra prediction (as opposed to default unconstrained) in D3D12 H264 and HEVC
encoding.
Usage:
false (default): `-constrained_intra_pred false` or
`-constrained_intra_pred 0`
true: `-constrained_intra_pred true` or
`-constrained_intra_pred 1`
Sample command line:
```
ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v
h264_d3d12va -constrained_intra_pred true -y output.mp4
ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v
hevc_d3d12va -constrained_intra_pred true -y output.mp4
```
---
libavcodec/d3d12va_encode_h264.c | 15 +++++++++++++++
libavcodec/d3d12va_encode_hevc.c | 16 ++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/libavcodec/d3d12va_encode_h264.c b/libavcodec/d3d12va_encode_h264.c
index 47c6953d1b..55ed249064 100644
--- a/libavcodec/d3d12va_encode_h264.c
+++ b/libavcodec/d3d12va_encode_h264.c
@@ -45,6 +45,7 @@ typedef struct D3D12VAEncodeH264Context {
int profile;
int level;
int deblock;
+ int constrained_intra_pred;
int idr_pic_id;
// Writer structures.
@@ -258,6 +259,7 @@ static int
d3d12va_encode_h264_init_sequence_params(AVCodecContext *avctx)
sps->log2_max_frame_num_minus4 = FFMAX(av_ceil_log2(base_ctx->gop_size) -
4, 0);
ctx->gop.pH264GroupOfPictures->log2_max_frame_num_minus4 =
sps->log2_max_frame_num_minus4;
pps->deblocking_filter_control_present_flag = 1;
+ pps->constrained_intra_pred_flag = priv->constrained_intra_pred;
return 0;
}
@@ -321,6 +323,16 @@ static int
d3d12va_encode_h264_get_encoder_caps(AVCodecContext *avctx)
}
}
+ // Constrained intra prediction configuration
+ if (priv->constrained_intra_pred) {
+ if (h264_caps.SupportFlags &
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAG_CONSTRAINED_INTRAPREDICTION_SUPPORT)
{
+ config->ConfigurationFlags |=
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_H264_FLAG_USE_CONSTRAINED_INTRAPREDICTION;
+ } else {
+ av_log(avctx, AV_LOG_WARNING, "Constrained intra prediction is not
supported by the driver, disabling.\n");
+ priv->constrained_intra_pred = 0;
+ }
+ }
+
base_ctx->surface_width = FFALIGN(avctx->width, 16);
base_ctx->surface_height = FFALIGN(avctx->height, 16);
@@ -653,6 +665,9 @@ static const AVOption d3d12va_encode_h264_options[] = {
{ "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX,
FLAGS, "coder" },
{ "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX,
FLAGS, "coder" },
+ { "constrained_intra_pred", "Constrained intra prediction
(constrained_intra_pred_flag)",
+ OFFSET(constrained_intra_pred), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
FLAGS },
+
{ NULL },
};
diff --git a/libavcodec/d3d12va_encode_hevc.c b/libavcodec/d3d12va_encode_hevc.c
index 8cae7a8b66..d2a862ac8b 100644
--- a/libavcodec/d3d12va_encode_hevc.c
+++ b/libavcodec/d3d12va_encode_hevc.c
@@ -46,6 +46,7 @@ typedef struct D3D12VAEncodeHEVCContext {
int qp;
int profile;
int level;
+ int constrained_intra_pred;
// Writer structures.
FFHWBaseEncodeH265 units;
@@ -376,6 +377,7 @@ static int
d3d12va_encode_hevc_init_sequence_params(AVCodecContext *avctx)
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_DISABLE_LOOP_FILTER_ACROSS_SLICES);
pps->deblocking_filter_control_present_flag = 1;
+ pps->constrained_intra_pred_flag = priv->constrained_intra_pred;
return 0;
}
@@ -387,6 +389,7 @@ static int
d3d12va_encode_hevc_get_encoder_caps(AVCodecContext *avctx)
uint8_t min_cu_size, max_cu_size;
FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
D3D12VAEncodeContext *ctx = avctx->priv_data;
+ D3D12VAEncodeHEVCContext *priv = avctx->priv_data;
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC *config;
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC hevc_caps;
@@ -439,6 +442,16 @@ static int
d3d12va_encode_hevc_get_encoder_caps(AVCodecContext *avctx)
if (hevc_caps.SupportFlags &
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_TRANSFORM_SKIP_SUPPORT)
config->ConfigurationFlags |=
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_TRANSFORM_SKIPPING;
+ // Constrained intra prediction configuration
+ if (priv->constrained_intra_pred) {
+ if (hevc_caps.SupportFlags &
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_CONSTRAINED_INTRAPREDICTION_SUPPORT)
{
+ config->ConfigurationFlags |=
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_USE_CONSTRAINED_INTRAPREDICTION;
+ } else {
+ av_log(avctx, AV_LOG_WARNING, "Constrained intra prediction is not
supported by the driver, disabling.\n");
+ priv->constrained_intra_pred = 0;
+ }
+ }
+
if (hevc_caps.SupportFlags &
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_P_FRAMES_IMPLEMENTED_AS_LOW_DELAY_B_FRAMES)
ctx->bi_not_empty = 1;
@@ -780,6 +793,9 @@ static const AVOption d3d12va_encode_hevc_options[] = {
{ LEVEL("6.2", 186) },
#undef LEVEL
+ { "constrained_intra_pred", "Constrained intra prediction
(constrained_intra_pred_flag)",
+ OFFSET(constrained_intra_pred), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
FLAGS },
+
{ NULL },
};
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]