Commit 4737bf36 authored by Monty Montgomery's avatar Monty Montgomery

Additional generalization in subband.c; allow each channel to be

running a different filterbank [subband_window]



git-svn-id: https://svn.xiph.org/trunk/postfish@6575 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent db87ca72
...@@ -361,30 +361,34 @@ static void multicompand_work(void *vs){ ...@@ -361,30 +361,34 @@ static void multicompand_work(void *vs){
subband_state *ss=&ms->ss; subband_state *ss=&ms->ss;
int i,j,k,bypass_visible=1; int i,j,k,bypass_visible=1;
float adj[input_size]; float adj[input_size];
int maxmaxbands=0;
float **peakfeed=ms->peak; float **peakfeed=ms->peak;
float **rmsfeed=ms->rms; 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]; float *x=ss->lap[i][j];
int active=(ss->effect_active1[j] ||
ss->effect_active0[j] ||
ss->effect_activeC[j]);
if(active){ if(active){
/* one thing is worth a note here; 'maxbands' can be /* one thing is worth a note here; 'maxbands' can be
'overrange' for the current bank. This is intentional; we 'overrange' for the current bank. This is intentional; we
...@@ -462,13 +466,10 @@ static void multicompand_work(void *vs){ ...@@ -462,13 +466,10 @@ static void multicompand_work(void *vs){
memset(&ms->over_iir[i][j],0,sizeof(iir_state)); memset(&ms->over_iir[i][j],0,sizeof(iir_state));
memset(&ms->under_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)); memset(&ms->base_iir[i][j],0,sizeof(iir_state));
} }
} }
}
for(;i<wP->freq_bands;i++){
for(;i<wP->freq_bands;i++)
for(j=0;j<input_ch;j++){
memset(&ms->over_peak[i][j],0,sizeof(peak_state)); memset(&ms->over_peak[i][j],0,sizeof(peak_state));
memset(&ms->under_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)); memset(&ms->base_peak[i][j],0,sizeof(peak_state));
...@@ -476,6 +477,7 @@ static void multicompand_work(void *vs){ ...@@ -476,6 +477,7 @@ static void multicompand_work(void *vs){
memset(&ms->under_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)); memset(&ms->base_iir[i][j],0,sizeof(iir_state));
} }
}
/* finish up the state feedabck */ /* finish up the state feedabck */
if(bypass_visible){ if(bypass_visible){
...@@ -489,12 +491,12 @@ static void multicompand_work(void *vs){ ...@@ -489,12 +491,12 @@ static void multicompand_work(void *vs){
(multicompand_feedback *) (multicompand_feedback *)
feedback_new(&ms->feedpool,new_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->peak[i],ms->peak[i],input_ch*sizeof(**ms->peak));
memcpy(ff->rms[i],ms->rms[i],input_ch*sizeof(**ms->rms)); memcpy(ff->rms[i],ms->rms[i],input_ch*sizeof(**ms->rms));
} }
ff->bypass=0; ff->bypass=0;
ff->freq_bands=w->freq_bands; ff->freq_bands=maxmaxbands;
feedback_push(&ms->feedpool,(feedback_generic *)ff); feedback_push(&ms->feedpool,(feedback_generic *)ff);
} }
} }
...@@ -502,13 +504,15 @@ static void multicompand_work(void *vs){ ...@@ -502,13 +504,15 @@ static void multicompand_work(void *vs){
time_linkage *multicompand_read(time_linkage *in){ time_linkage *multicompand_read(time_linkage *in){
int visible[input_ch]; int visible[input_ch];
int active[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++){ for(i=0;i<input_ch;i++){
visible[i]=compand_visible; visible[i]=compand_visible;
active[i]=compand_active; 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); visible,active,multicompand_work,&ms);
} }
......
...@@ -57,6 +57,11 @@ int subband_load(subband_state *f,int bands,int qblocksize){ ...@@ -57,6 +57,11 @@ int subband_load(subband_state *f,int bands,int qblocksize){
f->effect_active0=malloc(input_ch*sizeof(*f->effect_active0)); f->effect_active0=malloc(input_ch*sizeof(*f->effect_active0));
f->effect_activeC=malloc(input_ch*sizeof(*f->effect_activeC)); 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++) for(i=0;i<input_ch;i++)
f->cache0[i]=malloc(input_size*sizeof(**f->cache0)); f->cache0[i]=malloc(input_size*sizeof(**f->cache0));
for(i=0;i<input_ch;i++) for(i=0;i<input_ch;i++)
...@@ -205,7 +210,7 @@ int subband_reset(subband_state *f){ ...@@ -205,7 +210,7 @@ int subband_reset(subband_state *f){
static void subband_work(subband_state *f, static void subband_work(subband_state *f,
time_linkage *in, time_linkage *in,
subband_window *w, subband_window **w,
int *visible, int *visible,
int *active){ int *active){
...@@ -215,7 +220,6 @@ static void subband_work(subband_state *f, ...@@ -215,7 +220,6 @@ static void subband_work(subband_state *f,
u_int32_t mutemask=in->active; u_int32_t mutemask=in->active;
f->mutemaskC=mutemask; f->mutemaskC=mutemask;
f->wC=w;
for(i=0;i<input_ch;i++){ for(i=0;i<input_ch;i++){
...@@ -223,9 +227,10 @@ static void subband_work(subband_state *f, ...@@ -223,9 +227,10 @@ static void subband_work(subband_state *f,
int content_p0= f->lap_active0[i]; int content_p0= f->lap_active0[i];
int content_p1= f->lap_active1[i]; int content_p1= f->lap_active1[i];
int maxbands=w->freq_bands; int maxbands=w[i]->freq_bands;
if(maxbands<f->w0->freq_bands)maxbands=f->w0->freq_bands; if(maxbands<f->w0[i]->freq_bands)maxbands=f->w0[i]->freq_bands;
if(maxbands<f->w1->freq_bands)maxbands=f->w1->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->effect_activeC[i] = active[i] && !mute_channel_muted(mutemask,i);
f->visibleC[i] = visible[i]; f->visibleC[i] = visible[i];
...@@ -283,14 +288,15 @@ static void subband_work(subband_state *f, ...@@ -283,14 +288,15 @@ static void subband_work(subband_state *f,
fftwf_execute(f->fftwf_forward); fftwf_execute(f->fftwf_forward);
/* repeatedly filter and transform back */ /* 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 *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++){ for(l=0;l<f->qblocksize*2+1;l++){
f->fftwf_backward_in[2*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_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); fftwf_execute(f->fftwf_backward);
...@@ -306,7 +312,7 @@ static void subband_work(subband_state *f, ...@@ -306,7 +312,7 @@ static void subband_work(subband_state *f,
} }
/* if we're suddenly processing fewer bands than we were, we /* if we're suddenly processing fewer bands than we were, we
have to trail out zeroes until the band lap is emptied */ 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); memset(f->lap[k][i]+input_size*2,0,sizeof(*f->lap[k][i])*input_size);
} }
...@@ -330,9 +336,9 @@ static void unsubband_work(subband_state *f,time_linkage *in, time_linkage *out) ...@@ -330,9 +336,9 @@ static void unsubband_work(subband_state *f,time_linkage *in, time_linkage *out)
int muted_p1= mute_channel_muted(f->mutemask1,i); int muted_p1= mute_channel_muted(f->mutemask1,i);
int maxbands=f->wC->freq_bands; int maxbands=f->wC[i]->freq_bands;
if(maxbands<f->w0->freq_bands)maxbands=f->w0->freq_bands; if(maxbands<f->w0[i]->freq_bands)maxbands=f->w0[i]->freq_bands;
if(maxbands<f->w1->freq_bands)maxbands=f->w1->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 /* even if the lapping for a channel is active, we will draw
output from the cache is the effect is inactive; it saves output from the cache is the effect is inactive; it saves
...@@ -471,9 +477,9 @@ static void unsubband_work(subband_state *f,time_linkage *in, time_linkage *out) ...@@ -471,9 +477,9 @@ static void unsubband_work(subband_state *f,time_linkage *in, time_linkage *out)
f->mutemask1=f->mutemask0; f->mutemask1=f->mutemask0;
f->mutemask0=f->mutemaskC; f->mutemask0=f->mutemaskC;
f->wP=f->w1; memcpy(f->wP,f->w1,input_ch*sizeof(*f->w1));
f->w1=f->w0; memcpy(f->w1,f->w0,input_ch*sizeof(*f->w0));
f->w0=f->wC; memcpy(f->w0,f->wC,input_ch*sizeof(*f->wC));
f->lap_samples-=(out?f->out.samples:0); f->lap_samples-=(out?f->out.samples:0);
...@@ -481,7 +487,7 @@ static void unsubband_work(subband_state *f,time_linkage *in, time_linkage *out) ...@@ -481,7 +487,7 @@ static void unsubband_work(subband_state *f,time_linkage *in, time_linkage *out)
/* called only by playback thread */ /* called only by playback thread */
time_linkage *subband_read(time_linkage *in, subband_state *f, 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){ void (*workfunc)(void *),void *arg){
int i,j; int i,j;
...@@ -510,6 +516,11 @@ time_linkage *subband_read(time_linkage *in, subband_state *f, ...@@ -510,6 +516,11 @@ time_linkage *subband_read(time_linkage *in, subband_state *f,
memset(f->lap_active1,set,sizeof(*f->lap_active1)*input_ch); 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_active0,set,sizeof(*f->lap_active0)*input_ch);
//memset(f->lap_activeC,1,sizeof(*f->lap_activeC)*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); memcpy(f->effect_activeP,active,sizeof(*f->effect_activeP)*input_ch);
...@@ -524,10 +535,6 @@ time_linkage *subband_read(time_linkage *in, subband_state *f, ...@@ -524,10 +535,6 @@ time_linkage *subband_read(time_linkage *in, subband_state *f,
f->mutemask1=in->active; f->mutemask1=in->active;
f->mutemask0=in->active; f->mutemask0=in->active;
f->wP=w;
f->w1=w;
f->w0=w;
/* initially zero the padding of the input working array */ /* initially zero the padding of the input working array */
memset(f->fftwf_forward_in,0,f->qblocksize*4*sizeof(*f->fftwf_forward_in)); memset(f->fftwf_forward_in,0,f->qblocksize*4*sizeof(*f->fftwf_forward_in));
......
...@@ -71,10 +71,10 @@ typedef struct { ...@@ -71,10 +71,10 @@ typedef struct {
1: partial prime 1: partial prime
2: nominal 2: nominal
3: eof processed */ 3: eof processed */
subband_window *wP; subband_window **wP;
subband_window *w0; subband_window **w0;
subband_window *w1; subband_window **w1;
subband_window *wC; subband_window **wC;
} subband_state; } subband_state;
...@@ -85,7 +85,7 @@ extern int subband_load_freqs(subband_state *f,subband_window *w, ...@@ -85,7 +85,7 @@ extern int subband_load_freqs(subband_state *f,subband_window *w,
const float *freq_list,int bands); const float *freq_list,int bands);
extern time_linkage *subband_read(time_linkage *in, subband_state *f, 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); void (*workfunc)(void *),void *arg);
extern int subband_reset(subband_state *f); extern int subband_reset(subband_state *f);
......
...@@ -220,14 +220,16 @@ static void suppress_work(void *vs){ ...@@ -220,14 +220,16 @@ static void suppress_work(void *vs){
time_linkage *suppress_read(time_linkage *in){ time_linkage *suppress_read(time_linkage *in){
int visible[input_ch]; int visible[input_ch];
int active[input_ch]; int active[input_ch];
subband_window *w[input_ch];
int i; int i;
for(i=0;i<input_ch;i++){ for(i=0;i<input_ch;i++){
visible[i]=0; visible[i]=0;
active[i]=suppress_active; 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);
} }
#define VERSION "$Id$ " #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] */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment