123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595 |
- #ifndef SILK_SIGPROC_FIX_H
- #define SILK_SIGPROC_FIX_H
- #ifdef __cplusplus
- extern "C"
- {
- #endif
-
- #define SILK_MAX_ORDER_LPC 16 /* max order of the LPC analysis in schur() and k2a() */
- #include <string.h> /* for memset(), memcpy(), memmove() */
- #include "typedef.h"
- #include "resampler_structs.h"
- #include "macros.h"
- opus_int silk_resampler_init(
- silk_resampler_state_struct *S,
- opus_int32 Fs_Hz_in,
- opus_int32 Fs_Hz_out,
- opus_int forEnc
- );
- opus_int silk_resampler(
- silk_resampler_state_struct *S,
- opus_int16 out[],
- const opus_int16 in[],
- opus_int32 inLen
- );
- void silk_resampler_down2(
- opus_int32 *S,
- opus_int16 *out,
- const opus_int16 *in,
- opus_int32 inLen
- );
- void silk_resampler_down2_3(
- opus_int32 *S,
- opus_int16 *out,
- const opus_int16 *in,
- opus_int32 inLen
- );
- void silk_biquad_alt(
- const opus_int16 *in,
- const opus_int32 *B_Q28,
- const opus_int32 *A_Q28,
- opus_int32 *S,
- opus_int16 *out,
- const opus_int32 len,
- opus_int stride
- );
- void silk_LPC_analysis_filter(
- opus_int16 *out,
- const opus_int16 *in,
- const opus_int16 *B,
- const opus_int32 len,
- const opus_int32 d
- );
- void silk_bwexpander(
- opus_int16 *ar,
- const opus_int d,
- opus_int32 chirp_Q16
- );
- void silk_bwexpander_32(
- opus_int32 *ar,
- const opus_int d,
- opus_int32 chirp_Q16
- );
- opus_int32 silk_LPC_inverse_pred_gain(
- const opus_int16 *A_Q12,
- const opus_int order
- );
- opus_int32 silk_LPC_inverse_pred_gain_Q24(
- const opus_int32 *A_Q24,
- const opus_int order
- );
- void silk_ana_filt_bank_1(
- const opus_int16 *in,
- opus_int32 *S,
- opus_int16 *outL,
- opus_int16 *outH,
- const opus_int32 N
- );
- opus_int32 silk_lin2log(
- const opus_int32 inLin
- );
- opus_int silk_sigm_Q15(
- opus_int in_Q5
- );
- opus_int32 silk_log2lin(
- const opus_int32 inLog_Q7
- );
- void silk_sum_sqr_shift(
- opus_int32 *energy,
- opus_int *shift,
- const opus_int16 *x,
- opus_int len
- );
- opus_int32 silk_schur(
- opus_int16 *rc_Q15,
- const opus_int32 *c,
- const opus_int32 order
- );
- opus_int32 silk_schur64(
- opus_int32 rc_Q16[],
- const opus_int32 c[],
- opus_int32 order
- );
- void silk_k2a(
- opus_int32 *A_Q24,
- const opus_int16 *rc_Q15,
- const opus_int32 order
- );
- void silk_k2a_Q16(
- opus_int32 *A_Q24,
- const opus_int32 *rc_Q16,
- const opus_int32 order
- );
- void silk_apply_sine_window(
- opus_int16 px_win[],
- const opus_int16 px[],
- const opus_int win_type,
- const opus_int length
- );
- void silk_autocorr(
- opus_int32 *results,
- opus_int *scale,
- const opus_int16 *inputData,
- const opus_int inputDataSize,
- const opus_int correlationCount,
- int arch
- );
- void silk_decode_pitch(
- opus_int16 lagIndex,
- opus_int8 contourIndex,
- opus_int pitch_lags[],
- const opus_int Fs_kHz,
- const opus_int nb_subfr
- );
- opus_int silk_pitch_analysis_core(
- const opus_int16 *frame,
- opus_int *pitch_out,
- opus_int16 *lagIndex,
- opus_int8 *contourIndex,
- opus_int *LTPCorr_Q15,
- opus_int prevLag,
- const opus_int32 search_thres1_Q16,
- const opus_int search_thres2_Q13,
- const opus_int Fs_kHz,
- const opus_int complexity,
- const opus_int nb_subfr,
- int arch
- );
- void silk_A2NLSF(
- opus_int16 *NLSF,
- opus_int32 *a_Q16,
- const opus_int d
- );
- void silk_NLSF2A(
- opus_int16 *a_Q12,
- const opus_int16 *NLSF,
- const opus_int d
- );
- void silk_insertion_sort_increasing(
- opus_int32 *a,
- opus_int *idx,
- const opus_int L,
- const opus_int K
- );
- void silk_insertion_sort_decreasing_int16(
- opus_int16 *a,
- opus_int *idx,
- const opus_int L,
- const opus_int K
- );
- void silk_insertion_sort_increasing_all_values_int16(
- opus_int16 *a,
- const opus_int L
- );
- void silk_NLSF_stabilize(
- opus_int16 *NLSF_Q15,
- const opus_int16 *NDeltaMin_Q15,
- const opus_int L
- );
- void silk_NLSF_VQ_weights_laroia(
- opus_int16 *pNLSFW_Q_OUT,
- const opus_int16 *pNLSF_Q15,
- const opus_int D
- );
- void silk_burg_modified(
- opus_int32 *res_nrg,
- opus_int *res_nrg_Q,
- opus_int32 A_Q16[],
- const opus_int16 x[],
- const opus_int32 minInvGain_Q30,
- const opus_int subfr_length,
- const opus_int nb_subfr,
- const opus_int D,
- int arch
- );
- void silk_scale_copy_vector16(
- opus_int16 *data_out,
- const opus_int16 *data_in,
- opus_int32 gain_Q16,
- const opus_int dataSize
- );
- void silk_scale_vector32_Q26_lshift_18(
- opus_int32 *data1,
- opus_int32 gain_Q26,
- opus_int dataSize
- );
- opus_int32 silk_inner_prod_aligned(
- const opus_int16 *const inVec1,
- const opus_int16 *const inVec2,
- const opus_int len
- );
- opus_int32 silk_inner_prod_aligned_scale(
- const opus_int16 *const inVec1,
- const opus_int16 *const inVec2,
- const opus_int scale,
- const opus_int len
- );
- opus_int64 silk_inner_prod16_aligned_64(
- const opus_int16 *inVec1,
- const opus_int16 *inVec2,
- const opus_int len
- );
- static OPUS_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 ) {
- return (opus_int32) ((x << m) | (x >> (32 - m)));
- } else {
- return (opus_int32) ((x << (32 - r)) | (x >> r));
- }
- }
- #if EMBEDDED_ARM
- #define silk_DWORD_ALIGN __attribute__((aligned(4)))
- #else
- #define silk_DWORD_ALIGN
- #endif
- #define silk_memcpy(dest, src, size) memcpy((dest), (src), (size))
- #define silk_memset(dest, src, size) memset((dest), (src), (size))
- #define silk_memmove(dest, src, size) memmove((dest), (src), (size))
- #define silk_MUL(a32, b32) ((a32) * (b32))
- #define silk_MUL_uint(a32, b32) silk_MUL(a32, b32)
- #define silk_MLA(a32, b32, c32) silk_ADD32((a32),((b32) * (c32)))
- #define silk_MLA_uint(a32, b32, c32) silk_MLA(a32, b32, c32)
- #define silk_SMULTT(a32, b32) (((a32) >> 16) * ((b32) >> 16))
- #define silk_SMLATT(a32, b32, c32) silk_ADD32((a32),((b32) >> 16) * ((c32) >> 16))
- #define silk_SMLALBB(a64, b16, c16) silk_ADD64((a64),(opus_int64)((opus_int32)(b16) * (opus_int32)(c16)))
- #define silk_SMULL(a32, b32) ((opus_int64)(a32) * /*(opus_int64)*/(b32))
- #define silk_ADD32_ovflw(a, b) ((opus_int32)((opus_uint32)(a) + (opus_uint32)(b)))
- #define silk_SUB32_ovflw(a, b) ((opus_int32)((opus_uint32)(a) - (opus_uint32)(b)))
- #define silk_MLA_ovflw(a32, b32, c32) silk_ADD32_ovflw((a32), (opus_uint32)(b32) * (opus_uint32)(c32))
- #define silk_SMLABB_ovflw(a32, b32, c32) (silk_ADD32_ovflw((a32) , ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32))))
- #define silk_DIV32_16(a32, b16) ((opus_int32)((a32) / (b16)))
- #define silk_DIV32(a32, b32) ((opus_int32)((a32) / (b32)))
- #define silk_ADD16(a, b) ((a) + (b))
- #define silk_ADD32(a, b) ((a) + (b))
- #define silk_ADD64(a, b) ((a) + (b))
- #define silk_SUB16(a, b) ((a) - (b))
- #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_CHECK_FIT8(a) (a)
- #define silk_CHECK_FIT16(a) (a)
- #define silk_CHECK_FIT32(a) (a)
- #define silk_ADD_SAT16(a, b) (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a), (b) ) )
- #define silk_ADD_SAT64(a, b) ((((a) + (b)) & 0x8000000000000000LL) == 0 ? \
- ((((a) & (b)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a)+(b)) : \
- ((((a) | (b)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a)+(b)) )
- #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_POS_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : (a))
- #define silk_ADD_POS_SAT8(a, b) ((((a)+(b)) & 0x80) ? silk_int8_MAX : ((a)+(b)))
- #define silk_ADD_POS_SAT16(a, b) ((((a)+(b)) & 0x8000) ? silk_int16_MAX : ((a)+(b)))
- #define silk_ADD_POS_SAT32(a, b) ((((a)+(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b)))
- #define silk_ADD_POS_SAT64(a, b) ((((a)+(b)) & 0x8000000000000000LL) ? silk_int64_MAX : ((a)+(b)))
- #define silk_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_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_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_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_FIX_CONST( C, Q ) ((opus_int32)((C) * ((opus_int64)1 << (Q)) + 0.5))
- static OPUS_INLINE opus_int silk_min_int(opus_int a, opus_int b)
- {
- return (((a) < (b)) ? (a) : (b));
- }
- static OPUS_INLINE opus_int16 silk_min_16(opus_int16 a, opus_int16 b)
- {
- return (((a) < (b)) ? (a) : (b));
- }
- static OPUS_INLINE opus_int32 silk_min_32(opus_int32 a, opus_int32 b)
- {
- return (((a) < (b)) ? (a) : (b));
- }
- static OPUS_INLINE opus_int64 silk_min_64(opus_int64 a, opus_int64 b)
- {
- return (((a) < (b)) ? (a) : (b));
- }
- static OPUS_INLINE opus_int silk_max_int(opus_int a, opus_int b)
- {
- return (((a) > (b)) ? (a) : (b));
- }
- static OPUS_INLINE opus_int16 silk_max_16(opus_int16 a, opus_int16 b)
- {
- return (((a) > (b)) ? (a) : (b));
- }
- static OPUS_INLINE opus_int32 silk_max_32(opus_int32 a, opus_int32 b)
- {
- return (((a) > (b)) ? (a) : (b));
- }
- static OPUS_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_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_RAND(seed) (silk_MLA_ovflw(907633515, (seed), 196314165))
- #define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT64(silk_SMULL((a32), (b32)), 32)
- #include "Inlines.h"
- #include "MacroCount.h"
- #include "MacroDebug.h"
- #ifdef OPUS_ARM_INLINE_ASM
- #include "arm/SigProc_FIX_armv4.h"
- #endif
- #ifdef OPUS_ARM_INLINE_EDSP
- #include "arm/SigProc_FIX_armv5e.h"
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif /* SILK_SIGPROC_FIX_H */
|