bowen liu
/
mbed-os-example-blinky
ex
Fork of mbed-os-example-mbed5-blinky by
Embed:
(wiki syntax)
Show/hide line numbers
ltp.h
Go to the documentation of this file.
00001 /* Copyright (C) 2002 Jean-Marc Valin */ 00002 /** 00003 @file ltp.h 00004 @brief Long-Term Prediction functions 00005 */ 00006 /* 00007 Redistribution and use in source and binary forms, with or without 00008 modification, are permitted provided that the following conditions 00009 are met: 00010 00011 - Redistributions of source code must retain the above copyright 00012 notice, this list of conditions and the following disclaimer. 00013 00014 - Redistributions in binary form must reproduce the above copyright 00015 notice, this list of conditions and the following disclaimer in the 00016 documentation and/or other materials provided with the distribution. 00017 00018 - Neither the name of the Xiph.org Foundation nor the names of its 00019 contributors may be used to endorse or promote products derived from 00020 this software without specific prior written permission. 00021 00022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00025 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 00026 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00027 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00028 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00029 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00030 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00031 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00032 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 00035 #include <speex/speex_bits.h> 00036 #include "misc.h" 00037 00038 /** LTP parameters. */ 00039 typedef struct { 00040 const signed char *gain_cdbk; 00041 int gain_bits; 00042 int pitch_bits; 00043 } ltp_params; 00044 00045 #ifdef FIXED_POINT 00046 #define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -SHR16(g[0],1)) + (g[2]>0 ? g[2] : -SHR16(g[2],1))) 00047 #else 00048 #define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -.5*g[0]) + (g[2]>0 ? g[2] : -.5*g[2])) 00049 #endif 00050 00051 spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len); 00052 void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack); 00053 00054 void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack); 00055 00056 00057 /** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */ 00058 int pitch_search_3tap( 00059 spx_word16_t target[], /* Target vector */ 00060 spx_word16_t *sw, 00061 spx_coef_t ak[], /* LPCs for this subframe */ 00062 spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */ 00063 spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */ 00064 spx_sig_t exc[], /* Overlapping codebook */ 00065 const void *par, 00066 int start, /* Smallest pitch value allowed */ 00067 int end, /* Largest pitch value allowed */ 00068 spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ 00069 int p, /* Number of LPC coeffs */ 00070 int nsf, /* Number of samples in subframe */ 00071 SpeexBits *bits, 00072 char *stack, 00073 spx_word16_t *exc2, 00074 spx_word16_t *r, 00075 int complexity, 00076 int cdbk_offset, 00077 int plc_tuning, 00078 spx_word32_t *cumul_gain 00079 ); 00080 00081 /*Unquantize adaptive codebook and update pitch contribution*/ 00082 void pitch_unquant_3tap( 00083 spx_word16_t exc[], /* Input excitation */ 00084 spx_word32_t exc_out[], /* Output excitation */ 00085 int start, /* Smallest pitch value allowed */ 00086 int end, /* Largest pitch value allowed */ 00087 spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ 00088 const void *par, 00089 int nsf, /* Number of samples in subframe */ 00090 int *pitch_val, 00091 spx_word16_t *gain_val, 00092 SpeexBits *bits, 00093 char *stack, 00094 int lost, 00095 int subframe_offset, 00096 spx_word16_t last_pitch_gain, 00097 int cdbk_offset 00098 ); 00099 00100 /** Forced pitch delay and gain */ 00101 int forced_pitch_quant( 00102 spx_word16_t target[], /* Target vector */ 00103 spx_word16_t *sw, 00104 spx_coef_t ak[], /* LPCs for this subframe */ 00105 spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */ 00106 spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */ 00107 spx_sig_t exc[], /* Excitation */ 00108 const void *par, 00109 int start, /* Smallest pitch value allowed */ 00110 int end, /* Largest pitch value allowed */ 00111 spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ 00112 int p, /* Number of LPC coeffs */ 00113 int nsf, /* Number of samples in subframe */ 00114 SpeexBits *bits, 00115 char *stack, 00116 spx_word16_t *exc2, 00117 spx_word16_t *r, 00118 int complexity, 00119 int cdbk_offset, 00120 int plc_tuning, 00121 spx_word32_t *cumul_gain 00122 ); 00123 00124 /** Unquantize forced pitch delay and gain */ 00125 void forced_pitch_unquant( 00126 spx_word16_t exc[], /* Input excitation */ 00127 spx_word32_t exc_out[], /* Output excitation */ 00128 int start, /* Smallest pitch value allowed */ 00129 int end, /* Largest pitch value allowed */ 00130 spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ 00131 const void *par, 00132 int nsf, /* Number of samples in subframe */ 00133 int *pitch_val, 00134 spx_word16_t *gain_val, 00135 SpeexBits *bits, 00136 char *stack, 00137 int lost, 00138 int subframe_offset, 00139 spx_word16_t last_pitch_gain, 00140 int cdbk_offset 00141 );
Generated on Tue Jul 12 2022 16:28:53 by 1.7.2