comparison hr-sid/misorder.c @ 47:ee54b9748c09

hr-sid: add conversion of misordered SID field
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 24 Jul 2024 05:39:51 +0000
parents
children
comparison
equal deleted inserted replaced
46:d5f1b7aa76c4 47:ee54b9748c09
1 /*
2 * swSidDetection() in reid.c in GSM 06.06 source contains a table
3 * that identifies the 79 bits of the SID field when they got misordered
4 * as a result of decoding in unvoiced mode. That table is given
5 * in the form of an array of 18 codec params. We need the same mask
6 * of misordered SID field bits in the packed format of TS 101 318.
7 * This program performs the conversion.
8 */
9
10 #include <stdio.h>
11 #include <stdint.h>
12 #include <stdlib.h>
13
14 static const int16_t misordered_sid_params[18] = {
15 0x0001, /* R0 */ /* unvoiced */
16 0x00ef, /* LPC1 */
17 0x003e, /* LPC2 */
18 0x007f, /* LPC3 */
19 0x0001, /* INT LPC */
20 0x0003, /* Mode */
21 0x001f, /* Code1_1 */
22 0x0072, /* Code2_1 */
23 0x0012, /* GSP0_1 */
24 0x003f, /* Code1_2 */
25 0x007f, /* Code2_2 */
26 0x0008, /* GSP0_2 */
27 0x007f, /* Code1_3 */
28 0x007f, /* Code2_3 */
29 0x0008, /* GSP0_3 */
30 0x007f, /* Code1_4 */
31 0x007f, /* Code2_4 */
32 0x000c, /* GSP0_4 */
33 };
34
35 void
36 pack_ts101318_unvoiced(params, payload)
37 const int16_t *params;
38 uint8_t *payload;
39 {
40 uint8_t *c = payload;
41
42 /* unvoiced mode */
43 *c++ = ((params[0] & 0x1F) << 3)
44 | ((params[1] >> 8) & 0x7);
45 *c++ = params[1] & 0xFF;
46 *c++ = ((params[2] >> 1) & 0xFF);
47 *c++ = ((params[2] & 0x1) << 7)
48 | ((params[3] >> 1) & 0x7F);
49 *c++ = ((params[3] & 0x1) << 7)
50 | ((params[4] & 0x1) << 6)
51 | ((params[5] & 0x3) << 4)
52 | ((params[6] >> 3) & 0xF);
53 *c++ = ((params[6] & 0x7) << 5)
54 | ((params[7] >> 2) & 0x1F);
55 *c++ = ((params[7] & 0x3) << 6)
56 | ((params[8] & 0x1F) << 1)
57 | ((params[9] >> 6) & 0x1);
58 *c++ = ((params[9] & 0x3F) << 2)
59 | ((params[10] >> 5) & 0x3);
60 *c++ = ((params[10] & 0x1F) << 3)
61 | ((params[11] >> 2) & 0x7);
62 *c++ = ((params[11] & 0x3) << 6)
63 | ((params[12] >> 1) & 0x3F);
64 *c++ = ((params[12] & 0x1) << 7)
65 | (params[13] & 0x7F);
66 *c++ = ((params[14] & 0x1F) << 3)
67 | ((params[15] >> 4) & 0x7);
68 *c++ = ((params[15] & 0xF) << 4)
69 | ((params[16] >> 3) & 0xF);
70 *c++ = ((params[16] & 0x7) << 5)
71 | (params[17] & 0x1F);
72 }
73
74 main(argc, argv)
75 char **argv;
76 {
77 uint8_t packed_frame[14];
78 int i;
79
80 pack_ts101318_unvoiced(misordered_sid_params, packed_frame);
81 for (i = 0; i < 14; i++) {
82 printf("0x%02X,", packed_frame[i]);
83 if (i == 6 || i == 13)
84 putchar('\n');
85 else
86 putchar(' ');
87 }
88 exit(0);
89 }