[vlc-commits] [Git][videolan/vlc][master] 2 commits: vpx: check explicitly for the alpha marker in the codec i_level

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jul 18 14:58:11 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
6ccbc516 by Steve Lhomme at 2025-07-18T14:29:07+00:00
vpx: check explicitly for the alpha marker in the codec i_level

There may be other valid values than 0 or -1 for VP9.

- - - - -
fb1182e1 by Steve Lhomme at 2025-07-18T14:29:07+00:00
vpx: use i_level as a bitfield to mark/unmark alpha

We can keep the VP9 profile outside of the alpha pseudo decoder.

- - - - -


12 changed files:

- modules/codec/avcodec/fourcc.c
- modules/codec/gstreamer/gstdecode.c
- modules/codec/omxil/mediacodec.c
- modules/codec/omxil/utils.c
- modules/codec/vpx.c
- modules/codec/vpx_alpha.c
- modules/demux/mkv/matroska_segment_parse.cpp
- modules/hw/mmal/codec.c
- modules/hw/nvdec/nvdec.c
- modules/packetizer/avparser.c
- modules/stream_out/chromecast/cast.cpp
- modules/stream_out/rtpfmt.c


Changes:

=====================================
modules/codec/avcodec/fourcc.c
=====================================
@@ -547,9 +547,9 @@ bool GetFfmpegCodec( const es_format_t *es,
     const struct vlc_avcodec_fourcc *base;
     size_t count;
 
-    if (es->i_codec == VLC_CODEC_VP8 && es->i_level != 0 && es->i_level != -1) // contains alpha extradata
+    if (es->i_codec == VLC_CODEC_VP8 && (es->i_level & 0x1000) != 0) // contains alpha extradata
         return false;
-    if (es->i_codec == VLC_CODEC_VP9 && es->i_level != 0 && es->i_level != -1) // contains alpha extradata
+    if (es->i_codec == VLC_CODEC_VP9 && (es->i_level & 0x1000) != 0) // contains alpha extradata
         return false;
 
     switch( es->i_cat )


=====================================
modules/codec/gstreamer/gstdecode.c
=====================================
@@ -408,12 +408,12 @@ static GstStructure* vlc_to_gst_fmt( const es_format_t *p_fmt )
                 "systemstream", G_TYPE_BOOLEAN, FALSE, NULL );
         break;
     case VLC_CODEC_VP8:
-        if (p_fmt->i_level != 0 && p_fmt->i_level != -1) // contains alpha extradata
+        if ((p_fmt->i_level & 0x1000) != 0) // contains alpha extradata
             return NULL;
         p_str = gst_structure_new_empty( "video/x-vp8" );
         break;
     case VLC_CODEC_VP9:
-        if (p_fmt->i_level != 0 && p_fmt->i_level != -1) // contains alpha extradata
+        if ((p_fmt->i_level & 0x1000) != 0) // contains alpha extradata
             return NULL;
         p_str = gst_structure_new_empty( "video/x-vp9" );
         break;


=====================================
modules/codec/omxil/mediacodec.c
=====================================
@@ -864,11 +864,11 @@ static int OpenDecoder(vlc_object_t *p_this, pf_MediaCodecApi_init pf_init)
         case VLC_CODEC_WMV3: mime = "video/x-ms-wmv"; break;
         case VLC_CODEC_VC1:  mime = "video/wvc1"; break;
         case VLC_CODEC_VP8:
-            if (p_dec->fmt_in->i_level != 0 && p_dec->fmt_in->i_level != -1) // contains alpha extradata
+            if ((p_dec->fmt_in->i_level & 0x1000) != 0) // contains alpha extradata
                 return VLC_ENOTSUP;
             mime = "video/x-vnd.on2.vp8"; break;
         case VLC_CODEC_VP9:
-            if (p_dec->fmt_in->i_level != 0 && p_dec->fmt_in->i_level != -1) // contains alpha extradata
+            if ((p_dec->fmt_in->i_level & 0x1000) != 0) // contains alpha extradata
                 return VLC_ENOTSUP;
             mime = "video/x-vnd.on2.vp9"; break;
         }


=====================================
modules/codec/omxil/utils.c
=====================================
@@ -598,9 +598,9 @@ OMX_VIDEO_CODINGTYPE GetOmxVideoFormat( const es_format_t *es )
     for( size_t i = 0; i < ARRAY_SIZE(video_format_table); i++ )
         if( video_format_table[i].i_fourcc == i_fourcc )
         {
-            if (es->i_codec == VLC_CODEC_VP8 && es->i_level != 0 && es->i_level != -1) // contains alpha extradata
+            if (es->i_codec == VLC_CODEC_VP8 && (es->i_level & 0x1000) != 0) // contains alpha extradata
                 continue;
-            if (es->i_codec == VLC_CODEC_VP9 && es->i_level != 0 && es->i_level != -1) // contains alpha extradata
+            if (es->i_codec == VLC_CODEC_VP9 && (es->i_level & 0x1000) != 0) // contains alpha extradata
                 continue;
 
             return video_format_table[i].i_codec;


=====================================
modules/codec/vpx.c
=====================================
@@ -310,7 +310,7 @@ static int OpenDecoder(vlc_object_t *p_this)
     {
 #ifdef ENABLE_VP8_DECODER
     case VLC_CODEC_VP8:
-        if (dec->fmt_in->i_level != 0 && dec->fmt_in->i_level != -1) // contains alpha extradata
+        if ((dec->fmt_in->i_level & 0x1000) != 0) // contains alpha extradata
             return VLC_ENOTSUP;
         // fallthrough
     case VLC_CODEC_WEBP:
@@ -321,7 +321,7 @@ static int OpenDecoder(vlc_object_t *p_this)
 #endif
 #ifdef ENABLE_VP9_DECODER
     case VLC_CODEC_VP9:
-        if (dec->fmt_in->i_level != 0 && dec->fmt_in->i_level != -1) // contains alpha extradata
+        if ((dec->fmt_in->i_level & 0x1000) != 0) // contains alpha extradata
             return VLC_ENOTSUP;
         // fallthrough
     case VLC_CODEC_VP9ALPHA_ES:
@@ -413,7 +413,7 @@ static int OpenEncoder(vlc_object_t *p_this)
     {
 #ifdef ENABLE_VP8_ENCODER
     case VLC_CODEC_VP8:
-        if (p_enc->fmt_out.i_level != 0 && p_enc->fmt_out.i_level != -1) // contains alpha extradata
+        if ((p_enc->fmt_out.i_level & 0x1000) != 0) // contains alpha extradata
             return VLC_ENOTSUP;
         // fallthrough
     case VLC_CODEC_WEBP:
@@ -423,7 +423,7 @@ static int OpenEncoder(vlc_object_t *p_this)
 #endif
 #ifdef ENABLE_VP9_ENCODER
     case VLC_CODEC_VP9:
-        if (p_enc->fmt_out.i_level != 0 && p_enc->fmt_out.i_level != -1) // contains alpha extradata
+        if ((p_enc->fmt_out.i_level & 0x1000) != 0) // contains alpha extradata
             return VLC_ENOTSUP;
         iface = &vpx_codec_vp9_cx_algo;
         vp_version = 9;


=====================================
modules/codec/vpx_alpha.c
=====================================
@@ -570,7 +570,7 @@ int OpenDecoder(vlc_object_t *o)
     decoder_t *dec = container_of(o, decoder_t, obj);
     if (dec->fmt_in->i_codec != VLC_CODEC_VP8 && dec->fmt_in->i_codec != VLC_CODEC_VP9)
         return VLC_ENOTSUP;
-    if (dec->fmt_in->i_level == 0 || dec->fmt_in->i_level == -1)
+    if ((dec->fmt_in->i_level & 0x1000) == 0)
         return VLC_ENOTSUP;
 
     vpx_alpha *p_sys = vlc_obj_calloc(o, 1, sizeof(*p_sys));
@@ -593,7 +593,7 @@ int OpenDecoder(vlc_object_t *o)
         fmt.i_codec = VLC_CODEC_VP8;
     else
         fmt.i_codec = VLC_CODEC_VP9;
-    fmt.i_level = 0;
+    fmt.i_level &= ~0x1000;
     decoder_Init( &p_sys->opaque->dec, &p_sys->opaque->fmt_in, &fmt );
     vlc_picture_chain_Init(&p_sys->opaque->decoded);
     es_format_Init(&p_sys->opaque->fmt_out, VIDEO_ES, 0);


=====================================
modules/demux/mkv/matroska_segment_parse.cpp
=====================================
@@ -1816,6 +1816,8 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
         }
         S_CASE("V_VP9") {
             vars.p_fmt->i_codec = VLC_CODEC_VP9;
+            if (vars.p_tk->b_has_alpha)
+                vars.p_fmt->i_level = 0x1000; // mark as containing alpha data
             vars.p_tk->b_pts_only = true;
 
             fill_extra_data( vars.p_tk, 0 );
@@ -1833,8 +1835,12 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
                                 vars.p_fmt->i_profile = VP9CodecFeatures[2];
                             break;
                         case 2: // Level
-                            if (length == 1)
-                                vars.p_fmt->i_level = VP9CodecFeatures[2];
+                            if (length == 1) {
+                                if ((vars.p_fmt->i_level & 0x1000) != 0)
+                                    vars.p_fmt->i_level |= VP9CodecFeatures[2];
+                                else
+                                    vars.p_fmt->i_level = VP9CodecFeatures[2];
+                            }
                             break;
                         case 3: // Bit Depth
                         case 4: // Chroma Subsampling
@@ -1845,8 +1851,6 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
                     remain -= 1 + 1 + length;
                 }
             }
-            if (vars.p_tk->b_has_alpha)
-                vars.p_fmt->i_level = 0x1000; // mark as containing alpha data
         }
         S_CASE("V_AV1") {
             vars.p_fmt->i_codec = VLC_CODEC_AV1;


=====================================
modules/hw/mmal/codec.c
=====================================
@@ -151,7 +151,7 @@ static MMAL_FOURCC_T vlc_to_mmal_es_fourcc(const es_format_t *es)
     case VLC_CODEC_VP6:
         return MMAL_ENCODING_VP6;
     case VLC_CODEC_VP8:
-        if (es->i_level != 0 && es->i_level != -1) // contains alpha extradata
+        if ((es->i_level & 0x1000) != 0) // contains alpha extradata
             return 0;
         return MMAL_ENCODING_VP8;
     case VLC_CODEC_WMV1:


=====================================
modules/hw/nvdec/nvdec.c
=====================================
@@ -817,7 +817,7 @@ static int OpenDecoder(vlc_object_t *p_this)
         case VLC_CODEC_MP4V:
             break;
         case VLC_CODEC_VP8:
-            if (p_dec->fmt_in->i_level != 0 && p_dec->fmt_in->i_level != -1) // contains alpha extradata
+            if ((p_dec->fmt_in->i_level & 0x1000) != 0) // contains alpha extradata
                 goto early_exit;
             break;
         case VLC_CODEC_VP9:
@@ -826,7 +826,7 @@ static int OpenDecoder(vlc_object_t *p_this)
                 msg_Warn(p_dec, "Unsupported VP9 profile %d", p_dec->fmt_in->i_profile);
                 goto early_exit;
             }
-            if (p_dec->fmt_in->i_level != 0 && p_dec->fmt_in->i_level != -1) // contains alpha extradata
+            if ((p_dec->fmt_in->i_level & 0x1000) != 0) // contains alpha extradata
                 goto early_exit;
             break;
         default:


=====================================
modules/packetizer/avparser.c
=====================================
@@ -92,7 +92,7 @@ int avparser_OpenPacketizer( vlc_object_t *p_this )
      * removing this constraint */
     if( p_dec->fmt_in->i_codec != VLC_CODEC_VP9 )
         return VLC_ENOTSUP;
-    if( p_dec->fmt_in->i_level != 0 && p_dec->fmt_in->i_level != -1 ) // contains alpha extradata
+    if( (p_dec->fmt_in->i_level & 0x1000) != 0 ) // contains alpha extradata
         return VLC_ENOTSUP;
 
     enum AVCodecID i_avcodec_id;


=====================================
modules/stream_out/chromecast/cast.cpp
=====================================
@@ -773,11 +773,11 @@ bool sout_stream_sys_t::canDecodeVideo( const es_format_t *es ) const
         case VLC_CODEC_HEVC:
             return true;
         case VLC_CODEC_VP8:
-            if (es->i_level != 0 && es->i_level != -1) // contains alpha extradata
+            if ((es->i_level & 0x1000) != 0) // contains alpha extradata
                 return false;
             return true;
         case VLC_CODEC_VP9:
-            if (es->i_level != 0 && es->i_level != -1) // contains alpha extradata
+            if ((es->i_level & 0x1000) != 0) // contains alpha extradata
                 return false;
             return true;
         default:


=====================================
modules/stream_out/rtpfmt.c
=====================================
@@ -644,7 +644,7 @@ int rtp_get_fmt( vlc_object_t *obj, const es_format_t *p_fmt, const char *mux,
                 rtp_fmt->fmtp = strdup( "sprop-stereo=1" );
             break;
         case VLC_CODEC_VP8:
-            if (p_fmt->i_level != 0 && p_fmt->i_level != -1) // contains alpha extradata
+            if ((p_fmt->i_level & 0x1000) != 0) // contains alpha extradata
                 return VLC_ENOTSUP;
             rtp_fmt->ptname = "VP8";
             rtp_fmt->pf_packetize = rtp_packetize_vp8;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dac0736929af1beeddf5a1db7f6675a03007355c...fb1182e1421e7e4524c09193bb2367873a5e82a4

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dac0736929af1beeddf5a1db7f6675a03007355c...fb1182e1421e7e4524c09193bb2367873a5e82a4
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list