@@ -187,7 +187,7 @@ static const int BANDS[NBANDS+1]={
187
187
188
188
189
189
void usage (const char * _argv0 ) {
190
- fprintf (stderr ,"Usage: %s [-s] [-48k] [-s16|-s24|-f32] [-r rate2] <file1.sw> <file2.sw>\n" ,
190
+ fprintf (stderr ,"Usage: %s [-s] [-48k] [-s16|-s24|-f32] [-r rate2] [-thresholds err4 err16 rms] <file1.sw> <file2.sw>\n" ,
191
191
_argv0 );
192
192
}
193
193
@@ -222,6 +222,8 @@ int main(int _argc,const char **_argv){
222
222
int format ;
223
223
double rms = -1 ;
224
224
const char * argv0 = _argv [0 ];
225
+ double err4_threshold = -1 , err16_threshold = -1 , rms_threshold = -1 ;
226
+ int compare_thresholds = 0 ;
225
227
if (_argc < 3 ){
226
228
usage (argv0 );
227
229
return EXIT_FAILURE ;
@@ -256,6 +258,17 @@ int main(int _argc,const char **_argv){
256
258
format = FORMAT_F32_LE ;
257
259
_argv ++ ;
258
260
_argc -- ;
261
+ } else if (strcmp (_argv [1 ],"-thresholds" )== 0 ){
262
+ if (_argc < 7 ) {
263
+ usage (argv0 );
264
+ return EXIT_FAILURE ;
265
+ }
266
+ err4_threshold = atof (_argv [2 ]);
267
+ err16_threshold = atof (_argv [3 ]);
268
+ rms_threshold = atof (_argv [4 ]);
269
+ compare_thresholds = 1 ;
270
+ _argv += 4 ;
271
+ _argc -= 4 ;
259
272
} else if (strcmp (_argv [1 ],"-r" )== 0 ){
260
273
rate = atoi (_argv [2 ]);
261
274
if (rate != 8000 && rate != 12000 && rate != 16000 && rate != 24000 && rate != 48000 && rate != 96000 ){
@@ -496,5 +509,13 @@ int main(int _argc,const char **_argv){
496
509
err4 = pow (err4 /nframes ,1.0 /4 );
497
510
err16 = pow (err16 /nframes ,1.0 /16 );
498
511
fprintf (stderr , "err4 = %f, err16 = %f, rms = %f\n" , err4 , err16 , rms );
512
+ if (compare_thresholds ) {
513
+ if (err4 <= err4_threshold && err16 <= err16_threshold && rms <= rms_threshold ) {
514
+ fprintf (stderr , "Comparison PASSED\n" );
515
+ } else {
516
+ fprintf (stderr , "*** Comparison FAILED *** (thresholds were %f %f %f)\n" , err4_threshold , err16_threshold , rms_threshold );
517
+ return EXIT_FAILURE ;
518
+ }
519
+ }
499
520
return EXIT_SUCCESS ;
500
521
}
0 commit comments