PR #22926 opened by strrs
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22926
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22926.patch

Upstream master already includes the High10 plumbing for H.264 NVENC
(AVOption const `high10`, `NV_ENC_H264_PROFILE_HIGH_10` enum, profile-
GUID dispatch in `nvenc_setup_encoder`) under the
`NVENC_HAVE_H264_10BIT_SUPPORT` build flag introduced for SDK 13.0.

However, `nvenc_check_capabilities()` still gates 10-bit encoding behind
`NV_ENC_CAPS_SUPPORT_10BIT_ENCODE` against the codec GUID, and on
Blackwell silicon (RTX 5000-series, sm_120) that cap returns 0 for
`H264_GUID` even though the hardware supports the High10 profile. The
encode therefore never reaches the new High10 dispatch path and the
user sees "No capable devices found".

This patch defers the remaining cap checks for H.264 10-bit to encode-
session creation, completing the SDK 13.0 H.264 High10 path that was
introduced upstream.

Tested on RTX 5090, driver 596.21, NVENC API 13.0:
- Without patch: "No capable devices found".
- With patch: encode succeeds at ~387 fps for 1080p.
- ffprobe confirms profile=High 10, pix_fmt=yuv420p10le,
  bits_per_raw_sample=10.

HEVC 10-bit, AV1 10-bit, and H.264 8-bit paths are unchanged.


>From f326aa72f0f9894a148e5cb0328c1bcc5e328e17 Mon Sep 17 00:00:00 2001
From: Semih Baskan <[email protected]>
Date: Sun, 26 Apr 2026 12:00:00 +0000
Subject: [PATCH] avcodec/nvenc: allow H.264 10-bit (High10) on Blackwell GPUs

NVIDIA's 9th-generation NVENC silicon (Blackwell, RTX 5000-series,
sm_120) is the first generation with hardware H.264 High10 (10-bit)
encoding, documented in the NVIDIA Video Codec SDK 13.0 Application
Note "NVENC H264 Hardware Capabilities" matrix (High10 row: N for every
prior generation through Jetson Thor; Y for Blackwell).

For HEVC and AV1, 10-bit support is a codec-level capability (Main10 /
profile=2), so nvenc_check_cap(NV_ENC_CAPS_SUPPORT_10BIT_ENCODE) against
the codec GUID returns 1 on capable hardware and the existing gate at
nvenc_check_capabilities() works correctly.

For H.264, 10-bit is a *profile*-level capability (High10 profile,
NV_ENC_H264_PROFILE_HIGH_10_GUID).  Empirical testing on RTX 5090 with
NVIDIA driver 596.21 (NVENC API 13.0) shows two compounding issues:

  1. NV_ENC_CAPS_SUPPORT_10BIT_ENCODE queried against H264_GUID returns
     0 even on Blackwell silicon that supports High10.

  2. Subsequent NV_ENC_CAPS_* queries (CABAC, b-frame ref mode, etc.)
     can also return 0 because nvenc_check_capabilities() runs before
     init_encode_params.encodeGUID is fully set, producing spurious
     ENOSYS rejections for legitimate H.264 10-bit configurations.

Both surface to the user as "No capable devices found", even though the
hardware will happily encode if the session is allowed to proceed.

Defer the remaining cap checks for H.264 10-bit to encode-session
creation.  The codec-support GUID enumeration check (nvenc_check_codec_
support) is preserved.  HEVC and AV1 10-bit paths are unchanged: their
cap queries are accurate and continue to gate correctly.

Behavioral change is bounded:

  - Blackwell + H.264 10-bit: previously failed at the cap probe with
    "10 bit encode not supported" / "No capable devices found"; now
    encodes successfully (silicon supports it).

  - Pre-Blackwell + H.264 10-bit: failure point shifts from the cap
    probe to nvEncInitializeEncoder.  End state for the user is the
    same (encode fails, no output produced); only the error message
    changes.

  - All other codec/bit-depth combinations: unchanged.

Tested:
- RTX 5090 (Blackwell, sm_120), driver 596.21, NVENC API 13.0:
  encode succeeds at ~387 fps for 1080p; ffprobe reports
  profile=High 10, pix_fmt=yuv420p10le, bits_per_raw_sample=10.
- HEVC 10-bit on the same hardware: unchanged.
- AV1 10-bit on the same hardware: unchanged.
- H.264 8-bit on the same hardware: unchanged.

Signed-off-by: Semih Baskan <[email protected]>
---
 libavcodec/nvenc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 392230526d..34711946db 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -504,6 +504,13 @@ static int nvenc_check_capabilities(AVCodecContext *avctx)
         return ret;
     }
 
+    if (avctx->codec_id == AV_CODEC_ID_H264 && IS_10BIT(ctx->data_pix_fmt)) {
+        av_log(avctx, AV_LOG_VERBOSE,
+               "H.264 10-bit: deferring remaining capability checks to "
+               "encode-session creation\n");
+        return 0;
+    }
+
     ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_YUV444_ENCODE);
     if (IS_YUV444(ctx->data_pix_fmt) && ret <= 0) {
         av_log(avctx, AV_LOG_WARNING, "YUV444P not supported\n");
-- 
2.52.0

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

Reply via email to