Moves all the delay compensation back into the encoder only
This commit is contained in:
Jean-Marc Valin 2011-03-02 15:43:31 -05:00
parent d3dc19ba3d
commit d41c028d69
4 changed files with 5 additions and 30 deletions

View file

@ -1,5 +1,5 @@
INCLUDES = -I$(top_srcdir)/celt/libcelt/ -I$(top_srcdir)/silk/interface -I$(top_srcdir)/silk/src_SigProc_FIX INCLUDES = -I$(top_srcdir)/celt/libcelt/ -I$(top_srcdir)/silk/interface
lib_LTLIBRARIES = libietfcodec.la lib_LTLIBRARIES = libietfcodec.la
libietfcodec_la_SOURCES = opus_decoder.c opus_encoder.c libietfcodec_la_SOURCES = opus_decoder.c opus_encoder.c

View file

@ -36,7 +36,7 @@
#include "entdec.h" #include "entdec.h"
#include "modes.h" #include "modes.h"
#include "SKP_Silk_SDK_API.h" #include "SKP_Silk_SDK_API.h"
#include "SKP_Silk_SigProc_FIX.h"
OpusDecoder *opus_decoder_create(int Fs, int channels) OpusDecoder *opus_decoder_create(int Fs, int channels)
{ {
@ -166,12 +166,6 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
DecControl.internalSampleRate = 16000; DecControl.internalSampleRate = 16000;
} }
if (transition)
{
/*SKP_Silk_resampler_state_struct state;
SKP_Silk_resampler_init( &state, st->Fs, 16000);
*/
}
lost_flag = data == NULL ? 1 : 2 * decode_fec; lost_flag = data == NULL ? 1 : 2 * decode_fec;
decoded_samples = 0; decoded_samples = 0;
do { do {
@ -225,23 +219,8 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
celt_decoder_ctl(st->celt_dec, CELT_RESET_STATE); celt_decoder_ctl(st->celt_dec, CELT_RESET_STATE);
/* Decode CELT */ /* Decode CELT */
celt_ret = celt_decode_with_ec(st->celt_dec, decode_fec?NULL:data, len, pcm_celt, frame_size, &dec); celt_ret = celt_decode_with_ec(st->celt_dec, decode_fec?NULL:data, len, pcm_celt, frame_size, &dec);
/* Mix and add resampler delay compensation to CELT */
for (i=0;i<DECODER_DELAY*st->channels;i++)
pcm[i] = ADD_SAT16(pcm[i], st->delay_buffer[i+(DECODER_BUFFER-DECODER_DELAY)*st->channels]);
for (;i<frame_size*st->channels;i++)
pcm[i] = ADD_SAT16(pcm[i], pcm_celt[i-DECODER_DELAY*st->channels]);
if (frame_size>DECODER_BUFFER)
{
for (i=0;i<DECODER_BUFFER*st->channels;i++)
st->delay_buffer[i] = pcm_celt[(frame_size-DECODER_BUFFER)*st->channels+i];
} else {
int tmp = DECODER_BUFFER-frame_size;
for (i=0;i<tmp*st->channels;i++)
st->delay_buffer[i] = st->delay_buffer[i+frame_size*st->channels];
for (i=0;i<frame_size*st->channels;i++) for (i=0;i<frame_size*st->channels;i++)
st->delay_buffer[tmp*st->channels+i] = pcm_celt[i]; pcm[i] = ADD_SAT16(pcm[i], pcm_celt[i]);
}
} }
if (transition) if (transition)

View file

@ -31,9 +31,6 @@
#include "celt.h" #include "celt.h"
#include "opus.h" #include "opus.h"
#define DECODER_DELAY 5
#define DECODER_BUFFER 120
struct OpusDecoder { struct OpusDecoder {
CELTDecoder *celt_dec; CELTDecoder *celt_dec;
void *silk_dec; void *silk_dec;
@ -45,7 +42,6 @@ struct OpusDecoder {
int Fs; int Fs;
int prev_mode; int prev_mode;
short delay_buffer[DECODER_BUFFER*2];
#ifdef OPUS_TEST_RANGE_CODER_STATE #ifdef OPUS_TEST_RANGE_CODER_STATE
int rangeFinal; int rangeFinal;
#endif #endif

View file

@ -33,7 +33,7 @@
#include "SKP_Silk_SDK_API.h" #include "SKP_Silk_SDK_API.h"
/* FIXME: This is only valid for 48 kHz */ /* FIXME: This is only valid for 48 kHz */
#define ENCODER_DELAY_COMPENSATION 125 #define ENCODER_DELAY_COMPENSATION 130
#define ENCODER_BUFFER 480 #define ENCODER_BUFFER 480
struct OpusEncoder { struct OpusEncoder {