History

avcodec/aacenc: Remove always-false check

The sample rates have already been checked generically via AVCodec.supported_samplerates.

Andreas Rheinhardt committed 1 year ago

Commit ab1bc2f1 parent 516bcfc4 files · +10 −12Browse files

Showing the changes to libavcodec (4 of 4 files). Show all

Unified · Split

4 files
  1. libavcodec/aacenc.c +6 −7
  2. libavcodec/aacenctab.c +0 −3
  3. libavcodec/aacenctab.h +0 −2
  4. libavcodec/mpeg4audio_sample_rates.h +4 −0
libavcodec/aacenc.c+6−7
@@ -1235,14 +1235,13 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) · 1234 unmodified lines
12351235 }
12361236
12371237 /* 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;
12401242 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+ }
12461245
12471246 /* Bitrate limiting */
12481247 WARN_IF(1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * s->channels,
libavcodec/aacenctab.c+0−3
@@ -103,6 +103,3 @@ const uint8_t *const ff_aac_swb_size_1024[] = { · 102 unmodified lines
103103 swb_size_1024_16, swb_size_1024_16, swb_size_1024_8,
104104 swb_size_1024_8
105105 };
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);
libavcodec/aacenctab.h+0−2
@@ -41,9 +41,7 @@ · 40 unmodified lines
4141 #define AAC_MAX_CHANNELS 16
4242
4343 extern const uint8_t *const ff_aac_swb_size_1024[];
44−extern const int ff_aac_swb_size_1024_len;
4544 extern const uint8_t *const ff_aac_swb_size_128[];
46−extern const int ff_aac_swb_size_128_len;
4745
4846 /* Supported layouts without using a PCE */
4947 static const AVChannelLayout aac_normal_chan_layouts[7] = {
libavcodec/mpeg4audio_sample_rates.h+4−0
@@ -23,6 +23,10 @@ · 22 unmodified lines
2323 #ifndef AVCODEC_MPEG4AUDIO_SAMPLE_RATES_H
2424 #define AVCODEC_MPEG4AUDIO_SAMPLE_RATES_H
2525
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.
2630 const int ff_mpeg4audio_sample_rates[16] = {
2731 96000, 88200, 64000, 48000, 44100, 32000,
2832 24000, 22050, 16000, 12000, 11025, 8000, 7350

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t