本文整理汇总了C++中silk_SMULWB函数的典型用法代码示例。如果您正苦于以下问题:C++ silk_SMULWB函数的具体用法?C++ silk_SMULWB怎么用?C++ silk_SMULWB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了silk_SMULWB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: silk_setup_LBRR
static OPUS_INLINE opus_int silk_setup_LBRR(
silk_encoder_state *psEncC, /* I/O */
const opus_int32 TargetRate_bps /* I */
)
{
opus_int LBRR_in_previous_packet, ret = SILK_NO_ERROR;
opus_int32 LBRR_rate_thres_bps;
LBRR_in_previous_packet = psEncC->LBRR_enabled;
psEncC->LBRR_enabled = 0;
if( psEncC->useInBandFEC && psEncC->PacketLoss_perc > 0 ) {
if( psEncC->fs_kHz == 8 ) {
LBRR_rate_thres_bps = LBRR_NB_MIN_RATE_BPS;
} else if( psEncC->fs_kHz == 12 ) {
LBRR_rate_thres_bps = LBRR_MB_MIN_RATE_BPS;
} else {
LBRR_rate_thres_bps = LBRR_WB_MIN_RATE_BPS;
}
LBRR_rate_thres_bps = silk_SMULWB( silk_MUL( LBRR_rate_thres_bps, 125 - silk_min( psEncC->PacketLoss_perc, 25 ) ), SILK_FIX_CONST( 0.01, 16 ) );
if( TargetRate_bps > LBRR_rate_thres_bps ) {
/* Set gain increase for coding LBRR excitation */
if( LBRR_in_previous_packet == 0 ) {
/* Previous packet did not have LBRR, and was therefore coded at a higher bitrate */
psEncC->LBRR_GainIncreases = 7;
} else {
psEncC->LBRR_GainIncreases = silk_max_int( 7 - silk_SMULWB( (opus_int32)psEncC->PacketLoss_perc, SILK_FIX_CONST( 0.4, 16 ) ), 2 );
}
psEncC->LBRR_enabled = 1;
}
}
return ret;
}
示例2: silk_stereo_find_predictor
/* Find least-squares prediction gain for one signal based on another and quantize it */
int32_t silk_stereo_find_predictor( /* O Returns predictor in Q13 */
int32_t * ratio_Q14, /* O Ratio of residual and mid energies */
const int16_t x[], /* I Basis signal */
const int16_t y[], /* I Target signal */
int32_t mid_res_amp_Q0[], /* I/O Smoothed mid, residual norms */
int length, /* I Number of samples */
int smooth_coef_Q16 /* I Smoothing coefficient */
)
{
int scale, scale1, scale2;
int32_t nrgx, nrgy, corr, pred_Q13, pred2_Q10;
/* Find predictor */
silk_sum_sqr_shift(&nrgx, &scale1, x, length);
silk_sum_sqr_shift(&nrgy, &scale2, y, length);
scale = silk_max_int(scale1, scale2);
scale = scale + (scale & 1); /* make even */
nrgy = silk_RSHIFT32(nrgy, scale - scale2);
nrgx = silk_RSHIFT32(nrgx, scale - scale1);
nrgx = silk_max_int(nrgx, 1);
corr = silk_inner_prod_aligned_scale(x, y, scale, length);
pred_Q13 = silk_DIV32_varQ(corr, nrgx, 13);
pred_Q13 = silk_LIMIT(pred_Q13, -(1 << 14), 1 << 14);
pred2_Q10 = silk_SMULWB(pred_Q13, pred_Q13);
/* Faster update for signals with large prediction parameters */
smooth_coef_Q16 =
(int) silk_max_int(smooth_coef_Q16, silk_abs(pred2_Q10));
/* Smoothed mid and residual norms */
assert(smooth_coef_Q16 < 32768);
scale = silk_RSHIFT(scale, 1);
mid_res_amp_Q0[0] =
silk_SMLAWB(mid_res_amp_Q0[0],
silk_LSHIFT(silk_SQRT_APPROX(nrgx),
scale) - mid_res_amp_Q0[0],
smooth_coef_Q16);
/* Residual energy = nrgy - 2 * pred * corr + pred^2 * nrgx */
nrgy = silk_SUB_LSHIFT32(nrgy, silk_SMULWB(corr, pred_Q13), 3 + 1);
nrgy = silk_ADD_LSHIFT32(nrgy, silk_SMULWB(nrgx, pred2_Q10), 6);
mid_res_amp_Q0[1] =
silk_SMLAWB(mid_res_amp_Q0[1],
silk_LSHIFT(silk_SQRT_APPROX(nrgy),
scale) - mid_res_amp_Q0[1],
smooth_coef_Q16);
/* Ratio of smoothed residual and mid norms */
*ratio_Q14 =
silk_DIV32_varQ(mid_res_amp_Q0[1], silk_max(mid_res_amp_Q0[0], 1),
14);
*ratio_Q14 = silk_LIMIT(*ratio_Q14, 0, 32767);
return pred_Q13;
}
示例3: silk_gains_quant
/* 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_int k, double_step_size_threshold;
for( k = 0; k < nb_subfr; k++ ) {
/* Convert to log scale, scale, floor() */
ind[ k ] = silk_SMULWB( SCALE_Q16, silk_lin2log( gain_Q16[ k ] ) - OFFSET );
/* Round towards previous quantized gain (hysteresis) */
if( ind[ k ] < *prev_ind ) {
ind[ k ]++;
}
ind[ k ] = silk_LIMIT_int( ind[ k ], 0, N_LEVELS_QGAIN - 1 );
/* Compute delta indices and limit */
if( k == 0 && conditional == 0 ) {
/* Full index */
ind[ k ] = silk_LIMIT_int( ind[ k ], *prev_ind + MIN_DELTA_GAIN_QUANT, N_LEVELS_QGAIN - 1 );
*prev_ind = ind[ k ];
} else {
/* Delta index */
ind[ k ] = ind[ k ] - *prev_ind;
/* Double the quantization step size for large gain increases, so that the max gain level can be reached */
double_step_size_threshold = 2 * MAX_DELTA_GAIN_QUANT - N_LEVELS_QGAIN + *prev_ind;
if( ind[ k ] > double_step_size_threshold ) {
ind[ k ] = double_step_size_threshold + silk_RSHIFT( ind[ k ] - double_step_size_threshold + 1, 1 );
}
ind[ k ] = silk_LIMIT_int( ind[ k ], MIN_DELTA_GAIN_QUANT, MAX_DELTA_GAIN_QUANT );
/* Accumulate deltas */
if( ind[ k ] > double_step_size_threshold ) {
*prev_ind += silk_LSHIFT( ind[ k ], 1 ) - double_step_size_threshold;
*prev_ind = silk_min_int( *prev_ind, N_LEVELS_QGAIN - 1 );
} else {
*prev_ind += ind[ k ];
}
/* Shift to make non-negative */
ind[ k ] -= MIN_DELTA_GAIN_QUANT;
}
/* Scale and convert to linear scale */
gain_Q16[ k ] = silk_log2lin( silk_min_32( silk_SMULWB( INV_SCALE_Q16, *prev_ind ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */
}
}
示例4: silk_gains_dequant
/* 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_int k, ind_tmp, double_step_size_threshold;
for( k = 0; k < nb_subfr; k++ ) {
if( k == 0 && conditional == 0 ) {
/* Gain index is not allowed to go down more than 16 steps (~21.8 dB) */
*prev_ind = silk_max_int( ind[ k ], *prev_ind - 16 );
} else {
/* Delta index */
ind_tmp = ind[ k ] + MIN_DELTA_GAIN_QUANT;
/* Accumulate deltas */
double_step_size_threshold = 2 * MAX_DELTA_GAIN_QUANT - N_LEVELS_QGAIN + *prev_ind;
if( ind_tmp > double_step_size_threshold ) {
*prev_ind += silk_LSHIFT( ind_tmp, 1 ) - double_step_size_threshold;
} else {
*prev_ind += ind_tmp;
}
}
*prev_ind = silk_LIMIT_int( *prev_ind, 0, N_LEVELS_QGAIN - 1 );
/* Scale and convert to linear scale */
gain_Q16[ k ] = silk_log2lin( silk_min_32( silk_SMULWB( INV_SCALE_Q16, *prev_ind ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */
}
}
示例5: silk_SMULWB
static OPUS_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_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, 12 );
buf_ptr = &buf[ index_Q16 >> 16 ];
res_Q15 = silk_SMULBB( buf_ptr[ 0 ], silk_resampler_frac_FIR_12[ table_index ][ 0 ] );
res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 1 ], silk_resampler_frac_FIR_12[ table_index ][ 1 ] );
res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 2 ], silk_resampler_frac_FIR_12[ table_index ][ 2 ] );
res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 3 ], silk_resampler_frac_FIR_12[ table_index ][ 3 ] );
res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 4 ], silk_resampler_frac_FIR_12[ 11 - table_index ][ 3 ] );
res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 5 ], silk_resampler_frac_FIR_12[ 11 - table_index ][ 2 ] );
res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 6 ], silk_resampler_frac_FIR_12[ 11 - table_index ][ 1 ] );
res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 7 ], silk_resampler_frac_FIR_12[ 11 - table_index ][ 0 ] );
*out++ = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( res_Q15, 15 ) );
}
return out;
}
示例6: silk_stereo_decode_pred
/* Decode mid/side predictors */
void silk_stereo_decode_pred(
ec_dec *psRangeDec, /* I/O Compressor data structure */
opus_int32 pred_Q13[] /* O Predictors */
)
{
opus_int n, ix[ 2 ][ 3 ];
opus_int32 low_Q13, step_Q13;
/* Entropy decoding */
n = ec_dec_icdf( psRangeDec, silk_stereo_pred_joint_iCDF, 8 );
ix[ 0 ][ 2 ] = silk_DIV32_16( n, 5 );
ix[ 1 ][ 2 ] = n - 5 * ix[ 0 ][ 2 ];
for( n = 0; n < 2; n++ ) {
ix[ n ][ 0 ] = ec_dec_icdf( psRangeDec, silk_uniform3_iCDF, 8 );
ix[ n ][ 1 ] = ec_dec_icdf( psRangeDec, silk_uniform5_iCDF, 8 );
}
/* Dequantize */
for( n = 0; n < 2; n++ ) {
ix[ n ][ 0 ] += 3 * ix[ n ][ 2 ];
low_Q13 = silk_stereo_pred_quant_Q13[ ix[ n ][ 0 ] ];
step_Q13 = silk_SMULWB( silk_stereo_pred_quant_Q13[ ix[ n ][ 0 ] + 1 ] - low_Q13,
SILK_FIX_CONST( 0.5 / STEREO_QUANT_SUB_STEPS, 16 ) );
pred_Q13[ n ] = silk_SMLABB( low_Q13, step_Q13, 2 * ix[ n ][ 1 ] + 1 );
}
/* Subtract second from first predictor (helps when actually applying these) */
pred_Q13[ 0 ] -= pred_Q13[ 1 ];
}
示例7: silk_HP_variable_cutoff
/* 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 */
)
{
int quality_Q15;
int32_t pitch_freq_Hz_Q16, pitch_freq_log_Q7, delta_freq_Q7;
silk_encoder_state *psEncC1 = &state_Fxx[0].sCmn;
/* Adaptive cutoff frequency: estimate low end of pitch frequency range */
if (psEncC1->prevSignalType == TYPE_VOICED) {
/* difference, in log domain */
pitch_freq_Hz_Q16 =
silk_DIV32_16(silk_LSHIFT
(silk_MUL(psEncC1->fs_kHz, 1000), 16),
psEncC1->prevLag);
pitch_freq_log_Q7 = silk_lin2log(pitch_freq_Hz_Q16) - (16 << 7);
/* adjustment based on quality */
quality_Q15 = psEncC1->input_quality_bands_Q15[0];
pitch_freq_log_Q7 =
silk_SMLAWB(pitch_freq_log_Q7,
silk_SMULWB(silk_LSHIFT(-quality_Q15, 2),
quality_Q15),
pitch_freq_log_Q7 -
(silk_lin2log
(SILK_FIX_CONST(VARIABLE_HP_MIN_CUTOFF_HZ, 16))
- (16 << 7)));
/* delta_freq = pitch_freq_log - psEnc->variable_HP_smth1; */
delta_freq_Q7 =
pitch_freq_log_Q7 -
silk_RSHIFT(psEncC1->variable_HP_smth1_Q15, 8);
if (delta_freq_Q7 < 0) {
/* less smoothing for decreasing pitch frequency, to track something close to the minimum */
delta_freq_Q7 = silk_MUL(delta_freq_Q7, 3);
}
/* limit delta, to reduce impact of outliers in pitch estimation */
delta_freq_Q7 =
silk_LIMIT_32(delta_freq_Q7,
-SILK_FIX_CONST(VARIABLE_HP_MAX_DELTA_FREQ,
7),
SILK_FIX_CONST(VARIABLE_HP_MAX_DELTA_FREQ,
7));
/* update smoother */
psEncC1->variable_HP_smth1_Q15 =
silk_SMLAWB(psEncC1->variable_HP_smth1_Q15,
silk_SMULBB(psEncC1->speech_activity_Q8,
delta_freq_Q7),
SILK_FIX_CONST(VARIABLE_HP_SMTH_COEF1, 16));
/* limit frequency range */
psEncC1->variable_HP_smth1_Q15 =
silk_LIMIT_32(psEncC1->variable_HP_smth1_Q15,
silk_LSHIFT(silk_lin2log
(VARIABLE_HP_MIN_CUTOFF_HZ), 8),
silk_LSHIFT(silk_lin2log
(VARIABLE_HP_MAX_CUTOFF_HZ), 8));
}
}
示例8: silk_PLC_glue_frames
/* Glues concealed frames with new good received 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 signal */
)
{
opus_int i, energy_shift;
opus_int32 energy;
silk_PLC_struct *psPLC;
psPLC = &psDec->sPLC;
if( psDec->lossCnt ) {
/* Calculate energy in concealed residual */
silk_sum_sqr_shift( &psPLC->conc_energy, &psPLC->conc_energy_shift, frame, length );
psPLC->last_frame_lost = 1;
} else {
if( psDec->sPLC.last_frame_lost ) {
/* Calculate residual in decoded signal if last frame was lost */
silk_sum_sqr_shift( &energy, &energy_shift, frame, length );
/* Normalize energies */
if( energy_shift > psPLC->conc_energy_shift ) {
psPLC->conc_energy = silk_RSHIFT( psPLC->conc_energy, energy_shift - psPLC->conc_energy_shift );
} else if( energy_shift < psPLC->conc_energy_shift ) {
energy = silk_RSHIFT( energy, psPLC->conc_energy_shift - energy_shift );
}
/* Fade in the energy difference */
if( energy > psPLC->conc_energy ) {
opus_int32 frac_Q24, LZ;
opus_int32 gain_Q16, slope_Q16;
LZ = silk_CLZ32( psPLC->conc_energy );
LZ = LZ - 1;
psPLC->conc_energy = silk_LSHIFT( psPLC->conc_energy, LZ );
energy = silk_RSHIFT( energy, silk_max_32( 24 - LZ, 0 ) );
frac_Q24 = silk_DIV32( psPLC->conc_energy, silk_max( energy, 1 ) );
gain_Q16 = silk_LSHIFT( silk_SQRT_APPROX( frac_Q24 ), 4 );
slope_Q16 = silk_DIV32_16( ( (opus_int32)1 << 16 ) - gain_Q16, length );
/* Make slope 4x steeper to avoid missing onsets after DTX */
slope_Q16 = silk_LSHIFT( slope_Q16, 2 );
for( i = 0; i < length; i++ ) {
frame[ i ] = silk_SMULWB( gain_Q16, frame[ i ] );
gain_Q16 += slope_Q16;
if( gain_Q16 > (opus_int32)1 << 16 ) {
break;
}
}
}
}
psPLC->last_frame_lost = 0;
}
}
示例9: silk_prefilt_FIX
/* Prefilter for finding Quantizer input signal */
static OPUS_INLINE void silk_prefilt_FIX(
silk_prefilter_state_FIX *P, /* I/O state */
opus_int32 st_res_Q12[], /* I short term residual signal */
opus_int32 xw_Q3[], /* 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;
opus_int32 n_LTP_Q12, n_Tilt_Q10, n_LF_Q10;
opus_int32 sLF_MA_shp_Q12, sLF_AR_shp_Q12;
opus_int16 *LTP_shp_buf;
/* To speed up use temp variables instead of using the struct */
LTP_shp_buf = P->sLTP_shp;
LTP_shp_buf_idx = P->sLTP_shp_buf_idx;
sLF_AR_shp_Q12 = P->sLF_AR_shp_Q12;
sLF_MA_shp_Q12 = P->sLF_MA_shp_Q12;
for (i = 0; i < length; i++) {
if (lag > 0) {
/* unrolled loop */
silk_assert(HARM_SHAPE_FIR_TAPS == 3);
idx = lag + LTP_shp_buf_idx;
n_LTP_Q12 = silk_SMULBB(LTP_shp_buf[(idx - HARM_SHAPE_FIR_TAPS / 2 - 1) & LTP_MASK],
HarmShapeFIRPacked_Q12);
n_LTP_Q12 = silk_SMLABT(n_LTP_Q12,
LTP_shp_buf[(idx - HARM_SHAPE_FIR_TAPS / 2) & LTP_MASK],
HarmShapeFIRPacked_Q12);
n_LTP_Q12 = silk_SMLABB(n_LTP_Q12,
LTP_shp_buf[(idx - HARM_SHAPE_FIR_TAPS / 2 + 1) & LTP_MASK],
HarmShapeFIRPacked_Q12);
} else {
n_LTP_Q12 = 0;
}
n_Tilt_Q10 = silk_SMULWB(sLF_AR_shp_Q12, Tilt_Q14);
n_LF_Q10 = silk_SMLAWB(silk_SMULWT(sLF_AR_shp_Q12, LF_shp_Q14), sLF_MA_shp_Q12, LF_shp_Q14);
sLF_AR_shp_Q12 = silk_SUB32(st_res_Q12[i], silk_LSHIFT(n_Tilt_Q10, 2));
sLF_MA_shp_Q12 = silk_SUB32(sLF_AR_shp_Q12, silk_LSHIFT(n_LF_Q10, 2));
LTP_shp_buf_idx = (LTP_shp_buf_idx - 1) & LTP_MASK;
LTP_shp_buf[LTP_shp_buf_idx] = (opus_int16) silk_SAT16(
silk_RSHIFT_ROUND(sLF_MA_shp_Q12, 12));
xw_Q3[i] = silk_RSHIFT_ROUND(silk_SUB32(sLF_MA_shp_Q12, n_LTP_Q12), 9);
}
/* Copy temp variable back to state */
P->sLF_AR_shp_Q12 = sLF_AR_shp_Q12;
P->sLF_MA_shp_Q12 = sLF_MA_shp_Q12;
P->sLTP_shp_buf_idx = LTP_shp_buf_idx;
}
示例10: silk_biquad_alt
/* Second order ARMA filter, alternative implementation */
void silk_biquad_alt(const int16_t * in, /* I input signal */
const int32_t * B_Q28, /* I MA coefficients [3] */
const int32_t * A_Q28, /* I AR coefficients [2] */
int32_t * S, /* I/O State vector [2] */
int16_t * out, /* O output signal */
const int32_t len, /* I signal length (must be even) */
int stride /* I Operate on interleaved signal if > 1 */
)
{
/* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */
int k;
int32_t inval, A0_U_Q28, A0_L_Q28, A1_U_Q28, A1_L_Q28, out32_Q14;
/* Negate A_Q28 values and split in two parts */
A0_L_Q28 = (-A_Q28[0]) & 0x00003FFF; /* lower part */
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 */
for (k = 0; k < len; k++) {
/* S[ 0 ], S[ 1 ]: Q12 */
inval = in[k * stride];
out32_Q14 = silk_LSHIFT(silk_SMLAWB(S[0], B_Q28[0], inval), 2);
S[0] =
S[1] + silk_RSHIFT_ROUND(silk_SMULWB(out32_Q14, A0_L_Q28),
14);
S[0] = silk_SMLAWB(S[0], out32_Q14, A0_U_Q28);
S[0] = silk_SMLAWB(S[0], B_Q28[1], inval);
S[1] = silk_RSHIFT_ROUND(silk_SMULWB(out32_Q14, A1_L_Q28), 14);
S[1] = silk_SMLAWB(S[1], out32_Q14, A1_U_Q28);
S[1] = silk_SMLAWB(S[1], B_Q28[2], inval);
/* Scale back to Q0 and saturate */
out[k * stride] =
(int16_t)
silk_SAT16(silk_RSHIFT(out32_Q14 + (1 << 14) - 1, 14));
}
}
示例11: silk_scale_copy_vector16
/* 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_int i;
opus_int32 tmp32;
for(i = 0; i < dataSize; i++) {
tmp32 = silk_SMULWB(gain_Q16, data_in[ i ]);
data_out[ i ] = (opus_int16)silk_CHECK_FIT16(tmp32);
}
}
示例12: silk_process_gains_FIX
/* 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_shape_state_FIX *psShapeSt = &psEnc->sShape;
opus_int k;
opus_int32 s_Q16, InvMaxSqrVal_Q16, gain, gain_squared, ResNrg, ResNrgPart, quant_offset_Q10;
/* Gain reduction when LTP coding gain is high */
if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {
/*s = -0.5f * silk_sigmoid( 0.25f * ( psEncCtrl->LTPredCodGain - 12.0f ) ); */
s_Q16 = -silk_sigm_Q15( silk_RSHIFT_ROUND( psEncCtrl->LTPredCodGain_Q7 - SILK_FIX_CONST( 12.0, 7 ), 4 ) );
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
psEncCtrl->Gains_Q16[ k ] = silk_SMLAWB( psEncCtrl->Gains_Q16[ k ], psEncCtrl->Gains_Q16[ k ], s_Q16 );
}
}
/* Limit the quantized signal */
/* InvMaxSqrVal = pow( 2.0f, 0.33f * ( 21.0f - SNR_dB ) ) / subfr_length; */
InvMaxSqrVal_Q16 = silk_DIV32_16( silk_log2lin(
silk_SMULWB( SILK_FIX_CONST( 21 + 16 / 0.33, 7 ) - psEnc->sCmn.SNR_dB_Q7, SILK_FIX_CONST( 0.33, 16 ) ) ), psEnc->sCmn.subfr_length );
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
/* Soft limit on ratio residual energy and squared gains */
ResNrg = psEncCtrl->ResNrg[ k ];
ResNrgPart = silk_SMULWW( ResNrg, InvMaxSqrVal_Q16 );
if( psEncCtrl->ResNrgQ[ k ] > 0 ) {
ResNrgPart = silk_RSHIFT_ROUND( ResNrgPart, psEncCtrl->ResNrgQ[ k ] );
} else {
if( ResNrgPart >= silk_RSHIFT( silk_int32_MAX, -psEncCtrl->ResNrgQ[ k ] ) ) {
ResNrgPart = silk_int32_MAX;
} else {
ResNrgPart = silk_LSHIFT( ResNrgPart, -psEncCtrl->ResNrgQ[ k ] );
}
}
gain = psEncCtrl->Gains_Q16[ k ];
gain_squared = silk_ADD_SAT32( ResNrgPart, silk_SMMUL( gain, gain ) );
if( gain_squared < silk_int16_MAX ) {
/* recalculate with higher precision */
gain_squared = silk_SMLAWW( silk_LSHIFT( ResNrgPart, 16 ), gain, gain );
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 */
} else {
示例13: silk_noise_shape_analysis_FIX
void silk_noise_shape_analysis_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */
const opus_int16 *x, /* I Input signal [ frame_length + la_shape ] */
int arch /* I Run-time architecture */
)
{
silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
opus_int k, i, nSamples, Qnrg, b_Q14, warping_Q16, scale = 0;
opus_int32 SNR_adj_dB_Q7, HarmBoost_Q16, HarmShapeGain_Q16, Tilt_Q16, tmp32;
opus_int32 nrg, pre_nrg_Q30, log_energy_Q7, log_energy_prev_Q7, energy_variation_Q7;
opus_int32 delta_Q16, BWExp1_Q16, BWExp2_Q16, gain_mult_Q16, gain_add_Q16, strength_Q16, b_Q8;
opus_int32 auto_corr[ MAX_SHAPE_LPC_ORDER + 1 ];
opus_int32 refl_coef_Q16[ MAX_SHAPE_LPC_ORDER ];
opus_int32 AR1_Q24[ MAX_SHAPE_LPC_ORDER ];
opus_int32 AR2_Q24[ MAX_SHAPE_LPC_ORDER ];
VARDECL( opus_int16, x_windowed );
const opus_int16 *x_ptr, *pitch_res_ptr;
SAVE_STACK;
/* Point to start of first LPC analysis block */
x_ptr = x - psEnc->sCmn.la_shape;
/****************/
/* GAIN CONTROL */
/****************/
SNR_adj_dB_Q7 = psEnc->sCmn.SNR_dB_Q7;
/* Input quality is the average of the quality in the lowest two VAD bands */
psEncCtrl->input_quality_Q14 = ( opus_int )silk_RSHIFT( (opus_int32)psEnc->sCmn.input_quality_bands_Q15[ 0 ]
+ psEnc->sCmn.input_quality_bands_Q15[ 1 ], 2 );
/* Coding quality level, between 0.0_Q0 and 1.0_Q0, but in Q14 */
psEncCtrl->coding_quality_Q14 = silk_RSHIFT( silk_sigm_Q15( silk_RSHIFT_ROUND( SNR_adj_dB_Q7 -
SILK_FIX_CONST( 20.0, 7 ), 4 ) ), 1 );
/* Reduce coding SNR during low speech activity */
if( psEnc->sCmn.useCBR == 0 ) {
b_Q8 = SILK_FIX_CONST( 1.0, 8 ) - psEnc->sCmn.speech_activity_Q8;
b_Q8 = silk_SMULWB( silk_LSHIFT( b_Q8, 8 ), b_Q8 );
SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7,
silk_SMULBB( SILK_FIX_CONST( -BG_SNR_DECR_dB, 7 ) >> ( 4 + 1 ), b_Q8 ), /* Q11*/
silk_SMULWB( SILK_FIX_CONST( 1.0, 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) ); /* Q12*/
}
示例14: silk_resampler_private_AR2
/* Second order AR filter with single delay elements */
void silk_resampler_private_AR2(int32_t S[], /* I/O State vector [ 2 ] */
int32_t out_Q8[], /* O Output signal */
const int16_t in[], /* I Input signal */
const int16_t A_Q14[], /* I AR coefficients, Q14 */
int32_t len /* I Signal length */
)
{
int32_t k;
int32_t out32;
for (k = 0; k < len; k++) {
out32 = silk_ADD_LSHIFT32(S[0], (int32_t) in[k], 8);
out_Q8[k] = out32;
out32 = silk_LSHIFT(out32, 2);
S[0] = silk_SMLAWB(S[1], out32, A_Q14[0]);
S[1] = silk_SMULWB(out32, A_Q14[1]);
}
}
示例15: silk_resampler_private_AR2
/* 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 k;
opus_int32 out32;
for(k = 0; k < len; k++) {
out32 = silk_ADD_LSHIFT32(S[ 0 ], (opus_int32)in[ k ], 8);
out_Q8[ k ] = out32;
out32 = silk_LSHIFT(out32, 2);
S[ 0 ] = silk_SMLAWB(S[ 1 ], out32, A_Q14[ 0 ]);
S[ 1 ] = silk_SMULWB(out32, A_Q14[ 1 ]);
}
}