From 23fcd706fb6b752c642f94436a63b65afb6e8d0c Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jmvalin@jmvalin.ca>
Date: Fri, 21 Dec 2012 13:09:43 -0500
Subject: [PATCH] Only use automatic bandwidth detection when the user doesn't
 force bandwidth

Also fixes an issue with 40- and 60-ms frames using the repacketizer.
---
 src/opus_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index d1df5bfa1..be245bd9a 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -858,7 +858,7 @@ 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
-    if (st->detected_bandwidth)
+    if (st->detected_bandwidth && st->user_bandwidth == OPUS_AUTO)
     {
        st->bandwidth = IMIN(st->bandwidth, st->detected_bandwidth);
     }
-- 
GitLab