FreeCalypso > hg > vband-misc
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pcmu2efr/gen-amrefr.c Sun May 12 00:56:42 2024 +0000 @@ -0,0 +1,35 @@ +/* + * The code in this module takes linear_inputs[][] from gen160.c + * and generates EFR-format frames by way of libtwamr encoder. + */ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <gsm_efr.h> +#include <tw_amr.h> + +extern uint16_t linear_inputs[160][160]; + +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_inputs[m], + &amr_frame); + EFR_params2frame(amr_frame.param, amr_efr[m]); + } + free(st); +}