Skip to content

Commit a7ad267

Browse files
committed
qext_compare: Blackman-Harris window, weighting
1 parent 6ecb478 commit a7ad267

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/qext_compare.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ static void band_energy(float *_out,float *_ps,const int *_bands,int _nbands,
137137
s=c+_window_sz;
138138
x=s+_window_sz;
139139
ps_sz=_window_sz/2;
140+
/* Blackman-Harris window. */
140141
for(xj=0;xj<_window_sz;xj++){
141-
window[xj]=0.5F-0.5F*OPUS_COSF((2*OPUS_PI/(_window_sz-1))*xj);
142+
double n = (xj+.5)/_window_sz;
143+
window[xj]=0.35875 - 0.48829*cos(2*OPUS_PI*n) + 0.14128*cos(4*OPUS_PI*n) - 0.01168*cos(6*OPUS_PI*n);
142144
}
143145
for(xj=0;xj<_window_sz;xj++){
144146
c[xj]=OPUS_COSF((2*OPUS_PI/_window_sz)*xj);
@@ -456,13 +458,17 @@ int main(int _argc,const char **_argv){
456458
Ef4=0;
457459
for(bi=0;bi<ybands;bi++){
458460
double Eb;
461+
double w;
459462
Eb=0;
463+
w = .5+.5*tanh(.5*(22-bi));
460464
for(xj=BANDS[bi];xj<BANDS[bi+1]&&xj<max_compare;xj++){
461465
for(ci=0;ci<nchannels;ci++){
462466
float re;
463467
float im;
464468
re=Y[(xi*yfreqs+xj)*nchannels+ci]/X[(xi*nfreqs+xj)*nchannels+ci];
465469
im=re-log(re)-1;
470+
/* Per-band error weighting. */
471+
im *= w;
466472
Eb+=im;
467473
}
468474
}

0 commit comments

Comments
 (0)