FreeCalypso > hg > vband-misc
annotate pcmu2efr/gen-amr-2fr.c @ 34:307fe06fabec
dhf: generate EFR hex DHF in C form
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 14 May 2024 03:36:31 +0000 |
parents | 2628a34fe75b |
children |
rev | line source |
---|---|
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
22
f4420403219a
pcmu2efr: change linear input gen to support 2nd frame
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
2 * The code in this module takes linear_input_array[] from gen160.c |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
3 * and generates EFR-format frames by way of libtwamr encoder. |
23
2628a34fe75b
pcmu2efr: encode 2nd frame for AMR-EFR offsets 120-159
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
4 * This version does a second frame pass on offsets 120-159. |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdint.h> |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <gsm_efr.h> |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
11 #include <tw_amr.h> |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
22
f4420403219a
pcmu2efr: change linear input gen to support 2nd frame
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
13 extern uint16_t linear_input_array[480]; |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
15 uint8_t amr_efr[160][31]; |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 void |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
18 generate_amr_efr(void) |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 { |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
20 struct amr_encoder_state *st; |
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
21 struct amr_param_frame amr_frame; |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 unsigned m; |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
24 st = amr_encoder_create(0, 0); |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 if (!st) { |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
26 fprintf(stderr, "error: amr_encoder_create() failed\n"); |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 exit(1); |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 } |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 for (m = 0; m < 160; m++) { |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
30 amr_encoder_reset(st, 0, 0); |
22
f4420403219a
pcmu2efr: change linear input gen to support 2nd frame
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
31 amr_encode_frame(st, MR122, |
f4420403219a
pcmu2efr: change linear input gen to support 2nd frame
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
32 (const int16_t *) linear_input_array + 160 - m, |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
33 &amr_frame); |
23
2628a34fe75b
pcmu2efr: encode 2nd frame for AMR-EFR offsets 120-159
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
34 if (m >= 120) { |
2628a34fe75b
pcmu2efr: encode 2nd frame for AMR-EFR offsets 120-159
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
35 amr_encode_frame(st, MR122, |
2628a34fe75b
pcmu2efr: encode 2nd frame for AMR-EFR offsets 120-159
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
36 (const int16_t *) linear_input_array + 320 - m, |
2628a34fe75b
pcmu2efr: encode 2nd frame for AMR-EFR offsets 120-159
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
37 &amr_frame); |
2628a34fe75b
pcmu2efr: encode 2nd frame for AMR-EFR offsets 120-159
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
38 } |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
39 EFR_params2frame(amr_frame.param, amr_efr[m]); |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 } |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 free(st); |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |