diff options
Diffstat (limited to 'libmpcodecs/ad_ffmpeg.c')
-rw-r--r-- | libmpcodecs/ad_ffmpeg.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c index 8dc7ab3ed0..8578314bc6 100644 --- a/libmpcodecs/ad_ffmpeg.c +++ b/libmpcodecs/ad_ffmpeg.c @@ -22,7 +22,7 @@ #include "config.h" #include "mp_msg.h" -#include "help_mp.h" +#include "options.h" #include "ad_internal.h" #include "libaf/reorder_ch.h" @@ -54,6 +54,7 @@ static int preinit(sh_audio_t *sh) static int init(sh_audio_t *sh_audio) { + struct MPOpts *opts = sh_audio->opts; int tries = 0; int x; AVCodecContext *lavc_context; @@ -68,14 +69,14 @@ static int init(sh_audio_t *sh_audio) lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll); if(!lavc_codec){ - mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh_audio->codec->dll); + mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Cannot find codec '%s' in libavcodec...\n",sh_audio->codec->dll); return 0; } lavc_context = avcodec_alloc_context(); sh_audio->context=lavc_context; - lavc_context->drc_scale = drc_level; + lavc_context->drc_scale = opts->drc_level; lavc_context->sample_rate = sh_audio->samplerate; lavc_context->bit_rate = sh_audio->i_bps * 8; if(sh_audio->wf){ @@ -109,7 +110,7 @@ static int init(sh_audio_t *sh_audio) /* open it */ if (avcodec_open(lavc_context, lavc_codec) < 0) { - mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_CantOpenCodec); + mp_tmsg(MSGT_DECAUDIO,MSGL_ERR, "Could not open codec.\n"); return 0; } mp_msg(MSGT_DECAUDIO,MSGL_V,"INFO: libavcodec \"%s\" init OK!\n", lavc_codec->name); @@ -144,19 +145,18 @@ static int init(sh_audio_t *sh_audio) mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Unsupported sample format\n"); return 0; } - if(sh_audio->wf){ + /* If the audio is AAC the container level data may be unreliable + * because of SBR handling problems (possibly half real sample rate at + * container level). Default AAC decoding with ad_faad has used codec-level + * values for a long time without generating complaints so it should be OK. + */ + if (sh_audio->wf && lavc_context->codec_id != CODEC_ID_AAC) { // If the decoder uses the wrong number of channels all is lost anyway. // sh_audio->channels=sh_audio->wf->nChannels; - - if (lavc_context->codec_id == CODEC_ID_AAC && - sh_audio->samplerate == 2*sh_audio->wf->nSamplesPerSec) { - mp_msg(MSGT_DECAUDIO, MSGL_WARN, - "Ignoring broken container sample rate for ACC with SBR\n"); - } else if (sh_audio->wf->nSamplesPerSec) - sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; - + if (sh_audio->wf->nSamplesPerSec) + sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; if (sh_audio->wf->nAvgBytesPerSec) - sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; + sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; } sh_audio->samplesize=af_fmt2bits(sh_audio->sample_format)/ 8; return 1; @@ -167,7 +167,7 @@ static void uninit(sh_audio_t *sh) AVCodecContext *lavc_context = sh->context; if (avcodec_close(lavc_context) < 0) - mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec); + mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n"); av_freep(&lavc_context->extradata); av_freep(&lavc_context); } |