mirror of
https://github.com/xiph/opus.git
synced 2025-05-29 06:39:15 +00:00
Renamed SKP_[u]int* to opus_[u]int*
This commit is contained in:
parent
d77d6a58fc
commit
f9d14f8d77
164 changed files with 3297 additions and 3298 deletions
|
@ -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;
|
||||
opus_int i, k, lshift;
|
||||
const opus_int16 *r_ptr, *lag_ptr;
|
||||
opus_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;
|
||||
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;
|
||||
|
||||
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_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;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,13 +53,13 @@ extern "C"
|
|||
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
|
||||
void silk_HP_variable_cutoff(
|
||||
silk_encoder_state_Fxx state_Fxx[], /* I/O Encoder states */
|
||||
const SKP_int nChannels /* I Number of channels */
|
||||
const opus_int nChannels /* I Number of channels */
|
||||
);
|
||||
|
||||
/* Encoder main function */
|
||||
SKP_int silk_encode_frame_FIX(
|
||||
opus_int silk_encode_frame_FIX(
|
||||
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
|
||||
SKP_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */
|
||||
opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */
|
||||
ec_enc *psRangeEnc /* I/O compressor data structure */
|
||||
);
|
||||
|
||||
|
@ -67,21 +67,21 @@ SKP_int silk_encode_frame_FIX(
|
|||
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 */
|
||||
);
|
||||
|
||||
/* Initializes the Silk encoder state */
|
||||
SKP_int silk_init_encoder(
|
||||
opus_int silk_init_encoder(
|
||||
silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */
|
||||
);
|
||||
|
||||
/* Control the Silk encoder */
|
||||
SKP_int silk_control_encoder(
|
||||
opus_int silk_control_encoder(
|
||||
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk encoder state */
|
||||
silk_EncControlStruct *encControl, /* I: Control structure */
|
||||
const SKP_int32 TargetRate_bps, /* I Target max bitrate (bps) */
|
||||
const SKP_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
|
||||
const SKP_int channelNb /* I Channel number */
|
||||
const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */
|
||||
const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
|
||||
const opus_int channelNb /* I Channel number */
|
||||
);
|
||||
|
||||
/****************/
|
||||
|
@ -90,8 +90,8 @@ SKP_int silk_control_encoder(
|
|||
void silk_prefilter_FIX(
|
||||
silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
|
||||
const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */
|
||||
SKP_int16 xw[], /* O Weighted signal */
|
||||
const SKP_int16 x[] /* I Speech signal */
|
||||
opus_int16 xw[], /* O Weighted signal */
|
||||
const opus_int16 x[] /* I Speech signal */
|
||||
);
|
||||
|
||||
/**************************/
|
||||
|
@ -101,18 +101,18 @@ void silk_prefilter_FIX(
|
|||
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 */
|
||||
const SKP_int16 *x /* I Input signal [ frame_length + la_shape ] */
|
||||
const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */
|
||||
const opus_int16 *x /* I Input signal [ frame_length + la_shape ] */
|
||||
);
|
||||
|
||||
/* Autocorrelations for a warped frequency axis */
|
||||
void silk_warped_autocorrelation_FIX(
|
||||
SKP_int32 *corr, /* O Result [order + 1] */
|
||||
SKP_int *scale, /* O Scaling of the correlation vector */
|
||||
const SKP_int16 *input, /* I Input data to correlate */
|
||||
const SKP_int warping_Q16, /* I Warping coefficient */
|
||||
const SKP_int length, /* I Length of input */
|
||||
const SKP_int order /* I Correlation order (even) */
|
||||
opus_int32 *corr, /* O Result [order + 1] */
|
||||
opus_int *scale, /* O Scaling of the correlation vector */
|
||||
const opus_int16 *input, /* I Input data to correlate */
|
||||
const opus_int warping_Q16, /* I Warping coefficient */
|
||||
const opus_int length, /* I Length of input */
|
||||
const opus_int order /* I Correlation order (even) */
|
||||
);
|
||||
|
||||
/* Calculation of LTP state scaling */
|
||||
|
@ -128,77 +128,77 @@ void silk_LTP_scale_ctrl_FIX(
|
|||
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 */
|
||||
);
|
||||
|
||||
/* Find LPC and LTP coefficients */
|
||||
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 */
|
||||
);
|
||||
|
||||
/* LPC analysis */
|
||||
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 */
|
||||
);
|
||||
|
||||
/* LTP analysis */
|
||||
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 */
|
||||
);
|
||||
|
||||
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 */
|
||||
);
|
||||
|
||||
/* Calculates residual energies of input subframes where all subframes have LPC_order */
|
||||
/* of preceeding samples */
|
||||
void silk_residual_energy_FIX(
|
||||
SKP_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
|
||||
SKP_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
|
||||
const SKP_int16 x[], /* I Input signal */
|
||||
SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
|
||||
const SKP_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
|
||||
const SKP_int subfr_length, /* I Subframe length */
|
||||
const SKP_int nb_subfr, /* I Number of subframes */
|
||||
const SKP_int LPC_order /* I LPC order */
|
||||
opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
|
||||
opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
|
||||
const opus_int16 x[], /* I Input signal */
|
||||
opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
|
||||
const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
|
||||
const opus_int subfr_length, /* I Subframe length */
|
||||
const opus_int nb_subfr, /* I Number of subframes */
|
||||
const opus_int LPC_order /* I LPC order */
|
||||
);
|
||||
|
||||
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
|
||||
SKP_int32 silk_residual_energy16_covar_FIX(
|
||||
const SKP_int16 *c, /* I Prediction vector */
|
||||
const SKP_int32 *wXX, /* I Correlation matrix */
|
||||
const SKP_int32 *wXx, /* I Correlation vector */
|
||||
SKP_int32 wxx, /* I Signal energy */
|
||||
SKP_int D, /* I Dimension */
|
||||
SKP_int cQ /* I Q value for c vector 0 - 15 */
|
||||
opus_int32 silk_residual_energy16_covar_FIX(
|
||||
const opus_int16 *c, /* I Prediction vector */
|
||||
const opus_int32 *wXX, /* I Correlation matrix */
|
||||
const opus_int32 *wXx, /* I Correlation vector */
|
||||
opus_int32 wxx, /* I Signal energy */
|
||||
opus_int D, /* I Dimension */
|
||||
opus_int cQ /* I Q value for c vector 0 - 15 */
|
||||
);
|
||||
|
||||
/* Processing of gains */
|
||||
|
@ -212,38 +212,38 @@ void silk_process_gains_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 */
|
||||
);
|
||||
|
||||
/* 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 */
|
||||
);
|
||||
|
||||
/* Add noise to matrix diagonal */
|
||||
void silk_regularize_correlations_FIX(
|
||||
SKP_int32 *XX, /* I/O Correlation matrices */
|
||||
SKP_int32 *xx, /* I/O Correlation values */
|
||||
SKP_int32 noise, /* I Noise to add */
|
||||
SKP_int D /* I Dimension of XX */
|
||||
opus_int32 *XX, /* I/O Correlation matrices */
|
||||
opus_int32 *xx, /* I/O Correlation values */
|
||||
opus_int32 noise, /* I Noise to add */
|
||||
opus_int D /* I Dimension of XX */
|
||||
);
|
||||
|
||||
/* Solves Ax = b, assuming A is symmetric */
|
||||
void silk_solve_LDL_FIX(
|
||||
SKP_int32 *A, /* I Pointer to symetric square matrix A */
|
||||
SKP_int M, /* I Size of matrix */
|
||||
const SKP_int32 *b, /* I Pointer to b vector */
|
||||
SKP_int32 *x_Q16 /* O Pointer to x solution vector */
|
||||
opus_int32 *A, /* I Pointer to symetric square matrix A */
|
||||
opus_int M, /* I Size of matrix */
|
||||
const opus_int32 *b, /* I Pointer to b vector */
|
||||
opus_int32 *x_Q16 /* O Pointer to x solution vector */
|
||||
);
|
||||
|
||||
#ifndef FORCE_CPP_BUILD
|
||||
|
|
|
@ -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 */
|
||||
const SKP_int16 *x /* I Input signal [ frame_length + la_shape ] */
|
||||
const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */
|
||||
const opus_int16 *x /* I Input signal [ frame_length + la_shape ] */
|
||||
)
|
||||
{
|
||||
silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
|
||||
SKP_int k, i, nSamples, Qnrg, b_Q14, warping_Q16, scale = 0;
|
||||
SKP_int32 SNR_adj_dB_Q7, HarmBoost_Q16, HarmShapeGain_Q16, Tilt_Q16, tmp32;
|
||||
SKP_int32 nrg, pre_nrg_Q30, log_energy_Q7, log_energy_prev_Q7, energy_variation_Q7;
|
||||
SKP_int32 delta_Q16, BWExp1_Q16, BWExp2_Q16, gain_mult_Q16, gain_add_Q16, strength_Q16, b_Q8;
|
||||
SKP_int32 auto_corr[ MAX_SHAPE_LPC_ORDER + 1 ];
|
||||
SKP_int32 refl_coef_Q16[ MAX_SHAPE_LPC_ORDER ];
|
||||
SKP_int32 AR1_Q24[ MAX_SHAPE_LPC_ORDER ];
|
||||
SKP_int32 AR2_Q24[ MAX_SHAPE_LPC_ORDER ];
|
||||
SKP_int16 x_windowed[ SHAPE_LPC_WIN_MAX ];
|
||||
SKP_int32 sqrt_nrg[ MAX_NB_SUBFR ], Qnrg_vec[ MAX_NB_SUBFR ];
|
||||
const SKP_int16 *x_ptr, *pitch_res_ptr;
|
||||
opus_int k, i, nSamples, Qnrg, b_Q14, warping_Q16, scale = 0;
|
||||
opus_int32 SNR_adj_dB_Q7, HarmBoost_Q16, HarmShapeGain_Q16, Tilt_Q16, tmp32;
|
||||
opus_int32 nrg, pre_nrg_Q30, log_energy_Q7, log_energy_prev_Q7, energy_variation_Q7;
|
||||
opus_int32 delta_Q16, BWExp1_Q16, BWExp2_Q16, gain_mult_Q16, gain_add_Q16, strength_Q16, b_Q8;
|
||||
opus_int32 auto_corr[ MAX_SHAPE_LPC_ORDER + 1 ];
|
||||
opus_int32 refl_coef_Q16[ MAX_SHAPE_LPC_ORDER ];
|
||||
opus_int32 AR1_Q24[ MAX_SHAPE_LPC_ORDER ];
|
||||
opus_int32 AR2_Q24[ MAX_SHAPE_LPC_ORDER ];
|
||||
opus_int16 x_windowed[ SHAPE_LPC_WIN_MAX ];
|
||||
opus_int32 sqrt_nrg[ MAX_NB_SUBFR ], Qnrg_vec[ MAX_NB_SUBFR ];
|
||||
const opus_int16 *x_ptr, *pitch_res_ptr;
|
||||
|
||||
/* Point to start of first LPC analysis block */
|
||||
x_ptr = x - psEnc->sCmn.la_shape;
|
||||
|
@ -163,7 +163,7 @@ void silk_noise_shape_analysis_FIX(
|
|||
SNR_adj_dB_Q7 = psEnc->sCmn.SNR_dB_Q7;
|
||||
|
||||
/* Input quality is the average of the quality in the lowest two VAD bands */
|
||||
psEncCtrl->input_quality_Q14 = ( SKP_int )SKP_RSHIFT( ( SKP_int32 )psEnc->sCmn.input_quality_bands_Q15[ 0 ]
|
||||
psEncCtrl->input_quality_Q14 = ( opus_int )SKP_RSHIFT( ( opus_int32 )psEnc->sCmn.input_quality_bands_Q15[ 0 ]
|
||||
+ psEnc->sCmn.input_quality_bands_Q15[ 1 ], 2 );
|
||||
|
||||
/* Coding quality level, between 0.0_Q0 and 1.0_Q0, but in Q14 */
|
||||
|
@ -255,13 +255,13 @@ void silk_noise_shape_analysis_FIX(
|
|||
/********************************************/
|
||||
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
|
||||
/* Apply window: sine slope followed by flat part followed by cosine slope */
|
||||
SKP_int shift, slope_part, flat_part;
|
||||
opus_int shift, slope_part, flat_part;
|
||||
flat_part = psEnc->sCmn.fs_kHz * 3;
|
||||
slope_part = SKP_RSHIFT( psEnc->sCmn.shapeWinLength - flat_part, 1 );
|
||||
|
||||
silk_apply_sine_window( x_windowed, x_ptr, 1, slope_part );
|
||||
shift = slope_part;
|
||||
SKP_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(SKP_int16) );
|
||||
SKP_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(opus_int16) );
|
||||
shift += flat_part;
|
||||
silk_apply_sine_window( x_windowed + shift, x_ptr + shift, 2, slope_part );
|
||||
|
||||
|
@ -319,7 +319,7 @@ void silk_noise_shape_analysis_FIX(
|
|||
silk_bwexpander_32( AR2_Q24, psEnc->sCmn.shapingLPCOrder, BWExp2_Q16 );
|
||||
|
||||
/* Compute noise shaping filter coefficients */
|
||||
SKP_memcpy( AR1_Q24, AR2_Q24, psEnc->sCmn.shapingLPCOrder * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( AR1_Q24, AR2_Q24, psEnc->sCmn.shapingLPCOrder * sizeof( opus_int32 ) );
|
||||
|
||||
/* Bandwidth expansion for analysis filter shaping */
|
||||
SKP_assert( BWExp1_Q16 <= SILK_FIX_CONST( 1.0, 16 ) );
|
||||
|
@ -331,15 +331,15 @@ void silk_noise_shape_analysis_FIX(
|
|||
|
||||
//psEncCtrl->GainsPre[ k ] = 1.0f - 0.7f * ( 1.0f - pre_nrg / nrg ) = 0.3f + 0.7f * pre_nrg / nrg;
|
||||
pre_nrg_Q30 = SKP_LSHIFT32( SKP_SMULWB( pre_nrg_Q30, SILK_FIX_CONST( 0.7, 15 ) ), 1 );
|
||||
psEncCtrl->GainsPre_Q14[ k ] = ( SKP_int ) SILK_FIX_CONST( 0.3, 14 ) + silk_DIV32_varQ( pre_nrg_Q30, nrg, 14 );
|
||||
psEncCtrl->GainsPre_Q14[ k ] = ( opus_int ) SILK_FIX_CONST( 0.3, 14 ) + silk_DIV32_varQ( pre_nrg_Q30, nrg, 14 );
|
||||
|
||||
/* Convert to monic warped prediction coefficients and limit absolute values */
|
||||
limit_warped_coefs( AR2_Q24, AR1_Q24, warping_Q16, SILK_FIX_CONST( 3.999, 24 ), psEnc->sCmn.shapingLPCOrder );
|
||||
|
||||
/* Convert from Q24 to Q13 and store in int16 */
|
||||
for( i = 0; i < psEnc->sCmn.shapingLPCOrder; i++ ) {
|
||||
psEncCtrl->AR1_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( AR1_Q24[ i ], 11 ) );
|
||||
psEncCtrl->AR2_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( AR2_Q24[ i ], 11 ) );
|
||||
psEncCtrl->AR1_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (opus_int16)SKP_SAT16( SKP_RSHIFT_ROUND( AR1_Q24[ i ], 11 ) );
|
||||
psEncCtrl->AR2_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (opus_int16)SKP_SAT16( SKP_RSHIFT_ROUND( AR2_Q24[ i ], 11 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,14 +372,14 @@ void silk_noise_shape_analysis_FIX(
|
|||
if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {
|
||||
/* Reduce low frequencies quantization noise for periodic signals, depending on pitch lag */
|
||||
/*f = 400; freqz([1, -0.98 + 2e-4 * f], [1, -0.97 + 7e-4 * f], 2^12, Fs); axis([0, 1000, -10, 1])*/
|
||||
SKP_int fs_kHz_inv = SKP_DIV32_16( SILK_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz );
|
||||
opus_int fs_kHz_inv = SKP_DIV32_16( SILK_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz );
|
||||
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
|
||||
b_Q14 = fs_kHz_inv + SKP_DIV32_16( SILK_FIX_CONST( 3.0, 14 ), psEncCtrl->pitchL[ k ] );
|
||||
/* Pack two coefficients in one int32 */
|
||||
psEncCtrl->LF_shp_Q14[ k ] = SKP_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 - SKP_SMULWB( strength_Q16, b_Q14 ), 16 );
|
||||
psEncCtrl->LF_shp_Q14[ k ] |= (SKP_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) );
|
||||
psEncCtrl->LF_shp_Q14[ k ] |= (opus_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) );
|
||||
}
|
||||
SKP_assert( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ) < SILK_FIX_CONST( 0.5, 24 ) ); // Guarantees that second argument to SMULWB() is within range of an SKP_int16
|
||||
SKP_assert( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ) < SILK_FIX_CONST( 0.5, 24 ) ); // Guarantees that second argument to SMULWB() is within range of an opus_int16
|
||||
Tilt_Q16 = - SILK_FIX_CONST( HP_NOISE_COEF, 16 ) -
|
||||
SKP_SMULWB( SILK_FIX_CONST( 1.0, 16 ) - SILK_FIX_CONST( HP_NOISE_COEF, 16 ),
|
||||
SKP_SMULWB( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->sCmn.speech_activity_Q8 ) );
|
||||
|
@ -388,7 +388,7 @@ void silk_noise_shape_analysis_FIX(
|
|||
/* Pack two coefficients in one int32 */
|
||||
psEncCtrl->LF_shp_Q14[ 0 ] = SKP_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 -
|
||||
SKP_SMULWB( strength_Q16, SKP_SMULWB( SILK_FIX_CONST( 0.6, 16 ), b_Q14 ) ), 16 );
|
||||
psEncCtrl->LF_shp_Q14[ 0 ] |= (SKP_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) );
|
||||
psEncCtrl->LF_shp_Q14[ 0 ] |= (opus_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) );
|
||||
for( k = 1; k < psEnc->sCmn.nb_subfr; k++ ) {
|
||||
psEncCtrl->LF_shp_Q14[ k ] = psEncCtrl->LF_shp_Q14[ 0 ];
|
||||
}
|
||||
|
@ -430,8 +430,8 @@ void silk_noise_shape_analysis_FIX(
|
|||
psShapeSt->Tilt_smth_Q16 =
|
||||
SKP_SMLAWB( psShapeSt->Tilt_smth_Q16, Tilt_Q16 - psShapeSt->Tilt_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );
|
||||
|
||||
psEncCtrl->HarmBoost_Q14[ k ] = ( SKP_int )SKP_RSHIFT_ROUND( psShapeSt->HarmBoost_smth_Q16, 2 );
|
||||
psEncCtrl->HarmShapeGain_Q14[ k ] = ( SKP_int )SKP_RSHIFT_ROUND( psShapeSt->HarmShapeGain_smth_Q16, 2 );
|
||||
psEncCtrl->Tilt_Q14[ k ] = ( SKP_int )SKP_RSHIFT_ROUND( psShapeSt->Tilt_smth_Q16, 2 );
|
||||
psEncCtrl->HarmBoost_Q14[ k ] = ( opus_int )SKP_RSHIFT_ROUND( psShapeSt->HarmBoost_smth_Q16, 2 );
|
||||
psEncCtrl->HarmShapeGain_Q14[ k ] = ( opus_int )SKP_RSHIFT_ROUND( psShapeSt->HarmShapeGain_smth_Q16, 2 );
|
||||
psEncCtrl->Tilt_Q14[ k ] = ( opus_int )SKP_RSHIFT_ROUND( psShapeSt->Tilt_smth_Q16, 2 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,27 +31,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/* silk_prefilter. Prefilter for finding Quantizer input signal */
|
||||
SKP_INLINE void silk_prefilt_FIX(
|
||||
silk_prefilter_state_FIX *P, /* I/O state */
|
||||
SKP_int32 st_res_Q12[], /* I short term residual signal */
|
||||
SKP_int16 xw[], /* O prefiltered signal */
|
||||
SKP_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */
|
||||
SKP_int Tilt_Q14, /* I Tilt shaping coeficient */
|
||||
SKP_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients*/
|
||||
SKP_int lag, /* I Lag for harmonic shaping */
|
||||
SKP_int length /* I Length of signals */
|
||||
opus_int32 st_res_Q12[], /* I short term residual signal */
|
||||
opus_int16 xw[], /* O prefiltered signal */
|
||||
opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */
|
||||
opus_int Tilt_Q14, /* I Tilt shaping coeficient */
|
||||
opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients*/
|
||||
opus_int lag, /* I Lag for harmonic shaping */
|
||||
opus_int length /* I Length of signals */
|
||||
);
|
||||
|
||||
void silk_warped_LPC_analysis_filter_FIX(
|
||||
SKP_int32 state[], /* I/O State [order + 1] */
|
||||
SKP_int16 res[], /* O Residual signal [length] */
|
||||
const SKP_int16 coef_Q13[], /* I Coefficients [order] */
|
||||
const SKP_int16 input[], /* I Input signal [length] */
|
||||
const SKP_int16 lambda_Q16, /* I Warping factor */
|
||||
const SKP_int length, /* I Length of input signal */
|
||||
const SKP_int order /* I Filter order (even) */
|
||||
opus_int32 state[], /* I/O State [order + 1] */
|
||||
opus_int16 res[], /* O Residual signal [length] */
|
||||
const opus_int16 coef_Q13[], /* I Coefficients [order] */
|
||||
const opus_int16 input[], /* I Input signal [length] */
|
||||
const opus_int16 lambda_Q16, /* I Warping factor */
|
||||
const opus_int length, /* I Length of input signal */
|
||||
const opus_int order /* I Filter order (even) */
|
||||
)
|
||||
{
|
||||
SKP_int n, i;
|
||||
SKP_int32 acc_Q11, tmp1, tmp2;
|
||||
opus_int n, i;
|
||||
opus_int32 acc_Q11, tmp1, tmp2;
|
||||
|
||||
/* Order must be even */
|
||||
SKP_assert( ( order & 1 ) == 0 );
|
||||
|
@ -77,28 +77,28 @@ void silk_warped_LPC_analysis_filter_FIX(
|
|||
}
|
||||
state[ order ] = tmp1;
|
||||
acc_Q11 = SKP_SMLAWB( acc_Q11, tmp1, coef_Q13[ order - 1 ] );
|
||||
res[ n ] = ( SKP_int16 )SKP_SAT16( ( SKP_int32 )input[ n ] - SKP_RSHIFT_ROUND( acc_Q11, 11 ) );
|
||||
res[ n ] = ( opus_int16 )SKP_SAT16( ( opus_int32 )input[ n ] - SKP_RSHIFT_ROUND( acc_Q11, 11 ) );
|
||||
}
|
||||
}
|
||||
|
||||
void silk_prefilter_FIX(
|
||||
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
|
||||
const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control FIX */
|
||||
SKP_int16 xw[], /* O Weighted signal */
|
||||
const SKP_int16 x[] /* I Speech signal */
|
||||
opus_int16 xw[], /* O Weighted signal */
|
||||
const opus_int16 x[] /* I Speech signal */
|
||||
)
|
||||
{
|
||||
silk_prefilter_state_FIX *P = &psEnc->sPrefilt;
|
||||
SKP_int j, k, lag;
|
||||
SKP_int32 tmp_32;
|
||||
const SKP_int16 *AR1_shp_Q13;
|
||||
const SKP_int16 *px;
|
||||
SKP_int16 *pxw;
|
||||
SKP_int HarmShapeGain_Q12, Tilt_Q14;
|
||||
SKP_int32 HarmShapeFIRPacked_Q12, LF_shp_Q14;
|
||||
SKP_int32 x_filt_Q12[ MAX_FRAME_LENGTH / MAX_NB_SUBFR ];
|
||||
SKP_int16 st_res[ ( MAX_FRAME_LENGTH / MAX_NB_SUBFR ) + MAX_LPC_ORDER ];
|
||||
SKP_int16 B_Q12[ 2 ];
|
||||
opus_int j, k, lag;
|
||||
opus_int32 tmp_32;
|
||||
const opus_int16 *AR1_shp_Q13;
|
||||
const opus_int16 *px;
|
||||
opus_int16 *pxw;
|
||||
opus_int HarmShapeGain_Q12, Tilt_Q14;
|
||||
opus_int32 HarmShapeFIRPacked_Q12, LF_shp_Q14;
|
||||
opus_int32 x_filt_Q12[ MAX_FRAME_LENGTH / MAX_NB_SUBFR ];
|
||||
opus_int16 st_res[ ( MAX_FRAME_LENGTH / MAX_NB_SUBFR ) + MAX_LPC_ORDER ];
|
||||
opus_int16 B_Q12[ 2 ];
|
||||
|
||||
/* Setup pointers */
|
||||
px = x;
|
||||
|
@ -114,7 +114,7 @@ void silk_prefilter_FIX(
|
|||
HarmShapeGain_Q12 = SKP_SMULWB( psEncCtrl->HarmShapeGain_Q14[ k ], 16384 - psEncCtrl->HarmBoost_Q14[ k ] );
|
||||
SKP_assert( HarmShapeGain_Q12 >= 0 );
|
||||
HarmShapeFIRPacked_Q12 = SKP_RSHIFT( HarmShapeGain_Q12, 2 );
|
||||
HarmShapeFIRPacked_Q12 |= SKP_LSHIFT( ( SKP_int32 )SKP_RSHIFT( HarmShapeGain_Q12, 1 ), 16 );
|
||||
HarmShapeFIRPacked_Q12 |= SKP_LSHIFT( ( opus_int32 )SKP_RSHIFT( HarmShapeGain_Q12, 1 ), 16 );
|
||||
Tilt_Q14 = psEncCtrl->Tilt_Q14[ k ];
|
||||
LF_shp_Q14 = psEncCtrl->LF_shp_Q14[ k ];
|
||||
AR1_shp_Q13 = &psEncCtrl->AR1_Q13[ k * MAX_SHAPE_LPC_ORDER ];
|
||||
|
@ -150,19 +150,19 @@ void silk_prefilter_FIX(
|
|||
/* silk_prefilter. Prefilter for finding Quantizer input signal */
|
||||
SKP_INLINE void silk_prefilt_FIX(
|
||||
silk_prefilter_state_FIX *P, /* I/O state */
|
||||
SKP_int32 st_res_Q12[], /* I short term residual signal */
|
||||
SKP_int16 xw[], /* O prefiltered signal */
|
||||
SKP_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */
|
||||
SKP_int Tilt_Q14, /* I Tilt shaping coeficient */
|
||||
SKP_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients*/
|
||||
SKP_int lag, /* I Lag for harmonic shaping */
|
||||
SKP_int length /* I Length of signals */
|
||||
opus_int32 st_res_Q12[], /* I short term residual signal */
|
||||
opus_int16 xw[], /* O prefiltered signal */
|
||||
opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */
|
||||
opus_int Tilt_Q14, /* I Tilt shaping coeficient */
|
||||
opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients*/
|
||||
opus_int lag, /* I Lag for harmonic shaping */
|
||||
opus_int length /* I Length of signals */
|
||||
)
|
||||
{
|
||||
SKP_int i, idx, LTP_shp_buf_idx;
|
||||
SKP_int32 n_LTP_Q12, n_Tilt_Q10, n_LF_Q10;
|
||||
SKP_int32 sLF_MA_shp_Q12, sLF_AR_shp_Q12;
|
||||
SKP_int16 *LTP_shp_buf;
|
||||
opus_int i, idx, LTP_shp_buf_idx;
|
||||
opus_int32 n_LTP_Q12, n_Tilt_Q10, n_LF_Q10;
|
||||
opus_int32 sLF_MA_shp_Q12, sLF_AR_shp_Q12;
|
||||
opus_int16 *LTP_shp_buf;
|
||||
|
||||
/* To speed up use temp variables instead of using the struct */
|
||||
LTP_shp_buf = P->sLTP_shp;
|
||||
|
@ -189,9 +189,9 @@ SKP_INLINE void silk_prefilt_FIX(
|
|||
sLF_MA_shp_Q12 = SKP_SUB32( sLF_AR_shp_Q12, SKP_LSHIFT( n_LF_Q10, 2 ) );
|
||||
|
||||
LTP_shp_buf_idx = ( LTP_shp_buf_idx - 1 ) & LTP_MASK;
|
||||
LTP_shp_buf[ LTP_shp_buf_idx ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( sLF_MA_shp_Q12, 12 ) );
|
||||
LTP_shp_buf[ LTP_shp_buf_idx ] = ( opus_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( sLF_MA_shp_Q12, 12 ) );
|
||||
|
||||
xw[i] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SUB32( sLF_MA_shp_Q12, n_LTP_Q12 ), 12 ) );
|
||||
xw[i] = ( opus_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SUB32( sLF_MA_shp_Q12, n_LTP_Q12 ), 12 ) );
|
||||
}
|
||||
|
||||
/* Copy temp variable back to state */
|
||||
|
|
|
@ -35,8 +35,8 @@ void silk_process_gains_FIX(
|
|||
)
|
||||
{
|
||||
silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
|
||||
SKP_int k;
|
||||
SKP_int32 s_Q16, InvMaxSqrVal_Q16, gain, gain_squared, ResNrg, ResNrgPart, quant_offset_Q10;
|
||||
opus_int k;
|
||||
opus_int32 s_Q16, InvMaxSqrVal_Q16, gain, gain_squared, ResNrg, ResNrgPart, quant_offset_Q10;
|
||||
|
||||
/* Gain reduction when LTP coding gain is high */
|
||||
if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {
|
||||
|
|
|
@ -29,13 +29,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Add noise to matrix diagonal */
|
||||
void silk_regularize_correlations_FIX(
|
||||
SKP_int32 *XX, /* I/O Correlation matrices */
|
||||
SKP_int32 *xx, /* I/O Correlation values */
|
||||
SKP_int32 noise, /* I Noise to add */
|
||||
SKP_int D /* I Dimension of XX */
|
||||
opus_int32 *XX, /* I/O Correlation matrices */
|
||||
opus_int32 *xx, /* I/O Correlation values */
|
||||
opus_int32 noise, /* I Noise to add */
|
||||
opus_int D /* I Dimension of XX */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
opus_int i;
|
||||
for( i = 0; i < D; i++ ) {
|
||||
matrix_ptr( &XX[ 0 ], i, i, D ) = SKP_ADD32( matrix_ptr( &XX[ 0 ], i, i, D ), noise );
|
||||
}
|
||||
|
|
|
@ -28,19 +28,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "silk_main_FIX.h"
|
||||
|
||||
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
|
||||
SKP_int32 silk_residual_energy16_covar_FIX(
|
||||
const SKP_int16 *c, /* I Prediction vector */
|
||||
const SKP_int32 *wXX, /* I Correlation matrix */
|
||||
const SKP_int32 *wXx, /* I Correlation vector */
|
||||
SKP_int32 wxx, /* I Signal energy */
|
||||
SKP_int D, /* I Dimension */
|
||||
SKP_int cQ /* I Q value for c vector 0 - 15 */
|
||||
opus_int32 silk_residual_energy16_covar_FIX(
|
||||
const opus_int16 *c, /* I Prediction vector */
|
||||
const opus_int32 *wXX, /* I Correlation matrix */
|
||||
const opus_int32 *wXx, /* I Correlation vector */
|
||||
opus_int32 wxx, /* I Signal energy */
|
||||
opus_int D, /* I Dimension */
|
||||
opus_int cQ /* I Q value for c vector 0 - 15 */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, lshifts, Qxtra;
|
||||
SKP_int32 c_max, w_max, tmp, tmp2, nrg;
|
||||
SKP_int cn[ MAX_MATRIX_SIZE ];
|
||||
const SKP_int32 *pRow;
|
||||
opus_int i, j, lshifts, Qxtra;
|
||||
opus_int32 c_max, w_max, tmp, tmp2, nrg;
|
||||
opus_int cn[ MAX_MATRIX_SIZE ];
|
||||
const opus_int32 *pRow;
|
||||
|
||||
/* Safety checks */
|
||||
SKP_assert( D >= 0 );
|
||||
|
@ -53,7 +53,7 @@ SKP_int32 silk_residual_energy16_covar_FIX(
|
|||
|
||||
c_max = 0;
|
||||
for( i = 0; i < D; i++ ) {
|
||||
c_max = SKP_max_32( c_max, SKP_abs( ( SKP_int32 )c[ i ] ) );
|
||||
c_max = SKP_max_32( c_max, SKP_abs( ( opus_int32 )c[ i ] ) );
|
||||
}
|
||||
Qxtra = SKP_min_int( Qxtra, silk_CLZ32( c_max ) - 17 );
|
||||
|
||||
|
@ -61,7 +61,7 @@ SKP_int32 silk_residual_energy16_covar_FIX(
|
|||
Qxtra = SKP_min_int( Qxtra, silk_CLZ32( SKP_MUL( D, SKP_RSHIFT( SKP_SMULWB( w_max, c_max ), 4 ) ) ) - 5 );
|
||||
Qxtra = SKP_max_int( Qxtra, 0 );
|
||||
for( i = 0; i < D; i++ ) {
|
||||
cn[ i ] = SKP_LSHIFT( ( SKP_int )c[ i ], Qxtra );
|
||||
cn[ i ] = SKP_LSHIFT( ( opus_int )c[ i ], Qxtra );
|
||||
SKP_assert( SKP_abs(cn[i]) <= ( SKP_int16_MAX + 1 ) ); /* Check that SKP_SMLAWB can be used */
|
||||
}
|
||||
lshifts -= Qxtra;
|
||||
|
|
|
@ -30,20 +30,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/* Calculates residual energies of input subframes where all subframes have LPC_order */
|
||||
/* of preceeding samples */
|
||||
void silk_residual_energy_FIX(
|
||||
SKP_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
|
||||
SKP_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
|
||||
const SKP_int16 x[], /* I Input signal */
|
||||
SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
|
||||
const SKP_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
|
||||
const SKP_int subfr_length, /* I Subframe length */
|
||||
const SKP_int nb_subfr, /* I Number of subframes */
|
||||
const SKP_int LPC_order /* I LPC order */
|
||||
opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
|
||||
opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
|
||||
const opus_int16 x[], /* I Input signal */
|
||||
opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
|
||||
const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
|
||||
const opus_int subfr_length, /* I Subframe length */
|
||||
const opus_int nb_subfr, /* I Number of subframes */
|
||||
const opus_int LPC_order /* I LPC order */
|
||||
)
|
||||
{
|
||||
SKP_int offset, i, j, rshift, lz1, lz2;
|
||||
SKP_int16 *LPC_res_ptr, LPC_res[ ( MAX_FRAME_LENGTH + MAX_NB_SUBFR * MAX_LPC_ORDER ) / 2 ];
|
||||
const SKP_int16 *x_ptr;
|
||||
SKP_int32 tmp32;
|
||||
opus_int offset, i, j, rshift, lz1, lz2;
|
||||
opus_int16 *LPC_res_ptr, LPC_res[ ( MAX_FRAME_LENGTH + MAX_NB_SUBFR * MAX_LPC_ORDER ) / 2 ];
|
||||
const opus_int16 *x_ptr;
|
||||
opus_int32 tmp32;
|
||||
|
||||
x_ptr = x;
|
||||
offset = LPC_order + subfr_length;
|
||||
|
|
|
@ -33,50 +33,50 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/*****************************/
|
||||
|
||||
typedef struct {
|
||||
SKP_int32 Q36_part;
|
||||
SKP_int32 Q48_part;
|
||||
opus_int32 Q36_part;
|
||||
opus_int32 Q48_part;
|
||||
} inv_D_t;
|
||||
|
||||
/* Factorize square matrix A into LDL form */
|
||||
SKP_INLINE void silk_LDL_factorize_FIX(
|
||||
SKP_int32 *A, /* I/O Pointer to Symetric Square Matrix */
|
||||
SKP_int M, /* I Size of Matrix */
|
||||
SKP_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */
|
||||
opus_int32 *A, /* I/O Pointer to Symetric Square Matrix */
|
||||
opus_int M, /* I Size of Matrix */
|
||||
opus_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */
|
||||
inv_D_t *inv_D /* I/O Pointer to vector holding inverted diagonal elements of D */
|
||||
);
|
||||
|
||||
/* Solve Lx = b, when L is lower triangular and has ones on the diagonal */
|
||||
SKP_INLINE void silk_LS_SolveFirst_FIX(
|
||||
const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||
SKP_int M, /* I Dim of Matrix equation */
|
||||
const SKP_int32 *b, /* I b Vector */
|
||||
SKP_int32 *x_Q16 /* O x Vector */
|
||||
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||
opus_int M, /* I Dim of Matrix equation */
|
||||
const opus_int32 *b, /* I b Vector */
|
||||
opus_int32 *x_Q16 /* O x Vector */
|
||||
);
|
||||
|
||||
/* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */
|
||||
SKP_INLINE void silk_LS_SolveLast_FIX(
|
||||
const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||
const SKP_int M, /* I Dim of Matrix equation */
|
||||
const SKP_int32 *b, /* I b Vector */
|
||||
SKP_int32 *x_Q16 /* O x Vector */
|
||||
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||
const opus_int M, /* I Dim of Matrix equation */
|
||||
const opus_int32 *b, /* I b Vector */
|
||||
opus_int32 *x_Q16 /* O x Vector */
|
||||
);
|
||||
|
||||
SKP_INLINE void silk_LS_divide_Q16_FIX(
|
||||
SKP_int32 T[], /* I/O Numenator vector */
|
||||
opus_int32 T[], /* I/O Numenator vector */
|
||||
inv_D_t *inv_D, /* I 1 / D vector */
|
||||
SKP_int M /* I dimension */
|
||||
opus_int M /* I dimension */
|
||||
);
|
||||
|
||||
/* Solves Ax = b, assuming A is symmetric */
|
||||
void silk_solve_LDL_FIX(
|
||||
SKP_int32 *A, /* I Pointer to symetric square matrix A */
|
||||
SKP_int M, /* I Size of matrix */
|
||||
const SKP_int32 *b, /* I Pointer to b vector */
|
||||
SKP_int32 *x_Q16 /* O Pointer to x solution vector */
|
||||
opus_int32 *A, /* I Pointer to symetric square matrix A */
|
||||
opus_int M, /* I Size of matrix */
|
||||
const opus_int32 *b, /* I Pointer to b vector */
|
||||
opus_int32 *x_Q16 /* O Pointer to x solution vector */
|
||||
)
|
||||
{
|
||||
SKP_int32 L_Q16[ MAX_MATRIX_SIZE * MAX_MATRIX_SIZE ];
|
||||
SKP_int32 Y[ MAX_MATRIX_SIZE ];
|
||||
opus_int32 L_Q16[ MAX_MATRIX_SIZE * MAX_MATRIX_SIZE ];
|
||||
opus_int32 Y[ MAX_MATRIX_SIZE ];
|
||||
inv_D_t inv_D[ MAX_MATRIX_SIZE ];
|
||||
|
||||
SKP_assert( M <= MAX_MATRIX_SIZE );
|
||||
|
@ -106,17 +106,17 @@ void silk_solve_LDL_FIX(
|
|||
}
|
||||
|
||||
SKP_INLINE void silk_LDL_factorize_FIX(
|
||||
SKP_int32 *A, /* I Pointer to Symetric Square Matrix */
|
||||
SKP_int M, /* I Size of Matrix */
|
||||
SKP_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */
|
||||
opus_int32 *A, /* I Pointer to Symetric Square Matrix */
|
||||
opus_int M, /* I Size of Matrix */
|
||||
opus_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */
|
||||
inv_D_t *inv_D /* I/O Pointer to vector holding inverted diagonal elements of D */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, k, status, loop_count;
|
||||
const SKP_int32 *ptr1, *ptr2;
|
||||
SKP_int32 diag_min_value, tmp_32, err;
|
||||
SKP_int32 v_Q0[ MAX_MATRIX_SIZE ], D_Q0[ MAX_MATRIX_SIZE ];
|
||||
SKP_int32 one_div_diag_Q36, one_div_diag_Q40, one_div_diag_Q48;
|
||||
opus_int i, j, k, status, loop_count;
|
||||
const opus_int32 *ptr1, *ptr2;
|
||||
opus_int32 diag_min_value, tmp_32, err;
|
||||
opus_int32 v_Q0[ MAX_MATRIX_SIZE ], D_Q0[ MAX_MATRIX_SIZE ];
|
||||
opus_int32 one_div_diag_Q36, one_div_diag_Q40, one_div_diag_Q48;
|
||||
|
||||
SKP_assert( M <= MAX_MATRIX_SIZE );
|
||||
|
||||
|
@ -178,14 +178,14 @@ SKP_INLINE void silk_LDL_factorize_FIX(
|
|||
}
|
||||
|
||||
SKP_INLINE void silk_LS_divide_Q16_FIX(
|
||||
SKP_int32 T[], /* I/O Numenator vector */
|
||||
opus_int32 T[], /* I/O Numenator vector */
|
||||
inv_D_t *inv_D, /* I 1 / D vector */
|
||||
SKP_int M /* I Order */
|
||||
opus_int M /* I Order */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
SKP_int32 tmp_32;
|
||||
SKP_int32 one_div_diag_Q36, one_div_diag_Q48;
|
||||
opus_int i;
|
||||
opus_int32 tmp_32;
|
||||
opus_int32 one_div_diag_Q36, one_div_diag_Q48;
|
||||
|
||||
for( i = 0; i < M; i++ ) {
|
||||
one_div_diag_Q36 = inv_D[ i ].Q36_part;
|
||||
|
@ -198,15 +198,15 @@ SKP_INLINE void silk_LS_divide_Q16_FIX(
|
|||
|
||||
/* Solve Lx = b, when L is lower triangular and has ones on the diagonal */
|
||||
SKP_INLINE void silk_LS_SolveFirst_FIX(
|
||||
const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||
SKP_int M, /* I Dim of Matrix equation */
|
||||
const SKP_int32 *b, /* I b Vector */
|
||||
SKP_int32 *x_Q16 /* O x Vector */
|
||||
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||
opus_int M, /* I Dim of Matrix equation */
|
||||
const opus_int32 *b, /* I b Vector */
|
||||
opus_int32 *x_Q16 /* O x Vector */
|
||||
)
|
||||
{
|
||||
SKP_int i, j;
|
||||
const SKP_int32 *ptr32;
|
||||
SKP_int32 tmp_32;
|
||||
opus_int i, j;
|
||||
const opus_int32 *ptr32;
|
||||
opus_int32 tmp_32;
|
||||
|
||||
for( i = 0; i < M; i++ ) {
|
||||
ptr32 = matrix_adr( L_Q16, i, 0, M );
|
||||
|
@ -220,15 +220,15 @@ SKP_INLINE void silk_LS_SolveFirst_FIX(
|
|||
|
||||
/* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */
|
||||
SKP_INLINE void silk_LS_SolveLast_FIX(
|
||||
const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||
const SKP_int M, /* I Dim of Matrix equation */
|
||||
const SKP_int32 *b, /* I b Vector */
|
||||
SKP_int32 *x_Q16 /* O x Vector */
|
||||
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||
const opus_int M, /* I Dim of Matrix equation */
|
||||
const opus_int32 *b, /* I b Vector */
|
||||
opus_int32 *x_Q16 /* O x Vector */
|
||||
)
|
||||
{
|
||||
SKP_int i, j;
|
||||
const SKP_int32 *ptr32;
|
||||
SKP_int32 tmp_32;
|
||||
opus_int i, j;
|
||||
const opus_int32 *ptr32;
|
||||
opus_int32 tmp_32;
|
||||
|
||||
for( i = M - 1; i >= 0; i-- ) {
|
||||
ptr32 = matrix_adr( L_Q16, 0, i, M );
|
||||
|
|
|
@ -41,24 +41,24 @@ extern "C"
|
|||
/* Noise shaping analysis state */
|
||||
/********************************/
|
||||
typedef struct {
|
||||
SKP_int8 LastGainIndex;
|
||||
SKP_int32 HarmBoost_smth_Q16;
|
||||
SKP_int32 HarmShapeGain_smth_Q16;
|
||||
SKP_int32 Tilt_smth_Q16;
|
||||
opus_int8 LastGainIndex;
|
||||
opus_int32 HarmBoost_smth_Q16;
|
||||
opus_int32 HarmShapeGain_smth_Q16;
|
||||
opus_int32 Tilt_smth_Q16;
|
||||
} silk_shape_state_FIX;
|
||||
|
||||
/********************************/
|
||||
/* Prefilter state */
|
||||
/********************************/
|
||||
typedef struct {
|
||||
SKP_int16 sLTP_shp[ LTP_BUF_LENGTH ];
|
||||
SKP_int32 sAR_shp[ MAX_SHAPE_LPC_ORDER + 1 ];
|
||||
SKP_int sLTP_shp_buf_idx;
|
||||
SKP_int32 sLF_AR_shp_Q12;
|
||||
SKP_int32 sLF_MA_shp_Q12;
|
||||
SKP_int sHarmHP;
|
||||
SKP_int32 rand_seed;
|
||||
SKP_int lagPrev;
|
||||
opus_int16 sLTP_shp[ LTP_BUF_LENGTH ];
|
||||
opus_int32 sAR_shp[ MAX_SHAPE_LPC_ORDER + 1 ];
|
||||
opus_int sLTP_shp_buf_idx;
|
||||
opus_int32 sLF_AR_shp_Q12;
|
||||
opus_int32 sLF_MA_shp_Q12;
|
||||
opus_int sHarmHP;
|
||||
opus_int32 rand_seed;
|
||||
opus_int lagPrev;
|
||||
} silk_prefilter_state_FIX;
|
||||
|
||||
/********************************/
|
||||
|
@ -70,12 +70,12 @@ typedef struct {
|
|||
silk_prefilter_state_FIX sPrefilt; /* Prefilter State */
|
||||
|
||||
/* Buffer for find pitch and noise shape analysis */
|
||||
SKP_DWORD_ALIGN SKP_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */
|
||||
SKP_int LTPCorr_Q15; /* Normalized correlation from pitch lag estimator */
|
||||
SKP_DWORD_ALIGN opus_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */
|
||||
opus_int LTPCorr_Q15; /* Normalized correlation from pitch lag estimator */
|
||||
|
||||
/* Parameters For LTP scaling Control */
|
||||
SKP_int prevLTPredCodGain_Q7;
|
||||
SKP_int HPLTPredCodGain_Q7;
|
||||
opus_int prevLTPredCodGain_Q7;
|
||||
opus_int HPLTPredCodGain_Q7;
|
||||
} silk_encoder_state_FIX;
|
||||
|
||||
/************************/
|
||||
|
@ -83,31 +83,31 @@ typedef struct {
|
|||
/************************/
|
||||
typedef struct {
|
||||
/* Prediction and coding parameters */
|
||||
SKP_int32 Gains_Q16[ MAX_NB_SUBFR ];
|
||||
SKP_DWORD_ALIGN SKP_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
|
||||
SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ];
|
||||
SKP_int LTP_scale_Q14;
|
||||
SKP_int pitchL[ MAX_NB_SUBFR ];
|
||||
opus_int32 Gains_Q16[ MAX_NB_SUBFR ];
|
||||
SKP_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
|
||||
opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ];
|
||||
opus_int LTP_scale_Q14;
|
||||
opus_int pitchL[ MAX_NB_SUBFR ];
|
||||
|
||||
/* Noise shaping parameters */
|
||||
/* Testing */
|
||||
SKP_DWORD_ALIGN SKP_int16 AR1_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
||||
SKP_DWORD_ALIGN SKP_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
||||
SKP_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */
|
||||
SKP_int GainsPre_Q14[ MAX_NB_SUBFR ];
|
||||
SKP_int HarmBoost_Q14[ MAX_NB_SUBFR ];
|
||||
SKP_int Tilt_Q14[ MAX_NB_SUBFR ];
|
||||
SKP_int HarmShapeGain_Q14[ MAX_NB_SUBFR ];
|
||||
SKP_int Lambda_Q10;
|
||||
SKP_int input_quality_Q14;
|
||||
SKP_int coding_quality_Q14;
|
||||
SKP_DWORD_ALIGN opus_int16 AR1_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
||||
SKP_DWORD_ALIGN opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
||||
opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */
|
||||
opus_int GainsPre_Q14[ MAX_NB_SUBFR ];
|
||||
opus_int HarmBoost_Q14[ MAX_NB_SUBFR ];
|
||||
opus_int Tilt_Q14[ MAX_NB_SUBFR ];
|
||||
opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ];
|
||||
opus_int Lambda_Q10;
|
||||
opus_int input_quality_Q14;
|
||||
opus_int coding_quality_Q14;
|
||||
|
||||
/* measures */
|
||||
SKP_int sparseness_Q8;
|
||||
SKP_int32 predGain_Q16;
|
||||
SKP_int LTPredCodGain_Q7;
|
||||
SKP_int32 ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */
|
||||
SKP_int ResNrgQ[ MAX_NB_SUBFR ]; /* Q domain for the residual energy > 0 */
|
||||
opus_int sparseness_Q8;
|
||||
opus_int32 predGain_Q16;
|
||||
opus_int LTPredCodGain_Q7;
|
||||
opus_int32 ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */
|
||||
opus_int ResNrgQ[ MAX_NB_SUBFR ]; /* Q domain for the residual energy > 0 */
|
||||
|
||||
} silk_encoder_control_FIX;
|
||||
|
||||
|
@ -117,11 +117,11 @@ typedef struct {
|
|||
typedef struct {
|
||||
silk_encoder_state_FIX state_Fxx[ ENCODER_NUM_CHANNELS ];
|
||||
stereo_enc_state sStereo;
|
||||
SKP_int32 nBitsExceeded;
|
||||
SKP_int nChannelsAPI;
|
||||
SKP_int nChannelsInternal;
|
||||
SKP_int timeSinceSwitchAllowed_ms;
|
||||
SKP_int allowBandwidthSwitch;
|
||||
opus_int32 nBitsExceeded;
|
||||
opus_int nChannelsAPI;
|
||||
opus_int nChannelsInternal;
|
||||
opus_int timeSinceSwitchAllowed_ms;
|
||||
opus_int allowBandwidthSwitch;
|
||||
} silk_encoder;
|
||||
|
||||
|
||||
|
|
|
@ -32,18 +32,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Autocorrelations for a warped frequency axis */
|
||||
void silk_warped_autocorrelation_FIX(
|
||||
SKP_int32 *corr, /* O Result [order + 1] */
|
||||
SKP_int *scale, /* O Scaling of the correlation vector */
|
||||
const SKP_int16 *input, /* I Input data to correlate */
|
||||
const SKP_int warping_Q16, /* I Warping coefficient */
|
||||
const SKP_int length, /* I Length of input */
|
||||
const SKP_int order /* I Correlation order (even) */
|
||||
opus_int32 *corr, /* O Result [order + 1] */
|
||||
opus_int *scale, /* O Scaling of the correlation vector */
|
||||
const opus_int16 *input, /* I Input data to correlate */
|
||||
const opus_int warping_Q16, /* I Warping coefficient */
|
||||
const opus_int length, /* I Length of input */
|
||||
const opus_int order /* I Correlation order (even) */
|
||||
)
|
||||
{
|
||||
SKP_int n, i, lsh;
|
||||
SKP_int32 tmp1_QS, tmp2_QS;
|
||||
SKP_int32 state_QS[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 };
|
||||
SKP_int64 corr_QC[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 };
|
||||
opus_int n, i, lsh;
|
||||
opus_int32 tmp1_QS, tmp2_QS;
|
||||
opus_int32 state_QS[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 };
|
||||
opus_int64 corr_QC[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 };
|
||||
|
||||
/* Order must be even */
|
||||
SKP_assert( ( order & 1 ) == 0 );
|
||||
|
@ -51,7 +51,7 @@ void silk_warped_autocorrelation_FIX(
|
|||
|
||||
/* Loop over samples */
|
||||
for( n = 0; n < length; n++ ) {
|
||||
tmp1_QS = SKP_LSHIFT32( ( SKP_int32 )input[ n ], QS );
|
||||
tmp1_QS = SKP_LSHIFT32( ( opus_int32 )input[ n ], QS );
|
||||
/* Loop over allpass sections */
|
||||
for( i = 0; i < order; i += 2 ) {
|
||||
/* Output of allpass section */
|
||||
|
@ -73,11 +73,11 @@ void silk_warped_autocorrelation_FIX(
|
|||
SKP_assert( *scale >= -30 && *scale <= 12 );
|
||||
if( lsh >= 0 ) {
|
||||
for( i = 0; i < order + 1; i++ ) {
|
||||
corr[ i ] = ( SKP_int32 )SKP_CHECK_FIT32( SKP_LSHIFT64( corr_QC[ i ], lsh ) );
|
||||
corr[ i ] = ( opus_int32 )SKP_CHECK_FIT32( SKP_LSHIFT64( corr_QC[ i ], lsh ) );
|
||||
}
|
||||
} else {
|
||||
for( i = 0; i < order + 1; i++ ) {
|
||||
corr[ i ] = ( SKP_int32 )SKP_CHECK_FIT32( SKP_RSHIFT64( corr_QC[ i ], -lsh ) );
|
||||
corr[ i ] = ( opus_int32 )SKP_CHECK_FIT32( SKP_RSHIFT64( corr_QC[ i ], -lsh ) );
|
||||
}
|
||||
}
|
||||
SKP_assert( corr_QC[ 0 ] >= 0 ); // If breaking, decrease QC
|
||||
|
|
|
@ -40,10 +40,10 @@ void silk_LPC_analysis_filter16_FLP(
|
|||
SKP_float r_LPC[], /* O LPC residual signal */
|
||||
const SKP_float PredCoef[], /* I LPC coefficients */
|
||||
const SKP_float s[], /* I Input signal */
|
||||
const SKP_int length /* I Length of input signal */
|
||||
const opus_int length /* I Length of input signal */
|
||||
)
|
||||
{
|
||||
SKP_int ix;
|
||||
opus_int ix;
|
||||
SKP_float LPC_pred;
|
||||
const SKP_float *s_ptr;
|
||||
|
||||
|
@ -78,10 +78,10 @@ void silk_LPC_analysis_filter14_FLP(
|
|||
SKP_float r_LPC[], /* O LPC residual signal */
|
||||
const SKP_float PredCoef[], /* I LPC coefficients */
|
||||
const SKP_float s[], /* I Input signal */
|
||||
const SKP_int length /* I Length of input signal */
|
||||
const opus_int length /* I Length of input signal */
|
||||
)
|
||||
{
|
||||
SKP_int ix;
|
||||
opus_int ix;
|
||||
SKP_float LPC_pred;
|
||||
const SKP_float *s_ptr;
|
||||
|
||||
|
@ -114,10 +114,10 @@ void silk_LPC_analysis_filter12_FLP(
|
|||
SKP_float r_LPC[], /* O LPC residual signal */
|
||||
const SKP_float PredCoef[], /* I LPC coefficients */
|
||||
const SKP_float s[], /* I Input signal */
|
||||
const SKP_int length /* I Length of input signal */
|
||||
const opus_int length /* I Length of input signal */
|
||||
)
|
||||
{
|
||||
SKP_int ix;
|
||||
opus_int ix;
|
||||
SKP_float LPC_pred;
|
||||
const SKP_float *s_ptr;
|
||||
|
||||
|
@ -148,10 +148,10 @@ void silk_LPC_analysis_filter10_FLP(
|
|||
SKP_float r_LPC[], /* O LPC residual signal */
|
||||
const SKP_float PredCoef[], /* I LPC coefficients */
|
||||
const SKP_float s[], /* I Input signal */
|
||||
const SKP_int length /* I Length of input signal */
|
||||
const opus_int length /* I Length of input signal */
|
||||
)
|
||||
{
|
||||
SKP_int ix;
|
||||
opus_int ix;
|
||||
SKP_float LPC_pred;
|
||||
const SKP_float *s_ptr;
|
||||
|
||||
|
@ -180,10 +180,10 @@ void silk_LPC_analysis_filter8_FLP(
|
|||
SKP_float r_LPC[], /* O LPC residual signal */
|
||||
const SKP_float PredCoef[], /* I LPC coefficients */
|
||||
const SKP_float s[], /* I Input signal */
|
||||
const SKP_int length /* I Length of input signal */
|
||||
const opus_int length /* I Length of input signal */
|
||||
)
|
||||
{
|
||||
SKP_int ix;
|
||||
opus_int ix;
|
||||
SKP_float LPC_pred;
|
||||
const SKP_float *s_ptr;
|
||||
|
||||
|
@ -210,10 +210,10 @@ void silk_LPC_analysis_filter6_FLP(
|
|||
SKP_float r_LPC[], /* O LPC residual signal */
|
||||
const SKP_float PredCoef[], /* I LPC coefficients */
|
||||
const SKP_float s[], /* I Input signal */
|
||||
const SKP_int length /* I Length of input signal */
|
||||
const opus_int length /* I Length of input signal */
|
||||
)
|
||||
{
|
||||
SKP_int ix;
|
||||
opus_int ix;
|
||||
SKP_float LPC_pred;
|
||||
const SKP_float *s_ptr;
|
||||
|
||||
|
@ -244,8 +244,8 @@ void silk_LPC_analysis_filter_FLP(
|
|||
SKP_float r_LPC[], /* O LPC residual signal */
|
||||
const SKP_float PredCoef[], /* I LPC coefficients */
|
||||
const SKP_float s[], /* I Input signal */
|
||||
const SKP_int length, /* I Length of input signal */
|
||||
const SKP_int Order /* I LPC order */
|
||||
const opus_int length, /* I Length of input signal */
|
||||
const opus_int Order /* I LPC order */
|
||||
)
|
||||
{
|
||||
SKP_assert( Order <= length );
|
||||
|
|
|
@ -33,13 +33,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/* compute inverse of LPC prediction gain, and */
|
||||
/* test if LPC coefficients are stable (all poles within unit circle) */
|
||||
/* this code is based on silk_a2k_FLP() */
|
||||
SKP_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */
|
||||
opus_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */
|
||||
SKP_float *invGain, /* O: inverse prediction gain, energy domain */
|
||||
const SKP_float *A, /* I: prediction coefficients [order] */
|
||||
SKP_int32 order /* I: prediction order */
|
||||
opus_int32 order /* I: prediction order */
|
||||
)
|
||||
{
|
||||
SKP_int k, n;
|
||||
opus_int k, n;
|
||||
double rc, rc_mult1, rc_mult2;
|
||||
SKP_float Atmp[ 2 ][ SILK_MAX_ORDER_LPC ];
|
||||
SKP_float *Aold, *Anew;
|
||||
|
|
|
@ -31,18 +31,18 @@ void silk_LTP_analysis_filter_FLP(
|
|||
SKP_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */
|
||||
const SKP_float *x, /* I Input signal, with preceeding samples */
|
||||
const SKP_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */
|
||||
const SKP_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
|
||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
|
||||
const SKP_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */
|
||||
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 Preceeding samples 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 Preceeding samples for each subframe */
|
||||
)
|
||||
{
|
||||
const SKP_float *x_ptr, *x_lag_ptr;
|
||||
SKP_float Btmp[ LTP_ORDER ];
|
||||
SKP_float *LTP_res_ptr;
|
||||
SKP_float inv_gain;
|
||||
SKP_int k, i, j;
|
||||
opus_int k, i, j;
|
||||
|
||||
x_ptr = x;
|
||||
LTP_res_ptr = LTP_res;
|
||||
|
|
|
@ -32,7 +32,7 @@ void silk_LTP_scale_ctrl_FLP(
|
|||
silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */
|
||||
)
|
||||
{
|
||||
SKP_int round_loss;
|
||||
opus_int round_loss;
|
||||
|
||||
/* 1st order high-pass filter */
|
||||
//g_HP(n) = g(n) - 0.5 * g(n-1) + 0.5 * g_HP(n-1);
|
||||
|
@ -43,7 +43,7 @@ void silk_LTP_scale_ctrl_FLP(
|
|||
/* Only scale if first frame in packet */
|
||||
if( psEnc->sCmn.nFramesEncoded == 0 ) {
|
||||
round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket;
|
||||
psEnc->sCmn.indices.LTP_scaleIndex = (SKP_int8)SKP_LIMIT( round_loss * psEnc->HPLTPredCodGain * 0.1f, 0.0f, 2.0f );
|
||||
psEnc->sCmn.indices.LTP_scaleIndex = (opus_int8)SKP_LIMIT( round_loss * psEnc->HPLTPredCodGain * 0.1f, 0.0f, 2.0f );
|
||||
} else {
|
||||
/* Default is minimum scaling */
|
||||
psEnc->sCmn.indices.LTP_scaleIndex = 0;
|
||||
|
|
|
@ -43,44 +43,44 @@ extern "C"
|
|||
/* Chirp (bw expand) LP AR filter */
|
||||
void silk_bwexpander_FLP(
|
||||
SKP_float *ar, /* io AR filter to be expanded (without leading 1) */
|
||||
const SKP_int d, /* i length of ar */
|
||||
const opus_int d, /* i length of ar */
|
||||
const SKP_float chirp /* i chirp factor (typically in range (0..1) ) */
|
||||
);
|
||||
|
||||
/* compute inverse of LPC prediction gain, and */
|
||||
/* test if LPC coefficients are stable (all poles within unit circle) */
|
||||
/* this code is based on silk_FLP_a2k() */
|
||||
SKP_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */
|
||||
opus_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */
|
||||
SKP_float *invGain, /* O: inverse prediction gain, energy domain */
|
||||
const SKP_float *A, /* I: prediction coefficients [order] */
|
||||
SKP_int32 order /* I: prediction order */
|
||||
opus_int32 order /* I: prediction order */
|
||||
);
|
||||
|
||||
SKP_float silk_schur_FLP( /* O returns residual energy */
|
||||
SKP_float refl_coef[], /* O reflection coefficients (length order) */
|
||||
const SKP_float auto_corr[], /* I autocorrelation sequence (length order+1) */
|
||||
SKP_int order /* I order */
|
||||
opus_int order /* I order */
|
||||
);
|
||||
|
||||
void silk_k2a_FLP(
|
||||
SKP_float *A, /* O: prediction coefficients [order] */
|
||||
const SKP_float *rc, /* I: reflection coefficients [order] */
|
||||
SKP_int32 order /* I: prediction order */
|
||||
opus_int32 order /* I: prediction order */
|
||||
);
|
||||
|
||||
/* Solve the normal equations using the Levinson-Durbin recursion */
|
||||
SKP_float silk_levinsondurbin_FLP( /* O prediction error energy */
|
||||
SKP_float A[], /* O prediction coefficients [order] */
|
||||
const SKP_float corr[], /* I input auto-correlations [order + 1] */
|
||||
const SKP_int order /* I prediction order */
|
||||
const opus_int order /* I prediction order */
|
||||
);
|
||||
|
||||
/* compute autocorrelation */
|
||||
void silk_autocorrelation_FLP(
|
||||
SKP_float *results, /* o result (length correlationCount) */
|
||||
const SKP_float *inputData, /* i input data to correlate */
|
||||
SKP_int inputDataSize, /* i length of input */
|
||||
SKP_int correlationCount /* i number of correlation taps to compute */
|
||||
opus_int inputDataSize, /* i length of input */
|
||||
opus_int correlationCount /* i number of correlation taps to compute */
|
||||
);
|
||||
|
||||
/* Pitch estimator */
|
||||
|
@ -88,44 +88,44 @@ void silk_autocorrelation_FLP(
|
|||
#define SigProc_PE_MID_COMPLEX 1
|
||||
#define SigProc_PE_MAX_COMPLEX 2
|
||||
|
||||
SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */
|
||||
opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */
|
||||
const SKP_float *signal, /* I signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
|
||||
SKP_int *pitch_out, /* O 4 pitch lag values */
|
||||
SKP_int16 *lagIndex, /* O lag Index */
|
||||
SKP_int8 *contourIndex, /* O pitch contour Index */
|
||||
opus_int *pitch_out, /* O 4 pitch lag values */
|
||||
opus_int16 *lagIndex, /* O lag Index */
|
||||
opus_int8 *contourIndex, /* O pitch contour Index */
|
||||
SKP_float *LTPCorr, /* I/O normalized correlation; input: value from previous frame */
|
||||
SKP_int prevLag, /* I last lag of previous frame; set to zero is unvoiced */
|
||||
opus_int prevLag, /* I last lag of previous frame; set to zero is unvoiced */
|
||||
const SKP_float search_thres1, /* I first stage threshold for lag candidates 0 - 1 */
|
||||
const SKP_float search_thres2, /* I final threshold for lag candidates 0 - 1 */
|
||||
const SKP_int Fs_kHz, /* I sample frequency (kHz) */
|
||||
const SKP_int complexity, /* I Complexity setting, 0-2, where 2 is highest */
|
||||
const SKP_int nb_subfr /* I number of 5 ms subframes */
|
||||
const opus_int Fs_kHz, /* I sample frequency (kHz) */
|
||||
const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */
|
||||
const opus_int nb_subfr /* I number of 5 ms subframes */
|
||||
);
|
||||
|
||||
#define PI (3.1415926536f)
|
||||
|
||||
void silk_insertion_sort_decreasing_FLP(
|
||||
SKP_float *a, /* I/O: Unsorted / Sorted vector */
|
||||
SKP_int *idx, /* O: Index vector for the sorted elements */
|
||||
const SKP_int L, /* I: Vector length */
|
||||
const SKP_int K /* I: Number of correctly sorted positions */
|
||||
opus_int *idx, /* O: Index vector for the sorted elements */
|
||||
const opus_int L, /* I: Vector length */
|
||||
const opus_int K /* I: Number of correctly sorted positions */
|
||||
);
|
||||
|
||||
/* Compute reflection coefficients from input signal */
|
||||
SKP_float silk_burg_modified_FLP( /* O returns residual energy */
|
||||
SKP_float A[], /* O prediction coefficients (length order) */
|
||||
const SKP_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */
|
||||
const SKP_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
|
||||
const SKP_int nb_subfr, /* I number of subframes stacked in x */
|
||||
const opus_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
|
||||
const opus_int nb_subfr, /* I number of subframes stacked in x */
|
||||
const SKP_float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */
|
||||
const SKP_int D /* I order */
|
||||
const opus_int D /* I order */
|
||||
);
|
||||
|
||||
/* multiply a vector by a constant */
|
||||
void silk_scale_vector_FLP(
|
||||
SKP_float *data1,
|
||||
SKP_float gain,
|
||||
SKP_int dataSize
|
||||
opus_int dataSize
|
||||
);
|
||||
|
||||
/* copy and multiply a vector by a constant */
|
||||
|
@ -133,20 +133,20 @@ void silk_scale_copy_vector_FLP(
|
|||
SKP_float *data_out,
|
||||
const SKP_float *data_in,
|
||||
SKP_float gain,
|
||||
SKP_int dataSize
|
||||
opus_int dataSize
|
||||
);
|
||||
|
||||
/* inner product of two SKP_float arrays, with result as double */
|
||||
double silk_inner_product_FLP(
|
||||
const SKP_float *data1,
|
||||
const SKP_float *data2,
|
||||
SKP_int dataSize
|
||||
opus_int dataSize
|
||||
);
|
||||
|
||||
/* sum of squares of a SKP_float array, with result as double */
|
||||
double silk_energy_FLP(
|
||||
const SKP_float *data,
|
||||
SKP_int dataSize
|
||||
opus_int dataSize
|
||||
);
|
||||
|
||||
/********************************************************************/
|
||||
|
@ -167,31 +167,31 @@ SKP_INLINE SKP_float SKP_sigmoid(SKP_float x)
|
|||
}
|
||||
|
||||
/* floating-point to integer conversion (rounding) */
|
||||
SKP_INLINE SKP_int32 SKP_float2int(double x)
|
||||
SKP_INLINE opus_int32 SKP_float2int(double x)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
double t = x + 6755399441055744.0;
|
||||
return *((SKP_int32 *)( &t ));
|
||||
return *((opus_int32 *)( &t ));
|
||||
#else
|
||||
return (SKP_int32)( ( x > 0 ) ? x + 0.5 : x - 0.5 );
|
||||
return (opus_int32)( ( x > 0 ) ? x + 0.5 : x - 0.5 );
|
||||
#endif
|
||||
}
|
||||
|
||||
/* floating-point to integer conversion (rounding) */
|
||||
SKP_INLINE void SKP_float2short_array(
|
||||
SKP_int16 *out,
|
||||
opus_int16 *out,
|
||||
const SKP_float *in,
|
||||
SKP_int32 length
|
||||
opus_int32 length
|
||||
)
|
||||
{
|
||||
SKP_int32 k;
|
||||
opus_int32 k;
|
||||
for (k = length-1; k >= 0; k--) {
|
||||
#ifdef _WIN32
|
||||
double t = in[k] + 6755399441055744.0;
|
||||
out[k] = (SKP_int16)SKP_SAT16(*(( SKP_int32 * )( &t )));
|
||||
out[k] = (opus_int16)SKP_SAT16(*(( opus_int32 * )( &t )));
|
||||
#else
|
||||
double x = in[k];
|
||||
out[k] = (SKP_int16)SKP_SAT16( ( x > 0 ) ? x + 0.5 : x - 0.5 );
|
||||
out[k] = (opus_int16)SKP_SAT16( ( x > 0 ) ? x + 0.5 : x - 0.5 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -199,11 +199,11 @@ SKP_INLINE void SKP_float2short_array(
|
|||
/* integer to floating-point conversion */
|
||||
SKP_INLINE void SKP_short2float_array(
|
||||
SKP_float *out,
|
||||
const SKP_int16 *in,
|
||||
SKP_int32 length
|
||||
const opus_int16 *in,
|
||||
opus_int32 length
|
||||
)
|
||||
{
|
||||
SKP_int32 k;
|
||||
opus_int32 k;
|
||||
for (k = length-1; k >= 0; k--) {
|
||||
out[k] = (SKP_float)in[k];
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
void silk_apply_sine_window_FLP(
|
||||
SKP_float px_win[], /* O Pointer to windowed signal */
|
||||
const SKP_float px[], /* I Pointer to input signal */
|
||||
const SKP_int win_type, /* I Selects a window type */
|
||||
const SKP_int length /* I Window length, multiple of 4 */
|
||||
const opus_int win_type, /* I Selects a window type */
|
||||
const opus_int length /* I Window length, multiple of 4 */
|
||||
)
|
||||
{
|
||||
SKP_int k;
|
||||
opus_int k;
|
||||
SKP_float freq, c, S0, S1;
|
||||
|
||||
SKP_assert( win_type == 1 || win_type == 2 );
|
||||
|
|
|
@ -32,11 +32,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
void silk_autocorrelation_FLP(
|
||||
SKP_float *results, /* O result (length correlationCount) */
|
||||
const SKP_float *inputData, /* I input data to correlate */
|
||||
SKP_int inputDataSize, /* I length of input */
|
||||
SKP_int correlationCount /* I number of correlation taps to compute */
|
||||
opus_int inputDataSize, /* I length of input */
|
||||
opus_int correlationCount /* I number of correlation taps to compute */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
opus_int i;
|
||||
|
||||
if ( correlationCount > inputDataSize ) {
|
||||
correlationCount = inputDataSize;
|
||||
|
|
|
@ -34,13 +34,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
SKP_float silk_burg_modified_FLP( /* O returns residual energy */
|
||||
SKP_float A[], /* O prediction coefficients (length order) */
|
||||
const SKP_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */
|
||||
const SKP_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
|
||||
const SKP_int nb_subfr, /* I number of subframes stacked in x */
|
||||
const opus_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
|
||||
const opus_int nb_subfr, /* I number of subframes stacked in x */
|
||||
const SKP_float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */
|
||||
const SKP_int D /* I order */
|
||||
const opus_int D /* I order */
|
||||
)
|
||||
{
|
||||
SKP_int k, n, s;
|
||||
opus_int k, n, s;
|
||||
double C0, num, nrg_f, nrg_b, rc, Atmp, tmp1, tmp2;
|
||||
const SKP_float *x_ptr;
|
||||
double C_first_row[ SILK_MAX_ORDER_LPC ], C_last_row[ SILK_MAX_ORDER_LPC ];
|
||||
|
|
|
@ -32,11 +32,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/* Chirp (bw expand) LP AR filter */
|
||||
void silk_bwexpander_FLP(
|
||||
SKP_float *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||
const SKP_int d, /* I length of ar */
|
||||
const opus_int d, /* I length of ar */
|
||||
const SKP_float chirp /* I chirp factor (typically in range (0..1) ) */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
opus_int i;
|
||||
SKP_float cfac = chirp;
|
||||
|
||||
for( i = 0; i < d - 1; i++ ) {
|
||||
|
|
|
@ -35,12 +35,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
void silk_corrVector_FLP(
|
||||
const SKP_float *x, /* I x vector [L+order-1] used to create X */
|
||||
const SKP_float *t, /* I Target vector [L] */
|
||||
const SKP_int L, /* I Length of vecors */
|
||||
const SKP_int Order, /* I Max lag for correlation */
|
||||
const opus_int L, /* I Length of vecors */
|
||||
const opus_int Order, /* I Max lag for correlation */
|
||||
SKP_float *Xt /* O X'*t correlation vector [order] */
|
||||
)
|
||||
{
|
||||
SKP_int lag;
|
||||
opus_int lag;
|
||||
const SKP_float *ptr1;
|
||||
|
||||
ptr1 = &x[ Order - 1 ]; /* Points to first sample of column 0 of X: X[:,0] */
|
||||
|
@ -54,12 +54,12 @@ void silk_corrVector_FLP(
|
|||
/* Calculates correlation matrix X'*X */
|
||||
void silk_corrMatrix_FLP(
|
||||
const SKP_float *x, /* I x vector [ L+order-1 ] used to create X */
|
||||
const SKP_int L, /* I Length of vectors */
|
||||
const SKP_int Order, /* I Max lag for correlation */
|
||||
const opus_int L, /* I Length of vectors */
|
||||
const opus_int Order, /* I Max lag for correlation */
|
||||
SKP_float *XX /* O X'*X correlation matrix [order x order] */
|
||||
)
|
||||
{
|
||||
SKP_int j, lag;
|
||||
opus_int j, lag;
|
||||
double energy;
|
||||
const SKP_float *ptr1, *ptr2;
|
||||
|
||||
|
|
|
@ -31,14 +31,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/****************/
|
||||
/* Encode frame */
|
||||
/****************/
|
||||
SKP_int silk_encode_frame_FLP(
|
||||
opus_int silk_encode_frame_FLP(
|
||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||
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_FLP sEncCtrl;
|
||||
SKP_int i, ret = 0;
|
||||
opus_int i, ret = 0;
|
||||
SKP_float *x_frame, *res_pitch_frame;
|
||||
SKP_float xfw[ MAX_FRAME_LENGTH ];
|
||||
SKP_float res_pitch[ 2 * MAX_FRAME_LENGTH + LA_PITCH_MAX ];
|
||||
|
@ -195,21 +195,21 @@ TOC(ENCODE_PULSES)
|
|||
TOC(ENCODE_FRAME)
|
||||
|
||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
||||
//DEBUG_STORE_DATA( xf.dat, pIn_HP_LP, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );
|
||||
//DEBUG_STORE_DATA( xf.dat, pIn_HP_LP, psEnc->sCmn.frame_length * sizeof( opus_int16 ) );
|
||||
//DEBUG_STORE_DATA( xfw.dat, xfw, psEnc->sCmn.frame_length * sizeof( SKP_float ) );
|
||||
DEBUG_STORE_DATA( pitchL.dat, sEncCtrl.pitchL, MAX_NB_SUBFR * sizeof( SKP_int ) );
|
||||
DEBUG_STORE_DATA( pitchL.dat, sEncCtrl.pitchL, MAX_NB_SUBFR * sizeof( opus_int ) );
|
||||
DEBUG_STORE_DATA( pitchG_quantized.dat, sEncCtrl.LTPCoef, psEnc->sCmn.nb_subfr * LTP_ORDER * sizeof( SKP_float ) );
|
||||
DEBUG_STORE_DATA( LTPcorr.dat, &psEnc->LTPCorr, sizeof( SKP_float ) );
|
||||
DEBUG_STORE_DATA( gains.dat, sEncCtrl.Gains, psEnc->sCmn.nb_subfr * sizeof( SKP_float ) );
|
||||
DEBUG_STORE_DATA( gains_indices.dat, &psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr * sizeof( SKP_int8 ) );
|
||||
DEBUG_STORE_DATA( quantOffsetType.dat, &psEnc->sCmn.indices.quantOffsetType, sizeof( SKP_int8 ) );
|
||||
DEBUG_STORE_DATA( speech_activity_q8.dat, &psEnc->sCmn.speech_activity_Q8, sizeof( SKP_int ) );
|
||||
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( gains_indices.dat, &psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr * sizeof( opus_int8 ) );
|
||||
DEBUG_STORE_DATA( quantOffsetType.dat, &psEnc->sCmn.indices.quantOffsetType, sizeof( opus_int8 ) );
|
||||
DEBUG_STORE_DATA( speech_activity_q8.dat, &psEnc->sCmn.speech_activity_Q8, sizeof( opus_int ) );
|
||||
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 ) );
|
||||
DEBUG_STORE_DATA( PredCoef.dat, &sEncCtrl.PredCoef[ 1 ], psEnc->sCmn.predictLPCOrder * sizeof( SKP_float ) );
|
||||
DEBUG_STORE_DATA( ltp_scale_idx.dat, &psEnc->sCmn.indices.LTP_scaleIndex, sizeof( SKP_int8 ) );
|
||||
DEBUG_STORE_DATA( ltp_scale_idx.dat, &psEnc->sCmn.indices.LTP_scaleIndex, sizeof( opus_int8 ) );
|
||||
// DEBUG_STORE_DATA( xq.dat, psEnc->sCmn.sNSQ.xqBuf, psEnc->sCmn.frame_length * sizeof( SKP_float ) );
|
||||
#endif
|
||||
return ret;
|
||||
|
@ -222,8 +222,8 @@ void silk_LBRR_encode_FLP(
|
|||
const SKP_float xfw[] /* I Input signal */
|
||||
)
|
||||
{
|
||||
SKP_int k;
|
||||
SKP_int32 Gains_Q16[ MAX_NB_SUBFR ];
|
||||
opus_int k;
|
||||
opus_int32 Gains_Q16[ MAX_NB_SUBFR ];
|
||||
SKP_float TempGains[ MAX_NB_SUBFR ];
|
||||
SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesEncoded ];
|
||||
silk_nsq_state sNSQ_LBRR;
|
||||
|
|
|
@ -30,10 +30,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/* sum of squares of a SKP_float array, with result as double */
|
||||
double silk_energy_FLP(
|
||||
const SKP_float *data,
|
||||
SKP_int dataSize
|
||||
opus_int dataSize
|
||||
)
|
||||
{
|
||||
SKP_int i, dataSize4;
|
||||
opus_int i, dataSize4;
|
||||
double result;
|
||||
|
||||
/* 4x unrolled loop */
|
||||
|
|
|
@ -29,23 +29,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "silk_tuning_parameters.h"
|
||||
|
||||
void silk_find_LPC_FLP(
|
||||
SKP_int16 NLSF_Q15[], /* O NLSFs */
|
||||
SKP_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */
|
||||
const SKP_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */
|
||||
const SKP_int useInterpNLSFs, /* I Flag */
|
||||
const SKP_int firstFrameAfterReset, /* I Flag */
|
||||
const SKP_int LPC_order, /* I LPC order */
|
||||
opus_int16 NLSF_Q15[], /* O NLSFs */
|
||||
opus_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */
|
||||
const opus_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */
|
||||
const opus_int useInterpNLSFs, /* I Flag */
|
||||
const opus_int firstFrameAfterReset, /* I Flag */
|
||||
const opus_int LPC_order, /* I LPC order */
|
||||
const SKP_float x[], /* I Input signal */
|
||||
const SKP_int subfr_length, /* I Subframe length incl preceeding samples */
|
||||
const SKP_int nb_subfr /* I: Number of subframes */
|
||||
const opus_int subfr_length, /* I Subframe length incl preceeding samples */
|
||||
const opus_int nb_subfr /* I: Number of subframes */
|
||||
)
|
||||
{
|
||||
SKP_int k;
|
||||
opus_int k;
|
||||
SKP_float a[ MAX_LPC_ORDER ];
|
||||
|
||||
/* Used only for NLSF interpolation */
|
||||
double res_nrg, res_nrg_2nd, res_nrg_interp;
|
||||
SKP_int16 NLSF0_Q15[ MAX_LPC_ORDER ];
|
||||
opus_int16 NLSF0_Q15[ MAX_LPC_ORDER ];
|
||||
SKP_float a_tmp[ MAX_LPC_ORDER ];
|
||||
SKP_float LPC_res[ ( MAX_FRAME_LENGTH + MAX_NB_SUBFR * MAX_LPC_ORDER ) / 2 ];
|
||||
|
||||
|
@ -91,7 +91,7 @@ void silk_find_LPC_FLP(
|
|||
if( res_nrg_interp < res_nrg ) {
|
||||
/* Interpolation has lower residual energy */
|
||||
res_nrg = res_nrg_interp;
|
||||
*interpIndex = (SKP_int8)k;
|
||||
*interpIndex = (opus_int8)k;
|
||||
} else if( res_nrg_interp > res_nrg_2nd ) {
|
||||
/* No reason to continue iterating - residual energies will continue to climb */
|
||||
break;
|
||||
|
|
|
@ -33,14 +33,14 @@ void silk_find_LTP_FLP(
|
|||
SKP_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
|
||||
SKP_float *LTPredCodGain, /* O LTP coding gain */
|
||||
const SKP_float r_lpc[], /* I LPC residual */
|
||||
const SKP_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
||||
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
||||
const SKP_float Wght[ 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 */
|
||||
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 */
|
||||
)
|
||||
{
|
||||
SKP_int i, k;
|
||||
opus_int i, k;
|
||||
SKP_float *b_ptr, temp, *WLTP_ptr;
|
||||
SKP_float LPC_res_nrg, LPC_LTP_res_nrg;
|
||||
SKP_float d[ MAX_NB_SUBFR ], m, g, delta_b[ LTP_ORDER ];
|
||||
|
|
|
@ -36,7 +36,7 @@ void silk_find_pitch_lags_FLP(
|
|||
const SKP_float x[] /* I Speech signal */
|
||||
)
|
||||
{
|
||||
SKP_int buf_len;
|
||||
opus_int buf_len;
|
||||
SKP_float thrhld, res_nrg;
|
||||
const SKP_float *x_buf_ptr, *x_buf;
|
||||
SKP_float auto_corr[ MAX_FIND_PITCH_LPC_ORDER + 1 ];
|
||||
|
|
|
@ -35,10 +35,10 @@ void silk_find_pred_coefs_FLP(
|
|||
const SKP_float x[] /* I Speech signal */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
opus_int i;
|
||||
SKP_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ];
|
||||
SKP_float invGains[ MAX_NB_SUBFR ], Wght[ MAX_NB_SUBFR ];
|
||||
SKP_int16 NLSF_Q15[ MAX_LPC_ORDER ];
|
||||
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ];
|
||||
const SKP_float *x_ptr;
|
||||
SKP_float *x_pre_ptr, LPC_in_pre[ MAX_NB_SUBFR * MAX_LPC_ORDER + MAX_FRAME_LENGTH ];
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
double silk_inner_product_FLP( /* O result */
|
||||
const SKP_float *data1, /* I vector 1 */
|
||||
const SKP_float *data2, /* I vector 2 */
|
||||
SKP_int dataSize /* I length of vectors */
|
||||
opus_int dataSize /* I length of vectors */
|
||||
)
|
||||
{
|
||||
SKP_int i, dataSize4;
|
||||
opus_int i, dataSize4;
|
||||
double result;
|
||||
|
||||
/* 4x unrolled loop */
|
||||
|
|
|
@ -31,10 +31,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
void silk_k2a_FLP(
|
||||
SKP_float *A, /* O: prediction coefficients [order] */
|
||||
const SKP_float *rc, /* I: reflection coefficients [order] */
|
||||
SKP_int32 order /* I: prediction order */
|
||||
opus_int32 order /* I: prediction order */
|
||||
)
|
||||
{
|
||||
SKP_int k, n;
|
||||
opus_int k, n;
|
||||
SKP_float Atmp[ SILK_MAX_ORDER_LPC ];
|
||||
|
||||
for( k = 0; k < order; k++ ){
|
||||
|
|
|
@ -31,10 +31,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
SKP_float silk_levinsondurbin_FLP( /* O prediction error energy */
|
||||
SKP_float A[], /* O prediction coefficients [order] */
|
||||
const SKP_float corr[], /* I input auto-correlations [order + 1] */
|
||||
const SKP_int order /* I prediction order */
|
||||
const opus_int order /* I prediction order */
|
||||
)
|
||||
{
|
||||
SKP_int i, mHalf, m;
|
||||
opus_int i, mHalf, m;
|
||||
SKP_float min_nrg, nrg, t, km, Atmp1, Atmp2;
|
||||
|
||||
min_nrg = 1e-12f * corr[ 0 ] + 1e-9f;
|
||||
|
|
|
@ -51,13 +51,13 @@ extern "C"
|
|||
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
|
||||
void silk_HP_variable_cutoff(
|
||||
silk_encoder_state_Fxx state_Fxx[], /* I/O Encoder states */
|
||||
const SKP_int nChannels /* I Number of channels */
|
||||
const opus_int nChannels /* I Number of channels */
|
||||
);
|
||||
|
||||
/* Encoder main function */
|
||||
SKP_int silk_encode_frame_FLP(
|
||||
opus_int silk_encode_frame_FLP(
|
||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||
SKP_int32 *pnBytesOut, /* O Number of payload bytes; */
|
||||
opus_int32 *pnBytesOut, /* O Number of payload bytes; */
|
||||
ec_enc *psRangeEnc /* I/O compressor data structure */
|
||||
);
|
||||
|
||||
|
@ -69,17 +69,17 @@ void silk_LBRR_encode_FLP(
|
|||
);
|
||||
|
||||
/* Initializes the Silk encoder state */
|
||||
SKP_int silk_init_encoder(
|
||||
opus_int silk_init_encoder(
|
||||
silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
|
||||
);
|
||||
|
||||
/* Control the Silk encoder */
|
||||
SKP_int silk_control_encoder(
|
||||
opus_int silk_control_encoder(
|
||||
silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */
|
||||
silk_EncControlStruct *encControl, /* I: Control structure */
|
||||
const SKP_int32 TargetRate_bps, /* I Target max bitrate (bps) */
|
||||
const SKP_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
|
||||
const SKP_int channelNb /* I Channel number */
|
||||
const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */
|
||||
const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
|
||||
const opus_int channelNb /* I Channel number */
|
||||
);
|
||||
|
||||
/****************/
|
||||
|
@ -108,8 +108,8 @@ void silk_warped_autocorrelation_FLP(
|
|||
SKP_float *corr, /* O Result [order + 1] */
|
||||
const SKP_float *input, /* I Input data to correlate */
|
||||
const SKP_float warping, /* I Warping coefficient */
|
||||
const SKP_int length, /* I Length of input */
|
||||
const SKP_int order /* I Correlation order (even) */
|
||||
const opus_int length, /* I Length of input */
|
||||
const opus_int order /* I Correlation order (even) */
|
||||
);
|
||||
|
||||
/* Calculation of LTP state scaling */
|
||||
|
@ -139,15 +139,15 @@ void silk_find_pred_coefs_FLP(
|
|||
|
||||
/* LPC analysis */
|
||||
void silk_find_LPC_FLP(
|
||||
SKP_int16 NLSF_Q15[], /* O NLSFs */
|
||||
SKP_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */
|
||||
const SKP_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */
|
||||
const SKP_int useInterpNLSFs, /* I Flag */
|
||||
const SKP_int firstFrameAfterReset, /* I Flag */
|
||||
const SKP_int LPC_order, /* I LPC order */
|
||||
opus_int16 NLSF_Q15[], /* O NLSFs */
|
||||
opus_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */
|
||||
const opus_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */
|
||||
const opus_int useInterpNLSFs, /* I Flag */
|
||||
const opus_int firstFrameAfterReset, /* I Flag */
|
||||
const opus_int LPC_order, /* I LPC order */
|
||||
const SKP_float x[], /* I Input signal */
|
||||
const SKP_int subfr_length, /* I Subframe length incl preceeding samples */
|
||||
const SKP_int nb_subfr /* I: Number of subframes */
|
||||
const opus_int subfr_length, /* I Subframe length incl preceeding samples */
|
||||
const opus_int nb_subfr /* I: Number of subframes */
|
||||
);
|
||||
|
||||
/* LTP analysis */
|
||||
|
@ -156,22 +156,22 @@ void silk_find_LTP_FLP(
|
|||
SKP_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
|
||||
SKP_float *LTPredCodGain, /* O LTP coding gain */
|
||||
const SKP_float r_lpc[], /* I LPC residual */
|
||||
const SKP_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
||||
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
||||
const SKP_float Wght[ 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 */
|
||||
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 */
|
||||
);
|
||||
|
||||
void silk_LTP_analysis_filter_FLP(
|
||||
SKP_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */
|
||||
const SKP_float *x, /* I Input signal, with preceeding samples */
|
||||
const SKP_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */
|
||||
const SKP_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
|
||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
|
||||
const SKP_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */
|
||||
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 Preceeding samples 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 Preceeding samples for each subframe */
|
||||
);
|
||||
|
||||
/* Calculates residual energies of input subframes where all subframes have LPC_order */
|
||||
|
@ -181,9 +181,9 @@ void silk_residual_energy_FLP(
|
|||
const SKP_float x[], /* I Input signal */
|
||||
SKP_float a[ 2 ][ MAX_LPC_ORDER ],/* I AR coefs for each frame half */
|
||||
const SKP_float gains[], /* I Quantization gains */
|
||||
const SKP_int subfr_length, /* I Subframe length */
|
||||
const SKP_int nb_subfr, /* I number of subframes */
|
||||
const SKP_int LPC_order /* I LPC order */
|
||||
const opus_int subfr_length, /* I Subframe length */
|
||||
const opus_int nb_subfr, /* I number of subframes */
|
||||
const opus_int LPC_order /* I LPC order */
|
||||
);
|
||||
|
||||
/* 16th order LPC analysis filter */
|
||||
|
@ -191,19 +191,19 @@ void silk_LPC_analysis_filter_FLP(
|
|||
SKP_float r_LPC[], /* O LPC residual signal */
|
||||
const SKP_float PredCoef[], /* I LPC coefficients */
|
||||
const SKP_float s[], /* I Input signal */
|
||||
const SKP_int length, /* I Length of input signal */
|
||||
const SKP_int Order /* I LPC order */
|
||||
const opus_int length, /* I Length of input signal */
|
||||
const opus_int Order /* I LPC order */
|
||||
);
|
||||
|
||||
/* LTP tap quantizer */
|
||||
void silk_quant_LTP_gains_FLP(
|
||||
SKP_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (Un-)quantized LTP gains */
|
||||
SKP_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */
|
||||
SKP_int8 *periodicity_index, /* O Periodicity index */
|
||||
opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */
|
||||
opus_int8 *periodicity_index, /* O Periodicity index */
|
||||
const SKP_float W[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Error weights */
|
||||
const SKP_int mu_Q10, /* I Mu value (R/D tradeoff) */
|
||||
const SKP_int lowComplexity, /* I Flag for low complexity */
|
||||
const SKP_int nb_subfr /* I number of subframes */
|
||||
const opus_int mu_Q10, /* I Mu value (R/D tradeoff) */
|
||||
const opus_int lowComplexity, /* I Flag for low complexity */
|
||||
const opus_int nb_subfr /* I number of subframes */
|
||||
);
|
||||
|
||||
/******************/
|
||||
|
@ -213,8 +213,8 @@ void silk_quant_LTP_gains_FLP(
|
|||
void silk_process_NLSFs_FLP(
|
||||
silk_encoder_state *psEncC, /* I/O Encoder state */
|
||||
SKP_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */
|
||||
SKP_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
|
||||
const SKP_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
|
||||
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
|
||||
const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
|
||||
);
|
||||
|
||||
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
|
||||
|
@ -223,19 +223,19 @@ SKP_float silk_residual_energy_covar_FLP( /* O Weighted residual en
|
|||
SKP_float *wXX, /* I/O Weighted correlation matrix, reg. out */
|
||||
const SKP_float *wXx, /* I Weighted correlation vector */
|
||||
const SKP_float wxx, /* I Weighted correlation value */
|
||||
const SKP_int D /* I Dimension */
|
||||
const opus_int D /* I Dimension */
|
||||
);
|
||||
|
||||
/* Entropy constrained MATRIX-weighted VQ, for a single input data vector */
|
||||
void silk_VQ_WMat_EC_FLP(
|
||||
SKP_int *ind, /* O Index of best codebook vector */
|
||||
opus_int *ind, /* O Index of best codebook vector */
|
||||
SKP_float *rate_dist, /* O Best weighted quant. error + mu * rate */
|
||||
const SKP_float *in, /* I Input vector to be quantized */
|
||||
const SKP_float *W, /* I Weighting matrix */
|
||||
const SKP_int16 *cb, /* I Codebook */
|
||||
const SKP_int16 *cl_Q6, /* I Code length for each codebook vector */
|
||||
const opus_int16 *cb, /* I Codebook */
|
||||
const opus_int16 *cl_Q6, /* I Code length for each codebook vector */
|
||||
const SKP_float mu, /* I Tradeoff between WSSE and rate */
|
||||
const SKP_int L /* I Number of vectors in codebook */
|
||||
const opus_int L /* I Number of vectors in codebook */
|
||||
);
|
||||
|
||||
/* Processing of gains */
|
||||
|
@ -250,8 +250,8 @@ void silk_process_gains_FLP(
|
|||
/* Calculates correlation matrix X'*X */
|
||||
void silk_corrMatrix_FLP(
|
||||
const SKP_float *x, /* I x vector [ L+order-1 ] used to create X */
|
||||
const SKP_int L, /* I Length of vectors */
|
||||
const SKP_int Order, /* I Max lag for correlation */
|
||||
const opus_int L, /* I Length of vectors */
|
||||
const opus_int Order, /* I Max lag for correlation */
|
||||
SKP_float *XX /* O X'*X correlation matrix [order x order] */
|
||||
);
|
||||
|
||||
|
@ -259,8 +259,8 @@ void silk_corrMatrix_FLP(
|
|||
void silk_corrVector_FLP(
|
||||
const SKP_float *x, /* I x vector [L+order-1] used to create X */
|
||||
const SKP_float *t, /* I Target vector [L] */
|
||||
const SKP_int L, /* I Length of vecors */
|
||||
const SKP_int Order, /* I Max lag for correlation */
|
||||
const opus_int L, /* I Length of vecors */
|
||||
const opus_int Order, /* I Max lag for correlation */
|
||||
SKP_float *Xt /* O X'*t correlation vector [order] */
|
||||
);
|
||||
|
||||
|
@ -269,13 +269,13 @@ void silk_regularize_correlations_FLP(
|
|||
SKP_float *XX, /* I/O Correlation matrices */
|
||||
SKP_float *xx, /* I/O Correlation values */
|
||||
const SKP_float noise, /* I Noise energy to add */
|
||||
const SKP_int D /* I Dimension of XX */
|
||||
const opus_int D /* I Dimension of XX */
|
||||
);
|
||||
|
||||
/* Function to solve linear equation Ax = b, where A is an MxM symmetric matrix */
|
||||
void silk_solve_LDL_FLP(
|
||||
SKP_float *A, /* I/O Symmetric square matrix, out: reg. */
|
||||
const SKP_int M, /* I Size of matrix */
|
||||
const opus_int M, /* I Size of matrix */
|
||||
const SKP_float *b, /* I Pointer to b vector */
|
||||
SKP_float *x /* O Pointer to x solution vector */
|
||||
);
|
||||
|
@ -287,24 +287,24 @@ void silk_solve_LDL_FLP(
|
|||
void silk_apply_sine_window_FLP(
|
||||
SKP_float px_win[], /* O Pointer to windowed signal */
|
||||
const SKP_float px[], /* I Pointer to input signal */
|
||||
const SKP_int win_type, /* I Selects a window type */
|
||||
const SKP_int length /* I Window length, multiple of 4 */
|
||||
const opus_int win_type, /* I Selects a window type */
|
||||
const opus_int length /* I Window length, multiple of 4 */
|
||||
);
|
||||
|
||||
/* Wrapper functions. Call flp / fix code */
|
||||
|
||||
/* Convert AR filter coefficients to NLSF parameters */
|
||||
void silk_A2NLSF_FLP(
|
||||
SKP_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
|
||||
opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
|
||||
const SKP_float *pAR, /* I LPC coefficients [ LPC_order ] */
|
||||
const SKP_int LPC_order /* I LPC order */
|
||||
const opus_int LPC_order /* I LPC order */
|
||||
);
|
||||
|
||||
/* Convert NLSF parameters to AR prediction filter coefficients */
|
||||
void silk_NLSF2A_FLP(
|
||||
SKP_float *pAR, /* O LPC coefficients [ LPC_order ] */
|
||||
const SKP_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
|
||||
const SKP_int LPC_order /* I LPC order */
|
||||
const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
|
||||
const opus_int LPC_order /* I LPC order */
|
||||
);
|
||||
|
||||
/****************************************/
|
||||
|
@ -315,7 +315,7 @@ void silk_NSQ_wrapper_FLP(
|
|||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||
SideInfoIndices *psIndices, /* I/O Quantization indices */
|
||||
silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
|
||||
SKP_int8 pulses[], /* O Quantized pulse signal */
|
||||
opus_int8 pulses[], /* O Quantized pulse signal */
|
||||
const SKP_float x[] /* I Prefiltered input signal */
|
||||
);
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
SKP_INLINE SKP_float warped_gain(
|
||||
const SKP_float *coefs,
|
||||
SKP_float lambda,
|
||||
SKP_int order
|
||||
opus_int order
|
||||
) {
|
||||
SKP_int i;
|
||||
opus_int i;
|
||||
SKP_float gain;
|
||||
|
||||
lambda = -lambda;
|
||||
|
@ -53,9 +53,9 @@ SKP_INLINE void warped_true2monic_coefs(
|
|||
SKP_float *coefs_ana,
|
||||
SKP_float lambda,
|
||||
SKP_float limit,
|
||||
SKP_int order
|
||||
opus_int order
|
||||
) {
|
||||
SKP_int i, iter, ind = 0;
|
||||
opus_int i, iter, ind = 0;
|
||||
SKP_float tmp, maxabs, chirp, gain_syn, gain_ana;
|
||||
|
||||
/* Convert to monic coefficients */
|
||||
|
@ -127,7 +127,7 @@ void silk_noise_shape_analysis_FLP(
|
|||
)
|
||||
{
|
||||
silk_shape_state_FLP *psShapeSt = &psEnc->sShape;
|
||||
SKP_int k, nSamples;
|
||||
opus_int k, nSamples;
|
||||
SKP_float SNR_adj_dB, HarmBoost, HarmShapeGain, Tilt;
|
||||
SKP_float nrg, pre_nrg, log_energy, log_energy_prev, energy_variation;
|
||||
SKP_float delta, BWExp1, BWExp2, gain_mult, gain_add, strength, b, warping;
|
||||
|
@ -223,7 +223,7 @@ void silk_noise_shape_analysis_FLP(
|
|||
/********************************************/
|
||||
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
|
||||
/* Apply window: sine slope followed by flat part followed by cosine slope */
|
||||
SKP_int shift, slope_part, flat_part;
|
||||
opus_int shift, slope_part, flat_part;
|
||||
flat_part = psEnc->sCmn.fs_kHz * 3;
|
||||
slope_part = ( psEnc->sCmn.shapeWinLength - flat_part ) / 2;
|
||||
|
||||
|
|
|
@ -47,65 +47,65 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
static void silk_P_Ana_calc_corr_st3(
|
||||
SKP_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
||||
const SKP_float signal[], /* I vector to correlate */
|
||||
SKP_int start_lag, /* I start lag */
|
||||
SKP_int sf_length, /* I sub frame length */
|
||||
SKP_int nb_subfr, /* I number of subframes */
|
||||
SKP_int complexity /* I Complexity setting */
|
||||
opus_int start_lag, /* I start lag */
|
||||
opus_int sf_length, /* I sub frame length */
|
||||
opus_int nb_subfr, /* I number of subframes */
|
||||
opus_int complexity /* I Complexity setting */
|
||||
);
|
||||
|
||||
static void silk_P_Ana_calc_energy_st3(
|
||||
SKP_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
||||
const SKP_float signal[], /* I vector to correlate */
|
||||
SKP_int start_lag, /* I start lag */
|
||||
SKP_int sf_length, /* I sub frame length */
|
||||
SKP_int nb_subfr, /* I number of subframes */
|
||||
SKP_int complexity /* I Complexity setting */
|
||||
opus_int start_lag, /* I start lag */
|
||||
opus_int sf_length, /* I sub frame length */
|
||||
opus_int nb_subfr, /* I number of subframes */
|
||||
opus_int complexity /* I Complexity setting */
|
||||
);
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//% CORE PITCH ANALYSIS FUNCTION %
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */
|
||||
opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */
|
||||
const SKP_float *signal, /* I signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
|
||||
SKP_int *pitch_out, /* O 4 pitch lag values */
|
||||
SKP_int16 *lagIndex, /* O lag Index */
|
||||
SKP_int8 *contourIndex, /* O pitch contour Index */
|
||||
opus_int *pitch_out, /* O 4 pitch lag values */
|
||||
opus_int16 *lagIndex, /* O lag Index */
|
||||
opus_int8 *contourIndex, /* O pitch contour Index */
|
||||
SKP_float *LTPCorr, /* I/O normalized correlation; input: value from previous frame */
|
||||
SKP_int prevLag, /* I last lag of previous frame; set to zero is unvoiced */
|
||||
opus_int prevLag, /* I last lag of previous frame; set to zero is unvoiced */
|
||||
const SKP_float search_thres1, /* I first stage threshold for lag candidates 0 - 1 */
|
||||
const SKP_float search_thres2, /* I final threshold for lag candidates 0 - 1 */
|
||||
const SKP_int Fs_kHz, /* I sample frequency (kHz) */
|
||||
const SKP_int complexity, /* I Complexity setting, 0-2, where 2 is highest */
|
||||
const SKP_int nb_subfr /* I number of 5 ms subframes */
|
||||
const opus_int Fs_kHz, /* I sample frequency (kHz) */
|
||||
const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */
|
||||
const opus_int nb_subfr /* I number of 5 ms subframes */
|
||||
)
|
||||
{
|
||||
SKP_int i, k, d, j;
|
||||
opus_int i, k, d, j;
|
||||
SKP_float signal_8kHz[ PE_MAX_FRAME_LENGTH_MS * 8 ];
|
||||
SKP_float signal_4kHz[ PE_MAX_FRAME_LENGTH_MS * 4 ];
|
||||
SKP_int16 signal_8_FIX[ PE_MAX_FRAME_LENGTH_MS * 8 ];
|
||||
SKP_int16 signal_4_FIX[ PE_MAX_FRAME_LENGTH_MS * 4 ];
|
||||
SKP_int32 filt_state[ 6 ];
|
||||
opus_int16 signal_8_FIX[ PE_MAX_FRAME_LENGTH_MS * 8 ];
|
||||
opus_int16 signal_4_FIX[ PE_MAX_FRAME_LENGTH_MS * 4 ];
|
||||
opus_int32 filt_state[ 6 ];
|
||||
SKP_float threshold, contour_bias;
|
||||
SKP_float C[ PE_MAX_NB_SUBFR][ (PE_MAX_LAG >> 1) + 5 ];
|
||||
SKP_float CC[ PE_NB_CBKS_STAGE2_EXT ];
|
||||
const SKP_float *target_ptr, *basis_ptr;
|
||||
double cross_corr, normalizer, energy, energy_tmp;
|
||||
SKP_int d_srch[ PE_D_SRCH_LENGTH ];
|
||||
SKP_int16 d_comp[ (PE_MAX_LAG >> 1) + 5 ];
|
||||
SKP_int length_d_srch, length_d_comp;
|
||||
opus_int d_srch[ PE_D_SRCH_LENGTH ];
|
||||
opus_int16 d_comp[ (PE_MAX_LAG >> 1) + 5 ];
|
||||
opus_int length_d_srch, length_d_comp;
|
||||
SKP_float Cmax, CCmax, CCmax_b, CCmax_new_b, CCmax_new;
|
||||
SKP_int CBimax, CBimax_new, lag, start_lag, end_lag, lag_new;
|
||||
SKP_int cbk_size;
|
||||
opus_int CBimax, CBimax_new, lag, start_lag, end_lag, lag_new;
|
||||
opus_int cbk_size;
|
||||
SKP_float lag_log2, prevLag_log2, delta_lag_log2_sqr;
|
||||
SKP_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ];
|
||||
SKP_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ];
|
||||
SKP_int lag_counter;
|
||||
SKP_int frame_length, frame_length_8kHz, frame_length_4kHz;
|
||||
SKP_int sf_length, sf_length_8kHz, sf_length_4kHz;
|
||||
SKP_int min_lag, min_lag_8kHz, min_lag_4kHz;
|
||||
SKP_int max_lag, max_lag_8kHz, max_lag_4kHz;
|
||||
SKP_int nb_cbk_search;
|
||||
const SKP_int8 *Lag_CB_ptr;
|
||||
opus_int lag_counter;
|
||||
opus_int frame_length, frame_length_8kHz, frame_length_4kHz;
|
||||
opus_int sf_length, sf_length_8kHz, sf_length_4kHz;
|
||||
opus_int min_lag, min_lag_8kHz, min_lag_4kHz;
|
||||
opus_int max_lag, max_lag_8kHz, max_lag_4kHz;
|
||||
opus_int nb_cbk_search;
|
||||
const opus_int8 *Lag_CB_ptr;
|
||||
|
||||
/* Check for valid sampling frequency */
|
||||
SKP_assert( Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16 );
|
||||
|
@ -136,16 +136,16 @@ SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoice
|
|||
/* Resample from input sampled at Fs_kHz to 8 kHz */
|
||||
if( Fs_kHz == 16 ) {
|
||||
/* Resample to 16 -> 8 khz */
|
||||
SKP_int16 signal_16_FIX[ 16 * PE_MAX_FRAME_LENGTH_MS ];
|
||||
opus_int16 signal_16_FIX[ 16 * PE_MAX_FRAME_LENGTH_MS ];
|
||||
SKP_float2short_array( signal_16_FIX, signal, frame_length );
|
||||
SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) );
|
||||
SKP_memset( filt_state, 0, 2 * sizeof( opus_int32 ) );
|
||||
silk_resampler_down2( filt_state, signal_8_FIX, signal_16_FIX, frame_length );
|
||||
SKP_short2float_array( signal_8kHz, signal_8_FIX, frame_length_8kHz );
|
||||
} else if( Fs_kHz == 12 ) {
|
||||
/* Resample to 12 -> 8 khz */
|
||||
SKP_int16 signal_12_FIX[ 12 * PE_MAX_FRAME_LENGTH_MS ];
|
||||
opus_int16 signal_12_FIX[ 12 * PE_MAX_FRAME_LENGTH_MS ];
|
||||
SKP_float2short_array( signal_12_FIX, signal, frame_length );
|
||||
SKP_memset( filt_state, 0, 6 * sizeof( SKP_int32 ) );
|
||||
SKP_memset( filt_state, 0, 6 * sizeof( opus_int32 ) );
|
||||
silk_resampler_down2_3( filt_state, signal_8_FIX, signal_12_FIX, frame_length );
|
||||
SKP_short2float_array( signal_8kHz, signal_8_FIX, frame_length_8kHz );
|
||||
} else {
|
||||
|
@ -154,7 +154,7 @@ SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoice
|
|||
}
|
||||
|
||||
/* Decimate again to 4 kHz */
|
||||
SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) );
|
||||
SKP_memset( filt_state, 0, 2 * sizeof( opus_int32 ) );
|
||||
silk_resampler_down2( filt_state, signal_4_FIX, signal_8_FIX, frame_length_8kHz );
|
||||
SKP_short2float_array( signal_4kHz, signal_4_FIX, frame_length_4kHz );
|
||||
|
||||
|
@ -223,7 +223,7 @@ SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoice
|
|||
}
|
||||
threshold = Cmax * Cmax;
|
||||
if( energy / 16.0f > threshold ) {
|
||||
SKP_memset( pitch_out, 0, nb_subfr * sizeof( SKP_int ) );
|
||||
SKP_memset( pitch_out, 0, nb_subfr * sizeof( opus_int ) );
|
||||
*LTPCorr = 0.0f;
|
||||
*lagIndex = 0;
|
||||
*contourIndex = 0;
|
||||
|
@ -270,7 +270,7 @@ SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoice
|
|||
length_d_comp = 0;
|
||||
for( i = min_lag_8kHz; i < max_lag_8kHz + 4; i++ ) {
|
||||
if( d_comp[ i ] > 0 ) {
|
||||
d_comp[ length_d_comp ] = (SKP_int16)( i - 2 );
|
||||
d_comp[ length_d_comp ] = (opus_int16)( i - 2 );
|
||||
length_d_comp++;
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoice
|
|||
|
||||
if( lag == -1 ) {
|
||||
/* No suitable candidate found */
|
||||
SKP_memset( pitch_out, 0, PE_MAX_NB_SUBFR * sizeof(SKP_int) );
|
||||
SKP_memset( pitch_out, 0, PE_MAX_NB_SUBFR * sizeof(opus_int) );
|
||||
*LTPCorr = 0.0f;
|
||||
*lagIndex = 0;
|
||||
*contourIndex = 0;
|
||||
|
@ -425,7 +425,7 @@ SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoice
|
|||
|
||||
/* Setup cbk parameters acording to complexity setting and frame length */
|
||||
if( nb_subfr == PE_MAX_NB_SUBFR ) {
|
||||
nb_cbk_search = (SKP_int)silk_nb_cbk_searchs_stage3[ complexity ];
|
||||
nb_cbk_search = (opus_int)silk_nb_cbk_searchs_stage3[ complexity ];
|
||||
cbk_size = PE_NB_CBKS_STAGE3_MAX;
|
||||
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
|
||||
} else {
|
||||
|
@ -451,7 +451,7 @@ SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoice
|
|||
}
|
||||
|
||||
if( CCmax_new > CCmax &&
|
||||
( d + (SKP_int)silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag
|
||||
( d + (opus_int)silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag
|
||||
) {
|
||||
CCmax = CCmax_new;
|
||||
lag_new = d;
|
||||
|
@ -464,8 +464,8 @@ SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoice
|
|||
for( k = 0; k < nb_subfr; k++ ) {
|
||||
pitch_out[ k ] = lag_new + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size );
|
||||
}
|
||||
*lagIndex = (SKP_int16)( lag_new - min_lag );
|
||||
*contourIndex = (SKP_int8)CBimax;
|
||||
*lagIndex = (opus_int16)( lag_new - min_lag );
|
||||
*contourIndex = (opus_int8)CBimax;
|
||||
} else {
|
||||
/* Save Lags and correlation */
|
||||
SKP_assert( CCmax >= 0.0f );
|
||||
|
@ -473,8 +473,8 @@ SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoice
|
|||
for( k = 0; k < nb_subfr; k++ ) {
|
||||
pitch_out[ k ] = lag + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size );
|
||||
}
|
||||
*lagIndex = (SKP_int16)( lag - min_lag );
|
||||
*contourIndex = (SKP_int8)CBimax;
|
||||
*lagIndex = (opus_int16)( lag - min_lag );
|
||||
*contourIndex = (opus_int8)CBimax;
|
||||
}
|
||||
SKP_assert( *lagIndex >= 0 );
|
||||
/* return as voiced */
|
||||
|
@ -484,10 +484,10 @@ SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoice
|
|||
static void silk_P_Ana_calc_corr_st3(
|
||||
SKP_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
||||
const SKP_float signal[], /* I vector to correlate */
|
||||
SKP_int start_lag, /* I start lag */
|
||||
SKP_int sf_length, /* I sub frame length */
|
||||
SKP_int nb_subfr, /* I number of subframes */
|
||||
SKP_int complexity /* I Complexity setting */
|
||||
opus_int start_lag, /* I start lag */
|
||||
opus_int sf_length, /* I sub frame length */
|
||||
opus_int nb_subfr, /* I number of subframes */
|
||||
opus_int complexity /* I Complexity setting */
|
||||
)
|
||||
/***********************************************************************
|
||||
Calculates the correlations used in stage 3 search. In order to cover
|
||||
|
@ -504,10 +504,10 @@ static void silk_P_Ana_calc_corr_st3(
|
|||
**********************************************************************/
|
||||
{
|
||||
const SKP_float *target_ptr, *basis_ptr;
|
||||
SKP_int i, j, k, lag_counter, lag_low, lag_high;
|
||||
SKP_int nb_cbk_search, delta, idx, cbk_size;
|
||||
opus_int i, j, k, lag_counter, lag_low, lag_high;
|
||||
opus_int nb_cbk_search, delta, idx, cbk_size;
|
||||
SKP_float scratch_mem[ SCRATCH_SIZE ];
|
||||
const SKP_int8 *Lag_range_ptr, *Lag_CB_ptr;
|
||||
const opus_int8 *Lag_range_ptr, *Lag_CB_ptr;
|
||||
|
||||
SKP_assert( complexity >= SigProc_PE_MIN_COMPLEX );
|
||||
SKP_assert( complexity <= SigProc_PE_MAX_COMPLEX );
|
||||
|
@ -557,10 +557,10 @@ static void silk_P_Ana_calc_corr_st3(
|
|||
static void silk_P_Ana_calc_energy_st3(
|
||||
SKP_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
||||
const SKP_float signal[], /* I vector to correlate */
|
||||
SKP_int start_lag, /* I start lag */
|
||||
SKP_int sf_length, /* I sub frame length */
|
||||
SKP_int nb_subfr, /* I number of subframes */
|
||||
SKP_int complexity /* I Complexity setting */
|
||||
opus_int start_lag, /* I start lag */
|
||||
opus_int sf_length, /* I sub frame length */
|
||||
opus_int nb_subfr, /* I number of subframes */
|
||||
opus_int complexity /* I Complexity setting */
|
||||
)
|
||||
/****************************************************************
|
||||
Calculate the energies for first two subframes. The energies are
|
||||
|
@ -569,10 +569,10 @@ calculated recursively.
|
|||
{
|
||||
const SKP_float *target_ptr, *basis_ptr;
|
||||
double energy;
|
||||
SKP_int k, i, j, lag_counter;
|
||||
SKP_int nb_cbk_search, delta, idx, cbk_size, lag_diff;
|
||||
opus_int k, i, j, lag_counter;
|
||||
opus_int nb_cbk_search, delta, idx, cbk_size, lag_diff;
|
||||
SKP_float scratch_mem[ SCRATCH_SIZE ];
|
||||
const SKP_int8 *Lag_range_ptr, *Lag_CB_ptr;
|
||||
const opus_int8 *Lag_range_ptr, *Lag_CB_ptr;
|
||||
|
||||
SKP_assert( complexity >= SigProc_PE_MIN_COMPLEX );
|
||||
SKP_assert( complexity <= SigProc_PE_MAX_COMPLEX );
|
||||
|
|
|
@ -39,8 +39,8 @@ SKP_INLINE void silk_prefilt_FLP(
|
|||
SKP_float Tilt, /* I */
|
||||
SKP_float LF_MA_shp, /* I */
|
||||
SKP_float LF_AR_shp, /* I */
|
||||
SKP_int lag, /* I */
|
||||
SKP_int length /* I */
|
||||
opus_int lag, /* I */
|
||||
opus_int length /* I */
|
||||
);
|
||||
|
||||
void silk_warped_LPC_analysis_filter_FLP(
|
||||
|
@ -49,11 +49,11 @@ void silk_warped_LPC_analysis_filter_FLP(
|
|||
const SKP_float coef[], /* I Coefficients [order] */
|
||||
const SKP_float input[], /* I Input signal [length] */
|
||||
const SKP_float lambda, /* I Warping factor */
|
||||
const SKP_int length, /* I Length of input signal */
|
||||
const SKP_int order /* I Filter order (even) */
|
||||
const opus_int length, /* I Length of input signal */
|
||||
const opus_int order /* I Filter order (even) */
|
||||
)
|
||||
{
|
||||
SKP_int n, i;
|
||||
opus_int n, i;
|
||||
SKP_float acc, tmp1, tmp2;
|
||||
|
||||
/* Order must be even */
|
||||
|
@ -95,7 +95,7 @@ void silk_prefilter_FLP(
|
|||
)
|
||||
{
|
||||
silk_prefilter_state_FLP *P = &psEnc->sPrefilt;
|
||||
SKP_int j, k, lag;
|
||||
opus_int j, k, lag;
|
||||
SKP_float HarmShapeGain, Tilt, LF_MA_shp, LF_AR_shp;
|
||||
SKP_float B[ 2 ];
|
||||
const SKP_float *AR1_shp;
|
||||
|
@ -157,12 +157,12 @@ SKP_INLINE void silk_prefilt_FLP(
|
|||
SKP_float Tilt, /* I */
|
||||
SKP_float LF_MA_shp, /* I */
|
||||
SKP_float LF_AR_shp, /* I */
|
||||
SKP_int lag, /* I */
|
||||
SKP_int length /* I */
|
||||
opus_int lag, /* I */
|
||||
opus_int length /* I */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
SKP_int idx, LTP_shp_buf_idx;
|
||||
opus_int i;
|
||||
opus_int idx, LTP_shp_buf_idx;
|
||||
SKP_float n_Tilt, n_LF, n_LTP;
|
||||
SKP_float sLF_AR_shp, sLF_MA_shp;
|
||||
SKP_float *LTP_shp_buf;
|
||||
|
|
|
@ -35,8 +35,8 @@ void silk_process_gains_FLP(
|
|||
)
|
||||
{
|
||||
silk_shape_state_FLP *psShapeSt = &psEnc->sShape;
|
||||
SKP_int k;
|
||||
SKP_int32 pGains_Q16[ MAX_NB_SUBFR ];
|
||||
opus_int k;
|
||||
opus_int32 pGains_Q16[ MAX_NB_SUBFR ];
|
||||
SKP_float s, InvMaxSqrVal, gain, quant_offset;
|
||||
|
||||
/* Gain reduction when LTP coding gain is high */
|
||||
|
@ -59,7 +59,7 @@ void silk_process_gains_FLP(
|
|||
|
||||
/* Prepare gains for noise shaping quantization */
|
||||
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
|
||||
pGains_Q16[ k ] = ( SKP_int32 ) ( psEncCtrl->Gains[ k ] * 65536.0f );
|
||||
pGains_Q16[ k ] = ( opus_int32 ) ( psEncCtrl->Gains[ k ] * 65536.0f );
|
||||
}
|
||||
|
||||
/* Noise shaping quantization */
|
||||
|
|
|
@ -31,10 +31,10 @@ void silk_regularize_correlations_FLP(
|
|||
SKP_float *XX, /* I/O Correlation matrices */
|
||||
SKP_float *xx, /* I/O Correlation values */
|
||||
const SKP_float noise, /* I Noise energy to add */
|
||||
const SKP_int D /* I Dimension of XX */
|
||||
const opus_int D /* I Dimension of XX */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
opus_int i;
|
||||
|
||||
for( i = 0; i < D; i++ ) {
|
||||
matrix_ptr( &XX[ 0 ], i, i, D ) += noise;
|
||||
|
|
|
@ -36,10 +36,10 @@ SKP_float silk_residual_energy_covar_FLP( /* O Weighted residual en
|
|||
SKP_float *wXX, /* I/O Weighted correlation matrix, reg. out */
|
||||
const SKP_float *wXx, /* I Weighted correlation vector */
|
||||
const SKP_float wxx, /* I Weighted correlation value */
|
||||
const SKP_int D /* I Dimension */
|
||||
const opus_int D /* I Dimension */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, k;
|
||||
opus_int i, j, k;
|
||||
SKP_float tmp, nrg = 0.0f, regularization;
|
||||
|
||||
/* Safety checks */
|
||||
|
@ -89,12 +89,12 @@ void silk_residual_energy_FLP(
|
|||
const SKP_float x[], /* I Input signal */
|
||||
SKP_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
|
||||
const SKP_float gains[], /* I Quantization gains */
|
||||
const SKP_int subfr_length, /* I Subframe length */
|
||||
const SKP_int nb_subfr, /* I number of subframes */
|
||||
const SKP_int LPC_order /* I LPC order */
|
||||
const opus_int subfr_length, /* I Subframe length */
|
||||
const opus_int nb_subfr, /* I number of subframes */
|
||||
const opus_int LPC_order /* I LPC order */
|
||||
)
|
||||
{
|
||||
SKP_int shift;
|
||||
opus_int shift;
|
||||
SKP_float *LPC_res_ptr, LPC_res[ ( MAX_FRAME_LENGTH + MAX_NB_SUBFR * MAX_LPC_ORDER ) / 2 ];
|
||||
|
||||
LPC_res_ptr = LPC_res + LPC_order;
|
||||
|
|
|
@ -32,10 +32,10 @@ void silk_scale_copy_vector_FLP(
|
|||
SKP_float *data_out,
|
||||
const SKP_float *data_in,
|
||||
SKP_float gain,
|
||||
SKP_int dataSize
|
||||
opus_int dataSize
|
||||
)
|
||||
{
|
||||
SKP_int i, dataSize4;
|
||||
opus_int i, dataSize4;
|
||||
|
||||
/* 4x unrolled loop */
|
||||
dataSize4 = dataSize & 0xFFFC;
|
||||
|
|
|
@ -31,10 +31,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
void silk_scale_vector_FLP(
|
||||
SKP_float *data1,
|
||||
SKP_float gain,
|
||||
SKP_int dataSize
|
||||
opus_int dataSize
|
||||
)
|
||||
{
|
||||
SKP_int i, dataSize4;
|
||||
opus_int i, dataSize4;
|
||||
|
||||
/* 4x unrolled loop */
|
||||
dataSize4 = dataSize & 0xFFFC;
|
||||
|
|
|
@ -30,10 +30,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
SKP_float silk_schur_FLP( /* O returns residual energy */
|
||||
SKP_float refl_coef[], /* O reflection coefficients (length order) */
|
||||
const SKP_float auto_corr[], /* I autotcorrelation sequence (length order+1) */
|
||||
SKP_int order /* I order */
|
||||
opus_int order /* I order */
|
||||
)
|
||||
{
|
||||
SKP_int k, n;
|
||||
opus_int k, n;
|
||||
SKP_float C[ SILK_MAX_ORDER_LPC + 1 ][ 2 ];
|
||||
SKP_float Ctmp1, Ctmp2, rc_tmp;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
**********************************************************************/
|
||||
void silk_LDL_FLP(
|
||||
SKP_float *A, /* (I/O) Pointer to Symetric Square Matrix */
|
||||
SKP_int M, /* (I) Size of Matrix */
|
||||
opus_int M, /* (I) Size of Matrix */
|
||||
SKP_float *L, /* (I/O) Pointer to Square Upper triangular Matrix */
|
||||
SKP_float *Dinv /* (I/O) Pointer to vector holding the inverse diagonal elements of D */
|
||||
);
|
||||
|
@ -46,7 +46,7 @@ void silk_LDL_FLP(
|
|||
**********************************************************************/
|
||||
void silk_SolveWithLowerTriangularWdiagOnes_FLP(
|
||||
const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */
|
||||
SKP_int M, /* (I) Dim of Matrix equation */
|
||||
opus_int M, /* (I) Dim of Matrix equation */
|
||||
const SKP_float *b, /* (I) b Vector */
|
||||
SKP_float *x /* (O) x Vector */
|
||||
);
|
||||
|
@ -57,7 +57,7 @@ void silk_SolveWithLowerTriangularWdiagOnes_FLP(
|
|||
**********************************************************************/
|
||||
void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP(
|
||||
const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */
|
||||
SKP_int M, /* (I) Dim of Matrix equation */
|
||||
opus_int M, /* (I) Dim of Matrix equation */
|
||||
const SKP_float *b, /* (I) b Vector */
|
||||
SKP_float *x /* (O) x Vector */
|
||||
);
|
||||
|
@ -68,12 +68,12 @@ void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP(
|
|||
**********************************************************************/
|
||||
void silk_solve_LDL_FLP(
|
||||
SKP_float *A, /* I/O Symmetric square matrix, out: reg. */
|
||||
const SKP_int M, /* I Size of matrix */
|
||||
const opus_int M, /* I Size of matrix */
|
||||
const SKP_float *b, /* I Pointer to b vector */
|
||||
SKP_float *x /* O Pointer to x solution vector */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
opus_int i;
|
||||
SKP_float L[ MAX_MATRIX_SIZE ][ MAX_MATRIX_SIZE ];
|
||||
SKP_float T[ MAX_MATRIX_SIZE ];
|
||||
SKP_float Dinv[ MAX_MATRIX_SIZE ]; // inverse diagonal elements of D
|
||||
|
@ -107,12 +107,12 @@ void silk_solve_LDL_FLP(
|
|||
|
||||
void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP(
|
||||
const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */
|
||||
SKP_int M, /* (I) Dim of Matrix equation */
|
||||
opus_int M, /* (I) Dim of Matrix equation */
|
||||
const SKP_float *b, /* (I) b Vector */
|
||||
SKP_float *x /* (O) x Vector */
|
||||
)
|
||||
{
|
||||
SKP_int i, j;
|
||||
opus_int i, j;
|
||||
SKP_float temp;
|
||||
const SKP_float *ptr1;
|
||||
|
||||
|
@ -129,12 +129,12 @@ void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP(
|
|||
|
||||
void silk_SolveWithLowerTriangularWdiagOnes_FLP(
|
||||
const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */
|
||||
SKP_int M, /* (I) Dim of Matrix equation */
|
||||
opus_int M, /* (I) Dim of Matrix equation */
|
||||
const SKP_float *b, /* (I) b Vector */
|
||||
SKP_float *x /* (O) x Vector */
|
||||
)
|
||||
{
|
||||
SKP_int i, j;
|
||||
opus_int i, j;
|
||||
SKP_float temp;
|
||||
const SKP_float *ptr1;
|
||||
|
||||
|
@ -151,12 +151,12 @@ void silk_SolveWithLowerTriangularWdiagOnes_FLP(
|
|||
|
||||
void silk_LDL_FLP(
|
||||
SKP_float *A, /* (I/O) Pointer to Symetric Square Matrix */
|
||||
SKP_int M, /* (I) Size of Matrix */
|
||||
opus_int M, /* (I) Size of Matrix */
|
||||
SKP_float *L, /* (I/O) Pointer to Square Upper triangular Matrix */
|
||||
SKP_float *Dinv /* (I/O) Pointer to vector holding the inverse diagonal elements of D */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, k, loop_count, err = 1;
|
||||
opus_int i, j, k, loop_count, err = 1;
|
||||
SKP_float *ptr1, *ptr2;
|
||||
double temp, diag_min_value;
|
||||
SKP_float v[ MAX_MATRIX_SIZE ], D[ MAX_MATRIX_SIZE ]; // temp arrays
|
||||
|
|
|
@ -34,13 +34,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
void silk_insertion_sort_decreasing_FLP(
|
||||
SKP_float *a, /* I/O: Unsorted / Sorted vector */
|
||||
SKP_int *idx, /* O: Index vector for the sorted elements */
|
||||
const SKP_int L, /* I: Vector length */
|
||||
const SKP_int K /* I: Number of correctly sorted positions */
|
||||
opus_int *idx, /* O: Index vector for the sorted elements */
|
||||
const opus_int L, /* I: Vector length */
|
||||
const opus_int K /* I: Number of correctly sorted positions */
|
||||
)
|
||||
{
|
||||
SKP_float value;
|
||||
SKP_int i, j;
|
||||
opus_int i, j;
|
||||
|
||||
/* Safety checks */
|
||||
SKP_assert( K > 0 );
|
||||
|
|
|
@ -41,7 +41,7 @@ extern "C"
|
|||
/* Noise shaping analysis state */
|
||||
/********************************/
|
||||
typedef struct {
|
||||
SKP_int8 LastGainIndex;
|
||||
opus_int8 LastGainIndex;
|
||||
SKP_float HarmBoost_smth;
|
||||
SKP_float HarmShapeGain_smth;
|
||||
SKP_float Tilt_smth;
|
||||
|
@ -53,12 +53,12 @@ typedef struct {
|
|||
typedef struct {
|
||||
SKP_float sLTP_shp[ LTP_BUF_LENGTH ];
|
||||
SKP_float sAR_shp[ MAX_SHAPE_LPC_ORDER + 1 ];
|
||||
SKP_int sLTP_shp_buf_idx;
|
||||
opus_int sLTP_shp_buf_idx;
|
||||
SKP_float sLF_AR_shp;
|
||||
SKP_float sLF_MA_shp;
|
||||
SKP_float sHarmHP;
|
||||
SKP_int32 rand_seed;
|
||||
SKP_int lagPrev;
|
||||
opus_int32 rand_seed;
|
||||
opus_int lagPrev;
|
||||
} silk_prefilter_state_FLP;
|
||||
|
||||
/********************************/
|
||||
|
@ -87,7 +87,7 @@ typedef struct {
|
|||
SKP_float PredCoef[ 2 ][ MAX_LPC_ORDER ]; /* holds interpolated and final coefficients */
|
||||
SKP_float LTPCoef[LTP_ORDER * MAX_NB_SUBFR];
|
||||
SKP_float LTP_scale;
|
||||
SKP_int pitchL[ MAX_NB_SUBFR ];
|
||||
opus_int pitchL[ MAX_NB_SUBFR ];
|
||||
|
||||
/* Noise shaping parameters */
|
||||
SKP_float AR1[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
||||
|
@ -115,11 +115,11 @@ typedef struct {
|
|||
typedef struct {
|
||||
silk_encoder_state_FLP state_Fxx[ ENCODER_NUM_CHANNELS ];
|
||||
stereo_enc_state sStereo;
|
||||
SKP_int32 nBitsExceeded;
|
||||
SKP_int nChannelsAPI;
|
||||
SKP_int nChannelsInternal;
|
||||
SKP_int timeSinceSwitchAllowed_ms;
|
||||
SKP_int allowBandwidthSwitch;
|
||||
opus_int32 nBitsExceeded;
|
||||
opus_int nChannelsAPI;
|
||||
opus_int nChannelsInternal;
|
||||
opus_int timeSinceSwitchAllowed_ms;
|
||||
opus_int allowBandwidthSwitch;
|
||||
} silk_encoder;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -32,11 +32,11 @@ void silk_warped_autocorrelation_FLP(
|
|||
SKP_float *corr, /* O Result [order + 1] */
|
||||
const SKP_float *input, /* I Input data to correlate */
|
||||
const SKP_float warping, /* I Warping coefficient */
|
||||
const SKP_int length, /* I Length of input */
|
||||
const SKP_int order /* I Correlation order (even) */
|
||||
const opus_int length, /* I Length of input */
|
||||
const opus_int order /* I Correlation order (even) */
|
||||
)
|
||||
{
|
||||
SKP_int n, i;
|
||||
opus_int n, i;
|
||||
double tmp1, tmp2;
|
||||
double state[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 };
|
||||
double C[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 };
|
||||
|
|
|
@ -31,13 +31,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Convert AR filter coefficients to NLSF parameters */
|
||||
void silk_A2NLSF_FLP(
|
||||
SKP_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
|
||||
opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
|
||||
const SKP_float *pAR, /* I LPC coefficients [ LPC_order ] */
|
||||
const SKP_int LPC_order /* I LPC order */
|
||||
const opus_int LPC_order /* I LPC order */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
SKP_int32 a_fix_Q16[ MAX_LPC_ORDER ];
|
||||
opus_int i;
|
||||
opus_int32 a_fix_Q16[ MAX_LPC_ORDER ];
|
||||
|
||||
for( i = 0; i < LPC_order; i++ ) {
|
||||
a_fix_Q16[ i ] = SKP_float2int( pAR[ i ] * 65536.0f );
|
||||
|
@ -49,12 +49,12 @@ void silk_A2NLSF_FLP(
|
|||
/* Convert LSF parameters to AR prediction filter coefficients */
|
||||
void silk_NLSF2A_FLP(
|
||||
SKP_float *pAR, /* O LPC coefficients [ LPC_order ] */
|
||||
const SKP_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
|
||||
const SKP_int LPC_order /* I LPC order */
|
||||
const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
|
||||
const opus_int LPC_order /* I LPC order */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
SKP_int16 a_fix_Q12[ MAX_LPC_ORDER ];
|
||||
opus_int i;
|
||||
opus_int16 a_fix_Q12[ MAX_LPC_ORDER ];
|
||||
|
||||
silk_NLSF2A( a_fix_Q12, NLSF_Q15, LPC_order );
|
||||
|
||||
|
@ -69,12 +69,12 @@ void silk_NLSF2A_FLP(
|
|||
void silk_process_NLSFs_FLP(
|
||||
silk_encoder_state *psEncC, /* I/O Encoder state */
|
||||
SKP_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */
|
||||
SKP_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
|
||||
const SKP_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
|
||||
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
|
||||
const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
|
||||
)
|
||||
{
|
||||
SKP_int i, j;
|
||||
SKP_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
|
||||
opus_int i, j;
|
||||
opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
|
||||
|
||||
silk_process_NLSFs( psEncC, PredCoef_Q12, NLSF_Q15, prev_NLSF_Q15);
|
||||
|
||||
|
@ -93,23 +93,23 @@ void silk_NSQ_wrapper_FLP(
|
|||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||
SideInfoIndices *psIndices, /* I/O Quantization indices */
|
||||
silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
|
||||
SKP_int8 pulses[], /* O Quantized pulse signal */
|
||||
opus_int8 pulses[], /* O Quantized pulse signal */
|
||||
const SKP_float x[] /* I Prefiltered input signal */
|
||||
)
|
||||
{
|
||||
SKP_int i, j;
|
||||
SKP_int16 x_16[ MAX_FRAME_LENGTH ];
|
||||
SKP_int32 Gains_Q16[ MAX_NB_SUBFR ];
|
||||
SKP_DWORD_ALIGN SKP_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
|
||||
SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ];
|
||||
SKP_int LTP_scale_Q14;
|
||||
opus_int i, j;
|
||||
opus_int16 x_16[ MAX_FRAME_LENGTH ];
|
||||
opus_int32 Gains_Q16[ MAX_NB_SUBFR ];
|
||||
SKP_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
|
||||
opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ];
|
||||
opus_int LTP_scale_Q14;
|
||||
|
||||
/* Noise shaping parameters */
|
||||
SKP_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
||||
SKP_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */
|
||||
SKP_int Lambda_Q10;
|
||||
SKP_int Tilt_Q14[ MAX_NB_SUBFR ];
|
||||
SKP_int HarmShapeGain_Q14[ MAX_NB_SUBFR ];
|
||||
opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
||||
opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */
|
||||
opus_int Lambda_Q10;
|
||||
opus_int Tilt_Q14[ MAX_NB_SUBFR ];
|
||||
opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ];
|
||||
|
||||
/* Convert control struct to fix control struct */
|
||||
/* Noise shape parameters */
|
||||
|
@ -121,20 +121,20 @@ void silk_NSQ_wrapper_FLP(
|
|||
|
||||
for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
|
||||
LF_shp_Q14[ i ] = SKP_LSHIFT32( SKP_float2int( psEncCtrl->LF_AR_shp[ i ] * 16384.0f ), 16 ) |
|
||||
(SKP_uint16)SKP_float2int( psEncCtrl->LF_MA_shp[ i ] * 16384.0f );
|
||||
Tilt_Q14[ i ] = (SKP_int)SKP_float2int( psEncCtrl->Tilt[ i ] * 16384.0f );
|
||||
HarmShapeGain_Q14[ i ] = (SKP_int)SKP_float2int( psEncCtrl->HarmShapeGain[ i ] * 16384.0f );
|
||||
(opus_uint16)SKP_float2int( psEncCtrl->LF_MA_shp[ i ] * 16384.0f );
|
||||
Tilt_Q14[ i ] = (opus_int)SKP_float2int( psEncCtrl->Tilt[ i ] * 16384.0f );
|
||||
HarmShapeGain_Q14[ i ] = (opus_int)SKP_float2int( psEncCtrl->HarmShapeGain[ i ] * 16384.0f );
|
||||
}
|
||||
Lambda_Q10 = ( SKP_int )SKP_float2int( psEncCtrl->Lambda * 1024.0f );
|
||||
Lambda_Q10 = ( opus_int )SKP_float2int( psEncCtrl->Lambda * 1024.0f );
|
||||
|
||||
/* prediction and coding parameters */
|
||||
for( i = 0; i < psEnc->sCmn.nb_subfr * LTP_ORDER; i++ ) {
|
||||
LTPCoef_Q14[ i ] = ( SKP_int16 )SKP_float2int( psEncCtrl->LTPCoef[ i ] * 16384.0f );
|
||||
LTPCoef_Q14[ i ] = ( opus_int16 )SKP_float2int( psEncCtrl->LTPCoef[ i ] * 16384.0f );
|
||||
}
|
||||
|
||||
for( j = 0; j < 2; j++ ) {
|
||||
for( i = 0; i < psEnc->sCmn.predictLPCOrder; i++ ) {
|
||||
PredCoef_Q12[ j ][ i ] = ( SKP_int16 )SKP_float2int( psEncCtrl->PredCoef[ j ][ i ] * 4096.0f );
|
||||
PredCoef_Q12[ j ][ i ] = ( opus_int16 )SKP_float2int( psEncCtrl->PredCoef[ j ][ i ] * 4096.0f );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,23 +167,23 @@ void silk_NSQ_wrapper_FLP(
|
|||
/***********************************************/
|
||||
void silk_quant_LTP_gains_FLP(
|
||||
SKP_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (Un-)quantized LTP gains */
|
||||
SKP_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */
|
||||
SKP_int8 *periodicity_index, /* O Periodicity index */
|
||||
opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */
|
||||
opus_int8 *periodicity_index, /* O Periodicity index */
|
||||
const SKP_float W[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Error weights */
|
||||
const SKP_int mu_Q10, /* I Mu value (R/D tradeoff) */
|
||||
const SKP_int lowComplexity, /* I Flag for low complexity */
|
||||
const SKP_int nb_subfr /* I number of subframes */
|
||||
const opus_int mu_Q10, /* I Mu value (R/D tradeoff) */
|
||||
const opus_int lowComplexity, /* I Flag for low complexity */
|
||||
const opus_int nb_subfr /* I number of subframes */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
SKP_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ];
|
||||
SKP_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ];
|
||||
opus_int i;
|
||||
opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ];
|
||||
opus_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ];
|
||||
|
||||
for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) {
|
||||
B_Q14[ i ] = (SKP_int16)SKP_float2int( B[ i ] * 16384.0f );
|
||||
B_Q14[ i ] = (opus_int16)SKP_float2int( B[ i ] * 16384.0f );
|
||||
}
|
||||
for( i = 0; i < nb_subfr * LTP_ORDER * LTP_ORDER; i++ ) {
|
||||
W_Q18[ i ] = (SKP_int32)SKP_float2int( W[ i ] * 262144.0f );
|
||||
W_Q18[ i ] = (opus_int32)SKP_float2int( W[ i ] * 262144.0f );
|
||||
}
|
||||
|
||||
silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, W_Q18, mu_Q10, lowComplexity, nb_subfr );
|
||||
|
|
|
@ -45,11 +45,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/* Helper function for A2NLSF(..) */
|
||||
/* Transforms polynomials from cos(n*f) to cos(f)^n */
|
||||
SKP_INLINE void silk_A2NLSF_trans_poly(
|
||||
SKP_int32 *p, /* I/O Polynomial */
|
||||
const SKP_int dd /* I Polynomial order (= filter order / 2 ) */
|
||||
opus_int32 *p, /* I/O Polynomial */
|
||||
const opus_int dd /* I Polynomial order (= filter order / 2 ) */
|
||||
)
|
||||
{
|
||||
SKP_int k, n;
|
||||
opus_int k, n;
|
||||
|
||||
for( k = 2; k <= dd; k++ ) {
|
||||
for( n = dd; n > k; n-- ) {
|
||||
|
@ -60,14 +60,14 @@ SKP_INLINE void silk_A2NLSF_trans_poly(
|
|||
}
|
||||
/* Helper function for A2NLSF(..) */
|
||||
/* Polynomial evaluation */
|
||||
SKP_INLINE SKP_int32 silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */
|
||||
SKP_int32 *p, /* I Polynomial, QPoly */
|
||||
const SKP_int32 x, /* I Evaluation point, Q12 */
|
||||
const SKP_int dd /* I Order */
|
||||
SKP_INLINE opus_int32 silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */
|
||||
opus_int32 *p, /* I Polynomial, QPoly */
|
||||
const opus_int32 x, /* I Evaluation point, Q12 */
|
||||
const opus_int dd /* I Order */
|
||||
)
|
||||
{
|
||||
SKP_int n;
|
||||
SKP_int32 x_Q16, y32;
|
||||
opus_int n;
|
||||
opus_int32 x_Q16, y32;
|
||||
|
||||
y32 = p[ dd ]; /* QPoly */
|
||||
x_Q16 = SKP_LSHIFT( x, 4 );
|
||||
|
@ -78,13 +78,13 @@ SKP_INLINE SKP_int32 silk_A2NLSF_eval_poly( /* return the polynomial evaluati
|
|||
}
|
||||
|
||||
SKP_INLINE void silk_A2NLSF_init(
|
||||
const SKP_int32 *a_Q16,
|
||||
SKP_int32 *P,
|
||||
SKP_int32 *Q,
|
||||
const SKP_int dd
|
||||
const opus_int32 *a_Q16,
|
||||
opus_int32 *P,
|
||||
opus_int32 *Q,
|
||||
const opus_int dd
|
||||
)
|
||||
{
|
||||
SKP_int k;
|
||||
opus_int k;
|
||||
|
||||
/* Convert filter coefs to even and odd polynomials */
|
||||
P[dd] = SKP_LSHIFT( 1, QPoly );
|
||||
|
@ -118,19 +118,19 @@ SKP_INLINE void silk_A2NLSF_init(
|
|||
/* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */
|
||||
/* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */
|
||||
void silk_A2NLSF(
|
||||
SKP_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */
|
||||
SKP_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */
|
||||
const SKP_int d /* I Filter order (must be even) */
|
||||
opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */
|
||||
opus_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */
|
||||
const opus_int d /* I Filter order (must be even) */
|
||||
)
|
||||
{
|
||||
SKP_int i, k, m, dd, root_ix, ffrac;
|
||||
SKP_int32 xlo, xhi, xmid;
|
||||
SKP_int32 ylo, yhi, ymid;
|
||||
SKP_int32 nom, den;
|
||||
SKP_int32 P[ SILK_MAX_ORDER_LPC / 2 + 1 ];
|
||||
SKP_int32 Q[ SILK_MAX_ORDER_LPC / 2 + 1 ];
|
||||
SKP_int32 *PQ[ 2 ];
|
||||
SKP_int32 *p;
|
||||
opus_int i, k, m, dd, root_ix, ffrac;
|
||||
opus_int32 xlo, xhi, xmid;
|
||||
opus_int32 ylo, yhi, ymid;
|
||||
opus_int32 nom, den;
|
||||
opus_int32 P[ SILK_MAX_ORDER_LPC / 2 + 1 ];
|
||||
opus_int32 Q[ SILK_MAX_ORDER_LPC / 2 + 1 ];
|
||||
opus_int32 *PQ[ 2 ];
|
||||
opus_int32 *p;
|
||||
|
||||
/* Store pointers to array */
|
||||
PQ[ 0 ] = P;
|
||||
|
@ -211,9 +211,9 @@ void silk_A2NLSF(
|
|||
ffrac += SKP_DIV32( ylo, SKP_RSHIFT( ylo - yhi, 8 - BIN_DIV_STEPS_A2NLSF_FIX ) );
|
||||
}
|
||||
#if OVERSAMPLE_COSINE_TABLE
|
||||
NLSF[ root_ix ] = (SKP_int16)SKP_min_32( SKP_LSHIFT( (SKP_int32)k, 7 ) + ffrac, SKP_int16_MAX );
|
||||
NLSF[ root_ix ] = (opus_int16)SKP_min_32( SKP_LSHIFT( (opus_int32)k, 7 ) + ffrac, SKP_int16_MAX );
|
||||
#else
|
||||
NLSF[ root_ix ] = (SKP_int16)SKP_min_32( SKP_LSHIFT( (SKP_int32)k, 8 ) + ffrac, SKP_int16_MAX );
|
||||
NLSF[ root_ix ] = (opus_int16)SKP_min_32( SKP_LSHIFT( (opus_int32)k, 8 ) + ffrac, SKP_int16_MAX );
|
||||
#endif
|
||||
|
||||
SKP_assert( NLSF[ root_ix ] >= 0 );
|
||||
|
@ -250,9 +250,9 @@ void silk_A2NLSF(
|
|||
i++;
|
||||
if( i > MAX_ITERATIONS_A2NLSF_FIX ) {
|
||||
/* Set NLSFs to white spectrum and exit */
|
||||
NLSF[ 0 ] = (SKP_int16)SKP_DIV32_16( 1 << 15, d + 1 );
|
||||
NLSF[ 0 ] = (opus_int16)SKP_DIV32_16( 1 << 15, d + 1 );
|
||||
for( k = 1; k < d; k++ ) {
|
||||
NLSF[ k ] = (SKP_int16)SKP_SMULBB( k + 1, NLSF[ 0 ] );
|
||||
NLSF[ k ] = (opus_int16)SKP_SMULBB( k + 1, NLSF[ 0 ] );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ extern "C"
|
|||
|
||||
/* Struct for TOC (Table of Contents) */
|
||||
typedef struct {
|
||||
SKP_int VADFlag; /* Voice activity for packet */
|
||||
SKP_int VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in packet */
|
||||
SKP_int inbandFECFlag; /* Flag indicating if packet contains in-band FEC */
|
||||
opus_int VADFlag; /* Voice activity for packet */
|
||||
opus_int VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in packet */
|
||||
opus_int inbandFECFlag; /* Flag indicating if packet contains in-band FEC */
|
||||
} silk_TOC_struct;
|
||||
|
||||
/****************************************/
|
||||
|
@ -55,14 +55,14 @@ typedef struct {
|
|||
/***********************************************/
|
||||
/* Get size in bytes of the Silk encoder state */
|
||||
/***********************************************/
|
||||
SKP_int silk_Get_Encoder_Size( /* O: Returns error code */
|
||||
SKP_int32 *encSizeBytes /* O: Number of bytes in SILK encoder state */
|
||||
opus_int silk_Get_Encoder_Size( /* O: Returns error code */
|
||||
opus_int32 *encSizeBytes /* O: Number of bytes in SILK encoder state */
|
||||
);
|
||||
|
||||
/*************************/
|
||||
/* Init or reset encoder */
|
||||
/*************************/
|
||||
SKP_int silk_InitEncoder( /* O: Returns error code */
|
||||
opus_int silk_InitEncoder( /* O: Returns error code */
|
||||
void *encState, /* I/O: State */
|
||||
silk_EncControlStruct *encStatus /* O: Encoder Status */
|
||||
);
|
||||
|
@ -70,7 +70,7 @@ SKP_int silk_InitEncoder( /* O: Returns error co
|
|||
/***************************************/
|
||||
/* Read control structure from encoder */
|
||||
/***************************************/
|
||||
SKP_int silk_QueryEncoder( /* O: Returns error code */
|
||||
opus_int silk_QueryEncoder( /* O: Returns error code */
|
||||
const void *encState, /* I: State */
|
||||
silk_EncControlStruct *encStatus /* O: Encoder Status */
|
||||
);
|
||||
|
@ -80,14 +80,14 @@ SKP_int silk_QueryEncoder( /* O: Returns error co
|
|||
/**************************/
|
||||
/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */
|
||||
/* encControl->payloadSize_ms is set to */
|
||||
SKP_int silk_Encode( /* O: Returns error code */
|
||||
opus_int silk_Encode( /* O: Returns error code */
|
||||
void *encState, /* I/O: State */
|
||||
silk_EncControlStruct *encControl, /* I: Control status */
|
||||
const SKP_int16 *samplesIn, /* I: Speech sample input vector */
|
||||
SKP_int nSamplesIn, /* I: Number of samples in input vector */
|
||||
const opus_int16 *samplesIn, /* I: Speech sample input vector */
|
||||
opus_int nSamplesIn, /* I: Number of samples in input vector */
|
||||
ec_enc *psRangeEnc, /* I/O Compressor data structure */
|
||||
SKP_int32 *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
|
||||
const SKP_int prefillFlag /* I: Flag to indicate prefilling buffers no coding */
|
||||
opus_int32 *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
|
||||
const opus_int prefillFlag /* I: Flag to indicate prefilling buffers no coding */
|
||||
);
|
||||
|
||||
/****************************************/
|
||||
|
@ -97,37 +97,37 @@ SKP_int silk_Encode( /* O: Returns error co
|
|||
/***********************************************/
|
||||
/* Get size in bytes of the Silk decoder state */
|
||||
/***********************************************/
|
||||
SKP_int silk_Get_Decoder_Size( /* O: Returns error code */
|
||||
SKP_int32 *decSizeBytes /* O: Number of bytes in SILK decoder state */
|
||||
opus_int silk_Get_Decoder_Size( /* O: Returns error code */
|
||||
opus_int32 *decSizeBytes /* O: Number of bytes in SILK decoder state */
|
||||
);
|
||||
|
||||
/*************************/
|
||||
/* Init or Reset decoder */
|
||||
/*************************/
|
||||
SKP_int silk_InitDecoder( /* O: Returns error code */
|
||||
opus_int silk_InitDecoder( /* O: Returns error code */
|
||||
void *decState /* I/O: State */
|
||||
);
|
||||
|
||||
/******************/
|
||||
/* Decode a frame */
|
||||
/******************/
|
||||
SKP_int silk_Decode( /* O: Returns error code */
|
||||
opus_int silk_Decode( /* O: Returns error code */
|
||||
void* decState, /* I/O: State */
|
||||
silk_DecControlStruct* decControl, /* I/O: Control Structure */
|
||||
SKP_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode fec */
|
||||
SKP_int newPacketFlag, /* I: Indicates first decoder call for this packet */
|
||||
opus_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode fec */
|
||||
opus_int newPacketFlag, /* I: Indicates first decoder call for this packet */
|
||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||
SKP_int16 *samplesOut, /* O: Decoded output speech vector */
|
||||
SKP_int32 *nSamplesOut /* O: Number of samples decoded */
|
||||
opus_int16 *samplesOut, /* O: Decoded output speech vector */
|
||||
opus_int32 *nSamplesOut /* O: Number of samples decoded */
|
||||
);
|
||||
|
||||
/**************************************/
|
||||
/* Get table of contents for a packet */
|
||||
/**************************************/
|
||||
SKP_int silk_get_TOC(
|
||||
const SKP_uint8 *payload, /* I Payload data */
|
||||
const SKP_int nBytesIn, /* I: Number of input bytes */
|
||||
const SKP_int nFramesPerPayload, /* I: Number of SILK frames per payload */
|
||||
opus_int silk_get_TOC(
|
||||
const opus_uint8 *payload, /* I Payload data */
|
||||
const opus_int nBytesIn, /* I: Number of input bytes */
|
||||
const opus_int nFramesPerPayload, /* I: Number of SILK frames per payload */
|
||||
silk_TOC_struct *Silk_TOC /* O: Type of content */
|
||||
);
|
||||
|
||||
|
|
|
@ -29,15 +29,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Generates excitation for CNG LPC synthesis */
|
||||
SKP_INLINE void silk_CNG_exc(
|
||||
SKP_int32 residual_Q10[], /* O CNG residual signal Q10 */
|
||||
SKP_int32 exc_buf_Q10[], /* I Random samples buffer Q10 */
|
||||
SKP_int32 Gain_Q16, /* I Gain to apply */
|
||||
SKP_int length, /* I Length */
|
||||
SKP_int32 *rand_seed /* I/O Seed to random index generator */
|
||||
opus_int32 residual_Q10[], /* O CNG residual signal Q10 */
|
||||
opus_int32 exc_buf_Q10[], /* I Random samples buffer Q10 */
|
||||
opus_int32 Gain_Q16, /* I Gain to apply */
|
||||
opus_int length, /* I Length */
|
||||
opus_int32 *rand_seed /* I/O Seed to random index generator */
|
||||
)
|
||||
{
|
||||
SKP_int32 seed;
|
||||
SKP_int i, idx, exc_mask;
|
||||
opus_int32 seed;
|
||||
opus_int i, idx, exc_mask;
|
||||
|
||||
exc_mask = CNG_BUF_MASK_MAX;
|
||||
while( exc_mask > length ) {
|
||||
|
@ -47,10 +47,10 @@ SKP_INLINE void silk_CNG_exc(
|
|||
seed = *rand_seed;
|
||||
for( i = 0; i < length; i++ ) {
|
||||
seed = SKP_RAND( seed );
|
||||
idx = ( SKP_int )( SKP_RSHIFT( seed, 24 ) & exc_mask );
|
||||
idx = ( opus_int )( SKP_RSHIFT( seed, 24 ) & exc_mask );
|
||||
SKP_assert( idx >= 0 );
|
||||
SKP_assert( idx <= CNG_BUF_MASK_MAX );
|
||||
residual_Q10[ i ] = ( SKP_int16 )SKP_SAT16( SKP_SMULWW( exc_buf_Q10[ idx ], Gain_Q16 ) );
|
||||
residual_Q10[ i ] = ( opus_int16 )SKP_SAT16( SKP_SMULWW( exc_buf_Q10[ idx ], Gain_Q16 ) );
|
||||
}
|
||||
*rand_seed = seed;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void silk_CNG_Reset(
|
|||
silk_decoder_state *psDec /* I/O Decoder state */
|
||||
)
|
||||
{
|
||||
SKP_int i, NLSF_step_Q15, NLSF_acc_Q15;
|
||||
opus_int i, NLSF_step_Q15, NLSF_acc_Q15;
|
||||
|
||||
NLSF_step_Q15 = SKP_DIV32_16( SKP_int16_MAX, psDec->LPC_order + 1 );
|
||||
NLSF_acc_Q15 = 0;
|
||||
|
@ -75,14 +75,14 @@ void silk_CNG_Reset(
|
|||
void silk_CNG(
|
||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||
SKP_int16 signal[], /* I/O Signal */
|
||||
SKP_int length /* I Length of residual */
|
||||
opus_int16 signal[], /* I/O Signal */
|
||||
opus_int length /* I Length of residual */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, subfr;
|
||||
SKP_int32 sum_Q6, max_Gain_Q16;
|
||||
SKP_int16 A_Q12[ MAX_LPC_ORDER ];
|
||||
SKP_int32 CNG_sig_Q10[ MAX_FRAME_LENGTH + MAX_LPC_ORDER ];
|
||||
opus_int i, j, subfr;
|
||||
opus_int32 sum_Q6, max_Gain_Q16;
|
||||
opus_int16 A_Q12[ MAX_LPC_ORDER ];
|
||||
opus_int32 CNG_sig_Q10[ MAX_FRAME_LENGTH + MAX_LPC_ORDER ];
|
||||
silk_CNG_struct *psCNG = &psDec->sCNG;
|
||||
|
||||
if( psDec->fs_kHz != psCNG->fs_kHz ) {
|
||||
|
@ -108,8 +108,8 @@ void silk_CNG(
|
|||
}
|
||||
}
|
||||
/* Update CNG excitation buffer with excitation from this subframe */
|
||||
SKP_memmove( &psCNG->CNG_exc_buf_Q10[ psDec->subfr_length ], psCNG->CNG_exc_buf_Q10, ( psDec->nb_subfr - 1 ) * psDec->subfr_length * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( psCNG->CNG_exc_buf_Q10, &psDec->exc_Q10[ subfr * psDec->subfr_length ], psDec->subfr_length * sizeof( SKP_int32 ) );
|
||||
SKP_memmove( &psCNG->CNG_exc_buf_Q10[ psDec->subfr_length ], psCNG->CNG_exc_buf_Q10, ( psDec->nb_subfr - 1 ) * psDec->subfr_length * sizeof( opus_int32 ) );
|
||||
SKP_memcpy( psCNG->CNG_exc_buf_Q10, &psDec->exc_Q10[ subfr * psDec->subfr_length ], psDec->subfr_length * sizeof( opus_int32 ) );
|
||||
|
||||
/* Smooth gains */
|
||||
for( i = 0; i < psDec->nb_subfr; i++ ) {
|
||||
|
@ -127,7 +127,7 @@ void silk_CNG(
|
|||
silk_NLSF2A( A_Q12, psCNG->CNG_smth_NLSF_Q15, psDec->LPC_order );
|
||||
|
||||
/* Generate CNG signal, by synthesis filtering */
|
||||
SKP_memcpy( CNG_sig_Q10, psCNG->CNG_synth_state, MAX_LPC_ORDER * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( CNG_sig_Q10, psCNG->CNG_synth_state, MAX_LPC_ORDER * sizeof( opus_int32 ) );
|
||||
for( i = 0; i < length; i++ ) {
|
||||
/* Partially unrolled */
|
||||
sum_Q6 = SKP_SMULWB( CNG_sig_Q10[ MAX_LPC_ORDER + i - 1 ], A_Q12[ 0 ] );
|
||||
|
@ -149,8 +149,8 @@ void silk_CNG(
|
|||
|
||||
signal[ i ] = SKP_ADD_SAT16( signal[ i ], SKP_RSHIFT_ROUND( sum_Q6, 6 ) );
|
||||
}
|
||||
SKP_memcpy( psCNG->CNG_synth_state, &CNG_sig_Q10[ length ], MAX_LPC_ORDER * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( psCNG->CNG_synth_state, &CNG_sig_Q10[ length ], MAX_LPC_ORDER * sizeof( opus_int32 ) );
|
||||
} else {
|
||||
SKP_memset( psCNG->CNG_synth_state, 0, psDec->LPC_order * sizeof( SKP_int32 ) );
|
||||
SKP_memset( psCNG->CNG_synth_state, 0, psDec->LPC_order * sizeof( opus_int32 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,13 +38,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
|
||||
void silk_HP_variable_cutoff(
|
||||
silk_encoder_state_Fxx state_Fxx[], /* I/O Encoder states */
|
||||
const SKP_int nChannels /* I Number of channels */
|
||||
const opus_int nChannels /* I Number of channels */
|
||||
)
|
||||
{
|
||||
SKP_int quality_Q15, cutoff_Hz;
|
||||
SKP_int32 B_Q28[ 3 ], A_Q28[ 2 ];
|
||||
SKP_int32 Fc_Q19, r_Q28, r_Q22;
|
||||
SKP_int32 pitch_freq_Hz_Q16, pitch_freq_log_Q7, delta_freq_Q7;
|
||||
opus_int quality_Q15, cutoff_Hz;
|
||||
opus_int32 B_Q28[ 3 ], A_Q28[ 2 ];
|
||||
opus_int32 Fc_Q19, r_Q28, r_Q22;
|
||||
opus_int32 pitch_freq_Hz_Q16, pitch_freq_log_Q7, delta_freq_Q7;
|
||||
silk_encoder_state *psEncC1 = &state_Fxx[ 0 ].sCmn;
|
||||
|
||||
if( psEncC1->HP_cutoff_Hz == 0 ) {
|
||||
|
|
|
@ -37,15 +37,15 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
/* count leading zeros of SKP_int64 */
|
||||
SKP_INLINE SKP_int32 silk_CLZ64(SKP_int64 in)
|
||||
/* count leading zeros of opus_int64 */
|
||||
SKP_INLINE opus_int32 silk_CLZ64(opus_int64 in)
|
||||
{
|
||||
SKP_int32 in_upper;
|
||||
opus_int32 in_upper;
|
||||
|
||||
in_upper = (SKP_int32)SKP_RSHIFT64(in, 32);
|
||||
in_upper = (opus_int32)SKP_RSHIFT64(in, 32);
|
||||
if (in_upper == 0) {
|
||||
/* Search in the lower 32 bits */
|
||||
return 32 + silk_CLZ32( (SKP_int32) in );
|
||||
return 32 + silk_CLZ32( (opus_int32) in );
|
||||
} else {
|
||||
/* Search in the upper 32 bits */
|
||||
return silk_CLZ32( in_upper );
|
||||
|
@ -53,11 +53,11 @@ SKP_INLINE SKP_int32 silk_CLZ64(SKP_int64 in)
|
|||
}
|
||||
|
||||
/* get number of leading zeros and fractional part (the bits right after the leading one */
|
||||
SKP_INLINE void silk_CLZ_FRAC(SKP_int32 in, /* I: input */
|
||||
SKP_int32 *lz, /* O: number of leading zeros */
|
||||
SKP_int32 *frac_Q7) /* O: the 7 bits right after the leading one */
|
||||
SKP_INLINE void silk_CLZ_FRAC(opus_int32 in, /* I: input */
|
||||
opus_int32 *lz, /* O: number of leading zeros */
|
||||
opus_int32 *frac_Q7) /* O: the 7 bits right after the leading one */
|
||||
{
|
||||
SKP_int32 lzeros = silk_CLZ32(in);
|
||||
opus_int32 lzeros = silk_CLZ32(in);
|
||||
|
||||
* lz = lzeros;
|
||||
* frac_Q7 = silk_ROR32(in, 24 - lzeros) & 0x7f;
|
||||
|
@ -66,9 +66,9 @@ SKP_INLINE void silk_CLZ_FRAC(SKP_int32 in, /* I: input */
|
|||
/* Approximation of square root */
|
||||
/* Accuracy: < +/- 10% for output values > 15 */
|
||||
/* < +/- 2.5% for output values > 120 */
|
||||
SKP_INLINE SKP_int32 silk_SQRT_APPROX(SKP_int32 x)
|
||||
SKP_INLINE opus_int32 silk_SQRT_APPROX(opus_int32 x)
|
||||
{
|
||||
SKP_int32 y, lz, frac_Q7;
|
||||
opus_int32 y, lz, frac_Q7;
|
||||
|
||||
if( x <= 0 ) {
|
||||
return 0;
|
||||
|
@ -92,14 +92,14 @@ SKP_INLINE SKP_int32 silk_SQRT_APPROX(SKP_int32 x)
|
|||
}
|
||||
|
||||
/* Divide two int32 values and return result as int32 in a given Q-domain */
|
||||
SKP_INLINE SKP_int32 silk_DIV32_varQ( /* O returns a good approximation of "(a32 << Qres) / b32" */
|
||||
const SKP_int32 a32, /* I numerator (Q0) */
|
||||
const SKP_int32 b32, /* I denominator (Q0) */
|
||||
const SKP_int Qres /* I Q-domain of result (>= 0) */
|
||||
SKP_INLINE opus_int32 silk_DIV32_varQ( /* O returns a good approximation of "(a32 << Qres) / b32" */
|
||||
const opus_int32 a32, /* I numerator (Q0) */
|
||||
const opus_int32 b32, /* I denominator (Q0) */
|
||||
const opus_int Qres /* I Q-domain of result (>= 0) */
|
||||
)
|
||||
{
|
||||
SKP_int a_headrm, b_headrm, lshift;
|
||||
SKP_int32 b32_inv, a32_nrm, b32_nrm, result;
|
||||
opus_int a_headrm, b_headrm, lshift;
|
||||
opus_int32 b32_inv, a32_nrm, b32_nrm, result;
|
||||
|
||||
SKP_assert( b32 != 0 );
|
||||
SKP_assert( Qres >= 0 );
|
||||
|
@ -137,13 +137,13 @@ SKP_INLINE SKP_int32 silk_DIV32_varQ( /* O returns a good approximation of
|
|||
}
|
||||
|
||||
/* Invert int32 value and return result as int32 in a given Q-domain */
|
||||
SKP_INLINE SKP_int32 silk_INVERSE32_varQ( /* O returns a good approximation of "(1 << Qres) / b32" */
|
||||
const SKP_int32 b32, /* I denominator (Q0) */
|
||||
const SKP_int Qres /* I Q-domain of result (> 0) */
|
||||
SKP_INLINE opus_int32 silk_INVERSE32_varQ( /* O returns a good approximation of "(1 << Qres) / b32" */
|
||||
const opus_int32 b32, /* I denominator (Q0) */
|
||||
const opus_int Qres /* I Q-domain of result (> 0) */
|
||||
)
|
||||
{
|
||||
SKP_int b_headrm, lshift;
|
||||
SKP_int32 b32_inv, b32_nrm, err_Q32, result;
|
||||
opus_int b_headrm, lshift;
|
||||
opus_int32 b32_inv, b32_nrm, err_Q32, result;
|
||||
|
||||
SKP_assert( b32 != 0 );
|
||||
SKP_assert( Qres > 0 );
|
||||
|
|
|
@ -35,16 +35,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/*******************************************/
|
||||
|
||||
void silk_LPC_analysis_filter(
|
||||
SKP_int16 *out, /* O: Output signal */
|
||||
const SKP_int16 *in, /* I: Input signal */
|
||||
const SKP_int16 *B, /* I: MA prediction coefficients, Q12 [order] */
|
||||
const SKP_int32 len, /* I: Signal length */
|
||||
const SKP_int32 d /* I: Filter order */
|
||||
opus_int16 *out, /* O: Output signal */
|
||||
const opus_int16 *in, /* I: Input signal */
|
||||
const opus_int16 *B, /* I: MA prediction coefficients, Q12 [order] */
|
||||
const opus_int32 len, /* I: Signal length */
|
||||
const opus_int32 d /* I: Filter order */
|
||||
)
|
||||
{
|
||||
SKP_int ix, j;
|
||||
SKP_int32 out32_Q12, out32;
|
||||
const SKP_int16 *in_ptr;
|
||||
opus_int ix, j;
|
||||
opus_int32 out32_Q12, out32;
|
||||
const opus_int16 *in_ptr;
|
||||
|
||||
SKP_assert( d >= 6 );
|
||||
SKP_assert( (d & 1) == 0 );
|
||||
|
@ -65,15 +65,15 @@ void silk_LPC_analysis_filter(
|
|||
}
|
||||
|
||||
/* Subtract prediction */
|
||||
out32_Q12 = SKP_SUB32( SKP_LSHIFT( (SKP_int32)in_ptr[ 1 ], 12 ), out32_Q12 );
|
||||
out32_Q12 = SKP_SUB32( SKP_LSHIFT( (opus_int32)in_ptr[ 1 ], 12 ), out32_Q12 );
|
||||
|
||||
/* Scale to Q0 */
|
||||
out32 = SKP_RSHIFT_ROUND( out32_Q12, 12 );
|
||||
|
||||
/* Saturate output */
|
||||
out[ ix ] = ( SKP_int16 )SKP_SAT16( out32 );
|
||||
out[ ix ] = ( opus_int16 )SKP_SAT16( out32 );
|
||||
}
|
||||
|
||||
/* Set first d output samples to zero */
|
||||
SKP_memset( out, 0, d * sizeof( SKP_int16 ) );
|
||||
SKP_memset( out, 0, d * sizeof( opus_int16 ) );
|
||||
}
|
||||
|
|
|
@ -32,16 +32,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Compute inverse of LPC prediction gain, and */
|
||||
/* test if LPC coefficients are stable (all poles within unit circle) */
|
||||
static SKP_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, otherwise 0 */
|
||||
SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
||||
SKP_int32 A_QA[ 2 ][ SILK_MAX_ORDER_LPC ],
|
||||
static opus_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, otherwise 0 */
|
||||
opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
||||
opus_int32 A_QA[ 2 ][ SILK_MAX_ORDER_LPC ],
|
||||
/* I: Prediction coefficients */
|
||||
const SKP_int order /* I: Prediction order */
|
||||
const opus_int order /* I: Prediction order */
|
||||
)
|
||||
{
|
||||
SKP_int k, n, headrm;
|
||||
SKP_int32 rc_Q31, rc_mult1_Q30, rc_mult2_Q16, tmp_QA;
|
||||
SKP_int32 *Aold_QA, *Anew_QA;
|
||||
opus_int k, n, headrm;
|
||||
opus_int32 rc_Q31, rc_mult1_Q30, rc_mult2_Q16, tmp_QA;
|
||||
opus_int32 *Aold_QA, *Anew_QA;
|
||||
|
||||
Anew_QA = A_QA[ order & 1 ];
|
||||
|
||||
|
@ -103,36 +103,36 @@ static SKP_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, o
|
|||
}
|
||||
|
||||
/* For input in Q12 domain */
|
||||
SKP_int silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */
|
||||
SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
||||
const SKP_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */
|
||||
const SKP_int order /* I: Prediction order */
|
||||
opus_int silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */
|
||||
opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
||||
const opus_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */
|
||||
const opus_int order /* I: Prediction order */
|
||||
)
|
||||
{
|
||||
SKP_int k;
|
||||
SKP_int32 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ];
|
||||
SKP_int32 *Anew_QA;
|
||||
opus_int k;
|
||||
opus_int32 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ];
|
||||
opus_int32 *Anew_QA;
|
||||
|
||||
Anew_QA = Atmp_QA[ order & 1 ];
|
||||
|
||||
/* Increase Q domain of the AR coefficients */
|
||||
for( k = 0; k < order; k++ ) {
|
||||
Anew_QA[ k ] = SKP_LSHIFT( (SKP_int32)A_Q12[ k ], QA - 12 );
|
||||
Anew_QA[ k ] = SKP_LSHIFT( (opus_int32)A_Q12[ k ], QA - 12 );
|
||||
}
|
||||
|
||||
return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order );
|
||||
}
|
||||
|
||||
/* For input in Q24 domain */
|
||||
SKP_int silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */
|
||||
SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
||||
const SKP_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */
|
||||
const SKP_int order /* I: Prediction order */
|
||||
opus_int silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */
|
||||
opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
||||
const opus_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */
|
||||
const opus_int order /* I: Prediction order */
|
||||
)
|
||||
{
|
||||
SKP_int k;
|
||||
SKP_int32 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ];
|
||||
SKP_int32 *Anew_QA;
|
||||
opus_int k;
|
||||
opus_int32 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ];
|
||||
opus_int32 *Anew_QA;
|
||||
|
||||
Anew_QA = Atmp_QA[ order & 1 ];
|
||||
|
||||
|
|
|
@ -36,13 +36,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Helper function, interpolates the filter taps */
|
||||
SKP_INLINE void silk_LP_interpolate_filter_taps(
|
||||
SKP_int32 B_Q28[ TRANSITION_NB ],
|
||||
SKP_int32 A_Q28[ TRANSITION_NA ],
|
||||
const SKP_int ind,
|
||||
const SKP_int32 fac_Q16
|
||||
opus_int32 B_Q28[ TRANSITION_NB ],
|
||||
opus_int32 A_Q28[ TRANSITION_NA ],
|
||||
const opus_int ind,
|
||||
const opus_int32 fac_Q16
|
||||
)
|
||||
{
|
||||
SKP_int nb, na;
|
||||
opus_int nb, na;
|
||||
|
||||
if( ind < TRANSITION_INT_NUM - 1 ) {
|
||||
if( fac_Q16 > 0 ) {
|
||||
|
@ -81,12 +81,12 @@ SKP_INLINE void silk_LP_interpolate_filter_taps(
|
|||
}
|
||||
}
|
||||
} else {
|
||||
SKP_memcpy( B_Q28, silk_Transition_LP_B_Q28[ ind ], TRANSITION_NB * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( A_Q28, silk_Transition_LP_A_Q28[ ind ], TRANSITION_NA * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( B_Q28, silk_Transition_LP_B_Q28[ ind ], TRANSITION_NB * sizeof( opus_int32 ) );
|
||||
SKP_memcpy( A_Q28, silk_Transition_LP_A_Q28[ ind ], TRANSITION_NA * sizeof( opus_int32 ) );
|
||||
}
|
||||
} else {
|
||||
SKP_memcpy( B_Q28, silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NB * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( A_Q28, silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NA * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( B_Q28, silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NB * sizeof( opus_int32 ) );
|
||||
SKP_memcpy( A_Q28, silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NA * sizeof( opus_int32 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,12 +96,12 @@ SKP_INLINE void silk_LP_interpolate_filter_taps(
|
|||
/* Deactivate by setting psEncC->mode = 0; */
|
||||
void silk_LP_variable_cutoff(
|
||||
silk_LP_state *psLP, /* I/O LP filter state */
|
||||
SKP_int16 *signal, /* I/O Low-pass filtered output signal */
|
||||
const SKP_int frame_length /* I Frame length */
|
||||
opus_int16 *signal, /* I/O Low-pass filtered output signal */
|
||||
const opus_int frame_length /* I Frame length */
|
||||
)
|
||||
{
|
||||
SKP_int32 B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ], fac_Q16 = 0;
|
||||
SKP_int ind = 0;
|
||||
opus_int32 B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ], fac_Q16 = 0;
|
||||
opus_int ind = 0;
|
||||
|
||||
SKP_assert( psLP->transition_frame_no >= 0 && psLP->transition_frame_no <= TRANSITION_FRAMES );
|
||||
|
||||
|
|
|
@ -30,16 +30,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <stdio.h>
|
||||
|
||||
#ifdef SKP_MACRO_COUNT
|
||||
#define varDefine SKP_int64 ops_count = 0;
|
||||
#define varDefine opus_int64 ops_count = 0;
|
||||
|
||||
extern SKP_int64 ops_count;
|
||||
extern opus_int64 ops_count;
|
||||
|
||||
SKP_INLINE SKP_int64 SKP_SaveCount(){
|
||||
SKP_INLINE opus_int64 SKP_SaveCount(){
|
||||
return(ops_count);
|
||||
}
|
||||
|
||||
SKP_INLINE SKP_int64 SKP_SaveResetCount(){
|
||||
SKP_int64 ret;
|
||||
SKP_INLINE opus_int64 SKP_SaveResetCount(){
|
||||
opus_int64 ret;
|
||||
|
||||
ret = ops_count;
|
||||
ops_count = 0;
|
||||
|
@ -47,112 +47,112 @@ SKP_INLINE SKP_int64 SKP_SaveResetCount(){
|
|||
}
|
||||
|
||||
SKP_INLINE SKP_PrintCount(){
|
||||
printf("ops_count = %d \n ", (SKP_int32)ops_count);
|
||||
printf("ops_count = %d \n ", (opus_int32)ops_count);
|
||||
}
|
||||
|
||||
#undef SKP_MUL
|
||||
SKP_INLINE SKP_int32 SKP_MUL(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_MUL(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 ret;
|
||||
ops_count += 4;
|
||||
ret = a32 * b32;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_MUL_uint
|
||||
SKP_INLINE SKP_uint32 SKP_MUL_uint(SKP_uint32 a32, SKP_uint32 b32){
|
||||
SKP_uint32 ret;
|
||||
SKP_INLINE opus_uint32 SKP_MUL_uint(opus_uint32 a32, opus_uint32 b32){
|
||||
opus_uint32 ret;
|
||||
ops_count += 4;
|
||||
ret = a32 * b32;
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_MLA
|
||||
SKP_INLINE SKP_int32 SKP_MLA(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_MLA(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ops_count += 4;
|
||||
ret = a32 + b32 * c32;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_MLA_uint
|
||||
SKP_INLINE SKP_int32 SKP_MLA_uint(SKP_uint32 a32, SKP_uint32 b32, SKP_uint32 c32){
|
||||
SKP_uint32 ret;
|
||||
SKP_INLINE opus_int32 SKP_MLA_uint(opus_uint32 a32, opus_uint32 b32, opus_uint32 c32){
|
||||
opus_uint32 ret;
|
||||
ops_count += 4;
|
||||
ret = a32 + b32 * c32;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMULWB
|
||||
SKP_INLINE SKP_int32 SKP_SMULWB(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMULWB(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 ret;
|
||||
ops_count += 5;
|
||||
ret = (a32 >> 16) * (SKP_int32)((SKP_int16)b32) + (((a32 & 0x0000FFFF) * (SKP_int32)((SKP_int16)b32)) >> 16);
|
||||
ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16);
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_SMLAWB
|
||||
SKP_INLINE SKP_int32 SKP_SMLAWB(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMLAWB(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ops_count += 5;
|
||||
ret = ((a32) + ((((b32) >> 16) * (SKP_int32)((SKP_int16)(c32))) + ((((b32) & 0x0000FFFF) * (SKP_int32)((SKP_int16)(c32))) >> 16)));
|
||||
ret = ((a32) + ((((b32) >> 16) * (opus_int32)((opus_int16)(c32))) + ((((b32) & 0x0000FFFF) * (opus_int32)((opus_int16)(c32))) >> 16)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMULWT
|
||||
SKP_INLINE SKP_int32 SKP_SMULWT(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMULWT(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 ret;
|
||||
ops_count += 4;
|
||||
ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16);
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_SMLAWT
|
||||
SKP_INLINE SKP_int32 SKP_SMLAWT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMLAWT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ops_count += 4;
|
||||
ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16)) >> 16));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMULBB
|
||||
SKP_INLINE SKP_int32 SKP_SMULBB(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMULBB(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = (SKP_int32)((SKP_int16)a32) * (SKP_int32)((SKP_int16)b32);
|
||||
ret = (opus_int32)((opus_int16)a32) * (opus_int32)((opus_int16)b32);
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_SMLABB
|
||||
SKP_INLINE SKP_int32 SKP_SMLABB(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMLABB(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a32 + (SKP_int32)((SKP_int16)b32) * (SKP_int32)((SKP_int16)c32);
|
||||
ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMULBT
|
||||
SKP_INLINE SKP_int32 SKP_SMULBT(SKP_int32 a32, SKP_int32 b32 ){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMULBT(opus_int32 a32, opus_int32 b32 ){
|
||||
opus_int32 ret;
|
||||
ops_count += 4;
|
||||
ret = ((SKP_int32)((SKP_int16)a32)) * (b32 >> 16);
|
||||
ret = ((opus_int32)((opus_int16)a32)) * (b32 >> 16);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMLABT
|
||||
SKP_INLINE SKP_int32 SKP_SMLABT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMLABT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a32 + ((SKP_int32)((SKP_int16)b32)) * (c32 >> 16);
|
||||
ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMULTT
|
||||
SKP_INLINE SKP_int32 SKP_SMULTT(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMULTT(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = (a32 >> 16) * (b32 >> 16);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMLATT
|
||||
SKP_INLINE SKP_int32 SKP_SMLATT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMLATT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a32 + (b32 >> 16) * (c32 >> 16);
|
||||
return ret;
|
||||
|
@ -179,32 +179,32 @@ SKP_INLINE SKP_int32 SKP_SMLATT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
|||
#define SKP_SMLAWT_ovflw SKP_SMLAWT
|
||||
|
||||
#undef SKP_SMULL
|
||||
SKP_INLINE SKP_int64 SKP_SMULL(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int64 ret;
|
||||
SKP_INLINE opus_int64 SKP_SMULL(opus_int32 a32, opus_int32 b32){
|
||||
opus_int64 ret;
|
||||
ops_count += 8;
|
||||
ret = ((SKP_int64)(a32) * /*(SKP_int64)*/(b32));
|
||||
ret = ((opus_int64)(a32) * /*(opus_int64)*/(b32));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMLAL
|
||||
SKP_INLINE SKP_int64 SKP_SMLAL(SKP_int64 a64, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int64 ret;
|
||||
SKP_INLINE opus_int64 SKP_SMLAL(opus_int64 a64, opus_int32 b32, opus_int32 c32){
|
||||
opus_int64 ret;
|
||||
ops_count += 8;
|
||||
ret = a64 + ((SKP_int64)(b32) * /*(SKP_int64)*/(c32));
|
||||
ret = a64 + ((opus_int64)(b32) * /*(opus_int64)*/(c32));
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_SMLALBB
|
||||
SKP_INLINE SKP_int64 SKP_SMLALBB(SKP_int64 a64, SKP_int16 b16, SKP_int16 c16){
|
||||
SKP_int64 ret;
|
||||
SKP_INLINE opus_int64 SKP_SMLALBB(opus_int64 a64, opus_int16 b16, opus_int16 c16){
|
||||
opus_int64 ret;
|
||||
ops_count += 4;
|
||||
ret = a64 + ((SKP_int64)(b16) * /*(SKP_int64)*/(c16));
|
||||
ret = a64 + ((opus_int64)(b16) * /*(opus_int64)*/(c16));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SigProcFIX_CLZ16
|
||||
SKP_INLINE SKP_int32 SigProcFIX_CLZ16(SKP_int16 in16)
|
||||
SKP_INLINE opus_int32 SigProcFIX_CLZ16(opus_int16 in16)
|
||||
{
|
||||
SKP_int32 out32 = 0;
|
||||
opus_int32 out32 = 0;
|
||||
ops_count += 10;
|
||||
if( in16 == 0 ) {
|
||||
return 16;
|
||||
|
@ -240,242 +240,242 @@ SKP_INLINE SKP_int32 SigProcFIX_CLZ16(SKP_int16 in16)
|
|||
}
|
||||
|
||||
#undef SigProcFIX_CLZ32
|
||||
SKP_INLINE SKP_int32 SigProcFIX_CLZ32(SKP_int32 in32)
|
||||
SKP_INLINE opus_int32 SigProcFIX_CLZ32(opus_int32 in32)
|
||||
{
|
||||
/* test highest 16 bits and convert to SKP_int16 */
|
||||
/* test highest 16 bits and convert to opus_int16 */
|
||||
ops_count += 2;
|
||||
if( in32 & 0xFFFF0000 ) {
|
||||
return SigProcFIX_CLZ16((SKP_int16)(in32 >> 16));
|
||||
return SigProcFIX_CLZ16((opus_int16)(in32 >> 16));
|
||||
} else {
|
||||
return SigProcFIX_CLZ16((SKP_int16)in32) + 16;
|
||||
return SigProcFIX_CLZ16((opus_int16)in32) + 16;
|
||||
}
|
||||
}
|
||||
|
||||
#undef SKP_DIV32
|
||||
SKP_INLINE SKP_int32 SKP_DIV32(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_INLINE opus_int32 SKP_DIV32(opus_int32 a32, opus_int32 b32){
|
||||
ops_count += 64;
|
||||
return a32 / b32;
|
||||
}
|
||||
|
||||
#undef SKP_DIV32_16
|
||||
SKP_INLINE SKP_int32 SKP_DIV32_16(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_INLINE opus_int32 SKP_DIV32_16(opus_int32 a32, opus_int32 b32){
|
||||
ops_count += 32;
|
||||
return a32 / b32;
|
||||
}
|
||||
|
||||
#undef SKP_SAT8
|
||||
SKP_INLINE SKP_int8 SKP_SAT8(SKP_int64 a){
|
||||
SKP_int8 tmp;
|
||||
SKP_INLINE opus_int8 SKP_SAT8(opus_int64 a){
|
||||
opus_int8 tmp;
|
||||
ops_count += 1;
|
||||
tmp = (SKP_int8)((a) > SKP_int8_MAX ? SKP_int8_MAX : \
|
||||
tmp = (opus_int8)((a) > SKP_int8_MAX ? SKP_int8_MAX : \
|
||||
((a) < SKP_int8_MIN ? SKP_int8_MIN : (a)));
|
||||
return(tmp);
|
||||
}
|
||||
|
||||
#undef SKP_SAT16
|
||||
SKP_INLINE SKP_int16 SKP_SAT16(SKP_int64 a){
|
||||
SKP_int16 tmp;
|
||||
SKP_INLINE opus_int16 SKP_SAT16(opus_int64 a){
|
||||
opus_int16 tmp;
|
||||
ops_count += 1;
|
||||
tmp = (SKP_int16)((a) > SKP_int16_MAX ? SKP_int16_MAX : \
|
||||
tmp = (opus_int16)((a) > SKP_int16_MAX ? SKP_int16_MAX : \
|
||||
((a) < SKP_int16_MIN ? SKP_int16_MIN : (a)));
|
||||
return(tmp);
|
||||
}
|
||||
#undef SKP_SAT32
|
||||
SKP_INLINE SKP_int32 SKP_SAT32(SKP_int64 a){
|
||||
SKP_int32 tmp;
|
||||
SKP_INLINE opus_int32 SKP_SAT32(opus_int64 a){
|
||||
opus_int32 tmp;
|
||||
ops_count += 1;
|
||||
tmp = (SKP_int32)((a) > SKP_int32_MAX ? SKP_int32_MAX : \
|
||||
tmp = (opus_int32)((a) > SKP_int32_MAX ? SKP_int32_MAX : \
|
||||
((a) < SKP_int32_MIN ? SKP_int32_MIN : (a)));
|
||||
return(tmp);
|
||||
}
|
||||
#undef SKP_POS_SAT32
|
||||
SKP_INLINE SKP_int32 SKP_POS_SAT32(SKP_int64 a){
|
||||
SKP_int32 tmp;
|
||||
SKP_INLINE opus_int32 SKP_POS_SAT32(opus_int64 a){
|
||||
opus_int32 tmp;
|
||||
ops_count += 1;
|
||||
tmp = (SKP_int32)((a) > SKP_int32_MAX ? SKP_int32_MAX : (a));
|
||||
tmp = (opus_int32)((a) > SKP_int32_MAX ? SKP_int32_MAX : (a));
|
||||
return(tmp);
|
||||
}
|
||||
|
||||
#undef SKP_ADD_POS_SAT8
|
||||
SKP_INLINE SKP_int8 SKP_ADD_POS_SAT8(SKP_int64 a, SKP_int64 b){
|
||||
SKP_int8 tmp;
|
||||
SKP_INLINE opus_int8 SKP_ADD_POS_SAT8(opus_int64 a, opus_int64 b){
|
||||
opus_int8 tmp;
|
||||
ops_count += 1;
|
||||
tmp = (SKP_int8)((((a)+(b)) & 0x80) ? SKP_int8_MAX : ((a)+(b)));
|
||||
tmp = (opus_int8)((((a)+(b)) & 0x80) ? SKP_int8_MAX : ((a)+(b)));
|
||||
return(tmp);
|
||||
}
|
||||
#undef SKP_ADD_POS_SAT16
|
||||
SKP_INLINE SKP_int16 SKP_ADD_POS_SAT16(SKP_int64 a, SKP_int64 b){
|
||||
SKP_int16 tmp;
|
||||
SKP_INLINE opus_int16 SKP_ADD_POS_SAT16(opus_int64 a, opus_int64 b){
|
||||
opus_int16 tmp;
|
||||
ops_count += 1;
|
||||
tmp = (SKP_int16)((((a)+(b)) & 0x8000) ? SKP_int16_MAX : ((a)+(b)));
|
||||
tmp = (opus_int16)((((a)+(b)) & 0x8000) ? SKP_int16_MAX : ((a)+(b)));
|
||||
return(tmp);
|
||||
}
|
||||
|
||||
#undef SKP_ADD_POS_SAT32
|
||||
SKP_INLINE SKP_int32 SKP_ADD_POS_SAT32(SKP_int64 a, SKP_int64 b){
|
||||
SKP_int32 tmp;
|
||||
SKP_INLINE opus_int32 SKP_ADD_POS_SAT32(opus_int64 a, opus_int64 b){
|
||||
opus_int32 tmp;
|
||||
ops_count += 1;
|
||||
tmp = (SKP_int32)((((a)+(b)) & 0x80000000) ? SKP_int32_MAX : ((a)+(b)));
|
||||
tmp = (opus_int32)((((a)+(b)) & 0x80000000) ? SKP_int32_MAX : ((a)+(b)));
|
||||
return(tmp);
|
||||
}
|
||||
|
||||
#undef SKP_ADD_POS_SAT64
|
||||
SKP_INLINE SKP_int64 SKP_ADD_POS_SAT64(SKP_int64 a, SKP_int64 b){
|
||||
SKP_int64 tmp;
|
||||
SKP_INLINE opus_int64 SKP_ADD_POS_SAT64(opus_int64 a, opus_int64 b){
|
||||
opus_int64 tmp;
|
||||
ops_count += 1;
|
||||
tmp = ((((a)+(b)) & 0x8000000000000000LL) ? SKP_int64_MAX : ((a)+(b)));
|
||||
return(tmp);
|
||||
}
|
||||
|
||||
#undef SKP_LSHIFT8
|
||||
SKP_INLINE SKP_int8 SKP_LSHIFT8(SKP_int8 a, SKP_int32 shift){
|
||||
SKP_int8 ret;
|
||||
SKP_INLINE opus_int8 SKP_LSHIFT8(opus_int8 a, opus_int32 shift){
|
||||
opus_int8 ret;
|
||||
ops_count += 1;
|
||||
ret = a << shift;
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_LSHIFT16
|
||||
SKP_INLINE SKP_int16 SKP_LSHIFT16(SKP_int16 a, SKP_int32 shift){
|
||||
SKP_int16 ret;
|
||||
SKP_INLINE opus_int16 SKP_LSHIFT16(opus_int16 a, opus_int32 shift){
|
||||
opus_int16 ret;
|
||||
ops_count += 1;
|
||||
ret = a << shift;
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_LSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_LSHIFT32(SKP_int32 a, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_LSHIFT32(opus_int32 a, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a << shift;
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_LSHIFT64
|
||||
SKP_INLINE SKP_int64 SKP_LSHIFT64(SKP_int64 a, SKP_int shift){
|
||||
SKP_INLINE opus_int64 SKP_LSHIFT64(opus_int64 a, opus_int shift){
|
||||
ops_count += 1;
|
||||
return a << shift;
|
||||
}
|
||||
|
||||
#undef SKP_LSHIFT_ovflw
|
||||
SKP_INLINE SKP_int32 SKP_LSHIFT_ovflw(SKP_int32 a, SKP_int32 shift){
|
||||
SKP_INLINE opus_int32 SKP_LSHIFT_ovflw(opus_int32 a, opus_int32 shift){
|
||||
ops_count += 1;
|
||||
return a << shift;
|
||||
}
|
||||
|
||||
#undef SKP_LSHIFT_uint
|
||||
SKP_INLINE SKP_uint32 SKP_LSHIFT_uint(SKP_uint32 a, SKP_int32 shift){
|
||||
SKP_uint32 ret;
|
||||
SKP_INLINE opus_uint32 SKP_LSHIFT_uint(opus_uint32 a, opus_int32 shift){
|
||||
opus_uint32 ret;
|
||||
ops_count += 1;
|
||||
ret = a << shift;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_RSHIFT8
|
||||
SKP_INLINE SKP_int8 SKP_RSHIFT8(SKP_int8 a, SKP_int32 shift){
|
||||
SKP_INLINE opus_int8 SKP_RSHIFT8(opus_int8 a, opus_int32 shift){
|
||||
ops_count += 1;
|
||||
return a >> shift;
|
||||
}
|
||||
#undef SKP_RSHIFT16
|
||||
SKP_INLINE SKP_int16 SKP_RSHIFT16(SKP_int16 a, SKP_int32 shift){
|
||||
SKP_INLINE opus_int16 SKP_RSHIFT16(opus_int16 a, opus_int32 shift){
|
||||
ops_count += 1;
|
||||
return a >> shift;
|
||||
}
|
||||
#undef SKP_RSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_RSHIFT32(SKP_int32 a, SKP_int32 shift){
|
||||
SKP_INLINE opus_int32 SKP_RSHIFT32(opus_int32 a, opus_int32 shift){
|
||||
ops_count += 1;
|
||||
return a >> shift;
|
||||
}
|
||||
#undef SKP_RSHIFT64
|
||||
SKP_INLINE SKP_int64 SKP_RSHIFT64(SKP_int64 a, SKP_int64 shift){
|
||||
SKP_INLINE opus_int64 SKP_RSHIFT64(opus_int64 a, opus_int64 shift){
|
||||
ops_count += 1;
|
||||
return a >> shift;
|
||||
}
|
||||
|
||||
#undef SKP_RSHIFT_uint
|
||||
SKP_INLINE SKP_uint32 SKP_RSHIFT_uint(SKP_uint32 a, SKP_int32 shift){
|
||||
SKP_INLINE opus_uint32 SKP_RSHIFT_uint(opus_uint32 a, opus_int32 shift){
|
||||
ops_count += 1;
|
||||
return a >> shift;
|
||||
}
|
||||
|
||||
#undef SKP_ADD_LSHIFT
|
||||
SKP_INLINE SKP_int32 SKP_ADD_LSHIFT(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_ADD_LSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a + (b << shift);
|
||||
return ret; // shift >= 0
|
||||
}
|
||||
#undef SKP_ADD_LSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_ADD_LSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_ADD_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a + (b << shift);
|
||||
return ret; // shift >= 0
|
||||
}
|
||||
#undef SKP_ADD_LSHIFT_uint
|
||||
SKP_INLINE SKP_uint32 SKP_ADD_LSHIFT_uint(SKP_uint32 a, SKP_uint32 b, SKP_int32 shift){
|
||||
SKP_uint32 ret;
|
||||
SKP_INLINE opus_uint32 SKP_ADD_LSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){
|
||||
opus_uint32 ret;
|
||||
ops_count += 1;
|
||||
ret = a + (b << shift);
|
||||
return ret; // shift >= 0
|
||||
}
|
||||
#undef SKP_ADD_RSHIFT
|
||||
SKP_INLINE SKP_int32 SKP_ADD_RSHIFT(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_ADD_RSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a + (b >> shift);
|
||||
return ret; // shift > 0
|
||||
}
|
||||
#undef SKP_ADD_RSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_ADD_RSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_ADD_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a + (b >> shift);
|
||||
return ret; // shift > 0
|
||||
}
|
||||
#undef SKP_ADD_RSHIFT_uint
|
||||
SKP_INLINE SKP_uint32 SKP_ADD_RSHIFT_uint(SKP_uint32 a, SKP_uint32 b, SKP_int32 shift){
|
||||
SKP_uint32 ret;
|
||||
SKP_INLINE opus_uint32 SKP_ADD_RSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){
|
||||
opus_uint32 ret;
|
||||
ops_count += 1;
|
||||
ret = a + (b >> shift);
|
||||
return ret; // shift > 0
|
||||
}
|
||||
#undef SKP_SUB_LSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_SUB_LSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SUB_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a - (b << shift);
|
||||
return ret; // shift >= 0
|
||||
}
|
||||
#undef SKP_SUB_RSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_SUB_RSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SUB_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a - (b >> shift);
|
||||
return ret; // shift > 0
|
||||
}
|
||||
|
||||
#undef SKP_RSHIFT_ROUND
|
||||
SKP_INLINE SKP_int32 SKP_RSHIFT_ROUND(SKP_int32 a, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_RSHIFT_ROUND(opus_int32 a, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
ops_count += 3;
|
||||
ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_RSHIFT_ROUND64
|
||||
SKP_INLINE SKP_int64 SKP_RSHIFT_ROUND64(SKP_int64 a, SKP_int32 shift){
|
||||
SKP_int64 ret;
|
||||
SKP_INLINE opus_int64 SKP_RSHIFT_ROUND64(opus_int64 a, opus_int32 shift){
|
||||
opus_int64 ret;
|
||||
ops_count += 6;
|
||||
ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_abs_int64
|
||||
SKP_INLINE SKP_int64 SKP_abs_int64(SKP_int64 a){
|
||||
SKP_INLINE opus_int64 SKP_abs_int64(opus_int64 a){
|
||||
ops_count += 1;
|
||||
return (((a) > 0) ? (a) : -(a)); // Be careful, SKP_abs returns wrong when input equals to SKP_intXX_MIN
|
||||
}
|
||||
|
||||
#undef SKP_abs_int32
|
||||
SKP_INLINE SKP_int32 SKP_abs_int32(SKP_int32 a){
|
||||
SKP_INLINE opus_int32 SKP_abs_int32(opus_int32 a){
|
||||
ops_count += 1;
|
||||
return abs(a);
|
||||
}
|
||||
|
@ -498,64 +498,64 @@ static SKP_sign(a){
|
|||
}
|
||||
|
||||
#undef SKP_ADD16
|
||||
SKP_INLINE SKP_int16 SKP_ADD16(SKP_int16 a, SKP_int16 b){
|
||||
SKP_int16 ret;
|
||||
SKP_INLINE opus_int16 SKP_ADD16(opus_int16 a, opus_int16 b){
|
||||
opus_int16 ret;
|
||||
ops_count += 1;
|
||||
ret = a + b;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_ADD32
|
||||
SKP_INLINE SKP_int32 SKP_ADD32(SKP_int32 a, SKP_int32 b){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_ADD32(opus_int32 a, opus_int32 b){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a + b;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_ADD64
|
||||
SKP_INLINE SKP_int64 SKP_ADD64(SKP_int64 a, SKP_int64 b){
|
||||
SKP_int64 ret;
|
||||
SKP_INLINE opus_int64 SKP_ADD64(opus_int64 a, opus_int64 b){
|
||||
opus_int64 ret;
|
||||
ops_count += 2;
|
||||
ret = a + b;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SUB16
|
||||
SKP_INLINE SKP_int16 SKP_SUB16(SKP_int16 a, SKP_int16 b){
|
||||
SKP_int16 ret;
|
||||
SKP_INLINE opus_int16 SKP_SUB16(opus_int16 a, opus_int16 b){
|
||||
opus_int16 ret;
|
||||
ops_count += 1;
|
||||
ret = a - b;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SUB32
|
||||
SKP_INLINE SKP_int32 SKP_SUB32(SKP_int32 a, SKP_int32 b){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SUB32(opus_int32 a, opus_int32 b){
|
||||
opus_int32 ret;
|
||||
ops_count += 1;
|
||||
ret = a - b;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SUB64
|
||||
SKP_INLINE SKP_int64 SKP_SUB64(SKP_int64 a, SKP_int64 b){
|
||||
SKP_int64 ret;
|
||||
SKP_INLINE opus_int64 SKP_SUB64(opus_int64 a, opus_int64 b){
|
||||
opus_int64 ret;
|
||||
ops_count += 2;
|
||||
ret = a - b;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_ADD_SAT16
|
||||
SKP_INLINE SKP_int16 SKP_ADD_SAT16( SKP_int16 a16, SKP_int16 b16 ) {
|
||||
SKP_int16 res;
|
||||
SKP_INLINE opus_int16 SKP_ADD_SAT16( opus_int16 a16, opus_int16 b16 ) {
|
||||
opus_int16 res;
|
||||
// Nb will be counted in AKP_add32 and SKP_SAT16
|
||||
res = (SKP_int16)SKP_SAT16( SKP_ADD32( (SKP_int32)(a16), (b16) ) );
|
||||
res = (opus_int16)SKP_SAT16( SKP_ADD32( (opus_int32)(a16), (b16) ) );
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef SKP_ADD_SAT32
|
||||
SKP_INLINE SKP_int32 SKP_ADD_SAT32(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 res;
|
||||
SKP_INLINE opus_int32 SKP_ADD_SAT32(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 res;
|
||||
ops_count += 1;
|
||||
res = ((((a32) + (b32)) & 0x80000000) == 0 ? \
|
||||
((((a32) & (b32)) & 0x80000000) != 0 ? SKP_int32_MIN : (a32)+(b32)) : \
|
||||
|
@ -564,8 +564,8 @@ SKP_INLINE SKP_int32 SKP_ADD_SAT32(SKP_int32 a32, SKP_int32 b32){
|
|||
}
|
||||
|
||||
#undef SKP_ADD_SAT64
|
||||
SKP_INLINE SKP_int64 SKP_ADD_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
|
||||
SKP_int64 res;
|
||||
SKP_INLINE opus_int64 SKP_ADD_SAT64( opus_int64 a64, opus_int64 b64 ) {
|
||||
opus_int64 res;
|
||||
ops_count += 1;
|
||||
res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \
|
||||
((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? SKP_int64_MIN : (a64)+(b64)) : \
|
||||
|
@ -574,17 +574,17 @@ SKP_INLINE SKP_int64 SKP_ADD_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
|
|||
}
|
||||
|
||||
#undef SKP_SUB_SAT16
|
||||
SKP_INLINE SKP_int16 SKP_SUB_SAT16( SKP_int16 a16, SKP_int16 b16 ) {
|
||||
SKP_int16 res;
|
||||
SKP_INLINE opus_int16 SKP_SUB_SAT16( opus_int16 a16, opus_int16 b16 ) {
|
||||
opus_int16 res;
|
||||
SKP_assert(0);
|
||||
// Nb will be counted in sub-macros
|
||||
res = (SKP_int16)SKP_SAT16( SKP_SUB32( (SKP_int32)(a16), (b16) ) );
|
||||
res = (opus_int16)SKP_SAT16( SKP_SUB32( (opus_int32)(a16), (b16) ) );
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef SKP_SUB_SAT32
|
||||
SKP_INLINE SKP_int32 SKP_SUB_SAT32( SKP_int32 a32, SKP_int32 b32 ) {
|
||||
SKP_int32 res;
|
||||
SKP_INLINE opus_int32 SKP_SUB_SAT32( opus_int32 a32, opus_int32 b32 ) {
|
||||
opus_int32 res;
|
||||
ops_count += 1;
|
||||
res = ((((a32)-(b32)) & 0x80000000) == 0 ? \
|
||||
(( (a32) & ((b32)^0x80000000) & 0x80000000) ? SKP_int32_MIN : (a32)-(b32)) : \
|
||||
|
@ -593,8 +593,8 @@ SKP_INLINE SKP_int32 SKP_SUB_SAT32( SKP_int32 a32, SKP_int32 b32 ) {
|
|||
}
|
||||
|
||||
#undef SKP_SUB_SAT64
|
||||
SKP_INLINE SKP_int64 SKP_SUB_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
|
||||
SKP_int64 res;
|
||||
SKP_INLINE opus_int64 SKP_SUB_SAT64( opus_int64 a64, opus_int64 b64 ) {
|
||||
opus_int64 res;
|
||||
ops_count += 1;
|
||||
res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \
|
||||
(( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? SKP_int64_MIN : (a64)-(b64)) : \
|
||||
|
@ -604,42 +604,42 @@ SKP_INLINE SKP_int64 SKP_SUB_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
|
|||
}
|
||||
|
||||
#undef SKP_SMULWW
|
||||
SKP_INLINE SKP_int32 SKP_SMULWW(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMULWW(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 ret;
|
||||
// Nb will be counted in sub-macros
|
||||
ret = SKP_MLA(SKP_SMULWB((a32), (b32)), (a32), SKP_RSHIFT_ROUND((b32), 16));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMLAWW
|
||||
SKP_INLINE SKP_int32 SKP_SMLAWW(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMLAWW(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
// Nb will be counted in sub-macros
|
||||
ret = SKP_MLA(SKP_SMLAWB((a32), (b32), (c32)), (b32), SKP_RSHIFT_ROUND((c32), 16));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_min_int
|
||||
SKP_INLINE SKP_int SKP_min_int(SKP_int a, SKP_int b)
|
||||
SKP_INLINE opus_int SKP_min_int(opus_int a, opus_int b)
|
||||
{
|
||||
ops_count += 1;
|
||||
return (((a) < (b)) ? (a) : (b));
|
||||
}
|
||||
|
||||
#undef SKP_min_16
|
||||
SKP_INLINE SKP_int16 SKP_min_16(SKP_int16 a, SKP_int16 b)
|
||||
SKP_INLINE opus_int16 SKP_min_16(opus_int16 a, opus_int16 b)
|
||||
{
|
||||
ops_count += 1;
|
||||
return (((a) < (b)) ? (a) : (b));
|
||||
}
|
||||
#undef SKP_min_32
|
||||
SKP_INLINE SKP_int32 SKP_min_32(SKP_int32 a, SKP_int32 b)
|
||||
SKP_INLINE opus_int32 SKP_min_32(opus_int32 a, opus_int32 b)
|
||||
{
|
||||
ops_count += 1;
|
||||
return (((a) < (b)) ? (a) : (b));
|
||||
}
|
||||
#undef SKP_min_64
|
||||
SKP_INLINE SKP_int64 SKP_min_64(SKP_int64 a, SKP_int64 b)
|
||||
SKP_INLINE opus_int64 SKP_min_64(opus_int64 a, opus_int64 b)
|
||||
{
|
||||
ops_count += 1;
|
||||
return (((a) < (b)) ? (a) : (b));
|
||||
|
@ -647,26 +647,26 @@ SKP_INLINE SKP_int64 SKP_min_64(SKP_int64 a, SKP_int64 b)
|
|||
|
||||
/* SKP_min() versions with typecast in the function call */
|
||||
#undef SKP_max_int
|
||||
SKP_INLINE SKP_int SKP_max_int(SKP_int a, SKP_int b)
|
||||
SKP_INLINE opus_int SKP_max_int(opus_int a, opus_int b)
|
||||
{
|
||||
ops_count += 1;
|
||||
return (((a) > (b)) ? (a) : (b));
|
||||
}
|
||||
#undef SKP_max_16
|
||||
SKP_INLINE SKP_int16 SKP_max_16(SKP_int16 a, SKP_int16 b)
|
||||
SKP_INLINE opus_int16 SKP_max_16(opus_int16 a, opus_int16 b)
|
||||
{
|
||||
ops_count += 1;
|
||||
return (((a) > (b)) ? (a) : (b));
|
||||
}
|
||||
#undef SKP_max_32
|
||||
SKP_INLINE SKP_int32 SKP_max_32(SKP_int32 a, SKP_int32 b)
|
||||
SKP_INLINE opus_int32 SKP_max_32(opus_int32 a, opus_int32 b)
|
||||
{
|
||||
ops_count += 1;
|
||||
return (((a) > (b)) ? (a) : (b));
|
||||
}
|
||||
|
||||
#undef SKP_max_64
|
||||
SKP_INLINE SKP_int64 SKP_max_64(SKP_int64 a, SKP_int64 b)
|
||||
SKP_INLINE opus_int64 SKP_max_64(opus_int64 a, opus_int64 b)
|
||||
{
|
||||
ops_count += 1;
|
||||
return (((a) > (b)) ? (a) : (b));
|
||||
|
@ -674,9 +674,9 @@ SKP_INLINE SKP_int64 SKP_max_64(SKP_int64 a, SKP_int64 b)
|
|||
|
||||
|
||||
#undef SKP_LIMIT_int
|
||||
SKP_INLINE SKP_int SKP_LIMIT_int(SKP_int a, SKP_int limit1, SKP_int limit2)
|
||||
SKP_INLINE opus_int SKP_LIMIT_int(opus_int a, opus_int limit1, opus_int limit2)
|
||||
{
|
||||
SKP_int ret;
|
||||
opus_int ret;
|
||||
ops_count += 6;
|
||||
|
||||
ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
|
||||
|
@ -686,9 +686,9 @@ SKP_INLINE SKP_int SKP_LIMIT_int(SKP_int a, SKP_int limit1, SKP_int limit2)
|
|||
}
|
||||
|
||||
#undef SKP_LIMIT_16
|
||||
SKP_INLINE SKP_int16 SKP_LIMIT_16(SKP_int16 a, SKP_int16 limit1, SKP_int16 limit2)
|
||||
SKP_INLINE opus_int16 SKP_LIMIT_16(opus_int16 a, opus_int16 limit1, opus_int16 limit2)
|
||||
{
|
||||
SKP_int16 ret;
|
||||
opus_int16 ret;
|
||||
ops_count += 6;
|
||||
|
||||
ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
|
||||
|
@ -699,9 +699,9 @@ return(ret);
|
|||
|
||||
|
||||
#undef SKP_LIMIT_32
|
||||
SKP_INLINE SKP_int SKP_LIMIT_32(SKP_int32 a, SKP_int32 limit1, SKP_int32 limit2)
|
||||
SKP_INLINE opus_int SKP_LIMIT_32(opus_int32 a, opus_int32 limit1, opus_int32 limit2)
|
||||
{
|
||||
SKP_int32 ret;
|
||||
opus_int32 ret;
|
||||
ops_count += 6;
|
||||
|
||||
ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
|
||||
|
|
|
@ -34,8 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#if 0 && defined (_WIN32) && defined (_DEBUG) && !defined (SKP_MACRO_COUNT)
|
||||
|
||||
#undef SKP_ADD16
|
||||
SKP_INLINE SKP_int16 SKP_ADD16(SKP_int16 a, SKP_int16 b){
|
||||
SKP_int16 ret;
|
||||
SKP_INLINE opus_int16 SKP_ADD16(opus_int16 a, opus_int16 b){
|
||||
opus_int16 ret;
|
||||
|
||||
ret = a + b;
|
||||
SKP_assert( ret == SKP_ADD_SAT16( a, b ));
|
||||
|
@ -43,8 +43,8 @@ SKP_INLINE SKP_int16 SKP_ADD16(SKP_int16 a, SKP_int16 b){
|
|||
}
|
||||
|
||||
#undef SKP_ADD32
|
||||
SKP_INLINE SKP_int32 SKP_ADD32(SKP_int32 a, SKP_int32 b){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_ADD32(opus_int32 a, opus_int32 b){
|
||||
opus_int32 ret;
|
||||
|
||||
ret = a + b;
|
||||
SKP_assert( ret == SKP_ADD_SAT32( a, b ));
|
||||
|
@ -52,8 +52,8 @@ SKP_INLINE SKP_int32 SKP_ADD32(SKP_int32 a, SKP_int32 b){
|
|||
}
|
||||
|
||||
#undef SKP_ADD64
|
||||
SKP_INLINE SKP_int64 SKP_ADD64(SKP_int64 a, SKP_int64 b){
|
||||
SKP_int64 ret;
|
||||
SKP_INLINE opus_int64 SKP_ADD64(opus_int64 a, opus_int64 b){
|
||||
opus_int64 ret;
|
||||
|
||||
ret = a + b;
|
||||
SKP_assert( ret == SKP_ADD_SAT64( a, b ));
|
||||
|
@ -61,8 +61,8 @@ SKP_INLINE SKP_int64 SKP_ADD64(SKP_int64 a, SKP_int64 b){
|
|||
}
|
||||
|
||||
#undef SKP_SUB16
|
||||
SKP_INLINE SKP_int16 SKP_SUB16(SKP_int16 a, SKP_int16 b){
|
||||
SKP_int16 ret;
|
||||
SKP_INLINE opus_int16 SKP_SUB16(opus_int16 a, opus_int16 b){
|
||||
opus_int16 ret;
|
||||
|
||||
ret = a - b;
|
||||
SKP_assert( ret == SKP_SUB_SAT16( a, b ));
|
||||
|
@ -70,8 +70,8 @@ SKP_INLINE SKP_int16 SKP_SUB16(SKP_int16 a, SKP_int16 b){
|
|||
}
|
||||
|
||||
#undef SKP_SUB32
|
||||
SKP_INLINE SKP_int32 SKP_SUB32(SKP_int32 a, SKP_int32 b){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SUB32(opus_int32 a, opus_int32 b){
|
||||
opus_int32 ret;
|
||||
|
||||
ret = a - b;
|
||||
SKP_assert( ret == SKP_SUB_SAT32( a, b ));
|
||||
|
@ -79,8 +79,8 @@ SKP_INLINE SKP_int32 SKP_SUB32(SKP_int32 a, SKP_int32 b){
|
|||
}
|
||||
|
||||
#undef SKP_SUB64
|
||||
SKP_INLINE SKP_int64 SKP_SUB64(SKP_int64 a, SKP_int64 b){
|
||||
SKP_int64 ret;
|
||||
SKP_INLINE opus_int64 SKP_SUB64(opus_int64 a, opus_int64 b){
|
||||
opus_int64 ret;
|
||||
|
||||
ret = a - b;
|
||||
SKP_assert( ret == SKP_SUB_SAT64( a, b ));
|
||||
|
@ -88,26 +88,26 @@ SKP_INLINE SKP_int64 SKP_SUB64(SKP_int64 a, SKP_int64 b){
|
|||
}
|
||||
|
||||
#undef SKP_ADD_SAT16
|
||||
SKP_INLINE SKP_int16 SKP_ADD_SAT16( SKP_int16 a16, SKP_int16 b16 ) {
|
||||
SKP_int16 res;
|
||||
res = (SKP_int16)SKP_SAT16( SKP_ADD32( (SKP_int32)(a16), (b16) ) );
|
||||
SKP_assert( res == SKP_SAT16( ( SKP_int32 )a16 + ( SKP_int32 )b16 ) );
|
||||
SKP_INLINE opus_int16 SKP_ADD_SAT16( opus_int16 a16, opus_int16 b16 ) {
|
||||
opus_int16 res;
|
||||
res = (opus_int16)SKP_SAT16( SKP_ADD32( (opus_int32)(a16), (b16) ) );
|
||||
SKP_assert( res == SKP_SAT16( ( opus_int32 )a16 + ( opus_int32 )b16 ) );
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef SKP_ADD_SAT32
|
||||
SKP_INLINE SKP_int32 SKP_ADD_SAT32(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 res;
|
||||
SKP_INLINE opus_int32 SKP_ADD_SAT32(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 res;
|
||||
res = ((((a32) + (b32)) & 0x80000000) == 0 ? \
|
||||
((((a32) & (b32)) & 0x80000000) != 0 ? SKP_int32_MIN : (a32)+(b32)) : \
|
||||
((((a32) | (b32)) & 0x80000000) == 0 ? SKP_int32_MAX : (a32)+(b32)) );
|
||||
SKP_assert( res == SKP_SAT32( ( SKP_int64 )a32 + ( SKP_int64 )b32 ) );
|
||||
SKP_assert( res == SKP_SAT32( ( opus_int64 )a32 + ( opus_int64 )b32 ) );
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef SKP_ADD_SAT64
|
||||
SKP_INLINE SKP_int64 SKP_ADD_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
|
||||
SKP_int64 res;
|
||||
SKP_INLINE opus_int64 SKP_ADD_SAT64( opus_int64 a64, opus_int64 b64 ) {
|
||||
opus_int64 res;
|
||||
res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \
|
||||
((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? SKP_int64_MIN : (a64)+(b64)) : \
|
||||
((((a64) | (b64)) & 0x8000000000000000LL) == 0 ? SKP_int64_MAX : (a64)+(b64)) );
|
||||
|
@ -123,26 +123,26 @@ SKP_INLINE SKP_int64 SKP_ADD_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
|
|||
}
|
||||
|
||||
#undef SKP_SUB_SAT16
|
||||
SKP_INLINE SKP_int16 SKP_SUB_SAT16( SKP_int16 a16, SKP_int16 b16 ) {
|
||||
SKP_int16 res;
|
||||
res = (SKP_int16)SKP_SAT16( SKP_SUB32( (SKP_int32)(a16), (b16) ) );
|
||||
SKP_assert( res == SKP_SAT16( ( SKP_int32 )a16 - ( SKP_int32 )b16 ) );
|
||||
SKP_INLINE opus_int16 SKP_SUB_SAT16( opus_int16 a16, opus_int16 b16 ) {
|
||||
opus_int16 res;
|
||||
res = (opus_int16)SKP_SAT16( SKP_SUB32( (opus_int32)(a16), (b16) ) );
|
||||
SKP_assert( res == SKP_SAT16( ( opus_int32 )a16 - ( opus_int32 )b16 ) );
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef SKP_SUB_SAT32
|
||||
SKP_INLINE SKP_int32 SKP_SUB_SAT32( SKP_int32 a32, SKP_int32 b32 ) {
|
||||
SKP_int32 res;
|
||||
SKP_INLINE opus_int32 SKP_SUB_SAT32( opus_int32 a32, opus_int32 b32 ) {
|
||||
opus_int32 res;
|
||||
res = ((((a32)-(b32)) & 0x80000000) == 0 ? \
|
||||
(( (a32) & ((b32)^0x80000000) & 0x80000000) ? SKP_int32_MIN : (a32)-(b32)) : \
|
||||
((((a32)^0x80000000) & (b32) & 0x80000000) ? SKP_int32_MAX : (a32)-(b32)) );
|
||||
SKP_assert( res == SKP_SAT32( ( SKP_int64 )a32 - ( SKP_int64 )b32 ) );
|
||||
SKP_assert( res == SKP_SAT32( ( opus_int64 )a32 - ( opus_int64 )b32 ) );
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef SKP_SUB_SAT64
|
||||
SKP_INLINE SKP_int64 SKP_SUB_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
|
||||
SKP_int64 res;
|
||||
SKP_INLINE opus_int64 SKP_SUB_SAT64( opus_int64 a64, opus_int64 b64 ) {
|
||||
opus_int64 res;
|
||||
res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \
|
||||
(( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? SKP_int64_MIN : (a64)-(b64)) : \
|
||||
((((a64)^0x8000000000000000LL) & (b64) & 0x8000000000000000LL) ? SKP_int64_MAX : (a64)-(b64)) );
|
||||
|
@ -159,71 +159,71 @@ SKP_INLINE SKP_int64 SKP_SUB_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
|
|||
}
|
||||
|
||||
#undef SKP_MUL
|
||||
SKP_INLINE SKP_int32 SKP_MUL(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 ret;
|
||||
SKP_int64 ret64; // Will easily show how many bits that are needed
|
||||
SKP_INLINE opus_int32 SKP_MUL(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 ret;
|
||||
opus_int64 ret64; // Will easily show how many bits that are needed
|
||||
ret = a32 * b32;
|
||||
ret64 = (SKP_int64)a32 * (SKP_int64)b32;
|
||||
SKP_assert((SKP_int64)ret == ret64 ); //Check output overflow
|
||||
ret64 = (opus_int64)a32 * (opus_int64)b32;
|
||||
SKP_assert((opus_int64)ret == ret64 ); //Check output overflow
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_MUL_uint
|
||||
SKP_INLINE SKP_uint32 SKP_MUL_uint(SKP_uint32 a32, SKP_uint32 b32){
|
||||
SKP_uint32 ret;
|
||||
SKP_INLINE opus_uint32 SKP_MUL_uint(opus_uint32 a32, opus_uint32 b32){
|
||||
opus_uint32 ret;
|
||||
ret = a32 * b32;
|
||||
SKP_assert((SKP_uint64)ret == (SKP_uint64)a32 * (SKP_uint64)b32); //Check output overflow
|
||||
SKP_assert((opus_uint64)ret == (opus_uint64)a32 * (opus_uint64)b32); //Check output overflow
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_MLA
|
||||
SKP_INLINE SKP_int32 SKP_MLA(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_MLA(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ret = a32 + b32 * c32;
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (SKP_int64)b32 * (SKP_int64)c32); //Check output overflow
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a32 + (opus_int64)b32 * (opus_int64)c32); //Check output overflow
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_MLA_uint
|
||||
SKP_INLINE SKP_int32 SKP_MLA_uint(SKP_uint32 a32, SKP_uint32 b32, SKP_uint32 c32){
|
||||
SKP_uint32 ret;
|
||||
SKP_INLINE opus_int32 SKP_MLA_uint(opus_uint32 a32, opus_uint32 b32, opus_uint32 c32){
|
||||
opus_uint32 ret;
|
||||
ret = a32 + b32 * c32;
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (SKP_int64)b32 * (SKP_int64)c32); //Check output overflow
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a32 + (opus_int64)b32 * (opus_int64)c32); //Check output overflow
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMULWB
|
||||
SKP_INLINE SKP_int32 SKP_SMULWB(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 ret;
|
||||
ret = (a32 >> 16) * (SKP_int32)((SKP_int16)b32) + (((a32 & 0x0000FFFF) * (SKP_int32)((SKP_int16)b32)) >> 16);
|
||||
SKP_assert((SKP_int64)ret == ((SKP_int64)a32 * (SKP_int16)b32) >> 16);
|
||||
SKP_INLINE opus_int32 SKP_SMULWB(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 ret;
|
||||
ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16);
|
||||
SKP_assert((opus_int64)ret == ((opus_int64)a32 * (opus_int16)b32) >> 16);
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_SMLAWB
|
||||
SKP_INLINE SKP_int32 SKP_SMLAWB(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMLAWB(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ret = SKP_ADD32( a32, SKP_SMULWB( b32, c32 ) );
|
||||
SKP_assert(SKP_ADD32( a32, SKP_SMULWB( b32, c32 ) ) == SKP_ADD_SAT32( a32, SKP_SMULWB( b32, c32 ) ));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMULWT
|
||||
SKP_INLINE SKP_int32 SKP_SMULWT(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMULWT(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 ret;
|
||||
ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16);
|
||||
SKP_assert((SKP_int64)ret == ((SKP_int64)a32 * (b32 >> 16)) >> 16);
|
||||
SKP_assert((opus_int64)ret == ((opus_int64)a32 * (b32 >> 16)) >> 16);
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_SMLAWT
|
||||
SKP_INLINE SKP_int32 SKP_SMLAWT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMLAWT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16)) >> 16));
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (((SKP_int64)b32 * (c32 >> 16)) >> 16));
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a32 + (((opus_int64)b32 * (c32 >> 16)) >> 16));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMULL
|
||||
SKP_INLINE SKP_int64 SKP_SMULL(SKP_int64 a64, SKP_int64 b64){
|
||||
SKP_int64 ret64;
|
||||
SKP_INLINE opus_int64 SKP_SMULL(opus_int64 a64, opus_int64 b64){
|
||||
opus_int64 ret64;
|
||||
ret64 = a64 * b64;
|
||||
if( b64 != 0 ) {
|
||||
SKP_assert( a64 == (ret64 / b64) );
|
||||
|
@ -235,55 +235,55 @@ SKP_INLINE SKP_int64 SKP_SMULL(SKP_int64 a64, SKP_int64 b64){
|
|||
|
||||
// no checking needed for SKP_SMULBB
|
||||
#undef SKP_SMLABB
|
||||
SKP_INLINE SKP_int32 SKP_SMLABB(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
ret = a32 + (SKP_int32)((SKP_int16)b32) * (SKP_int32)((SKP_int16)c32);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (SKP_int64)b32 * (SKP_int16)c32);
|
||||
SKP_INLINE opus_int32 SKP_SMLABB(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32);
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a32 + (opus_int64)b32 * (opus_int16)c32);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// no checking needed for SKP_SMULBT
|
||||
#undef SKP_SMLABT
|
||||
SKP_INLINE SKP_int32 SKP_SMLABT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
ret = a32 + ((SKP_int32)((SKP_int16)b32)) * (c32 >> 16);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (SKP_int64)b32 * (c32 >> 16));
|
||||
SKP_INLINE opus_int32 SKP_SMLABT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16);
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a32 + (opus_int64)b32 * (c32 >> 16));
|
||||
return ret;
|
||||
}
|
||||
|
||||
// no checking needed for SKP_SMULTT
|
||||
#undef SKP_SMLATT
|
||||
SKP_INLINE SKP_int32 SKP_SMLATT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SMLATT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret;
|
||||
ret = a32 + (b32 >> 16) * (c32 >> 16);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (b32 >> 16) * (c32 >> 16));
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a32 + (b32 >> 16) * (c32 >> 16));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMULWW
|
||||
SKP_INLINE SKP_int32 SKP_SMULWW(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_int32 ret, tmp1, tmp2;
|
||||
SKP_int64 ret64;
|
||||
SKP_INLINE opus_int32 SKP_SMULWW(opus_int32 a32, opus_int32 b32){
|
||||
opus_int32 ret, tmp1, tmp2;
|
||||
opus_int64 ret64;
|
||||
|
||||
ret = SKP_SMULWB( a32, b32 );
|
||||
tmp1 = SKP_RSHIFT_ROUND( b32, 16 );
|
||||
tmp2 = SKP_MUL( a32, tmp1 );
|
||||
|
||||
SKP_assert( (SKP_int64)tmp2 == (SKP_int64) a32 * (SKP_int64) tmp1 );
|
||||
SKP_assert( (opus_int64)tmp2 == (opus_int64) a32 * (opus_int64) tmp1 );
|
||||
|
||||
tmp1 = ret;
|
||||
ret = SKP_ADD32( tmp1, tmp2 );
|
||||
SKP_assert( SKP_ADD32( tmp1, tmp2 ) == SKP_ADD_SAT32( tmp1, tmp2 ) );
|
||||
|
||||
ret64 = SKP_RSHIFT64( SKP_SMULL( a32, b32 ), 16 );
|
||||
SKP_assert( (SKP_int64)ret == ret64 );
|
||||
SKP_assert( (opus_int64)ret == ret64 );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_SMLAWW
|
||||
SKP_INLINE SKP_int32 SKP_SMLAWW(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
||||
SKP_int32 ret, tmp;
|
||||
SKP_INLINE opus_int32 SKP_SMLAWW(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||
opus_int32 ret, tmp;
|
||||
|
||||
tmp = SKP_SMULWW( b32, c32 );
|
||||
ret = SKP_ADD32( a32, tmp );
|
||||
|
@ -295,13 +295,13 @@ SKP_INLINE SKP_int32 SKP_SMLAWW(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
|||
#undef SKP_MLA_ovflw
|
||||
#define SKP_MLA_ovflw(a32, b32, c32) ((a32) + ((b32) * (c32)))
|
||||
#undef SKP_SMLABB_ovflw
|
||||
#define SKP_SMLABB_ovflw(a32, b32, c32) ((a32) + ((SKP_int32)((SKP_int16)(b32))) * (SKP_int32)((SKP_int16)(c32)))
|
||||
#define SKP_SMLABB_ovflw(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32)))
|
||||
#undef SKP_SMLABT_ovflw
|
||||
#define SKP_SMLABT_ovflw(a32, b32, c32) ((a32) + ((SKP_int32)((SKP_int16)(b32))) * ((c32) >> 16))
|
||||
#define SKP_SMLABT_ovflw(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32))) * ((c32) >> 16))
|
||||
#undef SKP_SMLATT_ovflw
|
||||
#define SKP_SMLATT_ovflw(a32, b32, c32) ((a32) + ((b32) >> 16) * ((c32) >> 16))
|
||||
#undef SKP_SMLAWB_ovflw
|
||||
#define SKP_SMLAWB_ovflw(a32, b32, c32) ((a32) + ((((b32) >> 16) * (SKP_int32)((SKP_int16)(c32))) + ((((b32) & 0x0000FFFF) * (SKP_int32)((SKP_int16)(c32))) >> 16)))
|
||||
#define SKP_SMLAWB_ovflw(a32, b32, c32) ((a32) + ((((b32) >> 16) * (opus_int32)((opus_int16)(c32))) + ((((b32) & 0x0000FFFF) * (opus_int32)((opus_int16)(c32))) >> 16)))
|
||||
#undef SKP_SMLAWT_ovflw
|
||||
#define SKP_SMLAWT_ovflw(a32, b32, c32) ((a32) + (((b32) >> 16) * ((c32) >> 16)) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16))
|
||||
|
||||
|
@ -312,13 +312,13 @@ SKP_INLINE SKP_int32 SKP_SMLAWW(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
|
|||
// no checking needed for SigProcFIX_CLZ32
|
||||
|
||||
#undef SKP_DIV32
|
||||
SKP_INLINE SKP_int32 SKP_DIV32(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_INLINE opus_int32 SKP_DIV32(opus_int32 a32, opus_int32 b32){
|
||||
SKP_assert( b32 != 0 );
|
||||
return a32 / b32;
|
||||
}
|
||||
|
||||
#undef SKP_DIV32_16
|
||||
SKP_INLINE SKP_int32 SKP_DIV32_16(SKP_int32 a32, SKP_int32 b32){
|
||||
SKP_INLINE opus_int32 SKP_DIV32_16(opus_int32 a32, opus_int32 b32){
|
||||
SKP_assert( b32 != 0 );
|
||||
SKP_assert( b32 <= SKP_int16_MAX );
|
||||
SKP_assert( b32 >= SKP_int16_MIN );
|
||||
|
@ -334,172 +334,172 @@ SKP_INLINE SKP_int32 SKP_DIV32_16(SKP_int32 a32, SKP_int32 b32){
|
|||
// no checking needed for SKP_ADD_POS_SAT32
|
||||
// no checking needed for SKP_ADD_POS_SAT64
|
||||
#undef SKP_LSHIFT8
|
||||
SKP_INLINE SKP_int8 SKP_LSHIFT8(SKP_int8 a, SKP_int32 shift){
|
||||
SKP_int8 ret;
|
||||
SKP_INLINE opus_int8 SKP_LSHIFT8(opus_int8 a, opus_int32 shift){
|
||||
opus_int8 ret;
|
||||
ret = a << shift;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift < 8);
|
||||
SKP_assert((SKP_int64)ret == ((SKP_int64)a) << shift);
|
||||
SKP_assert((opus_int64)ret == ((opus_int64)a) << shift);
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_LSHIFT16
|
||||
SKP_INLINE SKP_int16 SKP_LSHIFT16(SKP_int16 a, SKP_int32 shift){
|
||||
SKP_int16 ret;
|
||||
SKP_INLINE opus_int16 SKP_LSHIFT16(opus_int16 a, opus_int32 shift){
|
||||
opus_int16 ret;
|
||||
ret = a << shift;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift < 16);
|
||||
SKP_assert((SKP_int64)ret == ((SKP_int64)a) << shift);
|
||||
SKP_assert((opus_int64)ret == ((opus_int64)a) << shift);
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_LSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_LSHIFT32(SKP_int32 a, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_LSHIFT32(opus_int32 a, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
ret = a << shift;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift < 32);
|
||||
SKP_assert((SKP_int64)ret == ((SKP_int64)a) << shift);
|
||||
SKP_assert((opus_int64)ret == ((opus_int64)a) << shift);
|
||||
return ret;
|
||||
}
|
||||
#undef SKP_LSHIFT64
|
||||
SKP_INLINE SKP_int64 SKP_LSHIFT64(SKP_int64 a, SKP_int shift){
|
||||
SKP_INLINE opus_int64 SKP_LSHIFT64(opus_int64 a, opus_int shift){
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift < 64);
|
||||
return a << shift;
|
||||
}
|
||||
|
||||
#undef SKP_LSHIFT_ovflw
|
||||
SKP_INLINE SKP_int32 SKP_LSHIFT_ovflw(SKP_int32 a, SKP_int32 shift){
|
||||
SKP_INLINE opus_int32 SKP_LSHIFT_ovflw(opus_int32 a, opus_int32 shift){
|
||||
SKP_assert(shift >= 0); /* no check for overflow */
|
||||
return a << shift;
|
||||
}
|
||||
|
||||
#undef SKP_LSHIFT_uint
|
||||
SKP_INLINE SKP_uint32 SKP_LSHIFT_uint(SKP_uint32 a, SKP_int32 shift){
|
||||
SKP_uint32 ret;
|
||||
SKP_INLINE opus_uint32 SKP_LSHIFT_uint(opus_uint32 a, opus_int32 shift){
|
||||
opus_uint32 ret;
|
||||
ret = a << shift;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert((SKP_int64)ret == ((SKP_int64)a) << shift);
|
||||
SKP_assert((opus_int64)ret == ((opus_int64)a) << shift);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_RSHIFT8
|
||||
SKP_INLINE SKP_int8 SKP_RSHIFT8(SKP_int8 a, SKP_int32 shift){
|
||||
SKP_INLINE opus_int8 SKP_RSHIFT8(opus_int8 a, opus_int32 shift){
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift < 8);
|
||||
return a >> shift;
|
||||
}
|
||||
#undef SKP_RSHIFT16
|
||||
SKP_INLINE SKP_int16 SKP_RSHIFT16(SKP_int16 a, SKP_int32 shift){
|
||||
SKP_INLINE opus_int16 SKP_RSHIFT16(opus_int16 a, opus_int32 shift){
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift < 16);
|
||||
return a >> shift;
|
||||
}
|
||||
#undef SKP_RSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_RSHIFT32(SKP_int32 a, SKP_int32 shift){
|
||||
SKP_INLINE opus_int32 SKP_RSHIFT32(opus_int32 a, opus_int32 shift){
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift < 32);
|
||||
return a >> shift;
|
||||
}
|
||||
#undef SKP_RSHIFT64
|
||||
SKP_INLINE SKP_int64 SKP_RSHIFT64(SKP_int64 a, SKP_int64 shift){
|
||||
SKP_INLINE opus_int64 SKP_RSHIFT64(opus_int64 a, opus_int64 shift){
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift <= 63);
|
||||
return a >> shift;
|
||||
}
|
||||
|
||||
#undef SKP_RSHIFT_uint
|
||||
SKP_INLINE SKP_uint32 SKP_RSHIFT_uint(SKP_uint32 a, SKP_int32 shift){
|
||||
SKP_INLINE opus_uint32 SKP_RSHIFT_uint(opus_uint32 a, opus_int32 shift){
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift <= 32);
|
||||
return a >> shift;
|
||||
}
|
||||
|
||||
#undef SKP_ADD_LSHIFT
|
||||
SKP_INLINE SKP_int32 SKP_ADD_LSHIFT(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_ADD_LSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift <= 31);
|
||||
ret = a + (b << shift);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) << shift));
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
|
||||
return ret; // shift >= 0
|
||||
}
|
||||
#undef SKP_ADD_LSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_ADD_LSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_ADD_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift <= 31);
|
||||
ret = a + (b << shift);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) << shift));
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
|
||||
return ret; // shift >= 0
|
||||
}
|
||||
#undef SKP_ADD_LSHIFT_uint
|
||||
SKP_INLINE SKP_uint32 SKP_ADD_LSHIFT_uint(SKP_uint32 a, SKP_uint32 b, SKP_int32 shift){
|
||||
SKP_uint32 ret;
|
||||
SKP_INLINE opus_uint32 SKP_ADD_LSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){
|
||||
opus_uint32 ret;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift <= 32);
|
||||
ret = a + (b << shift);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) << shift));
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
|
||||
return ret; // shift >= 0
|
||||
}
|
||||
#undef SKP_ADD_RSHIFT
|
||||
SKP_INLINE SKP_int32 SKP_ADD_RSHIFT(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_ADD_RSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift <= 31);
|
||||
ret = a + (b >> shift);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) >> shift));
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
|
||||
return ret; // shift > 0
|
||||
}
|
||||
#undef SKP_ADD_RSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_ADD_RSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_ADD_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift <= 31);
|
||||
ret = a + (b >> shift);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) >> shift));
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
|
||||
return ret; // shift > 0
|
||||
}
|
||||
#undef SKP_ADD_RSHIFT_uint
|
||||
SKP_INLINE SKP_uint32 SKP_ADD_RSHIFT_uint(SKP_uint32 a, SKP_uint32 b, SKP_int32 shift){
|
||||
SKP_uint32 ret;
|
||||
SKP_INLINE opus_uint32 SKP_ADD_RSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){
|
||||
opus_uint32 ret;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift <= 32);
|
||||
ret = a + (b >> shift);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) >> shift));
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
|
||||
return ret; // shift > 0
|
||||
}
|
||||
#undef SKP_SUB_LSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_SUB_LSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SUB_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift <= 31);
|
||||
ret = a - (b << shift);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a - (((SKP_int64)b) << shift));
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a - (((opus_int64)b) << shift));
|
||||
return ret; // shift >= 0
|
||||
}
|
||||
#undef SKP_SUB_RSHIFT32
|
||||
SKP_INLINE SKP_int32 SKP_SUB_RSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_SUB_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
SKP_assert(shift >= 0);
|
||||
SKP_assert(shift <= 31);
|
||||
ret = a - (b >> shift);
|
||||
SKP_assert((SKP_int64)ret == (SKP_int64)a - (((SKP_int64)b) >> shift));
|
||||
SKP_assert((opus_int64)ret == (opus_int64)a - (((opus_int64)b) >> shift));
|
||||
return ret; // shift > 0
|
||||
}
|
||||
|
||||
#undef SKP_RSHIFT_ROUND
|
||||
SKP_INLINE SKP_int32 SKP_RSHIFT_ROUND(SKP_int32 a, SKP_int32 shift){
|
||||
SKP_int32 ret;
|
||||
SKP_INLINE opus_int32 SKP_RSHIFT_ROUND(opus_int32 a, opus_int32 shift){
|
||||
opus_int32 ret;
|
||||
SKP_assert(shift > 0); /* the marco definition can't handle a shift of zero */
|
||||
SKP_assert(shift < 32);
|
||||
ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
|
||||
SKP_assert((SKP_int64)ret == ((SKP_int64)a + ((SKP_int64)1 << (shift - 1))) >> shift);
|
||||
SKP_assert((opus_int64)ret == ((opus_int64)a + ((opus_int64)1 << (shift - 1))) >> shift);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef SKP_RSHIFT_ROUND64
|
||||
SKP_INLINE SKP_int64 SKP_RSHIFT_ROUND64(SKP_int64 a, SKP_int32 shift){
|
||||
SKP_int64 ret;
|
||||
SKP_INLINE opus_int64 SKP_RSHIFT_ROUND64(opus_int64 a, opus_int32 shift){
|
||||
opus_int64 ret;
|
||||
SKP_assert(shift > 0); /* the marco definition can't handle a shift of zero */
|
||||
SKP_assert(shift < 64);
|
||||
ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
|
||||
|
@ -508,44 +508,44 @@ SKP_INLINE SKP_int64 SKP_RSHIFT_ROUND64(SKP_int64 a, SKP_int32 shift){
|
|||
|
||||
// SKP_abs is used on floats also, so doesn't work...
|
||||
//#undef SKP_abs
|
||||
//SKP_INLINE SKP_int32 SKP_abs(SKP_int32 a){
|
||||
//SKP_INLINE opus_int32 SKP_abs(opus_int32 a){
|
||||
// SKP_assert(a != 0x80000000);
|
||||
// return (((a) > 0) ? (a) : -(a)); // Be careful, SKP_abs returns wrong when input equals to SKP_intXX_MIN
|
||||
//}
|
||||
|
||||
#undef SKP_abs_int64
|
||||
SKP_INLINE SKP_int64 SKP_abs_int64(SKP_int64 a){
|
||||
SKP_INLINE opus_int64 SKP_abs_int64(opus_int64 a){
|
||||
SKP_assert(a != 0x8000000000000000);
|
||||
return (((a) > 0) ? (a) : -(a)); // Be careful, SKP_abs returns wrong when input equals to SKP_intXX_MIN
|
||||
}
|
||||
|
||||
#undef SKP_abs_int32
|
||||
SKP_INLINE SKP_int32 SKP_abs_int32(SKP_int32 a){
|
||||
SKP_INLINE opus_int32 SKP_abs_int32(opus_int32 a){
|
||||
SKP_assert(a != 0x80000000);
|
||||
return abs(a);
|
||||
}
|
||||
|
||||
#undef SKP_CHECK_FIT8
|
||||
SKP_INLINE SKP_int8 SKP_CHECK_FIT8( SKP_int64 a ){
|
||||
SKP_int8 ret;
|
||||
ret = (SKP_int8)a;
|
||||
SKP_assert( (SKP_int64)ret == a );
|
||||
SKP_INLINE opus_int8 SKP_CHECK_FIT8( opus_int64 a ){
|
||||
opus_int8 ret;
|
||||
ret = (opus_int8)a;
|
||||
SKP_assert( (opus_int64)ret == a );
|
||||
return( ret );
|
||||
}
|
||||
|
||||
#undef SKP_CHECK_FIT16
|
||||
SKP_INLINE SKP_int16 SKP_CHECK_FIT16( SKP_int64 a ){
|
||||
SKP_int16 ret;
|
||||
ret = (SKP_int16)a;
|
||||
SKP_assert( (SKP_int64)ret == a );
|
||||
SKP_INLINE opus_int16 SKP_CHECK_FIT16( opus_int64 a ){
|
||||
opus_int16 ret;
|
||||
ret = (opus_int16)a;
|
||||
SKP_assert( (opus_int64)ret == a );
|
||||
return( ret );
|
||||
}
|
||||
|
||||
#undef SKP_CHECK_FIT32
|
||||
SKP_INLINE SKP_int32 SKP_CHECK_FIT32( SKP_int64 a ){
|
||||
SKP_int32 ret;
|
||||
ret = (SKP_int32)a;
|
||||
SKP_assert( (SKP_int64)ret == a );
|
||||
SKP_INLINE opus_int32 SKP_CHECK_FIT32( opus_int64 a ){
|
||||
opus_int32 ret;
|
||||
ret = (opus_int32)a;
|
||||
SKP_assert( (opus_int64)ret == a );
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
|
|
@ -38,21 +38,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* helper function for NLSF2A(..) */
|
||||
SKP_INLINE void silk_NLSF2A_find_poly(
|
||||
SKP_int32 *out, /* O intermediate polynomial, QA [dd+1] */
|
||||
const SKP_int32 *cLSF, /* I vector of interleaved 2*cos(LSFs), QA [d] */
|
||||
SKP_int dd /* I polynomial order (= 1/2 * filter order) */
|
||||
opus_int32 *out, /* O intermediate polynomial, QA [dd+1] */
|
||||
const opus_int32 *cLSF, /* I vector of interleaved 2*cos(LSFs), QA [d] */
|
||||
opus_int dd /* I polynomial order (= 1/2 * filter order) */
|
||||
)
|
||||
{
|
||||
SKP_int k, n;
|
||||
SKP_int32 ftmp;
|
||||
opus_int k, n;
|
||||
opus_int32 ftmp;
|
||||
|
||||
out[0] = SKP_LSHIFT( 1, QA );
|
||||
out[1] = -cLSF[0];
|
||||
for( k = 1; k < dd; k++ ) {
|
||||
ftmp = cLSF[2*k]; // QA
|
||||
out[k+1] = SKP_LSHIFT( out[k-1], 1 ) - (SKP_int32)SKP_RSHIFT_ROUND64( SKP_SMULL( ftmp, out[k] ), QA );
|
||||
out[k+1] = SKP_LSHIFT( out[k-1], 1 ) - (opus_int32)SKP_RSHIFT_ROUND64( SKP_SMULL( ftmp, out[k] ), QA );
|
||||
for( n = k; n > 1; n-- ) {
|
||||
out[n] += out[n-2] - (SKP_int32)SKP_RSHIFT_ROUND64( SKP_SMULL( ftmp, out[n-1] ), QA );
|
||||
out[n] += out[n-2] - (opus_int32)SKP_RSHIFT_ROUND64( SKP_SMULL( ftmp, out[n-1] ), QA );
|
||||
}
|
||||
out[1] -= ftmp;
|
||||
}
|
||||
|
@ -60,17 +60,17 @@ SKP_INLINE void silk_NLSF2A_find_poly(
|
|||
|
||||
/* compute whitening filter coefficients from normalized line spectral frequencies */
|
||||
void silk_NLSF2A(
|
||||
SKP_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */
|
||||
const SKP_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */
|
||||
const SKP_int d /* I filter order (should be even) */
|
||||
opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */
|
||||
const opus_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */
|
||||
const opus_int d /* I filter order (should be even) */
|
||||
)
|
||||
{
|
||||
SKP_int k, i, dd;
|
||||
SKP_int32 cos_LSF_QA[ SILK_MAX_ORDER_LPC ];
|
||||
SKP_int32 P[ SILK_MAX_ORDER_LPC / 2 + 1 ], Q[ SILK_MAX_ORDER_LPC / 2 + 1 ];
|
||||
SKP_int32 Ptmp, Qtmp, f_int, f_frac, cos_val, delta;
|
||||
SKP_int32 a32_QA1[ SILK_MAX_ORDER_LPC ];
|
||||
SKP_int32 maxabs, absval, idx=0, sc_Q16, invGain_Q30;
|
||||
opus_int k, i, dd;
|
||||
opus_int32 cos_LSF_QA[ SILK_MAX_ORDER_LPC ];
|
||||
opus_int32 P[ SILK_MAX_ORDER_LPC / 2 + 1 ], Q[ SILK_MAX_ORDER_LPC / 2 + 1 ];
|
||||
opus_int32 Ptmp, Qtmp, f_int, f_frac, cos_val, delta;
|
||||
opus_int32 a32_QA1[ SILK_MAX_ORDER_LPC ];
|
||||
opus_int32 maxabs, absval, idx=0, sc_Q16, invGain_Q30;
|
||||
|
||||
SKP_assert( LSF_COS_TAB_SZ_FIX == 128 );
|
||||
|
||||
|
@ -102,7 +102,7 @@ void silk_NLSF2A(
|
|||
silk_NLSF2A_find_poly( P, &cos_LSF_QA[ 0 ], dd );
|
||||
silk_NLSF2A_find_poly( Q, &cos_LSF_QA[ 1 ], dd );
|
||||
|
||||
/* convert even and odd polynomials to SKP_int32 Q12 filter coefs */
|
||||
/* convert even and odd polynomials to opus_int32 Q12 filter coefs */
|
||||
for( k = 0; k < dd; k++ ) {
|
||||
Ptmp = P[ k+1 ] + P[ k ];
|
||||
Qtmp = Q[ k+1 ] - Q[ k ];
|
||||
|
@ -139,12 +139,12 @@ void silk_NLSF2A(
|
|||
if( i == 10 ) {
|
||||
/* Reached the last iteration, clip the coefficients */
|
||||
for( k = 0; k < d; k++ ) {
|
||||
a_Q12[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( a32_QA1[ k ], QA + 1 - 12 ) ); /* QA+1 -> Q12 */
|
||||
a32_QA1[ k ] = SKP_LSHIFT( (SKP_int32)a_Q12[ k ], QA + 1 - 12 );
|
||||
a_Q12[ k ] = (opus_int16)SKP_SAT16( SKP_RSHIFT_ROUND( a32_QA1[ k ], QA + 1 - 12 ) ); /* QA+1 -> Q12 */
|
||||
a32_QA1[ k ] = SKP_LSHIFT( (opus_int32)a_Q12[ k ], QA + 1 - 12 );
|
||||
}
|
||||
} else {
|
||||
for( k = 0; k < d; k++ ) {
|
||||
a_Q12[ k ] = (SKP_int16)SKP_RSHIFT_ROUND( a32_QA1[ k ], QA + 1 - 12 ); /* QA+1 -> Q12 */
|
||||
a_Q12[ k ] = (opus_int16)SKP_RSHIFT_ROUND( a32_QA1[ k ], QA + 1 - 12 ); /* QA+1 -> Q12 */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ void silk_NLSF2A(
|
|||
/* on the unscaled coefficients, convert to Q12 and measure again */
|
||||
silk_bwexpander_32( a32_QA1, d, 65536 - SKP_SMULBB( 9 + i, i ) ); /* 10_Q16 = 0.00015 */
|
||||
for( k = 0; k < d; k++ ) {
|
||||
a_Q12[ k ] = (SKP_int16)SKP_RSHIFT_ROUND( a32_QA1[ k ], QA + 1 - 12 ); /* QA+1 -> Q12 */
|
||||
a_Q12[ k ] = (opus_int16)SKP_RSHIFT_ROUND( a32_QA1[ k ], QA + 1 - 12 ); /* QA+1 -> Q12 */
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
|
|
|
@ -29,15 +29,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
|
||||
void silk_NLSF_VQ(
|
||||
SKP_int32 err_Q26[], /* O Quantization errors [K] */
|
||||
const SKP_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */
|
||||
const SKP_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */
|
||||
const SKP_int K, /* I Number of codebook vectors */
|
||||
const SKP_int LPC_order /* I Number of LPCs */
|
||||
opus_int32 err_Q26[], /* O Quantization errors [K] */
|
||||
const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */
|
||||
const opus_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */
|
||||
const opus_int K, /* I Number of codebook vectors */
|
||||
const opus_int LPC_order /* I Number of LPCs */
|
||||
)
|
||||
{
|
||||
SKP_int i, m;
|
||||
SKP_int32 diff_Q15, sum_error_Q30, sum_error_Q26;
|
||||
opus_int i, m;
|
||||
opus_int32 diff_Q15, sum_error_Q30, sum_error_Q26;
|
||||
|
||||
SKP_assert( LPC_order <= 16 );
|
||||
SKP_assert( ( LPC_order & 1 ) == 0 );
|
||||
|
@ -47,11 +47,11 @@ void silk_NLSF_VQ(
|
|||
sum_error_Q26 = 0;
|
||||
for( m = 0; m < LPC_order; m += 2 ) {
|
||||
/* Compute weighted squared quantization error for index m */
|
||||
diff_Q15 = SKP_SUB_LSHIFT32( in_Q15[ m ], ( SKP_int32 )*pCB_Q8++, 7 ); // range: [ -32767 : 32767 ]
|
||||
diff_Q15 = SKP_SUB_LSHIFT32( in_Q15[ m ], ( opus_int32 )*pCB_Q8++, 7 ); // range: [ -32767 : 32767 ]
|
||||
sum_error_Q30 = SKP_SMULBB( diff_Q15, diff_Q15 );
|
||||
|
||||
/* Compute weighted squared quantization error for index m + 1 */
|
||||
diff_Q15 = SKP_SUB_LSHIFT32( in_Q15[m + 1], ( SKP_int32 )*pCB_Q8++, 7 ); // range: [ -32767 : 32767 ]
|
||||
diff_Q15 = SKP_SUB_LSHIFT32( in_Q15[m + 1], ( opus_int32 )*pCB_Q8++, 7 ); // range: [ -32767 : 32767 ]
|
||||
sum_error_Q30 = SKP_SMLABB( sum_error_Q30, diff_Q15, diff_Q15 );
|
||||
|
||||
sum_error_Q26 = SKP_ADD_RSHIFT32( sum_error_Q26, sum_error_Q30, 4 );
|
||||
|
|
|
@ -36,13 +36,13 @@ Signal Processing, pp. 641-644, 1991.
|
|||
|
||||
/* Laroia low complexity NLSF weights */
|
||||
void silk_NLSF_VQ_weights_laroia(
|
||||
SKP_int16 *pNLSFW_Q_OUT, /* O: Pointer to input vector weights [D x 1] */
|
||||
const SKP_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */
|
||||
const SKP_int D /* I: Input vector dimension (even) */
|
||||
opus_int16 *pNLSFW_Q_OUT, /* O: Pointer to input vector weights [D x 1] */
|
||||
const opus_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */
|
||||
const opus_int D /* I: Input vector dimension (even) */
|
||||
)
|
||||
{
|
||||
SKP_int k;
|
||||
SKP_int32 tmp1_int, tmp2_int;
|
||||
opus_int k;
|
||||
opus_int32 tmp1_int, tmp2_int;
|
||||
|
||||
SKP_assert( D > 0 );
|
||||
SKP_assert( ( D & 1 ) == 0 );
|
||||
|
@ -52,25 +52,25 @@ void silk_NLSF_VQ_weights_laroia(
|
|||
tmp1_int = SKP_DIV32_16( 1 << ( 15 + NLSF_W_Q ), tmp1_int );
|
||||
tmp2_int = SKP_max_int( pNLSF_Q15[ 1 ] - pNLSF_Q15[ 0 ], 1 );
|
||||
tmp2_int = SKP_DIV32_16( 1 << ( 15 + NLSF_W_Q ), tmp2_int );
|
||||
pNLSFW_Q_OUT[ 0 ] = (SKP_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
|
||||
pNLSFW_Q_OUT[ 0 ] = (opus_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
|
||||
SKP_assert( pNLSFW_Q_OUT[ 0 ] > 0 );
|
||||
|
||||
/* Main loop */
|
||||
for( k = 1; k < D - 1; k += 2 ) {
|
||||
tmp1_int = SKP_max_int( pNLSF_Q15[ k + 1 ] - pNLSF_Q15[ k ], 1 );
|
||||
tmp1_int = SKP_DIV32_16( 1 << ( 15 + NLSF_W_Q ), tmp1_int );
|
||||
pNLSFW_Q_OUT[ k ] = (SKP_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
|
||||
pNLSFW_Q_OUT[ k ] = (opus_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
|
||||
SKP_assert( pNLSFW_Q_OUT[ k ] > 0 );
|
||||
|
||||
tmp2_int = SKP_max_int( pNLSF_Q15[ k + 2 ] - pNLSF_Q15[ k + 1 ], 1 );
|
||||
tmp2_int = SKP_DIV32_16( 1 << ( 15 + NLSF_W_Q ), tmp2_int );
|
||||
pNLSFW_Q_OUT[ k + 1 ] = (SKP_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
|
||||
pNLSFW_Q_OUT[ k + 1 ] = (opus_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
|
||||
SKP_assert( pNLSFW_Q_OUT[ k + 1 ] > 0 );
|
||||
}
|
||||
|
||||
/* Last value */
|
||||
tmp1_int = SKP_max_int( ( 1 << 15 ) - pNLSF_Q15[ D - 1 ], 1 );
|
||||
tmp1_int = SKP_DIV32_16( 1 << ( 15 + NLSF_W_Q ), tmp1_int );
|
||||
pNLSFW_Q_OUT[ D - 1 ] = (SKP_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
|
||||
pNLSFW_Q_OUT[ D - 1 ] = (opus_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
|
||||
SKP_assert( pNLSFW_Q_OUT[ D - 1 ] > 0 );
|
||||
}
|
||||
|
|
|
@ -29,18 +29,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Predictive dequantizer for NLSF residuals */
|
||||
void silk_NLSF_residual_dequant( /* O Returns RD value in Q30 */
|
||||
SKP_int16 x_Q10[], /* O Output [ order ] */
|
||||
const SKP_int8 indices[], /* I Quantization indices [ order ] */
|
||||
const SKP_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */
|
||||
const SKP_int quant_step_size_Q16, /* I Quantization step size */
|
||||
const SKP_int16 order /* I Number of input values */
|
||||
opus_int16 x_Q10[], /* O Output [ order ] */
|
||||
const opus_int8 indices[], /* I Quantization indices [ order ] */
|
||||
const opus_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */
|
||||
const opus_int quant_step_size_Q16, /* I Quantization step size */
|
||||
const opus_int16 order /* I Number of input values */
|
||||
)
|
||||
{
|
||||
SKP_int i, out_Q10, pred_Q10;
|
||||
opus_int i, out_Q10, pred_Q10;
|
||||
|
||||
out_Q10 = 0;
|
||||
for( i = order-1; i >= 0; i-- ) {
|
||||
pred_Q10 = SKP_RSHIFT( SKP_SMULBB( out_Q10, (SKP_int16)pred_coef_Q8[ i ] ), 8 );
|
||||
pred_Q10 = SKP_RSHIFT( SKP_SMULBB( out_Q10, (opus_int16)pred_coef_Q8[ i ] ), 8 );
|
||||
out_Q10 = SKP_LSHIFT( indices[ i ], 10 );
|
||||
if( out_Q10 > 0 ) {
|
||||
out_Q10 = SKP_SUB16( out_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
|
||||
|
@ -57,23 +57,23 @@ void silk_NLSF_residual_dequant( /* O Returns RD v
|
|||
/* NLSF vector decoder */
|
||||
/***********************/
|
||||
void silk_NLSF_decode(
|
||||
SKP_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */
|
||||
SKP_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
|
||||
opus_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */
|
||||
opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
|
||||
const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
SKP_uint8 pred_Q8[ MAX_LPC_ORDER ];
|
||||
SKP_int16 ec_ix[ MAX_LPC_ORDER ];
|
||||
SKP_int16 res_Q10[ MAX_LPC_ORDER ];
|
||||
SKP_int16 W_tmp_QW[ MAX_LPC_ORDER ];
|
||||
SKP_int32 W_tmp_Q9, NLSF_Q15_tmp;
|
||||
const SKP_uint8 *pCB_element;
|
||||
opus_int i;
|
||||
opus_uint8 pred_Q8[ MAX_LPC_ORDER ];
|
||||
opus_int16 ec_ix[ MAX_LPC_ORDER ];
|
||||
opus_int16 res_Q10[ MAX_LPC_ORDER ];
|
||||
opus_int16 W_tmp_QW[ MAX_LPC_ORDER ];
|
||||
opus_int32 W_tmp_Q9, NLSF_Q15_tmp;
|
||||
const opus_uint8 *pCB_element;
|
||||
|
||||
/* Decode first stage */
|
||||
pCB_element = &psNLSF_CB->CB1_NLSF_Q8[ NLSFIndices[ 0 ] * psNLSF_CB->order ];
|
||||
for( i = 0; i < psNLSF_CB->order; i++ ) {
|
||||
pNLSF_Q15[ i ] = SKP_LSHIFT( ( SKP_int16 )pCB_element[ i ], 7 );
|
||||
pNLSF_Q15[ i ] = SKP_LSHIFT( ( opus_int16 )pCB_element[ i ], 7 );
|
||||
}
|
||||
|
||||
/* Unpack entropy table indices and predictor for current CB1 index */
|
||||
|
@ -87,9 +87,9 @@ void silk_NLSF_decode(
|
|||
|
||||
/* Apply inverse square-rooted weights and add to output */
|
||||
for( i = 0; i < psNLSF_CB->order; i++ ) {
|
||||
W_tmp_Q9 = silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_QW[ i ], 18 - NLSF_W_Q ) );
|
||||
NLSF_Q15_tmp = SKP_ADD32( pNLSF_Q15[ i ], SKP_DIV32_16( SKP_LSHIFT( ( SKP_int32 )res_Q10[ i ], 14 ), W_tmp_Q9 ) );
|
||||
pNLSF_Q15[ i ] = (SKP_int16)SKP_LIMIT( NLSF_Q15_tmp, 0, 32767 );
|
||||
W_tmp_Q9 = silk_SQRT_APPROX( SKP_LSHIFT( ( opus_int32 )W_tmp_QW[ i ], 18 - NLSF_W_Q ) );
|
||||
NLSF_Q15_tmp = SKP_ADD32( pNLSF_Q15[ i ], SKP_DIV32_16( SKP_LSHIFT( ( opus_int32 )res_Q10[ i ], 14 ), W_tmp_Q9 ) );
|
||||
pNLSF_Q15[ i ] = (opus_int16)SKP_LIMIT( NLSF_Q15_tmp, 0, 32767 );
|
||||
}
|
||||
|
||||
/* NLSF stabilization */
|
||||
|
|
|
@ -28,29 +28,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "silk_main.h"
|
||||
|
||||
/* Delayed-decision quantizer for NLSF residuals */
|
||||
SKP_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */
|
||||
SKP_int8 indices[], /* O Quantization indices [ order ] */
|
||||
const SKP_int16 x_Q10[], /* I Input [ order ] */
|
||||
const SKP_int16 w_Q5[], /* I Weights [ order ] */
|
||||
const SKP_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */
|
||||
const SKP_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */
|
||||
const SKP_uint8 ec_rates_Q5[], /* I Rates [] */
|
||||
const SKP_int quant_step_size_Q16, /* I Quantization step size */
|
||||
const SKP_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */
|
||||
const SKP_int32 mu_Q20, /* I R/D tradeoff */
|
||||
const SKP_int16 order /* I Number of input values */
|
||||
opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */
|
||||
opus_int8 indices[], /* O Quantization indices [ order ] */
|
||||
const opus_int16 x_Q10[], /* I Input [ order ] */
|
||||
const opus_int16 w_Q5[], /* I Weights [ order ] */
|
||||
const opus_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */
|
||||
const opus_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */
|
||||
const opus_uint8 ec_rates_Q5[], /* I Rates [] */
|
||||
const opus_int quant_step_size_Q16, /* I Quantization step size */
|
||||
const opus_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */
|
||||
const opus_int32 mu_Q20, /* I R/D tradeoff */
|
||||
const opus_int16 order /* I Number of input values */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, nStates, ind_tmp, ind_min_max, ind_max_min, in_Q10, res_Q10;
|
||||
SKP_int pred_Q10, diff_Q10, out0_Q10, out1_Q10, rate0_Q5, rate1_Q5;
|
||||
SKP_int32 RD_tmp_Q25, min_Q25, min_max_Q25, max_min_Q25, pred_coef_Q16;
|
||||
SKP_int ind_sort[ NLSF_QUANT_DEL_DEC_STATES ];
|
||||
SKP_int8 ind[ NLSF_QUANT_DEL_DEC_STATES ][ MAX_LPC_ORDER ];
|
||||
SKP_int16 prev_out_Q10[ 2 * NLSF_QUANT_DEL_DEC_STATES ];
|
||||
SKP_int32 RD_Q25[ 2 * NLSF_QUANT_DEL_DEC_STATES ];
|
||||
SKP_int32 RD_min_Q25[ NLSF_QUANT_DEL_DEC_STATES ];
|
||||
SKP_int32 RD_max_Q25[ NLSF_QUANT_DEL_DEC_STATES ];
|
||||
const SKP_uint8 *rates_Q5;
|
||||
opus_int i, j, nStates, ind_tmp, ind_min_max, ind_max_min, in_Q10, res_Q10;
|
||||
opus_int pred_Q10, diff_Q10, out0_Q10, out1_Q10, rate0_Q5, rate1_Q5;
|
||||
opus_int32 RD_tmp_Q25, min_Q25, min_max_Q25, max_min_Q25, pred_coef_Q16;
|
||||
opus_int ind_sort[ NLSF_QUANT_DEL_DEC_STATES ];
|
||||
opus_int8 ind[ NLSF_QUANT_DEL_DEC_STATES ][ MAX_LPC_ORDER ];
|
||||
opus_int16 prev_out_Q10[ 2 * NLSF_QUANT_DEL_DEC_STATES ];
|
||||
opus_int32 RD_Q25[ 2 * NLSF_QUANT_DEL_DEC_STATES ];
|
||||
opus_int32 RD_min_Q25[ NLSF_QUANT_DEL_DEC_STATES ];
|
||||
opus_int32 RD_max_Q25[ NLSF_QUANT_DEL_DEC_STATES ];
|
||||
const opus_uint8 *rates_Q5;
|
||||
|
||||
SKP_assert( (NLSF_QUANT_DEL_DEC_STATES & (NLSF_QUANT_DEL_DEC_STATES-1)) == 0 ); /* must be power of two */
|
||||
|
||||
|
@ -59,14 +59,14 @@ SKP_int32 silk_NLSF_del_dec_quant( /* O Returns RD value
|
|||
prev_out_Q10[ 0 ] = 0;
|
||||
for( i = order - 1; ; i-- ) {
|
||||
rates_Q5 = &ec_rates_Q5[ ec_ix[ i ] ];
|
||||
pred_coef_Q16 = SKP_LSHIFT( (SKP_int32)pred_coef_Q8[ i ], 8 );
|
||||
pred_coef_Q16 = SKP_LSHIFT( (opus_int32)pred_coef_Q8[ i ], 8 );
|
||||
in_Q10 = x_Q10[ i ];
|
||||
for( j = 0; j < nStates; j++ ) {
|
||||
pred_Q10 = SKP_SMULWB( pred_coef_Q16, prev_out_Q10[ j ] );
|
||||
res_Q10 = SKP_SUB16( in_Q10, pred_Q10 );
|
||||
ind_tmp = SKP_SMULWB( inv_quant_step_size_Q6, res_Q10 );
|
||||
ind_tmp = SKP_LIMIT( ind_tmp, -NLSF_QUANT_MAX_AMPLITUDE_EXT, NLSF_QUANT_MAX_AMPLITUDE_EXT-1 );
|
||||
ind[ j ][ i ] = (SKP_int8)ind_tmp;
|
||||
ind[ j ][ i ] = (opus_int8)ind_tmp;
|
||||
|
||||
/* compute outputs for ind_tmp and ind_tmp + 1 */
|
||||
out0_Q10 = SKP_LSHIFT( ind_tmp, 10 );
|
||||
|
@ -171,7 +171,7 @@ SKP_int32 silk_NLSF_del_dec_quant( /* O Returns RD value
|
|||
prev_out_Q10[ ind_max_min ] = prev_out_Q10[ ind_min_max + NLSF_QUANT_DEL_DEC_STATES ];
|
||||
RD_min_Q25[ ind_max_min ] = 0;
|
||||
RD_max_Q25[ ind_min_max ] = SKP_int32_MAX;
|
||||
SKP_memcpy( ind[ ind_max_min ], ind[ ind_min_max ], MAX_LPC_ORDER * sizeof( SKP_int8 ) );
|
||||
SKP_memcpy( ind[ ind_max_min ], ind[ ind_min_max ], MAX_LPC_ORDER * sizeof( opus_int8 ) );
|
||||
}
|
||||
/* increment index if it comes from the upper half */
|
||||
for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) {
|
||||
|
|
|
@ -32,37 +32,37 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/***********************/
|
||||
/* NLSF vector encoder */
|
||||
/***********************/
|
||||
SKP_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */
|
||||
SKP_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
|
||||
SKP_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */
|
||||
opus_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */
|
||||
opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
|
||||
opus_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */
|
||||
const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
|
||||
const SKP_int16 *pW_QW, /* I NLSF weight vector [ LPC_ORDER ] */
|
||||
const SKP_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */
|
||||
const SKP_int nSurvivors, /* I Max survivors after first stage */
|
||||
const SKP_int signalType /* I Signal type: 0/1/2 */
|
||||
const opus_int16 *pW_QW, /* I NLSF weight vector [ LPC_ORDER ] */
|
||||
const opus_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */
|
||||
const opus_int nSurvivors, /* I Max survivors after first stage */
|
||||
const opus_int signalType /* I Signal type: 0/1/2 */
|
||||
)
|
||||
{
|
||||
SKP_int i, s, ind1, bestIndex, prob_Q8, bits_q7;
|
||||
SKP_int32 W_tmp_Q9;
|
||||
SKP_int32 err_Q26[ NLSF_VQ_MAX_VECTORS ];
|
||||
SKP_int32 RD_Q25[ NLSF_VQ_MAX_SURVIVORS ];
|
||||
SKP_int tempIndices1[ NLSF_VQ_MAX_SURVIVORS ];
|
||||
SKP_int8 tempIndices2[ NLSF_VQ_MAX_SURVIVORS * MAX_LPC_ORDER ];
|
||||
SKP_int16 res_Q15[ MAX_LPC_ORDER ];
|
||||
SKP_int16 res_Q10[ MAX_LPC_ORDER ];
|
||||
SKP_int16 NLSF_tmp_Q15[ MAX_LPC_ORDER ];
|
||||
SKP_int16 W_tmp_QW[ MAX_LPC_ORDER ];
|
||||
SKP_int16 W_adj_Q5[ MAX_LPC_ORDER ];
|
||||
SKP_uint8 pred_Q8[ MAX_LPC_ORDER ];
|
||||
SKP_int16 ec_ix[ MAX_LPC_ORDER ];
|
||||
const SKP_uint8 *pCB_element, *iCDF_ptr;
|
||||
opus_int i, s, ind1, bestIndex, prob_Q8, bits_q7;
|
||||
opus_int32 W_tmp_Q9;
|
||||
opus_int32 err_Q26[ NLSF_VQ_MAX_VECTORS ];
|
||||
opus_int32 RD_Q25[ NLSF_VQ_MAX_SURVIVORS ];
|
||||
opus_int tempIndices1[ NLSF_VQ_MAX_SURVIVORS ];
|
||||
opus_int8 tempIndices2[ NLSF_VQ_MAX_SURVIVORS * MAX_LPC_ORDER ];
|
||||
opus_int16 res_Q15[ MAX_LPC_ORDER ];
|
||||
opus_int16 res_Q10[ MAX_LPC_ORDER ];
|
||||
opus_int16 NLSF_tmp_Q15[ MAX_LPC_ORDER ];
|
||||
opus_int16 W_tmp_QW[ MAX_LPC_ORDER ];
|
||||
opus_int16 W_adj_Q5[ MAX_LPC_ORDER ];
|
||||
opus_uint8 pred_Q8[ MAX_LPC_ORDER ];
|
||||
opus_int16 ec_ix[ MAX_LPC_ORDER ];
|
||||
const opus_uint8 *pCB_element, *iCDF_ptr;
|
||||
|
||||
#if STORE_LSF_DATA_FOR_TRAINING
|
||||
SKP_int16 pNLSF_Q15_orig[MAX_LPC_ORDER ];
|
||||
DEBUG_STORE_DATA( NLSF.dat, pNLSF_Q15, psNLSF_CB->order * sizeof( SKP_int16 ) );
|
||||
DEBUG_STORE_DATA( WNLSF.dat, pW_Q5, psNLSF_CB->order * sizeof( SKP_int16 ) );
|
||||
DEBUG_STORE_DATA( NLSF_mu.dat, &NLSF_mu_Q20, sizeof( SKP_int ) );
|
||||
DEBUG_STORE_DATA( sigType.dat, &signalType, sizeof( SKP_int ) );
|
||||
opus_int16 pNLSF_Q15_orig[MAX_LPC_ORDER ];
|
||||
DEBUG_STORE_DATA( NLSF.dat, pNLSF_Q15, psNLSF_CB->order * sizeof( opus_int16 ) );
|
||||
DEBUG_STORE_DATA( WNLSF.dat, pW_Q5, psNLSF_CB->order * sizeof( opus_int16 ) );
|
||||
DEBUG_STORE_DATA( NLSF_mu.dat, &NLSF_mu_Q20, sizeof( opus_int ) );
|
||||
DEBUG_STORE_DATA( sigType.dat, &signalType, sizeof( opus_int ) );
|
||||
SKP_memcpy(pNLSF_Q15_orig, pNLSF_Q15, sizeof( pNLSF_Q15_orig ));
|
||||
#endif
|
||||
|
||||
|
@ -86,7 +86,7 @@ SKP_int32 silk_NLSF_encode( /* O Returns RD v
|
|||
/* Residual after first stage */
|
||||
pCB_element = &psNLSF_CB->CB1_NLSF_Q8[ ind1 * psNLSF_CB->order ];
|
||||
for( i = 0; i < psNLSF_CB->order; i++ ) {
|
||||
NLSF_tmp_Q15[ i ] = SKP_LSHIFT16( ( SKP_int16 )pCB_element[ i ], 7 );
|
||||
NLSF_tmp_Q15[ i ] = SKP_LSHIFT16( ( opus_int16 )pCB_element[ i ], 7 );
|
||||
res_Q15[ i ] = pNLSF_Q15[ i ] - NLSF_tmp_Q15[ i ];
|
||||
}
|
||||
|
||||
|
@ -95,13 +95,13 @@ SKP_int32 silk_NLSF_encode( /* O Returns RD v
|
|||
|
||||
/* Apply square-rooted weights */
|
||||
for( i = 0; i < psNLSF_CB->order; i++ ) {
|
||||
W_tmp_Q9 = silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_QW[ i ], 18 - NLSF_W_Q ) );
|
||||
res_Q10[ i ] = ( SKP_int16 )SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 );
|
||||
W_tmp_Q9 = silk_SQRT_APPROX( SKP_LSHIFT( ( opus_int32 )W_tmp_QW[ i ], 18 - NLSF_W_Q ) );
|
||||
res_Q10[ i ] = ( opus_int16 )SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 );
|
||||
}
|
||||
|
||||
/* Modify input weights accordingly */
|
||||
for( i = 0; i < psNLSF_CB->order; i++ ) {
|
||||
W_adj_Q5[ i ] = SKP_DIV32_16( SKP_LSHIFT( ( SKP_int32 )pW_QW[ i ], 5 ), W_tmp_QW[ i ] );
|
||||
W_adj_Q5[ i ] = SKP_DIV32_16( SKP_LSHIFT( ( opus_int32 )pW_QW[ i ], 5 ), W_tmp_QW[ i ] );
|
||||
}
|
||||
|
||||
/* Unpack entropy table indices and predictor for current CB1 index */
|
||||
|
@ -125,8 +125,8 @@ SKP_int32 silk_NLSF_encode( /* O Returns RD v
|
|||
/* Find the lowest rate-distortion error */
|
||||
silk_insertion_sort_increasing( RD_Q25, &bestIndex, nSurvivors, 1 );
|
||||
|
||||
NLSFIndices[ 0 ] = ( SKP_int8 )tempIndices1[ bestIndex ];
|
||||
SKP_memcpy( &NLSFIndices[ 1 ], &tempIndices2[ bestIndex * MAX_LPC_ORDER ], psNLSF_CB->order * sizeof( SKP_int8 ) );
|
||||
NLSFIndices[ 0 ] = ( opus_int8 )tempIndices1[ bestIndex ];
|
||||
SKP_memcpy( &NLSFIndices[ 1 ], &tempIndices2[ bestIndex * MAX_LPC_ORDER ], psNLSF_CB->order * sizeof( opus_int8 ) );
|
||||
|
||||
/* Decode */
|
||||
silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB );
|
||||
|
@ -134,23 +134,23 @@ SKP_int32 silk_NLSF_encode( /* O Returns RD v
|
|||
#if STORE_LSF_DATA_FOR_TRAINING
|
||||
{
|
||||
/* code for training the codebooks */
|
||||
SKP_int32 RD_dec_Q22, Dist_Q22_dec, Rate_Q7, diff_Q15;
|
||||
opus_int32 RD_dec_Q22, Dist_Q22_dec, Rate_Q7, diff_Q15;
|
||||
ind1 = NLSFIndices[ 0 ];
|
||||
silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, ind1 );
|
||||
|
||||
pCB_element = &psNLSF_CB->CB1_NLSF_Q8[ ind1 * psNLSF_CB->order ];
|
||||
for( i = 0; i < psNLSF_CB->order; i++ ) {
|
||||
NLSF_tmp_Q15[ i ] = SKP_LSHIFT16( ( SKP_int16 )pCB_element[ i ], 7 );
|
||||
NLSF_tmp_Q15[ i ] = SKP_LSHIFT16( ( opus_int16 )pCB_element[ i ], 7 );
|
||||
}
|
||||
silk_NLSF_VQ_weights_laroia( W_tmp_QW, NLSF_tmp_Q15, psNLSF_CB->order );
|
||||
for( i = 0; i < psNLSF_CB->order; i++ ) {
|
||||
W_tmp_Q9 = silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_QW[ i ], 18 - NLSF_W_Q ) );
|
||||
W_tmp_Q9 = silk_SQRT_APPROX( SKP_LSHIFT( ( opus_int32 )W_tmp_QW[ i ], 18 - NLSF_W_Q ) );
|
||||
res_Q15[ i ] = pNLSF_Q15_orig[ i ] - NLSF_tmp_Q15[ i ];
|
||||
res_Q10[ i ] = (SKP_int16)SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 );
|
||||
DEBUG_STORE_DATA( NLSF_res_q10.dat, &res_Q10[ i ], sizeof( SKP_int16 ) );
|
||||
res_Q10[ i ] = (opus_int16)SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 );
|
||||
DEBUG_STORE_DATA( NLSF_res_q10.dat, &res_Q10[ i ], sizeof( opus_int16 ) );
|
||||
res_Q15[ i ] = pNLSF_Q15[ i ] - NLSF_tmp_Q15[ i ];
|
||||
res_Q10[ i ] = (SKP_int16)SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 );
|
||||
DEBUG_STORE_DATA( NLSF_resq_q10.dat, &res_Q10[ i ], sizeof( SKP_int16 ) );
|
||||
res_Q10[ i ] = (opus_int16)SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 );
|
||||
DEBUG_STORE_DATA( NLSF_resq_q10.dat, &res_Q10[ i ], sizeof( opus_int16 ) );
|
||||
}
|
||||
|
||||
Dist_Q22_dec = 0;
|
||||
|
@ -172,11 +172,11 @@ SKP_int32 silk_NLSF_encode( /* O Returns RD v
|
|||
}
|
||||
}
|
||||
RD_dec_Q22 = Dist_Q22_dec + Rate_Q7 * NLSF_mu_Q20 >> 5;
|
||||
DEBUG_STORE_DATA( dec_dist_q22.dat, &Dist_Q22_dec, sizeof( SKP_int32 ) );
|
||||
DEBUG_STORE_DATA( dec_rate_q7.dat, &Rate_Q7, sizeof( SKP_int32 ) );
|
||||
DEBUG_STORE_DATA( dec_rd_q22.dat, &RD_dec_Q22, sizeof( SKP_int32 ) );
|
||||
DEBUG_STORE_DATA( dec_dist_q22.dat, &Dist_Q22_dec, sizeof( opus_int32 ) );
|
||||
DEBUG_STORE_DATA( dec_rate_q7.dat, &Rate_Q7, sizeof( opus_int32 ) );
|
||||
DEBUG_STORE_DATA( dec_rd_q22.dat, &RD_dec_Q22, sizeof( opus_int32 ) );
|
||||
}
|
||||
DEBUG_STORE_DATA( NLSF_ind.dat, NLSFIndices, (psNLSF_CB->order+1) * sizeof( SKP_int8 ) );
|
||||
DEBUG_STORE_DATA( NLSF_ind.dat, NLSFIndices, (psNLSF_CB->order+1) * sizeof( opus_int8 ) );
|
||||
#endif
|
||||
|
||||
return RD_Q25[ 0 ];
|
||||
|
|
|
@ -41,16 +41,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* NLSF stabilizer, for a single input data vector */
|
||||
void silk_NLSF_stabilize(
|
||||
SKP_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */
|
||||
const SKP_int16 *NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */
|
||||
const SKP_int L /* I: Number of NLSF parameters in the input vector */
|
||||
opus_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */
|
||||
const opus_int16 *NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */
|
||||
const opus_int L /* I: Number of NLSF parameters in the input vector */
|
||||
)
|
||||
{
|
||||
SKP_int i, I=0, k, loops;
|
||||
SKP_int16 center_freq_Q15;
|
||||
SKP_int32 diff_Q15, min_diff_Q15, min_center_Q15, max_center_Q15;
|
||||
opus_int i, I=0, k, loops;
|
||||
opus_int16 center_freq_Q15;
|
||||
opus_int32 diff_Q15, min_diff_Q15, min_center_Q15, max_center_Q15;
|
||||
|
||||
/* This is necessary to ensure an output within range of a SKP_int16 */
|
||||
/* This is necessary to ensure an output within range of a opus_int16 */
|
||||
SKP_assert( NDeltaMin_Q15[L] >= 1 );
|
||||
|
||||
for( loops = 0; loops < MAX_LOOPS; loops++ ) {
|
||||
|
@ -106,7 +106,7 @@ void silk_NLSF_stabilize(
|
|||
max_center_Q15 -= SKP_RSHIFT( NDeltaMin_Q15[I], 1 );
|
||||
|
||||
/* Move apart, sorted by value, keeping the same center frequency */
|
||||
center_freq_Q15 = (SKP_int16)SKP_LIMIT_32( SKP_RSHIFT_ROUND( (SKP_int32)NLSF_Q15[I-1] + (SKP_int32)NLSF_Q15[I], 1 ),
|
||||
center_freq_Q15 = (opus_int16)SKP_LIMIT_32( SKP_RSHIFT_ROUND( (opus_int32)NLSF_Q15[I-1] + (opus_int32)NLSF_Q15[I], 1 ),
|
||||
min_center_Q15, max_center_Q15 );
|
||||
NLSF_Q15[I-1] = center_freq_Q15 - SKP_RSHIFT( NDeltaMin_Q15[I], 1 );
|
||||
NLSF_Q15[I] = NLSF_Q15[I-1] + NDeltaMin_Q15[I];
|
||||
|
|
|
@ -29,15 +29,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Unpack predictor values and indices for entropy coding tables */
|
||||
void silk_NLSF_unpack(
|
||||
SKP_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */
|
||||
SKP_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */
|
||||
opus_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */
|
||||
opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */
|
||||
const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
|
||||
const SKP_int CB1_index /* I Index of vector in first LSF codebook */
|
||||
const opus_int CB1_index /* I Index of vector in first LSF codebook */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
SKP_uint8 entry;
|
||||
const SKP_uint8 *ec_sel_ptr;
|
||||
opus_int i;
|
||||
opus_uint8 entry;
|
||||
const opus_uint8 *ec_sel_ptr;
|
||||
|
||||
ec_sel_ptr = &psNLSF_CB->ec_sel[ CB1_index * psNLSF_CB->order / 2 ];
|
||||
for( i = 0; i < psNLSF_CB->order; i += 2 ) {
|
||||
|
|
182
silk/silk_NSQ.c
182
silk/silk_NSQ.c
|
@ -30,64 +30,64 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
SKP_INLINE void silk_nsq_scale_states(
|
||||
const silk_encoder_state *psEncC, /* I Encoder State */
|
||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||
const SKP_int16 x[], /* I input in Q0 */
|
||||
SKP_int32 x_sc_Q10[], /* O input scaled with 1/Gain */
|
||||
const SKP_int16 sLTP[], /* I re-whitened LTP state in Q0 */
|
||||
SKP_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||
SKP_int subfr, /* I subframe number */
|
||||
const SKP_int LTP_scale_Q14, /* I */
|
||||
const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int pitchL[ MAX_NB_SUBFR ] /* I */
|
||||
const opus_int16 x[], /* I input in Q0 */
|
||||
opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */
|
||||
const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */
|
||||
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||
opus_int subfr, /* I subframe number */
|
||||
const opus_int LTP_scale_Q14, /* I */
|
||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int pitchL[ MAX_NB_SUBFR ] /* I */
|
||||
);
|
||||
|
||||
SKP_INLINE void silk_noise_shape_quantizer(
|
||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||
SKP_int signalType, /* I Signal type */
|
||||
const SKP_int32 x_sc_Q10[], /* I */
|
||||
SKP_int8 pulses[], /* O */
|
||||
SKP_int16 xq[], /* O */
|
||||
SKP_int32 sLTP_Q16[], /* I/O LTP state */
|
||||
const SKP_int16 a_Q12[], /* I Short term prediction coefs */
|
||||
const SKP_int16 b_Q14[], /* I Long term prediction coefs */
|
||||
const SKP_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */
|
||||
SKP_int lag, /* I Pitch lag */
|
||||
SKP_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||
SKP_int Tilt_Q14, /* I Spectral tilt */
|
||||
SKP_int32 LF_shp_Q14, /* I */
|
||||
SKP_int32 Gain_Q16, /* I */
|
||||
SKP_int Lambda_Q10, /* I */
|
||||
SKP_int offset_Q10, /* I */
|
||||
SKP_int length, /* I Input length */
|
||||
SKP_int shapingLPCOrder, /* I Noise shaping AR filter order */
|
||||
SKP_int predictLPCOrder /* I Prediction filter order */
|
||||
opus_int signalType, /* I Signal type */
|
||||
const opus_int32 x_sc_Q10[], /* I */
|
||||
opus_int8 pulses[], /* O */
|
||||
opus_int16 xq[], /* O */
|
||||
opus_int32 sLTP_Q16[], /* I/O LTP state */
|
||||
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
||||
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
||||
const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */
|
||||
opus_int lag, /* I Pitch lag */
|
||||
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||
opus_int Tilt_Q14, /* I Spectral tilt */
|
||||
opus_int32 LF_shp_Q14, /* I */
|
||||
opus_int32 Gain_Q16, /* I */
|
||||
opus_int Lambda_Q10, /* I */
|
||||
opus_int offset_Q10, /* I */
|
||||
opus_int length, /* I Input length */
|
||||
opus_int shapingLPCOrder, /* I Noise shaping AR filter order */
|
||||
opus_int predictLPCOrder /* I Prediction filter order */
|
||||
);
|
||||
|
||||
void silk_NSQ(
|
||||
const silk_encoder_state *psEncC, /* I/O Encoder State */
|
||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||
SideInfoIndices *psIndices, /* I/O Quantization Indices */
|
||||
const SKP_int16 x[], /* I prefiltered input signal */
|
||||
SKP_int8 pulses[], /* O quantized qulse signal */
|
||||
const SKP_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefficients */
|
||||
const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefficients */
|
||||
const SKP_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */
|
||||
const SKP_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
|
||||
const SKP_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int pitchL[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int Lambda_Q10, /* I */
|
||||
const SKP_int LTP_scale_Q14 /* I LTP state scaling */
|
||||
const opus_int16 x[], /* I prefiltered input signal */
|
||||
opus_int8 pulses[], /* O quantized qulse signal */
|
||||
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefficients */
|
||||
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefficients */
|
||||
const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */
|
||||
const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
|
||||
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int Lambda_Q10, /* I */
|
||||
const opus_int LTP_scale_Q14 /* I LTP state scaling */
|
||||
)
|
||||
{
|
||||
SKP_int k, lag, start_idx, LSF_interpolation_flag;
|
||||
const SKP_int16 *A_Q12, *B_Q14, *AR_shp_Q13;
|
||||
SKP_int16 *pxq;
|
||||
SKP_int32 sLTP_Q16[ 2 * MAX_FRAME_LENGTH ];
|
||||
SKP_int16 sLTP[ 2 * MAX_FRAME_LENGTH ];
|
||||
SKP_int32 HarmShapeFIRPacked_Q14;
|
||||
SKP_int offset_Q10;
|
||||
SKP_int32 x_sc_Q10[ MAX_FRAME_LENGTH / MAX_NB_SUBFR ];
|
||||
opus_int k, lag, start_idx, LSF_interpolation_flag;
|
||||
const opus_int16 *A_Q12, *B_Q14, *AR_shp_Q13;
|
||||
opus_int16 *pxq;
|
||||
opus_int32 sLTP_Q16[ 2 * MAX_FRAME_LENGTH ];
|
||||
opus_int16 sLTP[ 2 * MAX_FRAME_LENGTH ];
|
||||
opus_int32 HarmShapeFIRPacked_Q14;
|
||||
opus_int offset_Q10;
|
||||
opus_int32 x_sc_Q10[ MAX_FRAME_LENGTH / MAX_NB_SUBFR ];
|
||||
|
||||
NSQ->rand_seed = psIndices->Seed;
|
||||
|
||||
|
@ -116,7 +116,7 @@ void silk_NSQ(
|
|||
/* Noise shape parameters */
|
||||
SKP_assert( HarmShapeGain_Q14[ k ] >= 0 );
|
||||
HarmShapeFIRPacked_Q14 = SKP_RSHIFT( HarmShapeGain_Q14[ k ], 2 );
|
||||
HarmShapeFIRPacked_Q14 |= SKP_LSHIFT( ( SKP_int32 )SKP_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 );
|
||||
HarmShapeFIRPacked_Q14 |= SKP_LSHIFT( ( opus_int32 )SKP_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 );
|
||||
|
||||
NSQ->rewhite_flag = 0;
|
||||
if( psIndices->signalType == TYPE_VOICED ) {
|
||||
|
@ -152,13 +152,13 @@ void silk_NSQ(
|
|||
NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ];
|
||||
|
||||
/* Save quantized speech and noise shaping signals */
|
||||
SKP_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( SKP_int16 ) );
|
||||
SKP_memmove( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( SKP_int32 ) );
|
||||
SKP_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) );
|
||||
SKP_memmove( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) );
|
||||
|
||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
||||
DEBUG_STORE_DATA( xq.dat, &pxq[ -psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int16 ) );
|
||||
DEBUG_STORE_DATA( q.dat, &pulses[ -psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int8 ) );
|
||||
DEBUG_STORE_DATA( sLTP_Q16.dat, &sLTP_Q16[ psEncC->ltp_mem_length ], psEncC->frame_length * sizeof( SKP_int32 ) );
|
||||
DEBUG_STORE_DATA( xq.dat, &pxq[ -psEncC->frame_length ], psEncC->frame_length * sizeof( opus_int16 ) );
|
||||
DEBUG_STORE_DATA( q.dat, &pulses[ -psEncC->frame_length ], psEncC->frame_length * sizeof( opus_int8 ) );
|
||||
DEBUG_STORE_DATA( sLTP_Q16.dat, &sLTP_Q16[ psEncC->ltp_mem_length ], psEncC->frame_length * sizeof( opus_int32 ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -167,32 +167,32 @@ void silk_NSQ(
|
|||
/***********************************/
|
||||
SKP_INLINE void silk_noise_shape_quantizer(
|
||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||
SKP_int signalType, /* I Signal type */
|
||||
const SKP_int32 x_sc_Q10[], /* I */
|
||||
SKP_int8 pulses[], /* O */
|
||||
SKP_int16 xq[], /* O */
|
||||
SKP_int32 sLTP_Q16[], /* I/O LTP state */
|
||||
const SKP_int16 a_Q12[], /* I Short term prediction coefs */
|
||||
const SKP_int16 b_Q14[], /* I Long term prediction coefs */
|
||||
const SKP_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */
|
||||
SKP_int lag, /* I Pitch lag */
|
||||
SKP_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||
SKP_int Tilt_Q14, /* I Spectral tilt */
|
||||
SKP_int32 LF_shp_Q14, /* I */
|
||||
SKP_int32 Gain_Q16, /* I */
|
||||
SKP_int Lambda_Q10, /* I */
|
||||
SKP_int offset_Q10, /* I */
|
||||
SKP_int length, /* I Input length */
|
||||
SKP_int shapingLPCOrder, /* I Noise shaping AR filter order */
|
||||
SKP_int predictLPCOrder /* I Prediction filter order */
|
||||
opus_int signalType, /* I Signal type */
|
||||
const opus_int32 x_sc_Q10[], /* I */
|
||||
opus_int8 pulses[], /* O */
|
||||
opus_int16 xq[], /* O */
|
||||
opus_int32 sLTP_Q16[], /* I/O LTP state */
|
||||
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
||||
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
||||
const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */
|
||||
opus_int lag, /* I Pitch lag */
|
||||
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||
opus_int Tilt_Q14, /* I Spectral tilt */
|
||||
opus_int32 LF_shp_Q14, /* I */
|
||||
opus_int32 Gain_Q16, /* I */
|
||||
opus_int Lambda_Q10, /* I */
|
||||
opus_int offset_Q10, /* I */
|
||||
opus_int length, /* I Input length */
|
||||
opus_int shapingLPCOrder, /* I Noise shaping AR filter order */
|
||||
opus_int predictLPCOrder /* I Prediction filter order */
|
||||
)
|
||||
{
|
||||
SKP_int i, j;
|
||||
SKP_int32 LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14;
|
||||
SKP_int32 n_LF_Q10, r_Q10, rr_Q10, q1_Q10, q2_Q10, rd1_Q10, rd2_Q10;
|
||||
SKP_int32 dither, exc_Q10, LPC_exc_Q10, xq_Q10;
|
||||
SKP_int32 tmp1, tmp2, sLF_AR_shp_Q10;
|
||||
SKP_int32 *psLPC_Q14, *shp_lag_ptr, *pred_lag_ptr;
|
||||
opus_int i, j;
|
||||
opus_int32 LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14;
|
||||
opus_int32 n_LF_Q10, r_Q10, rr_Q10, q1_Q10, q2_Q10, rd1_Q10, rd2_Q10;
|
||||
opus_int32 dither, exc_Q10, LPC_exc_Q10, xq_Q10;
|
||||
opus_int32 tmp1, tmp2, sLF_AR_shp_Q10;
|
||||
opus_int32 *psLPC_Q14, *shp_lag_ptr, *pred_lag_ptr;
|
||||
|
||||
shp_lag_ptr = &NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ];
|
||||
pred_lag_ptr = &sLTP_Q16[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ];
|
||||
|
@ -209,7 +209,7 @@ SKP_INLINE void silk_noise_shape_quantizer(
|
|||
|
||||
/* Short-term prediction */
|
||||
SKP_assert( ( predictLPCOrder & 1 ) == 0 ); /* check that order is even */
|
||||
SKP_assert( ( (SKP_int64)a_Q12 & 3 ) == 0 ); /* check that array starts at 4-byte aligned address */
|
||||
SKP_assert( ( (opus_int64)a_Q12 & 3 ) == 0 ); /* check that array starts at 4-byte aligned address */
|
||||
SKP_assert( predictLPCOrder >= 10 ); /* check that unrolling works */
|
||||
|
||||
/* Partially unrolled */
|
||||
|
@ -325,7 +325,7 @@ SKP_INLINE void silk_noise_shape_quantizer(
|
|||
q1_Q10 = q2_Q10;
|
||||
}
|
||||
|
||||
pulses[ i ] = ( SKP_int8 )SKP_RSHIFT_ROUND( q1_Q10, 10 );
|
||||
pulses[ i ] = ( opus_int8 )SKP_RSHIFT_ROUND( q1_Q10, 10 );
|
||||
|
||||
/* Excitation */
|
||||
exc_Q10 = q1_Q10 ^ dither;
|
||||
|
@ -335,7 +335,7 @@ SKP_INLINE void silk_noise_shape_quantizer(
|
|||
xq_Q10 = SKP_ADD32( LPC_exc_Q10, LPC_pred_Q10 );
|
||||
|
||||
/* Scale XQ back to normal level before saving */
|
||||
xq[ i ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( xq_Q10, Gain_Q16 ), 10 ) );
|
||||
xq[ i ] = ( opus_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( xq_Q10, Gain_Q16 ), 10 ) );
|
||||
|
||||
/* Update states */
|
||||
psLPC_Q14++;
|
||||
|
@ -353,24 +353,24 @@ SKP_INLINE void silk_noise_shape_quantizer(
|
|||
}
|
||||
|
||||
/* Update LPC synth buffer */
|
||||
SKP_memcpy( NSQ->sLPC_Q14, &NSQ->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( NSQ->sLPC_Q14, &NSQ->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) );
|
||||
}
|
||||
|
||||
SKP_INLINE void silk_nsq_scale_states(
|
||||
const silk_encoder_state *psEncC, /* I Encoder State */
|
||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||
const SKP_int16 x[], /* I input in Q0 */
|
||||
SKP_int32 x_sc_Q10[], /* O input scaled with 1/Gain */
|
||||
const SKP_int16 sLTP[], /* I re-whitened LTP state in Q0 */
|
||||
SKP_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||
SKP_int subfr, /* I subframe number */
|
||||
const SKP_int LTP_scale_Q14, /* I */
|
||||
const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int pitchL[ MAX_NB_SUBFR ] /* I */
|
||||
const opus_int16 x[], /* I input in Q0 */
|
||||
opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */
|
||||
const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */
|
||||
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||
opus_int subfr, /* I subframe number */
|
||||
const opus_int LTP_scale_Q14, /* I */
|
||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int pitchL[ MAX_NB_SUBFR ] /* I */
|
||||
)
|
||||
{
|
||||
SKP_int i, lag;
|
||||
SKP_int32 inv_gain_Q16, gain_adj_Q16, inv_gain_Q32;
|
||||
opus_int i, lag;
|
||||
opus_int32 inv_gain_Q16, gain_adj_Q16, inv_gain_Q32;
|
||||
|
||||
inv_gain_Q16 = silk_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 );
|
||||
inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX );
|
||||
|
@ -418,7 +418,7 @@ SKP_INLINE void silk_nsq_scale_states(
|
|||
|
||||
/* Scale input */
|
||||
for( i = 0; i < psEncC->subfr_length; i++ ) {
|
||||
x_sc_Q10[ i ] = SKP_RSHIFT( SKP_SMULBB( x[ i ], ( SKP_int16 )inv_gain_Q16 ), 6 );
|
||||
x_sc_Q10[ i ] = SKP_RSHIFT( SKP_SMULBB( x[ i ], ( opus_int16 )inv_gain_Q16 ), 6 );
|
||||
}
|
||||
|
||||
/* save inv_gain */
|
||||
|
|
|
@ -28,42 +28,42 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "silk_main.h"
|
||||
|
||||
typedef struct {
|
||||
SKP_int32 sLPC_Q14[ MAX_FRAME_LENGTH / MAX_NB_SUBFR + NSQ_LPC_BUF_LENGTH ];
|
||||
SKP_int32 RandState[ DECISION_DELAY ];
|
||||
SKP_int32 Q_Q10[ DECISION_DELAY ];
|
||||
SKP_int32 Xq_Q10[ DECISION_DELAY ];
|
||||
SKP_int32 Pred_Q16[ DECISION_DELAY ];
|
||||
SKP_int32 Shape_Q10[ DECISION_DELAY ];
|
||||
SKP_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ];
|
||||
SKP_int32 LF_AR_Q12;
|
||||
SKP_int32 Seed;
|
||||
SKP_int32 SeedInit;
|
||||
SKP_int32 RD_Q10;
|
||||
opus_int32 sLPC_Q14[ MAX_FRAME_LENGTH / MAX_NB_SUBFR + NSQ_LPC_BUF_LENGTH ];
|
||||
opus_int32 RandState[ DECISION_DELAY ];
|
||||
opus_int32 Q_Q10[ DECISION_DELAY ];
|
||||
opus_int32 Xq_Q10[ DECISION_DELAY ];
|
||||
opus_int32 Pred_Q16[ DECISION_DELAY ];
|
||||
opus_int32 Shape_Q10[ DECISION_DELAY ];
|
||||
opus_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ];
|
||||
opus_int32 LF_AR_Q12;
|
||||
opus_int32 Seed;
|
||||
opus_int32 SeedInit;
|
||||
opus_int32 RD_Q10;
|
||||
} NSQ_del_dec_struct;
|
||||
|
||||
typedef struct {
|
||||
SKP_int32 Q_Q10;
|
||||
SKP_int32 RD_Q10;
|
||||
SKP_int32 xq_Q14;
|
||||
SKP_int32 LF_AR_Q12;
|
||||
SKP_int32 sLTP_shp_Q10;
|
||||
SKP_int32 LPC_exc_Q16;
|
||||
opus_int32 Q_Q10;
|
||||
opus_int32 RD_Q10;
|
||||
opus_int32 xq_Q14;
|
||||
opus_int32 LF_AR_Q12;
|
||||
opus_int32 sLTP_shp_Q10;
|
||||
opus_int32 LPC_exc_Q16;
|
||||
} NSQ_sample_struct;
|
||||
|
||||
SKP_INLINE void silk_nsq_del_dec_scale_states(
|
||||
const silk_encoder_state *psEncC, /* I Encoder State */
|
||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||
NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
|
||||
const SKP_int16 x[], /* I Input in Q0 */
|
||||
SKP_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */
|
||||
const SKP_int16 sLTP[], /* I Re-whitened LTP state in Q0 */
|
||||
SKP_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||
SKP_int subfr, /* I Subframe number */
|
||||
SKP_int nStatesDelayedDecision, /* I Number of del dec states */
|
||||
SKP_int smpl_buf_idx, /* I Index to newest samples in buffers */
|
||||
const SKP_int LTP_scale_Q14, /* I LTP state scaling */
|
||||
const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int pitchL[ MAX_NB_SUBFR ] /* I Pitch lag */
|
||||
const opus_int16 x[], /* I Input in Q0 */
|
||||
opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */
|
||||
const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */
|
||||
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||
opus_int subfr, /* I Subframe number */
|
||||
opus_int nStatesDelayedDecision, /* I Number of del dec states */
|
||||
opus_int smpl_buf_idx, /* I Index to newest samples in buffers */
|
||||
const opus_int LTP_scale_Q14, /* I LTP state scaling */
|
||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int pitchL[ MAX_NB_SUBFR ] /* I Pitch lag */
|
||||
);
|
||||
|
||||
/******************************************/
|
||||
|
@ -72,61 +72,61 @@ SKP_INLINE void silk_nsq_del_dec_scale_states(
|
|||
SKP_INLINE void silk_noise_shape_quantizer_del_dec(
|
||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||
NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
|
||||
SKP_int signalType, /* I Signal type */
|
||||
const SKP_int32 x_Q10[], /* I */
|
||||
SKP_int8 pulses[], /* O */
|
||||
SKP_int16 xq[], /* O */
|
||||
SKP_int32 sLTP_Q16[], /* I/O LTP filter state */
|
||||
SKP_int32 delayedGain_Q16[], /* I/O Gain delay buffer */
|
||||
const SKP_int16 a_Q12[], /* I Short term prediction coefs */
|
||||
const SKP_int16 b_Q14[], /* I Long term prediction coefs */
|
||||
const SKP_int16 AR_shp_Q13[], /* I Noise shaping coefs */
|
||||
SKP_int lag, /* I Pitch lag */
|
||||
SKP_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||
SKP_int Tilt_Q14, /* I Spectral tilt */
|
||||
SKP_int32 LF_shp_Q14, /* I */
|
||||
SKP_int32 Gain_Q16, /* I */
|
||||
SKP_int Lambda_Q10, /* I */
|
||||
SKP_int offset_Q10, /* I */
|
||||
SKP_int length, /* I Input length */
|
||||
SKP_int subfr, /* I Subframe number */
|
||||
SKP_int shapingLPCOrder, /* I Shaping LPC filter order */
|
||||
SKP_int predictLPCOrder, /* I Prediction filter order */
|
||||
SKP_int warping_Q16, /* I */
|
||||
SKP_int nStatesDelayedDecision, /* I Number of states in decision tree */
|
||||
SKP_int *smpl_buf_idx, /* I Index to newest samples in buffers */
|
||||
SKP_int decisionDelay /* I */
|
||||
opus_int signalType, /* I Signal type */
|
||||
const opus_int32 x_Q10[], /* I */
|
||||
opus_int8 pulses[], /* O */
|
||||
opus_int16 xq[], /* O */
|
||||
opus_int32 sLTP_Q16[], /* I/O LTP filter state */
|
||||
opus_int32 delayedGain_Q16[], /* I/O Gain delay buffer */
|
||||
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
||||
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
||||
const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */
|
||||
opus_int lag, /* I Pitch lag */
|
||||
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||
opus_int Tilt_Q14, /* I Spectral tilt */
|
||||
opus_int32 LF_shp_Q14, /* I */
|
||||
opus_int32 Gain_Q16, /* I */
|
||||
opus_int Lambda_Q10, /* I */
|
||||
opus_int offset_Q10, /* I */
|
||||
opus_int length, /* I Input length */
|
||||
opus_int subfr, /* I Subframe number */
|
||||
opus_int shapingLPCOrder, /* I Shaping LPC filter order */
|
||||
opus_int predictLPCOrder, /* I Prediction filter order */
|
||||
opus_int warping_Q16, /* I */
|
||||
opus_int nStatesDelayedDecision, /* I Number of states in decision tree */
|
||||
opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */
|
||||
opus_int decisionDelay /* I */
|
||||
);
|
||||
|
||||
void silk_NSQ_del_dec(
|
||||
const silk_encoder_state *psEncC, /* I/O Encoder State */
|
||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||
SideInfoIndices *psIndices, /* I/O Quantization Indices */
|
||||
const SKP_int16 x[], /* I Prefiltered input signal */
|
||||
SKP_int8 pulses[], /* O Quantized pulse signal */
|
||||
const SKP_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Prediction coefs */
|
||||
const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I LT prediction coefs */
|
||||
const SKP_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */
|
||||
const SKP_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
|
||||
const SKP_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int pitchL[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int Lambda_Q10, /* I */
|
||||
const SKP_int LTP_scale_Q14 /* I LTP state scaling */
|
||||
const opus_int16 x[], /* I Prefiltered input signal */
|
||||
opus_int8 pulses[], /* O Quantized pulse signal */
|
||||
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Prediction coefs */
|
||||
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I LT prediction coefs */
|
||||
const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */
|
||||
const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
|
||||
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int Lambda_Q10, /* I */
|
||||
const opus_int LTP_scale_Q14 /* I LTP state scaling */
|
||||
)
|
||||
{
|
||||
SKP_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr;
|
||||
SKP_int last_smple_idx, smpl_buf_idx, decisionDelay;
|
||||
const SKP_int16 *A_Q12, *B_Q14, *AR_shp_Q13;
|
||||
SKP_int16 *pxq;
|
||||
SKP_int32 sLTP_Q16[ 2 * MAX_FRAME_LENGTH ];
|
||||
SKP_int16 sLTP[ 2 * MAX_FRAME_LENGTH ];
|
||||
SKP_int32 HarmShapeFIRPacked_Q14;
|
||||
SKP_int offset_Q10;
|
||||
SKP_int32 RDmin_Q10;
|
||||
SKP_int32 x_sc_Q10[ MAX_SUB_FRAME_LENGTH ];
|
||||
SKP_int32 delayedGain_Q16[ DECISION_DELAY ];
|
||||
opus_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr;
|
||||
opus_int last_smple_idx, smpl_buf_idx, decisionDelay;
|
||||
const opus_int16 *A_Q12, *B_Q14, *AR_shp_Q13;
|
||||
opus_int16 *pxq;
|
||||
opus_int32 sLTP_Q16[ 2 * MAX_FRAME_LENGTH ];
|
||||
opus_int16 sLTP[ 2 * MAX_FRAME_LENGTH ];
|
||||
opus_int32 HarmShapeFIRPacked_Q14;
|
||||
opus_int offset_Q10;
|
||||
opus_int32 RDmin_Q10;
|
||||
opus_int32 x_sc_Q10[ MAX_SUB_FRAME_LENGTH ];
|
||||
opus_int32 delayedGain_Q16[ DECISION_DELAY ];
|
||||
NSQ_del_dec_struct psDelDec[ MAX_DEL_DEC_STATES ];
|
||||
NSQ_del_dec_struct *psDD;
|
||||
|
||||
|
@ -144,7 +144,7 @@ void silk_NSQ_del_dec(
|
|||
psDD->RD_Q10 = 0;
|
||||
psDD->LF_AR_Q12 = NSQ->sLF_AR_shp_Q12;
|
||||
psDD->Shape_Q10[ 0 ] = NSQ->sLTP_shp_Q10[ psEncC->ltp_mem_length - 1 ];
|
||||
SKP_memcpy( psDD->sLPC_Q14, NSQ->sLPC_Q14, NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( psDD->sLPC_Q14, NSQ->sLPC_Q14, NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) );
|
||||
SKP_memcpy( psDD->sAR2_Q14, NSQ->sAR2_Q14, sizeof( NSQ->sAR2_Q14 ) );
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ void silk_NSQ_del_dec(
|
|||
/* Noise shape parameters */
|
||||
SKP_assert( HarmShapeGain_Q14[ k ] >= 0 );
|
||||
HarmShapeFIRPacked_Q14 = SKP_RSHIFT( HarmShapeGain_Q14[ k ], 2 );
|
||||
HarmShapeFIRPacked_Q14 |= SKP_LSHIFT( ( SKP_int32 )SKP_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 );
|
||||
HarmShapeFIRPacked_Q14 |= SKP_LSHIFT( ( opus_int32 )SKP_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 );
|
||||
|
||||
NSQ->rewhite_flag = 0;
|
||||
if( psIndices->signalType == TYPE_VOICED ) {
|
||||
|
@ -215,8 +215,8 @@ void silk_NSQ_del_dec(
|
|||
last_smple_idx = smpl_buf_idx + decisionDelay;
|
||||
for( i = 0; i < decisionDelay; i++ ) {
|
||||
last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK;
|
||||
pulses[ i - decisionDelay ] = ( SKP_int8 )SKP_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 );
|
||||
pxq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
|
||||
pulses[ i - decisionDelay ] = ( opus_int8 )SKP_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 );
|
||||
pxq[ i - decisionDelay ] = ( opus_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
|
||||
SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], Gains_Q16[ 1 ] ), 10 ) );
|
||||
NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q10[ last_smple_idx ];
|
||||
}
|
||||
|
@ -265,13 +265,13 @@ void silk_NSQ_del_dec(
|
|||
last_smple_idx = smpl_buf_idx + decisionDelay;
|
||||
for( i = 0; i < decisionDelay; i++ ) {
|
||||
last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK;
|
||||
pulses[ i - decisionDelay ] = ( SKP_int8 )SKP_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 );
|
||||
pxq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
|
||||
pulses[ i - decisionDelay ] = ( opus_int8 )SKP_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 );
|
||||
pxq[ i - decisionDelay ] = ( opus_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
|
||||
SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], Gains_Q16[ psEncC->nb_subfr - 1 ] ), 10 ) );
|
||||
NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q10[ last_smple_idx ];
|
||||
sLTP_Q16[ NSQ->sLTP_buf_idx - decisionDelay + i ] = psDD->Pred_Q16[ last_smple_idx ];
|
||||
}
|
||||
SKP_memcpy( NSQ->sLPC_Q14, &psDD->sLPC_Q14[ psEncC->subfr_length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( NSQ->sLPC_Q14, &psDD->sLPC_Q14[ psEncC->subfr_length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) );
|
||||
SKP_memcpy( NSQ->sAR2_Q14, psDD->sAR2_Q14, sizeof( psDD->sAR2_Q14 ) );
|
||||
|
||||
/* Update states */
|
||||
|
@ -279,13 +279,13 @@ void silk_NSQ_del_dec(
|
|||
NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ];
|
||||
|
||||
/* Save quantized speech and noise shaping signals */
|
||||
SKP_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( SKP_int16 ) );
|
||||
SKP_memmove( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( SKP_int32 ) );
|
||||
SKP_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) );
|
||||
SKP_memmove( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) );
|
||||
|
||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
||||
DEBUG_STORE_DATA( xq.dat, &pxq[ -psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int16 ) );
|
||||
DEBUG_STORE_DATA( q.dat, &pulses[ -psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int8 ) );
|
||||
DEBUG_STORE_DATA( sLTP_Q16.dat, &sLTP_Q16[ psEncC->ltp_mem_length ], psEncC->frame_length * sizeof( SKP_int32 ) );
|
||||
DEBUG_STORE_DATA( xq.dat, &pxq[ -psEncC->frame_length ], psEncC->frame_length * sizeof( opus_int16 ) );
|
||||
DEBUG_STORE_DATA( q.dat, &pulses[ -psEncC->frame_length ], psEncC->frame_length * sizeof( opus_int8 ) );
|
||||
DEBUG_STORE_DATA( sLTP_Q16.dat, &sLTP_Q16[ psEncC->ltp_mem_length ], psEncC->frame_length * sizeof( opus_int32 ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -295,39 +295,39 @@ void silk_NSQ_del_dec(
|
|||
SKP_INLINE void silk_noise_shape_quantizer_del_dec(
|
||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||
NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
|
||||
SKP_int signalType, /* I Signal type */
|
||||
const SKP_int32 x_Q10[], /* I */
|
||||
SKP_int8 pulses[], /* O */
|
||||
SKP_int16 xq[], /* O */
|
||||
SKP_int32 sLTP_Q16[], /* I/O LTP filter state */
|
||||
SKP_int32 delayedGain_Q16[], /* I/O Gain delay buffer */
|
||||
const SKP_int16 a_Q12[], /* I Short term prediction coefs */
|
||||
const SKP_int16 b_Q14[], /* I Long term prediction coefs */
|
||||
const SKP_int16 AR_shp_Q13[], /* I Noise shaping coefs */
|
||||
SKP_int lag, /* I Pitch lag */
|
||||
SKP_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||
SKP_int Tilt_Q14, /* I Spectral tilt */
|
||||
SKP_int32 LF_shp_Q14, /* I */
|
||||
SKP_int32 Gain_Q16, /* I */
|
||||
SKP_int Lambda_Q10, /* I */
|
||||
SKP_int offset_Q10, /* I */
|
||||
SKP_int length, /* I Input length */
|
||||
SKP_int subfr, /* I Subframe number */
|
||||
SKP_int shapingLPCOrder, /* I Shaping LPC filter order */
|
||||
SKP_int predictLPCOrder, /* I Prediction filter order */
|
||||
SKP_int warping_Q16, /* I */
|
||||
SKP_int nStatesDelayedDecision, /* I Number of states in decision tree */
|
||||
SKP_int *smpl_buf_idx, /* I Index to newest samples in buffers */
|
||||
SKP_int decisionDelay /* I */
|
||||
opus_int signalType, /* I Signal type */
|
||||
const opus_int32 x_Q10[], /* I */
|
||||
opus_int8 pulses[], /* O */
|
||||
opus_int16 xq[], /* O */
|
||||
opus_int32 sLTP_Q16[], /* I/O LTP filter state */
|
||||
opus_int32 delayedGain_Q16[], /* I/O Gain delay buffer */
|
||||
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
||||
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
||||
const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */
|
||||
opus_int lag, /* I Pitch lag */
|
||||
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||
opus_int Tilt_Q14, /* I Spectral tilt */
|
||||
opus_int32 LF_shp_Q14, /* I */
|
||||
opus_int32 Gain_Q16, /* I */
|
||||
opus_int Lambda_Q10, /* I */
|
||||
opus_int offset_Q10, /* I */
|
||||
opus_int length, /* I Input length */
|
||||
opus_int subfr, /* I Subframe number */
|
||||
opus_int shapingLPCOrder, /* I Shaping LPC filter order */
|
||||
opus_int predictLPCOrder, /* I Prediction filter order */
|
||||
opus_int warping_Q16, /* I */
|
||||
opus_int nStatesDelayedDecision, /* I Number of states in decision tree */
|
||||
opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */
|
||||
opus_int decisionDelay /* I */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx;
|
||||
SKP_int32 Winner_rand_state;
|
||||
SKP_int32 LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14, LTP_Q10;
|
||||
SKP_int32 n_LF_Q10, r_Q10, rr_Q10, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10;
|
||||
SKP_int32 q1_Q10, q2_Q10, dither, exc_Q10, LPC_exc_Q10, xq_Q10;
|
||||
SKP_int32 tmp1, tmp2, sLF_AR_shp_Q10;
|
||||
SKP_int32 *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14;
|
||||
opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx;
|
||||
opus_int32 Winner_rand_state;
|
||||
opus_int32 LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14, LTP_Q10;
|
||||
opus_int32 n_LF_Q10, r_Q10, rr_Q10, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10;
|
||||
opus_int32 q1_Q10, q2_Q10, dither, exc_Q10, LPC_exc_Q10, xq_Q10;
|
||||
opus_int32 tmp1, tmp2, sLF_AR_shp_Q10;
|
||||
opus_int32 *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14;
|
||||
NSQ_sample_struct psSampleState[ MAX_DEL_DEC_STATES ][ 2 ];
|
||||
NSQ_del_dec_struct *psDD;
|
||||
NSQ_sample_struct *psSS;
|
||||
|
@ -382,7 +382,7 @@ SKP_INLINE void silk_noise_shape_quantizer_del_dec(
|
|||
/* Short-term prediction */
|
||||
SKP_assert( predictLPCOrder >= 10 ); /* check that unrolling works */
|
||||
SKP_assert( ( predictLPCOrder & 1 ) == 0 ); /* check that order is even */
|
||||
SKP_assert( ( (SKP_int64)a_Q12 & 3 ) == 0 ); /* check that array starts at 4-byte aligned address */
|
||||
SKP_assert( ( (opus_int64)a_Q12 & 3 ) == 0 ); /* check that array starts at 4-byte aligned address */
|
||||
/* Partially unrolled */
|
||||
LPC_pred_Q10 = SKP_SMULWB( psLPC_Q14[ 0 ], a_Q12[ 0 ] );
|
||||
LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -1 ], a_Q12[ 1 ] );
|
||||
|
@ -556,16 +556,16 @@ SKP_INLINE void silk_noise_shape_quantizer_del_dec(
|
|||
|
||||
/* Replace a state if best from second set outperforms worst in first set */
|
||||
if( RDmin_Q10 < RDmax_Q10 ) {
|
||||
SKP_memcpy( ((SKP_int32 *)&psDelDec[ RDmax_ind ]) + i,
|
||||
((SKP_int32 *)&psDelDec[ RDmin_ind ]) + i, sizeof( NSQ_del_dec_struct ) - i * sizeof( SKP_int32) );
|
||||
SKP_memcpy( ((opus_int32 *)&psDelDec[ RDmax_ind ]) + i,
|
||||
((opus_int32 *)&psDelDec[ RDmin_ind ]) + i, sizeof( NSQ_del_dec_struct ) - i * sizeof( opus_int32) );
|
||||
SKP_memcpy( &psSampleState[ RDmax_ind ][ 0 ], &psSampleState[ RDmin_ind ][ 1 ], sizeof( NSQ_sample_struct ) );
|
||||
}
|
||||
|
||||
/* Write samples from winner to output and long-term filter states */
|
||||
psDD = &psDelDec[ Winner_ind ];
|
||||
if( subfr > 0 || i >= decisionDelay ) {
|
||||
pulses[ i - decisionDelay ] = ( SKP_int8 )SKP_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 );
|
||||
xq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
|
||||
pulses[ i - decisionDelay ] = ( opus_int8 )SKP_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 );
|
||||
xq[ i - decisionDelay ] = ( opus_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
|
||||
SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], delayedGain_Q16[ last_smple_idx ] ), 10 ) );
|
||||
NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay ] = psDD->Shape_Q10[ last_smple_idx ];
|
||||
sLTP_Q16[ NSQ->sLTP_buf_idx - decisionDelay ] = psDD->Pred_Q16[ last_smple_idx ];
|
||||
|
@ -592,7 +592,7 @@ SKP_INLINE void silk_noise_shape_quantizer_del_dec(
|
|||
/* Update LPC states */
|
||||
for( k = 0; k < nStatesDelayedDecision; k++ ) {
|
||||
psDD = &psDelDec[ k ];
|
||||
SKP_memcpy( psDD->sLPC_Q14, &psDD->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( psDD->sLPC_Q14, &psDD->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -600,20 +600,20 @@ SKP_INLINE void silk_nsq_del_dec_scale_states(
|
|||
const silk_encoder_state *psEncC, /* I Encoder State */
|
||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||
NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
|
||||
const SKP_int16 x[], /* I Input in Q0 */
|
||||
SKP_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */
|
||||
const SKP_int16 sLTP[], /* I Re-whitened LTP state in Q0 */
|
||||
SKP_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||
SKP_int subfr, /* I Subframe number */
|
||||
SKP_int nStatesDelayedDecision, /* I Number of del dec states */
|
||||
SKP_int smpl_buf_idx, /* I Index to newest samples in buffers */
|
||||
const SKP_int LTP_scale_Q14, /* I LTP state scaling */
|
||||
const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const SKP_int pitchL[ MAX_NB_SUBFR ] /* I Pitch lag */
|
||||
const opus_int16 x[], /* I Input in Q0 */
|
||||
opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */
|
||||
const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */
|
||||
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||
opus_int subfr, /* I Subframe number */
|
||||
opus_int nStatesDelayedDecision, /* I Number of del dec states */
|
||||
opus_int smpl_buf_idx, /* I Index to newest samples in buffers */
|
||||
const opus_int LTP_scale_Q14, /* I LTP state scaling */
|
||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||
const opus_int pitchL[ MAX_NB_SUBFR ] /* I Pitch lag */
|
||||
)
|
||||
{
|
||||
SKP_int i, k, lag;
|
||||
SKP_int32 inv_gain_Q16, gain_adj_Q16, inv_gain_Q32;
|
||||
opus_int i, k, lag;
|
||||
opus_int32 inv_gain_Q16, gain_adj_Q16, inv_gain_Q32;
|
||||
NSQ_del_dec_struct *psDD;
|
||||
|
||||
inv_gain_Q16 = silk_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 );
|
||||
|
@ -671,7 +671,7 @@ SKP_INLINE void silk_nsq_del_dec_scale_states(
|
|||
|
||||
/* Scale input */
|
||||
for( i = 0; i < psEncC->subfr_length; i++ ) {
|
||||
x_sc_Q10[ i ] = SKP_RSHIFT( SKP_SMULBB( x[ i ], ( SKP_int16 )inv_gain_Q16 ), 6 );
|
||||
x_sc_Q10[ i ] = SKP_RSHIFT( SKP_SMULBB( x[ i ], ( opus_int16 )inv_gain_Q16 ), 6 );
|
||||
}
|
||||
|
||||
/* save inv_gain */
|
||||
|
|
|
@ -29,9 +29,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "silk_PLC.h"
|
||||
|
||||
#define NB_ATT 2
|
||||
static const SKP_int16 HARM_ATT_Q15[NB_ATT] = { 32440, 31130 }; /* 0.99, 0.95 */
|
||||
static const SKP_int16 PLC_RAND_ATTENUATE_V_Q15[NB_ATT] = { 31130, 26214 }; /* 0.95, 0.8 */
|
||||
static const SKP_int16 PLC_RAND_ATTENUATE_UV_Q15[NB_ATT] = { 32440, 29491 }; /* 0.99, 0.9 */
|
||||
static const opus_int16 HARM_ATT_Q15[NB_ATT] = { 32440, 31130 }; /* 0.99, 0.95 */
|
||||
static const opus_int16 PLC_RAND_ATTENUATE_V_Q15[NB_ATT] = { 31130, 26214 }; /* 0.95, 0.8 */
|
||||
static const opus_int16 PLC_RAND_ATTENUATE_UV_Q15[NB_ATT] = { 32440, 29491 }; /* 0.99, 0.9 */
|
||||
|
||||
void silk_PLC_Reset(
|
||||
silk_decoder_state *psDec /* I/O Decoder state */
|
||||
|
@ -43,9 +43,9 @@ void silk_PLC_Reset(
|
|||
void silk_PLC(
|
||||
silk_decoder_state *psDec, /* I Decoder state */
|
||||
silk_decoder_control *psDecCtrl, /* I Decoder control */
|
||||
SKP_int16 signal[], /* O Concealed signal */
|
||||
SKP_int length, /* I length of residual */
|
||||
SKP_int lost /* I Loss flag */
|
||||
opus_int16 signal[], /* O Concealed signal */
|
||||
opus_int length, /* I length of residual */
|
||||
opus_int lost /* I Loss flag */
|
||||
)
|
||||
{
|
||||
/* PLC control function */
|
||||
|
@ -75,12 +75,12 @@ void silk_PLC(
|
|||
void silk_PLC_update(
|
||||
silk_decoder_state *psDec, /* (I/O) Decoder state */
|
||||
silk_decoder_control *psDecCtrl, /* (I/O) Decoder control */
|
||||
SKP_int16 signal[],
|
||||
SKP_int length
|
||||
opus_int16 signal[],
|
||||
opus_int length
|
||||
)
|
||||
{
|
||||
SKP_int32 LTP_Gain_Q14, temp_LTP_Gain_Q14;
|
||||
SKP_int i, j;
|
||||
opus_int32 LTP_Gain_Q14, temp_LTP_Gain_Q14;
|
||||
opus_int i, j;
|
||||
silk_PLC_struct *psPLC;
|
||||
|
||||
psPLC = &psDec->sPLC;
|
||||
|
@ -102,21 +102,21 @@ void silk_PLC_update(
|
|||
LTP_Gain_Q14 = temp_LTP_Gain_Q14;
|
||||
SKP_memcpy( psPLC->LTPCoef_Q14,
|
||||
&psDecCtrl->LTPCoef_Q14[ SKP_SMULBB( psDec->nb_subfr - 1 - j, LTP_ORDER ) ],
|
||||
LTP_ORDER * sizeof( SKP_int16 ) );
|
||||
LTP_ORDER * sizeof( opus_int16 ) );
|
||||
|
||||
psPLC->pitchL_Q8 = SKP_LSHIFT( psDecCtrl->pitchL[ psDec->nb_subfr - 1 - j ], 8 );
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_SINGLE_TAP
|
||||
SKP_memset( psPLC->LTPCoef_Q14, 0, LTP_ORDER * sizeof( SKP_int16 ) );
|
||||
SKP_memset( psPLC->LTPCoef_Q14, 0, LTP_ORDER * sizeof( opus_int16 ) );
|
||||
psPLC->LTPCoef_Q14[ LTP_ORDER / 2 ] = LTP_Gain_Q14;
|
||||
#endif
|
||||
|
||||
/* Limit LT coefs */
|
||||
if( LTP_Gain_Q14 < V_PITCH_GAIN_START_MIN_Q14 ) {
|
||||
SKP_int scale_Q10;
|
||||
SKP_int32 tmp;
|
||||
opus_int scale_Q10;
|
||||
opus_int32 tmp;
|
||||
|
||||
tmp = SKP_LSHIFT( V_PITCH_GAIN_START_MIN_Q14, 10 );
|
||||
scale_Q10 = SKP_DIV32( tmp, SKP_max( LTP_Gain_Q14, 1 ) );
|
||||
|
@ -124,8 +124,8 @@ void silk_PLC_update(
|
|||
psPLC->LTPCoef_Q14[ i ] = SKP_RSHIFT( SKP_SMULBB( psPLC->LTPCoef_Q14[ i ], scale_Q10 ), 10 );
|
||||
}
|
||||
} else if( LTP_Gain_Q14 > V_PITCH_GAIN_START_MAX_Q14 ) {
|
||||
SKP_int scale_Q14;
|
||||
SKP_int32 tmp;
|
||||
opus_int scale_Q14;
|
||||
opus_int32 tmp;
|
||||
|
||||
tmp = SKP_LSHIFT( V_PITCH_GAIN_START_MAX_Q14, 14 );
|
||||
scale_Q14 = SKP_DIV32( tmp, SKP_max( LTP_Gain_Q14, 1 ) );
|
||||
|
@ -135,36 +135,36 @@ void silk_PLC_update(
|
|||
}
|
||||
} else {
|
||||
psPLC->pitchL_Q8 = SKP_LSHIFT( SKP_SMULBB( psDec->fs_kHz, 18 ), 8 );
|
||||
SKP_memset( psPLC->LTPCoef_Q14, 0, LTP_ORDER * sizeof( SKP_int16 ));
|
||||
SKP_memset( psPLC->LTPCoef_Q14, 0, LTP_ORDER * sizeof( opus_int16 ));
|
||||
}
|
||||
|
||||
/* Save LPC coeficients */
|
||||
SKP_memcpy( psPLC->prevLPC_Q12, psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order * sizeof( SKP_int16 ) );
|
||||
SKP_memcpy( psPLC->prevLPC_Q12, psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order * sizeof( opus_int16 ) );
|
||||
psPLC->prevLTP_scale_Q14 = psDecCtrl->LTP_scale_Q14;
|
||||
|
||||
/* Save Gains */
|
||||
SKP_memcpy( psPLC->prevGain_Q16, psDecCtrl->Gains_Q16, psDec->nb_subfr * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( psPLC->prevGain_Q16, psDecCtrl->Gains_Q16, psDec->nb_subfr * sizeof( opus_int32 ) );
|
||||
}
|
||||
|
||||
void silk_PLC_conceal(
|
||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||
SKP_int16 signal[], /* O concealed signal */
|
||||
SKP_int length /* I length of residual */
|
||||
opus_int16 signal[], /* O concealed signal */
|
||||
opus_int length /* I length of residual */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, k;
|
||||
SKP_int16 *B_Q14, exc_buf[ MAX_FRAME_LENGTH ], *exc_buf_ptr;
|
||||
SKP_int16 rand_scale_Q14, A_Q12_tmp[ MAX_LPC_ORDER ];
|
||||
SKP_int32 rand_seed, harm_Gain_Q15, rand_Gain_Q15;
|
||||
SKP_int lag, idx, sLTP_buf_idx, shift1, shift2;
|
||||
SKP_int32 energy1, energy2, *rand_ptr, *pred_lag_ptr;
|
||||
SKP_int32 sig_Q10[ MAX_FRAME_LENGTH ], *sig_Q10_ptr, LPC_exc_Q10, LPC_pred_Q10, LTP_pred_Q14;
|
||||
opus_int i, j, k;
|
||||
opus_int16 *B_Q14, exc_buf[ MAX_FRAME_LENGTH ], *exc_buf_ptr;
|
||||
opus_int16 rand_scale_Q14, A_Q12_tmp[ MAX_LPC_ORDER ];
|
||||
opus_int32 rand_seed, harm_Gain_Q15, rand_Gain_Q15;
|
||||
opus_int lag, idx, sLTP_buf_idx, shift1, shift2;
|
||||
opus_int32 energy1, energy2, *rand_ptr, *pred_lag_ptr;
|
||||
opus_int32 sig_Q10[ MAX_FRAME_LENGTH ], *sig_Q10_ptr, LPC_exc_Q10, LPC_pred_Q10, LTP_pred_Q14;
|
||||
silk_PLC_struct *psPLC;
|
||||
psPLC = &psDec->sPLC;
|
||||
|
||||
/* Update LTP buffer */
|
||||
SKP_memmove( psDec->sLTP_Q16, &psDec->sLTP_Q16[ psDec->frame_length ], psDec->ltp_mem_length * sizeof( SKP_int32 ) );
|
||||
SKP_memmove( psDec->sLTP_Q16, &psDec->sLTP_Q16[ psDec->frame_length ], psDec->ltp_mem_length * sizeof( opus_int32 ) );
|
||||
|
||||
/* LPC concealment. Apply BWE to previous LPC */
|
||||
silk_bwexpander( psPLC->prevLPC_Q12, psDec->LPC_order, SILK_FIX_CONST( BWE_COEF, 16 ) );
|
||||
|
@ -177,7 +177,7 @@ void silk_PLC_conceal(
|
|||
exc_buf[i] = 0;
|
||||
for( k = ( psDec->nb_subfr >> 1 ); k < psDec->nb_subfr; k++ ) {
|
||||
for( i = 0; i < psDec->subfr_length; i++ ) {
|
||||
exc_buf_ptr[ i ] = ( SKP_int16 )SKP_RSHIFT(
|
||||
exc_buf_ptr[ i ] = ( opus_int16 )SKP_RSHIFT(
|
||||
SKP_SMULWW( psDec->exc_Q10[ i + k * psDec->subfr_length ], psPLC->prevGain_Q16[ k ] ), 10 );
|
||||
}
|
||||
exc_buf_ptr += psDec->subfr_length;
|
||||
|
@ -216,10 +216,10 @@ void silk_PLC_conceal(
|
|||
rand_scale_Q14 -= B_Q14[ i ];
|
||||
}
|
||||
rand_scale_Q14 = SKP_max_16( 3277, rand_scale_Q14 ); /* 0.2 */
|
||||
rand_scale_Q14 = ( SKP_int16 )SKP_RSHIFT( SKP_SMULBB( rand_scale_Q14, psPLC->prevLTP_scale_Q14 ), 14 );
|
||||
rand_scale_Q14 = ( opus_int16 )SKP_RSHIFT( SKP_SMULBB( rand_scale_Q14, psPLC->prevLTP_scale_Q14 ), 14 );
|
||||
} else {
|
||||
/* Reduce random noise for unvoiced frames with high LPC gain */
|
||||
SKP_int32 invGain_Q30, down_scale_Q30;
|
||||
opus_int32 invGain_Q30, down_scale_Q30;
|
||||
|
||||
silk_LPC_inverse_pred_gain( &invGain_Q30, psPLC->prevLPC_Q12, psDec->LPC_order );
|
||||
|
||||
|
@ -284,7 +284,7 @@ void silk_PLC_conceal(
|
|||
/***************************/
|
||||
sig_Q10_ptr = sig_Q10;
|
||||
/* Preload LPC coeficients to array on stack. Gives small performance gain */
|
||||
SKP_memcpy( A_Q12_tmp, psPLC->prevLPC_Q12, psDec->LPC_order * sizeof( SKP_int16 ) );
|
||||
SKP_memcpy( A_Q12_tmp, psPLC->prevLPC_Q12, psDec->LPC_order * sizeof( opus_int16 ) );
|
||||
SKP_assert( psDec->LPC_order >= 10 ); /* check that unrolling works */
|
||||
for( k = 0; k < psDec->nb_subfr; k++ ) {
|
||||
for( i = 0; i < psDec->subfr_length; i++ ){
|
||||
|
@ -312,12 +312,12 @@ void silk_PLC_conceal(
|
|||
}
|
||||
sig_Q10_ptr += psDec->subfr_length;
|
||||
/* Update LPC filter state */
|
||||
SKP_memcpy( psDec->sLPC_Q14, &psDec->sLPC_Q14[ psDec->subfr_length ], MAX_LPC_ORDER * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( psDec->sLPC_Q14, &psDec->sLPC_Q14[ psDec->subfr_length ], MAX_LPC_ORDER * sizeof( opus_int32 ) );
|
||||
}
|
||||
|
||||
/* Scale with Gain */
|
||||
for( i = 0; i < psDec->frame_length; i++ ) {
|
||||
signal[ i ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( sig_Q10[ i ], psPLC->prevGain_Q16[ psDec->nb_subfr - 1 ] ), 10 ) );
|
||||
signal[ i ] = ( opus_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( sig_Q10[ i ], psPLC->prevGain_Q16[ psDec->nb_subfr - 1 ] ), 10 ) );
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
|
@ -334,12 +334,12 @@ void silk_PLC_conceal(
|
|||
void silk_PLC_glue_frames(
|
||||
silk_decoder_state *psDec, /* I/O decoder state */
|
||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||
SKP_int16 signal[], /* I/O signal */
|
||||
SKP_int length /* I length of residual */
|
||||
opus_int16 signal[], /* I/O signal */
|
||||
opus_int length /* I length of residual */
|
||||
)
|
||||
{
|
||||
SKP_int i, energy_shift;
|
||||
SKP_int32 energy;
|
||||
opus_int i, energy_shift;
|
||||
opus_int32 energy;
|
||||
silk_PLC_struct *psPLC;
|
||||
psPLC = &psDec->sPLC;
|
||||
|
||||
|
@ -362,8 +362,8 @@ void silk_PLC_glue_frames(
|
|||
|
||||
/* Fade in the energy difference */
|
||||
if( energy > psPLC->conc_energy ) {
|
||||
SKP_int32 frac_Q24, LZ;
|
||||
SKP_int32 gain_Q16, slope_Q16;
|
||||
opus_int32 frac_Q24, LZ;
|
||||
opus_int32 gain_Q16, slope_Q16;
|
||||
|
||||
LZ = silk_CLZ32( psPLC->conc_energy );
|
||||
LZ = LZ - 1;
|
||||
|
|
|
@ -49,30 +49,30 @@ void silk_PLC_Reset(
|
|||
void silk_PLC(
|
||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||
SKP_int16 signal[], /* I/O signal */
|
||||
SKP_int length, /* I length of residual */
|
||||
SKP_int lost /* I Loss flag */
|
||||
opus_int16 signal[], /* I/O signal */
|
||||
opus_int length, /* I length of residual */
|
||||
opus_int lost /* I Loss flag */
|
||||
);
|
||||
|
||||
void silk_PLC_update(
|
||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||
SKP_int16 signal[],
|
||||
SKP_int length
|
||||
opus_int16 signal[],
|
||||
opus_int length
|
||||
);
|
||||
|
||||
void silk_PLC_conceal(
|
||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||
SKP_int16 signal[], /* O LPC residual signal */
|
||||
SKP_int length /* I length of signal */
|
||||
opus_int16 signal[], /* O LPC residual signal */
|
||||
opus_int length /* I length of signal */
|
||||
);
|
||||
|
||||
void silk_PLC_glue_frames(
|
||||
silk_decoder_state *psDec, /* I/O decoder state */
|
||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||
SKP_int16 signal[], /* I/O signal */
|
||||
SKP_int length /* I length of signal */
|
||||
opus_int16 signal[], /* I/O signal */
|
||||
opus_int length /* I length of signal */
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -51,47 +51,47 @@ extern "C"
|
|||
/*!
|
||||
* Initialize/reset the resampler state for a given pair of input/output sampling rates
|
||||
*/
|
||||
SKP_int silk_resampler_init(
|
||||
opus_int silk_resampler_init(
|
||||
silk_resampler_state_struct *S, /* I/O: Resampler state */
|
||||
SKP_int32 Fs_Hz_in, /* I: Input sampling rate (Hz) */
|
||||
SKP_int32 Fs_Hz_out /* I: Output sampling rate (Hz) */
|
||||
opus_int32 Fs_Hz_in, /* I: Input sampling rate (Hz) */
|
||||
opus_int32 Fs_Hz_out /* I: Output sampling rate (Hz) */
|
||||
);
|
||||
|
||||
/*!
|
||||
* Clear the states of all resampling filters, without resetting sampling rate ratio
|
||||
*/
|
||||
SKP_int silk_resampler_clear(
|
||||
opus_int silk_resampler_clear(
|
||||
silk_resampler_state_struct *S /* I/O: Resampler state */
|
||||
);
|
||||
|
||||
/*!
|
||||
* Resampler: convert from one sampling rate to another
|
||||
*/
|
||||
SKP_int silk_resampler(
|
||||
opus_int silk_resampler(
|
||||
silk_resampler_state_struct *S, /* I/O: Resampler state */
|
||||
SKP_int16 out[], /* O: Output signal */
|
||||
const SKP_int16 in[], /* I: Input signal */
|
||||
SKP_int32 inLen /* I: Number of input samples */
|
||||
opus_int16 out[], /* O: Output signal */
|
||||
const opus_int16 in[], /* I: Input signal */
|
||||
opus_int32 inLen /* I: Number of input samples */
|
||||
);
|
||||
|
||||
/*!
|
||||
Upsample 2x, low quality
|
||||
*/
|
||||
void silk_resampler_up2(
|
||||
SKP_int32 *S, /* I/O: State vector [ 2 ] */
|
||||
SKP_int16 *out, /* O: Output signal [ 2 * len ] */
|
||||
const SKP_int16 *in, /* I: Input signal [ len ] */
|
||||
SKP_int32 len /* I: Number of input samples */
|
||||
opus_int32 *S, /* I/O: State vector [ 2 ] */
|
||||
opus_int16 *out, /* O: Output signal [ 2 * len ] */
|
||||
const opus_int16 *in, /* I: Input signal [ len ] */
|
||||
opus_int32 len /* I: Number of input samples */
|
||||
);
|
||||
|
||||
/*!
|
||||
* Downsample 2x, mediocre quality
|
||||
*/
|
||||
void silk_resampler_down2(
|
||||
SKP_int32 *S, /* I/O: State vector [ 2 ] */
|
||||
SKP_int16 *out, /* O: Output signal [ len ] */
|
||||
const SKP_int16 *in, /* I: Input signal [ floor(len/2) ] */
|
||||
SKP_int32 inLen /* I: Number of input samples */
|
||||
opus_int32 *S, /* I/O: State vector [ 2 ] */
|
||||
opus_int16 *out, /* O: Output signal [ len ] */
|
||||
const opus_int16 *in, /* I: Input signal [ floor(len/2) ] */
|
||||
opus_int32 inLen /* I: Number of input samples */
|
||||
);
|
||||
|
||||
|
||||
|
@ -99,20 +99,20 @@ void silk_resampler_down2(
|
|||
* Downsample by a factor 2/3, low quality
|
||||
*/
|
||||
void silk_resampler_down2_3(
|
||||
SKP_int32 *S, /* I/O: State vector [ 6 ] */
|
||||
SKP_int16 *out, /* O: Output signal [ floor(2*inLen/3) ] */
|
||||
const SKP_int16 *in, /* I: Input signal [ inLen ] */
|
||||
SKP_int32 inLen /* I: Number of input samples */
|
||||
opus_int32 *S, /* I/O: State vector [ 6 ] */
|
||||
opus_int16 *out, /* O: Output signal [ floor(2*inLen/3) ] */
|
||||
const opus_int16 *in, /* I: Input signal [ inLen ] */
|
||||
opus_int32 inLen /* I: Number of input samples */
|
||||
);
|
||||
|
||||
/*!
|
||||
* Downsample by a factor 3, low quality
|
||||
*/
|
||||
void silk_resampler_down3(
|
||||
SKP_int32 *S, /* I/O: State vector [ 8 ] */
|
||||
SKP_int16 *out, /* O: Output signal [ floor(inLen/3) ] */
|
||||
const SKP_int16 *in, /* I: Input signal [ inLen ] */
|
||||
SKP_int32 inLen /* I: Number of input samples */
|
||||
opus_int32 *S, /* I/O: State vector [ 8 ] */
|
||||
opus_int16 *out, /* O: Output signal [ floor(inLen/3) ] */
|
||||
const opus_int16 *in, /* I: Input signal [ inLen ] */
|
||||
opus_int32 inLen /* I: Number of input samples */
|
||||
);
|
||||
|
||||
/*!
|
||||
|
@ -121,58 +121,58 @@ void silk_resampler_down3(
|
|||
* can handle (slowly) varying coefficients
|
||||
*/
|
||||
void silk_biquad_alt(
|
||||
const SKP_int16 *in, /* I: input signal */
|
||||
const SKP_int32 *B_Q28, /* I: MA coefficients [3] */
|
||||
const SKP_int32 *A_Q28, /* I: AR coefficients [2] */
|
||||
SKP_int32 *S, /* I/O: State vector [2] */
|
||||
SKP_int16 *out, /* O: output signal */
|
||||
const SKP_int32 len /* I: signal length (must be even) */
|
||||
const opus_int16 *in, /* I: input signal */
|
||||
const opus_int32 *B_Q28, /* I: MA coefficients [3] */
|
||||
const opus_int32 *A_Q28, /* I: AR coefficients [2] */
|
||||
opus_int32 *S, /* I/O: State vector [2] */
|
||||
opus_int16 *out, /* O: output signal */
|
||||
const opus_int32 len /* I: signal length (must be even) */
|
||||
);
|
||||
|
||||
/* Variable order MA prediction error filter. */
|
||||
void silk_LPC_analysis_filter(
|
||||
SKP_int16 *out, /* O: Output signal */
|
||||
const SKP_int16 *in, /* I: Input signal */
|
||||
const SKP_int16 *B, /* I: MA prediction coefficients, Q12 [order] */
|
||||
const SKP_int32 len, /* I: Signal length */
|
||||
const SKP_int32 Order /* I: Filter order */
|
||||
opus_int16 *out, /* O: Output signal */
|
||||
const opus_int16 *in, /* I: Input signal */
|
||||
const opus_int16 *B, /* I: MA prediction coefficients, Q12 [order] */
|
||||
const opus_int32 len, /* I: Signal length */
|
||||
const opus_int32 Order /* I: Filter order */
|
||||
);
|
||||
|
||||
/* Chirp (bandwidth expand) LP AR filter */
|
||||
void silk_bwexpander(
|
||||
SKP_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||
const SKP_int d, /* I Length of ar */
|
||||
SKP_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
|
||||
opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||
const opus_int d, /* I Length of ar */
|
||||
opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
|
||||
);
|
||||
|
||||
/* Chirp (bandwidth expand) LP AR filter */
|
||||
void silk_bwexpander_32(
|
||||
SKP_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||
const SKP_int d, /* I Length of ar */
|
||||
SKP_int32 chirp_Q16 /* I Chirp factor in Q16 */
|
||||
opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||
const opus_int d, /* I Length of ar */
|
||||
opus_int32 chirp_Q16 /* I Chirp factor in Q16 */
|
||||
);
|
||||
|
||||
/* Compute inverse of LPC prediction gain, and */
|
||||
/* test if LPC coefficients are stable (all poles within unit circle) */
|
||||
SKP_int silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */
|
||||
SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
||||
const SKP_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */
|
||||
const SKP_int order /* I: Prediction order */
|
||||
opus_int silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */
|
||||
opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
||||
const opus_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */
|
||||
const opus_int order /* I: Prediction order */
|
||||
);
|
||||
|
||||
SKP_int silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */
|
||||
SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
||||
const SKP_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */
|
||||
const SKP_int order /* I: Prediction order */
|
||||
opus_int silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */
|
||||
opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
||||
const opus_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */
|
||||
const opus_int order /* I: Prediction order */
|
||||
);
|
||||
|
||||
/* split signal in two decimated bands using first-order allpass filters */
|
||||
void silk_ana_filt_bank_1(
|
||||
const SKP_int16 *in, /* I: Input signal [N] */
|
||||
SKP_int32 *S, /* I/O: State vector [2] */
|
||||
SKP_int16 *outL, /* O: Low band [N/2] */
|
||||
SKP_int16 *outH, /* O: High band [N/2] */
|
||||
const SKP_int32 N /* I: Number of input samples */
|
||||
const opus_int16 *in, /* I: Input signal [N] */
|
||||
opus_int32 *S, /* I/O: State vector [2] */
|
||||
opus_int16 *outL, /* O: Low band [N/2] */
|
||||
opus_int16 *outH, /* O: High band [N/2] */
|
||||
const opus_int32 N /* I: Number of input samples */
|
||||
);
|
||||
|
||||
/********************************************************************/
|
||||
|
@ -181,60 +181,60 @@ void silk_ana_filt_bank_1(
|
|||
|
||||
/* approximation of 128 * log2() (exact inverse of approx 2^() below) */
|
||||
/* convert input to a log scale */
|
||||
SKP_int32 silk_lin2log(const SKP_int32 inLin); /* I: input in linear scale */
|
||||
opus_int32 silk_lin2log(const opus_int32 inLin); /* I: input in linear scale */
|
||||
|
||||
/* Approximation of a sigmoid function */
|
||||
SKP_int silk_sigm_Q15(SKP_int in_Q5);
|
||||
opus_int silk_sigm_Q15(opus_int in_Q5);
|
||||
|
||||
/* approximation of 2^() (exact inverse of approx log2() above) */
|
||||
/* convert input to a linear scale */
|
||||
SKP_int32 silk_log2lin(const SKP_int32 inLog_Q7); /* I: input on log scale */
|
||||
opus_int32 silk_log2lin(const opus_int32 inLog_Q7); /* I: input on log scale */
|
||||
|
||||
/* Function that returns the maximum absolut value of the input vector */
|
||||
SKP_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */
|
||||
const SKP_int16 *vec, /* I Input vector [len] */
|
||||
const SKP_int32 len /* I Length of 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 */
|
||||
);
|
||||
|
||||
/* Compute number of bits to right shift the sum of squares of a vector */
|
||||
/* of int16s to make it fit in an int32 */
|
||||
void silk_sum_sqr_shift(
|
||||
SKP_int32 *energy, /* O Energy of x, after shifting to the right */
|
||||
SKP_int *shift, /* O Number of bits right shift applied to energy */
|
||||
const SKP_int16 *x, /* I Input vector */
|
||||
SKP_int len /* I Length of input vector */
|
||||
opus_int32 *energy, /* O Energy of x, after shifting to the right */
|
||||
opus_int *shift, /* O Number of bits right shift applied to energy */
|
||||
const opus_int16 *x, /* I Input vector */
|
||||
opus_int len /* I Length of input vector */
|
||||
);
|
||||
|
||||
/* Calculates the reflection coefficients from the correlation sequence */
|
||||
/* Faster than schur64(), but much less accurate. */
|
||||
/* uses SMLAWB(), requiring armv5E and higher. */
|
||||
SKP_int32 silk_schur( /* O: Returns residual energy */
|
||||
SKP_int16 *rc_Q15, /* O: reflection coefficients [order] Q15 */
|
||||
const SKP_int32 *c, /* I: correlations [order+1] */
|
||||
const SKP_int32 order /* I: prediction order */
|
||||
opus_int32 silk_schur( /* O: Returns residual energy */
|
||||
opus_int16 *rc_Q15, /* O: reflection coefficients [order] Q15 */
|
||||
const opus_int32 *c, /* I: correlations [order+1] */
|
||||
const opus_int32 order /* I: prediction order */
|
||||
);;
|
||||
|
||||
/* Calculates the reflection coefficients from the correlation sequence */
|
||||
/* Slower than schur(), but more accurate. */
|
||||
/* Uses SMULL(), available on armv4 */
|
||||
SKP_int32 silk_schur64( /* O: returns residual energy */
|
||||
SKP_int32 rc_Q16[], /* O: Reflection coefficients [order] Q16 */
|
||||
const SKP_int32 c[], /* I: Correlations [order+1] */
|
||||
SKP_int32 order /* I: Prediction order */
|
||||
opus_int32 silk_schur64( /* O: returns residual energy */
|
||||
opus_int32 rc_Q16[], /* O: Reflection coefficients [order] Q16 */
|
||||
const opus_int32 c[], /* I: Correlations [order+1] */
|
||||
opus_int32 order /* I: Prediction order */
|
||||
);
|
||||
|
||||
/* Step up function, converts reflection coefficients to prediction coefficients */
|
||||
void silk_k2a(
|
||||
SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
|
||||
const SKP_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */
|
||||
const SKP_int32 order /* I: Prediction order */
|
||||
opus_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
|
||||
const opus_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */
|
||||
const opus_int32 order /* I: Prediction order */
|
||||
);
|
||||
|
||||
/* Step up function, converts reflection coefficients to prediction coefficients */
|
||||
void silk_k2a_Q16(
|
||||
SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
|
||||
const SKP_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */
|
||||
const SKP_int32 order /* I: Prediction order */
|
||||
opus_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
|
||||
const opus_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */
|
||||
const opus_int32 order /* I: Prediction order */
|
||||
);
|
||||
|
||||
/* Apply sine window to signal vector. */
|
||||
|
@ -243,19 +243,19 @@ void silk_k2a_Q16(
|
|||
/* 2 -> sine window from pi/2 to pi */
|
||||
/* every other sample of window is linearly interpolated, for speed */
|
||||
void silk_apply_sine_window(
|
||||
SKP_int16 px_win[], /* O Pointer to windowed signal */
|
||||
const SKP_int16 px[], /* I Pointer to input signal */
|
||||
const SKP_int win_type, /* I Selects a window type */
|
||||
const SKP_int length /* I Window length, multiple of 4 */
|
||||
opus_int16 px_win[], /* O Pointer to windowed signal */
|
||||
const opus_int16 px[], /* I Pointer to input signal */
|
||||
const opus_int win_type, /* I Selects a window type */
|
||||
const opus_int length /* I Window length, multiple of 4 */
|
||||
);
|
||||
|
||||
/* Compute autocorrelation */
|
||||
void silk_autocorr(
|
||||
SKP_int32 *results, /* O Result (length correlationCount) */
|
||||
SKP_int *scale, /* O Scaling of the correlation vector */
|
||||
const SKP_int16 *inputData, /* I Input data to correlate */
|
||||
const SKP_int inputDataSize, /* I Length of input */
|
||||
const SKP_int correlationCount /* I Number of correlation taps to compute */
|
||||
opus_int32 *results, /* O Result (length correlationCount) */
|
||||
opus_int *scale, /* O Scaling of the correlation vector */
|
||||
const opus_int16 *inputData, /* I Input data to correlate */
|
||||
const opus_int inputDataSize, /* I Length of input */
|
||||
const opus_int correlationCount /* I Number of correlation taps to compute */
|
||||
);
|
||||
|
||||
/* Pitch estimator */
|
||||
|
@ -264,100 +264,100 @@ void silk_autocorr(
|
|||
#define SILK_PE_MAX_COMPLEX 2
|
||||
|
||||
void silk_decode_pitch(
|
||||
SKP_int16 lagIndex, /* I */
|
||||
SKP_int8 contourIndex, /* O */
|
||||
SKP_int pitch_lags[], /* O 4 pitch values */
|
||||
const SKP_int Fs_kHz, /* I sampling frequency (kHz) */
|
||||
const SKP_int nb_subfr /* I number of sub frames */
|
||||
opus_int16 lagIndex, /* I */
|
||||
opus_int8 contourIndex, /* O */
|
||||
opus_int pitch_lags[], /* O 4 pitch values */
|
||||
const opus_int Fs_kHz, /* I sampling frequency (kHz) */
|
||||
const opus_int nb_subfr /* I number of sub frames */
|
||||
);
|
||||
|
||||
SKP_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */
|
||||
const SKP_int16 *signal, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
|
||||
SKP_int *pitch_out, /* O 4 pitch lag values */
|
||||
SKP_int16 *lagIndex, /* O Lag Index */
|
||||
SKP_int8 *contourIndex, /* O Pitch contour Index */
|
||||
SKP_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */
|
||||
SKP_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */
|
||||
const SKP_int32 search_thres1_Q16, /* I First stage threshold for lag candidates 0 - 1 */
|
||||
const SKP_int search_thres2_Q15, /* I Final threshold for lag candidates 0 - 1 */
|
||||
const SKP_int Fs_kHz, /* I Sample frequency (kHz) */
|
||||
const SKP_int complexity, /* I Complexity setting, 0-2, where 2 is highest */
|
||||
const SKP_int nb_subfr /* I number of 5 ms subframes */
|
||||
opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */
|
||||
const opus_int16 *signal, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
|
||||
opus_int *pitch_out, /* O 4 pitch lag values */
|
||||
opus_int16 *lagIndex, /* O Lag Index */
|
||||
opus_int8 *contourIndex, /* O Pitch contour Index */
|
||||
opus_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */
|
||||
opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */
|
||||
const opus_int32 search_thres1_Q16, /* I First stage threshold for lag candidates 0 - 1 */
|
||||
const opus_int search_thres2_Q15, /* I Final threshold for lag candidates 0 - 1 */
|
||||
const opus_int Fs_kHz, /* I Sample frequency (kHz) */
|
||||
const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */
|
||||
const opus_int nb_subfr /* I number of 5 ms subframes */
|
||||
);
|
||||
|
||||
/* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */
|
||||
/* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */
|
||||
void silk_A2NLSF(
|
||||
SKP_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */
|
||||
SKP_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */
|
||||
const SKP_int d /* I Filter order (must be even) */
|
||||
opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */
|
||||
opus_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */
|
||||
const opus_int d /* I Filter order (must be even) */
|
||||
);
|
||||
|
||||
/* compute whitening filter coefficients from normalized line spectral frequencies */
|
||||
void silk_NLSF2A(
|
||||
SKP_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */
|
||||
const SKP_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */
|
||||
const SKP_int d /* I filter order (should be even) */
|
||||
opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */
|
||||
const opus_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */
|
||||
const opus_int d /* I filter order (should be even) */
|
||||
);
|
||||
|
||||
void silk_insertion_sort_increasing(
|
||||
SKP_int32 *a, /* I/O Unsorted / Sorted vector */
|
||||
SKP_int *idx, /* O: Index vector for the sorted elements */
|
||||
const SKP_int L, /* I: Vector length */
|
||||
const SKP_int K /* I: Number of correctly sorted positions */
|
||||
opus_int32 *a, /* I/O Unsorted / Sorted vector */
|
||||
opus_int *idx, /* O: Index vector for the sorted elements */
|
||||
const opus_int L, /* I: Vector length */
|
||||
const opus_int K /* I: Number of correctly sorted positions */
|
||||
);
|
||||
|
||||
void silk_insertion_sort_decreasing_int16(
|
||||
SKP_int16 *a, /* I/O: Unsorted / Sorted vector */
|
||||
SKP_int *idx, /* O: Index vector for the sorted elements */
|
||||
const SKP_int L, /* I: Vector length */
|
||||
const SKP_int K /* I: Number of correctly sorted positions */
|
||||
opus_int16 *a, /* I/O: Unsorted / Sorted vector */
|
||||
opus_int *idx, /* O: Index vector for the sorted elements */
|
||||
const opus_int L, /* I: Vector length */
|
||||
const opus_int K /* I: Number of correctly sorted positions */
|
||||
);
|
||||
|
||||
void silk_insertion_sort_increasing_all_values_int16(
|
||||
SKP_int16 *a, /* I/O: Unsorted / Sorted vector */
|
||||
const SKP_int L /* I: Vector length */
|
||||
opus_int16 *a, /* I/O: Unsorted / Sorted vector */
|
||||
const opus_int L /* I: Vector length */
|
||||
);
|
||||
|
||||
/* NLSF stabilizer, for a single input data vector */
|
||||
void silk_NLSF_stabilize(
|
||||
SKP_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */
|
||||
const SKP_int16 *NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */
|
||||
const SKP_int L /* I: Number of NLSF parameters in the input vector */
|
||||
opus_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */
|
||||
const opus_int16 *NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */
|
||||
const opus_int L /* I: Number of NLSF parameters in the input vector */
|
||||
);
|
||||
|
||||
/* Laroia low complexity NLSF weights */
|
||||
void silk_NLSF_VQ_weights_laroia(
|
||||
SKP_int16 *pNLSFW_Q_OUT, /* O: Pointer to input vector weights [D x 1] */
|
||||
const SKP_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */
|
||||
const SKP_int D /* I: Input vector dimension (even) */
|
||||
opus_int16 *pNLSFW_Q_OUT, /* O: Pointer to input vector weights [D x 1] */
|
||||
const opus_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */
|
||||
const opus_int D /* I: Input vector dimension (even) */
|
||||
);
|
||||
|
||||
/* Compute reflection coefficients from input signal */
|
||||
void silk_burg_modified(
|
||||
SKP_int32 *res_nrg, /* O residual energy */
|
||||
SKP_int *res_nrgQ, /* O residual energy Q value */
|
||||
SKP_int32 A_Q16[], /* O prediction coefficients (length order) */
|
||||
const SKP_int16 x[], /* I input signal, length: nb_subfr * ( D + subfr_length ) */
|
||||
const SKP_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
|
||||
const SKP_int nb_subfr, /* I number of subframes stacked in x */
|
||||
const SKP_int32 WhiteNoiseFrac_Q32, /* I fraction added to zero-lag autocorrelation */
|
||||
const SKP_int D /* I order */
|
||||
opus_int32 *res_nrg, /* O residual energy */
|
||||
opus_int *res_nrgQ, /* O residual energy Q value */
|
||||
opus_int32 A_Q16[], /* O prediction coefficients (length order) */
|
||||
const opus_int16 x[], /* I input signal, length: nb_subfr * ( D + subfr_length ) */
|
||||
const opus_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
|
||||
const opus_int nb_subfr, /* I number of subframes stacked in x */
|
||||
const opus_int32 WhiteNoiseFrac_Q32, /* I fraction added to zero-lag autocorrelation */
|
||||
const opus_int D /* I order */
|
||||
);
|
||||
|
||||
/* Copy and multiply a vector by a constant */
|
||||
void silk_scale_copy_vector16(
|
||||
SKP_int16 *data_out,
|
||||
const SKP_int16 *data_in,
|
||||
SKP_int32 gain_Q16, /* I: gain in Q16 */
|
||||
const SKP_int dataSize /* I: length */
|
||||
opus_int16 *data_out,
|
||||
const opus_int16 *data_in,
|
||||
opus_int32 gain_Q16, /* I: gain in Q16 */
|
||||
const opus_int dataSize /* I: length */
|
||||
);
|
||||
|
||||
/* Some for the LTP related function requires Q26 to work.*/
|
||||
void silk_scale_vector32_Q26_lshift_18(
|
||||
SKP_int32 *data1, /* I/O: Q0/Q18 */
|
||||
SKP_int32 gain_Q26, /* I: Q26 */
|
||||
SKP_int dataSize /* I: length */
|
||||
opus_int32 *data1, /* I/O: Q0/Q18 */
|
||||
opus_int32 gain_Q26, /* I: Q26 */
|
||||
opus_int dataSize /* I: length */
|
||||
);
|
||||
|
||||
/********************************************************************/
|
||||
|
@ -365,23 +365,23 @@ void silk_scale_vector32_Q26_lshift_18(
|
|||
/********************************************************************/
|
||||
|
||||
/* return sum(inVec1[i]*inVec2[i]) */
|
||||
SKP_int32 silk_inner_prod_aligned(
|
||||
const SKP_int16 *const inVec1, /* I input vector 1 */
|
||||
const SKP_int16 *const inVec2, /* I input vector 2 */
|
||||
const SKP_int len /* I vector lengths */
|
||||
opus_int32 silk_inner_prod_aligned(
|
||||
const opus_int16 *const inVec1, /* I input vector 1 */
|
||||
const opus_int16 *const inVec2, /* I input vector 2 */
|
||||
const opus_int len /* I vector lengths */
|
||||
);
|
||||
|
||||
SKP_int32 silk_inner_prod_aligned_scale(
|
||||
const SKP_int16 *const inVec1, /* I input vector 1 */
|
||||
const SKP_int16 *const inVec2, /* I input vector 2 */
|
||||
const SKP_int scale, /* I number of bits to shift */
|
||||
const SKP_int len /* I vector lengths */
|
||||
opus_int32 silk_inner_prod_aligned_scale(
|
||||
const opus_int16 *const inVec1, /* I input vector 1 */
|
||||
const opus_int16 *const inVec2, /* I input vector 2 */
|
||||
const opus_int scale, /* I number of bits to shift */
|
||||
const opus_int len /* I vector lengths */
|
||||
);
|
||||
|
||||
SKP_int64 silk_inner_prod16_aligned_64(
|
||||
const SKP_int16 *inVec1, /* I input vector 1 */
|
||||
const SKP_int16 *inVec2, /* I input vector 2 */
|
||||
const SKP_int len /* I vector lengths */
|
||||
opus_int64 silk_inner_prod16_aligned_64(
|
||||
const opus_int16 *inVec1, /* I input vector 1 */
|
||||
const opus_int16 *inVec2, /* I input vector 2 */
|
||||
const opus_int len /* I vector lengths */
|
||||
);
|
||||
|
||||
/********************************************************************/
|
||||
|
@ -392,18 +392,18 @@ SKP_int64 silk_inner_prod16_aligned_64(
|
|||
left. Output is 32bit int.
|
||||
Note: contemporary compilers recognize the C expression below and
|
||||
compile it into a 'ror' instruction if available. No need for inline ASM! */
|
||||
SKP_INLINE SKP_int32 silk_ROR32( SKP_int32 a32, SKP_int rot )
|
||||
SKP_INLINE opus_int32 silk_ROR32( opus_int32 a32, opus_int rot )
|
||||
{
|
||||
SKP_uint32 x = (SKP_uint32) a32;
|
||||
SKP_uint32 r = (SKP_uint32) rot;
|
||||
SKP_uint32 m = (SKP_uint32) -rot;
|
||||
opus_uint32 x = (opus_uint32) a32;
|
||||
opus_uint32 r = (opus_uint32) rot;
|
||||
opus_uint32 m = (opus_uint32) -rot;
|
||||
if(rot <= 0)
|
||||
return (SKP_int32) ((x << m) | (x >> (32 - m)));
|
||||
return (opus_int32) ((x << m) | (x >> (32 - m)));
|
||||
else
|
||||
return (SKP_int32) ((x << (32 - r)) | (x >> r));
|
||||
return (opus_int32) ((x << (32 - r)) | (x >> r));
|
||||
}
|
||||
|
||||
/* Allocate SKP_int16 alligned to 4-byte memory address */
|
||||
/* Allocate opus_int16 alligned to 4-byte memory address */
|
||||
#if EMBEDDED_ARM
|
||||
#define SKP_DWORD_ALIGN __attribute__((aligned(4)))
|
||||
#else
|
||||
|
@ -434,10 +434,10 @@ SKP_INLINE SKP_int32 silk_ROR32( SKP_int32 a32, SKP_int rot )
|
|||
// a32 + ((a32 >> 16) * (b32 >> 16)) output have to be 32bit int
|
||||
#define SKP_SMLATT(a32, b32, c32) SKP_ADD32((a32),((b32) >> 16) * ((c32) >> 16))
|
||||
|
||||
#define SKP_SMLALBB(a64, b16, c16) SKP_ADD64((a64),(SKP_int64)((SKP_int32)(b16) * (SKP_int32)(c16)))
|
||||
#define SKP_SMLALBB(a64, b16, c16) SKP_ADD64((a64),(opus_int64)((opus_int32)(b16) * (opus_int32)(c16)))
|
||||
|
||||
// (a32 * b32)
|
||||
#define SKP_SMULL(a32, b32) ((SKP_int64)(a32) * /*(SKP_int64)*/(b32))
|
||||
#define SKP_SMULL(a32, b32) ((opus_int64)(a32) * /*(opus_int64)*/(b32))
|
||||
|
||||
// multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode)
|
||||
#define SKP_MLA_ovflw(a32, b32, c32) SKP_MLA(a32, b32, c32)
|
||||
|
@ -449,8 +449,8 @@ SKP_INLINE SKP_int32 silk_ROR32( SKP_int32 a32, SKP_int rot )
|
|||
#define SKP_SMLAWB_ovflw(a32, b32, c32) SKP_SMLAWB(a32, b32, c32)
|
||||
#define SKP_SMLAWT_ovflw(a32, b32, c32) SKP_SMLAWT(a32, b32, c32)
|
||||
|
||||
#define SKP_DIV32_16(a32, b16) ((SKP_int32)((a32) / (b16)))
|
||||
#define SKP_DIV32(a32, b32) ((SKP_int32)((a32) / (b32)))
|
||||
#define SKP_DIV32_16(a32, b16) ((opus_int32)((a32) / (b16)))
|
||||
#define SKP_DIV32(a32, b32) ((opus_int32)((a32) / (b32)))
|
||||
|
||||
// These macros enables checking for overflow in silk_API_Debug.h
|
||||
#define SKP_ADD16(a, b) ((a) + (b))
|
||||
|
@ -472,12 +472,12 @@ SKP_INLINE SKP_int32 silk_ROR32( SKP_int32 a32, SKP_int rot )
|
|||
#define SKP_CHECK_FIT16(a) (a)
|
||||
#define SKP_CHECK_FIT32(a) (a)
|
||||
|
||||
#define SKP_ADD_SAT16(a, b) (SKP_int16)SKP_SAT16( SKP_ADD32( (SKP_int32)(a), (b) ) )
|
||||
#define SKP_ADD_SAT16(a, b) (opus_int16)SKP_SAT16( SKP_ADD32( (opus_int32)(a), (b) ) )
|
||||
#define SKP_ADD_SAT64(a, b) ((((a) + (b)) & 0x8000000000000000LL) == 0 ? \
|
||||
((((a) & (b)) & 0x8000000000000000LL) != 0 ? SKP_int64_MIN : (a)+(b)) : \
|
||||
((((a) | (b)) & 0x8000000000000000LL) == 0 ? SKP_int64_MAX : (a)+(b)) )
|
||||
|
||||
#define SKP_SUB_SAT16(a, b) (SKP_int16)SKP_SAT16( SKP_SUB32( (SKP_int32)(a), (b) ) )
|
||||
#define SKP_SUB_SAT16(a, b) (opus_int16)SKP_SAT16( SKP_SUB32( (opus_int32)(a), (b) ) )
|
||||
#define SKP_SUB_SAT64(a, b) ((((a)-(b)) & 0x8000000000000000LL) == 0 ? \
|
||||
(( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? SKP_int64_MIN : (a)-(b)) : \
|
||||
((((a)^0x8000000000000000LL) & (b) & 0x8000000000000000LL) ? SKP_int64_MAX : (a)-(b)) )
|
||||
|
@ -535,40 +535,40 @@ SKP_INLINE SKP_int32 silk_ROR32( SKP_int32 a32, SKP_int rot )
|
|||
#define SKP_max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
/* Macro to convert floating-point constants to fixed-point */
|
||||
#define SILK_FIX_CONST( C, Q ) ((SKP_int32)((C) * ((SKP_int64)1 << (Q)) + 0.5))
|
||||
#define SILK_FIX_CONST( C, Q ) ((opus_int32)((C) * ((opus_int64)1 << (Q)) + 0.5))
|
||||
|
||||
/* SKP_min() versions with typecast in the function call */
|
||||
SKP_INLINE SKP_int SKP_min_int(SKP_int a, SKP_int b)
|
||||
SKP_INLINE opus_int SKP_min_int(opus_int a, opus_int b)
|
||||
{
|
||||
return (((a) < (b)) ? (a) : (b));
|
||||
}
|
||||
SKP_INLINE SKP_int16 SKP_min_16(SKP_int16 a, SKP_int16 b)
|
||||
SKP_INLINE opus_int16 SKP_min_16(opus_int16 a, opus_int16 b)
|
||||
{
|
||||
return (((a) < (b)) ? (a) : (b));
|
||||
}
|
||||
SKP_INLINE SKP_int32 SKP_min_32(SKP_int32 a, SKP_int32 b)
|
||||
SKP_INLINE opus_int32 SKP_min_32(opus_int32 a, opus_int32 b)
|
||||
{
|
||||
return (((a) < (b)) ? (a) : (b));
|
||||
}
|
||||
SKP_INLINE SKP_int64 SKP_min_64(SKP_int64 a, SKP_int64 b)
|
||||
SKP_INLINE opus_int64 SKP_min_64(opus_int64 a, opus_int64 b)
|
||||
{
|
||||
return (((a) < (b)) ? (a) : (b));
|
||||
}
|
||||
|
||||
/* SKP_min() versions with typecast in the function call */
|
||||
SKP_INLINE SKP_int SKP_max_int(SKP_int a, SKP_int b)
|
||||
SKP_INLINE opus_int SKP_max_int(opus_int a, opus_int b)
|
||||
{
|
||||
return (((a) > (b)) ? (a) : (b));
|
||||
}
|
||||
SKP_INLINE SKP_int16 SKP_max_16(SKP_int16 a, SKP_int16 b)
|
||||
SKP_INLINE opus_int16 SKP_max_16(opus_int16 a, opus_int16 b)
|
||||
{
|
||||
return (((a) > (b)) ? (a) : (b));
|
||||
}
|
||||
SKP_INLINE SKP_int32 SKP_max_32(SKP_int32 a, SKP_int32 b)
|
||||
SKP_INLINE opus_int32 SKP_max_32(opus_int32 a, opus_int32 b)
|
||||
{
|
||||
return (((a) > (b)) ? (a) : (b));
|
||||
}
|
||||
SKP_INLINE SKP_int64 SKP_max_64(SKP_int64 a, SKP_int64 b)
|
||||
SKP_INLINE opus_int64 SKP_max_64(opus_int64 a, opus_int64 b)
|
||||
{
|
||||
return (((a) > (b)) ? (a) : (b));
|
||||
}
|
||||
|
@ -602,9 +602,9 @@ SKP_INLINE SKP_int64 SKP_max_64(SKP_int64 a, SKP_int64 b)
|
|||
// SKP_SMMUL: Signed top word multiply.
|
||||
// ARMv6 2 instruction cycles.
|
||||
// ARMv3M+ 3 instruction cycles. use SMULL and ignore LSB registers.(except xM)
|
||||
//#define SKP_SMMUL(a32, b32) (SKP_int32)SKP_RSHIFT(SKP_SMLAL(SKP_SMULWB((a32), (b32)), (a32), SKP_RSHIFT_ROUND((b32), 16)), 16)
|
||||
//#define SKP_SMMUL(a32, b32) (opus_int32)SKP_RSHIFT(SKP_SMLAL(SKP_SMULWB((a32), (b32)), (a32), SKP_RSHIFT_ROUND((b32), 16)), 16)
|
||||
// the following seems faster on x86
|
||||
#define SKP_SMMUL(a32, b32) (SKP_int32)SKP_RSHIFT64(SKP_SMULL((a32), (b32)), 32)
|
||||
#define SKP_SMMUL(a32, b32) (opus_int32)SKP_RSHIFT64(SKP_SMULL((a32), (b32)), 32)
|
||||
|
||||
#include "silk_Inlines.h"
|
||||
#include "silk_MacroCount.h"
|
||||
|
|
|
@ -31,11 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/**********************************/
|
||||
/* Initialization of the Silk VAD */
|
||||
/**********************************/
|
||||
SKP_int silk_VAD_Init( /* O Return value, 0 if success */
|
||||
opus_int silk_VAD_Init( /* O Return value, 0 if success */
|
||||
silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
|
||||
)
|
||||
{
|
||||
SKP_int b, ret = 0;
|
||||
opus_int b, ret = 0;
|
||||
|
||||
/* reset state memory */
|
||||
SKP_memset( psSilk_VAD, 0, sizeof( silk_VAD_state ) );
|
||||
|
@ -62,25 +62,25 @@ SKP_int silk_VAD_Init( /* O Return value, 0 if s
|
|||
}
|
||||
|
||||
/* Weighting factors for tilt measure */
|
||||
static const SKP_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -12000 };
|
||||
static const opus_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -12000 };
|
||||
|
||||
/***************************************/
|
||||
/* Get the speech activity level in Q8 */
|
||||
/***************************************/
|
||||
SKP_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */
|
||||
opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */
|
||||
silk_encoder_state *psEncC, /* I/O Encoder state */
|
||||
const SKP_int16 pIn[] /* I PCM input */
|
||||
const opus_int16 pIn[] /* I PCM input */
|
||||
)
|
||||
{
|
||||
SKP_int SA_Q15, pSNR_dB_Q7, input_tilt;
|
||||
SKP_int decimated_framelength, dec_subframe_length, dec_subframe_offset, SNR_Q7, i, b, s;
|
||||
SKP_int32 sumSquared, smooth_coef_Q16;
|
||||
SKP_int16 HPstateTmp;
|
||||
SKP_int16 X[ VAD_N_BANDS ][ MAX_FRAME_LENGTH / 2 ];
|
||||
SKP_int32 Xnrg[ VAD_N_BANDS ];
|
||||
SKP_int32 NrgToNoiseRatio_Q8[ VAD_N_BANDS ];
|
||||
SKP_int32 speech_nrg, x_tmp;
|
||||
SKP_int ret = 0;
|
||||
opus_int SA_Q15, pSNR_dB_Q7, input_tilt;
|
||||
opus_int decimated_framelength, dec_subframe_length, dec_subframe_offset, SNR_Q7, i, b, s;
|
||||
opus_int32 sumSquared, smooth_coef_Q16;
|
||||
opus_int16 HPstateTmp;
|
||||
opus_int16 X[ VAD_N_BANDS ][ MAX_FRAME_LENGTH / 2 ];
|
||||
opus_int32 Xnrg[ VAD_N_BANDS ];
|
||||
opus_int32 NrgToNoiseRatio_Q8[ VAD_N_BANDS ];
|
||||
opus_int32 speech_nrg, x_tmp;
|
||||
opus_int ret = 0;
|
||||
silk_VAD_state *psSilk_VAD = &psEncC->sVAD;
|
||||
|
||||
/* Safety checks */
|
||||
|
@ -194,7 +194,7 @@ SKP_int silk_VAD_GetSA_Q8( /* O Return value, 0 if s
|
|||
sumSquared = SKP_DIV32_16( sumSquared, VAD_N_BANDS ); /* Q14 */
|
||||
|
||||
/* Root-mean-square approximation, scale to dBs, and write to output pointer */
|
||||
pSNR_dB_Q7 = ( SKP_int16 )( 3 * silk_SQRT_APPROX( sumSquared ) ); /* Q7 */
|
||||
pSNR_dB_Q7 = ( opus_int16 )( 3 * silk_SQRT_APPROX( sumSquared ) ); /* Q7 */
|
||||
|
||||
/*********************************/
|
||||
/* Speech Probability Estimation */
|
||||
|
@ -261,13 +261,13 @@ SKP_int silk_VAD_GetSA_Q8( /* O Return value, 0 if s
|
|||
/* Noise level estimation */
|
||||
/**************************/
|
||||
void silk_VAD_GetNoiseLevels(
|
||||
const SKP_int32 pX[ VAD_N_BANDS ], /* I subband energies */
|
||||
const opus_int32 pX[ VAD_N_BANDS ], /* I subband energies */
|
||||
silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
|
||||
)
|
||||
{
|
||||
SKP_int k;
|
||||
SKP_int32 nl, nrg, inv_nrg;
|
||||
SKP_int coef, min_coef;
|
||||
opus_int k;
|
||||
opus_int32 nl, nrg, inv_nrg;
|
||||
opus_int coef, min_coef;
|
||||
|
||||
/* Initially faster smoothing */
|
||||
if( psSilk_VAD->counter < 1000 ) { /* 1000 = 20 sec */
|
||||
|
|
|
@ -29,20 +29,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */
|
||||
void silk_VQ_WMat_EC(
|
||||
SKP_int8 *ind, /* O index of best codebook vector */
|
||||
SKP_int32 *rate_dist_Q14, /* O best weighted quantization error + mu * rate*/
|
||||
const SKP_int16 *in_Q14, /* I input vector to be quantized */
|
||||
const SKP_int32 *W_Q18, /* I weighting matrix */
|
||||
const SKP_int8 *cb_Q7, /* I codebook */
|
||||
const SKP_uint8 *cl_Q5, /* I code length for each codebook vector */
|
||||
const SKP_int mu_Q9, /* I tradeoff between weighted error and rate */
|
||||
SKP_int L /* I number of vectors in codebook */
|
||||
opus_int8 *ind, /* O index of best codebook vector */
|
||||
opus_int32 *rate_dist_Q14, /* O best weighted quantization error + mu * rate*/
|
||||
const opus_int16 *in_Q14, /* I input vector to be quantized */
|
||||
const opus_int32 *W_Q18, /* I weighting matrix */
|
||||
const opus_int8 *cb_Q7, /* I codebook */
|
||||
const opus_uint8 *cl_Q5, /* I code length for each codebook vector */
|
||||
const opus_int mu_Q9, /* I tradeoff between weighted error and rate */
|
||||
opus_int L /* I number of vectors in codebook */
|
||||
)
|
||||
{
|
||||
SKP_int k;
|
||||
const SKP_int8 *cb_row_Q7;
|
||||
SKP_int16 diff_Q14[ 5 ];
|
||||
SKP_int32 sum1_Q14, sum2_Q16;
|
||||
opus_int k;
|
||||
const opus_int8 *cb_row_Q7;
|
||||
opus_int16 diff_Q14[ 5 ];
|
||||
opus_int32 sum1_Q14, sum2_Q16;
|
||||
|
||||
/* Loop over codebook */
|
||||
*rate_dist_Q14 = SKP_int32_MAX;
|
||||
|
@ -98,7 +98,7 @@ void silk_VQ_WMat_EC(
|
|||
/* find best */
|
||||
if( sum1_Q14 < *rate_dist_Q14 ) {
|
||||
*rate_dist_Q14 = sum1_Q14;
|
||||
*ind = (SKP_int8)k;
|
||||
*ind = (opus_int8)k;
|
||||
}
|
||||
|
||||
/* Go to next cbk vector */
|
||||
|
|
|
@ -29,25 +29,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Coefficients for 2-band filter bank based on first-order allpass filters */
|
||||
// old
|
||||
static SKP_int16 A_fb1_20[ 1 ] = { 5394 << 1 };
|
||||
static SKP_int16 A_fb1_21[ 1 ] = { 20623 << 1 }; /* wrap-around to negative number is intentional */
|
||||
static opus_int16 A_fb1_20[ 1 ] = { 5394 << 1 };
|
||||
static opus_int16 A_fb1_21[ 1 ] = { 20623 << 1 }; /* wrap-around to negative number is intentional */
|
||||
|
||||
/* Split signal into two decimated bands using first-order allpass filters */
|
||||
void silk_ana_filt_bank_1(
|
||||
const SKP_int16 *in, /* I: Input signal [N] */
|
||||
SKP_int32 *S, /* I/O: State vector [2] */
|
||||
SKP_int16 *outL, /* O: Low band [N/2] */
|
||||
SKP_int16 *outH, /* O: High band [N/2] */
|
||||
const SKP_int32 N /* I: Number of input samples */
|
||||
const opus_int16 *in, /* I: Input signal [N] */
|
||||
opus_int32 *S, /* I/O: State vector [2] */
|
||||
opus_int16 *outL, /* O: Low band [N/2] */
|
||||
opus_int16 *outH, /* O: High band [N/2] */
|
||||
const opus_int32 N /* I: Number of input samples */
|
||||
)
|
||||
{
|
||||
SKP_int k, N2 = SKP_RSHIFT( N, 1 );
|
||||
SKP_int32 in32, X, Y, out_1, out_2;
|
||||
opus_int k, N2 = SKP_RSHIFT( N, 1 );
|
||||
opus_int32 in32, X, Y, out_1, out_2;
|
||||
|
||||
/* Internal variables and state are in Q10 format */
|
||||
for( k = 0; k < N2; k++ ) {
|
||||
/* Convert to Q10 */
|
||||
in32 = SKP_LSHIFT( (SKP_int32)in[ 2 * k ], 10 );
|
||||
in32 = SKP_LSHIFT( (opus_int32)in[ 2 * k ], 10 );
|
||||
|
||||
/* All-pass section for even input sample */
|
||||
Y = SKP_SUB32( in32, S[ 0 ] );
|
||||
|
@ -56,7 +56,7 @@ void silk_ana_filt_bank_1(
|
|||
S[ 0 ] = SKP_ADD32( in32, X );
|
||||
|
||||
/* Convert to Q10 */
|
||||
in32 = SKP_LSHIFT( (SKP_int32)in[ 2 * k + 1 ], 10 );
|
||||
in32 = SKP_LSHIFT( (opus_int32)in[ 2 * k + 1 ], 10 );
|
||||
|
||||
/* All-pass section for odd input sample, and add to output of previous section */
|
||||
Y = SKP_SUB32( in32, S[ 1 ] );
|
||||
|
@ -65,7 +65,7 @@ void silk_ana_filt_bank_1(
|
|||
S[ 1 ] = SKP_ADD32( in32, X );
|
||||
|
||||
/* Add/subtract, convert back to int16 and store to output */
|
||||
outL[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( SKP_ADD32( out_2, out_1 ), 11 ) );
|
||||
outH[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SUB32( out_2, out_1 ), 11 ) );
|
||||
outL[ k ] = (opus_int16)SKP_SAT16( SKP_RSHIFT_ROUND( SKP_ADD32( out_2, out_1 ), 11 ) );
|
||||
outH[ k ] = (opus_int16)SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SUB32( out_2, out_1 ), 11 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,21 +37,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/* Matlab code for table:
|
||||
for k=16:9*4:16+2*9*4, fprintf(' %7.d,', -round(65536*pi ./ (k:4:k+8*4))); fprintf('\n'); end
|
||||
*/
|
||||
static SKP_int16 freq_table_Q16[ 27 ] = {
|
||||
static opus_int16 freq_table_Q16[ 27 ] = {
|
||||
12111, 9804, 8235, 7100, 6239, 5565, 5022, 4575, 4202,
|
||||
3885, 3612, 3375, 3167, 2984, 2820, 2674, 2542, 2422,
|
||||
2313, 2214, 2123, 2038, 1961, 1889, 1822, 1760, 1702,
|
||||
};
|
||||
|
||||
void silk_apply_sine_window(
|
||||
SKP_int16 px_win[], /* O Pointer to windowed signal */
|
||||
const SKP_int16 px[], /* I Pointer to input signal */
|
||||
const SKP_int win_type, /* I Selects a window type */
|
||||
const SKP_int length /* I Window length, multiple of 4 */
|
||||
opus_int16 px_win[], /* O Pointer to windowed signal */
|
||||
const opus_int16 px[], /* I Pointer to input signal */
|
||||
const opus_int win_type, /* I Selects a window type */
|
||||
const opus_int length /* I Window length, multiple of 4 */
|
||||
)
|
||||
{
|
||||
SKP_int k, f_Q16, c_Q16;
|
||||
SKP_int32 S0_Q16, S1_Q16;
|
||||
opus_int k, f_Q16, c_Q16;
|
||||
opus_int32 S0_Q16, S1_Q16;
|
||||
|
||||
SKP_assert( win_type == 1 || win_type == 2 );
|
||||
|
||||
|
@ -62,7 +62,7 @@ void silk_apply_sine_window(
|
|||
/* Frequency */
|
||||
k = ( length >> 2 ) - 4;
|
||||
SKP_assert( k >= 0 && k <= 26 );
|
||||
f_Q16 = (SKP_int)freq_table_Q16[ k ];
|
||||
f_Q16 = (opus_int)freq_table_Q16[ k ];
|
||||
|
||||
/* Factor used for cosine approximation */
|
||||
c_Q16 = SKP_SMULWB( f_Q16, -f_Q16 );
|
||||
|
@ -84,13 +84,13 @@ void silk_apply_sine_window(
|
|||
/* Uses the recursive equation: sin(n*f) = 2 * cos(f) * sin((n-1)*f) - sin((n-2)*f) */
|
||||
/* 4 samples at a time */
|
||||
for( k = 0; k < length; k += 4 ) {
|
||||
px_win[ k ] = (SKP_int16)SKP_SMULWB( SKP_RSHIFT( S0_Q16 + S1_Q16, 1 ), px[ k ] );
|
||||
px_win[ k + 1 ] = (SKP_int16)SKP_SMULWB( S1_Q16, px[ k + 1] );
|
||||
px_win[ k ] = (opus_int16)SKP_SMULWB( SKP_RSHIFT( S0_Q16 + S1_Q16, 1 ), px[ k ] );
|
||||
px_win[ k + 1 ] = (opus_int16)SKP_SMULWB( S1_Q16, px[ k + 1] );
|
||||
S0_Q16 = SKP_SMULWB( S1_Q16, c_Q16 ) + SKP_LSHIFT( S1_Q16, 1 ) - S0_Q16 + 1;
|
||||
S0_Q16 = SKP_min( S0_Q16, ( 1 << 16 ) );
|
||||
|
||||
px_win[ k + 2 ] = (SKP_int16)SKP_SMULWB( SKP_RSHIFT( S0_Q16 + S1_Q16, 1 ), px[ k + 2] );
|
||||
px_win[ k + 3 ] = (SKP_int16)SKP_SMULWB( S0_Q16, px[ k + 3 ] );
|
||||
px_win[ k + 2 ] = (opus_int16)SKP_SMULWB( SKP_RSHIFT( S0_Q16 + S1_Q16, 1 ), px[ k + 2] );
|
||||
px_win[ k + 3 ] = (opus_int16)SKP_SMULWB( S0_Q16, px[ k + 3 ] );
|
||||
S1_Q16 = SKP_SMULWB( S0_Q16, c_Q16 ) + SKP_LSHIFT( S0_Q16, 1 ) - S1_Q16;
|
||||
S1_Q16 = SKP_min( S1_Q16, ( 1 << 16 ) );
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "silk_SigProc_FIX.h"
|
||||
|
||||
/* Function that returns the maximum absolut value of the input vector */
|
||||
SKP_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */
|
||||
const SKP_int16 *vec, /* I Input vector [len] */
|
||||
const SKP_int32 len /* I Length of 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 */
|
||||
)
|
||||
{
|
||||
SKP_int32 max = 0, i, lvl = 0, ind;
|
||||
opus_int32 max = 0, i, lvl = 0, ind;
|
||||
if( len == 0 ) return 0;
|
||||
|
||||
ind = len - 1;
|
||||
|
|
|
@ -29,15 +29,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Compute autocorrelation */
|
||||
void silk_autocorr(
|
||||
SKP_int32 *results, /* O Result (length correlationCount) */
|
||||
SKP_int *scale, /* O Scaling of the correlation vector */
|
||||
const SKP_int16 *inputData, /* I Input data to correlate */
|
||||
const SKP_int inputDataSize, /* I Length of input */
|
||||
const SKP_int correlationCount /* I Number of correlation taps to compute */
|
||||
opus_int32 *results, /* O Result (length correlationCount) */
|
||||
opus_int *scale, /* O Scaling of the correlation vector */
|
||||
const opus_int16 *inputData, /* I Input data to correlate */
|
||||
const opus_int inputDataSize, /* I Length of input */
|
||||
const opus_int correlationCount /* I Number of correlation taps to compute */
|
||||
)
|
||||
{
|
||||
SKP_int i, lz, nRightShifts, corrCount;
|
||||
SKP_int64 corr64;
|
||||
opus_int i, lz, nRightShifts, corrCount;
|
||||
opus_int64 corr64;
|
||||
|
||||
corrCount = SKP_min_int( inputDataSize, correlationCount );
|
||||
|
||||
|
@ -55,18 +55,18 @@ void silk_autocorr(
|
|||
*scale = nRightShifts;
|
||||
|
||||
if( nRightShifts <= 0 ) {
|
||||
results[ 0 ] = SKP_LSHIFT( (SKP_int32)SKP_CHECK_FIT32( corr64 ), -nRightShifts );
|
||||
results[ 0 ] = SKP_LSHIFT( (opus_int32)SKP_CHECK_FIT32( corr64 ), -nRightShifts );
|
||||
|
||||
/* compute remaining correlations based on int32 inner product */
|
||||
for( i = 1; i < corrCount; i++ ) {
|
||||
results[ i ] = SKP_LSHIFT( silk_inner_prod_aligned( inputData, inputData + i, inputDataSize - i ), -nRightShifts );
|
||||
}
|
||||
} else {
|
||||
results[ 0 ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( corr64, nRightShifts ) );
|
||||
results[ 0 ] = (opus_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( corr64, nRightShifts ) );
|
||||
|
||||
/* compute remaining correlations based on int64 inner product */
|
||||
for( i = 1; i < corrCount; i++ ) {
|
||||
results[ i ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( silk_inner_prod16_aligned_64( inputData, inputData + i, inputDataSize - i ), nRightShifts ) );
|
||||
results[ i ] = (opus_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( silk_inner_prod16_aligned_64( inputData, inputData + i, inputDataSize - i ), nRightShifts ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Second order ARMA filter, alternative implementation */
|
||||
void silk_biquad_alt(
|
||||
const SKP_int16 *in, /* I: Input signal */
|
||||
const SKP_int32 *B_Q28, /* I: MA coefficients [3] */
|
||||
const SKP_int32 *A_Q28, /* I: AR coefficients [2] */
|
||||
SKP_int32 *S, /* I/O: State vector [2] */
|
||||
SKP_int16 *out, /* O: Output signal */
|
||||
const SKP_int32 len /* I: Signal length (must be even) */
|
||||
const opus_int16 *in, /* I: Input signal */
|
||||
const opus_int32 *B_Q28, /* I: MA coefficients [3] */
|
||||
const opus_int32 *A_Q28, /* I: AR coefficients [2] */
|
||||
opus_int32 *S, /* I/O: State vector [2] */
|
||||
opus_int16 *out, /* O: Output signal */
|
||||
const opus_int32 len /* I: Signal length (must be even) */
|
||||
)
|
||||
{
|
||||
/* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */
|
||||
SKP_int k;
|
||||
SKP_int32 inval, A0_U_Q28, A0_L_Q28, A1_U_Q28, A1_L_Q28, out32_Q14;
|
||||
opus_int k;
|
||||
opus_int32 inval, A0_U_Q28, A0_L_Q28, A1_U_Q28, A1_L_Q28, out32_Q14;
|
||||
|
||||
/* Negate A_Q28 values and split in two parts */
|
||||
A0_L_Q28 = ( -A_Q28[ 0 ] ) & 0x00003FFF; /* lower part */
|
||||
|
@ -68,6 +68,6 @@ void silk_biquad_alt(
|
|||
S[ 1 ] = SKP_SMLAWB( S[ 1 ], B_Q28[ 2 ], inval );
|
||||
|
||||
/* Scale back to Q0 and saturate */
|
||||
out[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT( out32_Q14 + (1<<14) - 1, 14 ) );
|
||||
out[ k ] = (opus_int16)SKP_SAT16( SKP_RSHIFT( out32_Q14 + (1<<14) - 1, 14 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,26 +37,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Compute reflection coefficients from input signal */
|
||||
void silk_burg_modified(
|
||||
SKP_int32 *res_nrg, /* O residual energy */
|
||||
SKP_int *res_nrg_Q, /* O residual energy Q value */
|
||||
SKP_int32 A_Q16[], /* O prediction coefficients (length order) */
|
||||
const SKP_int16 x[], /* I input signal, length: nb_subfr * ( D + subfr_length ) */
|
||||
const SKP_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
|
||||
const SKP_int nb_subfr, /* I number of subframes stacked in x */
|
||||
const SKP_int32 WhiteNoiseFrac_Q32, /* I fraction added to zero-lag autocorrelation */
|
||||
const SKP_int D /* I order */
|
||||
opus_int32 *res_nrg, /* O residual energy */
|
||||
opus_int *res_nrg_Q, /* O residual energy Q value */
|
||||
opus_int32 A_Q16[], /* O prediction coefficients (length order) */
|
||||
const opus_int16 x[], /* I input signal, length: nb_subfr * ( D + subfr_length ) */
|
||||
const opus_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
|
||||
const opus_int nb_subfr, /* I number of subframes stacked in x */
|
||||
const opus_int32 WhiteNoiseFrac_Q32, /* I fraction added to zero-lag autocorrelation */
|
||||
const opus_int D /* I order */
|
||||
)
|
||||
{
|
||||
SKP_int k, n, s, lz, rshifts, rshifts_extra;
|
||||
SKP_int32 C0, num, nrg, rc_Q31, Atmp_QA, Atmp1, tmp1, tmp2, x1, x2;
|
||||
const SKP_int16 *x_ptr;
|
||||
opus_int k, n, s, lz, rshifts, rshifts_extra;
|
||||
opus_int32 C0, num, nrg, rc_Q31, Atmp_QA, Atmp1, tmp1, tmp2, x1, x2;
|
||||
const opus_int16 *x_ptr;
|
||||
|
||||
SKP_int32 C_first_row[ SILK_MAX_ORDER_LPC ];
|
||||
SKP_int32 C_last_row[ SILK_MAX_ORDER_LPC ];
|
||||
SKP_int32 Af_QA[ SILK_MAX_ORDER_LPC ];
|
||||
opus_int32 C_first_row[ SILK_MAX_ORDER_LPC ];
|
||||
opus_int32 C_last_row[ SILK_MAX_ORDER_LPC ];
|
||||
opus_int32 Af_QA[ SILK_MAX_ORDER_LPC ];
|
||||
|
||||
SKP_int32 CAf[ SILK_MAX_ORDER_LPC + 1 ];
|
||||
SKP_int32 CAb[ SILK_MAX_ORDER_LPC + 1 ];
|
||||
opus_int32 CAf[ SILK_MAX_ORDER_LPC + 1 ];
|
||||
opus_int32 CAb[ SILK_MAX_ORDER_LPC + 1 ];
|
||||
|
||||
SKP_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE );
|
||||
SKP_assert( nb_subfr <= MAX_NB_SUBFR );
|
||||
|
@ -80,12 +80,12 @@ void silk_burg_modified(
|
|||
}
|
||||
rshifts += rshifts_extra;
|
||||
}
|
||||
SKP_memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( SKP_int32 ) );
|
||||
SKP_memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) );
|
||||
if( rshifts > 0 ) {
|
||||
for( s = 0; s < nb_subfr; s++ ) {
|
||||
x_ptr = x + s * subfr_length;
|
||||
for( n = 1; n < D + 1; n++ ) {
|
||||
C_first_row[ n - 1 ] += (SKP_int32)SKP_RSHIFT64(
|
||||
C_first_row[ n - 1 ] += (opus_int32)SKP_RSHIFT64(
|
||||
silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n ), rshifts );
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ void silk_burg_modified(
|
|||
}
|
||||
}
|
||||
}
|
||||
SKP_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) );
|
||||
|
||||
/* Initialize */
|
||||
CAb[ 0 ] = CAf[ 0 ] = C0 + SKP_SMMUL( WhiteNoiseFrac_Q32, C0 ) + 1; // Q(-rshifts)
|
||||
|
@ -111,10 +111,10 @@ void silk_burg_modified(
|
|||
if( rshifts > -2 ) {
|
||||
for( s = 0; s < nb_subfr; s++ ) {
|
||||
x_ptr = x + s * subfr_length;
|
||||
x1 = -SKP_LSHIFT32( (SKP_int32)x_ptr[ n ], 16 - rshifts ); // Q(16-rshifts)
|
||||
x2 = -SKP_LSHIFT32( (SKP_int32)x_ptr[ subfr_length - n - 1 ], 16 - rshifts ); // Q(16-rshifts)
|
||||
tmp1 = SKP_LSHIFT32( (SKP_int32)x_ptr[ n ], QA - 16 ); // Q(QA-16)
|
||||
tmp2 = SKP_LSHIFT32( (SKP_int32)x_ptr[ subfr_length - n - 1 ], QA - 16 ); // Q(QA-16)
|
||||
x1 = -SKP_LSHIFT32( (opus_int32)x_ptr[ n ], 16 - rshifts ); // Q(16-rshifts)
|
||||
x2 = -SKP_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 16 - rshifts ); // Q(16-rshifts)
|
||||
tmp1 = SKP_LSHIFT32( (opus_int32)x_ptr[ n ], QA - 16 ); // Q(QA-16)
|
||||
tmp2 = SKP_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], QA - 16 ); // Q(QA-16)
|
||||
for( k = 0; k < n; k++ ) {
|
||||
C_first_row[ k ] = SKP_SMLAWB( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); // Q( -rshifts )
|
||||
C_last_row[ k ] = SKP_SMLAWB( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); // Q( -rshifts )
|
||||
|
@ -132,10 +132,10 @@ void silk_burg_modified(
|
|||
} else {
|
||||
for( s = 0; s < nb_subfr; s++ ) {
|
||||
x_ptr = x + s * subfr_length;
|
||||
x1 = -SKP_LSHIFT32( (SKP_int32)x_ptr[ n ], -rshifts ); // Q( -rshifts )
|
||||
x2 = -SKP_LSHIFT32( (SKP_int32)x_ptr[ subfr_length - n - 1 ], -rshifts ); // Q( -rshifts )
|
||||
tmp1 = SKP_LSHIFT32( (SKP_int32)x_ptr[ n ], 17 ); // Q17
|
||||
tmp2 = SKP_LSHIFT32( (SKP_int32)x_ptr[ subfr_length - n - 1 ], 17 ); // Q17
|
||||
x1 = -SKP_LSHIFT32( (opus_int32)x_ptr[ n ], -rshifts ); // Q( -rshifts )
|
||||
x2 = -SKP_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], -rshifts ); // Q( -rshifts )
|
||||
tmp1 = SKP_LSHIFT32( (opus_int32)x_ptr[ n ], 17 ); // Q17
|
||||
tmp2 = SKP_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 17 ); // Q17
|
||||
for( k = 0; k < n; k++ ) {
|
||||
C_first_row[ k ] = SKP_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); // Q( -rshifts )
|
||||
C_last_row[ k ] = SKP_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); // Q( -rshifts )
|
||||
|
@ -147,9 +147,9 @@ void silk_burg_modified(
|
|||
tmp2 = -tmp2; // Q17
|
||||
for( k = 0; k <= n; k++ ) {
|
||||
CAf[ k ] = SKP_SMLAWW( CAf[ k ], tmp1,
|
||||
SKP_LSHIFT32( (SKP_int32)x_ptr[ n - k ], -rshifts - 1 ) ); // Q( -rshift )
|
||||
SKP_LSHIFT32( (opus_int32)x_ptr[ n - k ], -rshifts - 1 ) ); // Q( -rshift )
|
||||
CAb[ k ] = SKP_SMLAWW( CAb[ k ], tmp2,
|
||||
SKP_LSHIFT32( (SKP_int32)x_ptr[ subfr_length - n + k - 1 ], -rshifts - 1 ) );// Q( -rshift )
|
||||
SKP_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n + k - 1 ], -rshifts - 1 ) );// Q( -rshift )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ void silk_burg_modified(
|
|||
rc_Q31 = silk_DIV32_varQ( num, nrg, 31 );
|
||||
} else {
|
||||
/* Negative energy or ratio too high; set remaining coefficients to zero and exit loop */
|
||||
SKP_memset( &Af_QA[ n ], 0, ( D - n ) * sizeof( SKP_int32 ) );
|
||||
SKP_memset( &Af_QA[ n ], 0, ( D - n ) * sizeof( opus_int32 ) );
|
||||
SKP_assert( 0 );
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -29,19 +29,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Chirp (bandwidth expand) LP AR filter */
|
||||
void silk_bwexpander(
|
||||
SKP_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||
const SKP_int d, /* I Length of ar */
|
||||
SKP_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
|
||||
opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||
const opus_int d, /* I Length of ar */
|
||||
opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
SKP_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536;
|
||||
opus_int i;
|
||||
opus_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536;
|
||||
|
||||
/* NB: Dont use SKP_SMULWB, instead of SKP_RSHIFT_ROUND( SKP_MUL(), 16 ), below. */
|
||||
/* Bias in SKP_SMULWB can lead to unstable filters */
|
||||
for( i = 0; i < d - 1; i++ ) {
|
||||
ar[ i ] = (SKP_int16)SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, ar[ i ] ), 16 );
|
||||
ar[ i ] = (opus_int16)SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, ar[ i ] ), 16 );
|
||||
chirp_Q16 += SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 );
|
||||
}
|
||||
ar[ d - 1 ] = (SKP_int16)SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, ar[ d - 1 ] ), 16 );
|
||||
ar[ d - 1 ] = (opus_int16)SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, ar[ d - 1 ] ), 16 );
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/* Chirp (bandwidth expand) LP AR filter */
|
||||
void silk_bwexpander_32(
|
||||
SKP_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||
const SKP_int d, /* I Length of ar */
|
||||
SKP_int32 chirp_Q16 /* I Chirp factor in Q16 */
|
||||
opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||
const opus_int d, /* I Length of ar */
|
||||
opus_int32 chirp_Q16 /* I Chirp factor in Q16 */
|
||||
)
|
||||
{
|
||||
SKP_int i;
|
||||
SKP_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536;
|
||||
opus_int i;
|
||||
opus_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536;
|
||||
|
||||
for( i = 0; i < d - 1; i++ ) {
|
||||
ar[ i ] = SKP_SMULWW( chirp_Q16, ar[ i ] );
|
||||
|
|
|
@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "silk_errors.h"
|
||||
|
||||
/* Check encoder control struct */
|
||||
SKP_int check_control_input(
|
||||
opus_int check_control_input(
|
||||
silk_EncControlStruct *encControl /* I: Control structure */
|
||||
)
|
||||
{
|
||||
|
|
|
@ -36,17 +36,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/* Encodes signs of excitation */
|
||||
void silk_encode_signs(
|
||||
ec_enc *psRangeEnc, /* I/O Compressor data structure */
|
||||
const SKP_int8 pulses[], /* I pulse signal */
|
||||
SKP_int length, /* I length of input */
|
||||
const SKP_int signalType, /* I Signal type */
|
||||
const SKP_int quantOffsetType, /* I Quantization offset type */
|
||||
const SKP_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
|
||||
const opus_int8 pulses[], /* I pulse signal */
|
||||
opus_int length, /* I length of input */
|
||||
const opus_int signalType, /* I Signal type */
|
||||
const opus_int quantOffsetType, /* I Quantization offset type */
|
||||
const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, p;
|
||||
SKP_uint8 icdf[ 2 ];
|
||||
const SKP_int8 *q_ptr;
|
||||
const SKP_uint8 *icdf_ptr;
|
||||
opus_int i, j, p;
|
||||
opus_uint8 icdf[ 2 ];
|
||||
const opus_int8 *q_ptr;
|
||||
const opus_uint8 *icdf_ptr;
|
||||
|
||||
icdf[ 1 ] = 0;
|
||||
q_ptr = pulses;
|
||||
|
@ -70,17 +70,17 @@ void silk_encode_signs(
|
|||
/* Decodes signs of excitation */
|
||||
void silk_decode_signs(
|
||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||
SKP_int pulses[], /* I/O pulse signal */
|
||||
SKP_int length, /* I length of input */
|
||||
const SKP_int signalType, /* I Signal type */
|
||||
const SKP_int quantOffsetType, /* I Quantization offset type */
|
||||
const SKP_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
|
||||
opus_int pulses[], /* I/O pulse signal */
|
||||
opus_int length, /* I length of input */
|
||||
const opus_int signalType, /* I Signal type */
|
||||
const opus_int quantOffsetType, /* I Quantization offset type */
|
||||
const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, p;
|
||||
SKP_uint8 icdf[ 2 ];
|
||||
SKP_int *q_ptr;
|
||||
const SKP_uint8 *icdf_ptr;
|
||||
opus_int i, j, p;
|
||||
opus_uint8 icdf[ 2 ];
|
||||
opus_int *q_ptr;
|
||||
const opus_uint8 *icdf_ptr;
|
||||
|
||||
icdf[ 1 ] = 0;
|
||||
q_ptr = pulses;
|
||||
|
|
|
@ -45,58 +45,58 @@ extern "C"
|
|||
/***********************************************/
|
||||
typedef struct {
|
||||
/* I: Number of channels; 1/2 */
|
||||
SKP_int32 nChannelsAPI;
|
||||
opus_int32 nChannelsAPI;
|
||||
|
||||
/* I: Number of channels; 1/2 */
|
||||
SKP_int32 nChannelsInternal;
|
||||
opus_int32 nChannelsInternal;
|
||||
|
||||
/* I: Input signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */
|
||||
SKP_int32 API_sampleRate;
|
||||
opus_int32 API_sampleRate;
|
||||
|
||||
/* I: Maximum internal sampling rate in Hertz; 8000/12000/16000 */
|
||||
SKP_int32 maxInternalSampleRate;
|
||||
opus_int32 maxInternalSampleRate;
|
||||
|
||||
/* I: Minimum internal sampling rate in Hertz; 8000/12000/16000 */
|
||||
SKP_int32 minInternalSampleRate;
|
||||
opus_int32 minInternalSampleRate;
|
||||
|
||||
/* I: Soft request for internal sampling rate in Hertz; 8000/12000/16000 */
|
||||
SKP_int32 desiredInternalSampleRate;
|
||||
opus_int32 desiredInternalSampleRate;
|
||||
|
||||
/* I: Number of samples per packet in milliseconds; 10/20/40/60 */
|
||||
SKP_int payloadSize_ms;
|
||||
opus_int payloadSize_ms;
|
||||
|
||||
/* I: Bitrate during active speech in bits/second; internally limited */
|
||||
SKP_int32 bitRate;
|
||||
opus_int32 bitRate;
|
||||
|
||||
/* I: Uplink packet loss in percent (0-100) */
|
||||
SKP_int packetLossPercentage;
|
||||
opus_int packetLossPercentage;
|
||||
|
||||
/* I: Complexity mode; 0 is lowest, 10 is highest complexity */
|
||||
SKP_int complexity;
|
||||
opus_int complexity;
|
||||
|
||||
/* I: Flag to enable in-band Forward Error Correction (FEC); 0/1 */
|
||||
SKP_int useInBandFEC;
|
||||
opus_int useInBandFEC;
|
||||
|
||||
/* I: Flag to enable discontinuous transmission (DTX); 0/1 */
|
||||
SKP_int useDTX;
|
||||
opus_int useDTX;
|
||||
|
||||
/* I: Flag to use constant bitrate */
|
||||
SKP_int useCBR;
|
||||
opus_int useCBR;
|
||||
|
||||
/* I: Cutoff frequency of input HP filter (of zero: adaptive) */
|
||||
SKP_int HP_cutoff_Hz;
|
||||
opus_int HP_cutoff_Hz;
|
||||
|
||||
/* O: Internal sampling rate used, in Hertz; 8000/12000/16000 */
|
||||
SKP_int32 internalSampleRate;
|
||||
opus_int32 internalSampleRate;
|
||||
|
||||
/* O: Flag that bandwidth switching is allowed (because low voice activity) */
|
||||
SKP_int allowBandwidthSwitch;
|
||||
opus_int allowBandwidthSwitch;
|
||||
|
||||
/* O: Flag that SILK runs in WB mode without variable LP filter (use for switching between WB/SWB/FB) */
|
||||
SKP_int inWBmodeWithoutVariableLP;
|
||||
opus_int inWBmodeWithoutVariableLP;
|
||||
|
||||
/* O: Stereo width */
|
||||
SKP_int stereoWidth_Q14;
|
||||
opus_int stereoWidth_Q14;
|
||||
} silk_EncControlStruct;
|
||||
|
||||
/**************************************************************************/
|
||||
|
@ -104,19 +104,19 @@ typedef struct {
|
|||
/**************************************************************************/
|
||||
typedef struct {
|
||||
/* I: Number of channels; 1/2 */
|
||||
SKP_int32 nChannelsAPI;
|
||||
opus_int32 nChannelsAPI;
|
||||
|
||||
/* I: Number of channels; 1/2 */
|
||||
SKP_int32 nChannelsInternal;
|
||||
opus_int32 nChannelsInternal;
|
||||
|
||||
/* I: Output signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */
|
||||
SKP_int32 API_sampleRate;
|
||||
opus_int32 API_sampleRate;
|
||||
|
||||
/* I: Internal sampling rate used, in Hertz; 8000/12000/16000 */
|
||||
SKP_int32 internalSampleRate;
|
||||
opus_int32 internalSampleRate;
|
||||
|
||||
/* I: Number of samples per packet in milliseconds; 10/20/40/60 */
|
||||
SKP_int payloadSize_ms;
|
||||
opus_int payloadSize_ms;
|
||||
} silk_DecControlStruct;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -29,14 +29,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "silk_tuning_parameters.h"
|
||||
|
||||
/* Control SNR of redidual quantizer */
|
||||
SKP_int silk_control_SNR(
|
||||
opus_int silk_control_SNR(
|
||||
silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
|
||||
SKP_int32 TargetRate_bps /* I Target max bitrate (bps) */
|
||||
opus_int32 TargetRate_bps /* I Target max bitrate (bps) */
|
||||
)
|
||||
{
|
||||
SKP_int k, ret = SILK_NO_ERROR;
|
||||
SKP_int32 frac_Q6;
|
||||
const SKP_int32 *rateTable;
|
||||
opus_int k, ret = SILK_NO_ERROR;
|
||||
opus_int32 frac_Q6;
|
||||
const opus_int32 *rateTable;
|
||||
|
||||
/* Set bitrate/coding quality */
|
||||
TargetRate_bps = SKP_LIMIT( TargetRate_bps, MIN_TARGET_RATE_BPS, MAX_TARGET_RATE_BPS );
|
||||
|
|
|
@ -29,12 +29,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "silk_tuning_parameters.h"
|
||||
|
||||
/* Control internal sampling rate */
|
||||
SKP_int silk_control_audio_bandwidth(
|
||||
opus_int silk_control_audio_bandwidth(
|
||||
silk_encoder_state *psEncC /* I/O Pointer to Silk encoder state */
|
||||
)
|
||||
{
|
||||
SKP_int fs_kHz;
|
||||
SKP_int32 fs_Hz;
|
||||
opus_int fs_kHz;
|
||||
opus_int32 fs_Hz;
|
||||
|
||||
fs_kHz = psEncC->fs_kHz;
|
||||
fs_Hz = SKP_SMULBB( fs_kHz, 1000 );
|
||||
|
|
|
@ -37,38 +37,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#endif
|
||||
#include "silk_tuning_parameters.h"
|
||||
|
||||
SKP_int silk_setup_resamplers(
|
||||
opus_int silk_setup_resamplers(
|
||||
silk_encoder_state_Fxx *psEnc, /* I/O */
|
||||
SKP_int fs_kHz /* I */
|
||||
opus_int fs_kHz /* I */
|
||||
);
|
||||
|
||||
SKP_int silk_setup_fs(
|
||||
opus_int silk_setup_fs(
|
||||
silk_encoder_state_Fxx *psEnc, /* I/O */
|
||||
SKP_int fs_kHz, /* I */
|
||||
SKP_int PacketSize_ms /* I */
|
||||
opus_int fs_kHz, /* I */
|
||||
opus_int PacketSize_ms /* I */
|
||||
);
|
||||
|
||||
SKP_int silk_setup_complexity(
|
||||
opus_int silk_setup_complexity(
|
||||
silk_encoder_state *psEncC, /* I/O */
|
||||
SKP_int Complexity /* I */
|
||||
opus_int Complexity /* I */
|
||||
);
|
||||
|
||||
SKP_INLINE SKP_int silk_setup_LBRR(
|
||||
SKP_INLINE opus_int silk_setup_LBRR(
|
||||
silk_encoder_state *psEncC, /* I/O */
|
||||
const SKP_int32 TargetRate_bps /* I */
|
||||
const opus_int32 TargetRate_bps /* I */
|
||||
);
|
||||
|
||||
|
||||
/* Control encoder */
|
||||
SKP_int silk_control_encoder(
|
||||
opus_int silk_control_encoder(
|
||||
silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */
|
||||
silk_EncControlStruct *encControl, /* I: Control structure */
|
||||
const SKP_int32 TargetRate_bps, /* I Target max bitrate (bps) */
|
||||
const SKP_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
|
||||
const SKP_int channelNb /* I Channel number */
|
||||
const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */
|
||||
const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
|
||||
const opus_int channelNb /* I Channel number */
|
||||
)
|
||||
{
|
||||
SKP_int fs_kHz, ret = 0;
|
||||
opus_int fs_kHz, ret = 0;
|
||||
|
||||
psEnc->sCmn.useDTX = encControl->useDTX;
|
||||
psEnc->sCmn.useCBR = encControl->useCBR;
|
||||
|
@ -127,13 +127,13 @@ SKP_int silk_control_encoder(
|
|||
return ret;
|
||||
}
|
||||
|
||||
SKP_int silk_setup_resamplers(
|
||||
opus_int silk_setup_resamplers(
|
||||
silk_encoder_state_Fxx *psEnc, /* I/O */
|
||||
SKP_int fs_kHz /* I */
|
||||
opus_int fs_kHz /* I */
|
||||
)
|
||||
{
|
||||
SKP_int ret = SILK_NO_ERROR;
|
||||
SKP_int32 nSamples_temp;
|
||||
opus_int ret = SILK_NO_ERROR;
|
||||
opus_int32 nSamples_temp;
|
||||
|
||||
if( psEnc->sCmn.fs_kHz != fs_kHz || psEnc->sCmn.prev_API_fs_Hz != psEnc->sCmn.API_fs_Hz )
|
||||
{
|
||||
|
@ -142,11 +142,11 @@ SKP_int silk_setup_resamplers(
|
|||
ret += silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000 );
|
||||
} else {
|
||||
/* Allocate worst case space for temporary upsampling, 8 to 48 kHz, so a factor 6 */
|
||||
SKP_int16 x_buf_API_fs_Hz[ ( 2 * MAX_FRAME_LENGTH_MS + LA_SHAPE_MS ) * MAX_API_FS_KHZ ];
|
||||
opus_int16 x_buf_API_fs_Hz[ ( 2 * MAX_FRAME_LENGTH_MS + LA_SHAPE_MS ) * MAX_API_FS_KHZ ];
|
||||
#ifdef FIXED_POINT
|
||||
SKP_int16 *x_bufFIX = psEnc->x_buf;
|
||||
opus_int16 *x_bufFIX = psEnc->x_buf;
|
||||
#else
|
||||
SKP_int16 x_bufFIX[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];
|
||||
opus_int16 x_bufFIX[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];
|
||||
#endif
|
||||
|
||||
nSamples_temp = SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + LA_SHAPE_MS * psEnc->sCmn.fs_kHz;
|
||||
|
@ -174,7 +174,7 @@ SKP_int silk_setup_resamplers(
|
|||
|
||||
} else {
|
||||
/* Copy data */
|
||||
SKP_memcpy( x_buf_API_fs_Hz, x_bufFIX, nSamples_temp * sizeof( SKP_int16 ) );
|
||||
SKP_memcpy( x_buf_API_fs_Hz, x_bufFIX, nSamples_temp * sizeof( opus_int16 ) );
|
||||
}
|
||||
|
||||
if( 1000 * fs_kHz != psEnc->sCmn.API_fs_Hz ) {
|
||||
|
@ -192,13 +192,13 @@ SKP_int silk_setup_resamplers(
|
|||
return ret;
|
||||
}
|
||||
|
||||
SKP_int silk_setup_fs(
|
||||
opus_int silk_setup_fs(
|
||||
silk_encoder_state_Fxx *psEnc, /* I/O */
|
||||
SKP_int fs_kHz, /* I */
|
||||
SKP_int PacketSize_ms /* I */
|
||||
opus_int fs_kHz, /* I */
|
||||
opus_int PacketSize_ms /* I */
|
||||
)
|
||||
{
|
||||
SKP_int ret = SILK_NO_ERROR;
|
||||
opus_int ret = SILK_NO_ERROR;
|
||||
|
||||
/* Set packet size */
|
||||
if( PacketSize_ms != psEnc->sCmn.PacketSize_ms ) {
|
||||
|
@ -309,12 +309,12 @@ SKP_int silk_setup_fs(
|
|||
return ret;
|
||||
}
|
||||
|
||||
SKP_int silk_setup_complexity(
|
||||
opus_int silk_setup_complexity(
|
||||
silk_encoder_state *psEncC, /* I/O */
|
||||
SKP_int Complexity /* I */
|
||||
opus_int Complexity /* I */
|
||||
)
|
||||
{
|
||||
SKP_int ret = 0;
|
||||
opus_int ret = 0;
|
||||
|
||||
/* Set encoding complexity */
|
||||
SKP_assert( Complexity >= 0 && Complexity <= 10 );
|
||||
|
@ -391,13 +391,13 @@ SKP_int silk_setup_complexity(
|
|||
return ret;
|
||||
}
|
||||
|
||||
SKP_INLINE SKP_int silk_setup_LBRR(
|
||||
SKP_INLINE opus_int silk_setup_LBRR(
|
||||
silk_encoder_state *psEncC, /* I/O */
|
||||
const SKP_int32 TargetRate_bps /* I */
|
||||
const opus_int32 TargetRate_bps /* I */
|
||||
)
|
||||
{
|
||||
SKP_int ret = SILK_NO_ERROR;
|
||||
SKP_int32 LBRR_rate_thres_bps;
|
||||
opus_int ret = SILK_NO_ERROR;
|
||||
opus_int32 LBRR_rate_thres_bps;
|
||||
|
||||
psEncC->LBRR_enabled = 0;
|
||||
if( psEncC->useInBandFEC && psEncC->PacketLoss_perc > 0 ) {
|
||||
|
|
|
@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/************************/
|
||||
/* Init Decoder State */
|
||||
/************************/
|
||||
SKP_int silk_init_decoder(
|
||||
opus_int silk_init_decoder(
|
||||
silk_decoder_state *psDec /* I/O Decoder state pointer */
|
||||
)
|
||||
{
|
||||
|
|
|
@ -67,10 +67,10 @@ LARGE_INTEGER silk_Timer_start[SKP_NUM_TIMERS_MAX];
|
|||
unsigned long silk_Timer_start[SKP_NUM_TIMERS_MAX];
|
||||
#endif
|
||||
unsigned int silk_Timer_cnt[SKP_NUM_TIMERS_MAX];
|
||||
SKP_int64 silk_Timer_min[SKP_NUM_TIMERS_MAX];
|
||||
SKP_int64 silk_Timer_sum[SKP_NUM_TIMERS_MAX];
|
||||
SKP_int64 silk_Timer_max[SKP_NUM_TIMERS_MAX];
|
||||
SKP_int64 silk_Timer_depth[SKP_NUM_TIMERS_MAX];
|
||||
opus_int64 silk_Timer_min[SKP_NUM_TIMERS_MAX];
|
||||
opus_int64 silk_Timer_sum[SKP_NUM_TIMERS_MAX];
|
||||
opus_int64 silk_Timer_max[SKP_NUM_TIMERS_MAX];
|
||||
opus_int64 silk_Timer_depth[SKP_NUM_TIMERS_MAX];
|
||||
|
||||
#ifdef WIN32
|
||||
void silk_TimerSave(char *file_name)
|
||||
|
|
|
@ -104,10 +104,10 @@ extern LARGE_INTEGER silk_Timer_start[SKP_NUM_TIMERS_MAX];
|
|||
extern unsigned long silk_Timer_start[SKP_NUM_TIMERS_MAX];
|
||||
#endif
|
||||
extern unsigned int silk_Timer_cnt[SKP_NUM_TIMERS_MAX];
|
||||
extern SKP_int64 silk_Timer_sum[SKP_NUM_TIMERS_MAX];
|
||||
extern SKP_int64 silk_Timer_max[SKP_NUM_TIMERS_MAX];
|
||||
extern SKP_int64 silk_Timer_min[SKP_NUM_TIMERS_MAX];
|
||||
extern SKP_int64 silk_Timer_depth[SKP_NUM_TIMERS_MAX];
|
||||
extern opus_int64 silk_Timer_sum[SKP_NUM_TIMERS_MAX];
|
||||
extern opus_int64 silk_Timer_max[SKP_NUM_TIMERS_MAX];
|
||||
extern opus_int64 silk_Timer_min[SKP_NUM_TIMERS_MAX];
|
||||
extern opus_int64 silk_Timer_depth[SKP_NUM_TIMERS_MAX];
|
||||
|
||||
/* WARNING: TIC()/TOC can measure only up to 0.1 seconds at a time */
|
||||
#ifdef _WIN32
|
||||
|
@ -246,7 +246,7 @@ extern SKP_int64 silk_Timer_depth[SKP_NUM_TIMERS_MAX];
|
|||
/* opens an empty file if this file has not yet been open, then writes to the file and closes it */
|
||||
/* if file has been open previously it is opened again and the fwrite is appending, finally it is closed */
|
||||
#define SAVE_DATA( FILE_NAME, DATA_PTR, N_BYTES ) { \
|
||||
static SKP_int32 init = 0; \
|
||||
static opus_int32 init = 0; \
|
||||
FILE *fp; \
|
||||
if (init == 0) { \
|
||||
init = 1; \
|
||||
|
@ -258,7 +258,7 @@ extern SKP_int64 silk_Timer_depth[SKP_NUM_TIMERS_MAX];
|
|||
fclose(fp); \
|
||||
}
|
||||
|
||||
/* Example: DEBUG_STORE_DATA(testfile.pcm, &RIN[0], 160*sizeof(SKP_int16)); */
|
||||
/* Example: DEBUG_STORE_DATA(testfile.pcm, &RIN[0], 160*sizeof(opus_int16)); */
|
||||
|
||||
#if 0
|
||||
/* Ensure that everything is written to files when an assert breaks */
|
||||
|
@ -273,7 +273,7 @@ extern int silk_debug_store_count;
|
|||
|
||||
/* Faster way of storing the data */
|
||||
#define DEBUG_STORE_DATA( FILE_NAME, DATA_PTR, N_BYTES ) { \
|
||||
static SKP_int init = 0, cnt = 0; \
|
||||
static opus_int init = 0, cnt = 0; \
|
||||
static FILE **fp; \
|
||||
if (init == 0) { \
|
||||
init = 1; \
|
||||
|
@ -285,7 +285,7 @@ extern int silk_debug_store_count;
|
|||
|
||||
/* Call this at the end of main() */
|
||||
#define SILK_DEBUG_STORE_CLOSE_FILES { \
|
||||
SKP_int i; \
|
||||
opus_int i; \
|
||||
for( i = 0; i < silk_debug_store_count; i++ ) { \
|
||||
fclose( silk_debug_store_fp[ i ] ); \
|
||||
} \
|
||||
|
@ -293,7 +293,7 @@ extern int silk_debug_store_count;
|
|||
#endif
|
||||
|
||||
/* micro sec */
|
||||
#define SKP_GETTIME(void) time = (SKP_int64) silk_GetHighResolutionTime();
|
||||
#define SKP_GETTIME(void) time = (opus_int64) silk_GetHighResolutionTime();
|
||||
|
||||
#else /* SILK_DEBUG */
|
||||
|
||||
|
|
|
@ -37,17 +37,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
typedef struct {
|
||||
silk_decoder_state channel_state[ DECODER_NUM_CHANNELS ];
|
||||
stereo_dec_state sStereo;
|
||||
SKP_int nChannelsAPI;
|
||||
SKP_int nChannelsInternal;
|
||||
opus_int nChannelsAPI;
|
||||
opus_int nChannelsInternal;
|
||||
} silk_decoder;
|
||||
|
||||
/*********************/
|
||||
/* Decoder functions */
|
||||
/*********************/
|
||||
|
||||
SKP_int silk_Get_Decoder_Size( SKP_int32 *decSizeBytes )
|
||||
opus_int silk_Get_Decoder_Size( opus_int32 *decSizeBytes )
|
||||
{
|
||||
SKP_int ret = SILK_NO_ERROR;
|
||||
opus_int ret = SILK_NO_ERROR;
|
||||
|
||||
*decSizeBytes = sizeof( silk_decoder );
|
||||
|
||||
|
@ -55,11 +55,11 @@ SKP_int silk_Get_Decoder_Size( SKP_int32 *decSizeBytes )
|
|||
}
|
||||
|
||||
/* Reset decoder state */
|
||||
SKP_int silk_InitDecoder(
|
||||
opus_int silk_InitDecoder(
|
||||
void* decState /* I/O: State */
|
||||
)
|
||||
{
|
||||
SKP_int n, ret = SILK_NO_ERROR;
|
||||
opus_int n, ret = SILK_NO_ERROR;
|
||||
silk_decoder_state *channel_state = ((silk_decoder *)decState)->channel_state;
|
||||
|
||||
for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) {
|
||||
|
@ -70,22 +70,22 @@ SKP_int silk_InitDecoder(
|
|||
}
|
||||
|
||||
/* Decode a frame */
|
||||
SKP_int silk_Decode(
|
||||
opus_int silk_Decode(
|
||||
void* decState, /* I/O: State */
|
||||
silk_DecControlStruct* decControl, /* I/O: Control Structure */
|
||||
SKP_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode FEC */
|
||||
SKP_int newPacketFlag, /* I: Indicates first decoder call for this packet */
|
||||
opus_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode FEC */
|
||||
opus_int newPacketFlag, /* I: Indicates first decoder call for this packet */
|
||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||
SKP_int16 *samplesOut, /* O: Decoded output speech vector */
|
||||
SKP_int32 *nSamplesOut /* O: Number of samples decoded */
|
||||
opus_int16 *samplesOut, /* O: Decoded output speech vector */
|
||||
opus_int32 *nSamplesOut /* O: Number of samples decoded */
|
||||
)
|
||||
{
|
||||
SKP_int i, n, prev_fs_kHz, decode_only_middle = 0, ret = SILK_NO_ERROR;
|
||||
SKP_int32 nSamplesOutDec, LBRR_symbol;
|
||||
SKP_int16 samplesOut1_tmp[ 2 ][ MAX_FS_KHZ * MAX_FRAME_LENGTH_MS + 2 ];
|
||||
SKP_int16 samplesOut2_tmp[ MAX_API_FS_KHZ * MAX_FRAME_LENGTH_MS ];
|
||||
SKP_int MS_pred_Q13[ 2 ] = { 0 };
|
||||
SKP_int16 *resample_out_ptr;
|
||||
opus_int i, n, prev_fs_kHz, decode_only_middle = 0, ret = SILK_NO_ERROR;
|
||||
opus_int32 nSamplesOutDec, LBRR_symbol;
|
||||
opus_int16 samplesOut1_tmp[ 2 ][ MAX_FS_KHZ * MAX_FRAME_LENGTH_MS + 2 ];
|
||||
opus_int16 samplesOut2_tmp[ MAX_API_FS_KHZ * MAX_FRAME_LENGTH_MS ];
|
||||
opus_int MS_pred_Q13[ 2 ] = { 0 };
|
||||
opus_int16 *resample_out_ptr;
|
||||
silk_decoder *psDec = ( silk_decoder * )decState;
|
||||
silk_decoder_state *channel_state = psDec->channel_state;
|
||||
|
||||
|
@ -111,7 +111,7 @@ SKP_int silk_Decode(
|
|||
|
||||
for( n = 0; n < decControl->nChannelsInternal; n++ ) {
|
||||
if( channel_state[ n ].nFramesDecoded == 0 ) {
|
||||
SKP_int fs_kHz_dec;
|
||||
opus_int fs_kHz_dec;
|
||||
if( decControl->payloadSize_ms == 0 ) {
|
||||
/* Assuming packet loss, use 10 ms */
|
||||
channel_state[ n ].nFramesPerPacket = 1;
|
||||
|
@ -190,7 +190,7 @@ SKP_int silk_Decode(
|
|||
for( i = 0; i < channel_state[ 0 ].nFramesPerPacket; i++ ) {
|
||||
for( n = 0; n < decControl->nChannelsInternal; n++ ) {
|
||||
if( channel_state[ n ].LBRR_flags[ i ] ) {
|
||||
SKP_int pulses[ MAX_FRAME_LENGTH ];
|
||||
opus_int pulses[ MAX_FRAME_LENGTH ];
|
||||
if( decControl->nChannelsInternal == 2 && n == 0 ) {
|
||||
silk_stereo_decode_pred( psRangeDec, &decode_only_middle, MS_pred_Q13 );
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ SKP_int silk_Decode(
|
|||
if( n == 0 || decode_only_middle == 0 ) {
|
||||
ret += silk_decode_frame( &channel_state[ n ], psRangeDec, &samplesOut1_tmp[ n ][ 2 ], &nSamplesOutDec, lostFlag );
|
||||
} else {
|
||||
SKP_memset( &samplesOut1_tmp[ n ][ 2 ], 0, nSamplesOutDec * sizeof( SKP_int16 ) );
|
||||
SKP_memset( &samplesOut1_tmp[ n ][ 2 ], 0, nSamplesOutDec * sizeof( opus_int16 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,8 +228,8 @@ SKP_int silk_Decode(
|
|||
silk_stereo_MS_to_LR( &psDec->sStereo, samplesOut1_tmp[ 0 ], samplesOut1_tmp[ 1 ], MS_pred_Q13, channel_state[ 0 ].fs_kHz, nSamplesOutDec );
|
||||
} else {
|
||||
/* Buffering */
|
||||
SKP_memcpy( samplesOut1_tmp[ 0 ], psDec->sStereo.sMid, 2 * sizeof( SKP_int16 ) );
|
||||
SKP_memcpy( psDec->sStereo.sMid, &samplesOut1_tmp[ 0 ][ nSamplesOutDec ], 2 * sizeof( SKP_int16 ) );
|
||||
SKP_memcpy( samplesOut1_tmp[ 0 ], psDec->sStereo.sMid, 2 * sizeof( opus_int16 ) );
|
||||
SKP_memcpy( psDec->sStereo.sMid, &samplesOut1_tmp[ 0 ][ nSamplesOutDec ], 2 * sizeof( opus_int16 ) );
|
||||
}
|
||||
|
||||
/* Number of output samples */
|
||||
|
@ -265,14 +265,14 @@ SKP_int silk_Decode(
|
|||
}
|
||||
|
||||
/* Getting table of contents for a packet */
|
||||
SKP_int silk_get_TOC(
|
||||
const SKP_uint8 *payload, /* I Payload data */
|
||||
const SKP_int nBytesIn, /* I: Number of input bytes */
|
||||
const SKP_int nFramesPerPayload, /* I: Number of SILK frames per payload */
|
||||
opus_int silk_get_TOC(
|
||||
const opus_uint8 *payload, /* I Payload data */
|
||||
const opus_int nBytesIn, /* I: Number of input bytes */
|
||||
const opus_int nFramesPerPayload, /* I: Number of SILK frames per payload */
|
||||
silk_TOC_struct *Silk_TOC /* O: Type of content */
|
||||
)
|
||||
{
|
||||
SKP_int i, flags, ret = SILK_NO_ERROR;
|
||||
opus_int i, flags, ret = SILK_NO_ERROR;
|
||||
|
||||
if( nBytesIn < 1 ) {
|
||||
return -1;
|
||||
|
|
|
@ -33,17 +33,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
void silk_decode_core(
|
||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||
silk_decoder_control *psDecCtrl, /* I Decoder control */
|
||||
SKP_int16 xq[], /* O Decoded speech */
|
||||
const SKP_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */
|
||||
opus_int16 xq[], /* O Decoded speech */
|
||||
const opus_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */
|
||||
)
|
||||
{
|
||||
SKP_int i, j, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, signalType;
|
||||
SKP_int16 *A_Q12, *B_Q14, *pxq, A_Q12_tmp[ MAX_LPC_ORDER ];
|
||||
SKP_int16 sLTP[ MAX_FRAME_LENGTH ];
|
||||
SKP_int32 LTP_pred_Q14, LPC_pred_Q10, Gain_Q16, inv_gain_Q16, inv_gain_Q32, gain_adj_Q16, rand_seed, offset_Q10;
|
||||
SKP_int32 *pred_lag_ptr, *pexc_Q10, *pres_Q10;
|
||||
SKP_int32 res_Q10[ MAX_SUB_FRAME_LENGTH ];
|
||||
SKP_int32 vec_Q10[ MAX_SUB_FRAME_LENGTH ];
|
||||
opus_int i, j, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, signalType;
|
||||
opus_int16 *A_Q12, *B_Q14, *pxq, A_Q12_tmp[ MAX_LPC_ORDER ];
|
||||
opus_int16 sLTP[ MAX_FRAME_LENGTH ];
|
||||
opus_int32 LTP_pred_Q14, LPC_pred_Q10, Gain_Q16, inv_gain_Q16, inv_gain_Q32, gain_adj_Q16, rand_seed, offset_Q10;
|
||||
opus_int32 *pred_lag_ptr, *pexc_Q10, *pres_Q10;
|
||||
opus_int32 res_Q10[ MAX_SUB_FRAME_LENGTH ];
|
||||
opus_int32 vec_Q10[ MAX_SUB_FRAME_LENGTH ];
|
||||
|
||||
SKP_assert( psDec->prev_inv_gain_Q16 != 0 );
|
||||
|
||||
|
@ -59,7 +59,7 @@ void silk_decode_core(
|
|||
rand_seed = psDec->indices.Seed;
|
||||
for( i = 0; i < psDec->frame_length; i++ ) {
|
||||
rand_seed = SKP_RAND( rand_seed );
|
||||
psDec->exc_Q10[ i ] = SKP_LSHIFT( ( SKP_int32 )pulses[ i ], 10 );
|
||||
psDec->exc_Q10[ i ] = SKP_LSHIFT( ( opus_int32 )pulses[ i ], 10 );
|
||||
if( psDec->exc_Q10[ i ] > 0 ) {
|
||||
psDec->exc_Q10[ i ] -= QUANT_LEVEL_ADJUST_Q10;
|
||||
} else
|
||||
|
@ -73,7 +73,7 @@ void silk_decode_core(
|
|||
}
|
||||
|
||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
||||
DEBUG_STORE_DATA( dec_q.dat, pulses, psDec->frame_length * sizeof( SKP_int ) );
|
||||
DEBUG_STORE_DATA( dec_q.dat, pulses, psDec->frame_length * sizeof( opus_int ) );
|
||||
#endif
|
||||
|
||||
pexc_Q10 = psDec->exc_Q10;
|
||||
|
@ -85,7 +85,7 @@ void silk_decode_core(
|
|||
A_Q12 = psDecCtrl->PredCoef_Q12[ k >> 1 ];
|
||||
|
||||
/* Preload LPC coeficients to array on stack. Gives small performance gain */
|
||||
SKP_memcpy( A_Q12_tmp, A_Q12, psDec->LPC_order * sizeof( SKP_int16 ) );
|
||||
SKP_memcpy( A_Q12_tmp, A_Q12, psDec->LPC_order * sizeof( opus_int16 ) );
|
||||
B_Q14 = &psDecCtrl->LTPCoef_Q14[ k * LTP_ORDER ];
|
||||
Gain_Q16 = psDecCtrl->Gains_Q16[ k ];
|
||||
signalType = psDec->indices.signalType;
|
||||
|
@ -112,7 +112,7 @@ void silk_decode_core(
|
|||
if( psDec->lossCnt && psDec->prevSignalType == TYPE_VOICED &&
|
||||
psDec->indices.signalType != TYPE_VOICED && k < MAX_NB_SUBFR/2 ) {
|
||||
|
||||
SKP_memset( B_Q14, 0, LTP_ORDER * sizeof( SKP_int16 ) );
|
||||
SKP_memset( B_Q14, 0, LTP_ORDER * sizeof( opus_int16 ) );
|
||||
B_Q14[ LTP_ORDER/2 ] = SILK_FIX_CONST( 0.25, 14 );
|
||||
|
||||
signalType = TYPE_VOICED;
|
||||
|
@ -176,8 +176,8 @@ void silk_decode_core(
|
|||
}
|
||||
|
||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
||||
DEBUG_STORE_DATA( dec_exc_Q10.dat, pexc_Q10, psDec->subfr_length * sizeof( SKP_int32 ) );
|
||||
DEBUG_STORE_DATA( dec_res_Q10.dat, pres_Q10, psDec->subfr_length * sizeof( SKP_int32 ) );
|
||||
DEBUG_STORE_DATA( dec_exc_Q10.dat, pexc_Q10, psDec->subfr_length * sizeof( opus_int32 ) );
|
||||
DEBUG_STORE_DATA( dec_res_Q10.dat, pres_Q10, psDec->subfr_length * sizeof( opus_int32 ) );
|
||||
#endif
|
||||
|
||||
for( i = 0; i < psDec->subfr_length; i++ ) {
|
||||
|
@ -205,20 +205,20 @@ void silk_decode_core(
|
|||
|
||||
/* Scale with Gain */
|
||||
for( i = 0; i < psDec->subfr_length; i++ ) {
|
||||
pxq[ i ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( vec_Q10[ i ], Gain_Q16 ), 10 ) );
|
||||
pxq[ i ] = ( opus_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( vec_Q10[ i ], Gain_Q16 ), 10 ) );
|
||||
}
|
||||
|
||||
/* Update LPC filter state */
|
||||
SKP_memcpy( psDec->sLPC_Q14, &psDec->sLPC_Q14[ psDec->subfr_length ], MAX_LPC_ORDER * sizeof( SKP_int32 ) );
|
||||
SKP_memcpy( psDec->sLPC_Q14, &psDec->sLPC_Q14[ psDec->subfr_length ], MAX_LPC_ORDER * sizeof( opus_int32 ) );
|
||||
pexc_Q10 += psDec->subfr_length;
|
||||
pxq += psDec->subfr_length;
|
||||
}
|
||||
|
||||
/* Copy to output */
|
||||
SKP_memcpy( xq, &psDec->outBuf[ psDec->ltp_mem_length ], psDec->frame_length * sizeof( SKP_int16 ) );
|
||||
SKP_memcpy( xq, &psDec->outBuf[ psDec->ltp_mem_length ], psDec->frame_length * sizeof( opus_int16 ) );
|
||||
|
||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
||||
DEBUG_STORE_DATA( dec_sLTP_Q16.dat, &psDec->sLTP_Q16[ psDec->ltp_mem_length ], psDec->frame_length * sizeof( SKP_int32 ));
|
||||
DEBUG_STORE_DATA( dec_xq.dat, xq, psDec->frame_length * sizeof( SKP_int16 ) );
|
||||
DEBUG_STORE_DATA( dec_sLTP_Q16.dat, &psDec->sLTP_Q16[ psDec->ltp_mem_length ], psDec->frame_length * sizeof( opus_int32 ));
|
||||
DEBUG_STORE_DATA( dec_xq.dat, xq, psDec->frame_length * sizeof( opus_int16 ) );
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -31,17 +31,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/****************/
|
||||
/* Decode frame */
|
||||
/****************/
|
||||
SKP_int silk_decode_frame(
|
||||
opus_int silk_decode_frame(
|
||||
silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */
|
||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||
SKP_int16 pOut[], /* O Pointer to output speech frame */
|
||||
SKP_int32 *pN, /* O Pointer to size of output frame */
|
||||
SKP_int lostFlag /* I 0: no loss, 1 loss, 2 decode fec */
|
||||
opus_int16 pOut[], /* O Pointer to output speech frame */
|
||||
opus_int32 *pN, /* O Pointer to size of output frame */
|
||||
opus_int lostFlag /* I 0: no loss, 1 loss, 2 decode fec */
|
||||
)
|
||||
{
|
||||
silk_decoder_control sDecCtrl;
|
||||
SKP_int L, mv_len, ret = 0;
|
||||
SKP_int pulses[ MAX_FRAME_LENGTH ];
|
||||
opus_int L, mv_len, ret = 0;
|
||||
opus_int pulses[ MAX_FRAME_LENGTH ];
|
||||
|
||||
TIC(DECODE_FRAME)
|
||||
|
||||
|
@ -107,8 +107,8 @@ TOC(decode_core)
|
|||
/*************************/
|
||||
SKP_assert( psDec->ltp_mem_length >= psDec->frame_length );
|
||||
mv_len = psDec->ltp_mem_length - psDec->frame_length;
|
||||
SKP_memmove( psDec->outBuf, &psDec->outBuf[ psDec->frame_length ], mv_len * sizeof(SKP_int16) );
|
||||
SKP_memcpy( &psDec->outBuf[ mv_len ], pOut, psDec->frame_length * sizeof( SKP_int16 ) );
|
||||
SKP_memmove( psDec->outBuf, &psDec->outBuf[ psDec->frame_length ], mv_len * sizeof(opus_int16) );
|
||||
SKP_memcpy( &psDec->outBuf[ mv_len ], pOut, psDec->frame_length * sizeof( opus_int16 ) );
|
||||
|
||||
/****************************************************************/
|
||||
/* Ensure smooth connection of extrapolated and good frames */
|
||||
|
|
|
@ -31,14 +31,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
void silk_decode_indices(
|
||||
silk_decoder_state *psDec, /* I/O State */
|
||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||
SKP_int FrameIndex, /* I Frame number */
|
||||
SKP_int decode_LBRR /* I Flag indicating LBRR data is being decoded */
|
||||
opus_int FrameIndex, /* I Frame number */
|
||||
opus_int decode_LBRR /* I Flag indicating LBRR data is being decoded */
|
||||
)
|
||||
{
|
||||
SKP_int i, k, Ix, condCoding;
|
||||
SKP_int decode_absolute_lagIndex, delta_lagIndex;
|
||||
SKP_int16 ec_ix[ MAX_LPC_ORDER ];
|
||||
SKP_uint8 pred_Q8[ MAX_LPC_ORDER ];
|
||||
opus_int i, k, Ix, condCoding;
|
||||
opus_int decode_absolute_lagIndex, delta_lagIndex;
|
||||
opus_int16 ec_ix[ MAX_LPC_ORDER ];
|
||||
opus_uint8 pred_Q8[ MAX_LPC_ORDER ];
|
||||
|
||||
/* Use conditional coding if previous frame available */
|
||||
if( FrameIndex > 0 && ( decode_LBRR == 0 || psDec->LBRR_flags[ FrameIndex - 1 ] == 1 ) ) {
|
||||
|
@ -55,8 +55,8 @@ void silk_decode_indices(
|
|||
} else {
|
||||
Ix = ec_dec_icdf( psRangeDec, silk_type_offset_no_VAD_iCDF, 8 );
|
||||
}
|
||||
psDec->indices.signalType = (SKP_int8)SKP_RSHIFT( Ix, 1 );
|
||||
psDec->indices.quantOffsetType = (SKP_int8)( Ix & 1 );
|
||||
psDec->indices.signalType = (opus_int8)SKP_RSHIFT( Ix, 1 );
|
||||
psDec->indices.quantOffsetType = (opus_int8)( Ix & 1 );
|
||||
|
||||
/****************/
|
||||
/* Decode gains */
|
||||
|
@ -64,22 +64,22 @@ void silk_decode_indices(
|
|||
/* First subframe */
|
||||
if( condCoding ) {
|
||||
/* Conditional coding */
|
||||
psDec->indices.GainsIndices[ 0 ] = (SKP_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 );
|
||||
psDec->indices.GainsIndices[ 0 ] = (opus_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 );
|
||||
} else {
|
||||
/* Independent coding, in two stages: MSB bits followed by 3 LSBs */
|
||||
psDec->indices.GainsIndices[ 0 ] = (SKP_int8)SKP_LSHIFT( ec_dec_icdf( psRangeDec, silk_gain_iCDF[ psDec->indices.signalType ], 8 ), 3 );
|
||||
psDec->indices.GainsIndices[ 0 ] += (SKP_int8)ec_dec_icdf( psRangeDec, silk_uniform8_iCDF, 8 );
|
||||
psDec->indices.GainsIndices[ 0 ] = (opus_int8)SKP_LSHIFT( ec_dec_icdf( psRangeDec, silk_gain_iCDF[ psDec->indices.signalType ], 8 ), 3 );
|
||||
psDec->indices.GainsIndices[ 0 ] += (opus_int8)ec_dec_icdf( psRangeDec, silk_uniform8_iCDF, 8 );
|
||||
}
|
||||
|
||||
/* Remaining subframes */
|
||||
for( i = 1; i < psDec->nb_subfr; i++ ) {
|
||||
psDec->indices.GainsIndices[ i ] = (SKP_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 );
|
||||
psDec->indices.GainsIndices[ i ] = (opus_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 );
|
||||
}
|
||||
|
||||
/**********************/
|
||||
/* Decode LSF Indices */
|
||||
/**********************/
|
||||
psDec->indices.NLSFIndices[ 0 ] = (SKP_int8)ec_dec_icdf( psRangeDec, &psDec->psNLSF_CB->CB1_iCDF[ ( psDec->indices.signalType >> 1 ) * psDec->psNLSF_CB->nVectors ], 8 );
|
||||
psDec->indices.NLSFIndices[ 0 ] = (opus_int8)ec_dec_icdf( psRangeDec, &psDec->psNLSF_CB->CB1_iCDF[ ( psDec->indices.signalType >> 1 ) * psDec->psNLSF_CB->nVectors ], 8 );
|
||||
silk_NLSF_unpack( ec_ix, pred_Q8, psDec->psNLSF_CB, psDec->indices.NLSFIndices[ 0 ] );
|
||||
SKP_assert( psDec->psNLSF_CB->order == psDec->LPC_order );
|
||||
for( i = 0; i < psDec->psNLSF_CB->order; i++ ) {
|
||||
|
@ -89,12 +89,12 @@ void silk_decode_indices(
|
|||
} else if( Ix == 2 * NLSF_QUANT_MAX_AMPLITUDE ) {
|
||||
Ix += ec_dec_icdf( psRangeDec, silk_NLSF_EXT_iCDF, 8 );
|
||||
}
|
||||
psDec->indices.NLSFIndices[ i+1 ] = (SKP_int8)( Ix - NLSF_QUANT_MAX_AMPLITUDE );
|
||||
psDec->indices.NLSFIndices[ i+1 ] = (opus_int8)( Ix - NLSF_QUANT_MAX_AMPLITUDE );
|
||||
}
|
||||
|
||||
/* Decode LSF interpolation factor */
|
||||
if( psDec->nb_subfr == MAX_NB_SUBFR ) {
|
||||
psDec->indices.NLSFInterpCoef_Q2 = (SKP_int8)ec_dec_icdf( psRangeDec, silk_NLSF_interpolation_factor_iCDF, 8 );
|
||||
psDec->indices.NLSFInterpCoef_Q2 = (opus_int8)ec_dec_icdf( psRangeDec, silk_NLSF_interpolation_factor_iCDF, 8 );
|
||||
} else {
|
||||
psDec->indices.NLSFInterpCoef_Q2 = 4;
|
||||
}
|
||||
|
@ -108,38 +108,38 @@ void silk_decode_indices(
|
|||
decode_absolute_lagIndex = 1;
|
||||
if( condCoding && psDec->ec_prevSignalType == TYPE_VOICED ) {
|
||||
/* Decode Delta index */
|
||||
delta_lagIndex = (SKP_int16)ec_dec_icdf( psRangeDec, silk_pitch_delta_iCDF, 8 );
|
||||
delta_lagIndex = (opus_int16)ec_dec_icdf( psRangeDec, silk_pitch_delta_iCDF, 8 );
|
||||
if( delta_lagIndex > 0 ) {
|
||||
delta_lagIndex = delta_lagIndex - 9;
|
||||
psDec->indices.lagIndex = (SKP_int16)( psDec->ec_prevLagIndex + delta_lagIndex );
|
||||
psDec->indices.lagIndex = (opus_int16)( psDec->ec_prevLagIndex + delta_lagIndex );
|
||||
decode_absolute_lagIndex = 0;
|
||||
}
|
||||
}
|
||||
if( decode_absolute_lagIndex ) {
|
||||
/* Absolute decoding */
|
||||
psDec->indices.lagIndex = (SKP_int16)ec_dec_icdf( psRangeDec, silk_pitch_lag_iCDF, 8 ) * SKP_RSHIFT( psDec->fs_kHz, 1 );
|
||||
psDec->indices.lagIndex += (SKP_int16)ec_dec_icdf( psRangeDec, psDec->pitch_lag_low_bits_iCDF, 8 );
|
||||
psDec->indices.lagIndex = (opus_int16)ec_dec_icdf( psRangeDec, silk_pitch_lag_iCDF, 8 ) * SKP_RSHIFT( psDec->fs_kHz, 1 );
|
||||
psDec->indices.lagIndex += (opus_int16)ec_dec_icdf( psRangeDec, psDec->pitch_lag_low_bits_iCDF, 8 );
|
||||
}
|
||||
psDec->ec_prevLagIndex = psDec->indices.lagIndex;
|
||||
|
||||
/* Get countour index */
|
||||
psDec->indices.contourIndex = (SKP_int8)ec_dec_icdf( psRangeDec, psDec->pitch_contour_iCDF, 8 );
|
||||
psDec->indices.contourIndex = (opus_int8)ec_dec_icdf( psRangeDec, psDec->pitch_contour_iCDF, 8 );
|
||||
|
||||
/********************/
|
||||
/* Decode LTP gains */
|
||||
/********************/
|
||||
/* Decode PERIndex value */
|
||||
psDec->indices.PERIndex = (SKP_int8)ec_dec_icdf( psRangeDec, silk_LTP_per_index_iCDF, 8 );
|
||||
psDec->indices.PERIndex = (opus_int8)ec_dec_icdf( psRangeDec, silk_LTP_per_index_iCDF, 8 );
|
||||
|
||||
for( k = 0; k < psDec->nb_subfr; k++ ) {
|
||||
psDec->indices.LTPIndex[ k ] = (SKP_int8)ec_dec_icdf( psRangeDec, silk_LTP_gain_iCDF_ptrs[ psDec->indices.PERIndex ], 8 );
|
||||
psDec->indices.LTPIndex[ k ] = (opus_int8)ec_dec_icdf( psRangeDec, silk_LTP_gain_iCDF_ptrs[ psDec->indices.PERIndex ], 8 );
|
||||
}
|
||||
|
||||
/**********************/
|
||||
/* Decode LTP scaling */
|
||||
/**********************/
|
||||
if( !condCoding ) {
|
||||
psDec->indices.LTP_scaleIndex = (SKP_int8)ec_dec_icdf( psRangeDec, silk_LTPscale_iCDF, 8 );
|
||||
psDec->indices.LTP_scaleIndex = (opus_int8)ec_dec_icdf( psRangeDec, silk_LTPscale_iCDF, 8 );
|
||||
} else {
|
||||
psDec->indices.LTP_scaleIndex = 0;
|
||||
}
|
||||
|
@ -149,5 +149,5 @@ void silk_decode_indices(
|
|||
/***************/
|
||||
/* Decode seed */
|
||||
/***************/
|
||||
psDec->indices.Seed = (SKP_int8)ec_dec_icdf( psRangeDec, silk_uniform4_iCDF, 8 );
|
||||
psDec->indices.Seed = (opus_int8)ec_dec_icdf( psRangeDec, silk_uniform4_iCDF, 8 );
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ void silk_decode_parameters(
|
|||
silk_decoder_control *psDecCtrl /* I/O Decoder control */
|
||||
)
|
||||
{
|
||||
SKP_int i, k, Ix;
|
||||
SKP_int16 pNLSF_Q15[ MAX_LPC_ORDER ], pNLSF0_Q15[ MAX_LPC_ORDER ];
|
||||
const SKP_int8 *cbk_ptr_Q7;
|
||||
opus_int i, k, Ix;
|
||||
opus_int16 pNLSF_Q15[ MAX_LPC_ORDER ], pNLSF0_Q15[ MAX_LPC_ORDER ];
|
||||
const opus_int8 *cbk_ptr_Q7;
|
||||
|
||||
/* Dequant Gains */
|
||||
silk_gains_dequant( psDecCtrl->Gains_Q16, psDec->indices.GainsIndices,
|
||||
|
@ -68,10 +68,10 @@ void silk_decode_parameters(
|
|||
} else {
|
||||
/* Copy LPC coefficients for first half from second half */
|
||||
SKP_memcpy( psDecCtrl->PredCoef_Q12[ 0 ], psDecCtrl->PredCoef_Q12[ 1 ],
|
||||
psDec->LPC_order * sizeof( SKP_int16 ) );
|
||||
psDec->LPC_order * sizeof( opus_int16 ) );
|
||||
}
|
||||
|
||||
SKP_memcpy( psDec->prevNLSF_Q15, pNLSF_Q15, psDec->LPC_order * sizeof( SKP_int16 ) );
|
||||
SKP_memcpy( psDec->prevNLSF_Q15, pNLSF_Q15, psDec->LPC_order * sizeof( opus_int16 ) );
|
||||
|
||||
/* After a packet loss do BWE of LPC coefs */
|
||||
if( psDec->lossCnt ) {
|
||||
|
@ -103,8 +103,8 @@ void silk_decode_parameters(
|
|||
Ix = psDec->indices.LTP_scaleIndex;
|
||||
psDecCtrl->LTP_scale_Q14 = silk_LTPScales_table_Q14[ Ix ];
|
||||
} else {
|
||||
SKP_memset( psDecCtrl->pitchL, 0, psDec->nb_subfr * sizeof( SKP_int ) );
|
||||
SKP_memset( psDecCtrl->LTPCoef_Q14, 0, LTP_ORDER * psDec->nb_subfr * sizeof( SKP_int16 ) );
|
||||
SKP_memset( psDecCtrl->pitchL, 0, psDec->nb_subfr * sizeof( opus_int ) );
|
||||
SKP_memset( psDecCtrl->LTPCoef_Q14, 0, LTP_ORDER * psDec->nb_subfr * sizeof( opus_int16 ) );
|
||||
psDec->indices.PERIndex = 0;
|
||||
psDecCtrl->LTP_scale_Q14 = 0;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue