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

Git pushed a commit to branch master
in repository ffmpeg.

commit 1eb47126215761abf89ff9db8fd9164bd596d206
Author:     Diego de Souza <[email protected]>
AuthorDate: Sat Mar 14 01:38:17 2026 +0100
Commit:     Timo Rothenpieler <[email protected]>
CommitDate: Tue Jul 14 19:45:02 2026 +0000

    fftools/ffmpeg_dec: improve hwaccel format negotiation for CUARRAY
    
    Adjust get_format() to prefer the exact hwaccel_output_format requested
    by the user when multiple hardware formats are available (e.g. both
    AV_PIX_FMT_CUDA and AV_PIX_FMT_CUARRAY). Previously, the loop would
    break on the first matching device type, ignoring the user's preferred
    output format.
    
    When the preferred format is not available, the code now falls back
    gracefully and emits a warning.
    
    Signed-off-by: Diego de Souza <[email protected]>
---
 fftools/ffmpeg_dec.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 1b37d39e6d..1498afa880 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -1323,6 +1323,8 @@ static enum AVPixelFormat get_format(AVCodecContext *s, 
const enum AVPixelFormat
         return AV_PIX_FMT_NONE;
     }
 
+    dp->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
+
     for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
         const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p);
         const AVCodecHWConfig  *config = NULL;
@@ -1345,10 +1347,32 @@ static enum AVPixelFormat get_format(AVCodecContext *s, 
const enum AVPixelFormat
         }
         if (config && config->device_type == dp->hwaccel_device_type) {
             dp->hwaccel_pix_fmt = *p;
-            break;
+            /* Stop at the first matching hardware format unless the user
+             * explicitly requested a different *hardware* output format
+             * (e.g. CUARRAY vs CUDA, which share a device type) - in that
+             * case keep scanning for the exact match. A software
+             * hwaccel_output_format requests a download and imposes no such
+             * preference, so it must not switch us off the default (first)
+             * hardware format. */
+            if (dp->hwaccel_output_format == AV_PIX_FMT_NONE ||
+                dp->hwaccel_output_format == *p ||
+                !(av_pix_fmt_desc_get(dp->hwaccel_output_format)->flags & 
AV_PIX_FMT_FLAG_HWACCEL))
+                break;
         }
     }
 
+    if (dp->hwaccel_pix_fmt != AV_PIX_FMT_NONE) {
+        if (dp->hwaccel_output_format != AV_PIX_FMT_NONE &&
+            dp->hwaccel_output_format != dp->hwaccel_pix_fmt &&
+            (av_pix_fmt_desc_get(dp->hwaccel_output_format)->flags & 
AV_PIX_FMT_FLAG_HWACCEL))
+            av_log(dp, AV_LOG_WARNING,
+                   "Requested hwaccel output format '%s' not available, "
+                   "falling back to '%s'\n",
+                   av_get_pix_fmt_name(dp->hwaccel_output_format),
+                   av_get_pix_fmt_name(dp->hwaccel_pix_fmt));
+        return dp->hwaccel_pix_fmt;
+    }
+
     return *p;
 }
 

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

Reply via email to