valgrind fixes, thanks Torok
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 22 Sep 2010 07:04:58 +0000 (07:04 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 22 Sep 2010 07:04:58 +0000 (07:04 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@194 01035d8c-6547-0410-b346-abe4f91aad63

codec2/src/Makefile
codec2/src/c2sim.c
codec2/src/codec2.c

index f192954cf67e6c44344d86d4f5e314c5ae73f374..66af79f456ae894a5c271f8837037e1cd22f275e 100644 (file)
@@ -1,5 +1,5 @@
 CC=gcc
-CFLAGS=-g -Wall -I. -I../src -Wall -g -DFLOATING_POINT -DVAR_ARRAYS
+CFLAGS=-g -Wall -I. -I../src -Wall -g -DFLOATING_POINT -DVAR_ARRAYS -O2
 
 C2SIM_OBJ = sine.o nlp.o four1.o dump.o quantise.o lpc.o lsp.o phase.o \
             pack.o postfilter.o interp.o codec2.o c2sim.o 
index b9e5f0f78a19d5e74573d4ffe5c5b3bd9fa45e00..72c5632fcd1c43510e8eb192aa2b70dda40114d3 100644 (file)
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
   int   frames;
   float prev_Wo;
   float pitch;
-  int   voiced1;
+  int   voiced1 = 0;
 
   char  out_file[MAX_STR];
   int   arg;
@@ -372,6 +372,7 @@ int main(int argc, char *argv[])
        if (fout != NULL) fwrite(buf,sizeof(short),N,fout);
     }
   }
+  fclose(fin);
 
   if (fout != NULL)
     fclose(fout);
index 30142fec1da27448d7c44a998eafc48d87750b48..a09de717dee475d561c741e3cdefc654ba2a3da4 100644 (file)
@@ -109,6 +109,8 @@ void *codec2_create()
     for(l=1; l<=MAX_AMP; l++)
        c2->prev_model.A[l] = 0.0;
     c2->prev_model.Wo = TWO_PI/P_MAX;
+    c2->prev_model.L = PI/c2->prev_model.Wo;
+    c2->prev_model.voiced = 0;
 
     c2->nlp = nlp_create();
     if (c2->nlp == NULL) {
@@ -250,6 +252,7 @@ void codec2_decode(void *codec2_state, short speech[],
 
     model.Wo = decode_Wo(Wo_index);
     model.L = PI/model.Wo;
+    memset(&model.A, 0, (model.L+1)*sizeof(model.A[0]));
     decode_amplitudes(&model, 
                      ak,
                      lsp_indexes,
@@ -258,6 +261,8 @@ void codec2_decode(void *codec2_state, short speech[],
 
     model.voiced = voiced2;
     model_interp.voiced = voiced1;
+    model_interp.Wo = P_MAX/2;
+    memset(&model_interp.A, 0, MAX_AMP*sizeof(model_interp.A[0]));
     interpolate(&model_interp, &c2->prev_model, &model);
 
     synthesise_one_frame(c2,  speech,     &model_interp, ak);