FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/d3_14pf.c @ 477:4c9222d95647
libtwamr encoder: always emit frame->mode = mode;
In the original implementation of amr_encode_frame(), the 'mode' member
of the output struct was set to 0xFF if the output frame type is TX_NO_DATA.
This design was made to mimic the mode field (16-bit word) being set to
0xFFFF (or -1) in 3GPP test sequence format - but nothing actually depends
on this struct member being set in any way, and amr_frame_to_tseq()
generates the needed 0xFFFF on its own, based on frame->type being equal
to TX_NO_DATA.
It is simpler and more efficient to always set frame->mode to the actual
encoding mode in amr_encode_frame(), and this new behavior has already
been documented in doc/AMR-library-API description in anticipation of
the present change.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 18 May 2024 22:30:42 +0000 |
parents | f4a5545ea8b2 |
children |
rev | line source |
---|---|
333
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : d3_14pf.c |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Algebraic codebook decoder |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * MODULE INCLUDE FILE AND VERSION ID |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "namespace.h" |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "d3_14pf.h" |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 * INCLUDE FILES |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "typedef.h" |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "basic_op.h" |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "no_count.h" |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "cnst.h" |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 /* |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 * LOCAL VARIABLES AND TABLES |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 #define NB_PULSE 3 /* number of pulses */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 /* |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 * PUBLIC PROGRAM CODE |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 ******************************************************************************** |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 /************************************************************************* |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * FUNCTION: decode_3i40_14bits (decod_ACELP()) |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * PURPOSE: Algebraic codebook decoder |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 * |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 *************************************************************************/ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 void decode_3i40_14bits( |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 Word16 sign, /* i : signs of 3 pulses. */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 Word16 index, /* i : Positions of the 3 pulses. */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 Word16 cod[] /* o : algebraic (fixed) codebook excitation */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 ) |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 { |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 Word16 i, j; |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 Word16 pos[NB_PULSE]; |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 /* Decode the positions */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 i = index & 7; logic16 (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 pos[0] = add(i, shl(i, 2)); /* pos0 =i*5 */ move16 (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 index = shr(index, 3); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 j = index & 1; logic16 (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 index = shr(index, 1); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 i = index & 7; logic16 (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 i = add(i, shl(i, 2)); /* pos1 =i*5+1+j*2 */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 i = add(i, 1); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 j = shl(j, 1); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 pos[1] = add(i, j); move16 (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 index = shr(index, 3); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 j = index & 1; logic16 (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 index = shr(index, 1); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 i = index & 7; logic16 (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 i = add(i, shl(i, 2)); /* pos2 =i*5+2+j*2 */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 i = add(i, 2); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 j = shl(j, 1); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 pos[2] = add(i, j); move16 (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 /* decode the signs and build the codeword */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 for (i = 0; i < L_SUBFR; i++) { |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 cod[i] = 0; move16 (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 } |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 for (j = 0; j < NB_PULSE; j++) { |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 i = sign & 1; logic16 (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 sign = shr(sign, 1); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 test (); |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 if (i > 0) { |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 cod[pos[j]] = 8191; move16 (); /* +1.0 */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 } else { |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 cod[pos[j]] = -8192; move16 (); /* -1.0 */ |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 } |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 return; |
f4a5545ea8b2
libtwamr: integrate d3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |