[xiph-commits] r17670 - trunk/squishyball

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Sat Nov 27 16:25:43 PST 2010


Author: xiphmont
Date: 2010-11-27 16:25:43 -0800 (Sat, 27 Nov 2010)
New Revision: 17670

Modified:
   trunk/squishyball/main.c
Log:
Guard samples that are under the minimum invariant length (3 fragments)


Modified: trunk/squishyball/main.c
===================================================================
--- trunk/squishyball/main.c	2010-11-27 23:20:13 UTC (rev 17669)
+++ trunk/squishyball/main.c	2010-11-28 00:25:43 UTC (rev 17670)
@@ -1592,33 +1592,36 @@
     beep2[i] = w*b*mul*2;
   }
 
-  /* make sure that the samples are at least fragsamples*2 in length! If they're not, extend... */
-  if(pcm[0]->size<fragsamples*2){
-    int fadesize = pcm[0]->size/4;
+  /* make sure that the samples are at least fragsamples*3 in length! If they're not, extend... */
+  {
     int bps = (pcm[0]->bits+7)/8;
     int ch = pcm[0]->ch;
     int bpf = bps*ch;
 
-    for(i=0;i<test_files;i++){
-      int j,k;
-      unsigned char *newd=calloc(fadesize,bpf);
-      if(!newd){
-        fprintf(stderr,"Unable to allocate memory to extend sample to minimum length.\n");
-        exit(5);
-      }
-      memcpy(newd,pcm[i]->data,fragsamples*2*bpf);
-      free(pcm[i]->data);
-      pcm[i]->data=newd;
+    if(pcm[0]->size<fragsamples*bpf*3){
+      int fadesize = pcm[0]->size/4;
 
-      newd+=pcm[i]->size-fadesize;
-      for(j=0;j<fadesize;j++){
-        float v = cosf(M_PI*.5f*(i+.5f)/fadesize);
-        for(k=0;k<ch;k++){
-          put_val(newd,bps,v * get_val(newd,bps));
-          newd+=bps;
+      for(i=0;i<test_files;i++){
+        int j,k;
+        unsigned char *newd=calloc(fragsamples*3,bpf);
+        if(!newd){
+          fprintf(stderr,"Unable to allocate memory to extend sample to minimum length.\n");
+          exit(5);
         }
+        memcpy(newd,pcm[i]->data,fragsamples*3*bpf);
+        free(pcm[i]->data);
+        pcm[i]->data=newd;
+
+        newd+=pcm[i]->size-fadesize;
+        for(j=0;j<fadesize;j++){
+          float v = cosf(M_PI*.5f*(i+.5f)/fadesize);
+          for(k=0;k<ch;k++){
+            put_val(newd,bps,v * get_val(newd,bps));
+            newd+=bps;
+          }
+        }
+        pcm[i]->size=fragsamples*3;
       }
-      pcm[i]->size=fragsamples*2;
     }
   }
   return fragsamples;



More information about the commits mailing list