Browse code

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.

Originally committed as revision 19848 to svn://svn.ffmpeg.org/ffmpeg/trunk

Reimar Döffinger authored on 2009/09/15 07:03:07
Showing 1 changed files
... ...
@@ -488,6 +488,7 @@ static int dv_probe(AVProbeData *p)
488 488
 {
489 489
     unsigned state, marker_pos = 0;
490 490
     int i;
491
+    int matches = 0;
491 492
 
492 493
     if (p->buf_size < 5)
493 494
         return 0;
... ...
@@ -495,14 +496,19 @@ static int dv_probe(AVProbeData *p)
495 495
     state = AV_RB32(p->buf);
496 496
     for (i = 4; i < p->buf_size; i++) {
497 497
         if ((state & 0xffffff7f) == 0x1f07003f)
498
-            return AVPROBE_SCORE_MAX*3/4; // not max to avoid dv in mov to match
498
+            matches++;
499 499
         if (state == 0x003f0700 || state == 0xff3f0700)
500 500
             marker_pos = i;
501 501
         if (state == 0xff3f0701 && i - marker_pos == 80)
502
-            return AVPROBE_SCORE_MAX/4;
502
+            matches++;
503 503
         state = (state << 8) | p->buf[i];
504 504
     }
505 505
 
506
+    if (matches && p->buf_size / matches < 1024*1024) {
507
+        if (matches > 4)
508
+            return AVPROBE_SCORE_MAX*3/4; // not max to avoid dv in mov to match
509
+        return AVPROBE_SCORE_MAX/4;
510
+    }
506 511
     return 0;
507 512
 }
508 513