[vlc-commits] [Git][videolan/vlc][master] demux/mkv: extract the VP9 profile/level from the CodecPrivate

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Nov 1 12:30:06 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
c7b046d8 by Steve Lhomme at 2024-11-01T12:14:35+00:00
demux/mkv: extract the VP9 profile/level from the CodecPrivate

As defined in https://www.webmproject.org/docs/container/#vp9-codec-feature-metadata-codecprivate

This can be useful to pick the right decoder.
This is similar to what is done in the MP4 demuxer which uses a different extradata format:
https://www.webmproject.org/vp9/mp4/#vp-codec-configuration-box

- - - - -


1 changed file:

- modules/demux/mkv/matroska_segment_parse.cpp


Changes:

=====================================
modules/demux/mkv/matroska_segment_parse.cpp
=====================================
@@ -1804,11 +1804,37 @@ 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 );
+            if (vars.p_tk->fmt.i_extra)
+            {
+                const auto * VP9CodecFeatures = static_cast<const uint8_t*>(vars.p_tk->fmt.p_extra);
+                size_t remain = vars.p_tk->fmt.i_extra;
+                while (remain >= 3)
+                {
+                    uint8_t length = VP9CodecFeatures[1];
+                    switch (VP9CodecFeatures[0])
+                    {
+                        case 1: // Profile
+                            if (length == 1)
+                                vars.p_fmt->i_profile = VP9CodecFeatures[2];
+                            break;
+                        case 2: // Level
+                            if (length == 1)
+                                vars.p_fmt->i_level = VP9CodecFeatures[2];
+                            break;
+                        case 3: // Bit Depth
+                        case 4: // Chroma Subsampling
+                        default:
+                            break;
+                    }
+                    VP9CodecFeatures += 1 + 1 + length;
+                    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;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c7b046d8b3f6db3a6abc3c4766d22346de17fc8a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c7b046d8b3f6db3a6abc3c4766d22346de17fc8a
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