00001 /* Copyright (C) 2002 Jean-Marc Valin 00002 File: ltp.h 00003 Long-Term Prediction functions 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions 00007 are met: 00008 00009 - Redistributions of source code must retain the above copyright 00010 notice, this list of conditions and the following disclaimer. 00011 00012 - Redistributions in binary form must reproduce the above copyright 00013 notice, this list of conditions and the following disclaimer in the 00014 documentation and/or other materials provided with the distribution. 00015 00016 - Neither the name of the Xiph.org Foundation nor the names of its 00017 contributors may be used to endorse or promote products derived from 00018 this software without specific prior written permission. 00019 00020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00021 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00023 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 00024 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00026 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00027 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00028 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00029 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 */ 00032 00033 #include "speex_bits.h" 00034 00035 00036 typedef struct ltp_params { 00037 signed char *gain_cdbk; 00038 int gain_bits; 00039 int pitch_bits; 00040 } ltp_params; 00041 00042 00043 void open_loop_nbest_pitch(float *sw, int start, int end, int len, int *pitch, float *gain, int N, char *stack); 00044 00045 00047 int pitch_search_3tap( 00048 float target[], /* Target vector */ 00049 float *sw, 00050 float ak[], /* LPCs for this subframe */ 00051 float awk1[], /* Weighted LPCs #1 for this subframe */ 00052 float awk2[], /* Weighted LPCs #2 for this subframe */ 00053 float exc[], /* Overlapping codebook */ 00054 void *par, 00055 int start, /* Smallest pitch value allowed */ 00056 int end, /* Largest pitch value allowed */ 00057 float pitch_coef, /* Voicing (pitch) coefficient */ 00058 int p, /* Number of LPC coeffs */ 00059 int nsf, /* Number of samples in subframe */ 00060 SpeexBits *bits, 00061 char *stack, 00062 float *exc2, 00063 float *r, 00064 int complexity, 00065 int cdbk_offset 00066 ); 00067 00068 /*Unquantize adaptive codebook and update pitch contribution*/ 00069 void pitch_unquant_3tap( 00070 float exc[], /* Excitation */ 00071 int start, /* Smallest pitch value allowed */ 00072 int end, /* Largest pitch value allowed */ 00073 float pitch_coef, /* Voicing (pitch) coefficient */ 00074 void *par, 00075 int nsf, /* Number of samples in subframe */ 00076 int *pitch_val, 00077 float *gain_val, 00078 SpeexBits *bits, 00079 char *stack, 00080 int lost, 00081 int subframe_offset, 00082 float last_pitch_gain, 00083 int cdbk_offset 00084 ); 00085 00087 int forced_pitch_quant( 00088 float target[], /* Target vector */ 00089 float *sw, 00090 float ak[], /* LPCs for this subframe */ 00091 float awk1[], /* Weighted LPCs #1 for this subframe */ 00092 float awk2[], /* Weighted LPCs #2 for this subframe */ 00093 float exc[], /* Excitation */ 00094 void *par, 00095 int start, /* Smallest pitch value allowed */ 00096 int end, /* Largest pitch value allowed */ 00097 float pitch_coef, /* Voicing (pitch) coefficient */ 00098 int p, /* Number of LPC coeffs */ 00099 int nsf, /* Number of samples in subframe */ 00100 SpeexBits *bits, 00101 char *stack, 00102 float *exc2, 00103 float *r, 00104 int complexity, 00105 int cdbk_offset 00106 ); 00107 00109 void forced_pitch_unquant( 00110 float exc[], /* Excitation */ 00111 int start, /* Smallest pitch value allowed */ 00112 int end, /* Largest pitch value allowed */ 00113 float pitch_coef, /* Voicing (pitch) coefficient */ 00114 void *par, 00115 int nsf, /* Number of samples in subframe */ 00116 int *pitch_val, 00117 float *gain_val, 00118 SpeexBits *bits, 00119 char *stack, 00120 int lost, 00121 int subframe_offset, 00122 float last_pitch_gain, 00123 int cdbk_offset 00124 );