mirror of
https://github.com/xiph/opus.git
synced 2025-05-29 06:39:15 +00:00
Reformatting changes with an update to the MSVC project files
This commit is contained in:
parent
2d4f614091
commit
acc7a6c78b
151 changed files with 3736 additions and 4091 deletions
|
@ -43,14 +43,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define QPoly 16
|
#define QPoly 16
|
||||||
#define MAX_ITERATIONS_A2NLSF_FIX 30
|
#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(..) */
|
/* Helper function for A2NLSF(..) */
|
||||||
/* Transforms polynomials from cos(n*f) to cos(f)^n */
|
/* Transforms polynomials from cos(n*f) to cos(f)^n */
|
||||||
static inline void silk_A2NLSF_trans_poly(
|
static inline void silk_A2NLSF_trans_poly(
|
||||||
opus_int32 *p, /* I/O Polynomial */
|
opus_int32 *p, /* I/O Polynomial */
|
||||||
const opus_int dd /* I Polynomial order (= filter order / 2 ) */
|
const opus_int dd /* I Polynomial order (= filter order / 2 ) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, n;
|
opus_int k, n;
|
||||||
|
@ -62,21 +59,21 @@ static inline void silk_A2NLSF_trans_poly(
|
||||||
p[ k - 2 ] -= silk_LSHIFT( p[ k ], 1 );
|
p[ k - 2 ] -= silk_LSHIFT( p[ k ], 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Helper function for A2NLSF(..) */
|
/* Helper function for A2NLSF(..) */
|
||||||
/* Polynomial evaluation */
|
/* Polynomial evaluation */
|
||||||
static inline opus_int32 silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */
|
static inline opus_int32 silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */
|
||||||
opus_int32 *p, /* I Polynomial, QPoly */
|
opus_int32 *p, /* I Polynomial, QPoly */
|
||||||
const opus_int32 x, /* I Evaluation point, Q12 */
|
const opus_int32 x, /* I Evaluation point, Q12 */
|
||||||
const opus_int dd /* I Order */
|
const opus_int dd /* I Order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int n;
|
opus_int n;
|
||||||
opus_int32 x_Q16, y32;
|
opus_int32 x_Q16, y32;
|
||||||
|
|
||||||
y32 = p[ dd ]; /* QPoly */
|
y32 = p[ dd ]; /* QPoly */
|
||||||
x_Q16 = silk_LSHIFT( x, 4 );
|
x_Q16 = silk_LSHIFT( x, 4 );
|
||||||
for( n = dd - 1; n >= 0; n-- ) {
|
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;
|
return y32;
|
||||||
}
|
}
|
||||||
|
@ -119,12 +116,12 @@ static inline void silk_A2NLSF_init(
|
||||||
silk_A2NLSF_trans_poly( Q, dd );
|
silk_A2NLSF_trans_poly( Q, dd );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */
|
/* 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. */
|
/* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */
|
||||||
void silk_A2NLSF(
|
void silk_A2NLSF(
|
||||||
opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */
|
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] */
|
opus_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */
|
||||||
const opus_int d /* I Filter order (must be even) */
|
const opus_int d /* I Filter order (must be even) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, k, m, dd, root_ix, ffrac;
|
opus_int i, k, m, dd, root_ix, ffrac;
|
||||||
|
@ -145,7 +142,7 @@ void silk_A2NLSF(
|
||||||
silk_A2NLSF_init( a_Q16, P, Q, dd );
|
silk_A2NLSF_init( a_Q16, P, Q, dd );
|
||||||
|
|
||||||
/* Find roots, alternating between P and Q */
|
/* Find roots, alternating between P and Q */
|
||||||
p = P; /* Pointer to polynomial */
|
p = P; /* Pointer to polynomial */
|
||||||
|
|
||||||
xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; /* Q12*/
|
xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; /* Q12*/
|
||||||
ylo = silk_A2NLSF_eval_poly( p, xlo, dd );
|
ylo = silk_A2NLSF_eval_poly( p, xlo, dd );
|
||||||
|
@ -164,13 +161,7 @@ void silk_A2NLSF(
|
||||||
thr = 0;
|
thr = 0;
|
||||||
while( 1 ) {
|
while( 1 ) {
|
||||||
/* Evaluate polynomial */
|
/* 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 */
|
xhi = silk_LSFCosTab_FIX_Q12[ k ]; /* Q12 */
|
||||||
#endif
|
|
||||||
yhi = silk_A2NLSF_eval_poly( p, xhi, dd );
|
yhi = silk_A2NLSF_eval_poly( p, xhi, dd );
|
||||||
|
|
||||||
/* Detect zero crossing */
|
/* Detect zero crossing */
|
||||||
|
@ -183,11 +174,7 @@ void silk_A2NLSF(
|
||||||
thr = 0;
|
thr = 0;
|
||||||
}
|
}
|
||||||
/* Binary division */
|
/* Binary division */
|
||||||
#if OVERSAMPLE_COSINE_TABLE
|
|
||||||
ffrac = -128;
|
|
||||||
#else
|
|
||||||
ffrac = -256;
|
ffrac = -256;
|
||||||
#endif
|
|
||||||
for( m = 0; m < BIN_DIV_STEPS_A2NLSF_FIX; m++ ) {
|
for( m = 0; m < BIN_DIV_STEPS_A2NLSF_FIX; m++ ) {
|
||||||
/* Evaluate polynomial */
|
/* Evaluate polynomial */
|
||||||
xmid = silk_RSHIFT_ROUND( xlo + xhi, 1 );
|
xmid = silk_RSHIFT_ROUND( xlo + xhi, 1 );
|
||||||
|
@ -202,11 +189,7 @@ void silk_A2NLSF(
|
||||||
/* Increase frequency */
|
/* Increase frequency */
|
||||||
xlo = xmid;
|
xlo = xmid;
|
||||||
ylo = ymid;
|
ylo = ymid;
|
||||||
#if OVERSAMPLE_COSINE_TABLE
|
|
||||||
ffrac = silk_ADD_RSHIFT( ffrac, 64, m );
|
|
||||||
#else
|
|
||||||
ffrac = silk_ADD_RSHIFT( ffrac, 128, m );
|
ffrac = silk_ADD_RSHIFT( ffrac, 128, m );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,11 +205,7 @@ void silk_A2NLSF(
|
||||||
/* No risk of dividing by zero because abs(ylo - yhi) >= abs(ylo) >= 65536 */
|
/* 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 ) );
|
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 );
|
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 );
|
silk_assert( NLSF[ root_ix ] >= 0 );
|
||||||
|
|
||||||
|
@ -239,13 +218,7 @@ void silk_A2NLSF(
|
||||||
p = PQ[ root_ix & 1 ];
|
p = PQ[ root_ix & 1 ];
|
||||||
|
|
||||||
/* Evaluate polynomial */
|
/* 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*/
|
xlo = silk_LSFCosTab_FIX_Q12[ k - 1 ]; /* Q12*/
|
||||||
#endif
|
|
||||||
ylo = silk_LSHIFT( 1 - ( root_ix & 2 ), 12 );
|
ylo = silk_LSHIFT( 1 - ( root_ix & 2 ), 12 );
|
||||||
} else {
|
} else {
|
||||||
/* Increment loop counter */
|
/* Increment loop counter */
|
||||||
|
@ -254,11 +227,7 @@ void silk_A2NLSF(
|
||||||
ylo = yhi;
|
ylo = yhi;
|
||||||
thr = 0;
|
thr = 0;
|
||||||
|
|
||||||
#if OVERSAMPLE_COSINE_TABLE
|
|
||||||
if( k > 2 * LSF_COS_TAB_SZ_FIX ) {
|
|
||||||
#else
|
|
||||||
if( k > LSF_COS_TAB_SZ_FIX ) {
|
if( k > LSF_COS_TAB_SZ_FIX ) {
|
||||||
#endif
|
|
||||||
i++;
|
i++;
|
||||||
if( i > MAX_ITERATIONS_A2NLSF_FIX ) {
|
if( i > MAX_ITERATIONS_A2NLSF_FIX ) {
|
||||||
/* Set NLSFs to white spectrum and exit */
|
/* Set NLSFs to white spectrum and exit */
|
||||||
|
|
70
silk/API.h
70
silk/API.h
|
@ -43,9 +43,9 @@ extern "C"
|
||||||
|
|
||||||
/* Struct for TOC (Table of Contents) */
|
/* Struct for TOC (Table of Contents) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
opus_int VADFlag; /* Voice activity for packet */
|
opus_int VADFlag; /* Voice activity for packet */
|
||||||
opus_int VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in 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 inbandFECFlag; /* Flag indicating if packet contains in-band FEC */
|
||||||
} silk_TOC_struct;
|
} silk_TOC_struct;
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
@ -55,24 +55,24 @@ typedef struct {
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
/* Get size in bytes of the Silk encoder state */
|
/* Get size in bytes of the Silk encoder state */
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
opus_int silk_Get_Encoder_Size( /* O: Returns error code */
|
opus_int silk_Get_Encoder_Size( /* O Returns error code */
|
||||||
opus_int *encSizeBytes /* O: Number of bytes in SILK encoder state */
|
opus_int *encSizeBytes /* O Number of bytes in SILK encoder state */
|
||||||
);
|
);
|
||||||
|
|
||||||
/*************************/
|
/*************************/
|
||||||
/* Init or reset encoder */
|
/* Init or reset encoder */
|
||||||
/*************************/
|
/*************************/
|
||||||
opus_int silk_InitEncoder( /* O: Returns error code */
|
opus_int silk_InitEncoder( /* O Returns error code */
|
||||||
void *encState, /* I/O: State */
|
void *encState, /* I/O State */
|
||||||
silk_EncControlStruct *encStatus /* O: Encoder Status */
|
silk_EncControlStruct *encStatus /* O Encoder Status */
|
||||||
);
|
);
|
||||||
|
|
||||||
/***************************************/
|
/***************************************/
|
||||||
/* Read control structure from encoder */
|
/* Read control structure from encoder */
|
||||||
/***************************************/
|
/***************************************/
|
||||||
opus_int silk_QueryEncoder( /* O: Returns error code */
|
opus_int silk_QueryEncoder( /* O Returns error code */
|
||||||
const void *encState, /* I: State */
|
const void *encState, /* I State */
|
||||||
silk_EncControlStruct *encStatus /* O: Encoder Status */
|
silk_EncControlStruct *encStatus /* O Encoder Status */
|
||||||
);
|
);
|
||||||
|
|
||||||
/**************************/
|
/**************************/
|
||||||
|
@ -80,14 +80,14 @@ opus_int silk_QueryEncoder( /* O: Returns error c
|
||||||
/**************************/
|
/**************************/
|
||||||
/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */
|
/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */
|
||||||
/* encControl->payloadSize_ms is set to */
|
/* encControl->payloadSize_ms is set to */
|
||||||
opus_int silk_Encode( /* O: Returns error code */
|
opus_int silk_Encode( /* O Returns error code */
|
||||||
void *encState, /* I/O: State */
|
void *encState, /* I/O State */
|
||||||
silk_EncControlStruct *encControl, /* I: Control status */
|
silk_EncControlStruct *encControl, /* I Control status */
|
||||||
const opus_int16 *samplesIn, /* I: Speech sample input vector */
|
const opus_int16 *samplesIn, /* I Speech sample input vector */
|
||||||
opus_int nSamplesIn, /* I: Number of samples in input vector */
|
opus_int nSamplesIn, /* I Number of samples in input vector */
|
||||||
ec_enc *psRangeEnc, /* I/O Compressor data structure */
|
ec_enc *psRangeEnc, /* I/O Compressor data structure */
|
||||||
opus_int *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
|
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 */
|
const opus_int prefillFlag /* I Flag to indicate prefilling buffers no coding */
|
||||||
);
|
);
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
@ -97,38 +97,38 @@ opus_int silk_Encode( /* O: Returns error c
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
/* Get size in bytes of the Silk decoder state */
|
/* Get size in bytes of the Silk decoder state */
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
opus_int silk_Get_Decoder_Size( /* O: Returns error code */
|
opus_int silk_Get_Decoder_Size( /* O Returns error code */
|
||||||
opus_int *decSizeBytes /* O: Number of bytes in SILK decoder state */
|
opus_int *decSizeBytes /* O Number of bytes in SILK decoder state */
|
||||||
);
|
);
|
||||||
|
|
||||||
/*************************/
|
/*************************/
|
||||||
/* Init or Reset decoder */
|
/* Init or Reset decoder */
|
||||||
/*************************/
|
/*************************/
|
||||||
opus_int silk_InitDecoder( /* O: Returns error code */
|
opus_int silk_InitDecoder( /* O Returns error code */
|
||||||
void *decState /* I/O: State */
|
void *decState /* I/O State */
|
||||||
);
|
);
|
||||||
|
|
||||||
/******************/
|
/******************/
|
||||||
/* Decode a frame */
|
/* Decode a frame */
|
||||||
/******************/
|
/******************/
|
||||||
opus_int silk_Decode( /* O: Returns error code */
|
opus_int silk_Decode( /* O Returns error code */
|
||||||
void* decState, /* I/O: State */
|
void* decState, /* I/O State */
|
||||||
silk_DecControlStruct* decControl, /* I/O: Control Structure */
|
silk_DecControlStruct* decControl, /* I/O Control Structure */
|
||||||
opus_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode fec */
|
opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */
|
||||||
opus_int newPacketFlag, /* I: Indicates first decoder call for this packet */
|
opus_int newPacketFlag, /* I Indicates first decoder call for this packet */
|
||||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||||
opus_int16 *samplesOut, /* O: Decoded output speech vector */
|
opus_int16 *samplesOut, /* O Decoded output speech vector */
|
||||||
opus_int32 *nSamplesOut /* O: Number of samples decoded */
|
opus_int32 *nSamplesOut /* O Number of samples decoded */
|
||||||
);
|
);
|
||||||
|
|
||||||
/**************************************/
|
/**************************************/
|
||||||
/* Get table of contents for a packet */
|
/* Get table of contents for a packet */
|
||||||
/**************************************/
|
/**************************************/
|
||||||
opus_int silk_get_TOC(
|
opus_int silk_get_TOC(
|
||||||
const opus_uint8 *payload, /* I Payload data */
|
const opus_uint8 *payload, /* I Payload data */
|
||||||
const opus_int nBytesIn, /* I: Number of input bytes */
|
const opus_int nBytesIn, /* I Number of input bytes */
|
||||||
const opus_int nFramesPerPayload, /* I: Number of SILK frames per payload */
|
const opus_int nFramesPerPayload, /* I Number of SILK frames per payload */
|
||||||
silk_TOC_struct *Silk_TOC /* O: Type of content */
|
silk_TOC_struct *Silk_TOC /* O Type of content */
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
10
silk/CNG.c
10
silk/CNG.c
|
@ -60,7 +60,7 @@ static inline void silk_CNG_exc(
|
||||||
}
|
}
|
||||||
|
|
||||||
void silk_CNG_Reset(
|
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;
|
opus_int i, NLSF_step_Q15, NLSF_acc_Q15;
|
||||||
|
@ -77,10 +77,10 @@ void silk_CNG_Reset(
|
||||||
|
|
||||||
/* Updates CNG estimate, and applies the CNG when packet was lost */
|
/* Updates CNG estimate, and applies the CNG when packet was lost */
|
||||||
void silk_CNG(
|
void silk_CNG(
|
||||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||||
opus_int16 frame[], /* I/O Signal data */
|
opus_int16 frame[], /* I/O Signal */
|
||||||
opus_int length /* I Length of residual */
|
opus_int length /* I Length of residual */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j, subfr;
|
opus_int i, j, subfr;
|
||||||
|
|
|
@ -37,7 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
|
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
|
||||||
void silk_HP_variable_cutoff(
|
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;
|
opus_int quality_Q15;
|
||||||
|
|
|
@ -38,7 +38,7 @@ extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* count leading zeros of opus_int64 */
|
/* 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;
|
opus_int32 in_upper;
|
||||||
|
|
||||||
|
@ -53,9 +53,11 @@ static inline opus_int32 silk_CLZ64(opus_int64 in)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get number of leading zeros and fractional part (the bits right after the leading one */
|
/* 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 */
|
static inline void silk_CLZ_FRAC(
|
||||||
opus_int32 *lz, /* O: number of leading zeros */
|
opus_int32 in, /* I input */
|
||||||
opus_int32 *frac_Q7) /* O: the 7 bits right after the leading one */
|
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);
|
opus_int32 lzeros = silk_CLZ32(in);
|
||||||
|
|
||||||
|
@ -66,7 +68,7 @@ static inline void silk_CLZ_FRAC(opus_int32 in, /* I: input */
|
||||||
/* Approximation of square root */
|
/* Approximation of square root */
|
||||||
/* Accuracy: < +/- 10% for output values > 15 */
|
/* Accuracy: < +/- 10% for output values > 15 */
|
||||||
/* < +/- 2.5% for output values > 120 */
|
/* < +/- 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;
|
opus_int32 y, lz, frac_Q7;
|
||||||
|
|
||||||
|
@ -92,10 +94,10 @@ static inline opus_int32 silk_SQRT_APPROX(opus_int32 x)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Divide two int32 values and return result as int32 in a given Q-domain */
|
/* 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" */
|
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 a32, /* I numerator (Q0) */
|
||||||
const opus_int32 b32, /* I denominator (Q0) */
|
const opus_int32 b32, /* I denominator (Q0) */
|
||||||
const opus_int Qres /* I Q-domain of result (>= 0) */
|
const opus_int Qres /* I Q-domain of result (>= 0) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int a_headrm, b_headrm, lshift;
|
opus_int a_headrm, b_headrm, lshift;
|
||||||
|
@ -106,22 +108,22 @@ static inline opus_int32 silk_DIV32_varQ( /* O returns a good approximatio
|
||||||
|
|
||||||
/* Compute number of bits head room and normalize inputs */
|
/* Compute number of bits head room and normalize inputs */
|
||||||
a_headrm = silk_CLZ32( silk_abs(a32) ) - 1;
|
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;
|
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 */
|
/* 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 */
|
/* 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 */
|
/* 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 */
|
/* 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 */
|
/* 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 */
|
/* Convert to Qres domain */
|
||||||
lshift = 29 + a_headrm - b_headrm - Qres;
|
lshift = 29 + a_headrm - b_headrm - Qres;
|
||||||
|
@ -138,9 +140,9 @@ static inline opus_int32 silk_DIV32_varQ( /* O returns a good approximatio
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invert int32 value and return result as int32 in a given Q-domain */
|
/* 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" */
|
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_int32 b32, /* I denominator (Q0) */
|
||||||
const opus_int Qres /* I Q-domain of result (> 0) */
|
const opus_int Qres /* I Q-domain of result (> 0) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int b_headrm, lshift;
|
opus_int b_headrm, lshift;
|
||||||
|
@ -151,19 +153,19 @@ static inline opus_int32 silk_INVERSE32_varQ( /* O returns a good approxim
|
||||||
|
|
||||||
/* Compute number of bits head room and normalize input */
|
/* Compute number of bits head room and normalize input */
|
||||||
b_headrm = silk_CLZ32( silk_abs(b32) ) - 1;
|
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 */
|
/* 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 */
|
/* 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 */
|
/* 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 */
|
/* 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 */
|
/* Convert to Qres domain */
|
||||||
lshift = 61 - b_headrm - Qres;
|
lshift = 61 - b_headrm - Qres;
|
||||||
|
|
|
@ -39,11 +39,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
|
|
||||||
void silk_LPC_analysis_filter(
|
void silk_LPC_analysis_filter(
|
||||||
opus_int16 *out, /* O: Output signal */
|
opus_int16 *out, /* O Output signal */
|
||||||
const opus_int16 *in, /* I: Input signal */
|
const opus_int16 *in, /* I Input signal */
|
||||||
const opus_int16 *B, /* I: MA prediction coefficients, Q12 [order] */
|
const opus_int16 *B, /* I MA prediction coefficients, Q12 [order] */
|
||||||
const opus_int32 len, /* I: Signal length */
|
const opus_int32 len, /* I Signal length */
|
||||||
const opus_int32 d /* I: Filter order */
|
const opus_int32 d /* I Filter order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int ix, j;
|
opus_int ix, j;
|
||||||
|
@ -54,10 +54,10 @@ void silk_LPC_analysis_filter(
|
||||||
silk_assert( (d & 1) == 0 );
|
silk_assert( (d & 1) == 0 );
|
||||||
silk_assert( d <= len );
|
silk_assert( d <= len );
|
||||||
|
|
||||||
for ( ix = d; ix < len; ix++) {
|
for( ix = d; ix < len; ix++ ) {
|
||||||
in_ptr = &in[ ix - 1 ];
|
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
|
/* 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*/
|
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 ] );
|
out32_Q12 = silk_SMLABB_ovflw( out32_Q12, in_ptr[ -1 ], B[ 1 ] );
|
||||||
|
|
|
@ -31,18 +31,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "SigProc_FIX.h"
|
#include "SigProc_FIX.h"
|
||||||
|
|
||||||
#define QA 24
|
#define QA 24
|
||||||
#define A_LIMIT SILK_FIX_CONST( 0.99975, QA )
|
#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 */
|
/* Compute inverse of LPC prediction gain, and */
|
||||||
/* test if LPC coefficients are stable (all poles within unit circle) */
|
/* 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 */
|
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 *invGain_Q30, /* O Inverse prediction gain, Q30 energy domain */
|
||||||
opus_int32 A_QA[ 2 ][ SILK_MAX_ORDER_LPC ],
|
opus_int32 A_QA[ 2 ][ SILK_MAX_ORDER_LPC ], /* I Prediction coefficients */
|
||||||
/* I: Prediction coefficients */
|
const opus_int order /* I Prediction order */
|
||||||
const opus_int order /* I: Prediction order */
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, n, mult2Q;
|
opus_int k, n, mult2Q;
|
||||||
|
@ -108,10 +107,10 @@ static opus_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For input in Q12 domain */
|
/* For input in Q12 domain */
|
||||||
opus_int silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */
|
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 */
|
opus_int32 *invGain_Q30, /* O Inverse prediction gain, Q30 energy domain */
|
||||||
const opus_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */
|
const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */
|
||||||
const opus_int order /* I: Prediction order */
|
const opus_int order /* I Prediction order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k;
|
opus_int k;
|
||||||
|
@ -127,17 +126,17 @@ opus_int silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable,
|
||||||
Anew_QA[ k ] = silk_LSHIFT( (opus_int32)A_Q12[ k ], QA - 12 );
|
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 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 1;
|
||||||
}
|
}
|
||||||
return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order );
|
return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For input in Q24 domain */
|
/* For input in Q24 domain */
|
||||||
opus_int silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */
|
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 */
|
opus_int32 *invGain_Q30, /* O Inverse prediction gain, Q30 energy domain */
|
||||||
const opus_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */
|
const opus_int32 *A_Q24, /* I Prediction coefficients, Q24 [order] */
|
||||||
const opus_int order /* I: Prediction order */
|
const opus_int order /* I Prediction order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k;
|
opus_int k;
|
||||||
|
|
|
@ -30,12 +30,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Elliptic/Cauer filters designed with 0.1 dB passband ripple,
|
Elliptic/Cauer filters designed with 0.1 dB passband ripple,
|
||||||
80 dB minimum stopband attenuation, and
|
80 dB minimum stopband attenuation, and
|
||||||
[0.95 : 0.15 : 0.35] normalized cut off frequencies.
|
[0.95 : 0.15 : 0.35] normalized cut off frequencies.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
/* Helper function, interpolates the filter taps */
|
/* Helper function, interpolates the filter taps */
|
||||||
|
@ -99,9 +98,9 @@ static inline void silk_LP_interpolate_filter_taps(
|
||||||
/* Start by setting psEncC->mode <> 0; */
|
/* Start by setting psEncC->mode <> 0; */
|
||||||
/* Deactivate by setting psEncC->mode = 0; */
|
/* Deactivate by setting psEncC->mode = 0; */
|
||||||
void silk_LP_variable_cutoff(
|
void silk_LP_variable_cutoff(
|
||||||
silk_LP_state *psLP, /* I/O LP filter state */
|
silk_LP_state *psLP, /* I/O LP filter state */
|
||||||
opus_int16 *frame, /* I/O Low-pass filtered output */
|
opus_int16 *frame, /* I/O Low-pass filtered output signal */
|
||||||
const opus_int frame_length /* I Frame length */
|
const opus_int frame_length /* I Frame length */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int32 B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ], fac_Q16 = 0;
|
opus_int32 B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ], fac_Q16 = 0;
|
||||||
|
|
|
@ -33,7 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#if 0 && defined (_DEBUG) && !defined (silk_MACRO_COUNT)
|
#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){
|
static inline opus_int16 silk_ADD16(opus_int16 a, opus_int16 b){
|
||||||
opus_int16 ret;
|
opus_int16 ret;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ static inline opus_int16 silk_ADD16(opus_int16 a, opus_int16 b){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_ADD32
|
#undef silk_ADD32
|
||||||
static inline opus_int32 silk_ADD32(opus_int32 a, opus_int32 b){
|
static inline opus_int32 silk_ADD32(opus_int32 a, opus_int32 b){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ static inline opus_int32 silk_ADD32(opus_int32 a, opus_int32 b){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_ADD64
|
#undef silk_ADD64
|
||||||
static inline opus_int64 silk_ADD64(opus_int64 a, opus_int64 b){
|
static inline opus_int64 silk_ADD64(opus_int64 a, opus_int64 b){
|
||||||
opus_int64 ret;
|
opus_int64 ret;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ static inline opus_int64 silk_ADD64(opus_int64 a, opus_int64 b){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_SUB16
|
#undef silk_SUB16
|
||||||
static inline opus_int16 silk_SUB16(opus_int16 a, opus_int16 b){
|
static inline opus_int16 silk_SUB16(opus_int16 a, opus_int16 b){
|
||||||
opus_int16 ret;
|
opus_int16 ret;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ static inline opus_int16 silk_SUB16(opus_int16 a, opus_int16 b){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_SUB32
|
#undef silk_SUB32
|
||||||
static inline opus_int32 silk_SUB32(opus_int32 a, opus_int32 b){
|
static inline opus_int32 silk_SUB32(opus_int32 a, opus_int32 b){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ static inline opus_int32 silk_SUB32(opus_int32 a, opus_int32 b){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_SUB64
|
#undef silk_SUB64
|
||||||
static inline opus_int64 silk_SUB64(opus_int64 a, opus_int64 b){
|
static inline opus_int64 silk_SUB64(opus_int64 a, opus_int64 b){
|
||||||
opus_int64 ret;
|
opus_int64 ret;
|
||||||
|
|
||||||
|
@ -175,6 +175,7 @@ static inline opus_uint32 silk_MUL_uint(opus_uint32 a32, opus_uint32 b32){
|
||||||
silk_assert((opus_uint64)ret == (opus_uint64)a32 * (opus_uint64)b32); /* Check output overflow */
|
silk_assert((opus_uint64)ret == (opus_uint64)a32 * (opus_uint64)b32); /* Check output overflow */
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_MLA
|
#undef silk_MLA
|
||||||
static inline opus_int32 silk_MLA(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
static inline opus_int32 silk_MLA(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
|
@ -191,14 +192,15 @@ static inline opus_int32 silk_MLA_uint(opus_uint32 a32, opus_uint32 b32, opus_ui
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_SMULWB
|
#undef silk_SMULWB
|
||||||
static inline opus_int32 silk_SMULWB(opus_int32 a32, opus_int32 b32){
|
static inline opus_int32 silk_SMULWB(opus_int32 a32, opus_int32 b32){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16);
|
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);
|
silk_assert((opus_int64)ret == ((opus_int64)a32 * (opus_int16)b32) >> 16);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#undef silk_SMLAWB
|
|
||||||
|
#undef silk_SMLAWB
|
||||||
static inline opus_int32 silk_SMLAWB(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
static inline opus_int32 silk_SMLAWB(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
ret = silk_ADD32( a32, silk_SMULWB( b32, c32 ) );
|
ret = silk_ADD32( a32, silk_SMULWB( b32, c32 ) );
|
||||||
|
@ -213,6 +215,7 @@ static inline opus_int32 silk_SMULWT(opus_int32 a32, opus_int32 b32){
|
||||||
silk_assert((opus_int64)ret == ((opus_int64)a32 * (b32 >> 16)) >> 16);
|
silk_assert((opus_int64)ret == ((opus_int64)a32 * (b32 >> 16)) >> 16);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_SMLAWT
|
#undef silk_SMLAWT
|
||||||
static inline opus_int32 silk_SMLAWT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
static inline opus_int32 silk_SMLAWT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
|
@ -234,7 +237,7 @@ static inline opus_int64 silk_SMULL(opus_int64 a64, opus_int64 b64){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no checking needed for silk_SMULBB */
|
/* 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){
|
static inline opus_int32 silk_SMLABB(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32);
|
ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32);
|
||||||
|
@ -243,7 +246,7 @@ static inline opus_int32 silk_SMLABB(opus_int32 a32, opus_int32 b32, opus_int32
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no checking needed for silk_SMULBT */
|
/* 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){
|
static inline opus_int32 silk_SMLABT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16);
|
ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16);
|
||||||
|
@ -252,7 +255,7 @@ static inline opus_int32 silk_SMLABT(opus_int32 a32, opus_int32 b32, opus_int32
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no checking needed for silk_SMULTT */
|
/* 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){
|
static inline opus_int32 silk_SMLATT(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
ret = a32 + (b32 >> 16) * (c32 >> 16);
|
ret = a32 + (b32 >> 16) * (c32 >> 16);
|
||||||
|
@ -260,7 +263,7 @@ static inline opus_int32 silk_SMLATT(opus_int32 a32, opus_int32 b32, opus_int32
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_SMULWW
|
#undef silk_SMULWW
|
||||||
static inline opus_int32 silk_SMULWW(opus_int32 a32, opus_int32 b32){
|
static inline opus_int32 silk_SMULWW(opus_int32 a32, opus_int32 b32){
|
||||||
opus_int32 ret, tmp1, tmp2;
|
opus_int32 ret, tmp1, tmp2;
|
||||||
opus_int64 ret64;
|
opus_int64 ret64;
|
||||||
|
@ -281,7 +284,7 @@ static inline opus_int32 silk_SMULWW(opus_int32 a32, opus_int32 b32){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_SMLAWW
|
#undef silk_SMLAWW
|
||||||
static inline opus_int32 silk_SMLAWW(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
static inline opus_int32 silk_SMLAWW(opus_int32 a32, opus_int32 b32, opus_int32 c32){
|
||||||
opus_int32 ret, tmp;
|
opus_int32 ret, tmp;
|
||||||
|
|
||||||
|
@ -292,9 +295,9 @@ static inline opus_int32 silk_SMLAWW(opus_int32 a32, opus_int32 b32, opus_int32
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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) */
|
||||||
#undef silk_MLA_ovflw
|
#undef silk_MLA_ovflw
|
||||||
#define silk_MLA_ovflw(a32, b32, c32) ((a32) + ((b32) * (c32)))
|
#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)))
|
#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_SMULL
|
||||||
|
@ -325,7 +328,8 @@ static inline opus_int32 silk_DIV32_16(opus_int32 a32, opus_int32 b32){
|
||||||
no checking needed for silk_ADD_POS_SAT16
|
no checking needed for silk_ADD_POS_SAT16
|
||||||
no checking needed for silk_ADD_POS_SAT32
|
no checking needed for silk_ADD_POS_SAT32
|
||||||
no checking needed for silk_ADD_POS_SAT64 */
|
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){
|
static inline opus_int8 silk_LSHIFT8(opus_int8 a, opus_int32 shift){
|
||||||
opus_int8 ret;
|
opus_int8 ret;
|
||||||
ret = a << shift;
|
ret = a << shift;
|
||||||
|
@ -334,7 +338,8 @@ static inline opus_int8 silk_LSHIFT8(opus_int8 a, opus_int32 shift){
|
||||||
silk_assert((opus_int64)ret == ((opus_int64)a) << shift);
|
silk_assert((opus_int64)ret == ((opus_int64)a) << shift);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#undef silk_LSHIFT16
|
|
||||||
|
#undef silk_LSHIFT16
|
||||||
static inline opus_int16 silk_LSHIFT16(opus_int16 a, opus_int32 shift){
|
static inline opus_int16 silk_LSHIFT16(opus_int16 a, opus_int32 shift){
|
||||||
opus_int16 ret;
|
opus_int16 ret;
|
||||||
ret = a << shift;
|
ret = a << shift;
|
||||||
|
@ -343,7 +348,8 @@ static inline opus_int16 silk_LSHIFT16(opus_int16 a, opus_int32 shift){
|
||||||
silk_assert((opus_int64)ret == ((opus_int64)a) << shift);
|
silk_assert((opus_int64)ret == ((opus_int64)a) << shift);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#undef silk_LSHIFT32
|
|
||||||
|
#undef silk_LSHIFT32
|
||||||
static inline opus_int32 silk_LSHIFT32(opus_int32 a, opus_int32 shift){
|
static inline opus_int32 silk_LSHIFT32(opus_int32 a, opus_int32 shift){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
ret = a << shift;
|
ret = a << shift;
|
||||||
|
@ -352,20 +358,21 @@ static inline opus_int32 silk_LSHIFT32(opus_int32 a, opus_int32 shift){
|
||||||
silk_assert((opus_int64)ret == ((opus_int64)a) << shift);
|
silk_assert((opus_int64)ret == ((opus_int64)a) << shift);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#undef silk_LSHIFT64
|
|
||||||
|
#undef silk_LSHIFT64
|
||||||
static inline opus_int64 silk_LSHIFT64(opus_int64 a, opus_int shift){
|
static inline opus_int64 silk_LSHIFT64(opus_int64 a, opus_int shift){
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
silk_assert(shift < 64);
|
silk_assert(shift < 64);
|
||||||
return a << shift;
|
return a << shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_LSHIFT_ovflw
|
#undef silk_LSHIFT_ovflw
|
||||||
static inline opus_int32 silk_LSHIFT_ovflw(opus_int32 a, opus_int32 shift){
|
static inline opus_int32 silk_LSHIFT_ovflw(opus_int32 a, opus_int32 shift){
|
||||||
silk_assert(shift >= 0); /* no check for overflow */
|
silk_assert(shift >= 0); /* no check for overflow */
|
||||||
return a << shift;
|
return a << shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_LSHIFT_uint
|
#undef silk_LSHIFT_uint
|
||||||
static inline opus_uint32 silk_LSHIFT_uint(opus_uint32 a, opus_int32 shift){
|
static inline opus_uint32 silk_LSHIFT_uint(opus_uint32 a, opus_int32 shift){
|
||||||
opus_uint32 ret;
|
opus_uint32 ret;
|
||||||
ret = a << shift;
|
ret = a << shift;
|
||||||
|
@ -374,39 +381,42 @@ static inline opus_uint32 silk_LSHIFT_uint(opus_uint32 a, opus_int32 shift){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_RSHIFT8
|
#undef silk_RSHIFT8
|
||||||
static inline opus_int8 silk_RSHIFT8(opus_int8 a, opus_int32 shift){
|
static inline opus_int8 silk_RSHIFT8(opus_int8 a, opus_int32 shift){
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
silk_assert(shift < 8);
|
silk_assert(shift < 8);
|
||||||
return a >> shift;
|
return a >> shift;
|
||||||
}
|
}
|
||||||
#undef silk_RSHIFT16
|
|
||||||
|
#undef silk_RSHIFT16
|
||||||
static inline opus_int16 silk_RSHIFT16(opus_int16 a, opus_int32 shift){
|
static inline opus_int16 silk_RSHIFT16(opus_int16 a, opus_int32 shift){
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
silk_assert(shift < 16);
|
silk_assert(shift < 16);
|
||||||
return a >> shift;
|
return a >> shift;
|
||||||
}
|
}
|
||||||
#undef silk_RSHIFT32
|
|
||||||
|
#undef silk_RSHIFT32
|
||||||
static inline opus_int32 silk_RSHIFT32(opus_int32 a, opus_int32 shift){
|
static inline opus_int32 silk_RSHIFT32(opus_int32 a, opus_int32 shift){
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
silk_assert(shift < 32);
|
silk_assert(shift < 32);
|
||||||
return a >> shift;
|
return a >> shift;
|
||||||
}
|
}
|
||||||
#undef silk_RSHIFT64
|
|
||||||
|
#undef silk_RSHIFT64
|
||||||
static inline opus_int64 silk_RSHIFT64(opus_int64 a, opus_int64 shift){
|
static inline opus_int64 silk_RSHIFT64(opus_int64 a, opus_int64 shift){
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
silk_assert(shift <= 63);
|
silk_assert(shift <= 63);
|
||||||
return a >> shift;
|
return a >> shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_RSHIFT_uint
|
#undef silk_RSHIFT_uint
|
||||||
static inline opus_uint32 silk_RSHIFT_uint(opus_uint32 a, opus_int32 shift){
|
static inline opus_uint32 silk_RSHIFT_uint(opus_uint32 a, opus_int32 shift){
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
silk_assert(shift <= 32);
|
silk_assert(shift <= 32);
|
||||||
return a >> shift;
|
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){
|
static inline opus_int32 silk_ADD_LSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
|
@ -415,7 +425,8 @@ static inline opus_int32 silk_ADD_LSHIFT(opus_int32 a, opus_int32 b, opus_int32
|
||||||
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
|
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
|
||||||
return ret; /* shift >= 0 */
|
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){
|
static inline opus_int32 silk_ADD_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
|
@ -424,7 +435,8 @@ static inline opus_int32 silk_ADD_LSHIFT32(opus_int32 a, opus_int32 b, opus_int3
|
||||||
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
|
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
|
||||||
return ret; /* shift >= 0 */
|
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){
|
static inline opus_uint32 silk_ADD_LSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){
|
||||||
opus_uint32 ret;
|
opus_uint32 ret;
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
|
@ -433,7 +445,8 @@ static inline opus_uint32 silk_ADD_LSHIFT_uint(opus_uint32 a, opus_uint32 b, opu
|
||||||
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
|
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) << shift));
|
||||||
return ret; /* shift >= 0 */
|
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){
|
static inline opus_int32 silk_ADD_RSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
|
@ -442,7 +455,8 @@ static inline opus_int32 silk_ADD_RSHIFT(opus_int32 a, opus_int32 b, opus_int32
|
||||||
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
|
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
|
||||||
return ret; /* shift > 0 */
|
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){
|
static inline opus_int32 silk_ADD_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
|
@ -451,7 +465,8 @@ static inline opus_int32 silk_ADD_RSHIFT32(opus_int32 a, opus_int32 b, opus_int3
|
||||||
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
|
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
|
||||||
return ret; /* shift > 0 */
|
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){
|
static inline opus_uint32 silk_ADD_RSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){
|
||||||
opus_uint32 ret;
|
opus_uint32 ret;
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
|
@ -460,7 +475,8 @@ static inline opus_uint32 silk_ADD_RSHIFT_uint(opus_uint32 a, opus_uint32 b, opu
|
||||||
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
|
silk_assert((opus_int64)ret == (opus_int64)a + (((opus_int64)b) >> shift));
|
||||||
return ret; /* shift > 0 */
|
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){
|
static inline opus_int32 silk_SUB_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
|
@ -469,7 +485,8 @@ static inline opus_int32 silk_SUB_LSHIFT32(opus_int32 a, opus_int32 b, opus_int3
|
||||||
silk_assert((opus_int64)ret == (opus_int64)a - (((opus_int64)b) << shift));
|
silk_assert((opus_int64)ret == (opus_int64)a - (((opus_int64)b) << shift));
|
||||||
return ret; /* shift >= 0 */
|
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){
|
static inline opus_int32 silk_SUB_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
silk_assert(shift >= 0);
|
silk_assert(shift >= 0);
|
||||||
|
@ -479,7 +496,7 @@ static inline opus_int32 silk_SUB_RSHIFT32(opus_int32 a, opus_int32 b, opus_int3
|
||||||
return ret; /* 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){
|
static inline opus_int32 silk_RSHIFT_ROUND(opus_int32 a, opus_int32 shift){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
silk_assert(shift > 0); /* the marco definition can't handle a shift of zero */
|
silk_assert(shift > 0); /* the marco definition can't handle a shift of zero */
|
||||||
|
@ -489,7 +506,7 @@ static inline opus_int32 silk_RSHIFT_ROUND(opus_int32 a, opus_int32 shift){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_RSHIFT_ROUND64
|
#undef silk_RSHIFT_ROUND64
|
||||||
static inline opus_int64 silk_RSHIFT_ROUND64(opus_int64 a, opus_int32 shift){
|
static inline opus_int64 silk_RSHIFT_ROUND64(opus_int64 a, opus_int32 shift){
|
||||||
opus_int64 ret;
|
opus_int64 ret;
|
||||||
silk_assert(shift > 0); /* the marco definition can't handle a shift of zero */
|
silk_assert(shift > 0); /* the marco definition can't handle a shift of zero */
|
||||||
|
@ -499,25 +516,25 @@ static inline opus_int64 silk_RSHIFT_ROUND64(opus_int64 a, opus_int32 shift){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* silk_abs is used on floats also, so doesn't work... */
|
/* 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){
|
static inline opus_int32 silk_abs(opus_int32 a){
|
||||||
silk_assert(a != 0x80000000);
|
silk_assert(a != 0x80000000);
|
||||||
return (((a) > 0) ? (a) : -(a)); // Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN
|
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){
|
static inline opus_int64 silk_abs_int64(opus_int64 a){
|
||||||
silk_assert(a != 0x8000000000000000);
|
silk_assert(a != 0x8000000000000000);
|
||||||
return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */
|
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){
|
static inline opus_int32 silk_abs_int32(opus_int32 a){
|
||||||
silk_assert(a != 0x80000000);
|
silk_assert(a != 0x80000000);
|
||||||
return abs(a);
|
return abs(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_CHECK_FIT8
|
#undef silk_CHECK_FIT8
|
||||||
static inline opus_int8 silk_CHECK_FIT8( opus_int64 a ){
|
static inline opus_int8 silk_CHECK_FIT8( opus_int64 a ){
|
||||||
opus_int8 ret;
|
opus_int8 ret;
|
||||||
ret = (opus_int8)a;
|
ret = (opus_int8)a;
|
||||||
|
@ -525,7 +542,7 @@ static inline opus_int8 silk_CHECK_FIT8( opus_int64 a ){
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_CHECK_FIT16
|
#undef silk_CHECK_FIT16
|
||||||
static inline opus_int16 silk_CHECK_FIT16( opus_int64 a ){
|
static inline opus_int16 silk_CHECK_FIT16( opus_int64 a ){
|
||||||
opus_int16 ret;
|
opus_int16 ret;
|
||||||
ret = (opus_int16)a;
|
ret = (opus_int16)a;
|
||||||
|
@ -533,7 +550,7 @@ static inline opus_int16 silk_CHECK_FIT16( opus_int64 a ){
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef silk_CHECK_FIT32
|
#undef silk_CHECK_FIT32
|
||||||
static inline opus_int32 silk_CHECK_FIT32( opus_int64 a ){
|
static inline opus_int32 silk_CHECK_FIT32( opus_int64 a ){
|
||||||
opus_int32 ret;
|
opus_int32 ret;
|
||||||
ret = (opus_int32)a;
|
ret = (opus_int32)a;
|
||||||
|
|
|
@ -64,9 +64,9 @@ static inline void silk_NLSF2A_find_poly(
|
||||||
|
|
||||||
/* compute whitening filter coefficients from normalized line spectral frequencies */
|
/* compute whitening filter coefficients from normalized line spectral frequencies */
|
||||||
void silk_NLSF2A(
|
void silk_NLSF2A(
|
||||||
opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */
|
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_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */
|
||||||
const opus_int d /* I filter order (should be even) */
|
const opus_int d /* I filter order (should be even) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* This ordering was found to maximize quality. It improves numerical accuracy of
|
/* This ordering was found to maximize quality. It improves numerical accuracy of
|
||||||
|
|
|
@ -33,11 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
|
/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
|
||||||
void silk_NLSF_VQ(
|
void silk_NLSF_VQ(
|
||||||
opus_int32 err_Q26[], /* O Quantization errors [K] */
|
opus_int32 err_Q26[], /* O Quantization errors [K] */
|
||||||
const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */
|
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_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */
|
||||||
const opus_int K, /* I Number of codebook vectors */
|
const opus_int K, /* I Number of codebook vectors */
|
||||||
const opus_int LPC_order /* I Number of LPCs */
|
const opus_int LPC_order /* I Number of LPCs */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, m;
|
opus_int i, m;
|
||||||
|
|
|
@ -40,9 +40,9 @@ Signal Processing, pp. 641-644, 1991.
|
||||||
|
|
||||||
/* Laroia low complexity NLSF weights */
|
/* Laroia low complexity NLSF weights */
|
||||||
void silk_NLSF_VQ_weights_laroia(
|
void silk_NLSF_VQ_weights_laroia(
|
||||||
opus_int16 *pNLSFW_Q_OUT, /* O: Pointer to input vector weights [D x 1] */
|
opus_int16 *pNLSFW_Q_OUT, /* O Pointer to input vector weights [D] */
|
||||||
const opus_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */
|
const opus_int16 *pNLSF_Q15, /* I Pointer to input vector [D] */
|
||||||
const opus_int D /* I: Input vector dimension (even) */
|
const opus_int D /* I Input vector dimension (even) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k;
|
opus_int k;
|
||||||
|
|
|
@ -61,9 +61,9 @@ static inline void silk_NLSF_residual_dequant( /* O Returns RD
|
||||||
/* NLSF vector decoder */
|
/* NLSF vector decoder */
|
||||||
/***********************/
|
/***********************/
|
||||||
void silk_NLSF_decode(
|
void silk_NLSF_decode(
|
||||||
opus_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */
|
opus_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */
|
||||||
opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
|
opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
|
||||||
const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */
|
const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
|
|
@ -32,17 +32,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
/* Delayed-decision quantizer for NLSF residuals */
|
/* Delayed-decision quantizer for NLSF residuals */
|
||||||
opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */
|
opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */
|
||||||
opus_int8 indices[], /* O Quantization indices [ order ] */
|
opus_int8 indices[], /* O Quantization indices [ order ] */
|
||||||
const opus_int16 x_Q10[], /* I Input [ order ] */
|
const opus_int16 x_Q10[], /* I Input [ order ] */
|
||||||
const opus_int16 w_Q5[], /* I Weights [ order ] */
|
const opus_int16 w_Q5[], /* I Weights [ order ] */
|
||||||
const opus_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ 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_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */
|
||||||
const opus_uint8 ec_rates_Q5[], /* I Rates [] */
|
const opus_uint8 ec_rates_Q5[], /* I Rates [] */
|
||||||
const opus_int quant_step_size_Q16, /* I Quantization step size */
|
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_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */
|
||||||
const opus_int32 mu_Q20, /* I R/D tradeoff */
|
const opus_int32 mu_Q20, /* I R/D tradeoff */
|
||||||
const opus_int16 order /* I Number of input values */
|
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;
|
opus_int i, j, nStates, ind_tmp, ind_min_max, ind_max_min, in_Q10, res_Q10;
|
||||||
|
@ -182,7 +182,7 @@ opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD valu
|
||||||
ind[ j ][ i ] += silk_RSHIFT( ind_sort[ j ], NLSF_QUANT_DEL_DEC_STATES_LOG2 );
|
ind[ j ][ i ] += silk_RSHIFT( ind_sort[ j ], NLSF_QUANT_DEL_DEC_STATES_LOG2 );
|
||||||
}
|
}
|
||||||
} else { /* i == 0 */
|
} else { /* i == 0 */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,19 +31,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#define STORE_LSF_DATA_FOR_TRAINING 0
|
|
||||||
|
|
||||||
/***********************/
|
/***********************/
|
||||||
/* NLSF vector encoder */
|
/* NLSF vector encoder */
|
||||||
/***********************/
|
/***********************/
|
||||||
opus_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */
|
opus_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */
|
||||||
opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
|
opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
|
||||||
opus_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */
|
opus_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */
|
||||||
const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
|
const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
|
||||||
const opus_int16 *pW_QW, /* I NLSF weight vector [ LPC_ORDER ] */
|
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 NLSF_mu_Q20, /* I Rate weight for the RD optimization */
|
||||||
const opus_int nSurvivors, /* I Max survivors after first stage */
|
const opus_int nSurvivors, /* I Max survivors after first stage */
|
||||||
const opus_int signalType /* I Signal type: 0/1/2 */
|
const opus_int signalType /* I Signal type: 0/1/2 */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, s, ind1, bestIndex, prob_Q8, bits_q7;
|
opus_int i, s, ind1, bestIndex, prob_Q8, bits_q7;
|
||||||
|
@ -61,15 +59,6 @@ opus_int32 silk_NLSF_encode( /* O Returns RD
|
||||||
opus_int16 ec_ix[ MAX_LPC_ORDER ];
|
opus_int16 ec_ix[ MAX_LPC_ORDER ];
|
||||||
const opus_uint8 *pCB_element, *iCDF_ptr;
|
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( nSurvivors <= NLSF_VQ_MAX_SURVIVORS );
|
||||||
silk_assert( signalType >= 0 && signalType <= 2 );
|
silk_assert( signalType >= 0 && signalType <= 2 );
|
||||||
silk_assert( NLSF_mu_Q20 <= 32767 && NLSF_mu_Q20 >= 0 );
|
silk_assert( NLSF_mu_Q20 <= 32767 && NLSF_mu_Q20 >= 0 );
|
||||||
|
@ -135,53 +124,5 @@ opus_int32 silk_NLSF_encode( /* O Returns RD
|
||||||
/* Decode */
|
/* Decode */
|
||||||
silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB );
|
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 ];
|
return RD_Q25[ 0 ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* NLSF stabilizer, for a single input data vector */
|
/* NLSF stabilizer, for a single input data vector */
|
||||||
void silk_NLSF_stabilize(
|
void silk_NLSF_stabilize(
|
||||||
opus_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */
|
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_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 */
|
const opus_int L /* I Number of NLSF parameters in the input vector */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, I=0, k, loops;
|
opus_int i, I=0, k, loops;
|
||||||
|
@ -82,7 +82,7 @@ void silk_NLSF_stabilize(
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
/* Now check if the smallest distance non-negative */
|
/* Now check if the smallest distance non-negative */
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
if (min_diff_Q15 >= 0) {
|
if( min_diff_Q15 >= 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Unpack predictor values and indices for entropy coding tables */
|
/* Unpack predictor values and indices for entropy coding tables */
|
||||||
void silk_NLSF_unpack(
|
void silk_NLSF_unpack(
|
||||||
opus_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */
|
opus_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */
|
||||||
opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */
|
opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */
|
||||||
const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
|
const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
|
||||||
const opus_int CB1_index /* I Index of vector in first LSF codebook */
|
const opus_int CB1_index /* I Index of vector in first LSF codebook */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
|
155
silk/NSQ.c
155
silk/NSQ.c
|
@ -32,57 +32,57 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
static inline void silk_nsq_scale_states(
|
static inline void silk_nsq_scale_states(
|
||||||
const silk_encoder_state *psEncC, /* I Encoder State */
|
const silk_encoder_state *psEncC, /* I Encoder State */
|
||||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||||
const opus_int16 x[], /* I input in Q0 */
|
const opus_int16 x[], /* I input in Q0 */
|
||||||
opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */
|
opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */
|
||||||
const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */
|
const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */
|
||||||
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||||
opus_int subfr, /* I subframe number */
|
opus_int subfr, /* I subframe number */
|
||||||
const opus_int LTP_scale_Q14, /* I */
|
const opus_int LTP_scale_Q14, /* I */
|
||||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */
|
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */
|
||||||
const opus_int signal_type /* I Signal type */
|
const opus_int signal_type /* I Signal type */
|
||||||
);
|
);
|
||||||
|
|
||||||
static inline void silk_noise_shape_quantizer(
|
static inline void silk_noise_shape_quantizer(
|
||||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||||
opus_int signalType, /* I Signal type */
|
opus_int signalType, /* I Signal type */
|
||||||
const opus_int32 x_sc_Q10[], /* I */
|
const opus_int32 x_sc_Q10[], /* I */
|
||||||
opus_int8 pulses[], /* O */
|
opus_int8 pulses[], /* O */
|
||||||
opus_int16 xq[], /* O */
|
opus_int16 xq[], /* O */
|
||||||
opus_int32 sLTP_Q16[], /* I/O LTP state */
|
opus_int32 sLTP_Q16[], /* I/O LTP state */
|
||||||
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
||||||
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
||||||
const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */
|
const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */
|
||||||
opus_int lag, /* I Pitch lag */
|
opus_int lag, /* I Pitch lag */
|
||||||
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||||
opus_int Tilt_Q14, /* I Spectral tilt */
|
opus_int Tilt_Q14, /* I Spectral tilt */
|
||||||
opus_int32 LF_shp_Q14, /* I */
|
opus_int32 LF_shp_Q14, /* I */
|
||||||
opus_int32 Gain_Q16, /* I */
|
opus_int32 Gain_Q16, /* I */
|
||||||
opus_int Lambda_Q10, /* I */
|
opus_int Lambda_Q10, /* I */
|
||||||
opus_int offset_Q10, /* I */
|
opus_int offset_Q10, /* I */
|
||||||
opus_int length, /* I Input length */
|
opus_int length, /* I Input length */
|
||||||
opus_int shapingLPCOrder, /* I Noise shaping AR filter order */
|
opus_int shapingLPCOrder, /* I Noise shaping AR filter order */
|
||||||
opus_int predictLPCOrder /* I Prediction filter order */
|
opus_int predictLPCOrder /* I Prediction filter order */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_NSQ(
|
void silk_NSQ(
|
||||||
const silk_encoder_state *psEncC, /* I/O Encoder State */
|
const silk_encoder_state *psEncC, /* I/O Encoder State */
|
||||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||||
SideInfoIndices *psIndices, /* I/O Quantization Indices */
|
SideInfoIndices *psIndices, /* I/O Quantization Indices */
|
||||||
const opus_int16 x[], /* I prefiltered input signal */
|
const opus_int16 x[], /* I Prefiltered input signal */
|
||||||
opus_int8 pulses[], /* O quantized qulse signal */
|
opus_int8 pulses[], /* O Quantized pulse signal */
|
||||||
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefficients */
|
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 coefficients */
|
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 */
|
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 */
|
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_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
|
||||||
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */
|
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
|
||||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
|
||||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I */
|
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
|
||||||
const opus_int Lambda_Q10, /* I */
|
const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
|
||||||
const opus_int LTP_scale_Q14 /* I LTP state scaling */
|
const opus_int LTP_scale_Q14 /* I LTP state scaling */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, lag, start_idx, LSF_interpolation_flag;
|
opus_int k, lag, start_idx, LSF_interpolation_flag;
|
||||||
|
@ -159,36 +159,31 @@ void silk_NSQ(
|
||||||
/* Save quantized speech and noise shaping signals */
|
/* 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->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 ) );
|
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 */
|
/* silk_noise_shape_quantizer */
|
||||||
/***********************************/
|
/***********************************/
|
||||||
static inline void silk_noise_shape_quantizer(
|
static inline void silk_noise_shape_quantizer(
|
||||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||||
opus_int signalType, /* I Signal type */
|
opus_int signalType, /* I Signal type */
|
||||||
const opus_int32 x_sc_Q10[], /* I */
|
const opus_int32 x_sc_Q10[], /* I */
|
||||||
opus_int8 pulses[], /* O */
|
opus_int8 pulses[], /* O */
|
||||||
opus_int16 xq[], /* O */
|
opus_int16 xq[], /* O */
|
||||||
opus_int32 sLTP_Q16[], /* I/O LTP state */
|
opus_int32 sLTP_Q16[], /* I/O LTP state */
|
||||||
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
||||||
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
||||||
const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */
|
const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */
|
||||||
opus_int lag, /* I Pitch lag */
|
opus_int lag, /* I Pitch lag */
|
||||||
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||||
opus_int Tilt_Q14, /* I Spectral tilt */
|
opus_int Tilt_Q14, /* I Spectral tilt */
|
||||||
opus_int32 LF_shp_Q14, /* I */
|
opus_int32 LF_shp_Q14, /* I */
|
||||||
opus_int32 Gain_Q16, /* I */
|
opus_int32 Gain_Q16, /* I */
|
||||||
opus_int Lambda_Q10, /* I */
|
opus_int Lambda_Q10, /* I */
|
||||||
opus_int offset_Q10, /* I */
|
opus_int offset_Q10, /* I */
|
||||||
opus_int length, /* I Input length */
|
opus_int length, /* I Input length */
|
||||||
opus_int shapingLPCOrder, /* I Noise shaping AR filter order */
|
opus_int shapingLPCOrder, /* I Noise shaping AR filter order */
|
||||||
opus_int predictLPCOrder /* I Prediction filter order */
|
opus_int predictLPCOrder /* I Prediction filter order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j;
|
opus_int i, j;
|
||||||
|
@ -361,17 +356,17 @@ static inline void silk_noise_shape_quantizer(
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void silk_nsq_scale_states(
|
static inline void silk_nsq_scale_states(
|
||||||
const silk_encoder_state *psEncC, /* I Encoder State */
|
const silk_encoder_state *psEncC, /* I Encoder State */
|
||||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||||
const opus_int16 x[], /* I input in Q0 */
|
const opus_int16 x[], /* I input in Q0 */
|
||||||
opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */
|
opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */
|
||||||
const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */
|
const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */
|
||||||
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||||
opus_int subfr, /* I subframe number */
|
opus_int subfr, /* I subframe number */
|
||||||
const opus_int LTP_scale_Q14, /* I */
|
const opus_int LTP_scale_Q14, /* I */
|
||||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */
|
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */
|
||||||
const opus_int signal_type /* I Signal type */
|
const opus_int signal_type /* I Signal type */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, lag;
|
opus_int i, lag;
|
||||||
|
|
|
@ -58,17 +58,17 @@ static inline void silk_nsq_del_dec_scale_states(
|
||||||
const silk_encoder_state *psEncC, /* I Encoder State */
|
const silk_encoder_state *psEncC, /* I Encoder State */
|
||||||
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 */
|
NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
|
||||||
const opus_int16 x[], /* I Input in Q0 */
|
const opus_int16 x[], /* I Input in Q0 */
|
||||||
opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */
|
opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */
|
||||||
const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */
|
const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */
|
||||||
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||||
opus_int subfr, /* I Subframe number */
|
opus_int subfr, /* I Subframe number */
|
||||||
opus_int nStatesDelayedDecision, /* I Number of del dec states */
|
opus_int nStatesDelayedDecision, /* I Number of del dec states */
|
||||||
const opus_int LTP_scale_Q14, /* I LTP state scaling */
|
const opus_int LTP_scale_Q14, /* I LTP state scaling */
|
||||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */
|
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */
|
||||||
const opus_int signal_type, /* I Signal type */
|
const opus_int signal_type, /* I Signal type */
|
||||||
const opus_int decisionDelay /* I Decision delay */
|
const opus_int decisionDelay /* I Decision delay */
|
||||||
);
|
);
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
|
@ -77,48 +77,48 @@ static inline void silk_nsq_del_dec_scale_states(
|
||||||
static inline void silk_noise_shape_quantizer_del_dec(
|
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 */
|
NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
|
||||||
opus_int signalType, /* I Signal type */
|
opus_int signalType, /* I Signal type */
|
||||||
const opus_int32 x_Q10[], /* I */
|
const opus_int32 x_Q10[], /* I */
|
||||||
opus_int8 pulses[], /* O */
|
opus_int8 pulses[], /* O */
|
||||||
opus_int16 xq[], /* O */
|
opus_int16 xq[], /* O */
|
||||||
opus_int32 sLTP_Q16[], /* I/O LTP filter state */
|
opus_int32 sLTP_Q16[], /* I/O LTP filter state */
|
||||||
opus_int32 delayedGain_Q16[], /* I/O Gain delay buffer */
|
opus_int32 delayedGain_Q16[], /* I/O Gain delay buffer */
|
||||||
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
||||||
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
||||||
const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */
|
const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */
|
||||||
opus_int lag, /* I Pitch lag */
|
opus_int lag, /* I Pitch lag */
|
||||||
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||||
opus_int Tilt_Q14, /* I Spectral tilt */
|
opus_int Tilt_Q14, /* I Spectral tilt */
|
||||||
opus_int32 LF_shp_Q14, /* I */
|
opus_int32 LF_shp_Q14, /* I */
|
||||||
opus_int32 Gain_Q16, /* I */
|
opus_int32 Gain_Q16, /* I */
|
||||||
opus_int Lambda_Q10, /* I */
|
opus_int Lambda_Q10, /* I */
|
||||||
opus_int offset_Q10, /* I */
|
opus_int offset_Q10, /* I */
|
||||||
opus_int length, /* I Input length */
|
opus_int length, /* I Input length */
|
||||||
opus_int subfr, /* I Subframe number */
|
opus_int subfr, /* I Subframe number */
|
||||||
opus_int shapingLPCOrder, /* I Shaping LPC filter order */
|
opus_int shapingLPCOrder, /* I Shaping LPC filter order */
|
||||||
opus_int predictLPCOrder, /* I Prediction filter order */
|
opus_int predictLPCOrder, /* I Prediction filter order */
|
||||||
opus_int warping_Q16, /* I */
|
opus_int warping_Q16, /* I */
|
||||||
opus_int nStatesDelayedDecision, /* I Number of states in decision tree */
|
opus_int nStatesDelayedDecision, /* I Number of states in decision tree */
|
||||||
opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */
|
opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */
|
||||||
opus_int decisionDelay /* I */
|
opus_int decisionDelay /* I */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_NSQ_del_dec(
|
void silk_NSQ_del_dec(
|
||||||
const silk_encoder_state *psEncC, /* I/O Encoder State */
|
const silk_encoder_state *psEncC, /* I/O Encoder State */
|
||||||
silk_nsq_state *NSQ, /* I/O NSQ state */
|
silk_nsq_state *NSQ, /* I/O NSQ state */
|
||||||
SideInfoIndices *psIndices, /* I/O Quantization Indices */
|
SideInfoIndices *psIndices, /* I/O Quantization Indices */
|
||||||
const opus_int16 x[], /* I Prefiltered input signal */
|
const opus_int16 x[], /* I Prefiltered input signal */
|
||||||
opus_int8 pulses[], /* O Quantized pulse signal */
|
opus_int8 pulses[], /* O Quantized pulse signal */
|
||||||
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Prediction coefs */
|
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 LT 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 */
|
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 */
|
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_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
|
||||||
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */
|
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
|
||||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
|
||||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I */
|
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
|
||||||
const opus_int Lambda_Q10, /* I */
|
const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
|
||||||
const opus_int LTP_scale_Q14 /* I LTP state scaling */
|
const opus_int LTP_scale_Q14 /* I LTP state scaling */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr;
|
opus_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr;
|
||||||
|
@ -285,43 +285,38 @@ void silk_NSQ_del_dec(
|
||||||
/* Save quantized speech and noise shaping signals */
|
/* 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->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 ) );
|
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 */
|
/* Noise shape quantizer for one subframe */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
static inline void silk_noise_shape_quantizer_del_dec(
|
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 */
|
NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
|
||||||
opus_int signalType, /* I Signal type */
|
opus_int signalType, /* I Signal type */
|
||||||
const opus_int32 x_Q10[], /* I */
|
const opus_int32 x_Q10[], /* I */
|
||||||
opus_int8 pulses[], /* O */
|
opus_int8 pulses[], /* O */
|
||||||
opus_int16 xq[], /* O */
|
opus_int16 xq[], /* O */
|
||||||
opus_int32 sLTP_Q16[], /* I/O LTP filter state */
|
opus_int32 sLTP_Q16[], /* I/O LTP filter state */
|
||||||
opus_int32 delayedGain_Q16[], /* I/O Gain delay buffer */
|
opus_int32 delayedGain_Q16[], /* I/O Gain delay buffer */
|
||||||
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
const opus_int16 a_Q12[], /* I Short term prediction coefs */
|
||||||
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
const opus_int16 b_Q14[], /* I Long term prediction coefs */
|
||||||
const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */
|
const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */
|
||||||
opus_int lag, /* I Pitch lag */
|
opus_int lag, /* I Pitch lag */
|
||||||
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
opus_int32 HarmShapeFIRPacked_Q14, /* I */
|
||||||
opus_int Tilt_Q14, /* I Spectral tilt */
|
opus_int Tilt_Q14, /* I Spectral tilt */
|
||||||
opus_int32 LF_shp_Q14, /* I */
|
opus_int32 LF_shp_Q14, /* I */
|
||||||
opus_int32 Gain_Q16, /* I */
|
opus_int32 Gain_Q16, /* I */
|
||||||
opus_int Lambda_Q10, /* I */
|
opus_int Lambda_Q10, /* I */
|
||||||
opus_int offset_Q10, /* I */
|
opus_int offset_Q10, /* I */
|
||||||
opus_int length, /* I Input length */
|
opus_int length, /* I Input length */
|
||||||
opus_int subfr, /* I Subframe number */
|
opus_int subfr, /* I Subframe number */
|
||||||
opus_int shapingLPCOrder, /* I Shaping LPC filter order */
|
opus_int shapingLPCOrder, /* I Shaping LPC filter order */
|
||||||
opus_int predictLPCOrder, /* I Prediction filter order */
|
opus_int predictLPCOrder, /* I Prediction filter order */
|
||||||
opus_int warping_Q16, /* I */
|
opus_int warping_Q16, /* I */
|
||||||
opus_int nStatesDelayedDecision, /* I Number of states in decision tree */
|
opus_int nStatesDelayedDecision, /* I Number of states in decision tree */
|
||||||
opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */
|
opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */
|
||||||
opus_int decisionDelay /* I */
|
opus_int decisionDelay /* I */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx;
|
opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx;
|
||||||
|
@ -605,17 +600,17 @@ static inline void silk_nsq_del_dec_scale_states(
|
||||||
const silk_encoder_state *psEncC, /* I Encoder State */
|
const silk_encoder_state *psEncC, /* I Encoder State */
|
||||||
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 */
|
NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
|
||||||
const opus_int16 x[], /* I Input in Q0 */
|
const opus_int16 x[], /* I Input in Q0 */
|
||||||
opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */
|
opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */
|
||||||
const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */
|
const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */
|
||||||
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */
|
||||||
opus_int subfr, /* I Subframe number */
|
opus_int subfr, /* I Subframe number */
|
||||||
opus_int nStatesDelayedDecision, /* I Number of del dec states */
|
opus_int nStatesDelayedDecision, /* I Number of del dec states */
|
||||||
const opus_int LTP_scale_Q14, /* I LTP state scaling */
|
const opus_int LTP_scale_Q14, /* I LTP state scaling */
|
||||||
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
|
||||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */
|
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */
|
||||||
const opus_int signal_type, /* I Signal type */
|
const opus_int signal_type, /* I Signal type */
|
||||||
const opus_int decisionDelay /* I Decision delay */
|
const opus_int decisionDelay /* I Decision delay */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, k, lag;
|
opus_int i, k, lag;
|
||||||
|
|
38
silk/PLC.c
38
silk/PLC.c
|
@ -38,29 +38,29 @@ static const opus_int16 PLC_RAND_ATTENUATE_V_Q15[NB_ATT] = { 31130, 26214 }; /*
|
||||||
static const opus_int16 PLC_RAND_ATTENUATE_UV_Q15[NB_ATT] = { 32440, 29491 }; /* 0.99, 0.9 */
|
static const opus_int16 PLC_RAND_ATTENUATE_UV_Q15[NB_ATT] = { 32440, 29491 }; /* 0.99, 0.9 */
|
||||||
|
|
||||||
static inline void silk_PLC_update(
|
static inline void silk_PLC_update(
|
||||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||||
silk_decoder_control *psDecCtrl /* I/O Decoder control */
|
silk_decoder_control *psDecCtrl /* I/O Decoder control */
|
||||||
);
|
);
|
||||||
|
|
||||||
static inline void silk_PLC_conceal(
|
static inline void silk_PLC_conceal(
|
||||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||||
opus_int16 signal[] /* O LPC residual signal */
|
opus_int16 signal[] /* O LPC residual signal */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
void silk_PLC_Reset(
|
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 );
|
psDec->sPLC.pitchL_Q8 = silk_RSHIFT( psDec->frame_length, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void silk_PLC(
|
void silk_PLC(
|
||||||
silk_decoder_state *psDec, /* I Decoder state */
|
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||||
silk_decoder_control *psDecCtrl, /* I Decoder control */
|
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||||
opus_int16 frame[], /* O Concealed signal */
|
opus_int16 frame[], /* I/O signal */
|
||||||
opus_int lost /* I Loss flag */
|
opus_int lost /* I Loss flag */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* PLC control function */
|
/* PLC control function */
|
||||||
|
@ -88,8 +88,8 @@ void silk_PLC(
|
||||||
/* Update state of PLC */
|
/* Update state of PLC */
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
static inline void silk_PLC_update(
|
static inline void silk_PLC_update(
|
||||||
silk_decoder_state *psDec, /* (I/O) Decoder state */
|
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||||
silk_decoder_control *psDecCtrl /* (I/O) Decoder control */
|
silk_decoder_control *psDecCtrl /* I/O Decoder control */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int32 LTP_Gain_Q14, temp_LTP_Gain_Q14;
|
opus_int32 LTP_Gain_Q14, temp_LTP_Gain_Q14;
|
||||||
|
@ -104,7 +104,7 @@ static inline void silk_PLC_update(
|
||||||
if( psDec->indices.signalType == TYPE_VOICED ) {
|
if( psDec->indices.signalType == TYPE_VOICED ) {
|
||||||
/* Find the parameters for the last subframe which contains a pitch pulse */
|
/* 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++ ) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
temp_LTP_Gain_Q14 = 0;
|
temp_LTP_Gain_Q14 = 0;
|
||||||
|
@ -160,9 +160,9 @@ static inline void silk_PLC_update(
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void silk_PLC_conceal(
|
static inline void silk_PLC_conceal(
|
||||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||||
opus_int16 frame[] /* O concealed signal */
|
opus_int16 frame[] /* O LPC residual signal */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j, k;
|
opus_int i, j, k;
|
||||||
|
@ -344,9 +344,9 @@ static inline void silk_PLC_conceal(
|
||||||
|
|
||||||
/* Glues concealed frames with new good recieved frames */
|
/* Glues concealed frames with new good recieved frames */
|
||||||
void silk_PLC_glue_frames(
|
void silk_PLC_glue_frames(
|
||||||
silk_decoder_state *psDec, /* I/O decoder state */
|
silk_decoder_state *psDec, /* I/O decoder state */
|
||||||
opus_int16 frame[], /* I/O signal */
|
opus_int16 frame[], /* I/O signal */
|
||||||
opus_int length /* I length of residual */
|
opus_int length /* I length of signal */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, energy_shift;
|
opus_int i, energy_shift;
|
||||||
|
|
28
silk/PLC.h
28
silk/PLC.h
|
@ -31,32 +31,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#define BWE_COEF 0.99
|
#define BWE_COEF 0.99
|
||||||
#define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 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 V_PITCH_GAIN_START_MAX_Q14 15565 /* 0.95 in Q14 */
|
||||||
#define MAX_PITCH_LAG_MS 18
|
#define MAX_PITCH_LAG_MS 18
|
||||||
#define SA_THRES_Q8 50
|
#define SA_THRES_Q8 50
|
||||||
#define USE_SINGLE_TAP 1
|
#define USE_SINGLE_TAP 1
|
||||||
#define RAND_BUF_SIZE 128
|
#define RAND_BUF_SIZE 128
|
||||||
#define RAND_BUF_MASK (RAND_BUF_SIZE - 1)
|
#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_HIGH_THRES 3 /* 2^3 = 8 dB LPC gain */
|
||||||
#define LOG2_INV_LPC_GAIN_LOW_THRES 8 /* 2^8 = 24 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 PITCH_DRIFT_FAC_Q16 655 /* 0.01 in Q16 */
|
||||||
|
|
||||||
void silk_PLC_Reset(
|
void silk_PLC_Reset(
|
||||||
silk_decoder_state *psDec /* I/O Decoder state */
|
silk_decoder_state *psDec /* I/O Decoder state */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_PLC(
|
void silk_PLC(
|
||||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||||
opus_int16 signal[], /* I/O signal */
|
opus_int16 frame[], /* I/O signal */
|
||||||
opus_int lost /* I Loss flag */
|
opus_int lost /* I Loss flag */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_PLC_glue_frames(
|
void silk_PLC_glue_frames(
|
||||||
silk_decoder_state *psDec, /* I/O decoder state */
|
silk_decoder_state *psDec, /* I/O decoder state */
|
||||||
opus_int16 signal[], /* I/O signal */
|
opus_int16 frame[], /* I/O signal */
|
||||||
opus_int length /* I length of signal */
|
opus_int length /* I length of signal */
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,10 +35,10 @@ extern "C"
|
||||||
|
|
||||||
/*#define silk_MACRO_COUNT */ /* Used to enable WMOPS counting */
|
/*#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 <stdlib.h> /* for abs() */
|
||||||
#include <string.h> /* for memset(), memcpy(), memmove() */
|
#include <string.h> /* for memset(), memcpy(), memmove() */
|
||||||
#include "typedef.h"
|
#include "typedef.h"
|
||||||
#include "resampler_structs.h"
|
#include "resampler_structs.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
@ -52,39 +52,39 @@ extern "C"
|
||||||
* Initialize/reset the resampler state for a given pair of input/output sampling rates
|
* Initialize/reset the resampler state for a given pair of input/output sampling rates
|
||||||
*/
|
*/
|
||||||
opus_int silk_resampler_init(
|
opus_int silk_resampler_init(
|
||||||
silk_resampler_state_struct *S, /* I/O: Resampler state */
|
silk_resampler_state_struct *S, /* I/O Resampler state */
|
||||||
opus_int32 Fs_Hz_in, /* I: Input sampling rate (Hz) */
|
opus_int32 Fs_Hz_in, /* I Input sampling rate (Hz) */
|
||||||
opus_int32 Fs_Hz_out /* I: Output sampling rate (Hz) */
|
opus_int32 Fs_Hz_out /* I Output sampling rate (Hz) */
|
||||||
);
|
);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Resampler: convert from one sampling rate to another
|
* Resampler: convert from one sampling rate to another
|
||||||
*/
|
*/
|
||||||
opus_int silk_resampler(
|
opus_int silk_resampler(
|
||||||
silk_resampler_state_struct *S, /* I/O: Resampler state */
|
silk_resampler_state_struct *S, /* I/O Resampler state */
|
||||||
opus_int16 out[], /* O: Output signal */
|
opus_int16 out[], /* O Output signal */
|
||||||
const opus_int16 in[], /* I: Input signal */
|
const opus_int16 in[], /* I Input signal */
|
||||||
opus_int32 inLen /* I: Number of input samples */
|
opus_int32 inLen /* I Number of input samples */
|
||||||
);
|
);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Downsample 2x, mediocre quality
|
* Downsample 2x, mediocre quality
|
||||||
*/
|
*/
|
||||||
void silk_resampler_down2(
|
void silk_resampler_down2(
|
||||||
opus_int32 *S, /* I/O: State vector [ 2 ] */
|
opus_int32 *S, /* I/O State vector [ 2 ] */
|
||||||
opus_int16 *out, /* O: Output signal [ len ] */
|
opus_int16 *out, /* O Output signal [ len ] */
|
||||||
const opus_int16 *in, /* I: Input signal [ floor(len/2) ] */
|
const opus_int16 *in, /* I Input signal [ floor(len/2) ] */
|
||||||
opus_int32 inLen /* I: Number of input samples */
|
opus_int32 inLen /* I Number of input samples */
|
||||||
);
|
);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Downsample by a factor 2/3, low quality
|
* Downsample by a factor 2/3, low quality
|
||||||
*/
|
*/
|
||||||
void silk_resampler_down2_3(
|
void silk_resampler_down2_3(
|
||||||
opus_int32 *S, /* I/O: State vector [ 6 ] */
|
opus_int32 *S, /* I/O State vector [ 6 ] */
|
||||||
opus_int16 *out, /* O: Output signal [ floor(2*inLen/3) ] */
|
opus_int16 *out, /* O Output signal [ floor(2*inLen/3) ] */
|
||||||
const opus_int16 *in, /* I: Input signal [ inLen ] */
|
const opus_int16 *in, /* I Input signal [ inLen ] */
|
||||||
opus_int32 inLen /* I: Number of input samples */
|
opus_int32 inLen /* I Number of input samples */
|
||||||
);
|
);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -93,268 +93,269 @@ void silk_resampler_down2_3(
|
||||||
* can handle (slowly) varying coefficients
|
* can handle (slowly) varying coefficients
|
||||||
*/
|
*/
|
||||||
void silk_biquad_alt(
|
void silk_biquad_alt(
|
||||||
const opus_int16 *in, /* I: input signal */
|
const opus_int16 *in, /* I input signal */
|
||||||
const opus_int32 *B_Q28, /* I: MA coefficients [3] */
|
const opus_int32 *B_Q28, /* I MA coefficients [3] */
|
||||||
const opus_int32 *A_Q28, /* I: AR coefficients [2] */
|
const opus_int32 *A_Q28, /* I AR coefficients [2] */
|
||||||
opus_int32 *S, /* I/O: State vector [2] */
|
opus_int32 *S, /* I/O State vector [2] */
|
||||||
opus_int16 *out, /* O: output signal */
|
opus_int16 *out, /* O output signal */
|
||||||
const opus_int32 len, /* I: signal length (must be even) */
|
const opus_int32 len, /* I signal length (must be even) */
|
||||||
opus_int stride /* I: Operate on interleaved signal if > 1 */
|
opus_int stride /* I Operate on interleaved signal if > 1 */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Variable order MA prediction error filter. */
|
/* Variable order MA prediction error filter. */
|
||||||
void silk_LPC_analysis_filter(
|
void silk_LPC_analysis_filter(
|
||||||
opus_int16 *out, /* O: Output signal */
|
opus_int16 *out, /* O Output signal */
|
||||||
const opus_int16 *in, /* I: Input signal */
|
const opus_int16 *in, /* I Input signal */
|
||||||
const opus_int16 *B, /* I: MA prediction coefficients, Q12 [order] */
|
const opus_int16 *B, /* I MA prediction coefficients, Q12 [order] */
|
||||||
const opus_int32 len, /* I: Signal length */
|
const opus_int32 len, /* I Signal length */
|
||||||
const opus_int32 Order /* I: Filter order */
|
const opus_int32 d /* I Filter order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Chirp (bandwidth expand) LP AR filter */
|
/* Chirp (bandwidth expand) LP AR filter */
|
||||||
void silk_bwexpander(
|
void silk_bwexpander(
|
||||||
opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||||
const opus_int d, /* I Length of ar */
|
const opus_int d, /* I Length of ar */
|
||||||
opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
|
opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Chirp (bandwidth expand) LP AR filter */
|
/* Chirp (bandwidth expand) LP AR filter */
|
||||||
void silk_bwexpander_32(
|
void silk_bwexpander_32(
|
||||||
opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||||
const opus_int d, /* I Length of ar */
|
const opus_int d, /* I Length of ar */
|
||||||
opus_int32 chirp_Q16 /* I Chirp factor in Q16 */
|
opus_int32 chirp_Q16 /* I Chirp factor in Q16 */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Compute inverse of LPC prediction gain, and */
|
/* Compute inverse of LPC prediction gain, and */
|
||||||
/* test if LPC coefficients are stable (all poles within unit circle) */
|
/* 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_int silk_LPC_inverse_pred_gain( /* O Returns 1 if unstable, otherwise 0 */
|
||||||
opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
|
opus_int32 *invGain_Q30, /* O Inverse prediction gain, Q30 energy domain */
|
||||||
const opus_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */
|
const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */
|
||||||
const opus_int order /* I: Prediction order */
|
const opus_int order /* I Prediction order */
|
||||||
);
|
);
|
||||||
|
|
||||||
opus_int silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */
|
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 */
|
opus_int32 *invGain_Q30, /* O Inverse prediction gain, Q30 energy domain */
|
||||||
const opus_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */
|
const opus_int32 *A_Q24, /* I Prediction coefficients, Q24 [order] */
|
||||||
const opus_int order /* I: Prediction 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(
|
void silk_ana_filt_bank_1(
|
||||||
const opus_int16 *in, /* I: Input signal [N] */
|
const opus_int16 *in, /* I Input signal [N] */
|
||||||
opus_int32 *S, /* I/O: State vector [2] */
|
opus_int32 *S, /* I/O State vector [2] */
|
||||||
opus_int16 *outL, /* O: Low band [N/2] */
|
opus_int16 *outL, /* O Low band [N/2] */
|
||||||
opus_int16 *outH, /* O: High band [N/2] */
|
opus_int16 *outH, /* O High band [N/2] */
|
||||||
const opus_int32 N /* I: Number of input samples */
|
const opus_int32 N /* I Number of input samples */
|
||||||
);
|
);
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
/* SCALAR FUNCTIONS */
|
/* SCALAR FUNCTIONS */
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
|
||||||
/* approximation of 128 * log2() (exact inverse of approx 2^() below) */
|
/* Approximation of 128 * log2() (exact inverse of approx 2^() below) */
|
||||||
/* convert input to a log scale */
|
/* Convert input to a log scale */
|
||||||
opus_int32 silk_lin2log(const opus_int32 inLin); /* I: input in linear scale */
|
opus_int32 silk_lin2log(
|
||||||
|
const opus_int32 inLin /* I input in linear scale */
|
||||||
|
);
|
||||||
|
|
||||||
/* Approximation of a sigmoid function */
|
/* 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) */
|
/* Approximation of 2^() (exact inverse of approx log2() above) */
|
||||||
/* convert input to a linear scale */
|
/* Convert input to a linear scale */
|
||||||
opus_int32 silk_log2lin(const opus_int32 inLog_Q7); /* I: input on log scale */
|
opus_int32 silk_log2lin(
|
||||||
|
const opus_int32 inLog_Q7 /* I input on log scale */
|
||||||
|
);
|
||||||
|
|
||||||
/* Function that returns the maximum absolut value of the input vector */
|
/* 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 */
|
opus_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */
|
||||||
const opus_int16 *vec, /* I Input vector [len] */
|
const opus_int16 *vec, /* I Input vector [len] */
|
||||||
const opus_int32 len /* I Length of input vector */
|
const opus_int32 len /* I Length of input vector */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Compute number of bits to right shift the sum of squares of a vector */
|
/* Compute number of bits to right shift the sum of squares of a vector */
|
||||||
/* of int16s to make it fit in an int32 */
|
/* of int16s to make it fit in an int32 */
|
||||||
void silk_sum_sqr_shift(
|
void silk_sum_sqr_shift(
|
||||||
opus_int32 *energy, /* O Energy of x, after shifting to the right */
|
opus_int32 *energy, /* O Energy of x, after shifting to the right */
|
||||||
opus_int *shift, /* O Number of bits right shift applied to energy */
|
opus_int *shift, /* O Number of bits right shift applied to energy */
|
||||||
const opus_int16 *x, /* I Input vector */
|
const opus_int16 *x, /* I Input vector */
|
||||||
opus_int len /* I Length of input vector */
|
opus_int len /* I Length of input vector */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Calculates the reflection coefficients from the correlation sequence */
|
/* Calculates the reflection coefficients from the correlation sequence */
|
||||||
/* Faster than schur64(), but much less accurate. */
|
/* Faster than schur64(), but much less accurate. */
|
||||||
/* uses SMLAWB(), requiring armv5E and higher. */
|
/* uses SMLAWB(), requiring armv5E and higher. */
|
||||||
opus_int32 silk_schur( /* O: Returns residual energy */
|
opus_int32 silk_schur( /* O Returns residual energy */
|
||||||
opus_int16 *rc_Q15, /* O: reflection coefficients [order] Q15 */
|
opus_int16 *rc_Q15, /* O reflection coefficients [order] Q15 */
|
||||||
const opus_int32 *c, /* I: correlations [order+1] */
|
const opus_int32 *c, /* I correlations [order+1] */
|
||||||
const opus_int32 order /* I: prediction order */
|
const opus_int32 order /* I prediction order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Calculates the reflection coefficients from the correlation sequence */
|
/* Calculates the reflection coefficients from the correlation sequence */
|
||||||
/* Slower than schur(), but more accurate. */
|
/* Slower than schur(), but more accurate. */
|
||||||
/* Uses SMULL(), available on armv4 */
|
/* Uses SMULL(), available on armv4 */
|
||||||
opus_int32 silk_schur64( /* O: returns residual energy */
|
opus_int32 silk_schur64( /* O returns residual energy */
|
||||||
opus_int32 rc_Q16[], /* O: Reflection coefficients [order] Q16 */
|
opus_int32 rc_Q16[], /* O Reflection coefficients [order] Q16 */
|
||||||
const opus_int32 c[], /* I: Correlations [order+1] */
|
const opus_int32 c[], /* I Correlations [order+1] */
|
||||||
opus_int32 order /* I: Prediction order */
|
opus_int32 order /* I Prediction order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Step up function, converts reflection coefficients to prediction coefficients */
|
/* Step up function, converts reflection coefficients to prediction coefficients */
|
||||||
void silk_k2a(
|
void silk_k2a(
|
||||||
opus_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
|
opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */
|
||||||
const opus_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */
|
const opus_int16 *rc_Q15, /* I Reflection coefficients [order] Q15 */
|
||||||
const opus_int32 order /* I: Prediction order */
|
const opus_int32 order /* I Prediction order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Step up function, converts reflection coefficients to prediction coefficients */
|
/* Step up function, converts reflection coefficients to prediction coefficients */
|
||||||
void silk_k2a_Q16(
|
void silk_k2a_Q16(
|
||||||
opus_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
|
opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */
|
||||||
const opus_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */
|
const opus_int32 *rc_Q16, /* I Reflection coefficients [order] Q16 */
|
||||||
const opus_int32 order /* I: Prediction order */
|
const opus_int32 order /* I Prediction order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Apply sine window to signal vector. */
|
/* Apply sine window to signal vector. */
|
||||||
/* Window types: */
|
/* Window types: */
|
||||||
/* 1 -> sine window from 0 to pi/2 */
|
/* 1 -> sine window from 0 to pi/2 */
|
||||||
/* 2 -> sine window from pi/2 to pi */
|
/* 2 -> sine window from pi/2 to pi */
|
||||||
/* every other sample of window is linearly interpolated, for speed */
|
/* every other sample of window is linearly interpolated, for speed */
|
||||||
void silk_apply_sine_window(
|
void silk_apply_sine_window(
|
||||||
opus_int16 px_win[], /* O Pointer to windowed signal */
|
opus_int16 px_win[], /* O Pointer to windowed signal */
|
||||||
const opus_int16 px[], /* I Pointer to input signal */
|
const opus_int16 px[], /* I Pointer to input signal */
|
||||||
const opus_int win_type, /* I Selects a window type */
|
const opus_int win_type, /* I Selects a window type */
|
||||||
const opus_int length /* I Window length, multiple of 4 */
|
const opus_int length /* I Window length, multiple of 4 */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Compute autocorrelation */
|
/* Compute autocorrelation */
|
||||||
void silk_autocorr(
|
void silk_autocorr(
|
||||||
opus_int32 *results, /* O Result (length correlationCount) */
|
opus_int32 *results, /* O Result (length correlationCount) */
|
||||||
opus_int *scale, /* O Scaling of the correlation vector */
|
opus_int *scale, /* O Scaling of the correlation vector */
|
||||||
const opus_int16 *inputData, /* I Input data to correlate */
|
const opus_int16 *inputData, /* I Input data to correlate */
|
||||||
const opus_int inputDataSize, /* I Length of input */
|
const opus_int inputDataSize, /* I Length of input */
|
||||||
const opus_int correlationCount /* I Number of correlation taps to compute */
|
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(
|
void silk_decode_pitch(
|
||||||
opus_int16 lagIndex, /* I */
|
opus_int16 lagIndex, /* I */
|
||||||
opus_int8 contourIndex, /* O */
|
opus_int8 contourIndex, /* O */
|
||||||
opus_int pitch_lags[], /* O 4 pitch values */
|
opus_int pitch_lags[], /* O 4 pitch values */
|
||||||
const opus_int Fs_kHz, /* I sampling frequency (kHz) */
|
const opus_int Fs_kHz, /* I sampling frequency (kHz) */
|
||||||
const opus_int nb_subfr /* I number of sub frames */
|
const opus_int nb_subfr /* I number of sub frames */
|
||||||
);
|
);
|
||||||
|
|
||||||
opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */
|
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 */
|
const opus_int16 *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
|
||||||
opus_int *pitch_out, /* O 4 pitch lag values */
|
opus_int *pitch_out, /* O 4 pitch lag values */
|
||||||
opus_int16 *lagIndex, /* O Lag Index */
|
opus_int16 *lagIndex, /* O Lag Index */
|
||||||
opus_int8 *contourIndex, /* O Pitch contour Index */
|
opus_int8 *contourIndex, /* O Pitch contour Index */
|
||||||
opus_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */
|
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 */
|
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_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 search_thres2_Q15, /* I Final threshold for lag candidates 0 - 1 */
|
||||||
const opus_int Fs_kHz, /* I Sample frequency (kHz) */
|
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 complexity, /* I Complexity setting, 0-2, where 2 is highest */
|
||||||
const opus_int nb_subfr /* I number of 5 ms subframes */
|
const opus_int nb_subfr /* I number of 5 ms subframes */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */
|
/* 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. */
|
/* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */
|
||||||
void silk_A2NLSF(
|
void silk_A2NLSF(
|
||||||
opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */
|
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] */
|
opus_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */
|
||||||
const opus_int d /* I Filter order (must be even) */
|
const opus_int d /* I Filter order (must be even) */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* compute whitening filter coefficients from normalized line spectral frequencies */
|
/* compute whitening filter coefficients from normalized line spectral frequencies */
|
||||||
void silk_NLSF2A(
|
void silk_NLSF2A(
|
||||||
opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */
|
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_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */
|
||||||
const opus_int d /* I filter order (should be even) */
|
const opus_int d /* I filter order (should be even) */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_insertion_sort_increasing(
|
void silk_insertion_sort_increasing(
|
||||||
opus_int32 *a, /* I/O Unsorted / Sorted vector */
|
opus_int32 *a, /* I/O Unsorted / Sorted vector */
|
||||||
opus_int *idx, /* O: Index vector for the sorted elements */
|
opus_int *idx, /* O Index vector for the sorted elements */
|
||||||
const opus_int L, /* I: Vector length */
|
const opus_int L, /* I Vector length */
|
||||||
const opus_int K /* I: Number of correctly sorted positions */
|
const opus_int K /* I Number of correctly sorted positions */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_insertion_sort_decreasing_int16(
|
void silk_insertion_sort_decreasing_int16(
|
||||||
opus_int16 *a, /* I/O: Unsorted / Sorted vector */
|
opus_int16 *a, /* I/O Unsorted / Sorted vector */
|
||||||
opus_int *idx, /* O: Index vector for the sorted elements */
|
opus_int *idx, /* O Index vector for the sorted elements */
|
||||||
const opus_int L, /* I: Vector length */
|
const opus_int L, /* I Vector length */
|
||||||
const opus_int K /* I: Number of correctly sorted positions */
|
const opus_int K /* I Number of correctly sorted positions */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_insertion_sort_increasing_all_values_int16(
|
void silk_insertion_sort_increasing_all_values_int16(
|
||||||
opus_int16 *a, /* I/O: Unsorted / Sorted vector */
|
opus_int16 *a, /* I/O Unsorted / Sorted vector */
|
||||||
const opus_int L /* I: Vector length */
|
const opus_int L /* I Vector length */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* NLSF stabilizer, for a single input data vector */
|
/* NLSF stabilizer, for a single input data vector */
|
||||||
void silk_NLSF_stabilize(
|
void silk_NLSF_stabilize(
|
||||||
opus_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */
|
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_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 */
|
const opus_int L /* I Number of NLSF parameters in the input vector */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Laroia low complexity NLSF weights */
|
/* Laroia low complexity NLSF weights */
|
||||||
void silk_NLSF_VQ_weights_laroia(
|
void silk_NLSF_VQ_weights_laroia(
|
||||||
opus_int16 *pNLSFW_Q_OUT, /* O: Pointer to input vector weights [D x 1] */
|
opus_int16 *pNLSFW_Q_OUT, /* O Pointer to input vector weights [D] */
|
||||||
const opus_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */
|
const opus_int16 *pNLSF_Q15, /* I Pointer to input vector [D] */
|
||||||
const opus_int D /* I: Input vector dimension (even) */
|
const opus_int D /* I Input vector dimension (even) */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Compute reflection coefficients from input signal */
|
/* Compute reflection coefficients from input signal */
|
||||||
void silk_burg_modified(
|
void silk_burg_modified(
|
||||||
opus_int32 *res_nrg, /* O residual energy */
|
opus_int32 *res_nrg, /* O Residual energy */
|
||||||
opus_int *res_nrgQ, /* O residual energy Q value */
|
opus_int *res_nrg_Q, /* O Residual energy Q value */
|
||||||
opus_int32 A_Q16[], /* O prediction coefficients (length order) */
|
opus_int32 A_Q16[], /* O Prediction coefficients (length order) */
|
||||||
const opus_int16 x[], /* I input signal, length: nb_subfr * ( D + subfr_length ) */
|
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 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_int nb_subfr, /* I Number of subframes stacked in x */
|
||||||
const opus_int32 WhiteNoiseFrac_Q32, /* I fraction added to zero-lag autocorrelation */
|
const opus_int32 WhiteNoiseFrac_Q32, /* I Fraction added to zero-lag autocorrelation */
|
||||||
const opus_int D /* I order */
|
const opus_int D /* I Order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Copy and multiply a vector by a constant */
|
/* Copy and multiply a vector by a constant */
|
||||||
void silk_scale_copy_vector16(
|
void silk_scale_copy_vector16(
|
||||||
opus_int16 *data_out,
|
opus_int16 *data_out,
|
||||||
const opus_int16 *data_in,
|
const opus_int16 *data_in,
|
||||||
opus_int32 gain_Q16, /* I: gain in Q16 */
|
opus_int32 gain_Q16, /* I Gain in Q16 */
|
||||||
const opus_int dataSize /* I: length */
|
const opus_int dataSize /* I Length */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Some for the LTP related function requires Q26 to work.*/
|
/* Some for the LTP related function requires Q26 to work.*/
|
||||||
void silk_scale_vector32_Q26_lshift_18(
|
void silk_scale_vector32_Q26_lshift_18(
|
||||||
opus_int32 *data1, /* I/O: Q0/Q18 */
|
opus_int32 *data1, /* I/O Q0/Q18 */
|
||||||
opus_int32 gain_Q26, /* I: Q26 */
|
opus_int32 gain_Q26, /* I Q26 */
|
||||||
opus_int dataSize /* I: length */
|
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(
|
opus_int32 silk_inner_prod_aligned(
|
||||||
const opus_int16 *const inVec1, /* I input vector 1 */
|
const opus_int16 *const inVec1, /* I input vector 1 */
|
||||||
const opus_int16 *const inVec2, /* I input vector 2 */
|
const opus_int16 *const inVec2, /* I input vector 2 */
|
||||||
const opus_int len /* I vector lengths */
|
const opus_int len /* I vector lengths */
|
||||||
);
|
);
|
||||||
|
|
||||||
opus_int32 silk_inner_prod_aligned_scale(
|
opus_int32 silk_inner_prod_aligned_scale(
|
||||||
const opus_int16 *const inVec1, /* I input vector 1 */
|
const opus_int16 *const inVec1, /* I input vector 1 */
|
||||||
const opus_int16 *const inVec2, /* I input vector 2 */
|
const opus_int16 *const inVec2, /* I input vector 2 */
|
||||||
const opus_int scale, /* I number of bits to shift */
|
const opus_int scale, /* I number of bits to shift */
|
||||||
const opus_int len /* I vector lengths */
|
const opus_int len /* I vector lengths */
|
||||||
);
|
);
|
||||||
|
|
||||||
opus_int64 silk_inner_prod16_aligned_64(
|
opus_int64 silk_inner_prod16_aligned_64(
|
||||||
const opus_int16 *inVec1, /* I input vector 1 */
|
const opus_int16 *inVec1, /* I input vector 1 */
|
||||||
const opus_int16 *inVec2, /* I input vector 2 */
|
const opus_int16 *inVec2, /* I input vector 2 */
|
||||||
const opus_int len /* I vector lengths */
|
const opus_int len /* I vector lengths */
|
||||||
);
|
);
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
@ -370,12 +371,13 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot )
|
||||||
opus_uint32 x = (opus_uint32) a32;
|
opus_uint32 x = (opus_uint32) a32;
|
||||||
opus_uint32 r = (opus_uint32) rot;
|
opus_uint32 r = (opus_uint32) rot;
|
||||||
opus_uint32 m = (opus_uint32) -rot;
|
opus_uint32 m = (opus_uint32) -rot;
|
||||||
if (rot==0)
|
if( rot == 0 ) {
|
||||||
return a32;
|
return a32;
|
||||||
else if(rot < 0)
|
} else if( rot < 0 ) {
|
||||||
return (opus_int32) ((x << m) | (x >> (32 - m)));
|
return (opus_int32) ((x << m) | (x >> (32 - m)));
|
||||||
else
|
} else {
|
||||||
return (opus_int32) ((x << (32 - r)) | (x >> r));
|
return (opus_int32) ((x << (32 - r)) | (x >> r));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate opus_int16 alligned to 4-byte memory address */
|
/* Allocate opus_int16 alligned to 4-byte memory address */
|
||||||
|
@ -386,10 +388,11 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Useful Macros that can be adjusted to other platforms */
|
/* Useful Macros that can be adjusted to other platforms */
|
||||||
#define silk_memcpy(a, b, c) memcpy((a), (b), (c)) /* Dest, Src, ByteCount */
|
#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_memset(a, b, c) memset((a), (b), (c)) /* Dest, value, ByteCount */
|
||||||
#define silk_memmove(a, b, c) memmove((a), (b), (c)) /* Dest, Src, ByteCount */
|
#define silk_memmove(a, b, c) memmove((a), (b), (c)) /* Dest, Src, ByteCount */
|
||||||
/* fixed point macros */
|
|
||||||
|
/* Fixed point macros */
|
||||||
|
|
||||||
/* (a32 * b32) output have to be 32bit int */
|
/* (a32 * b32) output have to be 32bit int */
|
||||||
#define silk_MUL(a32, b32) ((a32) * (b32))
|
#define silk_MUL(a32, b32) ((a32) * (b32))
|
||||||
|
@ -421,14 +424,9 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot )
|
||||||
(just standard two's complement implementation-specific behaviour) */
|
(just standard two's complement implementation-specific behaviour) */
|
||||||
#define silk_SUB32_ovflw(a, b) ((opus_int32)((opus_uint32)(a) - (opus_uint32)(b)))
|
#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 */
|
/* Multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode) */
|
||||||
#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)*/
|
|
||||||
#define silk_MLA_ovflw(a32, b32, c32) silk_ADD32_ovflw((a32), (opus_uint32)(b32) * (opus_uint32)(c32))
|
#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))))
|
||||||
# define silk_SMLABB_ovflw(a32, b32, c32) silk_ADD32_ovflw((a32), (opus_int32)((opus_int16)(b32)) * (opus_int32)((opus_int16)(c32)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define silk_DIV32_16(a32, b16) ((opus_int32)((a32) / (b16)))
|
#define silk_DIV32_16(a32, b16) ((opus_int32)((a32) / (b16)))
|
||||||
#define silk_DIV32(a32, b32) ((opus_int32)((a32) / (b32)))
|
#define silk_DIV32(a32, b32) ((opus_int32)((a32) / (b32)))
|
||||||
|
@ -442,12 +440,12 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot )
|
||||||
#define silk_SUB32(a, b) ((a) - (b))
|
#define silk_SUB32(a, b) ((a) - (b))
|
||||||
#define silk_SUB64(a, b) ((a) - (b))
|
#define silk_SUB64(a, b) ((a) - (b))
|
||||||
|
|
||||||
#define silk_SAT8(a) ((a) > silk_int8_MAX ? silk_int8_MAX : \
|
#define silk_SAT8(a) ((a) > silk_int8_MAX ? silk_int8_MAX : \
|
||||||
((a) < silk_int8_MIN ? silk_int8_MIN : (a)))
|
((a) < silk_int8_MIN ? silk_int8_MIN : (a)))
|
||||||
#define silk_SAT16(a) ((a) > silk_int16_MAX ? silk_int16_MAX : \
|
#define silk_SAT16(a) ((a) > silk_int16_MAX ? silk_int16_MAX : \
|
||||||
((a) < silk_int16_MIN ? silk_int16_MIN : (a)))
|
((a) < silk_int16_MIN ? silk_int16_MIN : (a)))
|
||||||
#define silk_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : \
|
#define silk_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : \
|
||||||
((a) < silk_int32_MIN ? silk_int32_MIN : (a)))
|
((a) < silk_int32_MIN ? silk_int32_MIN : (a)))
|
||||||
|
|
||||||
#define silk_CHECK_FIT8(a) (a)
|
#define silk_CHECK_FIT8(a) (a)
|
||||||
#define silk_CHECK_FIT16(a) (a)
|
#define silk_CHECK_FIT16(a) (a)
|
||||||
|
@ -455,13 +453,13 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot )
|
||||||
|
|
||||||
#define silk_ADD_SAT16(a, b) (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a), (b) ) )
|
#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 ? \
|
#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_MIN : (a)+(b)) : \
|
||||||
((((a) | (b)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (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_SAT16(a, b) (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a), (b) ) )
|
||||||
#define silk_SUB_SAT64(a, b) ((((a)-(b)) & 0x8000000000000000LL) == 0 ? \
|
#define silk_SUB_SAT64(a, b) ((((a)-(b)) & 0x8000000000000000LL) == 0 ? \
|
||||||
(( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a)-(b)) : \
|
(( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a)-(b)) : \
|
||||||
((((a)^0x8000000000000000LL) & (b) & 0x8000000000000000LL) ? silk_int64_MAX : (a)-(b)) )
|
((((a)^0x8000000000000000LL) & (b) & 0x8000000000000000LL) ? silk_int64_MAX : (a)-(b)) )
|
||||||
|
|
||||||
/* Saturation for positive input values */
|
/* Saturation for positive input values */
|
||||||
#define silk_POS_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : (a))
|
#define silk_POS_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : (a))
|
||||||
|
@ -472,51 +470,51 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot )
|
||||||
#define silk_ADD_POS_SAT32(a, b) ((((a)+(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b)))
|
#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_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_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_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_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_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_LSHIFT(a, shift) silk_LSHIFT32(a, shift) /* shift >= 0, shift < 32 */
|
||||||
|
|
||||||
#define silk_RSHIFT8(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 8 */
|
#define silk_RSHIFT8(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 8 */
|
||||||
#define silk_RSHIFT16(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 16 */
|
#define silk_RSHIFT16(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 16 */
|
||||||
#define silk_RSHIFT32(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 32 */
|
#define silk_RSHIFT32(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 32 */
|
||||||
#define silk_RSHIFT64(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 64 */
|
#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_RSHIFT(a, shift) silk_RSHIFT32(a, shift) /* shift >= 0, shift < 32 */
|
||||||
|
|
||||||
/* saturates before shifting */
|
/* saturates before shifting */
|
||||||
#define silk_LSHIFT_SAT16(a, shift) (silk_LSHIFT16( silk_LIMIT( (a), silk_RSHIFT16( silk_int16_MIN, (shift) ), \
|
#define silk_LSHIFT_SAT16(a, shift) (silk_LSHIFT16( silk_LIMIT( (a), silk_RSHIFT16( silk_int16_MIN, (shift) ), \
|
||||||
silk_RSHIFT16( silk_int16_MAX, (shift) ) ), (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) ), \
|
#define silk_LSHIFT_SAT32(a, shift) (silk_LSHIFT32( silk_LIMIT( (a), silk_RSHIFT32( silk_int32_MIN, (shift) ), \
|
||||||
silk_RSHIFT32( silk_int32_MAX, (shift) ) ), (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_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_LSHIFT_uint(a, shift) ((a) << (shift)) /* shift >= 0 */
|
||||||
#define silk_RSHIFT_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_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_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_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_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_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_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_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_SUB_RSHIFT32(a, b, shift) silk_SUB32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */
|
||||||
|
|
||||||
/* Requires that 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_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_ROUND64(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1)
|
||||||
|
|
||||||
/* Number of rightshift required to fit the multiplication */
|
/* 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_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_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_min(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
#define silk_max(a, b) (((a) > (b)) ? (a) : (b))
|
#define silk_max(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
|
|
||||||
/* Macro to convert floating-point constants to fixed-point */
|
/* 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 */
|
/* silk_min() versions with typecast in the function call */
|
||||||
static inline opus_int silk_min_int(opus_int a, opus_int b)
|
static inline opus_int silk_min_int(opus_int a, opus_int b)
|
||||||
|
@ -554,38 +552,36 @@ static inline opus_int64 silk_max_64(opus_int64 a, opus_int64 b)
|
||||||
return (((a) > (b)) ? (a) : (b));
|
return (((a) > (b)) ? (a) : (b));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define silk_LIMIT( a, limit1, limit2) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
|
#define silk_LIMIT( a, limit1, limit2) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
|
||||||
: ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))))
|
: ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))))
|
||||||
|
|
||||||
#define silk_LIMIT_int silk_LIMIT
|
#define silk_LIMIT_int silk_LIMIT
|
||||||
#define silk_LIMIT_16 silk_LIMIT
|
#define silk_LIMIT_16 silk_LIMIT
|
||||||
#define silk_LIMIT_32 silk_LIMIT
|
#define silk_LIMIT_32 silk_LIMIT
|
||||||
|
|
||||||
/*#define silk_non_neg(a) ((a) & ((-(a)) >> (8 * sizeof(a) - 1)))*/ /* doesn't seem faster than silk_max(0, 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_abs(a) (((a) > 0) ? (a) : -(a)) /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */
|
#define silk_sign(a) ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 ))
|
||||||
#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_sqrt(a) (sqrt(a))
|
||||||
|
|
||||||
#define silk_sqrt(a) (sqrt(a))
|
|
||||||
|
|
||||||
/* PSEUDO-RANDOM GENERATOR */
|
/* PSEUDO-RANDOM GENERATOR */
|
||||||
/* Make sure to store the result as the seed for the next call (also in between */
|
/* 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 */
|
/* frames), otherwise result won't be random at all. When only using some of the */
|
||||||
/* bits, take the most significant bits by right-shifting. */
|
/* 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. */
|
/* Add some multiplication functions that can be easily mapped to ARM. */
|
||||||
|
|
||||||
/* silk_SMMUL: Signed top word multiply.
|
/* silk_SMMUL: Signed top word multiply.
|
||||||
ARMv6 2 instruction cycles.
|
ARMv6 2 instruction cycles.
|
||||||
ARMv3M+ 3 instruction cycles. use SMULL and ignore LSB registers.(except xM)*/
|
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)*/
|
/*#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 */
|
/* 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 "Inlines.h"
|
||||||
#include "MacroCount.h"
|
#include "MacroCount.h"
|
||||||
|
|
12
silk/VAD.c
12
silk/VAD.c
|
@ -41,8 +41,8 @@ static inline void silk_VAD_GetNoiseLevels(
|
||||||
/**********************************/
|
/**********************************/
|
||||||
/* Initialization of the Silk VAD */
|
/* Initialization of the Silk VAD */
|
||||||
/**********************************/
|
/**********************************/
|
||||||
opus_int silk_VAD_Init( /* O Return value, 0 if success */
|
opus_int silk_VAD_Init( /* O Return value, 0 if success */
|
||||||
silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
|
silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int b, ret = 0;
|
opus_int b, ret = 0;
|
||||||
|
@ -77,9 +77,9 @@ static const opus_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -120
|
||||||
/***************************************/
|
/***************************************/
|
||||||
/* Get the speech activity level in Q8 */
|
/* Get the speech activity level in Q8 */
|
||||||
/***************************************/
|
/***************************************/
|
||||||
opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */
|
opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */
|
||||||
silk_encoder_state *psEncC, /* I/O Encoder state */
|
silk_encoder_state *psEncC, /* I/O Encoder state */
|
||||||
const opus_int16 pIn[] /* I PCM input */
|
const opus_int16 pIn[] /* I PCM input */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int SA_Q15, pSNR_dB_Q7, input_tilt;
|
opus_int SA_Q15, pSNR_dB_Q7, input_tilt;
|
||||||
|
@ -271,7 +271,7 @@ opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if
|
||||||
/* Noise level estimation */
|
/* Noise level estimation */
|
||||||
/**************************/
|
/**************************/
|
||||||
static inline void silk_VAD_GetNoiseLevels(
|
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 */
|
silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,14 +33,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */
|
/* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */
|
||||||
void silk_VQ_WMat_EC(
|
void silk_VQ_WMat_EC(
|
||||||
opus_int8 *ind, /* O index of best codebook vector */
|
opus_int8 *ind, /* O index of best codebook vector */
|
||||||
opus_int32 *rate_dist_Q14, /* O best weighted quantization error + mu * rate*/
|
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_int16 *in_Q14, /* I input vector to be quantized */
|
||||||
const opus_int32 *W_Q18, /* I weighting matrix */
|
const opus_int32 *W_Q18, /* I weighting matrix */
|
||||||
const opus_int8 *cb_Q7, /* I codebook */
|
const opus_int8 *cb_Q7, /* I codebook */
|
||||||
const opus_uint8 *cl_Q5, /* I code length for each codebook vector */
|
const opus_uint8 *cl_Q5, /* I code length for each codebook vector */
|
||||||
const opus_int mu_Q9, /* I tradeoff between weighted error and rate */
|
const opus_int mu_Q9, /* I tradeoff betw. weighted error and rate */
|
||||||
opus_int L /* I number of vectors in codebook */
|
opus_int L /* I number of vectors in codebook */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k;
|
opus_int k;
|
||||||
|
|
|
@ -37,11 +37,11 @@ static opus_int16 A_fb1_21 = -24290; /* (opus_int16)(20623 << 1) */
|
||||||
|
|
||||||
/* Split signal into two decimated bands using first-order allpass filters */
|
/* Split signal into two decimated bands using first-order allpass filters */
|
||||||
void silk_ana_filt_bank_1(
|
void silk_ana_filt_bank_1(
|
||||||
const opus_int16 *in, /* I: Input signal [N] */
|
const opus_int16 *in, /* I Input signal [N] */
|
||||||
opus_int32 *S, /* I/O: State vector [2] */
|
opus_int32 *S, /* I/O State vector [2] */
|
||||||
opus_int16 *outL, /* O: Low band [N/2] */
|
opus_int16 *outL, /* O Low band [N/2] */
|
||||||
opus_int16 *outH, /* O: High band [N/2] */
|
opus_int16 *outH, /* O High band [N/2] */
|
||||||
const opus_int32 N /* I: Number of input samples */
|
const opus_int32 N /* I Number of input samples */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, N2 = silk_RSHIFT( N, 1 );
|
opus_int k, N2 = silk_RSHIFT( N, 1 );
|
||||||
|
|
|
@ -38,16 +38,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "SigProc_FIX.h"
|
#include "SigProc_FIX.h"
|
||||||
|
|
||||||
|
|
||||||
/* Second order ARMA filter, alternative implementation */
|
/* Second order ARMA filter, alternative implementation */
|
||||||
void silk_biquad_alt(
|
void silk_biquad_alt(
|
||||||
const opus_int16 *in, /* I: Input signal */
|
const opus_int16 *in, /* I input signal */
|
||||||
const opus_int32 *B_Q28, /* I: MA coefficients [3] */
|
const opus_int32 *B_Q28, /* I MA coefficients [3] */
|
||||||
const opus_int32 *A_Q28, /* I: AR coefficients [2] */
|
const opus_int32 *A_Q28, /* I AR coefficients [2] */
|
||||||
opus_int32 *S, /* I/O: State vector [2] */
|
opus_int32 *S, /* I/O State vector [2] */
|
||||||
opus_int16 *out, /* O: Output signal */
|
opus_int16 *out, /* O output signal */
|
||||||
const opus_int32 len, /* I: Signal length (must be even) */
|
const opus_int32 len, /* I signal length (must be even) */
|
||||||
opus_int stride /* I: Operate on interleaved signal if > 1 */
|
opus_int stride /* I Operate on interleaved signal if > 1 */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */
|
/* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */
|
||||||
|
@ -56,9 +55,9 @@ void silk_biquad_alt(
|
||||||
|
|
||||||
/* Negate A_Q28 values and split in two parts */
|
/* Negate A_Q28 values and split in two parts */
|
||||||
A0_L_Q28 = ( -A_Q28[ 0 ] ) & 0x00003FFF; /* lower part */
|
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_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++ ) {
|
for( k = 0; k < len; k++ ) {
|
||||||
/* S[ 0 ], S[ 1 ]: Q12 */
|
/* S[ 0 ], S[ 1 ]: Q12 */
|
||||||
|
|
|
@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Chirp (bandwidth expand) LP AR filter */
|
/* Chirp (bandwidth expand) LP AR filter */
|
||||||
void silk_bwexpander(
|
void silk_bwexpander(
|
||||||
opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||||
const opus_int d, /* I Length of ar */
|
const opus_int d, /* I Length of ar */
|
||||||
opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
|
opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
|
|
@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Chirp (bandwidth expand) LP AR filter */
|
/* Chirp (bandwidth expand) LP AR filter */
|
||||||
void silk_bwexpander_32(
|
void silk_bwexpander_32(
|
||||||
opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||||
const opus_int d, /* I Length of ar */
|
const opus_int d, /* I Length of ar */
|
||||||
opus_int32 chirp_Q16 /* I Chirp factor in Q16 */
|
opus_int32 chirp_Q16 /* I Chirp factor in Q16 */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
|
|
@ -35,7 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Check encoder control struct */
|
/* Check encoder control struct */
|
||||||
opus_int check_control_input(
|
opus_int check_control_input(
|
||||||
silk_EncControlStruct *encControl /* I: Control structure */
|
silk_EncControlStruct *encControl /* I Control structure */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
silk_assert( encControl != NULL );
|
silk_assert( encControl != NULL );
|
||||||
|
|
|
@ -40,11 +40,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/* Encodes signs of excitation */
|
/* Encodes signs of excitation */
|
||||||
void silk_encode_signs(
|
void silk_encode_signs(
|
||||||
ec_enc *psRangeEnc, /* I/O Compressor data structure */
|
ec_enc *psRangeEnc, /* I/O Compressor data structure */
|
||||||
const opus_int8 pulses[], /* I pulse signal */
|
const opus_int8 pulses[], /* I pulse signal */
|
||||||
opus_int length, /* I length of input */
|
opus_int length, /* I length of input */
|
||||||
const opus_int signalType, /* I Signal type */
|
const opus_int signalType, /* I Signal type */
|
||||||
const opus_int quantOffsetType, /* I Quantization offset 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_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j, p;
|
opus_int i, j, p;
|
||||||
|
@ -74,11 +74,11 @@ void silk_encode_signs(
|
||||||
/* Decodes signs of excitation */
|
/* Decodes signs of excitation */
|
||||||
void silk_decode_signs(
|
void silk_decode_signs(
|
||||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||||
opus_int pulses[], /* I/O pulse signal */
|
opus_int pulses[], /* I/O pulse signal */
|
||||||
opus_int length, /* I length of input */
|
opus_int length, /* I length of input */
|
||||||
const opus_int signalType, /* I Signal type */
|
const opus_int signalType, /* I Signal type */
|
||||||
const opus_int quantOffsetType, /* I Quantization offset 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_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j, p;
|
opus_int i, j, p;
|
||||||
|
|
|
@ -83,13 +83,13 @@ typedef struct {
|
||||||
/* I: Flag to use constant bitrate */
|
/* I: Flag to use constant bitrate */
|
||||||
opus_int useCBR;
|
opus_int useCBR;
|
||||||
|
|
||||||
/* I: Maximum number of bits allowed for the frame */
|
/* I: Maximum number of bits allowed for the frame */
|
||||||
opus_int maxBits;
|
opus_int maxBits;
|
||||||
|
|
||||||
/* I: Causes a smooth downmix to mono */
|
/* I: Causes a smooth downmix to mono */
|
||||||
opus_int toMono;
|
opus_int toMono;
|
||||||
|
|
||||||
/* I: Opus encoder is allowing us to switch bandwidth */
|
/* I: Opus encoder is allowing us to switch bandwidth */
|
||||||
opus_int opusCanSwitch;
|
opus_int opusCanSwitch;
|
||||||
|
|
||||||
/* O: Internal sampling rate used, in Hertz; 8000/12000/16000 */
|
/* O: Internal sampling rate used, in Hertz; 8000/12000/16000 */
|
||||||
|
@ -104,7 +104,7 @@ typedef struct {
|
||||||
/* O: Stereo width */
|
/* O: Stereo width */
|
||||||
opus_int stereoWidth_Q14;
|
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;
|
opus_int switchReady;
|
||||||
|
|
||||||
} silk_EncControlStruct;
|
} silk_EncControlStruct;
|
||||||
|
|
|
@ -34,8 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Control SNR of redidual quantizer */
|
/* Control SNR of redidual quantizer */
|
||||||
opus_int silk_control_SNR(
|
opus_int silk_control_SNR(
|
||||||
silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
|
silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
|
||||||
opus_int32 TargetRate_bps /* I Target max bitrate (bps) */
|
opus_int32 TargetRate_bps /* I Target max bitrate (bps) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, ret = SILK_NO_ERROR;
|
opus_int k, ret = SILK_NO_ERROR;
|
||||||
|
|
|
@ -34,8 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Control internal sampling rate */
|
/* Control internal sampling rate */
|
||||||
opus_int silk_control_audio_bandwidth(
|
opus_int silk_control_audio_bandwidth(
|
||||||
silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
|
silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
|
||||||
silk_EncControlStruct *encControl /* I: Control structure */
|
silk_EncControlStruct *encControl /* I Control structure */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int fs_kHz;
|
opus_int fs_kHz;
|
||||||
|
@ -71,7 +71,7 @@ opus_int silk_control_audio_bandwidth(
|
||||||
/* Reset transition filter state */
|
/* Reset transition filter state */
|
||||||
silk_memset( psEncC->sLP.In_LP_State, 0, sizeof( psEncC->sLP.In_LP_State ) );
|
silk_memset( psEncC->sLP.In_LP_State, 0, sizeof( psEncC->sLP.In_LP_State ) );
|
||||||
}
|
}
|
||||||
if (encControl->opusCanSwitch) {
|
if( encControl->opusCanSwitch ) {
|
||||||
/* Stop transition phase */
|
/* Stop transition phase */
|
||||||
psEncC->sLP.mode = 0;
|
psEncC->sLP.mode = 0;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ opus_int silk_control_audio_bandwidth(
|
||||||
if( silk_SMULBB( psEncC->fs_kHz, 1000 ) < psEncC->desiredInternal_fs_Hz )
|
if( silk_SMULBB( psEncC->fs_kHz, 1000 ) < psEncC->desiredInternal_fs_Hz )
|
||||||
{
|
{
|
||||||
/* Switch up */
|
/* Switch up */
|
||||||
if (encControl->opusCanSwitch) {
|
if( encControl->opusCanSwitch ) {
|
||||||
/* Switch to a higher sample frequency */
|
/* Switch to a higher sample frequency */
|
||||||
fs_kHz = psEncC->fs_kHz == 8 ? 12 : 16;
|
fs_kHz = psEncC->fs_kHz == 8 ? 12 : 16;
|
||||||
|
|
||||||
|
@ -115,9 +115,5 @@ opus_int silk_control_audio_bandwidth(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FORCE_INTERNAL_FS_KHZ
|
|
||||||
fs_kHz = FORCE_INTERNAL_FS_KHZ;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return fs_kHz;
|
return fs_kHz;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define silk_encoder_state_Fxx silk_encoder_state_FLP
|
#define silk_encoder_state_Fxx silk_encoder_state_FLP
|
||||||
#endif
|
#endif
|
||||||
#include "tuning_parameters.h"
|
#include "tuning_parameters.h"
|
||||||
|
#include "pitch_est_defines.h"
|
||||||
|
|
||||||
static const opus_int enc_delay_matrix[3][5] = {
|
static const opus_int enc_delay_matrix[3][5] = {
|
||||||
/*SILK API 8 12 16 24 48 */
|
/*SILK API 8 12 16 24 48 */
|
||||||
|
@ -47,34 +47,34 @@ static const opus_int enc_delay_matrix[3][5] = {
|
||||||
|
|
||||||
opus_int silk_setup_resamplers(
|
opus_int silk_setup_resamplers(
|
||||||
silk_encoder_state_Fxx *psEnc, /* I/O */
|
silk_encoder_state_Fxx *psEnc, /* I/O */
|
||||||
opus_int fs_kHz /* I */
|
opus_int fs_kHz /* I */
|
||||||
);
|
);
|
||||||
|
|
||||||
opus_int silk_setup_fs(
|
opus_int silk_setup_fs(
|
||||||
silk_encoder_state_Fxx *psEnc, /* I/O */
|
silk_encoder_state_Fxx *psEnc, /* I/O */
|
||||||
opus_int fs_kHz, /* I */
|
opus_int fs_kHz, /* I */
|
||||||
opus_int PacketSize_ms /* I */
|
opus_int PacketSize_ms /* I */
|
||||||
);
|
);
|
||||||
|
|
||||||
opus_int silk_setup_complexity(
|
opus_int silk_setup_complexity(
|
||||||
silk_encoder_state *psEncC, /* I/O */
|
silk_encoder_state *psEncC, /* I/O */
|
||||||
opus_int Complexity /* I */
|
opus_int Complexity /* I */
|
||||||
);
|
);
|
||||||
|
|
||||||
static inline opus_int silk_setup_LBRR(
|
static inline opus_int silk_setup_LBRR(
|
||||||
silk_encoder_state *psEncC, /* I/O */
|
silk_encoder_state *psEncC, /* I/O */
|
||||||
const opus_int32 TargetRate_bps /* I */
|
const opus_int32 TargetRate_bps /* I */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/* Control encoder */
|
/* Control encoder */
|
||||||
opus_int silk_control_encoder(
|
opus_int silk_control_encoder(
|
||||||
silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */
|
silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */
|
||||||
silk_EncControlStruct *encControl, /* I: Control structure */
|
silk_EncControlStruct *encControl, /* I Control structure */
|
||||||
const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */
|
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 allow_bw_switch, /* I Flag to allow switching audio bandwidth */
|
||||||
const opus_int channelNb, /* I Channel number */
|
const opus_int channelNb, /* I Channel number */
|
||||||
const opus_int force_fs_kHz
|
const opus_int force_fs_kHz
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int fs_kHz, ret = 0;
|
opus_int fs_kHz, ret = 0;
|
||||||
|
@ -105,8 +105,9 @@ opus_int silk_control_encoder(
|
||||||
/* Determine internal sampling rate */
|
/* Determine internal sampling rate */
|
||||||
/********************************************/
|
/********************************************/
|
||||||
fs_kHz = silk_control_audio_bandwidth( &psEnc->sCmn, encControl );
|
fs_kHz = silk_control_audio_bandwidth( &psEnc->sCmn, encControl );
|
||||||
if (force_fs_kHz)
|
if( force_fs_kHz ) {
|
||||||
fs_kHz = force_fs_kHz;
|
fs_kHz = force_fs_kHz;
|
||||||
|
}
|
||||||
/********************************************/
|
/********************************************/
|
||||||
/* Prepare resampler and buffered data */
|
/* Prepare resampler and buffered data */
|
||||||
/********************************************/
|
/********************************************/
|
||||||
|
@ -194,8 +195,8 @@ opus_int silk_setup_resamplers(
|
||||||
|
|
||||||
opus_int silk_setup_fs(
|
opus_int silk_setup_fs(
|
||||||
silk_encoder_state_Fxx *psEnc, /* I/O */
|
silk_encoder_state_Fxx *psEnc, /* I/O */
|
||||||
opus_int fs_kHz, /* I */
|
opus_int fs_kHz, /* I */
|
||||||
opus_int PacketSize_ms /* I */
|
opus_int PacketSize_ms /* I */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int ret = SILK_NO_ERROR;
|
opus_int ret = SILK_NO_ERROR;
|
||||||
|
@ -310,7 +311,7 @@ opus_int silk_setup_fs(
|
||||||
|
|
||||||
opus_int silk_setup_complexity(
|
opus_int silk_setup_complexity(
|
||||||
silk_encoder_state *psEncC, /* I/O */
|
silk_encoder_state *psEncC, /* I/O */
|
||||||
opus_int Complexity /* I */
|
opus_int Complexity /* I */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int ret = 0;
|
opus_int ret = 0;
|
||||||
|
@ -392,7 +393,7 @@ opus_int silk_setup_complexity(
|
||||||
|
|
||||||
static inline opus_int silk_setup_LBRR(
|
static inline opus_int silk_setup_LBRR(
|
||||||
silk_encoder_state *psEncC, /* I/O */
|
silk_encoder_state *psEncC, /* I/O */
|
||||||
const opus_int32 TargetRate_bps /* I */
|
const opus_int32 TargetRate_bps /* I */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int ret = SILK_NO_ERROR;
|
opus_int ret = SILK_NO_ERROR;
|
||||||
|
|
|
@ -31,12 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
|
||||||
/************************/
|
/************************/
|
||||||
/* Init Decoder State */
|
/* Init Decoder State */
|
||||||
/************************/
|
/************************/
|
||||||
opus_int silk_init_decoder(
|
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 */
|
/* Clear the entire encoder state, except anything copied */
|
||||||
|
|
|
@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#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 */
|
/* Returns a time counter in microsec */
|
||||||
/* the resolution is platform dependent */
|
/* the resolution is platform dependent */
|
||||||
|
@ -54,7 +54,7 @@ unsigned long silk_GetHighResolutionTime(void) /* O: time in usec*/
|
||||||
return (unsigned long)((1000000*(lpPerformanceCount.QuadPart)) / lpFrequency.QuadPart);
|
return (unsigned long)((1000000*(lpPerformanceCount.QuadPart)) / lpFrequency.QuadPart);
|
||||||
}
|
}
|
||||||
#else /* Linux or Mac*/
|
#else /* Linux or Mac*/
|
||||||
unsigned long GetHighResolutionTime(void) /* O: time in usec*/
|
unsigned long GetHighResolutionTime(void) /* O time in usec*/
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, 0);
|
gettimeofday(&tv, 0);
|
||||||
|
|
136
silk/debug.h
136
silk/debug.h
|
@ -41,7 +41,7 @@ extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#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 */
|
/* make SILK_DEBUG dependent on compiler's _DEBUG */
|
||||||
#if defined _WIN32
|
#if defined _WIN32
|
||||||
|
@ -62,7 +62,8 @@ unsigned long GetHighResolutionTime(void); /* O: time in usec*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Flag for using timers */
|
/* Flag for using timers */
|
||||||
#define SILK_TIC_TOC 0
|
#define SILK_TIC_TOC 0
|
||||||
|
|
||||||
|
|
||||||
#if SILK_TIC_TOC
|
#if SILK_TIC_TOC
|
||||||
|
|
||||||
|
@ -84,9 +85,9 @@ unsigned long GetHighResolutionTime(void); /* O: time in usec*/
|
||||||
/* */
|
/* */
|
||||||
/* and call the following just before exiting (from main) */
|
/* 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);
|
void silk_TimerSave(char *file_name);
|
||||||
|
|
||||||
|
@ -104,10 +105,10 @@ extern LARGE_INTEGER silk_Timer_start[silk_NUM_TIMERS_MAX];
|
||||||
extern unsigned long silk_Timer_start[silk_NUM_TIMERS_MAX];
|
extern unsigned long silk_Timer_start[silk_NUM_TIMERS_MAX];
|
||||||
#endif
|
#endif
|
||||||
extern unsigned int silk_Timer_cnt[silk_NUM_TIMERS_MAX];
|
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_sum[silk_NUM_TIMERS_MAX];
|
||||||
extern opus_int64 silk_Timer_max[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_min[silk_NUM_TIMERS_MAX];
|
||||||
extern opus_int64 silk_Timer_depth[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 */
|
/* WARNING: TIC()/TOC can measure only up to 0.1 seconds at a time */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -118,25 +119,25 @@ extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX];
|
||||||
{ \
|
{ \
|
||||||
int k; \
|
int k; \
|
||||||
init = 1; \
|
init = 1; \
|
||||||
for( k = 0; k < silk_Timer_nTimers; k++ ) { \
|
for( k = 0; k < silk_Timer_nTimers; k++ ) { \
|
||||||
if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
|
if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
|
||||||
ID = k; \
|
ID = k; \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
if (ID == -1) { \
|
if (ID == -1) { \
|
||||||
ID = silk_Timer_nTimers; \
|
ID = silk_Timer_nTimers; \
|
||||||
silk_Timer_nTimers++; \
|
silk_Timer_nTimers++; \
|
||||||
silk_Timer_depth[ID] = silk_Timer_depth_ctr; \
|
silk_Timer_depth[ID] = silk_Timer_depth_ctr; \
|
||||||
strcpy(silk_Timer_tags[ID], #TAG_NAME); \
|
strcpy(silk_Timer_tags[ID], #TAG_NAME); \
|
||||||
silk_Timer_cnt[ID] = 0; \
|
silk_Timer_cnt[ID] = 0; \
|
||||||
silk_Timer_sum[ID] = 0; \
|
silk_Timer_sum[ID] = 0; \
|
||||||
silk_Timer_min[ID] = 0xFFFFFFFF; \
|
silk_Timer_min[ID] = 0xFFFFFFFF; \
|
||||||
silk_Timer_max[ID] = 0; \
|
silk_Timer_max[ID] = 0; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
silk_Timer_depth_ctr++; \
|
silk_Timer_depth_ctr++; \
|
||||||
QueryPerformanceCounter(&silk_Timer_start[ID]); \
|
QueryPerformanceCounter(&silk_Timer_start[ID]); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define TIC(TAG_NAME) { \
|
#define TIC(TAG_NAME) { \
|
||||||
|
@ -146,25 +147,25 @@ extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX];
|
||||||
{ \
|
{ \
|
||||||
int k; \
|
int k; \
|
||||||
init = 1; \
|
init = 1; \
|
||||||
for( k = 0; k < silk_Timer_nTimers; k++ ) { \
|
for( k = 0; k < silk_Timer_nTimers; k++ ) { \
|
||||||
if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
|
if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
|
||||||
ID = k; \
|
ID = k; \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
if (ID == -1) { \
|
if (ID == -1) { \
|
||||||
ID = silk_Timer_nTimers; \
|
ID = silk_Timer_nTimers; \
|
||||||
silk_Timer_nTimers++; \
|
silk_Timer_nTimers++; \
|
||||||
silk_Timer_depth[ID] = silk_Timer_depth_ctr; \
|
silk_Timer_depth[ID] = silk_Timer_depth_ctr; \
|
||||||
strcpy(silk_Timer_tags[ID], #TAG_NAME); \
|
strcpy(silk_Timer_tags[ID], #TAG_NAME); \
|
||||||
silk_Timer_cnt[ID] = 0; \
|
silk_Timer_cnt[ID] = 0; \
|
||||||
silk_Timer_sum[ID] = 0; \
|
silk_Timer_sum[ID] = 0; \
|
||||||
silk_Timer_min[ID] = 0xFFFFFFFF; \
|
silk_Timer_min[ID] = 0xFFFFFFFF; \
|
||||||
silk_Timer_max[ID] = 0; \
|
silk_Timer_max[ID] = 0; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
silk_Timer_depth_ctr++; \
|
silk_Timer_depth_ctr++; \
|
||||||
silk_Timer_start[ID] = GetHighResolutionTime(); \
|
silk_Timer_start[ID] = GetHighResolutionTime(); \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -177,25 +178,25 @@ extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX];
|
||||||
{ \
|
{ \
|
||||||
int k; \
|
int k; \
|
||||||
init = 1; \
|
init = 1; \
|
||||||
for( k = 0; k < silk_Timer_nTimers; k++ ) { \
|
for( k = 0; k < silk_Timer_nTimers; k++ ) { \
|
||||||
if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
|
if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
|
||||||
ID = k; \
|
ID = k; \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
QueryPerformanceCounter(&lpPerformanceCount); \
|
QueryPerformanceCounter(&lpPerformanceCount); \
|
||||||
lpPerformanceCount.QuadPart -= silk_Timer_start[ID].QuadPart; \
|
lpPerformanceCount.QuadPart -= silk_Timer_start[ID].QuadPart; \
|
||||||
if((lpPerformanceCount.QuadPart < 100000000) && \
|
if((lpPerformanceCount.QuadPart < 100000000) && \
|
||||||
(lpPerformanceCount.QuadPart >= 0)) { \
|
(lpPerformanceCount.QuadPart >= 0)) { \
|
||||||
silk_Timer_cnt[ID]++; \
|
silk_Timer_cnt[ID]++; \
|
||||||
silk_Timer_sum[ID] += lpPerformanceCount.QuadPart; \
|
silk_Timer_sum[ID] += lpPerformanceCount.QuadPart; \
|
||||||
if( lpPerformanceCount.QuadPart > silk_Timer_max[ID] ) \
|
if( lpPerformanceCount.QuadPart > silk_Timer_max[ID] ) \
|
||||||
silk_Timer_max[ID] = lpPerformanceCount.QuadPart; \
|
silk_Timer_max[ID] = lpPerformanceCount.QuadPart; \
|
||||||
if( lpPerformanceCount.QuadPart < silk_Timer_min[ID] ) \
|
if( lpPerformanceCount.QuadPart < silk_Timer_min[ID] ) \
|
||||||
silk_Timer_min[ID] = lpPerformanceCount.QuadPart; \
|
silk_Timer_min[ID] = lpPerformanceCount.QuadPart; \
|
||||||
} \
|
} \
|
||||||
silk_Timer_depth_ctr--; \
|
silk_Timer_depth_ctr--; \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define TOC(TAG_NAME) { \
|
#define TOC(TAG_NAME) { \
|
||||||
|
@ -206,25 +207,25 @@ extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX];
|
||||||
{ \
|
{ \
|
||||||
int k; \
|
int k; \
|
||||||
init = 1; \
|
init = 1; \
|
||||||
for( k = 0; k < silk_Timer_nTimers; k++ ) { \
|
for( k = 0; k < silk_Timer_nTimers; k++ ) { \
|
||||||
if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
|
if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \
|
||||||
ID = k; \
|
ID = k; \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
endTime = GetHighResolutionTime(); \
|
endTime = GetHighResolutionTime(); \
|
||||||
endTime -= silk_Timer_start[ID]; \
|
endTime -= silk_Timer_start[ID]; \
|
||||||
if((endTime < 100000000) && \
|
if((endTime < 100000000) && \
|
||||||
(endTime >= 0)) { \
|
(endTime >= 0)) { \
|
||||||
silk_Timer_cnt[ID]++; \
|
silk_Timer_cnt[ID]++; \
|
||||||
silk_Timer_sum[ID] += endTime; \
|
silk_Timer_sum[ID] += endTime; \
|
||||||
if( endTime > silk_Timer_max[ID] ) \
|
if( endTime > silk_Timer_max[ID] ) \
|
||||||
silk_Timer_max[ID] = endTime; \
|
silk_Timer_max[ID] = endTime; \
|
||||||
if( endTime < silk_Timer_min[ID] ) \
|
if( endTime < silk_Timer_min[ID] ) \
|
||||||
silk_Timer_min[ID] = endTime; \
|
silk_Timer_min[ID] = endTime; \
|
||||||
} \
|
} \
|
||||||
silk_Timer_depth_ctr--; \
|
silk_Timer_depth_ctr--; \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -238,45 +239,22 @@ extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX];
|
||||||
#endif /* SILK_TIC_TOC */
|
#endif /* SILK_TIC_TOC */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if SILK_DEBUG
|
#if SILK_DEBUG
|
||||||
/************************************/
|
/************************************/
|
||||||
/* write data to file for debugging */
|
/* 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)); */
|
/* 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
|
#define silk_NUM_STORES_MAX 100
|
||||||
extern FILE *silk_debug_store_fp[ silk_NUM_STORES_MAX ];
|
extern FILE *silk_debug_store_fp[ silk_NUM_STORES_MAX ];
|
||||||
extern int silk_debug_store_count;
|
extern int silk_debug_store_count;
|
||||||
|
|
||||||
/* Faster way of storing the data */
|
/* Faster way of storing the data */
|
||||||
#define DEBUG_STORE_DATA( FILE_NAME, DATA_PTR, N_BYTES ) { \
|
#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; \
|
static FILE **fp; \
|
||||||
if (init == 0) { \
|
if (init == 0) { \
|
||||||
init = 1; \
|
init = 1; \
|
||||||
cnt = silk_debug_store_count++; \
|
cnt = silk_debug_store_count++; \
|
||||||
silk_debug_store_fp[ cnt ] = fopen(#FILE_NAME, "wb"); \
|
silk_debug_store_fp[ cnt ] = fopen(#FILE_NAME, "wb"); \
|
||||||
} \
|
} \
|
||||||
|
@ -285,12 +263,11 @@ extern int silk_debug_store_count;
|
||||||
|
|
||||||
/* Call this at the end of main() */
|
/* Call this at the end of main() */
|
||||||
#define SILK_DEBUG_STORE_CLOSE_FILES { \
|
#define SILK_DEBUG_STORE_CLOSE_FILES { \
|
||||||
opus_int i; \
|
opus_int i; \
|
||||||
for( i = 0; i < silk_debug_store_count; i++ ) { \
|
for( i = 0; i < silk_debug_store_count; i++ ) { \
|
||||||
fclose( silk_debug_store_fp[ i ] ); \
|
fclose( silk_debug_store_fp[ i ] ); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* micro sec */
|
/* micro sec */
|
||||||
#define silk_GETTIME(void) time = (opus_int64) silk_GetHighResolutionTime();
|
#define silk_GETTIME(void) time = (opus_int64) silk_GetHighResolutionTime();
|
||||||
|
@ -299,7 +276,6 @@ extern int silk_debug_store_count;
|
||||||
|
|
||||||
/* define macros as empty strings */
|
/* define macros as empty strings */
|
||||||
#define DEBUG_STORE_DATA(FILE_NAME, DATA_PTR, N_BYTES)
|
#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
|
#define SILK_DEBUG_STORE_CLOSE_FILES
|
||||||
|
|
||||||
#endif /* SILK_DEBUG */
|
#endif /* SILK_DEBUG */
|
||||||
|
|
|
@ -46,7 +46,9 @@ typedef struct {
|
||||||
/* Decoder functions */
|
/* 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;
|
opus_int ret = SILK_NO_ERROR;
|
||||||
|
|
||||||
|
@ -56,8 +58,8 @@ opus_int silk_Get_Decoder_Size( int *decSizeBytes )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset decoder state */
|
/* Reset decoder state */
|
||||||
opus_int silk_InitDecoder(
|
opus_int silk_InitDecoder( /* O Returns error code */
|
||||||
void* decState /* I/O: State */
|
void *decState /* I/O State */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int n, ret = SILK_NO_ERROR;
|
opus_int n, ret = SILK_NO_ERROR;
|
||||||
|
@ -71,14 +73,14 @@ opus_int silk_InitDecoder(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decode a frame */
|
/* Decode a frame */
|
||||||
opus_int silk_Decode(
|
opus_int silk_Decode( /* O Returns error code */
|
||||||
void* decState, /* I/O: State */
|
void* decState, /* I/O State */
|
||||||
silk_DecControlStruct* decControl, /* I/O: Control Structure */
|
silk_DecControlStruct* decControl, /* I/O Control Structure */
|
||||||
opus_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode FEC */
|
opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */
|
||||||
opus_int newPacketFlag, /* I: Indicates first decoder call for this packet */
|
opus_int newPacketFlag, /* I Indicates first decoder call for this packet */
|
||||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||||
opus_int16 *samplesOut, /* O: Decoded output speech vector */
|
opus_int16 *samplesOut, /* O Decoded output speech vector */
|
||||||
opus_int32 *nSamplesOut /* O: Number of samples decoded */
|
opus_int32 *nSamplesOut /* O Number of samples decoded */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, n, delay, decode_only_middle = 0, ret = SILK_NO_ERROR;
|
opus_int i, n, delay, decode_only_middle = 0, ret = SILK_NO_ERROR;
|
||||||
|
@ -237,7 +239,7 @@ opus_int silk_Decode(
|
||||||
psDec->channel_state[ 1 ].first_frame_after_reset = 1;
|
psDec->channel_state[ 1 ].first_frame_after_reset = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lostFlag == FLAG_DECODE_NORMAL) {
|
if( lostFlag == FLAG_DECODE_NORMAL ) {
|
||||||
has_side = !decode_only_middle;
|
has_side = !decode_only_middle;
|
||||||
} else {
|
} else {
|
||||||
has_side = !psDec->prev_decode_only_middle
|
has_side = !psDec->prev_decode_only_middle
|
||||||
|
@ -318,7 +320,7 @@ opus_int silk_Decode(
|
||||||
decControl->prevPitchLag = 0;
|
decControl->prevPitchLag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( lostFlag != FLAG_PACKET_LOST ) {
|
if( lostFlag != FLAG_PACKET_LOST ) {
|
||||||
psDec->prev_decode_only_middle = decode_only_middle;
|
psDec->prev_decode_only_middle = decode_only_middle;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -326,10 +328,10 @@ opus_int silk_Decode(
|
||||||
|
|
||||||
/* Getting table of contents for a packet */
|
/* Getting table of contents for a packet */
|
||||||
opus_int silk_get_TOC(
|
opus_int silk_get_TOC(
|
||||||
const opus_uint8 *payload, /* I Payload data */
|
const opus_uint8 *payload, /* I Payload data */
|
||||||
const opus_int nBytesIn, /* I: Number of input bytes */
|
const opus_int nBytesIn, /* I Number of input bytes */
|
||||||
const opus_int nFramesPerPayload, /* I: Number of SILK frames per payload */
|
const opus_int nFramesPerPayload, /* I Number of SILK frames per payload */
|
||||||
silk_TOC_struct *Silk_TOC /* O: Type of content */
|
silk_TOC_struct *Silk_TOC /* O Type of content */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, flags, ret = SILK_NO_ERROR;
|
opus_int i, flags, ret = SILK_NO_ERROR;
|
||||||
|
|
|
@ -35,10 +35,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/* Core decoder. Performs inverse NSQ operation LTP + LPC */
|
/* Core decoder. Performs inverse NSQ operation LTP + LPC */
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
void silk_decode_core(
|
void silk_decode_core(
|
||||||
silk_decoder_state *psDec, /* I/O Decoder state */
|
silk_decoder_state *psDec, /* I/O Decoder state */
|
||||||
silk_decoder_control *psDecCtrl, /* I Decoder control */
|
silk_decoder_control *psDecCtrl, /* I Decoder control */
|
||||||
opus_int16 xq[], /* O Decoded speech */
|
opus_int16 xq[], /* O Decoded speech */
|
||||||
const opus_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */
|
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;
|
opus_int i, j, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, signalType;
|
||||||
|
@ -77,10 +77,6 @@ void silk_decode_core(
|
||||||
rand_seed = silk_ADD32_ovflw(rand_seed, pulses[ i ]);
|
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 */
|
/* Copy LPC state */
|
||||||
silk_memcpy( sLPC_Q14, psDec->sLPC_Q14_buf, MAX_LPC_ORDER * sizeof( opus_int32 ) );
|
silk_memcpy( sLPC_Q14, psDec->sLPC_Q14_buf, MAX_LPC_ORDER * sizeof( opus_int32 ) );
|
||||||
|
|
||||||
|
@ -187,11 +183,6 @@ void silk_decode_core(
|
||||||
pres_Q10 = pexc_Q10;
|
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++ ) {
|
for( i = 0; i < psDec->subfr_length; i++ ) {
|
||||||
/* Partially unrolled */
|
/* Partially unrolled */
|
||||||
LPC_pred_Q10 = silk_SMULWB( sLPC_Q14[ MAX_LPC_ORDER + i - 1 ], A_Q12_tmp[ 0 ] );
|
LPC_pred_Q10 = silk_SMULWB( sLPC_Q14[ MAX_LPC_ORDER + i - 1 ], A_Q12_tmp[ 0 ] );
|
||||||
|
@ -223,9 +214,4 @@ void silk_decode_core(
|
||||||
|
|
||||||
/* Save LPC state */
|
/* Save LPC state */
|
||||||
silk_memcpy( psDec->sLPC_Q14_buf, sLPC_Q14, MAX_LPC_ORDER * sizeof( opus_int32 ) );
|
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
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,20 +36,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/* Decode frame */
|
/* Decode frame */
|
||||||
/****************/
|
/****************/
|
||||||
opus_int silk_decode_frame(
|
opus_int silk_decode_frame(
|
||||||
silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */
|
silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */
|
||||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||||
opus_int16 pOut[], /* O Pointer to output speech frame */
|
opus_int16 pOut[], /* O Pointer to output speech frame */
|
||||||
opus_int32 *pN, /* O Pointer to size of output 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 lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
silk_decoder_control sDecCtrl;
|
silk_decoder_control sDecCtrl;
|
||||||
opus_int L, mv_len, ret = 0;
|
opus_int L, mv_len, ret = 0;
|
||||||
opus_int pulses[ MAX_FRAME_LENGTH ];
|
opus_int pulses[ MAX_FRAME_LENGTH ];
|
||||||
|
|
||||||
TIC(DECODE_FRAME)
|
|
||||||
|
|
||||||
L = psDec->frame_length;
|
L = psDec->frame_length;
|
||||||
sDecCtrl.LTP_scale_Q14 = 0;
|
sDecCtrl.LTP_scale_Q14 = 0;
|
||||||
|
|
||||||
|
@ -62,24 +60,18 @@ TIC(DECODE_FRAME)
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
/* Decode quantization indices of side info */
|
/* Decode quantization indices of side info */
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
TIC(decode_indices)
|
|
||||||
silk_decode_indices( psDec, psRangeDec, psDec->nFramesDecoded, lostFlag, condCoding );
|
silk_decode_indices( psDec, psRangeDec, psDec->nFramesDecoded, lostFlag, condCoding );
|
||||||
TOC(decode_indices)
|
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
/* Decode quantization indices of excitation */
|
/* Decode quantization indices of excitation */
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
TIC(decode_pulses)
|
|
||||||
silk_decode_pulses( psRangeDec, pulses, psDec->indices.signalType,
|
silk_decode_pulses( psRangeDec, pulses, psDec->indices.signalType,
|
||||||
psDec->indices.quantOffsetType, psDec->frame_length );
|
psDec->indices.quantOffsetType, psDec->frame_length );
|
||||||
TOC(decode_pulses)
|
|
||||||
|
|
||||||
/********************************************/
|
/********************************************/
|
||||||
/* Decode parameters and pulse signal */
|
/* Decode parameters and pulse signal */
|
||||||
/********************************************/
|
/********************************************/
|
||||||
TIC(decode_params)
|
|
||||||
silk_decode_parameters( psDec, &sDecCtrl, condCoding );
|
silk_decode_parameters( psDec, &sDecCtrl, condCoding );
|
||||||
TOC(decode_params)
|
|
||||||
|
|
||||||
/* Update length. Sampling frequency may have changed */
|
/* Update length. Sampling frequency may have changed */
|
||||||
L = psDec->frame_length;
|
L = psDec->frame_length;
|
||||||
|
@ -87,9 +79,7 @@ TOC(decode_params)
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
/* Run inverse NSQ */
|
/* Run inverse NSQ */
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
TIC(decode_core)
|
|
||||||
silk_decode_core( psDec, &sDecCtrl, pOut, pulses );
|
silk_decode_core( psDec, &sDecCtrl, pOut, pulses );
|
||||||
TOC(decode_core)
|
|
||||||
|
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
/* Update PLC state */
|
/* Update PLC state */
|
||||||
|
@ -131,7 +121,5 @@ TOC(decode_core)
|
||||||
/* Set output frame length */
|
/* Set output frame length */
|
||||||
*pN = L;
|
*pN = L;
|
||||||
|
|
||||||
TOC(DECODE_FRAME)
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Decode side-information parameters from payload */
|
/* Decode side-information parameters from payload */
|
||||||
void silk_decode_indices(
|
void silk_decode_indices(
|
||||||
silk_decoder_state *psDec, /* I/O State */
|
silk_decoder_state *psDec, /* I/O State */
|
||||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||||
opus_int FrameIndex, /* I Frame number */
|
opus_int FrameIndex, /* I Frame number */
|
||||||
opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */
|
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 condCoding /* I The type of conditional coding to use */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, k, Ix;
|
opus_int i, k, Ix;
|
||||||
|
|
|
@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Decode parameters from payload */
|
/* Decode parameters from payload */
|
||||||
void silk_decode_parameters(
|
void silk_decode_parameters(
|
||||||
silk_decoder_state *psDec, /* I/O State */
|
silk_decoder_state *psDec, /* I/O State */
|
||||||
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, k, Ix;
|
opus_int i, k, Ix;
|
||||||
|
|
|
@ -36,11 +36,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "pitch_est_defines.h"
|
#include "pitch_est_defines.h"
|
||||||
|
|
||||||
void silk_decode_pitch(
|
void silk_decode_pitch(
|
||||||
opus_int16 lagIndex, /* I */
|
opus_int16 lagIndex, /* I */
|
||||||
opus_int8 contourIndex, /* O */
|
opus_int8 contourIndex, /* O */
|
||||||
opus_int pitch_lags[], /* O pitch values */
|
opus_int pitch_lags[], /* O 4 pitch values */
|
||||||
const opus_int Fs_kHz, /* I sampling frequency (kHz) */
|
const opus_int Fs_kHz, /* I sampling frequency (kHz) */
|
||||||
const opus_int nb_subfr /* I number of sub frames */
|
const opus_int nb_subfr /* I number of sub frames */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int lag, k, min_lag, max_lag, cbk_size;
|
opus_int lag, k, min_lag, max_lag, cbk_size;
|
||||||
|
|
|
@ -35,11 +35,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/* Decode quantization indices of excitation */
|
/* Decode quantization indices of excitation */
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
void silk_decode_pulses(
|
void silk_decode_pulses(
|
||||||
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
ec_dec *psRangeDec, /* I/O Compressor data structure */
|
||||||
opus_int pulses[], /* O Excitation signal */
|
opus_int pulses[], /* O Excitation signal */
|
||||||
const opus_int signalType, /* I Sigtype */
|
const opus_int signalType, /* I Sigtype */
|
||||||
const opus_int quantOffsetType, /* I quantOffsetType */
|
const opus_int quantOffsetType, /* I quantOffsetType */
|
||||||
const opus_int frame_length /* I Frame length */
|
const opus_int frame_length /* I Frame length */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j, k, iter, abs_q, nLS, RateLevelIndex;
|
opus_int i, j, k, iter, abs_q, nLS, RateLevelIndex;
|
||||||
|
@ -55,7 +55,7 @@ void silk_decode_pulses(
|
||||||
/* Calculate number of shell blocks */
|
/* Calculate number of shell blocks */
|
||||||
silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH );
|
silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH );
|
||||||
iter = silk_RSHIFT( frame_length, LOG2_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 */
|
silk_assert( frame_length == 12 * 10 ); /* Make sure only happens for 10 ms @ 12 kHz */
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ void silk_decode_pulses(
|
||||||
nLshifts[ i ]++;
|
nLshifts[ i ]++;
|
||||||
/* When we've already got 10 LSBs, we shift the table to not allow (MAX_PULSES + 1) */
|
/* When we've already got 10 LSBs, we shift the table to not allow (MAX_PULSES + 1) */
|
||||||
sum_pulses[ i ] = ec_dec_icdf( psRangeDec,
|
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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,9 @@ static const int dec_delay_matrix[3][5] = {
|
||||||
|
|
||||||
/* Set decoder sampling rate */
|
/* Set decoder sampling rate */
|
||||||
opus_int silk_decoder_set_fs(
|
opus_int silk_decoder_set_fs(
|
||||||
silk_decoder_state *psDec, /* I/O Decoder state pointer */
|
silk_decoder_state *psDec, /* I/O Decoder state pointer */
|
||||||
opus_int fs_kHz, /* I Sampling frequency (kHz) */
|
opus_int fs_kHz, /* I Sampling frequency (kHz) */
|
||||||
opus_int fs_API_Hz /* I API Sampling frequency (Hz) */
|
opus_int fs_API_Hz /* I API Sampling frequency (Hz) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int frame_length, ret = 0;
|
opus_int frame_length, ret = 0;
|
||||||
|
|
|
@ -57,7 +57,7 @@ extern "C"
|
||||||
#define NB_SPEECH_FRAMES_BEFORE_DTX 10 /* eq 200 ms */
|
#define NB_SPEECH_FRAMES_BEFORE_DTX 10 /* eq 200 ms */
|
||||||
#define MAX_CONSECUTIVE_DTX 20 /* eq 400 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_FS_KHZ 16
|
||||||
#define MAX_API_FS_KHZ 48
|
#define MAX_API_FS_KHZ 48
|
||||||
|
|
||||||
|
@ -74,12 +74,12 @@ extern "C"
|
||||||
/* Settings for stereo processing */
|
/* Settings for stereo processing */
|
||||||
#define STEREO_QUANT_TAB_SIZE 16
|
#define STEREO_QUANT_TAB_SIZE 16
|
||||||
#define STEREO_QUANT_SUB_STEPS 5
|
#define STEREO_QUANT_SUB_STEPS 5
|
||||||
#define STEREO_INTERP_LEN_MS 8 /* must be even */
|
#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_RATIO_SMOOTH_COEF 0.01 /* smoothing coef for signal norms and stereo width */
|
||||||
|
|
||||||
/* Range of pitch lag estimates */
|
/* Range of pitch lag estimates */
|
||||||
#define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */
|
#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_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */
|
||||||
|
|
||||||
/* Maximum number of subframes */
|
/* Maximum number of subframes */
|
||||||
#define MAX_NB_SUBFR 4
|
#define MAX_NB_SUBFR 4
|
||||||
|
@ -92,7 +92,7 @@ extern "C"
|
||||||
#define MAX_FRAME_LENGTH ( MAX_FRAME_LENGTH_MS * MAX_FS_KHZ )
|
#define MAX_FRAME_LENGTH ( MAX_FRAME_LENGTH_MS * MAX_FS_KHZ )
|
||||||
|
|
||||||
#define MAX_ENCODER_DELAY 18
|
#define MAX_ENCODER_DELAY 18
|
||||||
#define MAX_DECODER_DELAY 8
|
#define MAX_DECODER_DELAY 8
|
||||||
|
|
||||||
/* Milliseconds of lookahead for pitch analysis */
|
/* Milliseconds of lookahead for pitch analysis */
|
||||||
#define LA_PITCH_MS 2
|
#define LA_PITCH_MS 2
|
||||||
|
@ -193,11 +193,11 @@ extern "C"
|
||||||
#define VAD_INTERNAL_SUBFRAMES_LOG2 2
|
#define VAD_INTERNAL_SUBFRAMES_LOG2 2
|
||||||
#define VAD_INTERNAL_SUBFRAMES (1 << VAD_INTERNAL_SUBFRAMES_LOG2)
|
#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
|
#define VAD_NOISE_LEVELS_BIAS 50
|
||||||
|
|
||||||
/* Sigmoid settings */
|
/* 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
|
#define VAD_SNR_FACTOR_Q16 45000
|
||||||
|
|
||||||
/* smoothing for SNR measurement */
|
/* smoothing for SNR measurement */
|
||||||
|
@ -219,10 +219,10 @@ extern "C"
|
||||||
#define NLSF_QUANT_DEL_DEC_STATES ( 1 << NLSF_QUANT_DEL_DEC_STATES_LOG2 )
|
#define NLSF_QUANT_DEL_DEC_STATES ( 1 << NLSF_QUANT_DEL_DEC_STATES_LOG2 )
|
||||||
|
|
||||||
/* Transition filtering for mode switching */
|
/* Transition filtering for mode switching */
|
||||||
#define TRANSITION_TIME_MS 5120 /* 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)*/
|
#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_NB 3 /* Hardcoded in tables */
|
||||||
#define TRANSITION_NA 2 /* Hardcoded in tables */
|
#define TRANSITION_NA 2 /* Hardcoded in tables */
|
||||||
#define TRANSITION_INT_NUM 5 /* Hardcoded in tables */
|
#define TRANSITION_INT_NUM 5 /* Hardcoded in tables */
|
||||||
#define TRANSITION_FRAMES ( TRANSITION_TIME_MS / MAX_FRAME_LENGTH_MS )
|
#define TRANSITION_FRAMES ( TRANSITION_TIME_MS / MAX_FRAME_LENGTH_MS )
|
||||||
#define TRANSITION_INT_STEPS ( TRANSITION_FRAMES / ( TRANSITION_INT_NUM - 1 ) )
|
#define TRANSITION_INT_STEPS ( TRANSITION_FRAMES / ( TRANSITION_INT_NUM - 1 ) )
|
||||||
|
|
||||||
|
@ -230,9 +230,9 @@ extern "C"
|
||||||
#define BWE_AFTER_LOSS_Q16 63570
|
#define BWE_AFTER_LOSS_Q16 63570
|
||||||
|
|
||||||
/* Defines for CN generation */
|
/* Defines for CN generation */
|
||||||
#define CNG_BUF_MASK_MAX 255 /* 2^floor(log2(MAX_FRAME_LENGTH))-1 */
|
#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_GAIN_SMTH_Q16 4634 /* 0.25^(1/4) */
|
||||||
#define CNG_NLSF_SMTH_Q16 16348 /* 0.25 */
|
#define CNG_NLSF_SMTH_Q16 16348 /* 0.25 */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/* Encoder functions */
|
/* 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;
|
opus_int ret = SILK_NO_ERROR;
|
||||||
|
|
||||||
|
@ -56,9 +58,9 @@ opus_int silk_Get_Encoder_Size( opus_int *encSizeBytes )
|
||||||
/*************************/
|
/*************************/
|
||||||
/* Init or Reset encoder */
|
/* Init or Reset encoder */
|
||||||
/*************************/
|
/*************************/
|
||||||
opus_int silk_InitEncoder(
|
opus_int silk_InitEncoder( /* O Returns error code */
|
||||||
void *encState, /* I/O: State */
|
void *encState, /* I/O State */
|
||||||
silk_EncControlStruct *encStatus /* O: Control structure */
|
silk_EncControlStruct *encStatus /* O Encoder Status */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
silk_encoder *psEnc;
|
silk_encoder *psEnc;
|
||||||
|
@ -88,9 +90,9 @@ opus_int silk_InitEncoder(
|
||||||
/***************************************/
|
/***************************************/
|
||||||
/* Read control structure from encoder */
|
/* Read control structure from encoder */
|
||||||
/***************************************/
|
/***************************************/
|
||||||
opus_int silk_QueryEncoder(
|
opus_int silk_QueryEncoder( /* O Returns error code */
|
||||||
const void *encState, /* I: State Vector */
|
const void *encState, /* I State */
|
||||||
silk_EncControlStruct *encStatus /* O: Control Structure */
|
silk_EncControlStruct *encStatus /* O Encoder Status */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int ret = SILK_NO_ERROR;
|
opus_int ret = SILK_NO_ERROR;
|
||||||
|
@ -123,14 +125,16 @@ opus_int silk_QueryEncoder(
|
||||||
/**************************/
|
/**************************/
|
||||||
/* Encode frame with Silk */
|
/* Encode frame with Silk */
|
||||||
/**************************/
|
/**************************/
|
||||||
opus_int silk_Encode(
|
/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */
|
||||||
void *encState, /* I/O: State */
|
/* encControl->payloadSize_ms is set to */
|
||||||
silk_EncControlStruct *encControl, /* I: Control structure */
|
opus_int silk_Encode( /* O Returns error code */
|
||||||
const opus_int16 *samplesIn, /* I: Speech sample input vector */
|
void *encState, /* I/O State */
|
||||||
opus_int nSamplesIn, /* I: Number of samples in input vector */
|
silk_EncControlStruct *encControl, /* I Control status */
|
||||||
ec_enc *psRangeEnc, /* I/O Compressor data structure */
|
const opus_int16 *samplesIn, /* I Speech sample input vector */
|
||||||
opus_int *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
|
opus_int nSamplesIn, /* I Number of samples in input vector */
|
||||||
const opus_int prefillFlag /* I: Flag to indicate prefilling buffers; no coding */
|
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;
|
opus_int n, i, nBits, flags, tmp_payloadSize_ms = 0, tmp_complexity = 0, ret = 0;
|
||||||
|
@ -270,17 +274,18 @@ opus_int silk_Encode(
|
||||||
buf[ n + delay ] = (opus_int16)silk_RSHIFT_ROUND( samplesIn[ 2 * n ] + samplesIn[ 2 * n + 1 ], 1 );
|
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) {
|
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);
|
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));
|
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,
|
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 );
|
&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 */
|
/* 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,
|
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 );
|
&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 ] =
|
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 ]
|
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);
|
+ psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx+n+2 ], 1);
|
||||||
|
@ -367,8 +372,9 @@ opus_int silk_Encode(
|
||||||
/* Total target bits for packet */
|
/* Total target bits for packet */
|
||||||
nBits = silk_DIV32_16( silk_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 );
|
nBits = silk_DIV32_16( silk_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 );
|
||||||
/* Subtract half of the bits already used */
|
/* Subtract half of the bits already used */
|
||||||
if (!prefillFlag)
|
if( !prefillFlag ) {
|
||||||
nBits -= ec_tell( psRangeEnc ) >> 1;
|
nBits -= ec_tell( psRangeEnc ) >> 1;
|
||||||
|
}
|
||||||
/* Divide by number of uncoded frames left in packet */
|
/* 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 );
|
nBits = silk_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket - psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded );
|
||||||
/* Convert to bits/second */
|
/* Convert to bits/second */
|
||||||
|
|
|
@ -33,11 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Encode side-information parameters to payload */
|
/* Encode side-information parameters to payload */
|
||||||
void silk_encode_indices(
|
void silk_encode_indices(
|
||||||
silk_encoder_state *psEncC, /* I/O Encoder state */
|
silk_encoder_state *psEncC, /* I/O Encoder state */
|
||||||
ec_enc *psRangeEnc, /* I/O Compressor data structure */
|
ec_enc *psRangeEnc, /* I/O Compressor data structure */
|
||||||
opus_int FrameIndex, /* I Frame number */
|
opus_int FrameIndex, /* I Frame number */
|
||||||
opus_int encode_LBRR, /* I Flag indicating LBRR data is being encoded */
|
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 condCoding /* I The type of conditional coding to use */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, k, typeOffset;
|
opus_int i, k, typeOffset;
|
||||||
|
@ -45,10 +45,6 @@ void silk_encode_indices(
|
||||||
opus_int16 ec_ix[ MAX_LPC_ORDER ];
|
opus_int16 ec_ix[ MAX_LPC_ORDER ];
|
||||||
opus_uint8 pred_Q8[ MAX_LPC_ORDER ];
|
opus_uint8 pred_Q8[ MAX_LPC_ORDER ];
|
||||||
const SideInfoIndices *psIndices;
|
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 ) {
|
if( encode_LBRR ) {
|
||||||
psIndices = &psEncC->indices_LBRR[ FrameIndex ];
|
psIndices = &psEncC->indices_LBRR[ FrameIndex ];
|
||||||
|
@ -71,9 +67,6 @@ void silk_encode_indices(
|
||||||
/****************/
|
/****************/
|
||||||
/* Encode gains */
|
/* Encode gains */
|
||||||
/****************/
|
/****************/
|
||||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
|
||||||
nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
|
|
||||||
#endif
|
|
||||||
/* first subframe */
|
/* first subframe */
|
||||||
if( condCoding == CODE_CONDITIONALLY ) {
|
if( condCoding == CODE_CONDITIONALLY ) {
|
||||||
/* conditional coding */
|
/* conditional coding */
|
||||||
|
@ -92,18 +85,9 @@ void silk_encode_indices(
|
||||||
ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ i ], silk_delta_gain_iCDF, 8 );
|
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 */
|
/* 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 );
|
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_NLSF_unpack( ec_ix, pred_Q8, psEncC->psNLSF_CB, psIndices->NLSFIndices[ 0 ] );
|
||||||
silk_assert( psEncC->psNLSF_CB->order == psEncC->predictLPCOrder );
|
silk_assert( psEncC->psNLSF_CB->order == psEncC->predictLPCOrder );
|
||||||
|
@ -125,21 +109,11 @@ void silk_encode_indices(
|
||||||
ec_enc_icdf( psRangeEnc, psIndices->NLSFInterpCoef_Q2, silk_NLSF_interpolation_factor_iCDF, 8 );
|
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 )
|
if( psIndices->signalType == TYPE_VOICED )
|
||||||
{
|
{
|
||||||
/*********************/
|
/*********************/
|
||||||
/* Encode pitch lags */
|
/* Encode pitch lags */
|
||||||
/*********************/
|
/*********************/
|
||||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
|
||||||
nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
|
|
||||||
#endif
|
|
||||||
/* lag index */
|
/* lag index */
|
||||||
encode_absolute_lagIndex = 1;
|
encode_absolute_lagIndex = 1;
|
||||||
if( condCoding == CODE_CONDITIONALLY && psEncC->ec_prevSignalType == TYPE_VOICED ) {
|
if( condCoding == CODE_CONDITIONALLY && psEncC->ec_prevSignalType == TYPE_VOICED ) {
|
||||||
|
@ -166,14 +140,6 @@ void silk_encode_indices(
|
||||||
}
|
}
|
||||||
psEncC->ec_prevLagIndex = psIndices->lagIndex;
|
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 */
|
/* Countour index */
|
||||||
silk_assert( psIndices->contourIndex >= 0 );
|
silk_assert( psIndices->contourIndex >= 0 );
|
||||||
silk_assert( ( psIndices->contourIndex < 34 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 4 ) ||
|
silk_assert( ( psIndices->contourIndex < 34 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 4 ) ||
|
||||||
|
@ -181,18 +147,10 @@ void silk_encode_indices(
|
||||||
( psIndices->contourIndex < 12 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 2 ) ||
|
( psIndices->contourIndex < 12 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 2 ) ||
|
||||||
( psIndices->contourIndex < 3 && 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 );
|
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 */
|
/* Encode LTP gains */
|
||||||
/********************/
|
/********************/
|
||||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
|
||||||
nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* PERIndex value */
|
/* PERIndex value */
|
||||||
silk_assert( psIndices->PERIndex >= 0 && psIndices->PERIndex < 3 );
|
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->PERIndex, silk_LTP_per_index_iCDF, 8 );
|
||||||
|
@ -211,30 +169,10 @@ void silk_encode_indices(
|
||||||
ec_enc_icdf( psRangeEnc, psIndices->LTP_scaleIndex, silk_LTPscale_iCDF, 8 );
|
ec_enc_icdf( psRangeEnc, psIndices->LTP_scaleIndex, silk_LTPscale_iCDF, 8 );
|
||||||
}
|
}
|
||||||
silk_assert( !condCoding || psIndices->LTP_scaleIndex == 0 );
|
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;
|
psEncC->ec_prevSignalType = psIndices->signalType;
|
||||||
|
|
||||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
|
||||||
nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/***************/
|
/***************/
|
||||||
/* Encode seed */
|
/* Encode seed */
|
||||||
/***************/
|
/***************/
|
||||||
|
|
|
@ -35,11 +35,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/* Encode quantization indices of excitation */
|
/* Encode quantization indices of excitation */
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
|
|
||||||
static inline opus_int combine_and_check( /* return ok */
|
static inline opus_int combine_and_check( /* return ok */
|
||||||
opus_int *pulses_comb, /* O */
|
opus_int *pulses_comb, /* O */
|
||||||
const opus_int *pulses_in, /* I */
|
const opus_int *pulses_in, /* I */
|
||||||
opus_int max_pulses, /* I max value for sum of pulses */
|
opus_int max_pulses, /* I max value for sum of pulses */
|
||||||
opus_int len /* I number of output values */
|
opus_int len /* I number of output values */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, sum;
|
opus_int k, sum;
|
||||||
|
@ -57,11 +57,11 @@ static inline opus_int combine_and_check( /* return ok */
|
||||||
|
|
||||||
/* Encode quantization indices of excitation */
|
/* Encode quantization indices of excitation */
|
||||||
void silk_encode_pulses(
|
void silk_encode_pulses(
|
||||||
ec_enc *psRangeEnc, /* I/O compressor data structure */
|
ec_enc *psRangeEnc, /* I/O compressor data structure */
|
||||||
const opus_int signalType, /* I Sigtype */
|
const opus_int signalType, /* I Signal type */
|
||||||
const opus_int quantOffsetType, /* I quantOffsetType */
|
const opus_int quantOffsetType, /* I quantOffsetType */
|
||||||
opus_int8 pulses[], /* I quantization indices */
|
opus_int8 pulses[], /* I quantization indices */
|
||||||
const opus_int frame_length /* I Frame length */
|
const opus_int frame_length /* I Frame length */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, k, j, iter, bit, nLS, scale_down, RateLevelIndex = 0;
|
opus_int i, k, j, iter, bit, nLS, scale_down, RateLevelIndex = 0;
|
||||||
|
@ -83,7 +83,7 @@ void silk_encode_pulses(
|
||||||
/* Calculate number of shell blocks */
|
/* Calculate number of shell blocks */
|
||||||
silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH );
|
silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH );
|
||||||
iter = silk_RSHIFT( frame_length, LOG2_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 */
|
silk_assert( frame_length == 12 * 10 ); /* Make sure only happens for 10 ms @ 12 kHz */
|
||||||
iter++;
|
iter++;
|
||||||
silk_memset( &pulses[ frame_length ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof(opus_int8));
|
silk_memset( &pulses[ frame_length ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof(opus_int8));
|
||||||
|
|
|
@ -32,14 +32,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "main_FIX.h"
|
#include "main_FIX.h"
|
||||||
|
|
||||||
void silk_LTP_analysis_filter_FIX(
|
void silk_LTP_analysis_filter_FIX(
|
||||||
opus_int16 *LTP_res, /* O: LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */
|
opus_int16 *LTP_res, /* O LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */
|
||||||
const opus_int16 *x, /* I: Pointer to input signal with at least max( pitchL ) preceeding samples */
|
const opus_int16 *x, /* I Pointer to input signal with at least max( pitchL ) preceeding samples */
|
||||||
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I: LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */
|
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */
|
||||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I: Pitch lag, one for each subframe */
|
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag, one for each subframe */
|
||||||
const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I: Inverse quantization gains, one for each subframe */
|
const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I Inverse quantization gains, one for each subframe */
|
||||||
const opus_int subfr_length, /* I: Length of each subframe */
|
const opus_int subfr_length, /* I Length of each subframe */
|
||||||
const opus_int nb_subfr, /* I: Number of subframes */
|
const opus_int nb_subfr, /* I Number of subframes */
|
||||||
const opus_int pre_length /* I: Length of the preceeding samples starting at &x[0] for each subframe */
|
const opus_int pre_length /* I Length of the preceeding samples starting at &x[0] for each subframe */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const opus_int16 *x_ptr, *x_lag_ptr;
|
const opus_int16 *x_ptr, *x_lag_ptr;
|
||||||
|
|
|
@ -31,10 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "main_FIX.h"
|
#include "main_FIX.h"
|
||||||
|
|
||||||
|
/* Calculation of LTP state scaling */
|
||||||
void silk_LTP_scale_ctrl_FIX(
|
void silk_LTP_scale_ctrl_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O encoder state FIX */
|
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control FIX */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int round_loss;
|
opus_int round_loss;
|
||||||
|
|
|
@ -48,10 +48,10 @@ static opus_int16 freq_table_Q16[ 27 ] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void silk_apply_sine_window(
|
void silk_apply_sine_window(
|
||||||
opus_int16 px_win[], /* O Pointer to windowed signal */
|
opus_int16 px_win[], /* O Pointer to windowed signal */
|
||||||
const opus_int16 px[], /* I Pointer to input signal */
|
const opus_int16 px[], /* I Pointer to input signal */
|
||||||
const opus_int win_type, /* I Selects a window type */
|
const opus_int win_type, /* I Selects a window type */
|
||||||
const opus_int length /* I Window length, multiple of 4 */
|
const opus_int length /* I Window length, multiple of 4 */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, f_Q16, c_Q16;
|
opus_int k, f_Q16, c_Q16;
|
||||||
|
|
|
@ -33,11 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Compute autocorrelation */
|
/* Compute autocorrelation */
|
||||||
void silk_autocorr(
|
void silk_autocorr(
|
||||||
opus_int32 *results, /* O Result (length correlationCount) */
|
opus_int32 *results, /* O Result (length correlationCount) */
|
||||||
opus_int *scale, /* O Scaling of the correlation vector */
|
opus_int *scale, /* O Scaling of the correlation vector */
|
||||||
const opus_int16 *inputData, /* I Input data to correlate */
|
const opus_int16 *inputData, /* I Input data to correlate */
|
||||||
const opus_int inputDataSize, /* I Length of input */
|
const opus_int inputDataSize, /* I Length of input */
|
||||||
const opus_int correlationCount /* I Number of correlation taps to compute */
|
const opus_int correlationCount /* I Number of correlation taps to compute */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, lz, nRightShifts, corrCount;
|
opus_int i, lz, nRightShifts, corrCount;
|
||||||
|
|
|
@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "SigProc_FIX.h"
|
#include "SigProc_FIX.h"
|
||||||
|
|
||||||
#define MAX_FRAME_SIZE 384 /* subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384*/
|
#define MAX_FRAME_SIZE 384 /* subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384 */
|
||||||
#define MAX_NB_SUBFR 4
|
#define MAX_NB_SUBFR 4
|
||||||
|
|
||||||
#define QA 25
|
#define QA 25
|
||||||
|
@ -41,14 +41,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Compute reflection coefficients from input signal */
|
/* Compute reflection coefficients from input signal */
|
||||||
void silk_burg_modified(
|
void silk_burg_modified(
|
||||||
opus_int32 *res_nrg, /* O residual energy */
|
opus_int32 *res_nrg, /* O Residual energy */
|
||||||
opus_int *res_nrg_Q, /* O residual energy Q value */
|
opus_int *res_nrg_Q, /* O Residual energy Q value */
|
||||||
opus_int32 A_Q16[], /* O prediction coefficients (length order) */
|
opus_int32 A_Q16[], /* O Prediction coefficients (length order) */
|
||||||
const opus_int16 x[], /* I input signal, length: nb_subfr * ( D + subfr_length ) */
|
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 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_int nb_subfr, /* I Number of subframes stacked in x */
|
||||||
const opus_int32 WhiteNoiseFrac_Q32, /* I fraction added to zero-lag autocorrelation */
|
const opus_int32 WhiteNoiseFrac_Q32, /* I Fraction added to zero-lag autocorrelation */
|
||||||
const opus_int D /* I order */
|
const opus_int D /* I Order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, n, s, lz, rshifts, rshifts_extra;
|
opus_int k, n, s, lz, rshifts, rshifts_extra;
|
||||||
|
@ -105,7 +105,7 @@ void silk_burg_modified(
|
||||||
silk_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) );
|
silk_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) );
|
||||||
|
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
CAb[ 0 ] = CAf[ 0 ] = C0 + silk_SMMUL( WhiteNoiseFrac_Q32, C0 ) + 1; /* Q(-rshifts)*/
|
CAb[ 0 ] = CAf[ 0 ] = C0 + silk_SMMUL( WhiteNoiseFrac_Q32, C0 ) + 1; /* Q(-rshifts)*/
|
||||||
|
|
||||||
for( n = 0; n < D; n++ ) {
|
for( n = 0; n < D; n++ ) {
|
||||||
/* Update first row of correlation matrix (without first element) */
|
/* Update first row of correlation matrix (without first element) */
|
||||||
|
@ -115,70 +115,70 @@ void silk_burg_modified(
|
||||||
if( rshifts > -2 ) {
|
if( rshifts > -2 ) {
|
||||||
for( s = 0; s < nb_subfr; s++ ) {
|
for( s = 0; s < nb_subfr; s++ ) {
|
||||||
x_ptr = x + s * subfr_length;
|
x_ptr = x + s * subfr_length;
|
||||||
x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], 16 - rshifts ); /* Q(16-rshifts)*/
|
x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], 16 - rshifts ); /* Q(16-rshifts)*/
|
||||||
x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 16 - rshifts ); /* Q(16-rshifts)*/
|
x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 16 - rshifts ); /* Q(16-rshifts)*/
|
||||||
tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], QA - 16 ); /* Q(QA-16)*/
|
tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], QA - 16 ); /* Q(QA-16)*/
|
||||||
tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], QA - 16 ); /* Q(QA-16)*/
|
tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], QA - 16 ); /* Q(QA-16)*/
|
||||||
for( k = 0; k < n; k++ ) {
|
for( k = 0; k < n; k++ ) {
|
||||||
C_first_row[ k ] = silk_SMLAWB( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts )*/
|
C_first_row[ k ] = silk_SMLAWB( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts )*/
|
||||||
C_last_row[ k ] = silk_SMLAWB( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts )*/
|
C_last_row[ k ] = silk_SMLAWB( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts )*/
|
||||||
Atmp_QA = Af_QA[ k ];
|
Atmp_QA = Af_QA[ k ];
|
||||||
tmp1 = silk_SMLAWB( tmp1, Atmp_QA, x_ptr[ n - k - 1 ] ); /* Q(QA-16)*/
|
tmp1 = silk_SMLAWB( tmp1, Atmp_QA, x_ptr[ n - k - 1 ] ); /* Q(QA-16)*/
|
||||||
tmp2 = silk_SMLAWB( tmp2, Atmp_QA, x_ptr[ subfr_length - n + k ] ); /* Q(QA-16)*/
|
tmp2 = silk_SMLAWB( tmp2, Atmp_QA, x_ptr[ subfr_length - n + k ] ); /* Q(QA-16)*/
|
||||||
}
|
}
|
||||||
tmp1 = silk_LSHIFT32( -tmp1, 32 - QA - rshifts ); /* Q(16-rshifts)*/
|
tmp1 = silk_LSHIFT32( -tmp1, 32 - QA - rshifts ); /* Q(16-rshifts)*/
|
||||||
tmp2 = silk_LSHIFT32( -tmp2, 32 - QA - rshifts ); /* Q(16-rshifts)*/
|
tmp2 = silk_LSHIFT32( -tmp2, 32 - QA - rshifts ); /* Q(16-rshifts)*/
|
||||||
for( k = 0; k <= n; k++ ) {
|
for( k = 0; k <= n; k++ ) {
|
||||||
CAf[ k ] = silk_SMLAWB( CAf[ k ], tmp1, x_ptr[ n - k ] ); /* Q( -rshift )*/
|
CAf[ k ] = silk_SMLAWB( CAf[ k ], tmp1, x_ptr[ n - k ] ); /* Q( -rshift )*/
|
||||||
CAb[ k ] = silk_SMLAWB( CAb[ k ], tmp2, x_ptr[ subfr_length - n + k - 1 ] ); /* Q( -rshift )*/
|
CAb[ k ] = silk_SMLAWB( CAb[ k ], tmp2, x_ptr[ subfr_length - n + k - 1 ] ); /* Q( -rshift )*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for( s = 0; s < nb_subfr; s++ ) {
|
for( s = 0; s < nb_subfr; s++ ) {
|
||||||
x_ptr = x + s * subfr_length;
|
x_ptr = x + s * subfr_length;
|
||||||
x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], -rshifts ); /* Q( -rshifts )*/
|
x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], -rshifts ); /* Q( -rshifts )*/
|
||||||
x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], -rshifts ); /* Q( -rshifts )*/
|
x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], -rshifts ); /* Q( -rshifts )*/
|
||||||
tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], 17 ); /* Q17*/
|
tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], 17 ); /* Q17*/
|
||||||
tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 17 ); /* Q17*/
|
tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 17 ); /* Q17*/
|
||||||
for( k = 0; k < n; k++ ) {
|
for( k = 0; k < n; k++ ) {
|
||||||
C_first_row[ k ] = silk_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts )*/
|
C_first_row[ k ] = silk_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts )*/
|
||||||
C_last_row[ k ] = silk_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts )*/
|
C_last_row[ k ] = silk_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts )*/
|
||||||
Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17*/
|
Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17*/
|
||||||
tmp1 = silk_MLA( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17*/
|
tmp1 = silk_MLA( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17*/
|
||||||
tmp2 = silk_MLA( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17*/
|
tmp2 = silk_MLA( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17*/
|
||||||
}
|
}
|
||||||
tmp1 = -tmp1; /* Q17*/
|
tmp1 = -tmp1; /* Q17*/
|
||||||
tmp2 = -tmp2; /* Q17*/
|
tmp2 = -tmp2; /* Q17*/
|
||||||
for( k = 0; k <= n; k++ ) {
|
for( k = 0; k <= n; k++ ) {
|
||||||
CAf[ k ] = silk_SMLAWW( CAf[ k ], tmp1,
|
CAf[ k ] = silk_SMLAWW( CAf[ k ], tmp1,
|
||||||
silk_LSHIFT32( (opus_int32)x_ptr[ n - k ], -rshifts - 1 ) ); /* Q( -rshift )*/
|
silk_LSHIFT32( (opus_int32)x_ptr[ n - k ], -rshifts - 1 ) ); /* Q( -rshift )*/
|
||||||
CAb[ k ] = silk_SMLAWW( CAb[ k ], tmp2,
|
CAb[ k ] = silk_SMLAWW( CAb[ k ], tmp2,
|
||||||
silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n + k - 1 ], -rshifts - 1 ) );/* Q( -rshift )*/
|
silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n + k - 1 ], -rshifts - 1 ) ); /* Q( -rshift )*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate nominator and denominator for the next order reflection (parcor) coefficient */
|
/* Calculate nominator and denominator for the next order reflection (parcor) coefficient */
|
||||||
tmp1 = C_first_row[ n ]; /* Q( -rshifts )*/
|
tmp1 = C_first_row[ n ]; /* Q( -rshifts )*/
|
||||||
tmp2 = C_last_row[ n ]; /* Q( -rshifts )*/
|
tmp2 = C_last_row[ n ]; /* Q( -rshifts )*/
|
||||||
num = 0; /* Q( -rshifts )*/
|
num = 0; /* Q( -rshifts )*/
|
||||||
nrg = silk_ADD32( CAb[ 0 ], CAf[ 0 ] ); /* Q( 1-rshifts )*/
|
nrg = silk_ADD32( CAb[ 0 ], CAf[ 0 ] ); /* Q( 1-rshifts )*/
|
||||||
for( k = 0; k < n; k++ ) {
|
for( k = 0; k < n; k++ ) {
|
||||||
Atmp_QA = Af_QA[ k ];
|
Atmp_QA = Af_QA[ k ];
|
||||||
lz = silk_CLZ32( silk_abs( Atmp_QA ) ) - 1;
|
lz = silk_CLZ32( silk_abs( Atmp_QA ) ) - 1;
|
||||||
lz = silk_min( 32 - QA, lz );
|
lz = silk_min( 32 - QA, lz );
|
||||||
Atmp1 = silk_LSHIFT32( Atmp_QA, lz ); /* Q( QA + lz )*/
|
Atmp1 = silk_LSHIFT32( Atmp_QA, lz ); /* Q( QA + lz )*/
|
||||||
|
|
||||||
tmp1 = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( C_last_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts )*/
|
tmp1 = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( C_last_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts )*/
|
||||||
tmp2 = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( C_first_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts )*/
|
tmp2 = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( C_first_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts )*/
|
||||||
num = silk_ADD_LSHIFT32( num, silk_SMMUL( CAb[ n - k ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts )*/
|
num = silk_ADD_LSHIFT32( num, silk_SMMUL( CAb[ n - k ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts )*/
|
||||||
nrg = silk_ADD_LSHIFT32( nrg, silk_SMMUL( silk_ADD32( CAb[ k + 1 ], CAf[ k + 1 ] ),
|
nrg = silk_ADD_LSHIFT32( nrg, silk_SMMUL( silk_ADD32( CAb[ k + 1 ], CAf[ k + 1 ] ),
|
||||||
Atmp1 ), 32 - QA - lz ); /* Q( 1-rshifts )*/
|
Atmp1 ), 32 - QA - lz ); /* Q( 1-rshifts )*/
|
||||||
}
|
}
|
||||||
CAf[ n + 1 ] = tmp1; /* Q( -rshifts )*/
|
CAf[ n + 1 ] = tmp1; /* Q( -rshifts )*/
|
||||||
CAb[ n + 1 ] = tmp2; /* Q( -rshifts )*/
|
CAb[ n + 1 ] = tmp2; /* Q( -rshifts )*/
|
||||||
num = silk_ADD32( num, tmp2 ); /* Q( -rshifts )*/
|
num = silk_ADD32( num, tmp2 ); /* Q( -rshifts )*/
|
||||||
num = silk_LSHIFT32( -num, 1 ); /* Q( 1-rshifts )*/
|
num = silk_LSHIFT32( -num, 1 ); /* Q( 1-rshifts )*/
|
||||||
|
|
||||||
/* Calculate the next order reflection (parcor) coefficient */
|
/* Calculate the next order reflection (parcor) coefficient */
|
||||||
if( silk_abs( num ) < nrg ) {
|
if( silk_abs( num ) < nrg ) {
|
||||||
|
@ -192,31 +192,31 @@ void silk_burg_modified(
|
||||||
|
|
||||||
/* Update the AR coefficients */
|
/* Update the AR coefficients */
|
||||||
for( k = 0; k < (n + 1) >> 1; k++ ) {
|
for( k = 0; k < (n + 1) >> 1; k++ ) {
|
||||||
tmp1 = Af_QA[ k ]; /* QA*/
|
tmp1 = Af_QA[ k ]; /* QA*/
|
||||||
tmp2 = Af_QA[ n - k - 1 ]; /* QA*/
|
tmp2 = Af_QA[ n - k - 1 ]; /* QA*/
|
||||||
Af_QA[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* QA*/
|
Af_QA[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* QA*/
|
||||||
Af_QA[ n - k - 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* QA*/
|
Af_QA[ n - k - 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* QA*/
|
||||||
}
|
}
|
||||||
Af_QA[ n ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA*/
|
Af_QA[ n ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA*/
|
||||||
|
|
||||||
/* Update C * Af and C * Ab */
|
/* Update C * Af and C * Ab */
|
||||||
for( k = 0; k <= n + 1; k++ ) {
|
for( k = 0; k <= n + 1; k++ ) {
|
||||||
tmp1 = CAf[ k ]; /* Q( -rshifts )*/
|
tmp1 = CAf[ k ]; /* Q( -rshifts )*/
|
||||||
tmp2 = CAb[ n - k + 1 ]; /* Q( -rshifts )*/
|
tmp2 = CAb[ n - k + 1 ]; /* Q( -rshifts )*/
|
||||||
CAf[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* Q( -rshifts )*/
|
CAf[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* Q( -rshifts )*/
|
||||||
CAb[ n - k + 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* Q( -rshifts )*/
|
CAb[ n - k + 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* Q( -rshifts )*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return residual energy */
|
/* Return residual energy */
|
||||||
nrg = CAf[ 0 ]; /* Q( -rshifts )*/
|
nrg = CAf[ 0 ]; /* Q( -rshifts )*/
|
||||||
tmp1 = 1 << 16; /* Q16*/
|
tmp1 = 1 << 16; /* Q16*/
|
||||||
for( k = 0; k < D; k++ ) {
|
for( k = 0; k < D; k++ ) {
|
||||||
Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); /* Q16*/
|
Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); /* Q16*/
|
||||||
nrg = silk_SMLAWW( nrg, CAf[ k + 1 ], Atmp1 ); /* Q( -rshifts )*/
|
nrg = silk_SMLAWW( nrg, CAf[ k + 1 ], Atmp1 ); /* Q( -rshifts )*/
|
||||||
tmp1 = silk_SMLAWW( tmp1, Atmp1, Atmp1 ); /* Q16*/
|
tmp1 = silk_SMLAWW( tmp1, Atmp1, Atmp1 ); /* Q16*/
|
||||||
A_Q16[ k ] = -Atmp1;
|
A_Q16[ k ] = -Atmp1;
|
||||||
}
|
}
|
||||||
*res_nrg = silk_SMLAWW( nrg, silk_SMMUL( WhiteNoiseFrac_Q32, C0 ), -tmp1 ); /* Q( -rshifts )*/
|
*res_nrg = silk_SMLAWW( nrg, silk_SMMUL( WhiteNoiseFrac_Q32, C0 ), -tmp1 ); /* Q( -rshifts )*/
|
||||||
*res_nrg_Q = -rshifts;
|
*res_nrg_Q = -rshifts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Calculates correlation vector X'*t */
|
/* Calculates correlation vector X'*t */
|
||||||
void silk_corrVector_FIX(
|
void silk_corrVector_FIX(
|
||||||
const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
|
const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
|
||||||
const opus_int16 *t, /* I target vector [L] */
|
const opus_int16 *t, /* I Target vector [L] */
|
||||||
const opus_int L, /* I Length of vectors */
|
const opus_int L, /* I Length of vectors */
|
||||||
const opus_int order, /* I Max lag for correlation */
|
const opus_int order, /* I Max lag for correlation */
|
||||||
opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */
|
opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */
|
||||||
const opus_int rshifts /* I Right shifts of correlations */
|
const opus_int rshifts /* I Right shifts of correlations */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int lag, i;
|
opus_int lag, i;
|
||||||
|
@ -73,12 +73,12 @@ void silk_corrVector_FIX(
|
||||||
|
|
||||||
/* Calculates correlation matrix X'*X */
|
/* Calculates correlation matrix X'*X */
|
||||||
void silk_corrMatrix_FIX(
|
void silk_corrMatrix_FIX(
|
||||||
const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
|
const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
|
||||||
const opus_int L, /* I Length of vectors */
|
const opus_int L, /* I Length of vectors */
|
||||||
const opus_int order, /* I Max lag for correlation */
|
const opus_int order, /* I Max lag for correlation */
|
||||||
const opus_int head_room, /* I Desired headroom */
|
const opus_int head_room, /* I Desired headroom */
|
||||||
opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ]*/
|
opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */
|
||||||
opus_int *rshifts /* I/O Right shifts of correlations */
|
opus_int *rshifts /* I/O Right shifts of correlations */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j, lag, rshifts_local, head_room_rshifts;
|
opus_int i, j, lag, rshifts_local, head_room_rshifts;
|
||||||
|
|
|
@ -34,22 +34,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */
|
/* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */
|
||||||
static inline void silk_LBRR_encode_FIX(
|
static inline void silk_LBRR_encode_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
|
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */
|
||||||
const opus_int16 xfw[], /* I Input signal */
|
const opus_int16 xfw[], /* I Input signal */
|
||||||
opus_int condCoding /* I The type of conditional coding used so far for this frame */
|
opus_int condCoding /* I The type of conditional coding used so far for this frame */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_encode_do_VAD_FIX(
|
void silk_encode_do_VAD_FIX(
|
||||||
silk_encoder_state_FIX *psEnc /* I/O Encoder state FIX */
|
silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/****************************/
|
/****************************/
|
||||||
/* Voice Activity Detection */
|
/* Voice Activity Detection */
|
||||||
/****************************/
|
/****************************/
|
||||||
TIC(VAD)
|
|
||||||
silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 );
|
silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 );
|
||||||
TOC(VAD)
|
|
||||||
|
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
/* Convert speech activity into VAD and DTX flags */
|
/* Convert speech activity into VAD and DTX flags */
|
||||||
|
@ -76,12 +74,12 @@ TOC(VAD)
|
||||||
/* Encode frame */
|
/* Encode frame */
|
||||||
/****************/
|
/****************/
|
||||||
opus_int silk_encode_frame_FIX(
|
opus_int silk_encode_frame_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
|
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
|
||||||
opus_int32 *pnBytesOut, /* O Number of payload bytes */
|
opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */
|
||||||
ec_enc *psRangeEnc, /* I/O compressor data structure */
|
ec_enc *psRangeEnc, /* I/O compressor data structure */
|
||||||
opus_int condCoding, /* I The type of conditional coding to use */
|
opus_int condCoding, /* I The type of conditional coding to use */
|
||||||
opus_int maxBits, /* I If > 0: maximum number of output bits */
|
opus_int maxBits, /* I If > 0: maximum number of output bits */
|
||||||
opus_int useCBR /* I Flag to force constant-bitrate operation */
|
opus_int useCBR /* I Flag to force constant-bitrate operation */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
silk_encoder_control_FIX sEncCtrl;
|
silk_encoder_control_FIX sEncCtrl;
|
||||||
|
@ -99,10 +97,7 @@ opus_int silk_encode_frame_FIX(
|
||||||
opus_int8 LastGainIndex_copy2;
|
opus_int8 LastGainIndex_copy2;
|
||||||
opus_uint8 ec_buf_copy[ 1275 ];
|
opus_uint8 ec_buf_copy[ 1275 ];
|
||||||
|
|
||||||
TIC(ENCODE_FRAME)
|
/* This is totally unnecessary but many compilers (including gcc) are too dumb to realise it */
|
||||||
|
|
||||||
/* This is totally unnecessary but many compilers (including gcc) are too dumb
|
|
||||||
to realise it */
|
|
||||||
LastGainIndex_copy2 = nBits_lower = nBits_upper = gainMult_lower = gainMult_upper = 0;
|
LastGainIndex_copy2 = nBits_lower = nBits_upper = gainMult_lower = gainMult_upper = 0;
|
||||||
|
|
||||||
psEnc->sCmn.indices.Seed = psEnc->sCmn.frameCounter++ & 3;
|
psEnc->sCmn.indices.Seed = psEnc->sCmn.frameCounter++ & 3;
|
||||||
|
@ -127,47 +122,34 @@ TIC(ENCODE_FRAME)
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
/* Find pitch lags, initial LPC analysis */
|
/* Find pitch lags, initial LPC analysis */
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
TIC(FIND_PITCH)
|
|
||||||
silk_find_pitch_lags_FIX( psEnc, &sEncCtrl, res_pitch, x_frame );
|
silk_find_pitch_lags_FIX( psEnc, &sEncCtrl, res_pitch, x_frame );
|
||||||
TOC(FIND_PITCH)
|
|
||||||
|
|
||||||
/************************/
|
/************************/
|
||||||
/* Noise shape analysis */
|
/* Noise shape analysis */
|
||||||
/************************/
|
/************************/
|
||||||
TIC(NOISE_SHAPE_ANALYSIS)
|
|
||||||
silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame );
|
silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame );
|
||||||
TOC(NOISE_SHAPE_ANALYSIS)
|
|
||||||
|
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
/* Find linear prediction coefficients (LPC + LTP) */
|
/* Find linear prediction coefficients (LPC + LTP) */
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
TIC(FIND_PRED_COEF)
|
|
||||||
silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch, x_frame, condCoding );
|
silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch, x_frame, condCoding );
|
||||||
TOC(FIND_PRED_COEF)
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Process gains */
|
/* Process gains */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
TIC(PROCESS_GAINS)
|
|
||||||
silk_process_gains_FIX( psEnc, &sEncCtrl, condCoding );
|
silk_process_gains_FIX( psEnc, &sEncCtrl, condCoding );
|
||||||
TOC(PROCESS_GAINS)
|
|
||||||
|
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
/* Prefiltering for noise shaper */
|
/* Prefiltering for noise shaper */
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
TIC(PREFILTER)
|
|
||||||
silk_prefilter_FIX( psEnc, &sEncCtrl, xfw, x_frame );
|
silk_prefilter_FIX( psEnc, &sEncCtrl, xfw, x_frame );
|
||||||
TOC(PREFILTER)
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Low Bitrate Redundant Encoding */
|
/* Low Bitrate Redundant Encoding */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
TIC(LBRR)
|
|
||||||
silk_LBRR_encode_FIX( psEnc, &sEncCtrl, xfw, condCoding );
|
silk_LBRR_encode_FIX( psEnc, &sEncCtrl, xfw, condCoding );
|
||||||
TOC(LBRR)
|
|
||||||
|
|
||||||
if( psEnc->sCmn.prefillFlag ) {
|
if( psEnc->sCmn.prefillFlag ) {
|
||||||
TIC(NSQ)
|
|
||||||
if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) {
|
if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) {
|
||||||
silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses,
|
silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses,
|
||||||
sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14,
|
sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14,
|
||||||
|
@ -177,7 +159,6 @@ TIC(NSQ)
|
||||||
sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14,
|
sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14,
|
||||||
sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 );
|
sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 );
|
||||||
}
|
}
|
||||||
TOC(NSQ)
|
|
||||||
} else {
|
} else {
|
||||||
/* Loop over quantizer and entropy coding to control bitrate */
|
/* Loop over quantizer and entropy coding to control bitrate */
|
||||||
maxIter = 5;
|
maxIter = 5;
|
||||||
|
@ -211,7 +192,6 @@ TOC(NSQ)
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
/* Noise shaping quantization */
|
/* Noise shaping quantization */
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
TIC(NSQ)
|
|
||||||
if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) {
|
if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) {
|
||||||
silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses,
|
silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses,
|
||||||
sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14,
|
sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14,
|
||||||
|
@ -221,22 +201,17 @@ TIC(NSQ)
|
||||||
sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14,
|
sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14,
|
||||||
sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 );
|
sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 );
|
||||||
}
|
}
|
||||||
TOC(NSQ)
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Encode Parameters */
|
/* Encode Parameters */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
TIC(ENCODE_PARAMS)
|
|
||||||
silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding );
|
silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding );
|
||||||
TOC(ENCODE_PARAMS)
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Encode Excitation Signal */
|
/* Encode Excitation Signal */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
TIC(ENCODE_PULSES)
|
|
||||||
silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
|
silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
|
||||||
psEnc->sCmn.pulses, psEnc->sCmn.frame_length );
|
psEnc->sCmn.pulses, psEnc->sCmn.frame_length );
|
||||||
TOC(ENCODE_PULSES)
|
|
||||||
|
|
||||||
nBits = ec_tell( psRangeEnc );
|
nBits = ec_tell( psRangeEnc );
|
||||||
|
|
||||||
|
@ -344,59 +319,15 @@ TOC(ENCODE_PULSES)
|
||||||
/* Payload size */
|
/* Payload size */
|
||||||
*pnBytesOut = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
|
*pnBytesOut = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
|
||||||
|
|
||||||
TOC(ENCODE_FRAME)
|
|
||||||
|
|
||||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
|
||||||
{
|
|
||||||
silk_float tmp[ MAX_NB_SUBFR * LTP_ORDER ];
|
|
||||||
int i;
|
|
||||||
DEBUG_STORE_DATA( xf.dat, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.frame_length * sizeof( opus_int16 ) );
|
|
||||||
DEBUG_STORE_DATA( xfw.dat, xfw, psEnc->sCmn.frame_length * sizeof( opus_int16 ) );
|
|
||||||
DEBUG_STORE_DATA( pitchL.dat, sEncCtrl.pitchL, psEnc->sCmn.nb_subfr * sizeof( opus_int ) );
|
|
||||||
for( i = 0; i < psEnc->sCmn.nb_subfr * LTP_ORDER; i++ ) {
|
|
||||||
tmp[ i ] = (silk_float)sEncCtrl.LTPCoef_Q14[ i ] / 16384.0f;
|
|
||||||
}
|
|
||||||
DEBUG_STORE_DATA( pitchG_quantized.dat, tmp, psEnc->sCmn.nb_subfr * LTP_ORDER * sizeof( silk_float ) );
|
|
||||||
for( i = 0; i <psEnc->sCmn.predictLPCOrder; i++ ) {
|
|
||||||
tmp[ i ] = (silk_float)sEncCtrl.PredCoef_Q12[ 1 ][ i ] / 4096.0f;
|
|
||||||
}
|
|
||||||
DEBUG_STORE_DATA( PredCoef.dat, tmp, psEnc->sCmn.predictLPCOrder * sizeof( silk_float ) );
|
|
||||||
|
|
||||||
tmp[ 0 ] = (silk_float)sEncCtrl.LTPredCodGain_Q7 / 128.0f;
|
|
||||||
DEBUG_STORE_DATA( LTPredCodGain.dat, tmp, sizeof( silk_float ) );
|
|
||||||
tmp[ 0 ] = (silk_float)psEnc->LTPCorr_Q15 / 32768.0f;
|
|
||||||
DEBUG_STORE_DATA( LTPcorr.dat, tmp, sizeof( silk_float ) );
|
|
||||||
tmp[ 0 ] = (silk_float)psEnc->sCmn.input_tilt_Q15 / 32768.0f;
|
|
||||||
DEBUG_STORE_DATA( tilt.dat, tmp, sizeof( silk_float ) );
|
|
||||||
for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
|
|
||||||
tmp[ i ] = (silk_float)sEncCtrl.Gains_Q16[ i ] / 65536.0f;
|
|
||||||
}
|
|
||||||
DEBUG_STORE_DATA( gains.dat, tmp, psEnc->sCmn.nb_subfr * sizeof( silk_float ) );
|
|
||||||
DEBUG_STORE_DATA( gains_indices.dat, &psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr * sizeof( opus_int ) );
|
|
||||||
tmp[ 0 ] = (silk_float)sEncCtrl.current_SNR_dB_Q7 / 128.0f;
|
|
||||||
DEBUG_STORE_DATA( current_SNR_db.dat, tmp, sizeof( silk_float ) );
|
|
||||||
DEBUG_STORE_DATA( quantOffsetType.dat, &psEnc->sCmn.indices.quantOffsetType, sizeof( opus_int ) );
|
|
||||||
tmp[ 0 ] = (silk_float)psEnc->sCmn.speech_activity_Q8 / 256.0f;
|
|
||||||
DEBUG_STORE_DATA( speech_activity.dat, tmp, sizeof( silk_float ) );
|
|
||||||
for( i = 0; i < VAD_N_BANDS; i++ ) {
|
|
||||||
tmp[ i ] = (silk_float)psEnc->sCmn.input_quality_bands_Q15[ i ] / 32768.0f;
|
|
||||||
}
|
|
||||||
DEBUG_STORE_DATA( input_quality_bands.dat, tmp, VAD_N_BANDS * sizeof( silk_float ) );
|
|
||||||
DEBUG_STORE_DATA( signalType.dat, &psEnc->sCmn.indices.signalType, sizeof( opus_int8) );
|
|
||||||
DEBUG_STORE_DATA( lag_index.dat, &psEnc->sCmn.indices.lagIndex, sizeof( opus_int16 ) );
|
|
||||||
DEBUG_STORE_DATA( contour_index.dat, &psEnc->sCmn.indices.contourIndex, sizeof( opus_int8 ) );
|
|
||||||
DEBUG_STORE_DATA( per_index.dat, &psEnc->sCmn.indices.PERIndex, sizeof( opus_int8) );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */
|
/* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */
|
||||||
void silk_LBRR_encode_FIX(
|
static inline void silk_LBRR_encode_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
|
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */
|
||||||
const opus_int16 xfw[], /* I Input signal */
|
const opus_int16 xfw[], /* I Input signal */
|
||||||
opus_int condCoding /* I The type of conditional coding used so far for this frame */
|
opus_int condCoding /* I The type of conditional coding used so far for this frame */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int32 TempGains_Q16[ MAX_NB_SUBFR ];
|
opus_int32 TempGains_Q16[ MAX_NB_SUBFR ];
|
||||||
|
|
|
@ -34,15 +34,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Finds LPC vector from correlations, and converts to NLSF */
|
/* Finds LPC vector from correlations, and converts to NLSF */
|
||||||
void silk_find_LPC_FIX(
|
void silk_find_LPC_FIX(
|
||||||
opus_int16 NLSF_Q15[], /* O NLSFs */
|
opus_int16 NLSF_Q15[], /* O NLSFs */
|
||||||
opus_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */
|
opus_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */
|
||||||
const opus_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */
|
const opus_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */
|
||||||
const opus_int useInterpNLSFs, /* I Flag */
|
const opus_int useInterpNLSFs, /* I Flag */
|
||||||
const opus_int firstFrameAfterReset, /* I Flag */
|
const opus_int firstFrameAfterReset, /* I Flag */
|
||||||
const opus_int LPC_order, /* I LPC order */
|
const opus_int LPC_order, /* I LPC order */
|
||||||
const opus_int16 x[], /* I Input signal */
|
const opus_int16 x[], /* I Input signal */
|
||||||
const opus_int subfr_length, /* I Input signal subframe length including preceeding samples */
|
const opus_int subfr_length, /* I Input signal subframe length including preceeding samples */
|
||||||
const opus_int nb_subfr /* I: Number of subframes */
|
const opus_int nb_subfr /* I Number of subframes */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k;
|
opus_int k;
|
||||||
|
|
|
@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "main_FIX.h"
|
#include "main_FIX.h"
|
||||||
#include "tuning_parameters.h"
|
#include "tuning_parameters.h"
|
||||||
|
|
||||||
/* Head room for correlations */
|
/* Head room for correlations */
|
||||||
#define LTP_CORRS_HEAD_ROOM 2
|
#define LTP_CORRS_HEAD_ROOM 2
|
||||||
|
|
||||||
void silk_fit_LTP(
|
void silk_fit_LTP(
|
||||||
|
@ -41,16 +41,16 @@ void silk_fit_LTP(
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_find_LTP_FIX(
|
void silk_find_LTP_FIX(
|
||||||
opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
|
opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
|
||||||
opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
|
opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
|
||||||
opus_int *LTPredCodGain_Q7, /* O LTP coding gain */
|
opus_int *LTPredCodGain_Q7, /* O LTP coding gain */
|
||||||
const opus_int16 r_lpc[] , /* I residual signal after LPC signal + state for first 10 ms */
|
const opus_int16 r_lpc[], /* I residual signal after LPC signal + state for first 10 ms */
|
||||||
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
||||||
const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */
|
const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */
|
||||||
const opus_int subfr_length, /* I subframe length */
|
const opus_int subfr_length, /* I subframe length */
|
||||||
const opus_int nb_subfr, /* I number of subframes */
|
const opus_int nb_subfr, /* I number of subframes */
|
||||||
const opus_int mem_offset, /* I number of samples in LTP memory */
|
const opus_int mem_offset, /* I number of samples in LTP memory */
|
||||||
opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */
|
opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, k, lshift;
|
opus_int i, k, lshift;
|
||||||
|
@ -112,9 +112,9 @@ void silk_find_LTP_FIX(
|
||||||
denom32 = silk_LSHIFT_SAT32( silk_SMULWB( nrg[ k ], Wght_Q15[ k ] ), 1 + extra_shifts ) + /* Q( -corr_rshifts[ k ] + extra_shifts ) */
|
denom32 = silk_LSHIFT_SAT32( silk_SMULWB( nrg[ k ], Wght_Q15[ k ] ), 1 + extra_shifts ) + /* Q( -corr_rshifts[ k ] + extra_shifts ) */
|
||||||
silk_RSHIFT( silk_SMULWB( subfr_length, 655 ), corr_rshifts[ k ] - extra_shifts ); /* Q( -corr_rshifts[ k ] + extra_shifts ) */
|
silk_RSHIFT( silk_SMULWB( subfr_length, 655 ), corr_rshifts[ k ] - extra_shifts ); /* Q( -corr_rshifts[ k ] + extra_shifts ) */
|
||||||
denom32 = silk_max( denom32, 1 );
|
denom32 = silk_max( denom32, 1 );
|
||||||
silk_assert( ((opus_int64)Wght_Q15[ k ] << 16 ) < silk_int32_MAX ); /* Wght always < 0.5 in Q0 */
|
silk_assert( ((opus_int64)Wght_Q15[ k ] << 16 ) < silk_int32_MAX ); /* Wght always < 0.5 in Q0 */
|
||||||
temp32 = silk_DIV32( silk_LSHIFT( ( opus_int32 )Wght_Q15[ k ], 16 ), denom32 ); /* Q( 15 + 16 + corr_rshifts[k] - extra_shifts ) */
|
temp32 = silk_DIV32( silk_LSHIFT( ( opus_int32 )Wght_Q15[ k ], 16 ), denom32 ); /* Q( 15 + 16 + corr_rshifts[k] - extra_shifts ) */
|
||||||
temp32 = silk_RSHIFT( temp32, 31 + corr_rshifts[ k ] - extra_shifts - 26 ); /* Q26 */
|
temp32 = silk_RSHIFT( temp32, 31 + corr_rshifts[ k ] - extra_shifts - 26 ); /* Q26 */
|
||||||
|
|
||||||
/* Limit temp such that the below scaling never wraps around */
|
/* Limit temp such that the below scaling never wraps around */
|
||||||
WLTP_max = 0;
|
WLTP_max = 0;
|
||||||
|
@ -148,8 +148,8 @@ void silk_find_LTP_FIX(
|
||||||
LPC_res_nrg = 0;
|
LPC_res_nrg = 0;
|
||||||
silk_assert( LTP_CORRS_HEAD_ROOM >= 2 ); /* Check that no overflow will happen when adding */
|
silk_assert( LTP_CORRS_HEAD_ROOM >= 2 ); /* Check that no overflow will happen when adding */
|
||||||
for( k = 0; k < nb_subfr; k++ ) {
|
for( k = 0; k < nb_subfr; k++ ) {
|
||||||
LPC_res_nrg = silk_ADD32( LPC_res_nrg, silk_RSHIFT( silk_ADD32( silk_SMULWB( rr[ k ], Wght_Q15[ k ] ), 1 ), 1 + ( maxRshifts - corr_rshifts[ k ] ) ) ); /* Q( -maxRshifts ) */
|
LPC_res_nrg = silk_ADD32( LPC_res_nrg, silk_RSHIFT( silk_ADD32( silk_SMULWB( rr[ k ], Wght_Q15[ k ] ), 1 ), 1 + ( maxRshifts - corr_rshifts[ k ] ) ) ); /* Q( -maxRshifts ) */
|
||||||
LPC_LTP_res_nrg = silk_ADD32( LPC_LTP_res_nrg, silk_RSHIFT( silk_ADD32( silk_SMULWB( nrg[ k ], Wght_Q15[ k ] ), 1 ), 1 + ( maxRshifts - corr_rshifts[ k ] ) ) ); /* Q( -maxRshifts ) */
|
LPC_LTP_res_nrg = silk_ADD32( LPC_LTP_res_nrg, silk_RSHIFT( silk_ADD32( silk_SMULWB( nrg[ k ], Wght_Q15[ k ] ), 1 ), 1 + ( maxRshifts - corr_rshifts[ k ] ) ) ); /* Q( -maxRshifts ) */
|
||||||
}
|
}
|
||||||
LPC_LTP_res_nrg = silk_max( LPC_LTP_res_nrg, 1 ); /* avoid division by zero */
|
LPC_LTP_res_nrg = silk_max( LPC_LTP_res_nrg, 1 ); /* avoid division by zero */
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ void silk_find_LTP_FIX(
|
||||||
wd = 0;
|
wd = 0;
|
||||||
for( k = 0; k < nb_subfr; k++ ) {
|
for( k = 0; k < nb_subfr; k++ ) {
|
||||||
/* w has at least 2 bits of headroom so no overflow should happen */
|
/* w has at least 2 bits of headroom so no overflow should happen */
|
||||||
temp32 = silk_ADD32( temp32, silk_RSHIFT( w[ k ], maxRshifts_wxtra - corr_rshifts[ k ] ) ); /* Q( 18 - maxRshifts_wxtra ) */
|
temp32 = silk_ADD32( temp32, silk_RSHIFT( w[ k ], maxRshifts_wxtra - corr_rshifts[ k ] ) ); /* Q( 18 - maxRshifts_wxtra ) */
|
||||||
wd = silk_ADD32( wd, silk_LSHIFT( silk_SMULWW( silk_RSHIFT( w[ k ], maxRshifts_wxtra - corr_rshifts[ k ] ), d_Q14[ k ] ), 2 ) ); /* Q( 18 - maxRshifts_wxtra ) */
|
wd = silk_ADD32( wd, silk_LSHIFT( silk_SMULWW( silk_RSHIFT( w[ k ], maxRshifts_wxtra - corr_rshifts[ k ] ), d_Q14[ k ] ), 2 ) ); /* Q( 18 - maxRshifts_wxtra ) */
|
||||||
}
|
}
|
||||||
m_Q12 = silk_DIV32_varQ( wd, temp32, 12 );
|
m_Q12 = silk_DIV32_varQ( wd, temp32, 12 );
|
||||||
|
@ -215,7 +215,7 @@ void silk_find_LTP_FIX(
|
||||||
g_Q26 = silk_MUL(
|
g_Q26 = silk_MUL(
|
||||||
silk_DIV32(
|
silk_DIV32(
|
||||||
SILK_FIX_CONST( LTP_SMOOTHING, 26 ),
|
SILK_FIX_CONST( LTP_SMOOTHING, 26 ),
|
||||||
silk_RSHIFT( SILK_FIX_CONST( LTP_SMOOTHING, 26 ), 10 ) + temp32 ), /* Q10 */
|
silk_RSHIFT( SILK_FIX_CONST( LTP_SMOOTHING, 26 ), 10 ) + temp32 ), /* Q10 */
|
||||||
silk_LSHIFT_SAT32( silk_SUB_SAT32( ( opus_int32 )m_Q12, silk_RSHIFT( d_Q14[ k ], 2 ) ), 4 ) ); /* Q16 */
|
silk_LSHIFT_SAT32( silk_SUB_SAT32( ( opus_int32 )m_Q12, silk_RSHIFT( d_Q14[ k ], 2 ) ), 4 ) ); /* Q16 */
|
||||||
|
|
||||||
temp32 = 0;
|
temp32 = 0;
|
||||||
|
@ -229,7 +229,6 @@ void silk_find_LTP_FIX(
|
||||||
}
|
}
|
||||||
b_Q14_ptr += LTP_ORDER;
|
b_Q14_ptr += LTP_ORDER;
|
||||||
}
|
}
|
||||||
TOC(find_LTP_FIX)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void silk_fit_LTP(
|
void silk_fit_LTP(
|
||||||
|
|
|
@ -34,10 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Find pitch lags */
|
/* Find pitch lags */
|
||||||
void silk_find_pitch_lags_FIX(
|
void silk_find_pitch_lags_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
||||||
opus_int16 res[], /* O residual */
|
opus_int16 res[], /* O residual */
|
||||||
const opus_int16 x[] /* I Speech signal */
|
const opus_int16 x[] /* I Speech signal */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int buf_len, i, scale;
|
opus_int buf_len, i, scale;
|
||||||
|
|
|
@ -32,11 +32,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "main_FIX.h"
|
#include "main_FIX.h"
|
||||||
|
|
||||||
void silk_find_pred_coefs_FIX(
|
void silk_find_pred_coefs_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
||||||
const opus_int16 res_pitch[], /* I Residual from pitch analysis */
|
const opus_int16 res_pitch[], /* I Residual from pitch analysis */
|
||||||
const opus_int16 x[], /* I Speech signal */
|
const opus_int16 x[], /* I Speech signal */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
@ -112,16 +112,12 @@ void silk_find_pred_coefs_FIX(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */
|
/* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */
|
||||||
TIC(FIND_LPC)
|
|
||||||
silk_find_LPC_FIX( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15,
|
silk_find_LPC_FIX( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15,
|
||||||
psEnc->sCmn.useInterpolatedNLSFs, psEnc->sCmn.first_frame_after_reset, psEnc->sCmn.predictLPCOrder,
|
psEnc->sCmn.useInterpolatedNLSFs, psEnc->sCmn.first_frame_after_reset, psEnc->sCmn.predictLPCOrder,
|
||||||
LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr );
|
LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr );
|
||||||
TOC(FIND_LPC)
|
|
||||||
|
|
||||||
/* Quantize LSFs */
|
/* Quantize LSFs */
|
||||||
TIC(PROCESS_LSFS)
|
|
||||||
silk_process_NLSFs( &psEnc->sCmn, psEncCtrl->PredCoef_Q12, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 );
|
silk_process_NLSFs( &psEnc->sCmn, psEncCtrl->PredCoef_Q12, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 );
|
||||||
TOC(PROCESS_LSFS)
|
|
||||||
|
|
||||||
/* Calculate residual energy using quantized LPC coefficients */
|
/* Calculate residual energy using quantized LPC coefficients */
|
||||||
silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains,
|
silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains,
|
||||||
|
|
|
@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Step up function, converts reflection coefficients to prediction coefficients */
|
/* Step up function, converts reflection coefficients to prediction coefficients */
|
||||||
void silk_k2a(
|
void silk_k2a(
|
||||||
opus_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
|
opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */
|
||||||
const opus_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */
|
const opus_int16 *rc_Q15, /* I Reflection coefficients [order] Q15 */
|
||||||
const opus_int32 order /* I: Prediction order */
|
const opus_int32 order /* I Prediction order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, n;
|
opus_int k, n;
|
||||||
|
|
|
@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Step up function, converts reflection coefficients to prediction coefficients */
|
/* Step up function, converts reflection coefficients to prediction coefficients */
|
||||||
void silk_k2a_Q16(
|
void silk_k2a_Q16(
|
||||||
opus_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
|
opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */
|
||||||
const opus_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */
|
const opus_int32 *rc_Q16, /* I Reflection coefficients [order] Q16 */
|
||||||
const opus_int32 order /* I: Prediction order */
|
const opus_int32 order /* I Prediction order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, n;
|
opus_int k, n;
|
||||||
|
|
|
@ -53,47 +53,47 @@ extern "C"
|
||||||
|
|
||||||
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
|
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
|
||||||
void silk_HP_variable_cutoff(
|
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 */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Encoder main function */
|
/* Encoder main function */
|
||||||
void silk_encode_do_VAD_FIX(
|
void silk_encode_do_VAD_FIX(
|
||||||
silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */
|
silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Encoder main function */
|
/* Encoder main function */
|
||||||
opus_int silk_encode_frame_FIX(
|
opus_int silk_encode_frame_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
|
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
|
||||||
opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */
|
opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */
|
||||||
ec_enc *psRangeEnc, /* I/O compressor data structure */
|
ec_enc *psRangeEnc, /* I/O compressor data structure */
|
||||||
opus_int condCoding, /* I The type of conditional coding to use */
|
opus_int condCoding, /* I The type of conditional coding to use */
|
||||||
opus_int maxBits, /* I If > 0: maximum number of output bits */
|
opus_int maxBits, /* I If > 0: maximum number of output bits */
|
||||||
opus_int useCBR /* I Flag to force constant-bitrate operation */
|
opus_int useCBR /* I Flag to force constant-bitrate operation */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Initializes the Silk encoder state */
|
/* Initializes the Silk encoder state */
|
||||||
opus_int silk_init_encoder(
|
opus_int silk_init_encoder(
|
||||||
silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */
|
silk_encoder_state_Fxx *psEnc /* I/O Pointer to Silk FIX encoder state */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Control the Silk encoder */
|
/* Control the Silk encoder */
|
||||||
opus_int silk_control_encoder(
|
opus_int silk_control_encoder(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk encoder state */
|
silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */
|
||||||
silk_EncControlStruct *encControl, /* I: Control structure */
|
silk_EncControlStruct *encControl, /* I Control structure */
|
||||||
const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */
|
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 allow_bw_switch, /* I Flag to allow switching audio bandwidth */
|
||||||
const opus_int channelNb, /* I Channel number */
|
const opus_int channelNb, /* I Channel number */
|
||||||
const opus_int force_fs_kHz
|
const opus_int force_fs_kHz
|
||||||
);
|
);
|
||||||
|
|
||||||
/****************/
|
/****************/
|
||||||
/* Prefiltering */
|
/* Prefiltering */
|
||||||
/****************/
|
/****************/
|
||||||
void silk_prefilter_FIX(
|
void silk_prefilter_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
|
silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
|
||||||
const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */
|
const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */
|
||||||
opus_int16 xw[], /* O Weighted signal */
|
opus_int16 xw[], /* O Weighted signal */
|
||||||
const opus_int16 x[] /* I Speech signal */
|
const opus_int16 x[] /* I Speech signal */
|
||||||
);
|
);
|
||||||
|
|
||||||
/**************************/
|
/**************************/
|
||||||
|
@ -101,27 +101,27 @@ void silk_prefilter_FIX(
|
||||||
/**************************/
|
/**************************/
|
||||||
/* Compute noise shaping coefficients and initial gain values */
|
/* Compute noise shaping coefficients and initial gain values */
|
||||||
void silk_noise_shape_analysis_FIX(
|
void silk_noise_shape_analysis_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
|
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
|
||||||
const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */
|
const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */
|
||||||
const opus_int16 *x /* I Input signal [ frame_length + la_shape ] */
|
const opus_int16 *x /* I Input signal [ frame_length + la_shape ] */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Autocorrelations for a warped frequency axis */
|
/* Autocorrelations for a warped frequency axis */
|
||||||
void silk_warped_autocorrelation_FIX(
|
void silk_warped_autocorrelation_FIX(
|
||||||
opus_int32 *corr, /* O Result [order + 1] */
|
opus_int32 *corr, /* O Result [order + 1] */
|
||||||
opus_int *scale, /* O Scaling of the correlation vector */
|
opus_int *scale, /* O Scaling of the correlation vector */
|
||||||
const opus_int16 *input, /* I Input data to correlate */
|
const opus_int16 *input, /* I Input data to correlate */
|
||||||
const opus_int warping_Q16, /* I Warping coefficient */
|
const opus_int warping_Q16, /* I Warping coefficient */
|
||||||
const opus_int length, /* I Length of input */
|
const opus_int length, /* I Length of input */
|
||||||
const opus_int order /* I Correlation order (even) */
|
const opus_int order /* I Correlation order (even) */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Calculation of LTP state scaling */
|
/* Calculation of LTP state scaling */
|
||||||
void silk_LTP_scale_ctrl_FIX(
|
void silk_LTP_scale_ctrl_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
);
|
);
|
||||||
|
|
||||||
/**********************************************/
|
/**********************************************/
|
||||||
|
@ -129,87 +129,87 @@ void silk_LTP_scale_ctrl_FIX(
|
||||||
/**********************************************/
|
/**********************************************/
|
||||||
/* Find pitch lags */
|
/* Find pitch lags */
|
||||||
void silk_find_pitch_lags_FIX(
|
void silk_find_pitch_lags_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
||||||
opus_int16 res[], /* O residual */
|
opus_int16 res[], /* O residual */
|
||||||
const opus_int16 x[] /* I Speech signal */
|
const opus_int16 x[] /* I Speech signal */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Find LPC and LTP coefficients */
|
/* Find LPC and LTP coefficients */
|
||||||
void silk_find_pred_coefs_FIX(
|
void silk_find_pred_coefs_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
|
||||||
const opus_int16 res_pitch[], /* I Residual from pitch analysis */
|
const opus_int16 res_pitch[], /* I Residual from pitch analysis */
|
||||||
const opus_int16 x[], /* I Speech signal */
|
const opus_int16 x[], /* I Speech signal */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* LPC analysis */
|
/* LPC analysis */
|
||||||
void silk_find_LPC_FIX(
|
void silk_find_LPC_FIX(
|
||||||
opus_int16 NLSF_Q15[], /* O NLSFs */
|
opus_int16 NLSF_Q15[], /* O NLSFs */
|
||||||
opus_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */
|
opus_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */
|
||||||
const opus_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */
|
const opus_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */
|
||||||
const opus_int useInterpNLSFs, /* I Flag */
|
const opus_int useInterpNLSFs, /* I Flag */
|
||||||
const opus_int firstFrameAfterReset, /* I Flag */
|
const opus_int firstFrameAfterReset, /* I Flag */
|
||||||
const opus_int LPC_order, /* I LPC order */
|
const opus_int LPC_order, /* I LPC order */
|
||||||
const opus_int16 x[], /* I Input signal */
|
const opus_int16 x[], /* I Input signal */
|
||||||
const opus_int subfr_length, /* I Input signal subframe length including preceeding samples */
|
const opus_int subfr_length, /* I Input signal subframe length including preceeding samples */
|
||||||
const opus_int nb_subfr /* I: Number of subframes */
|
const opus_int nb_subfr /* I Number of subframes */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* LTP analysis */
|
/* LTP analysis */
|
||||||
void silk_find_LTP_FIX(
|
void silk_find_LTP_FIX(
|
||||||
opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
|
opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
|
||||||
opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
|
opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
|
||||||
opus_int *LTPredCodGain_Q7, /* O LTP coding gain */
|
opus_int *LTPredCodGain_Q7, /* O LTP coding gain */
|
||||||
const opus_int16 r_lpc[], /* I residual signal after LPC signal + state for first 10 ms */
|
const opus_int16 r_lpc[], /* I residual signal after LPC signal + state for first 10 ms */
|
||||||
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
||||||
const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */
|
const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */
|
||||||
const opus_int subfr_length, /* I subframe length */
|
const opus_int subfr_length, /* I subframe length */
|
||||||
const opus_int nb_subfr, /* I number of subframes */
|
const opus_int nb_subfr, /* I number of subframes */
|
||||||
const opus_int mem_offset, /* I number of samples in LTP memory */
|
const opus_int mem_offset, /* I number of samples in LTP memory */
|
||||||
opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */
|
opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_LTP_analysis_filter_FIX(
|
void silk_LTP_analysis_filter_FIX(
|
||||||
opus_int16 *LTP_res, /* O: LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */
|
opus_int16 *LTP_res, /* O LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */
|
||||||
const opus_int16 *x, /* I: Pointer to input signal with at least max( pitchL ) preceeding samples */
|
const opus_int16 *x, /* I Pointer to input signal with at least max( pitchL ) preceeding samples */
|
||||||
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I: LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */
|
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */
|
||||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I: Pitch lag, one for each subframe */
|
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag, one for each subframe */
|
||||||
const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I: Inverse quantization gains, one for each subframe */
|
const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I Inverse quantization gains, one for each subframe */
|
||||||
const opus_int subfr_length, /* I: Length of each subframe */
|
const opus_int subfr_length, /* I Length of each subframe */
|
||||||
const opus_int nb_subfr, /* I: Number of subframes */
|
const opus_int nb_subfr, /* I Number of subframes */
|
||||||
const opus_int pre_length /* I: Length of the preceeding samples starting at &x[0] for each subframe */
|
const opus_int pre_length /* I Length of the preceeding samples starting at &x[0] for each subframe */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Calculates residual energies of input subframes where all subframes have LPC_order */
|
/* Calculates residual energies of input subframes where all subframes have LPC_order */
|
||||||
/* of preceeding samples */
|
/* of preceeding samples */
|
||||||
void silk_residual_energy_FIX(
|
void silk_residual_energy_FIX(
|
||||||
opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
|
opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
|
||||||
opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
|
opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
|
||||||
const opus_int16 x[], /* I Input signal */
|
const opus_int16 x[], /* I Input signal */
|
||||||
opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
|
opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
|
||||||
const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
|
const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
|
||||||
const opus_int subfr_length, /* I Subframe length */
|
const opus_int subfr_length, /* I Subframe length */
|
||||||
const opus_int nb_subfr, /* I Number of subframes */
|
const opus_int nb_subfr, /* I Number of subframes */
|
||||||
const opus_int LPC_order /* I LPC order */
|
const opus_int LPC_order /* I LPC order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
|
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
|
||||||
opus_int32 silk_residual_energy16_covar_FIX(
|
opus_int32 silk_residual_energy16_covar_FIX(
|
||||||
const opus_int16 *c, /* I Prediction vector */
|
const opus_int16 *c, /* I Prediction vector */
|
||||||
const opus_int32 *wXX, /* I Correlation matrix */
|
const opus_int32 *wXX, /* I Correlation matrix */
|
||||||
const opus_int32 *wXx, /* I Correlation vector */
|
const opus_int32 *wXx, /* I Correlation vector */
|
||||||
opus_int32 wxx, /* I Signal energy */
|
opus_int32 wxx, /* I Signal energy */
|
||||||
opus_int D, /* I Dimension */
|
opus_int D, /* I Dimension */
|
||||||
opus_int cQ /* I Q value for c vector 0 - 15 */
|
opus_int cQ /* I Q value for c vector 0 - 15 */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Processing of gains */
|
/* Processing of gains */
|
||||||
void silk_process_gains_FIX(
|
void silk_process_gains_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
|
silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
);
|
);
|
||||||
|
|
||||||
/******************/
|
/******************/
|
||||||
|
@ -217,38 +217,38 @@ void silk_process_gains_FIX(
|
||||||
/******************/
|
/******************/
|
||||||
/* Calculates correlation matrix X'*X */
|
/* Calculates correlation matrix X'*X */
|
||||||
void silk_corrMatrix_FIX(
|
void silk_corrMatrix_FIX(
|
||||||
const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
|
const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
|
||||||
const opus_int L, /* I Length of vectors */
|
const opus_int L, /* I Length of vectors */
|
||||||
const opus_int order, /* I Max lag for correlation */
|
const opus_int order, /* I Max lag for correlation */
|
||||||
const opus_int head_room, /* I Desired headroom */
|
const opus_int head_room, /* I Desired headroom */
|
||||||
opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ]*/
|
opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */
|
||||||
opus_int *rshifts /* I/O Right shifts of correlations */
|
opus_int *rshifts /* I/O Right shifts of correlations */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Calculates correlation vector X'*t */
|
/* Calculates correlation vector X'*t */
|
||||||
void silk_corrVector_FIX(
|
void silk_corrVector_FIX(
|
||||||
const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
|
const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
|
||||||
const opus_int16 *t, /* I Target vector [L] */
|
const opus_int16 *t, /* I Target vector [L] */
|
||||||
const opus_int L, /* I Length of vectors */
|
const opus_int L, /* I Length of vectors */
|
||||||
const opus_int order, /* I Max lag for correlation */
|
const opus_int order, /* I Max lag for correlation */
|
||||||
opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */
|
opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */
|
||||||
const opus_int rshifts /* I Right shifts of correlations */
|
const opus_int rshifts /* I Right shifts of correlations */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Add noise to matrix diagonal */
|
/* Add noise to matrix diagonal */
|
||||||
void silk_regularize_correlations_FIX(
|
void silk_regularize_correlations_FIX(
|
||||||
opus_int32 *XX, /* I/O Correlation matrices */
|
opus_int32 *XX, /* I/O Correlation matrices */
|
||||||
opus_int32 *xx, /* I/O Correlation values */
|
opus_int32 *xx, /* I/O Correlation values */
|
||||||
opus_int32 noise, /* I Noise to add */
|
opus_int32 noise, /* I Noise to add */
|
||||||
opus_int D /* I Dimension of XX */
|
opus_int D /* I Dimension of XX */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Solves Ax = b, assuming A is symmetric */
|
/* Solves Ax = b, assuming A is symmetric */
|
||||||
void silk_solve_LDL_FIX(
|
void silk_solve_LDL_FIX(
|
||||||
opus_int32 *A, /* I Pointer to symetric square matrix A */
|
opus_int32 *A, /* I Pointer to symetric square matrix A */
|
||||||
opus_int M, /* I Size of matrix */
|
opus_int M, /* I Size of matrix */
|
||||||
const opus_int32 *b, /* I Pointer to b vector */
|
const opus_int32 *b, /* I Pointer to b vector */
|
||||||
opus_int32 *x_Q16 /* O Pointer to x solution vector */
|
opus_int32 *x_Q16 /* O Pointer to x solution vector */
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifndef FORCE_CPP_BUILD
|
#ifndef FORCE_CPP_BUILD
|
||||||
|
|
|
@ -139,10 +139,10 @@ static inline void limit_warped_coefs(
|
||||||
/* Compute noise shaping coefficients and initial gain values */
|
/* Compute noise shaping coefficients and initial gain values */
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
void silk_noise_shape_analysis_FIX(
|
void silk_noise_shape_analysis_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
|
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
|
||||||
const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */
|
const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */
|
||||||
const opus_int16 *x /* I Input signal [ frame_length + la_shape ] */
|
const opus_int16 *x /* I Input signal [ frame_length + la_shape ] */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
|
silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
|
||||||
|
|
|
@ -68,18 +68,18 @@ opus_int32 silk_P_Ana_find_scaling(
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
/* FIXED POINT CORE PITCH ANALYSIS FUNCTION */
|
/* FIXED POINT CORE PITCH ANALYSIS FUNCTION */
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */
|
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 */
|
const opus_int16 *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
|
||||||
opus_int *pitch_out, /* O 4 pitch lag values */
|
opus_int *pitch_out, /* O 4 pitch lag values */
|
||||||
opus_int16 *lagIndex, /* O Lag Index */
|
opus_int16 *lagIndex, /* O Lag Index */
|
||||||
opus_int8 *contourIndex, /* O Pitch contour Index */
|
opus_int8 *contourIndex, /* O Pitch contour Index */
|
||||||
opus_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */
|
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 */
|
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_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 search_thres2_Q15, /* I Final threshold for lag candidates 0 - 1 */
|
||||||
const opus_int Fs_kHz, /* I Sample frequency (kHz) */
|
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 complexity, /* I Complexity setting, 0-2, where 2 is highest */
|
||||||
const opus_int nb_subfr /* I number of 5 ms subframes */
|
const opus_int nb_subfr /* I number of 5 ms subframes */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int16 frame_8kHz[ PE_MAX_FRAME_LENGTH_ST_2 ];
|
opus_int16 frame_8kHz[ PE_MAX_FRAME_LENGTH_ST_2 ];
|
||||||
|
@ -136,7 +136,7 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1
|
||||||
if( Fs_kHz == 16 ) {
|
if( Fs_kHz == 16 ) {
|
||||||
silk_memset( filt_state, 0, 2 * sizeof( opus_int32 ) );
|
silk_memset( filt_state, 0, 2 * sizeof( opus_int32 ) );
|
||||||
silk_resampler_down2( filt_state, frame_8kHz, frame, frame_length );
|
silk_resampler_down2( filt_state, frame_8kHz, frame, frame_length );
|
||||||
} else if ( Fs_kHz == 12 ) {
|
} else if( Fs_kHz == 12 ) {
|
||||||
silk_memset( filt_state, 0, 6 * sizeof( opus_int32 ) );
|
silk_memset( filt_state, 0, 6 * sizeof( opus_int32 ) );
|
||||||
silk_resampler_down2_3( filt_state, frame_8kHz, frame, frame_length );
|
silk_resampler_down2_3( filt_state, frame_8kHz, frame, frame_length );
|
||||||
} else {
|
} else {
|
||||||
|
@ -429,10 +429,10 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1
|
||||||
CCmax_new_b -= prev_lag_bias_Q15; /* Q15 */
|
CCmax_new_b -= prev_lag_bias_Q15; /* Q15 */
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */
|
if( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */
|
||||||
CCmax_new > corr_thres_Q15 && /* Correlation needs to be high enough to be voiced */
|
CCmax_new > corr_thres_Q15 && /* Correlation needs to be high enough to be voiced */
|
||||||
silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */
|
silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */
|
||||||
) {
|
) {
|
||||||
CCmax_b = CCmax_new_b;
|
CCmax_b = CCmax_new_b;
|
||||||
CCmax = CCmax_new;
|
CCmax = CCmax_new;
|
||||||
lag = d;
|
lag = d;
|
||||||
|
@ -450,10 +450,9 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Fs_kHz > 8 ) {
|
if( Fs_kHz > 8 ) {
|
||||||
|
/***************************************************************************/
|
||||||
/******************************************************************************
|
/* Scale input signal down to avoid correlations measures from overflowing */
|
||||||
** Scale input signal down to avoid correlations measures from overflowing
|
/***************************************************************************/
|
||||||
*******************************************************************************/
|
|
||||||
/* find scaling as max scaling for each subframe */
|
/* find scaling as max scaling for each subframe */
|
||||||
shift = silk_P_Ana_find_scaling( frame, frame_length, sf_length );
|
shift = silk_P_Ana_find_scaling( frame, frame_length, sf_length );
|
||||||
if( shift > 0 ) {
|
if( shift > 0 ) {
|
||||||
|
@ -466,7 +465,6 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1
|
||||||
} else {
|
} else {
|
||||||
input_frame_ptr = (opus_int16*)frame;
|
input_frame_ptr = (opus_int16*)frame;
|
||||||
}
|
}
|
||||||
/*********************************************************************************/
|
|
||||||
|
|
||||||
/* Search in original signal */
|
/* Search in original signal */
|
||||||
|
|
||||||
|
@ -600,7 +598,7 @@ void silk_P_Ana_calc_corr_st3(
|
||||||
silk_assert( complexity >= SILK_PE_MIN_COMPLEX );
|
silk_assert( complexity >= SILK_PE_MIN_COMPLEX );
|
||||||
silk_assert( complexity <= SILK_PE_MAX_COMPLEX );
|
silk_assert( complexity <= SILK_PE_MAX_COMPLEX );
|
||||||
|
|
||||||
if( nb_subfr == PE_MAX_NB_SUBFR ){
|
if( nb_subfr == PE_MAX_NB_SUBFR ) {
|
||||||
Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
|
Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
|
||||||
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
|
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
|
||||||
nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ];
|
nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ];
|
||||||
|
@ -666,7 +664,7 @@ void silk_P_Ana_calc_energy_st3(
|
||||||
silk_assert( complexity >= SILK_PE_MIN_COMPLEX );
|
silk_assert( complexity >= SILK_PE_MIN_COMPLEX );
|
||||||
silk_assert( complexity <= SILK_PE_MAX_COMPLEX );
|
silk_assert( complexity <= SILK_PE_MAX_COMPLEX );
|
||||||
|
|
||||||
if( nb_subfr == PE_MAX_NB_SUBFR ){
|
if( nb_subfr == PE_MAX_NB_SUBFR ) {
|
||||||
Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
|
Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
|
||||||
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
|
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
|
||||||
nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ];
|
nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ];
|
||||||
|
|
|
@ -32,26 +32,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "main_FIX.h"
|
#include "main_FIX.h"
|
||||||
#include "tuning_parameters.h"
|
#include "tuning_parameters.h"
|
||||||
|
|
||||||
/* silk_prefilter. Prefilter for finding Quantizer input signal */
|
/* Prefilter for finding Quantizer input signal */
|
||||||
static inline void silk_prefilt_FIX(
|
static inline void silk_prefilt_FIX(
|
||||||
silk_prefilter_state_FIX *P, /* I/O state */
|
silk_prefilter_state_FIX *P, /* I/O state */
|
||||||
opus_int32 st_res_Q12[], /* I short term residual signal */
|
opus_int32 st_res_Q12[], /* I short term residual signal */
|
||||||
opus_int16 xw[], /* O prefiltered signal */
|
opus_int16 xw[], /* O prefiltered signal */
|
||||||
opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */
|
opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */
|
||||||
opus_int Tilt_Q14, /* I Tilt shaping coeficient */
|
opus_int Tilt_Q14, /* I Tilt shaping coeficient */
|
||||||
opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients*/
|
opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients */
|
||||||
opus_int lag, /* I Lag for harmonic shaping */
|
opus_int lag, /* I Lag for harmonic shaping */
|
||||||
opus_int length /* I Length of signals */
|
opus_int length /* I Length of signals */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_warped_LPC_analysis_filter_FIX(
|
void silk_warped_LPC_analysis_filter_FIX(
|
||||||
opus_int32 state[], /* I/O State [order + 1] */
|
opus_int32 state[], /* I/O State [order + 1] */
|
||||||
opus_int16 res[], /* O Residual signal [length] */
|
opus_int16 res[], /* O Residual signal [length] */
|
||||||
const opus_int16 coef_Q13[], /* I Coefficients [order] */
|
const opus_int16 coef_Q13[], /* I Coefficients [order] */
|
||||||
const opus_int16 input[], /* I Input signal [length] */
|
const opus_int16 input[], /* I Input signal [length] */
|
||||||
const opus_int16 lambda_Q16, /* I Warping factor */
|
const opus_int16 lambda_Q16, /* I Warping factor */
|
||||||
const opus_int length, /* I Length of input signal */
|
const opus_int length, /* I Length of input signal */
|
||||||
const opus_int order /* I Filter order (even) */
|
const opus_int order /* I Filter order (even) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int n, i;
|
opus_int n, i;
|
||||||
|
@ -86,10 +86,10 @@ void silk_warped_LPC_analysis_filter_FIX(
|
||||||
}
|
}
|
||||||
|
|
||||||
void silk_prefilter_FIX(
|
void silk_prefilter_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
|
silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
|
||||||
const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control FIX */
|
const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */
|
||||||
opus_int16 xw[], /* O Weighted signal */
|
opus_int16 xw[], /* O Weighted signal */
|
||||||
const opus_int16 x[] /* I Speech signal */
|
const opus_int16 x[] /* I Speech signal */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
silk_prefilter_state_FIX *P = &psEnc->sPrefilt;
|
silk_prefilter_state_FIX *P = &psEnc->sPrefilt;
|
||||||
|
@ -151,16 +151,16 @@ void silk_prefilter_FIX(
|
||||||
P->lagPrev = psEncCtrl->pitchL[ MAX_NB_SUBFR - 1 ];
|
P->lagPrev = psEncCtrl->pitchL[ MAX_NB_SUBFR - 1 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* silk_prefilter. Prefilter for finding Quantizer input signal */
|
/* Prefilter for finding Quantizer input signal */
|
||||||
static inline void silk_prefilt_FIX(
|
static inline void silk_prefilt_FIX(
|
||||||
silk_prefilter_state_FIX *P, /* I/O state */
|
silk_prefilter_state_FIX *P, /* I/O state */
|
||||||
opus_int32 st_res_Q12[], /* I short term residual signal */
|
opus_int32 st_res_Q12[], /* I short term residual signal */
|
||||||
opus_int16 xw[], /* O prefiltered signal */
|
opus_int16 xw[], /* O prefiltered signal */
|
||||||
opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */
|
opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */
|
||||||
opus_int Tilt_Q14, /* I Tilt shaping coeficient */
|
opus_int Tilt_Q14, /* I Tilt shaping coeficient */
|
||||||
opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients*/
|
opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients */
|
||||||
opus_int lag, /* I Lag for harmonic shaping */
|
opus_int lag, /* I Lag for harmonic shaping */
|
||||||
opus_int length /* I Length of signals */
|
opus_int length /* I Length of signals */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, idx, LTP_shp_buf_idx;
|
opus_int i, idx, LTP_shp_buf_idx;
|
||||||
|
|
|
@ -34,12 +34,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Processing of gains */
|
/* Processing of gains */
|
||||||
void silk_process_gains_FIX(
|
void silk_process_gains_FIX(
|
||||||
silk_encoder_state_FIX *psEnc, /* I/O Encoder state_FIX */
|
silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
|
||||||
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control_FIX */
|
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control */
|
||||||
opus_int condCoding /* The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
|
silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
|
||||||
opus_int k;
|
opus_int k;
|
||||||
opus_int32 s_Q16, InvMaxSqrVal_Q16, gain, gain_squared, ResNrg, ResNrgPart, quant_offset_Q10;
|
opus_int32 s_Q16, InvMaxSqrVal_Q16, gain, gain_squared, ResNrg, ResNrgPart, quant_offset_Q10;
|
||||||
|
|
||||||
|
@ -78,11 +78,11 @@ void silk_process_gains_FIX(
|
||||||
silk_assert( gain_squared > 0 );
|
silk_assert( gain_squared > 0 );
|
||||||
gain = silk_SQRT_APPROX( gain_squared ); /* Q8 */
|
gain = silk_SQRT_APPROX( gain_squared ); /* Q8 */
|
||||||
gain = silk_min( gain, silk_int32_MAX >> 8 );
|
gain = silk_min( gain, silk_int32_MAX >> 8 );
|
||||||
psEncCtrl->Gains_Q16[ k ] = silk_LSHIFT_SAT32( gain, 8 ); /* Q16 */
|
psEncCtrl->Gains_Q16[ k ] = silk_LSHIFT_SAT32( gain, 8 ); /* Q16 */
|
||||||
} else {
|
} else {
|
||||||
gain = silk_SQRT_APPROX( gain_squared ); /* Q0 */
|
gain = silk_SQRT_APPROX( gain_squared ); /* Q0 */
|
||||||
gain = silk_min( gain, silk_int32_MAX >> 16 );
|
gain = silk_min( gain, silk_int32_MAX >> 16 );
|
||||||
psEncCtrl->Gains_Q16[ k ] = silk_LSHIFT_SAT32( gain, 16 ); /* Q16 */
|
psEncCtrl->Gains_Q16[ k ] = silk_LSHIFT_SAT32( gain, 16 ); /* Q16 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Add noise to matrix diagonal */
|
/* Add noise to matrix diagonal */
|
||||||
void silk_regularize_correlations_FIX(
|
void silk_regularize_correlations_FIX(
|
||||||
opus_int32 *XX, /* I/O Correlation matrices */
|
opus_int32 *XX, /* I/O Correlation matrices */
|
||||||
opus_int32 *xx, /* I/O Correlation values */
|
opus_int32 *xx, /* I/O Correlation values */
|
||||||
opus_int32 noise, /* I Noise to add */
|
opus_int32 noise, /* I Noise to add */
|
||||||
opus_int D /* I Dimension of XX */
|
opus_int D /* I Dimension of XX */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
|
|
@ -33,12 +33,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
|
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
|
||||||
opus_int32 silk_residual_energy16_covar_FIX(
|
opus_int32 silk_residual_energy16_covar_FIX(
|
||||||
const opus_int16 *c, /* I Prediction vector */
|
const opus_int16 *c, /* I Prediction vector */
|
||||||
const opus_int32 *wXX, /* I Correlation matrix */
|
const opus_int32 *wXX, /* I Correlation matrix */
|
||||||
const opus_int32 *wXx, /* I Correlation vector */
|
const opus_int32 *wXx, /* I Correlation vector */
|
||||||
opus_int32 wxx, /* I Signal energy */
|
opus_int32 wxx, /* I Signal energy */
|
||||||
opus_int D, /* I Dimension */
|
opus_int D, /* I Dimension */
|
||||||
opus_int cQ /* I Q value for c vector 0 - 15 */
|
opus_int cQ /* I Q value for c vector 0 - 15 */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j, lshifts, Qxtra;
|
opus_int i, j, lshifts, Qxtra;
|
||||||
|
|
|
@ -34,14 +34,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/* Calculates residual energies of input subframes where all subframes have LPC_order */
|
/* Calculates residual energies of input subframes where all subframes have LPC_order */
|
||||||
/* of preceeding samples */
|
/* of preceeding samples */
|
||||||
void silk_residual_energy_FIX(
|
void silk_residual_energy_FIX(
|
||||||
opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
|
opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
|
||||||
opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
|
opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
|
||||||
const opus_int16 x[], /* I Input signal */
|
const opus_int16 x[], /* I Input signal */
|
||||||
opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
|
opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
|
||||||
const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
|
const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
|
||||||
const opus_int subfr_length, /* I Subframe length */
|
const opus_int subfr_length, /* I Subframe length */
|
||||||
const opus_int nb_subfr, /* I Number of subframes */
|
const opus_int nb_subfr, /* I Number of subframes */
|
||||||
const opus_int LPC_order /* I LPC order */
|
const opus_int LPC_order /* I LPC order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int offset, i, j, rshift, lz1, lz2;
|
opus_int offset, i, j, rshift, lz1, lz2;
|
||||||
|
|
|
@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Slower than schur(), but more accurate. */
|
/* Slower than schur(), but more accurate. */
|
||||||
/* Uses SMULL(), available on armv4 */
|
/* Uses SMULL(), available on armv4 */
|
||||||
opus_int32 silk_schur64( /* O: Returns residual energy */
|
opus_int32 silk_schur64( /* O returns residual energy */
|
||||||
opus_int32 rc_Q16[], /* O: Reflection coefficients [order] Q16 */
|
opus_int32 rc_Q16[], /* O Reflection coefficients [order] Q16 */
|
||||||
const opus_int32 c[], /* I: Correlations [order+1] */
|
const opus_int32 c[], /* I Correlations [order+1] */
|
||||||
opus_int32 order /* I: Prediction order */
|
opus_int32 order /* I Prediction order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, n;
|
opus_int k, n;
|
||||||
|
|
|
@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Faster than schur64(), but much less accurate. */
|
/* Faster than schur64(), but much less accurate. */
|
||||||
/* uses SMLAWB(), requiring armv5E and higher. */
|
/* uses SMLAWB(), requiring armv5E and higher. */
|
||||||
opus_int32 silk_schur( /* O: Returns residual energy */
|
opus_int32 silk_schur( /* O Returns residual energy */
|
||||||
opus_int16 *rc_Q15, /* O: reflection coefficients [order] Q15 */
|
opus_int16 *rc_Q15, /* O reflection coefficients [order] Q15 */
|
||||||
const opus_int32 *c, /* I: correlations [order+1] */
|
const opus_int32 *c, /* I correlations [order+1] */
|
||||||
const opus_int32 order /* I: prediction order */
|
const opus_int32 order /* I prediction order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, n, lz;
|
opus_int k, n, lz;
|
||||||
|
|
|
@ -1,124 +1,125 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{8484C90D-1561-402F-A91D-2DB10F8C5171}</ProjectGuid>
|
<ProjectGuid>{8484C90D-1561-402F-A91D-2DB10F8C5171}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>src_FIX</RootNamespace>
|
<RootNamespace>src_FIX</RootNamespace>
|
||||||
<ProjectName>silk_fixed</ProjectName>
|
<ProjectName>silk_fixed</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<TargetName>$(ProjectName)</TargetName>
|
<TargetName>$(ProjectName)</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<TargetName>$(ProjectName)</TargetName>
|
<TargetName>$(ProjectName)</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>../;../../win32;../../celt</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>../;../../win32;../../celt;../../include</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
</Lib>
|
</Lib>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>../;../../win32;../../celt</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>../;../../win32;../../celt;../../include</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
</Lib>
|
</Lib>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="ReadMe.txt" />
|
<None Include="ReadMe.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="corrMatrix_FIX.c" />
|
<ClCompile Include="corrMatrix_FIX.c" />
|
||||||
<ClCompile Include="encode_frame_FIX.c" />
|
<ClCompile Include="encode_frame_FIX.c" />
|
||||||
<ClCompile Include="find_LPC_FIX.c" />
|
<ClCompile Include="find_LPC_FIX.c" />
|
||||||
<ClCompile Include="find_LTP_FIX.c" />
|
<ClCompile Include="find_LTP_FIX.c" />
|
||||||
<ClCompile Include="find_pitch_lags_FIX.c" />
|
<ClCompile Include="find_pitch_lags_FIX.c" />
|
||||||
<ClCompile Include="find_pred_coefs_FIX.c" />
|
<ClCompile Include="find_pred_coefs_FIX.c" />
|
||||||
<ClCompile Include="LTP_analysis_filter_FIX.c" />
|
<ClCompile Include="LTP_analysis_filter_FIX.c" />
|
||||||
<ClCompile Include="LTP_scale_ctrl_FIX.c" />
|
<ClCompile Include="LTP_scale_ctrl_FIX.c" />
|
||||||
<ClCompile Include="noise_shape_analysis_FIX.c" />
|
<ClCompile Include="noise_shape_analysis_FIX.c" />
|
||||||
<ClCompile Include="prefilter_FIX.c" />
|
<ClCompile Include="prefilter_FIX.c" />
|
||||||
<ClCompile Include="process_gains_FIX.c" />
|
<ClCompile Include="process_gains_FIX.c" />
|
||||||
<ClCompile Include="regularize_correlations_FIX.c" />
|
<ClCompile Include="regularize_correlations_FIX.c" />
|
||||||
<ClCompile Include="residual_energy16_FIX.c" />
|
<ClCompile Include="residual_energy16_FIX.c" />
|
||||||
<ClCompile Include="residual_energy_FIX.c" />
|
<ClCompile Include="residual_energy_FIX.c" />
|
||||||
<ClCompile Include="solve_LS_FIX.c" />
|
<ClCompile Include="solve_LS_FIX.c" />
|
||||||
<ClCompile Include="warped_autocorrelation_FIX.c" />
|
<ClCompile Include="warped_autocorrelation_FIX.c" />
|
||||||
<ClCompile Include="k2a_FIX.c" />
|
<ClCompile Include="k2a_FIX.c" />
|
||||||
<ClCompile Include="k2a_Q16_FIX.c" />
|
<ClCompile Include="k2a_Q16_FIX.c" />
|
||||||
<ClCompile Include="apply_sine_window_FIX.c" />
|
<ClCompile Include="apply_sine_window_FIX.c" />
|
||||||
<ClCompile Include="autocorr_FIX.c" />
|
<ClCompile Include="autocorr_FIX.c" />
|
||||||
<ClCompile Include="burg_modified_FIX.c" />
|
<ClCompile Include="burg_modified_FIX.c" />
|
||||||
<ClCompile Include="pitch_analysis_core_FIX.c" />
|
<ClCompile Include="pitch_analysis_core_FIX.c" />
|
||||||
<ClCompile Include="vector_ops_FIX.c" />
|
<ClCompile Include="vector_ops_FIX.c" />
|
||||||
<ClCompile Include="schur_FIX.c" />
|
<ClCompile Include="schur_FIX.c" />
|
||||||
<ClCompile Include="schur64_FIX.c" />
|
<ClCompile Include="schur64_FIX.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\win32\config.h" />
|
<ClInclude Include="..\..\include\opus_types.h" />
|
||||||
<ClInclude Include="..\SigProc_FIX.h" />
|
<ClInclude Include="..\..\win32\config.h" />
|
||||||
<ClInclude Include="main_FIX.h" />
|
<ClInclude Include="..\SigProc_FIX.h" />
|
||||||
<ClInclude Include="structs_FIX.h" />
|
<ClInclude Include="main_FIX.h" />
|
||||||
</ItemGroup>
|
<ClInclude Include="structs_FIX.h" />
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
</ItemGroup>
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
</ImportGroup>
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</Project>
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -1,111 +1,114 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Source Files">
|
<Filter Include="Source Files">
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Header Files">
|
<Filter Include="Header Files">
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Resource Files">
|
<Filter Include="Resource Files">
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="ReadMe.txt" />
|
<None Include="ReadMe.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="corrMatrix_FIX.c">
|
<ClCompile Include="corrMatrix_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="encode_frame_FIX.c">
|
<ClCompile Include="encode_frame_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="find_LPC_FIX.c">
|
<ClCompile Include="find_LPC_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="find_LTP_FIX.c">
|
<ClCompile Include="find_LTP_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="find_pitch_lags_FIX.c">
|
<ClCompile Include="find_pitch_lags_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="find_pred_coefs_FIX.c">
|
<ClCompile Include="find_pred_coefs_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="LTP_analysis_filter_FIX.c">
|
<ClCompile Include="LTP_analysis_filter_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="LTP_scale_ctrl_FIX.c">
|
<ClCompile Include="LTP_scale_ctrl_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="noise_shape_analysis_FIX.c">
|
<ClCompile Include="noise_shape_analysis_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="prefilter_FIX.c">
|
<ClCompile Include="prefilter_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="process_gains_FIX.c">
|
<ClCompile Include="process_gains_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="regularize_correlations_FIX.c">
|
<ClCompile Include="regularize_correlations_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="residual_energy16_FIX.c">
|
<ClCompile Include="residual_energy16_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="residual_energy_FIX.c">
|
<ClCompile Include="residual_energy_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="solve_LS_FIX.c">
|
<ClCompile Include="solve_LS_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="warped_autocorrelation_FIX.c">
|
<ClCompile Include="warped_autocorrelation_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="apply_sine_window_FIX.c">
|
<ClCompile Include="apply_sine_window_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="k2a_FIX.c">
|
<ClCompile Include="k2a_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="k2a_Q16_FIX.c">
|
<ClCompile Include="k2a_Q16_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="burg_modified_FIX.c">
|
<ClCompile Include="burg_modified_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="autocorr_FIX.c">
|
<ClCompile Include="autocorr_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="pitch_analysis_core_FIX.c">
|
<ClCompile Include="pitch_analysis_core_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="vector_ops_FIX.c">
|
<ClCompile Include="vector_ops_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="schur_FIX.c">
|
<ClCompile Include="schur_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="schur64_FIX.c">
|
<ClCompile Include="schur64_FIX.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\win32\config.h">
|
<ClInclude Include="..\..\win32\config.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="main_FIX.h">
|
<ClInclude Include="main_FIX.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\SigProc_FIX.h">
|
<ClInclude Include="..\SigProc_FIX.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="structs_FIX.h">
|
<ClInclude Include="structs_FIX.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
<ClInclude Include="..\..\include\opus_types.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -43,40 +43,40 @@ typedef struct {
|
||||||
|
|
||||||
/* Factorize square matrix A into LDL form */
|
/* Factorize square matrix A into LDL form */
|
||||||
static inline void silk_LDL_factorize_FIX(
|
static inline void silk_LDL_factorize_FIX(
|
||||||
opus_int32 *A, /* I/O Pointer to Symetric Square Matrix */
|
opus_int32 *A, /* I/O Pointer to Symetric Square Matrix */
|
||||||
opus_int M, /* I Size of Matrix */
|
opus_int M, /* I Size of Matrix */
|
||||||
opus_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */
|
opus_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */
|
||||||
inv_D_t *inv_D /* I/O Pointer to vector holding inverted diagonal elements of D */
|
inv_D_t *inv_D /* I/O Pointer to vector holding inverted diagonal elements of D */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Solve Lx = b, when L is lower triangular and has ones on the diagonal */
|
/* Solve Lx = b, when L is lower triangular and has ones on the diagonal */
|
||||||
static inline void silk_LS_SolveFirst_FIX(
|
static inline void silk_LS_SolveFirst_FIX(
|
||||||
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||||
opus_int M, /* I Dim of Matrix equation */
|
opus_int M, /* I Dim of Matrix equation */
|
||||||
const opus_int32 *b, /* I b Vector */
|
const opus_int32 *b, /* I b Vector */
|
||||||
opus_int32 *x_Q16 /* O x Vector */
|
opus_int32 *x_Q16 /* O x Vector */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */
|
/* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */
|
||||||
static inline void silk_LS_SolveLast_FIX(
|
static inline void silk_LS_SolveLast_FIX(
|
||||||
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||||
const opus_int M, /* I Dim of Matrix equation */
|
const opus_int M, /* I Dim of Matrix equation */
|
||||||
const opus_int32 *b, /* I b Vector */
|
const opus_int32 *b, /* I b Vector */
|
||||||
opus_int32 *x_Q16 /* O x Vector */
|
opus_int32 *x_Q16 /* O x Vector */
|
||||||
);
|
);
|
||||||
|
|
||||||
static inline void silk_LS_divide_Q16_FIX(
|
static inline void silk_LS_divide_Q16_FIX(
|
||||||
opus_int32 T[], /* I/O Numenator vector */
|
opus_int32 T[], /* I/O Numenator vector */
|
||||||
inv_D_t *inv_D, /* I 1 / D vector */
|
inv_D_t *inv_D, /* I 1 / D vector */
|
||||||
opus_int M /* I dimension */
|
opus_int M /* I dimension */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Solves Ax = b, assuming A is symmetric */
|
/* Solves Ax = b, assuming A is symmetric */
|
||||||
void silk_solve_LDL_FIX(
|
void silk_solve_LDL_FIX(
|
||||||
opus_int32 *A, /* I Pointer to symetric square matrix A */
|
opus_int32 *A, /* I Pointer to symetric square matrix A */
|
||||||
opus_int M, /* I Size of matrix */
|
opus_int M, /* I Size of matrix */
|
||||||
const opus_int32 *b, /* I Pointer to b vector */
|
const opus_int32 *b, /* I Pointer to b vector */
|
||||||
opus_int32 *x_Q16 /* O Pointer to x solution vector */
|
opus_int32 *x_Q16 /* O Pointer to x solution vector */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int32 L_Q16[ MAX_MATRIX_SIZE * MAX_MATRIX_SIZE ];
|
opus_int32 L_Q16[ MAX_MATRIX_SIZE * MAX_MATRIX_SIZE ];
|
||||||
|
@ -110,10 +110,10 @@ void silk_solve_LDL_FIX(
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void silk_LDL_factorize_FIX(
|
static inline void silk_LDL_factorize_FIX(
|
||||||
opus_int32 *A, /* I Pointer to Symetric Square Matrix */
|
opus_int32 *A, /* I/O Pointer to Symetric Square Matrix */
|
||||||
opus_int M, /* I Size of Matrix */
|
opus_int M, /* I Size of Matrix */
|
||||||
opus_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */
|
opus_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */
|
||||||
inv_D_t *inv_D /* I/O Pointer to vector holding inverted diagonal elements of D */
|
inv_D_t *inv_D /* I/O Pointer to vector holding inverted diagonal elements of D */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j, k, status, loop_count;
|
opus_int i, j, k, status, loop_count;
|
||||||
|
@ -182,9 +182,9 @@ static inline void silk_LDL_factorize_FIX(
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void silk_LS_divide_Q16_FIX(
|
static inline void silk_LS_divide_Q16_FIX(
|
||||||
opus_int32 T[], /* I/O Numenator vector */
|
opus_int32 T[], /* I/O Numenator vector */
|
||||||
inv_D_t *inv_D, /* I 1 / D vector */
|
inv_D_t *inv_D, /* I 1 / D vector */
|
||||||
opus_int M /* I Order */
|
opus_int M /* I dimension */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
@ -202,10 +202,10 @@ static inline void silk_LS_divide_Q16_FIX(
|
||||||
|
|
||||||
/* Solve Lx = b, when L is lower triangular and has ones on the diagonal */
|
/* Solve Lx = b, when L is lower triangular and has ones on the diagonal */
|
||||||
static inline void silk_LS_SolveFirst_FIX(
|
static inline void silk_LS_SolveFirst_FIX(
|
||||||
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||||
opus_int M, /* I Dim of Matrix equation */
|
opus_int M, /* I Dim of Matrix equation */
|
||||||
const opus_int32 *b, /* I b Vector */
|
const opus_int32 *b, /* I b Vector */
|
||||||
opus_int32 *x_Q16 /* O x Vector */
|
opus_int32 *x_Q16 /* O x Vector */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j;
|
opus_int i, j;
|
||||||
|
@ -224,10 +224,10 @@ static inline void silk_LS_SolveFirst_FIX(
|
||||||
|
|
||||||
/* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */
|
/* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */
|
||||||
static inline void silk_LS_SolveLast_FIX(
|
static inline void silk_LS_SolveLast_FIX(
|
||||||
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
|
||||||
const opus_int M, /* I Dim of Matrix equation */
|
const opus_int M, /* I Dim of Matrix equation */
|
||||||
const opus_int32 *b, /* I b Vector */
|
const opus_int32 *b, /* I b Vector */
|
||||||
opus_int32 *x_Q16 /* O x Vector */
|
opus_int32 *x_Q16 /* O x Vector */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, j;
|
opus_int i, j;
|
||||||
|
|
|
@ -41,41 +41,41 @@ extern "C"
|
||||||
/* Noise shaping analysis state */
|
/* Noise shaping analysis state */
|
||||||
/********************************/
|
/********************************/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
opus_int8 LastGainIndex;
|
opus_int8 LastGainIndex;
|
||||||
opus_int32 HarmBoost_smth_Q16;
|
opus_int32 HarmBoost_smth_Q16;
|
||||||
opus_int32 HarmShapeGain_smth_Q16;
|
opus_int32 HarmShapeGain_smth_Q16;
|
||||||
opus_int32 Tilt_smth_Q16;
|
opus_int32 Tilt_smth_Q16;
|
||||||
} silk_shape_state_FIX;
|
} silk_shape_state_FIX;
|
||||||
|
|
||||||
/********************************/
|
/********************************/
|
||||||
/* Prefilter state */
|
/* Prefilter state */
|
||||||
/********************************/
|
/********************************/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
opus_int16 sLTP_shp[ LTP_BUF_LENGTH ];
|
opus_int16 sLTP_shp[ LTP_BUF_LENGTH ];
|
||||||
opus_int32 sAR_shp[ MAX_SHAPE_LPC_ORDER + 1 ];
|
opus_int32 sAR_shp[ MAX_SHAPE_LPC_ORDER + 1 ];
|
||||||
opus_int sLTP_shp_buf_idx;
|
opus_int sLTP_shp_buf_idx;
|
||||||
opus_int32 sLF_AR_shp_Q12;
|
opus_int32 sLF_AR_shp_Q12;
|
||||||
opus_int32 sLF_MA_shp_Q12;
|
opus_int32 sLF_MA_shp_Q12;
|
||||||
opus_int sHarmHP;
|
opus_int sHarmHP;
|
||||||
opus_int32 rand_seed;
|
opus_int32 rand_seed;
|
||||||
opus_int lagPrev;
|
opus_int lagPrev;
|
||||||
} silk_prefilter_state_FIX;
|
} silk_prefilter_state_FIX;
|
||||||
|
|
||||||
/********************************/
|
/********************************/
|
||||||
/* Encoder state FIX */
|
/* Encoder state FIX */
|
||||||
/********************************/
|
/********************************/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
silk_encoder_state sCmn; /* Common struct, shared with floating-point code */
|
silk_encoder_state sCmn; /* Common struct, shared with floating-point code */
|
||||||
silk_shape_state_FIX sShape; /* Shape state */
|
silk_shape_state_FIX sShape; /* Shape state */
|
||||||
silk_prefilter_state_FIX sPrefilt; /* Prefilter State */
|
silk_prefilter_state_FIX sPrefilt; /* Prefilter State */
|
||||||
|
|
||||||
/* Buffer for find pitch and noise shape analysis */
|
/* Buffer for find pitch and noise shape analysis */
|
||||||
silk_DWORD_ALIGN opus_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */
|
silk_DWORD_ALIGN opus_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */
|
||||||
opus_int LTPCorr_Q15; /* Normalized correlation from pitch lag estimator */
|
opus_int LTPCorr_Q15; /* Normalized correlation from pitch lag estimator */
|
||||||
|
|
||||||
/* Parameters For LTP scaling Control */
|
/* Parameters For LTP scaling Control */
|
||||||
opus_int prevLTPredCodGain_Q7;
|
opus_int prevLTPredCodGain_Q7;
|
||||||
opus_int HPLTPredCodGain_Q7;
|
opus_int HPLTPredCodGain_Q7;
|
||||||
} silk_encoder_state_FIX;
|
} silk_encoder_state_FIX;
|
||||||
|
|
||||||
/************************/
|
/************************/
|
||||||
|
@ -83,50 +83,50 @@ typedef struct {
|
||||||
/************************/
|
/************************/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* Prediction and coding parameters */
|
/* Prediction and coding parameters */
|
||||||
opus_int32 Gains_Q16[ MAX_NB_SUBFR ];
|
opus_int32 Gains_Q16[ MAX_NB_SUBFR ];
|
||||||
silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
|
silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
|
||||||
opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ];
|
opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ];
|
||||||
opus_int LTP_scale_Q14;
|
opus_int LTP_scale_Q14;
|
||||||
opus_int pitchL[ MAX_NB_SUBFR ];
|
opus_int pitchL[ MAX_NB_SUBFR ];
|
||||||
|
|
||||||
/* Noise shaping parameters */
|
/* Noise shaping parameters */
|
||||||
/* Testing */
|
/* Testing */
|
||||||
silk_DWORD_ALIGN opus_int16 AR1_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
silk_DWORD_ALIGN opus_int16 AR1_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
||||||
silk_DWORD_ALIGN opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
silk_DWORD_ALIGN opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ];
|
||||||
opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */
|
opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */
|
||||||
opus_int GainsPre_Q14[ MAX_NB_SUBFR ];
|
opus_int GainsPre_Q14[ MAX_NB_SUBFR ];
|
||||||
opus_int HarmBoost_Q14[ MAX_NB_SUBFR ];
|
opus_int HarmBoost_Q14[ MAX_NB_SUBFR ];
|
||||||
opus_int Tilt_Q14[ MAX_NB_SUBFR ];
|
opus_int Tilt_Q14[ MAX_NB_SUBFR ];
|
||||||
opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ];
|
opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ];
|
||||||
opus_int Lambda_Q10;
|
opus_int Lambda_Q10;
|
||||||
opus_int input_quality_Q14;
|
opus_int input_quality_Q14;
|
||||||
opus_int coding_quality_Q14;
|
opus_int coding_quality_Q14;
|
||||||
|
|
||||||
/* measures */
|
/* measures */
|
||||||
opus_int sparseness_Q8;
|
opus_int sparseness_Q8;
|
||||||
opus_int32 predGain_Q16;
|
opus_int32 predGain_Q16;
|
||||||
opus_int LTPredCodGain_Q7;
|
opus_int LTPredCodGain_Q7;
|
||||||
opus_int32 ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */
|
opus_int32 ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */
|
||||||
opus_int ResNrgQ[ MAX_NB_SUBFR ]; /* Q domain for the residual energy > 0 */
|
opus_int ResNrgQ[ MAX_NB_SUBFR ]; /* Q domain for the residual energy > 0 */
|
||||||
|
|
||||||
/* Parameters for CBR mode */
|
/* Parameters for CBR mode */
|
||||||
opus_int32 GainsUnq_Q16[ MAX_NB_SUBFR ];
|
opus_int32 GainsUnq_Q16[ MAX_NB_SUBFR ];
|
||||||
opus_int8 lastGainIndexPrev;
|
opus_int8 lastGainIndexPrev;
|
||||||
} silk_encoder_control_FIX;
|
} silk_encoder_control_FIX;
|
||||||
|
|
||||||
/************************/
|
/************************/
|
||||||
/* Encoder Super Struct */
|
/* Encoder Super Struct */
|
||||||
/************************/
|
/************************/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
silk_encoder_state_FIX state_Fxx[ ENCODER_NUM_CHANNELS ];
|
silk_encoder_state_FIX state_Fxx[ ENCODER_NUM_CHANNELS ];
|
||||||
stereo_enc_state sStereo;
|
stereo_enc_state sStereo;
|
||||||
opus_int32 nBitsExceeded;
|
opus_int32 nBitsExceeded;
|
||||||
opus_int nChannelsAPI;
|
opus_int nChannelsAPI;
|
||||||
opus_int nChannelsInternal;
|
opus_int nChannelsInternal;
|
||||||
opus_int nPrevChannelsInternal;
|
opus_int nPrevChannelsInternal;
|
||||||
opus_int timeSinceSwitchAllowed_ms;
|
opus_int timeSinceSwitchAllowed_ms;
|
||||||
opus_int allowBandwidthSwitch;
|
opus_int allowBandwidthSwitch;
|
||||||
opus_int prev_decode_only_middle;
|
opus_int prev_decode_only_middle;
|
||||||
} silk_encoder;
|
} silk_encoder;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Copy and multiply a vector by a constant */
|
/* Copy and multiply a vector by a constant */
|
||||||
void silk_scale_copy_vector16(
|
void silk_scale_copy_vector16(
|
||||||
opus_int16 *data_out,
|
opus_int16 *data_out,
|
||||||
const opus_int16 *data_in,
|
const opus_int16 *data_in,
|
||||||
opus_int32 gain_Q16, /* (I): gain in Q16 */
|
opus_int32 gain_Q16, /* I Gain in Q16 */
|
||||||
const opus_int dataSize /* (I): length */
|
const opus_int dataSize /* I Length */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
@ -50,28 +50,27 @@ void silk_scale_copy_vector16(
|
||||||
|
|
||||||
/* Multiply a vector by a constant */
|
/* Multiply a vector by a constant */
|
||||||
void silk_scale_vector32_Q26_lshift_18(
|
void silk_scale_vector32_Q26_lshift_18(
|
||||||
opus_int32 *data1, /* (I/O): Q0/Q18 */
|
opus_int32 *data1, /* I/O Q0/Q18 */
|
||||||
opus_int32 gain_Q26, /* (I): Q26 */
|
opus_int32 gain_Q26, /* I Q26 */
|
||||||
opus_int dataSize /* (I): length */
|
opus_int dataSize /* I length */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
|
||||||
for( i = 0; i < dataSize; i++ ) {
|
for( i = 0; i < dataSize; i++ ) {
|
||||||
data1[ i ] = (opus_int32)silk_CHECK_FIT32( silk_RSHIFT64( silk_SMULL( data1[ i ], gain_Q26 ), 8 ) );/* OUTPUT: Q18*/
|
data1[ i ] = (opus_int32)silk_CHECK_FIT32( silk_RSHIFT64( silk_SMULL( data1[ i ], gain_Q26 ), 8 ) ); /* OUTPUT: Q18 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum= for(i=0;i<len;i++)inVec1[i]*inVec2[i]; --- inner product */
|
/* sum = for(i=0;i<len;i++)inVec1[i]*inVec2[i]; --- inner product */
|
||||||
/* Note for ARM asm: */
|
/* Note for ARM asm: */
|
||||||
/* * inVec1 and inVec2 should be at least 2 byte aligned. (Or defined as short/int16) */
|
/* * inVec1 and inVec2 should be at least 2 byte aligned. */
|
||||||
/* * len should be positive 16bit integer. */
|
/* * len should be positive 16bit integer. */
|
||||||
/* * only when len>6, memory access can be reduced by half. */
|
/* * only when len>6, memory access can be reduced by half. */
|
||||||
|
|
||||||
opus_int32 silk_inner_prod_aligned(
|
opus_int32 silk_inner_prod_aligned(
|
||||||
const opus_int16 *const inVec1, /* I input vector 1 */
|
const opus_int16 *const inVec1, /* I input vector 1 */
|
||||||
const opus_int16 *const inVec2, /* I input vector 2 */
|
const opus_int16 *const inVec2, /* I input vector 2 */
|
||||||
const opus_int len /* I vector lengths */
|
const opus_int len /* I vector lengths */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
@ -83,9 +82,9 @@ opus_int32 silk_inner_prod_aligned(
|
||||||
}
|
}
|
||||||
|
|
||||||
opus_int64 silk_inner_prod16_aligned_64(
|
opus_int64 silk_inner_prod16_aligned_64(
|
||||||
const opus_int16 *inVec1, /* I input vector 1 */
|
const opus_int16 *inVec1, /* I input vector 1 */
|
||||||
const opus_int16 *inVec2, /* I input vector 2 */
|
const opus_int16 *inVec2, /* I input vector 2 */
|
||||||
const opus_int len /* I vector lengths */
|
const opus_int len /* I vector lengths */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
@ -97,9 +96,9 @@ opus_int64 silk_inner_prod16_aligned_64(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function that returns the maximum absolut value of the input vector */
|
/* 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 */
|
opus_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */
|
||||||
const opus_int16 *vec, /* I Input vector [len] */
|
const opus_int16 *vec, /* I Input vector [len] */
|
||||||
const opus_int32 len /* I Length of input vector */
|
const opus_int32 len /* I Length of input vector */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int32 max = 0, i, lvl = 0, ind;
|
opus_int32 max = 0, i, lvl = 0, ind;
|
||||||
|
@ -116,7 +115,7 @@ opus_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do not return 32768, as it will not fit in an int16 so may lead to problems later on */
|
/* Do not return 32768, as it will not fit in an int16 so may lead to problems later on */
|
||||||
if( max >= 1073676289 ) { /* (2^15-1)^2 = 1073676289*/
|
if( max >= 1073676289 ) { /* (2^15-1)^2 = 1073676289 */
|
||||||
return( silk_int16_MAX );
|
return( silk_int16_MAX );
|
||||||
} else {
|
} else {
|
||||||
if( vec[ ind ] < 0 ) {
|
if( vec[ ind ] < 0 ) {
|
||||||
|
|
|
@ -36,12 +36,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Autocorrelations for a warped frequency axis */
|
/* Autocorrelations for a warped frequency axis */
|
||||||
void silk_warped_autocorrelation_FIX(
|
void silk_warped_autocorrelation_FIX(
|
||||||
opus_int32 *corr, /* O Result [order + 1] */
|
opus_int32 *corr, /* O Result [order + 1] */
|
||||||
opus_int *scale, /* O Scaling of the correlation vector */
|
opus_int *scale, /* O Scaling of the correlation vector */
|
||||||
const opus_int16 *input, /* I Input data to correlate */
|
const opus_int16 *input, /* I Input data to correlate */
|
||||||
const opus_int warping_Q16, /* I Warping coefficient */
|
const opus_int warping_Q16, /* I Warping coefficient */
|
||||||
const opus_int length, /* I Length of input */
|
const opus_int length, /* I Length of input */
|
||||||
const opus_int order /* I Correlation order (even) */
|
const opus_int order /* I Correlation order (even) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int n, i, lsh;
|
opus_int n, i, lsh;
|
||||||
|
|
|
@ -51,7 +51,7 @@ static inline void silk_LPC_analysis_filter16_FLP(
|
||||||
silk_float LPC_pred;
|
silk_float LPC_pred;
|
||||||
const silk_float *s_ptr;
|
const silk_float *s_ptr;
|
||||||
|
|
||||||
for ( ix = 16; ix < length; ix++) {
|
for( ix = 16; ix < length; ix++ ) {
|
||||||
s_ptr = &s[ix - 1];
|
s_ptr = &s[ix - 1];
|
||||||
|
|
||||||
/* short-term prediction */
|
/* short-term prediction */
|
||||||
|
@ -89,7 +89,7 @@ static inline void silk_LPC_analysis_filter14_FLP(
|
||||||
silk_float LPC_pred;
|
silk_float LPC_pred;
|
||||||
const silk_float *s_ptr;
|
const silk_float *s_ptr;
|
||||||
|
|
||||||
for ( ix = 14; ix < length; ix++) {
|
for( ix = 14; ix < length; ix++ ) {
|
||||||
s_ptr = &s[ix - 1];
|
s_ptr = &s[ix - 1];
|
||||||
|
|
||||||
/* short-term prediction */
|
/* short-term prediction */
|
||||||
|
@ -125,7 +125,7 @@ static inline void silk_LPC_analysis_filter12_FLP(
|
||||||
silk_float LPC_pred;
|
silk_float LPC_pred;
|
||||||
const silk_float *s_ptr;
|
const silk_float *s_ptr;
|
||||||
|
|
||||||
for ( ix = 12; ix < length; ix++) {
|
for( ix = 12; ix < length; ix++ ) {
|
||||||
s_ptr = &s[ix - 1];
|
s_ptr = &s[ix - 1];
|
||||||
|
|
||||||
/* short-term prediction */
|
/* short-term prediction */
|
||||||
|
@ -159,7 +159,7 @@ static inline void silk_LPC_analysis_filter10_FLP(
|
||||||
silk_float LPC_pred;
|
silk_float LPC_pred;
|
||||||
const silk_float *s_ptr;
|
const silk_float *s_ptr;
|
||||||
|
|
||||||
for ( ix = 10; ix < length; ix++) {
|
for( ix = 10; ix < length; ix++ ) {
|
||||||
s_ptr = &s[ix - 1];
|
s_ptr = &s[ix - 1];
|
||||||
|
|
||||||
/* short-term prediction */
|
/* short-term prediction */
|
||||||
|
@ -191,7 +191,7 @@ static inline void silk_LPC_analysis_filter8_FLP(
|
||||||
silk_float LPC_pred;
|
silk_float LPC_pred;
|
||||||
const silk_float *s_ptr;
|
const silk_float *s_ptr;
|
||||||
|
|
||||||
for ( ix = 8; ix < length; ix++) {
|
for( ix = 8; ix < length; ix++ ) {
|
||||||
s_ptr = &s[ix - 1];
|
s_ptr = &s[ix - 1];
|
||||||
|
|
||||||
/* short-term prediction */
|
/* short-term prediction */
|
||||||
|
@ -221,7 +221,7 @@ static inline void silk_LPC_analysis_filter6_FLP(
|
||||||
silk_float LPC_pred;
|
silk_float LPC_pred;
|
||||||
const silk_float *s_ptr;
|
const silk_float *s_ptr;
|
||||||
|
|
||||||
for ( ix = 6; ix < length; ix++) {
|
for( ix = 6; ix < length; ix++ ) {
|
||||||
s_ptr = &s[ix - 1];
|
s_ptr = &s[ix - 1];
|
||||||
|
|
||||||
/* short-term prediction */
|
/* short-term prediction */
|
||||||
|
@ -243,13 +243,12 @@ static inline void silk_LPC_analysis_filter6_FLP(
|
||||||
/* filter always starts with zero state */
|
/* filter always starts with zero state */
|
||||||
/* first Order output samples are set to zero */
|
/* first Order output samples are set to zero */
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
void silk_LPC_analysis_filter_FLP(
|
void silk_LPC_analysis_filter_FLP(
|
||||||
silk_float r_LPC[], /* O LPC residual signal */
|
silk_float r_LPC[], /* O LPC residual signal */
|
||||||
const silk_float PredCoef[], /* I LPC coefficients */
|
const silk_float PredCoef[], /* I LPC coefficients */
|
||||||
const silk_float s[], /* I Input signal */
|
const silk_float s[], /* I Input signal */
|
||||||
const opus_int length, /* I Length of input signal */
|
const opus_int length, /* I Length of input signal */
|
||||||
const opus_int Order /* I LPC order */
|
const opus_int Order /* I LPC order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
silk_assert( Order <= length );
|
silk_assert( Order <= length );
|
||||||
|
|
|
@ -36,15 +36,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* compute inverse of LPC prediction gain, and */
|
/* compute inverse of LPC prediction gain, and */
|
||||||
/* test if LPC coefficients are stable (all poles within unit circle) */
|
/* test if LPC coefficients are stable (all poles within unit circle) */
|
||||||
/* this code is based on silk_a2k_FLP() */
|
/* this code is based on silk_a2k_FLP() */
|
||||||
opus_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */
|
opus_int silk_LPC_inverse_pred_gain_FLP( /* O returns 1 if unstable, otherwise 0 */
|
||||||
silk_float *invGain, /* O: inverse prediction gain, energy domain */
|
silk_float *invGain, /* O inverse prediction gain, energy domain */
|
||||||
const silk_float *A, /* I: prediction coefficients [order] */
|
const silk_float *A, /* I prediction coefficients [order] */
|
||||||
opus_int32 order /* I: prediction order */
|
opus_int32 order /* I prediction order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, n;
|
opus_int k, n;
|
||||||
double rc, rc_mult1, rc_mult2;
|
double rc, rc_mult1, rc_mult2;
|
||||||
silk_float Atmp[ 2 ][ SILK_MAX_ORDER_LPC ];
|
silk_float Atmp[ 2 ][ SILK_MAX_ORDER_LPC ];
|
||||||
silk_float *Aold, *Anew;
|
silk_float *Aold, *Anew;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ opus_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherw
|
||||||
*invGain = 1.0f;
|
*invGain = 1.0f;
|
||||||
for( k = order - 1; k > 0; k-- ) {
|
for( k = order - 1; k > 0; k-- ) {
|
||||||
rc = -Anew[ k ];
|
rc = -Anew[ k ];
|
||||||
if (rc > RC_THRESHOLD || rc < -RC_THRESHOLD) {
|
if( rc > RC_THRESHOLD || rc < -RC_THRESHOLD ) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
rc_mult1 = 1.0f - rc * rc;
|
rc_mult1 = 1.0f - rc * rc;
|
||||||
|
@ -68,7 +68,7 @@ opus_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rc = -Anew[ 0 ];
|
rc = -Anew[ 0 ];
|
||||||
if ( rc > RC_THRESHOLD || rc < -RC_THRESHOLD ) {
|
if( rc > RC_THRESHOLD || rc < -RC_THRESHOLD ) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
rc_mult1 = 1.0f - rc * rc;
|
rc_mult1 = 1.0f - rc * rc;
|
||||||
|
|
|
@ -32,14 +32,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "main_FLP.h"
|
#include "main_FLP.h"
|
||||||
|
|
||||||
void silk_LTP_analysis_filter_FLP(
|
void silk_LTP_analysis_filter_FLP(
|
||||||
silk_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */
|
silk_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */
|
||||||
const silk_float *x, /* I Input signal, with preceeding samples */
|
const silk_float *x, /* I Input signal, with preceeding samples */
|
||||||
const silk_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */
|
const silk_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */
|
||||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
|
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
|
||||||
const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */
|
const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */
|
||||||
const opus_int subfr_length, /* I Length of each subframe */
|
const opus_int subfr_length, /* I Length of each subframe */
|
||||||
const opus_int nb_subfr, /* I number of subframes */
|
const opus_int nb_subfr, /* I number of subframes */
|
||||||
const opus_int pre_length /* I Preceeding samples for each subframe */
|
const opus_int pre_length /* I Preceeding samples for each subframe */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const silk_float *x_ptr, *x_lag_ptr;
|
const silk_float *x_ptr, *x_lag_ptr;
|
||||||
|
|
|
@ -32,9 +32,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "main_FLP.h"
|
#include "main_FLP.h"
|
||||||
|
|
||||||
void silk_LTP_scale_ctrl_FLP(
|
void silk_LTP_scale_ctrl_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int round_loss;
|
opus_int round_loss;
|
||||||
|
|
|
@ -42,132 +42,127 @@ extern "C"
|
||||||
|
|
||||||
/* Chirp (bw expand) LP AR filter */
|
/* Chirp (bw expand) LP AR filter */
|
||||||
void silk_bwexpander_FLP(
|
void silk_bwexpander_FLP(
|
||||||
silk_float *ar, /* io AR filter to be expanded (without leading 1) */
|
silk_float *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||||
const opus_int d, /* i length of ar */
|
const opus_int d, /* I length of ar */
|
||||||
const silk_float chirp /* i chirp factor (typically in range (0..1) ) */
|
const silk_float chirp /* I chirp factor (typically in range (0..1) ) */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* compute inverse of LPC prediction gain, and */
|
/* compute inverse of LPC prediction gain, and */
|
||||||
/* test if LPC coefficients are stable (all poles within unit circle) */
|
/* test if LPC coefficients are stable (all poles within unit circle) */
|
||||||
/* this code is based on silk_FLP_a2k() */
|
/* this code is based on silk_FLP_a2k() */
|
||||||
opus_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */
|
opus_int silk_LPC_inverse_pred_gain_FLP( /* O returns 1 if unstable, otherwise 0 */
|
||||||
silk_float *invGain, /* O: inverse prediction gain, energy domain */
|
silk_float *invGain, /* O inverse prediction gain, energy domain */
|
||||||
const silk_float *A, /* I: prediction coefficients [order] */
|
const silk_float *A, /* I prediction coefficients [order] */
|
||||||
opus_int32 order /* I: prediction order */
|
opus_int32 order /* I prediction order */
|
||||||
);
|
);
|
||||||
|
|
||||||
silk_float silk_schur_FLP( /* O returns residual energy */
|
silk_float silk_schur_FLP( /* O returns residual energy */
|
||||||
silk_float refl_coef[], /* O reflection coefficients (length order) */
|
silk_float refl_coef[], /* O reflection coefficients (length order) */
|
||||||
const silk_float auto_corr[], /* I autocorrelation sequence (length order+1) */
|
const silk_float auto_corr[], /* I autocorrelation sequence (length order+1) */
|
||||||
opus_int order /* I order */
|
opus_int order /* I order */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_k2a_FLP(
|
void silk_k2a_FLP(
|
||||||
silk_float *A, /* O: prediction coefficients [order] */
|
silk_float *A, /* O prediction coefficients [order] */
|
||||||
const silk_float *rc, /* I: reflection coefficients [order] */
|
const silk_float *rc, /* I reflection coefficients [order] */
|
||||||
opus_int32 order /* I: prediction order */
|
opus_int32 order /* I prediction order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Solve the normal equations using the Levinson-Durbin recursion */
|
/* Solve the normal equations using the Levinson-Durbin recursion */
|
||||||
silk_float silk_levinsondurbin_FLP( /* O prediction error energy */
|
silk_float silk_levinsondurbin_FLP( /* O prediction error energy */
|
||||||
silk_float A[], /* O prediction coefficients [order] */
|
silk_float A[], /* O prediction coefficients [order] */
|
||||||
const silk_float corr[], /* I input auto-correlations [order + 1] */
|
const silk_float corr[], /* I input auto-correlations [order + 1] */
|
||||||
const opus_int order /* I prediction order */
|
const opus_int order /* I prediction order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* compute autocorrelation */
|
/* compute autocorrelation */
|
||||||
void silk_autocorrelation_FLP(
|
void silk_autocorrelation_FLP(
|
||||||
silk_float *results, /* o result (length correlationCount) */
|
silk_float *results, /* O result (length correlationCount) */
|
||||||
const silk_float *inputData, /* i input data to correlate */
|
const silk_float *inputData, /* I input data to correlate */
|
||||||
opus_int inputDataSize, /* i length of input */
|
opus_int inputDataSize, /* I length of input */
|
||||||
opus_int correlationCount /* i number of correlation taps to compute */
|
opus_int correlationCount /* I number of correlation taps to compute */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Pitch estimator */
|
opus_int silk_pitch_analysis_core_FLP( /* O Voicing estimate: 0 voiced, 1 unvoiced */
|
||||||
#define SigProc_PE_MIN_COMPLEX 0
|
const silk_float *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
|
||||||
#define SigProc_PE_MID_COMPLEX 1
|
opus_int *pitch_out, /* O Pitch lag values [nb_subfr] */
|
||||||
#define SigProc_PE_MAX_COMPLEX 2
|
opus_int16 *lagIndex, /* O Lag Index */
|
||||||
|
opus_int8 *contourIndex, /* O Pitch contour Index */
|
||||||
opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */
|
silk_float *LTPCorr, /* I/O Normalized correlation; input: value from previous frame */
|
||||||
const silk_float *signal, /* I signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
|
opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */
|
||||||
opus_int *pitch_out, /* O 4 pitch lag values */
|
const silk_float search_thres1, /* I First stage threshold for lag candidates 0 - 1 */
|
||||||
opus_int16 *lagIndex, /* O lag Index */
|
const silk_float search_thres2, /* I Final threshold for lag candidates 0 - 1 */
|
||||||
opus_int8 *contourIndex, /* O pitch contour Index */
|
const opus_int Fs_kHz, /* I sample frequency (kHz) */
|
||||||
silk_float *LTPCorr, /* I/O normalized correlation; input: value from previous frame */
|
const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */
|
||||||
opus_int prevLag, /* I last lag of previous frame; set to zero is unvoiced */
|
const opus_int nb_subfr /* I Number of 5 ms subframes */
|
||||||
const silk_float search_thres1, /* I first stage threshold for lag candidates 0 - 1 */
|
|
||||||
const silk_float search_thres2, /* 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 */
|
|
||||||
);
|
);
|
||||||
|
|
||||||
#define PI (3.1415926536f)
|
|
||||||
|
|
||||||
void silk_insertion_sort_decreasing_FLP(
|
void silk_insertion_sort_decreasing_FLP(
|
||||||
silk_float *a, /* I/O: Unsorted / Sorted vector */
|
silk_float *a, /* I/O Unsorted / Sorted vector */
|
||||||
opus_int *idx, /* O: Index vector for the sorted elements */
|
opus_int *idx, /* O Index vector for the sorted elements */
|
||||||
const opus_int L, /* I: Vector length */
|
const opus_int L, /* I Vector length */
|
||||||
const opus_int K /* I: Number of correctly sorted positions */
|
const opus_int K /* I Number of correctly sorted positions */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Compute reflection coefficients from input signal */
|
/* Compute reflection coefficients from input signal */
|
||||||
silk_float silk_burg_modified_FLP( /* O returns residual energy */
|
silk_float silk_burg_modified_FLP( /* O returns residual energy */
|
||||||
silk_float A[], /* O prediction coefficients (length order) */
|
silk_float A[], /* O prediction coefficients (length order) */
|
||||||
const silk_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */
|
const silk_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */
|
||||||
const opus_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
|
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_int nb_subfr, /* I number of subframes stacked in x */
|
||||||
const silk_float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */
|
const silk_float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */
|
||||||
const opus_int D /* I order */
|
const opus_int D /* I order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* multiply a vector by a constant */
|
/* multiply a vector by a constant */
|
||||||
void silk_scale_vector_FLP(
|
void silk_scale_vector_FLP(
|
||||||
silk_float *data1,
|
silk_float *data1,
|
||||||
silk_float gain,
|
silk_float gain,
|
||||||
opus_int dataSize
|
opus_int dataSize
|
||||||
);
|
);
|
||||||
|
|
||||||
/* copy and multiply a vector by a constant */
|
/* copy and multiply a vector by a constant */
|
||||||
void silk_scale_copy_vector_FLP(
|
void silk_scale_copy_vector_FLP(
|
||||||
silk_float *data_out,
|
silk_float *data_out,
|
||||||
const silk_float *data_in,
|
const silk_float *data_in,
|
||||||
silk_float gain,
|
silk_float gain,
|
||||||
opus_int dataSize
|
opus_int dataSize
|
||||||
);
|
);
|
||||||
|
|
||||||
/* inner product of two silk_float arrays, with result as double */
|
/* inner product of two silk_float arrays, with result as double */
|
||||||
double silk_inner_product_FLP(
|
double silk_inner_product_FLP(
|
||||||
const silk_float *data1,
|
const silk_float *data1,
|
||||||
const silk_float *data2,
|
const silk_float *data2,
|
||||||
opus_int dataSize
|
opus_int dataSize
|
||||||
);
|
);
|
||||||
|
|
||||||
/* sum of squares of a silk_float array, with result as double */
|
/* sum of squares of a silk_float array, with result as double */
|
||||||
double silk_energy_FLP(
|
double silk_energy_FLP(
|
||||||
const silk_float *data,
|
const silk_float *data,
|
||||||
opus_int dataSize
|
opus_int dataSize
|
||||||
);
|
);
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
/* MACROS */
|
/* MACROS */
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
|
||||||
#define silk_min_float(a, b) (((a) < (b)) ? (a) : (b))
|
#define PI (3.1415926536f)
|
||||||
#define silk_max_float(a, b) (((a) > (b)) ? (a) : (b))
|
|
||||||
#define silk_abs_float(a) ((silk_float)fabs(a))
|
|
||||||
|
|
||||||
#define silk_LIMIT_float( a, limit1, limit2) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
|
#define silk_min_float( a, b ) (((a) < (b)) ? (a) : (b))
|
||||||
: ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))))
|
#define silk_max_float( a, b ) (((a) > (b)) ? (a) : (b))
|
||||||
|
#define silk_abs_float( a ) ((silk_float)fabs(a))
|
||||||
|
|
||||||
|
#define silk_LIMIT_float( a, limit1, limit2 ) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
|
||||||
|
: ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))))
|
||||||
|
|
||||||
/* sigmoid function */
|
/* sigmoid function */
|
||||||
static inline silk_float silk_sigmoid(silk_float x)
|
static inline silk_float silk_sigmoid( silk_float x )
|
||||||
{
|
{
|
||||||
return (silk_float)(1.0 / (1.0 + exp(-x)));
|
return (silk_float)(1.0 / (1.0 + exp(-x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* floating-point to integer conversion (rounding) */
|
/* floating-point to integer conversion (rounding) */
|
||||||
static inline opus_int32 silk_float2int(double x)
|
static inline opus_int32 silk_float2int( double x )
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
double t = x + 6755399441055744.0;
|
double t = x + 6755399441055744.0;
|
||||||
|
@ -185,7 +180,7 @@ static inline void silk_float2short_array(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int32 k;
|
opus_int32 k;
|
||||||
for (k = length-1; k >= 0; k--) {
|
for( k = length - 1; k >= 0; k-- ) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
double t = in[k] + 6755399441055744.0;
|
double t = in[k] + 6755399441055744.0;
|
||||||
out[k] = (opus_int16)silk_SAT16(*(( opus_int32 * )( &t )));
|
out[k] = (opus_int16)silk_SAT16(*(( opus_int32 * )( &t )));
|
||||||
|
@ -204,13 +199,16 @@ static inline void silk_short2float_array(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int32 k;
|
opus_int32 k;
|
||||||
for (k = length-1; k >= 0; k--) {
|
for( k = length - 1; k >= 0; k-- ) {
|
||||||
out[k] = (silk_float)in[k];
|
out[k] = (silk_float)in[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* using log2() helps the fixed-point conversion */
|
/* using log2() helps the fixed-point conversion */
|
||||||
static inline silk_float silk_log2( double x ) { return ( silk_float )( 3.32192809488736 * log10( x ) ); }
|
static inline silk_float silk_log2( double x )
|
||||||
|
{
|
||||||
|
return ( silk_float )( 3.32192809488736 * log10( x ) );
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,15 +31,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "main_FLP.h"
|
#include "main_FLP.h"
|
||||||
|
|
||||||
/* Apply sine window to signal vector. */
|
/* Apply sine window to signal vector */
|
||||||
/* Window types: */
|
/* Window types: */
|
||||||
/* 1 -> sine window from 0 to pi/2 */
|
/* 1 -> sine window from 0 to pi/2 */
|
||||||
/* 2 -> sine window from pi/2 to pi */
|
/* 2 -> sine window from pi/2 to pi */
|
||||||
void silk_apply_sine_window_FLP(
|
void silk_apply_sine_window_FLP(
|
||||||
silk_float px_win[], /* O Pointer to windowed signal */
|
silk_float px_win[], /* O Pointer to windowed signal */
|
||||||
const silk_float px[], /* I Pointer to input signal */
|
const silk_float px[], /* I Pointer to input signal */
|
||||||
const opus_int win_type, /* I Selects a window type */
|
const opus_int win_type, /* I Selects a window type */
|
||||||
const opus_int length /* I Window length, multiple of 4 */
|
const opus_int length /* I Window length, multiple of 4 */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k;
|
opus_int k;
|
||||||
|
|
|
@ -34,15 +34,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* compute autocorrelation */
|
/* compute autocorrelation */
|
||||||
void silk_autocorrelation_FLP(
|
void silk_autocorrelation_FLP(
|
||||||
silk_float *results, /* O result (length correlationCount) */
|
silk_float *results, /* O result (length correlationCount) */
|
||||||
const silk_float *inputData, /* I input data to correlate */
|
const silk_float *inputData, /* I input data to correlate */
|
||||||
opus_int inputDataSize, /* I length of input */
|
opus_int inputDataSize, /* I length of input */
|
||||||
opus_int correlationCount /* I number of correlation taps to compute */
|
opus_int correlationCount /* I number of correlation taps to compute */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
|
||||||
if ( correlationCount > inputDataSize ) {
|
if( correlationCount > inputDataSize ) {
|
||||||
correlationCount = inputDataSize;
|
correlationCount = inputDataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define MAX_NB_SUBFR 4
|
#define MAX_NB_SUBFR 4
|
||||||
|
|
||||||
/* Compute reflection coefficients from input signal */
|
/* Compute reflection coefficients from input signal */
|
||||||
silk_float silk_burg_modified_FLP( /* O returns residual energy */
|
silk_float silk_burg_modified_FLP( /* O returns residual energy */
|
||||||
silk_float A[], /* O prediction coefficients (length order) */
|
silk_float A[], /* O prediction coefficients (length order) */
|
||||||
const silk_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */
|
const silk_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */
|
||||||
const opus_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
|
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_int nb_subfr, /* I number of subframes stacked in x */
|
||||||
const silk_float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */
|
const silk_float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */
|
||||||
const opus_int D /* I order */
|
const opus_int D /* I order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, n, s;
|
opus_int k, n, s;
|
||||||
|
|
|
@ -31,12 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "SigProc_FLP.h"
|
#include "SigProc_FLP.h"
|
||||||
|
|
||||||
|
|
||||||
/* Chirp (bw expand) LP AR filter */
|
/* Chirp (bw expand) LP AR filter */
|
||||||
void silk_bwexpander_FLP(
|
void silk_bwexpander_FLP(
|
||||||
silk_float *ar, /* I/O AR filter to be expanded (without leading 1) */
|
silk_float *ar, /* I/O AR filter to be expanded (without leading 1) */
|
||||||
const opus_int d, /* I length of ar */
|
const opus_int d, /* I length of ar */
|
||||||
const silk_float chirp /* I chirp factor (typically in range (0..1) ) */
|
const silk_float chirp /* I chirp factor (typically in range (0..1) ) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
|
|
@ -37,11 +37,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* Calculates correlation vector X'*t */
|
/* Calculates correlation vector X'*t */
|
||||||
void silk_corrVector_FLP(
|
void silk_corrVector_FLP(
|
||||||
const silk_float *x, /* I x vector [L+order-1] used to create X */
|
const silk_float *x, /* I x vector [L+order-1] used to create X */
|
||||||
const silk_float *t, /* I Target vector [L] */
|
const silk_float *t, /* I Target vector [L] */
|
||||||
const opus_int L, /* I Length of vecors */
|
const opus_int L, /* I Length of vecors */
|
||||||
const opus_int Order, /* I Max lag for correlation */
|
const opus_int Order, /* I Max lag for correlation */
|
||||||
silk_float *Xt /* O X'*t correlation vector [order] */
|
silk_float *Xt /* O X'*t correlation vector [order] */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int lag;
|
opus_int lag;
|
||||||
|
@ -57,10 +57,10 @@ void silk_corrVector_FLP(
|
||||||
|
|
||||||
/* Calculates correlation matrix X'*X */
|
/* Calculates correlation matrix X'*X */
|
||||||
void silk_corrMatrix_FLP(
|
void silk_corrMatrix_FLP(
|
||||||
const silk_float *x, /* I x vector [ L+order-1 ] used to create X */
|
const silk_float *x, /* I x vector [ L+order-1 ] used to create X */
|
||||||
const opus_int L, /* I Length of vectors */
|
const opus_int L, /* I Length of vectors */
|
||||||
const opus_int Order, /* I Max lag for correlation */
|
const opus_int Order, /* I Max lag for correlation */
|
||||||
silk_float *XX /* O X'*X correlation matrix [order x order] */
|
silk_float *XX /* O X'*X correlation matrix [order x order] */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int j, lag;
|
opus_int j, lag;
|
||||||
|
|
|
@ -32,24 +32,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "main_FLP.h"
|
#include "main_FLP.h"
|
||||||
#include "tuning_parameters.h"
|
#include "tuning_parameters.h"
|
||||||
|
|
||||||
/* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */
|
/* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */
|
||||||
static inline void silk_LBRR_encode_FLP(
|
static inline void silk_LBRR_encode_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
const silk_float xfw[], /* I Input signal */
|
const silk_float xfw[], /* I Input signal */
|
||||||
opus_int condCoding /* I The type of conditional coding used so far for this frame */
|
opus_int condCoding /* I The type of conditional coding used so far for this frame */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_encode_do_VAD_FLP(
|
void silk_encode_do_VAD_FLP(
|
||||||
silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/****************************/
|
/****************************/
|
||||||
/* Voice Activity Detection */
|
/* Voice Activity Detection */
|
||||||
/****************************/
|
/****************************/
|
||||||
TIC(VAD)
|
|
||||||
silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 );
|
silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 );
|
||||||
TOC(VAD)
|
|
||||||
|
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
/* Convert speech activity into VAD and DTX flags */
|
/* Convert speech activity into VAD and DTX flags */
|
||||||
|
@ -79,12 +77,12 @@ TOC(VAD)
|
||||||
/* Encode frame */
|
/* Encode frame */
|
||||||
/****************/
|
/****************/
|
||||||
opus_int silk_encode_frame_FLP(
|
opus_int silk_encode_frame_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
opus_int32 *pnBytesOut, /* O Number of payload bytes */
|
opus_int32 *pnBytesOut, /* O Number of payload bytes; */
|
||||||
ec_enc *psRangeEnc, /* I/O compressor data structure */
|
ec_enc *psRangeEnc, /* I/O compressor data structure */
|
||||||
opus_int condCoding, /* I The type of conditional coding to use */
|
opus_int condCoding, /* I The type of conditional coding to use */
|
||||||
opus_int maxBits, /* I If > 0: maximum number of output bits */
|
opus_int maxBits, /* I If > 0: maximum number of output bits */
|
||||||
opus_int useCBR /* I Flag to force constant-bitrate operation */
|
opus_int useCBR /* I Flag to force constant-bitrate operation */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
silk_encoder_control_FLP sEncCtrl;
|
silk_encoder_control_FLP sEncCtrl;
|
||||||
|
@ -103,10 +101,7 @@ opus_int silk_encode_frame_FLP(
|
||||||
opus_int32 pGains_Q16[ MAX_NB_SUBFR ];
|
opus_int32 pGains_Q16[ MAX_NB_SUBFR ];
|
||||||
opus_uint8 ec_buf_copy[ 1275 ];
|
opus_uint8 ec_buf_copy[ 1275 ];
|
||||||
|
|
||||||
TIC(ENCODE_FRAME)
|
/* This is totally unnecessary but many compilers (including gcc) are too dumb to realise it */
|
||||||
|
|
||||||
/* This is totally unnecessary but many compilers (including gcc) are too dumb
|
|
||||||
to realise it */
|
|
||||||
LastGainIndex_copy2 = nBits_lower = nBits_upper = gainMult_lower = gainMult_upper = 0;
|
LastGainIndex_copy2 = nBits_lower = nBits_upper = gainMult_lower = gainMult_upper = 0;
|
||||||
|
|
||||||
psEnc->sCmn.indices.Seed = psEnc->sCmn.frameCounter++ & 3;
|
psEnc->sCmn.indices.Seed = psEnc->sCmn.frameCounter++ & 3;
|
||||||
|
@ -136,50 +131,35 @@ TIC(ENCODE_FRAME)
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
/* Find pitch lags, initial LPC analysis */
|
/* Find pitch lags, initial LPC analysis */
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
TIC(FIND_PITCH)
|
|
||||||
silk_find_pitch_lags_FLP( psEnc, &sEncCtrl, res_pitch, x_frame );
|
silk_find_pitch_lags_FLP( psEnc, &sEncCtrl, res_pitch, x_frame );
|
||||||
TOC(FIND_PITCH)
|
|
||||||
|
|
||||||
/************************/
|
/************************/
|
||||||
/* Noise shape analysis */
|
/* Noise shape analysis */
|
||||||
/************************/
|
/************************/
|
||||||
TIC(NOISE_SHAPE_ANALYSIS)
|
|
||||||
silk_noise_shape_analysis_FLP( psEnc, &sEncCtrl, res_pitch_frame, x_frame );
|
silk_noise_shape_analysis_FLP( psEnc, &sEncCtrl, res_pitch_frame, x_frame );
|
||||||
TOC(NOISE_SHAPE_ANALYSIS)
|
|
||||||
|
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
/* Find linear prediction coefficients (LPC + LTP) */
|
/* Find linear prediction coefficients (LPC + LTP) */
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
TIC(FIND_PRED_COEF)
|
|
||||||
silk_find_pred_coefs_FLP( psEnc, &sEncCtrl, res_pitch, x_frame, condCoding );
|
silk_find_pred_coefs_FLP( psEnc, &sEncCtrl, res_pitch, x_frame, condCoding );
|
||||||
TOC(FIND_PRED_COEF)
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Process gains */
|
/* Process gains */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
TIC(PROCESS_GAINS)
|
|
||||||
silk_process_gains_FLP( psEnc, &sEncCtrl, condCoding );
|
silk_process_gains_FLP( psEnc, &sEncCtrl, condCoding );
|
||||||
TOC(PROCESS_GAINS)
|
|
||||||
|
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
/* Prefiltering for noise shaper */
|
/* Prefiltering for noise shaper */
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
TIC(PREFILTER)
|
|
||||||
silk_prefilter_FLP( psEnc, &sEncCtrl, xfw, x_frame );
|
silk_prefilter_FLP( psEnc, &sEncCtrl, xfw, x_frame );
|
||||||
TOC(PREFILTER)
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Low Bitrate Redundant Encoding */
|
/* Low Bitrate Redundant Encoding */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
TIC(LBRR)
|
|
||||||
silk_LBRR_encode_FLP( psEnc, &sEncCtrl, xfw, condCoding );
|
silk_LBRR_encode_FLP( psEnc, &sEncCtrl, xfw, condCoding );
|
||||||
TOC(LBRR)
|
|
||||||
|
|
||||||
if ( psEnc->sCmn.prefillFlag )
|
if( psEnc->sCmn.prefillFlag ) {
|
||||||
{
|
|
||||||
TIC(NSQ)
|
|
||||||
silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw );
|
silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw );
|
||||||
TOC(NSQ)
|
|
||||||
} else {
|
} else {
|
||||||
/* Loop over quantizer and entroy coding to control bitrate */
|
/* Loop over quantizer and entroy coding to control bitrate */
|
||||||
maxIter = 5;
|
maxIter = 5;
|
||||||
|
@ -213,24 +193,18 @@ TOC(NSQ)
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
/* Noise shaping quantization */
|
/* Noise shaping quantization */
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
TIC(NSQ)
|
|
||||||
silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw );
|
silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw );
|
||||||
TOC(NSQ)
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Encode Parameters */
|
/* Encode Parameters */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
TIC(ENCODE_PARAMS)
|
|
||||||
silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding );
|
silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding );
|
||||||
TOC(ENCODE_PARAMS)
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Encode Excitation Signal */
|
/* Encode Excitation Signal */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
TIC(ENCODE_PULSES)
|
|
||||||
silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
|
silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
|
||||||
psEnc->sCmn.pulses, psEnc->sCmn.frame_length );
|
psEnc->sCmn.pulses, psEnc->sCmn.frame_length );
|
||||||
TOC(ENCODE_PULSES)
|
|
||||||
|
|
||||||
nBits = ec_tell( psRangeEnc );
|
nBits = ec_tell( psRangeEnc );
|
||||||
|
|
||||||
|
@ -343,32 +317,15 @@ TOC(ENCODE_PULSES)
|
||||||
/* Payload size */
|
/* Payload size */
|
||||||
*pnBytesOut = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
|
*pnBytesOut = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
|
||||||
|
|
||||||
TOC(ENCODE_FRAME)
|
|
||||||
|
|
||||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
|
||||||
DEBUG_STORE_DATA( pitchL.dat, sEncCtrl.pitchL, MAX_NB_SUBFR * sizeof( opus_int ) );
|
|
||||||
DEBUG_STORE_DATA( pitchG_quantized.dat, sEncCtrl.LTPCoef, psEnc->sCmn.nb_subfr * LTP_ORDER * sizeof( silk_float ) );
|
|
||||||
DEBUG_STORE_DATA( LTPcorr.dat, &psEnc->LTPCorr, sizeof( silk_float ) );
|
|
||||||
DEBUG_STORE_DATA( gains.dat, sEncCtrl.Gains, psEnc->sCmn.nb_subfr * sizeof( silk_float ) );
|
|
||||||
DEBUG_STORE_DATA( gains_indices.dat, &psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr * sizeof( opus_int8 ) );
|
|
||||||
DEBUG_STORE_DATA( quantOffsetType.dat, &psEnc->sCmn.indices.quantOffsetType, sizeof( opus_int8 ) );
|
|
||||||
DEBUG_STORE_DATA( speech_activity_q8.dat, &psEnc->sCmn.speech_activity_Q8, sizeof( opus_int ) );
|
|
||||||
DEBUG_STORE_DATA( signalType.dat, &psEnc->sCmn.indices.signalType, sizeof( opus_int8 ) );
|
|
||||||
DEBUG_STORE_DATA( lag_index.dat, &psEnc->sCmn.indices.lagIndex, sizeof( opus_int16 ) );
|
|
||||||
DEBUG_STORE_DATA( contour_index.dat, &psEnc->sCmn.indices.contourIndex, sizeof( opus_int8 ) );
|
|
||||||
DEBUG_STORE_DATA( per_index.dat, &psEnc->sCmn.indices.PERIndex, sizeof( opus_int8 ) );
|
|
||||||
DEBUG_STORE_DATA( PredCoef.dat, &sEncCtrl.PredCoef[ 1 ], psEnc->sCmn.predictLPCOrder * sizeof( silk_float ) );
|
|
||||||
DEBUG_STORE_DATA( ltp_scale_idx.dat, &psEnc->sCmn.indices.LTP_scaleIndex, sizeof( opus_int8 ) );
|
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */
|
/* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */
|
||||||
static inline void silk_LBRR_encode_FLP(
|
static inline void silk_LBRR_encode_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
const silk_float xfw[], /* I Input signal */
|
const silk_float xfw[], /* I Input signal */
|
||||||
opus_int condCoding /* I The type of conditional coding used so far for this frame */
|
opus_int condCoding /* I The type of conditional coding used so far for this frame */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k;
|
opus_int k;
|
||||||
|
|
|
@ -33,8 +33,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* sum of squares of a silk_float array, with result as double */
|
/* sum of squares of a silk_float array, with result as double */
|
||||||
double silk_energy_FLP(
|
double silk_energy_FLP(
|
||||||
const silk_float *data,
|
const silk_float *data,
|
||||||
opus_int dataSize
|
opus_int dataSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, dataSize4;
|
opus_int i, dataSize4;
|
||||||
|
|
|
@ -33,15 +33,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "tuning_parameters.h"
|
#include "tuning_parameters.h"
|
||||||
|
|
||||||
void silk_find_LPC_FLP(
|
void silk_find_LPC_FLP(
|
||||||
opus_int16 NLSF_Q15[], /* O NLSFs */
|
opus_int16 NLSF_Q15[], /* O NLSFs */
|
||||||
opus_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */
|
opus_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */
|
||||||
const opus_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */
|
const opus_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */
|
||||||
const opus_int useInterpNLSFs, /* I Flag */
|
const opus_int useInterpNLSFs, /* I Flag */
|
||||||
const opus_int firstFrameAfterReset, /* I Flag */
|
const opus_int firstFrameAfterReset, /* I Flag */
|
||||||
const opus_int LPC_order, /* I LPC order */
|
const opus_int LPC_order, /* I LPC order */
|
||||||
const silk_float x[], /* I Input signal */
|
const silk_float x[], /* I Input signal */
|
||||||
const opus_int subfr_length, /* I Subframe length incl preceeding samples */
|
const opus_int subfr_length, /* I Subframe length incl preceeding samples */
|
||||||
const opus_int nb_subfr /* I: Number of subframes */
|
const opus_int nb_subfr /* I Number of subframes */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k;
|
opus_int k;
|
||||||
|
|
|
@ -33,15 +33,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "tuning_parameters.h"
|
#include "tuning_parameters.h"
|
||||||
|
|
||||||
void silk_find_LTP_FLP(
|
void silk_find_LTP_FLP(
|
||||||
silk_float b[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
|
silk_float b[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
|
||||||
silk_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
|
silk_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
|
||||||
silk_float *LTPredCodGain, /* O LTP coding gain */
|
silk_float *LTPredCodGain, /* O LTP coding gain */
|
||||||
const silk_float r_lpc[], /* I LPC residual */
|
const silk_float r_lpc[], /* I LPC residual */
|
||||||
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
||||||
const silk_float Wght[ MAX_NB_SUBFR ], /* I Weights */
|
const silk_float Wght[ MAX_NB_SUBFR ], /* I Weights */
|
||||||
const opus_int subfr_length, /* I Subframe length */
|
const opus_int subfr_length, /* I Subframe length */
|
||||||
const opus_int nb_subfr, /* I number of subframes */
|
const opus_int nb_subfr, /* I number of subframes */
|
||||||
const opus_int mem_offset /* I Number of samples in LTP memory */
|
const opus_int mem_offset /* I Number of samples in LTP memory */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, k;
|
opus_int i, k;
|
||||||
|
|
|
@ -34,10 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "tuning_parameters.h"
|
#include "tuning_parameters.h"
|
||||||
|
|
||||||
void silk_find_pitch_lags_FLP(
|
void silk_find_pitch_lags_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
silk_float res[], /* O Residual */
|
silk_float res[], /* O Residual */
|
||||||
const silk_float x[] /* I Speech signal */
|
const silk_float x[] /* I Speech signal */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int buf_len;
|
opus_int buf_len;
|
||||||
|
|
|
@ -31,13 +31,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "main_FLP.h"
|
#include "main_FLP.h"
|
||||||
|
|
||||||
|
/* Find LPC and LTP coefficients */
|
||||||
void silk_find_pred_coefs_FLP(
|
void silk_find_pred_coefs_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
const silk_float res_pitch[], /* I Residual from pitch analysis */
|
const silk_float res_pitch[], /* I Residual from pitch analysis */
|
||||||
const silk_float x[], /* I Speech signal */
|
const silk_float x[], /* I Speech signal */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i;
|
opus_int i;
|
||||||
|
@ -64,11 +64,6 @@ void silk_find_pred_coefs_FLP(
|
||||||
silk_find_LTP_FLP( psEncCtrl->LTPCoef, WLTP, &psEncCtrl->LTPredCodGain, res_pitch,
|
silk_find_LTP_FLP( psEncCtrl->LTPCoef, WLTP, &psEncCtrl->LTPredCodGain, res_pitch,
|
||||||
psEncCtrl->pitchL, Wght, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.ltp_mem_length );
|
psEncCtrl->pitchL, Wght, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.ltp_mem_length );
|
||||||
|
|
||||||
#ifdef SAVE_ALL_INTERNAL_DATA
|
|
||||||
DEBUG_STORE_DATA( ltp_gains.dat, psEncCtrl->LTPCoef, sizeof( psEncCtrl->LTPCoef ) );
|
|
||||||
DEBUG_STORE_DATA( ltp_weights.dat, WLTP, sizeof( WLTP ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Quantize LTP gain parameters */
|
/* Quantize LTP gain parameters */
|
||||||
silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex,
|
silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex,
|
||||||
WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr );
|
WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr );
|
||||||
|
@ -104,9 +99,7 @@ void silk_find_pred_coefs_FLP(
|
||||||
LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr );
|
LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr );
|
||||||
|
|
||||||
/* Quantize LSFs */
|
/* Quantize LSFs */
|
||||||
TIC(LSF_quant);
|
|
||||||
silk_process_NLSFs_FLP( &psEnc->sCmn, psEncCtrl->PredCoef, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 );
|
silk_process_NLSFs_FLP( &psEnc->sCmn, psEncCtrl->PredCoef, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 );
|
||||||
TOC(LSF_quant);
|
|
||||||
|
|
||||||
/* Calculate residual energy using quantized LPC coefficients */
|
/* Calculate residual energy using quantized LPC coefficients */
|
||||||
silk_residual_energy_FLP( psEncCtrl->ResNrg, LPC_in_pre, psEncCtrl->PredCoef, psEncCtrl->Gains,
|
silk_residual_energy_FLP( psEncCtrl->ResNrg, LPC_in_pre, psEncCtrl->PredCoef, psEncCtrl->Gains,
|
||||||
|
|
|
@ -31,11 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "SigProc_FLP.h"
|
#include "SigProc_FLP.h"
|
||||||
|
|
||||||
/* inner product of two silk_float arrays, with result as double */
|
/* inner product of two silk_float arrays, with result as double */
|
||||||
double silk_inner_product_FLP( /* O result */
|
double silk_inner_product_FLP(
|
||||||
const silk_float *data1, /* I vector 1 */
|
const silk_float *data1,
|
||||||
const silk_float *data2, /* I vector 2 */
|
const silk_float *data2,
|
||||||
opus_int dataSize /* I length of vectors */
|
opus_int dataSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, dataSize4;
|
opus_int i, dataSize4;
|
||||||
|
|
|
@ -33,16 +33,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/* step up function, converts reflection coefficients to prediction coefficients */
|
/* step up function, converts reflection coefficients to prediction coefficients */
|
||||||
void silk_k2a_FLP(
|
void silk_k2a_FLP(
|
||||||
silk_float *A, /* O: prediction coefficients [order] */
|
silk_float *A, /* O prediction coefficients [order] */
|
||||||
const silk_float *rc, /* I: reflection coefficients [order] */
|
const silk_float *rc, /* I reflection coefficients [order] */
|
||||||
opus_int32 order /* I: prediction order */
|
opus_int32 order /* I prediction order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int k, n;
|
opus_int k, n;
|
||||||
silk_float Atmp[ SILK_MAX_ORDER_LPC ];
|
silk_float Atmp[ SILK_MAX_ORDER_LPC ];
|
||||||
|
|
||||||
for( k = 0; k < order; k++ ){
|
for( k = 0; k < order; k++ ) {
|
||||||
for( n = 0; n < k; n++ ){
|
for( n = 0; n < k; n++ ) {
|
||||||
Atmp[ n ] = A[ n ];
|
Atmp[ n ] = A[ n ];
|
||||||
}
|
}
|
||||||
for( n = 0; n < k; n++ ) {
|
for( n = 0; n < k; n++ ) {
|
||||||
|
|
|
@ -32,10 +32,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "SigProc_FLP.h"
|
#include "SigProc_FLP.h"
|
||||||
|
|
||||||
/* Solve the normal equations using the Levinson-Durbin recursion */
|
/* Solve the normal equations using the Levinson-Durbin recursion */
|
||||||
silk_float silk_levinsondurbin_FLP( /* O prediction error energy */
|
silk_float silk_levinsondurbin_FLP( /* O prediction error energy */
|
||||||
silk_float A[], /* O prediction coefficients [order] */
|
silk_float A[], /* O prediction coefficients [order] */
|
||||||
const silk_float corr[], /* I input auto-correlations [order + 1] */
|
const silk_float corr[], /* I input auto-correlations [order + 1] */
|
||||||
const opus_int order /* I prediction order */
|
const opus_int order /* I prediction order */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
opus_int i, mHalf, m;
|
opus_int i, mHalf, m;
|
||||||
|
|
|
@ -51,47 +51,47 @@ extern "C"
|
||||||
|
|
||||||
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
|
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
|
||||||
void silk_HP_variable_cutoff(
|
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 */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Encoder main function */
|
/* Encoder main function */
|
||||||
void silk_encode_do_VAD_FLP(
|
void silk_encode_do_VAD_FLP(
|
||||||
silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Encoder main function */
|
/* Encoder main function */
|
||||||
opus_int silk_encode_frame_FLP(
|
opus_int silk_encode_frame_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
opus_int32 *pnBytesOut, /* O Number of payload bytes; */
|
opus_int32 *pnBytesOut, /* O Number of payload bytes; */
|
||||||
ec_enc *psRangeEnc, /* I/O compressor data structure */
|
ec_enc *psRangeEnc, /* I/O compressor data structure */
|
||||||
opus_int condCoding, /* I The type of conditional coding to use */
|
opus_int condCoding, /* I The type of conditional coding to use */
|
||||||
opus_int maxBits, /* I If > 0: maximum number of output bits */
|
opus_int maxBits, /* I If > 0: maximum number of output bits */
|
||||||
opus_int useCBR /* I Flag to force constant-bitrate operation */
|
opus_int useCBR /* I Flag to force constant-bitrate operation */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Initializes the Silk encoder state */
|
/* Initializes the Silk encoder state */
|
||||||
opus_int silk_init_encoder(
|
opus_int silk_init_encoder(
|
||||||
silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Control the Silk encoder */
|
/* Control the Silk encoder */
|
||||||
opus_int silk_control_encoder(
|
opus_int silk_control_encoder(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */
|
||||||
silk_EncControlStruct *encControl, /* I: Control structure */
|
silk_EncControlStruct *encControl, /* I Control structure */
|
||||||
const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */
|
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 allow_bw_switch, /* I Flag to allow switching audio bandwidth */
|
||||||
const opus_int channelNb, /* I Channel number */
|
const opus_int channelNb, /* I Channel number */
|
||||||
const opus_int force_fs_kHz
|
const opus_int force_fs_kHz
|
||||||
);
|
);
|
||||||
|
|
||||||
/****************/
|
/****************/
|
||||||
/* Prefiltering */
|
/* Prefiltering */
|
||||||
/****************/
|
/****************/
|
||||||
void silk_prefilter_FLP(
|
void silk_prefilter_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
const silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */
|
const silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */
|
||||||
silk_float xw[], /* O Weighted signal */
|
silk_float xw[], /* O Weighted signal */
|
||||||
const silk_float x[] /* I Speech signal */
|
const silk_float x[] /* I Speech signal */
|
||||||
);
|
);
|
||||||
|
|
||||||
/**************************/
|
/**************************/
|
||||||
|
@ -99,26 +99,26 @@ void silk_prefilter_FLP(
|
||||||
/**************************/
|
/**************************/
|
||||||
/* Compute noise shaping coefficients and initial gain values */
|
/* Compute noise shaping coefficients and initial gain values */
|
||||||
void silk_noise_shape_analysis_FLP(
|
void silk_noise_shape_analysis_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
const silk_float *pitch_res, /* I LPC residual from pitch analysis */
|
const silk_float *pitch_res, /* I LPC residual from pitch analysis */
|
||||||
const silk_float *x /* I Input signal [frame_length + la_shape] */
|
const silk_float *x /* I Input signal [frame_length + la_shape] */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Autocorrelations for a warped frequency axis */
|
/* Autocorrelations for a warped frequency axis */
|
||||||
void silk_warped_autocorrelation_FLP(
|
void silk_warped_autocorrelation_FLP(
|
||||||
silk_float *corr, /* O Result [order + 1] */
|
silk_float *corr, /* O Result [order + 1] */
|
||||||
const silk_float *input, /* I Input data to correlate */
|
const silk_float *input, /* I Input data to correlate */
|
||||||
const silk_float warping, /* I Warping coefficient */
|
const silk_float warping, /* I Warping coefficient */
|
||||||
const opus_int length, /* I Length of input */
|
const opus_int length, /* I Length of input */
|
||||||
const opus_int order /* I Correlation order (even) */
|
const opus_int order /* I Correlation order (even) */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Calculation of LTP state scaling */
|
/* Calculation of LTP state scaling */
|
||||||
void silk_LTP_scale_ctrl_FLP(
|
void silk_LTP_scale_ctrl_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
);
|
);
|
||||||
|
|
||||||
/**********************************************/
|
/**********************************************/
|
||||||
|
@ -126,127 +126,104 @@ void silk_LTP_scale_ctrl_FLP(
|
||||||
/**********************************************/
|
/**********************************************/
|
||||||
/* Find pitch lags */
|
/* Find pitch lags */
|
||||||
void silk_find_pitch_lags_FLP(
|
void silk_find_pitch_lags_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
silk_float res[], /* O Residual */
|
silk_float res[], /* O Residual */
|
||||||
const silk_float x[] /* I Speech signal */
|
const silk_float x[] /* I Speech signal */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Find LPC and LTP coefficients */
|
/* Find LPC and LTP coefficients */
|
||||||
void silk_find_pred_coefs_FLP(
|
void silk_find_pred_coefs_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
const silk_float res_pitch[], /* I Residual from pitch analysis */
|
const silk_float res_pitch[], /* I Residual from pitch analysis */
|
||||||
const silk_float x[], /* I Speech signal */
|
const silk_float x[], /* I Speech signal */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* LPC analysis */
|
/* LPC analysis */
|
||||||
void silk_find_LPC_FLP(
|
void silk_find_LPC_FLP(
|
||||||
opus_int16 NLSF_Q15[], /* O NLSFs */
|
opus_int16 NLSF_Q15[], /* O NLSFs */
|
||||||
opus_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */
|
opus_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */
|
||||||
const opus_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */
|
const opus_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */
|
||||||
const opus_int useInterpNLSFs, /* I Flag */
|
const opus_int useInterpNLSFs, /* I Flag */
|
||||||
const opus_int firstFrameAfterReset, /* I Flag */
|
const opus_int firstFrameAfterReset, /* I Flag */
|
||||||
const opus_int LPC_order, /* I LPC order */
|
const opus_int LPC_order, /* I LPC order */
|
||||||
const silk_float x[], /* I Input signal */
|
const silk_float x[], /* I Input signal */
|
||||||
const opus_int subfr_length, /* I Subframe length incl preceeding samples */
|
const opus_int subfr_length, /* I Subframe length incl preceeding samples */
|
||||||
const opus_int nb_subfr /* I: Number of subframes */
|
const opus_int nb_subfr /* I Number of subframes */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* LTP analysis */
|
/* LTP analysis */
|
||||||
void silk_find_LTP_FLP(
|
void silk_find_LTP_FLP(
|
||||||
silk_float b[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
|
silk_float b[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
|
||||||
silk_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
|
silk_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
|
||||||
silk_float *LTPredCodGain, /* O LTP coding gain */
|
silk_float *LTPredCodGain, /* O LTP coding gain */
|
||||||
const silk_float r_lpc[], /* I LPC residual */
|
const silk_float r_lpc[], /* I LPC residual */
|
||||||
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
|
||||||
const silk_float Wght[ MAX_NB_SUBFR ], /* I Weights */
|
const silk_float Wght[ MAX_NB_SUBFR ], /* I Weights */
|
||||||
const opus_int subfr_length, /* I Subframe length */
|
const opus_int subfr_length, /* I Subframe length */
|
||||||
const opus_int nb_subfr, /* I number of subframes */
|
const opus_int nb_subfr, /* I number of subframes */
|
||||||
const opus_int mem_offset /* I Number of samples in LTP memory */
|
const opus_int mem_offset /* I Number of samples in LTP memory */
|
||||||
);
|
);
|
||||||
|
|
||||||
void silk_LTP_analysis_filter_FLP(
|
void silk_LTP_analysis_filter_FLP(
|
||||||
silk_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */
|
silk_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */
|
||||||
const silk_float *x, /* I Input signal, with preceeding samples */
|
const silk_float *x, /* I Input signal, with preceeding samples */
|
||||||
const silk_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */
|
const silk_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */
|
||||||
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
|
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
|
||||||
const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */
|
const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */
|
||||||
const opus_int subfr_length, /* I Length of each subframe */
|
const opus_int subfr_length, /* I Length of each subframe */
|
||||||
const opus_int nb_subfr, /* I number of subframes */
|
const opus_int nb_subfr, /* I number of subframes */
|
||||||
const opus_int pre_length /* I Preceeding samples for each subframe */
|
const opus_int pre_length /* I Preceeding samples for each subframe */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Calculates residual energies of input subframes where all subframes have LPC_order */
|
/* Calculates residual energies of input subframes where all subframes have LPC_order */
|
||||||
/* of preceeding samples */
|
/* of preceeding samples */
|
||||||
void silk_residual_energy_FLP(
|
void silk_residual_energy_FLP(
|
||||||
silk_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
|
silk_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
|
||||||
const silk_float x[], /* I Input signal */
|
const silk_float x[], /* I Input signal */
|
||||||
silk_float a[ 2 ][ MAX_LPC_ORDER ],/* I AR coefs for each frame half */
|
silk_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
|
||||||
const silk_float gains[], /* I Quantization gains */
|
const silk_float gains[], /* I Quantization gains */
|
||||||
const opus_int subfr_length, /* I Subframe length */
|
const opus_int subfr_length, /* I Subframe length */
|
||||||
const opus_int nb_subfr, /* I number of subframes */
|
const opus_int nb_subfr, /* I number of subframes */
|
||||||
const opus_int LPC_order /* I LPC order */
|
const opus_int LPC_order /* I LPC order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* 16th order LPC analysis filter */
|
/* 16th order LPC analysis filter */
|
||||||
void silk_LPC_analysis_filter_FLP(
|
void silk_LPC_analysis_filter_FLP(
|
||||||
silk_float r_LPC[], /* O LPC residual signal */
|
silk_float r_LPC[], /* O LPC residual signal */
|
||||||
const silk_float PredCoef[], /* I LPC coefficients */
|
const silk_float PredCoef[], /* I LPC coefficients */
|
||||||
const silk_float s[], /* I Input signal */
|
const silk_float s[], /* I Input signal */
|
||||||
const opus_int length, /* I Length of input signal */
|
const opus_int length, /* I Length of input signal */
|
||||||
const opus_int Order /* I LPC order */
|
const opus_int Order /* I LPC order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* LTP tap quantizer */
|
/* LTP tap quantizer */
|
||||||
void silk_quant_LTP_gains_FLP(
|
void silk_quant_LTP_gains_FLP(
|
||||||
silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (Un-)quantized LTP gains */
|
silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (Un-)quantized LTP gains */
|
||||||
opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */
|
opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */
|
||||||
opus_int8 *periodicity_index, /* O Periodicity index */
|
opus_int8 *periodicity_index, /* O Periodicity index */
|
||||||
const silk_float W[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Error weights */
|
const silk_float W[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Error weights */
|
||||||
const opus_int mu_Q10, /* I Mu value (R/D tradeoff) */
|
const opus_int mu_Q10, /* I Mu value (R/D tradeoff) */
|
||||||
const opus_int lowComplexity, /* I Flag for low complexity */
|
const opus_int lowComplexity, /* I Flag for low complexity */
|
||||||
const opus_int nb_subfr /* I number of subframes */
|
const opus_int nb_subfr /* I number of subframes */
|
||||||
);
|
|
||||||
|
|
||||||
/******************/
|
|
||||||
/* NLSF Quantizer */
|
|
||||||
/******************/
|
|
||||||
/* Limit, stabilize, and quantize NLSFs */
|
|
||||||
void silk_process_NLSFs_FLP(
|
|
||||||
silk_encoder_state *psEncC, /* I/O Encoder state */
|
|
||||||
silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */
|
|
||||||
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
|
|
||||||
const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
|
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
|
||||||
silk_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */
|
silk_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */
|
||||||
const silk_float *c, /* I Filter coefficients */
|
const silk_float *c, /* I Filter coefficients */
|
||||||
silk_float *wXX, /* I/O Weighted correlation matrix, reg. out */
|
silk_float *wXX, /* I/O Weighted correlation matrix, reg. out */
|
||||||
const silk_float *wXx, /* I Weighted correlation vector */
|
const silk_float *wXx, /* I Weighted correlation vector */
|
||||||
const silk_float wxx, /* I Weighted correlation value */
|
const silk_float wxx, /* I Weighted correlation value */
|
||||||
const opus_int D /* I Dimension */
|
const opus_int D /* I Dimension */
|
||||||
);
|
|
||||||
|
|
||||||
/* Entropy constrained MATRIX-weighted VQ, for a single input data vector */
|
|
||||||
void silk_VQ_WMat_EC_FLP(
|
|
||||||
opus_int *ind, /* O Index of best codebook vector */
|
|
||||||
silk_float *rate_dist, /* O Best weighted quant. error + mu * rate */
|
|
||||||
const silk_float *in, /* I Input vector to be quantized */
|
|
||||||
const silk_float *W, /* I Weighting matrix */
|
|
||||||
const opus_int16 *cb, /* I Codebook */
|
|
||||||
const opus_int16 *cl_Q6, /* I Code length for each codebook vector */
|
|
||||||
const silk_float mu, /* I Tradeoff between WSSE and rate */
|
|
||||||
const opus_int L /* I Number of vectors in codebook */
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Processing of gains */
|
/* Processing of gains */
|
||||||
void silk_process_gains_FLP(
|
void silk_process_gains_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
opus_int condCoding /* I The type of conditional coding to use */
|
opus_int condCoding /* I The type of conditional coding to use */
|
||||||
);
|
);
|
||||||
|
|
||||||
/******************/
|
/******************/
|
||||||
|
@ -254,74 +231,80 @@ void silk_process_gains_FLP(
|
||||||
/******************/
|
/******************/
|
||||||
/* Calculates correlation matrix X'*X */
|
/* Calculates correlation matrix X'*X */
|
||||||
void silk_corrMatrix_FLP(
|
void silk_corrMatrix_FLP(
|
||||||
const silk_float *x, /* I x vector [ L+order-1 ] used to create X */
|
const silk_float *x, /* I x vector [ L+order-1 ] used to create X */
|
||||||
const opus_int L, /* I Length of vectors */
|
const opus_int L, /* I Length of vectors */
|
||||||
const opus_int Order, /* I Max lag for correlation */
|
const opus_int Order, /* I Max lag for correlation */
|
||||||
silk_float *XX /* O X'*X correlation matrix [order x order] */
|
silk_float *XX /* O X'*X correlation matrix [order x order] */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Calculates correlation vector X'*t */
|
/* Calculates correlation vector X'*t */
|
||||||
void silk_corrVector_FLP(
|
void silk_corrVector_FLP(
|
||||||
const silk_float *x, /* I x vector [L+order-1] used to create X */
|
const silk_float *x, /* I x vector [L+order-1] used to create X */
|
||||||
const silk_float *t, /* I Target vector [L] */
|
const silk_float *t, /* I Target vector [L] */
|
||||||
const opus_int L, /* I Length of vecors */
|
const opus_int L, /* I Length of vecors */
|
||||||
const opus_int Order, /* I Max lag for correlation */
|
const opus_int Order, /* I Max lag for correlation */
|
||||||
silk_float *Xt /* O X'*t correlation vector [order] */
|
silk_float *Xt /* O X'*t correlation vector [order] */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Add noise to matrix diagonal */
|
/* Add noise to matrix diagonal */
|
||||||
void silk_regularize_correlations_FLP(
|
void silk_regularize_correlations_FLP(
|
||||||
silk_float *XX, /* I/O Correlation matrices */
|
silk_float *XX, /* I/O Correlation matrices */
|
||||||
silk_float *xx, /* I/O Correlation values */
|
silk_float *xx, /* I/O Correlation values */
|
||||||
const silk_float noise, /* I Noise energy to add */
|
const silk_float noise, /* I Noise energy to add */
|
||||||
const opus_int D /* I Dimension of XX */
|
const opus_int D /* I Dimension of XX */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Function to solve linear equation Ax = b, where A is an MxM symmetric matrix */
|
/* Function to solve linear equation Ax = b, where A is an MxM symmetric matrix */
|
||||||
void silk_solve_LDL_FLP(
|
void silk_solve_LDL_FLP(
|
||||||
silk_float *A, /* I/O Symmetric square matrix, out: reg. */
|
silk_float *A, /* I/O Symmetric square matrix, out: reg. */
|
||||||
const opus_int M, /* I Size of matrix */
|
const opus_int M, /* I Size of matrix */
|
||||||
const silk_float *b, /* I Pointer to b vector */
|
const silk_float *b, /* I Pointer to b vector */
|
||||||
silk_float *x /* O Pointer to x solution vector */
|
silk_float *x /* O Pointer to x solution vector */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Apply sine window to signal vector. */
|
/* Apply sine window to signal vector. */
|
||||||
/* Window types: */
|
/* Window types: */
|
||||||
/* 1 -> sine window from 0 to pi/2 */
|
/* 1 -> sine window from 0 to pi/2 */
|
||||||
/* 2 -> sine window from pi/2 to pi */
|
/* 2 -> sine window from pi/2 to pi */
|
||||||
void silk_apply_sine_window_FLP(
|
void silk_apply_sine_window_FLP(
|
||||||
silk_float px_win[], /* O Pointer to windowed signal */
|
silk_float px_win[], /* O Pointer to windowed signal */
|
||||||
const silk_float px[], /* I Pointer to input signal */
|
const silk_float px[], /* I Pointer to input signal */
|
||||||
const opus_int win_type, /* I Selects a window type */
|
const opus_int win_type, /* I Selects a window type */
|
||||||
const opus_int length /* I Window length, multiple of 4 */
|
const opus_int length /* I Window length, multiple of 4 */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Wrapper functions. Call flp / fix code */
|
/* Wrapper functions. Call flp / fix code */
|
||||||
|
|
||||||
/* Convert AR filter coefficients to NLSF parameters */
|
/* Convert AR filter coefficients to NLSF parameters */
|
||||||
void silk_A2NLSF_FLP(
|
void silk_A2NLSF_FLP(
|
||||||
opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
|
opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
|
||||||
const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */
|
const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */
|
||||||
const opus_int LPC_order /* I LPC order */
|
const opus_int LPC_order /* I LPC order */
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Convert NLSF parameters to AR prediction filter coefficients */
|
/* Convert NLSF parameters to AR prediction filter coefficients */
|
||||||
void silk_NLSF2A_FLP(
|
void silk_NLSF2A_FLP(
|
||||||
silk_float *pAR, /* O LPC coefficients [ LPC_order ] */
|
silk_float *pAR, /* O LPC coefficients [ LPC_order ] */
|
||||||
const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
|
const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
|
||||||
const opus_int LPC_order /* I LPC order */
|
const opus_int LPC_order /* I LPC order */
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Limit, stabilize, and quantize NLSFs */
|
||||||
|
void silk_process_NLSFs_FLP(
|
||||||
|
silk_encoder_state *psEncC, /* I/O Encoder state */
|
||||||
|
silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */
|
||||||
|
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
|
||||||
|
const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
|
||||||
);
|
);
|
||||||
|
|
||||||
/****************************************/
|
|
||||||
/* Floating-point Silk NSQ wrapper */
|
/* Floating-point Silk NSQ wrapper */
|
||||||
/****************************************/
|
|
||||||
void silk_NSQ_wrapper_FLP(
|
void silk_NSQ_wrapper_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
SideInfoIndices *psIndices, /* I/O Quantization indices */
|
SideInfoIndices *psIndices, /* I/O Quantization indices */
|
||||||
silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
|
silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
|
||||||
opus_int8 pulses[], /* O Quantized pulse signal */
|
opus_int8 pulses[], /* O Quantized pulse signal */
|
||||||
const silk_float x[] /* I Prefiltered input signal */
|
const silk_float x[] /* I Prefiltered input signal */
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -124,10 +124,10 @@ static inline void warped_true2monic_coefs(
|
||||||
|
|
||||||
/* Compute noise shaping coefficients and initial gain values */
|
/* Compute noise shaping coefficients and initial gain values */
|
||||||
void silk_noise_shape_analysis_FLP(
|
void silk_noise_shape_analysis_FLP(
|
||||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||||
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
|
||||||
const silk_float *pitch_res, /* I LPC residual from pitch analysis */
|
const silk_float *pitch_res, /* I LPC residual from pitch analysis */
|
||||||
const silk_float *x /* I Input signal [frame_length + la_shape] */
|
const silk_float *x /* I Input signal [frame_length + la_shape] */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
silk_shape_state_FLP *psShapeSt = &psEnc->sShape;
|
silk_shape_state_FLP *psShapeSt = &psEnc->sShape;
|
||||||
|
|
|
@ -30,59 +30,51 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
|
||||||
* Pitch analyser function
|
* Pitch analyser function
|
||||||
*
|
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
#include "SigProc_FLP.h"
|
#include "SigProc_FLP.h"
|
||||||
#include "SigProc_FIX.h"
|
#include "SigProc_FIX.h"
|
||||||
#include "pitch_est_defines.h"
|
#include "pitch_est_defines.h"
|
||||||
|
|
||||||
#define SCRATCH_SIZE 22
|
#define SCRATCH_SIZE 22
|
||||||
|
#define eps 1.192092896e-07f
|
||||||
/************************************************************/
|
|
||||||
/* Definitions */
|
|
||||||
/************************************************************/
|
|
||||||
#define eps 1.192092896e-07f
|
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
/* Internally used functions */
|
/* Internally used functions */
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
static void silk_P_Ana_calc_corr_st3(
|
static void silk_P_Ana_calc_corr_st3(
|
||||||
silk_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
silk_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
||||||
const silk_float frame[], /* I vector to correlate */
|
const silk_float frame[], /* I vector to correlate */
|
||||||
opus_int start_lag, /* I start lag */
|
opus_int start_lag, /* I start lag */
|
||||||
opus_int sf_length, /* I sub frame length */
|
opus_int sf_length, /* I sub frame length */
|
||||||
opus_int nb_subfr, /* I number of subframes */
|
opus_int nb_subfr, /* I number of subframes */
|
||||||
opus_int complexity /* I Complexity setting */
|
opus_int complexity /* I Complexity setting */
|
||||||
);
|
);
|
||||||
|
|
||||||
static void silk_P_Ana_calc_energy_st3(
|
static void silk_P_Ana_calc_energy_st3(
|
||||||
silk_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
silk_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
||||||
const silk_float frame[], /* I vector to correlate */
|
const silk_float frame[], /* I vector to correlate */
|
||||||
opus_int start_lag, /* I start lag */
|
opus_int start_lag, /* I start lag */
|
||||||
opus_int sf_length, /* I sub frame length */
|
opus_int sf_length, /* I sub frame length */
|
||||||
opus_int nb_subfr, /* I number of subframes */
|
opus_int nb_subfr, /* I number of subframes */
|
||||||
opus_int complexity /* I Complexity setting */
|
opus_int complexity /* I Complexity setting */
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/************************************************************/
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
/* CORE PITCH ANALYSIS FUNCTION */
|
||||||
% CORE PITCH ANALYSIS FUNCTION %
|
/************************************************************/
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
opus_int silk_pitch_analysis_core_FLP( /* O Voicing estimate: 0 voiced, 1 unvoiced */
|
||||||
*/
|
const silk_float *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
|
||||||
opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */
|
opus_int *pitch_out, /* O Pitch lag values [nb_subfr] */
|
||||||
const silk_float *frame, /* I signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
|
opus_int16 *lagIndex, /* O Lag Index */
|
||||||
opus_int *pitch_out, /* O 4 pitch lag values */
|
opus_int8 *contourIndex, /* O Pitch contour Index */
|
||||||
opus_int16 *lagIndex, /* O lag Index */
|
silk_float *LTPCorr, /* I/O Normalized correlation; input: value from previous frame */
|
||||||
opus_int8 *contourIndex, /* O pitch contour Index */
|
opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */
|
||||||
silk_float *LTPCorr, /* I/O normalized correlation; input: value from previous frame */
|
const silk_float search_thres1, /* I First stage threshold for lag candidates 0 - 1 */
|
||||||
opus_int prevLag, /* I last lag of previous frame; set to zero is unvoiced */
|
const silk_float search_thres2, /* I Final threshold for lag candidates 0 - 1 */
|
||||||
const silk_float search_thres1, /* I first stage threshold for lag candidates 0 - 1 */
|
const opus_int Fs_kHz, /* I sample frequency (kHz) */
|
||||||
const silk_float search_thres2, /* I final threshold for lag candidates 0 - 1 */
|
const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */
|
||||||
const opus_int Fs_kHz, /* I sample frequency (kHz) */
|
const opus_int nb_subfr /* I Number of 5 ms subframes */
|
||||||
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_int i, k, d, j;
|
opus_int i, k, d, j;
|
||||||
|
@ -117,8 +109,8 @@ opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoic
|
||||||
silk_assert( Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16 );
|
silk_assert( Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16 );
|
||||||
|
|
||||||
/* Check for valid complexity setting */
|
/* Check for valid complexity setting */
|
||||||
silk_assert( complexity >= SigProc_PE_MIN_COMPLEX );
|
silk_assert( complexity >= SILK_PE_MIN_COMPLEX );
|
||||||
silk_assert( complexity <= SigProc_PE_MAX_COMPLEX );
|
silk_assert( complexity <= SILK_PE_MAX_COMPLEX );
|
||||||
|
|
||||||
silk_assert( search_thres1 >= 0.0f && search_thres1 <= 1.0f );
|
silk_assert( search_thres1 >= 0.0f && search_thres1 <= 1.0f );
|
||||||
silk_assert( search_thres2 >= 0.0f && search_thres2 <= 1.0f );
|
silk_assert( search_thres2 >= 0.0f && search_thres2 <= 1.0f );
|
||||||
|
@ -301,7 +293,7 @@ opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoic
|
||||||
basis_ptr = target_ptr - d;
|
basis_ptr = target_ptr - d;
|
||||||
cross_corr = silk_inner_product_FLP( basis_ptr, target_ptr, sf_length_8kHz );
|
cross_corr = silk_inner_product_FLP( basis_ptr, target_ptr, sf_length_8kHz );
|
||||||
energy = silk_energy_FLP( basis_ptr, sf_length_8kHz );
|
energy = silk_energy_FLP( basis_ptr, sf_length_8kHz );
|
||||||
if (cross_corr > 0.0f) {
|
if( cross_corr > 0.0f ) {
|
||||||
C[ k ][ d ] = (silk_float)(cross_corr * cross_corr / (energy * energy_tmp + eps));
|
C[ k ][ d ] = (silk_float)(cross_corr * cross_corr / (energy * energy_tmp + eps));
|
||||||
} else {
|
} else {
|
||||||
C[ k ][ d ] = 0.0f;
|
C[ k ][ d ] = 0.0f;
|
||||||
|
@ -334,7 +326,7 @@ opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoic
|
||||||
if( nb_subfr == PE_MAX_NB_SUBFR ) {
|
if( nb_subfr == PE_MAX_NB_SUBFR ) {
|
||||||
cbk_size = PE_NB_CBKS_STAGE2_EXT;
|
cbk_size = PE_NB_CBKS_STAGE2_EXT;
|
||||||
Lag_CB_ptr = &silk_CB_lags_stage2[ 0 ][ 0 ];
|
Lag_CB_ptr = &silk_CB_lags_stage2[ 0 ][ 0 ];
|
||||||
if( Fs_kHz == 8 && complexity > SigProc_PE_MIN_COMPLEX ) {
|
if( Fs_kHz == 8 && complexity > SILK_PE_MIN_COMPLEX ) {
|
||||||
/* If input is 8 khz use a larger codebook here because it is last stage */
|
/* If input is 8 khz use a larger codebook here because it is last stage */
|
||||||
nb_cbk_search = PE_NB_CBKS_STAGE2_EXT;
|
nb_cbk_search = PE_NB_CBKS_STAGE2_EXT;
|
||||||
} else {
|
} else {
|
||||||
|
@ -372,16 +364,16 @@ opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoic
|
||||||
CCmax_new_b -= PE_SHORTLAG_BIAS * nb_subfr * lag_log2;
|
CCmax_new_b -= PE_SHORTLAG_BIAS * nb_subfr * lag_log2;
|
||||||
|
|
||||||
/* Bias towards previous lag */
|
/* Bias towards previous lag */
|
||||||
if ( prevLag > 0 ) {
|
if( prevLag > 0 ) {
|
||||||
delta_lag_log2_sqr = lag_log2 - prevLag_log2;
|
delta_lag_log2_sqr = lag_log2 - prevLag_log2;
|
||||||
delta_lag_log2_sqr *= delta_lag_log2_sqr;
|
delta_lag_log2_sqr *= delta_lag_log2_sqr;
|
||||||
CCmax_new_b -= PE_PREVLAG_BIAS * nb_subfr * (*LTPCorr) * delta_lag_log2_sqr / (delta_lag_log2_sqr + 0.5f);
|
CCmax_new_b -= PE_PREVLAG_BIAS * nb_subfr * (*LTPCorr) * delta_lag_log2_sqr / (delta_lag_log2_sqr + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */
|
if( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */
|
||||||
CCmax_new > nb_subfr * search_thres2 * search_thres2 && /* Correlation needs to be high enough to be voiced */
|
CCmax_new > nb_subfr * search_thres2 * search_thres2 && /* Correlation needs to be high enough to be voiced */
|
||||||
silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */
|
silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */
|
||||||
) {
|
) {
|
||||||
CCmax_b = CCmax_new_b;
|
CCmax_b = CCmax_new_b;
|
||||||
CCmax = CCmax_new;
|
CCmax = CCmax_new;
|
||||||
lag = d;
|
lag = d;
|
||||||
|
@ -415,7 +407,7 @@ opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoic
|
||||||
lag_new = lag; /* to avoid undefined lag */
|
lag_new = lag; /* to avoid undefined lag */
|
||||||
CBimax = 0; /* to avoid undefined lag */
|
CBimax = 0; /* to avoid undefined lag */
|
||||||
silk_assert( CCmax >= 0.0f );
|
silk_assert( CCmax >= 0.0f );
|
||||||
*LTPCorr = (silk_float)sqrt( CCmax / nb_subfr ); /* Output normalized correlation */
|
*LTPCorr = (silk_float)sqrt( CCmax / nb_subfr ); /* Output normalized correlation */
|
||||||
|
|
||||||
CCmax = -1000.0f;
|
CCmax = -1000.0f;
|
||||||
|
|
||||||
|
@ -489,11 +481,11 @@ opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoic
|
||||||
|
|
||||||
static void silk_P_Ana_calc_corr_st3(
|
static void silk_P_Ana_calc_corr_st3(
|
||||||
silk_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
silk_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
||||||
const silk_float frame[], /* I vector to correlate */
|
const silk_float frame[], /* I vector to correlate */
|
||||||
opus_int start_lag, /* I start lag */
|
opus_int start_lag, /* I start lag */
|
||||||
opus_int sf_length, /* I sub frame length */
|
opus_int sf_length, /* I sub frame length */
|
||||||
opus_int nb_subfr, /* I number of subframes */
|
opus_int nb_subfr, /* I number of subframes */
|
||||||
opus_int complexity /* I Complexity setting */
|
opus_int complexity /* I Complexity setting */
|
||||||
)
|
)
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
Calculates the correlations used in stage 3 search. In order to cover
|
Calculates the correlations used in stage 3 search. In order to cover
|
||||||
|
@ -515,10 +507,10 @@ static void silk_P_Ana_calc_corr_st3(
|
||||||
silk_float scratch_mem[ SCRATCH_SIZE ];
|
silk_float scratch_mem[ SCRATCH_SIZE ];
|
||||||
const opus_int8 *Lag_range_ptr, *Lag_CB_ptr;
|
const opus_int8 *Lag_range_ptr, *Lag_CB_ptr;
|
||||||
|
|
||||||
silk_assert( complexity >= SigProc_PE_MIN_COMPLEX );
|
silk_assert( complexity >= SILK_PE_MIN_COMPLEX );
|
||||||
silk_assert( complexity <= SigProc_PE_MAX_COMPLEX );
|
silk_assert( complexity <= SILK_PE_MAX_COMPLEX );
|
||||||
|
|
||||||
if( nb_subfr == PE_MAX_NB_SUBFR ){
|
if( nb_subfr == PE_MAX_NB_SUBFR ) {
|
||||||
Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
|
Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
|
||||||
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
|
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
|
||||||
nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ];
|
nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ];
|
||||||
|
@ -562,11 +554,11 @@ static void silk_P_Ana_calc_corr_st3(
|
||||||
|
|
||||||
static void silk_P_Ana_calc_energy_st3(
|
static void silk_P_Ana_calc_energy_st3(
|
||||||
silk_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
silk_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
|
||||||
const silk_float frame[], /* I vector to correlate */
|
const silk_float frame[], /* I vector to correlate */
|
||||||
opus_int start_lag, /* I start lag */
|
opus_int start_lag, /* I start lag */
|
||||||
opus_int sf_length, /* I sub frame length */
|
opus_int sf_length, /* I sub frame length */
|
||||||
opus_int nb_subfr, /* I number of subframes */
|
opus_int nb_subfr, /* I number of subframes */
|
||||||
opus_int complexity /* I Complexity setting */
|
opus_int complexity /* I Complexity setting */
|
||||||
)
|
)
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
Calculate the energies for first two subframes. The energies are
|
Calculate the energies for first two subframes. The energies are
|
||||||
|
@ -580,10 +572,10 @@ calculated recursively.
|
||||||
silk_float scratch_mem[ SCRATCH_SIZE ];
|
silk_float scratch_mem[ SCRATCH_SIZE ];
|
||||||
const opus_int8 *Lag_range_ptr, *Lag_CB_ptr;
|
const opus_int8 *Lag_range_ptr, *Lag_CB_ptr;
|
||||||
|
|
||||||
silk_assert( complexity >= SigProc_PE_MIN_COMPLEX );
|
silk_assert( complexity >= SILK_PE_MIN_COMPLEX );
|
||||||
silk_assert( complexity <= SigProc_PE_MAX_COMPLEX );
|
silk_assert( complexity <= SILK_PE_MAX_COMPLEX );
|
||||||
|
|
||||||
if( nb_subfr == PE_MAX_NB_SUBFR ){
|
if( nb_subfr == PE_MAX_NB_SUBFR ) {
|
||||||
Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
|
Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
|
||||||
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
|
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
|
||||||
nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ];
|
nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ];
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue