FreeCalypso > hg > gsm-codec-lib
comparison amrefr/tseq-enc.c @ 434:ba5031723ab6
implement amrefr-tseq-enc test program
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 08 May 2024 02:17:08 +0000 |
parents | efrtest/etsi-enc.c@51678b070c7a |
children | 026bdc1f0dda |
comparison
equal
deleted
inserted
replaced
433:51678b070c7a | 434:ba5031723ab6 |
---|---|
1 /* | |
2 * amrefr-tseq-enc is a test program for our libtwamr-based "alternative EFR" | |
3 * encoder: it functions just like gsmefr-etsi-enc, but uses libtwamr as | |
4 * the encoder engine instead of libgsmefr. Libgsmefr functions are still | |
5 * used for frame packing, but not for actual encoding. Note that there is | |
6 * no -d option in this version, and no DTX encoding support: a DTX-capable | |
7 * AMR-EFR hybrid is a beast that is currently outside our capabilities. | |
8 * | |
9 * The byte order is LE by default or BE with -b option. Practical testing | |
10 * will always require some manual byte-swap conversion: t??_efr.cod files | |
11 * in amr122_efr.zip are shipped in BE, but the corresponding t??.inp files | |
12 * in the 06.74 package are LE. | |
13 */ | |
14 | |
15 #include <stdio.h> | |
16 #include <stdint.h> | |
17 #include <stdlib.h> | |
18 #include <string.h> | |
19 #include <strings.h> | |
20 #include <unistd.h> | |
21 #include "../libgsmefr/gsm_efr.h" | |
22 #include "../libtwamr/tw_amr.h" | |
23 | |
24 main(argc, argv) | |
25 char **argv; | |
26 { | |
27 char *infname, *outfname; | |
28 FILE *inf, *outf; | |
29 struct amr_encoder_state *state; | |
30 int16_t pcm[160]; | |
31 struct amr_param_frame amr_frame; | |
32 uint8_t efr_frame[EFR_RTP_FRAME_LEN], bits[250]; | |
33 int opt, rc, big_endian = 0; | |
34 extern int optind; | |
35 | |
36 while ((opt = getopt(argc, argv, "b")) != EOF) { | |
37 switch (opt) { | |
38 case 'b': | |
39 big_endian = 1; | |
40 continue; | |
41 default: | |
42 usage: | |
43 fprintf(stderr, "usage: %s [-b] input.inp output.cod\n", | |
44 argv[0]); | |
45 exit(1); | |
46 } | |
47 } | |
48 if (argc != optind + 2) | |
49 goto usage; | |
50 infname = argv[optind]; | |
51 outfname = argv[optind+1]; | |
52 | |
53 inf = fopen(infname, "r"); | |
54 if (!inf) { | |
55 perror(infname); | |
56 exit(1); | |
57 } | |
58 outf = fopen(outfname, "w"); | |
59 if (!outf) { | |
60 perror(outfname); | |
61 exit(1); | |
62 } | |
63 state = amr_encoder_create(0, 0); | |
64 if (!state) { | |
65 perror("amr_encoder_create()"); | |
66 exit(1); | |
67 } | |
68 for (;;) { | |
69 rc = read_input(inf, pcm, infname, big_endian); | |
70 if (!rc) | |
71 break; | |
72 amr_encode_frame(state, MR122, pcm, &amr_frame); | |
73 amr_dhf_subst_efr(&amr_frame); | |
74 EFR_params2frame(amr_frame.param, efr_frame); | |
75 frame2bits(efr_frame, bits); | |
76 bits[248] = 1; | |
77 bits[249] = 1; | |
78 emit_output(outf, bits + 4, 246, big_endian); | |
79 } | |
80 fclose(outf); | |
81 exit(0); | |
82 } |