[FFmpeg-cvslog] avcodec/aacenc: Remove always-false check

Andreas Rheinhardt git at videolan.org
Mon Apr 14 00:18:14 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Apr 10 13:56:14 2025 +0200| [ab1bc2f745740bdec047e5b2decc7006eed9881d] | committer: Andreas Rheinhardt

avcodec/aacenc: Remove always-false check

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

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab1bc2f745740bdec047e5b2decc7006eed9881d
---

 libavcodec/aacenc.c                  | 13 ++++++-------
 libavcodec/aacenctab.c               |  3 ---
 libavcodec/aacenctab.h               |  2 --
 libavcodec/mpeg4audio_sample_rates.h |  4 ++++
 4 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 0f124408da..afb4478bfe 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -1235,14 +1235,13 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
     }
 
     /* Samplerate */
-    for (i = 0; i < 16; i++)
-        if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i])
+    for (int i = 0;; i++) {
+        av_assert1(i < 13);
+        if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i]) {
+            s->samplerate_index = i;
             break;
-    s->samplerate_index = i;
-    ERROR_IF(s->samplerate_index == 16 ||
-             s->samplerate_index >= ff_aac_swb_size_1024_len ||
-             s->samplerate_index >= ff_aac_swb_size_128_len,
-             "Unsupported sample rate %d\n", avctx->sample_rate);
+        }
+    }
 
     /* Bitrate limiting */
     WARN_IF(1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * s->channels,
diff --git a/libavcodec/aacenctab.c b/libavcodec/aacenctab.c
index 874365a593..ca09e22ca8 100644
--- a/libavcodec/aacenctab.c
+++ b/libavcodec/aacenctab.c
@@ -103,6 +103,3 @@ const uint8_t *const ff_aac_swb_size_1024[] = {
     swb_size_1024_16, swb_size_1024_16, swb_size_1024_8,
     swb_size_1024_8
 };
-
-const int ff_aac_swb_size_128_len  = FF_ARRAY_ELEMS(ff_aac_swb_size_128);
-const int ff_aac_swb_size_1024_len = FF_ARRAY_ELEMS(ff_aac_swb_size_1024);
diff --git a/libavcodec/aacenctab.h b/libavcodec/aacenctab.h
index 60e1f22387..fee9c245d8 100644
--- a/libavcodec/aacenctab.h
+++ b/libavcodec/aacenctab.h
@@ -41,9 +41,7 @@
 #define AAC_MAX_CHANNELS 16
 
 extern const uint8_t *const ff_aac_swb_size_1024[];
-extern const int      ff_aac_swb_size_1024_len;
 extern const uint8_t *const ff_aac_swb_size_128[];
-extern const int      ff_aac_swb_size_128_len;
 
 /* Supported layouts without using a PCE */
 static const AVChannelLayout aac_normal_chan_layouts[7] = {
diff --git a/libavcodec/mpeg4audio_sample_rates.h b/libavcodec/mpeg4audio_sample_rates.h
index 0b8caa6d76..a847a97994 100644
--- a/libavcodec/mpeg4audio_sample_rates.h
+++ b/libavcodec/mpeg4audio_sample_rates.h
@@ -23,6 +23,10 @@
 #ifndef AVCODEC_MPEG4AUDIO_SAMPLE_RATES_H
 #define AVCODEC_MPEG4AUDIO_SAMPLE_RATES_H
 
+// This table contains only 13 real elements and is padded with zeroes.
+// It is used by the AAC encoder as sample rate table, so the encoder
+// needs to actually support all of these rates and it needs to have
+// a trailing zero.
 const int ff_mpeg4audio_sample_rates[16] = {
     96000, 88200, 64000, 48000, 44100, 32000,
     24000, 22050, 16000, 12000, 11025, 8000, 7350



More information about the ffmpeg-cvslog mailing list