Fixes two bandwidth decision issues
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Tue, 19 Feb 2013 05:42:15 +0000 (00:42 -0500)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Tue, 19 Feb 2013 05:42:15 +0000 (00:42 -0500)
1) In cases where the SILK desired bandwidth went down, then quickly up, we
count get stuck in a mode with the LP variation going the wrong way.
2) Bandwidth detection can no longer force SILK to go below wideband to
avoid switches that require redundancy.

silk/control_audio_bandwidth.c
src/opus_encoder.c

index b645dd5..ef02fed 100644 (file)
@@ -115,6 +115,9 @@ opus_int silk_control_audio_bandwidth(
                        psEncC->sLP.mode = 1;
                    }
                 }
+            } else {
+               if (psEncC->sLP.mode<0)
+                  psEncC->sLP.mode = 1;
             }
         }
     }
index ec7d6e7..a498329 100644 (file)
@@ -858,9 +858,15 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
     if (st->Fs <= 8000 && st->bandwidth > OPUS_BANDWIDTH_NARROWBAND)
         st->bandwidth = OPUS_BANDWIDTH_NARROWBAND;
 #ifndef FIXED_POINT
+    /* Use detected bandwidth to reduce the encoded bandwidth. */
     if (st->detected_bandwidth && st->user_bandwidth == OPUS_AUTO)
     {
-       st->bandwidth = IMIN(st->bandwidth, st->detected_bandwidth);
+       /* When operating in SILK/hybrid mode, we don't go below wideband to avoid
+          more complicated switches that require redundancy */
+       if (st->mode == MODE_CELT_ONLY)
+          st->bandwidth = IMIN(st->bandwidth, st->detected_bandwidth);
+       else
+          st->bandwidth = IMIN(st->bandwidth, IMAX(OPUS_BANDWIDTH_WIDEBAND, st->detected_bandwidth));
     }
 #endif
     celt_encoder_ctl(celt_enc, OPUS_SET_LSB_DEPTH(lsb_depth));