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

Git pushed a commit to branch master
in repository ffmpeg.

commit 3befae81f1dc20b615611f1562503747e812f6d5
Author:     Anton Khirnov <[email protected]>
AuthorDate: Mon Jan 5 12:23:55 2026 +0100
Commit:     James Almer <[email protected]>
CommitDate: Fri Mar 27 19:42:08 2026 -0300

    lavc/decode: change sw format selection logic in 
avcodec_default_get_format()
    
    Choose the first non-hwaccel format rather than the last one. This
    matches the logic in ffmpeg CLI and selects YUVA rather than YUV for
    HEVC with alpha.
---
 libavcodec/decode.c | 12 ++++++------
 libavcodec/decode.h |  6 ++++--
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 5de5a84038..4ce05ea820 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -987,7 +987,6 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, 
AVSubtitle *sub,
 enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *avctx,
                                               const enum AVPixelFormat *fmt)
 {
-    const AVPixFmtDescriptor *desc;
     const AVCodecHWConfig *config;
     int i, n;
 
@@ -1014,12 +1013,13 @@ enum AVPixelFormat avcodec_default_get_format(struct 
AVCodecContext *avctx,
     // No device or other setup, so we have to choose from things which
     // don't any other external information.
 
-    // If the last element of the list is a software format, choose it
+    // Choose the first software format
     // (this should be best software format if any exist).
-    for (n = 0; fmt[n] != AV_PIX_FMT_NONE; n++);
-    desc = av_pix_fmt_desc_get(fmt[n - 1]);
-    if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
-        return fmt[n - 1];
+    for (n = 0; fmt[n] != AV_PIX_FMT_NONE; n++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt[n]);
+        if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
+            return fmt[n];
+    }
 
     // Finally, traverse the list in order and choose the first entry
     // with no external dependencies (if there is no hardware configuration
diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index 561dc6a69c..b31ef79166 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -111,8 +111,10 @@ int ff_set_sar(AVCodecContext *avctx, AVRational sar);
  * instead of calling get_format() directly.
  *
  * The list of pixel formats must contain at least one valid entry, and is
- * terminated with AV_PIX_FMT_NONE.  If it is possible to decode to software,
- * the last entry in the list must be the most accurate software format.
+ * terminated with AV_PIX_FMT_NONE. If it is possible to decode to software,
+ * the first entry after the last hwaccel one in the list must be the most
+ * accurate software format, followed by less accurate ones in order of
+ * preference.
  * If it is not possible to decode to software, AVCodecContext.sw_pix_fmt
  * must be set before calling this function.
  */

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

Reply via email to