Improvements to the pitch search

Normalizes the cost function by (x+y) instead of sqrt(x*y)
This commit is contained in:
Koen Vos 2012-07-12 14:36:38 -04:00 committed by Jean-Marc Valin
parent 1bcf028af8
commit 9cbbcb53ae
6 changed files with 144 additions and 248 deletions

View file

@ -94,34 +94,3 @@ opus_int64 silk_inner_prod16_aligned_64(
}
return sum;
}
/* Function that returns the maximum absolut value of the input vector */
opus_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */
const opus_int16 *vec, /* I Input vector [len] */
const opus_int32 len /* I Length of input vector */
)
{
opus_int32 max = 0, i, lvl = 0, ind;
if( len == 0 ) return 0;
ind = len - 1;
max = silk_SMULBB( vec[ ind ], vec[ ind ] );
for( i = len - 2; i >= 0; i-- ) {
lvl = silk_SMULBB( vec[ i ], vec[ i ] );
if( lvl > max ) {
max = lvl;
ind = i;
}
}
/* Do not return 32768, as it will not fit in an int16 so may lead to problems later on */
if( max >= 1073676289 ) { /* (2^15-1)^2 = 1073676289 */
return( silk_int16_MAX );
} else {
if( vec[ ind ] < 0 ) {
return( -vec[ ind ] );
} else {
return( vec[ ind ] );
}
}
}