FreeCalypso > hg > gsm-codec-lib
changeset 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 | d4979cdbc081 |
children | 7d0e565aa1ae |
files | libgsmhr1/rxfe.c libgsmhr1/rxfe.h |
diffstat | 2 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libgsmhr1/rxfe.c Thu Feb 13 09:21:02 2025 +0000 +++ b/libgsmhr1/rxfe.c Thu Feb 13 10:02:45 2025 +0000 @@ -222,7 +222,7 @@ { int i; - memcpy(prm_out, st->saved_frame, sizeof(Shortword) * 4); + memcpy(prm_out, st->cn_r0_lpc, sizeof(Shortword) * 4); prm_out[4] = 1; /* soft interpolation */ prm_out[5] = 0; /* unvoiced mode */ for (i = 0; i < N_SUB; i++) { @@ -276,7 +276,10 @@ if (dtxd_sp) *dtxd_sp = 0; if (frame_class == VALIDSID) - memcpy(st->saved_frame, prm_in, sizeof(Shortword) * 4); + memcpy(st->cn_r0_lpc, prm_in, sizeof(Shortword) * 4); + else + memcpy(st->cn_r0_lpc, st->saved_frame, + sizeof(Shortword) * 4); init_cn_gen(st); cn_output(st, prm_out); break; @@ -284,7 +287,7 @@ if (dtxd_sp) *dtxd_sp = 0; if (frame_class == VALIDSID) - memcpy(st->saved_frame, prm_in, sizeof(Shortword) * 4); + memcpy(st->cn_r0_lpc, prm_in, sizeof(Shortword) * 4); else deco_mode = CNIBFI; /* for interpolation */ st->dtx_bfi_count = 0; @@ -296,11 +299,11 @@ *dtxd_sp = 0; if (st->dtx_muting) { if (fast_cn_muting) - st->saved_frame[0] = 0; + st->cn_r0_lpc[0] = 0; else { - st->saved_frame[0] -= 2; - if (st->saved_frame[0] < 0) - st->saved_frame[0] = 0; + st->cn_r0_lpc[0] -= 2; + if (st->cn_r0_lpc[0] < 0) + st->cn_r0_lpc[0] = 0; } } st->dtx_bfi_count++;
--- a/libgsmhr1/rxfe.h Thu Feb 13 09:21:02 2025 +0000 +++ b/libgsmhr1/rxfe.h Thu Feb 13 10:02:45 2025 +0000 @@ -19,6 +19,7 @@ struct gsmhr_rxfe_state { Shortword saved_frame[GSMHR_NUM_PARAMS]; Longword gs_history[GS_HISTORY_SIZE]; + Shortword cn_r0_lpc[4]; Longword cn_prng; Shortword gs_cn_out; uint8_t in_dtx;