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

Git pushed a commit to branch master
in repository ffmpeg.

commit 9515cb236b0a41792d13f7e8425101ceee2de2e2
Author:     Marton Balint <[email protected]>
AuthorDate: Sat Feb 7 00:19:47 2026 +0100
Commit:     Marton Balint <[email protected]>
CommitDate: Sun Feb 15 20:28:31 2026 +0100

    avformat/matroskaenc: only write AlphaMode for VP8 and VP9
    
    AlphaMode should indicate whether the BlockAdditional Element with 
BlockAddID
    of "1" contains Alpha data, as defined by to the Codec Mapping for the 
`CodecID`.
    
    Only VP8 and VP9 Codec Mappings define this, so writing it for all codecs 
with
    a pixel format of YUVA420P, or for codecs other than VP8/VP9 (if the 
alpha_mode
    metadata entry was set) was wrong.
    
    Signed-off-by: Marton Balint <[email protected]>
---
 libavformat/matroskaenc.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index be9e0c2922..afaa38b3a2 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdbool.h>
 #include <stdint.h>
 
 #include "config_components.h"
@@ -1787,11 +1788,23 @@ static void 
mkv_write_blockadditionmapping(AVFormatContext *s, const MatroskaMux
 #endif
 }
 
+static bool codec_has_blockadditional_alpha(AVFormatContext *s, const AVStream 
*st,
+                                            const AVCodecParameters *par)
+{
+    const AVDictionaryEntry *tag;
+    if (par->codec_id != AV_CODEC_ID_VP8 &&
+        par->codec_id != AV_CODEC_ID_VP9)
+        return false;
+    if (par->format == AV_PIX_FMT_YUVA420P)
+        return true;
+    return ((tag = av_dict_get(st->metadata, "alpha_mode", NULL, 0)) ||
+            (tag = av_dict_get( s->metadata, "alpha_mode", NULL, 0))) && 
strtol(tag->value, NULL, 0);
+}
+
 static int mkv_write_track_video(AVFormatContext *s, MatroskaMuxContext *mkv,
                                  const AVStream *st, const AVCodecParameters 
*par,
                                  AVIOContext *pb)
 {
-    const AVDictionaryEntry *tag;
     int display_width_div = 1, display_height_div = 1;
     uint8_t color_space[4], projection_private[20];
     const AVPacketSideData *sd;
@@ -1815,9 +1828,7 @@ static int mkv_write_track_video(AVFormatContext *s, 
MatroskaMuxContext *mkv,
     if (ret < 0)
         return ret;
 
-    if (par->format == AV_PIX_FMT_YUVA420P ||
-        ((tag = av_dict_get(st->metadata, "alpha_mode", NULL, 0)) ||
-         (tag = av_dict_get( s->metadata, "alpha_mode", NULL, 0))) && 
strtol(tag->value, NULL, 0))
+    if (codec_has_blockadditional_alpha(s, st, par))
         ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEOALPHAMODE, 1);
 
     sd = av_packet_side_data_get(par->coded_side_data,

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

Reply via email to