annotate libtwamr/b_cn_cod.c @ 287:f00925b533b7

gsmfr-encode: convert to libgsmfr2
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Apr 2024 06:16:47 +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.c
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 /*
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 * MODULE INCLUDE FILE AND VERSION ID
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 "namespace.h"
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #include "b_cn_cod.h"
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 /*
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 * INCLUDE FILES
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 */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 #include "typedef.h"
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #include "basic_op.h"
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "oper_32b.h"
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "no_count.h"
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "cnst.h"
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "window.h"
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 * LOCAL CONSTANTS
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 */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 #define NB_PULSE 10 /* number of random pulses in DTX operation */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 /*
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 ********************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 * PUBLIC PROGRAM CODE
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 ********************************************************************************
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 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 * FUNCTION NAME: pseudonoise
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 *
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 Word16 pseudonoise (
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 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
54 Word16 no_bits /* i : Number of bits */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 )
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 Word16 noise_bits, Sn, i;
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 noise_bits = 0; move16 ();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 for (i = 0; i < no_bits; i++)
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 /* State n == 31 */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 test (); logic32 ();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 if ((*shift_reg & 0x00000001L) != 0)
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 Sn = 1; move16 ();
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 else
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 Sn = 0; move16 ();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }
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 /* State n == 3 */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 test (); logic32 ();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 if ((*shift_reg & 0x10000000L) != 0)
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 Sn = Sn ^ 1; move16 (); logic16 ();
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 else
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 Sn = Sn ^ 0; move16 (); logic16 ();
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
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 noise_bits = shl (noise_bits, 1);
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 noise_bits = noise_bits | (extract_l (*shift_reg) & 1);
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 logic16 (); logic16 (); move16 ();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 *shift_reg = L_shr (*shift_reg, 1);
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 test ();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 if (Sn & 1)
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 *shift_reg = *shift_reg | 0x40000000L; move32 (); logic32 ();
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 }
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 return noise_bits;
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
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 /***************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 * Function : build_CN_code
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 *
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 void build_CN_code (
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 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
105 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
106 )
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 Word16 i, j, k;
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 for (i = 0; i < L_SUBFR; i++)
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 cod[i] = 0; move16 ();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 }
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 for (k = 0; k < NB_PULSE; k++)
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 i = pseudonoise (seed, 2); /* generate pulse position */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 i = shr (extract_l (L_mult (i, 10)), 1);
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 i = add (i, k);
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 j = pseudonoise (seed, 1); /* generate sign */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 test ();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 if (j > 0)
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 cod[i] = 4096; move16 ();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 }
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 else
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 cod[i] = -4096; move16 ();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 }
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 }
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 return;
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 }
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 /*************************************************************************
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 * FUNCTION NAME: build_CN_param
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 *
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 *************************************************************************/
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 void build_CN_param (
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 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
144 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
145 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
146 Word16 parm[] /* o : CN Generated params */
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 )
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 {
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 Word16 i;
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 const Word16 *p;
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 *seed = extract_l(L_add(L_shr(L_mult(*seed, 31821), 1), 13849L));
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 p = &window_200_40[*seed & 0x7F]; logic16();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 for(i=0; i< n_param;i++){
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 move16 (); logic16(); logic16(); logic16();
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 parm[i] = *p++ & ~(0xFFFF<<param_size_table[i]);
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 }
07f936338de1 libtwamr: integrated up to b_cn_cod.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 }