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