| OLD | NEW |
| 1 /*********************************************************************** | 1 /*********************************************************************** |
| 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. | 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
| 3 Redistribution and use in source and binary forms, with or without | 3 Redistribution and use in source and binary forms, with or without |
| 4 modification, are permitted provided that the following conditions | 4 modification, are permitted provided that the following conditions |
| 5 are met: | 5 are met: |
| 6 - Redistributions of source code must retain the above copyright notice, | 6 - Redistributions of source code must retain the above copyright notice, |
| 7 this list of conditions and the following disclaimer. | 7 this list of conditions and the following disclaimer. |
| 8 - Redistributions in binary form must reproduce the above copyright | 8 - Redistributions in binary form must reproduce the above copyright |
| 9 notice, this list of conditions and the following disclaimer in the | 9 notice, this list of conditions and the following disclaimer in the |
| 10 documentation and/or other materials provided with the distribution. | 10 documentation and/or other materials provided with the distribution. |
| 11 - Neither the name of Internet Society, IETF or IETF Trust, nor the | 11 - Neither the name of Internet Society, IETF or IETF Trust, nor the |
| 12 names of specific contributors, may be used to endorse or promote | 12 names of specific contributors, may be used to endorse or promote |
| 13 products derived from this software without specific prior written | 13 products derived from this software without specific prior written |
| 14 permission. | 14 permission. |
| 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” | 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 POSSIBILITY OF SUCH DAMAGE. | 25 POSSIBILITY OF SUCH DAMAGE. |
| 26 ***********************************************************************/ | 26 ***********************************************************************/ |
| 27 | 27 |
| 28 #ifdef HAVE_CONFIG_H | 28 #ifdef HAVE_CONFIG_H |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #include "SigProc_FIX.h" | 32 #include "SigProc_FIX.h" |
| 33 #include "resampler_private.h" | 33 #include "resampler_private.h" |
| 34 #include "stack_alloc.h" |
| 34 | 35 |
| 35 static inline opus_int16 *silk_resampler_private_down_FIR_INTERPOL( | 36 static inline opus_int16 *silk_resampler_private_down_FIR_INTERPOL( |
| 36 opus_int16 *out, | 37 opus_int16 *out, |
| 37 opus_int32 *buf, | 38 opus_int32 *buf, |
| 38 const opus_int16 *FIR_Coefs, | 39 const opus_int16 *FIR_Coefs, |
| 39 opus_int FIR_Order, | 40 opus_int FIR_Order, |
| 40 opus_int FIR_Fracs, | 41 opus_int FIR_Fracs, |
| 41 opus_int32 max_index_Q16, | 42 opus_int32 max_index_Q16, |
| 42 opus_int32 index_increment_Q16 | 43 opus_int32 index_increment_Q16 |
| 43 ) | 44 ) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 void silk_resampler_private_down_FIR( | 145 void silk_resampler_private_down_FIR( |
| 145 void *SS, /* I/O Resampler state
*/ | 146 void *SS, /* I/O Resampler state
*/ |
| 146 opus_int16 out[], /* O Output signal
*/ | 147 opus_int16 out[], /* O Output signal
*/ |
| 147 const opus_int16 in[], /* I Input signal
*/ | 148 const opus_int16 in[], /* I Input signal
*/ |
| 148 opus_int32 inLen /* I Number of input samp
les */ | 149 opus_int32 inLen /* I Number of input samp
les */ |
| 149 ) | 150 ) |
| 150 { | 151 { |
| 151 silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; | 152 silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; |
| 152 opus_int32 nSamplesIn; | 153 opus_int32 nSamplesIn; |
| 153 opus_int32 max_index_Q16, index_increment_Q16; | 154 opus_int32 max_index_Q16, index_increment_Q16; |
| 154 opus_int32 buf[ RESAMPLER_MAX_BATCH_SIZE_IN + SILK_RESAMPLER_MAX_FIR_ORDER ]
; | 155 VARDECL( opus_int32, buf ); |
| 155 const opus_int16 *FIR_Coefs; | 156 const opus_int16 *FIR_Coefs; |
| 157 SAVE_STACK; |
| 158 |
| 159 ALLOC( buf, S->batchSize + S->FIR_Order, opus_int32 ); |
| 156 | 160 |
| 157 /* Copy buffered samples to start of buffer */ | 161 /* Copy buffered samples to start of buffer */ |
| 158 silk_memcpy( buf, S->sFIR, S->FIR_Order * sizeof( opus_int32 ) ); | 162 silk_memcpy( buf, S->sFIR.i32, S->FIR_Order * sizeof( opus_int32 ) ); |
| 159 | 163 |
| 160 FIR_Coefs = &S->Coefs[ 2 ]; | 164 FIR_Coefs = &S->Coefs[ 2 ]; |
| 161 | 165 |
| 162 /* Iterate over blocks of frameSizeIn input samples */ | 166 /* Iterate over blocks of frameSizeIn input samples */ |
| 163 index_increment_Q16 = S->invRatio_Q16; | 167 index_increment_Q16 = S->invRatio_Q16; |
| 164 while( 1 ) { | 168 while( 1 ) { |
| 165 nSamplesIn = silk_min( inLen, S->batchSize ); | 169 nSamplesIn = silk_min( inLen, S->batchSize ); |
| 166 | 170 |
| 167 /* Second-order AR filter (output in Q8) */ | 171 /* Second-order AR filter (output in Q8) */ |
| 168 silk_resampler_private_AR2( S->sIIR, &buf[ S->FIR_Order ], in, S->Coefs,
nSamplesIn ); | 172 silk_resampler_private_AR2( S->sIIR, &buf[ S->FIR_Order ], in, S->Coefs,
nSamplesIn ); |
| 169 | 173 |
| 170 max_index_Q16 = silk_LSHIFT32( nSamplesIn, 16 ); | 174 max_index_Q16 = silk_LSHIFT32( nSamplesIn, 16 ); |
| 171 | 175 |
| 172 /* Interpolate filtered signal */ | 176 /* Interpolate filtered signal */ |
| 173 out = silk_resampler_private_down_FIR_INTERPOL( out, buf, FIR_Coefs, S->
FIR_Order, | 177 out = silk_resampler_private_down_FIR_INTERPOL( out, buf, FIR_Coefs, S->
FIR_Order, |
| 174 S->FIR_Fracs, max_index_Q16, index_increment_Q16 ); | 178 S->FIR_Fracs, max_index_Q16, index_increment_Q16 ); |
| 175 | 179 |
| 176 in += nSamplesIn; | 180 in += nSamplesIn; |
| 177 inLen -= nSamplesIn; | 181 inLen -= nSamplesIn; |
| 178 | 182 |
| 179 if( inLen > 1 ) { | 183 if( inLen > 1 ) { |
| 180 /* More iterations to do; copy last part of filtered signal to begin
ning of buffer */ | 184 /* More iterations to do; copy last part of filtered signal to begin
ning of buffer */ |
| 181 silk_memcpy( buf, &buf[ nSamplesIn ], S->FIR_Order * sizeof( opus_in
t32 ) ); | 185 silk_memcpy( buf, &buf[ nSamplesIn ], S->FIR_Order * sizeof( opus_in
t32 ) ); |
| 182 } else { | 186 } else { |
| 183 break; | 187 break; |
| 184 } | 188 } |
| 185 } | 189 } |
| 186 | 190 |
| 187 /* Copy last part of filtered signal to the state for the next call */ | 191 /* Copy last part of filtered signal to the state for the next call */ |
| 188 silk_memcpy( S->sFIR, &buf[ nSamplesIn ], S->FIR_Order * sizeof( opus_int32
) ); | 192 silk_memcpy( S->sFIR.i32, &buf[ nSamplesIn ], S->FIR_Order * sizeof( opus_in
t32 ) ); |
| 193 RESTORE_STACK; |
| 189 } | 194 } |
| OLD | NEW |