From c43d77c163d91cbe4eb1f8be1e3b3afca107faeb Mon Sep 17 00:00:00 2001 From: Måns Rullgård Date: Fri, 9 Jul 2010 16:06:05 +0000 Subject: tiny_psnr: skip wav headers on input files The byte count printed excludes the header, and offsets are applied after the the headers are skipped. Reference files updated to reflect new output. Some stddev/psnr values have changed slightly due to headers no longer being compared. Originally committed as revision 24143 to svn://svn.ffmpeg.org/ffmpeg/trunk --- tests/tiny_psnr.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'tests/tiny_psnr.c') diff --git a/tests/tiny_psnr.c b/tests/tiny_psnr.c index 66b6747af3..681fd13951 100644 --- a/tests/tiny_psnr.c +++ b/tests/tiny_psnr.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -117,8 +118,7 @@ int main(int argc,char* argv[]){ if(argc<3){ printf("tiny_psnr [ [ []]]\n"); - printf("For WAV files use the following:\n"); - printf("./tiny_psnr file1.wav file2.wav 2 0 44 to skip the header.\n"); + printf("WAV headers are skipped automatically.\n"); return -1; } @@ -128,7 +128,24 @@ int main(int argc,char* argv[]){ fprintf(stderr, "Could not open input files.\n"); return -1; } - fseek(f[shift<0], shift < 0 ? -shift : shift, SEEK_SET); + + for (i = 0; i < 2; i++) { + uint8_t *p = buf[i]; + fread(p, 1, 12, f[i]); + if (!memcmp(p, "RIFF", 4) && + !memcmp(p+8, "WAVE", 4)) { + fread(p, 1, 8, f[i]); + while (memcmp(p, "data", 4)) { + int s = p[4] | p[5]<<8 | p[6]<<16 | p[7]<<24; + fseek(f[i], s, SEEK_CUR); + fread(p, 1, 8, f[i]); + } + } else { + fseek(f[i], -12, SEEK_CUR); + } + } + + fseek(f[shift<0], shift < 0 ? -shift : shift, SEEK_CUR); fseek(f[0],skip_bytes,SEEK_CUR); fseek(f[1],skip_bytes,SEEK_CUR); -- cgit v1.2.3