initial bits of ilbc codec mod.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@452 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris committed 2006-01-27 00:48:15 +00:00
1 parent 3bbfb94a22
commit 954fe31140
54 files changed
+467 -5

No files matched your search

+5 -5
View File
@@ -5,11 +5,11 @@ CFLAGS += -fPIC
endif
LIB=libilbc.a
OBJS= anaFilter.o iCBSearch.o packing.o \
constants.o gainquant.o iLBC_decode.o StateConstructW.o \
createCB.o getCBvec.o iLBC_encode.o StateSearchW.o doCPLC.o \
helpfun.o syntFilter.o enhancer.o hpInput.o LPCdecode.o \
filter.o hpOutput.o LPCencode.o FrameClassify.o iCBConstruct.o lsf.o
OBJS= src/anaFilter.o src/iCBSearch.o src/packing.o \
src/constants.o src/gainquant.o src/iLBC_decode.o src/StateConstructW.o \
src/createCB.o src/getCBvec.o src/iLBC_encode.o src/StateSearchW.o src/doCPLC.o \
src/helpfun.o src/syntFilter.o src/enhancer.o src/hpInput.o src/LPCdecode.o \
src/filter.o src/hpOutput.o src/LPCencode.o src/FrameClassify.o src/iCBConstruct.o src/lsf.o
all: $(LIB)
+25
View File
@@ -0,0 +1,25 @@
EXTRA_DIST =
SUBDIRS =
AUTOMAKE_OPTS= gnu
MAKE=gmake
NAME=libilbc
AM_CC=gcc
AM_CFLAGS = -Wall -O3 -funroll-loops
AM_CPPFLAGS = $(AM_CFLAGS)
lib_LTLIBRARIES = libilbc.la
libgsm_la_SOURCES = src/anaFilter.o src/iCBSearch.o src/packing.o \
src/constants.o src/gainquant.o src/iLBC_decode.o src/StateConstructW.o \
src/createCB.o src/getCBvec.o src/iLBC_encode.o src/StateSearchW.o src/doCPLC.o \
src/helpfun.o src/syntFilter.o src/enhancer.o src/hpInput.o src/LPCdecode.o \
src/filter.o src/hpOutput.o src/LPCencode.o src/FrameClassify.o src/iCBConstruct.o src/lsf.o
libgsm_la_CFLAGS = $(AM_CFLAGS)
libgsm_la_LDFLAGS =
+34
View File
@@ -0,0 +1,34 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AM_INIT_AUTOMAKE(libilbc,0.1)
AC_CONFIG_SRCDIR([src])
# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
AC_PROG_INSTALL
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
# Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MALLOC
AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+16
View File
@@ -0,0 +1,16 @@
LDFLAGS +=-lilbc
all: depends $(MODNAME).so
depends:
$(BASE)/buildlib.sh $(BASE) install codec/ilbc --prefix=$(PREFIX)
$(MODNAME).so: $(MODNAME).c
$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o
$(CC) $(SOLINK) $(MODNAME).o -o $(MODNAME).so $(LDFLAGS)
clean:
rm -fr *.so *.o *~
install:
cp -f $(MODNAME).so $(PREFIX)/mod
+175
View File
@@ -0,0 +1,175 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthmct@yahoo.com>
* Michael Jerris <mike@jerris.com>
*
* mod_codec_gsm.c -- gsm Codec Module
*
*/
#include "switch.h"
#include "gsm.h"
␍static const char modname[] = "mod_codec_gsm";
␍␍struct gsm_context {
␍gsm encoder;
␍gsm decoder;
␍};
␍␍static switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flags,
const struct switch_codec_settings *codec_settings)
{
␍struct gsm_context *context;
␍int encoding, decoding;
␍␍encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
␍decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
␍␍if (!(encoding || decoding)) {
␍return SWITCH_STATUS_FALSE;
␍} else {
␍context = switch_core_alloc(codec->memory_pool, sizeof(*context));
␍if (encoding)
context->encoder = gsm_create();
␍if (decoding)
context->decoder = gsm_create();
␍}
␍␍codec->private = context;
␍␍return SWITCH_STATUS_SUCCESS;
␍␍}
␍␍static switch_status switch_gsm_destroy(switch_codec *codec)
{
␍struct gsm_context *context = codec->private;
␍int encoding = (codec->flags & SWITCH_CODEC_FLAG_ENCODE);
␍int decoding = (codec->flags & SWITCH_CODEC_FLAG_DECODE);
␍␍if (encoding)
gsm_destroy(context->encoder);
␍if (decoding)
gsm_destroy(context->decoder);
␍␍codec->private = NULL;
␍return SWITCH_STATUS_SUCCESS;
␍}
␍␍␍static switch_status switch_gsm_encode(switch_codec *codec, ␍switch_codec *other_codec, ␍void *decoded_data,
␍size_t decoded_data_len, ␍int decoded_rate, ␍void *encoded_data,
␍size_t *encoded_data_len, ␍int *encoded_rate, ␍unsigned int *flag)
{
␍struct gsm_context *context = codec->private;
␍int cbret = 0;
␍␍if (!context) {
␍return SWITCH_STATUS_FALSE;
␍}
␍if (decoded_data_len % 320 == 0) {
␍unsigned int new_len = 0;
␍gsm_signal * ddp = decoded_data;
␍gsm_byte * edp = encoded_data;
␍int x;
␍int loops = (int) decoded_data_len / 320;
␍for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
␍gsm_encode(context->encoder, ddp, edp);
␍edp += 33;
␍ddp += 160;
␍new_len += 33;
␍}
␍if (new_len <= *encoded_data_len) {
␍*encoded_data_len = new_len;
␍} else {
␍switch_console_printf(SWITCH_CHANNEL_CONSOLE, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
␍return SWITCH_STATUS_FALSE;
␍}
␍}
␍␍return SWITCH_STATUS_SUCCESS;
␍}
␍␍␍static switch_status switch_gsm_decode(switch_codec *codec, ␍switch_codec *other_codec, ␍void *encoded_data,
␍size_t encoded_data_len, ␍int encoded_rate, ␍void *decoded_data,
␍size_t *decoded_data_len, ␍int *decoded_rate, ␍unsigned int *flag)
{
␍struct gsm_context *context = codec->private;
␍␍if (!context) {
␍return SWITCH_STATUS_FALSE;
␍}
␍␍␍if (encoded_data_len % 33 == 0) {
␍int loops = (int) encoded_data_len / 33;
␍gsm_byte * edp = encoded_data;
␍gsm_signal * ddp = decoded_data;
␍int x;
␍unsigned int new_len = 0;
␍for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
␍gsm_decode(context->decoder, edp, ddp);
␍ddp += 160;
␍edp += 33;
␍new_len += 320;
␍}
␍if (new_len <= *decoded_data_len) {
␍*decoded_data_len = new_len;
␍} else {
␍switch_console_printf(SWITCH_CHANNEL_CONSOLE, "buffer overflow!!!\n");
␍return SWITCH_STATUS_FALSE;
␍}
␍} else {
␍switch_console_printf(SWITCH_CHANNEL_CONSOLE, "yo this frame is an odd size [%d]\n", encoded_data_len);
␍}
␍␍return SWITCH_STATUS_SUCCESS;
␍}
␍
/* Registration */
␍static const switch_codec_implementation gsm_8k_implementation = {
/*.samples_per_second */ 8000,
/*.bits_per_second */ 13200,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 33,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_gsm_init,
/*.encode */ switch_gsm_encode,
/*.decode */ switch_gsm_decode,
/*.destroy */ switch_gsm_destroy,
};
␍␍static const switch_codec_interface gsm_codec_interface = {
/*.interface_name */ "gsm",
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 3,
/*.iananame */ "gsm",
/*.implementations */ &gsm_8k_implementation,
};
␍␍static switch_loadable_module_interface gsm_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &gsm_codec_interface,
/*.application_interface */ NULL
};
␍␍␍SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface,
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
*interface = &gsm_module_interface;
␍
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
␍}
␍␍␍␍␍
+212
View File
@@ -0,0 +1,212 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="mod_ilbc"
ProjectGUID="{4926323F-4EA8-4B7D-A3D3-65488725988F}"
RootNamespace="mod_ilbc"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_Codecilbc Debug"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\codec\ilbc\inc&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libilbc.lib FreeSwitchCore.lib"
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ilbc.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\..\libs\codec\ilbc\Debug;..\..\..\..\w32\vsnet\Debug"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/mod_ilbc.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/mod_ilbc.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_Codecilbc Release"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(InputDir)..\..\..\include&quot;;&quot;$(InputDir)..\..\..\..\libs\include&quot;;&quot;$(InputDir)..\..\..\..\libs\codec\ilbc\inc&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libilbc.lib FreeSwitchCore.lib"
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ilbc.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\..\libs\codec\ilbc\Release;..\..\..\..\w32\vsnet\Release"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="1"
ImportLibrary="$(OutDir)/mod_ilbc.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="mod_ilbc.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>