From acc7a6c78b266e3ef0e1f91ee405af92a0989dec Mon Sep 17 00:00:00 2001 From: Koen Vos Date: Fri, 28 Oct 2011 19:44:26 -0400 Subject: Reformatting changes with an update to the MSVC project files --- silk/A2NLSF.c | 63 +-- silk/API.h | 70 ++-- silk/CNG.c | 10 +- silk/HP_variable_cutoff.c | 2 +- silk/Inlines.h | 48 +-- silk/LPC_analysis_filter.c | 14 +- silk/LPC_inv_pred_gain.c | 33 +- silk/LP_variable_cutoff.c | 13 +- silk/MacroDebug.h | 101 +++-- silk/NLSF2A.c | 6 +- silk/NLSF_VQ.c | 10 +- silk/NLSF_VQ_weights_laroia.c | 6 +- silk/NLSF_decode.c | 6 +- silk/NLSF_del_dec_quant.c | 24 +- silk/NLSF_encode.c | 75 +--- silk/NLSF_stabilize.c | 8 +- silk/NLSF_unpack.c | 8 +- silk/NSQ.c | 155 ++++---- silk/NSQ_del_dec.c | 177 +++++---- silk/PLC.c | 38 +- silk/PLC.h | 28 +- silk/SigProc_FIX.h | 480 ++++++++++++----------- silk/VAD.c | 12 +- silk/VQ_WMat_EC.c | 16 +- silk/ana_filt_bank_1.c | 10 +- silk/biquad_alt.c | 19 +- silk/bwexpander.c | 6 +- silk/bwexpander_32.c | 6 +- silk/check_control_input.c | 2 +- silk/code_signs.c | 20 +- silk/control.h | 8 +- silk/control_SNR.c | 4 +- silk/control_audio_bandwidth.c | 12 +- silk/control_codec.c | 35 +- silk/create_init_destroy.c | 3 +- silk/debug.c | 4 +- silk/debug.h | 136 +++---- silk/dec_API.c | 36 +- silk/decode_core.c | 22 +- silk/decode_frame.c | 24 +- silk/decode_indices.c | 10 +- silk/decode_parameters.c | 6 +- silk/decode_pitch.c | 10 +- silk/decode_pulses.c | 14 +- silk/decoder_set_fs.c | 6 +- silk/define.h | 30 +- silk/enc_API.c | 44 ++- silk/encode_indices.c | 72 +--- silk/encode_pulses.c | 22 +- silk/fixed/LTP_analysis_filter_FIX.c | 16 +- silk/fixed/LTP_scale_ctrl_FIX.c | 7 +- silk/fixed/apply_sine_window_FIX.c | 8 +- silk/fixed/autocorr_FIX.c | 10 +- silk/fixed/burg_modified_FIX.c | 116 +++--- silk/fixed/corrMatrix_FIX.c | 24 +- silk/fixed/encode_frame_FIX.c | 103 +---- silk/fixed/find_LPC_FIX.c | 18 +- silk/fixed/find_LTP_FIX.c | 37 +- silk/fixed/find_pitch_lags_FIX.c | 8 +- silk/fixed/find_pred_coefs_FIX.c | 14 +- silk/fixed/k2a_FIX.c | 6 +- silk/fixed/k2a_Q16_FIX.c | 6 +- silk/fixed/main_FIX.h | 210 +++++----- silk/fixed/noise_shape_analysis_FIX.c | 8 +- silk/fixed/pitch_analysis_core_FIX.c | 46 ++- silk/fixed/prefilter_FIX.c | 58 +-- silk/fixed/process_gains_FIX.c | 12 +- silk/fixed/regularize_correlations_FIX.c | 8 +- silk/fixed/residual_energy16_FIX.c | 12 +- silk/fixed/residual_energy_FIX.c | 16 +- silk/fixed/schur64_FIX.c | 8 +- silk/fixed/schur_FIX.c | 8 +- silk/fixed/silk_fixed.vcxproj | 249 ++++++------ silk/fixed/silk_fixed.vcxproj.filters | 223 +++++------ silk/fixed/solve_LS_FIX.c | 68 ++-- silk/fixed/structs_FIX.h | 96 ++--- silk/fixed/vector_ops_FIX.c | 41 +- silk/fixed/warped_autocorrelation_FIX.c | 12 +- silk/float/LPC_analysis_filter_FLP.c | 23 +- silk/float/LPC_inv_pred_gain_FLP.c | 16 +- silk/float/LTP_analysis_filter_FLP.c | 16 +- silk/float/LTP_scale_ctrl_FLP.c | 6 +- silk/float/SigProc_FLP.h | 154 ++++---- silk/float/apply_sine_window_FLP.c | 16 +- silk/float/autocorrelation_FLP.c | 10 +- silk/float/burg_modified_FLP.c | 14 +- silk/float/bwexpander_FLP.c | 7 +- silk/float/corrMatrix_FLP.c | 18 +- silk/float/encode_frame_FLP.c | 79 +--- silk/float/energy_FLP.c | 4 +- silk/float/find_LPC_FLP.c | 18 +- silk/float/find_LTP_FLP.c | 18 +- silk/float/find_pitch_lags_FLP.c | 8 +- silk/float/find_pred_coefs_FLP.c | 19 +- silk/float/inner_product_FLP.c | 10 +- silk/float/k2a_FLP.c | 10 +- silk/float/levinsondurbin_FLP.c | 8 +- silk/float/main_FLP.h | 295 +++++++------- silk/float/noise_shape_analysis_FLP.c | 8 +- silk/float/pitch_analysis_core_FLP.c | 114 +++--- silk/float/prefilter_FLP.c | 46 +-- silk/float/process_gains_FLP.c | 6 +- silk/float/regularize_correlations_FLP.c | 9 +- silk/float/residual_energy_FLP.c | 26 +- silk/float/scale_copy_vector_FLP.c | 8 +- silk/float/scale_vector_FLP.c | 6 +- silk/float/schur_FLP.c | 10 +- silk/float/silk_float.vcxproj | 259 ++++++------- silk/float/silk_float.vcxproj.filters | 259 ++++++------- silk/float/solve_LS_FLP.c | 56 +-- silk/float/sort_FLP.c | 8 +- silk/float/structs_FLP.h | 96 ++--- silk/float/warped_autocorrelation_FLP.c | 18 +- silk/float/wrappers_FLP.c | 44 +-- silk/gain_quant.c | 26 +- silk/init_encoder.c | 5 +- silk/inner_prod_aligned.c | 8 +- silk/interpolate.c | 10 +- silk/lin2log.c | 4 +- silk/log2lin.c | 4 +- silk/main.h | 435 ++++++++++----------- silk/pitch_est_defines.h | 67 ++-- silk/process_NLSFs.c | 11 +- silk/quant_LTP_gains.c | 18 +- silk/resampler.c | 44 +-- silk/resampler_down2.c | 8 +- silk/resampler_down2_3.c | 8 +- silk/resampler_private.h | 54 ++- silk/resampler_private_AR2.c | 10 +- silk/resampler_private_IIR_FIR.c | 17 +- silk/resampler_private_down_FIR.c | 31 +- silk/resampler_private_up2_HQ.c | 16 +- silk/resampler_rom.c | 4 +- silk/resampler_rom.h | 1 - silk/resampler_structs.h | 6 +- silk/shell_coder.c | 30 +- silk/sigm_Q15.c | 4 +- silk/silk_common.vcxproj | 386 +++++++++---------- silk/silk_common.vcxproj.filters | 634 +++++++++++++++---------------- silk/sort.c | 20 +- silk/stereo_LR_to_MS.c | 28 +- silk/stereo_MS_to_LR.c | 12 +- silk/stereo_decode_pred.c | 8 +- silk/stereo_encode_pred.c | 8 +- silk/stereo_find_predictor.c | 14 +- silk/stereo_quant_pred.c | 4 +- silk/structs.h | 312 +++++++-------- silk/sum_sqr_shift.c | 8 +- silk/tables.h | 102 ++--- src/opus.vcxproj | 210 +++++----- src/opus.vcxproj.filters | 142 +++---- 151 files changed, 3744 insertions(+), 4099 deletions(-) diff --git a/silk/A2NLSF.c b/silk/A2NLSF.c index 2881e8d1..a739ef34 100644 --- a/silk/A2NLSF.c +++ b/silk/A2NLSF.c @@ -43,14 +43,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define QPoly 16 #define MAX_ITERATIONS_A2NLSF_FIX 30 -/* Flag for using 2x as many cosine sampling points, reduces the risk of missing a root */ -#define OVERSAMPLE_COSINE_TABLE 0 - /* Helper function for A2NLSF(..) */ /* Transforms polynomials from cos(n*f) to cos(f)^n */ static inline void silk_A2NLSF_trans_poly( - opus_int32 *p, /* I/O Polynomial */ - const opus_int dd /* I Polynomial order (= filter order / 2 ) */ + opus_int32 *p, /* I/O Polynomial */ + const opus_int dd /* I Polynomial order (= filter order / 2 ) */ ) { opus_int k, n; @@ -62,21 +59,21 @@ static inline void silk_A2NLSF_trans_poly( p[ k - 2 ] -= silk_LSHIFT( p[ k ], 1 ); } } -/* Helper function for A2NLSF(..) */ -/* Polynomial evaluation */ -static inline opus_int32 silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */ - opus_int32 *p, /* I Polynomial, QPoly */ - const opus_int32 x, /* I Evaluation point, Q12 */ - const opus_int dd /* I Order */ +/* Helper function for A2NLSF(..) */ +/* Polynomial evaluation */ +static inline opus_int32 silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */ + opus_int32 *p, /* I Polynomial, QPoly */ + const opus_int32 x, /* I Evaluation point, Q12 */ + const opus_int dd /* I Order */ ) { opus_int n; opus_int32 x_Q16, y32; - y32 = p[ dd ]; /* QPoly */ + y32 = p[ dd ]; /* QPoly */ x_Q16 = silk_LSHIFT( x, 4 ); for( n = dd - 1; n >= 0; n-- ) { - y32 = silk_SMLAWW( p[ n ], y32, x_Q16 ); /* QPoly */ + y32 = silk_SMLAWW( p[ n ], y32, x_Q16 ); /* QPoly */ } return y32; } @@ -119,12 +116,12 @@ static inline void silk_A2NLSF_init( silk_A2NLSF_trans_poly( Q, dd ); } -/* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */ -/* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */ +/* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */ +/* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */ void silk_A2NLSF( - opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */ - opus_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */ - const opus_int d /* I Filter order (must be even) */ + opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies in Q15 (0..2^15-1) [d] */ + opus_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */ + const opus_int d /* I Filter order (must be even) */ ) { opus_int i, k, m, dd, root_ix, ffrac; @@ -145,7 +142,7 @@ void silk_A2NLSF( silk_A2NLSF_init( a_Q16, P, Q, dd ); /* Find roots, alternating between P and Q */ - p = P; /* Pointer to polynomial */ + p = P; /* Pointer to polynomial */ xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; /* Q12*/ ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); @@ -164,13 +161,7 @@ void silk_A2NLSF( thr = 0; while( 1 ) { /* Evaluate polynomial */ -#if OVERSAMPLE_COSINE_TABLE - xhi = silk_LSFCosTab_FIX_Q12[ k >> 1 ] + - ( ( silk_LSFCosTab_FIX_Q12[ ( k + 1 ) >> 1 ] - - silk_LSFCosTab_FIX_Q12[ k >> 1 ] ) >> 1 ); /* Q12 */ -#else xhi = silk_LSFCosTab_FIX_Q12[ k ]; /* Q12 */ -#endif yhi = silk_A2NLSF_eval_poly( p, xhi, dd ); /* Detect zero crossing */ @@ -183,11 +174,7 @@ void silk_A2NLSF( thr = 0; } /* Binary division */ -#if OVERSAMPLE_COSINE_TABLE - ffrac = -128; -#else ffrac = -256; -#endif for( m = 0; m < BIN_DIV_STEPS_A2NLSF_FIX; m++ ) { /* Evaluate polynomial */ xmid = silk_RSHIFT_ROUND( xlo + xhi, 1 ); @@ -202,11 +189,7 @@ void silk_A2NLSF( /* Increase frequency */ xlo = xmid; ylo = ymid; -#if OVERSAMPLE_COSINE_TABLE - ffrac = silk_ADD_RSHIFT( ffrac, 64, m ); -#else ffrac = silk_ADD_RSHIFT( ffrac, 128, m ); -#endif } } @@ -222,11 +205,7 @@ void silk_A2NLSF( /* No risk of dividing by zero because abs(ylo - yhi) >= abs(ylo) >= 65536 */ ffrac += silk_DIV32( ylo, silk_RSHIFT( ylo - yhi, 8 - BIN_DIV_STEPS_A2NLSF_FIX ) ); } -#if OVERSAMPLE_COSINE_TABLE - NLSF[ root_ix ] = (opus_int16)silk_min_32( silk_LSHIFT( (opus_int32)k, 7 ) + ffrac, silk_int16_MAX ); -#else NLSF[ root_ix ] = (opus_int16)silk_min_32( silk_LSHIFT( (opus_int32)k, 8 ) + ffrac, silk_int16_MAX ); -#endif silk_assert( NLSF[ root_ix ] >= 0 ); @@ -239,13 +218,7 @@ void silk_A2NLSF( p = PQ[ root_ix & 1 ]; /* Evaluate polynomial */ -#if OVERSAMPLE_COSINE_TABLE - xlo = silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] + - ( ( silk_LSFCosTab_FIX_Q12[ k >> 1 ] - - silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] ) >> 1 ); /* Q12*/ -#else xlo = silk_LSFCosTab_FIX_Q12[ k - 1 ]; /* Q12*/ -#endif ylo = silk_LSHIFT( 1 - ( root_ix & 2 ), 12 ); } else { /* Increment loop counter */ @@ -254,11 +227,7 @@ void silk_A2NLSF( ylo = yhi; thr = 0; -#if OVERSAMPLE_COSINE_TABLE - if( k > 2 * LSF_COS_TAB_SZ_FIX ) { -#else if( k > LSF_COS_TAB_SZ_FIX ) { -#endif i++; if( i > MAX_ITERATIONS_A2NLSF_FIX ) { /* Set NLSFs to white spectrum and exit */ diff --git a/silk/API.h b/silk/API.h index a96bd543..1bb39adc 100644 --- a/silk/API.h +++ b/silk/API.h @@ -43,9 +43,9 @@ extern "C" /* Struct for TOC (Table of Contents) */ typedef struct { - opus_int VADFlag; /* Voice activity for packet */ - opus_int VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in packet */ - opus_int inbandFECFlag; /* Flag indicating if packet contains in-band FEC */ + opus_int VADFlag; /* Voice activity for packet */ + opus_int VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in packet */ + opus_int inbandFECFlag; /* Flag indicating if packet contains in-band FEC */ } silk_TOC_struct; /****************************************/ @@ -55,24 +55,24 @@ typedef struct { /***********************************************/ /* Get size in bytes of the Silk encoder state */ /***********************************************/ -opus_int silk_Get_Encoder_Size( /* O: Returns error code */ - opus_int *encSizeBytes /* O: Number of bytes in SILK encoder state */ +opus_int silk_Get_Encoder_Size( /* O Returns error code */ + opus_int *encSizeBytes /* O Number of bytes in SILK encoder state */ ); /*************************/ /* Init or reset encoder */ /*************************/ -opus_int silk_InitEncoder( /* O: Returns error code */ - void *encState, /* I/O: State */ - silk_EncControlStruct *encStatus /* O: Encoder Status */ +opus_int silk_InitEncoder( /* O Returns error code */ + void *encState, /* I/O State */ + silk_EncControlStruct *encStatus /* O Encoder Status */ ); /***************************************/ /* Read control structure from encoder */ /***************************************/ -opus_int silk_QueryEncoder( /* O: Returns error code */ - const void *encState, /* I: State */ - silk_EncControlStruct *encStatus /* O: Encoder Status */ +opus_int silk_QueryEncoder( /* O Returns error code */ + const void *encState, /* I State */ + silk_EncControlStruct *encStatus /* O Encoder Status */ ); /**************************/ @@ -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 */ /* encControl->payloadSize_ms is set to */ -opus_int silk_Encode( /* O: Returns error code */ - void *encState, /* I/O: State */ - silk_EncControlStruct *encControl, /* I: Control status */ - const opus_int16 *samplesIn, /* I: Speech sample input vector */ - opus_int nSamplesIn, /* I: Number of samples in input vector */ - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */ - const opus_int prefillFlag /* I: Flag to indicate prefilling buffers no coding */ +opus_int silk_Encode( /* O Returns error code */ + void *encState, /* I/O State */ + silk_EncControlStruct *encControl, /* I Control status */ + const opus_int16 *samplesIn, /* I Speech sample input vector */ + opus_int nSamplesIn, /* I Number of samples in input vector */ + ec_enc *psRangeEnc, /* I/O Compressor data structure */ + opus_int *nBytesOut, /* I/O Number of bytes in payload (input: Max bytes) */ + const opus_int prefillFlag /* I Flag to indicate prefilling buffers no coding */ ); /****************************************/ @@ -97,38 +97,38 @@ opus_int silk_Encode( /* O: Returns error c /***********************************************/ /* Get size in bytes of the Silk decoder state */ /***********************************************/ -opus_int silk_Get_Decoder_Size( /* O: Returns error code */ - opus_int *decSizeBytes /* O: Number of bytes in SILK decoder state */ +opus_int silk_Get_Decoder_Size( /* O Returns error code */ + opus_int *decSizeBytes /* O Number of bytes in SILK decoder state */ ); /*************************/ /* Init or Reset decoder */ /*************************/ -opus_int silk_InitDecoder( /* O: Returns error code */ - void *decState /* I/O: State */ +opus_int silk_InitDecoder( /* O Returns error code */ + void *decState /* I/O State */ ); /******************/ /* Decode a frame */ /******************/ -opus_int silk_Decode( /* O: Returns error code */ - void* decState, /* I/O: State */ - silk_DecControlStruct* decControl, /* I/O: Control Structure */ - opus_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode fec */ - opus_int newPacketFlag, /* I: Indicates first decoder call for this packet */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 *samplesOut, /* O: Decoded output speech vector */ - opus_int32 *nSamplesOut /* O: Number of samples decoded */ +opus_int silk_Decode( /* O Returns error code */ + void* decState, /* I/O State */ + silk_DecControlStruct* decControl, /* I/O Control Structure */ + opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ + opus_int newPacketFlag, /* I Indicates first decoder call for this packet */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int16 *samplesOut, /* O Decoded output speech vector */ + opus_int32 *nSamplesOut /* O Number of samples decoded */ ); /**************************************/ /* Get table of contents for a packet */ /**************************************/ opus_int silk_get_TOC( - const opus_uint8 *payload, /* I Payload data */ - const opus_int nBytesIn, /* I: Number of input bytes */ - const opus_int nFramesPerPayload, /* I: Number of SILK frames per payload */ - silk_TOC_struct *Silk_TOC /* O: Type of content */ + const opus_uint8 *payload, /* I Payload data */ + const opus_int nBytesIn, /* I Number of input bytes */ + const opus_int nFramesPerPayload, /* I Number of SILK frames per payload */ + silk_TOC_struct *Silk_TOC /* O Type of content */ ); #ifdef __cplusplus diff --git a/silk/CNG.c b/silk/CNG.c index 0b43b865..d67e872d 100644 --- a/silk/CNG.c +++ b/silk/CNG.c @@ -60,7 +60,7 @@ static inline void silk_CNG_exc( } 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; @@ -77,10 +77,10 @@ void silk_CNG_Reset( /* Updates CNG estimate, and applies the CNG when packet was lost */ void silk_CNG( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 frame[], /* I/O Signal data */ - opus_int length /* I Length of residual */ + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ + opus_int16 frame[], /* I/O Signal */ + opus_int length /* I Length of residual */ ) { opus_int i, j, subfr; diff --git a/silk/HP_variable_cutoff.c b/silk/HP_variable_cutoff.c index c66f47bb..6eec9c1b 100644 --- a/silk/HP_variable_cutoff.c +++ b/silk/HP_variable_cutoff.c @@ -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 */ 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; diff --git a/silk/Inlines.h b/silk/Inlines.h index 765e7708..26b3b5a1 100644 --- a/silk/Inlines.h +++ b/silk/Inlines.h @@ -38,7 +38,7 @@ extern "C" #endif /* count leading zeros of opus_int64 */ -static inline opus_int32 silk_CLZ64(opus_int64 in) +static inline opus_int32 silk_CLZ64( opus_int64 in ) { opus_int32 in_upper; @@ -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 */ -static inline void silk_CLZ_FRAC(opus_int32 in, /* I: input */ - opus_int32 *lz, /* O: number of leading zeros */ - opus_int32 *frac_Q7) /* O: the 7 bits right after the leading one */ +static inline void silk_CLZ_FRAC( + opus_int32 in, /* I input */ + opus_int32 *lz, /* O number of leading zeros */ + opus_int32 *frac_Q7 /* O the 7 bits right after the leading one */ +) { opus_int32 lzeros = silk_CLZ32(in); @@ -66,7 +68,7 @@ static inline void silk_CLZ_FRAC(opus_int32 in, /* I: input */ /* Approximation of square root */ /* Accuracy: < +/- 10% for output values > 15 */ /* < +/- 2.5% for output values > 120 */ -static inline opus_int32 silk_SQRT_APPROX(opus_int32 x) +static inline opus_int32 silk_SQRT_APPROX( opus_int32 x ) { opus_int32 y, lz, frac_Q7; @@ -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 */ -static inline opus_int32 silk_DIV32_varQ( /* O returns a good approximation of "(a32 << Qres) / b32" */ - const opus_int32 a32, /* I numerator (Q0) */ - const opus_int32 b32, /* I denominator (Q0) */ - const opus_int Qres /* I Q-domain of result (>= 0) */ +static inline opus_int32 silk_DIV32_varQ( /* O returns a good approximation of "(a32 << Qres) / b32" */ + const opus_int32 a32, /* I numerator (Q0) */ + const opus_int32 b32, /* I denominator (Q0) */ + const opus_int Qres /* I Q-domain of result (>= 0) */ ) { opus_int a_headrm, b_headrm, lshift; @@ -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 */ a_headrm = silk_CLZ32( silk_abs(a32) ) - 1; - a32_nrm = silk_LSHIFT(a32, a_headrm); /* Q: a_headrm */ + a32_nrm = silk_LSHIFT(a32, a_headrm); /* Q: a_headrm */ b_headrm = silk_CLZ32( silk_abs(b32) ) - 1; - b32_nrm = silk_LSHIFT(b32, b_headrm); /* Q: b_headrm */ + b32_nrm = silk_LSHIFT(b32, b_headrm); /* Q: b_headrm */ /* Inverse of b32, with 14 bits of precision */ - b32_inv = silk_DIV32_16( silk_int32_MAX >> 2, silk_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */ + b32_inv = silk_DIV32_16( silk_int32_MAX >> 2, silk_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */ /* First approximation */ - result = silk_SMULWB(a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */ + result = silk_SMULWB(a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */ /* Compute residual by subtracting product of denominator and first approximation */ /* It's OK to overflow because the final value of a32_nrm should always be small */ - a32_nrm = silk_SUB32_ovflw(a32_nrm, silk_LSHIFT_ovflw( silk_SMMUL(b32_nrm, result), 3 )); /* Q: a_headrm */ + a32_nrm = silk_SUB32_ovflw(a32_nrm, silk_LSHIFT_ovflw( silk_SMMUL(b32_nrm, result), 3 )); /* Q: a_headrm */ /* Refinement */ - result = silk_SMLAWB(result, a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */ + result = silk_SMLAWB(result, a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */ /* Convert to Qres domain */ lshift = 29 + a_headrm - b_headrm - Qres; @@ -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 */ -static inline opus_int32 silk_INVERSE32_varQ( /* O returns a good approximation of "(1 << Qres) / b32" */ - const opus_int32 b32, /* I denominator (Q0) */ - const opus_int Qres /* I Q-domain of result (> 0) */ +static inline opus_int32 silk_INVERSE32_varQ( /* O returns a good approximation of "(1 << Qres) / b32" */ + const opus_int32 b32, /* I denominator (Q0) */ + const opus_int Qres /* I Q-domain of result (> 0) */ ) { opus_int b_headrm, lshift; @@ -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 */ b_headrm = silk_CLZ32( silk_abs(b32) ) - 1; - b32_nrm = silk_LSHIFT(b32, b_headrm); /* Q: b_headrm */ + b32_nrm = silk_LSHIFT(b32, b_headrm); /* Q: b_headrm */ /* Inverse of b32, with 14 bits of precision */ - b32_inv = silk_DIV32_16( silk_int32_MAX >> 2, silk_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */ + b32_inv = silk_DIV32_16( silk_int32_MAX >> 2, silk_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */ /* First approximation */ - result = silk_LSHIFT(b32_inv, 16); /* Q: 61 - b_headrm */ + result = silk_LSHIFT(b32_inv, 16); /* Q: 61 - b_headrm */ /* Compute residual by subtracting product of denominator and first approximation from one */ - err_Q32 = silk_LSHIFT( (1<<29) - silk_SMULWB(b32_nrm, b32_inv), 3 ); /* Q32 */ + err_Q32 = silk_LSHIFT( (1<<29) - silk_SMULWB(b32_nrm, b32_inv), 3 ); /* Q32 */ /* Refinement */ - result = silk_SMLAWW(result, err_Q32, b32_inv); /* Q: 61 - b_headrm */ + result = silk_SMLAWW(result, err_Q32, b32_inv); /* Q: 61 - b_headrm */ /* Convert to Qres domain */ lshift = 61 - b_headrm - Qres; diff --git a/silk/LPC_analysis_filter.c b/silk/LPC_analysis_filter.c index 5fc4349b..bf5c2843 100644 --- a/silk/LPC_analysis_filter.c +++ b/silk/LPC_analysis_filter.c @@ -39,11 +39,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /*******************************************/ void silk_LPC_analysis_filter( - opus_int16 *out, /* O: Output signal */ - const opus_int16 *in, /* I: Input signal */ - const opus_int16 *B, /* I: MA prediction coefficients, Q12 [order] */ - const opus_int32 len, /* I: Signal length */ - const opus_int32 d /* I: Filter order */ + opus_int16 *out, /* O Output signal */ + const opus_int16 *in, /* I Input signal */ + const opus_int16 *B, /* I MA prediction coefficients, Q12 [order] */ + const opus_int32 len, /* I Signal length */ + const opus_int32 d /* I Filter order */ ) { opus_int ix, j; @@ -54,10 +54,10 @@ void silk_LPC_analysis_filter( silk_assert( (d & 1) == 0 ); silk_assert( d <= len ); - for ( ix = d; ix < len; ix++) { + for( ix = d; ix < len; ix++ ) { in_ptr = &in[ ix - 1 ]; - out32_Q12 = silk_SMULBB( in_ptr[ 0 ], B[ 0 ] ); + out32_Q12 = silk_SMULBB( in_ptr[ 0 ], B[ 0 ] ); /* Allowing wrap around so that two wraps can cancel each other. The rare cases where the result wraps around can only be triggered by invalid streams*/ out32_Q12 = silk_SMLABB_ovflw( out32_Q12, in_ptr[ -1 ], B[ 1 ] ); diff --git a/silk/LPC_inv_pred_gain.c b/silk/LPC_inv_pred_gain.c index 3a2ff665..fb989acd 100644 --- a/silk/LPC_inv_pred_gain.c +++ b/silk/LPC_inv_pred_gain.c @@ -31,18 +31,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FIX.h" -#define QA 24 -#define A_LIMIT SILK_FIX_CONST( 0.99975, QA ) +#define QA 24 +#define A_LIMIT SILK_FIX_CONST( 0.99975, QA ) -#define MUL32_FRAC_Q(a32, b32, Q) ((opus_int32)(silk_RSHIFT_ROUND64(silk_SMULL(a32, b32), Q))) +#define MUL32_FRAC_Q(a32, b32, Q) ((opus_int32)(silk_RSHIFT_ROUND64(silk_SMULL(a32, b32), Q))) /* Compute inverse of LPC prediction gain, and */ /* test if LPC coefficients are stable (all poles within unit circle) */ -static opus_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, otherwise 0 */ - opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ - opus_int32 A_QA[ 2 ][ SILK_MAX_ORDER_LPC ], - /* I: Prediction coefficients */ - const opus_int order /* I: Prediction order */ +static opus_int LPC_inverse_pred_gain_QA( /* O Returns 1 if unstable, otherwise 0 */ + opus_int32 *invGain_Q30, /* O Inverse prediction gain, Q30 energy domain */ + opus_int32 A_QA[ 2 ][ SILK_MAX_ORDER_LPC ], /* I Prediction coefficients */ + const opus_int order /* I Prediction order */ ) { opus_int k, n, mult2Q; @@ -108,10 +107,10 @@ static opus_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, } /* For input in Q12 domain */ -opus_int silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */ - opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ - const opus_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */ - const opus_int order /* I: Prediction order */ +opus_int silk_LPC_inverse_pred_gain( /* O Returns 1 if unstable, otherwise 0 */ + opus_int32 *invGain_Q30, /* O Inverse prediction gain, Q30 energy domain */ + const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */ + const opus_int order /* I Prediction order */ ) { opus_int k; @@ -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 ); } /* If the DC is unstable, we don't even need to do the full calculations */ - if ( DC_resp >= 4096 ) { + if( DC_resp >= 4096 ) { return 1; } return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order ); } /* For input in Q24 domain */ -opus_int silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */ - opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ - const opus_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */ - const opus_int order /* I: Prediction order */ +opus_int silk_LPC_inverse_pred_gain_Q24( /* O Returns 1 if unstable, otherwise 0 */ + opus_int32 *invGain_Q30, /* O Inverse prediction gain, Q30 energy domain */ + const opus_int32 *A_Q24, /* I Prediction coefficients, Q24 [order] */ + const opus_int order /* I Prediction order */ ) { opus_int k; diff --git a/silk/LP_variable_cutoff.c b/silk/LP_variable_cutoff.c index 2ed062c6..44f541ec 100644 --- a/silk/LP_variable_cutoff.c +++ b/silk/LP_variable_cutoff.c @@ -30,12 +30,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif /* - Elliptic/Cauer filters designed with 0.1 dB passband ripple, - 80 dB minimum stopband attenuation, and - [0.95 : 0.15 : 0.35] normalized cut off frequencies. - + 80 dB minimum stopband attenuation, and + [0.95 : 0.15 : 0.35] normalized cut off frequencies. */ + #include "main.h" /* Helper function, interpolates the filter taps */ @@ -99,9 +98,9 @@ static inline void silk_LP_interpolate_filter_taps( /* Start by setting psEncC->mode <> 0; */ /* Deactivate by setting psEncC->mode = 0; */ void silk_LP_variable_cutoff( - silk_LP_state *psLP, /* I/O LP filter state */ - opus_int16 *frame, /* I/O Low-pass filtered output */ - const opus_int frame_length /* I Frame length */ + silk_LP_state *psLP, /* I/O LP filter state */ + opus_int16 *frame, /* I/O Low-pass filtered output signal */ + const opus_int frame_length /* I Frame length */ ) { opus_int32 B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ], fac_Q16 = 0; diff --git a/silk/MacroDebug.h b/silk/MacroDebug.h index 89f7f31d..e407b808 100644 --- a/silk/MacroDebug.h +++ b/silk/MacroDebug.h @@ -33,7 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if 0 && defined (_DEBUG) && !defined (silk_MACRO_COUNT) -#undef silk_ADD16 +#undef silk_ADD16 static inline opus_int16 silk_ADD16(opus_int16 a, opus_int16 b){ opus_int16 ret; @@ -42,7 +42,7 @@ static inline opus_int16 silk_ADD16(opus_int16 a, opus_int16 b){ return ret; } -#undef silk_ADD32 +#undef silk_ADD32 static inline opus_int32 silk_ADD32(opus_int32 a, opus_int32 b){ opus_int32 ret; @@ -51,7 +51,7 @@ static inline opus_int32 silk_ADD32(opus_int32 a, opus_int32 b){ return ret; } -#undef silk_ADD64 +#undef silk_ADD64 static inline opus_int64 silk_ADD64(opus_int64 a, opus_int64 b){ opus_int64 ret; @@ -60,7 +60,7 @@ static inline opus_int64 silk_ADD64(opus_int64 a, opus_int64 b){ return ret; } -#undef silk_SUB16 +#undef silk_SUB16 static inline opus_int16 silk_SUB16(opus_int16 a, opus_int16 b){ opus_int16 ret; @@ -69,7 +69,7 @@ static inline opus_int16 silk_SUB16(opus_int16 a, opus_int16 b){ return ret; } -#undef silk_SUB32 +#undef silk_SUB32 static inline opus_int32 silk_SUB32(opus_int32 a, opus_int32 b){ opus_int32 ret; @@ -78,7 +78,7 @@ static inline opus_int32 silk_SUB32(opus_int32 a, opus_int32 b){ return ret; } -#undef silk_SUB64 +#undef silk_SUB64 static inline opus_int64 silk_SUB64(opus_int64 a, opus_int64 b){ 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 */ return ret; } + #undef silk_MLA static inline opus_int32 silk_MLA(opus_int32 a32, opus_int32 b32, opus_int32 c32){ opus_int32 ret; @@ -191,14 +192,15 @@ static inline opus_int32 silk_MLA_uint(opus_uint32 a32, opus_uint32 b32, opus_ui return ret; } -#undef silk_SMULWB +#undef silk_SMULWB static inline opus_int32 silk_SMULWB(opus_int32 a32, opus_int32 b32){ opus_int32 ret; ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16); silk_assert((opus_int64)ret == ((opus_int64)a32 * (opus_int16)b32) >> 16); return ret; } -#undef silk_SMLAWB + +#undef silk_SMLAWB static inline opus_int32 silk_SMLAWB(opus_int32 a32, opus_int32 b32, opus_int32 c32){ opus_int32 ret; ret = silk_ADD32( a32, silk_SMULWB( b32, c32 ) ); @@ -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); return ret; } + #undef silk_SMLAWT static inline opus_int32 silk_SMLAWT(opus_int32 a32, opus_int32 b32, opus_int32 c32){ 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 */ -#undef silk_SMLABB +#undef silk_SMLABB static inline opus_int32 silk_SMLABB(opus_int32 a32, opus_int32 b32, opus_int32 c32){ opus_int32 ret; ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32); @@ -243,7 +246,7 @@ static inline opus_int32 silk_SMLABB(opus_int32 a32, opus_int32 b32, opus_int32 } /* no checking needed for silk_SMULBT */ -#undef silk_SMLABT +#undef silk_SMLABT static inline opus_int32 silk_SMLABT(opus_int32 a32, opus_int32 b32, opus_int32 c32){ opus_int32 ret; ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16); @@ -252,7 +255,7 @@ static inline opus_int32 silk_SMLABT(opus_int32 a32, opus_int32 b32, opus_int32 } /* no checking needed for silk_SMULTT */ -#undef silk_SMLATT +#undef silk_SMLATT static inline opus_int32 silk_SMLATT(opus_int32 a32, opus_int32 b32, opus_int32 c32){ opus_int32 ret; ret = a32 + (b32 >> 16) * (c32 >> 16); @@ -260,7 +263,7 @@ static inline opus_int32 silk_SMLATT(opus_int32 a32, opus_int32 b32, opus_int32 return ret; } -#undef silk_SMULWW +#undef silk_SMULWW static inline opus_int32 silk_SMULWW(opus_int32 a32, opus_int32 b32){ opus_int32 ret, tmp1, tmp2; opus_int64 ret64; @@ -281,7 +284,7 @@ static inline opus_int32 silk_SMULWW(opus_int32 a32, opus_int32 b32){ return ret; } -#undef silk_SMLAWW +#undef silk_SMLAWW static inline opus_int32 silk_SMLAWW(opus_int32 a32, opus_int32 b32, opus_int32 c32){ opus_int32 ret, tmp; @@ -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) */ -#undef silk_MLA_ovflw +#undef silk_MLA_ovflw #define silk_MLA_ovflw(a32, b32, c32) ((a32) + ((b32) * (c32))) -#undef silk_SMLABB_ovflw +#undef silk_SMLABB_ovflw #define silk_SMLABB_ovflw(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32))) /* no checking needed for silk_SMULL @@ -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_SAT32 no checking needed for silk_ADD_POS_SAT64 */ -#undef silk_LSHIFT8 + +#undef silk_LSHIFT8 static inline opus_int8 silk_LSHIFT8(opus_int8 a, opus_int32 shift){ opus_int8 ret; ret = a << shift; @@ -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); return ret; } -#undef silk_LSHIFT16 + +#undef silk_LSHIFT16 static inline opus_int16 silk_LSHIFT16(opus_int16 a, opus_int32 shift){ opus_int16 ret; ret = a << shift; @@ -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); return ret; } -#undef silk_LSHIFT32 + +#undef silk_LSHIFT32 static inline opus_int32 silk_LSHIFT32(opus_int32 a, opus_int32 shift){ opus_int32 ret; ret = a << shift; @@ -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); return ret; } -#undef silk_LSHIFT64 + +#undef silk_LSHIFT64 static inline opus_int64 silk_LSHIFT64(opus_int64 a, opus_int shift){ silk_assert(shift >= 0); silk_assert(shift < 64); return a << shift; } -#undef silk_LSHIFT_ovflw +#undef silk_LSHIFT_ovflw static inline opus_int32 silk_LSHIFT_ovflw(opus_int32 a, opus_int32 shift){ silk_assert(shift >= 0); /* no check for overflow */ return a << shift; } -#undef silk_LSHIFT_uint +#undef silk_LSHIFT_uint static inline opus_uint32 silk_LSHIFT_uint(opus_uint32 a, opus_int32 shift){ opus_uint32 ret; ret = a << shift; @@ -374,39 +381,42 @@ static inline opus_uint32 silk_LSHIFT_uint(opus_uint32 a, opus_int32 shift){ return ret; } -#undef silk_RSHIFT8 +#undef silk_RSHIFT8 static inline opus_int8 silk_RSHIFT8(opus_int8 a, opus_int32 shift){ silk_assert(shift >= 0); silk_assert(shift < 8); return a >> shift; } -#undef silk_RSHIFT16 + +#undef silk_RSHIFT16 static inline opus_int16 silk_RSHIFT16(opus_int16 a, opus_int32 shift){ silk_assert(shift >= 0); silk_assert(shift < 16); return a >> shift; } -#undef silk_RSHIFT32 + +#undef silk_RSHIFT32 static inline opus_int32 silk_RSHIFT32(opus_int32 a, opus_int32 shift){ silk_assert(shift >= 0); silk_assert(shift < 32); return a >> shift; } -#undef silk_RSHIFT64 + +#undef silk_RSHIFT64 static inline opus_int64 silk_RSHIFT64(opus_int64 a, opus_int64 shift){ silk_assert(shift >= 0); silk_assert(shift <= 63); return a >> shift; } -#undef silk_RSHIFT_uint +#undef silk_RSHIFT_uint static inline opus_uint32 silk_RSHIFT_uint(opus_uint32 a, opus_int32 shift){ silk_assert(shift >= 0); silk_assert(shift <= 32); return a >> shift; } -#undef silk_ADD_LSHIFT +#undef silk_ADD_LSHIFT static inline opus_int32 silk_ADD_LSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){ opus_int32 ret; silk_assert(shift >= 0); @@ -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)); return ret; /* shift >= 0 */ } -#undef silk_ADD_LSHIFT32 + +#undef silk_ADD_LSHIFT32 static inline opus_int32 silk_ADD_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ opus_int32 ret; silk_assert(shift >= 0); @@ -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)); return ret; /* shift >= 0 */ } -#undef silk_ADD_LSHIFT_uint + +#undef silk_ADD_LSHIFT_uint static inline opus_uint32 silk_ADD_LSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){ opus_uint32 ret; silk_assert(shift >= 0); @@ -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)); return ret; /* shift >= 0 */ } -#undef silk_ADD_RSHIFT + +#undef silk_ADD_RSHIFT static inline opus_int32 silk_ADD_RSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){ opus_int32 ret; silk_assert(shift >= 0); @@ -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)); return ret; /* shift > 0 */ } -#undef silk_ADD_RSHIFT32 + +#undef silk_ADD_RSHIFT32 static inline opus_int32 silk_ADD_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ opus_int32 ret; silk_assert(shift >= 0); @@ -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)); return ret; /* shift > 0 */ } -#undef silk_ADD_RSHIFT_uint + +#undef silk_ADD_RSHIFT_uint static inline opus_uint32 silk_ADD_RSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){ opus_uint32 ret; silk_assert(shift >= 0); @@ -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)); return ret; /* shift > 0 */ } -#undef silk_SUB_LSHIFT32 + +#undef silk_SUB_LSHIFT32 static inline opus_int32 silk_SUB_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ opus_int32 ret; silk_assert(shift >= 0); @@ -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)); return ret; /* shift >= 0 */ } -#undef silk_SUB_RSHIFT32 + +#undef silk_SUB_RSHIFT32 static inline opus_int32 silk_SUB_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ opus_int32 ret; silk_assert(shift >= 0); @@ -479,7 +496,7 @@ static inline opus_int32 silk_SUB_RSHIFT32(opus_int32 a, opus_int32 b, opus_int3 return ret; /* shift > 0 */ } -#undef silk_RSHIFT_ROUND +#undef silk_RSHIFT_ROUND static inline opus_int32 silk_RSHIFT_ROUND(opus_int32 a, opus_int32 shift){ opus_int32 ret; silk_assert(shift > 0); /* the marco definition can't handle a shift of zero */ @@ -489,7 +506,7 @@ static inline opus_int32 silk_RSHIFT_ROUND(opus_int32 a, opus_int32 shift){ return ret; } -#undef silk_RSHIFT_ROUND64 +#undef silk_RSHIFT_ROUND64 static inline opus_int64 silk_RSHIFT_ROUND64(opus_int64 a, opus_int32 shift){ opus_int64 ret; silk_assert(shift > 0); /* the marco definition can't handle a shift of zero */ @@ -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... */ -/*#undef silk_abs +/*#undef silk_abs static inline opus_int32 silk_abs(opus_int32 a){ silk_assert(a != 0x80000000); return (((a) > 0) ? (a) : -(a)); // Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN }*/ -#undef silk_abs_int64 +#undef silk_abs_int64 static inline opus_int64 silk_abs_int64(opus_int64 a){ silk_assert(a != 0x8000000000000000); return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */ } -#undef silk_abs_int32 +#undef silk_abs_int32 static inline opus_int32 silk_abs_int32(opus_int32 a){ silk_assert(a != 0x80000000); return abs(a); } -#undef silk_CHECK_FIT8 +#undef silk_CHECK_FIT8 static inline opus_int8 silk_CHECK_FIT8( opus_int64 a ){ opus_int8 ret; ret = (opus_int8)a; @@ -525,7 +542,7 @@ static inline opus_int8 silk_CHECK_FIT8( opus_int64 a ){ return( ret ); } -#undef silk_CHECK_FIT16 +#undef silk_CHECK_FIT16 static inline opus_int16 silk_CHECK_FIT16( opus_int64 a ){ opus_int16 ret; ret = (opus_int16)a; @@ -533,7 +550,7 @@ static inline opus_int16 silk_CHECK_FIT16( opus_int64 a ){ return( ret ); } -#undef silk_CHECK_FIT32 +#undef silk_CHECK_FIT32 static inline opus_int32 silk_CHECK_FIT32( opus_int64 a ){ opus_int32 ret; ret = (opus_int32)a; diff --git a/silk/NLSF2A.c b/silk/NLSF2A.c index d43b61de..abb73ed2 100644 --- a/silk/NLSF2A.c +++ b/silk/NLSF2A.c @@ -64,9 +64,9 @@ static inline void silk_NLSF2A_find_poly( /* compute whitening filter coefficients from normalized line spectral frequencies */ void silk_NLSF2A( - opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */ - const opus_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */ - const opus_int d /* I filter order (should be even) */ + opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */ + const opus_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */ + const opus_int d /* I filter order (should be even) */ ) { /* This ordering was found to maximize quality. It improves numerical accuracy of diff --git a/silk/NLSF_VQ.c b/silk/NLSF_VQ.c index a9d781a5..e547542d 100644 --- a/silk/NLSF_VQ.c +++ b/silk/NLSF_VQ.c @@ -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 */ void silk_NLSF_VQ( - opus_int32 err_Q26[], /* O Quantization errors [K] */ - const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */ - const opus_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */ - const opus_int K, /* I Number of codebook vectors */ - const opus_int LPC_order /* I Number of LPCs */ + opus_int32 err_Q26[], /* O Quantization errors [K] */ + const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */ + const opus_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */ + const opus_int K, /* I Number of codebook vectors */ + const opus_int LPC_order /* I Number of LPCs */ ) { opus_int i, m; diff --git a/silk/NLSF_VQ_weights_laroia.c b/silk/NLSF_VQ_weights_laroia.c index 887d3471..8e8be43c 100644 --- a/silk/NLSF_VQ_weights_laroia.c +++ b/silk/NLSF_VQ_weights_laroia.c @@ -40,9 +40,9 @@ Signal Processing, pp. 641-644, 1991. /* Laroia low complexity NLSF weights */ void silk_NLSF_VQ_weights_laroia( - opus_int16 *pNLSFW_Q_OUT, /* O: Pointer to input vector weights [D x 1] */ - const opus_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */ - const opus_int D /* I: Input vector dimension (even) */ + opus_int16 *pNLSFW_Q_OUT, /* O Pointer to input vector weights [D] */ + const opus_int16 *pNLSF_Q15, /* I Pointer to input vector [D] */ + const opus_int D /* I Input vector dimension (even) */ ) { opus_int k; diff --git a/silk/NLSF_decode.c b/silk/NLSF_decode.c index 43f4f9fc..b1b83ae9 100644 --- a/silk/NLSF_decode.c +++ b/silk/NLSF_decode.c @@ -61,9 +61,9 @@ static inline void silk_NLSF_residual_dequant( /* O Returns RD /* NLSF vector decoder */ /***********************/ void silk_NLSF_decode( - opus_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */ - opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ - const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */ + opus_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */ + opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ + const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */ ) { opus_int i; diff --git a/silk/NLSF_del_dec_quant.c b/silk/NLSF_del_dec_quant.c index 926ad7fd..d2eef3cb 100644 --- a/silk/NLSF_del_dec_quant.c +++ b/silk/NLSF_del_dec_quant.c @@ -32,17 +32,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main.h" /* Delayed-decision quantizer for NLSF residuals */ -opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ - opus_int8 indices[], /* O Quantization indices [ order ] */ - const opus_int16 x_Q10[], /* I Input [ order ] */ - const opus_int16 w_Q5[], /* I Weights [ order ] */ - const opus_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */ - const opus_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */ - const opus_uint8 ec_rates_Q5[], /* I Rates [] */ - const opus_int quant_step_size_Q16, /* I Quantization step size */ - const opus_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */ - const opus_int32 mu_Q20, /* I R/D tradeoff */ - const opus_int16 order /* I Number of input values */ +opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ + opus_int8 indices[], /* O Quantization indices [ order ] */ + const opus_int16 x_Q10[], /* I Input [ order ] */ + const opus_int16 w_Q5[], /* I Weights [ order ] */ + const opus_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */ + const opus_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */ + const opus_uint8 ec_rates_Q5[], /* I Rates [] */ + const opus_int quant_step_size_Q16, /* I Quantization step size */ + const opus_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */ + const opus_int32 mu_Q20, /* I R/D tradeoff */ + const opus_int16 order /* I Number of input values */ ) { opus_int i, j, nStates, ind_tmp, ind_min_max, ind_max_min, in_Q10, res_Q10; @@ -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 ); } } else { /* i == 0 */ - break; + break; } } diff --git a/silk/NLSF_encode.c b/silk/NLSF_encode.c index fbff0a05..cc841605 100644 --- a/silk/NLSF_encode.c +++ b/silk/NLSF_encode.c @@ -31,19 +31,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main.h" -#define STORE_LSF_DATA_FOR_TRAINING 0 - /***********************/ /* NLSF vector encoder */ /***********************/ -opus_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */ - opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ - opus_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */ - const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ - const opus_int16 *pW_QW, /* I NLSF weight vector [ LPC_ORDER ] */ - const opus_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */ - const opus_int nSurvivors, /* I Max survivors after first stage */ - const opus_int signalType /* I Signal type: 0/1/2 */ +opus_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */ + opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ + opus_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */ + const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ + const opus_int16 *pW_QW, /* I NLSF weight vector [ LPC_ORDER ] */ + const opus_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */ + const opus_int nSurvivors, /* I Max survivors after first stage */ + const opus_int signalType /* I Signal type: 0/1/2 */ ) { opus_int i, s, ind1, bestIndex, prob_Q8, bits_q7; @@ -61,15 +59,6 @@ opus_int32 silk_NLSF_encode( /* O Returns RD opus_int16 ec_ix[ MAX_LPC_ORDER ]; const opus_uint8 *pCB_element, *iCDF_ptr; -#if STORE_LSF_DATA_FOR_TRAINING - opus_int16 pNLSF_Q15_orig[MAX_LPC_ORDER ]; - DEBUG_STORE_DATA( NLSF.dat, pNLSF_Q15, psNLSF_CB->order * sizeof( opus_int16 ) ); - DEBUG_STORE_DATA( WNLSF.dat, pW_Q5, psNLSF_CB->order * sizeof( opus_int16 ) ); - DEBUG_STORE_DATA( NLSF_mu.dat, &NLSF_mu_Q20, sizeof( opus_int ) ); - DEBUG_STORE_DATA( sigType.dat, &signalType, sizeof( opus_int ) ); - silk_memcpy(pNLSF_Q15_orig, pNLSF_Q15, sizeof( pNLSF_Q15_orig )); -#endif - silk_assert( nSurvivors <= NLSF_VQ_MAX_SURVIVORS ); silk_assert( signalType >= 0 && signalType <= 2 ); silk_assert( NLSF_mu_Q20 <= 32767 && NLSF_mu_Q20 >= 0 ); @@ -135,53 +124,5 @@ opus_int32 silk_NLSF_encode( /* O Returns RD /* Decode */ silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB ); -#if STORE_LSF_DATA_FOR_TRAINING - { - /* code for training the codebooks */ - opus_int32 RD_dec_Q22, Dist_Q22_dec, Rate_Q7, diff_Q15; - ind1 = NLSFIndices[ 0 ]; - silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, ind1 ); - - pCB_element = &psNLSF_CB->CB1_NLSF_Q8[ ind1 * psNLSF_CB->order ]; - for( i = 0; i < psNLSF_CB->order; i++ ) { - NLSF_tmp_Q15[ i ] = silk_LSHIFT16( ( opus_int16 )pCB_element[ i ], 7 ); - } - silk_NLSF_VQ_weights_laroia( W_tmp_QW, NLSF_tmp_Q15, psNLSF_CB->order ); - for( i = 0; i < psNLSF_CB->order; i++ ) { - W_tmp_Q9 = silk_SQRT_APPROX( silk_LSHIFT( ( opus_int32 )W_tmp_QW[ i ], 18 - NLSF_W_Q ) ); - res_Q15[ i ] = pNLSF_Q15_orig[ i ] - NLSF_tmp_Q15[ i ]; - res_Q10[ i ] = (opus_int16)silk_RSHIFT( silk_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 ); - DEBUG_STORE_DATA( NLSF_res_q10.dat, &res_Q10[ i ], sizeof( opus_int16 ) ); - res_Q15[ i ] = pNLSF_Q15[ i ] - NLSF_tmp_Q15[ i ]; - res_Q10[ i ] = (opus_int16)silk_RSHIFT( silk_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 ); - DEBUG_STORE_DATA( NLSF_resq_q10.dat, &res_Q10[ i ], sizeof( opus_int16 ) ); - } - - Dist_Q22_dec = 0; - for( i = 0; i < psNLSF_CB->order; i++ ) { - diff_Q15 = pNLSF_Q15_orig[ i ] - pNLSF_Q15[ i ]; - Dist_Q22_dec += ( ( (diff_Q15 >> 5) * (diff_Q15 >> 5) ) * pW_Q5[ i ] ) >> 3; - } - iCDF_ptr = &psNLSF_CB->CB1_iCDF[ ( signalType >> 1 ) * psNLSF_CB->nVectors ]; - if( ind1 == 0 ) { - prob_Q8 = 256 - iCDF_ptr[ ind1 ]; - } else { - prob_Q8 = iCDF_ptr[ ind1 - 1 ] - iCDF_ptr[ ind1 ]; - } - Rate_Q7 = ( 8 << 7 ) - silk_lin2log( prob_Q8 ); - for( i = 0; i < psNLSF_CB->order; i++ ) { - Rate_Q7 += ((int)psNLSF_CB->ec_Rates_Q5[ ec_ix[ i ] + silk_LIMIT( NLSFIndices[ i + 1 ] + NLSF_QUANT_MAX_AMPLITUDE, 0, 2 * NLSF_QUANT_MAX_AMPLITUDE ) ] ) << 2; - if( silk_abs( NLSFIndices[ i + 1 ] ) >= NLSF_QUANT_MAX_AMPLITUDE ) { - Rate_Q7 += 128 << ( silk_abs( NLSFIndices[ i + 1 ] ) - NLSF_QUANT_MAX_AMPLITUDE ); - } - } - RD_dec_Q22 = Dist_Q22_dec + Rate_Q7 * NLSF_mu_Q20 >> 5; - DEBUG_STORE_DATA( dec_dist_q22.dat, &Dist_Q22_dec, sizeof( opus_int32 ) ); - DEBUG_STORE_DATA( dec_rate_q7.dat, &Rate_Q7, sizeof( opus_int32 ) ); - DEBUG_STORE_DATA( dec_rd_q22.dat, &RD_dec_Q22, sizeof( opus_int32 ) ); - } - DEBUG_STORE_DATA( NLSF_ind.dat, NLSFIndices, (psNLSF_CB->order+1) * sizeof( opus_int8 ) ); -#endif - return RD_Q25[ 0 ]; } diff --git a/silk/NLSF_stabilize.c b/silk/NLSF_stabilize.c index 1c7d60b2..d818ff08 100644 --- a/silk/NLSF_stabilize.c +++ b/silk/NLSF_stabilize.c @@ -45,9 +45,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* NLSF stabilizer, for a single input data vector */ void silk_NLSF_stabilize( - opus_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */ - const opus_int16 *NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */ - const opus_int L /* I: Number of NLSF parameters in the input vector */ + opus_int16 *NLSF_Q15, /* I/O Unstable/stabilized normalized LSF vector in Q15 [L] */ + const opus_int16 *NDeltaMin_Q15, /* I Min distance vector, NDeltaMin_Q15[L] must be >= 1 [L+1] */ + const opus_int L /* I Number of NLSF parameters in the input vector */ ) { opus_int i, I=0, k, loops; @@ -82,7 +82,7 @@ void silk_NLSF_stabilize( /***************************************************/ /* Now check if the smallest distance non-negative */ /***************************************************/ - if (min_diff_Q15 >= 0) { + if( min_diff_Q15 >= 0 ) { return; } diff --git a/silk/NLSF_unpack.c b/silk/NLSF_unpack.c index 3f4d292a..46b29403 100644 --- a/silk/NLSF_unpack.c +++ b/silk/NLSF_unpack.c @@ -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 */ void silk_NLSF_unpack( - opus_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */ - opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */ - const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ - const opus_int CB1_index /* I Index of vector in first LSF codebook */ + opus_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */ + opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */ + const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ + const opus_int CB1_index /* I Index of vector in first LSF codebook */ ) { opus_int i; diff --git a/silk/NSQ.c b/silk/NSQ.c index 6bd39eb4..031b5819 100644 --- a/silk/NSQ.c +++ b/silk/NSQ.c @@ -32,57 +32,57 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main.h" static inline void silk_nsq_scale_states( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - const opus_int16 x[], /* I input in Q0 */ - opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ - const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */ - opus_int subfr, /* I subframe number */ - const opus_int LTP_scale_Q14, /* I */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type /* I Signal type */ + const silk_encoder_state *psEncC, /* I Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + const opus_int16 x[], /* I input in Q0 */ + opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ + const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */ + opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */ + opus_int subfr, /* I subframe number */ + const opus_int LTP_scale_Q14, /* I */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ + const opus_int signal_type /* I Signal type */ ); static inline void silk_noise_shape_quantizer( - silk_nsq_state *NSQ, /* I/O NSQ state */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_sc_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q16[], /* I/O LTP state */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int shapingLPCOrder, /* I Noise shaping AR filter order */ - opus_int predictLPCOrder /* I Prediction filter order */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + opus_int signalType, /* I Signal type */ + const opus_int32 x_sc_Q10[], /* I */ + opus_int8 pulses[], /* O */ + opus_int16 xq[], /* O */ + opus_int32 sLTP_Q16[], /* I/O LTP state */ + const opus_int16 a_Q12[], /* I Short term prediction coefs */ + const opus_int16 b_Q14[], /* I Long term prediction coefs */ + const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ + opus_int lag, /* I Pitch lag */ + opus_int32 HarmShapeFIRPacked_Q14, /* I */ + opus_int Tilt_Q14, /* I Spectral tilt */ + opus_int32 LF_shp_Q14, /* I */ + opus_int32 Gain_Q16, /* I */ + opus_int Lambda_Q10, /* I */ + opus_int offset_Q10, /* I */ + opus_int length, /* I Input length */ + opus_int shapingLPCOrder, /* I Noise shaping AR filter order */ + opus_int predictLPCOrder /* I Prediction filter order */ ); void silk_NSQ( - const silk_encoder_state *psEncC, /* I/O Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x[], /* I prefiltered input signal */ - opus_int8 pulses[], /* O quantized qulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefficients */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefficients */ - const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I */ - const opus_int Lambda_Q10, /* I */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int16 x[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ ) { opus_int k, lag, start_idx, LSF_interpolation_flag; @@ -159,36 +159,31 @@ void silk_NSQ( /* Save quantized speech and noise shaping signals */ silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) ); silk_memmove( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) ); - -#ifdef SAVE_ALL_INTERNAL_DATA - DEBUG_STORE_DATA( xq.dat, &pxq[ -psEncC->frame_length ], psEncC->frame_length * sizeof( opus_int16 ) ); - DEBUG_STORE_DATA( q.dat, &pulses[ -psEncC->frame_length ], psEncC->frame_length * sizeof( opus_int8 ) ); -#endif } /***********************************/ /* silk_noise_shape_quantizer */ /***********************************/ static inline void silk_noise_shape_quantizer( - silk_nsq_state *NSQ, /* I/O NSQ state */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_sc_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q16[], /* I/O LTP state */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int shapingLPCOrder, /* I Noise shaping AR filter order */ - opus_int predictLPCOrder /* I Prediction filter order */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + opus_int signalType, /* I Signal type */ + const opus_int32 x_sc_Q10[], /* I */ + opus_int8 pulses[], /* O */ + opus_int16 xq[], /* O */ + opus_int32 sLTP_Q16[], /* I/O LTP state */ + const opus_int16 a_Q12[], /* I Short term prediction coefs */ + const opus_int16 b_Q14[], /* I Long term prediction coefs */ + const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ + opus_int lag, /* I Pitch lag */ + opus_int32 HarmShapeFIRPacked_Q14, /* I */ + opus_int Tilt_Q14, /* I Spectral tilt */ + opus_int32 LF_shp_Q14, /* I */ + opus_int32 Gain_Q16, /* I */ + opus_int Lambda_Q10, /* I */ + opus_int offset_Q10, /* I */ + opus_int length, /* I Input length */ + opus_int shapingLPCOrder, /* I Noise shaping AR filter order */ + opus_int predictLPCOrder /* I Prediction filter order */ ) { opus_int i, j; @@ -361,17 +356,17 @@ static inline void silk_noise_shape_quantizer( } static inline void silk_nsq_scale_states( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - const opus_int16 x[], /* I input in Q0 */ - opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ - const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */ - opus_int subfr, /* I subframe number */ - const opus_int LTP_scale_Q14, /* I */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type /* I Signal type */ + const silk_encoder_state *psEncC, /* I Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + const opus_int16 x[], /* I input in Q0 */ + opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ + const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */ + opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */ + opus_int subfr, /* I subframe number */ + const opus_int LTP_scale_Q14, /* I */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ + const opus_int signal_type /* I Signal type */ ) { opus_int i, lag; diff --git a/silk/NSQ_del_dec.c b/silk/NSQ_del_dec.c index b84f944d..4917ddbf 100644 --- a/silk/NSQ_del_dec.c +++ b/silk/NSQ_del_dec.c @@ -58,17 +58,17 @@ static inline void silk_nsq_del_dec_scale_states( const silk_encoder_state *psEncC, /* I Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - const opus_int16 x[], /* I Input in Q0 */ - opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ - const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */ - opus_int subfr, /* I Subframe number */ - opus_int nStatesDelayedDecision, /* I Number of del dec states */ - const opus_int LTP_scale_Q14, /* I LTP state scaling */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type, /* I Signal type */ - const opus_int decisionDelay /* I Decision delay */ + const opus_int16 x[], /* I Input in Q0 */ + opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ + const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ + opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */ + opus_int subfr, /* I Subframe number */ + opus_int nStatesDelayedDecision, /* I Number of del dec states */ + const opus_int LTP_scale_Q14, /* I LTP state scaling */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ + const opus_int signal_type, /* I Signal type */ + const opus_int decisionDelay /* I Decision delay */ ); /******************************************/ @@ -77,48 +77,48 @@ static inline void silk_nsq_del_dec_scale_states( static inline void silk_noise_shape_quantizer_del_dec( silk_nsq_state *NSQ, /* I/O NSQ state */ NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q16[], /* I/O LTP filter state */ - opus_int32 delayedGain_Q16[], /* I/O Gain delay buffer */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int subfr, /* I Subframe number */ - opus_int shapingLPCOrder, /* I Shaping LPC filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - opus_int warping_Q16, /* I */ - opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ - opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */ - opus_int decisionDelay /* I */ + opus_int signalType, /* I Signal type */ + const opus_int32 x_Q10[], /* I */ + opus_int8 pulses[], /* O */ + opus_int16 xq[], /* O */ + opus_int32 sLTP_Q16[], /* I/O LTP filter state */ + opus_int32 delayedGain_Q16[], /* I/O Gain delay buffer */ + const opus_int16 a_Q12[], /* I Short term prediction coefs */ + const opus_int16 b_Q14[], /* I Long term prediction coefs */ + const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ + opus_int lag, /* I Pitch lag */ + opus_int32 HarmShapeFIRPacked_Q14, /* I */ + opus_int Tilt_Q14, /* I Spectral tilt */ + opus_int32 LF_shp_Q14, /* I */ + opus_int32 Gain_Q16, /* I */ + opus_int Lambda_Q10, /* I */ + opus_int offset_Q10, /* I */ + opus_int length, /* I Input length */ + opus_int subfr, /* I Subframe number */ + opus_int shapingLPCOrder, /* I Shaping LPC filter order */ + opus_int predictLPCOrder, /* I Prediction filter order */ + opus_int warping_Q16, /* I */ + opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ + opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */ + opus_int decisionDelay /* I */ ); void silk_NSQ_del_dec( - const silk_encoder_state *psEncC, /* I/O Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x[], /* I Prefiltered input signal */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I LT prediction coefs */ - const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I */ - const opus_int Lambda_Q10, /* I */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int16 x[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ ) { opus_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr; @@ -285,43 +285,38 @@ void silk_NSQ_del_dec( /* Save quantized speech and noise shaping signals */ silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) ); silk_memmove( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) ); - -#ifdef SAVE_ALL_INTERNAL_DATA - DEBUG_STORE_DATA( xq.dat, &pxq[ -psEncC->frame_length ], psEncC->frame_length * sizeof( opus_int16 ) ); - DEBUG_STORE_DATA( q.dat, &pulses[ -psEncC->frame_length ], psEncC->frame_length * sizeof( opus_int8 ) ); -#endif } /******************************************/ /* Noise shape quantizer for one subframe */ /******************************************/ static inline void silk_noise_shape_quantizer_del_dec( - silk_nsq_state *NSQ, /* I/O NSQ state */ + silk_nsq_state *NSQ, /* I/O NSQ state */ NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q16[], /* I/O LTP filter state */ - opus_int32 delayedGain_Q16[], /* I/O Gain delay buffer */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int subfr, /* I Subframe number */ - opus_int shapingLPCOrder, /* I Shaping LPC filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - opus_int warping_Q16, /* I */ - opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ - opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */ - opus_int decisionDelay /* I */ + opus_int signalType, /* I Signal type */ + const opus_int32 x_Q10[], /* I */ + opus_int8 pulses[], /* O */ + opus_int16 xq[], /* O */ + opus_int32 sLTP_Q16[], /* I/O LTP filter state */ + opus_int32 delayedGain_Q16[], /* I/O Gain delay buffer */ + const opus_int16 a_Q12[], /* I Short term prediction coefs */ + const opus_int16 b_Q14[], /* I Long term prediction coefs */ + const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ + opus_int lag, /* I Pitch lag */ + opus_int32 HarmShapeFIRPacked_Q14, /* I */ + opus_int Tilt_Q14, /* I Spectral tilt */ + opus_int32 LF_shp_Q14, /* I */ + opus_int32 Gain_Q16, /* I */ + opus_int Lambda_Q10, /* I */ + opus_int offset_Q10, /* I */ + opus_int length, /* I Input length */ + opus_int subfr, /* I Subframe number */ + opus_int shapingLPCOrder, /* I Shaping LPC filter order */ + opus_int predictLPCOrder, /* I Prediction filter order */ + opus_int warping_Q16, /* I */ + opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ + opus_int *smpl_buf_idx, /* I Index to newest samples in buffers */ + opus_int decisionDelay /* I */ ) { opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx; @@ -605,17 +600,17 @@ static inline void silk_nsq_del_dec_scale_states( const silk_encoder_state *psEncC, /* I Encoder State */ silk_nsq_state *NSQ, /* I/O NSQ state */ NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - const opus_int16 x[], /* I Input in Q0 */ - opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ - const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */ - opus_int subfr, /* I Subframe number */ - opus_int nStatesDelayedDecision, /* I Number of del dec states */ - const opus_int LTP_scale_Q14, /* I LTP state scaling */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type, /* I Signal type */ - const opus_int decisionDelay /* I Decision delay */ + const opus_int16 x[], /* I Input in Q0 */ + opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ + const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ + opus_int32 sLTP_Q16[], /* O LTP state matching scaled input */ + opus_int subfr, /* I Subframe number */ + opus_int nStatesDelayedDecision, /* I Number of del dec states */ + const opus_int LTP_scale_Q14, /* I LTP state scaling */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ + const opus_int signal_type, /* I Signal type */ + const opus_int decisionDelay /* I Decision delay */ ) { opus_int i, k, lag; diff --git a/silk/PLC.c b/silk/PLC.c index 7624a918..e2ad20a4 100644 --- a/silk/PLC.c +++ b/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 inline void silk_PLC_update( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl /* I/O Decoder control */ + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl /* I/O Decoder control */ ); static inline void silk_PLC_conceal( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 signal[] /* O LPC residual signal */ + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ + opus_int16 signal[] /* O LPC residual signal */ ); void silk_PLC_Reset( - silk_decoder_state *psDec /* I/O Decoder state */ + silk_decoder_state *psDec /* I/O Decoder state */ ) { psDec->sPLC.pitchL_Q8 = silk_RSHIFT( psDec->frame_length, 1 ); } void silk_PLC( - silk_decoder_state *psDec, /* I Decoder state */ - silk_decoder_control *psDecCtrl, /* I Decoder control */ - opus_int16 frame[], /* O Concealed signal */ - opus_int lost /* I Loss flag */ + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ + opus_int16 frame[], /* I/O signal */ + opus_int lost /* I Loss flag */ ) { /* PLC control function */ @@ -88,8 +88,8 @@ void silk_PLC( /* Update state of PLC */ /**************************************************/ static inline void silk_PLC_update( - silk_decoder_state *psDec, /* (I/O) Decoder state */ - silk_decoder_control *psDecCtrl /* (I/O) Decoder control */ + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl /* I/O Decoder control */ ) { opus_int32 LTP_Gain_Q14, temp_LTP_Gain_Q14; @@ -104,7 +104,7 @@ static inline void silk_PLC_update( if( psDec->indices.signalType == TYPE_VOICED ) { /* Find the parameters for the last subframe which contains a pitch pulse */ for( j = 0; j * psDec->subfr_length < psDecCtrl->pitchL[ psDec->nb_subfr - 1 ]; j++ ) { - if( j == psDec->nb_subfr ){ + if( j == psDec->nb_subfr ) { break; } temp_LTP_Gain_Q14 = 0; @@ -160,9 +160,9 @@ static inline void silk_PLC_update( } static inline void silk_PLC_conceal( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 frame[] /* O concealed signal */ + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ + opus_int16 frame[] /* O LPC residual signal */ ) { opus_int i, j, k; @@ -344,9 +344,9 @@ static inline void silk_PLC_conceal( /* Glues concealed frames with new good recieved frames */ void silk_PLC_glue_frames( - silk_decoder_state *psDec, /* I/O decoder state */ - opus_int16 frame[], /* I/O signal */ - opus_int length /* I length of residual */ + silk_decoder_state *psDec, /* I/O decoder state */ + opus_int16 frame[], /* I/O signal */ + opus_int length /* I length of signal */ ) { opus_int i, energy_shift; diff --git a/silk/PLC.h b/silk/PLC.h index 4d985a61..c1f1e7eb 100644 --- a/silk/PLC.h +++ b/silk/PLC.h @@ -31,32 +31,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main.h" #define BWE_COEF 0.99 -#define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 in Q14 */ -#define V_PITCH_GAIN_START_MAX_Q14 15565 /* 0.95 in Q14 */ +#define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 in Q14 */ +#define V_PITCH_GAIN_START_MAX_Q14 15565 /* 0.95 in Q14 */ #define MAX_PITCH_LAG_MS 18 #define SA_THRES_Q8 50 #define USE_SINGLE_TAP 1 #define RAND_BUF_SIZE 128 -#define RAND_BUF_MASK (RAND_BUF_SIZE - 1) -#define LOG2_INV_LPC_GAIN_HIGH_THRES 3 /* 2^3 = 8 dB LPC gain */ -#define LOG2_INV_LPC_GAIN_LOW_THRES 8 /* 2^8 = 24 dB LPC gain */ -#define PITCH_DRIFT_FAC_Q16 655 /* 0.01 in Q16 */ +#define RAND_BUF_MASK ( RAND_BUF_SIZE - 1 ) +#define LOG2_INV_LPC_GAIN_HIGH_THRES 3 /* 2^3 = 8 dB LPC gain */ +#define LOG2_INV_LPC_GAIN_LOW_THRES 8 /* 2^8 = 24 dB LPC gain */ +#define PITCH_DRIFT_FAC_Q16 655 /* 0.01 in Q16 */ void silk_PLC_Reset( - silk_decoder_state *psDec /* I/O Decoder state */ + silk_decoder_state *psDec /* I/O Decoder state */ ); void silk_PLC( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 signal[], /* I/O signal */ - opus_int lost /* I Loss flag */ + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ + opus_int16 frame[], /* I/O signal */ + opus_int lost /* I Loss flag */ ); void silk_PLC_glue_frames( - silk_decoder_state *psDec, /* I/O decoder state */ - opus_int16 signal[], /* I/O signal */ - opus_int length /* I length of signal */ + silk_decoder_state *psDec, /* I/O decoder state */ + opus_int16 frame[], /* I/O signal */ + opus_int length /* I length of signal */ ); #endif diff --git a/silk/SigProc_FIX.h b/silk/SigProc_FIX.h index d24eac6f..a80ac97e 100644 --- a/silk/SigProc_FIX.h +++ b/silk/SigProc_FIX.h @@ -35,10 +35,10 @@ extern "C" /*#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 /* for abs() */ -#include /* for memset(), memcpy(), memmove() */ +#include /* for abs() */ +#include /* for memset(), memcpy(), memmove() */ #include "typedef.h" #include "resampler_structs.h" #include "macros.h" @@ -52,39 +52,39 @@ extern "C" * Initialize/reset the resampler state for a given pair of input/output sampling rates */ opus_int silk_resampler_init( - silk_resampler_state_struct *S, /* I/O: Resampler state */ - opus_int32 Fs_Hz_in, /* I: Input sampling rate (Hz) */ - opus_int32 Fs_Hz_out /* I: Output sampling rate (Hz) */ + silk_resampler_state_struct *S, /* I/O Resampler state */ + opus_int32 Fs_Hz_in, /* I Input sampling rate (Hz) */ + opus_int32 Fs_Hz_out /* I Output sampling rate (Hz) */ ); /*! * Resampler: convert from one sampling rate to another */ opus_int silk_resampler( - silk_resampler_state_struct *S, /* I/O: Resampler state */ - opus_int16 out[], /* O: Output signal */ - const opus_int16 in[], /* I: Input signal */ - opus_int32 inLen /* I: Number of input samples */ + silk_resampler_state_struct *S, /* I/O Resampler state */ + opus_int16 out[], /* O Output signal */ + const opus_int16 in[], /* I Input signal */ + opus_int32 inLen /* I Number of input samples */ ); /*! * Downsample 2x, mediocre quality */ void silk_resampler_down2( - opus_int32 *S, /* I/O: State vector [ 2 ] */ - opus_int16 *out, /* O: Output signal [ len ] */ - const opus_int16 *in, /* I: Input signal [ floor(len/2) ] */ - opus_int32 inLen /* I: Number of input samples */ + opus_int32 *S, /* I/O State vector [ 2 ] */ + opus_int16 *out, /* O Output signal [ len ] */ + const opus_int16 *in, /* I Input signal [ floor(len/2) ] */ + opus_int32 inLen /* I Number of input samples */ ); /*! * Downsample by a factor 2/3, low quality */ void silk_resampler_down2_3( - opus_int32 *S, /* I/O: State vector [ 6 ] */ - opus_int16 *out, /* O: Output signal [ floor(2*inLen/3) ] */ - const opus_int16 *in, /* I: Input signal [ inLen ] */ - opus_int32 inLen /* I: Number of input samples */ + opus_int32 *S, /* I/O State vector [ 6 ] */ + opus_int16 *out, /* O Output signal [ floor(2*inLen/3) ] */ + const opus_int16 *in, /* I Input signal [ inLen ] */ + opus_int32 inLen /* I Number of input samples */ ); /*! @@ -93,268 +93,269 @@ void silk_resampler_down2_3( * can handle (slowly) varying coefficients */ void silk_biquad_alt( - const opus_int16 *in, /* I: input signal */ - const opus_int32 *B_Q28, /* I: MA coefficients [3] */ - const opus_int32 *A_Q28, /* I: AR coefficients [2] */ - opus_int32 *S, /* I/O: State vector [2] */ - opus_int16 *out, /* O: output signal */ - const opus_int32 len, /* I: signal length (must be even) */ - opus_int stride /* I: Operate on interleaved signal if > 1 */ + const opus_int16 *in, /* I input signal */ + const opus_int32 *B_Q28, /* I MA coefficients [3] */ + const opus_int32 *A_Q28, /* I AR coefficients [2] */ + opus_int32 *S, /* I/O State vector [2] */ + opus_int16 *out, /* O output signal */ + const opus_int32 len, /* I signal length (must be even) */ + opus_int stride /* I Operate on interleaved signal if > 1 */ ); /* Variable order MA prediction error filter. */ void silk_LPC_analysis_filter( - opus_int16 *out, /* O: Output signal */ - const opus_int16 *in, /* I: Input signal */ - const opus_int16 *B, /* I: MA prediction coefficients, Q12 [order] */ - const opus_int32 len, /* I: Signal length */ - const opus_int32 Order /* I: Filter order */ + opus_int16 *out, /* O Output signal */ + const opus_int16 *in, /* I Input signal */ + const opus_int16 *B, /* I MA prediction coefficients, Q12 [order] */ + const opus_int32 len, /* I Signal length */ + const opus_int32 d /* I Filter order */ ); /* Chirp (bandwidth expand) LP AR filter */ void silk_bwexpander( - opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I Length of ar */ - opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ + opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ + const opus_int d, /* I Length of ar */ + opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ ); /* Chirp (bandwidth expand) LP AR filter */ void silk_bwexpander_32( - opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I Length of ar */ - opus_int32 chirp_Q16 /* I Chirp factor in Q16 */ + opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ + const opus_int d, /* I Length of ar */ + opus_int32 chirp_Q16 /* I Chirp factor in Q16 */ ); /* Compute inverse of LPC prediction gain, and */ /* test if LPC coefficients are stable (all poles within unit circle) */ -opus_int silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */ - opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ - const opus_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */ - const opus_int order /* I: Prediction order */ +opus_int silk_LPC_inverse_pred_gain( /* O Returns 1 if unstable, otherwise 0 */ + opus_int32 *invGain_Q30, /* O Inverse prediction gain, Q30 energy domain */ + const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */ + const opus_int order /* I Prediction order */ ); -opus_int silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */ - opus_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ - const opus_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */ - const opus_int order /* I: Prediction order */ +opus_int silk_LPC_inverse_pred_gain_Q24( /* O Returns 1 if unstable, otherwise 0 */ + opus_int32 *invGain_Q30, /* O Inverse prediction gain, Q30 energy domain */ + const opus_int32 *A_Q24, /* I Prediction coefficients, Q24 [order] */ + const opus_int order /* I Prediction order */ ); -/* split signal in two decimated bands using first-order allpass filters */ +/* Split signal in two decimated bands using first-order allpass filters */ void silk_ana_filt_bank_1( - const opus_int16 *in, /* I: Input signal [N] */ - opus_int32 *S, /* I/O: State vector [2] */ - opus_int16 *outL, /* O: Low band [N/2] */ - opus_int16 *outH, /* O: High band [N/2] */ - const opus_int32 N /* I: Number of input samples */ + const opus_int16 *in, /* I Input signal [N] */ + opus_int32 *S, /* I/O State vector [2] */ + opus_int16 *outL, /* O Low band [N/2] */ + opus_int16 *outH, /* O High band [N/2] */ + const opus_int32 N /* I Number of input samples */ ); /********************************************************************/ /* SCALAR FUNCTIONS */ /********************************************************************/ -/* approximation of 128 * log2() (exact inverse of approx 2^() below) */ -/* convert input to a log scale */ -opus_int32 silk_lin2log(const opus_int32 inLin); /* I: input in linear scale */ +/* Approximation of 128 * log2() (exact inverse of approx 2^() below) */ +/* Convert input to a log scale */ +opus_int32 silk_lin2log( + const opus_int32 inLin /* I input in linear scale */ +); /* Approximation of a sigmoid function */ -opus_int silk_sigm_Q15(opus_int in_Q5); +opus_int silk_sigm_Q15( + opus_int in_Q5 /* I */ +); -/* approximation of 2^() (exact inverse of approx log2() above) */ -/* convert input to a linear scale */ -opus_int32 silk_log2lin(const opus_int32 inLog_Q7); /* I: input on log scale */ +/* Approximation of 2^() (exact inverse of approx log2() above) */ +/* Convert input to a linear scale */ +opus_int32 silk_log2lin( + const opus_int32 inLog_Q7 /* I input on log scale */ +); /* Function that returns the maximum absolut value of the input vector */ -opus_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */ - const opus_int16 *vec, /* I Input vector [len] */ - const opus_int32 len /* I Length of input vector */ +opus_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */ + const opus_int16 *vec, /* I Input vector [len] */ + const opus_int32 len /* I Length of input vector */ ); /* Compute number of bits to right shift the sum of squares of a vector */ /* of int16s to make it fit in an int32 */ void silk_sum_sqr_shift( - opus_int32 *energy, /* O Energy of x, after shifting to the right */ - opus_int *shift, /* O Number of bits right shift applied to energy */ - const opus_int16 *x, /* I Input vector */ - opus_int len /* I Length of input vector */ + opus_int32 *energy, /* O Energy of x, after shifting to the right */ + opus_int *shift, /* O Number of bits right shift applied to energy */ + const opus_int16 *x, /* I Input vector */ + opus_int len /* I Length of input vector */ ); /* Calculates the reflection coefficients from the correlation sequence */ /* Faster than schur64(), but much less accurate. */ /* uses SMLAWB(), requiring armv5E and higher. */ -opus_int32 silk_schur( /* O: Returns residual energy */ - opus_int16 *rc_Q15, /* O: reflection coefficients [order] Q15 */ - const opus_int32 *c, /* I: correlations [order+1] */ - const opus_int32 order /* I: prediction order */ +opus_int32 silk_schur( /* O Returns residual energy */ + opus_int16 *rc_Q15, /* O reflection coefficients [order] Q15 */ + const opus_int32 *c, /* I correlations [order+1] */ + const opus_int32 order /* I prediction order */ ); /* Calculates the reflection coefficients from the correlation sequence */ /* Slower than schur(), but more accurate. */ /* Uses SMULL(), available on armv4 */ -opus_int32 silk_schur64( /* O: returns residual energy */ - opus_int32 rc_Q16[], /* O: Reflection coefficients [order] Q16 */ - const opus_int32 c[], /* I: Correlations [order+1] */ - opus_int32 order /* I: Prediction order */ +opus_int32 silk_schur64( /* O returns residual energy */ + opus_int32 rc_Q16[], /* O Reflection coefficients [order] Q16 */ + const opus_int32 c[], /* I Correlations [order+1] */ + opus_int32 order /* I Prediction order */ ); /* Step up function, converts reflection coefficients to prediction coefficients */ void silk_k2a( - opus_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ - const opus_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */ - const opus_int32 order /* I: Prediction order */ + opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */ + const opus_int16 *rc_Q15, /* I Reflection coefficients [order] Q15 */ + const opus_int32 order /* I Prediction order */ ); /* Step up function, converts reflection coefficients to prediction coefficients */ void silk_k2a_Q16( - opus_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ - const opus_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */ - const opus_int32 order /* I: Prediction order */ + opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */ + const opus_int32 *rc_Q16, /* I Reflection coefficients [order] Q16 */ + const opus_int32 order /* I Prediction order */ ); -/* Apply sine window to signal vector. */ -/* Window types: */ -/* 1 -> sine window from 0 to pi/2 */ -/* 2 -> sine window from pi/2 to pi */ -/* every other sample of window is linearly interpolated, for speed */ +/* Apply sine window to signal vector. */ +/* Window types: */ +/* 1 -> sine window from 0 to pi/2 */ +/* 2 -> sine window from pi/2 to pi */ +/* every other sample of window is linearly interpolated, for speed */ void silk_apply_sine_window( - opus_int16 px_win[], /* O Pointer to windowed signal */ - const opus_int16 px[], /* I Pointer to input signal */ - const opus_int win_type, /* I Selects a window type */ - const opus_int length /* I Window length, multiple of 4 */ + opus_int16 px_win[], /* O Pointer to windowed signal */ + const opus_int16 px[], /* I Pointer to input signal */ + const opus_int win_type, /* I Selects a window type */ + const opus_int length /* I Window length, multiple of 4 */ ); /* Compute autocorrelation */ void silk_autocorr( - opus_int32 *results, /* O Result (length correlationCount) */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *inputData, /* I Input data to correlate */ - const opus_int inputDataSize, /* I Length of input */ - const opus_int correlationCount /* I Number of correlation taps to compute */ + opus_int32 *results, /* O Result (length correlationCount) */ + opus_int *scale, /* O Scaling of the correlation vector */ + const opus_int16 *inputData, /* I Input data to correlate */ + const opus_int inputDataSize, /* I Length of input */ + const opus_int correlationCount /* I Number of correlation taps to compute */ ); -/* Pitch estimator */ -#define SILK_PE_MIN_COMPLEX 0 -#define SILK_PE_MID_COMPLEX 1 -#define SILK_PE_MAX_COMPLEX 2 - void silk_decode_pitch( - opus_int16 lagIndex, /* I */ - opus_int8 contourIndex, /* O */ - opus_int pitch_lags[], /* O 4 pitch values */ - const opus_int Fs_kHz, /* I sampling frequency (kHz) */ - const opus_int nb_subfr /* I number of sub frames */ -); - -opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */ - const opus_int16 *signal, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ - opus_int *pitch_out, /* O 4 pitch lag values */ - opus_int16 *lagIndex, /* O Lag Index */ - opus_int8 *contourIndex, /* O Pitch contour Index */ - opus_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */ - opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ - const opus_int32 search_thres1_Q16, /* I First stage threshold for lag candidates 0 - 1 */ - const opus_int search_thres2_Q15, /* I Final threshold for lag candidates 0 - 1 */ - const opus_int Fs_kHz, /* I Sample frequency (kHz) */ - const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */ - const opus_int nb_subfr /* I number of 5 ms subframes */ + opus_int16 lagIndex, /* I */ + opus_int8 contourIndex, /* O */ + opus_int pitch_lags[], /* O 4 pitch values */ + const opus_int Fs_kHz, /* I sampling frequency (kHz) */ + const opus_int nb_subfr /* I number of sub frames */ +); + +opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */ + const opus_int16 *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ + opus_int *pitch_out, /* O 4 pitch lag values */ + opus_int16 *lagIndex, /* O Lag Index */ + opus_int8 *contourIndex, /* O Pitch contour Index */ + opus_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */ + opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ + const opus_int32 search_thres1_Q16, /* I First stage threshold for lag candidates 0 - 1 */ + const opus_int search_thres2_Q15, /* I Final threshold for lag candidates 0 - 1 */ + const opus_int Fs_kHz, /* I Sample frequency (kHz) */ + const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */ + const opus_int nb_subfr /* I number of 5 ms subframes */ ); /* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */ /* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */ void silk_A2NLSF( - opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */ - opus_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */ - const opus_int d /* I Filter order (must be even) */ + opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies in Q15 (0..2^15-1) [d] */ + opus_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */ + const opus_int d /* I Filter order (must be even) */ ); /* compute whitening filter coefficients from normalized line spectral frequencies */ void silk_NLSF2A( - opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */ - const opus_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */ - const opus_int d /* I filter order (should be even) */ + opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */ + const opus_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */ + const opus_int d /* I filter order (should be even) */ ); void silk_insertion_sort_increasing( - opus_int32 *a, /* I/O Unsorted / Sorted vector */ - opus_int *idx, /* O: Index vector for the sorted elements */ - const opus_int L, /* I: Vector length */ - const opus_int K /* I: Number of correctly sorted positions */ + opus_int32 *a, /* I/O Unsorted / Sorted vector */ + opus_int *idx, /* O Index vector for the sorted elements */ + const opus_int L, /* I Vector length */ + const opus_int K /* I Number of correctly sorted positions */ ); void silk_insertion_sort_decreasing_int16( - opus_int16 *a, /* I/O: Unsorted / Sorted vector */ - opus_int *idx, /* O: Index vector for the sorted elements */ - const opus_int L, /* I: Vector length */ - const opus_int K /* I: Number of correctly sorted positions */ + opus_int16 *a, /* I/O Unsorted / Sorted vector */ + opus_int *idx, /* O Index vector for the sorted elements */ + const opus_int L, /* I Vector length */ + const opus_int K /* I Number of correctly sorted positions */ ); void silk_insertion_sort_increasing_all_values_int16( - opus_int16 *a, /* I/O: Unsorted / Sorted vector */ - const opus_int L /* I: Vector length */ + opus_int16 *a, /* I/O Unsorted / Sorted vector */ + const opus_int L /* I Vector length */ ); /* NLSF stabilizer, for a single input data vector */ void silk_NLSF_stabilize( - opus_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */ - const opus_int16 *NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */ - const opus_int L /* I: Number of NLSF parameters in the input vector */ + opus_int16 *NLSF_Q15, /* I/O Unstable/stabilized normalized LSF vector in Q15 [L] */ + const opus_int16 *NDeltaMin_Q15, /* I Min distance vector, NDeltaMin_Q15[L] must be >= 1 [L+1] */ + const opus_int L /* I Number of NLSF parameters in the input vector */ ); /* Laroia low complexity NLSF weights */ void silk_NLSF_VQ_weights_laroia( - opus_int16 *pNLSFW_Q_OUT, /* O: Pointer to input vector weights [D x 1] */ - const opus_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */ - const opus_int D /* I: Input vector dimension (even) */ + opus_int16 *pNLSFW_Q_OUT, /* O Pointer to input vector weights [D] */ + const opus_int16 *pNLSF_Q15, /* I Pointer to input vector [D] */ + const opus_int D /* I Input vector dimension (even) */ ); /* Compute reflection coefficients from input signal */ void silk_burg_modified( - opus_int32 *res_nrg, /* O residual energy */ - opus_int *res_nrgQ, /* O residual energy Q value */ - opus_int32 A_Q16[], /* O prediction coefficients (length order) */ - const opus_int16 x[], /* I input signal, length: nb_subfr * ( D + subfr_length ) */ - const opus_int subfr_length, /* I input signal subframe length (including D preceeding samples) */ - const opus_int nb_subfr, /* I number of subframes stacked in x */ - const opus_int32 WhiteNoiseFrac_Q32, /* I fraction added to zero-lag autocorrelation */ - const opus_int D /* I order */ + opus_int32 *res_nrg, /* O Residual energy */ + opus_int *res_nrg_Q, /* O Residual energy Q value */ + opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ + const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ + const opus_int subfr_length, /* I Input signal subframe length (incl. D preceeding samples) */ + const opus_int nb_subfr, /* I Number of subframes stacked in x */ + const opus_int32 WhiteNoiseFrac_Q32, /* I Fraction added to zero-lag autocorrelation */ + const opus_int D /* I Order */ ); /* Copy and multiply a vector by a constant */ void silk_scale_copy_vector16( - opus_int16 *data_out, - const opus_int16 *data_in, - opus_int32 gain_Q16, /* I: gain in Q16 */ - const opus_int dataSize /* I: length */ + opus_int16 *data_out, + const opus_int16 *data_in, + opus_int32 gain_Q16, /* I Gain in Q16 */ + const opus_int dataSize /* I Length */ ); /* Some for the LTP related function requires Q26 to work.*/ void silk_scale_vector32_Q26_lshift_18( - opus_int32 *data1, /* I/O: Q0/Q18 */ - opus_int32 gain_Q26, /* I: Q26 */ - opus_int dataSize /* I: length */ + opus_int32 *data1, /* I/O Q0/Q18 */ + opus_int32 gain_Q26, /* I Q26 */ + opus_int dataSize /* I length */ ); /********************************************************************/ -/* INLINE ARM MATH */ +/* INLINE ARM MATH */ /********************************************************************/ -/* return sum(inVec1[i]*inVec2[i]) */ +/* return sum( inVec1[i] * inVec2[i] ) */ opus_int32 silk_inner_prod_aligned( - const opus_int16 *const inVec1, /* I input vector 1 */ - const opus_int16 *const inVec2, /* I input vector 2 */ - const opus_int len /* I vector lengths */ + const opus_int16 *const inVec1, /* I input vector 1 */ + const opus_int16 *const inVec2, /* I input vector 2 */ + const opus_int len /* I vector lengths */ ); opus_int32 silk_inner_prod_aligned_scale( - const opus_int16 *const inVec1, /* I input vector 1 */ - const opus_int16 *const inVec2, /* I input vector 2 */ - const opus_int scale, /* I number of bits to shift */ - const opus_int len /* I vector lengths */ + const opus_int16 *const inVec1, /* I input vector 1 */ + const opus_int16 *const inVec2, /* I input vector 2 */ + const opus_int scale, /* I number of bits to shift */ + const opus_int len /* I vector lengths */ ); opus_int64 silk_inner_prod16_aligned_64( - const opus_int16 *inVec1, /* I input vector 1 */ - const opus_int16 *inVec2, /* I input vector 2 */ - const opus_int len /* I vector lengths */ + const opus_int16 *inVec1, /* I input vector 1 */ + const opus_int16 *inVec2, /* I input vector 2 */ + const opus_int len /* I vector lengths */ ); /********************************************************************/ @@ -370,12 +371,13 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot ) opus_uint32 x = (opus_uint32) a32; opus_uint32 r = (opus_uint32) rot; opus_uint32 m = (opus_uint32) -rot; - if (rot==0) - return a32; - else if(rot < 0) + if( rot == 0 ) { + return a32; + } else if( rot < 0 ) { return (opus_int32) ((x << m) | (x >> (32 - m))); - else + } else { return (opus_int32) ((x << (32 - r)) | (x >> r)); + } } /* Allocate opus_int16 alligned to 4-byte memory address */ @@ -386,10 +388,11 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot ) #endif /* Useful Macros that can be adjusted to other platforms */ -#define silk_memcpy(a, b, c) memcpy((a), (b), (c)) /* Dest, Src, ByteCount */ -#define silk_memset(a, b, c) memset((a), (b), (c)) /* Dest, value, ByteCount */ -#define silk_memmove(a, b, c) memmove((a), (b), (c)) /* Dest, Src, ByteCount */ -/* fixed point macros */ +#define silk_memcpy(a, b, c) memcpy((a), (b), (c)) /* Dest, Src, ByteCount */ +#define silk_memset(a, b, c) memset((a), (b), (c)) /* Dest, value, ByteCount */ +#define silk_memmove(a, b, c) memmove((a), (b), (c)) /* Dest, Src, ByteCount */ + +/* Fixed point macros */ /* (a32 * b32) output have to be 32bit int */ #define silk_MUL(a32, b32) ((a32) * (b32)) @@ -421,14 +424,9 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot ) (just standard two's complement implementation-specific behaviour) */ #define silk_SUB32_ovflw(a, b) ((opus_int32)((opus_uint32)(a) - (opus_uint32)(b))) -/* a32 + (opus_int32)((opus_int16)(b32)) * (opus_int32)((opus_int16)(c32)) output have to be 32bit int */ -#define silk_SMLABB_ovflw(a32, b32, c32) (silk_ADD32_ovflw((a32) , ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32)))) - -/* Multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode)*/ +/* Multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode) */ #define silk_MLA_ovflw(a32, b32, c32) silk_ADD32_ovflw((a32), (opus_uint32)(b32) * (opus_uint32)(c32)) -#ifndef silk_SMLABB_ovflw -# define silk_SMLABB_ovflw(a32, b32, c32) silk_ADD32_ovflw((a32), (opus_int32)((opus_int16)(b32)) * (opus_int32)((opus_int16)(c32))) -#endif +#define silk_SMLABB_ovflw(a32, b32, c32) (silk_ADD32_ovflw((a32) , ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32)))) #define silk_DIV32_16(a32, b16) ((opus_int32)((a32) / (b16))) #define silk_DIV32(a32, b32) ((opus_int32)((a32) / (b32))) @@ -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_SUB64(a, b) ((a) - (b)) -#define silk_SAT8(a) ((a) > silk_int8_MAX ? silk_int8_MAX : \ - ((a) < silk_int8_MIN ? silk_int8_MIN : (a))) -#define silk_SAT16(a) ((a) > silk_int16_MAX ? silk_int16_MAX : \ - ((a) < silk_int16_MIN ? silk_int16_MIN : (a))) -#define silk_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : \ - ((a) < silk_int32_MIN ? silk_int32_MIN : (a))) +#define silk_SAT8(a) ((a) > silk_int8_MAX ? silk_int8_MAX : \ + ((a) < silk_int8_MIN ? silk_int8_MIN : (a))) +#define silk_SAT16(a) ((a) > silk_int16_MAX ? silk_int16_MAX : \ + ((a) < silk_int16_MIN ? silk_int16_MIN : (a))) +#define silk_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : \ + ((a) < silk_int32_MIN ? silk_int32_MIN : (a))) #define silk_CHECK_FIT8(a) (a) #define silk_CHECK_FIT16(a) (a) @@ -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_SAT64(a, b) ((((a) + (b)) & 0x8000000000000000LL) == 0 ? \ - ((((a) & (b)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a)+(b)) : \ - ((((a) | (b)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a)+(b)) ) + ((((a) & (b)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a)+(b)) : \ + ((((a) | (b)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a)+(b)) ) #define silk_SUB_SAT16(a, b) (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a), (b) ) ) -#define silk_SUB_SAT64(a, b) ((((a)-(b)) & 0x8000000000000000LL) == 0 ? \ - (( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a)-(b)) : \ - ((((a)^0x8000000000000000LL) & (b) & 0x8000000000000000LL) ? silk_int64_MAX : (a)-(b)) ) +#define silk_SUB_SAT64(a, b) ((((a)-(b)) & 0x8000000000000000LL) == 0 ? \ + (( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a)-(b)) : \ + ((((a)^0x8000000000000000LL) & (b) & 0x8000000000000000LL) ? silk_int64_MAX : (a)-(b)) ) /* Saturation for positive input values */ #define silk_POS_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : (a)) @@ -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_SAT64(a, b) ((((a)+(b)) & 0x8000000000000000LL) ? silk_int64_MAX : ((a)+(b))) -#define silk_LSHIFT8(a, shift) ((opus_int8)((opus_uint8)(a)<<(shift))) /* shift >= 0, shift < 8 */ -#define silk_LSHIFT16(a, shift) ((opus_int16)((opus_uint16)(a)<<(shift))) /* shift >= 0, shift < 16 */ -#define silk_LSHIFT32(a, shift) ((opus_int32)((opus_uint32)(a)<<(shift))) /* shift >= 0, shift < 32 */ -#define silk_LSHIFT64(a, shift) ((opus_int64)((opus_uint64)(a)<<(shift))) /* shift >= 0, shift < 64 */ -#define silk_LSHIFT(a, shift) silk_LSHIFT32(a, shift) /* shift >= 0, shift < 32 */ +#define silk_LSHIFT8(a, shift) ((opus_int8)((opus_uint8)(a)<<(shift))) /* shift >= 0, shift < 8 */ +#define silk_LSHIFT16(a, shift) ((opus_int16)((opus_uint16)(a)<<(shift))) /* shift >= 0, shift < 16 */ +#define silk_LSHIFT32(a, shift) ((opus_int32)((opus_uint32)(a)<<(shift))) /* shift >= 0, shift < 32 */ +#define silk_LSHIFT64(a, shift) ((opus_int64)((opus_uint64)(a)<<(shift))) /* shift >= 0, shift < 64 */ +#define silk_LSHIFT(a, shift) silk_LSHIFT32(a, shift) /* shift >= 0, shift < 32 */ -#define silk_RSHIFT8(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 8 */ -#define silk_RSHIFT16(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 16 */ -#define silk_RSHIFT32(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 32 */ -#define silk_RSHIFT64(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 64 */ -#define silk_RSHIFT(a, shift) silk_RSHIFT32(a, shift) /* shift >= 0, shift < 32 */ +#define silk_RSHIFT8(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 8 */ +#define silk_RSHIFT16(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 16 */ +#define silk_RSHIFT32(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 32 */ +#define silk_RSHIFT64(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 64 */ +#define silk_RSHIFT(a, shift) silk_RSHIFT32(a, shift) /* shift >= 0, shift < 32 */ /* saturates before shifting */ -#define silk_LSHIFT_SAT16(a, shift) (silk_LSHIFT16( silk_LIMIT( (a), silk_RSHIFT16( silk_int16_MIN, (shift) ), \ - silk_RSHIFT16( silk_int16_MAX, (shift) ) ), (shift) )) -#define silk_LSHIFT_SAT32(a, shift) (silk_LSHIFT32( silk_LIMIT( (a), silk_RSHIFT32( silk_int32_MIN, (shift) ), \ - silk_RSHIFT32( silk_int32_MAX, (shift) ) ), (shift) )) - -#define silk_LSHIFT_ovflw(a, shift) ((opus_int32)((opus_uint32)(a)<<(shift))) /* shift >= 0, allowed to overflow */ -#define silk_LSHIFT_uint(a, shift) ((a)<<(shift)) /* shift >= 0 */ -#define silk_RSHIFT_uint(a, shift) ((a)>>(shift)) /* shift >= 0 */ - -#define silk_ADD_LSHIFT(a, b, shift) ((a) + silk_LSHIFT((b), (shift))) /* shift >= 0 */ -#define silk_ADD_LSHIFT32(a, b, shift) silk_ADD32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */ -#define silk_ADD_LSHIFT_uint(a, b, shift) ((a) + silk_LSHIFT_uint((b), (shift))) /* shift >= 0 */ -#define silk_ADD_RSHIFT(a, b, shift) ((a) + silk_RSHIFT((b), (shift))) /* shift >= 0 */ -#define silk_ADD_RSHIFT32(a, b, shift) silk_ADD32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */ -#define silk_ADD_RSHIFT_uint(a, b, shift) ((a) + silk_RSHIFT_uint((b), (shift))) /* shift >= 0 */ -#define silk_SUB_LSHIFT32(a, b, shift) silk_SUB32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */ -#define silk_SUB_RSHIFT32(a, b, shift) silk_SUB32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */ +#define silk_LSHIFT_SAT16(a, shift) (silk_LSHIFT16( silk_LIMIT( (a), silk_RSHIFT16( silk_int16_MIN, (shift) ), \ + silk_RSHIFT16( silk_int16_MAX, (shift) ) ), (shift) )) +#define silk_LSHIFT_SAT32(a, shift) (silk_LSHIFT32( silk_LIMIT( (a), silk_RSHIFT32( silk_int32_MIN, (shift) ), \ + silk_RSHIFT32( silk_int32_MAX, (shift) ) ), (shift) )) + +#define silk_LSHIFT_ovflw(a, shift) ((opus_int32)((opus_uint32)(a) << (shift))) /* shift >= 0, allowed to overflow */ +#define silk_LSHIFT_uint(a, shift) ((a) << (shift)) /* shift >= 0 */ +#define silk_RSHIFT_uint(a, shift) ((a) >> (shift)) /* shift >= 0 */ + +#define silk_ADD_LSHIFT(a, b, shift) ((a) + silk_LSHIFT((b), (shift))) /* shift >= 0 */ +#define silk_ADD_LSHIFT32(a, b, shift) silk_ADD32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */ +#define silk_ADD_LSHIFT_uint(a, b, shift) ((a) + silk_LSHIFT_uint((b), (shift))) /* shift >= 0 */ +#define silk_ADD_RSHIFT(a, b, shift) ((a) + silk_RSHIFT((b), (shift))) /* shift >= 0 */ +#define silk_ADD_RSHIFT32(a, b, shift) silk_ADD32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */ +#define silk_ADD_RSHIFT_uint(a, b, shift) ((a) + silk_RSHIFT_uint((b), (shift))) /* shift >= 0 */ +#define silk_SUB_LSHIFT32(a, b, shift) silk_SUB32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */ +#define silk_SUB_RSHIFT32(a, b, shift) silk_SUB32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */ /* Requires that shift > 0 */ -#define silk_RSHIFT_ROUND(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1) -#define silk_RSHIFT_ROUND64(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1) +#define silk_RSHIFT_ROUND(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1) +#define silk_RSHIFT_ROUND64(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1) /* Number of rightshift required to fit the multiplication */ -#define silk_NSHIFT_MUL_32_32(a, b) ( -(31- (32-silk_CLZ32(silk_abs(a)) + (32-silk_CLZ32(silk_abs(b))))) ) -#define silk_NSHIFT_MUL_16_16(a, b) ( -(15- (16-silk_CLZ16(silk_abs(a)) + (16-silk_CLZ16(silk_abs(b))))) ) +#define silk_NSHIFT_MUL_32_32(a, b) ( -(31- (32-silk_CLZ32(silk_abs(a)) + (32-silk_CLZ32(silk_abs(b))))) ) +#define silk_NSHIFT_MUL_16_16(a, b) ( -(15- (16-silk_CLZ16(silk_abs(a)) + (16-silk_CLZ16(silk_abs(b))))) ) -#define silk_min(a, b) (((a) < (b)) ? (a) : (b)) -#define silk_max(a, b) (((a) > (b)) ? (a) : (b)) +#define silk_min(a, b) (((a) < (b)) ? (a) : (b)) +#define silk_max(a, b) (((a) > (b)) ? (a) : (b)) /* Macro to convert floating-point constants to fixed-point */ -#define SILK_FIX_CONST( C, Q ) ((opus_int32)((C) * ((opus_int64)1 << (Q)) + 0.5)) +#define SILK_FIX_CONST( C, Q ) ((opus_int32)((C) * ((opus_int64)1 << (Q)) + 0.5)) /* silk_min() versions with typecast in the function call */ static inline opus_int silk_min_int(opus_int a, opus_int b) @@ -554,38 +552,36 @@ static inline opus_int64 silk_max_64(opus_int64 a, opus_int64 b) return (((a) > (b)) ? (a) : (b)); } -#define silk_LIMIT( a, limit1, limit2) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \ - : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a)))) - -#define silk_LIMIT_int silk_LIMIT -#define silk_LIMIT_16 silk_LIMIT -#define silk_LIMIT_32 silk_LIMIT +#define silk_LIMIT( a, limit1, limit2) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \ + : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a)))) -/*#define silk_non_neg(a) ((a) & ((-(a)) >> (8 * sizeof(a) - 1)))*/ /* doesn't seem faster than silk_max(0, a);*/ +#define silk_LIMIT_int silk_LIMIT +#define silk_LIMIT_16 silk_LIMIT +#define silk_LIMIT_32 silk_LIMIT -#define silk_abs(a) (((a) > 0) ? (a) : -(a)) /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */ -#define silk_abs_int(a) (((a) ^ ((a) >> (8 * sizeof(a) - 1))) - ((a) >> (8 * sizeof(a) - 1))) -#define silk_abs_int32(a) (((a) ^ ((a) >> 31)) - ((a) >> 31)) -#define silk_abs_int64(a) (((a) > 0) ? (a) : -(a)) +#define silk_abs(a) (((a) > 0) ? (a) : -(a)) /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */ +#define silk_abs_int(a) (((a) ^ ((a) >> (8 * sizeof(a) - 1))) - ((a) >> (8 * sizeof(a) - 1))) +#define silk_abs_int32(a) (((a) ^ ((a) >> 31)) - ((a) >> 31)) +#define silk_abs_int64(a) (((a) > 0) ? (a) : -(a)) -#define silk_sign(a) ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 )) +#define silk_sign(a) ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 )) -#define silk_sqrt(a) (sqrt(a)) +#define silk_sqrt(a) (sqrt(a)) /* PSEUDO-RANDOM GENERATOR */ /* Make sure to store the result as the seed for the next call (also in between */ /* frames), otherwise result won't be random at all. When only using some of the */ /* bits, take the most significant bits by right-shifting. */ -#define silk_RAND(seed) (silk_MLA_ovflw(907633515, (seed), 196314165)) +#define silk_RAND(seed) (silk_MLA_ovflw(907633515, (seed), 196314165)) /* Add some multiplication functions that can be easily mapped to ARM. */ /* silk_SMMUL: Signed top word multiply. ARMv6 2 instruction cycles. - ARMv3M+ 3 instruction cycles. use SMULL and ignore LSB registers.(except xM)*/ -/*#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT(silk_SMLAL(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16)), 16)*/ + ARMv3M+ 3 instruction cycles. use SMULL and ignore LSB registers.(except xM)*/ +/*#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT(silk_SMLAL(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16)), 16)*/ /* the following seems faster on x86 */ -#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT64(silk_SMULL((a32), (b32)), 32) +#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT64(silk_SMULL((a32), (b32)), 32) #include "Inlines.h" #include "MacroCount.h" diff --git a/silk/VAD.c b/silk/VAD.c index 5b13b903..1f7e5643 100644 --- a/silk/VAD.c +++ b/silk/VAD.c @@ -41,8 +41,8 @@ static inline void silk_VAD_GetNoiseLevels( /**********************************/ /* Initialization of the Silk VAD */ /**********************************/ -opus_int silk_VAD_Init( /* O Return value, 0 if success */ - silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ +opus_int silk_VAD_Init( /* O Return value, 0 if success */ + silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ ) { opus_int b, ret = 0; @@ -77,9 +77,9 @@ static const opus_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -120 /***************************************/ /* Get the speech activity level in Q8 */ /***************************************/ -opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ - silk_encoder_state *psEncC, /* I/O Encoder state */ - const opus_int16 pIn[] /* I PCM input */ +opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ + silk_encoder_state *psEncC, /* I/O Encoder state */ + const opus_int16 pIn[] /* I PCM input */ ) { opus_int SA_Q15, pSNR_dB_Q7, input_tilt; @@ -271,7 +271,7 @@ opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if /* Noise level estimation */ /**************************/ static inline void silk_VAD_GetNoiseLevels( - const opus_int32 pX[ VAD_N_BANDS ], /* I subband energies */ + const opus_int32 pX[ VAD_N_BANDS ], /* I subband energies */ silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ ) { diff --git a/silk/VQ_WMat_EC.c b/silk/VQ_WMat_EC.c index 5397d86f..4505a861 100644 --- a/silk/VQ_WMat_EC.c +++ b/silk/VQ_WMat_EC.c @@ -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 */ void silk_VQ_WMat_EC( - opus_int8 *ind, /* O index of best codebook vector */ - opus_int32 *rate_dist_Q14, /* O best weighted quantization error + mu * rate*/ - const opus_int16 *in_Q14, /* I input vector to be quantized */ - const opus_int32 *W_Q18, /* I weighting matrix */ - const opus_int8 *cb_Q7, /* I codebook */ - const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ - const opus_int mu_Q9, /* I tradeoff between weighted error and rate */ - opus_int L /* I number of vectors in codebook */ + opus_int8 *ind, /* O index of best codebook vector */ + opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */ + const opus_int16 *in_Q14, /* I input vector to be quantized */ + const opus_int32 *W_Q18, /* I weighting matrix */ + const opus_int8 *cb_Q7, /* I codebook */ + const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ + const opus_int mu_Q9, /* I tradeoff betw. weighted error and rate */ + opus_int L /* I number of vectors in codebook */ ) { opus_int k; diff --git a/silk/ana_filt_bank_1.c b/silk/ana_filt_bank_1.c index a3f93fbf..bad630e6 100644 --- a/silk/ana_filt_bank_1.c +++ b/silk/ana_filt_bank_1.c @@ -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 */ void silk_ana_filt_bank_1( - const opus_int16 *in, /* I: Input signal [N] */ - opus_int32 *S, /* I/O: State vector [2] */ - opus_int16 *outL, /* O: Low band [N/2] */ - opus_int16 *outH, /* O: High band [N/2] */ - const opus_int32 N /* I: Number of input samples */ + const opus_int16 *in, /* I Input signal [N] */ + opus_int32 *S, /* I/O State vector [2] */ + opus_int16 *outL, /* O Low band [N/2] */ + opus_int16 *outH, /* O High band [N/2] */ + const opus_int32 N /* I Number of input samples */ ) { opus_int k, N2 = silk_RSHIFT( N, 1 ); diff --git a/silk/biquad_alt.c b/silk/biquad_alt.c index 74a66a5c..91a75b65 100644 --- a/silk/biquad_alt.c +++ b/silk/biquad_alt.c @@ -38,16 +38,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FIX.h" - /* Second order ARMA filter, alternative implementation */ void silk_biquad_alt( - const opus_int16 *in, /* I: Input signal */ - const opus_int32 *B_Q28, /* I: MA coefficients [3] */ - const opus_int32 *A_Q28, /* I: AR coefficients [2] */ - opus_int32 *S, /* I/O: State vector [2] */ - opus_int16 *out, /* O: Output signal */ - const opus_int32 len, /* I: Signal length (must be even) */ - opus_int stride /* I: Operate on interleaved signal if > 1 */ + const opus_int16 *in, /* I input signal */ + const opus_int32 *B_Q28, /* I MA coefficients [3] */ + const opus_int32 *A_Q28, /* I AR coefficients [2] */ + opus_int32 *S, /* I/O State vector [2] */ + opus_int16 *out, /* O output signal */ + const opus_int32 len, /* I signal length (must be even) */ + opus_int stride /* I Operate on interleaved signal if > 1 */ ) { /* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */ @@ -56,9 +55,9 @@ void silk_biquad_alt( /* Negate A_Q28 values and split in two parts */ A0_L_Q28 = ( -A_Q28[ 0 ] ) & 0x00003FFF; /* lower part */ - A0_U_Q28 = silk_RSHIFT( -A_Q28[ 0 ], 14 ); /* upper part */ + A0_U_Q28 = silk_RSHIFT( -A_Q28[ 0 ], 14 ); /* upper part */ A1_L_Q28 = ( -A_Q28[ 1 ] ) & 0x00003FFF; /* lower part */ - A1_U_Q28 = silk_RSHIFT( -A_Q28[ 1 ], 14 ); /* upper part */ + A1_U_Q28 = silk_RSHIFT( -A_Q28[ 1 ], 14 ); /* upper part */ for( k = 0; k < len; k++ ) { /* S[ 0 ], S[ 1 ]: Q12 */ diff --git a/silk/bwexpander.c b/silk/bwexpander.c index ab74272d..279a9852 100644 --- a/silk/bwexpander.c +++ b/silk/bwexpander.c @@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Chirp (bandwidth expand) LP AR filter */ void silk_bwexpander( - opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I Length of ar */ - opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ + opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ + const opus_int d, /* I Length of ar */ + opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ ) { opus_int i; diff --git a/silk/bwexpander_32.c b/silk/bwexpander_32.c index 4bac1c68..24963621 100644 --- a/silk/bwexpander_32.c +++ b/silk/bwexpander_32.c @@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Chirp (bandwidth expand) LP AR filter */ void silk_bwexpander_32( - opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I Length of ar */ - opus_int32 chirp_Q16 /* I Chirp factor in Q16 */ + opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ + const opus_int d, /* I Length of ar */ + opus_int32 chirp_Q16 /* I Chirp factor in Q16 */ ) { opus_int i; diff --git a/silk/check_control_input.c b/silk/check_control_input.c index 0a8d7269..35888c9a 100644 --- a/silk/check_control_input.c +++ b/silk/check_control_input.c @@ -35,7 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Check encoder control struct */ opus_int check_control_input( - silk_EncControlStruct *encControl /* I: Control structure */ + silk_EncControlStruct *encControl /* I Control structure */ ) { silk_assert( encControl != NULL ); diff --git a/silk/code_signs.c b/silk/code_signs.c index 02a3aeb3..c0b940ad 100644 --- a/silk/code_signs.c +++ b/silk/code_signs.c @@ -40,11 +40,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Encodes signs of excitation */ void silk_encode_signs( ec_enc *psRangeEnc, /* I/O Compressor data structure */ - const opus_int8 pulses[], /* I pulse signal */ - opus_int length, /* I length of input */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I Quantization offset type */ - const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ + const opus_int8 pulses[], /* I pulse signal */ + opus_int length, /* I length of input */ + const opus_int signalType, /* I Signal type */ + const opus_int quantOffsetType, /* I Quantization offset type */ + const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ ) { opus_int i, j, p; @@ -74,11 +74,11 @@ void silk_encode_signs( /* Decodes signs of excitation */ void silk_decode_signs( ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int pulses[], /* I/O pulse signal */ - opus_int length, /* I length of input */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I Quantization offset type */ - const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ + opus_int pulses[], /* I/O pulse signal */ + opus_int length, /* I length of input */ + const opus_int signalType, /* I Signal type */ + const opus_int quantOffsetType, /* I Quantization offset type */ + const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ ) { opus_int i, j, p; diff --git a/silk/control.h b/silk/control.h index 47afecf6..a29c9ccf 100644 --- a/silk/control.h +++ b/silk/control.h @@ -83,13 +83,13 @@ typedef struct { /* I: Flag to use constant bitrate */ opus_int useCBR; - /* I: Maximum number of bits allowed for the frame */ + /* I: Maximum number of bits allowed for the frame */ opus_int maxBits; - /* I: Causes a smooth downmix to mono */ + /* I: Causes a smooth downmix to mono */ opus_int toMono; - /* I: Opus encoder is allowing us to switch bandwidth */ + /* I: Opus encoder is allowing us to switch bandwidth */ opus_int opusCanSwitch; /* O: Internal sampling rate used, in Hertz; 8000/12000/16000 */ @@ -104,7 +104,7 @@ typedef struct { /* O: Stereo width */ opus_int stereoWidth_Q14; - /* O: Tells the Opus encoder we're ready to switch */ + /* O: Tells the Opus encoder we're ready to switch */ opus_int switchReady; } silk_EncControlStruct; diff --git a/silk/control_SNR.c b/silk/control_SNR.c index 3c65fd72..3dbafb0c 100644 --- a/silk/control_SNR.c +++ b/silk/control_SNR.c @@ -34,8 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Control SNR of redidual quantizer */ opus_int silk_control_SNR( - silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ - opus_int32 TargetRate_bps /* I Target max bitrate (bps) */ + silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ + opus_int32 TargetRate_bps /* I Target max bitrate (bps) */ ) { opus_int k, ret = SILK_NO_ERROR; diff --git a/silk/control_audio_bandwidth.c b/silk/control_audio_bandwidth.c index e551e9d6..a8541f6e 100644 --- a/silk/control_audio_bandwidth.c +++ b/silk/control_audio_bandwidth.c @@ -34,8 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Control internal sampling rate */ opus_int silk_control_audio_bandwidth( - silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ - silk_EncControlStruct *encControl /* I: Control structure */ + silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ + silk_EncControlStruct *encControl /* I Control structure */ ) { opus_int fs_kHz; @@ -71,7 +71,7 @@ opus_int silk_control_audio_bandwidth( /* Reset transition filter state */ silk_memset( psEncC->sLP.In_LP_State, 0, sizeof( psEncC->sLP.In_LP_State ) ); } - if (encControl->opusCanSwitch) { + if( encControl->opusCanSwitch ) { /* Stop transition phase */ psEncC->sLP.mode = 0; @@ -91,7 +91,7 @@ opus_int silk_control_audio_bandwidth( if( silk_SMULBB( psEncC->fs_kHz, 1000 ) < psEncC->desiredInternal_fs_Hz ) { /* Switch up */ - if (encControl->opusCanSwitch) { + if( encControl->opusCanSwitch ) { /* Switch to a higher sample frequency */ fs_kHz = psEncC->fs_kHz == 8 ? 12 : 16; @@ -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; } diff --git a/silk/control_codec.c b/silk/control_codec.c index 418be4d9..829b08f7 100644 --- a/silk/control_codec.c +++ b/silk/control_codec.c @@ -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 #endif #include "tuning_parameters.h" - +#include "pitch_est_defines.h" static const opus_int enc_delay_matrix[3][5] = { /*SILK API 8 12 16 24 48 */ @@ -47,34 +47,34 @@ static const opus_int enc_delay_matrix[3][5] = { opus_int silk_setup_resamplers( silk_encoder_state_Fxx *psEnc, /* I/O */ - opus_int fs_kHz /* I */ + opus_int fs_kHz /* I */ ); opus_int silk_setup_fs( silk_encoder_state_Fxx *psEnc, /* I/O */ - opus_int fs_kHz, /* I */ - opus_int PacketSize_ms /* I */ + opus_int fs_kHz, /* I */ + opus_int PacketSize_ms /* I */ ); opus_int silk_setup_complexity( silk_encoder_state *psEncC, /* I/O */ - opus_int Complexity /* I */ + opus_int Complexity /* I */ ); static inline opus_int silk_setup_LBRR( silk_encoder_state *psEncC, /* I/O */ - const opus_int32 TargetRate_bps /* I */ + const opus_int32 TargetRate_bps /* I */ ); /* Control encoder */ opus_int silk_control_encoder( - silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */ - silk_EncControlStruct *encControl, /* I: Control structure */ - const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */ - const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ - const opus_int channelNb, /* I Channel number */ - const opus_int force_fs_kHz + silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */ + silk_EncControlStruct *encControl, /* I Control structure */ + const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */ + const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ + const opus_int channelNb, /* I Channel number */ + const opus_int force_fs_kHz ) { opus_int fs_kHz, ret = 0; @@ -105,8 +105,9 @@ opus_int silk_control_encoder( /* Determine internal sampling rate */ /********************************************/ fs_kHz = silk_control_audio_bandwidth( &psEnc->sCmn, encControl ); - if (force_fs_kHz) + if( force_fs_kHz ) { fs_kHz = force_fs_kHz; + } /********************************************/ /* Prepare resampler and buffered data */ /********************************************/ @@ -194,8 +195,8 @@ opus_int silk_setup_resamplers( opus_int silk_setup_fs( silk_encoder_state_Fxx *psEnc, /* I/O */ - opus_int fs_kHz, /* I */ - opus_int PacketSize_ms /* I */ + opus_int fs_kHz, /* I */ + opus_int PacketSize_ms /* I */ ) { opus_int ret = SILK_NO_ERROR; @@ -310,7 +311,7 @@ opus_int silk_setup_fs( opus_int silk_setup_complexity( silk_encoder_state *psEncC, /* I/O */ - opus_int Complexity /* I */ + opus_int Complexity /* I */ ) { opus_int ret = 0; @@ -392,7 +393,7 @@ opus_int silk_setup_complexity( static inline opus_int silk_setup_LBRR( silk_encoder_state *psEncC, /* I/O */ - const opus_int32 TargetRate_bps /* I */ + const opus_int32 TargetRate_bps /* I */ ) { opus_int ret = SILK_NO_ERROR; diff --git a/silk/create_init_destroy.c b/silk/create_init_destroy.c index ead74280..f744bc6e 100644 --- a/silk/create_init_destroy.c +++ b/silk/create_init_destroy.c @@ -31,12 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main.h" - /************************/ /* Init Decoder State */ /************************/ opus_int silk_init_decoder( - silk_decoder_state *psDec /* I/O Decoder state pointer */ + silk_decoder_state *psDec /* I/O Decoder state pointer */ ) { /* Clear the entire encoder state, except anything copied */ diff --git a/silk/debug.c b/silk/debug.c index b8a31b33..5dfcaa9a 100644 --- a/silk/debug.c +++ b/silk/debug.c @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif -unsigned long silk_GetHighResolutionTime(void) /* O: time in usec*/ +unsigned long silk_GetHighResolutionTime(void) /* O time in usec*/ { /* Returns a time counter in microsec */ /* the resolution is platform dependent */ @@ -54,7 +54,7 @@ unsigned long silk_GetHighResolutionTime(void) /* O: time in usec*/ return (unsigned long)((1000000*(lpPerformanceCount.QuadPart)) / lpFrequency.QuadPart); } #else /* Linux or Mac*/ -unsigned long GetHighResolutionTime(void) /* O: time in usec*/ +unsigned long GetHighResolutionTime(void) /* O time in usec*/ { struct timeval tv; gettimeofday(&tv, 0); diff --git a/silk/debug.h b/silk/debug.h index e48f55d7..a3ea5cd2 100644 --- a/silk/debug.h +++ b/silk/debug.h @@ -41,7 +41,7 @@ extern "C" { #endif -unsigned long GetHighResolutionTime(void); /* O: time in usec*/ +unsigned long GetHighResolutionTime(void); /* O time in usec*/ /* make SILK_DEBUG dependent on compiler's _DEBUG */ #if defined _WIN32 @@ -62,7 +62,8 @@ unsigned long GetHighResolutionTime(void); /* O: time in usec*/ #endif /* Flag for using timers */ -#define SILK_TIC_TOC 0 +#define SILK_TIC_TOC 0 + #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) */ /* */ -/* 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); @@ -104,10 +105,10 @@ extern LARGE_INTEGER silk_Timer_start[silk_NUM_TIMERS_MAX]; extern unsigned long silk_Timer_start[silk_NUM_TIMERS_MAX]; #endif extern unsigned int silk_Timer_cnt[silk_NUM_TIMERS_MAX]; -extern opus_int64 silk_Timer_sum[silk_NUM_TIMERS_MAX]; -extern opus_int64 silk_Timer_max[silk_NUM_TIMERS_MAX]; -extern opus_int64 silk_Timer_min[silk_NUM_TIMERS_MAX]; -extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX]; +extern opus_int64 silk_Timer_sum[silk_NUM_TIMERS_MAX]; +extern opus_int64 silk_Timer_max[silk_NUM_TIMERS_MAX]; +extern opus_int64 silk_Timer_min[silk_NUM_TIMERS_MAX]; +extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX]; /* WARNING: TIC()/TOC can measure only up to 0.1 seconds at a time */ #ifdef _WIN32 @@ -118,25 +119,25 @@ extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX]; { \ int k; \ init = 1; \ - for( k = 0; k < silk_Timer_nTimers; k++ ) { \ - if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ + for( k = 0; k < silk_Timer_nTimers; k++ ) { \ + if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ ID = k; \ break; \ } \ } \ if (ID == -1) { \ - ID = silk_Timer_nTimers; \ - silk_Timer_nTimers++; \ - silk_Timer_depth[ID] = silk_Timer_depth_ctr; \ - strcpy(silk_Timer_tags[ID], #TAG_NAME); \ - silk_Timer_cnt[ID] = 0; \ - silk_Timer_sum[ID] = 0; \ - silk_Timer_min[ID] = 0xFFFFFFFF; \ - silk_Timer_max[ID] = 0; \ + ID = silk_Timer_nTimers; \ + silk_Timer_nTimers++; \ + silk_Timer_depth[ID] = silk_Timer_depth_ctr; \ + strcpy(silk_Timer_tags[ID], #TAG_NAME); \ + silk_Timer_cnt[ID] = 0; \ + silk_Timer_sum[ID] = 0; \ + silk_Timer_min[ID] = 0xFFFFFFFF; \ + silk_Timer_max[ID] = 0; \ } \ } \ - silk_Timer_depth_ctr++; \ - QueryPerformanceCounter(&silk_Timer_start[ID]); \ + silk_Timer_depth_ctr++; \ + QueryPerformanceCounter(&silk_Timer_start[ID]); \ } #else #define TIC(TAG_NAME) { \ @@ -146,25 +147,25 @@ extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX]; { \ int k; \ init = 1; \ - for( k = 0; k < silk_Timer_nTimers; k++ ) { \ - if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ + for( k = 0; k < silk_Timer_nTimers; k++ ) { \ + if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ ID = k; \ break; \ } \ } \ if (ID == -1) { \ - ID = silk_Timer_nTimers; \ - silk_Timer_nTimers++; \ - silk_Timer_depth[ID] = silk_Timer_depth_ctr; \ - strcpy(silk_Timer_tags[ID], #TAG_NAME); \ - silk_Timer_cnt[ID] = 0; \ - silk_Timer_sum[ID] = 0; \ - silk_Timer_min[ID] = 0xFFFFFFFF; \ - silk_Timer_max[ID] = 0; \ + ID = silk_Timer_nTimers; \ + silk_Timer_nTimers++; \ + silk_Timer_depth[ID] = silk_Timer_depth_ctr; \ + strcpy(silk_Timer_tags[ID], #TAG_NAME); \ + silk_Timer_cnt[ID] = 0; \ + silk_Timer_sum[ID] = 0; \ + silk_Timer_min[ID] = 0xFFFFFFFF; \ + silk_Timer_max[ID] = 0; \ } \ } \ - silk_Timer_depth_ctr++; \ - silk_Timer_start[ID] = GetHighResolutionTime(); \ + silk_Timer_depth_ctr++; \ + silk_Timer_start[ID] = GetHighResolutionTime(); \ } #endif @@ -177,25 +178,25 @@ extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX]; { \ int k; \ init = 1; \ - for( k = 0; k < silk_Timer_nTimers; k++ ) { \ - if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ + for( k = 0; k < silk_Timer_nTimers; k++ ) { \ + if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ ID = k; \ break; \ } \ } \ } \ QueryPerformanceCounter(&lpPerformanceCount); \ - lpPerformanceCount.QuadPart -= silk_Timer_start[ID].QuadPart; \ + lpPerformanceCount.QuadPart -= silk_Timer_start[ID].QuadPart; \ if((lpPerformanceCount.QuadPart < 100000000) && \ (lpPerformanceCount.QuadPart >= 0)) { \ - silk_Timer_cnt[ID]++; \ - silk_Timer_sum[ID] += lpPerformanceCount.QuadPart; \ - if( lpPerformanceCount.QuadPart > silk_Timer_max[ID] ) \ - silk_Timer_max[ID] = lpPerformanceCount.QuadPart; \ - if( lpPerformanceCount.QuadPart < silk_Timer_min[ID] ) \ - silk_Timer_min[ID] = lpPerformanceCount.QuadPart; \ + silk_Timer_cnt[ID]++; \ + silk_Timer_sum[ID] += lpPerformanceCount.QuadPart; \ + if( lpPerformanceCount.QuadPart > silk_Timer_max[ID] ) \ + silk_Timer_max[ID] = lpPerformanceCount.QuadPart; \ + if( lpPerformanceCount.QuadPart < silk_Timer_min[ID] ) \ + silk_Timer_min[ID] = lpPerformanceCount.QuadPart; \ } \ - silk_Timer_depth_ctr--; \ + silk_Timer_depth_ctr--; \ } #else #define TOC(TAG_NAME) { \ @@ -206,25 +207,25 @@ extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX]; { \ int k; \ init = 1; \ - for( k = 0; k < silk_Timer_nTimers; k++ ) { \ - if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ + for( k = 0; k < silk_Timer_nTimers; k++ ) { \ + if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ ID = k; \ break; \ } \ } \ } \ endTime = GetHighResolutionTime(); \ - endTime -= silk_Timer_start[ID]; \ + endTime -= silk_Timer_start[ID]; \ if((endTime < 100000000) && \ (endTime >= 0)) { \ - silk_Timer_cnt[ID]++; \ - silk_Timer_sum[ID] += endTime; \ - if( endTime > silk_Timer_max[ID] ) \ - silk_Timer_max[ID] = endTime; \ - if( endTime < silk_Timer_min[ID] ) \ - silk_Timer_min[ID] = endTime; \ + silk_Timer_cnt[ID]++; \ + silk_Timer_sum[ID] += endTime; \ + if( endTime > silk_Timer_max[ID] ) \ + silk_Timer_max[ID] = endTime; \ + if( endTime < silk_Timer_min[ID] ) \ + silk_Timer_min[ID] = endTime; \ } \ - silk_Timer_depth_ctr--; \ + silk_Timer_depth_ctr--; \ } #endif @@ -238,45 +239,22 @@ extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX]; #endif /* SILK_TIC_TOC */ - #if SILK_DEBUG /************************************/ /* write data to file for debugging */ /************************************/ -/* opens an empty file if this file has not yet been open, then writes to the file and closes it */ -/* if file has been open previously it is opened again and the fwrite is appending, finally it is closed */ -#define SAVE_DATA( FILE_NAME, DATA_PTR, N_BYTES ) { \ - static opus_int32 init = 0; \ - FILE *fp; \ - if (init == 0) { \ - init = 1; \ - fp = fopen(#FILE_NAME, "wb"); \ - } else { \ - fp = fopen(#FILE_NAME, "ab+"); \ - } \ - fwrite((DATA_PTR), (N_BYTES), 1, fp); \ - fclose(fp); \ -} - /* Example: DEBUG_STORE_DATA(testfile.pcm, &RIN[0], 160*sizeof(opus_int16)); */ -#if 0 -/* Ensure that everything is written to files when an assert breaks */ -#define DEBUG_STORE_DATA(FILE_NAME, DATA_PTR, N_BYTES) SAVE_DATA(FILE_NAME, DATA_PTR, N_BYTES) -#define SILK_DEBUG_STORE_CLOSE_FILES - -#else - #define silk_NUM_STORES_MAX 100 extern FILE *silk_debug_store_fp[ silk_NUM_STORES_MAX ]; extern int silk_debug_store_count; /* Faster way of storing the data */ #define DEBUG_STORE_DATA( FILE_NAME, DATA_PTR, N_BYTES ) { \ - static opus_int init = 0, cnt = 0; \ + static opus_int init = 0, cnt = 0; \ static FILE **fp; \ if (init == 0) { \ - init = 1; \ + init = 1; \ cnt = silk_debug_store_count++; \ silk_debug_store_fp[ cnt ] = fopen(#FILE_NAME, "wb"); \ } \ @@ -285,12 +263,11 @@ extern int silk_debug_store_count; /* Call this at the end of main() */ #define SILK_DEBUG_STORE_CLOSE_FILES { \ - opus_int i; \ + opus_int i; \ for( i = 0; i < silk_debug_store_count; i++ ) { \ fclose( silk_debug_store_fp[ i ] ); \ } \ } -#endif /* micro sec */ #define silk_GETTIME(void) time = (opus_int64) silk_GetHighResolutionTime(); @@ -299,7 +276,6 @@ extern int silk_debug_store_count; /* define macros as empty strings */ #define DEBUG_STORE_DATA(FILE_NAME, DATA_PTR, N_BYTES) -#define SAVE_DATA(FILE_NAME, DATA_PTR, N_BYTES) #define SILK_DEBUG_STORE_CLOSE_FILES #endif /* SILK_DEBUG */ diff --git a/silk/dec_API.c b/silk/dec_API.c index 58cf59a8..9fe62d9b 100644 --- a/silk/dec_API.c +++ b/silk/dec_API.c @@ -46,7 +46,9 @@ typedef struct { /* 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; @@ -56,8 +58,8 @@ opus_int silk_Get_Decoder_Size( int *decSizeBytes ) } /* Reset decoder state */ -opus_int silk_InitDecoder( - void* decState /* I/O: State */ +opus_int silk_InitDecoder( /* O Returns error code */ + void *decState /* I/O State */ ) { opus_int n, ret = SILK_NO_ERROR; @@ -71,14 +73,14 @@ opus_int silk_InitDecoder( } /* Decode a frame */ -opus_int silk_Decode( - void* decState, /* I/O: State */ - silk_DecControlStruct* decControl, /* I/O: Control Structure */ - opus_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode FEC */ - opus_int newPacketFlag, /* I: Indicates first decoder call for this packet */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 *samplesOut, /* O: Decoded output speech vector */ - opus_int32 *nSamplesOut /* O: Number of samples decoded */ +opus_int silk_Decode( /* O Returns error code */ + void* decState, /* I/O State */ + silk_DecControlStruct* decControl, /* I/O Control Structure */ + opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ + opus_int newPacketFlag, /* I Indicates first decoder call for this packet */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int16 *samplesOut, /* O Decoded output speech vector */ + opus_int32 *nSamplesOut /* O Number of samples decoded */ ) { opus_int i, n, delay, decode_only_middle = 0, ret = SILK_NO_ERROR; @@ -237,7 +239,7 @@ opus_int silk_Decode( psDec->channel_state[ 1 ].first_frame_after_reset = 1; } - if (lostFlag == FLAG_DECODE_NORMAL) { + if( lostFlag == FLAG_DECODE_NORMAL ) { has_side = !decode_only_middle; } else { has_side = !psDec->prev_decode_only_middle @@ -318,7 +320,7 @@ opus_int silk_Decode( decControl->prevPitchLag = 0; } - if ( lostFlag != FLAG_PACKET_LOST ) { + if( lostFlag != FLAG_PACKET_LOST ) { psDec->prev_decode_only_middle = decode_only_middle; } return ret; @@ -326,10 +328,10 @@ opus_int silk_Decode( /* Getting table of contents for a packet */ opus_int silk_get_TOC( - const opus_uint8 *payload, /* I Payload data */ - const opus_int nBytesIn, /* I: Number of input bytes */ - const opus_int nFramesPerPayload, /* I: Number of SILK frames per payload */ - silk_TOC_struct *Silk_TOC /* O: Type of content */ + const opus_uint8 *payload, /* I Payload data */ + const opus_int nBytesIn, /* I Number of input bytes */ + const opus_int nFramesPerPayload, /* I Number of SILK frames per payload */ + silk_TOC_struct *Silk_TOC /* O Type of content */ ) { opus_int i, flags, ret = SILK_NO_ERROR; diff --git a/silk/decode_core.c b/silk/decode_core.c index fd7283fe..9a4c9f39 100644 --- a/silk/decode_core.c +++ b/silk/decode_core.c @@ -35,10 +35,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Core decoder. Performs inverse NSQ operation LTP + LPC */ /**********************************************************/ void silk_decode_core( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I Decoder control */ - opus_int16 xq[], /* O Decoded speech */ - const opus_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */ + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I Decoder control */ + opus_int16 xq[], /* O Decoded speech */ + const opus_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */ ) { opus_int i, j, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, signalType; @@ -77,10 +77,6 @@ void silk_decode_core( rand_seed = silk_ADD32_ovflw(rand_seed, pulses[ i ]); } -#ifdef SAVE_ALL_INTERNAL_DATA - DEBUG_STORE_DATA( dec_q.dat, pulses, psDec->frame_length * sizeof( opus_int ) ); -#endif - /* Copy LPC state */ silk_memcpy( sLPC_Q14, psDec->sLPC_Q14_buf, MAX_LPC_ORDER * sizeof( opus_int32 ) ); @@ -187,11 +183,6 @@ void silk_decode_core( pres_Q10 = pexc_Q10; } -#ifdef SAVE_ALL_INTERNAL_DATA - DEBUG_STORE_DATA( dec_exc_Q10.dat, pexc_Q10, psDec->subfr_length * sizeof( opus_int32 ) ); - DEBUG_STORE_DATA( dec_res_Q10.dat, pres_Q10, psDec->subfr_length * sizeof( opus_int32 ) ); -#endif - for( i = 0; i < psDec->subfr_length; i++ ) { /* Partially unrolled */ LPC_pred_Q10 = silk_SMULWB( sLPC_Q14[ MAX_LPC_ORDER + i - 1 ], A_Q12_tmp[ 0 ] ); @@ -223,9 +214,4 @@ void silk_decode_core( /* Save LPC state */ silk_memcpy( psDec->sLPC_Q14_buf, sLPC_Q14, MAX_LPC_ORDER * sizeof( opus_int32 ) ); - -#ifdef SAVE_ALL_INTERNAL_DATA - DEBUG_STORE_DATA( dec_sLTP_Q16.dat, &sLTP_Q16[ psDec->ltp_mem_length ], psDec->frame_length * sizeof( opus_int32 )); - DEBUG_STORE_DATA( dec_xq.dat, xq, psDec->frame_length * sizeof( opus_int16 ) ); -#endif } diff --git a/silk/decode_frame.c b/silk/decode_frame.c index 83c92210..91adc384 100644 --- a/silk/decode_frame.c +++ b/silk/decode_frame.c @@ -36,20 +36,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Decode frame */ /****************/ opus_int silk_decode_frame( - silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 pOut[], /* O Pointer to output speech frame */ - opus_int32 *pN, /* O Pointer to size of output frame */ - opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int16 pOut[], /* O Pointer to output speech frame */ + opus_int32 *pN, /* O Pointer to size of output frame */ + opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ + opus_int condCoding /* I The type of conditional coding to use */ ) { silk_decoder_control sDecCtrl; opus_int L, mv_len, ret = 0; opus_int pulses[ MAX_FRAME_LENGTH ]; -TIC(DECODE_FRAME) - L = psDec->frame_length; sDecCtrl.LTP_scale_Q14 = 0; @@ -62,24 +60,18 @@ TIC(DECODE_FRAME) /*********************************************/ /* Decode quantization indices of side info */ /*********************************************/ -TIC(decode_indices) silk_decode_indices( psDec, psRangeDec, psDec->nFramesDecoded, lostFlag, condCoding ); -TOC(decode_indices) /*********************************************/ /* Decode quantization indices of excitation */ /*********************************************/ -TIC(decode_pulses) silk_decode_pulses( psRangeDec, pulses, psDec->indices.signalType, psDec->indices.quantOffsetType, psDec->frame_length ); -TOC(decode_pulses) /********************************************/ /* Decode parameters and pulse signal */ /********************************************/ -TIC(decode_params) silk_decode_parameters( psDec, &sDecCtrl, condCoding ); -TOC(decode_params) /* Update length. Sampling frequency may have changed */ L = psDec->frame_length; @@ -87,9 +79,7 @@ TOC(decode_params) /********************************************************/ /* Run inverse NSQ */ /********************************************************/ -TIC(decode_core) silk_decode_core( psDec, &sDecCtrl, pOut, pulses ); -TOC(decode_core) /********************************************************/ /* Update PLC state */ @@ -131,7 +121,5 @@ TOC(decode_core) /* Set output frame length */ *pN = L; -TOC(DECODE_FRAME) - return ret; } diff --git a/silk/decode_indices.c b/silk/decode_indices.c index 8ac53f4b..e344b1e7 100644 --- a/silk/decode_indices.c +++ b/silk/decode_indices.c @@ -33,11 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Decode side-information parameters from payload */ void silk_decode_indices( - silk_decoder_state *psDec, /* I/O State */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int FrameIndex, /* I Frame number */ - opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_decoder_state *psDec, /* I/O State */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int FrameIndex, /* I Frame number */ + opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */ + opus_int condCoding /* I The type of conditional coding to use */ ) { opus_int i, k, Ix; diff --git a/silk/decode_parameters.c b/silk/decode_parameters.c index 1ab8ed74..6c69cfab 100644 --- a/silk/decode_parameters.c +++ b/silk/decode_parameters.c @@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Decode parameters from payload */ void silk_decode_parameters( - silk_decoder_state *psDec, /* I/O State */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_decoder_state *psDec, /* I/O State */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ + opus_int condCoding /* I The type of conditional coding to use */ ) { opus_int i, k, Ix; diff --git a/silk/decode_pitch.c b/silk/decode_pitch.c index 6aeb7ab2..8fc6f072 100644 --- a/silk/decode_pitch.c +++ b/silk/decode_pitch.c @@ -36,11 +36,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "pitch_est_defines.h" void silk_decode_pitch( - opus_int16 lagIndex, /* I */ - opus_int8 contourIndex, /* O */ - opus_int pitch_lags[], /* O pitch values */ - const opus_int Fs_kHz, /* I sampling frequency (kHz) */ - const opus_int nb_subfr /* I number of sub frames */ + opus_int16 lagIndex, /* I */ + opus_int8 contourIndex, /* O */ + opus_int pitch_lags[], /* O 4 pitch values */ + const opus_int Fs_kHz, /* I sampling frequency (kHz) */ + const opus_int nb_subfr /* I number of sub frames */ ) { opus_int lag, k, min_lag, max_lag, cbk_size; diff --git a/silk/decode_pulses.c b/silk/decode_pulses.c index 692ab925..e398f19c 100644 --- a/silk/decode_pulses.c +++ b/silk/decode_pulses.c @@ -35,11 +35,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Decode quantization indices of excitation */ /*********************************************/ void silk_decode_pulses( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int pulses[], /* O Excitation signal */ - const opus_int signalType, /* I Sigtype */ - const opus_int quantOffsetType, /* I quantOffsetType */ - const opus_int frame_length /* I Frame length */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int pulses[], /* O Excitation signal */ + const opus_int signalType, /* I Sigtype */ + const opus_int quantOffsetType, /* I quantOffsetType */ + const opus_int frame_length /* I Frame length */ ) { opus_int i, j, k, iter, abs_q, nLS, RateLevelIndex; @@ -55,7 +55,7 @@ void silk_decode_pulses( /* Calculate number of shell blocks */ silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH ); iter = silk_RSHIFT( frame_length, LOG2_SHELL_CODEC_FRAME_LENGTH ); - if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ){ + if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ) { silk_assert( frame_length == 12 * 10 ); /* Make sure only happens for 10 ms @ 12 kHz */ iter++; } @@ -73,7 +73,7 @@ void silk_decode_pulses( nLshifts[ i ]++; /* When we've already got 10 LSBs, we shift the table to not allow (MAX_PULSES + 1) */ sum_pulses[ i ] = ec_dec_icdf( psRangeDec, - silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1] + (nLshifts[ i ]==10), 8 ); + silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1] + ( nLshifts[ i ] == 10 ), 8 ); } } diff --git a/silk/decoder_set_fs.c b/silk/decoder_set_fs.c index f80470f3..5579b20e 100644 --- a/silk/decoder_set_fs.c +++ b/silk/decoder_set_fs.c @@ -40,9 +40,9 @@ static const int dec_delay_matrix[3][5] = { /* Set decoder sampling rate */ opus_int silk_decoder_set_fs( - silk_decoder_state *psDec, /* I/O Decoder state pointer */ - opus_int fs_kHz, /* I Sampling frequency (kHz) */ - opus_int fs_API_Hz /* I API Sampling frequency (Hz) */ + silk_decoder_state *psDec, /* I/O Decoder state pointer */ + opus_int fs_kHz, /* I Sampling frequency (kHz) */ + opus_int fs_API_Hz /* I API Sampling frequency (Hz) */ ) { opus_int frame_length, ret = 0; diff --git a/silk/define.h b/silk/define.h index 8f9935fc..dcfdee93 100644 --- a/silk/define.h +++ b/silk/define.h @@ -57,7 +57,7 @@ extern "C" #define NB_SPEECH_FRAMES_BEFORE_DTX 10 /* eq 200 ms */ #define MAX_CONSECUTIVE_DTX 20 /* eq 400 ms */ -/* Maximum sampling frequency, should be 16 for embedded */ +/* Maximum sampling frequency */ #define MAX_FS_KHZ 16 #define MAX_API_FS_KHZ 48 @@ -74,12 +74,12 @@ extern "C" /* Settings for stereo processing */ #define STEREO_QUANT_TAB_SIZE 16 #define STEREO_QUANT_SUB_STEPS 5 -#define STEREO_INTERP_LEN_MS 8 /* must be even */ -#define STEREO_RATIO_SMOOTH_COEF 0.01 /* smoothing coef for signal norms and stereo width */ +#define STEREO_INTERP_LEN_MS 8 /* must be even */ +#define STEREO_RATIO_SMOOTH_COEF 0.01 /* smoothing coef for signal norms and stereo width */ /* Range of pitch lag estimates */ -#define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */ -#define PITCH_EST_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */ +#define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */ +#define PITCH_EST_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */ /* Maximum number of subframes */ #define MAX_NB_SUBFR 4 @@ -92,7 +92,7 @@ extern "C" #define MAX_FRAME_LENGTH ( MAX_FRAME_LENGTH_MS * MAX_FS_KHZ ) #define MAX_ENCODER_DELAY 18 -#define MAX_DECODER_DELAY 8 +#define MAX_DECODER_DELAY 8 /* Milliseconds of lookahead for pitch analysis */ #define LA_PITCH_MS 2 @@ -193,11 +193,11 @@ extern "C" #define VAD_INTERNAL_SUBFRAMES_LOG2 2 #define VAD_INTERNAL_SUBFRAMES (1 << VAD_INTERNAL_SUBFRAMES_LOG2) -#define VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 1024 /* Must be < 4096 */ +#define VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 1024 /* Must be < 4096 */ #define VAD_NOISE_LEVELS_BIAS 50 /* Sigmoid settings */ -#define VAD_NEGATIVE_OFFSET_Q5 128 /* sigmoid is 0 at -128 */ +#define VAD_NEGATIVE_OFFSET_Q5 128 /* sigmoid is 0 at -128 */ #define VAD_SNR_FACTOR_Q16 45000 /* smoothing for SNR measurement */ @@ -219,10 +219,10 @@ extern "C" #define NLSF_QUANT_DEL_DEC_STATES ( 1 << NLSF_QUANT_DEL_DEC_STATES_LOG2 ) /* Transition filtering for mode switching */ -#define TRANSITION_TIME_MS 5120 /* 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)*/ -#define TRANSITION_NB 3 /* Hardcoded in tables */ -#define TRANSITION_NA 2 /* Hardcoded in tables */ -#define TRANSITION_INT_NUM 5 /* Hardcoded in tables */ +#define TRANSITION_TIME_MS 5120 /* 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)*/ +#define TRANSITION_NB 3 /* Hardcoded in tables */ +#define TRANSITION_NA 2 /* Hardcoded in tables */ +#define TRANSITION_INT_NUM 5 /* Hardcoded in tables */ #define TRANSITION_FRAMES ( TRANSITION_TIME_MS / MAX_FRAME_LENGTH_MS ) #define TRANSITION_INT_STEPS ( TRANSITION_FRAMES / ( TRANSITION_INT_NUM - 1 ) ) @@ -230,9 +230,9 @@ extern "C" #define BWE_AFTER_LOSS_Q16 63570 /* Defines for CN generation */ -#define CNG_BUF_MASK_MAX 255 /* 2^floor(log2(MAX_FRAME_LENGTH))-1 */ -#define CNG_GAIN_SMTH_Q16 4634 /* 0.25^(1/4) */ -#define CNG_NLSF_SMTH_Q16 16348 /* 0.25 */ +#define CNG_BUF_MASK_MAX 255 /* 2^floor(log2(MAX_FRAME_LENGTH))-1 */ +#define CNG_GAIN_SMTH_Q16 4634 /* 0.25^(1/4) */ +#define CNG_NLSF_SMTH_Q16 16348 /* 0.25 */ #ifdef __cplusplus } diff --git a/silk/enc_API.c b/silk/enc_API.c index 01a7e96b..02a8fd01 100644 --- a/silk/enc_API.c +++ b/silk/enc_API.c @@ -44,7 +44,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* 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; @@ -56,9 +58,9 @@ opus_int silk_Get_Encoder_Size( opus_int *encSizeBytes ) /*************************/ /* Init or Reset encoder */ /*************************/ -opus_int silk_InitEncoder( - void *encState, /* I/O: State */ - silk_EncControlStruct *encStatus /* O: Control structure */ +opus_int silk_InitEncoder( /* O Returns error code */ + void *encState, /* I/O State */ + silk_EncControlStruct *encStatus /* O Encoder Status */ ) { silk_encoder *psEnc; @@ -88,9 +90,9 @@ opus_int silk_InitEncoder( /***************************************/ /* Read control structure from encoder */ /***************************************/ -opus_int silk_QueryEncoder( - const void *encState, /* I: State Vector */ - silk_EncControlStruct *encStatus /* O: Control Structure */ +opus_int silk_QueryEncoder( /* O Returns error code */ + const void *encState, /* I State */ + silk_EncControlStruct *encStatus /* O Encoder Status */ ) { opus_int ret = SILK_NO_ERROR; @@ -123,14 +125,16 @@ opus_int silk_QueryEncoder( /**************************/ /* Encode frame with Silk */ /**************************/ -opus_int silk_Encode( - void *encState, /* I/O: State */ - silk_EncControlStruct *encControl, /* I: Control structure */ - const opus_int16 *samplesIn, /* I: Speech sample input vector */ - opus_int nSamplesIn, /* I: Number of samples in input vector */ - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */ - const opus_int prefillFlag /* I: Flag to indicate prefilling buffers; no coding */ +/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */ +/* encControl->payloadSize_ms is set to */ +opus_int silk_Encode( /* O Returns error code */ + void *encState, /* I/O State */ + silk_EncControlStruct *encControl, /* I Control status */ + const opus_int16 *samplesIn, /* I Speech sample input vector */ + opus_int nSamplesIn, /* I Number of samples in input vector */ + ec_enc *psRangeEnc, /* I/O Compressor data structure */ + opus_int *nBytesOut, /* I/O Number of bytes in payload (input: Max bytes) */ + const opus_int prefillFlag /* I Flag to indicate prefilling buffers no coding */ ) { opus_int n, i, nBits, flags, tmp_payloadSize_ms = 0, tmp_complexity = 0, ret = 0; @@ -270,17 +274,18 @@ opus_int silk_Encode( buf[ n + delay ] = (opus_int16)silk_RSHIFT_ROUND( samplesIn[ 2 * n ] + samplesIn[ 2 * n + 1 ], 1 ); } if(psEnc->nPrevChannelsInternal == 2 && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded==0) { - for ( n = 0; nstate_Fxx[ 0 ].sCmn.delayBuf[ n ] = silk_RSHIFT(psEnc->state_Fxx[ 0 ].sCmn.delayBuf[ n ]+(opus_int32)psEnc->state_Fxx[ 1 ].sCmn.delayBuf[ n ], 1); + } } silk_memcpy(buf, &psEnc->state_Fxx[ 0 ].sCmn.delayBuf[ MAX_ENCODER_DELAY - delay ], delay * sizeof(opus_int16)); ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput ); /* On the first mono frame, average the results for the two resampler states */ - if (psEnc->nPrevChannelsInternal == 2 && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded==0) { + if( psEnc->nPrevChannelsInternal == 2 && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded == 0 ) { ret += silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput ); - for ( n = 0; n < psEnc->state_Fxx[ 0 ].sCmn.frame_length; n++ ) { + for( n = 0; n < psEnc->state_Fxx[ 0 ].sCmn.frame_length; n++ ) { psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx+n+2 ] = silk_RSHIFT(psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx+n+2 ] + psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx+n+2 ], 1); @@ -367,8 +372,9 @@ opus_int silk_Encode( /* Total target bits for packet */ nBits = silk_DIV32_16( silk_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 ); /* Subtract half of the bits already used */ - if (!prefillFlag) + if( !prefillFlag ) { nBits -= ec_tell( psRangeEnc ) >> 1; + } /* Divide by number of uncoded frames left in packet */ nBits = silk_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket - psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ); /* Convert to bits/second */ diff --git a/silk/encode_indices.c b/silk/encode_indices.c index f87de036..f969a9b6 100644 --- a/silk/encode_indices.c +++ b/silk/encode_indices.c @@ -33,11 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Encode side-information parameters to payload */ void silk_encode_indices( - silk_encoder_state *psEncC, /* I/O Encoder state */ - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int FrameIndex, /* I Frame number */ - opus_int encode_LBRR, /* I Flag indicating LBRR data is being encoded */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state *psEncC, /* I/O Encoder state */ + ec_enc *psRangeEnc, /* I/O Compressor data structure */ + opus_int FrameIndex, /* I Frame number */ + opus_int encode_LBRR, /* I Flag indicating LBRR data is being encoded */ + opus_int condCoding /* I The type of conditional coding to use */ ) { opus_int i, k, typeOffset; @@ -45,10 +45,6 @@ void silk_encode_indices( opus_int16 ec_ix[ MAX_LPC_ORDER ]; opus_uint8 pred_Q8[ MAX_LPC_ORDER ]; const SideInfoIndices *psIndices; -#if SAVE_ALL_INTERNAL_DATA - opus_int nBytes_lagIndex, nBytes_contourIndex, nBytes_LTP; - opus_int nBytes_after, nBytes_before; -#endif if( encode_LBRR ) { psIndices = &psEncC->indices_LBRR[ FrameIndex ]; @@ -71,9 +67,6 @@ void silk_encode_indices( /****************/ /* Encode gains */ /****************/ -#ifdef SAVE_ALL_INTERNAL_DATA - nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); -#endif /* first subframe */ if( condCoding == CODE_CONDITIONALLY ) { /* conditional coding */ @@ -92,18 +85,9 @@ void silk_encode_indices( ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ i ], silk_delta_gain_iCDF, 8 ); } -#ifdef SAVE_ALL_INTERNAL_DATA - nBytes_after = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); - nBytes_after -= nBytes_before; /* bytes just added*/ - DEBUG_STORE_DATA( nBytes_gains.dat, &nBytes_after, sizeof( opus_int ) ); -#endif - /****************/ /* Encode NLSFs */ /****************/ -#ifdef SAVE_ALL_INTERNAL_DATA - nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); -#endif ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ 0 ], &psEncC->psNLSF_CB->CB1_iCDF[ ( psIndices->signalType >> 1 ) * psEncC->psNLSF_CB->nVectors ], 8 ); silk_NLSF_unpack( ec_ix, pred_Q8, psEncC->psNLSF_CB, psIndices->NLSFIndices[ 0 ] ); silk_assert( psEncC->psNLSF_CB->order == psEncC->predictLPCOrder ); @@ -125,21 +109,11 @@ void silk_encode_indices( ec_enc_icdf( psRangeEnc, psIndices->NLSFInterpCoef_Q2, silk_NLSF_interpolation_factor_iCDF, 8 ); } -#ifdef SAVE_ALL_INTERNAL_DATA - DEBUG_STORE_DATA( lsf_interpol.dat, &psIndices->NLSFInterpCoef_Q2, sizeof(int) ); - nBytes_after = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); - nBytes_after -= nBytes_before; /* bytes just added*/ - DEBUG_STORE_DATA( nBytes_LSF.dat, &nBytes_after, sizeof( opus_int ) ); -#endif - if( psIndices->signalType == TYPE_VOICED ) { /*********************/ /* Encode pitch lags */ /*********************/ -#ifdef SAVE_ALL_INTERNAL_DATA - nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); -#endif /* lag index */ encode_absolute_lagIndex = 1; if( condCoding == CODE_CONDITIONALLY && psEncC->ec_prevSignalType == TYPE_VOICED ) { @@ -166,14 +140,6 @@ void silk_encode_indices( } psEncC->ec_prevLagIndex = psIndices->lagIndex; -#ifdef SAVE_ALL_INTERNAL_DATA - nBytes_after = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); - nBytes_lagIndex = nBytes_after - nBytes_before; /* bytes just added*/ -#endif - -#ifdef SAVE_ALL_INTERNAL_DATA - nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); -#endif /* Countour index */ silk_assert( psIndices->contourIndex >= 0 ); silk_assert( ( psIndices->contourIndex < 34 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 4 ) || @@ -181,18 +147,10 @@ void silk_encode_indices( ( psIndices->contourIndex < 12 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 2 ) || ( psIndices->contourIndex < 3 && psEncC->fs_kHz == 8 && psEncC->nb_subfr == 2 ) ); ec_enc_icdf( psRangeEnc, psIndices->contourIndex, psEncC->pitch_contour_iCDF, 8 ); -#ifdef SAVE_ALL_INTERNAL_DATA - nBytes_after = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); - nBytes_contourIndex = nBytes_after - nBytes_before; /* bytes just added*/ -#endif /********************/ /* Encode LTP gains */ /********************/ -#ifdef SAVE_ALL_INTERNAL_DATA - nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); -#endif - /* PERIndex value */ silk_assert( psIndices->PERIndex >= 0 && psIndices->PERIndex < 3 ); ec_enc_icdf( psRangeEnc, psIndices->PERIndex, silk_LTP_per_index_iCDF, 8 ); @@ -211,30 +169,10 @@ void silk_encode_indices( ec_enc_icdf( psRangeEnc, psIndices->LTP_scaleIndex, silk_LTPscale_iCDF, 8 ); } silk_assert( !condCoding || psIndices->LTP_scaleIndex == 0 ); - -#ifdef SAVE_ALL_INTERNAL_DATA - nBytes_after = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); - nBytes_LTP = nBytes_after - nBytes_before; /* bytes just added*/ -#endif - } -#ifdef SAVE_ALL_INTERNAL_DATA - else { - /* Unvoiced speech*/ - nBytes_lagIndex = 0; - nBytes_contourIndex = 0; - nBytes_LTP = 0; } - DEBUG_STORE_DATA( nBytes_lagIndex.dat, &nBytes_lagIndex, sizeof( opus_int ) ); - DEBUG_STORE_DATA( nBytes_contourIndex.dat, &nBytes_contourIndex, sizeof( opus_int ) ); - DEBUG_STORE_DATA( nBytes_LTP.dat, &nBytes_LTP, sizeof( opus_int ) ); -#endif psEncC->ec_prevSignalType = psIndices->signalType; -#ifdef SAVE_ALL_INTERNAL_DATA - nBytes_before = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); -#endif - /***************/ /* Encode seed */ /***************/ diff --git a/silk/encode_pulses.c b/silk/encode_pulses.c index 2fd6b505..32eb4cf8 100644 --- a/silk/encode_pulses.c +++ b/silk/encode_pulses.c @@ -35,11 +35,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Encode quantization indices of excitation */ /*********************************************/ -static inline opus_int combine_and_check( /* return ok */ - opus_int *pulses_comb, /* O */ - const opus_int *pulses_in, /* I */ - opus_int max_pulses, /* I max value for sum of pulses */ - opus_int len /* I number of output values */ +static inline opus_int combine_and_check( /* return ok */ + opus_int *pulses_comb, /* O */ + const opus_int *pulses_in, /* I */ + opus_int max_pulses, /* I max value for sum of pulses */ + opus_int len /* I number of output values */ ) { opus_int k, sum; @@ -57,11 +57,11 @@ static inline opus_int combine_and_check( /* return ok */ /* Encode quantization indices of excitation */ void silk_encode_pulses( - ec_enc *psRangeEnc, /* I/O compressor data structure */ - const opus_int signalType, /* I Sigtype */ - const opus_int quantOffsetType, /* I quantOffsetType */ - opus_int8 pulses[], /* I quantization indices */ - const opus_int frame_length /* I Frame length */ + ec_enc *psRangeEnc, /* I/O compressor data structure */ + const opus_int signalType, /* I Signal type */ + const opus_int quantOffsetType, /* I quantOffsetType */ + opus_int8 pulses[], /* I quantization indices */ + const opus_int frame_length /* I Frame length */ ) { 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 */ silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH ); iter = silk_RSHIFT( frame_length, LOG2_SHELL_CODEC_FRAME_LENGTH ); - if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ){ + if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ) { silk_assert( frame_length == 12 * 10 ); /* Make sure only happens for 10 ms @ 12 kHz */ iter++; silk_memset( &pulses[ frame_length ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof(opus_int8)); diff --git a/silk/fixed/LTP_analysis_filter_FIX.c b/silk/fixed/LTP_analysis_filter_FIX.c index f31a5500..aad7b6eb 100644 --- a/silk/fixed/LTP_analysis_filter_FIX.c +++ b/silk/fixed/LTP_analysis_filter_FIX.c @@ -32,14 +32,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FIX.h" void silk_LTP_analysis_filter_FIX( - opus_int16 *LTP_res, /* O: LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */ - const opus_int16 *x, /* I: Pointer to input signal with at least max( pitchL ) preceeding samples */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I: LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I: Pitch lag, one for each subframe */ - const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I: Inverse quantization gains, one for each subframe */ - const opus_int subfr_length, /* I: Length of each subframe */ - const opus_int nb_subfr, /* I: Number of subframes */ - const opus_int pre_length /* I: Length of the preceeding samples starting at &x[0] for each subframe */ + opus_int16 *LTP_res, /* O LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */ + const opus_int16 *x, /* I Pointer to input signal with at least max( pitchL ) preceeding samples */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag, one for each subframe */ + const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I Inverse quantization gains, one for each subframe */ + const opus_int subfr_length, /* I Length of each subframe */ + const opus_int nb_subfr, /* I Number of subframes */ + const opus_int pre_length /* I Length of the preceeding samples starting at &x[0] for each subframe */ ) { const opus_int16 *x_ptr, *x_lag_ptr; diff --git a/silk/fixed/LTP_scale_ctrl_FIX.c b/silk/fixed/LTP_scale_ctrl_FIX.c index dd4923f8..0f347e3b 100644 --- a/silk/fixed/LTP_scale_ctrl_FIX.c +++ b/silk/fixed/LTP_scale_ctrl_FIX.c @@ -31,10 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FIX.h" +/* Calculation of LTP state scaling */ void silk_LTP_scale_ctrl_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state FIX */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control FIX */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ + opus_int condCoding /* I The type of conditional coding to use */ ) { opus_int round_loss; diff --git a/silk/fixed/apply_sine_window_FIX.c b/silk/fixed/apply_sine_window_FIX.c index 11a8545f..4d4f096e 100644 --- a/silk/fixed/apply_sine_window_FIX.c +++ b/silk/fixed/apply_sine_window_FIX.c @@ -48,10 +48,10 @@ static opus_int16 freq_table_Q16[ 27 ] = { }; void silk_apply_sine_window( - opus_int16 px_win[], /* O Pointer to windowed signal */ - const opus_int16 px[], /* I Pointer to input signal */ - const opus_int win_type, /* I Selects a window type */ - const opus_int length /* I Window length, multiple of 4 */ + opus_int16 px_win[], /* O Pointer to windowed signal */ + const opus_int16 px[], /* I Pointer to input signal */ + const opus_int win_type, /* I Selects a window type */ + const opus_int length /* I Window length, multiple of 4 */ ) { opus_int k, f_Q16, c_Q16; diff --git a/silk/fixed/autocorr_FIX.c b/silk/fixed/autocorr_FIX.c index 37ab66c0..dd6c7792 100644 --- a/silk/fixed/autocorr_FIX.c +++ b/silk/fixed/autocorr_FIX.c @@ -33,11 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Compute autocorrelation */ void silk_autocorr( - opus_int32 *results, /* O Result (length correlationCount) */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *inputData, /* I Input data to correlate */ - const opus_int inputDataSize, /* I Length of input */ - const opus_int correlationCount /* I Number of correlation taps to compute */ + opus_int32 *results, /* O Result (length correlationCount) */ + opus_int *scale, /* O Scaling of the correlation vector */ + const opus_int16 *inputData, /* I Input data to correlate */ + const opus_int inputDataSize, /* I Length of input */ + const opus_int correlationCount /* I Number of correlation taps to compute */ ) { opus_int i, lz, nRightShifts, corrCount; diff --git a/silk/fixed/burg_modified_FIX.c b/silk/fixed/burg_modified_FIX.c index 0bf90e51..69d87616 100644 --- a/silk/fixed/burg_modified_FIX.c +++ b/silk/fixed/burg_modified_FIX.c @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #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 QA 25 @@ -41,14 +41,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Compute reflection coefficients from input signal */ void silk_burg_modified( - opus_int32 *res_nrg, /* O residual energy */ - opus_int *res_nrg_Q, /* O residual energy Q value */ - opus_int32 A_Q16[], /* O prediction coefficients (length order) */ - const opus_int16 x[], /* I input signal, length: nb_subfr * ( D + subfr_length ) */ - const opus_int subfr_length, /* I input signal subframe length (including D preceeding samples) */ - const opus_int nb_subfr, /* I number of subframes stacked in x */ - const opus_int32 WhiteNoiseFrac_Q32, /* I fraction added to zero-lag autocorrelation */ - const opus_int D /* I order */ + opus_int32 *res_nrg, /* O Residual energy */ + opus_int *res_nrg_Q, /* O Residual energy Q value */ + opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ + const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ + const opus_int subfr_length, /* I Input signal subframe length (incl. D preceeding samples) */ + const opus_int nb_subfr, /* I Number of subframes stacked in x */ + const opus_int32 WhiteNoiseFrac_Q32, /* I Fraction added to zero-lag autocorrelation */ + const opus_int D /* I Order */ ) { 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 ) ); /* 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++ ) { /* Update first row of correlation matrix (without first element) */ @@ -115,70 +115,70 @@ void silk_burg_modified( if( rshifts > -2 ) { for( s = 0; s < nb_subfr; s++ ) { x_ptr = x + s * subfr_length; - 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)*/ - 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)*/ + 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)*/ + 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)*/ 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_last_row[ k ] = silk_SMLAWB( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts )*/ Atmp_QA = Af_QA[ k ]; - 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)*/ + 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)*/ } - tmp1 = silk_LSHIFT32( -tmp1, 32 - QA - rshifts ); /* Q(16-rshifts)*/ - tmp2 = silk_LSHIFT32( -tmp2, 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)*/ for( k = 0; k <= n; k++ ) { - 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 )*/ + 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 )*/ } } } else { for( s = 0; s < nb_subfr; s++ ) { x_ptr = x + s * subfr_length; - 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 )*/ - tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], 17 ); /* Q17*/ - tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 17 ); /* Q17*/ + 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 )*/ + tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], 17 ); /* Q17*/ + tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 17 ); /* Q17*/ 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_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*/ - tmp1 = silk_MLA( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17*/ - tmp2 = silk_MLA( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17*/ + Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17*/ + tmp1 = silk_MLA( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17*/ + tmp2 = silk_MLA( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17*/ } - tmp1 = -tmp1; /* Q17*/ - tmp2 = -tmp2; /* Q17*/ + tmp1 = -tmp1; /* Q17*/ + tmp2 = -tmp2; /* Q17*/ for( k = 0; k <= n; k++ ) { 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, - 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 */ - tmp1 = C_first_row[ n ]; /* Q( -rshifts )*/ - tmp2 = C_last_row[ n ]; /* Q( -rshifts )*/ - num = 0; /* Q( -rshifts )*/ - nrg = silk_ADD32( CAb[ 0 ], CAf[ 0 ] ); /* Q( 1-rshifts )*/ + tmp1 = C_first_row[ n ]; /* Q( -rshifts )*/ + tmp2 = C_last_row[ n ]; /* Q( -rshifts )*/ + num = 0; /* Q( -rshifts )*/ + nrg = silk_ADD32( CAb[ 0 ], CAf[ 0 ] ); /* Q( 1-rshifts )*/ for( k = 0; k < n; k++ ) { Atmp_QA = Af_QA[ k ]; lz = silk_CLZ32( silk_abs( Atmp_QA ) ) - 1; 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 )*/ - 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 )*/ + 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 )*/ + 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 ] ), Atmp1 ), 32 - QA - lz ); /* Q( 1-rshifts )*/ } - CAf[ n + 1 ] = tmp1; /* Q( -rshifts )*/ - CAb[ n + 1 ] = tmp2; /* Q( -rshifts )*/ - num = silk_ADD32( num, tmp2 ); /* Q( -rshifts )*/ - num = silk_LSHIFT32( -num, 1 ); /* Q( 1-rshifts )*/ + CAf[ n + 1 ] = tmp1; /* Q( -rshifts )*/ + CAb[ n + 1 ] = tmp2; /* Q( -rshifts )*/ + num = silk_ADD32( num, tmp2 ); /* Q( -rshifts )*/ + num = silk_LSHIFT32( -num, 1 ); /* Q( 1-rshifts )*/ /* Calculate the next order reflection (parcor) coefficient */ if( silk_abs( num ) < nrg ) { @@ -192,31 +192,31 @@ void silk_burg_modified( /* Update the AR coefficients */ for( k = 0; k < (n + 1) >> 1; k++ ) { - tmp1 = Af_QA[ k ]; /* QA*/ - tmp2 = Af_QA[ n - k - 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*/ + tmp1 = Af_QA[ k ]; /* QA*/ + tmp2 = Af_QA[ n - k - 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 ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA*/ + Af_QA[ n ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA*/ /* Update C * Af and C * Ab */ for( k = 0; k <= n + 1; k++ ) { - tmp1 = CAf[ k ]; /* Q( -rshifts )*/ - tmp2 = CAb[ n - k + 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 )*/ + tmp1 = CAf[ k ]; /* Q( -rshifts )*/ + tmp2 = CAb[ n - k + 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 )*/ } } /* Return residual energy */ - nrg = CAf[ 0 ]; /* Q( -rshifts )*/ - tmp1 = 1 << 16; /* Q16*/ + nrg = CAf[ 0 ]; /* Q( -rshifts )*/ + tmp1 = 1 << 16; /* Q16*/ for( k = 0; k < D; k++ ) { - Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); /* Q16*/ - nrg = silk_SMLAWW( nrg, CAf[ k + 1 ], Atmp1 ); /* Q( -rshifts )*/ - tmp1 = silk_SMLAWW( tmp1, Atmp1, Atmp1 ); /* Q16*/ + Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); /* Q16*/ + nrg = silk_SMLAWW( nrg, CAf[ k + 1 ], Atmp1 ); /* Q( -rshifts )*/ + tmp1 = silk_SMLAWW( tmp1, Atmp1, Atmp1 ); /* Q16*/ 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; } diff --git a/silk/fixed/corrMatrix_FIX.c b/silk/fixed/corrMatrix_FIX.c index 09994d0d..c0d3109a 100644 --- a/silk/fixed/corrMatrix_FIX.c +++ b/silk/fixed/corrMatrix_FIX.c @@ -37,12 +37,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Calculates correlation vector X'*t */ void silk_corrVector_FIX( - const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ - const opus_int16 *t, /* I target vector [L] */ - const opus_int L, /* I Length of vectors */ - const opus_int order, /* I Max lag for correlation */ - opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */ - const opus_int rshifts /* I Right shifts of correlations */ + const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ + const opus_int16 *t, /* I Target vector [L] */ + const opus_int L, /* I Length of vectors */ + const opus_int order, /* I Max lag for correlation */ + opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */ + const opus_int rshifts /* I Right shifts of correlations */ ) { opus_int lag, i; @@ -73,12 +73,12 @@ void silk_corrVector_FIX( /* Calculates correlation matrix X'*X */ void silk_corrMatrix_FIX( - const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ - const opus_int L, /* I Length of vectors */ - const opus_int order, /* I Max lag for correlation */ - const opus_int head_room, /* I Desired headroom */ - opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ]*/ - opus_int *rshifts /* I/O Right shifts of correlations */ + const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ + const opus_int L, /* I Length of vectors */ + const opus_int order, /* I Max lag for correlation */ + const opus_int head_room, /* I Desired headroom */ + opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */ + opus_int *rshifts /* I/O Right shifts of correlations */ ) { opus_int i, j, lag, rshifts_local, head_room_rshifts; diff --git a/silk/fixed/encode_frame_FIX.c b/silk/fixed/encode_frame_FIX.c index 1f27131b..6d279160 100644 --- a/silk/fixed/encode_frame_FIX.c +++ b/silk/fixed/encode_frame_FIX.c @@ -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 */ static inline void silk_LBRR_encode_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ - const opus_int16 xfw[], /* I Input signal */ - opus_int condCoding /* I The type of conditional coding used so far for this frame */ + silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ + const opus_int16 xfw[], /* I Input signal */ + opus_int condCoding /* I The type of conditional coding used so far for this frame */ ); 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 */ /****************************/ -TIC(VAD) silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 ); -TOC(VAD) /**************************************************/ /* Convert speech activity into VAD and DTX flags */ @@ -76,12 +74,12 @@ TOC(VAD) /* Encode frame */ /****************/ opus_int silk_encode_frame_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ - opus_int32 *pnBytesOut, /* O Number of payload bytes */ - ec_enc *psRangeEnc, /* I/O compressor data structure */ - opus_int condCoding, /* I The type of conditional coding to use */ - opus_int maxBits, /* I If > 0: maximum number of output bits */ - opus_int useCBR /* I Flag to force constant-bitrate operation */ + silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ + opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */ + ec_enc *psRangeEnc, /* I/O compressor data structure */ + opus_int condCoding, /* I The type of conditional coding to use */ + opus_int maxBits, /* I If > 0: maximum number of output bits */ + opus_int useCBR /* I Flag to force constant-bitrate operation */ ) { silk_encoder_control_FIX sEncCtrl; @@ -99,10 +97,7 @@ opus_int silk_encode_frame_FIX( opus_int8 LastGainIndex_copy2; 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; psEnc->sCmn.indices.Seed = psEnc->sCmn.frameCounter++ & 3; @@ -127,47 +122,34 @@ TIC(ENCODE_FRAME) /*****************************************/ /* Find pitch lags, initial LPC analysis */ /*****************************************/ -TIC(FIND_PITCH) silk_find_pitch_lags_FIX( psEnc, &sEncCtrl, res_pitch, x_frame ); -TOC(FIND_PITCH) /************************/ /* Noise shape analysis */ /************************/ -TIC(NOISE_SHAPE_ANALYSIS) silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame ); -TOC(NOISE_SHAPE_ANALYSIS) /***************************************************/ /* Find linear prediction coefficients (LPC + LTP) */ /***************************************************/ -TIC(FIND_PRED_COEF) silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch, x_frame, condCoding ); -TOC(FIND_PRED_COEF) /****************************************/ /* Process gains */ /****************************************/ -TIC(PROCESS_GAINS) silk_process_gains_FIX( psEnc, &sEncCtrl, condCoding ); -TOC(PROCESS_GAINS) /*****************************************/ /* Prefiltering for noise shaper */ /*****************************************/ -TIC(PREFILTER) silk_prefilter_FIX( psEnc, &sEncCtrl, xfw, x_frame ); -TOC(PREFILTER) /****************************************/ /* Low Bitrate Redundant Encoding */ /****************************************/ -TIC(LBRR) silk_LBRR_encode_FIX( psEnc, &sEncCtrl, xfw, condCoding ); -TOC(LBRR) if( psEnc->sCmn.prefillFlag ) { -TIC(NSQ) 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, 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.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 ); } -TOC(NSQ) } else { /* Loop over quantizer and entropy coding to control bitrate */ maxIter = 5; @@ -211,7 +192,6 @@ TOC(NSQ) /*****************************************/ /* Noise shaping quantization */ /*****************************************/ -TIC(NSQ) 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, 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.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 ); } -TOC(NSQ) /****************************************/ /* Encode Parameters */ /****************************************/ -TIC(ENCODE_PARAMS) silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding ); -TOC(ENCODE_PARAMS) /****************************************/ /* Encode Excitation Signal */ /****************************************/ -TIC(ENCODE_PULSES) silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, psEnc->sCmn.pulses, psEnc->sCmn.frame_length ); -TOC(ENCODE_PULSES) nBits = ec_tell( psRangeEnc ); @@ -344,59 +319,15 @@ TOC(ENCODE_PULSES) /* Payload size */ *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 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; } /* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */ -void silk_LBRR_encode_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ - const opus_int16 xfw[], /* I Input signal */ - opus_int condCoding /* I The type of conditional coding used so far for this frame */ +static inline void silk_LBRR_encode_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ + const opus_int16 xfw[], /* I Input signal */ + opus_int condCoding /* I The type of conditional coding used so far for this frame */ ) { opus_int32 TempGains_Q16[ MAX_NB_SUBFR ]; diff --git a/silk/fixed/find_LPC_FIX.c b/silk/fixed/find_LPC_FIX.c index aab4d0ff..c11826e5 100644 --- a/silk/fixed/find_LPC_FIX.c +++ b/silk/fixed/find_LPC_FIX.c @@ -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 */ void silk_find_LPC_FIX( - opus_int16 NLSF_Q15[], /* O NLSFs */ - opus_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */ - const opus_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */ - const opus_int useInterpNLSFs, /* I Flag */ - const opus_int firstFrameAfterReset, /* I Flag */ - const opus_int LPC_order, /* I LPC order */ - const opus_int16 x[], /* I Input signal */ - const opus_int subfr_length, /* I Input signal subframe length including preceeding samples */ - const opus_int nb_subfr /* I: Number of subframes */ + opus_int16 NLSF_Q15[], /* O NLSFs */ + opus_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */ + const opus_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */ + const opus_int useInterpNLSFs, /* I Flag */ + const opus_int firstFrameAfterReset, /* I Flag */ + const opus_int LPC_order, /* I LPC order */ + const opus_int16 x[], /* I Input signal */ + const opus_int subfr_length, /* I Input signal subframe length including preceeding samples */ + const opus_int nb_subfr /* I Number of subframes */ ) { opus_int k; diff --git a/silk/fixed/find_LTP_FIX.c b/silk/fixed/find_LTP_FIX.c index 2de290d5..daa3fef3 100644 --- a/silk/fixed/find_LTP_FIX.c +++ b/silk/fixed/find_LTP_FIX.c @@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FIX.h" #include "tuning_parameters.h" -/* Head room for correlations */ +/* Head room for correlations */ #define LTP_CORRS_HEAD_ROOM 2 void silk_fit_LTP( @@ -41,16 +41,16 @@ void silk_fit_LTP( ); void silk_find_LTP_FIX( - opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */ - opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ - opus_int *LTPredCodGain_Q7, /* O LTP coding gain */ - const opus_int16 r_lpc[] , /* I residual signal after LPC signal + state for first 10 ms */ - const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ - const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */ - const opus_int subfr_length, /* I subframe length */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int mem_offset, /* I number of samples in LTP memory */ - opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */ + opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */ + opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ + opus_int *LTPredCodGain_Q7, /* O LTP coding gain */ + const opus_int16 r_lpc[], /* I residual signal after LPC signal + state for first 10 ms */ + const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ + const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */ + const opus_int subfr_length, /* I subframe length */ + const opus_int nb_subfr, /* I number of subframes */ + const opus_int mem_offset, /* I number of samples in LTP memory */ + opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */ ) { 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 ) */ silk_RSHIFT( silk_SMULWB( subfr_length, 655 ), corr_rshifts[ k ] - extra_shifts ); /* Q( -corr_rshifts[ k ] + extra_shifts ) */ denom32 = silk_max( denom32, 1 ); - 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_RSHIFT( temp32, 31 + corr_rshifts[ k ] - extra_shifts - 26 ); /* Q26 */ + 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_RSHIFT( temp32, 31 + corr_rshifts[ k ] - extra_shifts - 26 ); /* Q26 */ /* Limit temp such that the below scaling never wraps around */ WLTP_max = 0; @@ -148,8 +148,8 @@ void silk_find_LTP_FIX( LPC_res_nrg = 0; silk_assert( LTP_CORRS_HEAD_ROOM >= 2 ); /* Check that no overflow will happen when adding */ 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_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_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_max( LPC_LTP_res_nrg, 1 ); /* avoid division by zero */ @@ -198,7 +198,7 @@ void silk_find_LTP_FIX( wd = 0; for( k = 0; k < nb_subfr; k++ ) { /* 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 ) */ } m_Q12 = silk_DIV32_varQ( wd, temp32, 12 ); @@ -215,7 +215,7 @@ void silk_find_LTP_FIX( g_Q26 = silk_MUL( silk_DIV32( 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 */ temp32 = 0; @@ -229,7 +229,6 @@ void silk_find_LTP_FIX( } b_Q14_ptr += LTP_ORDER; } -TOC(find_LTP_FIX) } void silk_fit_LTP( diff --git a/silk/fixed/find_pitch_lags_FIX.c b/silk/fixed/find_pitch_lags_FIX.c index c40efe94..0f411581 100644 --- a/silk/fixed/find_pitch_lags_FIX.c +++ b/silk/fixed/find_pitch_lags_FIX.c @@ -34,10 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Find pitch lags */ void silk_find_pitch_lags_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - opus_int16 res[], /* O residual */ - const opus_int16 x[] /* I Speech signal */ + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ + opus_int16 res[], /* O residual */ + const opus_int16 x[] /* I Speech signal */ ) { opus_int buf_len, i, scale; diff --git a/silk/fixed/find_pred_coefs_FIX.c b/silk/fixed/find_pred_coefs_FIX.c index 2cefd905..27e0c2c3 100644 --- a/silk/fixed/find_pred_coefs_FIX.c +++ b/silk/fixed/find_pred_coefs_FIX.c @@ -32,11 +32,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FIX.h" void silk_find_pred_coefs_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - const opus_int16 res_pitch[], /* I Residual from pitch analysis */ - const opus_int16 x[], /* I Speech signal */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ + const opus_int16 res_pitch[], /* I Residual from pitch analysis */ + const opus_int16 x[], /* I Speech signal */ + opus_int condCoding /* I The type of conditional coding to use */ ) { 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 */ - TIC(FIND_LPC) 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, LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr ); - TOC(FIND_LPC) /* Quantize LSFs */ - TIC(PROCESS_LSFS) 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 */ silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains, diff --git a/silk/fixed/k2a_FIX.c b/silk/fixed/k2a_FIX.c index 98c6bf29..9ccdc414 100644 --- a/silk/fixed/k2a_FIX.c +++ b/silk/fixed/k2a_FIX.c @@ -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 */ void silk_k2a( - opus_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ - const opus_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */ - const opus_int32 order /* I: Prediction order */ + opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */ + const opus_int16 *rc_Q15, /* I Reflection coefficients [order] Q15 */ + const opus_int32 order /* I Prediction order */ ) { opus_int k, n; diff --git a/silk/fixed/k2a_Q16_FIX.c b/silk/fixed/k2a_Q16_FIX.c index 962e2306..3f39d5fc 100644 --- a/silk/fixed/k2a_Q16_FIX.c +++ b/silk/fixed/k2a_Q16_FIX.c @@ -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 */ void silk_k2a_Q16( - opus_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ - const opus_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */ - const opus_int32 order /* I: Prediction order */ + opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */ + const opus_int32 *rc_Q16, /* I Reflection coefficients [order] Q16 */ + const opus_int32 order /* I Prediction order */ ) { opus_int k, n; diff --git a/silk/fixed/main_FIX.h b/silk/fixed/main_FIX.h index f4b0270c..30782e12 100644 --- a/silk/fixed/main_FIX.h +++ b/silk/fixed/main_FIX.h @@ -53,47 +53,47 @@ extern "C" /* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */ void silk_HP_variable_cutoff( - silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */ + silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */ ); /* Encoder main function */ 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 */ opus_int silk_encode_frame_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */ - ec_enc *psRangeEnc, /* I/O compressor data structure */ - opus_int condCoding, /* I The type of conditional coding to use */ - opus_int maxBits, /* I If > 0: maximum number of output bits */ - opus_int useCBR /* I Flag to force constant-bitrate operation */ + silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ + opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */ + ec_enc *psRangeEnc, /* I/O compressor data structure */ + opus_int condCoding, /* I The type of conditional coding to use */ + opus_int maxBits, /* I If > 0: maximum number of output bits */ + opus_int useCBR /* I Flag to force constant-bitrate operation */ ); /* Initializes the Silk encoder state */ 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 */ opus_int silk_control_encoder( - silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk encoder state */ - silk_EncControlStruct *encControl, /* I: Control structure */ - const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */ - const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ - const opus_int channelNb, /* I Channel number */ - const opus_int force_fs_kHz + silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */ + silk_EncControlStruct *encControl, /* I Control structure */ + const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */ + const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ + const opus_int channelNb, /* I Channel number */ + const opus_int force_fs_kHz ); /****************/ /* Prefiltering */ /****************/ void silk_prefilter_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ - const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */ - opus_int16 xw[], /* O Weighted signal */ - const opus_int16 x[] /* I Speech signal */ + silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ + const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */ + opus_int16 xw[], /* O Weighted signal */ + const opus_int16 x[] /* I Speech signal */ ); /**************************/ @@ -101,27 +101,27 @@ void silk_prefilter_FIX( /**************************/ /* Compute noise shaping coefficients and initial gain values */ void silk_noise_shape_analysis_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ - const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */ - const opus_int16 *x /* I Input signal [ frame_length + la_shape ] */ + silk_encoder_state_FIX *psEnc, /* I/O Encoder state 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 *x /* I Input signal [ frame_length + la_shape ] */ ); /* Autocorrelations for a warped frequency axis */ void silk_warped_autocorrelation_FIX( - opus_int32 *corr, /* O Result [order + 1] */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *input, /* I Input data to correlate */ - const opus_int warping_Q16, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ + opus_int32 *corr, /* O Result [order + 1] */ + opus_int *scale, /* O Scaling of the correlation vector */ + const opus_int16 *input, /* I Input data to correlate */ + const opus_int warping_Q16, /* I Warping coefficient */ + const opus_int length, /* I Length of input */ + const opus_int order /* I Correlation order (even) */ ); /* Calculation of LTP state scaling */ void silk_LTP_scale_ctrl_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ + opus_int condCoding /* I The type of conditional coding to use */ ); /**********************************************/ @@ -129,87 +129,87 @@ void silk_LTP_scale_ctrl_FIX( /**********************************************/ /* Find pitch lags */ void silk_find_pitch_lags_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - opus_int16 res[], /* O residual */ - const opus_int16 x[] /* I Speech signal */ + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ + opus_int16 res[], /* O residual */ + const opus_int16 x[] /* I Speech signal */ ); /* Find LPC and LTP coefficients */ void silk_find_pred_coefs_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - const opus_int16 res_pitch[], /* I Residual from pitch analysis */ - const opus_int16 x[], /* I Speech signal */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ + const opus_int16 res_pitch[], /* I Residual from pitch analysis */ + const opus_int16 x[], /* I Speech signal */ + opus_int condCoding /* I The type of conditional coding to use */ ); /* LPC analysis */ void silk_find_LPC_FIX( - opus_int16 NLSF_Q15[], /* O NLSFs */ - opus_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */ - const opus_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */ - const opus_int useInterpNLSFs, /* I Flag */ - const opus_int firstFrameAfterReset, /* I Flag */ - const opus_int LPC_order, /* I LPC order */ - const opus_int16 x[], /* I Input signal */ - const opus_int subfr_length, /* I Input signal subframe length including preceeding samples */ - const opus_int nb_subfr /* I: Number of subframes */ + opus_int16 NLSF_Q15[], /* O NLSFs */ + opus_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */ + const opus_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */ + const opus_int useInterpNLSFs, /* I Flag */ + const opus_int firstFrameAfterReset, /* I Flag */ + const opus_int LPC_order, /* I LPC order */ + const opus_int16 x[], /* I Input signal */ + const opus_int subfr_length, /* I Input signal subframe length including preceeding samples */ + const opus_int nb_subfr /* I Number of subframes */ ); /* LTP analysis */ void silk_find_LTP_FIX( - opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */ - opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ - opus_int *LTPredCodGain_Q7, /* O LTP coding gain */ - const opus_int16 r_lpc[], /* I residual signal after LPC signal + state for first 10 ms */ - const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ - const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */ - const opus_int subfr_length, /* I subframe length */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int mem_offset, /* I number of samples in LTP memory */ - opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */ + opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */ + opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ + opus_int *LTPredCodGain_Q7, /* O LTP coding gain */ + const opus_int16 r_lpc[], /* I residual signal after LPC signal + state for first 10 ms */ + const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ + const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */ + const opus_int subfr_length, /* I subframe length */ + const opus_int nb_subfr, /* I number of subframes */ + const opus_int mem_offset, /* I number of samples in LTP memory */ + opus_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */ ); void silk_LTP_analysis_filter_FIX( - opus_int16 *LTP_res, /* O: LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */ - const opus_int16 *x, /* I: Pointer to input signal with at least max( pitchL ) preceeding samples */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I: LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I: Pitch lag, one for each subframe */ - const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I: Inverse quantization gains, one for each subframe */ - const opus_int subfr_length, /* I: Length of each subframe */ - const opus_int nb_subfr, /* I: Number of subframes */ - const opus_int pre_length /* I: Length of the preceeding samples starting at &x[0] for each subframe */ + opus_int16 *LTP_res, /* O LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */ + const opus_int16 *x, /* I Pointer to input signal with at least max( pitchL ) preceeding samples */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag, one for each subframe */ + const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I Inverse quantization gains, one for each subframe */ + const opus_int subfr_length, /* I Length of each subframe */ + const opus_int nb_subfr, /* I Number of subframes */ + const opus_int pre_length /* I Length of the preceeding samples starting at &x[0] for each subframe */ ); /* Calculates residual energies of input subframes where all subframes have LPC_order */ /* of preceeding samples */ void silk_residual_energy_FIX( - opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ - opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */ - const opus_int16 x[], /* I Input signal */ - opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ - const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I Number of subframes */ - const opus_int LPC_order /* I LPC order */ + opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ + opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */ + const opus_int16 x[], /* I Input signal */ + opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ + const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */ + const opus_int subfr_length, /* I Subframe length */ + const opus_int nb_subfr, /* I Number of subframes */ + const opus_int LPC_order /* I LPC order */ ); /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ opus_int32 silk_residual_energy16_covar_FIX( - const opus_int16 *c, /* I Prediction vector */ - const opus_int32 *wXX, /* I Correlation matrix */ - const opus_int32 *wXx, /* I Correlation vector */ - opus_int32 wxx, /* I Signal energy */ - opus_int D, /* I Dimension */ - opus_int cQ /* I Q value for c vector 0 - 15 */ + const opus_int16 *c, /* I Prediction vector */ + const opus_int32 *wXX, /* I Correlation matrix */ + const opus_int32 *wXx, /* I Correlation vector */ + opus_int32 wxx, /* I Signal energy */ + opus_int D, /* I Dimension */ + opus_int cQ /* I Q value for c vector 0 - 15 */ ); /* Processing of gains */ void silk_process_gains_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control */ + 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 */ void silk_corrMatrix_FIX( - const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ - const opus_int L, /* I Length of vectors */ - const opus_int order, /* I Max lag for correlation */ - const opus_int head_room, /* I Desired headroom */ - opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ]*/ - opus_int *rshifts /* I/O Right shifts of correlations */ + const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ + const opus_int L, /* I Length of vectors */ + const opus_int order, /* I Max lag for correlation */ + const opus_int head_room, /* I Desired headroom */ + opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */ + opus_int *rshifts /* I/O Right shifts of correlations */ ); /* Calculates correlation vector X'*t */ void silk_corrVector_FIX( - const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ - const opus_int16 *t, /* I Target vector [L] */ - const opus_int L, /* I Length of vectors */ - const opus_int order, /* I Max lag for correlation */ - opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */ - const opus_int rshifts /* I Right shifts of correlations */ + const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ + const opus_int16 *t, /* I Target vector [L] */ + const opus_int L, /* I Length of vectors */ + const opus_int order, /* I Max lag for correlation */ + opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */ + const opus_int rshifts /* I Right shifts of correlations */ ); /* Add noise to matrix diagonal */ void silk_regularize_correlations_FIX( - opus_int32 *XX, /* I/O Correlation matrices */ - opus_int32 *xx, /* I/O Correlation values */ - opus_int32 noise, /* I Noise to add */ - opus_int D /* I Dimension of XX */ + opus_int32 *XX, /* I/O Correlation matrices */ + opus_int32 *xx, /* I/O Correlation values */ + opus_int32 noise, /* I Noise to add */ + opus_int D /* I Dimension of XX */ ); /* Solves Ax = b, assuming A is symmetric */ void silk_solve_LDL_FIX( - opus_int32 *A, /* I Pointer to symetric square matrix A */ - opus_int M, /* I Size of matrix */ - const opus_int32 *b, /* I Pointer to b vector */ - opus_int32 *x_Q16 /* O Pointer to x solution vector */ + opus_int32 *A, /* I Pointer to symetric square matrix A */ + opus_int M, /* I Size of matrix */ + const opus_int32 *b, /* I Pointer to b vector */ + opus_int32 *x_Q16 /* O Pointer to x solution vector */ ); #ifndef FORCE_CPP_BUILD diff --git a/silk/fixed/noise_shape_analysis_FIX.c b/silk/fixed/noise_shape_analysis_FIX.c index 8f5ac7bf..d2ed8e0e 100644 --- a/silk/fixed/noise_shape_analysis_FIX.c +++ b/silk/fixed/noise_shape_analysis_FIX.c @@ -139,10 +139,10 @@ static inline void limit_warped_coefs( /* Compute noise shaping coefficients and initial gain values */ /**************************************************************/ void silk_noise_shape_analysis_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ - const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */ - const opus_int16 *x /* I Input signal [ frame_length + la_shape ] */ + silk_encoder_state_FIX *psEnc, /* I/O Encoder state 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 *x /* I Input signal [ frame_length + la_shape ] */ ) { silk_shape_state_FIX *psShapeSt = &psEnc->sShape; diff --git a/silk/fixed/pitch_analysis_core_FIX.c b/silk/fixed/pitch_analysis_core_FIX.c index e5ea07b8..f76c611a 100644 --- a/silk/fixed/pitch_analysis_core_FIX.c +++ b/silk/fixed/pitch_analysis_core_FIX.c @@ -68,18 +68,18 @@ opus_int32 silk_P_Ana_find_scaling( /*************************************************************/ /* FIXED POINT CORE PITCH ANALYSIS FUNCTION */ /*************************************************************/ -opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */ - const opus_int16 *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ - opus_int *pitch_out, /* O 4 pitch lag values */ - opus_int16 *lagIndex, /* O Lag Index */ - opus_int8 *contourIndex, /* O Pitch contour Index */ - opus_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */ - opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ - const opus_int32 search_thres1_Q16, /* I First stage threshold for lag candidates 0 - 1 */ - const opus_int search_thres2_Q15, /* I Final threshold for lag candidates 0 - 1 */ - const opus_int Fs_kHz, /* I Sample frequency (kHz) */ - const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */ - const opus_int nb_subfr /* I number of 5 ms subframes */ +opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */ + const opus_int16 *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ + opus_int *pitch_out, /* O 4 pitch lag values */ + opus_int16 *lagIndex, /* O Lag Index */ + opus_int8 *contourIndex, /* O Pitch contour Index */ + opus_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */ + opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ + const opus_int32 search_thres1_Q16, /* I First stage threshold for lag candidates 0 - 1 */ + const opus_int search_thres2_Q15, /* I Final threshold for lag candidates 0 - 1 */ + const opus_int Fs_kHz, /* I Sample frequency (kHz) */ + const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */ + const opus_int nb_subfr /* I number of 5 ms subframes */ ) { 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 ) { silk_memset( filt_state, 0, 2 * sizeof( opus_int32 ) ); 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_resampler_down2_3( filt_state, frame_8kHz, frame, frame_length ); } 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 */ } - if ( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */ - 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 */ - ) { + if( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */ + 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 */ + ) { CCmax_b = CCmax_new_b; CCmax = CCmax_new; lag = d; @@ -450,10 +450,9 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 } 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 */ shift = silk_P_Ana_find_scaling( frame, frame_length, sf_length ); if( shift > 0 ) { @@ -466,7 +465,6 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 } else { input_frame_ptr = (opus_int16*)frame; } - /*********************************************************************************/ /* 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_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_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; 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_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_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ]; diff --git a/silk/fixed/prefilter_FIX.c b/silk/fixed/prefilter_FIX.c index 493a46b0..b930f49f 100644 --- a/silk/fixed/prefilter_FIX.c +++ b/silk/fixed/prefilter_FIX.c @@ -32,26 +32,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FIX.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( - silk_prefilter_state_FIX *P, /* I/O state */ - opus_int32 st_res_Q12[], /* I short term residual signal */ - opus_int16 xw[], /* O prefiltered signal */ - opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */ - opus_int Tilt_Q14, /* I Tilt shaping coeficient */ - opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients*/ - opus_int lag, /* I Lag for harmonic shaping */ - opus_int length /* I Length of signals */ + silk_prefilter_state_FIX *P, /* I/O state */ + opus_int32 st_res_Q12[], /* I short term residual signal */ + opus_int16 xw[], /* O prefiltered signal */ + opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */ + opus_int Tilt_Q14, /* I Tilt shaping coeficient */ + opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients */ + opus_int lag, /* I Lag for harmonic shaping */ + opus_int length /* I Length of signals */ ); void silk_warped_LPC_analysis_filter_FIX( - opus_int32 state[], /* I/O State [order + 1] */ - opus_int16 res[], /* O Residual signal [length] */ - const opus_int16 coef_Q13[], /* I Coefficients [order] */ - const opus_int16 input[], /* I Input signal [length] */ - const opus_int16 lambda_Q16, /* I Warping factor */ - const opus_int length, /* I Length of input signal */ - const opus_int order /* I Filter order (even) */ + opus_int32 state[], /* I/O State [order + 1] */ + opus_int16 res[], /* O Residual signal [length] */ + const opus_int16 coef_Q13[], /* I Coefficients [order] */ + const opus_int16 input[], /* I Input signal [length] */ + const opus_int16 lambda_Q16, /* I Warping factor */ + const opus_int length, /* I Length of input signal */ + const opus_int order /* I Filter order (even) */ ) { opus_int n, i; @@ -86,10 +86,10 @@ void silk_warped_LPC_analysis_filter_FIX( } void silk_prefilter_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ - const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control FIX */ - opus_int16 xw[], /* O Weighted signal */ - const opus_int16 x[] /* I Speech signal */ + silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ + const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */ + opus_int16 xw[], /* O Weighted signal */ + const opus_int16 x[] /* I Speech signal */ ) { silk_prefilter_state_FIX *P = &psEnc->sPrefilt; @@ -151,16 +151,16 @@ void silk_prefilter_FIX( 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( - silk_prefilter_state_FIX *P, /* I/O state */ - opus_int32 st_res_Q12[], /* I short term residual signal */ - opus_int16 xw[], /* O prefiltered signal */ - opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */ - opus_int Tilt_Q14, /* I Tilt shaping coeficient */ - opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients*/ - opus_int lag, /* I Lag for harmonic shaping */ - opus_int length /* I Length of signals */ + silk_prefilter_state_FIX *P, /* I/O state */ + opus_int32 st_res_Q12[], /* I short term residual signal */ + opus_int16 xw[], /* O prefiltered signal */ + opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */ + opus_int Tilt_Q14, /* I Tilt shaping coeficient */ + opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients */ + opus_int lag, /* I Lag for harmonic shaping */ + opus_int length /* I Length of signals */ ) { opus_int i, idx, LTP_shp_buf_idx; diff --git a/silk/fixed/process_gains_FIX.c b/silk/fixed/process_gains_FIX.c index f56a8f2f..740be0bc 100644 --- a/silk/fixed/process_gains_FIX.c +++ b/silk/fixed/process_gains_FIX.c @@ -34,12 +34,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Processing of gains */ void silk_process_gains_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state_FIX */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control_FIX */ - opus_int condCoding /* The type of conditional coding to use */ + silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control */ + 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_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 ); gain = silk_SQRT_APPROX( gain_squared ); /* Q8 */ 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 { gain = silk_SQRT_APPROX( gain_squared ); /* Q0 */ 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 */ } } diff --git a/silk/fixed/regularize_correlations_FIX.c b/silk/fixed/regularize_correlations_FIX.c index d8e79949..f0dac4a4 100644 --- a/silk/fixed/regularize_correlations_FIX.c +++ b/silk/fixed/regularize_correlations_FIX.c @@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Add noise to matrix diagonal */ void silk_regularize_correlations_FIX( - opus_int32 *XX, /* I/O Correlation matrices */ - opus_int32 *xx, /* I/O Correlation values */ - opus_int32 noise, /* I Noise to add */ - opus_int D /* I Dimension of XX */ + opus_int32 *XX, /* I/O Correlation matrices */ + opus_int32 *xx, /* I/O Correlation values */ + opus_int32 noise, /* I Noise to add */ + opus_int D /* I Dimension of XX */ ) { opus_int i; diff --git a/silk/fixed/residual_energy16_FIX.c b/silk/fixed/residual_energy16_FIX.c index e73cdf85..bbd10275 100644 --- a/silk/fixed/residual_energy16_FIX.c +++ b/silk/fixed/residual_energy16_FIX.c @@ -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 */ opus_int32 silk_residual_energy16_covar_FIX( - const opus_int16 *c, /* I Prediction vector */ - const opus_int32 *wXX, /* I Correlation matrix */ - const opus_int32 *wXx, /* I Correlation vector */ - opus_int32 wxx, /* I Signal energy */ - opus_int D, /* I Dimension */ - opus_int cQ /* I Q value for c vector 0 - 15 */ + const opus_int16 *c, /* I Prediction vector */ + const opus_int32 *wXX, /* I Correlation matrix */ + const opus_int32 *wXx, /* I Correlation vector */ + opus_int32 wxx, /* I Signal energy */ + opus_int D, /* I Dimension */ + opus_int cQ /* I Q value for c vector 0 - 15 */ ) { opus_int i, j, lshifts, Qxtra; diff --git a/silk/fixed/residual_energy_FIX.c b/silk/fixed/residual_energy_FIX.c index 0053a89d..38948810 100644 --- a/silk/fixed/residual_energy_FIX.c +++ b/silk/fixed/residual_energy_FIX.c @@ -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 */ /* of preceeding samples */ void silk_residual_energy_FIX( - opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ - opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */ - const opus_int16 x[], /* I Input signal */ - opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ - const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I Number of subframes */ - const opus_int LPC_order /* I LPC order */ + opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ + opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */ + const opus_int16 x[], /* I Input signal */ + opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ + const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */ + const opus_int subfr_length, /* I Subframe length */ + const opus_int nb_subfr, /* I Number of subframes */ + const opus_int LPC_order /* I LPC order */ ) { opus_int offset, i, j, rshift, lz1, lz2; diff --git a/silk/fixed/schur64_FIX.c b/silk/fixed/schur64_FIX.c index 8c9ee057..bab71155 100644 --- a/silk/fixed/schur64_FIX.c +++ b/silk/fixed/schur64_FIX.c @@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Slower than schur(), but more accurate. */ /* Uses SMULL(), available on armv4 */ -opus_int32 silk_schur64( /* O: Returns residual energy */ - opus_int32 rc_Q16[], /* O: Reflection coefficients [order] Q16 */ - const opus_int32 c[], /* I: Correlations [order+1] */ - opus_int32 order /* I: Prediction order */ +opus_int32 silk_schur64( /* O returns residual energy */ + opus_int32 rc_Q16[], /* O Reflection coefficients [order] Q16 */ + const opus_int32 c[], /* I Correlations [order+1] */ + opus_int32 order /* I Prediction order */ ) { opus_int k, n; diff --git a/silk/fixed/schur_FIX.c b/silk/fixed/schur_FIX.c index 86f37345..14e45780 100644 --- a/silk/fixed/schur_FIX.c +++ b/silk/fixed/schur_FIX.c @@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Faster than schur64(), but much less accurate. */ /* uses SMLAWB(), requiring armv5E and higher. */ -opus_int32 silk_schur( /* O: Returns residual energy */ - opus_int16 *rc_Q15, /* O: reflection coefficients [order] Q15 */ - const opus_int32 *c, /* I: correlations [order+1] */ - const opus_int32 order /* I: prediction order */ +opus_int32 silk_schur( /* O Returns residual energy */ + opus_int16 *rc_Q15, /* O reflection coefficients [order] Q15 */ + const opus_int32 *c, /* I correlations [order+1] */ + const opus_int32 order /* I prediction order */ ) { opus_int k, n, lz; diff --git a/silk/fixed/silk_fixed.vcxproj b/silk/fixed/silk_fixed.vcxproj index 638fab57..e6076542 100644 --- a/silk/fixed/silk_fixed.vcxproj +++ b/silk/fixed/silk_fixed.vcxproj @@ -1,124 +1,125 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {8484C90D-1561-402F-A91D-2DB10F8C5171} - Win32Proj - src_FIX - silk_fixed - - - - StaticLibrary - true - Unicode - - - StaticLibrary - false - true - Unicode - - - - - - - - - - - - - $(ProjectName) - - - $(ProjectName) - - - - - - Level3 - Disabled - HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - ../;../../win32;../../celt - - - Windows - true - - - $(OutDir)$(TargetName)$(TargetExt) - - - - - Level3 - - - MaxSpeed - true - true - HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - ../;../../win32;../../celt - - - Windows - true - true - true - - - $(OutDir)$(TargetName)$(TargetExt) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + + {8484C90D-1561-402F-A91D-2DB10F8C5171} + Win32Proj + src_FIX + silk_fixed + + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + $(ProjectName) + + + $(ProjectName) + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ../;../../win32;../../celt;../../include + + + Windows + true + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ../;../../win32;../../celt;../../include + + + Windows + true + true + true + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/silk/fixed/silk_fixed.vcxproj.filters b/silk/fixed/silk_fixed.vcxproj.filters index 252d975c..dfdc069c 100644 --- a/silk/fixed/silk_fixed.vcxproj.filters +++ b/silk/fixed/silk_fixed.vcxproj.filters @@ -1,111 +1,114 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + \ No newline at end of file diff --git a/silk/fixed/solve_LS_FIX.c b/silk/fixed/solve_LS_FIX.c index 3285051e..f6b5da01 100644 --- a/silk/fixed/solve_LS_FIX.c +++ b/silk/fixed/solve_LS_FIX.c @@ -43,40 +43,40 @@ typedef struct { /* Factorize square matrix A into LDL form */ static inline void silk_LDL_factorize_FIX( - opus_int32 *A, /* I/O Pointer to Symetric Square Matrix */ - opus_int M, /* I Size of Matrix */ - opus_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */ - inv_D_t *inv_D /* I/O Pointer to vector holding inverted diagonal elements of D */ + opus_int32 *A, /* I/O Pointer to Symetric Square Matrix */ + opus_int M, /* I Size of Matrix */ + opus_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */ + inv_D_t *inv_D /* I/O Pointer to vector holding inverted diagonal elements of D */ ); /* Solve Lx = b, when L is lower triangular and has ones on the diagonal */ static inline void silk_LS_SolveFirst_FIX( - const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ - opus_int M, /* I Dim of Matrix equation */ - const opus_int32 *b, /* I b Vector */ - opus_int32 *x_Q16 /* O x Vector */ + const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ + opus_int M, /* I Dim of Matrix equation */ + const opus_int32 *b, /* I b Vector */ + opus_int32 *x_Q16 /* O x Vector */ ); /* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */ static inline void silk_LS_SolveLast_FIX( - const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ - const opus_int M, /* I Dim of Matrix equation */ - const opus_int32 *b, /* I b Vector */ - opus_int32 *x_Q16 /* O x Vector */ + const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ + const opus_int M, /* I Dim of Matrix equation */ + const opus_int32 *b, /* I b Vector */ + opus_int32 *x_Q16 /* O x Vector */ ); static inline void silk_LS_divide_Q16_FIX( - opus_int32 T[], /* I/O Numenator vector */ - inv_D_t *inv_D, /* I 1 / D vector */ - opus_int M /* I dimension */ + opus_int32 T[], /* I/O Numenator vector */ + inv_D_t *inv_D, /* I 1 / D vector */ + opus_int M /* I dimension */ ); /* Solves Ax = b, assuming A is symmetric */ void silk_solve_LDL_FIX( - opus_int32 *A, /* I Pointer to symetric square matrix A */ - opus_int M, /* I Size of matrix */ - const opus_int32 *b, /* I Pointer to b vector */ - opus_int32 *x_Q16 /* O Pointer to x solution vector */ + opus_int32 *A, /* I Pointer to symetric square matrix A */ + opus_int M, /* I Size of matrix */ + const opus_int32 *b, /* I Pointer to b vector */ + opus_int32 *x_Q16 /* O Pointer to x solution vector */ ) { 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( - opus_int32 *A, /* I Pointer to Symetric Square Matrix */ - opus_int M, /* I Size of Matrix */ - opus_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */ - inv_D_t *inv_D /* I/O Pointer to vector holding inverted diagonal elements of D */ + opus_int32 *A, /* I/O Pointer to Symetric Square Matrix */ + opus_int M, /* I Size of Matrix */ + opus_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */ + inv_D_t *inv_D /* I/O Pointer to vector holding inverted diagonal elements of D */ ) { 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( - opus_int32 T[], /* I/O Numenator vector */ - inv_D_t *inv_D, /* I 1 / D vector */ - opus_int M /* I Order */ + opus_int32 T[], /* I/O Numenator vector */ + inv_D_t *inv_D, /* I 1 / D vector */ + opus_int M /* I dimension */ ) { 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 */ static inline void silk_LS_SolveFirst_FIX( - const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ - opus_int M, /* I Dim of Matrix equation */ - const opus_int32 *b, /* I b Vector */ - opus_int32 *x_Q16 /* O x Vector */ + const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ + opus_int M, /* I Dim of Matrix equation */ + const opus_int32 *b, /* I b Vector */ + opus_int32 *x_Q16 /* O x Vector */ ) { 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 */ static inline void silk_LS_SolveLast_FIX( - const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ - const opus_int M, /* I Dim of Matrix equation */ - const opus_int32 *b, /* I b Vector */ - opus_int32 *x_Q16 /* O x Vector */ + const opus_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ + const opus_int M, /* I Dim of Matrix equation */ + const opus_int32 *b, /* I b Vector */ + opus_int32 *x_Q16 /* O x Vector */ ) { opus_int i, j; diff --git a/silk/fixed/structs_FIX.h b/silk/fixed/structs_FIX.h index 8803c7f2..4569492f 100644 --- a/silk/fixed/structs_FIX.h +++ b/silk/fixed/structs_FIX.h @@ -41,41 +41,41 @@ extern "C" /* Noise shaping analysis state */ /********************************/ typedef struct { - opus_int8 LastGainIndex; - opus_int32 HarmBoost_smth_Q16; - opus_int32 HarmShapeGain_smth_Q16; - opus_int32 Tilt_smth_Q16; + opus_int8 LastGainIndex; + opus_int32 HarmBoost_smth_Q16; + opus_int32 HarmShapeGain_smth_Q16; + opus_int32 Tilt_smth_Q16; } silk_shape_state_FIX; /********************************/ /* Prefilter state */ /********************************/ typedef struct { - opus_int16 sLTP_shp[ LTP_BUF_LENGTH ]; - opus_int32 sAR_shp[ MAX_SHAPE_LPC_ORDER + 1 ]; - opus_int sLTP_shp_buf_idx; - opus_int32 sLF_AR_shp_Q12; - opus_int32 sLF_MA_shp_Q12; - opus_int sHarmHP; - opus_int32 rand_seed; - opus_int lagPrev; + opus_int16 sLTP_shp[ LTP_BUF_LENGTH ]; + opus_int32 sAR_shp[ MAX_SHAPE_LPC_ORDER + 1 ]; + opus_int sLTP_shp_buf_idx; + opus_int32 sLF_AR_shp_Q12; + opus_int32 sLF_MA_shp_Q12; + opus_int sHarmHP; + opus_int32 rand_seed; + opus_int lagPrev; } silk_prefilter_state_FIX; /********************************/ /* Encoder state FIX */ /********************************/ typedef struct { - silk_encoder_state sCmn; /* Common struct, shared with floating-point code */ - silk_shape_state_FIX sShape; /* Shape state */ - silk_prefilter_state_FIX sPrefilt; /* Prefilter State */ + silk_encoder_state sCmn; /* Common struct, shared with floating-point code */ + silk_shape_state_FIX sShape; /* Shape state */ + silk_prefilter_state_FIX sPrefilt; /* Prefilter State */ /* 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 */ + 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 */ /* Parameters For LTP scaling Control */ - opus_int prevLTPredCodGain_Q7; - opus_int HPLTPredCodGain_Q7; + opus_int prevLTPredCodGain_Q7; + opus_int HPLTPredCodGain_Q7; } silk_encoder_state_FIX; /************************/ @@ -83,50 +83,50 @@ typedef struct { /************************/ typedef struct { /* Prediction and coding parameters */ - opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; - silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; - opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; - opus_int LTP_scale_Q14; - opus_int pitchL[ MAX_NB_SUBFR ]; + opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; + silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; + opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; + opus_int LTP_scale_Q14; + opus_int pitchL[ MAX_NB_SUBFR ]; /* Noise shaping parameters */ /* Testing */ 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 ]; - opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */ - opus_int GainsPre_Q14[ MAX_NB_SUBFR ]; - opus_int HarmBoost_Q14[ MAX_NB_SUBFR ]; - opus_int Tilt_Q14[ MAX_NB_SUBFR ]; - opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ]; - opus_int Lambda_Q10; - opus_int input_quality_Q14; - opus_int coding_quality_Q14; + opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */ + opus_int GainsPre_Q14[ MAX_NB_SUBFR ]; + opus_int HarmBoost_Q14[ MAX_NB_SUBFR ]; + opus_int Tilt_Q14[ MAX_NB_SUBFR ]; + opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ]; + opus_int Lambda_Q10; + opus_int input_quality_Q14; + opus_int coding_quality_Q14; /* measures */ - opus_int sparseness_Q8; - opus_int32 predGain_Q16; - opus_int LTPredCodGain_Q7; - opus_int32 ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */ - opus_int ResNrgQ[ MAX_NB_SUBFR ]; /* Q domain for the residual energy > 0 */ + opus_int sparseness_Q8; + opus_int32 predGain_Q16; + opus_int LTPredCodGain_Q7; + opus_int32 ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */ + opus_int ResNrgQ[ MAX_NB_SUBFR ]; /* Q domain for the residual energy > 0 */ /* Parameters for CBR mode */ - opus_int32 GainsUnq_Q16[ MAX_NB_SUBFR ]; - opus_int8 lastGainIndexPrev; + opus_int32 GainsUnq_Q16[ MAX_NB_SUBFR ]; + opus_int8 lastGainIndexPrev; } silk_encoder_control_FIX; /************************/ /* Encoder Super Struct */ /************************/ typedef struct { - silk_encoder_state_FIX state_Fxx[ ENCODER_NUM_CHANNELS ]; - stereo_enc_state sStereo; - opus_int32 nBitsExceeded; - opus_int nChannelsAPI; - opus_int nChannelsInternal; - opus_int nPrevChannelsInternal; - opus_int timeSinceSwitchAllowed_ms; - opus_int allowBandwidthSwitch; - opus_int prev_decode_only_middle; + silk_encoder_state_FIX state_Fxx[ ENCODER_NUM_CHANNELS ]; + stereo_enc_state sStereo; + opus_int32 nBitsExceeded; + opus_int nChannelsAPI; + opus_int nChannelsInternal; + opus_int nPrevChannelsInternal; + opus_int timeSinceSwitchAllowed_ms; + opus_int allowBandwidthSwitch; + opus_int prev_decode_only_middle; } silk_encoder; diff --git a/silk/fixed/vector_ops_FIX.c b/silk/fixed/vector_ops_FIX.c index d416c931..6cf41d6c 100644 --- a/silk/fixed/vector_ops_FIX.c +++ b/silk/fixed/vector_ops_FIX.c @@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Copy and multiply a vector by a constant */ void silk_scale_copy_vector16( - opus_int16 *data_out, - const opus_int16 *data_in, - opus_int32 gain_Q16, /* (I): gain in Q16 */ - const opus_int dataSize /* (I): length */ + opus_int16 *data_out, + const opus_int16 *data_in, + opus_int32 gain_Q16, /* I Gain in Q16 */ + const opus_int dataSize /* I Length */ ) { opus_int i; @@ -50,28 +50,27 @@ void silk_scale_copy_vector16( /* Multiply a vector by a constant */ void silk_scale_vector32_Q26_lshift_18( - opus_int32 *data1, /* (I/O): Q0/Q18 */ - opus_int32 gain_Q26, /* (I): Q26 */ - opus_int dataSize /* (I): length */ + opus_int32 *data1, /* I/O Q0/Q18 */ + opus_int32 gain_Q26, /* I Q26 */ + opus_int dataSize /* I length */ ) { opus_int 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;i6, memory access can be reduced by half. */ - opus_int32 silk_inner_prod_aligned( - const opus_int16 *const inVec1, /* I input vector 1 */ - const opus_int16 *const inVec2, /* I input vector 2 */ - const opus_int len /* I vector lengths */ + const opus_int16 *const inVec1, /* I input vector 1 */ + const opus_int16 *const inVec2, /* I input vector 2 */ + const opus_int len /* I vector lengths */ ) { opus_int i; @@ -83,9 +82,9 @@ opus_int32 silk_inner_prod_aligned( } opus_int64 silk_inner_prod16_aligned_64( - const opus_int16 *inVec1, /* I input vector 1 */ - const opus_int16 *inVec2, /* I input vector 2 */ - const opus_int len /* I vector lengths */ + const opus_int16 *inVec1, /* I input vector 1 */ + const opus_int16 *inVec2, /* I input vector 2 */ + const opus_int len /* I vector lengths */ ) { opus_int i; @@ -97,9 +96,9 @@ opus_int64 silk_inner_prod16_aligned_64( } /* Function that returns the maximum absolut value of the input vector */ -opus_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */ - const opus_int16 *vec, /* I Input vector [len] */ - const opus_int32 len /* I Length of input vector */ +opus_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */ + const opus_int16 *vec, /* I Input vector [len] */ + const opus_int32 len /* I Length of input vector */ ) { 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 */ - if( max >= 1073676289 ) { /* (2^15-1)^2 = 1073676289*/ + if( max >= 1073676289 ) { /* (2^15-1)^2 = 1073676289 */ return( silk_int16_MAX ); } else { if( vec[ ind ] < 0 ) { diff --git a/silk/fixed/warped_autocorrelation_FIX.c b/silk/fixed/warped_autocorrelation_FIX.c index 73007e5b..c79c04f1 100644 --- a/silk/fixed/warped_autocorrelation_FIX.c +++ b/silk/fixed/warped_autocorrelation_FIX.c @@ -36,12 +36,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Autocorrelations for a warped frequency axis */ void silk_warped_autocorrelation_FIX( - opus_int32 *corr, /* O Result [order + 1] */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *input, /* I Input data to correlate */ - const opus_int warping_Q16, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ + opus_int32 *corr, /* O Result [order + 1] */ + opus_int *scale, /* O Scaling of the correlation vector */ + const opus_int16 *input, /* I Input data to correlate */ + const opus_int warping_Q16, /* I Warping coefficient */ + const opus_int length, /* I Length of input */ + const opus_int order /* I Correlation order (even) */ ) { opus_int n, i, lsh; diff --git a/silk/float/LPC_analysis_filter_FLP.c b/silk/float/LPC_analysis_filter_FLP.c index c91ef0ba..1413ff5a 100644 --- a/silk/float/LPC_analysis_filter_FLP.c +++ b/silk/float/LPC_analysis_filter_FLP.c @@ -51,7 +51,7 @@ static inline void silk_LPC_analysis_filter16_FLP( silk_float LPC_pred; const silk_float *s_ptr; - for ( ix = 16; ix < length; ix++) { + for( ix = 16; ix < length; ix++ ) { s_ptr = &s[ix - 1]; /* short-term prediction */ @@ -89,7 +89,7 @@ static inline void silk_LPC_analysis_filter14_FLP( silk_float LPC_pred; const silk_float *s_ptr; - for ( ix = 14; ix < length; ix++) { + for( ix = 14; ix < length; ix++ ) { s_ptr = &s[ix - 1]; /* short-term prediction */ @@ -125,7 +125,7 @@ static inline void silk_LPC_analysis_filter12_FLP( silk_float LPC_pred; const silk_float *s_ptr; - for ( ix = 12; ix < length; ix++) { + for( ix = 12; ix < length; ix++ ) { s_ptr = &s[ix - 1]; /* short-term prediction */ @@ -159,7 +159,7 @@ static inline void silk_LPC_analysis_filter10_FLP( silk_float LPC_pred; const silk_float *s_ptr; - for ( ix = 10; ix < length; ix++) { + for( ix = 10; ix < length; ix++ ) { s_ptr = &s[ix - 1]; /* short-term prediction */ @@ -191,7 +191,7 @@ static inline void silk_LPC_analysis_filter8_FLP( silk_float LPC_pred; const silk_float *s_ptr; - for ( ix = 8; ix < length; ix++) { + for( ix = 8; ix < length; ix++ ) { s_ptr = &s[ix - 1]; /* short-term prediction */ @@ -221,7 +221,7 @@ static inline void silk_LPC_analysis_filter6_FLP( silk_float LPC_pred; const silk_float *s_ptr; - for ( ix = 6; ix < length; ix++) { + for( ix = 6; ix < length; ix++ ) { s_ptr = &s[ix - 1]; /* short-term prediction */ @@ -243,13 +243,12 @@ static inline void silk_LPC_analysis_filter6_FLP( /* filter always starts with zero state */ /* first Order output samples are set to zero */ /************************************************/ - void silk_LPC_analysis_filter_FLP( - silk_float r_LPC[], /* O LPC residual signal */ - const silk_float PredCoef[], /* I LPC coefficients */ - const silk_float s[], /* I Input signal */ - const opus_int length, /* I Length of input signal */ - const opus_int Order /* I LPC order */ + silk_float r_LPC[], /* O LPC residual signal */ + const silk_float PredCoef[], /* I LPC coefficients */ + const silk_float s[], /* I Input signal */ + const opus_int length, /* I Length of input signal */ + const opus_int Order /* I LPC order */ ) { silk_assert( Order <= length ); diff --git a/silk/float/LPC_inv_pred_gain_FLP.c b/silk/float/LPC_inv_pred_gain_FLP.c index a141d111..d7a5d87e 100644 --- a/silk/float/LPC_inv_pred_gain_FLP.c +++ b/silk/float/LPC_inv_pred_gain_FLP.c @@ -36,15 +36,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* compute inverse of LPC prediction gain, and */ /* test if LPC coefficients are stable (all poles within unit circle) */ -/* this code is based on silk_a2k_FLP() */ -opus_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */ - silk_float *invGain, /* O: inverse prediction gain, energy domain */ - const silk_float *A, /* I: prediction coefficients [order] */ - opus_int32 order /* I: prediction order */ +/* this code is based on silk_a2k_FLP() */ +opus_int silk_LPC_inverse_pred_gain_FLP( /* O returns 1 if unstable, otherwise 0 */ + silk_float *invGain, /* O inverse prediction gain, energy domain */ + const silk_float *A, /* I prediction coefficients [order] */ + opus_int32 order /* I prediction order */ ) { 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 *Aold, *Anew; @@ -54,7 +54,7 @@ opus_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherw *invGain = 1.0f; for( k = order - 1; k > 0; k-- ) { rc = -Anew[ k ]; - if (rc > RC_THRESHOLD || rc < -RC_THRESHOLD) { + if( rc > RC_THRESHOLD || rc < -RC_THRESHOLD ) { return 1; } 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 ]; - if ( rc > RC_THRESHOLD || rc < -RC_THRESHOLD ) { + if( rc > RC_THRESHOLD || rc < -RC_THRESHOLD ) { return 1; } rc_mult1 = 1.0f - rc * rc; diff --git a/silk/float/LTP_analysis_filter_FLP.c b/silk/float/LTP_analysis_filter_FLP.c index 030aea11..7d2db93b 100644 --- a/silk/float/LTP_analysis_filter_FLP.c +++ b/silk/float/LTP_analysis_filter_FLP.c @@ -32,14 +32,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FLP.h" void silk_LTP_analysis_filter_FLP( - 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 B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */ - const opus_int subfr_length, /* I Length of each subframe */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int pre_length /* I Preceeding samples for each subframe */ + 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 B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */ + const opus_int subfr_length, /* I Length of each subframe */ + const opus_int nb_subfr, /* I number of subframes */ + const opus_int pre_length /* I Preceeding samples for each subframe */ ) { const silk_float *x_ptr, *x_lag_ptr; diff --git a/silk/float/LTP_scale_ctrl_FLP.c b/silk/float/LTP_scale_ctrl_FLP.c index cbac1005..ebfdbf49 100644 --- a/silk/float/LTP_scale_ctrl_FLP.c +++ b/silk/float/LTP_scale_ctrl_FLP.c @@ -32,9 +32,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FLP.h" void silk_LTP_scale_ctrl_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + opus_int condCoding /* I The type of conditional coding to use */ ) { opus_int round_loss; diff --git a/silk/float/SigProc_FLP.h b/silk/float/SigProc_FLP.h index b11c396d..bf1d8ee5 100644 --- a/silk/float/SigProc_FLP.h +++ b/silk/float/SigProc_FLP.h @@ -42,132 +42,127 @@ extern "C" /* Chirp (bw expand) LP AR filter */ void silk_bwexpander_FLP( - silk_float *ar, /* io AR filter to be expanded (without leading 1) */ - const opus_int d, /* i length of ar */ - const silk_float chirp /* i chirp factor (typically in range (0..1) ) */ + silk_float *ar, /* I/O AR filter to be expanded (without leading 1) */ + const opus_int d, /* I length of ar */ + const silk_float chirp /* I chirp factor (typically in range (0..1) ) */ ); -/* compute inverse of LPC prediction gain, and */ -/* test if LPC coefficients are stable (all poles within unit circle) */ -/* this code is based on silk_FLP_a2k() */ -opus_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */ - silk_float *invGain, /* O: inverse prediction gain, energy domain */ - const silk_float *A, /* I: prediction coefficients [order] */ - opus_int32 order /* I: prediction order */ +/* compute inverse of LPC prediction gain, and */ +/* test if LPC coefficients are stable (all poles within unit circle) */ +/* this code is based on silk_FLP_a2k() */ +opus_int silk_LPC_inverse_pred_gain_FLP( /* O returns 1 if unstable, otherwise 0 */ + silk_float *invGain, /* O inverse prediction gain, energy domain */ + const silk_float *A, /* I prediction coefficients [order] */ + opus_int32 order /* I prediction order */ ); -silk_float silk_schur_FLP( /* O returns residual energy */ - silk_float refl_coef[], /* O reflection coefficients (length order) */ - const silk_float auto_corr[], /* I autocorrelation sequence (length order+1) */ - opus_int order /* I order */ +silk_float silk_schur_FLP( /* O returns residual energy */ + silk_float refl_coef[], /* O reflection coefficients (length order) */ + const silk_float auto_corr[], /* I autocorrelation sequence (length order+1) */ + opus_int order /* I order */ ); void silk_k2a_FLP( - silk_float *A, /* O: prediction coefficients [order] */ - const silk_float *rc, /* I: reflection coefficients [order] */ - opus_int32 order /* I: prediction order */ + silk_float *A, /* O prediction coefficients [order] */ + const silk_float *rc, /* I reflection coefficients [order] */ + opus_int32 order /* I prediction order */ ); /* Solve the normal equations using the Levinson-Durbin recursion */ -silk_float silk_levinsondurbin_FLP( /* O prediction error energy */ - silk_float A[], /* O prediction coefficients [order] */ - const silk_float corr[], /* I input auto-correlations [order + 1] */ - const opus_int order /* I prediction order */ +silk_float silk_levinsondurbin_FLP( /* O prediction error energy */ + silk_float A[], /* O prediction coefficients [order] */ + const silk_float corr[], /* I input auto-correlations [order + 1] */ + const opus_int order /* I prediction order */ ); /* compute autocorrelation */ void silk_autocorrelation_FLP( - silk_float *results, /* o result (length correlationCount) */ - const silk_float *inputData, /* i input data to correlate */ - opus_int inputDataSize, /* i length of input */ - opus_int correlationCount /* i number of correlation taps to compute */ + silk_float *results, /* O result (length correlationCount) */ + const silk_float *inputData, /* I input data to correlate */ + opus_int inputDataSize, /* I length of input */ + opus_int correlationCount /* I number of correlation taps to compute */ ); -/* Pitch estimator */ -#define SigProc_PE_MIN_COMPLEX 0 -#define SigProc_PE_MID_COMPLEX 1 -#define SigProc_PE_MAX_COMPLEX 2 - -opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */ - const silk_float *signal, /* I signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ - opus_int *pitch_out, /* O 4 pitch lag values */ - opus_int16 *lagIndex, /* O lag Index */ - opus_int8 *contourIndex, /* O pitch contour Index */ - silk_float *LTPCorr, /* I/O normalized correlation; input: value from previous frame */ - opus_int prevLag, /* I last lag of previous frame; set to zero is unvoiced */ - 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 */ +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 *pitch_out, /* O Pitch lag values [nb_subfr] */ + opus_int16 *lagIndex, /* O Lag Index */ + opus_int8 *contourIndex, /* O Pitch contour Index */ + silk_float *LTPCorr, /* I/O Normalized correlation; input: value from previous frame */ + opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ + 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( - silk_float *a, /* I/O: Unsorted / Sorted vector */ - opus_int *idx, /* O: Index vector for the sorted elements */ - const opus_int L, /* I: Vector length */ - const opus_int K /* I: Number of correctly sorted positions */ + silk_float *a, /* I/O Unsorted / Sorted vector */ + opus_int *idx, /* O Index vector for the sorted elements */ + const opus_int L, /* I Vector length */ + const opus_int K /* I Number of correctly sorted positions */ ); /* Compute reflection coefficients from input signal */ -silk_float silk_burg_modified_FLP( /* O returns residual energy */ - silk_float A[], /* O prediction coefficients (length order) */ - 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 nb_subfr, /* I number of subframes stacked in x */ - const silk_float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */ - const opus_int D /* I order */ +silk_float silk_burg_modified_FLP( /* O returns residual energy */ + silk_float A[], /* O prediction coefficients (length order) */ + const silk_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ + 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 silk_float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */ + const opus_int D /* I order */ ); /* multiply a vector by a constant */ void silk_scale_vector_FLP( - silk_float *data1, - silk_float gain, - opus_int dataSize + silk_float *data1, + silk_float gain, + opus_int dataSize ); /* copy and multiply a vector by a constant */ void silk_scale_copy_vector_FLP( - silk_float *data_out, - const silk_float *data_in, - silk_float gain, - opus_int dataSize + silk_float *data_out, + const silk_float *data_in, + silk_float gain, + opus_int dataSize ); /* inner product of two silk_float arrays, with result as double */ double silk_inner_product_FLP( - const silk_float *data1, - const silk_float *data2, - opus_int dataSize + const silk_float *data1, + const silk_float *data2, + opus_int dataSize ); /* sum of squares of a silk_float array, with result as double */ double silk_energy_FLP( - const silk_float *data, - opus_int dataSize + const silk_float *data, + opus_int dataSize ); /********************************************************************/ -/* MACROS */ +/* MACROS */ /********************************************************************/ -#define silk_min_float(a, b) (((a) < (b)) ? (a) : (b)) -#define silk_max_float(a, b) (((a) > (b)) ? (a) : (b)) -#define silk_abs_float(a) ((silk_float)fabs(a)) +#define PI (3.1415926536f) + +#define silk_min_float( a, b ) (((a) < (b)) ? (a) : (b)) +#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)))) +#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 */ -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))); } /* floating-point to integer conversion (rounding) */ -static inline opus_int32 silk_float2int(double x) +static inline opus_int32 silk_float2int( double x ) { #ifdef _WIN32 double t = x + 6755399441055744.0; @@ -185,7 +180,7 @@ static inline void silk_float2short_array( ) { opus_int32 k; - for (k = length-1; k >= 0; k--) { + for( k = length - 1; k >= 0; k-- ) { #ifdef _WIN32 double t = in[k] + 6755399441055744.0; out[k] = (opus_int16)silk_SAT16(*(( opus_int32 * )( &t ))); @@ -204,13 +199,16 @@ static inline void silk_short2float_array( ) { opus_int32 k; - for (k = length-1; k >= 0; k--) { + for( k = length - 1; k >= 0; k-- ) { out[k] = (silk_float)in[k]; } } /* 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 } diff --git a/silk/float/apply_sine_window_FLP.c b/silk/float/apply_sine_window_FLP.c index 4de05dd7..d334e9d9 100644 --- a/silk/float/apply_sine_window_FLP.c +++ b/silk/float/apply_sine_window_FLP.c @@ -31,15 +31,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FLP.h" -/* Apply sine window to signal vector. */ -/* Window types: */ -/* 1 -> sine window from 0 to pi/2 */ -/* 2 -> sine window from pi/2 to pi */ +/* Apply sine window to signal vector */ +/* Window types: */ +/* 1 -> sine window from 0 to pi/2 */ +/* 2 -> sine window from pi/2 to pi */ void silk_apply_sine_window_FLP( - silk_float px_win[], /* O Pointer to windowed signal */ - const silk_float px[], /* I Pointer to input signal */ - const opus_int win_type, /* I Selects a window type */ - const opus_int length /* I Window length, multiple of 4 */ + silk_float px_win[], /* O Pointer to windowed signal */ + const silk_float px[], /* I Pointer to input signal */ + const opus_int win_type, /* I Selects a window type */ + const opus_int length /* I Window length, multiple of 4 */ ) { opus_int k; diff --git a/silk/float/autocorrelation_FLP.c b/silk/float/autocorrelation_FLP.c index 89c016df..8d388115 100644 --- a/silk/float/autocorrelation_FLP.c +++ b/silk/float/autocorrelation_FLP.c @@ -34,15 +34,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* compute autocorrelation */ void silk_autocorrelation_FLP( - silk_float *results, /* O result (length correlationCount) */ - const silk_float *inputData, /* I input data to correlate */ - opus_int inputDataSize, /* I length of input */ - opus_int correlationCount /* I number of correlation taps to compute */ + silk_float *results, /* O result (length correlationCount) */ + const silk_float *inputData, /* I input data to correlate */ + opus_int inputDataSize, /* I length of input */ + opus_int correlationCount /* I number of correlation taps to compute */ ) { opus_int i; - if ( correlationCount > inputDataSize ) { + if( correlationCount > inputDataSize ) { correlationCount = inputDataSize; } diff --git a/silk/float/burg_modified_FLP.c b/silk/float/burg_modified_FLP.c index afda4501..b5862a54 100644 --- a/silk/float/burg_modified_FLP.c +++ b/silk/float/burg_modified_FLP.c @@ -35,13 +35,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define MAX_NB_SUBFR 4 /* Compute reflection coefficients from input signal */ -silk_float silk_burg_modified_FLP( /* O returns residual energy */ - silk_float A[], /* O prediction coefficients (length order) */ - 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 nb_subfr, /* I number of subframes stacked in x */ - const silk_float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */ - const opus_int D /* I order */ +silk_float silk_burg_modified_FLP( /* O returns residual energy */ + silk_float A[], /* O prediction coefficients (length order) */ + const silk_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ + 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 silk_float WhiteNoiseFrac, /* I fraction added to zero-lag autocorrelation */ + const opus_int D /* I order */ ) { opus_int k, n, s; diff --git a/silk/float/bwexpander_FLP.c b/silk/float/bwexpander_FLP.c index 6b6acf08..1642b4b9 100644 --- a/silk/float/bwexpander_FLP.c +++ b/silk/float/bwexpander_FLP.c @@ -31,12 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FLP.h" - /* Chirp (bw expand) LP AR filter */ void silk_bwexpander_FLP( - silk_float *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I length of ar */ - const silk_float chirp /* I chirp factor (typically in range (0..1) ) */ + silk_float *ar, /* I/O AR filter to be expanded (without leading 1) */ + const opus_int d, /* I length of ar */ + const silk_float chirp /* I chirp factor (typically in range (0..1) ) */ ) { opus_int i; diff --git a/silk/float/corrMatrix_FLP.c b/silk/float/corrMatrix_FLP.c index 56ea1cd0..9de00d32 100644 --- a/silk/float/corrMatrix_FLP.c +++ b/silk/float/corrMatrix_FLP.c @@ -37,11 +37,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Calculates correlation vector X'*t */ void silk_corrVector_FLP( - const silk_float *x, /* I x vector [L+order-1] used to create X */ - const silk_float *t, /* I Target vector [L] */ - const opus_int L, /* I Length of vecors */ - const opus_int Order, /* I Max lag for correlation */ - silk_float *Xt /* O X'*t correlation vector [order] */ + const silk_float *x, /* I x vector [L+order-1] used to create X */ + const silk_float *t, /* I Target vector [L] */ + const opus_int L, /* I Length of vecors */ + const opus_int Order, /* I Max lag for correlation */ + silk_float *Xt /* O X'*t correlation vector [order] */ ) { opus_int lag; @@ -57,10 +57,10 @@ void silk_corrVector_FLP( /* Calculates correlation matrix X'*X */ void silk_corrMatrix_FLP( - 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 Order, /* I Max lag for correlation */ - silk_float *XX /* O X'*X correlation matrix [order x order] */ + 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 Order, /* I Max lag for correlation */ + silk_float *XX /* O X'*X correlation matrix [order x order] */ ) { opus_int j, lag; diff --git a/silk/float/encode_frame_FLP.c b/silk/float/encode_frame_FLP.c index 717b1e0a..08f3aa80 100644 --- a/silk/float/encode_frame_FLP.c +++ b/silk/float/encode_frame_FLP.c @@ -32,24 +32,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FLP.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( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - const silk_float xfw[], /* I Input signal */ - opus_int condCoding /* I The type of conditional coding used so far for this frame */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + const silk_float xfw[], /* I Input signal */ + opus_int condCoding /* I The type of conditional coding used so far for this frame */ ); 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 */ /****************************/ -TIC(VAD) silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 ); -TOC(VAD) /**************************************************/ /* Convert speech activity into VAD and DTX flags */ @@ -79,12 +77,12 @@ TOC(VAD) /* Encode frame */ /****************/ opus_int silk_encode_frame_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - opus_int32 *pnBytesOut, /* O Number of payload bytes */ - ec_enc *psRangeEnc, /* I/O compressor data structure */ - opus_int condCoding, /* I The type of conditional coding to use */ - opus_int maxBits, /* I If > 0: maximum number of output bits */ - opus_int useCBR /* I Flag to force constant-bitrate operation */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + opus_int32 *pnBytesOut, /* O Number of payload bytes; */ + ec_enc *psRangeEnc, /* I/O compressor data structure */ + opus_int condCoding, /* I The type of conditional coding to use */ + opus_int maxBits, /* I If > 0: maximum number of output bits */ + opus_int useCBR /* I Flag to force constant-bitrate operation */ ) { silk_encoder_control_FLP sEncCtrl; @@ -103,10 +101,7 @@ opus_int silk_encode_frame_FLP( opus_int32 pGains_Q16[ MAX_NB_SUBFR ]; 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; psEnc->sCmn.indices.Seed = psEnc->sCmn.frameCounter++ & 3; @@ -136,50 +131,35 @@ TIC(ENCODE_FRAME) /*****************************************/ /* Find pitch lags, initial LPC analysis */ /*****************************************/ -TIC(FIND_PITCH) silk_find_pitch_lags_FLP( psEnc, &sEncCtrl, res_pitch, x_frame ); -TOC(FIND_PITCH) /************************/ /* Noise shape analysis */ /************************/ -TIC(NOISE_SHAPE_ANALYSIS) silk_noise_shape_analysis_FLP( psEnc, &sEncCtrl, res_pitch_frame, x_frame ); -TOC(NOISE_SHAPE_ANALYSIS) /***************************************************/ /* Find linear prediction coefficients (LPC + LTP) */ /***************************************************/ -TIC(FIND_PRED_COEF) silk_find_pred_coefs_FLP( psEnc, &sEncCtrl, res_pitch, x_frame, condCoding ); -TOC(FIND_PRED_COEF) /****************************************/ /* Process gains */ /****************************************/ -TIC(PROCESS_GAINS) silk_process_gains_FLP( psEnc, &sEncCtrl, condCoding ); -TOC(PROCESS_GAINS) /*****************************************/ /* Prefiltering for noise shaper */ /*****************************************/ -TIC(PREFILTER) silk_prefilter_FLP( psEnc, &sEncCtrl, xfw, x_frame ); -TOC(PREFILTER) /****************************************/ /* Low Bitrate Redundant Encoding */ /****************************************/ -TIC(LBRR) silk_LBRR_encode_FLP( psEnc, &sEncCtrl, xfw, condCoding ); -TOC(LBRR) - if ( psEnc->sCmn.prefillFlag ) - { -TIC(NSQ) + if( psEnc->sCmn.prefillFlag ) { silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw ); -TOC(NSQ) } else { /* Loop over quantizer and entroy coding to control bitrate */ maxIter = 5; @@ -213,24 +193,18 @@ TOC(NSQ) /*****************************************/ /* Noise shaping quantization */ /*****************************************/ -TIC(NSQ) silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw ); -TOC(NSQ) /****************************************/ /* Encode Parameters */ /****************************************/ -TIC(ENCODE_PARAMS) silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding ); -TOC(ENCODE_PARAMS) /****************************************/ /* Encode Excitation Signal */ /****************************************/ -TIC(ENCODE_PULSES) silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, psEnc->sCmn.pulses, psEnc->sCmn.frame_length ); -TOC(ENCODE_PULSES) nBits = ec_tell( psRangeEnc ); @@ -343,32 +317,15 @@ TOC(ENCODE_PULSES) /* Payload size */ *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; } /* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */ static inline void silk_LBRR_encode_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - const silk_float xfw[], /* I Input signal */ - opus_int condCoding /* I The type of conditional coding used so far for this frame */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + const silk_float xfw[], /* I Input signal */ + opus_int condCoding /* I The type of conditional coding used so far for this frame */ ) { opus_int k; diff --git a/silk/float/energy_FLP.c b/silk/float/energy_FLP.c index f43143d5..19f902ce 100644 --- a/silk/float/energy_FLP.c +++ b/silk/float/energy_FLP.c @@ -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 */ double silk_energy_FLP( - const silk_float *data, - opus_int dataSize + const silk_float *data, + opus_int dataSize ) { opus_int i, dataSize4; diff --git a/silk/float/find_LPC_FLP.c b/silk/float/find_LPC_FLP.c index 18373fbf..23de2e73 100644 --- a/silk/float/find_LPC_FLP.c +++ b/silk/float/find_LPC_FLP.c @@ -33,15 +33,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tuning_parameters.h" void silk_find_LPC_FLP( - opus_int16 NLSF_Q15[], /* O NLSFs */ - opus_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */ - const opus_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */ - const opus_int useInterpNLSFs, /* I Flag */ - const opus_int firstFrameAfterReset, /* I Flag */ - const opus_int LPC_order, /* I LPC order */ - const silk_float x[], /* I Input signal */ - const opus_int subfr_length, /* I Subframe length incl preceeding samples */ - const opus_int nb_subfr /* I: Number of subframes */ + opus_int16 NLSF_Q15[], /* O NLSFs */ + opus_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */ + const opus_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */ + const opus_int useInterpNLSFs, /* I Flag */ + const opus_int firstFrameAfterReset, /* I Flag */ + const opus_int LPC_order, /* I LPC order */ + const silk_float x[], /* I Input signal */ + const opus_int subfr_length, /* I Subframe length incl preceeding samples */ + const opus_int nb_subfr /* I Number of subframes */ ) { opus_int k; diff --git a/silk/float/find_LTP_FLP.c b/silk/float/find_LTP_FLP.c index a95f5646..4caf4d24 100644 --- a/silk/float/find_LTP_FLP.c +++ b/silk/float/find_LTP_FLP.c @@ -33,15 +33,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tuning_parameters.h" void silk_find_LTP_FLP( - 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 *LTPredCodGain, /* O LTP coding gain */ - const silk_float r_lpc[], /* I LPC residual */ - const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ - const silk_float Wght[ MAX_NB_SUBFR ], /* I Weights */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int mem_offset /* I Number of samples in LTP memory */ + 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 *LTPredCodGain, /* O LTP coding gain */ + const silk_float r_lpc[], /* I LPC residual */ + const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ + const silk_float Wght[ MAX_NB_SUBFR ], /* I Weights */ + const opus_int subfr_length, /* I Subframe length */ + const opus_int nb_subfr, /* I number of subframes */ + const opus_int mem_offset /* I Number of samples in LTP memory */ ) { opus_int i, k; diff --git a/silk/float/find_pitch_lags_FLP.c b/silk/float/find_pitch_lags_FLP.c index b37c0ff0..43f7ff94 100644 --- a/silk/float/find_pitch_lags_FLP.c +++ b/silk/float/find_pitch_lags_FLP.c @@ -34,10 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tuning_parameters.h" void silk_find_pitch_lags_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - silk_float res[], /* O Residual */ - const silk_float x[] /* I Speech signal */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + silk_float res[], /* O Residual */ + const silk_float x[] /* I Speech signal */ ) { opus_int buf_len; diff --git a/silk/float/find_pred_coefs_FLP.c b/silk/float/find_pred_coefs_FLP.c index 90a4e467..03500c2c 100644 --- a/silk/float/find_pred_coefs_FLP.c +++ b/silk/float/find_pred_coefs_FLP.c @@ -31,13 +31,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FLP.h" - +/* Find LPC and LTP coefficients */ void silk_find_pred_coefs_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - const silk_float res_pitch[], /* I Residual from pitch analysis */ - const silk_float x[], /* I Speech signal */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + const silk_float res_pitch[], /* I Residual from pitch analysis */ + const silk_float x[], /* I Speech signal */ + opus_int condCoding /* I The type of conditional coding to use */ ) { opus_int i; @@ -64,11 +64,6 @@ void silk_find_pred_coefs_FLP( 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 ); -#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 */ 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 ); @@ -104,9 +99,7 @@ void silk_find_pred_coefs_FLP( LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr ); /* Quantize LSFs */ -TIC(LSF_quant); 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 */ silk_residual_energy_FLP( psEncCtrl->ResNrg, LPC_in_pre, psEncCtrl->PredCoef, psEncCtrl->Gains, diff --git a/silk/float/inner_product_FLP.c b/silk/float/inner_product_FLP.c index a8f04d73..0e4ebb21 100644 --- a/silk/float/inner_product_FLP.c +++ b/silk/float/inner_product_FLP.c @@ -31,11 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FLP.h" -/* inner product of two silk_float arrays, with result as double */ -double silk_inner_product_FLP( /* O result */ - const silk_float *data1, /* I vector 1 */ - const silk_float *data2, /* I vector 2 */ - opus_int dataSize /* I length of vectors */ +/* inner product of two silk_float arrays, with result as double */ +double silk_inner_product_FLP( + const silk_float *data1, + const silk_float *data2, + opus_int dataSize ) { opus_int i, dataSize4; diff --git a/silk/float/k2a_FLP.c b/silk/float/k2a_FLP.c index 8884b8dc..8702bc79 100644 --- a/silk/float/k2a_FLP.c +++ b/silk/float/k2a_FLP.c @@ -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 */ void silk_k2a_FLP( - silk_float *A, /* O: prediction coefficients [order] */ - const silk_float *rc, /* I: reflection coefficients [order] */ - opus_int32 order /* I: prediction order */ + silk_float *A, /* O prediction coefficients [order] */ + const silk_float *rc, /* I reflection coefficients [order] */ + opus_int32 order /* I prediction order */ ) { opus_int k, n; silk_float Atmp[ SILK_MAX_ORDER_LPC ]; - for( k = 0; k < order; k++ ){ - for( n = 0; n < k; n++ ){ + for( k = 0; k < order; k++ ) { + for( n = 0; n < k; n++ ) { Atmp[ n ] = A[ n ]; } for( n = 0; n < k; n++ ) { diff --git a/silk/float/levinsondurbin_FLP.c b/silk/float/levinsondurbin_FLP.c index 813b1175..a6bb59aa 100644 --- a/silk/float/levinsondurbin_FLP.c +++ b/silk/float/levinsondurbin_FLP.c @@ -32,10 +32,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FLP.h" /* Solve the normal equations using the Levinson-Durbin recursion */ -silk_float silk_levinsondurbin_FLP( /* O prediction error energy */ - silk_float A[], /* O prediction coefficients [order] */ - const silk_float corr[], /* I input auto-correlations [order + 1] */ - const opus_int order /* I prediction order */ +silk_float silk_levinsondurbin_FLP( /* O prediction error energy */ + silk_float A[], /* O prediction coefficients [order] */ + const silk_float corr[], /* I input auto-correlations [order + 1] */ + const opus_int order /* I prediction order */ ) { opus_int i, mHalf, m; diff --git a/silk/float/main_FLP.h b/silk/float/main_FLP.h index 07e31ab6..d2889009 100644 --- a/silk/float/main_FLP.h +++ b/silk/float/main_FLP.h @@ -51,47 +51,47 @@ extern "C" /* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */ void silk_HP_variable_cutoff( - silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */ + silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */ ); /* Encoder main function */ 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 */ opus_int silk_encode_frame_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - opus_int32 *pnBytesOut, /* O Number of payload bytes; */ - ec_enc *psRangeEnc, /* I/O compressor data structure */ - opus_int condCoding, /* I The type of conditional coding to use */ - opus_int maxBits, /* I If > 0: maximum number of output bits */ - opus_int useCBR /* I Flag to force constant-bitrate operation */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + opus_int32 *pnBytesOut, /* O Number of payload bytes; */ + ec_enc *psRangeEnc, /* I/O compressor data structure */ + opus_int condCoding, /* I The type of conditional coding to use */ + opus_int maxBits, /* I If > 0: maximum number of output bits */ + opus_int useCBR /* I Flag to force constant-bitrate operation */ ); /* Initializes the Silk encoder state */ 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 */ opus_int silk_control_encoder( - silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */ - silk_EncControlStruct *encControl, /* I: Control structure */ - const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */ - const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ - const opus_int channelNb, /* I Channel number */ - const opus_int force_fs_kHz + silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */ + silk_EncControlStruct *encControl, /* I Control structure */ + const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */ + const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ + const opus_int channelNb, /* I Channel number */ + const opus_int force_fs_kHz ); /****************/ /* Prefiltering */ /****************/ void silk_prefilter_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - const silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */ - silk_float xw[], /* O Weighted signal */ - const silk_float x[] /* I Speech signal */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + const silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */ + silk_float xw[], /* O Weighted signal */ + const silk_float x[] /* I Speech signal */ ); /**************************/ @@ -99,26 +99,26 @@ void silk_prefilter_FLP( /**************************/ /* Compute noise shaping coefficients and initial gain values */ void silk_noise_shape_analysis_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state 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 *x /* I Input signal [frame_length + la_shape] */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state 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 *x /* I Input signal [frame_length + la_shape] */ ); /* Autocorrelations for a warped frequency axis */ void silk_warped_autocorrelation_FLP( - silk_float *corr, /* O Result [order + 1] */ - const silk_float *input, /* I Input data to correlate */ - const silk_float warping, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ + silk_float *corr, /* O Result [order + 1] */ + const silk_float *input, /* I Input data to correlate */ + const silk_float warping, /* I Warping coefficient */ + const opus_int length, /* I Length of input */ + const opus_int order /* I Correlation order (even) */ ); /* Calculation of LTP state scaling */ void silk_LTP_scale_ctrl_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + opus_int condCoding /* I The type of conditional coding to use */ ); /**********************************************/ @@ -126,127 +126,104 @@ void silk_LTP_scale_ctrl_FLP( /**********************************************/ /* Find pitch lags */ void silk_find_pitch_lags_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - silk_float res[], /* O Residual */ - const silk_float x[] /* I Speech signal */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + silk_float res[], /* O Residual */ + const silk_float x[] /* I Speech signal */ ); /* Find LPC and LTP coefficients */ void silk_find_pred_coefs_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - const silk_float res_pitch[], /* I Residual from pitch analysis */ - const silk_float x[], /* I Speech signal */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + const silk_float res_pitch[], /* I Residual from pitch analysis */ + const silk_float x[], /* I Speech signal */ + opus_int condCoding /* I The type of conditional coding to use */ ); /* LPC analysis */ void silk_find_LPC_FLP( - opus_int16 NLSF_Q15[], /* O NLSFs */ - opus_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */ - const opus_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */ - const opus_int useInterpNLSFs, /* I Flag */ - const opus_int firstFrameAfterReset, /* I Flag */ - const opus_int LPC_order, /* I LPC order */ - const silk_float x[], /* I Input signal */ - const opus_int subfr_length, /* I Subframe length incl preceeding samples */ - const opus_int nb_subfr /* I: Number of subframes */ + opus_int16 NLSF_Q15[], /* O NLSFs */ + opus_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */ + const opus_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */ + const opus_int useInterpNLSFs, /* I Flag */ + const opus_int firstFrameAfterReset, /* I Flag */ + const opus_int LPC_order, /* I LPC order */ + const silk_float x[], /* I Input signal */ + const opus_int subfr_length, /* I Subframe length incl preceeding samples */ + const opus_int nb_subfr /* I Number of subframes */ ); /* LTP analysis */ void silk_find_LTP_FLP( - 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 *LTPredCodGain, /* O LTP coding gain */ - const silk_float r_lpc[], /* I LPC residual */ - const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ - const silk_float Wght[ MAX_NB_SUBFR ], /* I Weights */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int mem_offset /* I Number of samples in LTP memory */ + 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 *LTPredCodGain, /* O LTP coding gain */ + const silk_float r_lpc[], /* I LPC residual */ + const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ + const silk_float Wght[ MAX_NB_SUBFR ], /* I Weights */ + const opus_int subfr_length, /* I Subframe length */ + const opus_int nb_subfr, /* I number of subframes */ + const opus_int mem_offset /* I Number of samples in LTP memory */ ); void silk_LTP_analysis_filter_FLP( - 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 B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */ - const opus_int subfr_length, /* I Length of each subframe */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int pre_length /* I Preceeding samples for each subframe */ + 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 B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */ + const opus_int subfr_length, /* I Length of each subframe */ + const opus_int nb_subfr, /* I number of subframes */ + const opus_int pre_length /* I Preceeding samples for each subframe */ ); /* Calculates residual energies of input subframes where all subframes have LPC_order */ /* of preceeding samples */ void silk_residual_energy_FLP( - silk_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ - const silk_float x[], /* I Input signal */ - silk_float a[ 2 ][ MAX_LPC_ORDER ],/* I AR coefs for each frame half */ - const silk_float gains[], /* I Quantization gains */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int LPC_order /* I LPC order */ + silk_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ + const silk_float x[], /* I Input signal */ + silk_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ + const silk_float gains[], /* I Quantization gains */ + const opus_int subfr_length, /* I Subframe length */ + const opus_int nb_subfr, /* I number of subframes */ + const opus_int LPC_order /* I LPC order */ ); /* 16th order LPC analysis filter */ void silk_LPC_analysis_filter_FLP( - silk_float r_LPC[], /* O LPC residual signal */ - const silk_float PredCoef[], /* I LPC coefficients */ - const silk_float s[], /* I Input signal */ - const opus_int length, /* I Length of input signal */ - const opus_int Order /* I LPC order */ + silk_float r_LPC[], /* O LPC residual signal */ + const silk_float PredCoef[], /* I LPC coefficients */ + const silk_float s[], /* I Input signal */ + const opus_int length, /* I Length of input signal */ + const opus_int Order /* I LPC order */ ); /* LTP tap quantizer */ void silk_quant_LTP_gains_FLP( - 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 *periodicity_index, /* O Periodicity index */ - 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 lowComplexity, /* I Flag for low complexity */ - 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)) */ + 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 *periodicity_index, /* O Periodicity index */ + 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 lowComplexity, /* I Flag for low complexity */ + const opus_int nb_subfr /* I number of subframes */ ); /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ -silk_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */ - const silk_float *c, /* I Filter coefficients */ - 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 value */ - 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 */ +silk_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */ + const silk_float *c, /* I Filter coefficients */ + 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 value */ + const opus_int D /* I Dimension */ ); /* Processing of gains */ void silk_process_gains_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + 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 */ void silk_corrMatrix_FLP( - 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 Order, /* I Max lag for correlation */ - silk_float *XX /* O X'*X correlation matrix [order x order] */ + 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 Order, /* I Max lag for correlation */ + silk_float *XX /* O X'*X correlation matrix [order x order] */ ); /* Calculates correlation vector X'*t */ void silk_corrVector_FLP( - const silk_float *x, /* I x vector [L+order-1] used to create X */ - const silk_float *t, /* I Target vector [L] */ - const opus_int L, /* I Length of vecors */ - const opus_int Order, /* I Max lag for correlation */ - silk_float *Xt /* O X'*t correlation vector [order] */ + const silk_float *x, /* I x vector [L+order-1] used to create X */ + const silk_float *t, /* I Target vector [L] */ + const opus_int L, /* I Length of vecors */ + const opus_int Order, /* I Max lag for correlation */ + silk_float *Xt /* O X'*t correlation vector [order] */ ); /* Add noise to matrix diagonal */ void silk_regularize_correlations_FLP( - silk_float *XX, /* I/O Correlation matrices */ - silk_float *xx, /* I/O Correlation values */ - const silk_float noise, /* I Noise energy to add */ - const opus_int D /* I Dimension of XX */ + silk_float *XX, /* I/O Correlation matrices */ + silk_float *xx, /* I/O Correlation values */ + const silk_float noise, /* I Noise energy to add */ + const opus_int D /* I Dimension of XX */ ); /* Function to solve linear equation Ax = b, where A is an MxM symmetric matrix */ void silk_solve_LDL_FLP( - silk_float *A, /* I/O Symmetric square matrix, out: reg. */ - const opus_int M, /* I Size of matrix */ - const silk_float *b, /* I Pointer to b vector */ - silk_float *x /* O Pointer to x solution vector */ + silk_float *A, /* I/O Symmetric square matrix, out: reg. */ + const opus_int M, /* I Size of matrix */ + const silk_float *b, /* I Pointer to b vector */ + silk_float *x /* O Pointer to x solution vector */ ); -/* Apply sine window to signal vector. */ -/* Window types: */ -/* 1 -> sine window from 0 to pi/2 */ -/* 2 -> sine window from pi/2 to pi */ +/* Apply sine window to signal vector. */ +/* Window types: */ +/* 1 -> sine window from 0 to pi/2 */ +/* 2 -> sine window from pi/2 to pi */ void silk_apply_sine_window_FLP( - silk_float px_win[], /* O Pointer to windowed signal */ - const silk_float px[], /* I Pointer to input signal */ - const opus_int win_type, /* I Selects a window type */ - const opus_int length /* I Window length, multiple of 4 */ + silk_float px_win[], /* O Pointer to windowed signal */ + const silk_float px[], /* I Pointer to input signal */ + const opus_int win_type, /* I Selects a window type */ + const opus_int length /* I Window length, multiple of 4 */ ); /* Wrapper functions. Call flp / fix code */ /* Convert AR filter coefficients to NLSF parameters */ void silk_A2NLSF_FLP( - opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */ - const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */ - const opus_int LPC_order /* I LPC order */ + opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */ + const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */ + const opus_int LPC_order /* I LPC order */ ); /* Convert NLSF parameters to AR prediction filter coefficients */ void silk_NLSF2A_FLP( - silk_float *pAR, /* O LPC coefficients [ LPC_order ] */ - const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */ - const opus_int LPC_order /* I LPC order */ + silk_float *pAR, /* O LPC coefficients [ LPC_order ] */ + const opus_int16 *NLSF_Q15, /* I NLSF vector [ 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 */ -/****************************************/ void silk_NSQ_wrapper_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - SideInfoIndices *psIndices, /* I/O Quantization indices */ - silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const silk_float x[] /* I Prefiltered input signal */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + SideInfoIndices *psIndices, /* I/O Quantization indices */ + silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const silk_float x[] /* I Prefiltered input signal */ ); #ifdef __cplusplus diff --git a/silk/float/noise_shape_analysis_FLP.c b/silk/float/noise_shape_analysis_FLP.c index 4d82858b..e19ff70a 100644 --- a/silk/float/noise_shape_analysis_FLP.c +++ b/silk/float/noise_shape_analysis_FLP.c @@ -124,10 +124,10 @@ static inline void warped_true2monic_coefs( /* Compute noise shaping coefficients and initial gain values */ void silk_noise_shape_analysis_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state 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 *x /* I Input signal [frame_length + la_shape] */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state 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 *x /* I Input signal [frame_length + la_shape] */ ) { silk_shape_state_FLP *psShapeSt = &psEnc->sShape; diff --git a/silk/float/pitch_analysis_core_FLP.c b/silk/float/pitch_analysis_core_FLP.c index 4108d63d..a4d39a71 100644 --- a/silk/float/pitch_analysis_core_FLP.c +++ b/silk/float/pitch_analysis_core_FLP.c @@ -30,59 +30,51 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif /***************************************************************************** -* * Pitch analyser function -* ******************************************************************************/ #include "SigProc_FLP.h" #include "SigProc_FIX.h" #include "pitch_est_defines.h" -#define SCRATCH_SIZE 22 - -/************************************************************/ -/* Definitions */ -/************************************************************/ -#define eps 1.192092896e-07f +#define SCRATCH_SIZE 22 +#define eps 1.192092896e-07f /************************************************************/ /* Internally used functions */ /************************************************************/ 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 */ - const silk_float frame[], /* I vector to correlate */ - opus_int start_lag, /* I start lag */ - opus_int sf_length, /* I sub frame length */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity /* I Complexity setting */ + const silk_float frame[], /* I vector to correlate */ + opus_int start_lag, /* I start lag */ + opus_int sf_length, /* I sub frame length */ + opus_int nb_subfr, /* I number of subframes */ + opus_int complexity /* I Complexity setting */ ); static void silk_P_Ana_calc_energy_st3( 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 */ - opus_int start_lag, /* I start lag */ - opus_int sf_length, /* I sub frame length */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity /* I Complexity setting */ + const silk_float frame[], /* I vector to correlate */ + opus_int start_lag, /* I start lag */ + opus_int sf_length, /* I sub frame length */ + opus_int nb_subfr, /* I number of subframes */ + opus_int complexity /* I Complexity setting */ ); -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% CORE PITCH ANALYSIS FUNCTION % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*/ -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 *pitch_out, /* O 4 pitch lag values */ - opus_int16 *lagIndex, /* O lag Index */ - opus_int8 *contourIndex, /* O pitch contour Index */ - silk_float *LTPCorr, /* I/O normalized correlation; input: value from previous frame */ - opus_int prevLag, /* I last lag of previous frame; set to zero is unvoiced */ - 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 */ +/************************************************************/ +/* 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 *pitch_out, /* O Pitch lag values [nb_subfr] */ + opus_int16 *lagIndex, /* O Lag Index */ + opus_int8 *contourIndex, /* O Pitch contour Index */ + silk_float *LTPCorr, /* I/O Normalized correlation; input: value from previous frame */ + opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ + 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 */ ) { 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 ); /* Check for valid complexity setting */ - silk_assert( complexity >= SigProc_PE_MIN_COMPLEX ); - silk_assert( complexity <= SigProc_PE_MAX_COMPLEX ); + silk_assert( complexity >= SILK_PE_MIN_COMPLEX ); + silk_assert( complexity <= SILK_PE_MAX_COMPLEX ); silk_assert( search_thres1 >= 0.0f && search_thres1 <= 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; cross_corr = silk_inner_product_FLP( basis_ptr, target_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)); } else { 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 ) { cbk_size = PE_NB_CBKS_STAGE2_EXT; 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 */ nb_cbk_search = PE_NB_CBKS_STAGE2_EXT; } 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; /* Bias towards previous lag */ - if ( prevLag > 0 ) { + if( prevLag > 0 ) { delta_lag_log2_sqr = lag_log2 - prevLag_log2; 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); } - 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 */ - silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */ - ) { + 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 */ + silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */ + ) { CCmax_b = CCmax_new_b; CCmax = CCmax_new; 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 */ CBimax = 0; /* to avoid undefined lag */ 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; @@ -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( 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 */ - opus_int start_lag, /* I start lag */ - opus_int sf_length, /* I sub frame length */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity /* I Complexity setting */ + const silk_float frame[], /* I vector to correlate */ + opus_int start_lag, /* I start lag */ + opus_int sf_length, /* I sub frame length */ + opus_int nb_subfr, /* I number of subframes */ + opus_int complexity /* I Complexity setting */ ) /*********************************************************************** Calculates the correlations used in stage 3 search. In order to cover @@ -515,10 +507,10 @@ static void silk_P_Ana_calc_corr_st3( silk_float scratch_mem[ SCRATCH_SIZE ]; const opus_int8 *Lag_range_ptr, *Lag_CB_ptr; - silk_assert( complexity >= SigProc_PE_MIN_COMPLEX ); - silk_assert( complexity <= SigProc_PE_MAX_COMPLEX ); + silk_assert( complexity >= SILK_PE_MIN_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_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; 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( 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 */ - opus_int start_lag, /* I start lag */ - opus_int sf_length, /* I sub frame length */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity /* I Complexity setting */ + const silk_float frame[], /* I vector to correlate */ + opus_int start_lag, /* I start lag */ + opus_int sf_length, /* I sub frame length */ + opus_int nb_subfr, /* I number of subframes */ + opus_int complexity /* I Complexity setting */ ) /**************************************************************** Calculate the energies for first two subframes. The energies are @@ -580,10 +572,10 @@ calculated recursively. silk_float scratch_mem[ SCRATCH_SIZE ]; const opus_int8 *Lag_range_ptr, *Lag_CB_ptr; - silk_assert( complexity >= SigProc_PE_MIN_COMPLEX ); - silk_assert( complexity <= SigProc_PE_MAX_COMPLEX ); + silk_assert( complexity >= SILK_PE_MIN_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_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ]; diff --git a/silk/float/prefilter_FLP.c b/silk/float/prefilter_FLP.c index 9f16e2dd..3dcf7b53 100644 --- a/silk/float/prefilter_FLP.c +++ b/silk/float/prefilter_FLP.c @@ -33,18 +33,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tuning_parameters.h" /* -* silk_prefilter. Prefilter for finding Quantizer input signal +* Prefilter for finding Quantizer input signal */ static inline void silk_prefilt_FLP( - silk_prefilter_state_FLP *P,/* I/O state */ - silk_float st_res[], /* I */ - silk_float xw[], /* O */ - silk_float *HarmShapeFIR, /* I */ - silk_float Tilt, /* I */ - silk_float LF_MA_shp, /* I */ - silk_float LF_AR_shp, /* I */ - opus_int lag, /* I */ - opus_int length /* I */ + silk_prefilter_state_FLP *P, /* I/O state */ + silk_float st_res[], /* I */ + silk_float xw[], /* O */ + silk_float *HarmShapeFIR, /* I */ + silk_float Tilt, /* I */ + silk_float LF_MA_shp, /* I */ + silk_float LF_AR_shp, /* I */ + opus_int lag, /* I */ + opus_int length /* I */ ); void silk_warped_LPC_analysis_filter_FLP( @@ -92,10 +92,10 @@ void silk_warped_LPC_analysis_filter_FLP( * silk_prefilter. Main prefilter function */ void silk_prefilter_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - const silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */ - silk_float xw[], /* O Weighted signal */ - const silk_float x[] /* I Speech signal */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + const silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */ + silk_float xw[], /* O Weighted signal */ + const silk_float x[] /* I Speech signal */ ) { silk_prefilter_state_FLP *P = &psEnc->sPrefilt; @@ -154,15 +154,15 @@ void silk_prefilter_FLP( * Prefilter for finding Quantizer input signal */ static inline void silk_prefilt_FLP( - silk_prefilter_state_FLP *P,/* I/O state */ - silk_float st_res[], /* I */ - silk_float xw[], /* O */ - silk_float *HarmShapeFIR, /* I */ - silk_float Tilt, /* I */ - silk_float LF_MA_shp, /* I */ - silk_float LF_AR_shp, /* I */ - opus_int lag, /* I */ - opus_int length /* I */ + silk_prefilter_state_FLP *P, /* I/O state */ + silk_float st_res[], /* I */ + silk_float xw[], /* O */ + silk_float *HarmShapeFIR, /* I */ + silk_float Tilt, /* I */ + silk_float LF_MA_shp, /* I */ + silk_float LF_AR_shp, /* I */ + opus_int lag, /* I */ + opus_int length /* I */ ) { opus_int i; diff --git a/silk/float/process_gains_FLP.c b/silk/float/process_gains_FLP.c index f9b57f46..020f847b 100644 --- a/silk/float/process_gains_FLP.c +++ b/silk/float/process_gains_FLP.c @@ -34,9 +34,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Processing of gains */ void silk_process_gains_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + opus_int condCoding /* I The type of conditional coding to use */ ) { silk_shape_state_FLP *psShapeSt = &psEnc->sShape; diff --git a/silk/float/regularize_correlations_FLP.c b/silk/float/regularize_correlations_FLP.c index 0876e6a9..79447809 100644 --- a/silk/float/regularize_correlations_FLP.c +++ b/silk/float/regularize_correlations_FLP.c @@ -31,11 +31,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main_FLP.h" +/* Add noise to matrix diagonal */ void silk_regularize_correlations_FLP( - silk_float *XX, /* I/O Correlation matrices */ - silk_float *xx, /* I/O Correlation values */ - const silk_float noise, /* I Noise energy to add */ - const opus_int D /* I Dimension of XX */ + silk_float *XX, /* I/O Correlation matrices */ + silk_float *xx, /* I/O Correlation values */ + const silk_float noise, /* I Noise energy to add */ + const opus_int D /* I Dimension of XX */ ) { opus_int i; diff --git a/silk/float/residual_energy_FLP.c b/silk/float/residual_energy_FLP.c index da3b841d..03604bd1 100644 --- a/silk/float/residual_energy_FLP.c +++ b/silk/float/residual_energy_FLP.c @@ -35,12 +35,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define REGULARIZATION_FACTOR 1e-8f /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ -silk_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */ - const silk_float *c, /* I Filter coefficients */ - 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 value */ - const opus_int D /* I Dimension */ +silk_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */ + const silk_float *c, /* I Filter coefficients */ + 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 value */ + const opus_int D /* I Dimension */ ) { opus_int i, j, k; @@ -89,13 +89,13 @@ silk_float silk_residual_energy_covar_FLP( /* O Weighted residual e /* Calculates residual energies of input subframes where all subframes have LPC_order */ /* of preceeding samples */ void silk_residual_energy_FLP( - silk_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ - const silk_float x[], /* I Input signal */ - silk_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ - const silk_float gains[], /* I Quantization gains */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int LPC_order /* I LPC order */ + silk_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ + const silk_float x[], /* I Input signal */ + silk_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ + const silk_float gains[], /* I Quantization gains */ + const opus_int subfr_length, /* I Subframe length */ + const opus_int nb_subfr, /* I number of subframes */ + const opus_int LPC_order /* I LPC order */ ) { opus_int shift; diff --git a/silk/float/scale_copy_vector_FLP.c b/silk/float/scale_copy_vector_FLP.c index 689134f4..efc922fc 100644 --- a/silk/float/scale_copy_vector_FLP.c +++ b/silk/float/scale_copy_vector_FLP.c @@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* copy and multiply a vector by a constant */ void silk_scale_copy_vector_FLP( - silk_float *data_out, - const silk_float *data_in, - silk_float gain, - opus_int dataSize + silk_float *data_out, + const silk_float *data_in, + silk_float gain, + opus_int dataSize ) { opus_int i, dataSize4; diff --git a/silk/float/scale_vector_FLP.c b/silk/float/scale_vector_FLP.c index 656061e4..09feeacf 100644 --- a/silk/float/scale_vector_FLP.c +++ b/silk/float/scale_vector_FLP.c @@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* multiply a vector by a constant */ void silk_scale_vector_FLP( - silk_float *data1, - silk_float gain, - opus_int dataSize + silk_float *data1, + silk_float gain, + opus_int dataSize ) { opus_int i, dataSize4; diff --git a/silk/float/schur_FLP.c b/silk/float/schur_FLP.c index 59921bb7..205f8d4d 100644 --- a/silk/float/schur_FLP.c +++ b/silk/float/schur_FLP.c @@ -31,10 +31,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FLP.h" -silk_float silk_schur_FLP( /* O returns residual energy */ - silk_float refl_coef[], /* O reflection coefficients (length order) */ - const silk_float auto_corr[], /* I autotcorrelation sequence (length order+1) */ - opus_int order /* I order */ +silk_float silk_schur_FLP( /* O returns residual energy */ + silk_float refl_coef[], /* O reflection coefficients (length order) */ + const silk_float auto_corr[], /* I autocorrelation sequence (length order+1) */ + opus_int order /* I order */ ) { opus_int k, n; @@ -56,7 +56,7 @@ silk_float silk_schur_FLP( /* O returns residual energy refl_coef[ k ] = rc_tmp; /* Update correlations */ - for( n = 0; n < order - k; n++ ){ + for( n = 0; n < order - k; n++ ) { Ctmp1 = C[ n + k + 1 ][ 0 ]; Ctmp2 = C[ n ][ 1 ]; C[ n + k + 1 ][ 0 ] = Ctmp1 + Ctmp2 * rc_tmp; diff --git a/silk/float/silk_float.vcxproj b/silk/float/silk_float.vcxproj index 44539478..9a428055 100644 --- a/silk/float/silk_float.vcxproj +++ b/silk/float/silk_float.vcxproj @@ -1,130 +1,131 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782} - Win32Proj - src_FLP - silk_float - - - - StaticLibrary - true - Unicode - - - StaticLibrary - false - true - Unicode - - - - - - - - - - - - - $(ProjectName) - - - $(ProjectName) - - - - - - Level3 - Disabled - HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - ../;../fixed;../../win32;../../celt - - - Windows - true - - - $(OutDir)$(TargetName)$(TargetExt) - - - - - Level3 - - - MaxSpeed - true - true - HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - ../;../fixed;../../win32;../../celt - - - Windows - true - true - true - - - $(OutDir)$(TargetName)$(TargetExt) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782} + Win32Proj + src_FLP + silk_float + + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + $(ProjectName) + + + $(ProjectName) + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ../;../fixed;../../win32;../../celt;../../include + + + Windows + true + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ../;../fixed;../../win32;../../celt;../../include + + + Windows + true + true + true + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/silk/float/silk_float.vcxproj.filters b/silk/float/silk_float.vcxproj.filters index bf29bbe1..a4f075b6 100644 --- a/silk/float/silk_float.vcxproj.filters +++ b/silk/float/silk_float.vcxproj.filters @@ -1,129 +1,132 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + \ No newline at end of file diff --git a/silk/float/solve_LS_FLP.c b/silk/float/solve_LS_FLP.c index c04cb59d..dd3775a9 100644 --- a/silk/float/solve_LS_FLP.c +++ b/silk/float/solve_LS_FLP.c @@ -38,10 +38,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * the symmetric matric A is given by A = L*D*L'. **********************************************************************/ static inline void silk_LDL_FLP( - silk_float *A, /* (I/O) Pointer to Symetric Square Matrix */ - opus_int M, /* (I) Size of Matrix */ - silk_float *L, /* (I/O) Pointer to Square Upper triangular Matrix */ - silk_float *Dinv /* (I/O) Pointer to vector holding the inverse diagonal elements of D */ + silk_float *A, /* I/O Pointer to Symetric Square Matrix */ + opus_int M, /* I Size of Matrix */ + silk_float *L, /* I/O Pointer to Square Upper triangular Matrix */ + silk_float *Dinv /* I/O Pointer to vector holding the inverse diagonal elements of D */ ); /********************************************************************** @@ -49,10 +49,10 @@ static inline void silk_LDL_FLP( * triangular matrix, with ones on the diagonal. **********************************************************************/ static inline void silk_SolveWithLowerTriangularWdiagOnes_FLP( - const silk_float *L, /* (I) Pointer to Lower Triangular Matrix */ - opus_int M, /* (I) Dim of Matrix equation */ - const silk_float *b, /* (I) b Vector */ - silk_float *x /* (O) x Vector */ + const silk_float *L, /* I Pointer to Lower Triangular Matrix */ + opus_int M, /* I Dim of Matrix equation */ + const silk_float *b, /* I b Vector */ + silk_float *x /* O x Vector */ ); /********************************************************************** @@ -60,10 +60,10 @@ static inline void silk_SolveWithLowerTriangularWdiagOnes_FLP( * triangular, with ones on the diagonal. (ie then A^T is upper triangular) **********************************************************************/ static inline void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( - const silk_float *L, /* (I) Pointer to Lower Triangular Matrix */ - opus_int M, /* (I) Dim of Matrix equation */ - const silk_float *b, /* (I) b Vector */ - silk_float *x /* (O) x Vector */ + const silk_float *L, /* I Pointer to Lower Triangular Matrix */ + opus_int M, /* I Dim of Matrix equation */ + const silk_float *b, /* I b Vector */ + silk_float *x /* O x Vector */ ); /********************************************************************** @@ -71,10 +71,10 @@ static inline void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( * symmetric square matrix - using LDL factorisation **********************************************************************/ void silk_solve_LDL_FLP( - silk_float *A, /* I/O Symmetric square matrix, out: reg. */ - const opus_int M, /* I Size of matrix */ - const silk_float *b, /* I Pointer to b vector */ - silk_float *x /* O Pointer to x solution vector */ + silk_float *A, /* I/O Symmetric square matrix, out: reg. */ + const opus_int M, /* I Size of matrix */ + const silk_float *b, /* I Pointer to b vector */ + silk_float *x /* O Pointer to x solution vector */ ) { opus_int i; @@ -110,10 +110,10 @@ void silk_solve_LDL_FLP( } static inline void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( - const silk_float *L, /* (I) Pointer to Lower Triangular Matrix */ - opus_int M, /* (I) Dim of Matrix equation */ - const silk_float *b, /* (I) b Vector */ - silk_float *x /* (O) x Vector */ + const silk_float *L, /* I Pointer to Lower Triangular Matrix */ + opus_int M, /* I Dim of Matrix equation */ + const silk_float *b, /* I b Vector */ + silk_float *x /* O x Vector */ ) { opus_int i, j; @@ -132,10 +132,10 @@ static inline void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( } static inline void silk_SolveWithLowerTriangularWdiagOnes_FLP( - const silk_float *L, /* (I) Pointer to Lower Triangular Matrix */ - opus_int M, /* (I) Dim of Matrix equation */ - const silk_float *b, /* (I) b Vector */ - silk_float *x /* (O) x Vector */ + const silk_float *L, /* I Pointer to Lower Triangular Matrix */ + opus_int M, /* I Dim of Matrix equation */ + const silk_float *b, /* I b Vector */ + silk_float *x /* O x Vector */ ) { opus_int i, j; @@ -154,10 +154,10 @@ static inline void silk_SolveWithLowerTriangularWdiagOnes_FLP( } static inline void silk_LDL_FLP( - silk_float *A, /* (I/O) Pointer to Symetric Square Matrix */ - opus_int M, /* (I) Size of Matrix */ - silk_float *L, /* (I/O) Pointer to Square Upper triangular Matrix */ - silk_float *Dinv /* (I/O) Pointer to vector holding the inverse diagonal elements of D */ + silk_float *A, /* I/O Pointer to Symetric Square Matrix */ + opus_int M, /* I Size of Matrix */ + silk_float *L, /* I/O Pointer to Square Upper triangular Matrix */ + silk_float *Dinv /* I/O Pointer to vector holding the inverse diagonal elements of D */ ) { opus_int i, j, k, loop_count, err = 1; diff --git a/silk/float/sort_FLP.c b/silk/float/sort_FLP.c index 19860db9..2b0a1d1a 100644 --- a/silk/float/sort_FLP.c +++ b/silk/float/sort_FLP.c @@ -37,10 +37,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FLP.h" void silk_insertion_sort_decreasing_FLP( - silk_float *a, /* I/O: Unsorted / Sorted vector */ - opus_int *idx, /* O: Index vector for the sorted elements */ - const opus_int L, /* I: Vector length */ - const opus_int K /* I: Number of correctly sorted positions */ + silk_float *a, /* I/O Unsorted / Sorted vector */ + opus_int *idx, /* O Index vector for the sorted elements */ + const opus_int L, /* I Vector length */ + const opus_int K /* I Number of correctly sorted positions */ ) { silk_float value; diff --git a/silk/float/structs_FLP.h b/silk/float/structs_FLP.h index dd776b5c..f56a972a 100644 --- a/silk/float/structs_FLP.h +++ b/silk/float/structs_FLP.h @@ -41,41 +41,41 @@ extern "C" /* Noise shaping analysis state */ /********************************/ typedef struct { - opus_int8 LastGainIndex; - silk_float HarmBoost_smth; - silk_float HarmShapeGain_smth; - silk_float Tilt_smth; + opus_int8 LastGainIndex; + silk_float HarmBoost_smth; + silk_float HarmShapeGain_smth; + silk_float Tilt_smth; } silk_shape_state_FLP; /********************************/ /* Prefilter state */ /********************************/ typedef struct { - silk_float sLTP_shp[ LTP_BUF_LENGTH ]; - silk_float sAR_shp[ MAX_SHAPE_LPC_ORDER + 1 ]; - opus_int sLTP_shp_buf_idx; - silk_float sLF_AR_shp; - silk_float sLF_MA_shp; - silk_float sHarmHP; - opus_int32 rand_seed; - opus_int lagPrev; + silk_float sLTP_shp[ LTP_BUF_LENGTH ]; + silk_float sAR_shp[ MAX_SHAPE_LPC_ORDER + 1 ]; + opus_int sLTP_shp_buf_idx; + silk_float sLF_AR_shp; + silk_float sLF_MA_shp; + silk_float sHarmHP; + opus_int32 rand_seed; + opus_int lagPrev; } silk_prefilter_state_FLP; /********************************/ /* Encoder state FLP */ /********************************/ typedef struct { - silk_encoder_state sCmn; /* Common struct, shared with fixed-point code */ - silk_shape_state_FLP sShape; /* Noise shaping state */ - silk_prefilter_state_FLP sPrefilt; /* Prefilter State */ + silk_encoder_state sCmn; /* Common struct, shared with fixed-point code */ + silk_shape_state_FLP sShape; /* Noise shaping state */ + silk_prefilter_state_FLP sPrefilt; /* Prefilter State */ /* Buffer for find pitch and noise shape analysis */ - silk_float x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */ - silk_float LTPCorr; /* Normalized correlation from pitch lag estimator */ + silk_float x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */ + silk_float LTPCorr; /* Normalized correlation from pitch lag estimator */ /* Parameters for LTP scaling control */ - silk_float prevLTPredCodGain; - silk_float HPLTPredCodGain; + silk_float prevLTPredCodGain; + silk_float HPLTPredCodGain; } silk_encoder_state_FLP; /************************/ @@ -83,34 +83,34 @@ typedef struct { /************************/ typedef struct { /* Prediction and coding parameters */ - silk_float Gains[ MAX_NB_SUBFR ]; - silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ]; /* holds interpolated and final coefficients */ - silk_float LTPCoef[LTP_ORDER * MAX_NB_SUBFR]; - silk_float LTP_scale; - opus_int pitchL[ MAX_NB_SUBFR ]; + silk_float Gains[ MAX_NB_SUBFR ]; + silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ]; /* holds interpolated and final coefficients */ + silk_float LTPCoef[LTP_ORDER * MAX_NB_SUBFR]; + silk_float LTP_scale; + opus_int pitchL[ MAX_NB_SUBFR ]; /* Noise shaping parameters */ - silk_float AR1[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ]; - silk_float AR2[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ]; - silk_float LF_MA_shp[ MAX_NB_SUBFR ]; - silk_float LF_AR_shp[ MAX_NB_SUBFR ]; - silk_float GainsPre[ MAX_NB_SUBFR ]; - silk_float HarmBoost[ MAX_NB_SUBFR ]; - silk_float Tilt[ MAX_NB_SUBFR ]; - silk_float HarmShapeGain[ MAX_NB_SUBFR ]; - silk_float Lambda; - silk_float input_quality; - silk_float coding_quality; + silk_float AR1[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ]; + silk_float AR2[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ]; + silk_float LF_MA_shp[ MAX_NB_SUBFR ]; + silk_float LF_AR_shp[ MAX_NB_SUBFR ]; + silk_float GainsPre[ MAX_NB_SUBFR ]; + silk_float HarmBoost[ MAX_NB_SUBFR ]; + silk_float Tilt[ MAX_NB_SUBFR ]; + silk_float HarmShapeGain[ MAX_NB_SUBFR ]; + silk_float Lambda; + silk_float input_quality; + silk_float coding_quality; /* Measures */ - silk_float sparseness; - silk_float predGain; - silk_float LTPredCodGain; - silk_float ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */ + silk_float sparseness; + silk_float predGain; + silk_float LTPredCodGain; + silk_float ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */ /* Parameters for CBR mode */ - opus_int32 GainsUnq_Q16[ MAX_NB_SUBFR ]; - opus_int8 lastGainIndexPrev; + opus_int32 GainsUnq_Q16[ MAX_NB_SUBFR ]; + opus_int8 lastGainIndexPrev; } silk_encoder_control_FLP; /************************/ @@ -119,13 +119,13 @@ typedef struct { typedef struct { silk_encoder_state_FLP state_Fxx[ ENCODER_NUM_CHANNELS ]; stereo_enc_state sStereo; - opus_int32 nBitsExceeded; - opus_int nChannelsAPI; - opus_int nChannelsInternal; - opus_int nPrevChannelsInternal; - opus_int timeSinceSwitchAllowed_ms; - opus_int allowBandwidthSwitch; - opus_int prev_decode_only_middle; + opus_int32 nBitsExceeded; + opus_int nChannelsAPI; + opus_int nChannelsInternal; + opus_int nPrevChannelsInternal; + opus_int timeSinceSwitchAllowed_ms; + opus_int allowBandwidthSwitch; + opus_int prev_decode_only_middle; } silk_encoder; #ifdef __cplusplus diff --git a/silk/float/warped_autocorrelation_FLP.c b/silk/float/warped_autocorrelation_FLP.c index 2f15fa52..4bbfabea 100644 --- a/silk/float/warped_autocorrelation_FLP.c +++ b/silk/float/warped_autocorrelation_FLP.c @@ -33,17 +33,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Autocorrelations for a warped frequency axis */ void silk_warped_autocorrelation_FLP( - silk_float *corr, /* O Result [order + 1] */ - const silk_float *input, /* I Input data to correlate */ - const silk_float warping, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ + silk_float *corr, /* O Result [order + 1] */ + const silk_float *input, /* I Input data to correlate */ + const silk_float warping, /* I Warping coefficient */ + const opus_int length, /* I Length of input */ + const opus_int order /* I Correlation order (even) */ ) { - opus_int n, i; - double tmp1, tmp2; - double state[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; - double C[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; + opus_int n, i; + double tmp1, tmp2; + double state[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; + double C[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; /* Order must be even */ silk_assert( ( order & 1 ) == 0 ); diff --git a/silk/float/wrappers_FLP.c b/silk/float/wrappers_FLP.c index f4c046a6..9fd91477 100644 --- a/silk/float/wrappers_FLP.c +++ b/silk/float/wrappers_FLP.c @@ -35,9 +35,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Convert AR filter coefficients to NLSF parameters */ void silk_A2NLSF_FLP( - opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */ - const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */ - const opus_int LPC_order /* I LPC order */ + opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */ + const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */ + const opus_int LPC_order /* I LPC order */ ) { opus_int i; @@ -52,9 +52,9 @@ void silk_A2NLSF_FLP( /* Convert LSF parameters to AR prediction filter coefficients */ void silk_NLSF2A_FLP( - silk_float *pAR, /* O LPC coefficients [ LPC_order ] */ - const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */ - const opus_int LPC_order /* I LPC order */ + silk_float *pAR, /* O LPC coefficients [ LPC_order ] */ + const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */ + const opus_int LPC_order /* I LPC order */ ) { opus_int i; @@ -72,9 +72,9 @@ void silk_NLSF2A_FLP( /******************************************/ 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)) */ + 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)) */ ) { opus_int i, j; @@ -93,12 +93,12 @@ void silk_process_NLSFs_FLP( /* Floating-point Silk NSQ wrapper */ /****************************************/ void silk_NSQ_wrapper_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - SideInfoIndices *psIndices, /* I/O Quantization indices */ - silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const silk_float x[] /* I Prefiltered input signal */ + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ + SideInfoIndices *psIndices, /* I/O Quantization indices */ + silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const silk_float x[] /* I Prefiltered input signal */ ) { opus_int i, j; @@ -170,13 +170,13 @@ void silk_NSQ_wrapper_FLP( /* Floating-point Silk LTP quantiation wrapper */ /***********************************************/ void silk_quant_LTP_gains_FLP( - 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 *periodicity_index, /* O Periodicity index */ - 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 lowComplexity, /* I Flag for low complexity */ - const opus_int nb_subfr /* I number of subframes */ + 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 *periodicity_index, /* O Periodicity index */ + 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 lowComplexity, /* I Flag for low complexity */ + const opus_int nb_subfr /* I number of subframes */ ) { opus_int i; diff --git a/silk/gain_quant.c b/silk/gain_quant.c index 189f5fdd..287e936f 100644 --- a/silk/gain_quant.c +++ b/silk/gain_quant.c @@ -37,11 +37,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Gain scalar quantization with hysteresis, uniform on log scale */ void silk_gains_quant( - opus_int8 ind[ MAX_NB_SUBFR ], /* O gain indices */ - opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* I/O gains (quantized out) */ - opus_int8 *prev_ind, /* I/O last index in previous frame */ - const opus_int conditional, /* I first gain is delta coded if 1 */ - const opus_int nb_subfr /* I number of subframes */ + opus_int8 ind[ MAX_NB_SUBFR ], /* O gain indices */ + opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* I/O gains (quantized out) */ + opus_int8 *prev_ind, /* I/O last index in previous frame */ + const opus_int conditional, /* I first gain is delta coded if 1 */ + const opus_int nb_subfr /* I number of subframes */ ) { opus_int k, double_step_size_threshold; @@ -91,11 +91,11 @@ void silk_gains_quant( /* Gains scalar dequantization, uniform on log scale */ void silk_gains_dequant( - opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* O quantized gains */ - const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ - opus_int8 *prev_ind, /* I/O last index in previous frame */ - const opus_int conditional, /* I first gain is delta coded if 1 */ - const opus_int nb_subfr /* I number of subframes */ + opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* O quantized gains */ + const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ + opus_int8 *prev_ind, /* I/O last index in previous frame */ + const opus_int conditional, /* I first gain is delta coded if 1 */ + const opus_int nb_subfr /* I number of subframes */ ) { opus_int k, ind_tmp, double_step_size_threshold; @@ -123,9 +123,9 @@ void silk_gains_dequant( } /* Compute unique identifier of gain indices vector */ -opus_int32 silk_gains_ID( /* O returns unique identifier of gains */ - const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ - const opus_int nb_subfr /* I number of subframes */ +opus_int32 silk_gains_ID( /* O returns unique identifier of gains */ + const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ + const opus_int nb_subfr /* I number of subframes */ ) { opus_int k; diff --git a/silk/init_encoder.c b/silk/init_encoder.c index 52befadf..1441a966 100644 --- a/silk/init_encoder.c +++ b/silk/init_encoder.c @@ -39,8 +39,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Initialize Silk Encoder state */ /*********************************/ opus_int silk_init_encoder( - silk_encoder_state_Fxx *psEnc /* I/O Pointer to Silk encoder state */ -) { + silk_encoder_state_Fxx *psEnc /* I/O Pointer to Silk FIX encoder state */ +) +{ opus_int ret = 0; /* Clear the entire encoder state */ diff --git a/silk/inner_prod_aligned.c b/silk/inner_prod_aligned.c index 9c8fbff2..22e4b2bc 100644 --- a/silk/inner_prod_aligned.c +++ b/silk/inner_prod_aligned.c @@ -32,10 +32,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FIX.h" opus_int32 silk_inner_prod_aligned_scale( - const opus_int16 *const inVec1, /* I input vector 1 */ - const opus_int16 *const inVec2, /* I input vector 2 */ - const opus_int scale, /* I number of bits to shift */ - const opus_int len /* I vector lengths */ + const opus_int16 *const inVec1, /* I input vector 1 */ + const opus_int16 *const inVec2, /* I input vector 2 */ + const opus_int scale, /* I number of bits to shift */ + const opus_int len /* I vector lengths */ ) { opus_int i; diff --git a/silk/interpolate.c b/silk/interpolate.c index 9309aad5..0f40a935 100644 --- a/silk/interpolate.c +++ b/silk/interpolate.c @@ -33,11 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Interpolate two vectors */ void silk_interpolate( - opus_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */ - const opus_int16 x0[ MAX_LPC_ORDER ], /* I first vector */ - const opus_int16 x1[ MAX_LPC_ORDER ], /* I second vector */ - const opus_int ifact_Q2, /* I interp. factor, weight on 2nd vector */ - const opus_int d /* I number of parameters */ + opus_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */ + const opus_int16 x0[ MAX_LPC_ORDER ], /* I first vector */ + const opus_int16 x1[ MAX_LPC_ORDER ], /* I second vector */ + const opus_int ifact_Q2, /* I interp. factor, weight on 2nd vector */ + const opus_int d /* I number of parameters */ ) { opus_int i; diff --git a/silk/lin2log.c b/silk/lin2log.c index 99641583..0772e470 100644 --- a/silk/lin2log.c +++ b/silk/lin2log.c @@ -32,7 +32,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FIX.h" /* Approximation of 128 * log2() (very close inverse of silk_log2lin()) */ /* 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 */ +) { opus_int32 lz, frac_Q7; diff --git a/silk/log2lin.c b/silk/log2lin.c index b49dd0a2..1a78de59 100644 --- a/silk/log2lin.c +++ b/silk/log2lin.c @@ -33,7 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Approximation of 2^() (very close inverse of silk_lin2log()) */ /* 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 */ +) { opus_int32 out, frac_Q7; diff --git a/silk/main.h b/silk/main.h index 29c45217..adf11f6e 100644 --- a/silk/main.h +++ b/silk/main.h @@ -38,114 +38,109 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "entenc.h" #include "entdec.h" -/* Uncomment the next line to store intermadiate data to files */ -/*#define SAVE_ALL_INTERNAL_DATA 1*/ -/* Uncomment the next line to force a fixed internal sampling rate (independent of what bitrate is used */ -/*#define FORCE_INTERNAL_FS_KHZ 16*/ - /* Simple way to make [8000, 12000, 16000, 24000, 48000] to [0,1,2,3,4] */ #define rateID(R) ( ( ( ((R)>>12) - ((R)>16000) ) >> ((R)>24000) ) - 1 ) /* Convert Left/Right stereo signal to adaptive Mid/Side representation */ void silk_stereo_LR_to_MS( - stereo_enc_state *state, /* I/O State */ - opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ - opus_int16 x2[], /* I/O Right input signal, becomes side signal */ - opus_int8 ix[ 2 ][ 3 ], /* O Quantization indices */ - opus_int8 *mid_only_flag, /* O Flag: only mid signal coded */ - opus_int32 mid_side_rates_bps[], /* O Bitrates for mid and side signals */ - opus_int32 total_rate_bps, /* I Total bitrate */ - opus_int prev_speech_act_Q8, /* I Speech activity level in previous frame */ - opus_int toMono, /* I Last frame before a stereo->mono transition */ - opus_int fs_kHz, /* I Sample rate (kHz) */ - opus_int frame_length /* I Number of samples */ + stereo_enc_state *state, /* I/O State */ + opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ + opus_int16 x2[], /* I/O Right input signal, becomes side signal */ + opus_int8 ix[ 2 ][ 3 ], /* O Quantization indices */ + opus_int8 *mid_only_flag, /* O Flag: only mid signal coded */ + opus_int32 mid_side_rates_bps[], /* O Bitrates for mid and side signals */ + opus_int32 total_rate_bps, /* I Total bitrate */ + opus_int prev_speech_act_Q8, /* I Speech activity level in previous frame */ + opus_int toMono, /* I Last frame before a stereo->mono transition */ + opus_int fs_kHz, /* I Sample rate (kHz) */ + opus_int frame_length /* I Number of samples */ ); /* Convert adaptive Mid/Side representation to Left/Right stereo signal */ void silk_stereo_MS_to_LR( - stereo_dec_state *state, /* I/O State */ - opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ - opus_int16 x2[], /* I/O Right input signal, becomes side signal */ - const opus_int32 pred_Q13[], /* I Predictors */ - opus_int fs_kHz, /* I Samples rate (kHz) */ - opus_int frame_length /* I Number of samples */ + stereo_dec_state *state, /* I/O State */ + opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ + opus_int16 x2[], /* I/O Right input signal, becomes side signal */ + const opus_int32 pred_Q13[], /* I Predictors */ + opus_int fs_kHz, /* I Samples rate (kHz) */ + opus_int frame_length /* I Number of samples */ ); /* Find least-squares prediction gain for one signal based on another and quantize it */ -opus_int32 silk_stereo_find_predictor( /* O Returns predictor in Q13 */ - opus_int32 *ratio_Q14, /* O Ratio of residual and mid energies */ - const opus_int16 x[], /* I Basis signal */ - const opus_int16 y[], /* I Target signal */ - opus_int32 mid_res_amp_Q0[], /* I/O Smoothed mid, residual norms */ - opus_int length, /* I Number of samples */ - opus_int smooth_coef_Q16 /* I Smoothing coefficient */ +opus_int32 silk_stereo_find_predictor( /* O Returns predictor in Q13 */ + opus_int32 *ratio_Q14, /* O Ratio of residual and mid energies */ + const opus_int16 x[], /* I Basis signal */ + const opus_int16 y[], /* I Target signal */ + opus_int32 mid_res_amp_Q0[], /* I/O Smoothed mid, residual norms */ + opus_int length, /* I Number of samples */ + opus_int smooth_coef_Q16 /* I Smoothing coefficient */ ); /* Quantize mid/side predictors */ void silk_stereo_quant_pred( - opus_int32 pred_Q13[], /* I/O Predictors (out: quantized) */ - opus_int8 ix[ 2 ][ 3 ] /* O Quantization indices */ + opus_int32 pred_Q13[], /* I/O Predictors (out: quantized) */ + opus_int8 ix[ 2 ][ 3 ] /* O Quantization indices */ ); /* Entropy code the mid/side quantization indices */ void silk_stereo_encode_pred( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int8 ix[ 2 ][ 3 ] /* I Quantization indices */ + ec_enc *psRangeEnc, /* I/O Compressor data structure */ + opus_int8 ix[ 2 ][ 3 ] /* I Quantization indices */ ); /* Entropy code the mid-only flag */ void silk_stereo_encode_mid_only( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int8 mid_only_flag + ec_enc *psRangeEnc, /* I/O Compressor data structure */ + opus_int8 mid_only_flag ); /* Decode mid/side predictors */ void silk_stereo_decode_pred( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int32 pred_Q13[] /* O Predictors */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int32 pred_Q13[] /* O Predictors */ ); /* Decode mid-only flag */ void silk_stereo_decode_mid_only( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int *decode_only_mid /* O Flag that only mid channel has been coded */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int *decode_only_mid /* O Flag that only mid channel has been coded */ ); /* Encodes signs of excitation */ void silk_encode_signs( ec_enc *psRangeEnc, /* I/O Compressor data structure */ - const opus_int8 pulses[], /* I pulse signal */ - opus_int length, /* I length of input */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I Quantization offset type */ - const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ + const opus_int8 pulses[], /* I pulse signal */ + opus_int length, /* I length of input */ + const opus_int signalType, /* I Signal type */ + const opus_int quantOffsetType, /* I Quantization offset type */ + const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ ); /* Decodes signs of excitation */ void silk_decode_signs( ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int pulses[], /* I/O pulse signal */ - opus_int length, /* I length of input */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I Quantization offset type */ - const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ + opus_int pulses[], /* I/O pulse signal */ + opus_int length, /* I length of input */ + const opus_int signalType, /* I Signal type */ + const opus_int quantOffsetType, /* I Quantization offset type */ + const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ ); /* Check encoder control struct */ opus_int check_control_input( - silk_EncControlStruct *encControl /* I: Control structure */ + silk_EncControlStruct *encControl /* I Control structure */ ); /* Control internal sampling rate */ opus_int silk_control_audio_bandwidth( - silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ - silk_EncControlStruct *encControl /* I: Control structure */ + silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ + silk_EncControlStruct *encControl /* I Control structure */ ); /* Control SNR of redidual quantizer */ opus_int silk_control_SNR( - silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ - opus_int32 TargetRate_bps /* I Target max bitrate (bps) */ + silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ + opus_int32 TargetRate_bps /* I Target max bitrate (bps) */ ); /***************/ @@ -154,143 +149,143 @@ opus_int silk_control_SNR( /* Encode quantization indices of excitation */ void silk_encode_pulses( - ec_enc *psRangeEnc, /* I/O compressor data structure */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I quantOffsetType */ - opus_int8 pulses[], /* I quantization indices */ - const opus_int frame_length /* I Frame length */ + ec_enc *psRangeEnc, /* I/O compressor data structure */ + const opus_int signalType, /* I Signal type */ + const opus_int quantOffsetType, /* I quantOffsetType */ + opus_int8 pulses[], /* I quantization indices */ + const opus_int frame_length /* I Frame length */ ); /* Shell encoder, operates on one shell code frame of 16 pulses */ void silk_shell_encoder( - ec_enc *psRangeEnc, /* I/O compressor data structure */ - const opus_int *pulses0 /* I data: nonnegative pulse amplitudes */ + ec_enc *psRangeEnc, /* I/O compressor data structure */ + const opus_int *pulses0 /* I data: nonnegative pulse amplitudes */ ); /* Shell decoder, operates on one shell code frame of 16 pulses */ void silk_shell_decoder( - opus_int *pulses0, /* O data: nonnegative pulse amplitudes */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - const opus_int pulses4 /* I number of pulses per pulse-subframe */ + opus_int *pulses0, /* O data: nonnegative pulse amplitudes */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + const opus_int pulses4 /* I number of pulses per pulse-subframe */ ); /* Gain scalar quantization with hysteresis, uniform on log scale */ void silk_gains_quant( - opus_int8 ind[ MAX_NB_SUBFR ], /* O gain indices */ - opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* I/O gains (quantized out) */ - opus_int8 *prev_ind, /* I/O last index in previous frame */ - const opus_int conditional, /* I first gain is delta coded if 1 */ - const opus_int nb_subfr /* I number of subframes */ + opus_int8 ind[ MAX_NB_SUBFR ], /* O gain indices */ + opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* I/O gains (quantized out) */ + opus_int8 *prev_ind, /* I/O last index in previous frame */ + const opus_int conditional, /* I first gain is delta coded if 1 */ + const opus_int nb_subfr /* I number of subframes */ ); /* Gains scalar dequantization, uniform on log scale */ void silk_gains_dequant( - opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* O quantized gains */ - const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ - opus_int8 *prev_ind, /* I/O last index in previous frame */ - const opus_int conditional, /* I first gain is delta coded if 1 */ - const opus_int nb_subfr /* I number of subframes */ + opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* O quantized gains */ + const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ + opus_int8 *prev_ind, /* I/O last index in previous frame */ + const opus_int conditional, /* I first gain is delta coded if 1 */ + const opus_int nb_subfr /* I number of subframes */ ); /* Compute unique identifier of gain indices vector */ -opus_int32 silk_gains_ID( /* O returns unique identifier of gains */ - const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ - const opus_int nb_subfr /* I number of subframes */ +opus_int32 silk_gains_ID( /* O returns unique identifier of gains */ + const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ + const opus_int nb_subfr /* I number of subframes */ ); /* Interpolate two vectors */ void silk_interpolate( - opus_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */ - const opus_int16 x0[ MAX_LPC_ORDER ], /* I first vector */ - const opus_int16 x1[ MAX_LPC_ORDER ], /* I second vector */ - const opus_int ifact_Q2, /* I interp. factor, weight on 2nd vector */ - const opus_int d /* I number of parameters */ + opus_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */ + const opus_int16 x0[ MAX_LPC_ORDER ], /* I first vector */ + const opus_int16 x1[ MAX_LPC_ORDER ], /* I second vector */ + const opus_int ifact_Q2, /* I interp. factor, weight on 2nd vector */ + const opus_int d /* I number of parameters */ ); /* LTP tap quantizer */ void silk_quant_LTP_gains( - opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (un)quantized LTP gains */ - opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ - opus_int8 *periodicity_index, /* O Periodicity Index */ - const opus_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Error Weights in Q18 */ - opus_int mu_Q9, /* I Mu value (R/D tradeoff) */ - opus_int lowComplexity, /* I Flag for low complexity */ - const opus_int nb_subfr /* I number of subframes */ + opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (un)quantized LTP gains */ + opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ + opus_int8 *periodicity_index, /* O Periodicity Index */ + const opus_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Error Weights in Q18 */ + opus_int mu_Q9, /* I Mu value (R/D tradeoff) */ + opus_int lowComplexity, /* I Flag for low complexity */ + const opus_int nb_subfr /* I number of subframes */ ); /* Entropy constrained matrix-weighted VQ, for a single input data vector */ void silk_VQ_WMat_EC( - opus_int8 *ind, /* O index of best codebook vector */ - opus_int32 *rate_dist_Q14, /* O best weighted quantization error + mu * rate*/ - const opus_int16 *in_Q14, /* I input vector to be quantized */ - const opus_int32 *W_Q18, /* I weighting matrix */ - const opus_int8 *cb_Q7, /* I codebook */ - const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ - const opus_int mu_Q9, /* I tradeoff between weighted error and rate */ - opus_int L /* I number of vectors in codebook */ -); - -/***********************************/ -/* Noise shaping quantization (NSQ)*/ -/***********************************/ + opus_int8 *ind, /* O index of best codebook vector */ + opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */ + const opus_int16 *in_Q14, /* I input vector to be quantized */ + const opus_int32 *W_Q18, /* I weighting matrix */ + const opus_int8 *cb_Q7, /* I codebook */ + const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ + const opus_int mu_Q9, /* I tradeoff betw. weighted error and rate */ + opus_int L /* I number of vectors in codebook */ +); + +/************************************/ +/* Noise shaping quantization (NSQ) */ +/************************************/ void silk_NSQ( - const silk_encoder_state *psEncC, /* I/O Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x[], /* I prefiltered input signal */ - opus_int8 pulses[], /* O quantized qulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefficients */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefficients */ - const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I */ - const opus_int Lambda_Q10, /* I */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int16 x[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ ); /* Noise shaping using delayed decision */ void silk_NSQ_del_dec( - const silk_encoder_state *psEncC, /* I/O Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x[], /* I Prefiltered input signal */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I LT prediction coefs */ - const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I */ - const opus_int Lambda_Q10, /* I */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ + SideInfoIndices *psIndices, /* I/O Quantization Indices */ + const opus_int16 x[], /* I Prefiltered input signal */ + opus_int8 pulses[], /* O Quantized pulse signal */ + const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ + const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ + const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ + const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ + const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ + const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ + const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ + const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ + const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ + const opus_int LTP_scale_Q14 /* I LTP state scaling */ ); /************/ /* Silk VAD */ /************/ /* Initialize the Silk VAD */ -opus_int silk_VAD_Init( /* O Return value, 0 if success */ - silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ +opus_int silk_VAD_Init( /* O Return value, 0 if success */ + silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ ); /* Get speech activity level in Q8 */ -opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ - silk_encoder_state *psEncC, /* I/O Encoder state */ - const opus_int16 pIn[] /* I PCM input */ +opus_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ + silk_encoder_state *psEncC, /* I/O Encoder state */ + const opus_int16 pIn[] /* I PCM input */ ); /* Low-pass filter with variable cutoff frequency based on */ /* piece-wise linear interpolation between elliptic filters */ /* Start by setting transition_frame_no = 1; */ void silk_LP_variable_cutoff( - silk_LP_state *psLP, /* I/O LP filter state */ - opus_int16 *signal, /* I/O Low-pass filtered output signal */ - const opus_int frame_length /* I Frame length */ + silk_LP_state *psLP, /* I/O LP filter state */ + opus_int16 *frame, /* I/O Low-pass filtered output signal */ + const opus_int frame_length /* I Frame length */ ); /******************/ @@ -298,133 +293,119 @@ void silk_LP_variable_cutoff( /******************/ /* Limit, stabilize, convert and quantize NLSFs */ void silk_process_NLSFs( - silk_encoder_state *psEncC, /* I/O Encoder state */ - opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ - opus_int16 pNLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ - const opus_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ + silk_encoder_state *psEncC, /* I/O Encoder state */ + opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ + opus_int16 pNLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ + const opus_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ ); -opus_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */ - opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ - opus_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */ - const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ - const opus_int16 *pW_QW, /* I NLSF weight vector [ LPC_ORDER ] */ - const opus_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */ - const opus_int nSurvivors, /* I Max survivors after first stage */ - const opus_int signalType /* I Signal type: 0/1/2 */ +opus_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */ + opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ + opus_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */ + const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ + const opus_int16 *pW_QW, /* I NLSF weight vector [ LPC_ORDER ] */ + const opus_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */ + const opus_int nSurvivors, /* I Max survivors after first stage */ + const opus_int signalType /* I Signal type: 0/1/2 */ ); /* Compute quantization errors for an LPC_order element input vector for a VQ codebook */ void silk_NLSF_VQ( - opus_int32 err_Q26[], /* O Quantization errors [K] */ - const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */ - const opus_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */ - const opus_int K, /* I Number of codebook vectors */ - const opus_int LPC_order /* I Number of LPCs */ + opus_int32 err_Q26[], /* O Quantization errors [K] */ + const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */ + const opus_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */ + const opus_int K, /* I Number of codebook vectors */ + const opus_int LPC_order /* I Number of LPCs */ ); /* Delayed-decision quantizer for NLSF residuals */ -opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ - opus_int8 indices[], /* O Quantization indices [ order ] */ - const opus_int16 x_Q10[], /* I Input [ order ] */ - const opus_int16 w_Q5[], /* I Weights [ order ] */ - const opus_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */ - const opus_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */ - const opus_uint8 ec_rates_Q5[], /* I Rates [] */ - const opus_int quant_step_size_Q16, /* I Quantization step size */ - const opus_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */ - const opus_int32 mu_Q20, /* I R/D tradeoff */ - const opus_int16 order /* I Number of input values */ +opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ + opus_int8 indices[], /* O Quantization indices [ order ] */ + const opus_int16 x_Q10[], /* I Input [ order ] */ + const opus_int16 w_Q5[], /* I Weights [ order ] */ + const opus_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */ + const opus_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */ + const opus_uint8 ec_rates_Q5[], /* I Rates [] */ + const opus_int quant_step_size_Q16, /* I Quantization step size */ + const opus_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */ + const opus_int32 mu_Q20, /* I R/D tradeoff */ + const opus_int16 order /* I Number of input values */ ); /* Unpack predictor values and indices for entropy coding tables */ void silk_NLSF_unpack( - opus_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */ - opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */ - const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ - const opus_int CB1_index /* I Index of vector in first LSF codebook */ + opus_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */ + opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */ + const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ + const opus_int CB1_index /* I Index of vector in first LSF codebook */ ); /***********************/ /* NLSF vector decoder */ /***********************/ void silk_NLSF_decode( - opus_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */ - opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ - const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */ + opus_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */ + opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ + const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */ ); /****************************************************/ /* Decoder Functions */ /****************************************************/ -opus_int silk_create_decoder( - silk_decoder_state **ppsDec /* I/O Decoder state pointer pointer */ -); - -opus_int silk_free_decoder( - silk_decoder_state *psDec /* I/O Decoder state pointer */ -); - opus_int silk_init_decoder( - silk_decoder_state *psDec /* I/O Decoder state pointer */ + silk_decoder_state *psDec /* I/O Decoder state pointer */ ); /* Set decoder sampling rate */ opus_int silk_decoder_set_fs( - silk_decoder_state *psDec, /* I/O Decoder state pointer */ - opus_int fs_kHz, /* I Sampling frequency (kHz) */ - opus_int fs_API_Hz /* I API Sampling frequency (Hz) */ + silk_decoder_state *psDec, /* I/O Decoder state pointer */ + opus_int fs_kHz, /* I Sampling frequency (kHz) */ + opus_int fs_API_Hz /* I API Sampling frequency (Hz) */ ); /****************/ /* Decode frame */ /****************/ opus_int silk_decode_frame( - silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 pOut[], /* O Pointer to output speech frame */ - opus_int32 *pN, /* O Pointer to size of output frame */ - opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ - opus_int condCoding /* I The type of conditional coding to use */ -); - -/* Decode LBRR side info and excitation */ -void silk_LBRR_extract( - silk_decoder_state *psDec, /* I/O State */ - ec_dec *psRangeDec /* I/O Compressor data structure */ + silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int16 pOut[], /* O Pointer to output speech frame */ + opus_int32 *pN, /* O Pointer to size of output frame */ + opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ + opus_int condCoding /* I The type of conditional coding to use */ ); -/* Decode indices from payload v4 Bitstream */ +/* Decode indices from bitstream */ void silk_decode_indices( - silk_decoder_state *psDec, /* I/O State */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int FrameIndex, /* I Frame number */ - opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_decoder_state *psDec, /* I/O State */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int FrameIndex, /* I Frame number */ + opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */ + opus_int condCoding /* I The type of conditional coding to use */ ); /* Decode parameters from payload */ void silk_decode_parameters( - silk_decoder_state *psDec, /* I/O State */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_decoder_state *psDec, /* I/O State */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ + opus_int condCoding /* I The type of conditional coding to use */ ); /* Core decoder. Performs inverse NSQ operation LTP + LPC */ void silk_decode_core( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I Decoder control */ - opus_int16 xq[], /* O Decoded speech */ - const opus_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */ + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I Decoder control */ + opus_int16 xq[], /* O Decoded speech */ + const opus_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */ ); /* Decode quantization indices of excitation (Shell coding) */ void silk_decode_pulses( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int pulses[], /* O Excitation signal */ - const opus_int signalType, /* I Sigtype */ - const opus_int quantOffsetType, /* I quantOffsetType */ - const opus_int frame_length /* I Frame length */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int pulses[], /* O Excitation signal */ + const opus_int signalType, /* I Sigtype */ + const opus_int quantOffsetType, /* I quantOffsetType */ + const opus_int frame_length /* I Frame length */ ); /******************/ @@ -433,24 +414,24 @@ void silk_decode_pulses( /* Reset CNG */ void silk_CNG_Reset( - silk_decoder_state *psDec /* I/O Decoder state */ + silk_decoder_state *psDec /* I/O Decoder state */ ); /* Updates CNG estimate, and applies the CNG when packet was lost */ void silk_CNG( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 signal[], /* I/O Signal */ - opus_int length /* I Length of residual */ + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ + opus_int16 frame[], /* I/O Signal */ + opus_int length /* I Length of residual */ ); /* Encoding of various parameters */ void silk_encode_indices( - silk_encoder_state *psEncC, /* I/O Encoder state */ - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int FrameIndex, /* I Frame number */ - opus_int encode_LBRR, /* I Flag indicating LBRR data is being encoded */ - opus_int condCoding /* I The type of conditional coding to use */ + silk_encoder_state *psEncC, /* I/O Encoder state */ + ec_enc *psRangeEnc, /* I/O Compressor data structure */ + opus_int FrameIndex, /* I Frame number */ + opus_int encode_LBRR, /* I Flag indicating LBRR data is being encoded */ + opus_int condCoding /* I The type of conditional coding to use */ ); #endif diff --git a/silk/pitch_est_defines.h b/silk/pitch_est_defines.h index c6f084f7..32d2042a 100644 --- a/silk/pitch_est_defines.h +++ b/silk/pitch_est_defines.h @@ -30,55 +30,60 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FIX.h" -/************************************************************/ -/* Definitions For Fix pitch estimator */ -/************************************************************/ +/********************************************************/ +/* Definitions for pitch estimator */ +/********************************************************/ -#define PE_MAX_FS_KHZ 16 /* Maximum sampling frequency used */ +#define PE_MAX_FS_KHZ 16 /* Maximum sampling frequency used */ -#define PE_MAX_NB_SUBFR 4 -#define PE_SUBFR_LENGTH_MS 5 /* 5 ms */ +#define PE_MAX_NB_SUBFR 4 +#define PE_SUBFR_LENGTH_MS 5 /* 5 ms */ -#define PE_LTP_MEM_LENGTH_MS (4 * PE_SUBFR_LENGTH_MS) +#define PE_LTP_MEM_LENGTH_MS ( 4 * PE_SUBFR_LENGTH_MS ) -#define PE_MAX_FRAME_LENGTH_MS (PE_LTP_MEM_LENGTH_MS + PE_MAX_NB_SUBFR * PE_SUBFR_LENGTH_MS) -#define PE_MAX_FRAME_LENGTH (PE_MAX_FRAME_LENGTH_MS * PE_MAX_FS_KHZ) -#define PE_MAX_FRAME_LENGTH_ST_1 (PE_MAX_FRAME_LENGTH >> 2) -#define PE_MAX_FRAME_LENGTH_ST_2 (PE_MAX_FRAME_LENGTH >> 1) -#define PE_MAX_SF_FRAME_LENGTH (PE_SUB_FRAME * PE_MAX_FS_KHZ) +#define PE_MAX_FRAME_LENGTH_MS ( PE_LTP_MEM_LENGTH_MS + PE_MAX_NB_SUBFR * PE_SUBFR_LENGTH_MS ) +#define PE_MAX_FRAME_LENGTH ( PE_MAX_FRAME_LENGTH_MS * PE_MAX_FS_KHZ ) +#define PE_MAX_FRAME_LENGTH_ST_1 ( PE_MAX_FRAME_LENGTH >> 2 ) +#define PE_MAX_FRAME_LENGTH_ST_2 ( PE_MAX_FRAME_LENGTH >> 1 ) +#define PE_MAX_SF_FRAME_LENGTH ( PE_SUB_FRAME * PE_MAX_FS_KHZ ) -#define PE_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */ -#define PE_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */ -#define PE_MAX_LAG (PE_MAX_LAG_MS * PE_MAX_FS_KHZ) -#define PE_MIN_LAG (PE_MIN_LAG_MS * PE_MAX_FS_KHZ) +#define PE_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */ +#define PE_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */ +#define PE_MAX_LAG ( PE_MAX_LAG_MS * PE_MAX_FS_KHZ ) +#define PE_MIN_LAG ( PE_MIN_LAG_MS * PE_MAX_FS_KHZ ) -#define PE_D_SRCH_LENGTH 24 +#define PE_D_SRCH_LENGTH 24 -#define PE_NB_STAGE3_LAGS 5 +#define PE_NB_STAGE3_LAGS 5 -#define PE_NB_CBKS_STAGE2 3 -#define PE_NB_CBKS_STAGE2_EXT 11 +#define PE_NB_CBKS_STAGE2 3 +#define PE_NB_CBKS_STAGE2_EXT 11 -#define PE_CB_mn2 1 -#define PE_CB_mx2 2 +#define PE_CB_mn2 1 +#define PE_CB_mx2 2 -#define PE_NB_CBKS_STAGE3_MAX 34 -#define PE_NB_CBKS_STAGE3_MID 24 -#define PE_NB_CBKS_STAGE3_MIN 16 +#define PE_NB_CBKS_STAGE3_MAX 34 +#define PE_NB_CBKS_STAGE3_MID 24 +#define PE_NB_CBKS_STAGE3_MIN 16 -#define PE_NB_CBKS_STAGE3_10MS 12 -#define PE_NB_CBKS_STAGE2_10MS 3 +#define PE_NB_CBKS_STAGE3_10MS 12 +#define PE_NB_CBKS_STAGE2_10MS 3 -#define PE_SHORTLAG_BIAS 0.2f /* for logarithmic weighting */ -#define PE_PREVLAG_BIAS 0.2f /* for logarithmic weighting */ -#define PE_FLATCONTOUR_BIAS 0.05f +#define PE_SHORTLAG_BIAS 0.2f /* for logarithmic weighting */ +#define PE_PREVLAG_BIAS 0.2f /* for logarithmic weighting */ +#define PE_FLATCONTOUR_BIAS 0.05f +#define SILK_PE_MIN_COMPLEX 0 +#define SILK_PE_MID_COMPLEX 1 +#define SILK_PE_MAX_COMPLEX 2 + +/* Tables for 20 ms frames */ extern const opus_int8 silk_CB_lags_stage2[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE2_EXT ]; extern const opus_int8 silk_CB_lags_stage3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ]; extern const opus_int8 silk_Lag_range_stage3[ SILK_PE_MAX_COMPLEX + 1 ] [ PE_MAX_NB_SUBFR ][ 2 ]; extern const opus_int8 silk_nb_cbk_searchs_stage3[ SILK_PE_MAX_COMPLEX + 1 ]; -/* Tables added for 10 ms frames */ +/* Tables for 10 ms frames */ extern const opus_int8 silk_CB_lags_stage2_10_ms[ PE_MAX_NB_SUBFR >> 1][ 3 ]; extern const opus_int8 silk_CB_lags_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 12 ]; extern const opus_int8 silk_Lag_range_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 2 ]; diff --git a/silk/process_NLSFs.c b/silk/process_NLSFs.c index 6e1cc06f..c49f884f 100644 --- a/silk/process_NLSFs.c +++ b/silk/process_NLSFs.c @@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Limit, stabilize, convert and quantize NLSFs */ void silk_process_NLSFs( - silk_encoder_state *psEncC, /* I/O Encoder state */ - opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ - opus_int16 pNLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ - const opus_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ + silk_encoder_state *psEncC, /* I/O Encoder state */ + opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ + opus_int16 pNLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ + const opus_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ ) { opus_int i, doInterpolate; @@ -80,15 +80,12 @@ void silk_process_NLSFs( i_sqr_Q15 = silk_LSHIFT( silk_SMULBB( psEncC->indices.NLSFInterpCoef_Q2, psEncC->indices.NLSFInterpCoef_Q2 ), 11 ); for( i = 0; i < psEncC->predictLPCOrder; i++ ) { pNLSFW_QW[ i ] = silk_SMLAWB( silk_RSHIFT( pNLSFW_QW[ i ], 1 ), pNLSFW0_temp_QW[ i ], i_sqr_Q15 ); - silk_assert( pNLSFW_QW[ i ] <= silk_int16_MAX ); silk_assert( pNLSFW_QW[ i ] >= 1 ); } } - TIC(NLSF_encode) silk_NLSF_encode( psEncC->indices.NLSFIndices, pNLSF_Q15, psEncC->psNLSF_CB, pNLSFW_QW, NLSF_mu_Q20, psEncC->NLSF_MSVQ_Survivors, psEncC->indices.signalType ); - TOC(NLSF_encode) /* Convert quantized NLSFs back to LPC coefficients */ silk_NLSF2A( PredCoef_Q12[ 1 ], pNLSF_Q15, psEncC->predictLPCOrder ); diff --git a/silk/quant_LTP_gains.c b/silk/quant_LTP_gains.c index 7a5c46c3..47246592 100644 --- a/silk/quant_LTP_gains.c +++ b/silk/quant_LTP_gains.c @@ -32,13 +32,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main.h" void silk_quant_LTP_gains( - opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (un)quantized LTP gains */ - opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ - opus_int8 *periodicity_index, /* O Periodicity Index */ - const opus_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Error Weights in Q18 */ - opus_int mu_Q9, /* I Mu value (R/D tradeoff) */ - opus_int lowComplexity, /* I Flag for low complexity */ - const opus_int nb_subfr /* I number of subframes */ + opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (un)quantized LTP gains */ + opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ + opus_int8 *periodicity_index, /* O Periodicity Index */ + const opus_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Error Weights in Q18 */ + opus_int mu_Q9, /* I Mu value (R/D tradeoff) */ + opus_int lowComplexity, /* I Flag for low complexity */ + const opus_int nb_subfr /* I number of subframes */ ) { opus_int j, k, cbk_size; @@ -49,8 +49,6 @@ void silk_quant_LTP_gains( const opus_int32 *W_Q18_ptr; opus_int32 rate_dist_Q14_subfr, rate_dist_Q14, min_rate_dist_Q14; -TIC(quant_LTP) - /***************************************************/ /* iterate over different codebooks with different */ /* rates/distortions, and choose best */ @@ -67,7 +65,6 @@ TIC(quant_LTP) rate_dist_Q14 = 0; for( j = 0; j < nb_subfr; j++ ) { - silk_VQ_WMat_EC( &temp_idx[ j ], /* O index of best codebook vector */ &rate_dist_Q14_subfr, /* O best weighted quantization error + mu * rate */ @@ -106,6 +103,5 @@ TIC(quant_LTP) B_Q14[ j * LTP_ORDER + k ] = silk_LSHIFT( cbk_ptr_Q7[ cbk_index[ j ] * LTP_ORDER + k ], 7 ); } } -TOC(quant_LTP) } diff --git a/silk/resampler.c b/silk/resampler.c index 3102d42b..eeda054a 100644 --- a/silk/resampler.c +++ b/silk/resampler.c @@ -53,16 +53,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "resampler_private.h" -#define USE_silk_resampler_copy (0) -#define USE_silk_resampler_private_up2_HQ_wrapper (1) -#define USE_silk_resampler_private_IIR_FIR (2) -#define USE_silk_resampler_private_down_FIR (3) +#define USE_silk_resampler_copy (0) +#define USE_silk_resampler_private_up2_HQ_wrapper (1) +#define USE_silk_resampler_private_IIR_FIR (2) +#define USE_silk_resampler_private_down_FIR (3) /* Initialize/reset the resampler state for a given pair of input/output sampling rates */ opus_int silk_resampler_init( - silk_resampler_state_struct *S, /* I/O: Resampler state */ - opus_int32 Fs_Hz_in, /* I: Input sampling rate (Hz) */ - opus_int32 Fs_Hz_out /* I: Output sampling rate (Hz) */ + silk_resampler_state_struct *S, /* I/O Resampler state */ + opus_int32 Fs_Hz_in, /* I Input sampling rate (Hz) */ + opus_int32 Fs_Hz_out /* I Output sampling rate (Hz) */ ) { opus_int32 up2 = 0, down2 = 0; @@ -71,8 +71,8 @@ opus_int silk_resampler_init( silk_memset( S, 0, sizeof( silk_resampler_state_struct ) ); /* Input checking */ - if( (Fs_Hz_in!=8000 && Fs_Hz_in!=12000 && Fs_Hz_in!=16000 && Fs_Hz_in!=24000 && Fs_Hz_in!=48000) || - (Fs_Hz_out!=8000 && Fs_Hz_out!=12000 && Fs_Hz_out!=16000 && Fs_Hz_out!=24000 && Fs_Hz_out!=48000) ) { + if( ( Fs_Hz_in != 8000 && Fs_Hz_in != 12000 && Fs_Hz_in != 16000 && Fs_Hz_in != 24000 && Fs_Hz_in != 48000 ) || + ( Fs_Hz_out != 8000 && Fs_Hz_out != 12000 && Fs_Hz_out != 16000 && Fs_Hz_out != 24000 && Fs_Hz_out != 48000 ) ) { silk_assert( 0 ); return -1; } @@ -83,7 +83,7 @@ opus_int silk_resampler_init( /* Find resampler with the right sampling ratio */ if( Fs_Hz_out > Fs_Hz_in ) { /* Upsample */ - if( Fs_Hz_out == silk_MUL( Fs_Hz_in, 2 ) ) { /* Fs_out : Fs_in = 2 : 1 */ + if( Fs_Hz_out == silk_MUL( Fs_Hz_in, 2 ) ) { /* Fs_out : Fs_in = 2 : 1 */ /* Special case: directly use 2x upsampler */ S->resampler_function = USE_silk_resampler_private_up2_HQ_wrapper; } else { @@ -93,28 +93,28 @@ opus_int silk_resampler_init( } } else if ( Fs_Hz_out < Fs_Hz_in ) { /* Downsample */ - if( silk_MUL( Fs_Hz_out, 4 ) == silk_MUL( Fs_Hz_in, 3 ) ) { /* Fs_out : Fs_in = 3 : 4 */ + if( silk_MUL( Fs_Hz_out, 4 ) == silk_MUL( Fs_Hz_in, 3 ) ) { /* Fs_out : Fs_in = 3 : 4 */ S->FIR_Fracs = 3; S->Coefs = silk_Resampler_3_4_COEFS; S->resampler_function = USE_silk_resampler_private_down_FIR; - } else if( silk_MUL( Fs_Hz_out, 3 ) == silk_MUL( Fs_Hz_in, 2 ) ) { /* Fs_out : Fs_in = 2 : 3 */ + } else if( silk_MUL( Fs_Hz_out, 3 ) == silk_MUL( Fs_Hz_in, 2 ) ) { /* Fs_out : Fs_in = 2 : 3 */ S->FIR_Fracs = 2; S->Coefs = silk_Resampler_2_3_COEFS; S->resampler_function = USE_silk_resampler_private_down_FIR; - } else if( silk_MUL( Fs_Hz_out, 2 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 2 */ + } else if( silk_MUL( Fs_Hz_out, 2 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 2 */ S->FIR_Fracs = 1; S->Coefs = silk_Resampler_1_2_COEFS; S->resampler_function = USE_silk_resampler_private_down_FIR; - } else if( silk_MUL( Fs_Hz_out, 3 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 3 */ + } else if( silk_MUL( Fs_Hz_out, 3 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 3 */ S->FIR_Fracs = 1; S->Coefs = silk_Resampler_1_3_COEFS; S->resampler_function = USE_silk_resampler_private_down_FIR; - } else if( silk_MUL( Fs_Hz_out, 4 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 4 */ + } else if( silk_MUL( Fs_Hz_out, 4 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 4 */ S->FIR_Fracs = 1; down2 = 1; S->Coefs = silk_Resampler_1_2_COEFS; S->resampler_function = USE_silk_resampler_private_down_FIR; - } else if( silk_MUL( Fs_Hz_out, 6 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 6 */ + } else if( silk_MUL( Fs_Hz_out, 6 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 6 */ S->FIR_Fracs = 1; down2 = 1; S->Coefs = silk_Resampler_1_3_COEFS; @@ -141,16 +141,16 @@ opus_int silk_resampler_init( return 0; } -/* Resampler: convert from one sampling rate to another */ +/* Resampler: convert from one sampling rate to another */ opus_int silk_resampler( - silk_resampler_state_struct *S, /* I/O: Resampler state */ - opus_int16 out[], /* O: Output signal */ - const opus_int16 in[], /* I: Input signal */ - opus_int32 inLen /* I: Number of input samples */ + silk_resampler_state_struct *S, /* I/O Resampler state */ + opus_int16 out[], /* O Output signal */ + const opus_int16 in[], /* I Input signal */ + opus_int32 inLen /* I Number of input samples */ ) { /* Input and output sampling rate are at most 48000 Hz */ - switch(S->resampler_function) { + switch( S->resampler_function ) { case USE_silk_resampler_private_up2_HQ_wrapper: silk_resampler_private_up2_HQ_wrapper( S, out, in, inLen ); break; diff --git a/silk/resampler_down2.c b/silk/resampler_down2.c index 5a04247c..fe33d35d 100644 --- a/silk/resampler_down2.c +++ b/silk/resampler_down2.c @@ -34,10 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Downsample by a factor 2, mediocre quality */ void silk_resampler_down2( - opus_int32 *S, /* I/O: State vector [ 2 ] */ - opus_int16 *out, /* O: Output signal [ len ] */ - const opus_int16 *in, /* I: Input signal [ floor(len/2) ] */ - opus_int32 inLen /* I: Number of input samples */ + opus_int32 *S, /* I/O State vector [ 2 ] */ + opus_int16 *out, /* O Output signal [ len ] */ + const opus_int16 *in, /* I Input signal [ floor(len/2) ] */ + opus_int32 inLen /* I Number of input samples */ ) { opus_int32 k, len2 = silk_RSHIFT32( inLen, 1 ); diff --git a/silk/resampler_down2_3.c b/silk/resampler_down2_3.c index bd74c614..9f4f22fc 100644 --- a/silk/resampler_down2_3.c +++ b/silk/resampler_down2_3.c @@ -36,10 +36,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Downsample by a factor 2/3, low quality */ void silk_resampler_down2_3( - opus_int32 *S, /* I/O: State vector [ 6 ] */ - opus_int16 *out, /* O: Output signal [ floor(2*inLen/3) ] */ - const opus_int16 *in, /* I: Input signal [ inLen ] */ - opus_int32 inLen /* I: Number of input samples */ + opus_int32 *S, /* I/O State vector [ 6 ] */ + opus_int16 *out, /* O Output signal [ floor(2*inLen/3) ] */ + const opus_int16 *in, /* I Input signal [ inLen ] */ + opus_int32 inLen /* I Number of input samples */ ) { opus_int32 nSamplesIn, counter, res_Q6; diff --git a/silk/resampler_private.h b/silk/resampler_private.h index 36292c6f..50a66cfe 100644 --- a/silk/resampler_private.h +++ b/silk/resampler_private.h @@ -39,53 +39,45 @@ extern "C" { /* Number of input samples to process in the inner loop */ #define RESAMPLER_MAX_BATCH_SIZE_IN 480 -/* Description: Hybrid IIR/FIR polyphase implementation of resampling */ +/* Description: Hybrid IIR/FIR polyphase implementation of resampling */ void silk_resampler_private_IIR_FIR( - void *SS, /* I/O: Resampler state */ - opus_int16 out[], /* O: Output signal */ - const opus_int16 in[], /* I: Input signal */ - opus_int32 inLen /* I: Number of input samples */ + void *SS, /* I/O Resampler state */ + opus_int16 out[], /* O Output signal */ + const opus_int16 in[], /* I Input signal */ + opus_int32 inLen /* I Number of input samples */ ); -/* Description: Hybrid IIR/FIR polyphase implementation of resampling */ +/* Description: Hybrid IIR/FIR polyphase implementation of resampling */ void silk_resampler_private_down_FIR( - void *SS, /* I/O: Resampler state */ - opus_int16 out[], /* O: Output signal */ - const opus_int16 in[], /* I: Input signal */ - opus_int32 inLen /* I: Number of input samples */ -); - -/* Copy */ -void silk_resampler_private_copy( - void *SS, /* I/O: Resampler state (unused) */ - opus_int16 out[], /* O: Output signal */ - const opus_int16 in[], /* I: Input signal */ - opus_int32 inLen /* I: Number of input samples */ + void *SS, /* I/O Resampler state */ + opus_int16 out[], /* O Output signal */ + const opus_int16 in[], /* I Input signal */ + opus_int32 inLen /* I Number of input samples */ ); /* Upsample by a factor 2, high quality */ void silk_resampler_private_up2_HQ_wrapper( - void *SS, /* I/O: Resampler state (unused) */ - opus_int16 *out, /* O: Output signal [ 2 * len ] */ - const opus_int16 *in, /* I: Input signal [ len ] */ - opus_int32 len /* I: Number of input samples */ + void *SS, /* I/O Resampler state (unused) */ + opus_int16 *out, /* O Output signal [ 2 * len ] */ + const opus_int16 *in, /* I Input signal [ len ] */ + opus_int32 len /* I Number of input samples */ ); /* Upsample by a factor 2, high quality */ void silk_resampler_private_up2_HQ( - opus_int32 *S, /* I/O: Resampler state [ 6 ] */ - opus_int16 *out, /* O: Output signal [ 2 * len ] */ - const opus_int16 *in, /* I: Input signal [ len ] */ - opus_int32 len /* I: Number of input samples */ + opus_int32 *S, /* I/O Resampler state [ 6 ] */ + opus_int16 *out, /* O Output signal [ 2 * len ] */ + const opus_int16 *in, /* I Input signal [ len ] */ + opus_int32 len /* I Number of input samples */ ); /* Second order AR filter */ void silk_resampler_private_AR2( - opus_int32 S[], /* I/O: State vector [ 2 ] */ - opus_int32 out_Q8[], /* O: Output signal */ - const opus_int16 in[], /* I: Input signal */ - const opus_int16 A_Q14[], /* I: AR coefficients, Q14 */ - opus_int32 len /* I: Signal length */ + opus_int32 S[], /* I/O State vector [ 2 ] */ + opus_int32 out_Q8[], /* O Output signal */ + const opus_int16 in[], /* I Input signal */ + const opus_int16 A_Q14[], /* I AR coefficients, Q14 */ + opus_int32 len /* I Signal length */ ); #ifdef __cplusplus diff --git a/silk/resampler_private_AR2.c b/silk/resampler_private_AR2.c index 5c5b3f1f..5add3553 100644 --- a/silk/resampler_private_AR2.c +++ b/silk/resampler_private_AR2.c @@ -34,11 +34,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Second order AR filter with single delay elements */ void silk_resampler_private_AR2( - opus_int32 S[], /* I/O: State vector [ 2 ] */ - opus_int32 out_Q8[], /* O: Output signal */ - const opus_int16 in[], /* I: Input signal */ - const opus_int16 A_Q14[], /* I: AR coefficients, Q14 */ - opus_int32 len /* I: Signal length */ + opus_int32 S[], /* I/O State vector [ 2 ] */ + opus_int32 out_Q8[], /* O Output signal */ + const opus_int16 in[], /* I Input signal */ + const opus_int16 A_Q14[], /* I AR coefficients, Q14 */ + opus_int32 len /* I Signal length */ ) { opus_int32 k; diff --git a/silk/resampler_private_IIR_FIR.c b/silk/resampler_private_IIR_FIR.c index 9c9ffcaa..725f8576 100644 --- a/silk/resampler_private_IIR_FIR.c +++ b/silk/resampler_private_IIR_FIR.c @@ -33,10 +33,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "resampler_private.h" static inline opus_int16 *silk_resampler_private_IIR_FIR_INTERPOL( - opus_int16 * out, opus_int16 * buf, opus_int32 max_index_Q16 , opus_int32 index_increment_Q16 ){ + opus_int16 *out, + opus_int16 *buf, + opus_int32 max_index_Q16, + opus_int32 index_increment_Q16 +) +{ opus_int32 index_Q16, res_Q15; opus_int16 *buf_ptr; opus_int32 table_index; + /* Interpolate upsampled signal and store in output array */ for( index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16 ) { table_index = silk_SMULWB( index_Q16 & 0xFFFF, 144 ); @@ -54,10 +60,10 @@ static inline opus_int16 *silk_resampler_private_IIR_FIR_INTERPOL( } /* Upsample using a combination of allpass-based 2x upsampling and FIR interpolation */ void silk_resampler_private_IIR_FIR( - void *SS, /* I/O: Resampler state */ - opus_int16 out[], /* O: Output signal */ - const opus_int16 in[], /* I: Input signal */ - opus_int32 inLen /* I: Number of input samples */ + void *SS, /* I/O Resampler state */ + opus_int16 out[], /* O Output signal */ + const opus_int16 in[], /* I Input signal */ + opus_int32 inLen /* I Number of input samples */ ) { silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; @@ -65,7 +71,6 @@ void silk_resampler_private_IIR_FIR( opus_int32 max_index_Q16, index_increment_Q16; opus_int16 buf[ 2 * RESAMPLER_MAX_BATCH_SIZE_IN + RESAMPLER_ORDER_FIR_144 ]; - /* Copy buffered samples to start of buffer */ silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_144 * sizeof( opus_int32 ) ); diff --git a/silk/resampler_private_down_FIR.c b/silk/resampler_private_down_FIR.c index 028a200e..b9c2519b 100644 --- a/silk/resampler_private_down_FIR.c +++ b/silk/resampler_private_down_FIR.c @@ -33,10 +33,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "resampler_private.h" static inline opus_int16 *silk_resampler_private_down_FIR_INTERPOL0( - opus_int16 *out, opus_int32 *buf2, const opus_int16 *FIR_Coefs, opus_int32 max_index_Q16, opus_int32 index_increment_Q16){ - + opus_int16 *out, + opus_int32 *buf2, + const opus_int16 *FIR_Coefs, + opus_int32 max_index_Q16, + opus_int32 index_increment_Q16 +) +{ opus_int32 index_Q16, res_Q6; opus_int32 *buf_ptr; + for( index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16 ) { /* Integer part gives pointer to buffered input */ buf_ptr = buf2 + silk_RSHIFT( index_Q16, 16 ); @@ -51,19 +57,26 @@ static inline opus_int16 *silk_resampler_private_down_FIR_INTERPOL0( res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 6 ], buf_ptr[ 9 ] ), FIR_Coefs[ 6 ] ); res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 7 ], buf_ptr[ 8 ] ), FIR_Coefs[ 7 ] ); - /* Scale down, saturate and store in output array */ + /* Scale down, saturate and store in output array */ *out++ = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( res_Q6, 6 ) ); } return out; } static inline opus_int16 *silk_resampler_private_down_FIR_INTERPOL1( - opus_int16 *out, opus_int32 *buf2, const opus_int16 *FIR_Coefs, opus_int32 max_index_Q16, opus_int32 index_increment_Q16, opus_int32 FIR_Fracs){ - + opus_int16 *out, + opus_int32 *buf2, + const opus_int16 *FIR_Coefs, + opus_int32 max_index_Q16, + opus_int32 index_increment_Q16, + opus_int32 FIR_Fracs +) +{ opus_int32 index_Q16, res_Q6; opus_int32 *buf_ptr; opus_int32 interpol_ind; const opus_int16 *interpol_ptr; + for( index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16 ) { /* Integer part gives pointer to buffered input */ buf_ptr = buf2 + silk_RSHIFT( index_Q16, 16 ); @@ -100,10 +113,10 @@ static inline opus_int16 *silk_resampler_private_down_FIR_INTERPOL1( /* Resample with a 2x downsampler (optional), a 2nd order AR filter followed by FIR interpolation */ void silk_resampler_private_down_FIR( - void *SS, /* I/O: Resampler state */ - opus_int16 out[], /* O: Output signal */ - const opus_int16 in[], /* I: Input signal */ - opus_int32 inLen /* I: Number of input samples */ + void *SS, /* I/O Resampler state */ + opus_int16 out[], /* O Output signal */ + const opus_int16 in[], /* I Input signal */ + opus_int32 inLen /* I Number of input samples */ ) { silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; diff --git a/silk/resampler_private_up2_HQ.c b/silk/resampler_private_up2_HQ.c index e02ee5e6..05e6afb3 100644 --- a/silk/resampler_private_up2_HQ.c +++ b/silk/resampler_private_up2_HQ.c @@ -36,10 +36,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Uses 2nd order allpass filters for the 2x upsampling, followed by a */ /* notch filter just above Nyquist. */ void silk_resampler_private_up2_HQ( - opus_int32 *S, /* I/O: Resampler state [ 6 ] */ - opus_int16 *out, /* O: Output signal [ 2 * len ] */ - const opus_int16 *in, /* I: Input signal [ len ] */ - opus_int32 len /* I: Number of INPUT samples */ + opus_int32 *S, /* I/O Resampler state [ 6 ] */ + opus_int16 *out, /* O Output signal [ 2 * len ] */ + const opus_int16 *in, /* I Input signal [ len ] */ + opus_int32 len /* I Number of input samples */ ) { opus_int32 k; @@ -102,10 +102,10 @@ void silk_resampler_private_up2_HQ( } void silk_resampler_private_up2_HQ_wrapper( - void *SS, /* I/O: Resampler state (unused) */ - opus_int16 *out, /* O: Output signal [ 2 * len ] */ - const opus_int16 *in, /* I: Input signal [ len ] */ - opus_int32 len /* I: Number of input samples */ + void *SS, /* I/O Resampler state (unused) */ + opus_int16 *out, /* O Output signal [ 2 * len ] */ + const opus_int16 *in, /* I Input signal [ len ] */ + opus_int32 len /* I Number of input samples */ ) { silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; diff --git a/silk/resampler_rom.c b/silk/resampler_rom.c index 72217b85..15473e09 100644 --- a/silk/resampler_rom.c +++ b/silk/resampler_rom.c @@ -29,8 +29,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "config.h" #endif -/* Filter coefficients for IIR/FIR polyphase resampling * - * Total size: < 600 Words (1.2 kB) */ +/* Filter coefficients for IIR/FIR polyphase resampling * + * Total size: < 600 Words (1.2 kB) */ #include "resampler_private.h" diff --git a/silk/resampler_rom.h b/silk/resampler_rom.h index ed506004..0eeb9441 100644 --- a/silk/resampler_rom.h +++ b/silk/resampler_rom.h @@ -39,7 +39,6 @@ extern "C" #define RESAMPLER_DOWN_ORDER_FIR 16 #define RESAMPLER_ORDER_FIR_144 6 - /* Tables for 2x downsampler. Values above 32767 intentionally wrap to a negative value. */ extern const opus_int16 silk_resampler_down2_0; extern const opus_int16 silk_resampler_down2_1; diff --git a/silk/resampler_structs.h b/silk/resampler_structs.h index 61dd1bd0..eb2844df 100644 --- a/silk/resampler_structs.h +++ b/silk/resampler_structs.h @@ -32,13 +32,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern "C" { #endif -/* Flag to enable support for input/output sampling rates above 48 kHz. Turn off for embedded devices */ #define SILK_RESAMPLER_MAX_FIR_ORDER 16 #define SILK_RESAMPLER_MAX_IIR_ORDER 6 - typedef struct _silk_resampler_state_struct{ - opus_int32 sIIR[ SILK_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */ + opus_int32 sIIR[ SILK_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */ opus_int32 sFIR[ SILK_RESAMPLER_MAX_FIR_ORDER ]; opus_int32 sDown2[ 2 ]; opus_int32 resampler_function; @@ -46,7 +44,7 @@ typedef struct _silk_resampler_state_struct{ opus_int32 invRatio_Q16; opus_int32 FIR_Fracs; opus_int32 input2x; - const opus_int16 *Coefs; + const opus_int16 *Coefs; } silk_resampler_state_struct; #ifdef __cplusplus diff --git a/silk/shell_coder.c b/silk/shell_coder.c index 2793887e..9ec343c0 100644 --- a/silk/shell_coder.c +++ b/silk/shell_coder.c @@ -34,9 +34,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* shell coder; pulse-subframe length is hardcoded */ static inline void combine_pulses( - opus_int *out, /* O: combined pulses vector [len] */ - const opus_int *in, /* I: input vector [2 * len] */ - const opus_int len /* I: number of OUTPUT samples */ + opus_int *out, /* O combined pulses vector [len] */ + const opus_int *in, /* I input vector [2 * len] */ + const opus_int len /* I number of OUTPUT samples */ ) { opus_int k; @@ -47,9 +47,9 @@ static inline void combine_pulses( static inline void encode_split( ec_enc *psRangeEnc, /* I/O compressor data structure */ - const opus_int p_child1, /* I: pulse amplitude of first child subframe */ - const opus_int p, /* I: pulse amplitude of current subframe */ - const opus_uint8 *shell_table /* I: table of shell cdfs */ + const opus_int p_child1, /* I pulse amplitude of first child subframe */ + const opus_int p, /* I pulse amplitude of current subframe */ + const opus_uint8 *shell_table /* I table of shell cdfs */ ) { if( p > 0 ) { @@ -58,11 +58,11 @@ static inline void encode_split( } static inline void decode_split( - opus_int *p_child1, /* O: pulse amplitude of first child subframe */ - opus_int *p_child2, /* O: pulse amplitude of second child subframe */ + opus_int *p_child1, /* O pulse amplitude of first child subframe */ + opus_int *p_child2, /* O pulse amplitude of second child subframe */ ec_dec *psRangeDec, /* I/O Compressor data structure */ - const opus_int p, /* I: pulse amplitude of current subframe */ - const opus_uint8 *shell_table /* I: table of shell cdfs */ + const opus_int p, /* I pulse amplitude of current subframe */ + const opus_uint8 *shell_table /* I table of shell cdfs */ ) { if( p > 0 ) { @@ -76,8 +76,8 @@ static inline void decode_split( /* Shell encoder, operates on one shell code frame of 16 pulses */ void silk_shell_encoder( - ec_enc *psRangeEnc, /* I/O compressor data structure */ - const opus_int *pulses0 /* I data: nonnegative pulse amplitudes */ + ec_enc *psRangeEnc, /* I/O compressor data structure */ + const opus_int *pulses0 /* I data: nonnegative pulse amplitudes */ ) { opus_int pulses1[ 8 ], pulses2[ 4 ], pulses3[ 2 ], pulses4[ 1 ]; @@ -117,9 +117,9 @@ void silk_shell_encoder( /* Shell decoder, operates on one shell code frame of 16 pulses */ void silk_shell_decoder( - opus_int *pulses0, /* O data: nonnegative pulse amplitudes */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - const opus_int pulses4 /* I number of pulses per pulse-subframe */ + opus_int *pulses0, /* O data: nonnegative pulse amplitudes */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + const opus_int pulses4 /* I number of pulses per pulse-subframe */ ) { opus_int pulses3[ 2 ], pulses2[ 4 ], pulses1[ 8 ]; diff --git a/silk/sigm_Q15.c b/silk/sigm_Q15.c index 7181d29f..8d6b84b0 100644 --- a/silk/sigm_Q15.c +++ b/silk/sigm_Q15.c @@ -46,7 +46,9 @@ static const opus_int32 sigm_LUT_neg_Q15[ 6 ] = { 16384, 8812, 3906, 1554, 589, 219 }; -opus_int silk_sigm_Q15( opus_int in_Q5 ) +opus_int silk_sigm_Q15( + opus_int in_Q5 /* I */ +) { opus_int ind; diff --git a/silk/silk_common.vcxproj b/silk/silk_common.vcxproj index 5be5cba2..b10a6f26 100644 --- a/silk/silk_common.vcxproj +++ b/silk/silk_common.vcxproj @@ -1,193 +1,193 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} - Win32Proj - src_common - silk_common - - - - StaticLibrary - true - Unicode - - - StaticLibrary - false - true - Unicode - - - - - - - - - - - - - $(ProjectName) - - - $(ProjectName) - - - - - - Level3 - Disabled - HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - fixed;float;../win32;../celt - - - Windows - true - - - $(OutDir)$(TargetName)$(TargetExt) - - - - - Level3 - - - MaxSpeed - true - true - HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - fixed;float;../win32;../celt - - - Windows - true - true - true - - - $(OutDir)$(TargetName)$(TargetExt) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} + Win32Proj + src_common + silk_common + + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + $(ProjectName) + + + $(ProjectName) + + + + + + Level3 + Disabled + HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + fixed;float;../win32;../celt;../include + + + Windows + true + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + Level3 + + + MaxSpeed + true + true + HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + fixed;float;../win32;../celt;../include + + + Windows + true + true + true + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/silk/silk_common.vcxproj.filters b/silk/silk_common.vcxproj.filters index a2b5cb8a..f83f070b 100644 --- a/silk/silk_common.vcxproj.filters +++ b/silk/silk_common.vcxproj.filters @@ -1,318 +1,318 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + \ No newline at end of file diff --git a/silk/sort.c b/silk/sort.c index 26d81715..1d92ed38 100644 --- a/silk/sort.c +++ b/silk/sort.c @@ -38,10 +38,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SigProc_FIX.h" void silk_insertion_sort_increasing( - opus_int32 *a, /* I/O: Unsorted / Sorted vector */ - opus_int *idx, /* O: Index vector for the sorted elements */ - const opus_int L, /* I: Vector length */ - const opus_int K /* I: Number of correctly sorted positions */ + opus_int32 *a, /* I/O Unsorted / Sorted vector */ + opus_int *idx, /* O Index vector for the sorted elements */ + const opus_int L, /* I Vector length */ + const opus_int K /* I Number of correctly sorted positions */ ) { opus_int32 value; @@ -84,10 +84,10 @@ void silk_insertion_sort_increasing( } void silk_insertion_sort_decreasing_int16( - opus_int16 *a, /* I/O: Unsorted / Sorted vector */ - opus_int *idx, /* O: Index vector for the sorted elements */ - const opus_int L, /* I: Vector length */ - const opus_int K /* I: Number of correctly sorted positions */ + opus_int16 *a, /* I/O Unsorted / Sorted vector */ + opus_int *idx, /* O Index vector for the sorted elements */ + const opus_int L, /* I Vector length */ + const opus_int K /* I Number of correctly sorted positions */ ) { opus_int i, j; @@ -130,8 +130,8 @@ void silk_insertion_sort_decreasing_int16( } void silk_insertion_sort_increasing_all_values_int16( - opus_int16 *a, /* I/O: Unsorted / Sorted vector */ - const opus_int L /* I: Vector length */ + opus_int16 *a, /* I/O Unsorted / Sorted vector */ + const opus_int L /* I Vector length */ ) { opus_int value; diff --git a/silk/stereo_LR_to_MS.c b/silk/stereo_LR_to_MS.c index bbcd30bf..df600e68 100644 --- a/silk/stereo_LR_to_MS.c +++ b/silk/stereo_LR_to_MS.c @@ -33,17 +33,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Convert Left/Right stereo signal to adaptive Mid/Side representation */ void silk_stereo_LR_to_MS( - stereo_enc_state *state, /* I/O State */ - opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ - opus_int16 x2[], /* I/O Right input signal, becomes side signal */ - opus_int8 ix[ 2 ][ 3 ], /* O Quantization indices */ - opus_int8 *mid_only_flag, /* O Flag: only mid signal coded */ - opus_int32 mid_side_rates_bps[], /* O Bitrates for mid and side signals */ - opus_int32 total_rate_bps, /* I Total bitrate */ - opus_int prev_speech_act_Q8, /* I Speech activity level in previous frame */ - opus_int toMono, /* I Last frame before a stereo->mono transition */ - opus_int fs_kHz, /* I Sample rate (kHz) */ - opus_int frame_length /* I Number of samples */ + stereo_enc_state *state, /* I/O State */ + opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ + opus_int16 x2[], /* I/O Right input signal, becomes side signal */ + opus_int8 ix[ 2 ][ 3 ], /* O Quantization indices */ + opus_int8 *mid_only_flag, /* O Flag: only mid signal coded */ + opus_int32 mid_side_rates_bps[], /* O Bitrates for mid and side signals */ + opus_int32 total_rate_bps, /* I Total bitrate */ + opus_int prev_speech_act_Q8, /* I Speech activity level in previous frame */ + opus_int toMono, /* I Last frame before a stereo->mono transition */ + opus_int fs_kHz, /* I Sample rate (kHz) */ + opus_int frame_length /* I Number of samples */ ) { opus_int n, is10msFrame, denom_Q16, delta0_Q13, delta1_Q13; @@ -185,12 +185,6 @@ void silk_stereo_LR_to_MS( mid_side_rates_bps[ 1 ] = 1; mid_side_rates_bps[ 0 ] = silk_max_int( 1, total_rate_bps - mid_side_rates_bps[ 1 ]); } -#if 0 - DEBUG_STORE_DATA( midside.dat, &mid_side_rates_bps[ 0 ], 8 ); - DEBUG_STORE_DATA( norms0.pcm, &state->mid_side_amp_Q0[0], 8 ); - DEBUG_STORE_DATA( norms1.pcm, &state->mid_side_amp_Q0[2], 8 ); - DEBUG_STORE_DATA( width.pcm, &width_Q14, 4 ); -#endif /* Interpolate predictors and subtract prediction from side channel */ pred0_Q13 = -state->pred_prev_Q13[ 0 ]; diff --git a/silk/stereo_MS_to_LR.c b/silk/stereo_MS_to_LR.c index efd72c46..e95e47b5 100644 --- a/silk/stereo_MS_to_LR.c +++ b/silk/stereo_MS_to_LR.c @@ -33,12 +33,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Convert adaptive Mid/Side representation to Left/Right stereo signal */ void silk_stereo_MS_to_LR( - stereo_dec_state *state, /* I/O State */ - opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ - opus_int16 x2[], /* I/O Right input signal, becomes side signal */ - const opus_int32 pred_Q13[], /* I Predictors */ - opus_int fs_kHz, /* I Samples rate (kHz) */ - opus_int frame_length /* I Number of samples */ + stereo_dec_state *state, /* I/O State */ + opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ + opus_int16 x2[], /* I/O Right input signal, becomes side signal */ + const opus_int32 pred_Q13[], /* I Predictors */ + opus_int fs_kHz, /* I Samples rate (kHz) */ + opus_int frame_length /* I Number of samples */ ) { opus_int n, denom_Q16, delta0_Q13, delta1_Q13; diff --git a/silk/stereo_decode_pred.c b/silk/stereo_decode_pred.c index 43886f1e..a7c2e41b 100644 --- a/silk/stereo_decode_pred.c +++ b/silk/stereo_decode_pred.c @@ -33,8 +33,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Decode mid/side predictors */ void silk_stereo_decode_pred( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int32 pred_Q13[] /* O Predictors */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int32 pred_Q13[] /* O Predictors */ ) { opus_int n, ix[ 2 ][ 3 ]; @@ -64,8 +64,8 @@ void silk_stereo_decode_pred( /* Decode mid-only flag */ void silk_stereo_decode_mid_only( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int *decode_only_mid /* O Flag that only mid channel has been coded */ + ec_dec *psRangeDec, /* I/O Compressor data structure */ + opus_int *decode_only_mid /* O Flag that only mid channel has been coded */ ) { /* Decode flag that only mid channel is coded */ diff --git a/silk/stereo_encode_pred.c b/silk/stereo_encode_pred.c index a6419f25..0b78a2e5 100644 --- a/silk/stereo_encode_pred.c +++ b/silk/stereo_encode_pred.c @@ -33,8 +33,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Entropy code the mid/side quantization indices */ void silk_stereo_encode_pred( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int8 ix[ 2 ][ 3 ] /* I Quantization indices */ + ec_enc *psRangeEnc, /* I/O Compressor data structure */ + opus_int8 ix[ 2 ][ 3 ] /* I Quantization indices */ ) { opus_int n; @@ -53,8 +53,8 @@ void silk_stereo_encode_pred( /* Entropy code the mid-only flag */ void silk_stereo_encode_mid_only( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int8 mid_only_flag + ec_enc *psRangeEnc, /* I/O Compressor data structure */ + opus_int8 mid_only_flag ) { /* Encode flag that only mid channel is coded */ diff --git a/silk/stereo_find_predictor.c b/silk/stereo_find_predictor.c index d7be0f5f..9460bf7b 100644 --- a/silk/stereo_find_predictor.c +++ b/silk/stereo_find_predictor.c @@ -32,13 +32,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "main.h" /* Find least-squares prediction gain for one signal based on another and quantize it */ -opus_int32 silk_stereo_find_predictor( /* O Returns predictor in Q13 */ - opus_int32 *ratio_Q14, /* O Ratio of residual and mid energies */ - const opus_int16 x[], /* I Basis signal */ - const opus_int16 y[], /* I Target signal */ - opus_int32 mid_res_amp_Q0[], /* I/O Smoothed mid, residual norms */ - opus_int length, /* I Number of samples */ - opus_int smooth_coef_Q16 /* I Smoothing coefficient */ +opus_int32 silk_stereo_find_predictor( /* O Returns predictor in Q13 */ + opus_int32 *ratio_Q14, /* O Ratio of residual and mid energies */ + const opus_int16 x[], /* I Basis signal */ + const opus_int16 y[], /* I Target signal */ + opus_int32 mid_res_amp_Q0[], /* I/O Smoothed mid, residual norms */ + opus_int length, /* I Number of samples */ + opus_int smooth_coef_Q16 /* I Smoothing coefficient */ ) { opus_int scale, scale1, scale2; diff --git a/silk/stereo_quant_pred.c b/silk/stereo_quant_pred.c index f91ed923..faacf04d 100644 --- a/silk/stereo_quant_pred.c +++ b/silk/stereo_quant_pred.c @@ -33,8 +33,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Quantize mid/side predictors */ void silk_stereo_quant_pred( - opus_int32 pred_Q13[], /* I/O Predictors (out: quantized) */ - opus_int8 ix[ 2 ][ 3 ] /* O Quantization indices */ + opus_int32 pred_Q13[], /* I/O Predictors (out: quantized) */ + opus_int8 ix[ 2 ][ 3 ] /* O Quantization indices */ ) { opus_int i, j, n; diff --git a/silk/structs.h b/silk/structs.h index 51c0f866..02750192 100644 --- a/silk/structs.h +++ b/silk/structs.h @@ -43,40 +43,40 @@ extern "C" /* Noise shaping quantization state */ /************************************/ typedef struct { - opus_int16 xq[ 2 * MAX_FRAME_LENGTH ]; /* Buffer for quantized output signal */ - opus_int32 sLTP_shp_Q10[ 2 * MAX_FRAME_LENGTH ]; - opus_int32 sLPC_Q14[ MAX_SUB_FRAME_LENGTH + NSQ_LPC_BUF_LENGTH ]; - opus_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ]; - opus_int32 sLF_AR_shp_Q12; - opus_int lagPrev; - opus_int sLTP_buf_idx; - opus_int sLTP_shp_buf_idx; - opus_int32 rand_seed; - opus_int32 prev_inv_gain_Q16; - opus_int rewhite_flag; + opus_int16 xq[ 2 * MAX_FRAME_LENGTH ]; /* Buffer for quantized output signal */ + opus_int32 sLTP_shp_Q10[ 2 * MAX_FRAME_LENGTH ]; + opus_int32 sLPC_Q14[ MAX_SUB_FRAME_LENGTH + NSQ_LPC_BUF_LENGTH ]; + opus_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ]; + opus_int32 sLF_AR_shp_Q12; + opus_int lagPrev; + opus_int sLTP_buf_idx; + opus_int sLTP_shp_buf_idx; + opus_int32 rand_seed; + opus_int32 prev_inv_gain_Q16; + opus_int rewhite_flag; } silk_nsq_state; /********************************/ /* VAD state */ /********************************/ typedef struct { - opus_int32 AnaState[ 2 ]; /* Analysis filterbank state: 0-8 kHz */ - opus_int32 AnaState1[ 2 ]; /* Analysis filterbank state: 0-4 kHz */ - opus_int32 AnaState2[ 2 ]; /* Analysis filterbank state: 0-2 kHz */ - opus_int32 XnrgSubfr[ VAD_N_BANDS ]; /* Subframe energies */ - opus_int32 NrgRatioSmth_Q8[ VAD_N_BANDS ]; /* Smoothed energy level in each band */ - opus_int16 HPstate; /* State of differentiator in the lowest band */ - opus_int32 NL[ VAD_N_BANDS ]; /* Noise energy level in each band */ - opus_int32 inv_NL[ VAD_N_BANDS ]; /* Inverse noise energy level in each band */ - opus_int32 NoiseLevelBias[ VAD_N_BANDS ]; /* Noise level estimator bias/offset */ - opus_int32 counter; /* Frame counter used in the initial phase */ + opus_int32 AnaState[ 2 ]; /* Analysis filterbank state: 0-8 kHz */ + opus_int32 AnaState1[ 2 ]; /* Analysis filterbank state: 0-4 kHz */ + opus_int32 AnaState2[ 2 ]; /* Analysis filterbank state: 0-2 kHz */ + opus_int32 XnrgSubfr[ VAD_N_BANDS ]; /* Subframe energies */ + opus_int32 NrgRatioSmth_Q8[ VAD_N_BANDS ]; /* Smoothed energy level in each band */ + opus_int16 HPstate; /* State of differentiator in the lowest band */ + opus_int32 NL[ VAD_N_BANDS ]; /* Noise energy level in each band */ + opus_int32 inv_NL[ VAD_N_BANDS ]; /* Inverse noise energy level in each band */ + opus_int32 NoiseLevelBias[ VAD_N_BANDS ]; /* Noise level estimator bias/offset */ + opus_int32 counter; /* Frame counter used in the initial phase */ } silk_VAD_state; /* Variable cut-off low-pass filter state */ typedef struct { opus_int32 In_LP_State[ 2 ]; /* Low pass filter state */ opus_int32 transition_frame_no; /* Counter which is mapped to a cut-off frequency */ - opus_int mode; /* Operating mode, <0: switch down, >0: switch up; 0: do nothing */ + opus_int mode; /* Operating mode, <0: switch down, >0: switch up; 0: do nothing */ } silk_LP_state; /* Structure containing NLSF codebook */ @@ -130,176 +130,176 @@ typedef struct { /* Encoder state */ /********************************/ typedef struct { - opus_int32 In_HP_State[ 2 ]; /* High pass filter state */ - opus_int32 variable_HP_smth1_Q15; /* State of first smoother */ - opus_int32 variable_HP_smth2_Q15; /* State of second smoother */ - silk_LP_state sLP; /* Low pass filter state */ - silk_VAD_state sVAD; /* Voice activity detector state */ - silk_nsq_state sNSQ; /* Noise Shape Quantizer State */ - opus_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ];/* Previously quantized NLSF vector */ - opus_int speech_activity_Q8; /* Speech activity */ - opus_int allow_bandwidth_switch; /* Flag indicating that switching of internal bandwidth is allowed */ - opus_int8 LBRRprevLastGainIndex; - opus_int8 prevSignalType; - opus_int prevLag; - opus_int pitch_LPC_win_length; - opus_int max_pitch_lag; /* Highest possible pitch lag (samples) */ - opus_int32 API_fs_Hz; /* API sampling frequency (Hz) */ - opus_int32 prev_API_fs_Hz; /* Previous API sampling frequency (Hz) */ - opus_int maxInternal_fs_Hz; /* Maximum internal sampling frequency (Hz) */ - opus_int minInternal_fs_Hz; /* Minimum internal sampling frequency (Hz) */ - opus_int desiredInternal_fs_Hz; /* Soft request for internal sampling frequency (Hz) */ - opus_int fs_kHz; /* Internal sampling frequency (kHz) */ - opus_int delay; /* Number of samples of delay to apply */ - opus_int nb_subfr; /* Number of 5 ms subframes in a frame */ - opus_int frame_length; /* Frame length (samples) */ - opus_int subfr_length; /* Subframe length (samples) */ - opus_int ltp_mem_length; /* Length of LTP memory */ - opus_int la_pitch; /* Look-ahead for pitch analysis (samples) */ - opus_int la_shape; /* Look-ahead for noise shape analysis (samples) */ - opus_int shapeWinLength; /* Window length for noise shape analysis (samples) */ - opus_int32 TargetRate_bps; /* Target bitrate (bps) */ - opus_int PacketSize_ms; /* Number of milliseconds to put in each packet */ - opus_int PacketLoss_perc; /* Packet loss rate measured by farend */ - opus_int32 frameCounter; - opus_int Complexity; /* Complexity setting */ - opus_int nStatesDelayedDecision; /* Number of states in delayed decision quantization */ - opus_int useInterpolatedNLSFs; /* Flag for using NLSF interpolation */ - opus_int shapingLPCOrder; /* Filter order for noise shaping filters */ - opus_int predictLPCOrder; /* Filter order for prediction filters */ - opus_int pitchEstimationComplexity; /* Complexity level for pitch estimator */ - opus_int pitchEstimationLPCOrder; /* Whitening filter order for pitch estimator */ - opus_int32 pitchEstimationThreshold_Q16; /* Threshold for pitch estimator */ - opus_int LTPQuantLowComplexity; /* Flag for low complexity LTP quantization */ - opus_int mu_LTP_Q9; /* Rate-distortion tradeoff in LTP quantization */ - opus_int NLSF_MSVQ_Survivors; /* Number of survivors in NLSF MSVQ */ - opus_int first_frame_after_reset; /* Flag for deactivating NLSF interpolation, pitch prediction */ - opus_int controlled_since_last_payload; /* Flag for ensuring codec_control only runs once per packet */ - opus_int warping_Q16; /* Warping parameter for warped noise shaping */ - opus_int useCBR; /* Flag to enable constant bitrate */ - opus_int prefillFlag; /* Flag to indicate that only buffers are prefilled, no coding */ - const opus_uint8 *pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */ - const opus_uint8 *pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */ - const silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ - opus_int input_quality_bands_Q15[ VAD_N_BANDS ]; - opus_int input_tilt_Q15; - opus_int SNR_dB_Q7; /* Quality setting */ - - opus_int8 VAD_flags[ MAX_FRAMES_PER_PACKET ]; - opus_int8 LBRR_flag; - opus_int LBRR_flags[ MAX_FRAMES_PER_PACKET ]; - - SideInfoIndices indices; - opus_int8 pulses[ MAX_FRAME_LENGTH ]; + opus_int32 In_HP_State[ 2 ]; /* High pass filter state */ + opus_int32 variable_HP_smth1_Q15; /* State of first smoother */ + opus_int32 variable_HP_smth2_Q15; /* State of second smoother */ + silk_LP_state sLP; /* Low pass filter state */ + silk_VAD_state sVAD; /* Voice activity detector state */ + silk_nsq_state sNSQ; /* Noise Shape Quantizer State */ + opus_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ]; /* Previously quantized NLSF vector */ + opus_int speech_activity_Q8; /* Speech activity */ + opus_int allow_bandwidth_switch; /* Flag indicating that switching of internal bandwidth is allowed */ + opus_int8 LBRRprevLastGainIndex; + opus_int8 prevSignalType; + opus_int prevLag; + opus_int pitch_LPC_win_length; + opus_int max_pitch_lag; /* Highest possible pitch lag (samples) */ + opus_int32 API_fs_Hz; /* API sampling frequency (Hz) */ + opus_int32 prev_API_fs_Hz; /* Previous API sampling frequency (Hz) */ + opus_int maxInternal_fs_Hz; /* Maximum internal sampling frequency (Hz) */ + opus_int minInternal_fs_Hz; /* Minimum internal sampling frequency (Hz) */ + opus_int desiredInternal_fs_Hz; /* Soft request for internal sampling frequency (Hz) */ + opus_int fs_kHz; /* Internal sampling frequency (kHz) */ + opus_int delay; /* Number of samples of delay to apply */ + opus_int nb_subfr; /* Number of 5 ms subframes in a frame */ + opus_int frame_length; /* Frame length (samples) */ + opus_int subfr_length; /* Subframe length (samples) */ + opus_int ltp_mem_length; /* Length of LTP memory */ + opus_int la_pitch; /* Look-ahead for pitch analysis (samples) */ + opus_int la_shape; /* Look-ahead for noise shape analysis (samples) */ + opus_int shapeWinLength; /* Window length for noise shape analysis (samples) */ + opus_int32 TargetRate_bps; /* Target bitrate (bps) */ + opus_int PacketSize_ms; /* Number of milliseconds to put in each packet */ + opus_int PacketLoss_perc; /* Packet loss rate measured by farend */ + opus_int32 frameCounter; + opus_int Complexity; /* Complexity setting */ + opus_int nStatesDelayedDecision; /* Number of states in delayed decision quantization */ + opus_int useInterpolatedNLSFs; /* Flag for using NLSF interpolation */ + opus_int shapingLPCOrder; /* Filter order for noise shaping filters */ + opus_int predictLPCOrder; /* Filter order for prediction filters */ + opus_int pitchEstimationComplexity; /* Complexity level for pitch estimator */ + opus_int pitchEstimationLPCOrder; /* Whitening filter order for pitch estimator */ + opus_int32 pitchEstimationThreshold_Q16; /* Threshold for pitch estimator */ + opus_int LTPQuantLowComplexity; /* Flag for low complexity LTP quantization */ + opus_int mu_LTP_Q9; /* Rate-distortion tradeoff in LTP quantization */ + opus_int NLSF_MSVQ_Survivors; /* Number of survivors in NLSF MSVQ */ + opus_int first_frame_after_reset; /* Flag for deactivating NLSF interpolation, pitch prediction */ + opus_int controlled_since_last_payload; /* Flag for ensuring codec_control only runs once per packet */ + opus_int warping_Q16; /* Warping parameter for warped noise shaping */ + opus_int useCBR; /* Flag to enable constant bitrate */ + opus_int prefillFlag; /* Flag to indicate that only buffers are prefilled, no coding */ + const opus_uint8 *pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */ + const opus_uint8 *pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */ + const silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ + opus_int input_quality_bands_Q15[ VAD_N_BANDS ]; + opus_int input_tilt_Q15; + opus_int SNR_dB_Q7; /* Quality setting */ + + opus_int8 VAD_flags[ MAX_FRAMES_PER_PACKET ]; + opus_int8 LBRR_flag; + opus_int LBRR_flags[ MAX_FRAMES_PER_PACKET ]; + + SideInfoIndices indices; + opus_int8 pulses[ MAX_FRAME_LENGTH ]; /* Input/output buffering */ - opus_int16 inputBuf[ MAX_FRAME_LENGTH + 2 ]; /* Buffer containing input signal */ - opus_int16 delayBuf[MAX_ENCODER_DELAY]; - opus_int inputBufIx; - opus_int nFramesPerPacket; - opus_int nFramesEncoded; /* Number of frames analyzed in current packet */ + opus_int16 inputBuf[ MAX_FRAME_LENGTH + 2 ]; /* Buffer containing input signal */ + opus_int16 delayBuf[MAX_ENCODER_DELAY]; + opus_int inputBufIx; + opus_int nFramesPerPacket; + opus_int nFramesEncoded; /* Number of frames analyzed in current packet */ - opus_int nChannelsAPI; - opus_int nChannelsInternal; - opus_int channelNb; + opus_int nChannelsAPI; + opus_int nChannelsInternal; + opus_int channelNb; /* Parameters For LTP scaling Control */ - opus_int frames_since_onset; + opus_int frames_since_onset; /* Specifically for entropy coding */ - opus_int ec_prevSignalType; - opus_int16 ec_prevLagIndex; + opus_int ec_prevSignalType; + opus_int16 ec_prevLagIndex; silk_resampler_state_struct resampler_state; /* DTX */ - opus_int useDTX; /* Flag to enable DTX */ - opus_int inDTX; /* Flag to signal DTX period */ - opus_int noSpeechCounter; /* Counts concecutive nonactive frames, used by DTX */ + opus_int useDTX; /* Flag to enable DTX */ + opus_int inDTX; /* Flag to signal DTX period */ + opus_int noSpeechCounter; /* Counts concecutive nonactive frames, used by DTX */ /* Inband Low Bitrate Redundancy (LBRR) data */ - opus_int useInBandFEC; /* Saves the API setting for query */ - opus_int LBRR_enabled; /* Depends on useInBandFRC, bitrate and packet loss rate */ - opus_int LBRR_GainIncreases; /* Gains increment for coding LBRR frames */ - SideInfoIndices indices_LBRR[ MAX_FRAMES_PER_PACKET ]; - opus_int8 pulses_LBRR[ MAX_FRAMES_PER_PACKET ][ MAX_FRAME_LENGTH ]; + opus_int useInBandFEC; /* Saves the API setting for query */ + opus_int LBRR_enabled; /* Depends on useInBandFRC, bitrate and packet loss rate */ + opus_int LBRR_GainIncreases; /* Gains increment for coding LBRR frames */ + SideInfoIndices indices_LBRR[ MAX_FRAMES_PER_PACKET ]; + opus_int8 pulses_LBRR[ MAX_FRAMES_PER_PACKET ][ MAX_FRAME_LENGTH ]; } silk_encoder_state; /* Struct for Packet Loss Concealment */ typedef struct { - opus_int32 pitchL_Q8; /* Pitch lag to use for voiced concealment */ - opus_int16 LTPCoef_Q14[ LTP_ORDER ]; /* LTP coeficients to use for voiced concealment */ - opus_int16 prevLPC_Q12[ MAX_LPC_ORDER ]; - opus_int last_frame_lost; /* Was previous frame lost */ - opus_int32 rand_seed; /* Seed for unvoiced signal generation */ - opus_int16 randScale_Q14; /* Scaling of unvoiced random signal */ - opus_int32 conc_energy; - opus_int conc_energy_shift; - opus_int16 prevLTP_scale_Q14; - opus_int32 prevGain_Q16[ MAX_NB_SUBFR ]; - opus_int fs_kHz; + opus_int32 pitchL_Q8; /* Pitch lag to use for voiced concealment */ + opus_int16 LTPCoef_Q14[ LTP_ORDER ]; /* LTP coeficients to use for voiced concealment */ + opus_int16 prevLPC_Q12[ MAX_LPC_ORDER ]; + opus_int last_frame_lost; /* Was previous frame lost */ + opus_int32 rand_seed; /* Seed for unvoiced signal generation */ + opus_int16 randScale_Q14; /* Scaling of unvoiced random signal */ + opus_int32 conc_energy; + opus_int conc_energy_shift; + opus_int16 prevLTP_scale_Q14; + opus_int32 prevGain_Q16[ MAX_NB_SUBFR ]; + opus_int fs_kHz; } silk_PLC_struct; /* Struct for CNG */ typedef struct { - opus_int32 CNG_exc_buf_Q10[ MAX_FRAME_LENGTH ]; - opus_int16 CNG_smth_NLSF_Q15[ MAX_LPC_ORDER ]; - opus_int32 CNG_synth_state[ MAX_LPC_ORDER ]; - opus_int32 CNG_smth_Gain_Q16; - opus_int32 rand_seed; - opus_int fs_kHz; + opus_int32 CNG_exc_buf_Q10[ MAX_FRAME_LENGTH ]; + opus_int16 CNG_smth_NLSF_Q15[ MAX_LPC_ORDER ]; + opus_int32 CNG_synth_state[ MAX_LPC_ORDER ]; + opus_int32 CNG_smth_Gain_Q16; + opus_int32 rand_seed; + opus_int fs_kHz; } silk_CNG_struct; /********************************/ /* Decoder state */ /********************************/ typedef struct { - opus_int32 prev_inv_gain_Q16; - opus_int32 exc_Q10[ MAX_FRAME_LENGTH ]; - opus_int32 sLPC_Q14_buf[ MAX_LPC_ORDER ]; - opus_int16 outBuf[ MAX_FRAME_LENGTH + 2 * MAX_SUB_FRAME_LENGTH ]; /* Buffer for output signal */ - opus_int16 delayBuf[ MAX_DECODER_DELAY ]; /* Buffer for delaying the SILK output prior to resampling */ - opus_int delay; /* How much decoder delay to add */ - opus_int lagPrev; /* Previous Lag */ - opus_int8 LastGainIndex; /* Previous gain index */ - opus_int fs_kHz; /* Sampling frequency in kHz */ - opus_int32 fs_API_hz; /* API sample frequency (Hz) */ - opus_int nb_subfr; /* Number of 5 ms subframes in a frame */ - opus_int frame_length; /* Frame length (samples) */ - opus_int subfr_length; /* Subframe length (samples) */ - opus_int ltp_mem_length; /* Length of LTP memory */ - opus_int LPC_order; /* LPC order */ - opus_int16 prevNLSF_Q15[ MAX_LPC_ORDER ]; /* Used to interpolate LSFs */ - opus_int first_frame_after_reset; /* Flag for deactivating NLSF interpolation */ - const opus_uint8 *pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */ - const opus_uint8 *pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */ + opus_int32 prev_inv_gain_Q16; + opus_int32 exc_Q10[ MAX_FRAME_LENGTH ]; + opus_int32 sLPC_Q14_buf[ MAX_LPC_ORDER ]; + opus_int16 outBuf[ MAX_FRAME_LENGTH + 2 * MAX_SUB_FRAME_LENGTH ]; /* Buffer for output signal */ + opus_int16 delayBuf[ MAX_DECODER_DELAY ]; /* Buffer for delaying the SILK output prior to resampling */ + opus_int delay; /* How much decoder delay to add */ + opus_int lagPrev; /* Previous Lag */ + opus_int8 LastGainIndex; /* Previous gain index */ + opus_int fs_kHz; /* Sampling frequency in kHz */ + opus_int32 fs_API_hz; /* API sample frequency (Hz) */ + opus_int nb_subfr; /* Number of 5 ms subframes in a frame */ + opus_int frame_length; /* Frame length (samples) */ + opus_int subfr_length; /* Subframe length (samples) */ + opus_int ltp_mem_length; /* Length of LTP memory */ + opus_int LPC_order; /* LPC order */ + opus_int16 prevNLSF_Q15[ MAX_LPC_ORDER ]; /* Used to interpolate LSFs */ + opus_int first_frame_after_reset; /* Flag for deactivating NLSF interpolation */ + const opus_uint8 *pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */ + const opus_uint8 *pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */ /* For buffering payload in case of more frames per packet */ - opus_int nFramesDecoded; - opus_int nFramesPerPacket; + opus_int nFramesDecoded; + opus_int nFramesPerPacket; /* Specifically for entropy coding */ - opus_int ec_prevSignalType; - opus_int16 ec_prevLagIndex; + opus_int ec_prevSignalType; + opus_int16 ec_prevLagIndex; - opus_int VAD_flags[ MAX_FRAMES_PER_PACKET ]; - opus_int LBRR_flag; - opus_int LBRR_flags[ MAX_FRAMES_PER_PACKET ]; + opus_int VAD_flags[ MAX_FRAMES_PER_PACKET ]; + opus_int LBRR_flag; + opus_int LBRR_flags[ MAX_FRAMES_PER_PACKET ]; silk_resampler_state_struct resampler_state; - const silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ + const silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ /* Quantization indices */ - SideInfoIndices indices; + SideInfoIndices indices; /* CNG state */ - silk_CNG_struct sCNG; + silk_CNG_struct sCNG; /* Stuff used for PLC */ - opus_int lossCnt; - opus_int prevSignalType; + opus_int lossCnt; + opus_int prevSignalType; silk_PLC_struct sPLC; @@ -309,13 +309,13 @@ typedef struct { /* Decoder control */ /************************/ typedef struct { - /* prediction and coding parameters */ - opus_int pitchL[ MAX_NB_SUBFR ]; - opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; - /* holds interpolated and final coefficients, 4-byte aligned */ + /* Prediction and coding parameters */ + opus_int pitchL[ MAX_NB_SUBFR ]; + opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; + /* Holds interpolated and final coefficients, 4-byte aligned */ silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; - opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; - opus_int LTP_scale_Q14; + opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; + opus_int LTP_scale_Q14; } silk_decoder_control; diff --git a/silk/sum_sqr_shift.c b/silk/sum_sqr_shift.c index dcadf1b4..246d5f4a 100644 --- a/silk/sum_sqr_shift.c +++ b/silk/sum_sqr_shift.c @@ -34,10 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Compute number of bits to right shift the sum of squares of a vector */ /* of int16s to make it fit in an int32 */ void silk_sum_sqr_shift( - opus_int32 *energy, /* O Energy of x, after shifting to the right */ - opus_int *shift, /* O Number of bits right shift applied to energy */ - const opus_int16 *x, /* I Input vector */ - opus_int len /* I Length of input vector */ + opus_int32 *energy, /* O Energy of x, after shifting to the right */ + opus_int *shift, /* O Number of bits right shift applied to energy */ + const opus_int16 *x, /* I Input vector */ + opus_int len /* I Length of input vector */ ) { opus_int i, shft; diff --git a/silk/tables.h b/silk/tables.h index 1b8b68fd..813fadd1 100644 --- a/silk/tables.h +++ b/silk/tables.h @@ -36,82 +36,82 @@ extern "C" { #endif -/* entropy coding tables */ -extern const opus_uint8 silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ]; /* 24 */ -extern const opus_uint8 silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ]; /* 41 */ +/* Entropy coding tables (with size in bytes indicated) */ +extern const opus_uint8 silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ]; /* 24 */ +extern const opus_uint8 silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ]; /* 41 */ -extern const opus_uint8 silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ]; /* 32 */ -extern const opus_uint8 silk_pitch_delta_iCDF[ 21 ]; /* 21 */ -extern const opus_uint8 silk_pitch_contour_iCDF[ 34 ]; /* 34 */ -extern const opus_uint8 silk_pitch_contour_NB_iCDF[ 11 ]; /* 11 */ -extern const opus_uint8 silk_pitch_contour_10_ms_iCDF[ 12 ]; /* 12 */ -extern const opus_uint8 silk_pitch_contour_10_ms_NB_iCDF[ 3 ]; /* 3 */ +extern const opus_uint8 silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ];/* 32 */ +extern const opus_uint8 silk_pitch_delta_iCDF[ 21 ]; /* 21 */ +extern const opus_uint8 silk_pitch_contour_iCDF[ 34 ]; /* 34 */ +extern const opus_uint8 silk_pitch_contour_NB_iCDF[ 11 ]; /* 11 */ +extern const opus_uint8 silk_pitch_contour_10_ms_iCDF[ 12 ]; /* 12 */ +extern const opus_uint8 silk_pitch_contour_10_ms_NB_iCDF[ 3 ]; /* 3 */ -extern const opus_uint8 silk_pulses_per_block_iCDF[ N_RATE_LEVELS ][ MAX_PULSES + 2 ]; /* 180 */ -extern const opus_uint8 silk_pulses_per_block_BITS_Q5[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 2 ]; /* 162 */ +extern const opus_uint8 silk_pulses_per_block_iCDF[ N_RATE_LEVELS ][ MAX_PULSES + 2 ]; /* 180 */ +extern const opus_uint8 silk_pulses_per_block_BITS_Q5[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 2 ]; /* 162 */ -extern const opus_uint8 silk_rate_levels_iCDF[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ -extern const opus_uint8 silk_rate_levels_BITS_Q5[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ +extern const opus_uint8 silk_rate_levels_iCDF[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ +extern const opus_uint8 silk_rate_levels_BITS_Q5[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ -extern const opus_uint8 silk_max_pulses_table[ 4 ]; /* 4 */ +extern const opus_uint8 silk_max_pulses_table[ 4 ]; /* 4 */ -extern const opus_uint8 silk_shell_code_table0[ 152 ]; /* 152 */ -extern const opus_uint8 silk_shell_code_table1[ 152 ]; /* 152 */ -extern const opus_uint8 silk_shell_code_table2[ 152 ]; /* 152 */ -extern const opus_uint8 silk_shell_code_table3[ 152 ]; /* 152 */ -extern const opus_uint8 silk_shell_code_table_offsets[ MAX_PULSES + 1 ]; /* 17 */ +extern const opus_uint8 silk_shell_code_table0[ 152 ]; /* 152 */ +extern const opus_uint8 silk_shell_code_table1[ 152 ]; /* 152 */ +extern const opus_uint8 silk_shell_code_table2[ 152 ]; /* 152 */ +extern const opus_uint8 silk_shell_code_table3[ 152 ]; /* 152 */ +extern const opus_uint8 silk_shell_code_table_offsets[ MAX_PULSES + 1 ]; /* 17 */ -extern const opus_uint8 silk_lsb_iCDF[ 2 ]; /* 2 */ +extern const opus_uint8 silk_lsb_iCDF[ 2 ]; /* 2 */ -extern const opus_uint8 silk_sign_iCDF[ 42 ]; /* 42 */ +extern const opus_uint8 silk_sign_iCDF[ 42 ]; /* 42 */ -extern const opus_uint8 silk_uniform3_iCDF[ 3 ]; /* 3 */ -extern const opus_uint8 silk_uniform4_iCDF[ 4 ]; /* 4 */ -extern const opus_uint8 silk_uniform5_iCDF[ 5 ]; /* 5 */ -extern const opus_uint8 silk_uniform6_iCDF[ 6 ]; /* 6 */ -extern const opus_uint8 silk_uniform8_iCDF[ 8 ]; /* 8 */ +extern const opus_uint8 silk_uniform3_iCDF[ 3 ]; /* 3 */ +extern const opus_uint8 silk_uniform4_iCDF[ 4 ]; /* 4 */ +extern const opus_uint8 silk_uniform5_iCDF[ 5 ]; /* 5 */ +extern const opus_uint8 silk_uniform6_iCDF[ 6 ]; /* 6 */ +extern const opus_uint8 silk_uniform8_iCDF[ 8 ]; /* 8 */ -extern const opus_uint8 silk_NLSF_EXT_iCDF[ 7 ]; /* 7 */ +extern const opus_uint8 silk_NLSF_EXT_iCDF[ 7 ]; /* 7 */ -extern const opus_uint8 silk_LTP_per_index_iCDF[ 3 ]; /* 3 */ -extern const opus_uint8 * const silk_LTP_gain_iCDF_ptrs[ NB_LTP_CBKS ]; /* 3 */ -extern const opus_uint8 * const silk_LTP_gain_BITS_Q5_ptrs[ NB_LTP_CBKS ]; /* 3 */ +extern const opus_uint8 silk_LTP_per_index_iCDF[ 3 ]; /* 3 */ +extern const opus_uint8 * const silk_LTP_gain_iCDF_ptrs[ NB_LTP_CBKS ]; /* 3 */ +extern const opus_uint8 * const silk_LTP_gain_BITS_Q5_ptrs[ NB_LTP_CBKS ]; /* 3 */ extern const opus_int16 silk_LTP_gain_middle_avg_RD_Q14; -extern const opus_int8 * const silk_LTP_vq_ptrs_Q7[ NB_LTP_CBKS ]; /* 168 */ -extern const opus_int8 silk_LTP_vq_sizes[ NB_LTP_CBKS ]; /* 3 */ +extern const opus_int8 * const silk_LTP_vq_ptrs_Q7[ NB_LTP_CBKS ]; /* 168 */ +extern const opus_int8 silk_LTP_vq_sizes[ NB_LTP_CBKS ]; /* 3 */ -extern const opus_uint8 silk_LTPscale_iCDF[ 3 ]; /* 4 */ -extern const opus_int16 silk_LTPScales_table_Q14[ 3 ]; +extern const opus_uint8 silk_LTPscale_iCDF[ 3 ]; /* 4 */ +extern const opus_int16 silk_LTPScales_table_Q14[ 3 ]; /* 6 */ -extern const opus_uint8 silk_type_offset_VAD_iCDF[ 4 ]; /* 4 */ -extern const opus_uint8 silk_type_offset_no_VAD_iCDF[ 2 ]; /* 2 */ +extern const opus_uint8 silk_type_offset_VAD_iCDF[ 4 ]; /* 4 */ +extern const opus_uint8 silk_type_offset_no_VAD_iCDF[ 2 ]; /* 2 */ -extern const opus_int16 silk_stereo_pred_quant_Q13[ STEREO_QUANT_TAB_SIZE ]; /* 32 */ -extern const opus_uint8 silk_stereo_pred_joint_iCDF[ 25 ]; /* 25 */ -extern const opus_uint8 silk_stereo_only_code_mid_iCDF[ 2 ]; /* 2 */ +extern const opus_int16 silk_stereo_pred_quant_Q13[ STEREO_QUANT_TAB_SIZE ]; /* 32 */ +extern const opus_uint8 silk_stereo_pred_joint_iCDF[ 25 ]; /* 25 */ +extern const opus_uint8 silk_stereo_only_code_mid_iCDF[ 2 ]; /* 2 */ -extern const opus_uint8 * const silk_LBRR_flags_iCDF_ptr[ 2 ]; /* 10 */ +extern const opus_uint8 * const silk_LBRR_flags_iCDF_ptr[ 2 ]; /* 10 */ -extern const opus_uint8 silk_NLSF_interpolation_factor_iCDF[ 5 ]; /* 5 */ +extern const opus_uint8 silk_NLSF_interpolation_factor_iCDF[ 5 ]; /* 5 */ -extern const silk_NLSF_CB_struct silk_NLSF_CB_WB; -extern const silk_NLSF_CB_struct silk_NLSF_CB_NB_MB; +extern const silk_NLSF_CB_struct silk_NLSF_CB_WB; /* 1040 */ +extern const silk_NLSF_CB_struct silk_NLSF_CB_NB_MB; /* 728 */ /* Piece-wise linear mapping from bitrate in kbps to coding quality in dB SNR */ -extern const opus_int32 silk_TargetRate_table_NB[ TARGET_RATE_TAB_SZ ]; -extern const opus_int32 silk_TargetRate_table_MB[ TARGET_RATE_TAB_SZ ]; -extern const opus_int32 silk_TargetRate_table_WB[ TARGET_RATE_TAB_SZ ]; -extern const opus_int16 silk_SNR_table_Q1[ TARGET_RATE_TAB_SZ ]; +extern const opus_int32 silk_TargetRate_table_NB[ TARGET_RATE_TAB_SZ ]; /* 32 */ +extern const opus_int32 silk_TargetRate_table_MB[ TARGET_RATE_TAB_SZ ]; /* 32 */ +extern const opus_int32 silk_TargetRate_table_WB[ TARGET_RATE_TAB_SZ ]; /* 32 */ +extern const opus_int16 silk_SNR_table_Q1[ TARGET_RATE_TAB_SZ ]; /* 32 */ /* Quantization offsets */ -extern const opus_int16 silk_Quantization_Offsets_Q10[ 2 ][ 2 ]; +extern const opus_int16 silk_Quantization_Offsets_Q10[ 2 ][ 2 ]; /* 8 */ /* Interpolation points for filter coefficients used in the bandwidth transition smoother */ -extern const opus_int32 silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ]; -extern const opus_int32 silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ]; +extern const opus_int32 silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ]; /* 60 */ +extern const opus_int32 silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ]; /* 60 */ /* Rom table with cosine values */ -extern const opus_int16 silk_LSFCosTab_FIX_Q12[ LSF_COS_TAB_SZ_FIX + 1 ]; +extern const opus_int16 silk_LSFCosTab_FIX_Q12[ LSF_COS_TAB_SZ_FIX + 1 ]; /* 258 */ #ifdef __cplusplus } diff --git a/src/opus.vcxproj b/src/opus.vcxproj index 9183787e..4e1d4dd5 100644 --- a/src/opus.vcxproj +++ b/src/opus.vcxproj @@ -1,106 +1,106 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - Win32Proj - opus - {219EC965-228A-1824-174D-96449D05F88A} - - - - Application - true - - - Application - false - - - - - - - - - - - - - true - $(ProjectName)_debug - $(SolutionDir)\bin\ - - - false - $(SolutionDir)\bin\ - - - - HAVE_CONFIG_H;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - ../silk;../celt;../win32;%(AdditionalIncludeDirectories) - MultiThreadedDebugDLL - Level3 - ProgramDatabase - Disabled - - - MachineX86 - true - Console - $(SolutionDir)$(Configuration);%(AdditionalLibraryDirectories) - celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - HAVE_CONFIG_H;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - ../silk;../celt;../win32;%(AdditionalIncludeDirectories) - MultiThreadedDLL - Level3 - ProgramDatabase - - - MachineX86 - false - Console - true - true - celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)$(Configuration);%(AdditionalLibraryDirectories) - false - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + + Win32Proj + opus + {219EC965-228A-1824-174D-96449D05F88A} + + + + Application + true + + + Application + false + + + + + + + + + + + + + true + $(ProjectName)_debug + $(SolutionDir)\bin\ + + + false + $(SolutionDir)\bin\ + + + + HAVE_CONFIG_H;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../silk;../celt;../win32;../include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + + + MachineX86 + true + Console + $(SolutionDir)$(Configuration);%(AdditionalLibraryDirectories) + celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + HAVE_CONFIG_H;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../silk;../celt;../win32;../include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + Level3 + ProgramDatabase + + + MachineX86 + false + Console + true + true + celt.lib;silk_common.lib;silk_fixed.lib;silk_float.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration);%(AdditionalLibraryDirectories) + false + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/opus.vcxproj.filters b/src/opus.vcxproj.filters index 18b67f0c..11dac619 100644 --- a/src/opus.vcxproj.filters +++ b/src/opus.vcxproj.filters @@ -1,72 +1,72 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + \ No newline at end of file -- cgit v1.2.3