[FFmpeg-cvslog] avcodec/aacps_common: Avoid superfluous VLC structures
Andreas Rheinhardt
git at videolan.org
Tue Oct 31 23:20:02 EET 2023
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Sep 26 18:01:07 2023 +0200| [eb422c606aac55429cc50fb7f3a4534c4e8f3906] | committer: Andreas Rheinhardt
avcodec/aacps_common: Avoid superfluous VLC structures
For all VLCs here, the number of bits of the VLC is
write-only, because it is hardcoded at the call site.
Therefore one can replace these VLC structures with
the only thing that is actually used: The pointer
to the VLCElem table.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb422c606aac55429cc50fb7f3a4534c4e8f3906
---
libavcodec/aacps_common.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/libavcodec/aacps_common.c b/libavcodec/aacps_common.c
index 6b5493d4c2..281eaa12e7 100644
--- a/libavcodec/aacps_common.c
+++ b/libavcodec/aacps_common.c
@@ -58,7 +58,7 @@ static const int huff_iid[] = {
huff_iid_dt1,
};
-static VLC vlc_ps[10];
+static const VLCElem *vlc_ps[10];
#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION, NB_BITS, MAX_DEPTH) \
/** \
@@ -77,7 +77,7 @@ static int read_ ## PAR ## _data(void *logctx, GetBitContext *gb, PSCommonContex
int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \
{ \
int b, num = ps->nr_ ## PAR ## _par; \
- const VLCElem *vlc_table = vlc_ps[table_idx].table; \
+ const VLCElem *vlc_table = vlc_ps[table_idx]; \
if (dt) { \
int e_prev = e ? e - 1 : ps->num_env_old - 1; \
e_prev = FFMAX(e_prev, 0); \
@@ -289,16 +289,18 @@ err:
}
#define PS_INIT_VLC_STATIC(num, nb_bits, size) \
- VLC_INIT_STATIC(&vlc_ps[num], nb_bits, ps_tmp[num].table_size / ps_tmp[num].elem_size, \
- ps_tmp[num].ps_bits, 1, 1, \
- ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, \
- size);
+ vlc_ps[num] = ff_vlc_init_tables(&state, nb_bits, ps_tmp[num].table_size / ps_tmp[num].elem_size, \
+ ps_tmp[num].ps_bits, 1, 1, \
+ ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, 0);
#define PS_VLC_ROW(name) \
{ name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }
av_cold void ff_ps_init_common(void)
{
+ static VLCElem vlc_buf[(1544 + 832 + 1024 + 1036) +
+ (544 + 544) + (32 + 32 + 32 + 32)];
+ VLCInitState state = VLC_INIT_STATE(vlc_buf);
// Syntax initialization
static const struct {
const void *ps_codes, *ps_bits;
More information about the ffmpeg-cvslog
mailing list