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

SILK encoder control struct no longer part of the state

parent 67008d23
No related branches found
No related tags found
No related merge requests found
......@@ -45,9 +45,12 @@ HybridEncoder *hybrid_encoder_create(int Fs)
{
HybridEncoder *st;
int ret, encSizeBytes;
SKP_SILK_SDK_EncControlStruct encControl;
st = calloc(sizeof(HybridEncoder), 1);
st->Fs = Fs;
/* Create SILK encoder */
ret = SKP_Silk_SDK_Get_Encoder_Size( &encSizeBytes );
if( ret ) {
......@@ -55,23 +58,16 @@ HybridEncoder *hybrid_encoder_create(int Fs)
}
st->silk_enc = malloc(encSizeBytes);
ret = SKP_Silk_SDK_InitEncoder( st->silk_enc, &st->encControl );
/*encControl.API_sampleRate = st->Fs;
encControl.packetLossPercentage = 0;
encControl.useInBandFEC = 0;
encControl.useDTX = 0;
encControl.complexity = 2;*/
ret = SKP_Silk_SDK_InitEncoder( st->silk_enc, &encControl );
if( ret ) {
/* Handle error */
}
st->Fs = Fs;
/* Set Encoder parameters */
st->encControl.API_sampleRate = Fs;
st->encControl.maxInternalSampleRate = 16000;
st->encControl.packetSize = Fs/50;
st->encControl.packetLossPercentage = 0;
st->encControl.useInBandFEC = 0;
st->encControl.useDTX = 0;
st->encControl.complexity = 2;
st->encControl.bitRate = 18000;
/* Create CELT encoder */
/* We should not have to create a CELT mode for each encoder state */
st->celt_mode = celt_mode_create(Fs, Fs/50, NULL);
......@@ -93,27 +89,35 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
SKP_int16 nBytes;
ec_enc enc;
ec_byte_buffer buf;
SKP_SILK_SDK_EncControlStruct encControl;
ec_byte_writeinit_buffer(&buf, data, bytes_per_packet);
ec_enc_init(&enc,&buf);
if (st->mode != MODE_CELT_ONLY)
{
st->encControl.bitRate = (bytes_per_packet*50*8+6000)/2;
/* Set Encoder parameters */
encControl.API_sampleRate = st->Fs;
encControl.packetLossPercentage = 0;
encControl.useInBandFEC = 0;
encControl.useDTX = 0;
encControl.complexity = 2;
encControl.bitRate = (bytes_per_packet*50*8+6000)/2;
if (st->Fs / frame_size == 100)
st->encControl.bitRate += 5000;
st->encControl.packetSize = frame_size;
encControl.bitRate += 5000;
encControl.packetSize = frame_size;
if (st->bandwidth == BANDWIDTH_NARROWBAND)
st->encControl.maxInternalSampleRate = 8000;
encControl.maxInternalSampleRate = 8000;
else if (st->bandwidth == BANDWIDTH_MEDIUMBAND)
st->encControl.maxInternalSampleRate = 12000;
encControl.maxInternalSampleRate = 12000;
else
st->encControl.maxInternalSampleRate = 16000;
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 );
ret = SKP_Silk_SDK_Encode( st->silk_enc, &encControl, pcm, frame_size, &enc, &nBytes );
if( ret ) {
fprintf (stderr, "SILK encode error\n");
/* Handle error */
......
......@@ -43,7 +43,6 @@ struct HybridEncoder {
CELTMode *celt_mode;
CELTEncoder *celt_enc;
void *silk_enc;
SKP_SILK_SDK_EncControlStruct encControl;
int mode;
int bandwidth;
......
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