comparison libgsmefr/int_lpc.c @ 53:49dd1ac8e75b

libgsmefr: import most *.c files from ETSI source
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 25 Nov 2022 16:18:21 +0000
parents
children a0a1e8de4b46
comparison
equal deleted inserted replaced
52:988fd7ff514f 53:49dd1ac8e75b
1 /*************************************************************************
2 *
3 * FUNCTION: Int_lpc()
4 *
5 * PURPOSE: Interpolates the LSPs and converts to LPC parameters to get
6 * a different LP filter in each subframe.
7 *
8 * DESCRIPTION:
9 * The 20 ms speech frame is divided into 4 subframes.
10 * The LSPs are quantized and transmitted at the 2nd and 4th subframes
11 * (twice per frame) and interpolated at the 1st and 3rd subframe.
12 *
13 * |------|------|------|------|
14 * sf1 sf2 sf3 sf4
15 * F0 Fm F1
16 *
17 * sf1: 1/2 Fm + 1/2 F0 sf3: 1/2 F1 + 1/2 Fm
18 * sf2: Fm sf4: F1
19 *
20 *************************************************************************/
21
22 #include "typedef.h"
23 #include "basic_op.h"
24 #include "count.h"
25 #include "sig_proc.h"
26
27 #define M 10 /* LP order */
28 #define MP1 11 /* M+1 */
29
30 void Int_lpc (
31 Word16 lsp_old[], /* input : LSP vector at the 4th subframe
32 of past frame */
33 Word16 lsp_mid[], /* input : LSP vector at the 2nd subframe
34 of present frame */
35 Word16 lsp_new[], /* input : LSP vector at the 4th subframe of
36 present frame */
37 Word16 Az[] /* output: interpolated LP parameters in
38 all subframes */
39 )
40 {
41 Word16 i;
42 Word16 lsp[M];
43
44 /* lsp[i] = lsp_mid[i] * 0.5 + lsp_old[i] * 0.5 */
45
46 for (i = 0; i < M; i++)
47 {
48 lsp[i] = add (shr (lsp_mid[i], 1), shr (lsp_old[i], 1));
49 move16 ();
50 }
51
52 Lsp_Az (lsp, Az); /* Subframe 1 */
53 Az += MP1; move16 ();
54
55 Lsp_Az (lsp_mid, Az); /* Subframe 2 */
56 Az += MP1; move16 ();
57
58 for (i = 0; i < M; i++)
59 {
60 lsp[i] = add (shr (lsp_mid[i], 1), shr (lsp_new[i], 1));
61 move16 ();
62 }
63
64 Lsp_Az (lsp, Az); /* Subframe 3 */
65 Az += MP1; move16 ();
66
67 Lsp_Az (lsp_new, Az); /* Subframe 4 */
68
69 return;
70 }
71
72 /*----------------------------------------------------------------------*
73 * Function Int_lpc2() *
74 * ~~~~~~~~~~~~~~~~~~ *
75 * Interpolation of the LPC parameters. *
76 * Same as the previous function but we do not recompute Az() for *
77 * subframe 2 and 4 because it is already available. *
78 *----------------------------------------------------------------------*/
79
80 void Int_lpc2 (
81 Word16 lsp_old[], /* input : LSP vector at the 4th subframe
82 of past frame */
83 Word16 lsp_mid[], /* input : LSP vector at the 2nd subframe
84 of present frame */
85 Word16 lsp_new[], /* input : LSP vector at the 4th subframe of
86 present frame */
87 Word16 Az[] /* output: interpolated LP parameters
88 in subframes 1 and 3 */
89 )
90 {
91 Word16 i;
92 Word16 lsp[M];
93
94 /* lsp[i] = lsp_mid[i] * 0.5 + lsp_old[i] * 0.5 */
95
96 for (i = 0; i < M; i++)
97 {
98 lsp[i] = add (shr (lsp_mid[i], 1), shr (lsp_old[i], 1));
99 move16 ();
100 }
101 Lsp_Az (lsp, Az); /* Subframe 1 */
102 Az += MP1 * 2; move16 ();
103
104 for (i = 0; i < M; i++)
105 {
106 lsp[i] = add (shr (lsp_mid[i], 1), shr (lsp_new[i], 1));
107 move16 ();
108 }
109 Lsp_Az (lsp, Az); /* Subframe 3 */
110
111 return;
112 }