[FFmpeg-devel] [PATCH] avcodec/aacenctab: Simplify exporting array size

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Tue Jan 12 02:16:22 EET 2021


Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libavcodec/aacenc.c    | 4 ++--
>  libavcodec/aacenctab.c | 7 ++-----
>  libavcodec/aacenctab.h | 6 ++----
>  3 files changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
> index 070a2e706a..75e40c9d7f 100644
> --- a/libavcodec/aacenc.c
> +++ b/libavcodec/aacenc.c
> @@ -999,8 +999,8 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
>              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,
> +             s->samplerate_index >= FF_ARRAY_ELEMS(ff_aac_swb_size_1024) ||
> +             s->samplerate_index >= FF_ARRAY_ELEMS(ff_aac_swb_size_128),
>               "Unsupported sample rate %d\n", avctx->sample_rate);
>  
>      /* Bitrate limiting */
> diff --git a/libavcodec/aacenctab.c b/libavcodec/aacenctab.c
> index 874365a593..69458cf1fd 100644
> --- a/libavcodec/aacenctab.c
> +++ b/libavcodec/aacenctab.c
> @@ -88,7 +88,7 @@ static const uint8_t swb_size_1024_8[] = {
>      32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80
>  };
>  
> -const uint8_t *const ff_aac_swb_size_128[] = {
> +const uint8_t *const ff_aac_swb_size_128[13] = {
>      swb_size_128_96, swb_size_128_96, swb_size_128_64,
>      swb_size_128_48, swb_size_128_48, swb_size_128_48,
>      swb_size_128_24, swb_size_128_24, swb_size_128_16,
> @@ -96,13 +96,10 @@ const uint8_t *const ff_aac_swb_size_128[] = {
>      swb_size_128_8
>  };
>  
> -const uint8_t *const ff_aac_swb_size_1024[] = {
> +const uint8_t *const ff_aac_swb_size_1024[13] = {
>      swb_size_1024_96, swb_size_1024_96, swb_size_1024_64,
>      swb_size_1024_48, swb_size_1024_48, swb_size_1024_32,
>      swb_size_1024_24, swb_size_1024_24, swb_size_1024_16,
>      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 dbbdf61dfd..39f7e52909 100644
> --- a/libavcodec/aacenctab.h
> +++ b/libavcodec/aacenctab.h
> @@ -38,10 +38,8 @@
>  
>  #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;
> +extern const uint8_t *const ff_aac_swb_size_1024[13];
> +extern const uint8_t *const ff_aac_swb_size_128[13];
>  
>  /* Supported layouts without using a PCE */
>  static const int64_t aac_normal_chan_layouts[7] = {
> 
Will apply this patch tomorrow unless there are objections.

- Andreas


More information about the ffmpeg-devel mailing list