123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #include "SigProc_FIX.h"
- #include "resampler_private.h"
- #include "stack_alloc.h"
- 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;
-
- 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;
- }
- void silk_resampler_private_IIR_FIR(
- void *SS,
- opus_int16 out[],
- const opus_int16 in[],
- opus_int32 inLen
- )
- {
- silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS;
- opus_int32 nSamplesIn;
- opus_int32 max_index_Q16, index_increment_Q16;
- VARDECL( opus_int16, buf );
- SAVE_STACK;
- ALLOC( buf, 2 * S->batchSize + RESAMPLER_ORDER_FIR_12, opus_int16 );
-
- silk_memcpy( buf, S->sFIR.i16, RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
-
- index_increment_Q16 = S->invRatio_Q16;
- while( 1 ) {
- nSamplesIn = silk_min( inLen, S->batchSize );
-
- silk_resampler_private_up2_HQ( S->sIIR, &buf[ RESAMPLER_ORDER_FIR_12 ], in, nSamplesIn );
- max_index_Q16 = silk_LSHIFT32( nSamplesIn, 16 + 1 );
- out = silk_resampler_private_IIR_FIR_INTERPOL( out, buf, max_index_Q16, index_increment_Q16 );
- in += nSamplesIn;
- inLen -= nSamplesIn;
- if( inLen > 0 ) {
-
- silk_memcpy( buf, &buf[ nSamplesIn << 1 ], RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
- } else {
- break;
- }
- }
-
- silk_memcpy( S->sFIR.i16, &buf[ nSamplesIn << 1 ], RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
- RESTORE_STACK;
- }
|