shithub: opus

Download patch

ref: 65b131ec0984973166973878b14506f782704a3f
parent: 7070dfec4f473f54d588827871fe386cbd06470a
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Tue Feb 6 15:52:21 EST 2024

Add basic testing for Deep PLC, DRED, and OSCE

Still need more targeted tests, DRED decoding

--- a/tests/test_opus_decode.c
+++ b/tests/test_opus_decode.c
@@ -105,6 +105,9 @@
       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();
@@ -185,6 +188,9 @@
          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();
@@ -200,6 +206,9 @@
          /* 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();
@@ -295,6 +304,9 @@
          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));
@@ -322,6 +334,9 @@
       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;
@@ -341,6 +356,9 @@
       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();
--- a/tests/test_opus_encode.c
+++ b/tests/test_opus_encode.c
@@ -250,7 +250,9 @@
          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, "
@@ -395,6 +397,9 @@
       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;
--