diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-01-04 02:01:18 -0600 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-04-23 14:23:04 +0000 |
commit | 14c6bb798d6bebc80f07e863236adbaf8d156a9c (patch) | |
tree | 551a4b641906c2626af844fa3239c1b2b1ff0ad3 /lib/rbcodec/codecs/libopus/silk/PLC.c | |
parent | 75d93937965ec4df70d37df6d4feea04577c996b (diff) | |
download | rockbox-14c6bb798d6bebc80f07e863236adbaf8d156a9c.tar.gz rockbox-14c6bb798d6bebc80f07e863236adbaf8d156a9c.zip |
Sync opus codec to upstream git
Change-Id: I0cfcc0005c4ad7bfbb1aaf454188ce70fb043dc1
Diffstat (limited to 'lib/rbcodec/codecs/libopus/silk/PLC.c')
-rw-r--r-- | lib/rbcodec/codecs/libopus/silk/PLC.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/rbcodec/codecs/libopus/silk/PLC.c b/lib/rbcodec/codecs/libopus/silk/PLC.c index 8b0a8fe57d..f89391651c 100644 --- a/lib/rbcodec/codecs/libopus/silk/PLC.c +++ b/lib/rbcodec/codecs/libopus/silk/PLC.c | |||
@@ -46,7 +46,8 @@ static OPUS_INLINE void silk_PLC_update( | |||
46 | static OPUS_INLINE void silk_PLC_conceal( | 46 | static OPUS_INLINE void silk_PLC_conceal( |
47 | silk_decoder_state *psDec, /* I/O Decoder state */ | 47 | silk_decoder_state *psDec, /* I/O Decoder state */ |
48 | silk_decoder_control *psDecCtrl, /* I/O Decoder control */ | 48 | silk_decoder_control *psDecCtrl, /* I/O Decoder control */ |
49 | opus_int16 frame[] /* O LPC residual signal */ | 49 | opus_int16 frame[], /* O LPC residual signal */ |
50 | int arch /* I Run-time architecture */ | ||
50 | ); | 51 | ); |
51 | 52 | ||
52 | 53 | ||
@@ -65,7 +66,8 @@ void silk_PLC( | |||
65 | silk_decoder_state *psDec, /* I/O Decoder state */ | 66 | silk_decoder_state *psDec, /* I/O Decoder state */ |
66 | silk_decoder_control *psDecCtrl, /* I/O Decoder control */ | 67 | silk_decoder_control *psDecCtrl, /* I/O Decoder control */ |
67 | opus_int16 frame[], /* I/O signal */ | 68 | opus_int16 frame[], /* I/O signal */ |
68 | opus_int lost /* I Loss flag */ | 69 | opus_int lost, /* I Loss flag */ |
70 | int arch /* I Run-time architecture */ | ||
69 | ) | 71 | ) |
70 | { | 72 | { |
71 | /* PLC control function */ | 73 | /* PLC control function */ |
@@ -78,7 +80,7 @@ void silk_PLC( | |||
78 | /****************************/ | 80 | /****************************/ |
79 | /* Generate Signal */ | 81 | /* Generate Signal */ |
80 | /****************************/ | 82 | /****************************/ |
81 | silk_PLC_conceal( psDec, psDecCtrl, frame ); | 83 | silk_PLC_conceal( psDec, psDecCtrl, frame, arch ); |
82 | 84 | ||
83 | psDec->lossCnt++; | 85 | psDec->lossCnt++; |
84 | } else { | 86 | } else { |
@@ -192,7 +194,8 @@ static OPUS_INLINE void silk_PLC_energy(opus_int32 *energy1, opus_int *shift1, o | |||
192 | static OPUS_INLINE void silk_PLC_conceal( | 194 | static OPUS_INLINE void silk_PLC_conceal( |
193 | silk_decoder_state *psDec, /* I/O Decoder state */ | 195 | silk_decoder_state *psDec, /* I/O Decoder state */ |
194 | silk_decoder_control *psDecCtrl, /* I/O Decoder control */ | 196 | silk_decoder_control *psDecCtrl, /* I/O Decoder control */ |
195 | opus_int16 frame[] /* O LPC residual signal */ | 197 | opus_int16 frame[], /* O LPC residual signal */ |
198 | int arch /* I Run-time architecture */ | ||
196 | ) | 199 | ) |
197 | { | 200 | { |
198 | opus_int i, j, k; | 201 | opus_int i, j, k; |
@@ -272,7 +275,7 @@ static OPUS_INLINE void silk_PLC_conceal( | |||
272 | /* Reduce random noise for unvoiced frames with high LPC gain */ | 275 | /* Reduce random noise for unvoiced frames with high LPC gain */ |
273 | opus_int32 invGain_Q30, down_scale_Q30; | 276 | opus_int32 invGain_Q30, down_scale_Q30; |
274 | 277 | ||
275 | invGain_Q30 = silk_LPC_inverse_pred_gain( psPLC->prevLPC_Q12, psDec->LPC_order ); | 278 | invGain_Q30 = silk_LPC_inverse_pred_gain( psPLC->prevLPC_Q12, psDec->LPC_order, arch ); |
276 | 279 | ||
277 | down_scale_Q30 = silk_min_32( silk_RSHIFT( (opus_int32)1 << 30, LOG2_INV_LPC_GAIN_HIGH_THRES ), invGain_Q30 ); | 280 | down_scale_Q30 = silk_min_32( silk_RSHIFT( (opus_int32)1 << 30, LOG2_INV_LPC_GAIN_HIGH_THRES ), invGain_Q30 ); |
278 | down_scale_Q30 = silk_max_32( silk_RSHIFT( (opus_int32)1 << 30, LOG2_INV_LPC_GAIN_LOW_THRES ), down_scale_Q30 ); | 281 | down_scale_Q30 = silk_max_32( silk_RSHIFT( (opus_int32)1 << 30, LOG2_INV_LPC_GAIN_LOW_THRES ), down_scale_Q30 ); |
@@ -288,8 +291,8 @@ static OPUS_INLINE void silk_PLC_conceal( | |||
288 | 291 | ||
289 | /* Rewhiten LTP state */ | 292 | /* Rewhiten LTP state */ |
290 | idx = psDec->ltp_mem_length - lag - psDec->LPC_order - LTP_ORDER / 2; | 293 | idx = psDec->ltp_mem_length - lag - psDec->LPC_order - LTP_ORDER / 2; |
291 | silk_assert( idx > 0 ); | 294 | celt_assert( idx > 0 ); |
292 | silk_LPC_analysis_filter( &sLTP[ idx ], &psDec->outBuf[ idx ], A_Q12, psDec->ltp_mem_length - idx, psDec->LPC_order ); | 295 | silk_LPC_analysis_filter( &sLTP[ idx ], &psDec->outBuf[ idx ], A_Q12, psDec->ltp_mem_length - idx, psDec->LPC_order, arch ); |
293 | /* Scale LTP state */ | 296 | /* Scale LTP state */ |
294 | inv_gain_Q30 = silk_INVERSE32_varQ( psPLC->prevGain_Q16[ 1 ], 46 ); | 297 | inv_gain_Q30 = silk_INVERSE32_varQ( psPLC->prevGain_Q16[ 1 ], 46 ); |
295 | inv_gain_Q30 = silk_min( inv_gain_Q30, silk_int32_MAX >> 1 ); | 298 | inv_gain_Q30 = silk_min( inv_gain_Q30, silk_int32_MAX >> 1 ); |
@@ -325,8 +328,10 @@ static OPUS_INLINE void silk_PLC_conceal( | |||
325 | for( j = 0; j < LTP_ORDER; j++ ) { | 328 | for( j = 0; j < LTP_ORDER; j++ ) { |
326 | B_Q14[ j ] = silk_RSHIFT( silk_SMULBB( harm_Gain_Q15, B_Q14[ j ] ), 15 ); | 329 | B_Q14[ j ] = silk_RSHIFT( silk_SMULBB( harm_Gain_Q15, B_Q14[ j ] ), 15 ); |
327 | } | 330 | } |
328 | /* Gradually reduce excitation gain */ | 331 | if ( psDec->indices.signalType != TYPE_NO_VOICE_ACTIVITY ) { |
329 | rand_scale_Q14 = silk_RSHIFT( silk_SMULBB( rand_scale_Q14, rand_Gain_Q15 ), 15 ); | 332 | /* Gradually reduce excitation gain */ |
333 | rand_scale_Q14 = silk_RSHIFT( silk_SMULBB( rand_scale_Q14, rand_Gain_Q15 ), 15 ); | ||
334 | } | ||
330 | 335 | ||
331 | /* Slowly increase pitch lag */ | 336 | /* Slowly increase pitch lag */ |
332 | psPLC->pitchL_Q8 = silk_SMLAWB( psPLC->pitchL_Q8, psPLC->pitchL_Q8, PITCH_DRIFT_FAC_Q16 ); | 337 | psPLC->pitchL_Q8 = silk_SMLAWB( psPLC->pitchL_Q8, psPLC->pitchL_Q8, PITCH_DRIFT_FAC_Q16 ); |
@@ -342,7 +347,7 @@ static OPUS_INLINE void silk_PLC_conceal( | |||
342 | /* Copy LPC state */ | 347 | /* Copy LPC state */ |
343 | silk_memcpy( sLPC_Q14_ptr, psDec->sLPC_Q14_buf, MAX_LPC_ORDER * sizeof( opus_int32 ) ); | 348 | silk_memcpy( sLPC_Q14_ptr, psDec->sLPC_Q14_buf, MAX_LPC_ORDER * sizeof( opus_int32 ) ); |
344 | 349 | ||
345 | silk_assert( psDec->LPC_order >= 10 ); /* check that unrolling works */ | 350 | celt_assert( psDec->LPC_order >= 10 ); /* check that unrolling works */ |
346 | for( i = 0; i < psDec->frame_length; i++ ) { | 351 | for( i = 0; i < psDec->frame_length; i++ ) { |
347 | /* partly unrolled */ | 352 | /* partly unrolled */ |
348 | /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ | 353 | /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ |
@@ -362,7 +367,8 @@ static OPUS_INLINE void silk_PLC_conceal( | |||
362 | } | 367 | } |
363 | 368 | ||
364 | /* Add prediction to LPC excitation */ | 369 | /* Add prediction to LPC excitation */ |
365 | sLPC_Q14_ptr[ MAX_LPC_ORDER + i ] = silk_ADD_LSHIFT32( sLPC_Q14_ptr[ MAX_LPC_ORDER + i ], LPC_pred_Q10, 4 ); | 370 | sLPC_Q14_ptr[ MAX_LPC_ORDER + i ] = silk_ADD_SAT32( sLPC_Q14_ptr[ MAX_LPC_ORDER + i ], |
371 | silk_LSHIFT_SAT32( LPC_pred_Q10, 4 )); | ||
366 | 372 | ||
367 | /* Scale with Gain */ | 373 | /* Scale with Gain */ |
368 | frame[ i ] = (opus_int16)silk_SAT16( silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( sLPC_Q14_ptr[ MAX_LPC_ORDER + i ], prevGain_Q10[ 1 ] ), 8 ) ) ); | 374 | frame[ i ] = (opus_int16)silk_SAT16( silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( sLPC_Q14_ptr[ MAX_LPC_ORDER + i ], prevGain_Q10[ 1 ] ), 8 ) ) ); |