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 a93cb79da2 avcodec/d3d12va_encode: Bug fix and refactor for motion 
estimation precision initialization
a93cb79da2 is described below

commit a93cb79da2f1bcff2170ad755e3073f5f12d2064
Author:     Ling, Edison <[email protected]>
AuthorDate: Fri Jan 16 13:36:59 2026 -0500
Commit:     Tong Wu <[email protected]>
CommitDate: Fri Jan 23 13:25:55 2026 +0000

    avcodec/d3d12va_encode: Bug fix and refactor for motion estimation 
precision initialization
    
    Move motion estimation precision check from standalone
    `d3d12va_encode_init_motion_estimation_precision()` function into each
    codec's init_sequence_params() to reuse existing feature support
    queries.
    
     - fixes AV1 using wrong support structure (SUPPORT instead of SUPPORT1)
     - eliminates duplicate setup code
     - removes redundant CheckFeatureSupport API call
     - no intended functional changes other than bug fix
---
 libavcodec/d3d12va_encode.c      | 89 ----------------------------------------
 libavcodec/d3d12va_encode_av1.c  | 11 +++++
 libavcodec/d3d12va_encode_h264.c | 11 +++++
 libavcodec/d3d12va_encode_hevc.c | 11 +++++
 4 files changed, 33 insertions(+), 89 deletions(-)

diff --git a/libavcodec/d3d12va_encode.c b/libavcodec/d3d12va_encode.c
index 1fba31117d..14efe633ae 100644
--- a/libavcodec/d3d12va_encode.c
+++ b/libavcodec/d3d12va_encode.c
@@ -1259,91 +1259,6 @@ rc_mode_found:
     return 0;
 }
 
-static int d3d12va_encode_init_motion_estimation_precision(AVCodecContext 
*avctx)
-{
-    FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
-    D3D12VAEncodeContext       *ctx = avctx->priv_data;
-    AVD3D12VAFramesContext   *hwctx = base_ctx->input_frames->hwctx;
-    HRESULT hr;
-
-    if (ctx->me_precision == 
D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE_MAXIMUM)
-        return 0;
-
-    D3D12_VIDEO_ENCODER_PROFILE_DESC      profile = { 0 };
-    D3D12_VIDEO_ENCODER_PROFILE_H264 h264_profile = 
D3D12_VIDEO_ENCODER_PROFILE_H264_MAIN;
-    D3D12_VIDEO_ENCODER_PROFILE_HEVC hevc_profile = 
D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN;
-#if CONFIG_AV1_D3D12VA_ENCODER
-    D3D12_VIDEO_ENCODER_AV1_PROFILE   av1_profile = 
D3D12_VIDEO_ENCODER_AV1_PROFILE_MAIN;
-#endif
-
-    D3D12_VIDEO_ENCODER_LEVEL_SETTING                    level = { 0 };
-    D3D12_VIDEO_ENCODER_LEVELS_H264                 h264_level = { 0 };
-    D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC hevc_level = { 0 };
-#if CONFIG_AV1_D3D12VA_ENCODER
-    D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS   av1_level = { 0 };
-#endif
-
-    switch (ctx->codec->d3d12_codec) {
-        case D3D12_VIDEO_ENCODER_CODEC_H264:
-            profile.DataSize        = sizeof(D3D12_VIDEO_ENCODER_PROFILE_H264);
-            profile.pH264Profile    = &h264_profile;
-            level.DataSize          = sizeof(D3D12_VIDEO_ENCODER_LEVELS_H264);
-            level.pH264LevelSetting = &h264_level;
-            break;
-        case D3D12_VIDEO_ENCODER_CODEC_HEVC:
-            profile.DataSize        = sizeof(D3D12_VIDEO_ENCODER_PROFILE_HEVC);
-            profile.pHEVCProfile    = &hevc_profile;
-            level.DataSize          = 
sizeof(D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC);
-            level.pHEVCLevelSetting = &hevc_level;
-            break;
-#if CONFIG_AV1_D3D12VA_ENCODER
-        case D3D12_VIDEO_ENCODER_CODEC_AV1:
-            profile.DataSize        = sizeof(D3D12_VIDEO_ENCODER_AV1_PROFILE);
-            profile.pAV1Profile     = &av1_profile;
-            level.DataSize          = 
sizeof(D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS);
-            level.pAV1LevelSetting  = &av1_level;
-            break;
-#endif
-        default:
-            av_assert0(0);
-    }
-
-    D3D12_FEATURE_DATA_VIDEO_ENCODER_SUPPORT support = {
-        .NodeIndex                   = 0,
-        .Codec                       = ctx->codec->d3d12_codec,
-        .InputFormat                 = hwctx->format,
-        .RateControl                 = ctx->rc,
-        .IntraRefresh                = 
D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_NONE,
-        .SubregionFrameEncoding      = 
D3D12_VIDEO_ENCODER_FRAME_SUBREGION_LAYOUT_MODE_FULL_FRAME,
-        .ResolutionsListCount        = 1,
-        .pResolutionList             = &ctx->resolution,
-        .CodecGopSequence            = ctx->gop,
-        .MaxReferenceFramesInDPB     = MAX_DPB_SIZE - 1,
-        .CodecConfiguration          = ctx->codec_conf,
-        .SuggestedProfile            = profile,
-        .SuggestedLevel              = level,
-        .pResolutionDependentSupport = &ctx->res_limits,
-    };
-
-    hr = ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, 
D3D12_FEATURE_VIDEO_ENCODER_SUPPORT,
-                                                &support, sizeof(support));
-    if (FAILED(hr)) {
-        av_log(avctx, AV_LOG_ERROR, "Failed to check encoder support for 
motion estimation.\n");
-        return AVERROR(EINVAL);
-    }
-
-    if (!(support.SupportFlags & 
D3D12_VIDEO_ENCODER_SUPPORT_FLAG_MOTION_ESTIMATION_PRECISION_MODE_LIMIT_AVAILABLE))
 {
-        av_log(avctx, AV_LOG_ERROR, "Hardware does not support motion 
estimation "
-            "precision mode limits.\n");
-        return AVERROR(ENOTSUP);
-    }
-
-    av_log(avctx, AV_LOG_VERBOSE, "Hardware supports motion estimation "
-        "precision mode limits.\n");
-
-    return 0;
-}
-
 static int d3d12va_encode_init_gop_structure(AVCodecContext *avctx)
 {
     FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
@@ -1882,10 +1797,6 @@ int ff_d3d12va_encode_init(AVCodecContext *avctx)
             goto fail;
     }
 
-    err = d3d12va_encode_init_motion_estimation_precision(avctx);
-    if (err < 0)
-        goto fail;
-
     if (ctx->codec->init_sequence_params) {
         err = ctx->codec->init_sequence_params(avctx);
         if (err < 0) {
diff --git a/libavcodec/d3d12va_encode_av1.c b/libavcodec/d3d12va_encode_av1.c
index 5ead741141..912f411547 100644
--- a/libavcodec/d3d12va_encode_av1.c
+++ b/libavcodec/d3d12va_encode_av1.c
@@ -602,6 +602,17 @@ static int 
d3d12va_encode_av1_init_sequence_params(AVCodecContext *avctx)
         av_log(avctx, AV_LOG_DEBUG, "ROI encoding not supported by hardware 
for current rate control mode \n");
     }
 
+    // Check motion estimation precision mode support
+    if (ctx->me_precision != 
D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE_MAXIMUM) {
+        if (!(support.SupportFlags & 
D3D12_VIDEO_ENCODER_SUPPORT_FLAG_MOTION_ESTIMATION_PRECISION_MODE_LIMIT_AVAILABLE))
 {
+            av_log(avctx, AV_LOG_ERROR, "Hardware does not support motion 
estimation "
+                "precision mode limits.\n");
+            return AVERROR(ENOTSUP);
+        }
+        av_log(avctx, AV_LOG_VERBOSE, "Hardware supports motion estimation "
+            "precision mode limits.\n");
+    }
+
     memset(seqheader_obu, 0, sizeof(*seqheader_obu));
     seq->seq_profile = profile;
     seq->seq_level_idx[0] = level.Level;
diff --git a/libavcodec/d3d12va_encode_h264.c b/libavcodec/d3d12va_encode_h264.c
index a40db145fc..eae97e1f23 100644
--- a/libavcodec/d3d12va_encode_h264.c
+++ b/libavcodec/d3d12va_encode_h264.c
@@ -224,6 +224,17 @@ static int 
d3d12va_encode_h264_init_sequence_params(AVCodecContext *avctx)
         av_log(avctx, AV_LOG_DEBUG, "ROI encoding not supported by hardware 
for current rate control mode \n");
     }
 
+    // Check motion estimation precision mode support
+    if (ctx->me_precision != 
D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE_MAXIMUM) {
+        if (!(support.SupportFlags & 
D3D12_VIDEO_ENCODER_SUPPORT_FLAG_MOTION_ESTIMATION_PRECISION_MODE_LIMIT_AVAILABLE))
 {
+            av_log(avctx, AV_LOG_ERROR, "Hardware does not support motion 
estimation "
+                "precision mode limits.\n");
+            return AVERROR(ENOTSUP);
+        }
+        av_log(avctx, AV_LOG_VERBOSE, "Hardware supports motion estimation "
+            "precision mode limits.\n");
+    }
+
     desc = av_pix_fmt_desc_get(base_ctx->input_frames->sw_format);
     av_assert0(desc);
 
diff --git a/libavcodec/d3d12va_encode_hevc.c b/libavcodec/d3d12va_encode_hevc.c
index 921324b5d2..45038bbad6 100644
--- a/libavcodec/d3d12va_encode_hevc.c
+++ b/libavcodec/d3d12va_encode_hevc.c
@@ -295,6 +295,17 @@ static int 
d3d12va_encode_hevc_init_sequence_params(AVCodecContext *avctx)
         av_log(avctx, AV_LOG_DEBUG, "ROI encoding not supported by hardware 
for current rate control mode \n");
     }
 
+    // Check motion estimation precision mode support
+    if (ctx->me_precision != 
D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE_MAXIMUM) {
+        if (!(support.SupportFlags & 
D3D12_VIDEO_ENCODER_SUPPORT_FLAG_MOTION_ESTIMATION_PRECISION_MODE_LIMIT_AVAILABLE))
 {
+            av_log(avctx, AV_LOG_ERROR, "Hardware does not support motion 
estimation "
+                "precision mode limits.\n");
+            return AVERROR(ENOTSUP);
+        }
+        av_log(avctx, AV_LOG_VERBOSE, "Hardware supports motion estimation "
+            "precision mode limits.\n");
+    }
+
     desc = av_pix_fmt_desc_get(base_ctx->input_frames->sw_format);
     av_assert0(desc);
 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to