ref: 6fbfed6a0b927f0b54340081675c116955dd3705
parent: ae7dc8a13fb61a50204c5b28aac3c1c4c2e1c0dc
author: Jean-Marc Valin <[email protected]>
date: Fri Sep 13 13:16:38 EDT 2013
Allowing surround to use lower bandwidth than fullband
--- a/src/opus_multistream_encoder.c
+++ b/src/opus_multistream_encoder.c
@@ -747,7 +747,18 @@
opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrates[s]));
if (st->surround)
{
- opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
+ opus_int32 equiv_rate;
+ equiv_rate = st->bitrate_bps;
+ if (frame_size*50 < Fs)
+ equiv_rate -= 60*(Fs/frame_size - 50)*st->layout.nb_channels;
+ if (equiv_rate > 112000)
+ opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
+ else if (equiv_rate > 76000)
+ opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_SUPERWIDEBAND));
+ else if (equiv_rate > 48000)
+ opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_WIDEBAND));
+ else
+ opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND));
if (s < st->layout.nb_coupled_streams)
{
/* To preserve the spatial image, force stereo CELT on coupled streams */