[xiph-cvs] r6532 - trunk/postfish
xiphmont at xiph.org
xiphmont at xiph.org
Sun Apr 18 19:29:53 PDT 2004
Author: xiphmont
Date: 2004-04-18 22:29:52 -0400 (Sun, 18 Apr 2004)
New Revision: 6532
Modified:
trunk/postfish/declip.c
trunk/postfish/output.c
trunk/postfish/reconstruct.c
trunk/postfish/reconstruct.h
trunk/postfish/version.h
Log:
Eliminate block change CPU latency in declipping filter by pre-caching blocksize changes w.r.t. FFTW
<p><p>Modified: trunk/postfish/declip.c
===================================================================
--- trunk/postfish/declip.c 2004-04-18 23:18:16 UTC (rev 6531)
+++ trunk/postfish/declip.c 2004-04-19 02:29:52 UTC (rev 6532)
@@ -34,7 +34,9 @@
extern int inbytes;
/* accessed only in playback thread/setup */
+
static fftwf_plan fftwf_weight;
+
static float *work;
static float *freq;
@@ -63,29 +65,6 @@
static float convergence=0.;
static float iterations=0.;
-#include <stdio.h>
-static void _analysis(char *base,int i,float *v,int n,int dB,int offset){
- int j;
- FILE *of;
- char buffer[80];
-
- sprintf(buffer,"%s_%d.m",base,i);
- of=fopen(buffer,"a");
-
- if(!of)perror("failed to open data dump file");
-
- for(j=0;j<n;j++){
- fprintf(of,"%f ",(float)j+offset);
- if(dB)
- fprintf(of,"%f\n",todB(v[j]));
- else
- fprintf(of,"%f\n",(v[j]));
- }
- fprintf(of,"\n");
- fclose(of);
-}
-
-
/* feedback! */
typedef struct declip_feedback{
feedback_generic parent_class;
@@ -149,14 +128,13 @@
static void setup_blocksize(int newblocksize){
int i;
+
if(blocksize)fftwf_destroy_plan(fftwf_weight);
blocksize=newblocksize;
-
- fftwf_weight=fftwf_plan_dft_r2c_1d(blocksize*2,
- work,
- (fftwf_complex *)freq,
- FFTW_MEASURE);
-
+ fftwf_weight=fftwf_plan_dft_r2c_1d(blocksize*2,work,
+ (fftwf_complex *)freq,
+ FFTW_MEASURE);
+
lopad=1-rint(fromBark(toBark(0.)-width)*blocksize*2/input_rate);
hipad=rint(fromBark(toBark(input_rate*.5)+width)*blocksize*2/input_rate)+lopad;
for(i=0;i<blocksize;i++){
@@ -171,7 +149,7 @@
/* called only by initial setup */
int declip_load(void){
- int i;
+ int i,j;
declip_active=calloc(input_ch,sizeof(*declip_active));
declip_prev_active=calloc(input_ch,sizeof(*declip_prev_active));
chtrigger=malloc(input_ch*sizeof(*chtrigger));
@@ -204,8 +182,16 @@
widthlookup=malloc((hiestpad+1)*sizeof(*widthlookup));
freq=fftwf_malloc((blocksize*2+2)*sizeof(freq));
work=fftwf_malloc((blocksize*2)*sizeof(freq));
- }
+ for(i=0,j=32;j<=blocksize*2;i++,j*=2){
+ fftwf_weight=fftwf_plan_dft_r2c_1d(j,work,
+ (fftwf_complex *)freq,
+ FFTW_MEASURE);
+ fftwf_destroy_plan(fftwf_weight);
+ }
+ }
+ reconstruct_init(32,input_size*4);
+
pending_blocksize=input_size*2;
return(0);
}
@@ -321,7 +307,6 @@
}
/* called only by playback thread */
-static int offset=0;
time_linkage *declip_read(time_linkage *in){
int i,j,k;
float local_trigger[input_ch];
@@ -359,7 +344,7 @@
declip_prev_active[i]=channel_active;
/* peak feedback */
- if(declip_visible){
+ if(declip_visible && !mute_channel_muted(in->active,i)){
float *l=in->data[i];
for(j=0;j<in->samples;j++)
if(fabs(l[j])>peak[i])peak[i]=fabs(l[j]);
@@ -435,7 +420,7 @@
int channel_active=declip_active[i];
/* peak feedback */
- if(declip_visible){
+ if(declip_visible && !mute_channel_muted(in->active,i)){
float *l=in->data[i];
for(j=0;j<in->samples;j++)
if(fabs(l[j])>peak[i])peak[i]=fabs(l[j]);
@@ -645,11 +630,5 @@
out.active=active;
- /* XXXX Temporary! Until later plugins can handle mute, we zero out
- muted channels here */
- for(i=0;i<input_ch;i++)
- if((active & (1<<i))==0)
- memset(out.data[i],0,sizeof(*out.data[i])*input_size);
-
return &out;
}
Modified: trunk/postfish/output.c
===================================================================
--- trunk/postfish/output.c 2004-04-18 23:18:16 UTC (rev 6531)
+++ trunk/postfish/output.c 2004-04-19 02:29:52 UTC (rev 6532)
@@ -240,6 +240,13 @@
link=declip_read(link);
result|=link->samples;
+ /* XXXX Temporary! Until later plugins can handle mute, we zero out
+ muted channels here */
+ for(i=0;i<input_ch;i++)
+ if((link->active & (1<<i))==0)
+ memset(link->data[i],0,sizeof(*link->data[i])*input_size);
+
+
link=multicompand_read(link);
result|=link->samples;
link=singlecomp_read(link);
Modified: trunk/postfish/reconstruct.c
===================================================================
--- trunk/postfish/reconstruct.c 2004-04-18 23:18:16 UTC (rev 6531)
+++ trunk/postfish/reconstruct.c 2004-04-19 02:29:52 UTC (rev 6532)
@@ -42,6 +42,26 @@
static float *s;
static int blocksize=0;
+
+void reconstruct_init(int minblock,int maxblock){
+ int i;
+
+ q=fftwf_malloc((maxblock+2)*sizeof(*q));
+ s=fftwf_malloc((maxblock+2)*sizeof(*s));
+
+ /* fftw priming trick; run it thorugh the paces and prime a plan for
+ every size we may need. fftw will cache the information and not
+ need to re-measure later */
+
+ for(i=minblock;i<=maxblock;i<<=1){
+ fftwf_qf=fftwf_plan_dft_r2c_1d(i,q,(fftwf_complex *)q,FFTW_MEASURE);
+ fftwf_qb=fftwf_plan_dft_c2r_1d(i,(fftwf_complex *)q,q,FFTW_MEASURE);
+ fftwf_destroy_plan(fftwf_qf);
+ fftwf_destroy_plan(fftwf_qb);
+ }
+}
+
+
void reconstruct_reinit(int n){
if(blocksize!=n){
if(blocksize){
Modified: trunk/postfish/reconstruct.h
===================================================================
--- trunk/postfish/reconstruct.h 2004-04-18 23:18:16 UTC (rev 6531)
+++ trunk/postfish/reconstruct.h 2004-04-19 02:29:52 UTC (rev 6532)
@@ -21,6 +21,7 @@
*
*/
+extern void reconstruct_init(int min,int max);
extern void reconstruct_reinit(int n);
extern void reconstruct(float *x, float *w, float *flag,
float e,int max);
Modified: trunk/postfish/version.h
===================================================================
--- trunk/postfish/version.h 2004-04-18 23:18:16 UTC (rev 6531)
+++ trunk/postfish/version.h 2004-04-19 02:29:52 UTC (rev 6532)
@@ -1,2 +1,2 @@
#define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Sun Apr 18 18:58:52 EDT 2004] */
+/* DO NOT EDIT: Automated versioning hack [Sun Apr 18 22:28:48 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