diff mbox series

[FFmpeg-devel,4/4] avformat/smacker: Don't return packets for streams with AVDISCARD_ALL

Message ID 20200724083717.8491-3-andreas.rheinhardt@gmail.com
State Accepted
Commit dfd12ee053c0dbcb590ad5c758df6bb3b38777ea
Headers show
Series [FFmpeg-devel] avformat/smacker: Support seeking to first frame
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt July 24, 2020, 8:37 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/smacker.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index b7a68a63f3..9966a67055 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -308,8 +308,11 @@  static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
             smk->frame_size -= size;
             size            -= 4;
 
-            if (smk->indexes[i] < 0) {
-                avio_skip(s->pb, size);
+            if (smk->indexes[i] < 0 ||
+                s->streams[smk->indexes[i]]->discard >= AVDISCARD_ALL) {
+                smk->aud_pts[i] += smk->duration_size[i] ? avio_rl32(s->pb)
+                                                         : size;
+                avio_skip(s->pb, size - smk->duration_size[i]);
                 continue;
             }
             if ((ret = av_get_packet(s->pb, pkt, size)) != size) {
@@ -326,6 +329,10 @@  static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
         }
     }
 
+    if (s->streams[smk->videoindex]->discard >= AVDISCARD_ALL) {
+        ret = FFERROR_REDO;
+        goto next_frame;
+    }
     if (smk->frame_size >= INT_MAX/2) {
         ret = AVERROR_INVALIDDATA;
         goto next_frame;