shithub: opus

Download patch

ref: 617fcd2cf0352574cace66392001228bb96769a2
parent: d43419297e0bbac2824bc0cd0cb647e8cb25e2f6
author: Jean-Marc Valin <[email protected]>
date: Wed Mar 16 18:11:53 EDT 2011

Fixes a few PLC/DTX bugs due to the recent decode API change

--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -216,8 +216,9 @@
             /* Shrink decoder because of raw bits */
             dec.storage -= redundancy_bytes;
         }
-        start_band = 17;
     }
+    if (mode != MODE_CELT_ONLY)
+    	start_band = 17;
 
     if (mode != MODE_SILK_ONLY)
     {
@@ -343,7 +344,9 @@
 	unsigned char ch, toc;
 	/* 48 x 2.5 ms = 120 ms */
 	short size[48];
-	if (len<1)
+	if (len==0 || data==NULL)
+	    return opus_decode_frame(st, NULL, 0, pcm, frame_size, 0);
+	else if (len<0)
 		return CELT_BAD_ARG;
 	st->mode = opus_packet_get_mode(data);
 	st->bandwidth = opus_packet_get_bandwidth(data);
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -293,6 +293,9 @@
             fprintf (stderr, "SILK encode error: %d\n", ret);
             /* Handle error */
         }
+        if (nBytes==0)
+            return 0;
+
         /* Extract SILK internal bandwidth for signaling in first byte */
         if( st->mode == MODE_SILK_ONLY ) {
             if( st->silk_mode.internalSampleRate == 8000 ) {
--- a/src/test_opus.c
+++ b/src/test_opus.c
@@ -285,13 +285,13 @@
 #if OPUS_TEST_RANGE_CODER_STATE
       enc_final_range[toggle] = opus_encoder_get_final_range( enc );
 #endif
-      if (len[toggle] <= 0)
+      if (len[toggle] < 0)
       {
          fprintf (stderr, "opus_encode() returned %d\n", len[toggle]);
          return 1;
       }
 
-      lost = rand()%100<packet_loss_perc;
+      lost = rand()%100<packet_loss_perc || len[toggle]==0;
       if( count >= use_inbandfec ) {
           /* delay by one packet when using in-band FEC */
           if( use_inbandfec  ) {