diff mbox

[FFmpeg-devel] avformat/mov: Discard redundant and invalid STSC entries

Message ID 20180522202104.22853-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer May 22, 2018, 8:21 p.m. UTC
This reduces the amount of log message noise for files that contain
many such redundant entries

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/mov.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f2a540ad50..b555c8cb7f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2638,6 +2638,13 @@  static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         sc->stsc_data[i].first = avio_rb32(pb);
         sc->stsc_data[i].count = avio_rb32(pb);
         sc->stsc_data[i].id = avio_rb32(pb);
+        if (i &&
+            sc->stsc_data[i].count == sc->stsc_data[i-1].count &&
+            sc->stsc_data[i].id    == sc->stsc_data[i-1].id &&
+            sc->stsc_data[i].first >= sc->stsc_data[i-1].first) {
+            i --;
+            entries --;
+        }
     }
 
     sc->stsc_count = i;