annotate src/opus-1.3/silk/fixed/find_LTP_FIX.c @ 79:91c729825bca pa_catalina

Update build for AUDIO_COMPONENT_FIX
author Chris Cannam
date Wed, 30 Oct 2019 12:40:34 +0000
parents 7aeed7906520
children
rev   line source
Chris@69 1 /***********************************************************************
Chris@69 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved.
Chris@69 3 Redistribution and use in source and binary forms, with or without
Chris@69 4 modification, are permitted provided that the following conditions
Chris@69 5 are met:
Chris@69 6 - Redistributions of source code must retain the above copyright notice,
Chris@69 7 this list of conditions and the following disclaimer.
Chris@69 8 - Redistributions in binary form must reproduce the above copyright
Chris@69 9 notice, this list of conditions and the following disclaimer in the
Chris@69 10 documentation and/or other materials provided with the distribution.
Chris@69 11 - Neither the name of Internet Society, IETF or IETF Trust, nor the
Chris@69 12 names of specific contributors, may be used to endorse or promote
Chris@69 13 products derived from this software without specific prior written
Chris@69 14 permission.
Chris@69 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Chris@69 16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Chris@69 17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Chris@69 18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
Chris@69 19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Chris@69 20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Chris@69 21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Chris@69 22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Chris@69 23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Chris@69 24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Chris@69 25 POSSIBILITY OF SUCH DAMAGE.
Chris@69 26 ***********************************************************************/
Chris@69 27
Chris@69 28 #ifdef HAVE_CONFIG_H
Chris@69 29 #include "config.h"
Chris@69 30 #endif
Chris@69 31
Chris@69 32 #include "main_FIX.h"
Chris@69 33 #include "tuning_parameters.h"
Chris@69 34
Chris@69 35 void silk_find_LTP_FIX(
Chris@69 36 opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Correlation matrix */
Chris@69 37 opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O Correlation vector */
Chris@69 38 const opus_int16 r_ptr[], /* I Residual signal after LPC */
Chris@69 39 const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
Chris@69 40 const opus_int subfr_length, /* I Subframe length */
Chris@69 41 const opus_int nb_subfr, /* I Number of subframes */
Chris@69 42 int arch /* I Run-time architecture */
Chris@69 43 )
Chris@69 44 {
Chris@69 45 opus_int i, k, extra_shifts;
Chris@69 46 opus_int xx_shifts, xX_shifts, XX_shifts;
Chris@69 47 const opus_int16 *lag_ptr;
Chris@69 48 opus_int32 *XXLTP_Q17_ptr, *xXLTP_Q17_ptr;
Chris@69 49 opus_int32 xx, nrg, temp;
Chris@69 50
Chris@69 51 xXLTP_Q17_ptr = xXLTP_Q17;
Chris@69 52 XXLTP_Q17_ptr = XXLTP_Q17;
Chris@69 53 for( k = 0; k < nb_subfr; k++ ) {
Chris@69 54 lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 );
Chris@69 55
Chris@69 56 silk_sum_sqr_shift( &xx, &xx_shifts, r_ptr, subfr_length + LTP_ORDER ); /* xx in Q( -xx_shifts ) */
Chris@69 57 silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, XXLTP_Q17_ptr, &nrg, &XX_shifts, arch ); /* XXLTP_Q17_ptr and nrg in Q( -XX_shifts ) */
Chris@69 58 extra_shifts = xx_shifts - XX_shifts;
Chris@69 59 if( extra_shifts > 0 ) {
Chris@69 60 /* Shift XX */
Chris@69 61 xX_shifts = xx_shifts;
Chris@69 62 for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) {
Chris@69 63 XXLTP_Q17_ptr[ i ] = silk_RSHIFT32( XXLTP_Q17_ptr[ i ], extra_shifts ); /* Q( -xX_shifts ) */
Chris@69 64 }
Chris@69 65 nrg = silk_RSHIFT32( nrg, extra_shifts ); /* Q( -xX_shifts ) */
Chris@69 66 } else if( extra_shifts < 0 ) {
Chris@69 67 /* Shift xx */
Chris@69 68 xX_shifts = XX_shifts;
Chris@69 69 xx = silk_RSHIFT32( xx, -extra_shifts ); /* Q( -xX_shifts ) */
Chris@69 70 } else {
Chris@69 71 xX_shifts = xx_shifts;
Chris@69 72 }
Chris@69 73 silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, xXLTP_Q17_ptr, xX_shifts, arch ); /* xXLTP_Q17_ptr in Q( -xX_shifts ) */
Chris@69 74
Chris@69 75 /* At this point all correlations are in Q(-xX_shifts) */
Chris@69 76 temp = silk_SMLAWB( 1, nrg, SILK_FIX_CONST( LTP_CORR_INV_MAX, 16 ) );
Chris@69 77 temp = silk_max( temp, xx );
Chris@69 78 TIC(div)
Chris@69 79 #if 0
Chris@69 80 for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) {
Chris@69 81 XXLTP_Q17_ptr[ i ] = silk_DIV32_varQ( XXLTP_Q17_ptr[ i ], temp, 17 );
Chris@69 82 }
Chris@69 83 for( i = 0; i < LTP_ORDER; i++ ) {
Chris@69 84 xXLTP_Q17_ptr[ i ] = silk_DIV32_varQ( xXLTP_Q17_ptr[ i ], temp, 17 );
Chris@69 85 }
Chris@69 86 #else
Chris@69 87 for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) {
Chris@69 88 XXLTP_Q17_ptr[ i ] = (opus_int32)( silk_LSHIFT64( (opus_int64)XXLTP_Q17_ptr[ i ], 17 ) / temp );
Chris@69 89 }
Chris@69 90 for( i = 0; i < LTP_ORDER; i++ ) {
Chris@69 91 xXLTP_Q17_ptr[ i ] = (opus_int32)( silk_LSHIFT64( (opus_int64)xXLTP_Q17_ptr[ i ], 17 ) / temp );
Chris@69 92 }
Chris@69 93 #endif
Chris@69 94 TOC(div)
Chris@69 95 r_ptr += subfr_length;
Chris@69 96 XXLTP_Q17_ptr += LTP_ORDER * LTP_ORDER;
Chris@69 97 xXLTP_Q17_ptr += LTP_ORDER;
Chris@69 98 }
Chris@69 99 }