summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-07-24 09:01:47 +0300
committerUoti Urpala <uau@mplayer2.org>2012-07-24 09:01:47 +0300
commit5f3c3f8c32d20405a2caf7de66aa1ea7f513d4d2 (patch)
tree44a68334360af69b358dafc0cecf773ca5871ecc
parent65b24e46a1c2f26688458cf16a11733e96da0f22 (diff)
downloadmpv-5f3c3f8c32d20405a2caf7de66aa1ea7f513d4d2.tar.bz2
mpv-5f3c3f8c32d20405a2caf7de66aa1ea7f513d4d2.tar.xz
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.
-rw-r--r--codec-cfg.c131
-rw-r--r--codec-cfg.h5
-rw-r--r--etc/codecs.conf15
-rw-r--r--libmpcodecs/ad_ffmpeg.c39
-rw-r--r--libmpcodecs/dec_audio.c51
-rw-r--r--libmpcodecs/dec_video.c15
-rw-r--r--libmpcodecs/mpc_info.h1
-rw-r--r--libmpcodecs/vd.c28
-rw-r--r--libmpcodecs/vd_ffmpeg.c43
-rw-r--r--libmpdemux/demux_lavf.c12
-rw-r--r--libmpdemux/demuxer.c30
-rw-r--r--libmpdemux/stheader.h2
-rw-r--r--mplayer.c5
13 files changed, 175 insertions, 202 deletions
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 <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@@ -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<<i;
- s += strlen(flagstr[i]);
- } while (*(s++) == ',');
-
- if (*(--s) != '\0')
- goto err_out_parse_error;
-
- return flags;
-err_out_parse_error:
- return 0;
-}
-
static struct bstr filetext;
static int line_num = 0;
static char *line;
@@ -543,15 +485,11 @@ int parse_codec_cfg(const char *cfgfile)
codec_type = TYPE_VIDEO;
nr_codecsp = &nr_vcodecs;
codecsp = &video_codecs;
- } else if (*token[0] == 'a') {
+ } else {
+ assert(*token[0] == 'a');
codec_type = TYPE_AUDIO;
nr_codecsp = &nr_acodecs;
codecsp = &audio_codecs;
-#ifdef DEBUG
- } else {
- mp_msg(MSGT_CODECCFG,MSGL_ERR,"picsba\n");
- goto err_out;
-#endif
}
if (!(*codecsp = realloc(*codecsp,
sizeof(codecs_t) * (*nr_codecsp + 2)))) {
@@ -671,11 +609,8 @@ int parse_codec_cfg(const char *cfgfile)
codec->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;
}
diff --git a/codec-cfg.h b/codec-cfg.h
index 19fd47d94c..480f570bba 100644
--- a/codec-cfg.h
+++ b/codec-cfg.h
@@ -19,6 +19,8 @@
#ifndef MPLAYER_CODEC_CFG_H
#define MPLAYER_CODEC_CFG_H
+#include <stdbool.h>
+
#define CODECS_MAX_FOURCC 92
#define CODECS_MAX_OUTFMT 16
#define CODECS_MAX_INFMT 16
@@ -67,10 +69,9 @@ typedef struct codecs {
char *dll;
char* drv;
GUID guid;
-// short driver;
short flags;
short status;
- short cpuflags;
+ bool anyinput;
} codecs_t;
int parse_codec_cfg(const char *cfgfile);
diff --git a/etc/codecs.conf b/etc/codecs.conf
index 2767c7ac3c..8f0220fece 100644
--- a/etc/codecs.conf
+++ b/etc/codecs.conf
@@ -3,12 +3,18 @@
; Before editing this file, please read DOCS/tech/codecs.conf.txt !
;=============================================================================
-release 20120702
+release 20120717
;=============================================================================
; VIDEO CODECS
;=============================================================================
+videocodec lavc
+ info "Generic libavcodec decoder"
+ status buggy
+ driver ffmpeg
+ anyinput
+
videocodec ffanm
info "FFmpeg Deluxe Paint Animation"
status working
@@ -3485,6 +3491,7 @@ videocodec null
status crashing
comment "for unknown/unsupported codecs or testing"
driver null
+ anyinput
out YV12
out I420
out YUY2
@@ -3496,6 +3503,12 @@ videocodec null
; AUDIO CODECS
;=============================================================================
+audiocodec lavc
+ info "Generic libavcodec decoder"
+ status buggy
+ driver ffmpeg
+ anyinput
+
audiocodec wma9dmo
info "Windows Media Audio 9 DMO"
status working
diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c
index 0bfc5e5f0a..a20689eab8 100644
--- a/libmpcodecs/ad_ffmpeg.c
+++ b/libmpcodecs/ad_ffmpeg.c
@@ -38,11 +38,12 @@
static const ad_info_t info =
{
- "FFmpeg/libavcodec audio decoders",
+ "libavcodec audio decoders",
"ffmpeg",
- "Nick Kurshev",
- "ffmpeg.sf.net",
- ""
+ "",
+ "",
+ "",
+ .print_name = "libavcodec",
};
LIBAD_EXTERN(ffmpeg)
@@ -112,16 +113,31 @@ static int init(sh_audio_t *sh_audio)
AVCodecContext *lavc_context;
AVCodec *lavc_codec;
- mp_msg(MSGT_DECAUDIO, MSGL_V, "FFmpeg's libavcodec audio codec\n");
-
- lavc_codec = avcodec_find_decoder_by_name(sh_audio->codec->dll);
- if (!lavc_codec) {
- mp_tmsg(MSGT_DECAUDIO, MSGL_ERR,
- "Cannot find codec '%s' in libavcodec...\n",
- sh_audio->codec->dll);
+ if (sh_audio->codec->dll) {
+ lavc_codec = avcodec_find_decoder_by_name(sh_audio->codec->dll);
+ if (!lavc_codec) {
+ mp_tmsg(MSGT_DECAUDIO, MSGL_ERR,
+ "Cannot find codec '%s' in libavcodec...\n",
+ sh_audio->codec->dll);
+ return 0;
+ }
+ } else if (!sh_audio->libav_codec_id) {
+ mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "No Libav codec ID known. "
+ "Generic lavc decoder is not applicable.\n");
return 0;
+ } else {
+ lavc_codec = avcodec_find_decoder(sh_audio->libav_codec_id);
+ if (!lavc_codec) {
+ mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Libavcodec has no decoder "
+ "for this codec\n");
+ return 0;
+ }
}
+ sh_audio->codecname = lavc_codec->long_name;
+ if (!sh_audio->codecname)
+ sh_audio->codecname = lavc_codec->name;
+
struct priv *ctx = talloc_zero(NULL, struct priv);
sh_audio->context = ctx;
lavc_context = avcodec_alloc_context3(lavc_codec);
@@ -217,6 +233,7 @@ static int init(sh_audio_t *sh_audio)
static void uninit(sh_audio_t *sh)
{
+ sh->codecname = NULL;
struct priv *ctx = sh->context;
if (!ctx)
return;
diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c
index 2445649075..59c05a187a 100644
--- a/libmpcodecs/dec_audio.c
+++ b/libmpcodecs/dec_audio.c
@@ -96,14 +96,12 @@ static int init_audio_codec(sh_audio_t *sh_audio)
sh_audio->audio_out_minsize, base_size, sh_audio->a_buffer_size);
sh_audio->a_buffer = av_mallocz(sh_audio->a_buffer_size);
- if (!sh_audio->a_buffer) {
- mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Cannot allocate audio out buffer.\n");
- return 0;
- }
+ if (!sh_audio->a_buffer)
+ abort();
sh_audio->a_buffer_len = 0;
if (!sh_audio->ad_driver->init(sh_audio)) {
- mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "ADecoder init failed :(\n");
+ mp_tmsg(MSGT_DECAUDIO, MSGL_V, "ADecoder init failed :(\n");
uninit_audio(sh_audio); // free buffers
return 0;
}
@@ -111,7 +109,8 @@ static int init_audio_codec(sh_audio_t *sh_audio)
sh_audio->initialized = 1;
if (!sh_audio->channels || !sh_audio->samplerate) {
- mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "Unknown/missing audio format -> no sound\n");
+ mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Audio decoder did not specify "
+ "audio format!\n");
uninit_audio(sh_audio); // free buffers
return 0;
}
@@ -119,18 +118,6 @@ static int init_audio_codec(sh_audio_t *sh_audio)
if (!sh_audio->o_bps)
sh_audio->o_bps = sh_audio->channels * sh_audio->samplerate
* sh_audio->samplesize;
-
- mp_msg(MSGT_DECAUDIO, MSGL_INFO,
- "AUDIO: %d Hz, %d ch, %s, %3.1f kbit/%3.2f%% (ratio: %d->%d)\n",
- sh_audio->samplerate, sh_audio->channels,
- af_fmt2str_short(sh_audio->sample_format),
- sh_audio->i_bps * 8 * 0.001,
- ((float) sh_audio->i_bps / sh_audio->o_bps) * 100.0,
- sh_audio->i_bps, sh_audio->o_bps);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_AUDIO_BITRATE=%d\nID_AUDIO_RATE=%d\n" "ID_AUDIO_NCH=%d\n",
- sh_audio->i_bps * 8, sh_audio->samplerate, sh_audio->channels);
-
return 1;
}
@@ -181,13 +168,12 @@ static int init_audio(sh_audio_t *sh_audio, char *codecname, char *afm,
}
// it's available, let's try to init!
// init()
- mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Opening audio decoder: [%s] %s\n",
+ mp_tmsg(MSGT_DECAUDIO, MSGL_V, "Opening audio decoder: [%s] %s\n",
mpadec->info->short_name, mpadec->info->name);
sh_audio->ad_driver = mpadec;
if (!init_audio_codec(sh_audio)) {
- mp_tmsg(MSGT_DECAUDIO, MSGL_WARN,
- "Could not open audio decoder %s.\n",
- mpadec->info->short_name);
+ mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "Audio decoder init failed for "
+ "codecs.conf entry \"%s\".\n", sh_audio->codec->name);
continue; // try next...
}
// Yeah! We got it!
@@ -251,8 +237,25 @@ int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list,
return 0; // failed
}
- mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Selected audio codec: [%s] afm: %s (%s)\n",
- sh_audio->codec->name, sh_audio->codec->drv, sh_audio->codec->info);
+ mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Selected audio codec: %s [%s]\n",
+ sh_audio->codecname ? sh_audio->codecname : sh_audio->codec->info,
+ sh_audio->ad_driver->info->print_name ?
+ sh_audio->ad_driver->info->print_name :
+ sh_audio->ad_driver->info->short_name);
+ mp_tmsg(MSGT_DECAUDIO, MSGL_V,
+ "Audio codecs.conf entry: %s (%s) afm: %s\n",
+ sh_audio->codec->name, sh_audio->codec->info, sh_audio->codec->drv);
+ mp_msg(MSGT_DECAUDIO, MSGL_INFO,
+ "AUDIO: %d Hz, %d ch, %s, %3.1f kbit/%3.2f%% (ratio: %d->%d)\n",
+ sh_audio->samplerate, sh_audio->channels,
+ af_fmt2str_short(sh_audio->sample_format),
+ sh_audio->i_bps * 8 * 0.001,
+ ((float) sh_audio->i_bps / sh_audio->o_bps) * 100.0,
+ sh_audio->i_bps, sh_audio->o_bps);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_AUDIO_BITRATE=%d\nID_AUDIO_RATE=%d\n" "ID_AUDIO_NCH=%d\n",
+ sh_audio->i_bps * 8, sh_audio->samplerate, sh_audio->channels);
+
return 1; // success
}
diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c
index 14cf029fbe..baa8467c1e 100644
--- a/libmpcodecs/dec_video.c
+++ b/libmpcodecs/dec_video.c
@@ -310,13 +310,14 @@ static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
// init()
const struct vd_functions *vd = sh_video->vd_driver;
- mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Opening video decoder: [%s] %s\n",
+ mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Opening video decoder: [%s] %s\n",
vd->info->short_name, vd->info->name);
// clear vf init error, it is no longer relevant
if (sh_video->vf_initialized < 0)
sh_video->vf_initialized = 0;
if (!vd->init(sh_video)) {
- mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "VDecoder init failed :(\n");
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Video decoder init failed for "
+ "codecs.conf entry \"%s\".\n", sh_video->codec->name);
sh_video->disp_w = orig_w;
sh_video->disp_h = orig_h;
if (sh_video->bih) {
@@ -389,8 +390,14 @@ int init_best_video_codec(sh_video_t *sh_video, char **video_codec_list,
return 0; // failed
}
- mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Selected video codec: [%s] vfm: %s (%s)\n",
- sh_video->codec->name, sh_video->codec->drv, sh_video->codec->info);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Selected video codec: %s [%s]\n",
+ sh_video->codecname ? sh_video->codecname : sh_video->codec->info,
+ sh_video->vd_driver->info->print_name ?
+ sh_video->vd_driver->info->print_name :
+ sh_video->vd_driver->info->short_name);
+ mp_tmsg(MSGT_DECVIDEO, MSGL_V,
+ "Video codecs.conf entry: %s (%s) vfm: %s\n",
+ sh_video->codec->name, sh_video->codec->info, sh_video->codec->drv);
return 1; // success
}
diff --git a/libmpcodecs/mpc_info.h b/libmpcodecs/mpc_info.h
index 45139947cb..de1631cad8 100644
--- a/libmpcodecs/mpc_info.h
+++ b/libmpcodecs/mpc_info.h
@@ -31,6 +31,7 @@ struct mp_codec_info
const char *author;
/* any additional comments */
const char *comment;
+ const char *print_name;
};
#define CONTROL_OK 1
diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c
index 5a96e07783..a883f257b5 100644
--- a/libmpcodecs/vd.c
+++ b/libmpcodecs/vd.c
@@ -125,6 +125,11 @@ int mpcodecs_config_vo2(sh_video_t *sh, int w, int h,
if (h)
sh->disp_h = h;
+ mp_msg(MSGT_DECVIDEO, MSGL_INFO,
+ "VIDEO: %dx%d %5.3f fps %5.1f kbps (%4.1f kB/s)\n",
+ sh->disp_w, sh->disp_h, sh->fps, sh->i_bps * 0.008,
+ sh->i_bps / 1000.0);
+
if (!sh->disp_w || !sh->disp_h)
return 0;
@@ -293,22 +298,23 @@ int mpcodecs_config_vo2(sh_video_t *sh, int w, int h,
}
}
if (sh->aspect > 0.01) {
- int w;
- mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Movie-Aspect is %.2f:1 - prescaling to correct movie aspect.\n",
- sh->aspect);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n",
sh->aspect);
- w = (int) ((float) screen_size_y * sh->aspect);
- w += w % 2; // round
+ int w = screen_size_y * sh->aspect;
+ int h = screen_size_y;
// we don't like horizontal downscale || user forced width:
if (w < screen_size_x || opts->screen_size_xy > 8) {
- screen_size_y =
- (int) ((float) screen_size_x * (1.0 / sh->aspect));
- screen_size_y += screen_size_y % 2; // round
- } else
- screen_size_x = w; // keep new width
+ w = screen_size_x;
+ h = screen_size_x / sh->aspect;
+ }
+ if (abs(screen_size_x - w) >= 4 || abs(screen_size_y - h) >= 4) {
+ screen_size_x = w;
+ screen_size_y = h;
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Aspect ratio is %.2f:1 - "
+ "scaling to correct movie aspect.\n", sh->aspect);
+ }
} else {
- mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Movie-Aspect is undefined - no prescaling applied.\n");
+ mp_tmsg(MSGT_CPLAYER, MSGL_V, "Movie-Aspect is undefined - no prescaling applied.\n");
}
}
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 5a45fef6d8..b34b5b5593 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -43,11 +43,12 @@
#include "osdep/numcores.h"
static const vd_info_t info = {
- "FFmpeg's libavcodec codec family",
+ "libavcodec video codecs",
"ffmpeg",
- "A'rpi",
- "A'rpi, Michael, Alex",
- "native codecs"
+ "",
+ "",
+ "native codecs",
+ .print_name = "libavcodec",
};
#include "libavcodec/avcodec.h"
@@ -129,14 +130,32 @@ static int init(sh_video_t *sh)
ctx = sh->context = talloc_zero(NULL, vd_ffmpeg_ctx);
- lavc_codec = avcodec_find_decoder_by_name(sh->codec->dll);
- if (!lavc_codec) {
- mp_tmsg(MSGT_DECVIDEO, MSGL_ERR,
- "Cannot find codec '%s' in libavcodec...\n", sh->codec->dll);
- uninit(sh);
+ if (sh->codec->dll) {
+ lavc_codec = avcodec_find_decoder_by_name(sh->codec->dll);
+ if (!lavc_codec) {
+ mp_tmsg(MSGT_DECVIDEO, MSGL_ERR,
+ "Cannot find codec '%s' in libavcodec...\n",
+ sh->codec->dll);
+ uninit(sh);
+ return 0;
+ }
+ } else if (!sh->libav_codec_id) {
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "No Libav codec ID known. "
+ "Generic lavc decoder is not applicable.\n");
return 0;
+ } else {
+ lavc_codec = avcodec_find_decoder(sh->libav_codec_id);
+ if (!lavc_codec) {
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Libavcodec has no decoder "
+ "for this codec\n");
+ return 0;
+ }
}
+ sh->codecname = lavc_codec->long_name;
+ if (!sh->codecname)
+ sh->codecname = lavc_codec->name;
+
if (sh->opts->vd_use_slices
&& (lavc_codec->capabilities & CODEC_CAP_DRAW_HORIZ_BAND)
&& !do_vis_debug)
@@ -191,7 +210,7 @@ static int init(sh_video_t *sh)
if (lavc_param->threads > 1) {
ctx->do_dr1 = false;
ctx->do_slices = false;
- mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Asking decoder to use "
+ mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Asking decoder to use "
"%d threads if supported.\n", lavc_param->threads);
}
@@ -320,8 +339,7 @@ static int init(sh_video_t *sh)
uninit(sh);
return 0;
}
- mp_msg(MSGT_DECVIDEO, MSGL_V, "INFO: libavcodec init OK!\n");
- return 1; //mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, IMGFMT_YV12);
+ return 1;
}
static void uninit(sh_video_t *sh)
@@ -329,6 +347,7 @@ static void uninit(sh_video_t *sh)
vd_ffmpeg_ctx *ctx = sh->context;
AVCodecContext *avctx = ctx->avctx;
+ sh->codecname = NULL;
if (sh->opts->lavc_param.vstats && avctx->coded_frame) {
for (int i = 1; i < 32; i++)
mp_msg(MSGT_DECVIDEO, MSGL_INFO,
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index 62cb0bad1b..68dd218ad7 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -310,6 +310,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
break;
stream_type = "audio";
priv->astreams[priv->audio_streams] = i;
+ sh_audio->libav_codec_id = codec->codec_id;
wf = calloc(sizeof(*wf) + codec->extradata_size, 1);
// mp4a tag is used for all mp4 files no matter what they actually contain
if (codec->codec_tag == MKTAG('m', 'p', '4', 'a'))
@@ -387,6 +388,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
break;
stream_type = "video";
priv->vstreams[priv->video_streams] = i;
+ sh_video->libav_codec_id = codec->codec_id;
bih = calloc(sizeof(*bih) + codec->extradata_size, 1);
if (codec->codec_id == CODEC_ID_RAWVIDEO) {
@@ -398,9 +400,14 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
}
if (!codec->codec_tag)
codec->codec_tag = avcodec_pix_fmt_to_codec_tag(codec->pix_fmt);
- }
- if (!codec->codec_tag)
+ } else if (!codec->codec_tag) {
codec->codec_tag = mp_taglist_video(codec->codec_id);
+ /* 0 might mean either unset or rawvideo; if codec_id
+ * was not RAWVIDEO assume it's unset
+ */
+ if (!codec->codec_tag)
+ codec->codec_tag = -1;
+ }
bih->biSize = sizeof(*bih) + codec->extradata_size;
bih->biWidth = codec->width;
bih->biHeight = codec->height;
@@ -492,6 +499,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
break;
stream_type = "subtitle";
priv->sstreams[priv->sub_streams] = i;
+ sh_sub->libav_codec_id = codec->codec_id;
sh_sub->type = type;
if (codec->extradata_size) {
sh_sub->extradata = malloc(codec->extradata_size);
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index 0ff734b074..8691880fe1 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -998,11 +998,8 @@ static struct demuxer *demux_open_stream(struct MPOpts *opts,
if (!desc)
// should only happen with obsolete -demuxer 99 numeric format
return NULL;
- demuxer = open_given_type(opts, desc, stream, force, audio_id,
- video_id, sub_id, filename, params);
- if (demuxer)
- goto dmx_open;
- return NULL;
+ return open_given_type(opts, desc, stream, force, audio_id,
+ video_id, sub_id, filename, params);
}
// Test demuxers with safe file checks
@@ -1011,7 +1008,7 @@ static struct demuxer *demux_open_stream(struct MPOpts *opts,
demuxer = open_given_type(opts, desc, stream, false, audio_id,
video_id, sub_id, filename, params);
if (demuxer)
- goto dmx_open;
+ return demuxer;
}
}
@@ -1024,7 +1021,7 @@ static struct demuxer *demux_open_stream(struct MPOpts *opts,
demuxer = open_given_type(opts, desc, stream, false, audio_id,
video_id, sub_id, filename, params);
if (demuxer)
- goto dmx_open;
+ return demuxer;
}
// Finally try detection for demuxers with unsafe checks
@@ -1033,28 +1030,11 @@ static struct demuxer *demux_open_stream(struct MPOpts *opts,
demuxer = open_given_type(opts, desc, stream, false, audio_id,
video_id, sub_id, filename, params);
if (demuxer)
- goto dmx_open;
+ return demuxer;
}
}
return NULL;
-
- dmx_open:
-
- if (demuxer->type == DEMUXER_TYPE_PLAYLIST)
- return demuxer;
-
- struct sh_video *sh_video = demuxer->video->sh;
- if (sh_video && sh_video->bih) {
- int biComp = le2me_32(sh_video->bih->biCompression);
- mp_msg(MSGT_DEMUX, MSGL_INFO,
- "VIDEO: [%.4s] %dx%d %dbpp %5.3f fps %5.1f kbps (%4.1f kbyte/s)\n",
- (char *) &biComp, sh_video->bih->biWidth,
- sh_video->bih->biHeight, sh_video->bih->biBitCount,
- sh_video->fps, sh_video->i_bps * 0.008f,
- sh_video->i_bps / 1024.0f);
- }
- return demuxer;
}
struct demuxer *demux_open(struct MPOpts *opts, stream_t *vs, int file_format,
diff --git a/libmpdemux/stheader.h b/libmpdemux/stheader.h
index 06f52324e5..58390650b2 100644
--- a/libmpdemux/stheader.h
+++ b/libmpdemux/stheader.h
@@ -33,6 +33,7 @@ struct demuxer;
struct demux_stream *ds; \
struct codecs *codec; \
unsigned int format; \
+ int libav_codec_id; \
int initialized; \
/* number of seconds stream should be delayed \
* (according to dwStart or similar) */ \
@@ -46,6 +47,7 @@ struct demuxer;
double pts; \
/* decoder context */ \
void *context; \
+ const char *codecname; \
char *lang; /* track language */ \
char *title; /* track title */ \
bool default_track; \
diff --git a/mplayer.c b/mplayer.c
index 2a87de2c2c..934ba3a819 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1770,14 +1770,11 @@ void reinit_audio_chain(struct MPContext *mpctx)
}
if (!(mpctx->initialized_flags & INITIALIZED_ACODEC)) {
current_module = "init_audio_codec";
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n");
if (!init_best_audio_codec(mpctx->sh_audio, audio_codec_list, audio_fm_list))
goto init_error;
mpctx->initialized_flags |= INITIALIZED_ACODEC;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n");
}
-
current_module = "af_preinit";
if (!(mpctx->initialized_flags & INITIALIZED_AO)) {
mpctx->initialized_flags |= INITIALIZED_AO;
@@ -2696,9 +2693,7 @@ int reinit_video_chain(struct MPContext *mpctx)
current_module = "init_video_codec";
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n");
init_best_video_codec(sh_video, video_codec_list, video_fm_list);
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n");
if (!sh_video->initialized) {
if (!opts->fixed_vo)