comparison libtwamr/d2_9pf.c @ 332:2303ba1490dd

libtwamr: integrate d2_9pf.c
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 18 Apr 2024 22:18:45 +0000
parents
children
comparison
equal deleted inserted replaced
331:c75327562b5e 332:2303ba1490dd
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 : d2_9pf.c
11 * Purpose : Algebraic codebook decoder
12 *
13 *****************************************************************************
14 */
15
16 /*
17 *****************************************************************************
18 * MODULE INCLUDE FILE AND VERSION ID
19 *****************************************************************************
20 */
21 #include "namespace.h"
22 #include "d2_9pf.h"
23
24 /*
25 *****************************************************************************
26 * INCLUDE FILES
27 *****************************************************************************
28 */
29 #include "typedef.h"
30 #include "basic_op.h"
31 #include "no_count.h"
32 #include "cnst.h"
33
34 /*
35 ********************************************************************************
36 * LOCAL VARIABLES AND TABLES
37 ********************************************************************************
38 */
39 #define NB_PULSE 2 /* number of pulses */
40
41 #include "c2_9pf.tab"
42
43 /*
44 ********************************************************************************
45 * PUBLIC PROGRAM CODE
46 ********************************************************************************
47 */
48 /*************************************************************************
49 *
50 * FUNCTION: decode_2i40_9bits (decod_ACELP())
51 *
52 * PURPOSE: Algebraic codebook decoder. For details about the encoding se
53 * c2_9pf.c
54 *
55 *************************************************************************/
56
57 void decode_2i40_9bits(
58 Word16 subNr, /* i : subframe number */
59 Word16 sign, /* i : signs of 2 pulses. */
60 Word16 index, /* i : Positions of the 2 pulses. */
61 Word16 cod[] /* o : algebraic (fixed) codebook excitation */
62 )
63 {
64 Word16 i, j, k;
65 Word16 pos[NB_PULSE];
66
67 /* Decode the positions */
68 /* table bit is the MSB */
69 j = shr((index & 64),6); logic16 ();
70
71 i = index & 7; logic16 ();
72
73 i = add(i, shl(i, 2)); /* pos0 =i*5+startPos[j*8+subNr*2] */
74 k = startPos[add(shl(j, 3), shl(subNr, 1))];
75 pos[0] = add(i, k); move16 ();
76
77 index = shr(index, 3);
78 i = index & 7; logic16 ();
79
80 i = add(i, shl(i, 2)); /* pos1 =i*5+startPos[j*8+subNr*2+1] */
81 k = startPos[add(add(shl(j, 3), shl(subNr, 1)), 1)];
82 pos[1] = add(i, k); move16 ();
83
84 /* decode the signs and build the codeword */
85
86 for (i = 0; i < L_SUBFR; i++) {
87 cod[i] = 0; move16 ();
88 }
89
90 for (j = 0; j < NB_PULSE; j++) {
91 i = sign & 1; logic16 ();
92 sign = shr(sign, 1);
93
94 test ();
95 if (i != 0) {
96 cod[pos[j]] = 8191; move16 (); /* +1.0 */
97 } else {
98 cod[pos[j]] = -8192; move16 (); /* -1.0 */
99 }
100 }
101
102 return;
103 }