add mod_avmd for win

This commit is contained in:
Jeff Lenk
2010-05-26 13:30:29 -05:00
parent e00d2af95e
commit df4bd93545
7 changed files with 408 additions and 27 deletions
+15 -8
View File
@@ -3,6 +3,13 @@
#include <stdlib.h>
#include <assert.h>
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#define BUFF_TYPE double
typedef struct {
@@ -18,20 +25,20 @@ typedef struct {
extern size_t next_power_of_2(size_t v);
#define INC_POS(b) \
do{ \
{ \
(b)->pos++; \
(b)->pos &= (b)->mask; \
(b)->lpos++; \
if((b)->backlog < (b)->buf_len) (b)->backlog++; \
}while(0)
}
#define DEC_POS(b) \
do{ \
{ \
(b)->pos--; \
(b)->pos &= (b)->mask; \
(b)->lpos--; \
if(((b)->backlog - 1) < (b)->backlog) (b)->backlog--; \
}while(0)
}
#define GET_SAMPLE(b, i) ((b)->buf[(i) & (b)->mask])
#define SET_SAMPLE(b, i, v) ((b)->buf[(i) & (b)->mask] = (v))
@@ -49,7 +56,7 @@ extern size_t next_power_of_2(size_t v);
}while(0)
#define INSERT_INT16_FRAME(b, f, l) \
do{ \
{ \
for((b)->i = 0; (b)->i < (l); (b)->i++){ \
SET_SAMPLE( \
(b), \
@@ -66,13 +73,13 @@ extern size_t next_power_of_2(size_t v);
(b)->pos &= (b)->mask; \
(b)->backlog += (l); \
if((b)->backlog > (b)->buf_len) (b)->backlog = (b)->buf_len; \
}while(0)
}
#define CALC_BUFF_LEN(fl, bl) (((fl) >= (bl))? next_power_of_2((fl) << 1): next_power_of_2((bl) << 1))
#define INIT_CIRC_BUFFER(bf, bl, fl) \
do{ \
{ \
(bf)->buf_len = CALC_BUFF_LEN((fl), (bl)); \
(bf)->mask = (bf)->buf_len - 1; \
(bf)->buf = (BUFF_TYPE *)calloc((bf)->buf_len, sizeof(BUFF_TYPE)); \
@@ -80,7 +87,7 @@ extern size_t next_power_of_2(size_t v);
(bf)->pos = 0; \
(bf)->lpos = 0; \
(bf)->backlog = 0; \
}while(0)
}
#define DESTROY_CIRC_BUFFER(b) free((b)->buf)
#define GET_BACKLOG_POS(b) ((b)->lpos - (b)->backlog)
@@ -1,14 +1,20 @@
#include <stdio.h>
#include <stdlib.h>
#ifndef _MSC_VER
#include <stdint.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifndef _MSC_VER
#include <sys/mman.h>
#endif
#include <assert.h>
#include <errno.h>
#include <math.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include "fast_acosf.h"
#include "options.h"
+7
View File
@@ -1,9 +1,16 @@
#ifndef __GOERTZEL_H__
#define __GOERTZEL_H__
#ifndef _MSC_VER
#include <stdint.h>
#endif
#include "buffer.h"
#if !defined(M_PI)
/* C99 systems may not define M_PI */
#define M_PI 3.14159265358979323846264338327
#endif
extern double goertzel(circ_buffer_t *b, size_t pos, double f, size_t num);
#endif
@@ -0,0 +1,339 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="mod_avmd"
ProjectGUID="{990BAA76-89D3-4E38-8479-C7B28784EFC8}"
RootNamespace="mod_avmd"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
ConfigurationType="2"
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
ConfigurationType="2"
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
ConfigurationType="2"
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Header Files"
>
<File
RelativePath=".\amplitude.h"
>
</File>
<File
RelativePath=".\buffer.h"
>
</File>
<File
RelativePath=".\desa2.h"
>
</File>
<File
RelativePath=".\fast_acosf.h"
>
</File>
<File
RelativePath=".\goertzel.h"
>
</File>
<File
RelativePath=".\options.h"
>
</File>
<File
RelativePath=".\psi.h"
>
</File>
<File
RelativePath=".\sma_buf.h"
>
</File>
</Filter>
<File
RelativePath=".\amplitude.c"
>
</File>
<File
RelativePath=".\buffer.c"
>
</File>
<File
RelativePath=".\desa2.c"
>
</File>
<File
RelativePath=".\fast_acosf.c"
>
</File>
<File
RelativePath=".\goertzel.c"
>
</File>
<File
RelativePath=".\mod_avmd.c"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
+6 -2
View File
@@ -535,8 +535,12 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
else if(s_rate >= 0.99 && avg_a > 0.04) valid = 1;
else if(s_rate == 1.00 && avg_a > 0.02) valid = 1;
if(valid) APPEND_SMA_VAL(&session->sma_b, s_rate * avg_a);
else APPEND_SMA_VAL(&session->sma_b, 0.0 );
if(valid) {
APPEND_SMA_VAL(&session->sma_b, s_rate * avg_a);
}
else {
APPEND_SMA_VAL(&session->sma_b, 0.0 );
}
/*! If sma is higher then 0 we have some kind of detection (increase this value to eliminate false positives ex: 0.01) */
if(session->sma_b.sma > 0.00){
+10 -8
View File
@@ -2,7 +2,9 @@
#define __SMA_BUFFER_H__
#include <stdio.h>
#include <stdlib.h>
#ifndef _MSC_VER
#include <stdint.h>
#endif
#include <string.h>
#include <assert.h>
#include "buffer.h"
@@ -16,7 +18,7 @@ typedef struct {
} sma_buffer_t;
#define INIT_SMA_BUFFER(b, l, s) \
do{ \
{ \
(void)memset((b), 0, sizeof(sma_buffer_t)); \
(b)->len = (l); \
(b)->data = (BUFF_TYPE *)switch_core_session_alloc((s), sizeof(BUFF_TYPE) * (l)); \
@@ -25,31 +27,31 @@ typedef struct {
(b)->sma = 0.0; \
(b)->pos = 0; \
(b)->lpos = 0; \
}while(0)
}
#define GET_SMA_SAMPLE(b, p) ((b)->data[(p) % (b)->len])
#define SET_SMA_SAMPLE(b, p, v) ((b)->data[(p) % (b)->len] = (v))
#define GET_CURRENT_SMA_POS(b) ((b)->lpos)
#define INC_SMA_POS(b) \
do { \
{ \
(b)->lpos++; \
(b)->pos = (b)->lpos % (b)->len; \
}while(0)
}
#define APPEND_SMA_VAL(b, v) \
do{ \
{ \
INC_SMA_POS(b); \
(b)->sma -= ((b)->data[(b)->pos] / (BUFF_TYPE)(b)->len); \
(b)->data[(b)->pos] = (v); \
(b)->sma += ((b)->data[(b)->pos] / (BUFF_TYPE)(b)->len); \
}while(0)
}
#define RESET_SMA_BUFFER(b) \
do{ \
{ \
(b)->sma = 0.0; \
(void)memset((b)->data, 0, sizeof(BUFF_TYPE) * (b)->len); \
}while(0)
}
/*
#define DESTROY_SMA_BUFFER(b) \