Revert "Update opus to 1.3.1 and opusfile to 0.11"
This reverts commit e00426c512.
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.
This commit is contained in:
parent
974646309b
commit
46ae64cd60
225 changed files with 6909 additions and 10450 deletions
105
thirdparty/opus/silk/float/encode_frame_FLP.c
vendored
105
thirdparty/opus/silk/float/encode_frame_FLP.c
vendored
|
|
@ -29,7 +29,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "main_FLP.h"
|
||||
#include "tuning_parameters.h"
|
||||
|
||||
|
|
@ -42,28 +41,21 @@ static OPUS_INLINE void silk_LBRR_encode_FLP(
|
|||
);
|
||||
|
||||
void silk_encode_do_VAD_FLP(
|
||||
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
|
||||
opus_int activity /* I Decision of Opus voice activity detector */
|
||||
silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
|
||||
)
|
||||
{
|
||||
const opus_int activity_threshold = SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 );
|
||||
|
||||
/****************************/
|
||||
/* Voice Activity Detection */
|
||||
/****************************/
|
||||
silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.arch );
|
||||
/* If Opus VAD is inactive and Silk VAD is active: lower Silk VAD to just under the threshold */
|
||||
if( activity == VAD_NO_ACTIVITY && psEnc->sCmn.speech_activity_Q8 >= activity_threshold ) {
|
||||
psEnc->sCmn.speech_activity_Q8 = activity_threshold - 1;
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/* Convert speech activity into VAD and DTX flags */
|
||||
/**************************************************/
|
||||
if( psEnc->sCmn.speech_activity_Q8 < activity_threshold ) {
|
||||
if( psEnc->sCmn.speech_activity_Q8 < SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) {
|
||||
psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY;
|
||||
psEnc->sCmn.noSpeechCounter++;
|
||||
if( psEnc->sCmn.noSpeechCounter <= NB_SPEECH_FRAMES_BEFORE_DTX ) {
|
||||
if( psEnc->sCmn.noSpeechCounter < NB_SPEECH_FRAMES_BEFORE_DTX ) {
|
||||
psEnc->sCmn.inDTX = 0;
|
||||
} else if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX + NB_SPEECH_FRAMES_BEFORE_DTX ) {
|
||||
psEnc->sCmn.noSpeechCounter = NB_SPEECH_FRAMES_BEFORE_DTX;
|
||||
|
|
@ -93,6 +85,7 @@ opus_int silk_encode_frame_FLP(
|
|||
silk_encoder_control_FLP sEncCtrl;
|
||||
opus_int i, iter, maxIter, found_upper, found_lower, ret = 0;
|
||||
silk_float *x_frame, *res_pitch_frame;
|
||||
silk_float xfw[ MAX_FRAME_LENGTH ];
|
||||
silk_float res_pitch[ 2 * MAX_FRAME_LENGTH + LA_PITCH_MAX ];
|
||||
ec_enc sRangeEnc_copy, sRangeEnc_copy2;
|
||||
silk_nsq_state sNSQ_copy, sNSQ_copy2;
|
||||
|
|
@ -104,9 +97,6 @@ opus_int silk_encode_frame_FLP(
|
|||
opus_int8 LastGainIndex_copy2;
|
||||
opus_int32 pGains_Q16[ MAX_NB_SUBFR ];
|
||||
opus_uint8 ec_buf_copy[ 1275 ];
|
||||
opus_int gain_lock[ MAX_NB_SUBFR ] = {0};
|
||||
opus_int16 best_gain_mult[ MAX_NB_SUBFR ];
|
||||
opus_int best_sum[ MAX_NB_SUBFR ];
|
||||
|
||||
/* This is totally unnecessary but many compilers (including gcc) are too dumb to realise it */
|
||||
LastGainIndex_copy2 = nBits_lower = nBits_upper = gainMult_lower = gainMult_upper = 0;
|
||||
|
|
@ -149,17 +139,22 @@ opus_int silk_encode_frame_FLP(
|
|||
/***************************************************/
|
||||
/* Find linear prediction coefficients (LPC + LTP) */
|
||||
/***************************************************/
|
||||
silk_find_pred_coefs_FLP( psEnc, &sEncCtrl, res_pitch_frame, x_frame, condCoding );
|
||||
silk_find_pred_coefs_FLP( psEnc, &sEncCtrl, res_pitch, x_frame, condCoding );
|
||||
|
||||
/****************************************/
|
||||
/* Process gains */
|
||||
/****************************************/
|
||||
silk_process_gains_FLP( psEnc, &sEncCtrl, condCoding );
|
||||
|
||||
/*****************************************/
|
||||
/* Prefiltering for noise shaper */
|
||||
/*****************************************/
|
||||
silk_prefilter_FLP( psEnc, &sEncCtrl, xfw, x_frame );
|
||||
|
||||
/****************************************/
|
||||
/* Low Bitrate Redundant Encoding */
|
||||
/****************************************/
|
||||
silk_LBRR_encode_FLP( psEnc, &sEncCtrl, x_frame, condCoding );
|
||||
silk_LBRR_encode_FLP( psEnc, &sEncCtrl, xfw, condCoding );
|
||||
|
||||
/* Loop over quantizer and entroy coding to control bitrate */
|
||||
maxIter = 6;
|
||||
|
|
@ -193,11 +188,7 @@ opus_int silk_encode_frame_FLP(
|
|||
/*****************************************/
|
||||
/* Noise shaping quantization */
|
||||
/*****************************************/
|
||||
silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, x_frame );
|
||||
|
||||
if ( iter == maxIter && !found_lower ) {
|
||||
silk_memcpy( &sRangeEnc_copy2, psRangeEnc, sizeof( ec_enc ) );
|
||||
}
|
||||
silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw );
|
||||
|
||||
/****************************************/
|
||||
/* Encode Parameters */
|
||||
|
|
@ -212,33 +203,6 @@ opus_int silk_encode_frame_FLP(
|
|||
|
||||
nBits = ec_tell( psRangeEnc );
|
||||
|
||||
/* If we still bust after the last iteration, do some damage control. */
|
||||
if ( iter == maxIter && !found_lower && nBits > maxBits ) {
|
||||
silk_memcpy( psRangeEnc, &sRangeEnc_copy2, sizeof( ec_enc ) );
|
||||
|
||||
/* Keep gains the same as the last frame. */
|
||||
psEnc->sShape.LastGainIndex = sEncCtrl.lastGainIndexPrev;
|
||||
for ( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
|
||||
psEnc->sCmn.indices.GainsIndices[ i ] = 4;
|
||||
}
|
||||
if (condCoding != CODE_CONDITIONALLY) {
|
||||
psEnc->sCmn.indices.GainsIndices[ 0 ] = sEncCtrl.lastGainIndexPrev;
|
||||
}
|
||||
psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy;
|
||||
psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy;
|
||||
/* Clear all pulses. */
|
||||
for ( i = 0; i < psEnc->sCmn.frame_length; i++ ) {
|
||||
psEnc->sCmn.pulses[ i ] = 0;
|
||||
}
|
||||
|
||||
silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding );
|
||||
|
||||
silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
|
||||
psEnc->sCmn.pulses, psEnc->sCmn.frame_length );
|
||||
|
||||
nBits = ec_tell( psRangeEnc );
|
||||
}
|
||||
|
||||
if( useCBR == 0 && iter == 0 && nBits <= maxBits ) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -248,7 +212,7 @@ opus_int silk_encode_frame_FLP(
|
|||
if( found_lower && ( gainsID == gainsID_lower || nBits > maxBits ) ) {
|
||||
/* Restore output state from earlier iteration that did meet the bitrate budget */
|
||||
silk_memcpy( psRangeEnc, &sRangeEnc_copy2, sizeof( ec_enc ) );
|
||||
celt_assert( sRangeEnc_copy2.offs <= 1275 );
|
||||
silk_assert( sRangeEnc_copy2.offs <= 1275 );
|
||||
silk_memcpy( psRangeEnc->buf, ec_buf_copy, sRangeEnc_copy2.offs );
|
||||
silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy2, sizeof( silk_nsq_state ) );
|
||||
psEnc->sShape.LastGainIndex = LastGainIndex_copy2;
|
||||
|
|
@ -259,9 +223,7 @@ opus_int silk_encode_frame_FLP(
|
|||
if( nBits > maxBits ) {
|
||||
if( found_lower == 0 && iter >= 2 ) {
|
||||
/* Adjust the quantizer's rate/distortion tradeoff and discard previous "upper" results */
|
||||
sEncCtrl.Lambda = silk_max_float(sEncCtrl.Lambda*1.5f, 1.5f);
|
||||
/* Reducing dithering can help us hit the target. */
|
||||
psEnc->sCmn.indices.quantOffsetType = 0;
|
||||
sEncCtrl.Lambda *= 1.5f;
|
||||
found_upper = 0;
|
||||
gainsID_upper = -1;
|
||||
} else {
|
||||
|
|
@ -278,7 +240,7 @@ opus_int silk_encode_frame_FLP(
|
|||
gainsID_lower = gainsID;
|
||||
/* Copy part of the output state */
|
||||
silk_memcpy( &sRangeEnc_copy2, psRangeEnc, sizeof( ec_enc ) );
|
||||
celt_assert( psRangeEnc->offs <= 1275 );
|
||||
silk_assert( psRangeEnc->offs <= 1275 );
|
||||
silk_memcpy( ec_buf_copy, psRangeEnc->buf, psRangeEnc->offs );
|
||||
silk_memcpy( &sNSQ_copy2, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) );
|
||||
LastGainIndex_copy2 = psEnc->sShape.LastGainIndex;
|
||||
|
|
@ -288,34 +250,15 @@ opus_int silk_encode_frame_FLP(
|
|||
break;
|
||||
}
|
||||
|
||||
if ( !found_lower && nBits > maxBits ) {
|
||||
int j;
|
||||
for ( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
|
||||
int sum=0;
|
||||
for ( j = i*psEnc->sCmn.subfr_length; j < (i+1)*psEnc->sCmn.subfr_length; j++ ) {
|
||||
sum += abs( psEnc->sCmn.pulses[j] );
|
||||
}
|
||||
if ( iter == 0 || (sum < best_sum[i] && !gain_lock[i]) ) {
|
||||
best_sum[i] = sum;
|
||||
best_gain_mult[i] = gainMult_Q8;
|
||||
} else {
|
||||
gain_lock[i] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( ( found_lower & found_upper ) == 0 ) {
|
||||
/* Adjust gain according to high-rate rate/distortion curve */
|
||||
opus_int32 gain_factor_Q16;
|
||||
gain_factor_Q16 = silk_log2lin( silk_LSHIFT( nBits - maxBits, 7 ) / psEnc->sCmn.frame_length + SILK_FIX_CONST( 16, 7 ) );
|
||||
gain_factor_Q16 = silk_min_32( gain_factor_Q16, SILK_FIX_CONST( 2, 16 ) );
|
||||
if( nBits > maxBits ) {
|
||||
if (gainMult_Q8 < 16384) {
|
||||
gainMult_Q8 *= 2;
|
||||
} else {
|
||||
gainMult_Q8 = 32767;
|
||||
}
|
||||
} else {
|
||||
opus_int32 gain_factor_Q16;
|
||||
gain_factor_Q16 = silk_log2lin( silk_LSHIFT( nBits - maxBits, 7 ) / psEnc->sCmn.frame_length + SILK_FIX_CONST( 16, 7 ) );
|
||||
gainMult_Q8 = silk_SMULWB( gain_factor_Q16, gainMult_Q8 );
|
||||
gain_factor_Q16 = silk_max_32( gain_factor_Q16, SILK_FIX_CONST( 1.3, 16 ) );
|
||||
}
|
||||
gainMult_Q8 = silk_SMULWB( gain_factor_Q16, gainMult_Q8 );
|
||||
} else {
|
||||
/* Adjust gain by interpolating */
|
||||
gainMult_Q8 = gainMult_lower + ( ( gainMult_upper - gainMult_lower ) * ( maxBits - nBits_lower ) ) / ( nBits_upper - nBits_lower );
|
||||
|
|
@ -329,13 +272,7 @@ opus_int silk_encode_frame_FLP(
|
|||
}
|
||||
|
||||
for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
|
||||
opus_int16 tmp;
|
||||
if ( gain_lock[i] ) {
|
||||
tmp = best_gain_mult[i];
|
||||
} else {
|
||||
tmp = gainMult_Q8;
|
||||
}
|
||||
pGains_Q16[ i ] = silk_LSHIFT_SAT32( silk_SMULWB( sEncCtrl.GainsUnq_Q16[ i ], tmp ), 8 );
|
||||
pGains_Q16[ i ] = silk_LSHIFT_SAT32( silk_SMULWB( sEncCtrl.GainsUnq_Q16[ i ], gainMult_Q8 ), 8 );
|
||||
}
|
||||
|
||||
/* Quantize gains */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue