@@ -90,6 +90,7 @@ struct OpusCustomDecoder {
90
90
int start , end ;
91
91
int signalling ;
92
92
int disable_inv ;
93
+ int complexity ;
93
94
int arch ;
94
95
95
96
/* Everything beyond this point gets cleared on a reset */
@@ -110,7 +111,7 @@ struct OpusCustomDecoder {
110
111
111
112
celt_sig preemph_memD [2 ];
112
113
113
- #ifdef ENABLE_DRED
114
+ #ifdef ENABLE_DEEP_PLC
114
115
opus_int16 plc_pcm [PLC_UPDATE_SAMPLES ];
115
116
int plc_fill ;
116
117
float plc_preemphasis_mem ;
@@ -551,7 +552,7 @@ static void prefilter_and_fold(CELTDecoder * OPUS_RESTRICT st, int N)
551
552
} while (++ c < CC );
552
553
}
553
554
554
- #ifdef ENABLE_DRED
555
+ #ifdef ENABLE_DEEP_PLC
555
556
556
557
#define SINC_ORDER 48
557
558
/* h=cos(pi/2*abs(sin([-24:24]/48*pi*23./24)).^2);
@@ -603,7 +604,7 @@ void update_plc_state(LPCNetPLCState *lpcnet, celt_sig *decode_mem[2], int CC)
603
604
#endif
604
605
605
606
static void celt_decode_lost (CELTDecoder * OPUS_RESTRICT st , int N , int LM
606
- #ifdef ENABLE_DRED
607
+ #ifdef ENABLE_DEEP_PLC
607
608
,LPCNetPLCState * lpcnet
608
609
#endif
609
610
)
@@ -641,7 +642,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM
641
642
642
643
loss_duration = st -> loss_duration ;
643
644
start = st -> start ;
644
- #ifdef ENABLE_DRED
645
+ #ifdef ENABLE_DEEP_PLC
645
646
noise_based = start != 0 || (lpcnet -> fec_fill_pos == 0 && (st -> skip_plc || loss_duration >= 80 ));
646
647
#else
647
648
noise_based = loss_duration >= 40 || start != 0 || st -> skip_plc ;
@@ -718,7 +719,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM
718
719
719
720
if (loss_duration == 0 )
720
721
{
721
- #ifdef ENABLE_DRED
722
+ #ifdef ENABLE_DEEP_PLC
722
723
update_plc_state (lpcnet , decode_mem , C );
723
724
#endif
724
725
st -> last_pitch_index = pitch_index = celt_plc_pitch_search (decode_mem , C , st -> arch );
@@ -911,8 +912,8 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM
911
912
912
913
} while (++ c < C );
913
914
914
- #ifdef ENABLE_DRED
915
- {
915
+ #ifdef ENABLE_DEEP_PLC
916
+ if ( st -> complexity >= 5 || lpcnet -> fec_fill_pos > 0 ) {
916
917
float overlap_mem ;
917
918
int samples_needed16k ;
918
919
int ignored = 0 ;
@@ -982,7 +983,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM
982
983
983
984
int celt_decode_with_ec_dred (CELTDecoder * OPUS_RESTRICT st , const unsigned char * data ,
984
985
int len , opus_val16 * OPUS_RESTRICT pcm , int frame_size , ec_dec * dec , int accum
985
- #ifdef ENABLE_DRED
986
+ #ifdef ENABLE_DEEP_PLC
986
987
,LPCNetPLCState * lpcnet
987
988
#endif
988
989
)
@@ -1103,15 +1104,15 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char
1103
1104
if (data == NULL || len <=1 )
1104
1105
{
1105
1106
celt_decode_lost (st , N , LM
1106
- #ifdef ENABLE_DRED
1107
+ #ifdef ENABLE_DEEP_PLC
1107
1108
, lpcnet
1108
1109
#endif
1109
1110
);
1110
1111
deemphasis (out_syn , pcm , N , CC , st -> downsample , mode -> preemph , st -> preemph_memD , accum );
1111
1112
RESTORE_STACK ;
1112
1113
return frame_size /st -> downsample ;
1113
1114
}
1114
- #ifdef ENABLE_DRED
1115
+ #ifdef ENABLE_DEEP_PLC
1115
1116
else {
1116
1117
/* FIXME: This is a bit of a hack just to make sure opus_decode_native() knows we're no longer in PLC. */
1117
1118
if (lpcnet ) lpcnet -> blend = 0 ;
@@ -1365,7 +1366,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
1365
1366
int len , opus_val16 * OPUS_RESTRICT pcm , int frame_size , ec_dec * dec , int accum )
1366
1367
{
1367
1368
return celt_decode_with_ec_dred (st , data , len , pcm , frame_size , dec , accum
1368
- #ifdef ENABLE_DRED
1369
+ #ifdef ENABLE_DEEP_PLC
1369
1370
, NULL
1370
1371
#endif
1371
1372
);
@@ -1443,6 +1444,26 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...)
1443
1444
va_start (ap , request );
1444
1445
switch (request )
1445
1446
{
1447
+ case OPUS_SET_COMPLEXITY_REQUEST :
1448
+ {
1449
+ opus_int32 value = va_arg (ap , opus_int32 );
1450
+ if (value < 0 || value > 10 )
1451
+ {
1452
+ goto bad_arg ;
1453
+ }
1454
+ st -> complexity = value ;
1455
+ }
1456
+ break ;
1457
+ case OPUS_GET_COMPLEXITY_REQUEST :
1458
+ {
1459
+ opus_int32 * value = va_arg (ap , opus_int32 * );
1460
+ if (!value )
1461
+ {
1462
+ goto bad_arg ;
1463
+ }
1464
+ * value = st -> complexity ;
1465
+ }
1466
+ break ;
1446
1467
case CELT_SET_START_BAND_REQUEST :
1447
1468
{
1448
1469
opus_int32 value = va_arg (ap , opus_int32 );
0 commit comments