ref: fa43c770e0fd0ebc796a61a32c305dfcf3869128
parent: f55b0eaca57a7d89a37630fd9f944407fae58d05
author: Jean-Marc Valin <[email protected]>
date: Fri Mar 8 06:35:15 EST 2013
Making CELT stereo<->mono transitions gradual This not only avoids sudden changes in audio quality, but also increases quality when we don't have enough bits to code a wide stereo image.
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -122,8 +122,8 @@
48000, 2000, /* SWB<->FB */
};
/* Threshold bit-rates for switching between mono and stereo */
-static const opus_int32 stereo_voice_threshold = 26000;
-static const opus_int32 stereo_music_threshold = 36000;
+static const opus_int32 stereo_voice_threshold = 31000;
+static const opus_int32 stereo_music_threshold = 31000;
/* Threshold bit-rate for switching between SILK/hybrid and CELT-only */
static const opus_int32 mode_thresholds[2][2] = {
@@ -710,9 +710,9 @@
/* Hysteresis */
if (st->prev_mode == MODE_CELT_ONLY)
- threshold -= 4000;
+ threshold -= 1000;
else if (st->prev_mode>0)
- threshold += 4000;
+ threshold += 1000;
st->mode = (equiv_rate >= threshold) ? MODE_CELT_ONLY: MODE_SILK_ONLY;
@@ -1241,7 +1241,7 @@
}
st->prev_HB_gain = HB_gain;
if (st->mode != MODE_HYBRID || st->stream_channels==1)
- st->silk_mode.stereoWidth_Q14 = 1<<14;
+ st->silk_mode.stereoWidth_Q14 = IMIN((1<<14),IMAX(0,st->bitrate_bps-32000));
if( st->channels == 2 ) {
/* Apply stereo width reduction (at low bitrates) */
if( st->hybrid_stereo_width_Q14 < (1 << 14) || st->silk_mode.stereoWidth_Q14 < (1 << 14) ) {