#define QPoly 16
#define MAX_ITERATIONS_A2NLSF_FIX 30
-/* Flag for using 2x as many cosine sampling points, reduces the risk of missing a root */
-#define OVERSAMPLE_COSINE_TABLE 0
-
/* Helper function for A2NLSF(..) */
/* Transforms polynomials from cos(n*f) to cos(f)^n */
static inline void silk_A2NLSF_trans_poly(
- opus_int32 *p, /* I/O Polynomial */
- const opus_int dd /* I Polynomial order (= filter order / 2 ) */
+ opus_int32 *p, /* I/O Polynomial */
+ const opus_int dd /* I Polynomial order (= filter order / 2 ) */
)
{
opus_int k, n;
p[ k - 2 ] -= silk_LSHIFT( p[ k ], 1 );
}
}
-/* Helper function for A2NLSF(..) */
-/* Polynomial evaluation */
-static 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 */
+/* Helper function for A2NLSF(..) */
+/* Polynomial evaluation */
+static 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 */
)
{
opus_int n;
opus_int32 x_Q16, y32;
- y32 = p[ dd ]; /* QPoly */
+ y32 = p[ dd ]; /* QPoly */
x_Q16 = silk_LSHIFT( x, 4 );
for( n = dd - 1; n >= 0; n-- ) {
- y32 = silk_SMLAWW( p[ n ], y32, x_Q16 ); /* QPoly */
+ y32 = silk_SMLAWW( p[ n ], y32, x_Q16 ); /* QPoly */
}
return y32;
}
silk_A2NLSF_trans_poly( Q, dd );
}
-/* 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. */
+/* 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(
- 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) */
+ opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies in 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) */
)
{
opus_int i, k, m, dd, root_ix, ffrac;
silk_A2NLSF_init( a_Q16, P, Q, dd );
/* Find roots, alternating between P and Q */
- p = P; /* Pointer to polynomial */
+ p = P; /* Pointer to polynomial */
xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; /* Q12*/
ylo = silk_A2NLSF_eval_poly( p, xlo, dd );
thr = 0;
while( 1 ) {
/* Evaluate polynomial */
-#if OVERSAMPLE_COSINE_TABLE
- xhi = silk_LSFCosTab_FIX_Q12[ k >> 1 ] +
- ( ( silk_LSFCosTab_FIX_Q12[ ( k + 1 ) >> 1 ] -
- silk_LSFCosTab_FIX_Q12[ k >> 1 ] ) >> 1 ); /* Q12 */
-#else
xhi = silk_LSFCosTab_FIX_Q12[ k ]; /* Q12 */
-#endif
yhi = silk_A2NLSF_eval_poly( p, xhi, dd );
/* Detect zero crossing */
thr = 0;
}
/* Binary division */
-#if OVERSAMPLE_COSINE_TABLE
- ffrac = -128;
-#else
ffrac = -256;
-#endif
for( m = 0; m < BIN_DIV_STEPS_A2NLSF_FIX; m++ ) {
/* Evaluate polynomial */
xmid = silk_RSHIFT_ROUND( xlo + xhi, 1 );
/* Increase frequency */
xlo = xmid;
ylo = ymid;
-#if OVERSAMPLE_COSINE_TABLE
- ffrac = silk_ADD_RSHIFT( ffrac, 64, m );
-#else
ffrac = silk_ADD_RSHIFT( ffrac, 128, m );
-#endif
}
}
/* No risk of dividing by zero because abs(ylo - yhi) >= abs(ylo) >= 65536 */
ffrac += silk_DIV32( ylo, silk_RSHIFT( ylo - yhi, 8 - BIN_DIV_STEPS_A2NLSF_FIX ) );
}
-#if OVERSAMPLE_COSINE_TABLE
- NLSF[ root_ix ] = (opus_int16)silk_min_32( silk_LSHIFT( (opus_int32)k, 7 ) + ffrac, silk_int16_MAX );
-#else
NLSF[ root_ix ] = (opus_int16)silk_min_32( silk_LSHIFT( (opus_int32)k, 8 ) + ffrac, silk_int16_MAX );
-#endif
silk_assert( NLSF[ root_ix ] >= 0 );
p = PQ[ root_ix & 1 ];
/* Evaluate polynomial */
-#if OVERSAMPLE_COSINE_TABLE
- xlo = silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] +
- ( ( silk_LSFCosTab_FIX_Q12[ k >> 1 ] -
- silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] ) >> 1 ); /* Q12*/
-#else
xlo = silk_LSFCosTab_FIX_Q12[ k - 1 ]; /* Q12*/
-#endif
ylo = silk_LSHIFT( 1 - ( root_ix & 2 ), 12 );
} else {
/* Increment loop counter */
ylo = yhi;
thr = 0;
-#if OVERSAMPLE_COSINE_TABLE
- if( k > 2 * LSF_COS_TAB_SZ_FIX ) {
-#else
if( k > LSF_COS_TAB_SZ_FIX ) {
-#endif
i++;
if( i > MAX_ITERATIONS_A2NLSF_FIX ) {
/* Set NLSFs to white spectrum and exit */
/* Struct for TOC (Table of Contents) */
typedef struct {
- 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 */
+ 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;
/****************************************/
/***********************************************/
/* Get size in bytes of the Silk encoder state */
/***********************************************/
-opus_int silk_Get_Encoder_Size( /* O: Returns error code */
- opus_int *encSizeBytes /* O: Number of bytes in SILK encoder state */
+opus_int silk_Get_Encoder_Size( /* O Returns error code */
+ opus_int *encSizeBytes /* O Number of bytes in SILK encoder state */
);
/*************************/
/* Init or reset encoder */
/*************************/
-opus_int silk_InitEncoder( /* O: Returns error code */
- void *encState, /* I/O: State */
- silk_EncControlStruct *encStatus /* O: Encoder Status */
+opus_int silk_InitEncoder( /* O Returns error code */
+ void *encState, /* I/O State */
+ silk_EncControlStruct *encStatus /* O Encoder Status */
);
/***************************************/
/* Read control structure from encoder */
/***************************************/
-opus_int silk_QueryEncoder( /* O: Returns error code */
- const void *encState, /* I: State */
- silk_EncControlStruct *encStatus /* O: Encoder Status */
+opus_int silk_QueryEncoder( /* O Returns error code */
+ const void *encState, /* I State */
+ silk_EncControlStruct *encStatus /* O Encoder Status */
);
/**************************/
/**************************/
/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */
/* encControl->payloadSize_ms is set to */
-opus_int silk_Encode( /* O: Returns error code */
- void *encState, /* I/O: State */
- silk_EncControlStruct *encControl, /* I: Control status */
- 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 */
- opus_int *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
- const opus_int prefillFlag /* I: Flag to indicate prefilling buffers no coding */
+opus_int silk_Encode( /* O Returns error code */
+ void *encState, /* I/O State */
+ silk_EncControlStruct *encControl, /* I Control status */
+ 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 */
+ opus_int *nBytesOut, /* I/O Number of bytes in payload (input: Max bytes) */
+ const opus_int prefillFlag /* I Flag to indicate prefilling buffers no coding */
);
/****************************************/
/***********************************************/
/* Get size in bytes of the Silk decoder state */
/***********************************************/
-opus_int silk_Get_Decoder_Size( /* O: Returns error code */
- opus_int *decSizeBytes /* O: Number of bytes in SILK decoder state */
+opus_int silk_Get_Decoder_Size( /* O Returns error code */
+ opus_int *decSizeBytes /* O Number of bytes in SILK decoder state */
);
/*************************/
/* Init or Reset decoder */
/*************************/
-opus_int silk_InitDecoder( /* O: Returns error code */
- void *decState /* I/O: State */
+opus_int silk_InitDecoder( /* O Returns error code */
+ void *decState /* I/O State */
);
/******************/
/* Decode a frame */
/******************/
-opus_int silk_Decode( /* O: Returns error code */
- void* decState, /* I/O: State */
- silk_DecControlStruct* decControl, /* I/O: Control Structure */
- 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 */
- opus_int16 *samplesOut, /* O: Decoded output speech vector */
- opus_int32 *nSamplesOut /* O: Number of samples decoded */
+opus_int silk_Decode( /* O Returns error code */
+ void* decState, /* I/O State */
+ silk_DecControlStruct* decControl, /* I/O Control Structure */
+ 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 */
+ opus_int16 *samplesOut, /* O Decoded output speech vector */
+ opus_int32 *nSamplesOut /* O Number of samples decoded */
);
/**************************************/
/* Get table of contents for a packet */
/**************************************/
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 */
+ 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 */
);
#ifdef __cplusplus
}
void silk_CNG_Reset(
- silk_decoder_state *psDec /* I/O Decoder state */
+ silk_decoder_state *psDec /* I/O Decoder state */
)
{
opus_int i, NLSF_step_Q15, NLSF_acc_Q15;
/* Updates CNG estimate, and applies the CNG when packet was lost */
void silk_CNG(
- silk_decoder_state *psDec, /* I/O Decoder state */
- silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- opus_int16 frame[], /* I/O Signal data */
- opus_int length /* I Length of residual */
+ silk_decoder_state *psDec, /* I/O Decoder state */
+ silk_decoder_control *psDecCtrl, /* I/O Decoder control */
+ opus_int16 frame[], /* I/O Signal */
+ opus_int length /* I Length of residual */
)
{
opus_int i, j, subfr;
/* 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 */
+ silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */
)
{
opus_int quality_Q15;
#endif
/* count leading zeros of opus_int64 */
-static inline opus_int32 silk_CLZ64(opus_int64 in)
+static inline opus_int32 silk_CLZ64( opus_int64 in )
{
opus_int32 in_upper;
}
/* get number of leading zeros and fractional part (the bits right after the leading one */
-static 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 */
+static 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 */
+)
{
opus_int32 lzeros = silk_CLZ32(in);
/* Approximation of square root */
/* Accuracy: < +/- 10% for output values > 15 */
/* < +/- 2.5% for output values > 120 */
-static inline opus_int32 silk_SQRT_APPROX(opus_int32 x)
+static inline opus_int32 silk_SQRT_APPROX( opus_int32 x )
{
opus_int32 y, lz, frac_Q7;
}
/* Divide two int32 values and return result as int32 in a given Q-domain */
-static 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) */
+static 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) */
)
{
opus_int a_headrm, b_headrm, lshift;
/* Compute number of bits head room and normalize inputs */
a_headrm = silk_CLZ32( silk_abs(a32) ) - 1;
- a32_nrm = silk_LSHIFT(a32, a_headrm); /* Q: a_headrm */
+ a32_nrm = silk_LSHIFT(a32, a_headrm); /* Q: a_headrm */
b_headrm = silk_CLZ32( silk_abs(b32) ) - 1;
- b32_nrm = silk_LSHIFT(b32, b_headrm); /* Q: b_headrm */
+ b32_nrm = silk_LSHIFT(b32, b_headrm); /* Q: b_headrm */
/* Inverse of b32, with 14 bits of precision */
- b32_inv = silk_DIV32_16( silk_int32_MAX >> 2, silk_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */
+ b32_inv = silk_DIV32_16( silk_int32_MAX >> 2, silk_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */
/* First approximation */
- result = silk_SMULWB(a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */
+ result = silk_SMULWB(a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */
/* Compute residual by subtracting product of denominator and first approximation */
/* It's OK to overflow because the final value of a32_nrm should always be small */
- a32_nrm = silk_SUB32_ovflw(a32_nrm, silk_LSHIFT_ovflw( silk_SMMUL(b32_nrm, result), 3 )); /* Q: a_headrm */
+ a32_nrm = silk_SUB32_ovflw(a32_nrm, silk_LSHIFT_ovflw( silk_SMMUL(b32_nrm, result), 3 )); /* Q: a_headrm */
/* Refinement */
- result = silk_SMLAWB(result, a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */
+ result = silk_SMLAWB(result, a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */
/* Convert to Qres domain */
lshift = 29 + a_headrm - b_headrm - Qres;
}
/* Invert int32 value and return result as int32 in a given Q-domain */
-static 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) */
+static 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) */
)
{
opus_int b_headrm, lshift;
/* Compute number of bits head room and normalize input */
b_headrm = silk_CLZ32( silk_abs(b32) ) - 1;
- b32_nrm = silk_LSHIFT(b32, b_headrm); /* Q: b_headrm */
+ b32_nrm = silk_LSHIFT(b32, b_headrm); /* Q: b_headrm */
/* Inverse of b32, with 14 bits of precision */
- b32_inv = silk_DIV32_16( silk_int32_MAX >> 2, silk_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */
+ b32_inv = silk_DIV32_16( silk_int32_MAX >> 2, silk_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */
/* First approximation */
- result = silk_LSHIFT(b32_inv, 16); /* Q: 61 - b_headrm */
+ result = silk_LSHIFT(b32_inv, 16); /* Q: 61 - b_headrm */
/* Compute residual by subtracting product of denominator and first approximation from one */
- err_Q32 = silk_LSHIFT( (1<<29) - silk_SMULWB(b32_nrm, b32_inv), 3 ); /* Q32 */
+ err_Q32 = silk_LSHIFT( (1<<29) - silk_SMULWB(b32_nrm, b32_inv), 3 ); /* Q32 */
/* Refinement */
- result = silk_SMLAWW(result, err_Q32, b32_inv); /* Q: 61 - b_headrm */
+ result = silk_SMLAWW(result, err_Q32, b32_inv); /* Q: 61 - b_headrm */
/* Convert to Qres domain */
lshift = 61 - b_headrm - Qres;
/*******************************************/
void silk_LPC_analysis_filter(
- 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 */
+ 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 */
)
{
opus_int ix, j;
silk_assert( (d & 1) == 0 );
silk_assert( d <= len );
- for ( ix = d; ix < len; ix++) {
+ for( ix = d; ix < len; ix++ ) {
in_ptr = &in[ ix - 1 ];
- out32_Q12 = silk_SMULBB( in_ptr[ 0 ], B[ 0 ] );
+ out32_Q12 = silk_SMULBB( in_ptr[ 0 ], B[ 0 ] );
/* Allowing wrap around so that two wraps can cancel each other. The rare
cases where the result wraps around can only be triggered by invalid streams*/
out32_Q12 = silk_SMLABB_ovflw( out32_Q12, in_ptr[ -1 ], B[ 1 ] );
#include "SigProc_FIX.h"
-#define QA 24
-#define A_LIMIT SILK_FIX_CONST( 0.99975, QA )
+#define QA 24
+#define A_LIMIT SILK_FIX_CONST( 0.99975, QA )
-#define MUL32_FRAC_Q(a32, b32, Q) ((opus_int32)(silk_RSHIFT_ROUND64(silk_SMULL(a32, b32), Q)))
+#define MUL32_FRAC_Q(a32, b32, Q) ((opus_int32)(silk_RSHIFT_ROUND64(silk_SMULL(a32, b32), Q)))
/* Compute inverse of LPC prediction gain, and */
/* test if LPC coefficients are stable (all poles within unit circle) */
-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 opus_int order /* I: Prediction order */
+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 opus_int order /* I Prediction order */
)
{
opus_int k, n, mult2Q;
}
/* For input in Q12 domain */
-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 */
+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 */
)
{
opus_int k;
Anew_QA[ k ] = silk_LSHIFT( (opus_int32)A_Q12[ k ], QA - 12 );
}
/* If the DC is unstable, we don't even need to do the full calculations */
- if ( DC_resp >= 4096 ) {
+ if( DC_resp >= 4096 ) {
return 1;
}
return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order );
}
/* For input in Q24 domain */
-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 */
+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 */
)
{
opus_int k;
#endif
/*
-
Elliptic/Cauer filters designed with 0.1 dB passband ripple,
- 80 dB minimum stopband attenuation, and
- [0.95 : 0.15 : 0.35] normalized cut off frequencies.
-
+ 80 dB minimum stopband attenuation, and
+ [0.95 : 0.15 : 0.35] normalized cut off frequencies.
*/
+
#include "main.h"
/* Helper function, interpolates the filter taps */
/* Start by setting psEncC->mode <> 0; */
/* Deactivate by setting psEncC->mode = 0; */
void silk_LP_variable_cutoff(
- silk_LP_state *psLP, /* I/O LP filter state */
- opus_int16 *frame, /* I/O Low-pass filtered output */
- const opus_int frame_length /* I Frame length */
+ silk_LP_state *psLP, /* I/O LP filter state */
+ opus_int16 *frame, /* I/O Low-pass filtered output signal */
+ const opus_int frame_length /* I Frame length */
)
{
opus_int32 B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ], fac_Q16 = 0;
#if 0 && defined (_DEBUG) && !defined (silk_MACRO_COUNT)
-#undef silk_ADD16
+#undef silk_ADD16
static inline opus_int16 silk_ADD16(opus_int16 a, opus_int16 b){
opus_int16 ret;
return ret;
}
-#undef silk_ADD32
+#undef silk_ADD32
static inline opus_int32 silk_ADD32(opus_int32 a, opus_int32 b){
opus_int32 ret;
return ret;
}
-#undef silk_ADD64
+#undef silk_ADD64
static inline opus_int64 silk_ADD64(opus_int64 a, opus_int64 b){
opus_int64 ret;
return ret;
}
-#undef silk_SUB16
+#undef silk_SUB16
static inline opus_int16 silk_SUB16(opus_int16 a, opus_int16 b){
opus_int16 ret;
return ret;
}
-#undef silk_SUB32
+#undef silk_SUB32
static inline opus_int32 silk_SUB32(opus_int32 a, opus_int32 b){
opus_int32 ret;
return ret;
}
-#undef silk_SUB64
+#undef silk_SUB64
static inline opus_int64 silk_SUB64(opus_int64 a, opus_int64 b){
opus_int64 ret;
silk_assert((opus_uint64)ret == (opus_uint64)a32 * (opus_uint64)b32); /* Check output overflow */
return ret;
}
+
#undef silk_MLA
static inline opus_int32 silk_MLA(opus_int32 a32, opus_int32 b32, opus_int32 c32){
opus_int32 ret;
return ret;
}
-#undef silk_SMULWB
+#undef silk_SMULWB
static inline opus_int32 silk_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);
silk_assert((opus_int64)ret == ((opus_int64)a32 * (opus_int16)b32) >> 16);
return ret;
}
-#undef silk_SMLAWB
+
+#undef silk_SMLAWB
static inline opus_int32 silk_SMLAWB(opus_int32 a32, opus_int32 b32, opus_int32 c32){
opus_int32 ret;
ret = silk_ADD32( a32, silk_SMULWB( b32, c32 ) );
silk_assert((opus_int64)ret == ((opus_int64)a32 * (b32 >> 16)) >> 16);
return ret;
}
+
#undef silk_SMLAWT
static inline opus_int32 silk_SMLAWT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
opus_int32 ret;
}
/* no checking needed for silk_SMULBB */
-#undef silk_SMLABB
+#undef silk_SMLABB
static inline opus_int32 silk_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);
}
/* no checking needed for silk_SMULBT */
-#undef silk_SMLABT
+#undef silk_SMLABT
static inline opus_int32 silk_SMLABT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
opus_int32 ret;
ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16);
}
/* no checking needed for silk_SMULTT */
-#undef silk_SMLATT
+#undef silk_SMLATT
static inline opus_int32 silk_SMLATT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
opus_int32 ret;
ret = a32 + (b32 >> 16) * (c32 >> 16);
return ret;
}
-#undef silk_SMULWW
+#undef silk_SMULWW
static inline opus_int32 silk_SMULWW(opus_int32 a32, opus_int32 b32){
opus_int32 ret, tmp1, tmp2;
opus_int64 ret64;
return ret;
}
-#undef silk_SMLAWW
+#undef silk_SMLAWW
static inline opus_int32 silk_SMLAWW(opus_int32 a32, opus_int32 b32, opus_int32 c32){
opus_int32 ret, tmp;
}
/* Multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode) */
-#undef silk_MLA_ovflw
+#undef silk_MLA_ovflw
#define silk_MLA_ovflw(a32, b32, c32) ((a32) + ((b32) * (c32)))
-#undef silk_SMLABB_ovflw
+#undef silk_SMLABB_ovflw
#define silk_SMLABB_ovflw(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32)))
/* no checking needed for silk_SMULL
no checking needed for silk_ADD_POS_SAT16
no checking needed for silk_ADD_POS_SAT32
no checking needed for silk_ADD_POS_SAT64 */
-#undef silk_LSHIFT8
+
+#undef silk_LSHIFT8
static inline opus_int8 silk_LSHIFT8(opus_int8 a, opus_int32 shift){
opus_int8 ret;
ret = a << shift;
silk_assert((opus_int64)ret == ((opus_int64)a) << shift);
return ret;
}
-#undef silk_LSHIFT16
+
+#undef silk_LSHIFT16
static inline opus_int16 silk_LSHIFT16(opus_int16 a, opus_int32 shift){
opus_int16 ret;
ret = a << shift;
silk_assert((opus_int64)ret == ((opus_int64)a) << shift);
return ret;
}
-#undef silk_LSHIFT32
+
+#undef silk_LSHIFT32
static inline opus_int32 silk_LSHIFT32(opus_int32 a, opus_int32 shift){
opus_int32 ret;
ret = a << shift;
silk_assert((opus_int64)ret == ((opus_int64)a) << shift);
return ret;
}
-#undef silk_LSHIFT64
+
+#undef silk_LSHIFT64
static inline opus_int64 silk_LSHIFT64(opus_int64 a, opus_int shift){
silk_assert(shift >= 0);
silk_assert(shift < 64);
return a << shift;
}
-#undef silk_LSHIFT_ovflw
+#undef silk_LSHIFT_ovflw
static inline opus_int32 silk_LSHIFT_ovflw(opus_int32 a, opus_int32 shift){
silk_assert(shift >= 0); /* no check for overflow */
return a << shift;
}
-#undef silk_LSHIFT_uint
+#undef silk_LSHIFT_uint
static inline opus_uint32 silk_LSHIFT_uint(opus_uint32 a, opus_int32 shift){
opus_uint32 ret;
ret = a << shift;
return ret;
}
-#undef silk_RSHIFT8
+#undef silk_RSHIFT8
static inline opus_int8 silk_RSHIFT8(opus_int8 a, opus_int32 shift){
silk_assert(shift >= 0);
silk_assert(shift < 8);
return a >> shift;
}
-#undef silk_RSHIFT16
+
+#undef silk_RSHIFT16
static inline opus_int16 silk_RSHIFT16(opus_int16 a, opus_int32 shift){
silk_assert(shift >= 0);
silk_assert(shift < 16);
return a >> shift;
}
-#undef silk_RSHIFT32
+
+#undef silk_RSHIFT32
static inline opus_int32 silk_RSHIFT32(opus_int32 a, opus_int32 shift){
silk_assert(shift >= 0);
silk_assert(shift < 32);
return a >> shift;
}
-#undef silk_RSHIFT64
+
+#undef silk_RSHIFT64
static inline opus_int64 silk_RSHIFT64(opus_int64 a, opus_int64 shift){
silk_assert(shift >= 0);
silk_assert(shift <= 63);
return a >> shift;
}
-#undef silk_RSHIFT_uint
+#undef silk_RSHIFT_uint
static inline opus_uint32 silk_RSHIFT_uint(opus_uint32 a, opus_int32 shift){
silk_assert(shift >= 0);
silk_assert(shift <= 32);
return a >> shift;
}
-#undef silk_ADD_LSHIFT
+#undef silk_ADD_LSHIFT
static inline opus_int32 silk_ADD_LSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){
opus_int32 ret;
silk_assert(shift >= 0);
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
return ret; /* shift >= 0 */
}
-#undef silk_ADD_LSHIFT32
+
+#undef silk_ADD_LSHIFT32
static inline opus_int32 silk_ADD_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
opus_int32 ret;
silk_assert(shift >= 0);
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
return ret; /* shift >= 0 */
}
-#undef silk_ADD_LSHIFT_uint
+
+#undef silk_ADD_LSHIFT_uint
static inline opus_uint32 silk_ADD_LSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){
opus_uint32 ret;
silk_assert(shift >= 0);
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
return ret; /* shift >= 0 */
}
-#undef silk_ADD_RSHIFT
+
+#undef silk_ADD_RSHIFT
static inline opus_int32 silk_ADD_RSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){
opus_int32 ret;
silk_assert(shift >= 0);
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
return ret; /* shift > 0 */
}
-#undef silk_ADD_RSHIFT32
+
+#undef silk_ADD_RSHIFT32
static inline opus_int32 silk_ADD_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
opus_int32 ret;
silk_assert(shift >= 0);
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
return ret; /* shift > 0 */
}
-#undef silk_ADD_RSHIFT_uint
+
+#undef silk_ADD_RSHIFT_uint
static inline opus_uint32 silk_ADD_RSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){
opus_uint32 ret;
silk_assert(shift >= 0);
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
return ret; /* shift > 0 */
}
-#undef silk_SUB_LSHIFT32
+
+#undef silk_SUB_LSHIFT32
static inline opus_int32 silk_SUB_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
opus_int32 ret;
silk_assert(shift >= 0);
silk_assert((opus_int64)ret == (opus_int64)a - (((opus_int64)b) << shift));
return ret; /* shift >= 0 */
}
-#undef silk_SUB_RSHIFT32
+
+#undef silk_SUB_RSHIFT32
static inline opus_int32 silk_SUB_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
opus_int32 ret;
silk_assert(shift >= 0);
return ret; /* shift > 0 */
}
-#undef silk_RSHIFT_ROUND
+#undef silk_RSHIFT_ROUND
static inline opus_int32 silk_RSHIFT_ROUND(opus_int32 a, opus_int32 shift){
opus_int32 ret;
silk_assert(shift > 0); /* the marco definition can't handle a shift of zero */
return ret;
}
-#undef silk_RSHIFT_ROUND64
+#undef silk_RSHIFT_ROUND64
static inline opus_int64 silk_RSHIFT_ROUND64(opus_int64 a, opus_int32 shift){
opus_int64 ret;
silk_assert(shift > 0); /* the marco definition can't handle a shift of zero */
}
/* silk_abs is used on floats also, so doesn't work... */
-/*#undef silk_abs
+/*#undef silk_abs
static inline opus_int32 silk_abs(opus_int32 a){
silk_assert(a != 0x80000000);
return (((a) > 0) ? (a) : -(a)); // Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN
}*/
-#undef silk_abs_int64
+#undef silk_abs_int64
static inline opus_int64 silk_abs_int64(opus_int64 a){
silk_assert(a != 0x8000000000000000);
return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */
}
-#undef silk_abs_int32
+#undef silk_abs_int32
static inline opus_int32 silk_abs_int32(opus_int32 a){
silk_assert(a != 0x80000000);
return abs(a);
}
-#undef silk_CHECK_FIT8
+#undef silk_CHECK_FIT8
static inline opus_int8 silk_CHECK_FIT8( opus_int64 a ){
opus_int8 ret;
ret = (opus_int8)a;
return( ret );
}
-#undef silk_CHECK_FIT16
+#undef silk_CHECK_FIT16
static inline opus_int16 silk_CHECK_FIT16( opus_int64 a ){
opus_int16 ret;
ret = (opus_int16)a;
return( ret );
}
-#undef silk_CHECK_FIT32
+#undef silk_CHECK_FIT32
static inline opus_int32 silk_CHECK_FIT32( opus_int64 a ){
opus_int32 ret;
ret = (opus_int32)a;
/* compute whitening filter coefficients from normalized line spectral frequencies */
void silk_NLSF2A(
- 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) */
+ 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) */
)
{
/* This ordering was found to maximize quality. It improves numerical accuracy of
/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
void silk_NLSF_VQ(
- 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 */
+ 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 */
)
{
opus_int i, m;
/* Laroia low complexity NLSF weights */
void silk_NLSF_VQ_weights_laroia(
- 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) */
+ opus_int16 *pNLSFW_Q_OUT, /* O Pointer to input vector weights [D] */
+ const opus_int16 *pNLSF_Q15, /* I Pointer to input vector [D] */
+ const opus_int D /* I Input vector dimension (even) */
)
{
opus_int k;
/* NLSF vector decoder */
/***********************/
void silk_NLSF_decode(
- 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 */
+ 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 */
)
{
opus_int i;
#include "main.h"
/* Delayed-decision quantizer for NLSF residuals */
-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 */
+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 */
)
{
opus_int i, j, nStates, ind_tmp, ind_min_max, ind_max_min, in_Q10, res_Q10;
ind[ j ][ i ] += silk_RSHIFT( ind_sort[ j ], NLSF_QUANT_DEL_DEC_STATES_LOG2 );
}
} else { /* i == 0 */
- break;
+ break;
}
}
#include "main.h"
-#define STORE_LSF_DATA_FOR_TRAINING 0
-
/***********************/
/* NLSF vector encoder */
/***********************/
-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 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 */
+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 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 */
)
{
opus_int i, s, ind1, bestIndex, prob_Q8, bits_q7;
opus_int16 ec_ix[ MAX_LPC_ORDER ];
const opus_uint8 *pCB_element, *iCDF_ptr;
-#if STORE_LSF_DATA_FOR_TRAINING
- 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 ) );
- silk_memcpy(pNLSF_Q15_orig, pNLSF_Q15, sizeof( pNLSF_Q15_orig ));
-#endif
-
silk_assert( nSurvivors <= NLSF_VQ_MAX_SURVIVORS );
silk_assert( signalType >= 0 && signalType <= 2 );
silk_assert( NLSF_mu_Q20 <= 32767 && NLSF_mu_Q20 >= 0 );
/* Decode */
silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB );
-#if STORE_LSF_DATA_FOR_TRAINING
- {
- /* code for training the codebooks */
- 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 ] = silk_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( silk_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 ] = (opus_int16)silk_RSHIFT( silk_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 ] = (opus_int16)silk_RSHIFT( silk_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;
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- diff_Q15 = pNLSF_Q15_orig[ i ] - pNLSF_Q15[ i ];
- Dist_Q22_dec += ( ( (diff_Q15 >> 5) * (diff_Q15 >> 5) ) * pW_Q5[ i ] ) >> 3;
- }
- iCDF_ptr = &psNLSF_CB->CB1_iCDF[ ( signalType >> 1 ) * psNLSF_CB->nVectors ];
- if( ind1 == 0 ) {
- prob_Q8 = 256 - iCDF_ptr[ ind1 ];
- } else {
- prob_Q8 = iCDF_ptr[ ind1 - 1 ] - iCDF_ptr[ ind1 ];
- }
- Rate_Q7 = ( 8 << 7 ) - silk_lin2log( prob_Q8 );
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- Rate_Q7 += ((int)psNLSF_CB->ec_Rates_Q5[ ec_ix[ i ] + silk_LIMIT( NLSFIndices[ i + 1 ] + NLSF_QUANT_MAX_AMPLITUDE, 0, 2 * NLSF_QUANT_MAX_AMPLITUDE ) ] ) << 2;
- if( silk_abs( NLSFIndices[ i + 1 ] ) >= NLSF_QUANT_MAX_AMPLITUDE ) {
- Rate_Q7 += 128 << ( silk_abs( NLSFIndices[ i + 1 ] ) - NLSF_QUANT_MAX_AMPLITUDE );
- }
- }
- RD_dec_Q22 = Dist_Q22_dec + Rate_Q7 * NLSF_mu_Q20 >> 5;
- 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( opus_int8 ) );
-#endif
-
return RD_Q25[ 0 ];
}
/* NLSF stabilizer, for a single input data vector */
void silk_NLSF_stabilize(
- 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 */
+ opus_int16 *NLSF_Q15, /* I/O Unstable/stabilized normalized LSF vector in Q15 [L] */
+ const opus_int16 *NDeltaMin_Q15, /* I Min distance vector, NDeltaMin_Q15[L] must be >= 1 [L+1] */
+ const opus_int L /* I Number of NLSF parameters in the input vector */
)
{
opus_int i, I=0, k, loops;
/***************************************************/
/* Now check if the smallest distance non-negative */
/***************************************************/
- if (min_diff_Q15 >= 0) {
+ if( min_diff_Q15 >= 0 ) {
return;
}
/* Unpack predictor values and indices for entropy coding tables */
void silk_NLSF_unpack(
- 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 opus_int CB1_index /* I Index of vector in first LSF codebook */
+ 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 opus_int CB1_index /* I Index of vector in first LSF codebook */
)
{
opus_int i;
#include "main.h"
static inline void silk_nsq_scale_states(
- const silk_encoder_state *psEncC, /* I Encoder State */
- silk_nsq_state *NSQ, /* I/O NSQ state */
- 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 Pitch lag */
- const opus_int signal_type /* I Signal type */
+ const silk_encoder_state *psEncC, /* I Encoder State */
+ silk_nsq_state *NSQ, /* I/O NSQ state */
+ 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 Pitch lag */
+ const opus_int signal_type /* I Signal type */
);
static inline void silk_noise_shape_quantizer(
- silk_nsq_state *NSQ, /* I/O NSQ state */
- 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 */
+ silk_nsq_state *NSQ, /* I/O NSQ state */
+ 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 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 */
+ const silk_encoder_state *psEncC, /* I/O Encoder State */
+ silk_nsq_state *NSQ, /* I/O NSQ state */
+ SideInfoIndices *psIndices, /* I/O Quantization Indices */
+ 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 Short term prediction coefs */
+ const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
+ const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
+ const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
+ const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
+ const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
+ const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
+ const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
+ const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
+ const opus_int LTP_scale_Q14 /* I LTP state scaling */
)
{
opus_int k, lag, start_idx, LSF_interpolation_flag;
/* Save quantized speech and noise shaping signals */
silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) );
silk_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( opus_int16 ) );
- DEBUG_STORE_DATA( q.dat, &pulses[ -psEncC->frame_length ], psEncC->frame_length * sizeof( opus_int8 ) );
-#endif
}
/***********************************/
/* silk_noise_shape_quantizer */
/***********************************/
static inline void silk_noise_shape_quantizer(
- silk_nsq_state *NSQ, /* I/O NSQ state */
- 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 */
+ silk_nsq_state *NSQ, /* I/O NSQ state */
+ 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 */
)
{
opus_int i, j;
}
static inline void silk_nsq_scale_states(
- const silk_encoder_state *psEncC, /* I Encoder State */
- silk_nsq_state *NSQ, /* I/O NSQ state */
- 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 Pitch lag */
- const opus_int signal_type /* I Signal type */
+ const silk_encoder_state *psEncC, /* I Encoder State */
+ silk_nsq_state *NSQ, /* I/O NSQ state */
+ 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 Pitch lag */
+ const opus_int signal_type /* I Signal type */
)
{
opus_int i, lag;
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 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 */
- 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 */
- const opus_int signal_type, /* I Signal type */
- const opus_int decisionDelay /* I Decision delay */
+ 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 */
+ 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 */
+ const opus_int signal_type, /* I Signal type */
+ const opus_int decisionDelay /* I Decision delay */
);
/******************************************/
static 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 */
- 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 */
+ 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 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 */
+ const silk_encoder_state *psEncC, /* I/O Encoder State */
+ silk_nsq_state *NSQ, /* I/O NSQ state */
+ SideInfoIndices *psIndices, /* I/O Quantization Indices */
+ 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 Short term prediction coefs */
+ const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
+ const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
+ const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
+ const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
+ const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
+ const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
+ const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
+ const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
+ const opus_int LTP_scale_Q14 /* I LTP state scaling */
)
{
opus_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr;
/* Save quantized speech and noise shaping signals */
silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) );
silk_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( opus_int16 ) );
- DEBUG_STORE_DATA( q.dat, &pulses[ -psEncC->frame_length ], psEncC->frame_length * sizeof( opus_int8 ) );
-#endif
}
/******************************************/
/* Noise shape quantizer for one subframe */
/******************************************/
static inline void silk_noise_shape_quantizer_del_dec(
- silk_nsq_state *NSQ, /* I/O NSQ state */
+ silk_nsq_state *NSQ, /* I/O NSQ state */
NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
- 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 */
+ 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 */
)
{
opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx;
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 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 */
- 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 */
- const opus_int signal_type, /* I Signal type */
- const opus_int decisionDelay /* I Decision delay */
+ 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 */
+ 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 */
+ const opus_int signal_type, /* I Signal type */
+ const opus_int decisionDelay /* I Decision delay */
)
{
opus_int i, k, lag;
static const opus_int16 PLC_RAND_ATTENUATE_UV_Q15[NB_ATT] = { 32440, 29491 }; /* 0.99, 0.9 */
static inline void silk_PLC_update(
- silk_decoder_state *psDec, /* I/O Decoder state */
- silk_decoder_control *psDecCtrl /* I/O Decoder control */
+ silk_decoder_state *psDec, /* I/O Decoder state */
+ silk_decoder_control *psDecCtrl /* I/O Decoder control */
);
static inline void silk_PLC_conceal(
- silk_decoder_state *psDec, /* I/O Decoder state */
- silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- opus_int16 signal[] /* O LPC residual signal */
+ silk_decoder_state *psDec, /* I/O Decoder state */
+ silk_decoder_control *psDecCtrl, /* I/O Decoder control */
+ opus_int16 signal[] /* O LPC residual signal */
);
void silk_PLC_Reset(
- silk_decoder_state *psDec /* I/O Decoder state */
+ silk_decoder_state *psDec /* I/O Decoder state */
)
{
psDec->sPLC.pitchL_Q8 = silk_RSHIFT( psDec->frame_length, 1 );
}
void silk_PLC(
- silk_decoder_state *psDec, /* I Decoder state */
- silk_decoder_control *psDecCtrl, /* I Decoder control */
- opus_int16 frame[], /* O Concealed signal */
- opus_int lost /* I Loss flag */
+ silk_decoder_state *psDec, /* I/O Decoder state */
+ silk_decoder_control *psDecCtrl, /* I/O Decoder control */
+ opus_int16 frame[], /* I/O signal */
+ opus_int lost /* I Loss flag */
)
{
/* PLC control function */
/* Update state of PLC */
/**************************************************/
static inline void silk_PLC_update(
- silk_decoder_state *psDec, /* (I/O) Decoder state */
- silk_decoder_control *psDecCtrl /* (I/O) Decoder control */
+ silk_decoder_state *psDec, /* I/O Decoder state */
+ silk_decoder_control *psDecCtrl /* I/O Decoder control */
)
{
opus_int32 LTP_Gain_Q14, temp_LTP_Gain_Q14;
if( psDec->indices.signalType == TYPE_VOICED ) {
/* Find the parameters for the last subframe which contains a pitch pulse */
for( j = 0; j * psDec->subfr_length < psDecCtrl->pitchL[ psDec->nb_subfr - 1 ]; j++ ) {
- if( j == psDec->nb_subfr ){
+ if( j == psDec->nb_subfr ) {
break;
}
temp_LTP_Gain_Q14 = 0;
}
static inline void silk_PLC_conceal(
- silk_decoder_state *psDec, /* I/O Decoder state */
- silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- opus_int16 frame[] /* O concealed signal */
+ silk_decoder_state *psDec, /* I/O Decoder state */
+ silk_decoder_control *psDecCtrl, /* I/O Decoder control */
+ opus_int16 frame[] /* O LPC residual signal */
)
{
opus_int i, j, k;
/* Glues concealed frames with new good recieved frames */
void silk_PLC_glue_frames(
- silk_decoder_state *psDec, /* I/O decoder state */
- opus_int16 frame[], /* I/O signal */
- opus_int length /* I length of residual */
+ silk_decoder_state *psDec, /* I/O decoder state */
+ opus_int16 frame[], /* I/O signal */
+ opus_int length /* I length of signal */
)
{
opus_int i, energy_shift;
#include "main.h"
#define BWE_COEF 0.99
-#define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 in Q14 */
-#define V_PITCH_GAIN_START_MAX_Q14 15565 /* 0.95 in Q14 */
+#define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 in Q14 */
+#define V_PITCH_GAIN_START_MAX_Q14 15565 /* 0.95 in Q14 */
#define MAX_PITCH_LAG_MS 18
#define SA_THRES_Q8 50
#define USE_SINGLE_TAP 1
#define RAND_BUF_SIZE 128
-#define RAND_BUF_MASK (RAND_BUF_SIZE - 1)
-#define LOG2_INV_LPC_GAIN_HIGH_THRES 3 /* 2^3 = 8 dB LPC gain */
-#define LOG2_INV_LPC_GAIN_LOW_THRES 8 /* 2^8 = 24 dB LPC gain */
-#define PITCH_DRIFT_FAC_Q16 655 /* 0.01 in Q16 */
+#define RAND_BUF_MASK ( RAND_BUF_SIZE - 1 )
+#define LOG2_INV_LPC_GAIN_HIGH_THRES 3 /* 2^3 = 8 dB LPC gain */
+#define LOG2_INV_LPC_GAIN_LOW_THRES 8 /* 2^8 = 24 dB LPC gain */
+#define PITCH_DRIFT_FAC_Q16 655 /* 0.01 in Q16 */
void silk_PLC_Reset(
- silk_decoder_state *psDec /* I/O Decoder state */
+ silk_decoder_state *psDec /* I/O Decoder state */
);
void silk_PLC(
- silk_decoder_state *psDec, /* I/O Decoder state */
- silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- opus_int16 signal[], /* I/O signal */
- opus_int lost /* I Loss flag */
+ silk_decoder_state *psDec, /* I/O Decoder state */
+ silk_decoder_control *psDecCtrl, /* I/O Decoder control */
+ opus_int16 frame[], /* I/O signal */
+ opus_int lost /* I Loss flag */
);
void silk_PLC_glue_frames(
- silk_decoder_state *psDec, /* I/O decoder state */
- opus_int16 signal[], /* I/O signal */
- opus_int length /* I length of signal */
+ silk_decoder_state *psDec, /* I/O decoder state */
+ opus_int16 frame[], /* I/O signal */
+ opus_int length /* I length of signal */
);
#endif
/*#define silk_MACRO_COUNT */ /* Used to enable WMOPS counting */
-#define SILK_MAX_ORDER_LPC 16 /* max order of the LPC analysis in schur() and k2a() */
+#define SILK_MAX_ORDER_LPC 16 /* max order of the LPC analysis in schur() and k2a() */
-#include <stdlib.h> /* for abs() */
-#include <string.h> /* for memset(), memcpy(), memmove() */
+#include <stdlib.h> /* for abs() */
+#include <string.h> /* for memset(), memcpy(), memmove() */
#include "typedef.h"
#include "resampler_structs.h"
#include "macros.h"
* Initialize/reset the resampler state for a given pair of input/output sampling rates
*/
opus_int silk_resampler_init(
- silk_resampler_state_struct *S, /* I/O: Resampler state */
- opus_int32 Fs_Hz_in, /* I: Input sampling rate (Hz) */
- opus_int32 Fs_Hz_out /* I: Output sampling rate (Hz) */
+ silk_resampler_state_struct *S, /* I/O Resampler state */
+ opus_int32 Fs_Hz_in, /* I Input sampling rate (Hz) */
+ opus_int32 Fs_Hz_out /* I Output sampling rate (Hz) */
);
/*!
* Resampler: convert from one sampling rate to another
*/
opus_int silk_resampler(
- silk_resampler_state_struct *S, /* I/O: Resampler state */
- opus_int16 out[], /* O: Output signal */
- const opus_int16 in[], /* I: Input signal */
- opus_int32 inLen /* I: Number of input samples */
+ silk_resampler_state_struct *S, /* I/O Resampler state */
+ opus_int16 out[], /* O Output signal */
+ const opus_int16 in[], /* I Input signal */
+ opus_int32 inLen /* I Number of input samples */
);
/*!
* Downsample 2x, mediocre quality
*/
void silk_resampler_down2(
- 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 */
+ 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 */
);
/*!
* Downsample by a factor 2/3, low quality
*/
void silk_resampler_down2_3(
- 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 */
+ 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 */
);
/*!
* can handle (slowly) varying coefficients
*/
void silk_biquad_alt(
- 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) */
- opus_int stride /* I: Operate on interleaved signal if > 1 */
+ 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) */
+ opus_int stride /* I Operate on interleaved signal if > 1 */
);
/* Variable order MA prediction error filter. */
void silk_LPC_analysis_filter(
- 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 */
+ 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 */
);
/* Chirp (bandwidth expand) LP AR filter */
void silk_bwexpander(
- 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) */
+ 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(
- 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 */
+ 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) */
-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 */
+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 */
);
-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 */
+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 */
+/* Split signal in two decimated bands using first-order allpass filters */
void silk_ana_filt_bank_1(
- 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 */
+ 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 */
);
/********************************************************************/
/* SCALAR FUNCTIONS */
/********************************************************************/
-/* approximation of 128 * log2() (exact inverse of approx 2^() below) */
-/* convert input to a log scale */
-opus_int32 silk_lin2log(const opus_int32 inLin); /* I: input in linear scale */
+/* Approximation of 128 * log2() (exact inverse of approx 2^() below) */
+/* Convert input to a log scale */
+opus_int32 silk_lin2log(
+ const opus_int32 inLin /* I input in linear scale */
+);
/* Approximation of a sigmoid function */
-opus_int silk_sigm_Q15(opus_int in_Q5);
+opus_int silk_sigm_Q15(
+ opus_int in_Q5 /* I */
+);
-/* approximation of 2^() (exact inverse of approx log2() above) */
-/* convert input to a linear scale */
-opus_int32 silk_log2lin(const opus_int32 inLog_Q7); /* I: input on log scale */
+/* Approximation of 2^() (exact inverse of approx log2() above) */
+/* Convert input to a linear 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 */
-opus_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */
- const opus_int16 *vec, /* I Input vector [len] */
- const opus_int32 len /* I Length of input vector */
+opus_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(
- 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 */
+ 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. */
-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 */
+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 */
-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 */
+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(
- 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 */
+ 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(
- 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 */
+ 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. */
-/* Window types: */
-/* 1 -> sine window from 0 to pi/2 */
-/* 2 -> sine window from pi/2 to pi */
-/* every other sample of window is linearly interpolated, for speed */
+/* Apply sine window to signal vector. */
+/* Window types: */
+/* 1 -> sine window from 0 to pi/2 */
+/* 2 -> sine window from pi/2 to pi */
+/* every other sample of window is linearly interpolated, for speed */
void silk_apply_sine_window(
- 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 */
+ 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(
- 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 */
+ 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 */
-#define SILK_PE_MIN_COMPLEX 0
-#define SILK_PE_MID_COMPLEX 1
-#define SILK_PE_MAX_COMPLEX 2
-
void silk_decode_pitch(
- 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 */
-);
-
-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 */
+ 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 */
+);
+
+opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */
+ const opus_int16 *frame, /* 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(
- 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) */
+ opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies in 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(
- 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) */
+ 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(
- 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 */
+ 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(
- 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 */
+ 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(
- opus_int16 *a, /* I/O: Unsorted / Sorted vector */
- const opus_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(
- 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 */
+ opus_int16 *NLSF_Q15, /* I/O Unstable/stabilized normalized LSF vector in Q15 [L] */
+ const opus_int16 *NDeltaMin_Q15, /* I Min distance vector, 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(
- 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) */
+ opus_int16 *pNLSFW_Q_OUT, /* O Pointer to input vector weights [D] */
+ const opus_int16 *pNLSF_Q15, /* I Pointer to input vector [D] */
+ const opus_int D /* I Input vector dimension (even) */
);
/* Compute reflection coefficients from input signal */
void silk_burg_modified(
- 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 */
+ 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 (incl. 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(
- opus_int16 *data_out,
- const opus_int16 *data_in,
- opus_int32 gain_Q16, /* I: gain in Q16 */
- const opus_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(
- opus_int32 *data1, /* I/O: Q0/Q18 */
- opus_int32 gain_Q26, /* I: Q26 */
- opus_int dataSize /* I: length */
+ opus_int32 *data1, /* I/O Q0/Q18 */
+ opus_int32 gain_Q26, /* I Q26 */
+ opus_int dataSize /* I length */
);
/********************************************************************/
-/* INLINE ARM MATH */
+/* INLINE ARM MATH */
/********************************************************************/
-/* return sum(inVec1[i]*inVec2[i]) */
+/* return sum( inVec1[i] * inVec2[i] ) */
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 */
+ 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 */
);
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 */
+ 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 */
);
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 */
+ const opus_int16 *inVec1, /* I input vector 1 */
+ const opus_int16 *inVec2, /* I input vector 2 */
+ const opus_int len /* I vector lengths */
);
/********************************************************************/
opus_uint32 x = (opus_uint32) a32;
opus_uint32 r = (opus_uint32) rot;
opus_uint32 m = (opus_uint32) -rot;
- if (rot==0)
- return a32;
- else if(rot < 0)
+ if( rot == 0 ) {
+ return a32;
+ } else if( rot < 0 ) {
return (opus_int32) ((x << m) | (x >> (32 - m)));
- else
+ } else {
return (opus_int32) ((x << (32 - r)) | (x >> r));
+ }
}
/* Allocate opus_int16 alligned to 4-byte memory address */
#endif
/* Useful Macros that can be adjusted to other platforms */
-#define silk_memcpy(a, b, c) memcpy((a), (b), (c)) /* Dest, Src, ByteCount */
-#define silk_memset(a, b, c) memset((a), (b), (c)) /* Dest, value, ByteCount */
-#define silk_memmove(a, b, c) memmove((a), (b), (c)) /* Dest, Src, ByteCount */
-/* fixed point macros */
+#define silk_memcpy(a, b, c) memcpy((a), (b), (c)) /* Dest, Src, ByteCount */
+#define silk_memset(a, b, c) memset((a), (b), (c)) /* Dest, value, ByteCount */
+#define silk_memmove(a, b, c) memmove((a), (b), (c)) /* Dest, Src, ByteCount */
+
+/* Fixed point macros */
/* (a32 * b32) output have to be 32bit int */
#define silk_MUL(a32, b32) ((a32) * (b32))
(just standard two's complement implementation-specific behaviour) */
#define silk_SUB32_ovflw(a, b) ((opus_int32)((opus_uint32)(a) - (opus_uint32)(b)))
-/* a32 + (opus_int32)((opus_int16)(b32)) * (opus_int32)((opus_int16)(c32)) output have to be 32bit int */
-#define silk_SMLABB_ovflw(a32, b32, c32) (silk_ADD32_ovflw((a32) , ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32))))
-
-/* Multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode)*/
+/* Multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode) */
#define silk_MLA_ovflw(a32, b32, c32) silk_ADD32_ovflw((a32), (opus_uint32)(b32) * (opus_uint32)(c32))
-#ifndef silk_SMLABB_ovflw
-# define silk_SMLABB_ovflw(a32, b32, c32) silk_ADD32_ovflw((a32), (opus_int32)((opus_int16)(b32)) * (opus_int32)((opus_int16)(c32)))
-#endif
+#define silk_SMLABB_ovflw(a32, b32, c32) (silk_ADD32_ovflw((a32) , ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32))))
#define silk_DIV32_16(a32, b16) ((opus_int32)((a32) / (b16)))
#define silk_DIV32(a32, b32) ((opus_int32)((a32) / (b32)))
#define silk_SUB32(a, b) ((a) - (b))
#define silk_SUB64(a, b) ((a) - (b))
-#define silk_SAT8(a) ((a) > silk_int8_MAX ? silk_int8_MAX : \
- ((a) < silk_int8_MIN ? silk_int8_MIN : (a)))
-#define silk_SAT16(a) ((a) > silk_int16_MAX ? silk_int16_MAX : \
- ((a) < silk_int16_MIN ? silk_int16_MIN : (a)))
-#define silk_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : \
- ((a) < silk_int32_MIN ? silk_int32_MIN : (a)))
+#define silk_SAT8(a) ((a) > silk_int8_MAX ? silk_int8_MAX : \
+ ((a) < silk_int8_MIN ? silk_int8_MIN : (a)))
+#define silk_SAT16(a) ((a) > silk_int16_MAX ? silk_int16_MAX : \
+ ((a) < silk_int16_MIN ? silk_int16_MIN : (a)))
+#define silk_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : \
+ ((a) < silk_int32_MIN ? silk_int32_MIN : (a)))
#define silk_CHECK_FIT8(a) (a)
#define silk_CHECK_FIT16(a) (a)
#define silk_ADD_SAT16(a, b) (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a), (b) ) )
#define silk_ADD_SAT64(a, b) ((((a) + (b)) & 0x8000000000000000LL) == 0 ? \
- ((((a) & (b)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a)+(b)) : \
- ((((a) | (b)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a)+(b)) )
+ ((((a) & (b)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a)+(b)) : \
+ ((((a) | (b)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a)+(b)) )
#define silk_SUB_SAT16(a, b) (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a), (b) ) )
-#define silk_SUB_SAT64(a, b) ((((a)-(b)) & 0x8000000000000000LL) == 0 ? \
- (( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a)-(b)) : \
- ((((a)^0x8000000000000000LL) & (b) & 0x8000000000000000LL) ? silk_int64_MAX : (a)-(b)) )
+#define silk_SUB_SAT64(a, b) ((((a)-(b)) & 0x8000000000000000LL) == 0 ? \
+ (( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a)-(b)) : \
+ ((((a)^0x8000000000000000LL) & (b) & 0x8000000000000000LL) ? silk_int64_MAX : (a)-(b)) )
/* Saturation for positive input values */
#define silk_POS_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : (a))
#define silk_ADD_POS_SAT32(a, b) ((((a)+(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b)))
#define silk_ADD_POS_SAT64(a, b) ((((a)+(b)) & 0x8000000000000000LL) ? silk_int64_MAX : ((a)+(b)))
-#define silk_LSHIFT8(a, shift) ((opus_int8)((opus_uint8)(a)<<(shift))) /* shift >= 0, shift < 8 */
-#define silk_LSHIFT16(a, shift) ((opus_int16)((opus_uint16)(a)<<(shift))) /* shift >= 0, shift < 16 */
-#define silk_LSHIFT32(a, shift) ((opus_int32)((opus_uint32)(a)<<(shift))) /* shift >= 0, shift < 32 */
-#define silk_LSHIFT64(a, shift) ((opus_int64)((opus_uint64)(a)<<(shift))) /* shift >= 0, shift < 64 */
-#define silk_LSHIFT(a, shift) silk_LSHIFT32(a, shift) /* shift >= 0, shift < 32 */
+#define silk_LSHIFT8(a, shift) ((opus_int8)((opus_uint8)(a)<<(shift))) /* shift >= 0, shift < 8 */
+#define silk_LSHIFT16(a, shift) ((opus_int16)((opus_uint16)(a)<<(shift))) /* shift >= 0, shift < 16 */
+#define silk_LSHIFT32(a, shift) ((opus_int32)((opus_uint32)(a)<<(shift))) /* shift >= 0, shift < 32 */
+#define silk_LSHIFT64(a, shift) ((opus_int64)((opus_uint64)(a)<<(shift))) /* shift >= 0, shift < 64 */
+#define silk_LSHIFT(a, shift) silk_LSHIFT32(a, shift) /* shift >= 0, shift < 32 */
-#define silk_RSHIFT8(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 8 */
-#define silk_RSHIFT16(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 16 */
-#define silk_RSHIFT32(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 32 */
-#define silk_RSHIFT64(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 64 */
-#define silk_RSHIFT(a, shift) silk_RSHIFT32(a, shift) /* shift >= 0, shift < 32 */
+#define silk_RSHIFT8(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 8 */
+#define silk_RSHIFT16(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 16 */
+#define silk_RSHIFT32(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 32 */
+#define silk_RSHIFT64(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 64 */
+#define silk_RSHIFT(a, shift) silk_RSHIFT32(a, shift) /* shift >= 0, shift < 32 */
/* saturates before shifting */
-#define silk_LSHIFT_SAT16(a, shift) (silk_LSHIFT16( silk_LIMIT( (a), silk_RSHIFT16( silk_int16_MIN, (shift) ), \
- silk_RSHIFT16( silk_int16_MAX, (shift) ) ), (shift) ))
-#define silk_LSHIFT_SAT32(a, shift) (silk_LSHIFT32( silk_LIMIT( (a), silk_RSHIFT32( silk_int32_MIN, (shift) ), \
- silk_RSHIFT32( silk_int32_MAX, (shift) ) ), (shift) ))
-
-#define silk_LSHIFT_ovflw(a, shift) ((opus_int32)((opus_uint32)(a)<<(shift))) /* shift >= 0, allowed to overflow */
-#define silk_LSHIFT_uint(a, shift) ((a)<<(shift)) /* shift >= 0 */
-#define silk_RSHIFT_uint(a, shift) ((a)>>(shift)) /* shift >= 0 */
-
-#define silk_ADD_LSHIFT(a, b, shift) ((a) + silk_LSHIFT((b), (shift))) /* shift >= 0 */
-#define silk_ADD_LSHIFT32(a, b, shift) silk_ADD32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */
-#define silk_ADD_LSHIFT_uint(a, b, shift) ((a) + silk_LSHIFT_uint((b), (shift))) /* shift >= 0 */
-#define silk_ADD_RSHIFT(a, b, shift) ((a) + silk_RSHIFT((b), (shift))) /* shift >= 0 */
-#define silk_ADD_RSHIFT32(a, b, shift) silk_ADD32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */
-#define silk_ADD_RSHIFT_uint(a, b, shift) ((a) + silk_RSHIFT_uint((b), (shift))) /* shift >= 0 */
-#define silk_SUB_LSHIFT32(a, b, shift) silk_SUB32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */
-#define silk_SUB_RSHIFT32(a, b, shift) silk_SUB32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */
+#define silk_LSHIFT_SAT16(a, shift) (silk_LSHIFT16( silk_LIMIT( (a), silk_RSHIFT16( silk_int16_MIN, (shift) ), \
+ silk_RSHIFT16( silk_int16_MAX, (shift) ) ), (shift) ))
+#define silk_LSHIFT_SAT32(a, shift) (silk_LSHIFT32( silk_LIMIT( (a), silk_RSHIFT32( silk_int32_MIN, (shift) ), \
+ silk_RSHIFT32( silk_int32_MAX, (shift) ) ), (shift) ))
+
+#define silk_LSHIFT_ovflw(a, shift) ((opus_int32)((opus_uint32)(a) << (shift))) /* shift >= 0, allowed to overflow */
+#define silk_LSHIFT_uint(a, shift) ((a) << (shift)) /* shift >= 0 */
+#define silk_RSHIFT_uint(a, shift) ((a) >> (shift)) /* shift >= 0 */
+
+#define silk_ADD_LSHIFT(a, b, shift) ((a) + silk_LSHIFT((b), (shift))) /* shift >= 0 */
+#define silk_ADD_LSHIFT32(a, b, shift) silk_ADD32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */
+#define silk_ADD_LSHIFT_uint(a, b, shift) ((a) + silk_LSHIFT_uint((b), (shift))) /* shift >= 0 */
+#define silk_ADD_RSHIFT(a, b, shift) ((a) + silk_RSHIFT((b), (shift))) /* shift >= 0 */
+#define silk_ADD_RSHIFT32(a, b, shift) silk_ADD32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */
+#define silk_ADD_RSHIFT_uint(a, b, shift) ((a) + silk_RSHIFT_uint((b), (shift))) /* shift >= 0 */
+#define silk_SUB_LSHIFT32(a, b, shift) silk_SUB32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */
+#define silk_SUB_RSHIFT32(a, b, shift) silk_SUB32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */
/* Requires that shift > 0 */
-#define silk_RSHIFT_ROUND(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1)
-#define silk_RSHIFT_ROUND64(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1)
+#define silk_RSHIFT_ROUND(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1)
+#define silk_RSHIFT_ROUND64(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1)
/* Number of rightshift required to fit the multiplication */
-#define silk_NSHIFT_MUL_32_32(a, b) ( -(31- (32-silk_CLZ32(silk_abs(a)) + (32-silk_CLZ32(silk_abs(b))))) )
-#define silk_NSHIFT_MUL_16_16(a, b) ( -(15- (16-silk_CLZ16(silk_abs(a)) + (16-silk_CLZ16(silk_abs(b))))) )
+#define silk_NSHIFT_MUL_32_32(a, b) ( -(31- (32-silk_CLZ32(silk_abs(a)) + (32-silk_CLZ32(silk_abs(b))))) )
+#define silk_NSHIFT_MUL_16_16(a, b) ( -(15- (16-silk_CLZ16(silk_abs(a)) + (16-silk_CLZ16(silk_abs(b))))) )
-#define silk_min(a, b) (((a) < (b)) ? (a) : (b))
-#define silk_max(a, b) (((a) > (b)) ? (a) : (b))
+#define silk_min(a, b) (((a) < (b)) ? (a) : (b))
+#define silk_max(a, b) (((a) > (b)) ? (a) : (b))
/* Macro to convert floating-point constants to fixed-point */
-#define SILK_FIX_CONST( C, Q ) ((opus_int32)((C) * ((opus_int64)1 << (Q)) + 0.5))
+#define SILK_FIX_CONST( C, Q ) ((opus_int32)((C) * ((opus_int64)1 << (Q)) + 0.5))
/* silk_min() versions with typecast in the function call */
static inline opus_int silk_min_int(opus_int a, opus_int b)
return (((a) > (b)) ? (a) : (b));
}
-#define silk_LIMIT( a, limit1, limit2) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
- : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))))
-
-#define silk_LIMIT_int silk_LIMIT
-#define silk_LIMIT_16 silk_LIMIT
-#define silk_LIMIT_32 silk_LIMIT
+#define silk_LIMIT( a, limit1, limit2) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
+ : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))))
-/*#define silk_non_neg(a) ((a) & ((-(a)) >> (8 * sizeof(a) - 1)))*/ /* doesn't seem faster than silk_max(0, a);*/
+#define silk_LIMIT_int silk_LIMIT
+#define silk_LIMIT_16 silk_LIMIT
+#define silk_LIMIT_32 silk_LIMIT
-#define silk_abs(a) (((a) > 0) ? (a) : -(a)) /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */
-#define silk_abs_int(a) (((a) ^ ((a) >> (8 * sizeof(a) - 1))) - ((a) >> (8 * sizeof(a) - 1)))
-#define silk_abs_int32(a) (((a) ^ ((a) >> 31)) - ((a) >> 31))
-#define silk_abs_int64(a) (((a) > 0) ? (a) : -(a))
+#define silk_abs(a) (((a) > 0) ? (a) : -(a)) /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */
+#define silk_abs_int(a) (((a) ^ ((a) >> (8 * sizeof(a) - 1))) - ((a) >> (8 * sizeof(a) - 1)))
+#define silk_abs_int32(a) (((a) ^ ((a) >> 31)) - ((a) >> 31))
+#define silk_abs_int64(a) (((a) > 0) ? (a) : -(a))
-#define silk_sign(a) ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 ))
+#define silk_sign(a) ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 ))
-#define silk_sqrt(a) (sqrt(a))
+#define silk_sqrt(a) (sqrt(a))
/* PSEUDO-RANDOM GENERATOR */
/* Make sure to store the result as the seed for the next call (also in between */
/* frames), otherwise result won't be random at all. When only using some of the */
/* bits, take the most significant bits by right-shifting. */
-#define silk_RAND(seed) (silk_MLA_ovflw(907633515, (seed), 196314165))
+#define silk_RAND(seed) (silk_MLA_ovflw(907633515, (seed), 196314165))
/* Add some multiplication functions that can be easily mapped to ARM. */
/* silk_SMMUL: Signed top word multiply.
ARMv6 2 instruction cycles.
- ARMv3M+ 3 instruction cycles. use SMULL and ignore LSB registers.(except xM)*/
-/*#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT(silk_SMLAL(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16)), 16)*/
+ ARMv3M+ 3 instruction cycles. use SMULL and ignore LSB registers.(except xM)*/
+/*#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT(silk_SMLAL(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16)), 16)*/
/* the following seems faster on x86 */
-#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT64(silk_SMULL((a32), (b32)), 32)
+#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT64(silk_SMULL((a32), (b32)), 32)
#include "Inlines.h"
#include "MacroCount.h"
/**********************************/
/* Initialization of the Silk VAD */
/**********************************/
-opus_int silk_VAD_Init( /* O Return value, 0 if success */
- silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
+opus_int silk_VAD_Init( /* O Return value, 0 if success */
+ silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
)
{
opus_int b, ret = 0;
/***************************************/
/* Get the speech activity level in Q8 */
/***************************************/
-opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */
- silk_encoder_state *psEncC, /* I/O Encoder state */
- const opus_int16 pIn[] /* I PCM input */
+opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */
+ silk_encoder_state *psEncC, /* I/O Encoder state */
+ const opus_int16 pIn[] /* I PCM input */
)
{
opus_int SA_Q15, pSNR_dB_Q7, input_tilt;
/* Noise level estimation */
/**************************/
static inline void silk_VAD_GetNoiseLevels(
- const opus_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 */
)
{
/* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */
void silk_VQ_WMat_EC(
- 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 */
+ opus_int8 *ind, /* O index of best codebook vector */
+ opus_int32 *rate_dist_Q14, /* O best weighted quant 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 betw. weighted error and rate */
+ opus_int L /* I number of vectors in codebook */
)
{
opus_int k;
/* Split signal into two decimated bands using first-order allpass filters */
void silk_ana_filt_bank_1(
- 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 */
+ 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 */
)
{
opus_int k, N2 = silk_RSHIFT( N, 1 );
#include "SigProc_FIX.h"
-
/* Second order ARMA filter, alternative implementation */
void silk_biquad_alt(
- 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) */
- opus_int stride /* I: Operate on interleaved signal if > 1 */
+ 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) */
+ opus_int stride /* I Operate on interleaved signal if > 1 */
)
{
/* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */
/* Negate A_Q28 values and split in two parts */
A0_L_Q28 = ( -A_Q28[ 0 ] ) & 0x00003FFF; /* lower part */
- A0_U_Q28 = silk_RSHIFT( -A_Q28[ 0 ], 14 ); /* upper part */
+ A0_U_Q28 = silk_RSHIFT( -A_Q28[ 0 ], 14 ); /* upper part */
A1_L_Q28 = ( -A_Q28[ 1 ] ) & 0x00003FFF; /* lower part */
- A1_U_Q28 = silk_RSHIFT( -A_Q28[ 1 ], 14 ); /* upper part */
+ A1_U_Q28 = silk_RSHIFT( -A_Q28[ 1 ], 14 ); /* upper part */
for( k = 0; k < len; k++ ) {
/* S[ 0 ], S[ 1 ]: Q12 */
/* Chirp (bandwidth expand) LP AR filter */
void silk_bwexpander(
- 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) */
+ 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) */
)
{
opus_int i;
/* Chirp (bandwidth expand) LP AR filter */
void silk_bwexpander_32(
- 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 */
+ 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 */
)
{
opus_int i;
/* Check encoder control struct */
opus_int check_control_input(
- silk_EncControlStruct *encControl /* I: Control structure */
+ silk_EncControlStruct *encControl /* I Control structure */
)
{
silk_assert( encControl != NULL );
/* Encodes signs of excitation */
void silk_encode_signs(
ec_enc *psRangeEnc, /* I/O Compressor data structure */
- 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 */
+ 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 */
)
{
opus_int i, j, p;
/* Decodes signs of excitation */
void silk_decode_signs(
ec_dec *psRangeDec, /* I/O Compressor data structure */
- 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 */
+ 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 */
)
{
opus_int i, j, p;
/* I: Flag to use constant bitrate */
opus_int useCBR;
- /* I: Maximum number of bits allowed for the frame */
+ /* I: Maximum number of bits allowed for the frame */
opus_int maxBits;
- /* I: Causes a smooth downmix to mono */
+ /* I: Causes a smooth downmix to mono */
opus_int toMono;
- /* I: Opus encoder is allowing us to switch bandwidth */
+ /* I: Opus encoder is allowing us to switch bandwidth */
opus_int opusCanSwitch;
/* O: Internal sampling rate used, in Hertz; 8000/12000/16000 */
/* O: Stereo width */
opus_int stereoWidth_Q14;
- /* O: Tells the Opus encoder we're ready to switch */
+ /* O: Tells the Opus encoder we're ready to switch */
opus_int switchReady;
} silk_EncControlStruct;
/* Control SNR of redidual quantizer */
opus_int silk_control_SNR(
- silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
- opus_int32 TargetRate_bps /* I Target max bitrate (bps) */
+ silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
+ opus_int32 TargetRate_bps /* I Target max bitrate (bps) */
)
{
opus_int k, ret = SILK_NO_ERROR;
/* Control internal sampling rate */
opus_int silk_control_audio_bandwidth(
- silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
- silk_EncControlStruct *encControl /* I: Control structure */
+ silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
+ silk_EncControlStruct *encControl /* I Control structure */
)
{
opus_int fs_kHz;
/* Reset transition filter state */
silk_memset( psEncC->sLP.In_LP_State, 0, sizeof( psEncC->sLP.In_LP_State ) );
}
- if (encControl->opusCanSwitch) {
+ if( encControl->opusCanSwitch ) {
/* Stop transition phase */
psEncC->sLP.mode = 0;
if( silk_SMULBB( psEncC->fs_kHz, 1000 ) < psEncC->desiredInternal_fs_Hz )
{
/* Switch up */
- if (encControl->opusCanSwitch) {
+ if( encControl->opusCanSwitch ) {
/* Switch to a higher sample frequency */
fs_kHz = psEncC->fs_kHz == 8 ? 12 : 16;
}
}
-#ifdef FORCE_INTERNAL_FS_KHZ
- fs_kHz = FORCE_INTERNAL_FS_KHZ;
-#endif
-
return fs_kHz;
}
#define silk_encoder_state_Fxx silk_encoder_state_FLP
#endif
#include "tuning_parameters.h"
-
+#include "pitch_est_defines.h"
static const opus_int enc_delay_matrix[3][5] = {
/*SILK API 8 12 16 24 48 */
opus_int silk_setup_resamplers(
silk_encoder_state_Fxx *psEnc, /* I/O */
- opus_int fs_kHz /* I */
+ opus_int fs_kHz /* I */
);
opus_int silk_setup_fs(
silk_encoder_state_Fxx *psEnc, /* I/O */
- opus_int fs_kHz, /* I */
- opus_int PacketSize_ms /* I */
+ opus_int fs_kHz, /* I */
+ opus_int PacketSize_ms /* I */
);
opus_int silk_setup_complexity(
silk_encoder_state *psEncC, /* I/O */
- opus_int Complexity /* I */
+ opus_int Complexity /* I */
);
static inline opus_int silk_setup_LBRR(
silk_encoder_state *psEncC, /* I/O */
- const opus_int32 TargetRate_bps /* I */
+ const opus_int32 TargetRate_bps /* I */
);
/* 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 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 */
- const opus_int force_fs_kHz
+ silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */
+ silk_EncControlStruct *encControl, /* I Control structure */
+ 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 */
+ const opus_int force_fs_kHz
)
{
opus_int fs_kHz, ret = 0;
/* Determine internal sampling rate */
/********************************************/
fs_kHz = silk_control_audio_bandwidth( &psEnc->sCmn, encControl );
- if (force_fs_kHz)
+ if( force_fs_kHz ) {
fs_kHz = force_fs_kHz;
+ }
/********************************************/
/* Prepare resampler and buffered data */
/********************************************/
opus_int silk_setup_fs(
silk_encoder_state_Fxx *psEnc, /* I/O */
- opus_int fs_kHz, /* I */
- opus_int PacketSize_ms /* I */
+ opus_int fs_kHz, /* I */
+ opus_int PacketSize_ms /* I */
)
{
opus_int ret = SILK_NO_ERROR;
opus_int silk_setup_complexity(
silk_encoder_state *psEncC, /* I/O */
- opus_int Complexity /* I */
+ opus_int Complexity /* I */
)
{
opus_int ret = 0;
static inline opus_int silk_setup_LBRR(
silk_encoder_state *psEncC, /* I/O */
- const opus_int32 TargetRate_bps /* I */
+ const opus_int32 TargetRate_bps /* I */
)
{
opus_int ret = SILK_NO_ERROR;
#include "main.h"
-
/************************/
/* Init Decoder State */
/************************/
opus_int silk_init_decoder(
- silk_decoder_state *psDec /* I/O Decoder state pointer */
+ silk_decoder_state *psDec /* I/O Decoder state pointer */
)
{
/* Clear the entire encoder state, except anything copied */
#include <sys/time.h>
#endif
-unsigned long silk_GetHighResolutionTime(void) /* O: time in usec*/
+unsigned long silk_GetHighResolutionTime(void) /* O time in usec*/
{
/* Returns a time counter in microsec */
/* the resolution is platform dependent */
return (unsigned long)((1000000*(lpPerformanceCount.QuadPart)) / lpFrequency.QuadPart);
}
#else /* Linux or Mac*/
-unsigned long GetHighResolutionTime(void) /* O: time in usec*/
+unsigned long GetHighResolutionTime(void) /* O time in usec*/
{
struct timeval tv;
gettimeofday(&tv, 0);
{
#endif
-unsigned long GetHighResolutionTime(void); /* O: time in usec*/
+unsigned long GetHighResolutionTime(void); /* O time in usec*/
/* make SILK_DEBUG dependent on compiler's _DEBUG */
#if defined _WIN32
#endif
/* Flag for using timers */
-#define SILK_TIC_TOC 0
+#define SILK_TIC_TOC 0
+
#if SILK_TIC_TOC
/* */
/* and call the following just before exiting (from main) */
/* */
-/* silk_TimerSave("silk_TimingData.txt"); */
+/* silk_TimerSave("silk_TimingData.txt"); */
/* */
-/* results are now in silk_TimingData.txt */
+/* results are now in silk_TimingData.txt */
void silk_TimerSave(char *file_name);
extern unsigned long silk_Timer_start[silk_NUM_TIMERS_MAX];
#endif
extern unsigned int silk_Timer_cnt[silk_NUM_TIMERS_MAX];
-extern opus_int64 silk_Timer_sum[silk_NUM_TIMERS_MAX];
-extern opus_int64 silk_Timer_max[silk_NUM_TIMERS_MAX];
-extern opus_int64 silk_Timer_min[silk_NUM_TIMERS_MAX];
-extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX];
+extern opus_int64 silk_Timer_sum[silk_NUM_TIMERS_MAX];
+extern opus_int64 silk_Timer_max[silk_NUM_TIMERS_MAX];
+extern opus_int64 silk_Timer_min[silk_NUM_TIMERS_MAX];
+extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX];
/* WARNING: TIC()/TOC can measure only up to 0.1 seconds at a time */
#ifdef _WIN32
{ \
int k; \
init = 1; \
- for( k = 0; k < silk_Timer_nTimers; k++ ) { \
- if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
+ for( k = 0; k < silk_Timer_nTimers; k++ ) { \
+ if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
ID = k; \
break; \
} \
} \
if (ID == -1) { \
- ID = silk_Timer_nTimers; \
- silk_Timer_nTimers++; \
- silk_Timer_depth[ID] = silk_Timer_depth_ctr; \
- strcpy(silk_Timer_tags[ID], #TAG_NAME); \
- silk_Timer_cnt[ID] = 0; \
- silk_Timer_sum[ID] = 0; \
- silk_Timer_min[ID] = 0xFFFFFFFF; \
- silk_Timer_max[ID] = 0; \
+ ID = silk_Timer_nTimers; \
+ silk_Timer_nTimers++; \
+ silk_Timer_depth[ID] = silk_Timer_depth_ctr; \
+ strcpy(silk_Timer_tags[ID], #TAG_NAME); \
+ silk_Timer_cnt[ID] = 0; \
+ silk_Timer_sum[ID] = 0; \
+ silk_Timer_min[ID] = 0xFFFFFFFF; \
+ silk_Timer_max[ID] = 0; \
} \
} \
- silk_Timer_depth_ctr++; \
- QueryPerformanceCounter(&silk_Timer_start[ID]); \
+ silk_Timer_depth_ctr++; \
+ QueryPerformanceCounter(&silk_Timer_start[ID]); \
}
#else
#define TIC(TAG_NAME) { \
{ \
int k; \
init = 1; \
- for( k = 0; k < silk_Timer_nTimers; k++ ) { \
- if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
+ for( k = 0; k < silk_Timer_nTimers; k++ ) { \
+ if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
ID = k; \
break; \
} \
} \
if (ID == -1) { \
- ID = silk_Timer_nTimers; \
- silk_Timer_nTimers++; \
- silk_Timer_depth[ID] = silk_Timer_depth_ctr; \
- strcpy(silk_Timer_tags[ID], #TAG_NAME); \
- silk_Timer_cnt[ID] = 0; \
- silk_Timer_sum[ID] = 0; \
- silk_Timer_min[ID] = 0xFFFFFFFF; \
- silk_Timer_max[ID] = 0; \
+ ID = silk_Timer_nTimers; \
+ silk_Timer_nTimers++; \
+ silk_Timer_depth[ID] = silk_Timer_depth_ctr; \
+ strcpy(silk_Timer_tags[ID], #TAG_NAME); \
+ silk_Timer_cnt[ID] = 0; \
+ silk_Timer_sum[ID] = 0; \
+ silk_Timer_min[ID] = 0xFFFFFFFF; \
+ silk_Timer_max[ID] = 0; \
} \
} \
- silk_Timer_depth_ctr++; \
- silk_Timer_start[ID] = GetHighResolutionTime(); \
+ silk_Timer_depth_ctr++; \
+ silk_Timer_start[ID] = GetHighResolutionTime(); \
}
#endif
{ \
int k; \
init = 1; \
- for( k = 0; k < silk_Timer_nTimers; k++ ) { \
- if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
+ for( k = 0; k < silk_Timer_nTimers; k++ ) { \
+ if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
ID = k; \
break; \
} \
} \
} \
QueryPerformanceCounter(&lpPerformanceCount); \
- lpPerformanceCount.QuadPart -= silk_Timer_start[ID].QuadPart; \
+ lpPerformanceCount.QuadPart -= silk_Timer_start[ID].QuadPart; \
if((lpPerformanceCount.QuadPart < 100000000) && \
(lpPerformanceCount.QuadPart >= 0)) { \
- silk_Timer_cnt[ID]++; \
- silk_Timer_sum[ID] += lpPerformanceCount.QuadPart; \
- if( lpPerformanceCount.QuadPart > silk_Timer_max[ID] ) \
- silk_Timer_max[ID] = lpPerformanceCount.QuadPart; \
- if( lpPerformanceCount.QuadPart < silk_Timer_min[ID] ) \
- silk_Timer_min[ID] = lpPerformanceCount.QuadPart; \
+ silk_Timer_cnt[ID]++; \
+ silk_Timer_sum[ID] += lpPerformanceCount.QuadPart; \
+ if( lpPerformanceCount.QuadPart > silk_Timer_max[ID] ) \
+ silk_Timer_max[ID] = lpPerformanceCount.QuadPart; \
+ if( lpPerformanceCount.QuadPart < silk_Timer_min[ID] ) \
+ silk_Timer_min[ID] = lpPerformanceCount.QuadPart; \
} \
- silk_Timer_depth_ctr--; \
+ silk_Timer_depth_ctr--; \
}
#else
#define TOC(TAG_NAME) { \
{ \
int k; \
init = 1; \
- for( k = 0; k < silk_Timer_nTimers; k++ ) { \
- if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
+ for( k = 0; k < silk_Timer_nTimers; k++ ) { \
+ if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
ID = k; \
break; \
} \
} \
} \
endTime = GetHighResolutionTime(); \
- endTime -= silk_Timer_start[ID]; \
+ endTime -= silk_Timer_start[ID]; \
if((endTime < 100000000) && \
(endTime >= 0)) { \
- silk_Timer_cnt[ID]++; \
- silk_Timer_sum[ID] += endTime; \
- if( endTime > silk_Timer_max[ID] ) \
- silk_Timer_max[ID] = endTime; \
- if( endTime < silk_Timer_min[ID] ) \
- silk_Timer_min[ID] = endTime; \
+ silk_Timer_cnt[ID]++; \
+ silk_Timer_sum[ID] += endTime; \
+ if( endTime > silk_Timer_max[ID] ) \
+ silk_Timer_max[ID] = endTime; \
+ if( endTime < silk_Timer_min[ID] ) \
+ silk_Timer_min[ID] = endTime; \
} \
- silk_Timer_depth_ctr--; \
+ silk_Timer_depth_ctr--; \
}
#endif
#endif /* SILK_TIC_TOC */
-
#if SILK_DEBUG
/************************************/
/* write data to file for debugging */
/************************************/
-/* 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 opus_int32 init = 0; \
- FILE *fp; \
- if (init == 0) { \
- init = 1; \
- fp = fopen(#FILE_NAME, "wb"); \
- } else { \
- fp = fopen(#FILE_NAME, "ab+"); \
- } \
- fwrite((DATA_PTR), (N_BYTES), 1, fp); \
- fclose(fp); \
-}
-
/* 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 */
-#define DEBUG_STORE_DATA(FILE_NAME, DATA_PTR, N_BYTES) SAVE_DATA(FILE_NAME, DATA_PTR, N_BYTES)
-#define SILK_DEBUG_STORE_CLOSE_FILES
-
-#else
-
#define silk_NUM_STORES_MAX 100
extern FILE *silk_debug_store_fp[ silk_NUM_STORES_MAX ];
extern int silk_debug_store_count;
/* Faster way of storing the data */
#define DEBUG_STORE_DATA( FILE_NAME, DATA_PTR, N_BYTES ) { \
- static opus_int init = 0, cnt = 0; \
+ static opus_int init = 0, cnt = 0; \
static FILE **fp; \
if (init == 0) { \
- init = 1; \
+ init = 1; \
cnt = silk_debug_store_count++; \
silk_debug_store_fp[ cnt ] = fopen(#FILE_NAME, "wb"); \
} \
/* Call this at the end of main() */
#define SILK_DEBUG_STORE_CLOSE_FILES { \
- opus_int i; \
+ opus_int i; \
for( i = 0; i < silk_debug_store_count; i++ ) { \
fclose( silk_debug_store_fp[ i ] ); \
} \
}
-#endif
/* micro sec */
#define silk_GETTIME(void) time = (opus_int64) silk_GetHighResolutionTime();
/* define macros as empty strings */
#define DEBUG_STORE_DATA(FILE_NAME, DATA_PTR, N_BYTES)
-#define SAVE_DATA(FILE_NAME, DATA_PTR, N_BYTES)
#define SILK_DEBUG_STORE_CLOSE_FILES
#endif /* SILK_DEBUG */
/* Decoder functions */
/*********************/
-opus_int silk_Get_Decoder_Size( int *decSizeBytes )
+opus_int silk_Get_Decoder_Size( /* O Returns error code */
+ opus_int *decSizeBytes /* O Number of bytes in SILK decoder state */
+)
{
opus_int ret = SILK_NO_ERROR;
}
/* Reset decoder state */
-opus_int silk_InitDecoder(
- void* decState /* I/O: State */
+opus_int silk_InitDecoder( /* O Returns error code */
+ void *decState /* I/O State */
)
{
opus_int n, ret = SILK_NO_ERROR;
}
/* Decode a frame */
-opus_int silk_Decode(
- void* decState, /* I/O: State */
- silk_DecControlStruct* decControl, /* I/O: Control Structure */
- 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 */
- opus_int16 *samplesOut, /* O: Decoded output speech vector */
- opus_int32 *nSamplesOut /* O: Number of samples decoded */
+opus_int silk_Decode( /* O Returns error code */
+ void* decState, /* I/O State */
+ silk_DecControlStruct* decControl, /* I/O Control Structure */
+ 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 */
+ opus_int16 *samplesOut, /* O Decoded output speech vector */
+ opus_int32 *nSamplesOut /* O Number of samples decoded */
)
{
opus_int i, n, delay, decode_only_middle = 0, ret = SILK_NO_ERROR;
psDec->channel_state[ 1 ].first_frame_after_reset = 1;
}
- if (lostFlag == FLAG_DECODE_NORMAL) {
+ if( lostFlag == FLAG_DECODE_NORMAL ) {
has_side = !decode_only_middle;
} else {
has_side = !psDec->prev_decode_only_middle
decControl->prevPitchLag = 0;
}
- if ( lostFlag != FLAG_PACKET_LOST ) {
+ if( lostFlag != FLAG_PACKET_LOST ) {
psDec->prev_decode_only_middle = decode_only_middle;
}
return ret;
/* Getting table of contents for a packet */
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 */
+ 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 */
)
{
opus_int i, flags, ret = SILK_NO_ERROR;
/* Core decoder. Performs inverse NSQ operation LTP + LPC */
/**********************************************************/
void silk_decode_core(
- silk_decoder_state *psDec, /* I/O Decoder state */
- silk_decoder_control *psDecCtrl, /* I Decoder control */
- opus_int16 xq[], /* O Decoded speech */
- const opus_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */
+ silk_decoder_state *psDec, /* I/O Decoder state */
+ silk_decoder_control *psDecCtrl, /* I Decoder control */
+ opus_int16 xq[], /* O Decoded speech */
+ const opus_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */
)
{
opus_int i, j, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, signalType;
rand_seed = silk_ADD32_ovflw(rand_seed, pulses[ i ]);
}
-#ifdef SAVE_ALL_INTERNAL_DATA
- DEBUG_STORE_DATA( dec_q.dat, pulses, psDec->frame_length * sizeof( opus_int ) );
-#endif
-
/* Copy LPC state */
silk_memcpy( sLPC_Q14, psDec->sLPC_Q14_buf, MAX_LPC_ORDER * sizeof( opus_int32 ) );
pres_Q10 = pexc_Q10;
}
-#ifdef SAVE_ALL_INTERNAL_DATA
- 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++ ) {
/* Partially unrolled */
LPC_pred_Q10 = silk_SMULWB( sLPC_Q14[ MAX_LPC_ORDER + i - 1 ], A_Q12_tmp[ 0 ] );
/* Save LPC state */
silk_memcpy( psDec->sLPC_Q14_buf, sLPC_Q14, MAX_LPC_ORDER * sizeof( opus_int32 ) );
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- DEBUG_STORE_DATA( dec_sLTP_Q16.dat, &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
}
/* 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 */
- 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 */
- opus_int condCoding /* I The type of conditional coding to use */
+ silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */
+ ec_dec *psRangeDec, /* I/O Compressor data structure */
+ 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 */
+ opus_int condCoding /* I The type of conditional coding to use */
)
{
silk_decoder_control sDecCtrl;
opus_int L, mv_len, ret = 0;
opus_int pulses[ MAX_FRAME_LENGTH ];
-TIC(DECODE_FRAME)
-
L = psDec->frame_length;
sDecCtrl.LTP_scale_Q14 = 0;
/*********************************************/
/* Decode quantization indices of side info */
/*********************************************/
-TIC(decode_indices)
silk_decode_indices( psDec, psRangeDec, psDec->nFramesDecoded, lostFlag, condCoding );
-TOC(decode_indices)
/*********************************************/
/* Decode quantization indices of excitation */
/*********************************************/
-TIC(decode_pulses)
silk_decode_pulses( psRangeDec, pulses, psDec->indices.signalType,
psDec->indices.quantOffsetType, psDec->frame_length );
-TOC(decode_pulses)
/********************************************/
/* Decode parameters and pulse signal */
/********************************************/
-TIC(decode_params)
silk_decode_parameters( psDec, &sDecCtrl, condCoding );
-TOC(decode_params)
/* Update length. Sampling frequency may have changed */
L = psDec->frame_length;
/********************************************************/
/* Run inverse NSQ */
/********************************************************/
-TIC(decode_core)
silk_decode_core( psDec, &sDecCtrl, pOut, pulses );
-TOC(decode_core)
/********************************************************/
/* Update PLC state */
/* Set output frame length */
*pN = L;
-TOC(DECODE_FRAME)
-
return ret;
}
/* Decode side-information parameters from payload */
void silk_decode_indices(
- silk_decoder_state *psDec, /* I/O State */
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- opus_int FrameIndex, /* I Frame number */
- opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */
- opus_int condCoding /* I The type of conditional coding to use */
+ silk_decoder_state *psDec, /* I/O State */
+ ec_dec *psRangeDec, /* I/O Compressor data structure */
+ opus_int FrameIndex, /* I Frame number */
+ opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */
+ opus_int condCoding /* I The type of conditional coding to use */
)
{
opus_int i, k, Ix;
/* Decode parameters from payload */
void silk_decode_parameters(
- silk_decoder_state *psDec, /* I/O State */
- silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- opus_int condCoding /* I The type of conditional coding to use */
+ silk_decoder_state *psDec, /* I/O State */
+ silk_decoder_control *psDecCtrl, /* I/O Decoder control */
+ opus_int condCoding /* I The type of conditional coding to use */
)
{
opus_int i, k, Ix;
#include "pitch_est_defines.h"
void silk_decode_pitch(
- opus_int16 lagIndex, /* I */
- opus_int8 contourIndex, /* O */
- opus_int pitch_lags[], /* O pitch values */
- const opus_int Fs_kHz, /* I sampling frequency (kHz) */
- const opus_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 */
)
{
opus_int lag, k, min_lag, max_lag, cbk_size;
/* Decode quantization indices of excitation */
/*********************************************/
void silk_decode_pulses(
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- opus_int pulses[], /* O Excitation signal */
- const opus_int signalType, /* I Sigtype */
- const opus_int quantOffsetType, /* I quantOffsetType */
- const opus_int frame_length /* I Frame length */
+ ec_dec *psRangeDec, /* I/O Compressor data structure */
+ opus_int pulses[], /* O Excitation signal */
+ const opus_int signalType, /* I Sigtype */
+ const opus_int quantOffsetType, /* I quantOffsetType */
+ const opus_int frame_length /* I Frame length */
)
{
opus_int i, j, k, iter, abs_q, nLS, RateLevelIndex;
/* Calculate number of shell blocks */
silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH );
iter = silk_RSHIFT( frame_length, LOG2_SHELL_CODEC_FRAME_LENGTH );
- if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ){
+ if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ) {
silk_assert( frame_length == 12 * 10 ); /* Make sure only happens for 10 ms @ 12 kHz */
iter++;
}
nLshifts[ i ]++;
/* When we've already got 10 LSBs, we shift the table to not allow (MAX_PULSES + 1) */
sum_pulses[ i ] = ec_dec_icdf( psRangeDec,
- silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1] + (nLshifts[ i ]==10), 8 );
+ silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1] + ( nLshifts[ i ] == 10 ), 8 );
}
}
/* Set decoder sampling rate */
opus_int silk_decoder_set_fs(
- silk_decoder_state *psDec, /* I/O Decoder state pointer */
- opus_int fs_kHz, /* I Sampling frequency (kHz) */
- opus_int fs_API_Hz /* I API Sampling frequency (Hz) */
+ silk_decoder_state *psDec, /* I/O Decoder state pointer */
+ opus_int fs_kHz, /* I Sampling frequency (kHz) */
+ opus_int fs_API_Hz /* I API Sampling frequency (Hz) */
)
{
opus_int frame_length, ret = 0;
#define NB_SPEECH_FRAMES_BEFORE_DTX 10 /* eq 200 ms */
#define MAX_CONSECUTIVE_DTX 20 /* eq 400 ms */
-/* Maximum sampling frequency, should be 16 for embedded */
+/* Maximum sampling frequency */
#define MAX_FS_KHZ 16
#define MAX_API_FS_KHZ 48
/* Settings for stereo processing */
#define STEREO_QUANT_TAB_SIZE 16
#define STEREO_QUANT_SUB_STEPS 5
-#define STEREO_INTERP_LEN_MS 8 /* must be even */
-#define STEREO_RATIO_SMOOTH_COEF 0.01 /* smoothing coef for signal norms and stereo width */
+#define STEREO_INTERP_LEN_MS 8 /* must be even */
+#define STEREO_RATIO_SMOOTH_COEF 0.01 /* smoothing coef for signal norms and stereo width */
/* Range of pitch lag estimates */
-#define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */
-#define PITCH_EST_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */
+#define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */
+#define PITCH_EST_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */
/* Maximum number of subframes */
#define MAX_NB_SUBFR 4
#define MAX_FRAME_LENGTH ( MAX_FRAME_LENGTH_MS * MAX_FS_KHZ )
#define MAX_ENCODER_DELAY 18
-#define MAX_DECODER_DELAY 8
+#define MAX_DECODER_DELAY 8
/* Milliseconds of lookahead for pitch analysis */
#define LA_PITCH_MS 2
#define VAD_INTERNAL_SUBFRAMES_LOG2 2
#define VAD_INTERNAL_SUBFRAMES (1 << VAD_INTERNAL_SUBFRAMES_LOG2)
-#define VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 1024 /* Must be < 4096 */
+#define VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 1024 /* Must be < 4096 */
#define VAD_NOISE_LEVELS_BIAS 50
/* Sigmoid settings */
-#define VAD_NEGATIVE_OFFSET_Q5 128 /* sigmoid is 0 at -128 */
+#define VAD_NEGATIVE_OFFSET_Q5 128 /* sigmoid is 0 at -128 */
#define VAD_SNR_FACTOR_Q16 45000
/* smoothing for SNR measurement */
#define NLSF_QUANT_DEL_DEC_STATES ( 1 << NLSF_QUANT_DEL_DEC_STATES_LOG2 )
/* Transition filtering for mode switching */
-#define TRANSITION_TIME_MS 5120 /* 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)*/
-#define TRANSITION_NB 3 /* Hardcoded in tables */
-#define TRANSITION_NA 2 /* Hardcoded in tables */
-#define TRANSITION_INT_NUM 5 /* Hardcoded in tables */
+#define TRANSITION_TIME_MS 5120 /* 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)*/
+#define TRANSITION_NB 3 /* Hardcoded in tables */
+#define TRANSITION_NA 2 /* Hardcoded in tables */
+#define TRANSITION_INT_NUM 5 /* Hardcoded in tables */
#define TRANSITION_FRAMES ( TRANSITION_TIME_MS / MAX_FRAME_LENGTH_MS )
#define TRANSITION_INT_STEPS ( TRANSITION_FRAMES / ( TRANSITION_INT_NUM - 1 ) )
#define BWE_AFTER_LOSS_Q16 63570
/* Defines for CN generation */
-#define CNG_BUF_MASK_MAX 255 /* 2^floor(log2(MAX_FRAME_LENGTH))-1 */
-#define CNG_GAIN_SMTH_Q16 4634 /* 0.25^(1/4) */
-#define CNG_NLSF_SMTH_Q16 16348 /* 0.25 */
+#define CNG_BUF_MASK_MAX 255 /* 2^floor(log2(MAX_FRAME_LENGTH))-1 */
+#define CNG_GAIN_SMTH_Q16 4634 /* 0.25^(1/4) */
+#define CNG_NLSF_SMTH_Q16 16348 /* 0.25 */
#ifdef __cplusplus
}
/* Encoder functions */
/****************************************/
-opus_int silk_Get_Encoder_Size( opus_int *encSizeBytes )
+opus_int silk_Get_Encoder_Size( /* O Returns error code */
+ opus_int *encSizeBytes /* O Number of bytes in SILK encoder state */
+)
{
opus_int ret = SILK_NO_ERROR;
/*************************/
/* Init or Reset encoder */
/*************************/
-opus_int silk_InitEncoder(
- void *encState, /* I/O: State */
- silk_EncControlStruct *encStatus /* O: Control structure */
+opus_int silk_InitEncoder( /* O Returns error code */
+ void *encState, /* I/O State */
+ silk_EncControlStruct *encStatus /* O Encoder Status */
)
{
silk_encoder *psEnc;
/***************************************/
/* Read control structure from encoder */
/***************************************/
-opus_int silk_QueryEncoder(
- const void *encState, /* I: State Vector */
- silk_EncControlStruct *encStatus /* O: Control Structure */
+opus_int silk_QueryEncoder( /* O Returns error code */
+ const void *encState, /* I State */
+ silk_EncControlStruct *encStatus /* O Encoder Status */
)
{
opus_int ret = SILK_NO_ERROR;
/**************************/
/* Encode frame with Silk */
/**************************/
-opus_int silk_Encode(
- void *encState, /* I/O: State */
- silk_EncControlStruct *encControl, /* I: Control structure */
- 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 */
- opus_int *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
- const opus_int prefillFlag /* I: Flag to indicate prefilling buffers; no coding */
+/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */
+/* encControl->payloadSize_ms is set to */
+opus_int silk_Encode( /* O Returns error code */
+ void *encState, /* I/O State */
+ silk_EncControlStruct *encControl, /* I Control status */
+ 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 */
+ opus_int *nBytesOut, /* I/O Number of bytes in payload (input: Max bytes) */
+ const opus_int prefillFlag /* I Flag to indicate prefilling buffers no coding */
)
{
opus_int n, i, nBits, flags, tmp_payloadSize_ms = 0, tmp_complexity = 0, ret = 0;
buf[ n + delay ] = (opus_int16)silk_RSHIFT_ROUND( samplesIn[ 2 * n ] + samplesIn[ 2 * n + 1 ], 1 );
}
if(psEnc->nPrevChannelsInternal == 2 && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded==0) {
- for ( n = 0; n<MAX_ENCODER_DELAY; n++ )
+ for( n = 0; n<MAX_ENCODER_DELAY; n++ ) {
psEnc->state_Fxx[ 0 ].sCmn.delayBuf[ n ] = silk_RSHIFT(psEnc->state_Fxx[ 0 ].sCmn.delayBuf[ n ]+(opus_int32)psEnc->state_Fxx[ 1 ].sCmn.delayBuf[ n ], 1);
+ }
}
silk_memcpy(buf, &psEnc->state_Fxx[ 0 ].sCmn.delayBuf[ MAX_ENCODER_DELAY - delay ], delay * sizeof(opus_int16));
ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state,
&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput );
/* On the first mono frame, average the results for the two resampler states */
- if (psEnc->nPrevChannelsInternal == 2 && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded==0) {
+ if( psEnc->nPrevChannelsInternal == 2 && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded == 0 ) {
ret += silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state,
&psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput );
- for ( n = 0; n < psEnc->state_Fxx[ 0 ].sCmn.frame_length; n++ ) {
+ for( n = 0; n < psEnc->state_Fxx[ 0 ].sCmn.frame_length; n++ ) {
psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx+n+2 ] =
silk_RSHIFT(psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx+n+2 ]
+ psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx+n+2 ], 1);
/* Total target bits for packet */
nBits = silk_DIV32_16( silk_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 );
/* Subtract half of the bits already used */
- if (!prefillFlag)
+ if( !prefillFlag ) {
nBits -= ec_tell( psRangeEnc ) >> 1;
+ }
/* Divide by number of uncoded frames left in packet */
nBits = silk_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket - psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded );
/* Convert to bits/second */
/* Encode side-information parameters to payload */
void silk_encode_indices(
- silk_encoder_state *psEncC, /* I/O Encoder state */
- ec_enc *psRangeEnc, /* I/O Compressor data structure */
- opus_int FrameIndex, /* I Frame number */
- opus_int encode_LBRR, /* I Flag indicating LBRR data is being encoded */
- opus_int condCoding /* I The type of conditional coding to use */
+ silk_encoder_state *psEncC, /* I/O Encoder state */
+ ec_enc *psRangeEnc, /* I/O Compressor data structure */
+ opus_int FrameIndex, /* I Frame number */
+ opus_int encode_LBRR, /* I Flag indicating LBRR data is being encoded */
+ opus_int condCoding /* I The type of conditional coding to use */
)
{
opus_int i, k, typeOffset;
opus_int16 ec_ix[ MAX_LPC_ORDER ];
opus_uint8 pred_Q8[ MAX_LPC_ORDER ];
const SideInfoIndices *psIndices;
-#if SAVE_ALL_INTERNAL_DATA
- opus_int nBytes_lagIndex, nBytes_contourIndex, nBytes_LTP;
- opus_int nBytes_after, nBytes_before;
-#endif
if( encode_LBRR ) {
psIndices = &psEncC->indices_LBRR[ FrameIndex ];
/****************/
/* Encode gains */
/****************/
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
/* first subframe */
if( condCoding == CODE_CONDITIONALLY ) {
/* conditional coding */
ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ i ], silk_delta_gain_iCDF, 8 );
}
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_after = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
- nBytes_after -= nBytes_before; /* bytes just added*/
- DEBUG_STORE_DATA( nBytes_gains.dat, &nBytes_after, sizeof( opus_int ) );
-#endif
-
/****************/
/* Encode NLSFs */
/****************/
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ 0 ], &psEncC->psNLSF_CB->CB1_iCDF[ ( psIndices->signalType >> 1 ) * psEncC->psNLSF_CB->nVectors ], 8 );
silk_NLSF_unpack( ec_ix, pred_Q8, psEncC->psNLSF_CB, psIndices->NLSFIndices[ 0 ] );
silk_assert( psEncC->psNLSF_CB->order == psEncC->predictLPCOrder );
ec_enc_icdf( psRangeEnc, psIndices->NLSFInterpCoef_Q2, silk_NLSF_interpolation_factor_iCDF, 8 );
}
-#ifdef SAVE_ALL_INTERNAL_DATA
- DEBUG_STORE_DATA( lsf_interpol.dat, &psIndices->NLSFInterpCoef_Q2, sizeof(int) );
- nBytes_after = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
- nBytes_after -= nBytes_before; /* bytes just added*/
- DEBUG_STORE_DATA( nBytes_LSF.dat, &nBytes_after, sizeof( opus_int ) );
-#endif
-
if( psIndices->signalType == TYPE_VOICED )
{
/*********************/
/* Encode pitch lags */
/*********************/
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
/* lag index */
encode_absolute_lagIndex = 1;
if( condCoding == CODE_CONDITIONALLY && psEncC->ec_prevSignalType == TYPE_VOICED ) {
}
psEncC->ec_prevLagIndex = psIndices->lagIndex;
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_after = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
- nBytes_lagIndex = nBytes_after - nBytes_before; /* bytes just added*/
-#endif
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
/* Countour index */
silk_assert( psIndices->contourIndex >= 0 );
silk_assert( ( psIndices->contourIndex < 34 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 4 ) ||
( psIndices->contourIndex < 12 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 2 ) ||
( psIndices->contourIndex < 3 && psEncC->fs_kHz == 8 && psEncC->nb_subfr == 2 ) );
ec_enc_icdf( psRangeEnc, psIndices->contourIndex, psEncC->pitch_contour_iCDF, 8 );
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_after = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
- nBytes_contourIndex = nBytes_after - nBytes_before; /* bytes just added*/
-#endif
/********************/
/* Encode LTP gains */
/********************/
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
-
/* PERIndex value */
silk_assert( psIndices->PERIndex >= 0 && psIndices->PERIndex < 3 );
ec_enc_icdf( psRangeEnc, psIndices->PERIndex, silk_LTP_per_index_iCDF, 8 );
ec_enc_icdf( psRangeEnc, psIndices->LTP_scaleIndex, silk_LTPscale_iCDF, 8 );
}
silk_assert( !condCoding || psIndices->LTP_scaleIndex == 0 );
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_after = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
- nBytes_LTP = nBytes_after - nBytes_before; /* bytes just added*/
-#endif
- }
-#ifdef SAVE_ALL_INTERNAL_DATA
- else {
- /* Unvoiced speech*/
- nBytes_lagIndex = 0;
- nBytes_contourIndex = 0;
- nBytes_LTP = 0;
}
- DEBUG_STORE_DATA( nBytes_lagIndex.dat, &nBytes_lagIndex, sizeof( opus_int ) );
- DEBUG_STORE_DATA( nBytes_contourIndex.dat, &nBytes_contourIndex, sizeof( opus_int ) );
- DEBUG_STORE_DATA( nBytes_LTP.dat, &nBytes_LTP, sizeof( opus_int ) );
-#endif
psEncC->ec_prevSignalType = psIndices->signalType;
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
-
/***************/
/* Encode seed */
/***************/
/* Encode quantization indices of excitation */
/*********************************************/
-static inline opus_int combine_and_check( /* return ok */
- opus_int *pulses_comb, /* O */
- const opus_int *pulses_in, /* I */
- opus_int max_pulses, /* I max value for sum of pulses */
- opus_int len /* I number of output values */
+static inline opus_int combine_and_check( /* return ok */
+ opus_int *pulses_comb, /* O */
+ const opus_int *pulses_in, /* I */
+ opus_int max_pulses, /* I max value for sum of pulses */
+ opus_int len /* I number of output values */
)
{
opus_int k, sum;
/* Encode quantization indices of excitation */
void silk_encode_pulses(
- ec_enc *psRangeEnc, /* I/O compressor data structure */
- const opus_int signalType, /* I Sigtype */
- const opus_int quantOffsetType, /* I quantOffsetType */
- opus_int8 pulses[], /* I quantization indices */
- const opus_int frame_length /* I Frame length */
+ ec_enc *psRangeEnc, /* I/O compressor data structure */
+ const opus_int signalType, /* I Signal type &nbs