changeset 5185:0c742c9c4aa7 libavformat

Try harder to avoid false positives for DV probe. Require at least one signature match per provided 1MB of probe data, and if there is only a single match, return at most MAX/4. Fixes issue1382 but could/should probably still be improved.
author reimar
date Mon, 14 Sep 2009 22:03:07 +0000
parents 2d15ea28c450
children cbaefd9135ac
files dv.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dv.c	Mon Sep 14 21:50:23 2009 +0000
+++ b/dv.c	Mon Sep 14 22:03:07 2009 +0000
@@ -488,6 +488,7 @@
 {
     unsigned state, marker_pos = 0;
     int i;
+    int matches = 0;
 
     if (p->buf_size < 5)
         return 0;
@@ -495,14 +496,19 @@
     state = AV_RB32(p->buf);
     for (i = 4; i < p->buf_size; i++) {
         if ((state & 0xffffff7f) == 0x1f07003f)
-            return AVPROBE_SCORE_MAX*3/4; // not max to avoid dv in mov to match
+            matches++;
         if (state == 0x003f0700 || state == 0xff3f0700)
             marker_pos = i;
         if (state == 0xff3f0701 && i - marker_pos == 80)
-            return AVPROBE_SCORE_MAX/4;
+            matches++;
         state = (state << 8) | p->buf[i];
     }
 
+    if (matches && p->buf_size / matches < 1024*1024) {
+        if (matches > 4)
+            return AVPROBE_SCORE_MAX*3/4; // not max to avoid dv in mov to match
+        return AVPROBE_SCORE_MAX/4;
+    }
     return 0;
 }