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

Added SILK encoder to the hybrid -- totally untested

parent 05a2297f
No related branches found
No related tags found
No related merge requests found
all:
gcc -DHAVE_CONFIG_H -I../celt -W -Wextra -Wall -O3 -g -I../ -I../celt/libcelt -L../celt/libcelt/.libs/ -o test_hybrid test_hybrid.c hybrid_decoder.c hybrid_encoder.c -lcelt0 -lm
gcc -DHAVE_CONFIG_H -I../celt -W -Wextra -Wall -O3 -g -I../ -I../celt/libcelt -L../celt/libcelt/.libs/ -o test_hybrid test_hybrid.c hybrid_decoder.c hybrid_encoder.c ../silk/test/SKP_debug.o ../silk/libSKP_SILK_SDK.a -lcelt0 -I../silk/interface -lm
......@@ -37,16 +37,37 @@
#include "hybrid_encoder.h"
#include "celt/libcelt/entenc.h"
#include "celt/libcelt/modes.h"
#include "SKP_Silk_SDK_API.h"
HybridEncoder *hybrid_encoder_create()
{
HybridEncoder *st;
int ret, encSizeBytes;
st = malloc(sizeof(HybridEncoder));
/* FIXME: Initialize SILK encoder here */
st->silk_enc = NULL;
/* Create SILK encoder */
ret = SKP_Silk_SDK_Get_Encoder_Size( &encSizeBytes );
if( ret ) {
/* Handle error */
}
st->silk_enc = malloc(encSizeBytes);
ret = SKP_Silk_SDK_InitEncoder( st->silk_enc, &st->encControl );
if( ret ) {
/* Handle error */
}
/* Set Encoder parameters */
st->encControl.API_sampleRate = 48000;
st->encControl.maxInternalSampleRate = 16000;
st->encControl.packetSize = 960;
st->encControl.packetLossPercentage = 0;
st->encControl.useInBandFEC = 0;
st->encControl.useDTX = 0;
st->encControl.complexity = 2;
st->encControl.bitRate = 20000;
/* Create CELT encoder */
/* We should not have to create a CELT mode for each encoder state */
st->celt_mode = celt_mode_create(48000, 960, NULL);
/* Initialize CELT encoder */
......@@ -58,7 +79,8 @@ HybridEncoder *hybrid_encoder_create()
int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
unsigned char *data, int bytes_per_packet)
{
int celt_ret;
int silk_ret, celt_ret;
SKP_int16 nBytes;
ec_enc enc;
ec_byte_buffer buf;
......@@ -66,6 +88,10 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
ec_enc_init(&enc,&buf);
/* FIXME: Call SILK encoder for the low band */
silk_ret = SKP_Silk_SDK_Encode( st->silk_enc, &st->encControl, pcm, 960, &enc, &nBytes );
if( silk_ret ) {
/* Handle error */
}
/* This should be adjusted based on the SILK bandwidth */
celt_encoder_ctl(st->celt_enc, CELT_SET_START_BAND(13));
......@@ -78,7 +104,7 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
void hybrid_encoder_destroy(HybridEncoder *st)
{
/* FIXME: Destroy SILK encoder state */
free(st->silk_enc);
celt_encoder_destroy(st->celt_enc);
celt_mode_destroy(st->celt_mode);
......
......@@ -34,11 +34,13 @@
#include "celt/libcelt/celt.h"
#include "hybrid.h"
#include "SKP_Silk_SDK_API.h"
struct HybridEncoder {
CELTMode *celt_mode;
CELTEncoder *celt_enc;
void *silk_enc;
SKP_SILK_SDK_EncControlStruct encControl;
};
......
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