diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-03-21 11:05:36 +0300 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-03-23 04:39:14 +0300 |
commit | bc17bd90f51a6eb464746b2d5144e1ec57ca4bfb (patch) | |
tree | 15f4c76281a8ea5d5d5749136f12b358828071c1 /libavformat | |
parent | 78e99e0f32b610a3cf302b2b35e500f4e9eaff07 (diff) |
matroskaenc: simplify get_aac_sample_rates by using ff_mpeg4audio_get_config
This also fixes broken SBR detection, which produced files with double
sample rate since 8ae0fa2.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/matroskaenc.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index fba7dbc564..0ab1832cb7 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -439,28 +439,15 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContex static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int *sample_rate, int *output_sample_rate) { int sri; + MPEG4AudioConfig mp4ac; - if (codec->extradata_size < 2) { - av_log(s, AV_LOG_WARNING, "No AAC extradata, unable to determine samplerate.\n"); + if (ff_mpeg4audio_get_config(&mp4ac, codec->extradata, codec->extradata_size) < 0) { + av_log(s, AV_LOG_WARNING, "Error parsing AAC extradata, unable to determine samplerate.\n"); return; } - sri = ((codec->extradata[0] << 1) & 0xE) | (codec->extradata[1] >> 7); - if (sri > 12) { - av_log(s, AV_LOG_WARNING, "AAC samplerate index out of bounds\n"); - return; - } - *sample_rate = ff_mpeg4audio_sample_rates[sri]; - - // if sbr, get output sample rate as well - if (codec->extradata_size == 5) { - sri = (codec->extradata[4] >> 3) & 0xF; - if (sri > 12) { - av_log(s, AV_LOG_WARNING, "AAC output samplerate index out of bounds\n"); - return; - } - *output_sample_rate = ff_mpeg4audio_sample_rates[sri]; - } + *sample_rate = mp4ac.sample_rate; + *output_sample_rate = mp4ac.ext_sample_rate; } static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec, int native_id, int qt_id) |