FreeCalypso > hg > gsm-codec-lib
comparison dev/gsm0611-silence-fr.c @ 276:e4ca04586118
dev/gsm0611-silence-fr: rework to eliminate libgsm dependency
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Apr 2024 03:38:09 +0000 |
parents | 61cb83bd11ec |
children |
comparison
equal
deleted
inserted
replaced
275:5fbb323b2978 | 276:e4ca04586118 |
---|---|
1 /* | 1 /* |
2 * This program is meant to be run only once by the developer - it uses | 2 * This program is meant to be run only once by the developer - it uses |
3 * libgsm function gsm_implode() to transform the idle frame of GSM 06.11 | 3 * libgsm function gsm_implode() to transform the idle frame of GSM 06.11 |
4 * (3GPP TS 46.011) from the table format given in the spec into | 4 * (3GPP TS 46.011) from the table format given in the spec into |
5 * libgsm/RTP format. | 5 * libgsm/RTP format. |
6 * | |
7 * Later update: this program has been reworked to use the local function | |
8 * in pack_gsmfr_rtp.c instead of gsm_implode(), in order to eliminate | |
9 * all build dependencies on old libgsm. | |
6 */ | 10 */ |
7 | 11 |
8 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <stdint.h> | |
9 #include <stdlib.h> | 14 #include <stdlib.h> |
10 #include <string.h> | 15 #include <string.h> |
11 #include <strings.h> | 16 #include <strings.h> |
12 #include <gsm.h> | |
13 | 17 |
14 static const gsm_signal lar_params[8] = {42, 39, 21, 10, 9, 4, 3, 2}; | 18 extern void gsmfr_pack_to_rtp(const int16_t *params, uint8_t *frame); |
15 static const gsm_signal subframe_params[17] = | 19 |
20 static const int16_t lar_params[8] = {42, 39, 21, 10, 9, 4, 3, 2}; | |
21 static const int16_t subframe_params[17] = | |
16 {40, 0, 1, 0, 3, 4, 3, 4, 4, 3, 3, 3, 3, 4, 4, 3, 3}; | 22 {40, 0, 1, 0, 3, 4, 3, 4, 4, 3, 3, 3, 3, 4, 4, 3, 3}; |
17 | 23 |
18 main(argc, argv) | 24 main(argc, argv) |
19 char **argv; | 25 char **argv; |
20 { | 26 { |
21 gsm state; | 27 int16_t params[76]; |
22 gsm_signal params[76]; | 28 uint8_t frame[33]; |
23 gsm_byte frame[33]; | |
24 unsigned n; | 29 unsigned n; |
25 | 30 |
26 /* gsm_implode() requires dummy state */ | |
27 state = gsm_create(); | |
28 if (!state) { | |
29 fprintf(stderr, "gsm_create() failed!\n"); | |
30 exit(1); | |
31 } | |
32 /* gather params */ | 31 /* gather params */ |
33 bcopy(lar_params, params, sizeof(gsm_signal) * 8); | 32 bcopy(lar_params, params, sizeof(int16_t) * 8); |
34 bcopy(subframe_params, params + 8, sizeof(gsm_signal) * 17); | 33 bcopy(subframe_params, params + 8, sizeof(int16_t) * 17); |
35 bcopy(subframe_params, params + 25, sizeof(gsm_signal) * 17); | 34 bcopy(subframe_params, params + 25, sizeof(int16_t) * 17); |
36 bcopy(subframe_params, params + 42, sizeof(gsm_signal) * 17); | 35 bcopy(subframe_params, params + 42, sizeof(int16_t) * 17); |
37 bcopy(subframe_params, params + 59, sizeof(gsm_signal) * 17); | 36 bcopy(subframe_params, params + 59, sizeof(int16_t) * 17); |
38 /* generate frame */ | 37 /* generate frame */ |
39 gsm_implode(state, params, frame); | 38 gsmfr_pack_to_rtp(params, frame); |
40 /* print the frame */ | 39 /* print the frame */ |
41 for (n = 0; n < 33; n++) { | 40 for (n = 0; n < 33; n++) { |
42 printf("0x%02X,", frame[n]); | 41 printf("0x%02X,", frame[n]); |
43 if (n == 4 || n == 11 || n == 18 || n == 25 || n == 32) | 42 if (n == 4 || n == 11 || n == 18 || n == 25 || n == 32) |
44 putchar('\n'); | 43 putchar('\n'); |