[MPlayer-cvslog] r28845 - trunk/libaf/af_resample.c

reimar subversion at mplayerhq.hu
Fri Mar 6 12:39:13 CET 2009


Author: reimar
Date: Fri Mar  6 12:39:13 2009
New Revision: 28845

Log:
Use a single malloc to allocate space for the circular buffers.

Modified:
   trunk/libaf/af_resample.c

Modified: trunk/libaf/af_resample.c
==============================================================================
--- trunk/libaf/af_resample.c	Fri Mar  6 12:31:18 2009	(r28844)
+++ trunk/libaf/af_resample.c	Fri Mar  6 12:39:13 2009	(r28845)
@@ -181,9 +181,7 @@ static int control(struct af_instance_s*
 
     // Free space for circular buffers
     if(s->xq){
-      for(i=1;i<af->data->nch;i++)
-	if(s->xq[i])
-	  free(s->xq[i]);
+      free(s->xq[0]);
       free(s->xq);
       s->xq = NULL;
     }
@@ -218,8 +216,9 @@ static int control(struct af_instance_s*
 
     // Create space for circular buffers
     s->xq = malloc(n->nch*sizeof(void*));
-    for(i=0;i<n->nch;i++)
-      s->xq[i] = malloc(2*L*af->data->bps);
+    s->xq[0] = malloc(n->nch*2*L*af->data->bps);
+    for(i=1;i<n->nch;i++)
+      s->xq[i] = (uint8_t *)s->xq[i-1] + 2*L*af->data->bps;
     s->xi = 0;
 
     // Check if the design needs to be redone



More information about the MPlayer-cvslog mailing list