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

Michael Niedermayer michael at niedermayer.cc
Tue May 22 23:21:04 EEST 2018


This reduces the amount of log message noise for files that contain
many such redundant entries

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

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;
-- 
2.17.0



More information about the ffmpeg-devel mailing list