Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Edison Ling via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Edison Ling <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] avcodec/d3d12va_encode: Add H.264 entropy coder parameter support (PR #21424)
Date: Fri, 09 Jan 2026 22:00:31 -0000
Message-ID: <176799603206.25.10889933777532410381@4457048688e7> (raw)

PR #21424 opened by Edison Ling (edisonling)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21424
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21424.patch

add parameter `coder` for users to explicitly select CABAC or CAVLC coding in D3D12 H264 encoding

usage:
`-coder cabac` or `-coder ac` or `-coder 1`
`-coder cavlc` or `-coder vlc` or `-coder 0`
`-coder auto`  or `-coder -1`

sample command line:
```
.\ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v h264_d3d12va -coder cabac -y output.mp4
```


>From 6fe819efd483640aaa843803f3159446e0b3d128 Mon Sep 17 00:00:00 2001
From: "Ling, Edison" <Edison.Ling+amdeng@amd.com>
Date: Fri, 9 Jan 2026 16:49:33 -0500
Subject: [PATCH] avcodec/d3d12va_encode: Add H264 entropy coder parameter
 support

add parameter `coder` for users to explicitly select CABAC or CAVLC coding in D3D12 H264 encoding

usage:
`-coder cabac` or `-coder ac` or `-coder 1`
`-coder cavlc` or `-coder vlc` or `-coder 0`
`-coder auto`  or `-coder -1`

sample command line:
```
.\ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v h264_d3d12va -coder cabac -y output.mp4
```
---
 libavcodec/d3d12va_encode_h264.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/libavcodec/d3d12va_encode_h264.c b/libavcodec/d3d12va_encode_h264.c
index bcf5a326e5..8ac26c34f8 100644
--- a/libavcodec/d3d12va_encode_h264.c
+++ b/libavcodec/d3d12va_encode_h264.c
@@ -44,6 +44,7 @@ typedef struct D3D12VAEncodeH264Context {
     int qp;
     int profile;
     int level;
+    int coder;
     int idr_pic_id;
 
     // Writer structures.
@@ -269,9 +270,24 @@ static int d3d12va_encode_h264_get_encoder_caps(AVCodecContext *avctx)
 
     config->ConfigurationFlags = D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_H264_FLAG_NONE;
 
-    if (h264_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAG_CABAC_ENCODING_SUPPORT) {
-        config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_H264_FLAG_ENABLE_CABAC_ENCODING;
-        priv->unit_opts.cabac = 1;
+    // Entropy coder configuration
+    if (priv->coder == 1) {
+        if (h264_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAG_CABAC_ENCODING_SUPPORT) {
+            config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_H264_FLAG_ENABLE_CABAC_ENCODING;
+            priv->unit_opts.cabac = 1;
+        } else {
+            av_log(avctx, AV_LOG_ERROR, "CABAC entropy coding requested but not supported by driver.\n");
+            return AVERROR(ENOTSUP);
+        }
+    } else if (priv->coder == 0) {
+        priv->unit_opts.cabac = 0;
+    } else {
+        if (h264_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264_FLAG_CABAC_ENCODING_SUPPORT) {
+            config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_H264_FLAG_ENABLE_CABAC_ENCODING;
+            priv->unit_opts.cabac = 1;
+        } else {
+            priv->unit_opts.cabac = 0;
+        }
     }
 
     base_ctx->surface_width  = FFALIGN(avctx->width,  16);
@@ -591,6 +607,14 @@ static const AVOption d3d12va_encode_h264_options[] = {
     { LEVEL("6.2",  62) },
 #undef LEVEL
 
+    { "coder", "Entropy coder type",
+      OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, FLAGS, .unit = "coder" },
+        { "auto",   "Driver default",              0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, FLAGS, .unit = "coder" },
+        { "cavlc",  "CAVLC entropy coder",         0, AV_OPT_TYPE_CONST, { .i64 = 0 },  0, 0, FLAGS, .unit = "coder" },
+        { "vlc",    "VLC entropy coder (CAVLC)",   0, AV_OPT_TYPE_CONST, { .i64 = 0 },  0, 0, FLAGS, .unit = "coder" },
+        { "cabac",  "CABAC entropy coder",         0, AV_OPT_TYPE_CONST, { .i64 = 1 },  0, 0, FLAGS, .unit = "coder" },
+        { "ac",     "Arithmetic coder (CABAC)",    0, AV_OPT_TYPE_CONST, { .i64 = 1 },  0, 0, FLAGS, .unit = "coder" },
+
     { NULL },
 };
 
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2026-01-09 22:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=176799603206.25.10889933777532410381@4457048688e7 \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git