comparison pcmu2efr/gen-amr-2fr.c @ 23:2628a34fe75b

pcmu2efr: encode 2nd frame for AMR-EFR offsets 120-159
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 12 May 2024 04:24:15 +0000
parents pcmu2efr/gen-amrefr.c@f4420403219a
children
comparison
equal deleted inserted replaced
22:f4420403219a 23:2628a34fe75b
1 /*
2 * The code in this module takes linear_input_array[] from gen160.c
3 * and generates EFR-format frames by way of libtwamr encoder.
4 * This version does a second frame pass on offsets 120-159.
5 */
6
7 #include <stdio.h>
8 #include <stdint.h>
9 #include <stdlib.h>
10 #include <gsm_efr.h>
11 #include <tw_amr.h>
12
13 extern uint16_t linear_input_array[480];
14
15 uint8_t amr_efr[160][31];
16
17 void
18 generate_amr_efr(void)
19 {
20 struct amr_encoder_state *st;
21 struct amr_param_frame amr_frame;
22 unsigned m;
23
24 st = amr_encoder_create(0, 0);
25 if (!st) {
26 fprintf(stderr, "error: amr_encoder_create() failed\n");
27 exit(1);
28 }
29 for (m = 0; m < 160; m++) {
30 amr_encoder_reset(st, 0, 0);
31 amr_encode_frame(st, MR122,
32 (const int16_t *) linear_input_array + 160 - m,
33 &amr_frame);
34 if (m >= 120) {
35 amr_encode_frame(st, MR122,
36 (const int16_t *) linear_input_array + 320 - m,
37 &amr_frame);
38 }
39 EFR_params2frame(amr_frame.param, amr_efr[m]);
40 }
41 free(st);
42 }