From 5dc31bc67b2de29045b437037ba6a8fd81f1696c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 26 Sep 2023 18:19:57 +0200 Subject: [PATCH] avcodec/aacps_common: Apply offset for VLCs during init This avoids having to apply it later after every get_vlc2(). Signed-off-by: Andreas Rheinhardt --- libavcodec/aacps_common.c | 14 +++++++------- libavcodec/aacpsdata.c | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libavcodec/aacps_common.c b/libavcodec/aacps_common.c index 7a83cbd7d6..74fa005aaf 100644 --- a/libavcodec/aacps_common.c +++ b/libavcodec/aacps_common.c @@ -60,7 +60,7 @@ static const int huff_iid[] = { static const VLCElem *vlc_ps[10]; -#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION, NB_BITS, MAX_DEPTH) \ +#define READ_PAR_DATA(PAR, MASK, ERR_CONDITION, NB_BITS, MAX_DEPTH) \ /** \ * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ \ * Inter-channel Phase Difference/Overall Phase Difference parameters from the \ @@ -82,7 +82,7 @@ static int read_ ## PAR ## _data(void *logctx, GetBitContext *gb, PSCommonContex int e_prev = e ? e - 1 : ps->num_env_old - 1; \ e_prev = FFMAX(e_prev, 0); \ for (b = 0; b < num; b++) { \ - int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, NB_BITS, MAX_DEPTH) - OFFSET; \ + int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, NB_BITS, MAX_DEPTH); \ if (MASK) val &= MASK; \ PAR[e][b] = val; \ if (ERR_CONDITION) \ @@ -91,7 +91,7 @@ static int read_ ## PAR ## _data(void *logctx, GetBitContext *gb, PSCommonContex } else { \ int val = 0; \ for (b = 0; b < num; b++) { \ - val += get_vlc2(gb, vlc_table, NB_BITS, MAX_DEPTH) - OFFSET; \ + val += get_vlc2(gb, vlc_table, NB_BITS, MAX_DEPTH); \ if (MASK) val &= MASK; \ PAR[e][b] = val; \ if (ERR_CONDITION) \ @@ -104,9 +104,9 @@ err: \ return AVERROR_INVALIDDATA; \ } -READ_PAR_DATA(iid, huff_offset[table_idx], 0, FFABS(ps->iid_par[e][b]) > 7 + 8 * ps->iid_quant, 9, 3) -READ_PAR_DATA(icc, huff_offset[table_idx], 0, ps->icc_par[e][b] > 7U, 9, 2) -READ_PAR_DATA(ipdopd, 0, 0x07, 0, 5, 1) +READ_PAR_DATA(iid, 0, FFABS(ps->iid_par[e][b]) > 7 + 8 * ps->iid_quant, 9, 3) +READ_PAR_DATA(icc, 0, ps->icc_par[e][b] > 7U, 9, 2) +READ_PAR_DATA(ipdopd, 0x07, 0, 5, 1) static int ps_read_extension_data(GetBitContext *gb, PSCommonContext *ps, int ps_extension_id) @@ -300,7 +300,7 @@ av_cold void ff_ps_init_common(void) ff_vlc_init_tables_from_lengths(&state, i <= 5 ? 9 : 5, huff_sizes[i], &tab[0][1], 2, &tab[0][0], 2, 1, - 0, 0); + huff_offset[i], 0); tab += huff_sizes[i]; } } diff --git a/libavcodec/aacpsdata.c b/libavcodec/aacpsdata.c index 6885b386c0..8c79a154e2 100644 --- a/libavcodec/aacpsdata.c +++ b/libavcodec/aacpsdata.c @@ -89,9 +89,9 @@ static const uint8_t aacps_huff_tabs[][2] = { }; static const int8_t huff_offset[] = { - 30, 30, - 14, 14, - 7, 7, + -30, -30, + -14, -14, + -7, -7, 0, 0, 0, 0, };