shithub: opus

Download patch

ref: bfad28185c9016cc21282e0839ac4b891cb87970
parent: 97cefddc278e1d024d2035a92850f836959280f3
author: Jean-Marc Valin <[email protected]>
date: Tue Oct 25 09:46:35 EDT 2011

Adjusts the bandwidth thresholds depending on complexity and CBR

--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -639,7 +639,17 @@
         const opus_int32 *voice_bandwidth_thresholds, *music_bandwidth_thresholds;
         opus_int32 bandwidth_thresholds[8];
         int bandwidth = OPUS_BANDWIDTH_FULLBAND;
+        opus_int32 equiv_rate2;
 
+        equiv_rate2 = equiv_rate;
+        if (st->mode != MODE_CELT_ONLY)
+        {
+           /* Adjust the threshold +/- 10% depending on complexity */
+           equiv_rate2 = equiv_rate2 * (45+st->silk_mode.complexity)/50;
+           /* CBR is less efficient by ~1 kb/s */
+           if (!st->use_vbr)
+              equiv_rate2 -= 1000;
+        }
         if (st->channels==2 && st->force_channels!=1)
         {
            voice_bandwidth_thresholds = stereo_voice_bandwidth_thresholds;
@@ -665,7 +675,7 @@
                 else
                     threshold += hysteresis;
             }
-            if (equiv_rate >= threshold)
+            if (equiv_rate2 >= threshold)
                 break;
         } while (--bandwidth>OPUS_BANDWIDTH_NARROWBAND);
         st->bandwidth = bandwidth;