FreeCalypso > hg > gsm-codec-lib
view hrutil/tw5b-dump.c @ 581:e2d5cad04cbf
libgsmhr1 RxFE: store CN R0+LPC separately from speech
In the original GSM 06.06 code the ECU for speech mode is entirely
separate from the CN generator, maintaining separate state. (The
main intertie between them is the speech vs CN state variable,
distinguishing between speech and CN BFIs, in addition to the
CN-specific function of distinguishing between initial and update
SIDs.)
In the present RxFE implementation I initially thought that we could
use the same saved_frame buffer for both ECU and CN, overwriting
just the first 4 params (R0 and LPC) when a valid SID comes in.
However, I now realize it was a bad idea: the original code has a
corner case (long sequence of speech-mode BFIs to put the ECU in
state 6, then SID and CN-mode BFIs, then a good speech frame) that
would be broken by that buffer reuse approach. We could eliminate
this corner case by resetting the ECU state when passing through
a CN insertion period, but doing so would needlessly increase
the behavioral diffs between GSM 06.06 and our version.
Solution: use a separate CN-specific buffer for CN R0+LPC parameters,
and match the behavior of GSM 06.06 code in this regard.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 13 Feb 2025 10:02:45 +0000 |
parents | 707d6f7a54dc |
children |
line wrap: on
line source
/* * This program reads a TW-TS-005 Annex B hexadecimal file * and dumps all frames in human-readable form. */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "../libgsmhr1/tw_gsmhr.h" #include "../libtest/tw5reader.h" main(argc, argv) char **argv; { FILE *hexf; unsigned lineno; uint8_t frame[TWTS005_MAX_FRAME]; unsigned frame_len, ft; int16_t params[GSMHR_NUM_PARAMS]; int rc; if (argc != 2) { fprintf(stderr, "usage: %s hex-file\n", argv[0]); exit(1); } hexf = fopen(argv[1], "r"); if (!hexf) { perror(argv[1]); exit(1); } lineno = 0; for (;;) { rc = twts005_read_frame(hexf, &lineno, frame, &frame_len); if (rc < 0) { fprintf(stderr, "%s line %u: not valid TW-TS-005\n", argv[1], lineno); exit(1); } if (!rc) break; switch (frame_len) { case 0: printf("line %u: NULL frame\n", lineno); break; case 1: if (frame[0] & 0x80) goto invalid; ft = frame[0] >> 4; switch (ft) { case 1: printf("line %u: Invalid_SID frame\n", lineno); break; case 7: printf("line %u: No_Data frame\n", lineno); break; default: goto invalid; } printf(" ToC=%02X (DTXd=%u UFI=%u TAF=%u)\n", frame[0], (frame[0] >> 3) & 1, (frame[0] >> 1) & 1, frame[0] & 1); break; case GSMHR_FRAME_LEN_RPF: printf("line %u: TS 101 318 frame\n", lineno); gsmhr_unpack_ts101318(frame, params); print_frame_params(params); break; case GSMHR_FRAME_LEN_5993: if (frame[0] & 0x80) goto invalid; ft = frame[0] >> 4; switch (ft) { case 0: printf("line %u: good speech frame\n", lineno); break; case 2: printf("line %u: good SID frame\n", lineno); break; case 6: printf("line %u: bad speech frame\n", lineno); break; default: goto invalid; } printf(" ToC=%02X (DTXd=%u UFI=%u TAF=%u)\n", frame[0], (frame[0] >> 3) & 1, (frame[0] >> 1) & 1, frame[0] & 1); gsmhr_unpack_ts101318(frame + 1, params); print_frame_params(params); break; default: invalid: fprintf(stderr, "%s line %u: not a valid GSM-HR frame\n", argv[1], lineno); exit(1); } } exit(0); }