annotate libtwamr/tseq_out.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 eced57698c03
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
420
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement encoder output conversion to 3GPP
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * test sequence format.
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdint.h>
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "tw_amr.h"
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "namespace.h"
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "typedef.h"
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "cnst.h"
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "prm2bits.h"
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 void amr_frame_to_tseq(const struct amr_param_frame *frame, uint16_t *cod)
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 enum Mode pack_mode;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 cod[0] = frame->type;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 memset(cod + 1, 0, (AMR_COD_WORDS-1) * sizeof(uint16_t));
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 switch (frame->type) {
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 case TX_SPEECH_GOOD:
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 pack_mode = frame->mode;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 cod[MAX_SERIAL_SIZE+1] = frame->mode;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 break;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 case TX_SID_FIRST:
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 case TX_SID_UPDATE:
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 pack_mode = MRDTX;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 cod[MAX_SERIAL_SIZE+1] = frame->mode;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 break;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 case TX_NO_DATA:
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 pack_mode = MRDTX;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 cod[MAX_SERIAL_SIZE+1] = 0xFFFF;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 break;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 default:
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /* invalid usage, not allowed! */
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 return;
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 Prm2bits(pack_mode, frame->param, (Word16 *)(cod + 1));
eced57698c03 libtwamr: implement test sequence output
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 }