FreeCalypso > hg > vband-misc
comparison pcma2efr/gen-amr-2fr.c @ 28:4f47447fd17f
pcma2efr: starting with DHF check
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 13 May 2024 02:45:17 +0000 |
parents | pcmu2efr/gen-amr-2fr.c@2628a34fe75b |
children |
comparison
equal
deleted
inserted
replaced
27:2095f3c23dad | 28:4f47447fd17f |
---|---|
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 <string.h> | |
11 #include <strings.h> | |
12 #include <gsm_efr.h> | |
13 #include <tw_amr.h> | |
14 | |
15 extern uint16_t linear_input_array[480]; | |
16 | |
17 uint8_t amr_efr[160][31]; | |
18 | |
19 void | |
20 generate_amr_efr(void) | |
21 { | |
22 struct amr_encoder_state *st; | |
23 struct amr_param_frame amr_frame; | |
24 unsigned m; | |
25 | |
26 st = amr_encoder_create(0, 0); | |
27 if (!st) { | |
28 fprintf(stderr, "error: amr_encoder_create() failed\n"); | |
29 exit(1); | |
30 } | |
31 for (m = 0; m < 160; m++) { | |
32 amr_encoder_reset(st, 0, 0); | |
33 amr_encode_frame(st, MR122, | |
34 (const int16_t *) linear_input_array + 160 - m, | |
35 &amr_frame); | |
36 if (m >= 120) { | |
37 if (bcmp(amr_frame.param, amr_dhf_mr122, | |
38 EFR_NUM_PARAMS * sizeof(int16_t))) { | |
39 fprintf(stderr, | |
40 "MR122 DHF check failed on AMR-EFR first frame #%u\n", | |
41 m); | |
42 exit(1); | |
43 } | |
44 amr_encode_frame(st, MR122, | |
45 (const int16_t *) linear_input_array + 320 - m, | |
46 &amr_frame); | |
47 } | |
48 EFR_params2frame(amr_frame.param, amr_efr[m]); | |
49 } | |
50 free(st); | |
51 } |