Skip to content
Snippets Groups Projects
Commit e2d1ef1f authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Delay compensation, disabling the CELT pitch predictor

parent 24f36e0a
No related branches found
No related tags found
No related merge requests found
......@@ -46,7 +46,7 @@ HybridEncoder *hybrid_encoder_create()
HybridEncoder *st;
int ret, encSizeBytes;
st = malloc(sizeof(HybridEncoder));
st = calloc(sizeof(HybridEncoder), 1);
/* Create SILK encoder */
ret = SKP_Silk_SDK_Get_Encoder_Size( &encSizeBytes );
......@@ -77,6 +77,7 @@ HybridEncoder *hybrid_encoder_create()
st->mode = MODE_HYBRID;
st->bandwidth = BANDWIDTH_FULLBAND;
st->vbr_rate = 0;
return st;
}
......@@ -84,6 +85,7 @@ HybridEncoder *hybrid_encoder_create()
int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
unsigned char *data, int bytes_per_packet)
{
int i;
int ret=0;
SKP_int16 nBytes;
ec_enc enc;
......@@ -94,7 +96,7 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
if (st->mode != MODE_CELT_ONLY)
{
st->encControl.bitRate = (bytes_per_packet*50*8+4000)/2;
st->encControl.bitRate = (bytes_per_packet*50*8+6000)/2;
/* Call SILK encoder for the low band */
nBytes = bytes_per_packet;
ret = SKP_Silk_SDK_Encode( st->silk_enc, &st->encControl, pcm, 960, &enc, &nBytes );
......@@ -115,9 +117,19 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
if (st->mode != MODE_SILK_ONLY)
{
short buf[960];
for (i=0;i<ENCODER_DELAY_COMPENSATION;i++)
buf[i] = st->delay_buffer[i];
for (;i<960;i++)
buf[i] = pcm[i-ENCODER_DELAY_COMPENSATION];
celt_encoder_ctl(st->celt_enc, CELT_SET_PREDICTION(1));
/* Encode high band with CELT */
/* FIXME: Do some delay compensation here */
ret = celt_encode_with_ec(st->celt_enc, pcm, NULL, frame_size, data, bytes_per_packet, &enc);
ret = celt_encode_with_ec(st->celt_enc, buf, NULL, frame_size, data, bytes_per_packet, &enc);
for (i=0;i<ENCODER_DELAY_COMPENSATION;i++)
st->delay_buffer[i] = pcm[960-ENCODER_DELAY_COMPENSATION+i];
} else {
ec_enc_done(&enc);
}
......
......@@ -36,6 +36,9 @@
#include "hybrid.h"
#include "SKP_Silk_SDK_API.h"
/* FIXME: This is only valid for 48 kHz */
#define ENCODER_DELAY_COMPENSATION 130
struct HybridEncoder {
CELTMode *celt_mode;
CELTEncoder *celt_enc;
......@@ -45,6 +48,8 @@ struct HybridEncoder {
int mode;
int bandwidth;
int vbr_rate;
short delay_buffer[ENCODER_DELAY_COMPENSATION];
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment