| OLD | NEW |
| (Empty) | |
| 1 /*********************************************************************** |
| 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
| 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 - Redistributions of source code must retain the above copyright notice, |
| 7 this list of conditions and the following disclaimer. |
| 8 - Redistributions in binary form must reproduce the above copyright |
| 9 notice, this list of conditions and the following disclaimer in the |
| 10 documentation and/or other materials provided with the distribution. |
| 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 |
| 13 products derived from this software without specific prior written |
| 14 permission. |
| 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 |
| 17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 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 |
| 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 |
| 25 POSSIBILITY OF SUCH DAMAGE. |
| 26 ***********************************************************************/ |
| 27 |
| 28 #ifdef HAVE_CONFIG_H |
| 29 #include "config.h" |
| 30 #endif |
| 31 |
| 32 /********************************************************************** |
| 33 * Correlation matrix computations for LS estimate. |
| 34 **********************************************************************/ |
| 35 |
| 36 #include "main_FLP.h" |
| 37 |
| 38 /* Calculates correlation vector X'*t */ |
| 39 void silk_corrVector_FLP( |
| 40 const silk_float *x, /* I
x vector [L+order-1] used to create X */ |
| 41 const silk_float *t, /* I
Target vector [L] */ |
| 42 const opus_int L, /* I
Length of vecors */ |
| 43 const opus_int Order, /* I
Max lag for correlation */ |
| 44 silk_float *Xt /* O
X'*t correlation vector [order] */ |
| 45 ) |
| 46 { |
| 47 opus_int lag; |
| 48 const silk_float *ptr1; |
| 49 |
| 50 ptr1 = &x[ Order - 1 ]; /* Points to first sample of col
umn 0 of X: X[:,0] */ |
| 51 for( lag = 0; lag < Order; lag++ ) { |
| 52 /* Calculate X[:,lag]'*t */ |
| 53 Xt[ lag ] = (silk_float)silk_inner_product_FLP( ptr1, t, L ); |
| 54 ptr1--; /* Next column of X */ |
| 55 } |
| 56 } |
| 57 |
| 58 /* Calculates correlation matrix X'*X */ |
| 59 void silk_corrMatrix_FLP( |
| 60 const silk_float *x, /* I
x vector [ L+order-1 ] used to create X */ |
| 61 const opus_int L, /* I
Length of vectors */ |
| 62 const opus_int Order, /* I
Max lag for correlation */ |
| 63 silk_float *XX /* O
X'*X correlation matrix [order x order] */ |
| 64 ) |
| 65 { |
| 66 opus_int j, lag; |
| 67 double energy; |
| 68 const silk_float *ptr1, *ptr2; |
| 69 |
| 70 ptr1 = &x[ Order - 1 ]; /* First sample of column 0 of X
*/ |
| 71 energy = silk_energy_FLP( ptr1, L ); /* X[:,0]'*X[:,0] */ |
| 72 matrix_ptr( XX, 0, 0, Order ) = ( silk_float )energy; |
| 73 for( j = 1; j < Order; j++ ) { |
| 74 /* Calculate X[:,j]'*X[:,j] */ |
| 75 energy += ptr1[ -j ] * ptr1[ -j ] - ptr1[ L - j ] * ptr1[ L - j ]; |
| 76 matrix_ptr( XX, j, j, Order ) = ( silk_float )energy; |
| 77 } |
| 78 |
| 79 ptr2 = &x[ Order - 2 ]; /* First sample of column 1 of X
*/ |
| 80 for( lag = 1; lag < Order; lag++ ) { |
| 81 /* Calculate X[:,0]'*X[:,lag] */ |
| 82 energy = silk_inner_product_FLP( ptr1, ptr2, L ); |
| 83 matrix_ptr( XX, lag, 0, Order ) = ( silk_float )energy; |
| 84 matrix_ptr( XX, 0, lag, Order ) = ( silk_float )energy; |
| 85 /* Calculate X[:,j]'*X[:,j + lag] */ |
| 86 for( j = 1; j < ( Order - lag ); j++ ) { |
| 87 energy += ptr1[ -j ] * ptr2[ -j ] - ptr1[ L - j ] * ptr2[ L - j ]; |
| 88 matrix_ptr( XX, lag + j, j, Order ) = ( silk_float )energy; |
| 89 matrix_ptr( XX, j, lag + j, Order ) = ( silk_float )energy; |
| 90 } |
| 91 ptr2--; /* Next column of X */ |
| 92 } |
| 93 } |
| OLD | NEW |