| 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. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 #include "main_FIX.h" | 36 #include "main_FIX.h" |
| 37 | 37 |
| 38 /* Calculates correlation vector X'*t */ | 38 /* Calculates correlation vector X'*t */ |
| 39 void silk_corrVector_FIX( | 39 void silk_corrVector_FIX( |
| 40 const opus_int16 *x, /* I
x vector [L + order - 1] used to form data matrix X
*/ | 40 const opus_int16 *x, /* I
x vector [L + order - 1] used to form data matrix X
*/ |
| 41 const opus_int16 *t, /* I
Target vector [L]
*/ | 41 const opus_int16 *t, /* I
Target vector [L]
*/ |
| 42 const opus_int L, /* I
Length of vectors
*/ | 42 const opus_int L, /* I
Length of vectors
*/ |
| 43 const opus_int order, /* I
Max lag for correlation
*/ | 43 const opus_int order, /* I
Max lag for correlation
*/ |
| 44 opus_int32 *Xt, /* O
Pointer to X'*t correlation vector [order]
*/ | 44 opus_int32 *Xt, /* O
Pointer to X'*t correlation vector [order]
*/ |
| 45 const opus_int rshifts /* I
Right shifts of correlations
*/ | 45 const opus_int rshifts, /* I
Right shifts of correlations
*/ |
| 46 int arch /* I
Run-time architecture
*/ |
| 46 ) | 47 ) |
| 47 { | 48 { |
| 48 opus_int lag, i; | 49 opus_int lag, i; |
| 49 const opus_int16 *ptr1, *ptr2; | 50 const opus_int16 *ptr1, *ptr2; |
| 50 opus_int32 inner_prod; | 51 opus_int32 inner_prod; |
| 51 | 52 |
| 52 ptr1 = &x[ order - 1 ]; /* Points to first sample of column 0 of X: X[:,0] *
/ | 53 ptr1 = &x[ order - 1 ]; /* Points to first sample of column 0 of X: X[:,0] *
/ |
| 53 ptr2 = t; | 54 ptr2 = t; |
| 54 /* Calculate X'*t */ | 55 /* Calculate X'*t */ |
| 55 if( rshifts > 0 ) { | 56 if( rshifts > 0 ) { |
| 56 /* Right shifting used */ | 57 /* Right shifting used */ |
| 57 for( lag = 0; lag < order; lag++ ) { | 58 for( lag = 0; lag < order; lag++ ) { |
| 58 inner_prod = 0; | 59 inner_prod = 0; |
| 59 for( i = 0; i < L; i++ ) { | 60 for( i = 0; i < L; i++ ) { |
| 60 inner_prod += silk_RSHIFT32( silk_SMULBB( ptr1[ i ], ptr2[i] ),
rshifts ); | 61 inner_prod += silk_RSHIFT32( silk_SMULBB( ptr1[ i ], ptr2[i] ),
rshifts ); |
| 61 } | 62 } |
| 62 Xt[ lag ] = inner_prod; /* X[:,lag]'*t */ | 63 Xt[ lag ] = inner_prod; /* X[:,lag]'*t */ |
| 63 ptr1--; /* Go to next column of X */ | 64 ptr1--; /* Go to next column of X */ |
| 64 } | 65 } |
| 65 } else { | 66 } else { |
| 66 silk_assert( rshifts == 0 ); | 67 silk_assert( rshifts == 0 ); |
| 67 for( lag = 0; lag < order; lag++ ) { | 68 for( lag = 0; lag < order; lag++ ) { |
| 68 Xt[ lag ] = silk_inner_prod_aligned( ptr1, ptr2, L ); /* X[:,lag]'*t
*/ | 69 Xt[ lag ] = silk_inner_prod_aligned( ptr1, ptr2, L, arch ); /* X[:,l
ag]'*t */ |
| 69 ptr1--; /* Go to next column of X */ | 70 ptr1--; /* Go to next column of X */ |
| 70 } | 71 } |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 74 /* Calculates correlation matrix X'*X */ | 75 /* Calculates correlation matrix X'*X */ |
| 75 void silk_corrMatrix_FIX( | 76 void silk_corrMatrix_FIX( |
| 76 const opus_int16 *x, /* I
x vector [L + order - 1] used to form data matrix X
*/ | 77 const opus_int16 *x, /* I
x vector [L + order - 1] used to form data matrix X
*/ |
| 77 const opus_int L, /* I
Length of vectors
*/ | 78 const opus_int L, /* I
Length of vectors
*/ |
| 78 const opus_int order, /* I
Max lag for correlation
*/ | 79 const opus_int order, /* I
Max lag for correlation
*/ |
| 79 const opus_int head_room, /* I
Desired headroom
*/ | 80 const opus_int head_room, /* I
Desired headroom
*/ |
| 80 opus_int32 *XX, /* O
Pointer to X'*X correlation matrix [ order x order ]
*/ | 81 opus_int32 *XX, /* O
Pointer to X'*X correlation matrix [ order x order ]
*/ |
| 81 opus_int *rshifts /* I
/O Right shifts of correlations
*/ | 82 opus_int *rshifts, /* I
/O Right shifts of correlations
*/ |
| 83 int arch /* I
Run-time architecture
*/ |
| 82 ) | 84 ) |
| 83 { | 85 { |
| 84 opus_int i, j, lag, rshifts_local, head_room_rshifts; | 86 opus_int i, j, lag, rshifts_local, head_room_rshifts; |
| 85 opus_int32 energy; | 87 opus_int32 energy; |
| 86 const opus_int16 *ptr1, *ptr2; | 88 const opus_int16 *ptr1, *ptr2; |
| 87 | 89 |
| 88 /* Calculate energy to find shift used to fit in 32 bits */ | 90 /* Calculate energy to find shift used to fit in 32 bits */ |
| 89 silk_sum_sqr_shift( &energy, &rshifts_local, x, L + order - 1 ); | 91 silk_sum_sqr_shift( &energy, &rshifts_local, x, L + order - 1 ); |
| 90 /* Add shifts to get the desired head room */ | 92 /* Add shifts to get the desired head room */ |
| 91 head_room_rshifts = silk_max( head_room - silk_CLZ32( energy ), 0 ); | 93 head_room_rshifts = silk_max( head_room - silk_CLZ32( energy ), 0 ); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 energy = silk_SUB32( energy, silk_RSHIFT32( silk_SMULBB( ptr1[ L
- j ], ptr2[ L - j ] ), rshifts_local ) ); | 133 energy = silk_SUB32( energy, silk_RSHIFT32( silk_SMULBB( ptr1[ L
- j ], ptr2[ L - j ] ), rshifts_local ) ); |
| 132 energy = silk_ADD32( energy, silk_RSHIFT32( silk_SMULBB( ptr1[ -
j ], ptr2[ -j ] ), rshifts_local ) ); | 134 energy = silk_ADD32( energy, silk_RSHIFT32( silk_SMULBB( ptr1[ -
j ], ptr2[ -j ] ), rshifts_local ) ); |
| 133 matrix_ptr( XX, lag + j, j, order ) = energy; | 135 matrix_ptr( XX, lag + j, j, order ) = energy; |
| 134 matrix_ptr( XX, j, lag + j, order ) = energy; | 136 matrix_ptr( XX, j, lag + j, order ) = energy; |
| 135 } | 137 } |
| 136 ptr2--; /* Update pointer to first sample of next column (lag) in X
*/ | 138 ptr2--; /* Update pointer to first sample of next column (lag) in X
*/ |
| 137 } | 139 } |
| 138 } else { | 140 } else { |
| 139 for( lag = 1; lag < order; lag++ ) { | 141 for( lag = 1; lag < order; lag++ ) { |
| 140 /* Inner product of column 0 and column lag: X[:,0]'*X[:,lag] */ | 142 /* Inner product of column 0 and column lag: X[:,0]'*X[:,lag] */ |
| 141 energy = silk_inner_prod_aligned( ptr1, ptr2, L ); | 143 energy = silk_inner_prod_aligned( ptr1, ptr2, L, arch ); |
| 142 matrix_ptr( XX, lag, 0, order ) = energy; | 144 matrix_ptr( XX, lag, 0, order ) = energy; |
| 143 matrix_ptr( XX, 0, lag, order ) = energy; | 145 matrix_ptr( XX, 0, lag, order ) = energy; |
| 144 /* Calculate remaining off diagonal: X[:,j]'*X[:,j + lag] */ | 146 /* Calculate remaining off diagonal: X[:,j]'*X[:,j + lag] */ |
| 145 for( j = 1; j < ( order - lag ); j++ ) { | 147 for( j = 1; j < ( order - lag ); j++ ) { |
| 146 energy = silk_SUB32( energy, silk_SMULBB( ptr1[ L - j ], ptr2[ L
- j ] ) ); | 148 energy = silk_SUB32( energy, silk_SMULBB( ptr1[ L - j ], ptr2[ L
- j ] ) ); |
| 147 energy = silk_SMLABB( energy, ptr1[ -j ], ptr2[ -j ] ); | 149 energy = silk_SMLABB( energy, ptr1[ -j ], ptr2[ -j ] ); |
| 148 matrix_ptr( XX, lag + j, j, order ) = energy; | 150 matrix_ptr( XX, lag + j, j, order ) = energy; |
| 149 matrix_ptr( XX, j, lag + j, order ) = energy; | 151 matrix_ptr( XX, j, lag + j, order ) = energy; |
| 150 } | 152 } |
| 151 ptr2--;/* Update pointer to first sample of next column (lag) in X *
/ | 153 ptr2--;/* Update pointer to first sample of next column (lag) in X *
/ |
| 152 } | 154 } |
| 153 } | 155 } |
| 154 *rshifts = rshifts_local; | 156 *rshifts = rshifts_local; |
| 155 } | 157 } |
| 156 | 158 |
| OLD | NEW |