OLD | NEW |
1 /* Copyright (c) 2011-2012 Xiph.Org Foundation, Mozilla Corporation | 1 /* Copyright (c) 2011-2012 Xiph.Org Foundation, Mozilla Corporation |
2 Written by Jean-Marc Valin and Timothy B. Terriberry */ | 2 Written by Jean-Marc Valin and Timothy B. Terriberry */ |
3 /* | 3 /* |
4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
6 are met: | 6 are met: |
7 | 7 |
8 - Redistributions of source code must retain the above copyright | 8 - Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 | 10 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 356 } |
357 Eb /= (BANDS[bi+1]-BANDS[bi])*nchannels; | 357 Eb /= (BANDS[bi+1]-BANDS[bi])*nchannels; |
358 Ef += Eb*Eb; | 358 Ef += Eb*Eb; |
359 } | 359 } |
360 /*Using a fixed normalization value means we're willing to accept slightly | 360 /*Using a fixed normalization value means we're willing to accept slightly |
361 lower quality for lower sampling rates.*/ | 361 lower quality for lower sampling rates.*/ |
362 Ef/=NBANDS; | 362 Ef/=NBANDS; |
363 Ef*=Ef; | 363 Ef*=Ef; |
364 err+=Ef*Ef; | 364 err+=Ef*Ef; |
365 } | 365 } |
| 366 free(xb); |
| 367 free(X); |
| 368 free(Y); |
366 err=pow(err/nframes,1.0/16); | 369 err=pow(err/nframes,1.0/16); |
367 Q=100*(1-0.5*log(1+err)/log(1.13)); | 370 Q=100*(1-0.5*log(1+err)/log(1.13)); |
368 if(Q<0){ | 371 if(Q<0){ |
369 fprintf(stderr,"Test vector FAILS\n"); | 372 fprintf(stderr,"Test vector FAILS\n"); |
370 fprintf(stderr,"Internal weighted error is %f\n",err); | 373 fprintf(stderr,"Internal weighted error is %f\n",err); |
371 return EXIT_FAILURE; | 374 return EXIT_FAILURE; |
372 } | 375 } |
373 else{ | 376 else{ |
374 fprintf(stderr,"Test vector PASSES\n"); | 377 fprintf(stderr,"Test vector PASSES\n"); |
375 fprintf(stderr, | 378 fprintf(stderr, |
376 "Opus quality metric: %.1f %% (internal weighted error is %f)\n",Q,err); | 379 "Opus quality metric: %.1f %% (internal weighted error is %f)\n",Q,err); |
377 return EXIT_SUCCESS; | 380 return EXIT_SUCCESS; |
378 } | 381 } |
379 } | 382 } |
OLD | NEW |