Message ID | 20210110061501.3863886-1-andreas.rheinhardt@gmail.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] avcodec/aacenctab: Simplify exporting array size | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@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
> On Jan 12, 2021, at 8:16 AM, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote: > > Andreas Rheinhardt: >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@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. Two mismatches can happen after the patch: 1. mismatch between the array length in header file and source file 2. mismatch between the specified array length and the number of elements Add or remove element needs to change three parts of the code. There is no such disadvantage before the patch. Just my two cents. > > - Andreas > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
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] = {
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavcodec/aacenc.c | 4 ++-- libavcodec/aacenctab.c | 7 ++----- libavcodec/aacenctab.h | 6 ++---- 3 files changed, 6 insertions(+), 11 deletions(-)