[FFmpeg-devel] [PATCH] improve DV probe score

Reimar Döffinger Reimar.Doeffinger
Mon Sep 14 09:59:31 CEST 2009


On Mon, Sep 14, 2009 at 01:34:32AM +0200, Michael Niedermayer wrote:
> On Sun, Sep 13, 2009 at 11:35:35PM +0200, Reimar D?ffinger wrote:
> > Hello,
> > this is a suggestion for fixing issue1382.
> > It returns the rather high probe value of 3/4 of max only when multiple
> > DV-typical bit patterns were found (ca. 128 bit worth), otherwise only
> > 1/3 of max.
> > Though I think with the improved mp3 probe it might make sense to
> > increase its values a bit, too...
> 
> feeding the probe code with random data or systematic nonsense should
> as the amount of data is increased cause the returned score to fall
> toward 0
> your code can only increase its score as more data is added, this feels
> quite incorrect

Well, since that is the case for many formats I'd expected it is good
enough to even it out.
I don't like making such extensive changes since we have few DV samples,
but what about this change?
Index: libavformat/dv.c
===================================================================
--- libavformat/dv.c    (revision 19824)
+++ libavformat/dv.c    (working copy)
@@ -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/3;
+    }
     return 0;
 }



More information about the ffmpeg-devel mailing list