summaryrefslogtreecommitdiff
path: root/src/opus_encoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/opus_encoder.c')
-rw-r--r--src/opus_encoder.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 7e3d9578..70433d29 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -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;