The branch, master has been updated
       via  9893d66addd19401830a9187525194354882fee8 (commit)
      from  2296a9c1bc0636c9ccf5217a49d87d29638ea65a (commit)


- Log -----------------------------------------------------------------
commit 9893d66addd19401830a9187525194354882fee8
Author:     Tong Wu <[email protected]>
AuthorDate: Tue Aug 19 22:42:25 2025 +0800
Commit:     Derek Buitenhuis <[email protected]>
CommitDate: Sun Aug 31 10:46:11 2025 +0000

    avcodec/d3d12va_encode: add max_frame_size option
    
    Add the max_frame_size option to support setting max frame size in
    bytes. Max frame size is the maximum cap in the bitrate algorithm per
    each encoded frame.
    
    Signed-off-by: Tong Wu <[email protected]>

diff --git a/libavcodec/d3d12va_encode.c b/libavcodec/d3d12va_encode.c
index 1ecaee3b6d..008b0ddc2a 100644
--- a/libavcodec/d3d12va_encode.c
+++ b/libavcodec/d3d12va_encode.c
@@ -992,6 +992,11 @@ rc_mode_found:
                 ctx->rc.Flags |= 
D3D12_VIDEO_ENCODER_RATE_CONTROL_FLAG_ENABLE_QP_RANGE;
             }
 
+            if (ctx->max_frame_size > 0) {
+                cbr_ctl->MaxFrameBitSize = ctx->max_frame_size * 8;
+                ctx->rc.Flags |= 
D3D12_VIDEO_ENCODER_RATE_CONTROL_FLAG_ENABLE_MAX_FRAME_SIZE;
+            }
+
             ctx->rc.ConfigParams.pConfiguration_CBR = cbr_ctl;
             break;
         }
@@ -1015,6 +1020,11 @@ rc_mode_found:
                 ctx->rc.Flags |= 
D3D12_VIDEO_ENCODER_RATE_CONTROL_FLAG_ENABLE_QP_RANGE;
             }
 
+            if (ctx->max_frame_size > 0) {
+                vbr_ctl->MaxFrameBitSize = ctx->max_frame_size * 8;
+                ctx->rc.Flags |= 
D3D12_VIDEO_ENCODER_RATE_CONTROL_FLAG_ENABLE_MAX_FRAME_SIZE;
+            }
+
             ctx->rc.ConfigParams.pConfiguration_VBR = vbr_ctl;
             break;
         }
@@ -1036,6 +1046,11 @@ rc_mode_found:
                 ctx->rc.Flags |= 
D3D12_VIDEO_ENCODER_RATE_CONTROL_FLAG_ENABLE_QP_RANGE;
             }
 
+            if (ctx->max_frame_size > 0) {
+                qvbr_ctl->MaxFrameBitSize = ctx->max_frame_size * 8;
+                ctx->rc.Flags |= 
D3D12_VIDEO_ENCODER_RATE_CONTROL_FLAG_ENABLE_MAX_FRAME_SIZE;
+            }
+
             ctx->rc.ConfigParams.pConfiguration_QVBR = qvbr_ctl;
             break;
         }
diff --git a/libavcodec/d3d12va_encode.h b/libavcodec/d3d12va_encode.h
index 3b0b8153d5..8af5554626 100644
--- a/libavcodec/d3d12va_encode.h
+++ b/libavcodec/d3d12va_encode.h
@@ -149,6 +149,11 @@ typedef struct D3D12VAEncodeContext {
      */
     const struct D3D12VAEncodeType *codec;
 
+    /**
+     * Max frame size
+     */
+    int max_frame_size;
+
     /**
      * Explicitly set RC mode (otherwise attempt to pick from
      * available modes).
@@ -317,6 +322,12 @@ int ff_d3d12va_encode_receive_packet(AVCodecContext 
*avctx, AVPacket *pkt);
 int ff_d3d12va_encode_init(AVCodecContext *avctx);
 int ff_d3d12va_encode_close(AVCodecContext *avctx);
 
+#define D3D12VA_ENCODE_COMMON_OPTIONS \
+    { "max_frame_size", \
+      "Maximum frame size (in bytes)",\
+      OFFSET(common.max_frame_size), AV_OPT_TYPE_INT, \
+      { .i64 = 0 }, 0, INT_MAX / 8, FLAGS }
+
 #define D3D12VA_ENCODE_RC_MODE(name, desc) \
     { #name, desc, 0, AV_OPT_TYPE_CONST, { .i64 = RC_MODE_ ## name }, \
       0, 0, FLAGS, .unit = "rc_mode" }
diff --git a/libavcodec/d3d12va_encode_hevc.c b/libavcodec/d3d12va_encode_hevc.c
index 0aa1a1d3a4..4f4dda1f8f 100644
--- a/libavcodec/d3d12va_encode_hevc.c
+++ b/libavcodec/d3d12va_encode_hevc.c
@@ -705,6 +705,7 @@ static int d3d12va_encode_hevc_close(AVCodecContext *avctx)
 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
 static const AVOption d3d12va_encode_hevc_options[] = {
     HW_BASE_ENCODE_COMMON_OPTIONS,
+    D3D12VA_ENCODE_COMMON_OPTIONS,
     D3D12VA_ENCODE_RC_OPTIONS,
 
     { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",

-----------------------------------------------------------------------

Summary of changes:
 libavcodec/d3d12va_encode.c      | 15 +++++++++++++++
 libavcodec/d3d12va_encode.h      | 11 +++++++++++
 libavcodec/d3d12va_encode_hevc.c |  1 +
 3 files changed, 27 insertions(+)


hooks/post-receive
-- 

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

Reply via email to