ref: 95561be6dedc77a95a217989ee93255f48f91530
parent: 744836604644fbb94409592069238088852db599
author: Jean-Marc Valin <[email protected]>
date: Mon Dec 17 12:54:01 EST 2012
Better handling of the multistream bitrate Now supports OPUS_AUTO and OPUS_BITRATE_MAX
--- a/src/opus_multistream_encoder.c
+++ b/src/opus_multistream_encoder.c
@@ -39,7 +39,6 @@
struct OpusMSEncoder {
ChannelLayout layout;
- int bitrate;
int variable_duration;
opus_int32 bitrate_bps;
opus_val32 subframe_mem[3];
@@ -105,6 +104,7 @@
st->layout.nb_streams = streams;
st->layout.nb_coupled_streams = coupled_streams;
+ st->bitrate_bps = OPUS_AUTO;
for (i=0;i<st->layout.nb_channels;i++)
st->layout.mapping[i] = mapping[i];
if (!validate_layout(&st->layout) || !validate_encoder_layout(&st->layout))
@@ -249,7 +249,15 @@
/* Compute bitrate allocation between streams (this could be a lot better) */
coded_channels = st->layout.nb_streams + st->layout.nb_coupled_streams;
- channel_rate = st->bitrate_bps / coded_channels;
+ if (st->bitrate_bps==OPUS_AUTO)
+ {
+ channel_rate = Fs+60*Fs/orig_frame_size;
+ } else if (st->bitrate_bps==OPUS_BITRATE_MAX)
+ {
+ channel_rate = 300000;
+ } else {
+ channel_rate = st->bitrate_bps/coded_channels;
+ }
#ifndef FIXED_POINT
if (st->variable_duration && orig_frame_size != frame_size)
{
@@ -435,6 +443,8 @@
case OPUS_SET_BITRATE_REQUEST:
{
opus_int32 value = va_arg(ap, opus_int32);
+ if (value<0 && value!=OPUS_AUTO && value!=OPUS_BITRATE_MAX)
+ goto bad_arg;
st->bitrate_bps = value;
}
break;