annotate libtwamr/cnst.h @ 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 57b4053559ff
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
252
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 *****************************************************************************
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 *****************************************************************************
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : cnst.h
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Speech codec constant parameters
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 * : (encoder, decoder, and postfilter)
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 *
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 *****************************************************************************
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #ifndef cnst_h
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #define cnst_h "$Id $"
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #define L_TOTAL 320 /* Total size of speech buffer. */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 #define L_WINDOW 240 /* Window size in LP analysis */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #define L_FRAME 160 /* Frame size */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #define L_FRAME_BY2 80 /* Frame size divided by 2 */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #define L_SUBFR 40 /* Subframe size */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 #define L_CODE 40 /* codevector length */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 #define NB_TRACK 5 /* number of tracks */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 #define STEP 5 /* codebook step size */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 #define NB_TRACK_MR102 4 /* number of tracks mode mr102 */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 #define STEP_MR102 4 /* codebook step size mode mr102 */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #define M 10 /* Order of LP filter */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #define MP1 (M+1) /* Order of LP filter + 1 */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #define LSF_GAP 205 /* Minimum distance between LSF after quan-
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 tization; 50 Hz = 205 */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #define LSP_PRED_FAC_MR122 21299 /* MR122 LSP prediction factor (0.65 Q15) */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #define AZ_SIZE (4*M+4) /* Size of array of LP filters in 4 subfr.s */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 #define PIT_MIN_MR122 18 /* Minimum pitch lag (MR122 mode) */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 #define PIT_MIN 20 /* Minimum pitch lag (all other modes) */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 #define PIT_MAX 143 /* Maximum pitch lag */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 #define L_INTERPOL (10+1) /* Length of filter for interpolation */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 #define L_INTER_SRCH 4 /* Length of filter for CL LTP search
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 interpolation */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 #define MU 26214 /* Factor for tilt compensation filter 0.8 */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 #define AGC_FAC 29491 /* Factor for automatic gain control 0.9 */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 #define L_NEXT 40 /* Overhead in LP analysis */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 #define SHARPMAX 13017 /* Maximum value of pitch sharpening */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 #define SHARPMIN 0 /* Minimum value of pitch sharpening */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 #define MAX_PRM_SIZE 57 /* max. num. of params */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 #define MAX_SERIAL_SIZE 244 /* max. num. of serial bits */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 #define GP_CLIP 15565 /* Pitch gain clipping = 0.95 */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 #define N_FRAME 7 /* old pitch gains in average calculation */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 #define EHF_MASK 0x0008 /* encoder homing frame pattern */
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
57b4053559ff libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 #endif