comparison libtwamr/d1035pf.c @ 330:2cf33c211544

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