]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/dv.c
Merge commit '874838dc6589d978611c89a40694a5074f892a76'
[ffmpeg] / libavformat / dv.c
index e3b0d0a31e24c8a809730b78e7e77b6f6fc0916b..f972478f6999686d5390a97daadf92c0d3dbf580 100644 (file)
@@ -32,7 +32,7 @@
 #include "avformat.h"
 #include "internal.h"
 #include "libavcodec/dv_profile.h"
-#include "libavcodec/dvdata.h"
+#include "libavcodec/dv.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
@@ -582,31 +582,37 @@ static int dv_read_close(AVFormatContext *s)
 
 static int dv_probe(AVProbeData *p)
 {
-    unsigned state, marker_pos = 0;
+    unsigned marker_pos = 0;
     int i;
     int matches           = 0;
+    int firstmatch        = 0;
     int secondary_matches = 0;
 
     if (p->buf_size < 5)
         return 0;
 
-    state = AV_RB32(p->buf);
-    for (i = 4; i < p->buf_size; i++) {
-        if ((state & 0xffffff7f) == 0x1f07003f)
-            matches++;
-        // any section header, also with seq/chan num != 0,
-        // should appear around every 12000 bytes, at least 10 per frame
-        if ((state & 0xff07ff7f) == 0x1f07003f)
-            secondary_matches++;
-        if (state == 0x003f0700 || state == 0xff3f0700)
-            marker_pos = i;
-        if (state == 0xff3f0701 && i - marker_pos == 80)
-            matches++;
-        state = (state << 8) | p->buf[i];
+    for (i = 0; i < p->buf_size-4; i++) {
+        unsigned state = AV_RB32(p->buf+i);
+        if ((state & 0x0007f840) == 0x00070000) {
+            // any section header, also with seq/chan num != 0,
+            // should appear around every 12000 bytes, at least 10 per frame
+            if ((state & 0xff07ff7f) == 0x1f07003f) {
+                secondary_matches++;
+                if ((state & 0xffffff7f) == 0x1f07003f) {
+                    matches++;
+                    if (!i)
+                        firstmatch = 1;
+                }
+            }
+            if (state == 0x003f0700 || state == 0xff3f0700)
+                marker_pos = i;
+            if (state == 0xff3f0701 && i - marker_pos == 80)
+                matches++;
+        }
     }
 
     if (matches && p->buf_size / matches < 1024 * 1024) {
-        if (matches > 4 ||
+        if (matches > 4 || firstmatch ||
             (secondary_matches >= 10 &&
              p->buf_size / secondary_matches < 24000))
             // not max to avoid dv in mov to match