After seeking fragments with an offset > 0 must be skipped to correctly
assemble packets.

Bug-Id: 43
---
 libavformat/asfdec.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 8580ce0..1da0eab 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1103,6 +1103,16 @@ static int asf_parse_packet(AVFormatContext *s, 
AVIOContext *pb, AVPacket *pkt)
         asf_st = asf->asf_st;
         av_assert0(asf_st);
 
+        if (!asf_st->frag_offset && asf->packet_frag_offset) {
+            av_dlog(s, "skipping asf data pkt with fragment offset for "
+                    "stream:%d, expected:%d but got %d from pkt)\n",
+                    asf->stream_index, asf_st->frag_offset,
+                    asf->packet_frag_offset);
+            avio_skip(pb, asf->packet_frag_size);
+            asf->packet_size_left -= asf->packet_frag_size;
+            continue;
+        }
+
         if (asf->packet_replic_size == 1) {
             // frag_offset is here used as the beginning timestamp
             asf->packet_frag_timestamp = asf->packet_time_start;
@@ -1282,6 +1292,7 @@ static int asf_read_packet(AVFormatContext *s, AVPacket 
*pkt)
         /* parse cached packets, if any */
         if ((ret = asf_parse_packet(s, s->pb, pkt)) <= 0)
             return ret;
+
         if ((ret = asf_get_packet(s, s->pb)) < 0)
             assert(asf->packet_size_left < FRAME_HEADER_SIZE ||
                    asf->packet_segments < 1);
-- 
1.8.5.4

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to