summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2013-03-08 11:35:15 -0500
committerJean-Marc Valin <jmvalin@jmvalin.ca>2013-03-08 11:35:15 -0500
commitfa43c770e0fd0ebc796a61a32c305dfcf3869128 (patch)
tree8a403ba7a40cac187bd4734ca7dfed0c9c82a3ac /src
parentf55b0eaca57a7d89a37630fd9f944407fae58d05 (diff)
downloadopus-fa43c770e0fd0ebc796a61a32c305dfcf3869128.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/opus_encoder.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index a4983291..0daeb020 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -122,8 +122,8 @@ static const opus_int32 stereo_music_bandwidth_thresholds[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 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
/* 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 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
}
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) ) {