diff --git a/decoder_plugins/aac/aac.c b/decoder_plugins/aac/aac.c index 3d9f8c3e..6f763239 100644 --- a/decoder_plugins/aac/aac.c +++ b/decoder_plugins/aac/aac.c @@ -249,13 +249,14 @@ static int aac_count_time (struct aac_data *data) return -1; samples /= frames; - samples /= MIN(2, data->channels); + samples /= data->channels; bytes /= frames; return ((file_size / bytes) * samples) / data->sample_rate; } -static void *aac_open_internal (struct io_stream *stream, const char *fname) +static struct aac_data *aac_open_internal (struct io_stream *stream, + const char *fname, bool timing_only) { struct aac_data *data; NeAACDecConfigurationPtr neaac_cfg; @@ -270,7 +271,7 @@ static void *aac_open_internal (struct io_stream *stream, const char *fname) /* set decoder config */ neaac_cfg = NeAACDecGetCurrentConfiguration(data->decoder); neaac_cfg->outputFormat = FAAD_FMT_16BIT; /* force 16 bit audio */ - neaac_cfg->downMatrix = 1; /* 5.1 -> stereo */ + neaac_cfg->downMatrix = !timing_only; /* 5.1 -> stereo */ neaac_cfg->dontUpSampleImplicitSBR = 0; /* upsample, please! */ NeAACDecSetConfiguration(data->decoder, neaac_cfg); @@ -314,14 +315,16 @@ static void *aac_open_internal (struct io_stream *stream, const char *fname) return data; } - if (data->channels == 6) { - logit ("sample rate %dHz, channels %d (downmixed to stereo)", - data->sample_rate, data->channels); - data->channels = 2; + if (!timing_only) { + if (data->channels == 6) { + logit ("sample rate %dHz, channels %d (downmixed to stereo)", + data->sample_rate, data->channels); + data->channels = 2; + } + else + logit ("sample rate %dHz, channels %d", + data->sample_rate, data->channels); } - else - logit ("sample rate %dHz, channels %d", data->sample_rate, - data->channels); if (!data->sample_rate || !data->channels) { decoder_error (&data->error, ERROR_FATAL, 0, @@ -349,12 +352,11 @@ static void aac_close (void *prv_data) free (data); } - static void *aac_open (const char *file) { struct aac_data *data; - data = aac_open_internal (NULL, file); + data = aac_open_internal (NULL, file, true); if (data->ok) { int duration = -1; @@ -366,7 +368,8 @@ static void *aac_open (const char *file) if (duration > 0 && file_size != -1) avg_bitrate = file_size / duration * 8; aac_close (data); - data = aac_open_internal (NULL, file); + + data = aac_open_internal (NULL, file, false); data->duration = duration; data->avg_bitrate = avg_bitrate; } @@ -378,7 +381,7 @@ static void *aac_open_stream (struct io_stream *stream) { assert (stream != NULL); - return aac_open_internal (stream, NULL); + return aac_open_internal (stream, NULL, false); } static char *get_tag (struct id3_tag *tag, const char *what) @@ -433,7 +436,7 @@ static void aac_info (const char *file_name, if (tags_sel & TAGS_TIME) { struct aac_data *data; - data = aac_open_internal (NULL, file_name); + data = aac_open_internal (NULL, file_name, true); if (data->ok) info->time = aac_count_time (data);