Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Marc Valin <jean-marc.valin@octasic.com>2010-07-20 19:13:30 +0400
committerJean-Marc Valin <jean-marc.valin@octasic.com>2010-07-20 19:13:30 +0400
commit67008d23cd569595409703b8341533e8ced01baf (patch)
tree035fb28ea697f2200def19ed6768e472b0aa759c /src
parentae18090b550cb9a116712be2f9d96957d7f305f3 (diff)
Support for setting the audio bandwidth
Diffstat (limited to 'src')
-rw-r--r--src/hybrid.h7
-rw-r--r--src/hybrid_decoder.c9
-rw-r--r--src/hybrid_encoder.c15
3 files changed, 26 insertions, 5 deletions
diff --git a/src/hybrid.h b/src/hybrid.h
index ae1566da..541fca16 100644
--- a/src/hybrid.h
+++ b/src/hybrid.h
@@ -52,9 +52,10 @@ extern "C" {
#define MODE_CELT_ONLY 1002
#define BANDWIDTH_NARROWBAND 1100
-#define BANDWIDTH_WIDEBAND 1101
-#define BANDWIDTH_SUPERWIDEBAND 1102
-#define BANDWIDTH_FULLBAND 1103
+#define BANDWIDTH_MEDIUMBAND 1101
+#define BANDWIDTH_WIDEBAND 1102
+#define BANDWIDTH_SUPERWIDEBAND 1103
+#define BANDWIDTH_FULLBAND 1104
diff --git a/src/hybrid_decoder.c b/src/hybrid_decoder.c
index 8eab5c90..8425350a 100644
--- a/src/hybrid_decoder.c
+++ b/src/hybrid_decoder.c
@@ -88,6 +88,9 @@ int hybrid_decode(HybridDecoder *st, const unsigned char *data,
if (st->mode != MODE_CELT_ONLY)
{
DecControl.API_sampleRate = st->Fs;
+
+ /* We Should eventually have to set the bandwidth here */
+
/* Call SILK encoder for the low band */
silk_ret = SKP_Silk_SDK_Decode( st->silk_dec, &DecControl, 0, &dec, len, pcm, &silk_frame_size );
if (silk_ret)
@@ -108,8 +111,12 @@ int hybrid_decode(HybridDecoder *st, const unsigned char *data,
celt_decoder_ctl(st->celt_dec, CELT_SET_START_BAND(0));
}
- if (st->mode != MODE_SILK_ONLY)
+ if (st->mode != MODE_SILK_ONLY && st->bandwidth > BANDWIDTH_WIDEBAND)
{
+ if (st->bandwidth == BANDWIDTH_SUPERWIDEBAND)
+ celt_decoder_ctl(st->celt_dec, CELT_SET_END_BAND(20));
+ else
+ celt_decoder_ctl(st->celt_dec, CELT_SET_END_BAND(21));
/* Encode high band with CELT */
celt_ret = celt_decode_with_ec(st->celt_dec, data, len, pcm_celt, frame_size, &dec);
for (i=0;i<frame_size;i++)
diff --git a/src/hybrid_encoder.c b/src/hybrid_encoder.c
index 413f08b2..2acf3eb5 100644
--- a/src/hybrid_encoder.c
+++ b/src/hybrid_encoder.c
@@ -103,6 +103,14 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
if (st->Fs / frame_size == 100)
st->encControl.bitRate += 5000;
st->encControl.packetSize = frame_size;
+
+ if (st->bandwidth == BANDWIDTH_NARROWBAND)
+ st->encControl.maxInternalSampleRate = 8000;
+ else if (st->bandwidth == BANDWIDTH_MEDIUMBAND)
+ st->encControl.maxInternalSampleRate = 12000;
+ else
+ st->encControl.maxInternalSampleRate = 16000;
+
/* Call SILK encoder for the low band */
nBytes = bytes_per_packet;
ret = SKP_Silk_SDK_Encode( st->silk_enc, &st->encControl, pcm, frame_size, &enc, &nBytes );
@@ -121,10 +129,15 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
celt_encoder_ctl(st->celt_enc, CELT_SET_START_BAND(0));
}
- if (st->mode != MODE_SILK_ONLY)
+ if (st->mode != MODE_SILK_ONLY && st->bandwidth > BANDWIDTH_WIDEBAND)
{
short buf[960];
+ if (st->bandwidth == BANDWIDTH_SUPERWIDEBAND)
+ celt_encoder_ctl(st->celt_enc, CELT_SET_END_BAND(20));
+ else
+ celt_encoder_ctl(st->celt_enc, CELT_SET_END_BAND(21));
+
for (i=0;i<ENCODER_DELAY_COMPENSATION;i++)
buf[i] = st->delay_buffer[i];
for (;i<frame_size;i++)