ref: c5ea074c028398eb0a2d51f39fddf0524e78d24a
parent: 05a2297f72980d2e95566ed16405832f43d1bb13
author: Jean-Marc Valin <[email protected]>
date: Mon Jul 5 07:11:54 EDT 2010
Added SILK encoder to the hybrid -- totally untested
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,2 +1,2 @@
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
--- a/src/hybrid_encoder.c
+++ b/src/hybrid_encoder.c
@@ -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 @@
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 @@
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 @@
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);
--- a/src/hybrid_encoder.h
+++ b/src/hybrid_encoder.h
@@ -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;
};