annotate libtwamr/ol_ltp.c @ 527:f3246d109e2d

libgsmfr2: add gsmfr_fulldec_bfi_bits()
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 19 Sep 2024 07:03:12 +0000
parents f17e42c63058
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
417
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : ol_ltp.c
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Compute the open loop pitch lag.
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 /*
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 * MODULE INCLUDE FILE AND VERSION ID
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #include "namespace.h"
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #include "ol_ltp.h"
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /*
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 * INCLUDE FILES
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #include "typedef.h"
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "cnst.h"
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "pitch_ol.h"
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "p_ol_wgh.h"
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "no_count.h"
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #include "basic_op.h"
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 /*
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 * LOCAL VARIABLES AND TABLES
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 /*
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 * PUBLIC PROGRAM CODE
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 ********************************************************************************
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 int ol_ltp(
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 pitchOLWghtState *st, /* i/o : State struct */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 vadState *vadSt, /* i/o : VAD state struct */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 enum Mode mode, /* i : coder mode */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 Word16 wsp[], /* i : signal used to compute the OL pitch, Q0 */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 /* uses signal[-pit_max] to signal[-1] */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 Word16 *T_op, /* o : open loop pitch lag, Q0 */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 Word16 old_lags[], /* i : history with old stored Cl lags */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 Word16 ol_gain_flg[], /* i : OL gain flag */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 Word16 idx, /* i : index */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 Flag dtx /* i : dtx flag; use dtx=1, do not use dtx=0 */
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 )
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 {
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 test ();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 if (sub (mode, MR102) != 0 )
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 {
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 ol_gain_flg[0] = 0; move16 ();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 ol_gain_flg[1] = 0; move16 ();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 }
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 test (); test ();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 if (sub (mode, MR475) == 0 || sub (mode, MR515) == 0 )
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 {
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN, PIT_MAX, L_FRAME, idx, dtx);
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 move16 ();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 }
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 else
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 {
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 if ( sub (mode, MR795) <= 0 )
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 {
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 test();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2,
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 idx, dtx);
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 move16 ();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 else if ( sub (mode, MR102) == 0 )
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 {
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 test(); test();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 *T_op = Pitch_ol_wgh(st, vadSt, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2,
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 old_lags, ol_gain_flg, idx, dtx);
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 move16 ();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 }
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 else
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 {
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 test(); test();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN_MR122, PIT_MAX,
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 L_FRAME_BY2, idx, dtx);
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 move16 ();
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 }
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 }
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 return 0;
f17e42c63058 libtwamr: integrate ol_ltp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 }