1c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*
2c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * Copyright (C) 2004-2010 NXP Software
3c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * Copyright (C) 2010 The Android Open Source Project
4c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent *
5c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * Licensed under the Apache License, Version 2.0 (the "License");
6c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * you may not use this file except in compliance with the License.
7c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * You may obtain a copy of the License at
8c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent *
9c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent *      http://www.apache.org/licenses/LICENSE-2.0
10c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent *
11c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * Unless required by applicable law or agreed to in writing, software
12c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * distributed under the License is distributed on an "AS IS" BASIS,
13c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * See the License for the specific language governing permissions and
15c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent * limitations under the License.
16c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent */
17c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
18c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#ifndef __LVREV_PRIVATE_H__
19c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define __LVREV_PRIVATE_H__
20c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
21c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#ifdef __cplusplus
22c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentextern "C" {
23c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#endif
24c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
25c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
26c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
27c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
28c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  Includes                                                                            */
29c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
30c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
31c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#include "LVREV.h"
32c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#include "LVREV_Tables.h"
33c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#include "BIQUAD.h"
34c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#include "Filter.h"
35c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#include "VectorArithmetic.h"
36c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#include "Mixer.h"
37c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#include "LVM_Macros.h"
38c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
39c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
40c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
41c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
42c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  Defines                                                                             */
43c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
44c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
45d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#ifndef BUILD_FLOAT
46c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* General */
47c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define ONE_OVER_SQRT_TWO               23170           /* 1/sqrt(2) * 2^15 */
48c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_B_8_on_1000            17179869           /* 0.8 * 2^31 */
49c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_HEADROOM                   8192           /* -12dB * 2^15 */
50c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_2_9_INQ29           1583769190L           /* 2.9 in Q29 format */
51c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MIN3DB                   0x5A82           /* -3dB in Q15 format */
52d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#else
53d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri/* General */
54d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define ONE_OVER_SQRT_TWO            0.707107f           /* 1/sqrt(2) * 2^15 */
55d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_B_8_on_1000               0.008f           /* 0.8 * 2^31 */
56d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_HEADROOM                   0.25f           /* -12dB * 2^15 */
57d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_2_9_INQ29                   2.9f           /* 2.9 in Q29 format */
58d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MIN3DB                0.7079457f           /* -3dB in Q15 format */
59d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#endif
60c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
61c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* Intenal constants */
62c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_LP_Poly_Order                 4
63c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_LP_Poly_Shift                 5
64d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
65d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#ifndef BUILD_FLOAT
66c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_T_3_Power_0_on_4          32768
67c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_T_3_Power_1_on_4          43125
68c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_T_3_Power_2_on_4          56755
69c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_T_3_Power_3_on_4          74694
70c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_T60_SCALE                306774           /*(32767/7000)<<16 */
71c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_T_3_Power_minus0_on_4     32767           /* 3^(-0/4) * 2^15 */
72c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_T_3_Power_minus1_on_4     24898           /* 3^(-1/4) * 2^15 */
73c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_T_3_Power_minus2_on_4     18919           /* 3^(-2/4) * 2^15 */
74c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_T_3_Power_minus3_on_4     14375           /* 3^(-3/4) * 2^15 */
75d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#else/*BUILD_FLOAT*/
76d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_T60_SCALE                0.000142f           /*(1/7000) */
77d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
78d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_T_3_Power_0_on_4              1.0f
79d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_T_3_Power_1_on_4         1.316074f
80d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_T_3_Power_2_on_4         1.732051f
81d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_T_3_Power_3_on_4         2.279507f
82d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_T_3_Power_minus0_on_4         1.0f        /* 3^(-0/4) * 2^15 */
83d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_T_3_Power_minus1_on_4    0.759836f        /* 3^(-1/4) * 2^15 */
84d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_T_3_Power_minus2_on_4    0.577350f        /* 3^(-2/4) * 2^15 */
85d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_T_3_Power_minus3_on_4    0.438691f        /* 3^(-3/4) * 2^15 */
86d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#endif
87d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
88d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#ifndef HIGHER_FS
89d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_T3_DELAY                2527           /* ((48000 * 120 * LVREV_T_3_Power_minus3_on_4) >> 15) / 1000 */
90d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_T2_DELAY                3326           /* ((48000 * 120 * LVREV_T_3_Power_minus2_on_4) >> 15) / 1000 */
91d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_T1_DELAY                4377           /* ((48000 * 120 * LVREV_T_3_Power_minus1_on_4) >> 15) / 1000 */
92d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_T0_DELAY                5760           /* ((48000 * 120 * LVREV_T_3_Power_minus0_on_4) >> 15) / 1000 */
93d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_AP3_DELAY               1685           /* ((48000 * 120 * LVREV_T_3_Power_minus3_on_4) >> 15) / 1500 */
94d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_AP2_DELAY               2218           /* ((48000 * 120 * LVREV_T_3_Power_minus2_on_4) >> 15) / 1500 */
95d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_AP1_DELAY               2918           /* ((48000 * 120 * LVREV_T_3_Power_minus1_on_4) >> 15) / 1500 */
96d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_AP0_DELAY               3840           /* ((48000 * 120 * LVREV_T_3_Power_minus0_on_4) >> 15) / 1500 */
97d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#else
98d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* ((192000 * 120 * LVREV_T_3_Power_minus3_on_4) >> 15) / 1000 */
99d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_T3_DELAY               10108
100d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* ((192000 * 120 * LVREV_T_3_Power_minus2_on_4) >> 15) / 1000 */
101d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_T2_DELAY               13304
102d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* ((192000 * 120 * LVREV_T_3_Power_minus1_on_4) >> 15) / 1000 */
103d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_T1_DELAY               17508
104d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* ((192000 * 120 * LVREV_T_3_Power_minus0_on_4) >> 15) / 1000 */
105d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_T0_DELAY               23040
106d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* ((192000 * 120 * LVREV_T_3_Power_minus3_on_4) >> 15) / 1500 */
107d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_AP3_DELAY               6740
108d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* ((192000 * 120 * LVREV_T_3_Power_minus2_on_4) >> 15) / 1500 */
109d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_AP2_DELAY               8872
110d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* ((192000 * 120 * LVREV_T_3_Power_minus1_on_4) >> 15) / 1500 */
111d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_AP1_DELAY              11672
112d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* ((192000 * 120 * LVREV_T_3_Power_minus0_on_4) >> 15) / 1500 */
113d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_MAX_AP0_DELAY              15360
114d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#endif
115d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
116c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_BYPASSMIXER_TC             1000           /* Bypass mixer time constant*/
117c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_ALLPASS_TC                 1000           /* All-pass filter time constant */
118c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_ALLPASS_TAP_TC             10000           /* All-pass filter dely tap change */
119c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_FEEDBACKMIXER_TC            100           /* Feedback mixer time constant*/
120c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_OUTPUTGAIN_SHIFT              5           /* Bits shift for output gain correction */
121c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
122c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* Parameter limits */
123d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#ifndef HIGHER_FS
124c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_NUM_FS                        9           /* Number of supported sample rates */
125d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#else
126d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#define LVREV_NUM_FS                       11           /* Number of supported sample rates */
127d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#endif
128d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
129c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MAXBLKSIZE_LIMIT             64           /* Maximum block size low limit */
130c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MAX_LEVEL                   100           /* Maximum level, 100% */
131c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MIN_LPF_CORNER               50           /* Low pass filter limits */
132c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MAX_LPF_CORNER            23999
133c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MIN_HPF_CORNER               20           /* High pass filrer limits */
134c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MAX_HPF_CORNER             1000
135c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MAX_T60                    7000           /* Maximum T60 time in ms */
136c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MAX_DENSITY                 100           /* Maximum density, 100% */
137c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MAX_DAMPING                 100           /* Maximum damping, 100% */
138c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#define LVREV_MAX_ROOMSIZE                100           /* Maximum room size, 100% */
139c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
140c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
141c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
142c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
143c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
144c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  Structures                                                                          */
145c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
146c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
147d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#ifndef BUILD_FLOAT
148c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* Fast data structure */
149c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurenttypedef struct
150c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent{
151c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
152c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Biquad_1I_Order1_Taps_t HPTaps;                     /* High pass filter taps */
153c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Biquad_1I_Order1_Taps_t LPTaps;                     /* Low pass filter taps */
154c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Biquad_1I_Order1_Taps_t RevLPTaps[4];               /* Reverb low pass filters taps */
155c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
156c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent} LVREV_FastData_st;
157c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
158c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
159c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* Fast coefficient structure */
160c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurenttypedef struct
161c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent{
162c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
163c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Biquad_Instance_t       HPCoefs;                    /* High pass filter coefficients */
164c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Biquad_Instance_t       LPCoefs;                    /* Low pass filter coefficients */
165c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Biquad_Instance_t       RevLPCoefs[4];              /* Reverb low pass filters coefficients */
166c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
167c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent} LVREV_FastCoef_st;
168c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
169c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
170c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* Instance parameter structure */
171c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurenttypedef struct
172c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent{
173c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /* General */
174c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVREV_InstanceParams_st InstanceParams;             /* Initialisation time instance parameters */
175c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVREV_MemoryTable_st    MemoryTable;                /* Memory table */
176c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVREV_ControlParams_st  CurrentParams;              /* Parameters being used */
177c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVREV_ControlParams_st  NewParams;                  /* New parameters from the calling application */
178c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_CHAR                bControlPending;            /* Flag to indicate new parameters are available */
179c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_CHAR                bFirstControl;              /* Flag to indicate that the control function is called for the first time */
180c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_CHAR                bDisableReverb;             /* Flag to indicate that the mix level is 0% and the reverb can be disabled */
181c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               RoomSizeInms;               /* Room size in msec */
182c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               MaxBlkLen;                  /* Maximum block size for internal processing */
183c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
184c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /* Aligned memory pointers */
185c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVREV_FastData_st       *pFastData;                 /* Fast data memory base address */
186c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVREV_FastCoef_st       *pFastCoef;                 /* Fast coefficient memory base address */
187c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               *pScratchDelayLine[4];      /* Delay line scratch memory */
188c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               *pScratch;                  /* Multi ussge scratch */
189c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               *pInputSave;                /* Reverb block input save for dry/wet mixing*/
190c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
191c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /* Feedback matrix */
192c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Mix_1St_Cll_t           FeedbackMixer[4];           /* Mixer for Pop and Click Supression caused by feedback Gain */
193c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
194c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /* All-Pass Filter */
195c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               T[4];                       /* Maximum delay size of buffer */
196c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               *pDelay_T[4];               /* Pointer to delay buffers */
197c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               Delay_AP[4];                /* Offset to AP delay buffer start */
198c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT16               AB_Selection;               /* Smooth from tap A to B when 1 otherwise B to A */
199c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               A_DelaySize[4];             /* A delay length in samples */
200c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               B_DelaySize[4];             /* B delay length in samples */
201c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               *pOffsetA[4];               /* Offset for the A delay tap */
202c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT32               *pOffsetB[4];               /* Offset for the B delay tap */
203c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Mix_2St_Cll_t           Mixer_APTaps[4];            /* Smoothed AP delay mixer */
204c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Mix_1St_Cll_t           Mixer_SGFeedback[4];        /* Smoothed SAfeedback gain */
205c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Mix_1St_Cll_t           Mixer_SGFeedforward[4];     /* Smoothed AP feedforward gain */
206c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
207c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    /* Output gain */
208c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Mix_2St_Cll_t           BypassMixer;                /* Dry/wet mixer */
209c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    LVM_INT16               Gain;                       /* Gain applied to output to maintain average signal power */
210c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    Mix_1St_Cll_t           GainMixer;                  /* Gain smoothing */
211c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
212c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent} LVREV_Instance_st;
213c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
214d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#else /* BUILD_FLOAT */
215d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
216d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri/* Fast data structure */
217d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuritypedef struct
218d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri{
219d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Biquad_1I_Order1_FLOAT_Taps_t HPTaps;                     /* High pass filter taps */
220d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Biquad_1I_Order1_FLOAT_Taps_t LPTaps;                     /* Low pass filter taps */
221d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Biquad_1I_Order1_FLOAT_Taps_t RevLPTaps[4];               /* Reverb low pass filters taps */
222d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
223d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri} LVREV_FastData_st;
224d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
225c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
226d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri/* Fast coefficient structure */
227d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuritypedef struct
228d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri{
229d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
230d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Biquad_FLOAT_Instance_t       HPCoefs;              /* High pass filter coefficients */
231d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Biquad_FLOAT_Instance_t       LPCoefs;              /* Low pass filter coefficients */
232d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Biquad_FLOAT_Instance_t       RevLPCoefs[4];        /* Reverb low pass filters coefficients */
233d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
234d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri} LVREV_FastCoef_st;
235d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuritypedef struct
236d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri{
237d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* General */
238d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVREV_InstanceParams_st InstanceParams;           /* Initialisation time instance parameters */
239d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVREV_MemoryTable_st    MemoryTable;              /* Memory table */
240d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVREV_ControlParams_st  CurrentParams;            /* Parameters being used */
241d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVREV_ControlParams_st  NewParams;                /* New parameters from the \
242d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                                         calling application */
243d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_CHAR                bControlPending;          /* Flag to indicate new parameters \
244d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                                         are available */
245d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_CHAR                bFirstControl;            /* Flag to indicate that the control \
246d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                                         function is called for the first time */
247d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_CHAR                bDisableReverb;           /* Flag to indicate that the mix level is
248d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                                         0% and the reverb can be disabled */
249d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_INT32               RoomSizeInms;             /* Room size in msec */
250d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_INT32               MaxBlkLen;                /* Maximum block size for internal
251d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                                         processing */
252d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
253d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* Aligned memory pointers */
254d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVREV_FastData_st       *pFastData;               /* Fast data memory base address */
255d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVREV_FastCoef_st       *pFastCoef;               /* Fast coefficient memory base address */
256d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_FLOAT               *pScratchDelayLine[4];    /* Delay line scratch memory */
257d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_FLOAT               *pScratch;                /* Multi ussge scratch */
258d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_FLOAT               *pInputSave;              /* Reverb block input save for dry/wet
259d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                                         mixing*/
260d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
261d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* Feedback matrix */
262d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Mix_1St_Cll_FLOAT_t     FeedbackMixer[4];         /* Mixer for Pop and Click Supression \
263d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                                         caused by feedback Gain */
264d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
265d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
266d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* All-Pass Filter */
267d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_INT32               T[4];                     /* Maximum delay size of buffer */
268d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_FLOAT               *pDelay_T[4];             /* Pointer to delay buffers */
269d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_INT32               Delay_AP[4];              /* Offset to AP delay buffer start */
270d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_INT16               AB_Selection;             /* Smooth from tap A to B when 1 \
271d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                                         otherwise B to A */
272d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_INT32               A_DelaySize[4];           /* A delay length in samples */
273d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_INT32               B_DelaySize[4];           /* B delay length in samples */
274d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_FLOAT               *pOffsetA[4];             /* Offset for the A delay tap */
275d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_FLOAT               *pOffsetB[4];             /* Offset for the B delay tap */
276d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Mix_2St_Cll_FLOAT_t     Mixer_APTaps[4];          /* Smoothed AP delay mixer */
277d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Mix_1St_Cll_FLOAT_t     Mixer_SGFeedback[4];      /* Smoothed SAfeedback gain */
278d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Mix_1St_Cll_FLOAT_t     Mixer_SGFeedforward[4];   /* Smoothed AP feedforward gain */
279d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
280d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    /* Output gain */
281d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Mix_2St_Cll_FLOAT_t     BypassMixer;              /* Dry/wet mixer */
282d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    LVM_FLOAT               Gain;                     /* Gain applied to output to maintain
283d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                                         average signal power */
284d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri    Mix_1St_Cll_FLOAT_t     GainMixer;                /* Gain smoothing */
285d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
286d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri} LVREV_Instance_st;
287d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri
288d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#endif
289c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
290c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
291c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*  Function prototypes                                                                 */
292c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/*                                                                                      */
293c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/****************************************************************************************/
294c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
295c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric LaurentLVREV_ReturnStatus_en   LVREV_ApplyNewSettings(LVREV_Instance_st     *pPrivate);
296d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#ifdef BUILD_FLOAT
297d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katurivoid                    ReverbBlock(LVM_FLOAT           *pInput,
298d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                    LVM_FLOAT           *pOutput,
299d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                    LVREV_Instance_st   *pPrivate,
300d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri                                    LVM_UINT16          NumSamples);
301d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#else
302c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentvoid                    ReverbBlock(LVM_INT32           *pInput,
303c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                                    LVM_INT32           *pOutput,
304c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                                    LVREV_Instance_st   *pPrivate,
305c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                                    LVM_UINT16          NumSamples);
306d7d013446a64c6de9f0f2dfe098a721b140e0b48Ramesh Katuri#endif
307c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric LaurentLVM_INT32               BypassMixer_Callback(void       *pCallbackData,
308c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                                             void       *pGeneralPurpose,
309c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent                                             LVM_INT16  GeneralPurpose );
310c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
311c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
312c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#ifdef __cplusplus
313c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent}
314c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#endif
315c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
316c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent#endif  /** __LVREV_PRIVATE_H__ **/
317c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent
318c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent/* End of file */
319