From 5f3c3f8c32d20405a2caf7de66aa1ea7f513d4d2 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 24 Jul 2012 09:01:47 +0300 Subject: video, audio: use lavc decoders without codecs.conf entries Add support for using libavcodec decoders that do not have entries in codecs.conf. This is currently only used with demux_lavf, and the codec selection is based on codec_id returned by libavformat. Also modify codec-related terminal output somewhat to make it use information from libavcodec and avoid excessively long default output. The new any-lavc-codec support is implemented with codecs.conf entries that invoke vd_ffmpeg/ad_ffmpeg without directly specifying any libavcodec codec name. In this mode, the decoders now instead select the libavcodec codec based on codec_id previously set by demux_lavf (if any). These new "generic" codecs.conf entries specify "status buggy", so that they're tried after any specific entries with higher-priority status. Add new directive "anyinput" to codecs.conf syntax. This means the entry will always match regardless of fourcc. This is used for the above new codecs.conf entries (so the driver always gets to decide whether to accept the input, and will fail init() if it can't find a suitable codec in libavcodec). Remove parsing support for the obsolete codecs.conf directive "cpuflags". This directive has not had any effect and has not been used in default codecs.conf since many years ago. Shorten codec-related terminal output. When using libavcodec decoders, show the libavcodec long_name field rather than codecs.conf "info" field as the name of the codec. Stop showing the codecs.conf entry name and "vfm/afm" name by default, as these are rarely needed; they're now in verbose output only. Show "VIDEO:" line at VO initialization rather than at demuxer open. This didn't really belong in demuxer code; the new location may show more accurate values (known after decoder has been opened) and works right if video track is changed after initial demuxer open. The vd.c changes (primarily done for terminal output changes) remove round-to-even behavior from code setting dimensions based on aspect ratio. I hope nothing depended on this; at least the even values were not consistently guaranteed anyway, as the rounding code did not run if the video file did not specify a nonzero aspect value. --- codec-cfg.c | 131 ++++++++++++------------------------------------------------ 1 file changed, 26 insertions(+), 105 deletions(-) (limited to 'codec-cfg.c') diff --git a/codec-cfg.c b/codec-cfg.c index 199ba70f19..0c25e73901 100644 --- a/codec-cfg.c +++ b/codec-cfg.c @@ -20,11 +20,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define DEBUG - -//disable asserts -#define NDEBUG - #include #include #include @@ -301,35 +296,11 @@ static int validate_codec(codecs_t *c, int type) if (!c->info) c->info = strdup(c->name); -#if 0 - if (c->fourcc[0] == 0xffffffff) { - mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) does not have FourCC/format!\n", c->name); - return 0; - } -#endif - if (!c->drv) { mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) does not have a driver!\n", c->name); return 0; } -#if 0 -//FIXME: codec->driver == 4;... <- this should not be put in here... -//FIXME: Where are they defined ???????????? - if (!c->dll && (c->driver == 4 || - (c->driver == 2 && type == TYPE_VIDEO))) { - mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) needs a 'dll'!\n", c->name); - return 0; - } -// FIXME: Can guid.f1 be 0? How does one know that it was not given? -// if (!(codec->flags & CODECS_FLAG_AUDIO) && codec->driver == 4) - - if (type == TYPE_VIDEO) - if (c->outfmt[0] == 0xffffffff) { - mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) needs an 'outfmt'!\n", c->name); - return 0; - } -#endif return 1; } @@ -351,35 +322,6 @@ static int add_comment(char *s, char **d) return 1; } -static short get_cpuflags(char *s) -{ - static char *flagstr[] = { - "mmx", - "sse", - "3dnow", - NULL - }; - int i; - short flags = 0; - - do { - for (i = 0; flagstr[i]; i++) - if (!strncmp(s, flagstr[i], strlen(flagstr[i]))) - break; - if (!flagstr[i]) - goto err_out_parse_error; - flags |= 1<status = CODECS_STATUS_PROBLEMS; else goto err_out_parse_error; - } else if (!strcmp(token[0], "cpuflags")) { - if (get_token(1, 1) < 0) - goto err_out_parse_error; - if (!(codec->cpuflags = get_cpuflags(token[0]))) - goto err_out_parse_error; + } else if (!strcmp(token[0], "anyinput")) { + codec->anyinput = true; } else goto err_out_parse_error; } @@ -743,46 +678,32 @@ codecs_t *find_video_codec(unsigned int fourcc, unsigned int *fourccmap, return find_codec(fourcc, fourccmap, start, 0, force); } -codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap, - codecs_t *start, int audioflag, int force) +struct codecs *find_codec(unsigned int fourcc, unsigned int *fourccmap, + codecs_t *start, int audioflag, int force) { - int i, j; - codecs_t *c; + struct codecs *c, *end; -#if 0 - if (start) { - for (/* NOTHING */; start->name; start++) { - for (j = 0; j < CODECS_MAX_FOURCC; j++) { - if (start->fourcc[j] == fourcc) { - if (fourccmap) - *fourccmap = start->fourccmap[j]; - return start; - } - } - } - } else -#endif - { - if (audioflag) { - i = nr_acodecs; - c = audio_codecs; - } else { - i = nr_vcodecs; - c = video_codecs; - } - if(!i) return NULL; - for (/* NOTHING */; i--; c++) { - if(start && c<=start) continue; - for (j = 0; j < CODECS_MAX_FOURCC; j++) { - // FIXME: do NOT hardwire 'null' name here: - if (c->fourcc[j]==fourcc || !strcmp(c->drv,"null")) { - if (fourccmap) - *fourccmap = c->fourccmap[j]; - return c; - } + if (audioflag) { + c = audio_codecs; + end = c + nr_acodecs; + } else { + c = video_codecs; + end = c + nr_vcodecs; + } + if (start) + c = start + 1; // actually starts from the next one after the given one + for (; c < end; c++) { + for (int j = 0; j < CODECS_MAX_FOURCC; j++) { + if (c->fourcc[j] == -1) + break; + if (c->fourcc[j] == fourcc) { + if (fourccmap) + *fourccmap = c->fourccmap[j]; + return c; } - if (force) return c; } + if (c->anyinput || force) + return c; } return NULL; } -- cgit v1.2.3