1 /* Copyright (C) 2002 Jean-Marc Valin */ 2 /** 3 @file filters.h 4 @brief Various analysis/synthesis filters 5 */ 6 /* 7 Redistribution and use in source and binary forms, with or without 8 modification, are permitted provided that the following conditions 9 are met: 10 11 - Redistributions of source code must retain the above copyright 12 notice, this list of conditions and the following disclaimer. 13 14 - Redistributions in binary form must reproduce the above copyright 15 notice, this list of conditions and the following disclaimer in the 16 documentation and/or other materials provided with the distribution. 17 18 - Neither the name of the Xiph.org Foundation nor the names of its 19 contributors may be used to endorse or promote products derived from 20 this software without specific prior written permission. 21 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #ifndef FILTERS_H 36 #define FILTERS_H 37 38 #include "misc.h" 39 40 spx_word16_t compute_rms(const spx_sig_t *x, int len); 41 void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len); 42 void signal_div(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len); 43 44 #ifdef FIXED_POINT 45 46 int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len); 47 48 #endif 49 50 /** Combined filter memory. */ 51 typedef struct { 52 int last_pitch; 53 spx_word16_t last_pitch_gain[3]; 54 spx_word16_t smooth_gain; 55 } CombFilterMem; 56 57 58 void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack); 59 void fir_mem_up(const spx_sig_t *x, const spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack); 60 61 62 void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem); 63 void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem); 64 void iir_mem2(const spx_sig_t *x, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem); 65 66 /* Apply bandwidth expansion on LPC coef */ 67 void bw_lpc(spx_word16_t , const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order); 68 69 70 71 void syn_percep_zero(const spx_sig_t *x, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack); 72 73 void residue_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack); 74 75 void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack); 76 77 void comb_filter_mem_init (CombFilterMem *mem); 78 79 void comb_filter( 80 spx_sig_t *exc, /*decoded excitation*/ 81 spx_sig_t *new_exc, /*enhanced excitation*/ 82 spx_coef_t *ak, /*LPC filter coefs*/ 83 int p, /*LPC order*/ 84 int nsf, /*sub-frame size*/ 85 int pitch, /*pitch period*/ 86 spx_word16_t *pitch_gain, /*pitch gain (3-tap)*/ 87 spx_word16_t comb_gain, /*gain of comb filter*/ 88 CombFilterMem *mem 89 ); 90 91 92 #endif 93