ref: b386458fa3eb1d0e9b664e0c8c8269fbfc903a7f
parent: eeca56821167303c2a050a548ca43029c4a402df
author: Jean-Marc Valin <[email protected]>
date: Mon Jan 31 07:41:49 EST 2011
Got stereo support to work in CELT-only mode
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -58,7 +58,7 @@
st = (OpusDecoder*)raw_state;
st->silk_dec = (void*)(raw_state+sizeof(OpusDecoder));
st->celt_dec = (CELTDecoder*)(raw_state+sizeof(OpusDecoder)+silkDecSizeBytes);
- st->channels = channels;
+ st->stream_channels = st->channels = channels;
st->Fs = Fs;
@@ -111,6 +111,7 @@
else
audiosize = (st->Fs<<audiosize)/100;
}
+ st->stream_channels = (data[0]&0x4) ? 2 : 1;
/*printf ("%d %d %d\n", st->mode, st->bandwidth, audiosize);*/
len -= 1;
@@ -180,6 +181,7 @@
break;
}
celt_decoder_ctl(st->celt_dec, CELT_SET_END_BAND(endband));
+ celt_decoder_ctl(st->celt_dec, CELT_SET_CHANNELS(st->stream_channels));
/* Encode high band with CELT */
celt_ret = celt_decode_with_ec(st->celt_dec, data, len, pcm_celt, frame_size, &dec);
--- a/src/opus_decoder.h
+++ b/src/opus_decoder.h
@@ -39,6 +39,7 @@
CELTDecoder *celt_dec;
void *silk_dec;
int channels;
+ int stream_channels;
int mode;
int bandwidth;
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -58,7 +58,7 @@
st = (OpusEncoder*)raw_state;
st->silk_enc = (void*)(raw_state+sizeof(OpusEncoder));
st->celt_enc = (CELTEncoder*)(raw_state+sizeof(OpusEncoder)+silkEncSizeBytes);
- st->channels = channels;
+ st->stream_channels = st->channels = channels;
st->Fs = Fs;
@@ -168,6 +168,7 @@
break;
}
celt_encoder_ctl(st->celt_enc, CELT_SET_END_BAND(endband));
+ celt_encoder_ctl(st->celt_enc, CELT_SET_CHANNELS(st->stream_channels));
for (i=0;i<ENCODER_DELAY_COMPENSATION*st->channels;i++)
pcm_buf[i] = st->delay_buffer[i];
@@ -178,7 +179,9 @@
if (st->vbr_rate != 0)
{
- int tmp = (st->vbr_rate-6000)/2;
+ int tmp;
+
+ tmp = (st->mode == MODE_HYBRID) ? (st->vbr_rate-6000)/2 : st->vbr_rate;
tmp = ((ec_enc_tell(&enc, 0)+4)>>3) + tmp * frame_size/(8*st->Fs);
if (tmp <= bytes_per_packet)
bytes_per_packet = tmp;
@@ -219,6 +222,7 @@
data[0] |= (st->bandwidth-BANDWIDTH_SUPERWIDEBAND)<<4;
data[0] |= (period-2)<<3;
}
+ data[0] |= (st->stream_channels==2)<<2;
/*printf ("%x\n", (int)data[0]);*/
return ret+1;
--- a/src/opus_encoder.h
+++ b/src/opus_encoder.h
@@ -43,6 +43,7 @@
CELTEncoder *celt_enc;
void *silk_enc;
int channels;
+ int stream_channels;
int mode;
int bandwidth;