[FFmpeg-devel] [RFC] special "broken DV" demuxer

Reimar Döffinger Reimar.Doeffinger
Tue Mar 10 09:54:56 CET 2009


On Tue, Mar 10, 2009 at 01:21:52AM -0700, Baptiste Coudurier wrote:
> On 3/10/2009 1:18 AM, Reimar D?ffinger wrote:
> > On Mon, Mar 09, 2009 at 04:40:13PM -0700, Roman V Shaposhnik wrote:
> >> On Sun, 2009-03-08 at 18:28 +0100, Reimar D?ffinger wrote:
> >>> in our samples there is one horribly broken DV file:
> >>> http://samples.mplayerhq.hu/V-codecs/DVSD/pond.dv
> >>> As far as I can tell (with my limited understanding of the DV format)
> >>> this is basically some DV headers "randomly" placed and then
> >>> the data essential to decoding DV written over it.
> >> Huh? pond.dv used to be a perfectly good DV sample.
> > 
> > My judgement is limited since I never read the DV spec, but I find it
> > hard to believe that a file without header, audio or video sections,
> > half of the bits marked as "reserved, must be 1" in our encoder set to 0
> > etc. qualifies as "perfectly good".
> 
> It seems file is weird indeed.
> However, it seems this file has some pattern which could be recognized
> around offset 0x50 (3F 07 00), and after this file seems ok.

Here is a patch that uses this. But, compared to my other suggestion it
might not work for DV files that are broken differently (the section we
are checking for does not seem important, so I would expect there will
be DV files that lack it, even if it violates the specification).
Also it requires seeking.
-------------- next part --------------
Index: libavformat/dv.c
===================================================================
--- libavformat/dv.c	(revision 17914)
+++ libavformat/dv.c	(working copy)
@@ -413,6 +413,12 @@
             av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n");
             return -1;
         }
+        if (url_ftell(s->pb) >= 0x54 && (state & 0xffffff80) == 0x3f070080) {
+            av_log(s, AV_LOG_WARNING, "This DV file looks broken, missing header section?\n");
+            url_fseek(s->pb, -0x54, SEEK_CUR);
+            state = get_be32(s->pb);
+            break;
+        }
         state = (state << 8) | get_byte(s->pb);
     }
     AV_WB32(c->buf, state);
@@ -486,6 +492,8 @@
     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
+        if (i >= 0x54 && (state & 0xffffff80) == 0x3f070080)
+            return AVPROBE_SCORE_MAX/4; // 17 bits are not really reliable
         state = (state << 8) | p->buf[i];
     }
 



More information about the ffmpeg-devel mailing list