FreeCalypso > hg > gsm-codec-lib
view dev/xmaxc-tables.c @ 585:3c6bf0d26ee7 default tip
TW-TS-005 reader: fix maximum line length bug
TW-TS-005 section 4.1 states:
The maximum allowed length of each line is 80 characters, not
including the OS-specific newline encoding.
The implementation of this line length limit in the TW-TS-005 hex file
reader function in the present suite was wrong, such that lines of
the full maximum length could not be read. Fix it.
Note that this bug affects comment lines too, not just actual RTP
payloads. Neither Annex A nor Annex B features an RTP payload format
that goes to the maximum of 40 bytes, but if a comment line goes to
the maximum allowed length of 80 characters not including the
terminating newline, the bug will be triggered, necessitating
the present fix.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 25 Feb 2025 07:49:28 +0000 |
parents | 56d3fbacd115 |
children |
line wrap: on
line source
/* * For libgsmfrp: if we are going to initiate comfort noise generation * upon receiving an invalid SID, and if we are going to harvest the * needed LARc and Xmaxc parameters from the last speech frame, we'll * need a way to compute a single mean Xmaxc from the 4 subframe Xmaxc * parameters of that last speech frame. * * This program generates Xmaxc dequantization and requantization tables * that are specifically optimized for performing this mean manipulation. */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> static uint16_t dequant_table[64]; static uint8_t requant_table[1024]; static void compute_dequant() { unsigned xmaxc, dequant, step; dequant = 0; step = 1; for (xmaxc = 0; xmaxc < 64; xmaxc++) { dequant_table[xmaxc] = dequant; dequant += step; if ((xmaxc & 7) == 7 && xmaxc != 7) step <<= 1; } } static void compute_requant() { unsigned x, c; for (x = 0; x < 1024; x++) { for (c = 0; c < 63; c++) { if (x < dequant_table[c+1]) break; } requant_table[x] = c; } } static void print_dequant() { unsigned c, r; puts("const uint16_t dequant_table[64] = {"); for (c = 0; c < 64; c++) { r = c & 7; if (!r) putchar('\t'); printf("%3u,", dequant_table[c]); if (r == 7) putchar('\n'); else putchar(' '); } fputs("};\n\n", stdout); } static void print_requant() { unsigned x, r; puts("const uint8_t requant_table[1024] = {"); for (x = 0; x < 1024; x++) { r = x & 15; if (!r) putchar('\t'); printf("%2u,", requant_table[x]); if (r == 15) putchar('\n'); else putchar(' '); } fputs("};\n", stdout); } main(argc, argv) char **argv; { compute_dequant(); compute_requant(); print_dequant(); print_requant(); exit(0); }