FreeCalypso > hg > vband-misc
annotate pcmu2efr/gen-amrefr.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 | f4420403219a |
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. |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
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 #include <stdio.h> |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdint.h> |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <gsm_efr.h> |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
10 #include <tw_amr.h> |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
22
f4420403219a
pcmu2efr: change linear input gen to support 2nd frame
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
12 extern uint16_t linear_input_array[480]; |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
14 uint8_t amr_efr[160][31]; |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 void |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
17 generate_amr_efr(void) |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 { |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
19 struct amr_encoder_state *st; |
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
20 struct amr_param_frame amr_frame; |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 unsigned m; |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
23 st = amr_encoder_create(0, 0); |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (!st) { |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
25 fprintf(stderr, "error: amr_encoder_create() failed\n"); |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 exit(1); |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 for (m = 0; m < 160; m++) { |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
29 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
|
30 amr_encode_frame(st, MR122, |
f4420403219a
pcmu2efr: change linear input gen to support 2nd frame
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
31 (const int16_t *) linear_input_array + 160 - m, |
19
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
32 &amr_frame); |
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
33 EFR_params2frame(amr_frame.param, amr_efr[m]); |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 free(st); |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |