From fce7cfee35468decc8246c410cfd100dc6df7d5a Mon Sep 17 00:00:00 2001 From: Piotr Gregor Date: Sat, 19 Mar 2016 23:28:35 +0000 Subject: [PATCH] FS-8960 Set buffer position to beginning on reset Now buffer position is reset to 0. --- src/mod/applications/mod_avmd/buffer.h | 7 ++++--- src/mod/applications/mod_avmd/mod_avmd.c | 26 ++++++------------------ src/mod/applications/mod_avmd/sma_buf.h | 5 ++++- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/mod/applications/mod_avmd/buffer.h b/src/mod/applications/mod_avmd/buffer.h index a92904ddbc..46d1c07d4c 100644 --- a/src/mod/applications/mod_avmd/buffer.h +++ b/src/mod/applications/mod_avmd/buffer.h @@ -92,13 +92,14 @@ extern size_t next_power_of_2(size_t v); //#define DESTROY_CIRC_BUFFER(b) free((b)->buf) #define GET_BACKLOG_POS(b) ((b)->lpos - (b)->backlog) -#define GET_CURRENT_POS(b) ((b)->lpos) -#define GET_CURRENT_SAMPLE(b) GET_SAMPLE((b), GET_CURRENT_POS((b))) +#define GET_CURRENT_POS(b) ((b)->pos) +#define GET_CURRENT_LPOS(b) ((b)->lpos) +#define GET_CURRENT_SAMPLE(b) GET_SAMPLE((b), GET_CURRENT_LPOS((b))) #define ADD_SAMPLE(b, s) \ do { \ INC_POS((b)); \ - SET_SAMPLE((b), GET_CURRENT_POS((b)), (s)); \ + SET_SAMPLE((b), GET_CURRENT_LPOS((b)), (s)); \ } while (0) #endif diff --git a/src/mod/applications/mod_avmd/mod_avmd.c b/src/mod/applications/mod_avmd/mod_avmd.c index ed1b676756..66a07264c1 100644 --- a/src/mod/applications/mod_avmd/mod_avmd.c +++ b/src/mod/applications/mod_avmd/mod_avmd.c @@ -25,22 +25,9 @@ * * This module detects voicemail beeps using a generalized approach. * - * Mofdifications: - * - * Piotr Gregor - * FS-8808 : code refactor - * FS-8809 : fix MAP_POPULATE undeclared - * FS-8810 : fix float-int-float fast arc cosine - * mapping construction (reuse) - * FS-8852 : use predefined table length instead - * of hardcoded computation - * FS-8853 : enable change of resolution (and size) - * of fast arc cos table - * FS-8854 : initialize circular buffer - * FS-8855 : fix APPEND_SMA_VAL macro and avmd_process - * callback so that the variance of tone's - * frequency estimation is correctly - * calculated + * Modifications: + * Piotr Gregor : + * FS-8808, FS-8809, FS-8810, FS-8852, FS-8853, FS-8854, FS-8855 */ #include @@ -91,7 +78,7 @@ /*! Maximum frequency as digital normalized frequency */ #define MAX_FREQUENCY_R(r) ((2.0 * M_PI * MAX_FREQUENCY) / (r)) /* decrease this value to eliminate false positives */ -#define VARIANCE_THRESHOLD (0.001) +#define VARIANCE_THRESHOLD (0.0001) #include "amplitude.h" #include "buffer.h" @@ -233,7 +220,7 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, sw /*! \brief FreeSWITCH module loading function. * * @author Eric des Courtis - * @par Changes: Piotr Gregor, 07 Feb 2016 (FS-8809, FS-8810) + * @par Modifications: Piotr Gregor * @return On success SWITCH_STATUS_SUCCES, * on failure SWITCH_STATUS_TERM. */ @@ -587,8 +574,7 @@ end: /*! \brief Process one frame of data with avmd algorithm. * @author Eric des Courtis - * @par Modifications: Piotr Gregor (FS-8852, FS-8853, FS-8854, FS-8855) - * (improved variance estimation calculation) + * @par Modifications: Piotr Gregor * @param session An avmd session. * @param frame An audio frame. */ diff --git a/src/mod/applications/mod_avmd/sma_buf.h b/src/mod/applications/mod_avmd/sma_buf.h index 0bbdc3e1f4..55a50719d4 100644 --- a/src/mod/applications/mod_avmd/sma_buf.h +++ b/src/mod/applications/mod_avmd/sma_buf.h @@ -31,7 +31,8 @@ typedef struct { #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 GET_CURRENT_SMA_POS(b) ((b)->pos) +#define GET_CURRENT_SMA_LPOS(b) ((b)->lpos) #define INC_SMA_POS(b) \ { \ @@ -52,6 +53,8 @@ typedef struct { { \ (b)->sma = 0.0; \ (void)memset((b)->data, 0, sizeof(BUFF_TYPE) * (b)->len); \ + (b)->pos = 0; \ + (b)->lpos = 0; \ } /*