diff options
author | Jean-Marc Valin <jean-marc.valin@octasic.com> | 2011-01-31 20:41:49 +0300 |
---|---|---|
committer | Jean-Marc Valin <jean-marc.valin@octasic.com> | 2011-01-31 20:41:49 +0300 |
commit | b386458fa3eb1d0e9b664e0c8c8269fbfc903a7f (patch) | |
tree | 50586bb57fef15f78b5b5850915192d7acba9e38 /src | |
parent | eeca56821167303c2a050a548ca43029c4a402df (diff) |
Got stereo support to work in CELT-only mode
Diffstat (limited to 'src')
-rw-r--r-- | src/opus_decoder.c | 4 | ||||
-rw-r--r-- | src/opus_decoder.h | 1 | ||||
-rw-r--r-- | src/opus_encoder.c | 8 | ||||
-rw-r--r-- | src/opus_encoder.h | 1 |
4 files changed, 11 insertions, 3 deletions
diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 242fed0e..72f76a34 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -58,7 +58,7 @@ OpusDecoder *opus_decoder_create(int Fs, int channels) 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 @@ int opus_decode(OpusDecoder *st, const unsigned char *data, 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 @@ int opus_decode(OpusDecoder *st, const unsigned char *data, 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); diff --git a/src/opus_decoder.h b/src/opus_decoder.h index f4f012a3..3a39c872 100644 --- a/src/opus_decoder.h +++ b/src/opus_decoder.h @@ -39,6 +39,7 @@ struct OpusDecoder { CELTDecoder *celt_dec; void *silk_dec; int channels; + int stream_channels; int mode; int bandwidth; diff --git a/src/opus_encoder.c b/src/opus_encoder.c index fa507d0e..0cfc30dc 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -58,7 +58,7 @@ OpusEncoder *opus_encoder_create(int Fs, int channels) 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 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, 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 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, 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 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, 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; diff --git a/src/opus_encoder.h b/src/opus_encoder.h index 1f061dbe..1b0271e4 100644 --- a/src/opus_encoder.h +++ b/src/opus_encoder.h @@ -43,6 +43,7 @@ struct OpusEncoder { CELTEncoder *celt_enc; void *silk_enc; int channels; + int stream_channels; int mode; int bandwidth; |