The sample rates have already been checked generically via AVCodec.supported_samplerates.
Unified · Split
| @@ -1235,14 +1235,13 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) · 1234 unmodified lines | ||
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | 1237 | /* Samplerate */ |
| 1238 | − for (i = 0; i < 16; i++) | |
| 1239 | − if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i]) | |
| 1238 | + for (int i = 0;; i++) { | |
| 1239 | + av_assert1(i < 13); | |
| 1240 | + if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i]) { | |
| 1241 | + s->samplerate_index = i; | |
| 1240 | 1242 | break; |
| 1241 | − s->samplerate_index = i; | |
| 1242 | − ERROR_IF(s->samplerate_index == 16 || | |
| 1243 | − s->samplerate_index >= ff_aac_swb_size_1024_len || | |
| 1244 | − s->samplerate_index >= ff_aac_swb_size_128_len, | |
| 1245 | − "Unsupported sample rate %d\n", avctx->sample_rate); | |
| 1243 | + } | |
| 1244 | + } | |
| 1246 | 1245 | |
| 1247 | 1246 | /* Bitrate limiting */ |
| 1248 | 1247 | WARN_IF(1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * s->channels, |
| @@ -103,6 +103,3 @@ const uint8_t *const ff_aac_swb_size_1024[] = { · 102 unmodified lines | ||
| 103 | 103 | swb_size_1024_16, swb_size_1024_16, swb_size_1024_8, |
| 104 | 104 | swb_size_1024_8 |
| 105 | 105 | }; |
| 106 | − | |
| 107 | −const int ff_aac_swb_size_128_len = FF_ARRAY_ELEMS(ff_aac_swb_size_128); | |
| 108 | −const int ff_aac_swb_size_1024_len = FF_ARRAY_ELEMS(ff_aac_swb_size_1024); | |
| @@ -41,9 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | #define AAC_MAX_CHANNELS 16 |
| 42 | 42 | |
| 43 | 43 | extern const uint8_t *const ff_aac_swb_size_1024[]; |
| 44 | −extern const int ff_aac_swb_size_1024_len; | |
| 45 | 44 | extern const uint8_t *const ff_aac_swb_size_128[]; |
| 46 | −extern const int ff_aac_swb_size_128_len; | |
| 47 | 45 | |
| 48 | 46 | /* Supported layouts without using a PCE */ |
| 49 | 47 | static const AVChannelLayout aac_normal_chan_layouts[7] = { |
| @@ -23,6 +23,10 @@ · 22 unmodified lines | ||
| 23 | 23 | #ifndef AVCODEC_MPEG4AUDIO_SAMPLE_RATES_H |
| 24 | 24 | #define AVCODEC_MPEG4AUDIO_SAMPLE_RATES_H |
| 25 | 25 | |
| 26 | +// This table contains only 13 real elements and is padded with zeroes. | |
| 27 | +// It is used by the AAC encoder as sample rate table, so the encoder | |
| 28 | +// needs to actually support all of these rates and it needs to have | |
| 29 | +// a trailing zero. | |
| 26 | 30 | const int ff_mpeg4audio_sample_rates[16] = { |
| 27 | 31 | 96000, 88200, 64000, 48000, 44100, 32000, |
| 28 | 32 | 24000, 22050, 16000, 12000, 11025, 8000, 7350 |