[xiph-cvs] r6575 - trunk/postfish

xiphmont at xiph.org xiphmont at xiph.org
Tue May 4 21:25:34 PDT 2004



Author: xiphmont
Date: 2004-04-22 06:39:28 -0400 (Thu, 22 Apr 2004)
New Revision: 6575

Modified:
   trunk/postfish/multicompand.c
   trunk/postfish/subband.c
   trunk/postfish/subband.h
   trunk/postfish/suppress.c
   trunk/postfish/version.h
Log:
Additional generalization in subband.c; allow each channel to be
running a different filterbank [subband_window]

<p><p>Modified: trunk/postfish/multicompand.c
===================================================================
--- trunk/postfish/multicompand.c	2004-04-22 09:46:43 UTC (rev 6574)
+++ trunk/postfish/multicompand.c	2004-04-22 10:39:28 UTC (rev 6575)
@@ -361,30 +361,34 @@
   subband_state *ss=&ms->ss;
   int i,j,k,bypass_visible=1;
   float adj[input_size];
+  int maxmaxbands=0;
 
   float **peakfeed=ms->peak;
   float **rmsfeed=ms->rms;
-
-  int bank;
-  subband_window *w=ss->w1;
-  subband_window *wP=ss->wP;
-  int maxbands=ss->wC->freq_bands;
-  if(maxbands<ss->w0->freq_bands)maxbands=ss->w0->freq_bands;
-  if(maxbands<ss->w1->freq_bands)maxbands=ss->w1->freq_bands;
-
-  if(w==&ms->sw[0]){
-    bank=0;
-  }else if(w==&ms->sw[1]){
-    bank=1;
-  }else bank=2;
   
-  for(i=0;i<maxbands;i++){
-    for(j=0;j<input_ch;j++){
+  for(j=0;j<input_ch;j++){
+    int active=(ss->effect_active1[j] || 
+		ss->effect_active0[j] || 
+		ss->effect_activeC[j]);
+    
+    int bank;
+    subband_window *w=ss->w1[j];
+    subband_window *wP=ss->wP[j];
+    int maxbands=ss->wC[j]->freq_bands;
+    if(maxbands<ss->w0[j]->freq_bands)maxbands=ss->w0[j]->freq_bands;
+    if(maxbands<ss->w1[j]->freq_bands)maxbands=ss->w1[j]->freq_bands;
+    if(maxbands>maxmaxbands)maxmaxbands=maxbands;
+    
+    if(w==&ms->sw[0]){
+      bank=0;
+    }else if(w==&ms->sw[1]){
+      bank=1;
+    }else bank=2;
+    
+    for(i=0;i<maxbands;i++){
+      
       float *x=ss->lap[i][j];
-      int active=(ss->effect_active1[j] || 
-		  ss->effect_active0[j] || 
-		  ss->effect_activeC[j]);
-
+      
       if(active){
         /* one thing is worth a note here; 'maxbands' can be
            'overrange' for the current bank.  This is intentional; we
@@ -462,13 +466,10 @@
         memset(&ms->over_iir[i][j],0,sizeof(iir_state));
         memset(&ms->under_iir[i][j],0,sizeof(iir_state));
         memset(&ms->base_iir[i][j],0,sizeof(iir_state));
-      }
-
+      }   
     }
-  }
-
-  for(;i<wP->freq_bands;i++)
-    for(j=0;j<input_ch;j++){
+    
+    for(;i<wP->freq_bands;i++){
       memset(&ms->over_peak[i][j],0,sizeof(peak_state));
       memset(&ms->under_peak[i][j],0,sizeof(peak_state));
       memset(&ms->base_peak[i][j],0,sizeof(peak_state));
@@ -476,6 +477,7 @@
       memset(&ms->under_iir[i][j],0,sizeof(iir_state));
       memset(&ms->base_iir[i][j],0,sizeof(iir_state));
     }
+  }
 
   /* finish up the state feedabck */
   if(bypass_visible){
@@ -489,12 +491,12 @@
       (multicompand_feedback *)
       feedback_new(&ms->feedpool,new_multicompand_feedback);
     
-    for(i=0;i<w->freq_bands;i++){
+    for(i=0;i<maxmaxbands;i++){
       memcpy(ff->peak[i],ms->peak[i],input_ch*sizeof(**ms->peak));
       memcpy(ff->rms[i],ms->rms[i],input_ch*sizeof(**ms->rms));
     } 
     ff->bypass=0;
-    ff->freq_bands=w->freq_bands;
+    ff->freq_bands=maxmaxbands;
     feedback_push(&ms->feedpool,(feedback_generic *)ff);
   }
 }
@@ -502,13 +504,15 @@
 time_linkage *multicompand_read(time_linkage *in){
   int visible[input_ch];
   int active[input_ch];
-  int i;
+  subband_window *w[input_ch];
+  int i,ab=c.active_bank;
 
   for(i=0;i<input_ch;i++){
     visible[i]=compand_visible;
     active[i]=compand_active;
+    w[i]=&ms.sw[ab];
   }
-  return subband_read(in, &ms.ss, &ms.sw[c.active_bank],
+  return subband_read(in, &ms.ss, w,
                       visible,active,multicompand_work,&ms);
 
 }

Modified: trunk/postfish/subband.c
===================================================================
--- trunk/postfish/subband.c	2004-04-22 09:46:43 UTC (rev 6574)
+++ trunk/postfish/subband.c	2004-04-22 10:39:28 UTC (rev 6575)
@@ -57,6 +57,11 @@
   f->effect_active0=malloc(input_ch*sizeof(*f->effect_active0));
   f->effect_activeC=malloc(input_ch*sizeof(*f->effect_activeC));
 
+  f->wP=calloc(input_ch,sizeof(*f->wP));
+  f->w1=calloc(input_ch,sizeof(*f->w1));
+  f->w0=calloc(input_ch,sizeof(*f->w0));
+  f->wC=calloc(input_ch,sizeof(*f->wC));
+
   for(i=0;i<input_ch;i++)
     f->cache0[i]=malloc(input_size*sizeof(**f->cache0));
   for(i=0;i<input_ch;i++)
@@ -205,7 +210,7 @@
 
 static void subband_work(subband_state *f,
                          time_linkage *in,
-			 subband_window *w,
+			 subband_window **w,
                          int      *visible,
                          int      *active){
 
@@ -215,7 +220,6 @@
   u_int32_t mutemask=in->active;
 
   f->mutemaskC=mutemask;
-  f->wC=w;
 
   for(i=0;i<input_ch;i++){
 
@@ -223,9 +227,10 @@
     int content_p0= f->lap_active0[i];
     int content_p1= f->lap_active1[i];
 
-    int maxbands=w->freq_bands;
-    if(maxbands<f->w0->freq_bands)maxbands=f->w0->freq_bands;
-    if(maxbands<f->w1->freq_bands)maxbands=f->w1->freq_bands;
+    int maxbands=w[i]->freq_bands;
+    if(maxbands<f->w0[i]->freq_bands)maxbands=f->w0[i]->freq_bands;
+    if(maxbands<f->w1[i]->freq_bands)maxbands=f->w1[i]->freq_bands;
+    f->wC[i]=w[i];
 
     f->effect_activeC[i] = active[i] && !mute_channel_muted(mutemask,i);
     f->visibleC[i] = visible[i];
@@ -283,14 +288,15 @@
         fftwf_execute(f->fftwf_forward);
         
         /* repeatedly filter and transform back */
-	for(k=0;k<w->freq_bands;k++){
+	for(k=0;k<w[i]->freq_bands;k++){
           float *lapcb=f->lap[k][i]+input_size*2+(j-3)*f->qblocksize;
-	  
+	  float *hw=w[i]->ho_window[k];
+
           for(l=0;l<f->qblocksize*2+1;l++){
             f->fftwf_backward_in[2*l]= 
-	      f->fftwf_forward_out[2*l]*w->ho_window[k][l];
+	      f->fftwf_forward_out[2*l]*hw[l];
             f->fftwf_backward_in[2*l+1]= 
-	      f->fftwf_forward_out[2*l+1]*w->ho_window[k][l];
+	      f->fftwf_forward_out[2*l+1]*hw[l];
           }
           
           fftwf_execute(f->fftwf_backward);
@@ -306,7 +312,7 @@
       }
       /* if we're suddenly processing fewer bands than we were, we
          have to trail out zeroes until the band lap is emptied */
-      for(k=w->freq_bands;k<maxbands;k++)
+      for(k=w[i]->freq_bands;k<maxbands;k++)
         memset(f->lap[k][i]+input_size*2,0,sizeof(*f->lap[k][i])*input_size);
           
     }
@@ -330,9 +336,9 @@
 
     int muted_p1= mute_channel_muted(f->mutemask1,i);
 
-    int maxbands=f->wC->freq_bands;
-    if(maxbands<f->w0->freq_bands)maxbands=f->w0->freq_bands;
-    if(maxbands<f->w1->freq_bands)maxbands=f->w1->freq_bands;
+    int maxbands=f->wC[i]->freq_bands;
+    if(maxbands<f->w0[i]->freq_bands)maxbands=f->w0[i]->freq_bands;
+    if(maxbands<f->w1[i]->freq_bands)maxbands=f->w1[i]->freq_bands;
   
     /* even if the lapping for a channel is active, we will draw
        output from the cache is the effect is inactive; it saves
@@ -471,9 +477,9 @@
   f->mutemask1=f->mutemask0;
   f->mutemask0=f->mutemaskC;
 
-  f->wP=f->w1;
-  f->w1=f->w0;
-  f->w0=f->wC;
+  memcpy(f->wP,f->w1,input_ch*sizeof(*f->w1));
+  memcpy(f->w1,f->w0,input_ch*sizeof(*f->w0));
+  memcpy(f->w0,f->wC,input_ch*sizeof(*f->wC));
 
   f->lap_samples-=(out?f->out.samples:0);
 
@@ -481,7 +487,7 @@
 
 /* called only by playback thread */
 time_linkage *subband_read(time_linkage *in, subband_state *f,
-			   subband_window *w,int *visible, int *active,
+			   subband_window **w,int *visible, int *active,
                            void (*workfunc)(void *),void *arg){
   int i,j;
   
@@ -510,6 +516,11 @@
       memset(f->lap_active1,set,sizeof(*f->lap_active1)*input_ch);
       memset(f->lap_active0,set,sizeof(*f->lap_active0)*input_ch);
       //memset(f->lap_activeC,1,sizeof(*f->lap_activeC)*input_ch);
+
+      f->wP[i]=w[i];
+      f->w1[i]=w[i];
+      f->w0[i]=w[i];
+
     }
     
     memcpy(f->effect_activeP,active,sizeof(*f->effect_activeP)*input_ch);
@@ -524,10 +535,6 @@
     f->mutemask1=in->active;
     f->mutemask0=in->active;
 
-    f->wP=w;
-    f->w1=w;
-    f->w0=w;
-
     /* initially zero the padding of the input working array */
     memset(f->fftwf_forward_in,0,f->qblocksize*4*sizeof(*f->fftwf_forward_in));
 

Modified: trunk/postfish/subband.h
===================================================================
--- trunk/postfish/subband.h	2004-04-22 09:46:43 UTC (rev 6574)
+++ trunk/postfish/subband.h	2004-04-22 10:39:28 UTC (rev 6575)
@@ -71,10 +71,10 @@
                              1: partial prime
                              2: nominal
                              3: eof processed */
-  subband_window *wP;
-  subband_window *w0;
-  subband_window *w1;
-  subband_window *wC;
+  subband_window **wP;
+  subband_window **w0;
+  subband_window **w1;
+  subband_window **wC;
 
 } subband_state;
 
@@ -85,7 +85,7 @@
                               const float *freq_list,int bands);
 
 extern time_linkage *subband_read(time_linkage *in, subband_state *f,
-				  subband_window *w,int *visible, int *active,
+				  subband_window **w,int *visible, int *active,
                                   void (*workfunc)(void *),void *arg);
 
 extern int subband_reset(subband_state *f);

Modified: trunk/postfish/suppress.c
===================================================================
--- trunk/postfish/suppress.c	2004-04-22 09:46:43 UTC (rev 6574)
+++ trunk/postfish/suppress.c	2004-04-22 10:39:28 UTC (rev 6575)
@@ -220,14 +220,16 @@
 time_linkage *suppress_read(time_linkage *in){
   int visible[input_ch];
   int active[input_ch];
+  subband_window *w[input_ch];
   int i;
 
   for(i=0;i<input_ch;i++){
     visible[i]=0;
     active[i]=suppress_active;
+    w[i]=&sss.sw;
   }
   
-  return subband_read(in, &sss.ss, &sss.sw, visible, active, suppress_work, &sss);
+  return subband_read(in, &sss.ss, w, visible, active, suppress_work, &sss);
 }
 
 

Modified: trunk/postfish/version.h
===================================================================
--- trunk/postfish/version.h	2004-04-22 09:46:43 UTC (rev 6574)
+++ trunk/postfish/version.h	2004-04-22 10:39:28 UTC (rev 6575)
@@ -1,2 +1,2 @@
 #define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Thu Apr 22 05:44:00 EDT 2004] */
+/* DO NOT EDIT: Automated versioning hack [Thu Apr 22 06:37:00 EDT 2004] */

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list