xref: /aosp_15_r20/external/libopus/dnn/freq.h (revision a58d3d2adb790c104798cd88c8a3aff4fa8b82cc)
1 /* Copyright (c) 2017-2018 Mozilla */
2 /*
3    Redistribution and use in source and binary forms, with or without
4    modification, are permitted provided that the following conditions
5    are met:
6 
7    - Redistributions of source code must retain the above copyright
8    notice, this list of conditions and the following disclaimer.
9 
10    - Redistributions in binary form must reproduce the above copyright
11    notice, this list of conditions and the following disclaimer in the
12    documentation and/or other materials provided with the distribution.
13 
14    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
18    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 #ifndef FREQ_H
28 #define FREQ_H
29 
30 #include "kiss_fft.h"
31 
32 #define LPC_ORDER 16
33 
34 #define PREEMPHASIS (0.85f)
35 
36 #define FRAME_SIZE_5MS (2)
37 #define OVERLAP_SIZE_5MS (2)
38 #define TRAINING_OFFSET_5MS (1)
39 
40 #define WINDOW_SIZE_5MS (FRAME_SIZE_5MS + OVERLAP_SIZE_5MS)
41 
42 #define FRAME_SIZE (80*FRAME_SIZE_5MS)
43 #define OVERLAP_SIZE (80*OVERLAP_SIZE_5MS)
44 #define TRAINING_OFFSET (80*TRAINING_OFFSET_5MS)
45 #define WINDOW_SIZE (FRAME_SIZE + OVERLAP_SIZE)
46 #define FREQ_SIZE (WINDOW_SIZE/2 + 1)
47 
48 #define NB_BANDS 18
49 #define NB_BANDS_1 (NB_BANDS - 1)
50 
51 void lpcn_compute_band_energy(float *bandE, const kiss_fft_cpx *X);
52 void burg_cepstral_analysis(float *ceps, const float *x);
53 
54 void apply_window(float *x);
55 void dct(float *out, const float *in);
56 void forward_transform(kiss_fft_cpx *out, const float *in);
57 float lpc_from_cepstrum(float *lpc, const float *cepstrum);
58 void apply_window(float *x);
59 void lpc_weighting(float *lpc, float gamma);
60 
61 #endif
62