This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 7ac3d83e7a5113fb217735b76d0843e8942c2383
Author:     Diego de Souza <[email protected]>
AuthorDate: Tue Apr 21 17:34:49 2026 +0200
Commit:     Timo Rothenpieler <[email protected]>
CommitDate: Mon May 18 20:47:15 2026 +0000

    avcodec/nvdec: fix dimension rounding for monochrome/444 formats
    
    frames_ctx->width/height were unconditionally rounded to even, causing
    odd-dimension monochrome/444 clips to be reported with incorrect
    surface pool dimensions. Round only for 4:2:0 and 4:2:2; for
    monochrome/444 use avctx->coded_width/coded_height unchanged,
    matching the dimensions set by the software codec layer.
    
    Patch by: Aniket Dhok <[email protected]>
    Signed-off-by: Diego de Souza <[email protected]>
---
 libavcodec/nvdec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 911fc336c7..e64ee7a9d6 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -732,8 +732,18 @@ int ff_nvdec_frame_params(AVCodecContext *avctx,
     chroma_444 = supports_444 && cuvid_chroma_format == 
cudaVideoChromaFormat_444;
 
     frames_ctx->format            = AV_PIX_FMT_CUDA;
-    frames_ctx->width             = (avctx->coded_width + 1) & ~1;
-    frames_ctx->height            = (avctx->coded_height + 1) & ~1;
+    // NVDEC target dimensions must be even-aligned for internal surface 
allocation.
+    // For chroma-subsampled formats (420/422), the output dimensions must 
also be
+    // even. For monochrome/444, keep the original output dimensions and only
+    // even-align the NVDEC target — the frame copy will crop to avctx 
dimensions.
+    if (cuvid_chroma_format == cudaVideoChromaFormat_420 ||
+        cuvid_chroma_format == cudaVideoChromaFormat_422) {
+        frames_ctx->width         = (avctx->coded_width  + 1) & ~1;
+        frames_ctx->height        = (avctx->coded_height + 1) & ~1;
+    } else {
+        frames_ctx->width         = avctx->coded_width;
+        frames_ctx->height        = avctx->coded_height;
+    }
     /*
      * We add two extra frames to the pool to account for deinterlacing filters
      * holding onto their frames.

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

Reply via email to