Commit f9d14f8d authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Renamed SKP_[u]int* to opus_[u]int*

parent d77d6a58
......@@ -148,4 +148,13 @@
#endif
#define opus_int int /* used for counters etc; at least 16 bits */
#define opus_int64 long long
#define opus_int8 signed char
#define opus_uint unsigned int /* used for counters etc; at least 16 bits */
#define opus_uint64 unsigned long long
#define opus_uint8 unsigned char
#endif /* _OPUS_TYPES_H */
......@@ -28,21 +28,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "silk_main_FIX.h"
void silk_LTP_analysis_filter_FIX(
SKP_int16 *LTP_res, /* O: LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */
const SKP_int16 *x, /* I: Pointer to input signal with at least max( pitchL ) preceeding samples */
const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I: LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */
const SKP_int pitchL[ MAX_NB_SUBFR ], /* I: Pitch lag, one for each subframe */
const SKP_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I: Inverse quantization gains, one for each subframe */
const SKP_int subfr_length, /* I: Length of each subframe */
const SKP_int nb_subfr, /* I: Number of subframes */
const SKP_int pre_length /* I: Length of the preceeding samples starting at &x[0] for each subframe */
opus_int16 *LTP_res, /* O: LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */
const opus_int16 *x, /* I: Pointer to input signal with at least max( pitchL ) preceeding samples */
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I: LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */
const opus_int pitchL[ MAX_NB_SUBFR ], /* I: Pitch lag, one for each subframe */
const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I: Inverse quantization gains, one for each subframe */
const opus_int subfr_length, /* I: Length of each subframe */
const opus_int nb_subfr, /* I: Number of subframes */
const opus_int pre_length /* I: Length of the preceeding samples starting at &x[0] for each subframe */
)
{
const SKP_int16 *x_ptr, *x_lag_ptr;
SKP_int16 Btmp_Q14[ LTP_ORDER ];
SKP_int16 *LTP_res_ptr;
SKP_int k, i, j;
SKP_int32 LTP_est;
const opus_int16 *x_ptr, *x_lag_ptr;
opus_int16 Btmp_Q14[ LTP_ORDER ];
opus_int16 *LTP_res_ptr;
opus_int k, i, j;
opus_int32 LTP_est;
x_ptr = x;
LTP_res_ptr = LTP_res;
......@@ -65,7 +65,7 @@ void silk_LTP_analysis_filter_FIX(
LTP_est = SKP_RSHIFT_ROUND( LTP_est, 14 ); // round and -> Q0
/* Subtract long-term prediction */
LTP_res_ptr[ i ] = ( SKP_int16 )SKP_SAT16( ( SKP_int32 )x_ptr[ i ] - LTP_est );
LTP_res_ptr[ i ] = ( opus_int16 )SKP_SAT16( ( opus_int32 )x_ptr[ i ] - LTP_est );
/* Scale residual */
LTP_res_ptr[ i ] = SKP_SMULWB( invGains_Q16[ k ], LTP_res_ptr[ i ] );
......
......@@ -32,7 +32,7 @@ void silk_LTP_scale_ctrl_FIX(
silk_encoder_control_FIX *psEncCtrl /* I/O encoder control FIX */
)
{
SKP_int round_loss;
opus_int round_loss;
/* 1st order high-pass filter */
psEnc->HPLTPredCodGain_Q7 = SKP_max_int( psEncCtrl->LTPredCodGain_Q7 - SKP_RSHIFT( psEnc->prevLTPredCodGain_Q7, 1 ), 0 )
......@@ -42,7 +42,7 @@ void silk_LTP_scale_ctrl_FIX(
/* Only scale if first frame in packet */
if( psEnc->sCmn.nFramesEncoded == 0 ) {
round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket - 1;
psEnc->sCmn.indices.LTP_scaleIndex = (SKP_int8)SKP_LIMIT(
psEnc->sCmn.indices.LTP_scaleIndex = (opus_int8)SKP_LIMIT(
SKP_SMULWB( SKP_SMULBB( round_loss, psEnc->HPLTPredCodGain_Q7 ), SILK_FIX_CONST( 0.1, 9 ) ), 0, 2 );
} else {
/* Default is minimum scaling */
......
......@@ -33,17 +33,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Calculates correlation vector X'*t */
void silk_corrVector_FIX(
const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
const SKP_int16 *t, /* I target vector [L] */
const SKP_int L, /* I Length of vectors */
const SKP_int order, /* I Max lag for correlation */
SKP_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */
const SKP_int rshifts /* I Right shifts of correlations */
const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
const opus_int16 *t, /* I target vector [L] */
const opus_int L, /* I Length of vectors */
const opus_int order, /* I Max lag for correlation */
opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */
const opus_int rshifts /* I Right shifts of correlations */
)
{
SKP_int lag, i;
const SKP_int16 *ptr1, *ptr2;
SKP_int32 inner_prod;
opus_int lag, i;
const opus_int16 *ptr1, *ptr2;
opus_int32 inner_prod;
ptr1 = &x[ order - 1 ]; /* Points to first sample of column 0 of X: X[:,0] */
ptr2 = t;
......@@ -69,17 +69,17 @@ void silk_corrVector_FIX(
/* Calculates correlation matrix X'*X */
void silk_corrMatrix_FIX(
const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
const SKP_int L, /* I Length of vectors */
const SKP_int order, /* I Max lag for correlation */
const SKP_int head_room, /* I Desired headroom */
SKP_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ]*/
SKP_int *rshifts /* I/O Right shifts of correlations */
const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
const opus_int L, /* I Length of vectors */
const opus_int order, /* I Max lag for correlation */
const opus_int head_room, /* I Desired headroom */
opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ]*/
opus_int *rshifts /* I/O Right shifts of correlations */
)
{
SKP_int i, j, lag, rshifts_local, head_room_rshifts;
SKP_int32 energy;
const SKP_int16 *ptr1, *ptr2;
opus_int i, j, lag, rshifts_local, head_room_rshifts;
opus_int32 energy;
const opus_int16 *ptr1, *ptr2;
/* Calculate energy to find shift used to fit in 32 bits */
silk_sum_sqr_shift( &energy, &rshifts_local, x, L + order - 1 );
......
......@@ -31,17 +31,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/****************/
/* Encode frame */
/****************/
SKP_int silk_encode_frame_FIX(
opus_int silk_encode_frame_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
SKP_int32 *pnBytesOut, /* O Number of payload bytes */
opus_int32 *pnBytesOut, /* O Number of payload bytes */
ec_enc *psRangeEnc /* I/O compressor data structure */
)
{
silk_encoder_control_FIX sEncCtrl;
SKP_int ret = 0;
SKP_int16 *x_frame, *res_pitch_frame;
SKP_int16 xfw[ MAX_FRAME_LENGTH ];
SKP_int16 res_pitch[ 2 * MAX_FRAME_LENGTH + LA_PITCH_MAX ];
opus_int ret = 0;
opus_int16 *x_frame, *res_pitch_frame;
opus_int16 xfw[ MAX_FRAME_LENGTH ];
opus_int16 res_pitch[ 2 * MAX_FRAME_LENGTH + LA_PITCH_MAX ];
TIC(ENCODE_FRAME)
......@@ -92,7 +92,7 @@ TOC(VAD)
/*******************************************/
/* Copy new frame to front of input buffer */
/*******************************************/
SKP_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );
SKP_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length * sizeof( opus_int16 ) );
/*****************************************/
/* Find pitch lags, initial LPC analysis */
......@@ -153,7 +153,7 @@ TOC(NSQ)
/* Update input buffer */
SKP_memmove( psEnc->x_buf, &psEnc->x_buf[ psEnc->sCmn.frame_length ],
( psEnc->sCmn.ltp_mem_length + LA_SHAPE_MS * psEnc->sCmn.fs_kHz ) * sizeof( SKP_int16 ) );
( psEnc->sCmn.ltp_mem_length + LA_SHAPE_MS * psEnc->sCmn.fs_kHz ) * sizeof( opus_int16 ) );
/* Parameters needed for next frame */
psEnc->sCmn.prevLag = sEncCtrl.pitchL[ psEnc->sCmn.nb_subfr - 1 ];
......@@ -201,9 +201,9 @@ TOC(ENCODE_FRAME)
{
SKP_float tmp[ MAX_NB_SUBFR * LTP_ORDER ];
int i;
DEBUG_STORE_DATA( xf.dat, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );
DEBUG_STORE_DATA( xfw.dat, xfw, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );
DEBUG_STORE_DATA( pitchL.dat, sEncCtrl.pitchL, psEnc->sCmn.nb_subfr * sizeof( SKP_int ) );
DEBUG_STORE_DATA( xf.dat, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.frame_length * sizeof( opus_int16 ) );
DEBUG_STORE_DATA( xfw.dat, xfw, psEnc->sCmn.frame_length * sizeof( opus_int16 ) );
DEBUG_STORE_DATA( pitchL.dat, sEncCtrl.pitchL, psEnc->sCmn.nb_subfr * sizeof( opus_int ) );
for( i = 0; i < psEnc->sCmn.nb_subfr * LTP_ORDER; i++ ) {
tmp[ i ] = (SKP_float)sEncCtrl.LTPCoef_Q14[ i ] / 16384.0f;
}
......@@ -223,20 +223,20 @@ TOC(ENCODE_FRAME)
tmp[ i ] = (SKP_float)sEncCtrl.Gains_Q16[ i ] / 65536.0f;
}
DEBUG_STORE_DATA( gains.dat, tmp, psEnc->sCmn.nb_subfr * sizeof( SKP_float ) );
DEBUG_STORE_DATA( gains_indices.dat, &psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr * sizeof( SKP_int ) );
DEBUG_STORE_DATA( gains_indices.dat, &psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr * sizeof( opus_int ) );
tmp[ 0 ] = (SKP_float)sEncCtrl.current_SNR_dB_Q7 / 128.0f;
DEBUG_STORE_DATA( current_SNR_db.dat, tmp, sizeof( SKP_float ) );
DEBUG_STORE_DATA( quantOffsetType.dat, &psEnc->sCmn.indices.quantOffsetType, sizeof( SKP_int ) );
DEBUG_STORE_DATA( quantOffsetType.dat, &psEnc->sCmn.indices.quantOffsetType, sizeof( opus_int ) );
tmp[ 0 ] = (SKP_float)psEnc->sCmn.speech_activity_Q8 / 256.0f;
DEBUG_STORE_DATA( speech_activity.dat, tmp, sizeof( SKP_float ) );
for( i = 0; i < VAD_N_BANDS; i++ ) {
tmp[ i ] = (SKP_float)psEnc->sCmn.input_quality_bands_Q15[ i ] / 32768.0f;
}
DEBUG_STORE_DATA( input_quality_bands.dat, tmp, VAD_N_BANDS * sizeof( SKP_float ) );
DEBUG_STORE_DATA( signalType.dat, &psEnc->sCmn.indices.signalType, sizeof( SKP_int8) );
DEBUG_STORE_DATA( lag_index.dat, &psEnc->sCmn.indices.lagIndex, sizeof( SKP_int16 ) );
DEBUG_STORE_DATA( contour_index.dat, &psEnc->sCmn.indices.contourIndex, sizeof( SKP_int8 ) );
DEBUG_STORE_DATA( per_index.dat, &psEnc->sCmn.indices.PERIndex, sizeof( SKP_int8) );
DEBUG_STORE_DATA( signalType.dat, &psEnc->sCmn.indices.signalType, sizeof( opus_int8) );
DEBUG_STORE_DATA( lag_index.dat, &psEnc->sCmn.indices.lagIndex, sizeof( opus_int16 ) );
DEBUG_STORE_DATA( contour_index.dat, &psEnc->sCmn.indices.contourIndex, sizeof( opus_int8 ) );
DEBUG_STORE_DATA( per_index.dat, &psEnc->sCmn.indices.PERIndex, sizeof( opus_int8) );
}
#endif
return ret;
......@@ -246,10 +246,10 @@ TOC(ENCODE_FRAME)
void silk_LBRR_encode_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */
const SKP_int16 xfw[] /* I Input signal */
const opus_int16 xfw[] /* I Input signal */
)
{
SKP_int32 TempGains_Q16[ MAX_NB_SUBFR ];
opus_int32 TempGains_Q16[ MAX_NB_SUBFR ];
SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesEncoded ];
silk_nsq_state sNSQ_LBRR;
......@@ -264,7 +264,7 @@ void silk_LBRR_encode_FIX(
SKP_memcpy( psIndices_LBRR, &psEnc->sCmn.indices, sizeof( SideInfoIndices ) );
/* Save original gains */
SKP_memcpy( TempGains_Q16, psEncCtrl->Gains_Q16, psEnc->sCmn.nb_subfr * sizeof( SKP_int32 ) );
SKP_memcpy( TempGains_Q16, psEncCtrl->Gains_Q16, psEnc->sCmn.nb_subfr * sizeof( opus_int32 ) );
if( psEnc->sCmn.nFramesEncoded == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded - 1 ] == 0 ) {
/* First frame in packet or previous frame not LBRR coded */
......@@ -296,6 +296,6 @@ void silk_LBRR_encode_FIX(
}
/* Restore original gains */
SKP_memcpy( psEncCtrl->Gains_Q16, TempGains_Q16, psEnc->sCmn.nb_subfr * sizeof( SKP_int32 ) );
SKP_memcpy( psEncCtrl->Gains_Q16, TempGains_Q16, psEnc->sCmn.nb_subfr * sizeof( opus_int32 ) );
}
}
......@@ -30,29 +30,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Finds LPC vector from correlations, and converts to NLSF */
void silk_find_LPC_FIX(
SKP_int16 NLSF_Q15[], /* O NLSFs */
SKP_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */
const SKP_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */
const SKP_int useInterpNLSFs, /* I Flag */
const SKP_int firstFrameAfterReset, /* I Flag */
const SKP_int LPC_order, /* I LPC order */
const SKP_int16 x[], /* I Input signal */
const SKP_int subfr_length, /* I Input signal subframe length including preceeding samples */
const SKP_int nb_subfr /* I: Number of subframes */
opus_int16 NLSF_Q15[], /* O NLSFs */
opus_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */
const opus_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */
const opus_int useInterpNLSFs, /* I Flag */
const opus_int firstFrameAfterReset, /* I Flag */
const opus_int LPC_order, /* I LPC order */
const opus_int16 x[], /* I Input signal */
const opus_int subfr_length, /* I Input signal subframe length including preceeding samples */
const opus_int nb_subfr /* I: Number of subframes */
)
{
SKP_int k;
SKP_int32 a_Q16[ MAX_LPC_ORDER ];
SKP_int isInterpLower, shift;
SKP_int32 res_nrg0, res_nrg1;
SKP_int rshift0, rshift1;
opus_int k;
opus_int32 a_Q16[ MAX_LPC_ORDER ];
opus_int isInterpLower, shift;
opus_int32 res_nrg0, res_nrg1;
opus_int rshift0, rshift1;
/* Used only for LSF interpolation */
SKP_int32 a_tmp_Q16[ MAX_LPC_ORDER ], res_nrg_interp, res_nrg, res_tmp_nrg, res_nrg_2nd;
SKP_int res_nrg_interp_Q, res_nrg_Q, res_tmp_nrg_Q, res_nrg_2nd_Q;
SKP_int16 a_tmp_Q12[ MAX_LPC_ORDER ];
SKP_int16 NLSF0_Q15[ MAX_LPC_ORDER ];
SKP_int16 LPC_res[ ( MAX_FRAME_LENGTH + MAX_NB_SUBFR * MAX_LPC_ORDER ) / 2 ];
opus_int32 a_tmp_Q16[ MAX_LPC_ORDER ], res_nrg_interp, res_nrg, res_tmp_nrg, res_nrg_2nd;
opus_int res_nrg_interp_Q, res_nrg_Q, res_tmp_nrg_Q, res_nrg_2nd_Q;
opus_int16 a_tmp_Q12[ MAX_LPC_ORDER ];
opus_int16 NLSF0_Q15[ MAX_LPC_ORDER ];
opus_int16 LPC_res[ ( MAX_FRAME_LENGTH + MAX_NB_SUBFR * MAX_LPC_ORDER ) / 2 ];
/* Default: no interpolation */
*interpIndex = 4;
......@@ -141,7 +141,7 @@ void silk_find_LPC_FIX(
/* Interpolation has lower residual energy */
res_nrg = res_nrg_interp;
res_nrg_Q = res_nrg_interp_Q;
*interpIndex = (SKP_int8)k;
*interpIndex = (opus_int8)k;
}
res_nrg_2nd = res_nrg_interp;
res_nrg_2nd_Q = res_nrg_interp_Q;
......
......@@ -32,38 +32,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define LTP_CORRS_HEAD_ROOM 2
void silk_fit_LTP(
SKP_int32 LTP_coefs_Q16[ LTP_ORDER ],
SKP_int16 LTP_coefs_Q14[ LTP_ORDER ]
opus_int32 LTP_coefs_Q16[ LTP_ORDER ],
opus_int16 LTP_coefs_Q14[ LTP_ORDER ]
);
void silk_find_LTP_FIX(
SKP_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
SKP_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
SKP_int *LTPredCodGain_Q7, /* O LTP coding gain */
const SKP_int16 r_lpc[] , /* I residual signal after LPC signal + state for first 10 ms */
const SKP_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
const SKP_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */
const SKP_int subfr_length, /* I subframe length */
const SKP_int nb_subfr, /* I number of subframes */
const SKP_int mem_offset, /* I number of samples in LTP memory */
SKP_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */
opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
opus_int *LTPredCodGain_Q7, /* O LTP coding gain */
const opus_int16 r_lpc[] , /* I residual signal after LPC signal + state for first 10 ms */
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */
const opus_int subfr_length, /* I subframe length */
const opus_int nb_subfr, /* I number of subframes */
const opus_int mem_offset, /* I number of samples in LTP memory */
opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */
)
{
SKP_int i, k, lshift;
const SKP_int16 *r_ptr, *lag_ptr;
SKP_int16 *b_Q14_ptr;
SKP_int32 regu;
SKP_int32 *WLTP_ptr;
SKP_int32 b_Q16[ LTP_ORDER ], delta_b_Q14[ LTP_ORDER ], d_Q14[ MAX_NB_SUBFR ], nrg[ MAX_NB_SUBFR ], g_Q26;
SKP_int32 w[ MAX_NB_SUBFR ], WLTP_max, max_abs_d_Q14, max_w_bits;
SKP_int32 temp32, denom32;
SKP_int extra_shifts;
SKP_int rr_shifts, maxRshifts, maxRshifts_wxtra, LZs;
SKP_int32 LPC_res_nrg, LPC_LTP_res_nrg, div_Q16;
SKP_int32 Rr[ LTP_ORDER ], rr[ MAX_NB_SUBFR ];
SKP_int32 wd, m_Q12;
opus_int i, k, lshift;
const opus_int16 *r_ptr, *lag_ptr;
opus_int16 *b_Q14_ptr;
opus_int32 regu;
opus_int32 *WLTP_ptr;
opus_int32 b_Q16[ LTP_ORDER ], delta_b_Q14[ LTP_ORDER ], d_Q14[ MAX_NB_SUBFR ], nrg[ MAX_NB_SUBFR ], g_Q26;
opus_int32 w[ MAX_NB_SUBFR ], WLTP_max, max_abs_d_Q14, max_w_bits;
opus_int32 temp32, denom32;
opus_int extra_shifts;
opus_int rr_shifts, maxRshifts, maxRshifts_wxtra, LZs;
opus_int32 LPC_res_nrg, LPC_LTP_res_nrg, div_Q16;
opus_int32 Rr[ LTP_ORDER ], rr[ MAX_NB_SUBFR ];
opus_int32 wd, m_Q12;
b_Q14_ptr = b_Q14;
WLTP_ptr = WLTP;
......@@ -108,8 +108,8 @@ void silk_find_LTP_FIX(
denom32 = SKP_LSHIFT_SAT32( SKP_SMULWB( nrg[ k ], Wght_Q15[ k ] ), 1 + extra_shifts ) + /* Q( -corr_rshifts[ k ] + extra_shifts ) */
SKP_RSHIFT( SKP_SMULWB( subfr_length, 655 ), corr_rshifts[ k ] - extra_shifts ); /* Q( -corr_rshifts[ k ] + extra_shifts ) */
denom32 = SKP_max( denom32, 1 );
SKP_assert( ((SKP_int64)Wght_Q15[ k ] << 16 ) < SKP_int32_MAX ); /* Wght always < 0.5 in Q0 */
temp32 = SKP_DIV32( SKP_LSHIFT( ( SKP_int32 )Wght_Q15[ k ], 16 ), denom32 ); /* Q( 15 + 16 + corr_rshifts[k] - extra_shifts ) */
SKP_assert( ((opus_int64)Wght_Q15[ k ] << 16 ) < SKP_int32_MAX ); /* Wght always < 0.5 in Q0 */
temp32 = SKP_DIV32( SKP_LSHIFT( ( opus_int32 )Wght_Q15[ k ], 16 ), denom32 ); /* Q( 15 + 16 + corr_rshifts[k] - extra_shifts ) */
temp32 = SKP_RSHIFT( temp32, 31 + corr_rshifts[ k ] - extra_shifts - 26 ); /* Q26 */
/* Limit temp such that the below scaling never wraps around */
......@@ -120,7 +120,7 @@ void silk_find_LTP_FIX(
lshift = silk_CLZ32( WLTP_max ) - 1 - 3; /* keep 3 bits free for vq_nearest_neighbor_fix */
SKP_assert( 26 - 18 + lshift >= 0 );
if( 26 - 18 + lshift < 31 ) {
temp32 = SKP_min_32( temp32, SKP_LSHIFT( ( SKP_int32 )1, 26 - 18 + lshift ) );
temp32 = SKP_min_32( temp32, SKP_LSHIFT( ( opus_int32 )1, 26 - 18 + lshift ) );
}
silk_scale_vector32_Q26_lshift_18( WLTP_ptr, temp32, LTP_ORDER * LTP_ORDER ); /* WLTP_ptr in Q( 18 - corr_rshifts[ k ] ) */
......@@ -150,9 +150,9 @@ void silk_find_LTP_FIX(
LPC_LTP_res_nrg = SKP_max( LPC_LTP_res_nrg, 1 ); /* avoid division by zero */
div_Q16 = silk_DIV32_varQ( LPC_res_nrg, LPC_LTP_res_nrg, 16 );
*LTPredCodGain_Q7 = ( SKP_int )SKP_SMULBB( 3, silk_lin2log( div_Q16 ) - ( 16 << 7 ) );
*LTPredCodGain_Q7 = ( opus_int )SKP_SMULBB( 3, silk_lin2log( div_Q16 ) - ( 16 << 7 ) );
SKP_assert( *LTPredCodGain_Q7 == ( SKP_int )SKP_SAT16( SKP_MUL( 3, silk_lin2log( div_Q16 ) - ( 16 << 7 ) ) ) );
SKP_assert( *LTPredCodGain_Q7 == ( opus_int )SKP_SAT16( SKP_MUL( 3, silk_lin2log( div_Q16 ) - ( 16 << 7 ) ) ) );
}
/* smoothing */
......@@ -212,7 +212,7 @@ void silk_find_LTP_FIX(
SKP_DIV32(
SILK_FIX_CONST( LTP_SMOOTHING, 26 ),
SKP_RSHIFT( SILK_FIX_CONST( LTP_SMOOTHING, 26 ), 10 ) + temp32 ), /* Q10 */
SKP_LSHIFT_SAT32( SKP_SUB_SAT32( ( SKP_int32 )m_Q12, SKP_RSHIFT( d_Q14[ k ], 2 ) ), 4 ) ); /* Q16 */
SKP_LSHIFT_SAT32( SKP_SUB_SAT32( ( opus_int32 )m_Q12, SKP_RSHIFT( d_Q14[ k ], 2 ) ), 4 ) ); /* Q16 */
temp32 = 0;
for( i = 0; i < LTP_ORDER; i++ ) {
......@@ -221,7 +221,7 @@ void silk_find_LTP_FIX(
}
temp32 = SKP_DIV32( g_Q26, temp32 ); /* Q14->Q12 */
for( i = 0; i < LTP_ORDER; i++ ) {
b_Q14_ptr[ i ] = SKP_LIMIT_32( ( SKP_int32 )b_Q14_ptr[ i ] + SKP_SMULWB( SKP_LSHIFT_SAT32( temp32, 4 ), delta_b_Q14[ i ] ), -16000, 28000 );
b_Q14_ptr[ i ] = SKP_LIMIT_32( ( opus_int32 )b_Q14_ptr[ i ] + SKP_SMULWB( SKP_LSHIFT_SAT32( temp32, 4 ), delta_b_Q14[ i ] ), -16000, 28000 );
}
b_Q14_ptr += LTP_ORDER;
}
......@@ -229,13 +229,13 @@ TOC(find_LTP_FIX)
}
void silk_fit_LTP(
SKP_int32 LTP_coefs_Q16[ LTP_ORDER ],
SKP_int16 LTP_coefs_Q14[ LTP_ORDER ]
opus_int32 LTP_coefs_Q16[ LTP_ORDER ],
opus_int16 LTP_coefs_Q14[ LTP_ORDER ]
)
{
SKP_int i;
opus_int i;
for( i = 0; i < LTP_ORDER; i++ ) {
LTP_coefs_Q14[ i ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( LTP_coefs_Q16[ i ], 2 ) );
LTP_coefs_Q14[ i ] = ( opus_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( LTP_coefs_Q16[ i ], 2 ) );
}
}
......@@ -32,18 +32,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
void silk_find_pitch_lags_FIX(
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
SKP_int16 res[], /* O residual */
const SKP_int16 x[] /* I Speech signal */
opus_int16 res[], /* O residual */
const opus_int16 x[] /* I Speech signal */
)
{
SKP_int buf_len, i, scale;
SKP_int32 thrhld_Q15, res_nrg;
const SKP_int16 *x_buf, *x_buf_ptr;
SKP_int16 Wsig[ FIND_PITCH_LPC_WIN_MAX ], *Wsig_ptr;
SKP_int32 auto_corr[ MAX_FIND_PITCH_LPC_ORDER + 1 ];
SKP_int16 rc_Q15[ MAX_FIND_PITCH_LPC_ORDER ];
SKP_int32 A_Q24[ MAX_FIND_PITCH_LPC_ORDER ];
SKP_int16 A_Q12[ MAX_FIND_PITCH_LPC_ORDER ];
opus_int buf_len, i, scale;
opus_int32 thrhld_Q15, res_nrg;
const opus_int16 *x_buf, *x_buf_ptr;
opus_int16 Wsig[ FIND_PITCH_LPC_WIN_MAX ], *Wsig_ptr;
opus_int32 auto_corr[ MAX_FIND_PITCH_LPC_ORDER + 1 ];
opus_int16 rc_Q15[ MAX_FIND_PITCH_LPC_ORDER ];
opus_int32 A_Q24[ MAX_FIND_PITCH_LPC_ORDER ];
opus_int16 A_Q12[ MAX_FIND_PITCH_LPC_ORDER ];
/******************************************/
/* Setup buffer lengths etc based on Fs */
......@@ -69,7 +69,7 @@ void silk_find_pitch_lags_FIX(
/* Middle un - windowed samples */
Wsig_ptr += psEnc->sCmn.la_pitch;
x_buf_ptr += psEnc->sCmn.la_pitch;
SKP_memcpy( Wsig_ptr, x_buf_ptr, ( psEnc->sCmn.pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 ) ) * sizeof( SKP_int16 ) );
SKP_memcpy( Wsig_ptr, x_buf_ptr, ( psEnc->sCmn.pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 ) ) * sizeof( opus_int16 ) );
/* Last LA_LTP samples */
Wsig_ptr += psEnc->sCmn.pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 );
......@@ -93,7 +93,7 @@ void silk_find_pitch_lags_FIX(
/* Convert From 32 bit Q24 to 16 bit Q12 coefs */
for( i = 0; i < psEnc->sCmn.pitchEstimationLPCOrder; i++ ) {
A_Q12[ i ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT( A_Q24[ i ], 12 ) );
A_Q12[ i ] = ( opus_int16 )SKP_SAT16( SKP_RSHIFT( A_Q24[ i ], 12 ) );
}
/* Do BWE */
......@@ -118,7 +118,7 @@ void silk_find_pitch_lags_FIX(
/*****************************************/
if( silk_pitch_analysis_core( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex, &psEnc->sCmn.indices.contourIndex,
&psEnc->LTPCorr_Q15, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16,
( SKP_int16 )thrhld_Q15, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr ) == 0 )
( opus_int16 )thrhld_Q15, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr ) == 0 )
{
psEnc->sCmn.indices.signalType = TYPE_VOICED;
} else {
......
......@@ -30,18 +30,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
void silk_find_pred_coefs_FIX(
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
const SKP_int16 res_pitch[], /* I Residual from pitch analysis */
const SKP_int16 x[] /* I Speech signal */
const opus_int16 res_pitch[], /* I Residual from pitch analysis */
const opus_int16 x[] /* I Speech signal */
)
{
SKP_int i;
SKP_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ];
SKP_int32 invGains_Q16[ MAX_NB_SUBFR ], local_gains[ MAX_NB_SUBFR ], Wght_Q15[ MAX_NB_SUBFR ];
SKP_int16 NLSF_Q15[ MAX_LPC_ORDER ];
const SKP_int16 *x_ptr;
SKP_int16 *x_pre_ptr, LPC_in_pre[ MAX_NB_SUBFR * MAX_LPC_ORDER + MAX_FRAME_LENGTH ];
SKP_int32 tmp, min_gain_Q16;
SKP_int LTP_corrs_rshift[ MAX_NB_SUBFR ];
opus_int i;
opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ];
opus_int32 invGains_Q16[ MAX_NB_SUBFR ], local_gains[ MAX_NB_SUBFR ], Wght_Q15[ MAX_NB_SUBFR ];
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ];
const opus_int16 *x_ptr;
opus_int16 *x_pre_ptr, LPC_in_pre[ MAX_NB_SUBFR * MAX_LPC_ORDER + MAX_FRAME_LENGTH ];
opus_int32 tmp, min_gain_Q16;
opus_int LTP_corrs_rshift[ MAX_NB_SUBFR ];
/* weighting for weighted least squares */
min_gain_Q16 = SKP_int32_MAX >> 6;
......@@ -102,7 +102,7 @@ void silk_find_pred_coefs_FIX(
x_ptr += psEnc->sCmn.subfr_length;
}
SKP_memset( psEncCtrl->LTPCoef_Q14, 0, psEnc->sCmn.nb_subfr * LTP_ORDER * sizeof( SKP_int16 ) );
SKP_memset( psEncCtrl->LTPCoef_Q14, 0, psEnc->sCmn.nb_subfr * LTP_ORDER * sizeof( opus_int16 ) );
psEncCtrl->LTPredCodGain_Q7 = 0;
}
......
This diff is collapsed.
......@@ -30,13 +30,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Compute gain to make warped filter coefficients have a zero mean log frequency response on a */
/* non-warped frequency scale. (So that it can be implemented with a minimum-phase monic filter.) */
SKP_INLINE SKP_int32 warped_gain( // gain in Q16
const SKP_int32 *coefs_Q24,
SKP_int lambda_Q16,
SKP_int order
SKP_INLINE opus_int32 warped_gain( // gain in Q16
const opus_int32 *coefs_Q24,
opus_int lambda_Q16,
opus_int order
) {
SKP_int i;
SKP_int32 gain_Q24;
opus_int i;
opus_int32 gain_Q24;
lambda_Q16 = -lambda_Q16;
gain_Q24 = coefs_Q24[ order - 1 ];
......@@ -50,15 +50,15 @@ SKP_INLINE SKP_int32 warped_gain( // gain in Q16
/* Convert warped filter coefficients to monic pseudo-warped coefficients and limit maximum */
/* amplitude of monic warped coefficients by using bandwidth expansion on the true coefficients */
SKP_INLINE void limit_warped_coefs(
SKP_int32 *coefs_syn_Q24,
SKP_int32 *coefs_ana_Q24,
SKP_int lambda_Q16,
SKP_int32 limit_Q24,
SKP_int order
opus_int32 *coefs_syn_Q24,
opus_int32 *coefs_ana_Q24,
opus_int lambda_Q16,
opus_int32 limit_Q24,
opus_int order
) {
SKP_int i, iter, ind = 0;
SKP_int32 tmp, maxabs_Q24, chirp_Q16, gain_syn_Q16, gain_ana_Q16;
SKP_int32 nom_Q16, den_Q24;
opus_int i, iter, ind = 0;
opus_int32 tmp, maxabs_Q24, chirp_Q16, gain_syn_Q16, gain_ana_Q16;
opus_int32 nom_Q16, den_Q24;
/* Convert to monic coefficients */
lambda_Q16 = -lambda_Q16;
......@@ -137,22 +137,22 @@ SKP_INLINE void limit_warped_coefs(
void silk_noise_shape_analysis_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
const SKP_int16 *pitch_res, /* I LPC residual from pitch analysis */