1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

g723.1: do not pass large structs by value

Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
Mans Rullgard 2012-08-11 21:04:14 +01:00
parent 138914dcd8
commit 69665bd6f4

View File

@ -498,7 +498,7 @@ static void gen_dirac_train(int16_t *buf, int pitch_lag)
* @param pitch_lag closed loop pitch lag * @param pitch_lag closed loop pitch lag
* @param index current subframe index * @param index current subframe index
*/ */
static void gen_fcb_excitation(int16_t *vector, G723_1_Subframe subfrm, static void gen_fcb_excitation(int16_t *vector, G723_1_Subframe *subfrm,
enum Rate cur_rate, int pitch_lag, int index) enum Rate cur_rate, int pitch_lag, int index)
{ {
int temp, i, j; int temp, i, j;
@ -506,34 +506,34 @@ static void gen_fcb_excitation(int16_t *vector, G723_1_Subframe subfrm,
memset(vector, 0, SUBFRAME_LEN * sizeof(*vector)); memset(vector, 0, SUBFRAME_LEN * sizeof(*vector));
if (cur_rate == RATE_6300) { if (cur_rate == RATE_6300) {
if (subfrm.pulse_pos >= max_pos[index]) if (subfrm->pulse_pos >= max_pos[index])
return; return;
/* Decode amplitudes and positions */ /* Decode amplitudes and positions */
j = PULSE_MAX - pulses[index]; j = PULSE_MAX - pulses[index];
temp = subfrm.pulse_pos; temp = subfrm->pulse_pos;
for (i = 0; i < SUBFRAME_LEN / GRID_SIZE; i++) { for (i = 0; i < SUBFRAME_LEN / GRID_SIZE; i++) {
temp -= combinatorial_table[j][i]; temp -= combinatorial_table[j][i];
if (temp >= 0) if (temp >= 0)
continue; continue;
temp += combinatorial_table[j++][i]; temp += combinatorial_table[j++][i];
if (subfrm.pulse_sign & (1 << (PULSE_MAX - j))) { if (subfrm->pulse_sign & (1 << (PULSE_MAX - j))) {
vector[subfrm.grid_index + GRID_SIZE * i] = vector[subfrm->grid_index + GRID_SIZE * i] =
-fixed_cb_gain[subfrm.amp_index]; -fixed_cb_gain[subfrm->amp_index];
} else { } else {
vector[subfrm.grid_index + GRID_SIZE * i] = vector[subfrm->grid_index + GRID_SIZE * i] =
fixed_cb_gain[subfrm.amp_index]; fixed_cb_gain[subfrm->amp_index];
} }
if (j == PULSE_MAX) if (j == PULSE_MAX)
break; break;
} }
if (subfrm.dirac_train == 1) if (subfrm->dirac_train == 1)
gen_dirac_train(vector, pitch_lag); gen_dirac_train(vector, pitch_lag);
} else { /* 5300 bps */ } else { /* 5300 bps */
int cb_gain = fixed_cb_gain[subfrm.amp_index]; int cb_gain = fixed_cb_gain[subfrm->amp_index];
int cb_shift = subfrm.grid_index; int cb_shift = subfrm->grid_index;
int cb_sign = subfrm.pulse_sign; int cb_sign = subfrm->pulse_sign;
int cb_pos = subfrm.pulse_pos; int cb_pos = subfrm->pulse_pos;
int offset, beta, lag; int offset, beta, lag;
for (i = 0; i < 8; i += 2) { for (i = 0; i < 8; i += 2) {
@ -544,9 +544,9 @@ static void gen_fcb_excitation(int16_t *vector, G723_1_Subframe subfrm,
} }
/* Enhance harmonic components */ /* Enhance harmonic components */
lag = pitch_contrib[subfrm.ad_cb_gain << 1] + pitch_lag + lag = pitch_contrib[subfrm->ad_cb_gain << 1] + pitch_lag +
subfrm.ad_cb_lag - 1; subfrm->ad_cb_lag - 1;
beta = pitch_contrib[(subfrm.ad_cb_gain << 1) + 1]; beta = pitch_contrib[(subfrm->ad_cb_gain << 1) + 1];
if (lag < SUBFRAME_LEN - 2) { if (lag < SUBFRAME_LEN - 2) {
for (i = lag; i < SUBFRAME_LEN; i++) for (i = lag; i < SUBFRAME_LEN; i++)
@ -586,12 +586,12 @@ static int dot_product(const int16_t *a, const int16_t *b, int length)
* Generate adaptive codebook excitation. * Generate adaptive codebook excitation.
*/ */
static void gen_acb_excitation(int16_t *vector, int16_t *prev_excitation, static void gen_acb_excitation(int16_t *vector, int16_t *prev_excitation,
int pitch_lag, G723_1_Subframe subfrm, int pitch_lag, G723_1_Subframe *subfrm,
enum Rate cur_rate) enum Rate cur_rate)
{ {
int16_t residual[SUBFRAME_LEN + PITCH_ORDER - 1]; int16_t residual[SUBFRAME_LEN + PITCH_ORDER - 1];
const int16_t *cb_ptr; const int16_t *cb_ptr;
int lag = pitch_lag + subfrm.ad_cb_lag - 1; int lag = pitch_lag + subfrm->ad_cb_lag - 1;
int i; int i;
int sum; int sum;
@ -605,7 +605,7 @@ static void gen_acb_excitation(int16_t *vector, int16_t *prev_excitation,
cb_ptr = adaptive_cb_gain170; cb_ptr = adaptive_cb_gain170;
/* Calculate adaptive vector */ /* Calculate adaptive vector */
cb_ptr += subfrm.ad_cb_gain * 20; cb_ptr += subfrm->ad_cb_gain * 20;
for (i = 0; i < SUBFRAME_LEN; i++) { for (i = 0; i < SUBFRAME_LEN; i++) {
sum = dot_product(residual + i, cb_ptr, PITCH_ORDER); sum = dot_product(residual + i, cb_ptr, PITCH_ORDER);
vector[i] = av_sat_dadd32(1 << 15, sum) >> 16; vector[i] = av_sat_dadd32(1 << 15, sum) >> 16;
@ -1057,10 +1057,10 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data,
p->interp_gain = fixed_cb_gain[(p->subframe[2].amp_index + p->interp_gain = fixed_cb_gain[(p->subframe[2].amp_index +
p->subframe[3].amp_index) >> 1]; p->subframe[3].amp_index) >> 1];
for (i = 0; i < SUBFRAMES; i++) { for (i = 0; i < SUBFRAMES; i++) {
gen_fcb_excitation(vector_ptr, p->subframe[i], p->cur_rate, gen_fcb_excitation(vector_ptr, &p->subframe[i], p->cur_rate,
p->pitch_lag[i >> 1], i); p->pitch_lag[i >> 1], i);
gen_acb_excitation(acb_vector, &p->excitation[SUBFRAME_LEN * i], gen_acb_excitation(acb_vector, &p->excitation[SUBFRAME_LEN * i],
p->pitch_lag[i >> 1], p->subframe[i], p->pitch_lag[i >> 1], &p->subframe[i],
p->cur_rate); p->cur_rate);
/* Get the total excitation */ /* Get the total excitation */
for (j = 0; j < SUBFRAME_LEN; j++) { for (j = 0; j < SUBFRAME_LEN; j++) {