changeset 14283:91170dd147c6

faster packed<->planar conversation
author michael
date Fri, 31 Dec 2004 13:14:01 +0000
parents 2188637c0e8f
children 08399423fe30
files libaf/af_lavcresample.c
diffstat 1 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_lavcresample.c	Fri Dec 31 11:40:01 2004 +0000
+++ b/libaf/af_lavcresample.c	Fri Dec 31 13:14:01 2004 +0000
@@ -118,9 +118,18 @@
       }
   }
 
-  for(j=0; j<in_len; j++){
-      for(i=0; i<chans; i++){
-          s->in[i][j + s->index]= *(in++);
+  if(chans==1){
+      memcpy(&s->in[0][s->index], in, in_len * sizeof(int16_t));
+  }else if(chans==2){
+      for(j=0; j<in_len; j++){
+          s->in[0][j + s->index]= *(in++);
+          s->in[1][j + s->index]= *(in++);
+      }
+  }else{
+      for(j=0; j<in_len; j++){
+          for(i=0; i<chans; i++){
+              s->in[i][j + s->index]= *(in++);
+          }
       }
   }
   in_len += s->index;
@@ -135,9 +144,18 @@
       memmove(s->in[i], s->in[i] + consumed, s->index*sizeof(int16_t));
   }
 
-  for(j=0; j<out_len; j++){
-      for(i=0; i<chans; i++){
-          *(out++)= tmp[i][j];
+  if(chans==1){
+      memcpy(out, tmp[0], out_len*sizeof(int16_t));
+  }else if(chans==2){
+      for(j=0; j<out_len; j++){
+          *(out++)= tmp[0][j];
+          *(out++)= tmp[1][j];
+      }
+  }else{
+      for(j=0; j<out_len; j++){
+          for(i=0; i<chans; i++){
+              *(out++)= tmp[i][j];
+          }
       }
   }