123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #ifndef SILK_MACROS_H
- #define SILK_MACROS_H
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #define silk_SMULWB(a32, b32) ((((a32) >> 16) * (opus_int32)((opus_int16)(b32))) + ((((a32) & 0x0000FFFF) * (opus_int32)((opus_int16)(b32))) >> 16))
- #define silk_SMLAWB(a32, b32, c32) ((a32) + ((((b32) >> 16) * (opus_int32)((opus_int16)(c32))) + ((((b32) & 0x0000FFFF) * (opus_int32)((opus_int16)(c32))) >> 16)))
- #define silk_SMULWT(a32, b32) (((a32) >> 16) * ((b32) >> 16) + ((((a32) & 0x0000FFFF) * ((b32) >> 16)) >> 16))
- #define silk_SMLAWT(a32, b32, c32) ((a32) + (((b32) >> 16) * ((c32) >> 16)) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16))
- #define silk_SMULBB(a32, b32) ((opus_int32)((opus_int16)(a32)) * (opus_int32)((opus_int16)(b32)))
- #define silk_SMLABB(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32)))
- #define silk_SMULBT(a32, b32) ((opus_int32)((opus_int16)(a32)) * ((b32) >> 16))
- #define silk_SMLABT(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32))) * ((c32) >> 16))
- #define silk_SMLAL(a64, b32, c32) (silk_ADD64((a64), ((opus_int64)(b32) * (opus_int64)(c32))))
- #define silk_SMULWW(a32, b32) silk_MLA(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16))
- #define silk_SMLAWW(a32, b32, c32) silk_MLA(silk_SMLAWB((a32), (b32), (c32)), (b32), silk_RSHIFT_ROUND((c32), 16))
- #define silk_ADD_SAT32(a, b) ((((opus_uint32)(a) + (opus_uint32)(b)) & 0x80000000) == 0 ? \
- ((((a) & (b)) & 0x80000000) != 0 ? silk_int32_MIN : (a)+(b)) : \
- ((((a) | (b)) & 0x80000000) == 0 ? silk_int32_MAX : (a)+(b)) )
- #define silk_SUB_SAT32(a, b) ((((opus_uint32)(a)-(opus_uint32)(b)) & 0x80000000) == 0 ? \
- (( (a) & ((b)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a)-(b)) : \
- ((((a)^0x80000000) & (b) & 0x80000000) ? silk_int32_MAX : (a)-(b)) )
- static inline opus_int32 silk_CLZ16(opus_int16 in16)
- {
- opus_int32 out32 = 0;
- if( in16 == 0 ) {
- return 16;
- }
-
- if( in16 & 0xFF00 ) {
- if( in16 & 0xF000 ) {
- in16 >>= 12;
- } else {
- out32 += 4;
- in16 >>= 8;
- }
- } else {
- if( in16 & 0xFFF0 ) {
- out32 += 8;
- in16 >>= 4;
- } else {
- out32 += 12;
- }
- }
-
- if( in16 & 0xC ) {
- if( in16 & 0x8 )
- return out32 + 0;
- else
- return out32 + 1;
- } else {
- if( in16 & 0xE )
- return out32 + 2;
- else
- return out32 + 3;
- }
- }
- static inline opus_int32 silk_CLZ32(opus_int32 in32)
- {
-
- if( in32 & 0xFFFF0000 ) {
- return silk_CLZ16((opus_int16)(in32 >> 16));
- } else {
- return silk_CLZ16((opus_int16)in32) + 16;
- }
- }
- #define matrix_ptr(Matrix_base_adr, row, column, N) *(Matrix_base_adr + ((row)*(N)+(column)))
- #define matrix_adr(Matrix_base_adr, row, column, N) (Matrix_base_adr + ((row)*(N)+(column)))
- #ifndef matrix_c_ptr
- # define matrix_c_ptr(Matrix_base_adr, row, column, M) *(Matrix_base_adr + ((row)+(M)*(column)))
- #endif
- #endif
|