[MPlayer-dev-eng] [PATCH] add lavfpref demuxer for formats where lavf is preferred over native demuxers
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Apr 10 18:48:40 CEST 2007
Hello,
On Sat, Apr 07, 2007 at 08:16:28PM +0200, Reimar D?ffinger wrote:
> wanted to do this since a long time.
> It is a demuxer that does almost the same as the normal lavf one, only
> that it only accepts some formats and is tested much earlier.
> Does it look okay?
> I also removed a few entries from extension.c that should not be needed
> anymore.
Since the discussion got a bit side-tracked, I hereby threaten to apply
attached patch (only added the change to DEMUXER_TYPE_MAX) unless there
are objections.
Suggestions for more formats in preferred_list are welcome, but not
relevant to this patch, this is first of all about adding the
functionality, getting the details straight is the next step.
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demuxer.c
===================================================================
--- libmpdemux/demuxer.c (revision 22937)
+++ libmpdemux/demuxer.c (working copy)
@@ -64,6 +64,7 @@
extern demuxer_desc_t demuxer_desc_mpeg_ty;
extern demuxer_desc_t demuxer_desc_rtp;
extern demuxer_desc_t demuxer_desc_lavf;
+extern demuxer_desc_t demuxer_desc_lavf_preferred;
extern demuxer_desc_t demuxer_desc_aac;
extern demuxer_desc_t demuxer_desc_nut;
@@ -74,6 +75,7 @@
&demuxer_desc_tv,
#endif
&demuxer_desc_mf,
+ &demuxer_desc_lavf_preferred,
&demuxer_desc_avi,
&demuxer_desc_y4m,
&demuxer_desc_asf,
Index: libmpdemux/demuxer.h
===================================================================
--- libmpdemux/demuxer.h (revision 22940)
+++ libmpdemux/demuxer.h (working copy)
@@ -55,11 +55,12 @@
#define DEMUXER_TYPE_MPEG_PES 41
#define DEMUXER_TYPE_MPEG_GXF 42
#define DEMUXER_TYPE_NUT 43
+#define DEMUXER_TYPE_LAVF_PREFERRED 44
// This should always match the higest demuxer type number.
// Unless you want to disallow users to force the demuxer to some types
#define DEMUXER_TYPE_MIN 0
-#define DEMUXER_TYPE_MAX 43
+#define DEMUXER_TYPE_MAX 44
#define DEMUXER_TYPE_DEMUXERS (1<<16)
// A virtual demuxer type for the network code
Index: libmpdemux/demux_lavf.c
===================================================================
--- libmpdemux/demux_lavf.c (revision 22937)
+++ libmpdemux/demux_lavf.c (working copy)
@@ -210,7 +210,30 @@
return DEMUXER_TYPE_LAVF;
}
+
+static const char *preferred_list[] = {
+ "dxa",
+ "wv",
+ "nuv",
+ "nut",
+ "gxf",
+ "mxf",
+ NULL
+};
+
+static int lavf_check_preferred_file(demuxer_t *demuxer){
+ if (lavf_check_file(demuxer)) {
+ char **p = preferred_list;
+ lavf_priv_t *priv = demuxer->priv;
+ while (*p) {
+ if (strcmp(*p, priv->avif->name) == 0)
+ return DEMUXER_TYPE_LAVF_PREFERRED;
+ p++;
+ }
+ }
+ return 0;
+}
static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
AVFormatContext *avfc;
AVFormatParameters ap;
@@ -609,3 +662,18 @@
demux_lavf_control
};
+demuxer_desc_t demuxer_desc_lavf_preferred = {
+ "libavformat preferred demuxer",
+ "lavfpref",
+ "libavformat",
+ "Michael Niedermayer",
+ "supports many formats, requires libavformat",
+ DEMUXER_TYPE_LAVF_PREFERRED,
+ 0, // Check after other demuxer
+ lavf_check_preferred_file,
+ demux_lavf_fill_buffer,
+ demux_open_lavf,
+ demux_close_lavf,
+ demux_seek_lavf,
+ demux_lavf_control
+};
Index: libmpdemux/extension.c
===================================================================
--- libmpdemux/extension.c (revision 22938)
+++ libmpdemux/extension.c (working copy)
@@ -57,20 +57,16 @@
#ifdef USE_WIN32DLL
{ "avs", DEMUXER_TYPE_AVS },
#endif
- { "nut", DEMUXER_TYPE_LAVF },
{ "swf", DEMUXER_TYPE_LAVF },
{ "flv", DEMUXER_TYPE_LAVF },
{ "302", DEMUXER_TYPE_LAVF },
{ "264", DEMUXER_TYPE_H264_ES },
{ "26l", DEMUXER_TYPE_H264_ES },
{ "ac3", DEMUXER_TYPE_LAVF },
- { "wv", DEMUXER_TYPE_LAVF },
// At least the following are hacks against broken autodetection
// that should not be there
-// demux_audio is too greedy
- { "dxa", DEMUXER_TYPE_LAVF },
};
int demuxer_type_by_filename(char* filename){
More information about the MPlayer-dev-eng
mailing list