shithub: opus

Download patch

ref: 1bf32bb5ac1b55c5c383024426bb0adad72a95a8
parent: f77410deb6922e8f557d6b53d9102763c4d28158
author: Jean-Marc Valin <[email protected]>
date: Mon Apr 22 22:41:28 EDT 2013

Fixes FEC issues introduced in 7fcd66c

This left FEC disabled on the decoder side for all cases except concatenated
packets. Also fixes a FEC bug in opus_demo (wrong output buffer size
calculation).

--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -781,17 +781,20 @@
       int duration_copy;
       int ret;
       /* If no FEC can be present, run the PLC (recursive call) */
-      if (frame_size <= packet_frame_size || packet_mode == MODE_CELT_ONLY || st->mode == MODE_CELT_ONLY)
+      if (frame_size < packet_frame_size || packet_mode == MODE_CELT_ONLY || st->mode == MODE_CELT_ONLY)
          return opus_decode_native(st, NULL, 0, pcm, frame_size, 0, 0, NULL, soft_clip);
       /* Otherwise, run the PLC on everything except the size for which we might have FEC */
       duration_copy = st->last_packet_duration;
-      ret = opus_decode_native(st, NULL, 0, pcm, frame_size-packet_frame_size, 0, 0, NULL, soft_clip);
-      if (ret<0)
+      if (frame_size-packet_frame_size!=0)
       {
-         st->last_packet_duration = duration_copy;
-         return ret;
+         ret = opus_decode_native(st, NULL, 0, pcm, frame_size-packet_frame_size, 0, 0, NULL, soft_clip);
+         if (ret<0)
+         {
+            st->last_packet_duration = duration_copy;
+            return ret;
+         }
+         celt_assert(ret==frame_size-packet_frame_size);
       }
-      celt_assert(ret==frame_size-packet_frame_size);
       /* Complete with FEC */
       st->mode = packet_mode;
       st->bandwidth = packet_bandwidth;
--- a/src/opus_demo.c
+++ b/src/opus_demo.c
@@ -737,9 +737,11 @@
                 if( use_inbandfec  ) {
                     if( lost_prev ) {
                         /* attempt to decode with in-band FEC from next packet */
+                        opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples));
                         output_samples = opus_decode(dec, lost ? NULL : data[toggle], len[toggle], out, output_samples, 1);
                     } else {
                         /* regular decode */
+                        output_samples = max_frame_size;
                         output_samples = opus_decode(dec, data[1-toggle], len[1-toggle], out, output_samples, 0);
                     }
                 } else {