FreeCalypso > hg > gsm-codec-lib
changeset 411:bd5614fc780a
libtwamr: integrate VAD2 lflg_upd.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 07 May 2024 01:18:25 +0000 |
parents | 0152c069d01f |
children | 810ac4b99025 |
files | libtwamr/Makefile libtwamr/lflg_upd.c |
diffstat | 2 files changed, 93 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libtwamr/Makefile Tue May 07 01:14:14 2024 +0000 +++ b/libtwamr/Makefile Tue May 07 01:18:25 2024 +0000 @@ -9,13 +9,14 @@ dtx_enc.o e_homing.o ec_gains.o enc_lag3.o enc_lag6.o ex_ctrl.o \ g_adapt.o g_code.o g_pitch.o gain_q.o gains_tab.o gc_pred.o gmed_n.o \ graytab.o hp_max.o int_lpc.o int_lsf.o inter_36.o inv_sqrt.o lag_wind.o\ - levinson.o log2.o lpc.o lsfwt.o lsp.o lsp_avg.o lsp_az.o lsp_lsf.o \ - lsp_tab.o mac_32.o oper_32b.o ph_disp.o pitch_fr.o post_pro.o pow2.o \ - pre_big.o pre_proc.o pred_lt.o preemph.o prm2bits.o prmno.o pstfilt.o \ - q_gain_c.o q_gain_p.o q_plsf.o q_plsf3_tab.o q_plsf5_tab.o q_plsf_3.o \ - q_plsf_5.o qgain475.o qgain795.o qua_gain.o qua_gain_tab.o reorder.o \ - residu.o s10_8pf.o set_sign.o sid_sync.o spreproc.o spstproc.o sqrt_l.o\ - syn_filt.o tls_flags.o ton_stab.o vad1.o vad2.o weight_a.o window.o + levinson.o lflg_upd.o log2.o lpc.o lsfwt.o lsp.o lsp_avg.o lsp_az.o \ + lsp_lsf.o lsp_tab.o mac_32.o oper_32b.o ph_disp.o pitch_fr.o post_pro.o\ + pow2.o pre_big.o pre_proc.o pred_lt.o preemph.o prm2bits.o prmno.o \ + pstfilt.o q_gain_c.o q_gain_p.o q_plsf.o q_plsf3_tab.o q_plsf5_tab.o \ + q_plsf_3.o q_plsf_5.o qgain475.o qgain795.o qua_gain.o qua_gain_tab.o \ + reorder.o residu.o s10_8pf.o set_sign.o sid_sync.o spreproc.o \ + spstproc.o sqrt_l.o syn_filt.o tls_flags.o ton_stab.o vad1.o vad2.o \ + weight_a.o window.o HDRS= namespace.h LIB= libtwamr.a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtwamr/lflg_upd.c Tue May 07 01:18:25 2024 +0000 @@ -0,0 +1,85 @@ +/* +***************************************************************************** +* +* GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 +* R99 Version 3.3.0 +* REL-4 Version 4.1.0 +* +***************************************************************************** +* +* File : lflg_upd.c +* Purpose : LTP_flag update for AMR VAD option 2 +* +***************************************************************************** +*/ + +#include "tw_amr.h" +#include "namespace.h" +#include "typedef.h" +#include "cnst.h" +#include "basic_op.h" +#include "oper_32b.h" +#include "no_count.h" +#include "vad2.h" + +/*************************************************************************** + * + * FUNCTION NAME: LTP_flag_update + * + * PURPOSE: + * Set LTP_flag if the LTP gain > LTP_THRESHOLD, where the value of + * LTP_THRESHOLD depends on the LTP analysis window length. + * + * INPUTS: + * + * mode + * AMR mode + * vadState->L_R0 + * LTP energy + * vadState->L_Rmax + * LTP maximum autocorrelation + * OUTPUTS: + * + * vadState->LTP_flag + * Set if LTP gain > LTP_THRESHOLD + * + * RETURN VALUE: + * + * none + * + *************************************************************************/ + +void LTP_flag_update (vadState2 * st, Word16 mode) +{ + Word16 thresh; + Word16 hi1; + Word16 lo1; + Word32 Ltmp; + + test(); test(); + if ((sub(mode, MR475) == 0) || (sub(mode, MR515) == 0)) + { + thresh = (Word16)(32768.0*0.55); move16(); + } + else if (sub(mode, MR102) == 0) + { + thresh = (Word16)(32768.0*0.60); move16(); + } + else + { + thresh = (Word16)(32768.0*0.65); move16(); + } + + L_Extract (st->L_R0, &hi1, &lo1); + Ltmp = Mpy_32_16(hi1, lo1, thresh); test(); + if (L_sub(st->L_Rmax, Ltmp) > 0) + { + st->LTP_flag = TRUE; move16(); + } + else + { + st->LTP_flag = FALSE; move16(); + } + + return; +}