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

Reimar Döffinger Reimar.Doeffinger
Sun Mar 8 18:28:29 CET 2009


Hello,
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.
Since it seems all DV decoders and demuxers including ours have no
error checking whatsoever it still plays "fine".
Unfortunately, the recently added autodetection, that also allows to
play badly cut DV files, can not handle it.
Thus attached patch adds a second DV demuxers, especially for such files
which does not do any more checking than necessary as originally.
Why a different demuxer? That allows to behave differently depending on
whether the probe function found something or not, while at the same
time letting the user force a certain behaviour.
-------------- next part --------------
Index: libavformat/dv.c
===================================================================
--- libavformat/dv.c	(revision 17865)
+++ libavformat/dv.c	(working copy)
@@ -408,6 +408,7 @@
         return -1;
 
     state = get_be32(s->pb);
+    if (s->iformat->read_probe)
     while ((state & 0xffffff7f) != 0x1f07003f) {
         if (url_feof(s->pb)) {
             av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n");
@@ -502,6 +503,19 @@
     dv_read_packet,
     dv_read_close,
     dv_read_seek,
+};
+#endif
+
+#if CONFIG_DV_BROKEN_DEMUXER
+AVInputFormat dv_broken_demuxer = {
+    "dv_broken",
+    NULL_IF_CONFIG_SMALL("broken DV video format"),
+    sizeof(RawDVContext),
+    NULL,
+    dv_read_header,
+    dv_read_packet,
+    dv_read_close,
+    dv_read_seek,
     .extensions = "dv,dif",
 };
 #endif
Index: libavformat/Makefile
===================================================================
--- libavformat/Makefile	(revision 17865)
+++ libavformat/Makefile	(working copy)
@@ -45,6 +45,7 @@
 OBJS-$(CONFIG_DTS_DEMUXER)               += raw.o id3v2.o
 OBJS-$(CONFIG_DTS_MUXER)                 += raw.o
 OBJS-$(CONFIG_DV_DEMUXER)                += dv.o
+OBJS-$(CONFIG_DV_BROKEN_DEMUXER)         += dv.o
 OBJS-$(CONFIG_DV_MUXER)                  += dvenc.o
 OBJS-$(CONFIG_DXA_DEMUXER)               += dxa.o riff.o
 OBJS-$(CONFIG_EA_CDATA_DEMUXER)          += eacdata.o
Index: libavformat/allformats.c
===================================================================
--- libavformat/allformats.c	(revision 17865)
+++ libavformat/allformats.c	(working copy)
@@ -73,6 +73,7 @@
     REGISTER_DEMUXER  (DSICIN, dsicin);
     REGISTER_MUXDEMUX (DTS, dts);
     REGISTER_MUXDEMUX (DV, dv);
+    REGISTER_DEMUXER  (DV_BROKEN, dv_broken);
     REGISTER_DEMUXER  (DXA, dxa);
     REGISTER_DEMUXER  (EA, ea);
     REGISTER_DEMUXER  (EA_CDATA, ea_cdata);



More information about the ffmpeg-devel mailing list