diff mbox series

[FFmpeg-devel,v2,1/2] avformat/mov: skip moof and sidx before found moov

Message ID tencent_888CE0B05B5234D580CA34913FAB57039D09@qq.com
State New
Headers show
Series [FFmpeg-devel,v2,1/2] avformat/mov: skip moof and sidx before found moov | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

Commit Message

zhilizhao(赵志立) Dec. 25, 2021, 8:45 a.m. UTC
It's required for #8883. VLC and quicktime player can handle the
sample file.
---
 libavformat/mov.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2aed6e80ef..ea2f010aa0 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7366,6 +7366,21 @@  static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             break;
         a.size = FFMIN(a.size, atom.size - total_size);
 
+        if (!c->found_moov) {
+            static uint32_t skip_before_moov[] = {
+                MKTAG('m', 'o', 'o', 'f'),
+                MKTAG('s', 'i', 'd', 'x'),
+            };
+            for (size_t i = 0; i < FF_ARRAY_ELEMS(skip_before_moov); i++) {
+                if (a.type == skip_before_moov[i]) {
+                    av_log(c->fc, AV_LOG_WARNING, "Skip %s atom before moov.\n",
+                           av_fourcc2str(a.type));
+                    parse = NULL;
+                    goto skip;
+                }
+            }
+        }
+
         for (i = 0; mov_default_parse_table[i].type; i++)
             if (mov_default_parse_table[i].type == a.type) {
                 parse = mov_default_parse_table[i].parse;
@@ -7386,6 +7401,7 @@  static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             parse = mov_read_keys;
         }
 
+skip:
         if (!parse) { /* skip leaf atoms data */
             avio_skip(pb, a.size);
         } else {