FreeCalypso > hg > gsm-codec-lib
diff libgsmefr/q_gains.c @ 88:03599300d2db
libgsmefr: q_gains.c compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 26 Nov 2022 11:21:22 +0000 |
parents | 49dd1ac8e75b |
children | 33487966077e |
line wrap: on
line diff
--- a/libgsmefr/q_gains.c Sat Nov 26 10:27:34 2022 +0000 +++ b/libgsmefr/q_gains.c Sat Nov 26 11:21:22 2022 +0000 @@ -7,25 +7,20 @@ * (in dB/(20*log10(2))) with mean removed. * *-------------------------------------------------------------------------*/ +#include "gsm_efr.h" #include "typedef.h" +#include "namespace.h" #include "basic_op.h" #include "oper_32b.h" -#include "count.h" +#include "no_count.h" #include "sig_proc.h" +#include "codec.h" #include "gains_tb.h" #include "cnst.h" #include "dtx.h" - -/* past quantized energies. */ -/* initialized to -14.0/constant, constant = 20*Log10(2) */ -Word16 past_qua_en[4]; - -/* MA prediction coeff */ -Word16 pred[4]; - -extern Word16 CN_excitation_gain, gain_code_old_tx[4 * DTX_HANGOVER]; +#include "enc_state.h" Word16 q_gain_pitch ( /* Return index of quantization */ Word16 *gain /* (i) : Pitch gain to quantize */ @@ -61,6 +56,7 @@ #define MEAN_ENER 783741L /* 36/(20*log10(2)) */ Word16 q_gain_code ( /* Return quantization index */ + struct EFR_encoder_state *st, Word16 code[], /* (i) : fixed codebook excitation */ Word16 lcode, /* (i) : codevector size */ Word16 *gain, /* (i/o) : quantized fixed codebook gain */ @@ -72,9 +68,7 @@ Word16 gcode0, err, err_min, exp, frac; Word32 ener, ener_code; Word16 aver_gain; - static Word16 gcode0_CN; - logic16 (); test (); if ((txdtx_ctrl & TX_SP_FLAG) != 0) { @@ -104,7 +98,7 @@ ener = MEAN_ENER; move32 (); for (i = 0; i < 4; i++) { - ener = L_mac (ener, past_qua_en[i], pred[i]); + ener = L_mac (ener, st->past_qua_en[i], st->pred[i]); } /*-------------------------------------------------------------------* @@ -154,46 +148,42 @@ for (i = 3; i > 0; i--) { - past_qua_en[i] = past_qua_en[i - 1];move16 (); + st->past_qua_en[i] = st->past_qua_en[i - 1]; } Log2 (L_deposit_l (qua_gain_code[index]), &exp, &frac); - past_qua_en[0] = shr (frac, 5); move16 (); - past_qua_en[0] = add (past_qua_en[0], shl (sub (exp, 11), 10)); - move16 (); + st->past_qua_en[0] = shr (frac, 5); + st->past_qua_en[0] = add (st->past_qua_en[0], shl (sub (exp, 11), 10)); - update_gain_code_history_tx (*gain, gain_code_old_tx); + update_gain_code_history_tx (st, *gain); } else { - logic16 (); test (); test (); if ((txdtx_ctrl & TX_PREV_HANGOVER_ACTIVE) != 0 && (i_subfr == 0)) { - gcode0_CN = update_gcode0_CN (gain_code_old_tx); - gcode0_CN = shl (gcode0_CN, 4); + st->gcode0_CN = update_gcode0_CN (st->gain_code_old_tx); + st->gcode0_CN = shl (st->gcode0_CN, 4); } - *gain = CN_excitation_gain; move16 (); + *gain = st->CN_excitation_gain; - logic16 (); test (); test (); if ((txdtx_ctrl & TX_SID_UPDATE) != 0) { - aver_gain = aver_gain_code_history (CN_excitation_gain, - gain_code_old_tx); + aver_gain = aver_gain_code_history (st->CN_excitation_gain, + st->gain_code_old_tx); /*---------------------------------------------------------------* * Search for best quantizer * *---------------------------------------------------------------*/ err_min = abs_s (sub (aver_gain, - mult (gcode0_CN, qua_gain_code[0]))); - index = 0; move16 (); + mult (st->gcode0_CN, qua_gain_code[0]))); + index = 0; for (i = 1; i < NB_QUA_CODE; i++) { err = abs_s (sub (aver_gain, - mult (gcode0_CN, qua_gain_code[i]))); + mult (st->gcode0_CN, qua_gain_code[i]))); - test (); if (sub (err, err_min) < 0) { err_min = err; move16 (); @@ -201,7 +191,7 @@ } } } - update_gain_code_history_tx (*gain, gain_code_old_tx); + update_gain_code_history_tx (st, *gain); /*-------------------------------------------------------------------* * reset table of past quantized energies * @@ -210,7 +200,7 @@ for (i = 0; i < 4; i++) { - past_qua_en[i] = -2381; move16 (); + st->past_qua_en[i] = -2381; } }