diff options
author | Jean-Marc Valin <jean-marc.valin@usherbrooke.ca> | 2011-01-31 07:44:51 +0300 |
---|---|---|
committer | Jean-Marc Valin <jean-marc.valin@usherbrooke.ca> | 2011-01-31 07:44:51 +0300 |
commit | e6f53b730328093831f992f1bac78cdb2e266ded (patch) | |
tree | b28d44cf9890998fdfc0a5d41a60ffdde53703aa | |
parent | 3c8bd3ffc7342089c74a7386ae9785c473cff5fc (diff) |
Updated to CELT's new API
m--------- | celt | 10 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/opus_decoder.c | 34 | ||||
-rw-r--r-- | src/opus_decoder.h | 1 | ||||
-rw-r--r-- | src/opus_encoder.c | 45 | ||||
-rw-r--r-- | src/opus_encoder.h | 1 |
6 files changed, 53 insertions, 40 deletions
diff --git a/celt b/celt -Subproject 620e716b764eb643e0a376f64f55448ad9447eb +Subproject 8cf29f0991bea7460adbd90fd39d95328b9a306 diff --git a/configure.ac b/configure.ac index 950609ab..8dc2c1d8 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.59]) AC_INIT(src/opus.h) -AM_INIT_AUTOMAKE(opus,20101113) +AM_INIT_AUTOMAKE(opus,20110122) # Checks for programs. AC_PROG_CC diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 3db3dcba..d15c9768 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -46,25 +46,20 @@ OpusDecoder *opus_decoder_create(int Fs) { char *raw_state; int ret, silkDecSizeBytes, celtDecSizeBytes; - CELTMode *celtMode; OpusDecoder *st; - /* We should not have to create a CELT mode for each encoder state */ - celtMode = celt_mode_create(Fs, Fs/50, NULL); - /* Initialize SILK encoder */ ret = SKP_Silk_SDK_Get_Decoder_Size( &silkDecSizeBytes ); if( ret ) { /* Handle error */ } - celtDecSizeBytes = celt_decoder_get_size(celtMode, 1); + celtDecSizeBytes = celt_decoder_get_size(1); raw_state = calloc(sizeof(OpusDecoder)+silkDecSizeBytes+celtDecSizeBytes, 1); st = (OpusDecoder*)raw_state; st->silk_dec = (void*)(raw_state+sizeof(OpusDecoder)); st->celt_dec = (CELTDecoder*)(raw_state+sizeof(OpusDecoder)+silkDecSizeBytes); st->Fs = Fs; - st->celt_mode = celtMode; /* Reset decoder */ ret = SKP_Silk_SDK_InitDecoder( st->silk_dec ); @@ -73,7 +68,7 @@ OpusDecoder *opus_decoder_create(int Fs) } /* Initialize CELT decoder */ - st->celt_dec = celt_decoder_init(st->celt_dec, st->celt_mode, 1, NULL); + st->celt_dec = celt_decoder_init(st->celt_dec, 48000, 1, NULL); return st; @@ -166,10 +161,25 @@ int opus_decode(OpusDecoder *st, const unsigned char *data, 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)); + int endband; + + switch(st->bandwidth) + { + case BANDWIDTH_NARROWBAND: + endband = 13; + break; + case BANDWIDTH_WIDEBAND: + endband = 17; + break; + case BANDWIDTH_SUPERWIDEBAND: + endband = 19; + break; + case BANDWIDTH_FULLBAND: + endband = 21; + break; + } + celt_decoder_ctl(st->celt_dec, CELT_SET_END_BAND(endband)); + /* 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++) @@ -221,7 +231,5 @@ void opus_decoder_ctl(OpusDecoder *st, int request, ...) void opus_decoder_destroy(OpusDecoder *st) { - celt_mode_destroy(st->celt_mode); - free(st); } diff --git a/src/opus_decoder.h b/src/opus_decoder.h index 9bb81061..c7a3be6b 100644 --- a/src/opus_decoder.h +++ b/src/opus_decoder.h @@ -36,7 +36,6 @@ #include "opus.h" struct OpusDecoder { - CELTMode *celt_mode; CELTDecoder *celt_dec; void *silk_dec; diff --git a/src/opus_encoder.c b/src/opus_encoder.c index f66b189b..7de1b21c 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -44,27 +44,22 @@ OpusEncoder *opus_encoder_create(int Fs) { char *raw_state; - CELTMode *celtMode; OpusEncoder *st; int ret, silkEncSizeBytes, celtEncSizeBytes; SKP_SILK_SDK_EncControlStruct encControl; - /* We should not have to create a CELT mode for each encoder state */ - celtMode = celt_mode_create(Fs, Fs/50, NULL); - /* Create SILK encoder */ ret = SKP_Silk_SDK_Get_Encoder_Size( &silkEncSizeBytes ); if( ret ) { /* Handle error */ } - celtEncSizeBytes = celt_encoder_get_size(celtMode, 1); + celtEncSizeBytes = celt_encoder_get_size(1); raw_state = calloc(sizeof(OpusEncoder)+silkEncSizeBytes+celtEncSizeBytes, 1); st = (OpusEncoder*)raw_state; st->silk_enc = (void*)(raw_state+sizeof(OpusEncoder)); st->celt_enc = (CELTEncoder*)(raw_state+sizeof(OpusEncoder)+silkEncSizeBytes); st->Fs = Fs; - st->celt_mode = celtMode; /*encControl.API_sampleRate = st->Fs; encControl.packetLossPercentage = 0; @@ -78,7 +73,7 @@ OpusEncoder *opus_encoder_create(int Fs) /* Create CELT encoder */ /* Initialize CELT encoder */ - st->celt_enc = celt_encoder_init(st->celt_enc, st->celt_mode, 1, NULL); + st->celt_enc = celt_encoder_init(st->celt_enc, Fs, 1, NULL); st->mode = MODE_HYBRID; st->bandwidth = BANDWIDTH_FULLBAND; @@ -119,19 +114,19 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, if (st->Fs == 100 * frame_size) encControl.bitRate -= 5000; } - encControl.payloadSize_ms = 1000 * frame_size / st->Fs; + encControl.payloadSize_ms = 1000 * frame_size / st->Fs; - if (st->mode == MODE_HYBRID) - encControl.minInternalSampleRate = 16000; - else - encControl.minInternalSampleRate = 8000; + if (st->mode == MODE_HYBRID) + encControl.minInternalSampleRate = 16000; + else + encControl.minInternalSampleRate = 8000; if (st->bandwidth == BANDWIDTH_NARROWBAND) encControl.maxInternalSampleRate = 8000; else if (st->bandwidth == BANDWIDTH_MEDIUMBAND) - encControl.maxInternalSampleRate = 12000; + encControl.maxInternalSampleRate = 12000; else - encControl.maxInternalSampleRate = 16000; + encControl.maxInternalSampleRate = 16000; /* Call SILK encoder for the low band */ nBytes = bytes_per_packet; @@ -153,12 +148,25 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, if (st->mode != MODE_SILK_ONLY && st->bandwidth > BANDWIDTH_WIDEBAND) { + int endband; short pcm_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)); + switch(st->bandwidth) + { + case BANDWIDTH_NARROWBAND: + endband = 13; + break; + case BANDWIDTH_WIDEBAND: + endband = 17; + break; + case BANDWIDTH_SUPERWIDEBAND: + endband = 19; + break; + case BANDWIDTH_FULLBAND: + endband = 21; + break; + } + celt_encoder_ctl(st->celt_enc, CELT_SET_END_BAND(endband)); for (i=0;i<ENCODER_DELAY_COMPENSATION;i++) pcm_buf[i] = st->delay_buffer[i]; @@ -269,7 +277,6 @@ void opus_encoder_ctl(OpusEncoder *st, int request, ...) void opus_encoder_destroy(OpusEncoder *st) { - celt_mode_destroy(st->celt_mode); free(st); } diff --git a/src/opus_encoder.h b/src/opus_encoder.h index 8c952abb..37d43700 100644 --- a/src/opus_encoder.h +++ b/src/opus_encoder.h @@ -40,7 +40,6 @@ #define ENCODER_DELAY_COMPENSATION 130 struct OpusEncoder { - CELTMode *celt_mode; CELTEncoder *celt_enc; void *silk_enc; |