FreeCalypso > hg > vband-misc
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pcma2efr/gen-amr-2fr.c Mon May 13 02:45:17 2024 +0000 @@ -0,0 +1,51 @@ +/* + * The code in this module takes linear_input_array[] from gen160.c + * and generates EFR-format frames by way of libtwamr encoder. + * This version does a second frame pass on offsets 120-159. + */ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <gsm_efr.h> +#include <tw_amr.h> + +extern uint16_t linear_input_array[480]; + +uint8_t amr_efr[160][31]; + +void +generate_amr_efr(void) +{ + struct amr_encoder_state *st; + struct amr_param_frame amr_frame; + unsigned m; + + st = amr_encoder_create(0, 0); + if (!st) { + fprintf(stderr, "error: amr_encoder_create() failed\n"); + exit(1); + } + for (m = 0; m < 160; m++) { + amr_encoder_reset(st, 0, 0); + amr_encode_frame(st, MR122, + (const int16_t *) linear_input_array + 160 - m, + &amr_frame); + if (m >= 120) { + if (bcmp(amr_frame.param, amr_dhf_mr122, + EFR_NUM_PARAMS * sizeof(int16_t))) { + fprintf(stderr, + "MR122 DHF check failed on AMR-EFR first frame #%u\n", + m); + exit(1); + } + amr_encode_frame(st, MR122, + (const int16_t *) linear_input_array + 320 - m, + &amr_frame); + } + EFR_params2frame(amr_frame.param, amr_efr[m]); + } + free(st); +}