FreeCalypso > hg > gsm-codec-lib
comparison amrefr/encode-r.c @ 438:1bf1bbcef763
amrefr: implement amrefr-encode-r utility
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Wed, 08 May 2024 23:43:26 +0000 |
| parents | efrtest/encode-r.c@cab6690535ec |
| children | 0c4e1bc06740 |
comparison
equal
deleted
inserted
replaced
| 437:3eadaef8b28f | 438:1bf1bbcef763 |
|---|---|
| 1 /* | |
| 2 * amrefr-encode-r is a counterpart to gsmefr-encode-r, implementing | |
| 3 * "alternative EFR" by way of libtwamr. Unlike standard gsmefr-encode-r, | |
| 4 * there is no -d option and no DTX support in this version. | |
| 5 */ | |
| 6 | |
| 7 #include <stdio.h> | |
| 8 #include <stdint.h> | |
| 9 #include <stdlib.h> | |
| 10 #include <string.h> | |
| 11 #include <strings.h> | |
| 12 #include "../libgsmefr/gsm_efr.h" | |
| 13 #include "../libtwamr/tw_amr.h" | |
| 14 #include "../libtest/roberead.h" | |
| 15 | |
| 16 main(argc, argv) | |
| 17 char **argv; | |
| 18 { | |
| 19 FILE *inf, *binf; | |
| 20 struct amr_encoder_state *state; | |
| 21 int16_t pcm[160]; | |
| 22 struct amr_param_frame amr_frame; | |
| 23 uint8_t efr_frame[EFR_RTP_FRAME_LEN]; | |
| 24 int rc; | |
| 25 | |
| 26 if (argc != 3) { | |
| 27 fprintf(stderr, "usage: %s input.robe output.gsmx\n", argv[0]); | |
| 28 exit(1); | |
| 29 } | |
| 30 inf = fopen(argv[1], "r"); | |
| 31 if (!inf) { | |
| 32 perror(argv[1]); | |
| 33 exit(1); | |
| 34 } | |
| 35 binf = fopen(argv[2], "w"); | |
| 36 if (!binf) { | |
| 37 perror(argv[2]); | |
| 38 exit(1); | |
| 39 } | |
| 40 state = amr_encoder_create(0, 0); | |
| 41 if (!state) { | |
| 42 perror("amr_encoder_create()"); | |
| 43 exit(1); | |
| 44 } | |
| 45 for (;;) { | |
| 46 rc = robe_get_pcm_block(inf, pcm); | |
| 47 if (!rc) | |
| 48 break; | |
| 49 amr_encode_frame(state, MR122, pcm, &amr_frame); | |
| 50 amr_dhf_subst_efr(&amr_frame); | |
| 51 EFR_params2frame(amr_frame.param, efr_frame); | |
| 52 fwrite(efr_frame, 1, sizeof efr_frame, binf); | |
| 53 } | |
| 54 fclose(binf); | |
| 55 exit(0); | |
| 56 } |
