FreeCalypso > hg > vband-misc
annotate pcmu2efr/gen-amrefr.c @ 19:2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 12 May 2024 00:56:42 +0000 |
parents | pcmu2efr/gen-efr.c@528eef871e23 |
children | f4420403219a |
rev | line source |
---|---|
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * The code in this module takes linear_inputs[][] 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 |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 extern uint16_t linear_inputs[160][160]; |
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); |
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
30 amr_encode_frame(st, MR122, (const int16_t *) linear_inputs[m], |
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
31 &amr_frame); |
2bdcd2ed9a1c
pcmu2efr: generate AMR-EFR version
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
32 EFR_params2frame(amr_frame.param, amr_efr[m]); |
15
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 free(st); |
528eef871e23
pcmu2efr project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 } |