diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-11-18 09:56:18 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2019-11-18 09:56:48 +0100 |
commit | 46ae64cd60166ead412bacc1bf03e9c8f8965e2c (patch) | |
tree | 9e592667ffa91e55491a66733e5e3d7de0b666c9 /thirdparty/opus/silk/sum_sqr_shift.c | |
parent | 974646309bfe09c48c8a72bf751b0ea6ad8b5bc5 (diff) | |
download | redot-engine-46ae64cd60166ead412bacc1bf03e9c8f8965e2c.tar.gz |
Revert "Update opus to 1.3.1 and opusfile to 0.11"
This reverts commit e00426c512a7905f5f925d382c443bab7a0ca693.
The way we handle platform-specific intrinsics is not good, so the
current state will not compile on armv8. This commit also requires
SSE4.1 support, which is likely not a good idea for portable binaries.
We'll have to redo this with more caution after 3.2 is released, or
we might simply drop opus as we're only using it as dependency for
theora right now.
Fixes #33606.
Diffstat (limited to 'thirdparty/opus/silk/sum_sqr_shift.c')
-rw-r--r-- | thirdparty/opus/silk/sum_sqr_shift.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/thirdparty/opus/silk/sum_sqr_shift.c b/thirdparty/opus/silk/sum_sqr_shift.c index 4fd0c3d7d5..129df191d8 100644 --- a/thirdparty/opus/silk/sum_sqr_shift.c +++ b/thirdparty/opus/silk/sum_sqr_shift.c @@ -41,40 +41,43 @@ void silk_sum_sqr_shift( ) { opus_int i, shft; - opus_uint32 nrg_tmp; - opus_int32 nrg; + opus_int32 nrg_tmp, nrg; - /* Do a first run with the maximum shift we could have. */ - shft = 31-silk_CLZ32(len); - /* Let's be conservative with rounding and start with nrg=len. */ - nrg = len; - for( i = 0; i < len - 1; i += 2 ) { - nrg_tmp = silk_SMULBB( x[ i ], x[ i ] ); - nrg_tmp = silk_SMLABB_ovflw( nrg_tmp, x[ i + 1 ], x[ i + 1 ] ); - nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, nrg_tmp, shft ); + nrg = 0; + shft = 0; + len--; + for( i = 0; i < len; i += 2 ) { + nrg = silk_SMLABB_ovflw( nrg, x[ i ], x[ i ] ); + nrg = silk_SMLABB_ovflw( nrg, x[ i + 1 ], x[ i + 1 ] ); + if( nrg < 0 ) { + /* Scale down */ + nrg = (opus_int32)silk_RSHIFT_uint( (opus_uint32)nrg, 2 ); + shft = 2; + i+=2; + break; + } } - if( i < len ) { - /* One sample left to process */ - nrg_tmp = silk_SMULBB( x[ i ], x[ i ] ); - nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, nrg_tmp, shft ); - } - silk_assert( nrg >= 0 ); - /* Make sure the result will fit in a 32-bit signed integer with two bits - of headroom. */ - shft = silk_max_32(0, shft+3 - silk_CLZ32(nrg)); - nrg = 0; - for( i = 0 ; i < len - 1; i += 2 ) { + for( ; i < len; i += 2 ) { nrg_tmp = silk_SMULBB( x[ i ], x[ i ] ); nrg_tmp = silk_SMLABB_ovflw( nrg_tmp, x[ i + 1 ], x[ i + 1 ] ); - nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, nrg_tmp, shft ); + nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, (opus_uint32)nrg_tmp, shft ); + if( nrg < 0 ) { + /* Scale down */ + nrg = (opus_int32)silk_RSHIFT_uint( (opus_uint32)nrg, 2 ); + shft += 2; + } } - if( i < len ) { + if( i == len ) { /* One sample left to process */ nrg_tmp = silk_SMULBB( x[ i ], x[ i ] ); nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, nrg_tmp, shft ); } - silk_assert( nrg >= 0 ); + /* Make sure to have at least one extra leading zero (two leading zeros in total) */ + if( nrg & 0xC0000000 ) { + nrg = silk_RSHIFT_uint( (opus_uint32)nrg, 2 ); + shft += 2; + } /* Output arguments */ *shift = shft; |