From 92a945abe63a2579c66257696ddda848ab5a3ea0 Mon Sep 17 00:00:00 2001 From: markster Date: Thu, 14 Oct 2004 05:15:48 +0000 Subject: Update to new iLBC codec git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3997 f38db490-d61c-443f-a65b-d21fe96a405b --- codecs/ilbc/createCB.c | 423 +++++++++++++++++++++++++------------------------ 1 file changed, 215 insertions(+), 208 deletions(-) (limited to 'codecs/ilbc/createCB.c') diff --git a/codecs/ilbc/createCB.c b/codecs/ilbc/createCB.c index 4d95b7513..b3b0c2b0f 100755 --- a/codecs/ilbc/createCB.c +++ b/codecs/ilbc/createCB.c @@ -1,208 +1,215 @@ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - createCB.c - - Copyright (c) 2001, - Global IP Sound AB. - All rights reserved. - -******************************************************************/ - -#include "iLBC_define.h" -#include "constants.h" -#include "createCB.h" -#include -#include - -/*----------------------------------------------------------------* - * Construct an additional codebook vector by filtering the - * initial codebook buffer. This vector is then used to expand - * the codebook with an additional section. - *---------------------------------------------------------------*/ - -void filteredCBvecs( - float *cbvectors, /* (o) Codebook vectors for the higher -section */ - float *mem, /* (i) Buffer to create codebook vector from -*/ - int lMem /* (i) Length of buffer */ -){ - int j, k; - float *pp, *pp1; - float tempbuff2[CB_MEML+CB_FILTERLEN]; - float *pos; - - memset(tempbuff2, 0, (CB_HALFFILTERLEN-1)*sizeof(float)); - memcpy(&tempbuff2[CB_HALFFILTERLEN-1], mem, lMem*sizeof(float)); - memset(&tempbuff2[lMem+CB_HALFFILTERLEN-1], 0, - (CB_HALFFILTERLEN+1)*sizeof(float)); - - /* Create codebook vector for higher section by filtering */ - - /* do filtering */ - pos=cbvectors; - memset(pos, 0, lMem*sizeof(float)); - for (k=0; k0.0) { - invenergy[tmpIndex]=(float)1.0/(energy[tmpIndex]+EPS); - } else { - invenergy[tmpIndex] = (float) 0.0; - } - - if (stage==0) { - measure = (float)-10000000.0; - - if (crossDot > 0.0) { - measure = crossDot*crossDot*invenergy[tmpIndex]; - } - } - else { - measure = crossDot*crossDot*invenergy[tmpIndex]; - } - - /* check if measure is better */ - ftmp = crossDot*invenergy[tmpIndex]; - - if ((measure>*max_measure) && (fabs(ftmp) +#include + +/*----------------------------------------------------------------* + * Construct an additional codebook vector by filtering the + * initial codebook buffer. This vector is then used to expand + * the codebook with an additional section. + *---------------------------------------------------------------*/ + +void filteredCBvecs( + float *cbvectors, /* (o) Codebook vectors for the + higher section */ + float *mem, /* (i) Buffer to create codebook + vector from */ + int lMem /* (i) Length of buffer */ +){ + int j, k; + float *pp, *pp1; + float tempbuff2[CB_MEML+CB_FILTERLEN]; + float *pos; + + memset(tempbuff2, 0, (CB_HALFFILTERLEN-1)*sizeof(float)); + memcpy(&tempbuff2[CB_HALFFILTERLEN-1], mem, lMem*sizeof(float)); + memset(&tempbuff2[lMem+CB_HALFFILTERLEN-1], 0, + (CB_HALFFILTERLEN+1)*sizeof(float)); + + /* Create codebook vector for higher section by filtering */ + + /* do filtering */ + pos=cbvectors; + memset(pos, 0, lMem*sizeof(float)); + for (k=0; k0.0) { + invenergy[tmpIndex]=(float)1.0/(energy[tmpIndex]+EPS); + } else { + invenergy[tmpIndex] = (float) 0.0; + } + + if (stage==0) { + measure = (float)-10000000.0; + + if (crossDot > 0.0) { + measure = crossDot*crossDot*invenergy[tmpIndex]; + } + } + else { + measure = crossDot*crossDot*invenergy[tmpIndex]; + } + + /* check if measure is better */ + ftmp = crossDot*invenergy[tmpIndex]; + + if ((measure>*max_measure) && (fabs(ftmp)