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

Git pushed a commit to branch master
in repository ffmpeg.

commit f3431169daab3f1ca26638de6d4f6fca0f090c15
Author:     Nicolas George <[email protected]>
AuthorDate: Sat Apr 25 19:52:58 2026 +0200
Commit:     Nicolas George <[email protected]>
CommitDate: Mon Jul 27 10:27:27 2026 +0200

    lavfi: do not send premultiplied alpha to filters not ready for it
    
    The arithmetic to process colors in premultiplied alpha is
    completely different from the arithmetic for straight alpha.
    Running a filter using straight arithmetic on premultiplied
    will result in incorrect and sometimes invalid output.
    Therefore, premultiplied alpha should only be selected for
    filters that either explicitly support it or only use
    elementary color arithmetic or none at all.
    For other filters, automatic conversion will do its work.
---
 libavfilter/formats.c | 15 ++++++++++++++-
 libavfilter/formats.h | 12 ++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index fac2e4a393..da5b7abbb8 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -722,6 +722,14 @@ AVFilterFormats *ff_all_color_ranges(void)
     return ret;
 }
 
+AVFilterFormats *ff_alpha_mode_straight(void)
+{
+    AVFilterFormats *ret = NULL;
+    if (ff_add_format(&ret, AVALPHA_MODE_STRAIGHT) < 0)
+            return NULL;
+    return ret;
+}
+
 AVFilterFormats *ff_all_alpha_modes(void)
 {
     AVFilterFormats *ret = NULL;
@@ -951,6 +959,11 @@ int ff_set_common_alpha_modes_from_list(AVFilterContext 
*ctx,
     return ff_set_common_alpha_modes(ctx, ff_make_format_list(alpha_modes));
 }
 
+int ff_set_common_alpha_mode_straight(AVFilterContext *ctx)
+{
+    return ff_set_common_alpha_modes(ctx, ff_alpha_mode_straight());
+}
+
 int ff_set_common_all_alpha_modes(AVFilterContext *ctx)
 {
     return ff_set_common_alpha_modes(ctx, ff_all_alpha_modes());
@@ -1215,7 +1228,7 @@ int ff_default_query_formats(AVFilterContext *ctx)
         ret = ff_set_common_all_color_ranges(ctx);
         if (ret < 0)
             return ret;
-        ret = ff_set_common_all_alpha_modes(ctx);
+        ret = ff_set_common_alpha_mode_straight(ctx);
         if (ret < 0)
             return ret;
     }
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index 45864a32db..cde86a40b1 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -144,6 +144,12 @@ AVFilterFormats *ff_all_color_spaces(void);
 av_warn_unused_result
 AVFilterFormats *ff_all_color_ranges(void);
 
+/**
+ * Construct an AVFilterFormats with only premultiplied alpha.
+ */
+av_warn_unused_result
+AVFilterFormats *ff_alpha_mode_straight(void);
+
 /**
  * Construct an AVFilterFormats representing all possible alpha modes.
  */
@@ -227,6 +233,12 @@ av_warn_unused_result
 int ff_set_common_alpha_modes_from_list(AVFilterContext *ctx,
                                         const int *alpha_modes);
 
+/**
+ * Equivalent to ff_set_common_alpha_modes(ctx, ff_alpha_mode_straight())
+ */
+av_warn_unused_result
+int ff_set_common_alpha_mode_straight(AVFilterContext *ctx);
+
 /**
  * Equivalent to ff_set_common_alpha_modes(ctx, ff_all_alpha_modes())
  */

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

Reply via email to