annotate libtwamr/b_cn_cod.h @ 556:18aca50d68df default tip

doc/Calypso-TCH-downlink: update for FR1 BFI-with-data
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 11 Oct 2024 01:54:00 +0000
parents 07f936338de1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
255
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : b_cn_cod.h
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Contains function for comfort noise generation.
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #ifndef b_cn_cod_h
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #define b_cn_cod_h "$Id $"
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 /*
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 * INCLUDE FILES
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #include "typedef.h"
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 /*
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 * DEFINITION OF DATA TYPES
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 /*
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 * DECLARATION OF PROTOTYPES
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 /*************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 * FUNCTION NAME: pseudonoise
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 * PURPOSE: Generate a random integer value to use in comfort noise
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 * generation. The algorithm uses polynomial x^31 + x^3 + 1
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 * (length of PN sequence is 2^31 - 1).
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 * INPUTS: *shift_reg Old CN generator shift register state
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 * OUTPUTS: *shift_reg Updated CN generator shift register state
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 * RETURN VALUE: Generated random integer value
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 *************************************************************************/
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 Word16 pseudonoise (
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 Word32 *shift_reg, /* i/o : Old CN generator shift register state */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 Word16 no_bits /* i : Number of bits */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 );
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 /*************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 * FUNCTION NAME: build_CN_code
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 * PURPOSE: Compute the comfort noise fixed codebook excitation. The
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 * gains of the pulses are always +/-1.
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 * INPUTS: *seed Old CN generator shift register state
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 * OUTPUTS: cod[0..39] Generated comfort noise fixed codebook vector
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 * *seed Updated CN generator shift register state
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 * RETURN VALUE: none
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 *************************************************************************/
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 void build_CN_code (
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 Word32 *seed, /* i/o : Old CN generator shift register state */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 Word16 cod[] /* o : Generated CN fixed codebook vector */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 );
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 /*************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 * FUNCTION NAME: build_CN_param
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 * PURPOSE: Randomize the speech parameters. So that they
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 * do not produce tonal artifacts if used by ECU.
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 * INPUTS: *seed Old CN generator shift register state
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 * n_param, Number of parameters to randomize
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 * parm_size_table,
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 * OUTPUTS: parm CN Generated Parameters
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 * *seed Updated CN generator shift register state
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 * RETURN VALUE: none
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 *************************************************************************/
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 void build_CN_param (
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 Word16 *seed, /* i/o : Old CN generator shift register state */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 const Word16 n_param, /* i : number of params */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 const Word16 param_size_table[], /* i : size of params */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 Word16 parm[] /* o : CN Generated Params*/
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 );
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 #endif