FreeCalypso > hg > gsm-codec-lib
changeset 88:03599300d2db
libgsmefr: q_gains.c compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 26 Nov 2022 11:21:22 +0000 |
parents | 41d8e8f4058d |
children | 77803ce2cc22 |
files | libgsmefr/Makefile libgsmefr/enc_state.h libgsmefr/q_gains.c |
diffstat | 3 files changed, 23 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/libgsmefr/Makefile Sat Nov 26 10:27:34 2022 +0000 +++ b/libgsmefr/Makefile Sat Nov 26 11:21:22 2022 +0000 @@ -5,7 +5,7 @@ dec_lag6.o dtx.o e_homing.o enc_create.o enc_lag6.o frame2params.o \ g_code.o g_pitch.o int_lpc.o inter_6.o inv_sqrt.o lag_wind.o levinson.o\ log2.o lsp_az.o lsp_lsf.o oper_32b.o params2frame.o pitch_f6.o \ - pitch_ol.o pow2.o pre_proc.o pred_lt6.o preemph.o pstfilt2.o \ + pitch_ol.o pow2.o pre_proc.o pred_lt6.o preemph.o pstfilt2.o q_gains.o \ sid_class.o sid_insert.o tls_flags.o HDRS= basic_op.h cnst.h codec.h d_homing.h dec_state.h dtx.h e_homing.h \ enc_state.h gains_tb.h gsm_efr.h memops.h namespace.h no_count.h \
--- a/libgsmefr/enc_state.h Sat Nov 26 10:27:34 2022 +0000 +++ b/libgsmefr/enc_state.h Sat Nov 26 11:21:22 2022 +0000 @@ -35,6 +35,7 @@ /* from q_gains.c */ Word16 past_qua_en[4]; Word16 pred[4]; + Word16 gcode0_CN; /* from dtx.c */ Word16 txdtx_ctrl; Word16 CN_excitation_gain;
--- 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; } }