comparison libtwamr/spreproc.c @ 403:7e0aeab69b10

libtwamr: integrate spreproc.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 23:11:34 +0000
parents
children
comparison
equal deleted inserted replaced
402:a8b73b1c5b19 403:7e0aeab69b10
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 : spreproc.c
11 * Purpose : Subframe preprocessing
12 *
13 ********************************************************************************
14 */
15
16 /*
17 ********************************************************************************
18 * MODULE INCLUDE FILE AND VERSION ID
19 ********************************************************************************
20 */
21 #include "namespace.h"
22 #include "spreproc.h"
23
24 /*
25 ********************************************************************************
26 * INCLUDE FILES
27 ********************************************************************************
28 */
29 #include "typedef.h"
30 #include "basic_op.h"
31 #include "oper_32b.h"
32 #include "weight_a.h"
33 #include "syn_filt.h"
34 #include "residu.h"
35 #include "memops.h"
36 #include "no_count.h"
37
38 /*
39 ********************************************************************************
40 * PUBLIC PROGRAM CODE
41 ********************************************************************************
42 */
43 int subframePreProc(
44 enum Mode mode, /* i : coder mode */
45 const Word16 gamma1[], /* i : spectral exp. factor 1 */
46 const Word16 gamma1_12k2[],/* i : spectral exp. factor 1 for EFR */
47 const Word16 gamma2[], /* i : spectral exp. factor 2 */
48 Word16 *A, /* i : A(z) unquantized for the 4 subframes */
49 Word16 *Aq, /* i : A(z) quantized for the 4 subframes */
50 Word16 *speech, /* i : speech segment */
51 Word16 *mem_err, /* i : pointer to error signal */
52 Word16 *mem_w0, /* i : memory of weighting filter */
53 Word16 *zero, /* i : pointer to zero vector */
54 Word16 ai_zero[], /* o : history of weighted synth. filter */
55 Word16 exc[], /* o : long term prediction residual */
56 Word16 h1[], /* o : impulse response */
57 Word16 xn[], /* o : target vector for pitch search */
58 Word16 res2[], /* o : long term prediction residual */
59 Word16 error[] /* o : error of LPC synthesis filter */
60 )
61 {
62 Word16 i;
63 Word16 Ap1[MP1]; /* A(z) with spectral expansion */
64 Word16 Ap2[MP1]; /* A(z) with spectral expansion */
65 const Word16 *g1; /* Pointer to correct gammma1 vector */
66
67 /*---------------------------------------------------------------*
68 * mode specific pointer to gamma1 values *
69 *---------------------------------------------------------------*/
70 test (); test ();
71 if ( sub(mode, MR122) == 0 || sub(mode, MR102) == 0 )
72 {
73 g1 = gamma1_12k2; move16 ();
74 }
75 else
76 {
77 g1 = gamma1; move16 ();
78 }
79 /*---------------------------------------------------------------*
80 * Find the weighted LPC coefficients for the weighting filter. *
81 *---------------------------------------------------------------*/
82 Weight_Ai(A, g1, Ap1);
83 Weight_Ai(A, gamma2, Ap2);
84
85 /*---------------------------------------------------------------*
86 * Compute impulse response, h1[], of weighted synthesis filter *
87 *---------------------------------------------------------------*/
88 for (i = 0; i <= M; i++)
89 {
90 ai_zero[i] = Ap1[i]; move16 ();
91 }
92
93 Syn_filt(Aq, ai_zero, h1, L_SUBFR, zero, 0);
94 Syn_filt(Ap2, h1, h1, L_SUBFR, zero, 0);
95
96 /*------------------------------------------------------------------------*
97 * *
98 * Find the target vector for pitch search: *
99 * *
100 *------------------------------------------------------------------------*/
101
102 /* LPC residual */
103 Residu(Aq, speech, res2, L_SUBFR);
104 Copy(res2, exc, L_SUBFR);
105
106 Syn_filt(Aq, exc, error, L_SUBFR, mem_err, 0);
107
108 Residu(Ap1, error, xn, L_SUBFR);
109
110 /* target signal xn[]*/
111 Syn_filt(Ap2, xn, xn, L_SUBFR, mem_w0, 0);
112
113 return 0;
114 }