annotate libtwamr/d1035pf.c @ 451:614ae8dc6807

README: update for libgsmfr2+libgsmefr+libtwamr set
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 10 May 2024 02:36:34 +0000
parents 2cf33c211544
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
330
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : d1035pf.c
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Builds the innovative codevector
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 /*
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 * MODULE INCLUDE FILE AND VERSION ID
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #include "namespace.h"
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #include "d1035pf.h"
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 /*
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 * INCLUDE FILES
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "typedef.h"
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "basic_op.h"
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "no_count.h"
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "cnst.h"
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #include "graytab.h"
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 /*
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 * LOCAL VARIABLES AND TABLES
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 #define NB_PULSE 10 /* number of pulses */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 /*
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 * PUBLIC PROGRAM CODE
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 ********************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 /*************************************************************************
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 *
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 * FUNCTION: dec_10i40_35bits()
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 *
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 * PURPOSE: Builds the innovative codevector from the received
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 * index of algebraic codebook.
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 *
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 * See c1035pf.c for more details about the algebraic codebook structure.
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 *
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 *************************************************************************/
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 void dec_10i40_35bits (
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 Word16 index[], /* (i) : index of 10 pulses (sign+position) */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 Word16 cod[] /* (o) : algebraic (fixed) codebook excitation */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 )
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 {
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 Word16 i, j, pos1, pos2, sign, tmp;
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 for (i = 0; i < L_CODE; i++)
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 {
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 cod[i] = 0; move16 ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 }
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 /* decode the positions and signs of pulses and build the codeword */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 for (j = 0; j < NB_TRACK; j++)
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 {
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 /* compute index i */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 tmp = index[j]; move16 ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 i = tmp & 7; logic16 ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 i = dgray[i]; move16 ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 i = extract_l (L_shr (L_mult (i, 5), 1));
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 pos1 = add (i, j); /* position of pulse "j" */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 i = shr (tmp, 3) & 1; logic16 ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 test ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 if (i == 0)
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 {
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 sign = 4096; move16 (); /* +1.0 */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 }
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 else
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 {
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 sign = -4096; move16 (); /* -1.0 */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 }
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 cod[pos1] = sign; move16 ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 /* compute index i */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 i = index[add (j, 5)] & 7; logic16 ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 i = dgray[i]; move16 ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 i = extract_l (L_shr (L_mult (i, 5), 1));
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 pos2 = add (i, j); /* position of pulse "j+5" */
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 test ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 if (sub (pos2, pos1) < 0)
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 {
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 sign = negate (sign);
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 }
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 cod[pos2] = add (cod[pos2], sign); move16 ();
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 }
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 return;
2cf33c211544 libtwamr: integrate d1035pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 }