forked from ytxyt/silk-v3-decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
166 changed files
with
31,049 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash -e | ||
# File: convert2mp3.sh | ||
# Date: February 8th, 2016 | ||
# Time: 01:06:23 +0800 | ||
# Author: kn007 <kn007@126.com> | ||
# Blog: https://kn007.net | ||
# Usage: sh convert2mp3.sh silk_v3_file output_format | ||
# Requirement: gcc ffmpeg | ||
|
||
cur_dir=$(cd `dirname $0`; pwd) | ||
|
||
if [ ! -r "$cur_dir/silk/decoder" ] ; then | ||
echo 'Silk v3 Decoder is not found, compile it.' | ||
cd $cur_dir/silk | ||
make && make decoder | ||
echo '========= Compile Finish =========' | ||
fi | ||
|
||
cd $cur_dir | ||
$cur_dir/silk/decoder $1 $1.pcm | ||
ffmpeg -f s16le -ar 24000 -ac 1 -i $1.pcm $1.$2 | ||
rm $1.pcm | ||
echo "Convert $1 To $1.$2 Finish." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# | ||
# Makefile for Silk SDK | ||
# | ||
# Copyright (c) 2012, Skype Limited | ||
# All rights reserved. | ||
# | ||
|
||
#Platform detection and settings | ||
|
||
BUILD_OS := $(shell uname | sed -e 's/^.*Darwin.*/MacOS-X/ ; s/^.*CYGWIN.*/Windows/') | ||
|
||
BUILD_ARCHITECTURE := $(shell uname -m | sed -e 's/i686/i386/') | ||
|
||
EXESUFFIX = | ||
LIBPREFIX = lib | ||
LIBSUFFIX = .a | ||
OBJSUFFIX = .o | ||
|
||
CC = $(TOOLCHAIN_PREFIX)gcc$(TOOLCHAIN_SUFFIX) | ||
CXX = $(TOOLCHAIN_PREFIX)g++$(TOOLCHAIN_SUFFIX) | ||
AR = $(TOOLCHAIN_PREFIX)ar | ||
RANLIB = $(TOOLCHAIN_PREFIX)ranlib | ||
CP = $(TOOLCHAIN_PREFIX)cp | ||
|
||
cppflags-from-defines = $(addprefix -D,$(1)) | ||
cppflags-from-includes = $(addprefix -I,$(1)) | ||
ldflags-from-ldlibdirs = $(addprefix -L,$(1)) | ||
ldlibs-from-libs = $(addprefix -l,$(1)) | ||
|
||
ifneq (,$(TARGET_CPU)) | ||
CFLAGS += -mcpu=$(TARGET_CPU) | ||
ifneq (,$(TARGET_TUNE)) | ||
CFLAGS += -mtune=$(TARGET_TUNE) | ||
else | ||
CFLAGS += -mtune=$(TARGET_CPU) | ||
endif | ||
endif | ||
ifneq (,$(TARGET_FPU)) | ||
CFLAGS += -mfpu=$(TARGET_FPU) | ||
endif | ||
ifneq (,$(TARGET_ARCH)) | ||
CFLAGS += -march=$(TARGET_ARCH) | ||
endif | ||
# Helper to make NEON testing easier, when using USE_NEON=yes do not set TARGET_CPU or TARGET_FPU | ||
ifeq (yes,$(USE_NEON)) | ||
CFLAGS += -mcpu=cortex-a8 -mfloat-abi=softfp -mfpu=neon | ||
endif | ||
|
||
|
||
CFLAGS += -Wall -enable-threads -O3 | ||
|
||
CFLAGS += $(call cppflags-from-defines,$(CDEFINES)) | ||
CFLAGS += $(call cppflags-from-defines,$(ADDED_DEFINES)) | ||
CFLAGS += $(call cppflags-from-includes,$(CINCLUDES)) | ||
LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS)) | ||
LDLIBS += $(call ldlibs-from-libs,$(LIBS)) | ||
|
||
COMPILE.c.cmdline = $(CC) -c $(CFLAGS) $(ADDED_CFLAGS) -o $@ $< | ||
COMPILE.S.cmdline = $(CC) -c $(CFLAGS) $(ADDED_CFLAGS) -o $@ $< | ||
COMPILE.cpp.cmdline = $(CXX) -c $(CFLAGS) $(ADDED_CFLAGS) -o $@ $< | ||
LINK.o = $(CXX) $(LDPREFLAGS) $(LDFLAGS) | ||
LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX) | ||
ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@ | ||
|
||
%$(OBJSUFFIX):%.c | ||
$(COMPILE.c.cmdline) | ||
|
||
%$(OBJSUFFIX):%.cpp | ||
$(COMPILE.cpp.cmdline) | ||
|
||
%$(OBJSUFFIX):%.S | ||
$(COMPILE.S.cmdline) | ||
|
||
# Directives | ||
|
||
CINCLUDES += interface src test | ||
|
||
# VPATH e.g. VPATH = src:../headers | ||
VPATH = ./ \ | ||
interface \ | ||
src \ | ||
test | ||
|
||
# Variable definitions | ||
LIB_NAME = SKP_SILK_SDK | ||
TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX) | ||
|
||
SRCS_C = $(wildcard src/*.c) | ||
ifneq (,$(TOOLCHAIN_PREFIX)) | ||
SRCS_S = $(wildcard src/*.S) | ||
OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) $(patsubst %.S,%$(OBJSUFFIX),$(SRCS_S)) | ||
else | ||
OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) | ||
endif | ||
|
||
ENCODER_SRCS_C = test/Encoder.c | ||
ENCODER_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(ENCODER_SRCS_C)) | ||
|
||
DECODER_SRCS_C = test/Decoder.c | ||
DECODER_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(DECODER_SRCS_C)) | ||
|
||
SIGNALCMP_SRCS_C = test/signalCompare.c | ||
SIGNALCMP_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SIGNALCMP_SRCS_C)) | ||
|
||
LIBS = \ | ||
$(LIB_NAME) | ||
|
||
LDLIBDIRS = ./ | ||
|
||
# Rules | ||
default: all | ||
|
||
all: $(TARGET) decoder | ||
|
||
lib: $(TARGET) | ||
|
||
$(TARGET): $(OBJS) | ||
$(ARCHIVE.cmdline) | ||
|
||
encoder$(EXESUFFIX): $(ENCODER_OBJS) | ||
$(LINK.o.cmdline) | ||
|
||
decoder$(EXESUFFIX): $(DECODER_OBJS) | ||
$(LINK.o.cmdline) | ||
|
||
signalcompare$(EXESUFFIX): $(SIGNALCMP_OBJS) | ||
$(LINK.o.cmdline) | ||
|
||
clean: | ||
$(RM) $(TARGET)* $(OBJS) $(ENCODER_OBJS) $(DECODER_OBJS) \ | ||
$(SIGNALCMP_OBJS) $(TEST_OBJS) \ | ||
encoder$(EXESUFFIX) decoder$(EXESUFFIX) signalcompare$(EXESUFFIX) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/*********************************************************************** | ||
Copyright (c) 2006-2012, Skype Limited. All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, (subject to the limitations in the disclaimer below) | ||
are permitted provided that the following conditions are met: | ||
- Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
- Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
- Neither the name of Skype Limited, nor the names of specific | ||
contributors, may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED | ||
BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | ||
CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
***********************************************************************/ | ||
|
||
#ifndef SKP_SILK_SDK_API_H | ||
#define SKP_SILK_SDK_API_H | ||
|
||
#include "SKP_Silk_control.h" | ||
#include "SKP_Silk_typedef.h" | ||
#include "SKP_Silk_errors.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#define SILK_MAX_FRAMES_PER_PACKET 5 | ||
|
||
/* Struct for TOC (Table of Contents) */ | ||
typedef struct { | ||
SKP_int framesInPacket; /* Number of 20 ms frames in packet */ | ||
SKP_int fs_kHz; /* Sampling frequency in packet */ | ||
SKP_int inbandLBRR; /* Does packet contain LBRR information */ | ||
SKP_int corrupt; /* Packet is corrupt */ | ||
SKP_int vadFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* VAD flag for each frame in packet */ | ||
SKP_int sigtypeFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Signal type for each frame in packet */ | ||
} SKP_Silk_TOC_struct; | ||
|
||
/****************************************/ | ||
/* Encoder functions */ | ||
/****************************************/ | ||
|
||
/***********************************************/ | ||
/* Get size in bytes of the Silk encoder state */ | ||
/***********************************************/ | ||
SKP_int SKP_Silk_SDK_Get_Encoder_Size( | ||
SKP_int32 *encSizeBytes /* O: Number of bytes in SILK encoder state */ | ||
); | ||
|
||
/*************************/ | ||
/* Init or reset encoder */ | ||
/*************************/ | ||
SKP_int SKP_Silk_SDK_InitEncoder( | ||
void *encState, /* I/O: State */ | ||
SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */ | ||
); | ||
|
||
/***************************************/ | ||
/* Read control structure from encoder */ | ||
/***************************************/ | ||
SKP_int SKP_Silk_SDK_QueryEncoder( | ||
const void *encState, /* I: State */ | ||
SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */ | ||
); | ||
|
||
/**************************/ | ||
/* Encode frame with Silk */ | ||
/**************************/ | ||
SKP_int SKP_Silk_SDK_Encode( | ||
void *encState, /* I/O: State */ | ||
const SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control status */ | ||
const SKP_int16 *samplesIn, /* I: Speech sample input vector */ | ||
SKP_int nSamplesIn, /* I: Number of samples in input vector */ | ||
SKP_uint8 *outData, /* O: Encoded output vector */ | ||
SKP_int16 *nBytesOut /* I/O: Number of bytes in outData (input: Max bytes) */ | ||
); | ||
|
||
/****************************************/ | ||
/* Decoder functions */ | ||
/****************************************/ | ||
|
||
/***********************************************/ | ||
/* Get size in bytes of the Silk decoder state */ | ||
/***********************************************/ | ||
SKP_int SKP_Silk_SDK_Get_Decoder_Size( | ||
SKP_int32 *decSizeBytes /* O: Number of bytes in SILK decoder state */ | ||
); | ||
|
||
/*************************/ | ||
/* Init or Reset decoder */ | ||
/*************************/ | ||
SKP_int SKP_Silk_SDK_InitDecoder( | ||
void *decState /* I/O: State */ | ||
); | ||
|
||
/******************/ | ||
/* Decode a frame */ | ||
/******************/ | ||
SKP_int SKP_Silk_SDK_Decode( | ||
void* decState, /* I/O: State */ | ||
SKP_SILK_SDK_DecControlStruct* decControl, /* I/O: Control Structure */ | ||
SKP_int lostFlag, /* I: 0: no loss, 1 loss */ | ||
const SKP_uint8 *inData, /* I: Encoded input vector */ | ||
const SKP_int nBytesIn, /* I: Number of input bytes */ | ||
SKP_int16 *samplesOut, /* O: Decoded output speech vector */ | ||
SKP_int16 *nSamplesOut /* I/O: Number of samples (vector/decoded) */ | ||
); | ||
|
||
/***************************************************************/ | ||
/* Find Low Bit Rate Redundancy (LBRR) information in a packet */ | ||
/***************************************************************/ | ||
void SKP_Silk_SDK_search_for_LBRR( | ||
const SKP_uint8 *inData, /* I: Encoded input vector */ | ||
const SKP_int nBytesIn, /* I: Number of input Bytes */ | ||
SKP_int lost_offset, /* I: Offset from lost packet */ | ||
SKP_uint8 *LBRRData, /* O: LBRR payload */ | ||
SKP_int16 *nLBRRBytes /* O: Number of LBRR Bytes */ | ||
); | ||
|
||
/**************************************/ | ||
/* Get table of contents for a packet */ | ||
/**************************************/ | ||
void SKP_Silk_SDK_get_TOC( | ||
const SKP_uint8 *inData, /* I: Encoded input vector */ | ||
const SKP_int nBytesIn, /* I: Number of input bytes */ | ||
SKP_Silk_TOC_struct *Silk_TOC /* O: Table of contents */ | ||
); | ||
|
||
/**************************/ | ||
/* Get the version number */ | ||
/**************************/ | ||
/* Return a pointer to string specifying the version */ | ||
const char *SKP_Silk_SDK_get_version(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.