FreeCalypso > hg > vband-misc
view hr-sid/misorder.c @ 54:0832b5ac62b2
efr-sid/Unit-test-desc: update for complete status
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 19 Aug 2024 17:40:43 +0000 |
parents | ee54b9748c09 |
children |
line wrap: on
line source
/* * swSidDetection() in reid.c in GSM 06.06 source contains a table * that identifies the 79 bits of the SID field when they got misordered * as a result of decoding in unvoiced mode. That table is given * in the form of an array of 18 codec params. We need the same mask * of misordered SID field bits in the packed format of TS 101 318. * This program performs the conversion. */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> static const int16_t misordered_sid_params[18] = { 0x0001, /* R0 */ /* unvoiced */ 0x00ef, /* LPC1 */ 0x003e, /* LPC2 */ 0x007f, /* LPC3 */ 0x0001, /* INT LPC */ 0x0003, /* Mode */ 0x001f, /* Code1_1 */ 0x0072, /* Code2_1 */ 0x0012, /* GSP0_1 */ 0x003f, /* Code1_2 */ 0x007f, /* Code2_2 */ 0x0008, /* GSP0_2 */ 0x007f, /* Code1_3 */ 0x007f, /* Code2_3 */ 0x0008, /* GSP0_3 */ 0x007f, /* Code1_4 */ 0x007f, /* Code2_4 */ 0x000c, /* GSP0_4 */ }; void pack_ts101318_unvoiced(params, payload) const int16_t *params; uint8_t *payload; { uint8_t *c = payload; /* unvoiced mode */ *c++ = ((params[0] & 0x1F) << 3) | ((params[1] >> 8) & 0x7); *c++ = params[1] & 0xFF; *c++ = ((params[2] >> 1) & 0xFF); *c++ = ((params[2] & 0x1) << 7) | ((params[3] >> 1) & 0x7F); *c++ = ((params[3] & 0x1) << 7) | ((params[4] & 0x1) << 6) | ((params[5] & 0x3) << 4) | ((params[6] >> 3) & 0xF); *c++ = ((params[6] & 0x7) << 5) | ((params[7] >> 2) & 0x1F); *c++ = ((params[7] & 0x3) << 6) | ((params[8] & 0x1F) << 1) | ((params[9] >> 6) & 0x1); *c++ = ((params[9] & 0x3F) << 2) | ((params[10] >> 5) & 0x3); *c++ = ((params[10] & 0x1F) << 3) | ((params[11] >> 2) & 0x7); *c++ = ((params[11] & 0x3) << 6) | ((params[12] >> 1) & 0x3F); *c++ = ((params[12] & 0x1) << 7) | (params[13] & 0x7F); *c++ = ((params[14] & 0x1F) << 3) | ((params[15] >> 4) & 0x7); *c++ = ((params[15] & 0xF) << 4) | ((params[16] >> 3) & 0xF); *c++ = ((params[16] & 0x7) << 5) | (params[17] & 0x1F); } main(argc, argv) char **argv; { uint8_t packed_frame[14]; int i; pack_ts101318_unvoiced(misordered_sid_params, packed_frame); for (i = 0; i < 14; i++) { printf("0x%02X,", packed_frame[i]); if (i == 6 || i == 13) putchar('\n'); else putchar(' '); } exit(0); }