avcodec/g723_1: Deduplicate arrays

Saves about 17KB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2021-01-02 20:18:22 +01:00
parent f4bdeddc3c
commit 3d284e35c2
4 changed files with 1110 additions and 1096 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -221,16 +221,16 @@ static void gen_fcb_excitation(int16_t *vector, G723_1_Subframe *subfrm,
j = PULSE_MAX - pulses[index];
temp = subfrm->pulse_pos;
for (i = 0; i < SUBFRAME_LEN / GRID_SIZE; i++) {
temp -= combinatorial_table[j][i];
temp -= ff_g723_1_combinatorial_table[j][i];
if (temp >= 0)
continue;
temp += combinatorial_table[j++][i];
temp += ff_g723_1_combinatorial_table[j++][i];
if (subfrm->pulse_sign & (1 << (PULSE_MAX - j))) {
vector[subfrm->grid_index + GRID_SIZE * i] =
-fixed_cb_gain[subfrm->amp_index];
-ff_g723_1_fixed_cb_gain[subfrm->amp_index];
} else {
vector[subfrm->grid_index + GRID_SIZE * i] =
fixed_cb_gain[subfrm->amp_index];
ff_g723_1_fixed_cb_gain[subfrm->amp_index];
}
if (j == PULSE_MAX)
break;
@ -238,7 +238,7 @@ static void gen_fcb_excitation(int16_t *vector, G723_1_Subframe *subfrm,
if (subfrm->dirac_train == 1)
ff_g723_1_gen_dirac_train(vector, pitch_lag);
} else { /* 5300 bps */
int cb_gain = fixed_cb_gain[subfrm->amp_index];
int cb_gain = ff_g723_1_fixed_cb_gain[subfrm->amp_index];
int cb_shift = subfrm->grid_index;
int cb_sign = subfrm->pulse_sign;
int cb_pos = subfrm->pulse_pos;
@ -915,7 +915,7 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data,
int16_t *vector_ptr = p->excitation + PITCH_MAX;
/* Update interpolation gain memory */
p->interp_gain = fixed_cb_gain[(p->subframe[2].amp_index +
p->interp_gain = ff_g723_1_fixed_cb_gain[(p->subframe[2].amp_index +
p->subframe[3].amp_index) >> 1];
for (i = 0; i < SUBFRAMES; i++) {
gen_fcb_excitation(vector_ptr, &p->subframe[i], p->cur_rate,

View File

@ -242,14 +242,14 @@ static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp)
p = 0;
temp = 0;
for (i = 0; i <= LPC_ORDER / 2; i++)
temp += f[2 * i] * cos_tab[0];
temp += f[2 * i] * G723_1_COS_TAB_FIRST_ELEMENT;
prev_val = av_clipl_int32(temp << 1);
count = 0;
for (i = 1; i < COS_TBL_SIZE / 2; i++) {
/* Evaluate */
temp = 0;
for (j = 0; j <= LPC_ORDER / 2; j++)
temp += f[LPC_ORDER - 2 * j + p] * cos_tab[i * j % COS_TBL_SIZE];
temp += f[LPC_ORDER - 2 * j + p] * ff_g723_1_cos_tab[i * j % COS_TBL_SIZE];
cur_val = av_clipl_int32(temp << 1);
/* Check for sign change, indicating a zero crossing */
@ -273,7 +273,7 @@ static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp)
temp = 0;
for (j = 0; j <= LPC_ORDER / 2; j++)
temp += f[LPC_ORDER - 2 * j + p] *
cos_tab[i * j % COS_TBL_SIZE];
ff_g723_1_cos_tab[i * j % COS_TBL_SIZE];
cur_val = av_clipl_int32(temp << 1);
}
prev_val = cur_val;
@ -298,11 +298,11 @@ static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp)
\
for (i = 0; i < LSP_CB_SIZE; i++) { \
for (j = 0; j < size; j++){ \
temp[j] = (weight[j + (offset)] * lsp_band##num[i][j] + \
temp[j] = (weight[j + (offset)] * ff_g723_1_lsp_band##num[i][j] + \
(1 << 14)) >> 15; \
} \
error = ff_g723_1_dot_product(lsp + (offset), temp, size) << 1; \
error -= ff_g723_1_dot_product(lsp_band##num[i], temp, size); \
error -= ff_g723_1_dot_product(ff_g723_1_lsp_band##num[i], temp, size); \
if (error > max) { \
max = error; \
lsp_index[num] = i; \
@ -642,7 +642,7 @@ static void acb_search(G723_1_ChannelContext *p, int16_t *residual,
{
int16_t flt_buf[PITCH_ORDER][SUBFRAME_LEN];
const int16_t *cb_tbl = adaptive_cb_gain85;
const int16_t *cb_tbl = ff_g723_1_adaptive_cb_gain85;
int ccr_buf[PITCH_ORDER * SUBFRAMES << 2];
@ -720,7 +720,7 @@ static void acb_search(G723_1_ChannelContext *p, int16_t *residual,
/* Select quantization table */
if (!odd_frame && pitch_lag + i - 1 >= SUBFRAME_LEN - 2 ||
odd_frame && pitch_lag >= SUBFRAME_LEN - 2) {
cb_tbl = adaptive_cb_gain170;
cb_tbl = ff_g723_1_adaptive_cb_gain170;
tbl_size = 170;
}
@ -838,7 +838,7 @@ static void get_fcb_param(FCBParam *optim, int16_t *impulse_resp,
min = 1 << 30;
max_amp_index = GAIN_LEVELS - 2;
for (j = max_amp_index; j >= 2; j--) {
temp = av_clipl_int32((int64_t) fixed_cb_gain[j] *
temp = av_clipl_int32((int64_t) ff_g723_1_fixed_cb_gain[j] *
impulse_corr[0] << 1);
temp = FFABS(temp - amp);
if (temp < min) {
@ -855,7 +855,7 @@ static void get_fcb_param(FCBParam *optim, int16_t *impulse_resp,
ccr2[k] = ccr1[k];
}
param.amp_index = max_amp_index + j - 2;
amp = fixed_cb_gain[param.amp_index];
amp = ff_g723_1_fixed_cb_gain[param.amp_index];
param.pulse_sign[0] = (ccr2[param.pulse_pos[0]] < 0) ? -amp : amp;
temp_corr[param.pulse_pos[0]] = 1;
@ -942,7 +942,7 @@ static void pack_fcb_param(G723_1_Subframe *subfrm, FCBParam *optim,
for (i = 0; i < SUBFRAME_LEN >> 1; i++) {
int val = buf[optim->grid_index + (i << 1)];
if (!val) {
subfrm->pulse_pos += combinatorial_table[j][i];
subfrm->pulse_pos += ff_g723_1_combinatorial_table[j][i];
} else {
subfrm->pulse_sign <<= 1;
if (val < 0)