annotate libgsmfr2/enc_main.c @ 470:ea89eb8291bf

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