annotate libtwamr/e_homing.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 2a094af3d384
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
361
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 *****************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 *****************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : e_homing.c
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 *
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *****************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 */
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 /*
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 *****************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 * MODULE INCLUDE FILE AND VERSION ID
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 *****************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 */
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #include "namespace.h"
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #include "e_homing.h"
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /*
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 *****************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 * INCLUDE FILES
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 *****************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 */
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "typedef.h"
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "cnst.h"
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 /*
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 *****************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 * PUBLIC PROGRAM CODE
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 *****************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 */
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 /*
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 ********************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 *
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 * Function : encoder_homing_frame_test
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 * In : input_frame[] one frame of speech samples
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 * Out : none
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 * Calls : none
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 * Tables : none
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 * Compile Defines : none
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 * Return : 0 input frame does not match the encoder homing frame pattern
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 * 1 input frame matches the encoder homing frame pattern
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 * Information : Checks if all samples of the input frame matches the encoder
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 * homing frame pattern, which is 0x0008 for all samples.
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 *
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 ********************************************************************************
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 */
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55
419
2a094af3d384 libtwamr: implement encoder top level
Mychaela Falconia <falcon@freecalypso.org>
parents: 361
diff changeset
56 Word16 encoder_homing_frame_test (const Word16 input_frame[])
361
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 {
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 Word16 i, j;
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 /* check 160 input samples for matching EHF_MASK: defined in e_homing.h */
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 for (i = 0; i < L_FRAME; i++)
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 {
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 j = input_frame[i] ^ EHF_MASK;
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 if (j)
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 break;
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 }
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 return !j;
9aa554f8cf39 libtwamr: integrate e_homing.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 }