comparison libtwamr/lflg_upd.c @ 411:bd5614fc780a

libtwamr: integrate VAD2 lflg_upd.c
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 May 2024 01:18:25 +0000
parents
children
comparison
equal deleted inserted replaced
410:0152c069d01f 411:bd5614fc780a
1 /*
2 *****************************************************************************
3 *
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
5 * R99 Version 3.3.0
6 * REL-4 Version 4.1.0
7 *
8 *****************************************************************************
9 *
10 * File : lflg_upd.c
11 * Purpose : LTP_flag update for AMR VAD option 2
12 *
13 *****************************************************************************
14 */
15
16 #include "tw_amr.h"
17 #include "namespace.h"
18 #include "typedef.h"
19 #include "cnst.h"
20 #include "basic_op.h"
21 #include "oper_32b.h"
22 #include "no_count.h"
23 #include "vad2.h"
24
25 /***************************************************************************
26 *
27 * FUNCTION NAME: LTP_flag_update
28 *
29 * PURPOSE:
30 * Set LTP_flag if the LTP gain > LTP_THRESHOLD, where the value of
31 * LTP_THRESHOLD depends on the LTP analysis window length.
32 *
33 * INPUTS:
34 *
35 * mode
36 * AMR mode
37 * vadState->L_R0
38 * LTP energy
39 * vadState->L_Rmax
40 * LTP maximum autocorrelation
41 * OUTPUTS:
42 *
43 * vadState->LTP_flag
44 * Set if LTP gain > LTP_THRESHOLD
45 *
46 * RETURN VALUE:
47 *
48 * none
49 *
50 *************************************************************************/
51
52 void LTP_flag_update (vadState2 * st, Word16 mode)
53 {
54 Word16 thresh;
55 Word16 hi1;
56 Word16 lo1;
57 Word32 Ltmp;
58
59 test(); test();
60 if ((sub(mode, MR475) == 0) || (sub(mode, MR515) == 0))
61 {
62 thresh = (Word16)(32768.0*0.55); move16();
63 }
64 else if (sub(mode, MR102) == 0)
65 {
66 thresh = (Word16)(32768.0*0.60); move16();
67 }
68 else
69 {
70 thresh = (Word16)(32768.0*0.65); move16();
71 }
72
73 L_Extract (st->L_R0, &hi1, &lo1);
74 Ltmp = Mpy_32_16(hi1, lo1, thresh); test();
75 if (L_sub(st->L_Rmax, Ltmp) > 0)
76 {
77 st->LTP_flag = TRUE; move16();
78 }
79 else
80 {
81 st->LTP_flag = FALSE; move16();
82 }
83
84 return;
85 }