comparison libtwamr/preemph.c @ 399:3618b5cf25a6

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