annotate libtwamr/preemph.c @ 556:18aca50d68df default tip

doc/Calypso-TCH-downlink: update for FR1 BFI-with-data
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 11 Oct 2024 01:54:00 +0000
parents 3618b5cf25a6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
399
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : preemph.c
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Preemphasis filtering
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 * Description : Filtering through 1 - g z^-1
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 *
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 /*
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 * MODULE INCLUDE FILE AND VERSION ID
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #include "namespace.h"
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #include "preemph.h"
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 /*
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 * INCLUDE FILES
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "typedef.h"
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "basic_op.h"
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "no_count.h"
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 /*
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 * LOCAL VARIABLES AND TABLES
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 /*
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 * PUBLIC PROGRAM CODE
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 ********************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 /*************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 * Function: preemphasis_reset
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 * Purpose: Initializes state memory to zero
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 *
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 **************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 void preemphasis_reset (preemphasisState *state)
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 {
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 state->mem_pre = 0;
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 /*
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 **************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 * Function: preemphasis
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 * Purpose: Filtering through 1 - g z^-1
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 *
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 **************************************************************************
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 int preemphasis (
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 preemphasisState *st, /* (i/o) : preemphasis filter state */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 Word16 *signal, /* (i/o) : input signal overwritten by the output */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 Word16 g, /* (i) : preemphasis coefficient */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 Word16 L /* (i) : size of filtering */
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 )
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 {
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 Word16 *p1, *p2, temp, i;
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 p1 = signal + L - 1; move16 ();
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 p2 = p1 - 1; move16 ();
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 temp = *p1; move16 ();
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 for (i = 0; i <= L - 2; i++)
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 {
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 *p1 = sub (*p1, mult (g, *p2--)); move16 ();
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 p1--;
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 }
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 *p1 = sub (*p1, mult (g, st->mem_pre)); move16 ();
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 st->mem_pre = temp; move16 ();
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 return 0;
3618b5cf25a6 libtwamr: integrate preemph.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 }