Skip to content

Commit

Permalink
Add basic testing for Deep PLC, DRED, and OSCE
Browse files Browse the repository at this point in the history
Still need more targeted tests, DRED decoding
  • Loading branch information
jmvalin committed Feb 7, 2024
1 parent 7070dfe commit 65b131e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 18 additions & 0 deletions tests/test_opus_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ int test_decoder_code0(int no_fuzz)
for(fec=0;fec<2;fec++)
{
opus_int32 dur;
#if defined(ENABLE_OSCE) || defined(ENABLE_DEEP_PLC)
opus_decoder_ctl(dec[t], OPUS_SET_COMPLEXITY(fast_rand()%11));
#endif
/*Test PLC on a fresh decoder*/
out_samples = opus_decode(dec[t], 0, 0, outbuf, 120/factor, fec);
if(out_samples!=120/factor)test_failed();
Expand Down Expand Up @@ -185,6 +188,9 @@ int test_decoder_code0(int no_fuzz)
packet[1]=j;
for(t=0;t<5*2;t++)
{
#if defined(ENABLE_OSCE) || defined(ENABLE_DEEP_PLC)
opus_decoder_ctl(dec[t], OPUS_SET_COMPLEXITY(fast_rand()%11));
#endif
out_samples = opus_decode(dec[t], packet, 3, outbuf, MAX_FRAME_SAMP, 0);
if(out_samples!=expected[t])test_failed();
if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
Expand All @@ -200,6 +206,9 @@ int test_decoder_code0(int no_fuzz)
/* The PLC is run for 6 frames in order to get better PLC coverage. */
for(j=0;j<6;j++)
{
#if defined(ENABLE_OSCE) || defined(ENABLE_DEEP_PLC)
opus_decoder_ctl(dec[t], OPUS_SET_COMPLEXITY(fast_rand()%11));
#endif
out_samples = opus_decode(dec[t], 0, 0, outbuf, expected[t], 0);
if(out_samples!=expected[t])test_failed();
if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
Expand Down Expand Up @@ -295,6 +304,9 @@ int test_decoder_code0(int no_fuzz)
for(jj=0;jj<j;jj++)packet[jj+1]=fast_rand()&255;
for(t=0;t<5*2;t++)
{
#if defined(ENABLE_OSCE) || defined(ENABLE_DEEP_PLC)
opus_decoder_ctl(dec[t], OPUS_SET_COMPLEXITY(fast_rand()%11));
#endif
out_samples = opus_decode(dec[t], packet, j+1, outbuf, MAX_FRAME_SAMP, 0);
if(out_samples!=expected[t])test_failed();
opus_decoder_ctl(dec[t], OPUS_GET_FINAL_RANGE(&dec_final_range1));
Expand Down Expand Up @@ -322,6 +334,9 @@ int test_decoder_code0(int no_fuzz)
for(t=0;t<5*2;t++)
{
opus_int32 dur;
#if defined(ENABLE_OSCE) || defined(ENABLE_DEEP_PLC)
opus_decoder_ctl(dec[t], OPUS_SET_COMPLEXITY(fast_rand()%11));
#endif
out_samples = opus_decode(dec[t], packet, plen+1, outbuf, MAX_FRAME_SAMP, 0);
if(out_samples!=expected[t])test_failed();
if(t==0)dec_final_range2=dec_final_range1;
Expand All @@ -341,6 +356,9 @@ int test_decoder_code0(int no_fuzz)
expected=opus_decoder_get_nb_samples(dec[t],packet,plen);
for(count=0;count<10;count++)
{
#if defined(ENABLE_OSCE) || defined(ENABLE_DEEP_PLC)
opus_decoder_ctl(dec[t], OPUS_SET_COMPLEXITY(fast_rand()%11));
#endif
for(j=0;j<plen;j++)packet[j+1]=(fast_rand()|fast_rand())&255;
out_samples = opus_decode(dec[t], packet, plen+1, outbuf, MAX_FRAME_SAMP, 0);
if(out_samples!=expected)test_failed();
Expand Down
7 changes: 6 additions & 1 deletion tests/test_opus_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ void fuzz_encoder_settings(const int num_encoders, const int num_setting_changes
if(opus_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(pred_disabled)) != OPUS_OK) test_failed();
if(opus_encoder_ctl(enc, OPUS_SET_DTX(dtx)) != OPUS_OK) test_failed();
if(opus_encoder_ctl(enc, OPUS_SET_EXPERT_FRAME_DURATION(frame_size_enum)) != OPUS_OK) test_failed();

#ifdef ENABLE_DRED
if(opus_encoder_ctl(enc, OPUS_SET_DRED_DURATION(fast_rand()%101)) != OPUS_OK) test_failed();
#endif
if(test_encode(enc, num_channels, frame_size, dec)) {
fprintf(stderr,
"fuzz_encoder_settings: %d kHz, %d ch, application: %d, "
Expand Down Expand Up @@ -395,6 +397,9 @@ int run_test1(int no_fuzz)
if(opus_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(rc==1))!=OPUS_OK)test_failed();
if(opus_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(rc==1))!=OPUS_OK)test_failed();
if(opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(rc==0))!=OPUS_OK)test_failed();
#ifdef ENABLE_DRED
if(opus_encoder_ctl(enc, OPUS_SET_DRED_DURATION(fast_rand()%101)) != OPUS_OK) test_failed();
#endif
for(j=0;j<13;j++)
{
int rate;
Expand Down

0 comments on commit 65b131e

Please sign in to comment.