Don't attenuate hybrid high-band for surround
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Tue, 19 Nov 2013 04:00:36 +0000 (23:00 -0500)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Tue, 19 Nov 2013 04:00:36 +0000 (23:00 -0500)
src/opus_encoder.c

index 7e3d957..70433d2 100644 (file)
@@ -1476,11 +1476,14 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
             if( st->silk_mode.bitRate > total_bitRate * 4/5 ) {
                 st->silk_mode.bitRate = total_bitRate * 4/5;
             }
-            /* Increasingly attenuate high band when it gets allocated fewer bits */
-            celt_rate = total_bitRate - st->silk_mode.bitRate;
-            HB_gain_ref = (curr_bandwidth == OPUS_BANDWIDTH_SUPERWIDEBAND) ? 3000 : 3600;
-            HB_gain = SHL32((opus_val32)celt_rate, 9) / SHR32((opus_val32)celt_rate + st->stream_channels * HB_gain_ref, 6);
-            HB_gain = HB_gain < Q15ONE*6/7 ? HB_gain + Q15ONE/7 : Q15ONE;
+            if (!st->energy_masking)
+            {
+               /* Increasingly attenuate high band when it gets allocated fewer bits */
+               celt_rate = total_bitRate - st->silk_mode.bitRate;
+               HB_gain_ref = (curr_bandwidth == OPUS_BANDWIDTH_SUPERWIDEBAND) ? 3000 : 3600;
+               HB_gain = SHL32((opus_val32)celt_rate, 9) / SHR32((opus_val32)celt_rate + st->stream_channels * HB_gain_ref, 6);
+               HB_gain = HB_gain < Q15ONE*6/7 ? HB_gain + Q15ONE/7 : Q15ONE;
+            }
         } else {
             /* SILK gets all bits */
             st->silk_mode.bitRate = total_bitRate;