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

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new 2ae2413488 avcodec/vp8, vp9: warn when native decoders ignore WebM 
alpha
2ae2413488 is described below

commit 2ae24134889e3684327196a2e6354c36d967051a
Author:     wangnov <[email protected]>
AuthorDate: Thu Jul 2 18:28:13 2026 +0800
Commit:     Marton Balint <[email protected]>
CommitDate: Thu Jul 30 06:51:57 2026 +0000

    avcodec/vp8, vp9: warn when native decoders ignore WebM alpha
    
    WebM VP8/VP9 alpha is a second bitstream attached via a Matroska
    BlockAdditional element (BlockAddID 1). Only the libvpx wrapper
    decoders merge it into the output frame; the native vp8/vp9 decoders
    have no code path for it and silently return an opaque frame.
    
    Warn once per decoder instance instead of failing silently, pointing
    at the decoder that does support it. The av_log_once() state is
    synchronized across frame-thread contexts to avoid duplicate warnings
    with frame threading.
    
    Reported in https://trac.ffmpeg.org/ticket/11165 and
    https://github.com/renpy/renpy/issues/1402.
    
    Signed-off-by: wangnov <[email protected]>
---
 libavcodec/vp8.c    | 30 +++++++++++++++++++++++++++++-
 libavcodec/vp8.h    |  2 ++
 libavcodec/vp9.c    | 22 ++++++++++++++++++++++
 libavcodec/vp9dec.h |  2 ++
 4 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 39cc00fefe..fe154c6914 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -27,6 +27,7 @@
 #include "config_components.h"
 
 #include "libavutil/attributes.h"
+#include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 
@@ -2850,12 +2851,38 @@ static void vp8_filter_mb_row(AVCodecContext *avctx, 
void *tdata,
     filter_mb_row(avctx, tdata, jobnr, threadnr, 0);
 }
 
+static void vp8_warn_unsupported_webm_alpha(AVCodecContext *avctx,
+                                            const AVPacket *avpkt)
+{
+    VP8Context *s = avctx->priv_data;
+    const uint8_t *sd;
+    size_t sd_size;
+
+    sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
+                                 &sd_size);
+    if (!sd || sd_size < 8 || AV_RB64(sd) != 1)
+        return;
+
+    av_log_once(avctx, AV_LOG_WARNING, AV_LOG_DEBUG,
+                &s->webm_alpha_warned,
+                "Ignoring unsupported WebM alpha channel side data; use the "
+                "libvpx decoder to decode it.\n");
+}
+
 int ff_vp8_decode_frame(AVCodecContext *avctx, AVFrame *frame,
                         int *got_frame, AVPacket *avpkt)
 {
     return vp78_decode_frame(avctx, frame, got_frame, avpkt, IS_VP8);
 }
 
+static int vp8_decode_frame(AVCodecContext *avctx, AVFrame *frame,
+                            int *got_frame, AVPacket *avpkt)
+{
+    vp8_warn_unsupported_webm_alpha(avctx, avpkt);
+
+    return ff_vp8_decode_frame(avctx, frame, got_frame, avpkt);
+}
+
 av_cold int ff_vp8_decode_init(AVCodecContext *avctx)
 {
     VP8Context *s = avctx->priv_data;
@@ -2896,6 +2923,7 @@ static int 
vp8_decode_update_thread_context(AVCodecContext *dst,
     s->prob[0]      = s_src->prob[!s_src->update_probabilities];
     s->segmentation = s_src->segmentation;
     s->lf_delta     = s_src->lf_delta;
+    s->webm_alpha_warned = s_src->webm_alpha_warned;
     memcpy(s->sign_bias, s_src->sign_bias, sizeof(s->sign_bias));
 
     for (int i = 0; i < FF_ARRAY_ELEMS(s_src->frames); i++)
@@ -2967,7 +2995,7 @@ const FFCodec ff_vp8_decoder = {
     .priv_data_size        = sizeof(VP8Context),
     .init                  = ff_vp8_decode_init,
     .close                 = ff_vp8_decode_free,
-    FF_CODEC_DECODE_CB(ff_vp8_decode_frame),
+    FF_CODEC_DECODE_CB(vp8_decode_frame),
     .p.capabilities        = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
                              AV_CODEC_CAP_SLICE_THREADS,
     .caps_internal         = FF_CODEC_CAP_USES_PROGRESSFRAMES,
diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h
index 9bdef0aa88..02272bcadd 100644
--- a/libavcodec/vp8.h
+++ b/libavcodec/vp8.h
@@ -346,6 +346,8 @@ typedef struct VP8Context {
     uint8_t feature_present_prob[4];
     uint8_t feature_index_prob[4][3];
     uint8_t feature_value[4][4];
+
+    int webm_alpha_warned; ///< warn once about unsupported WebM alpha
 } VP8Context;
 
 int ff_vp8_decode_init(AVCodecContext *avctx);
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 4755d15bda..7be733a0da 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -43,6 +43,7 @@
 #include "vpx_rac.h"
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/video_enc_params.h"
@@ -1581,6 +1582,24 @@ static int vp9_export_enc_params(VP9Context *s, VP9Frame 
*frame)
     return 0;
 }
 
+static void vp9_warn_unsupported_webm_alpha(AVCodecContext *avctx,
+                                            const AVPacket *pkt)
+{
+    VP9Context *s = avctx->priv_data;
+    const uint8_t *sd;
+    size_t sd_size;
+
+    sd = av_packet_get_side_data(pkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
+                                 &sd_size);
+    if (!sd || sd_size < 8 || AV_RB64(sd) != 1)
+        return;
+
+    av_log_once(avctx, AV_LOG_WARNING, AV_LOG_DEBUG,
+                &s->webm_alpha_warned,
+                "Ignoring unsupported WebM alpha channel side data; use the "
+                "libvpx-vp9 decoder to decode it.\n");
+}
+
 static int vp9_decode_frame(AVCodecContext *avctx, AVFrame *frame,
                             int *got_frame, AVPacket *pkt)
 {
@@ -1596,6 +1615,8 @@ static int vp9_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
     const VP9Frame *src;
     AVFrame *f;
 
+    vp9_warn_unsupported_webm_alpha(avctx, pkt);
+
     ret = ff_cbs_read_packet(s->cbc, &s->current_frag, pkt);
     if (ret < 0) {
         ff_cbs_fragment_reset(&s->current_frag);
@@ -1912,6 +1933,7 @@ static int 
vp9_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo
     s->s.h.bpp = ssrc->s.h.bpp;
     s->bpp_index = ssrc->bpp_index;
     s->pix_fmt = ssrc->pix_fmt;
+    s->webm_alpha_warned = ssrc->webm_alpha_warned;
     memcpy(&s->prob_ctx, &ssrc->prob_ctx, sizeof(s->prob_ctx));
     memcpy(&s->s.h.lf_delta, &ssrc->s.h.lf_delta, sizeof(s->s.h.lf_delta));
     memcpy(&s->s.h.segmentation.feat, &ssrc->s.h.segmentation.feat,
diff --git a/libavcodec/vp9dec.h b/libavcodec/vp9dec.h
index c3ad2bbcdb..fd33d03c2b 100644
--- a/libavcodec/vp9dec.h
+++ b/libavcodec/vp9dec.h
@@ -168,6 +168,8 @@ typedef struct VP9Context {
     // frame specific buffer pools
     struct AVRefStructPool *frame_extradata_pool;
     int frame_extradata_pool_size;
+
+    int webm_alpha_warned; ///< warn once about unsupported WebM alpha
 } VP9Context;
 
 struct VP9TileData {

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

Reply via email to