Skip to content

Commit 435b185

Browse files
committed
qext_compare: Add RMS calculation
1 parent 1d40993 commit 435b185

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/qext_compare.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ int main(int _argc,const char **_argv){
220220
size_t test_win_step;
221221
int max_compare;
222222
int format;
223+
double rms=-1;
223224
const char *argv0 = _argv[0];
224225
if(_argc<3){
225226
usage(argv0);
@@ -322,6 +323,15 @@ int main(int _argc,const char **_argv){
322323
(unsigned long)xlength,test_win_size);
323324
return EXIT_FAILURE;
324325
}
326+
if (nchannels==2 && downsample==1){
327+
size_t i;
328+
rms=0;
329+
for (i=0;i<xlength*nchannels;i++){
330+
double e=x[i]-y[i];
331+
rms+=e*e;
332+
}
333+
rms=sqrt(rms/(xlength*nchannels));
334+
}
325335
nframes=(xlength-test_win_size+test_win_step)/test_win_step;
326336
xb=(float *)opus_malloc(nframes*nbands*nchannels*sizeof(*xb));
327337
X=(float *)opus_malloc(nframes*nfreqs*nchannels*sizeof(*X));
@@ -474,6 +484,6 @@ int main(int _argc,const char **_argv){
474484
free(Y);
475485
err4=pow(err4/nframes,1.0/4);
476486
err16=pow(err16/nframes,1.0/16);
477-
fprintf(stderr, "err4 = %f, err16 = %f\n", err4, err16);
487+
fprintf(stderr, "err4 = %f, err16 = %f, rms = %f\n", err4, err16, rms);
478488
return EXIT_SUCCESS;
479489
}

0 commit comments

Comments
 (0)