comparison libgsmfr2/enc_main.c @ 265:a7b593e68ac3

libgsmfr2: integrate encoder main function from libgsm
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Apr 2024 00:24:21 +0000
parents
children
comparison
equal deleted inserted replaced
264:8b21a6b7a3bf 265:a7b593e68ac3
1 /*
2 * This C source file has been adapted from TU-Berlin libgsm source
3 * (src/code.c), original notice follows:
4 *
5 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
6 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
7 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
8 */
9
10 #include <stdint.h>
11 #include <string.h>
12 #include "tw_gsmfr.h"
13 #include "typedef.h"
14 #include "ed_state.h"
15 #include "ed_internal.h"
16
17 /*
18 * 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER
19 */
20
21 void gsmfr_0610_encode_params(struct gsmfr_0610_state *S, const int16_t *s,
22 struct gsmfr_param_frame *outp)
23 {
24 int k;
25 word * dp = S->dp0 + 120; /* [ -120...-1 ] */
26 word * dpp = dp; /* [ 0...39 ] */
27
28 word so[160];
29
30 Gsm_Preprocess (S, s, so);
31 Gsm_LPC_Analysis (S, so, outp->LARc);
32 Gsm_Short_Term_Analysis_Filter (S, outp->LARc, so);
33
34 for (k = 0; k <= 3; k++) {
35
36 Gsm_Long_Term_Predictor ( S,
37 so+k*40, /* d [0..39] IN */
38 dp, /* dp [-120..-1] IN */
39 S->e + 5, /* e [0..39] OUT */
40 dpp, /* dpp [0..39] OUT */
41 &outp->Nc[k],
42 &outp->bc[k]);
43
44 Gsm_RPE_Encoding ( S,
45 S->e + 5,/* e ][0..39][ IN/OUT */
46 &outp->xmaxc[k], &outp->Mc[k],
47 outp->xMc[k] );
48 /*
49 * Gsm_Update_of_reconstructed_short_time_residual_signal
50 * ( dpp, S->e + 5, dp );
51 */
52
53 { register int i;
54 register longword ltmp;
55 for (i = 0; i <= 39; i++)
56 dp[ i ] = GSM_ADD( S->e[5 + i], dpp[i] );
57 }
58 dp += 40;
59 dpp += 40;
60
61 }
62 (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160),
63 120 * sizeof(*S->dp0) );
64 }