diff options
author | Uoti Urpala <uau@mplayer2.org> | 2012-07-24 09:01:47 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2012-07-24 09:01:47 +0300 |
commit | 5f3c3f8c32d20405a2caf7de66aa1ea7f513d4d2 (patch) | |
tree | 44a68334360af69b358dafc0cecf773ca5871ecc /libmpcodecs/dec_audio.c | |
parent | 65b24e46a1c2f26688458cf16a11733e96da0f22 (diff) | |
download | mpv-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.
Diffstat (limited to 'libmpcodecs/dec_audio.c')
-rw-r--r-- | libmpcodecs/dec_audio.c | 51 |
1 files changed, 27 insertions, 24 deletions
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 } |