[vlc-commits] [Git][videolan/vlc][master] avformat: demux: use AV1_Unpack_Sample for AV1

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Jul 8 11:53:24 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
9dfb7279 by Alexandre Janniaux at 2026-07-08T11:32:50+00:00
avformat: demux: use AV1_Unpack_Sample for AV1

mp4 and mkv demuxers are using AV1_Unpack_Sample to add the proper
packet metadata that the packetizer expects[^1], since we don't use
BLOCK_FLAG_AU_END for AV1. This is copied from mkv module.

AV1_Unpack_Sample() will add the last size field and the TU that are
needed, see av1_unpack.h.

Without this, the playback works correctly but the stream output
scenario, which always trigger the packetizer insertion, defers the
start of the decoder until the packetizer is ready to emit a frame.

In the sample I was using coming from streaming platform, it defers
up to 5s later.

[^1]: https://aomediacodec.github.io/av1-isobmff/#sampleformat

- - - - -


1 changed file:

- modules/demux/avformat/demux.c


Changes:

=====================================
modules/demux/avformat/demux.c
=====================================
@@ -44,6 +44,7 @@
 #include "avformat.h"
 #include "../xiph.h"
 #include "../vobsub.h"
+#include "../av1_unpack.h"
 
 #include <libavformat/avformat.h>
 #include <libavutil/display.h>
@@ -909,6 +910,17 @@ static int Demux( demux_t *p_demux )
     if( pkt.flags & AV_PKT_FLAG_KEY )
         p_frame->i_flags |= BLOCK_FLAG_TYPE_I;
 
+    if( p_stream->codecpar->codec_id == AV_CODEC_ID_AV1 )
+    {
+        /* Prepare the packet like the mkv/mp4 demuxers do. */
+        p_frame = AV1_Unpack_Sample( p_frame );
+        if( unlikely( p_frame == NULL ) )
+        {
+            av_packet_unref( &pkt );
+            return VLC_DEMUXER_EOF;
+        }
+    }
+
     /* Used to avoid timestamps overflow */
     if( p_sys->ic->start_time != (int64_t)AV_NOPTS_VALUE )
     {



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

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/9dfb7279314346eed7791f93ddc586eeb72991d9
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list