-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathde_acelp.c
70 lines (55 loc) · 1.76 KB
/
de_acelp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ITU-T G.729 Software Package Release 2 (November 2006) */
/*
ITU-T G.729A Speech Coder ANSI-C Source Code
Version 1.1 Last modified: September 1996
Copyright (c) 1996,
AT&T, France Telecom, NTT, Universite de Sherbrooke, Lucent Technologies
All rights reserved.
*/
/*-----------------------------------------------------------*
* Function Decod_ACELP() *
* ~~~~~~~~~~~~~~~~~~~~~~~ *
* Algebraic codebook decoder. *
*----------------------------------------------------------*/
#include "typedef.h"
#include "basic_op.h"
#include "ld8a.h"
void Decod_ACELP(Word16 sign, /* (i) : signs of 4 pulses. */
Word16 index, /* (i) : Positions of the 4 pulses. */
Word16 cod[] /* (o) Q13 : algebraic (fixed) codebook excitation */
) {
Word16 i, j;
Word16 pos[4];
/* Decode the positions */
i = index & (Word16) 7;
pos[0] = add(i, shl(i, 2)); /* pos0 =i*5 */
index = shr(index, 3);
i = index & (Word16) 7;
i = add(i, shl(i, 2)); /* pos1 =i*5+1 */
pos[1] = add(i, 1);
index = shr(index, 3);
i = index & (Word16) 7;
i = add(i, shl(i, 2)); /* pos2 =i*5+1 */
pos[2] = add(i, 2);
index = shr(index, 3);
j = index & (Word16) 1;
index = shr(index, 1);
i = index & (Word16) 7;
i = add(i, shl(i, 2)); /* pos3 =i*5+3+j */
i = add(i, 3);
pos[3] = add(i, j);
/* decode the signs and build the codeword */
for (i = 0; i < L_SUBFR; i++) {
cod[i] = 0;
}
for (j = 0; j < 4; j++) {
i = sign & (Word16) 1;
sign = shr(sign, 1);
if (i != 0) {
cod[pos[j]] = 8191; /* Q13 +1.0 */
} else {
cod[pos[j]] = -8192; /* Q13 -1.0 */
}
}
return;
}