diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-07-24 17:24:36 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-07-24 17:24:36 +0000 |
commit | 1e90317b655699a2877478e335e998fb5e4b79d8 (patch) | |
tree | 4bfc63a22f0bac399fea463ef2e7d4eb01f751c4 /tests/tiny_psnr.c | |
parent | ac5057c2de1678847f1ce5b508fc18a9126b5e20 (diff) | |
download | ffmpeg-1e90317b655699a2877478e335e998fb5e4b79d8.tar.gz |
Fix tiny_psnr so it compares all bytes (it did skip the last block).
Also display both file sizes and slightly change the output formatting.
[not split in 3 patches to avoid the huge checksum files from being changed
and having to be reviewed 3 times, if people want it split i can revert and
split it]
Originally committed as revision 14374 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'tests/tiny_psnr.c')
-rw-r--r-- | tests/tiny_psnr.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/tiny_psnr.c b/tests/tiny_psnr.c index b7b1d0848f..6327e6f9e4 100644 --- a/tests/tiny_psnr.c +++ b/tests/tiny_psnr.c @@ -23,6 +23,7 @@ #include <inttypes.h> #include <assert.h> +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) #define F 100 #define SIZE 2048 @@ -110,6 +111,8 @@ int main(int argc,char* argv[]){ int64_t max= (1<<(8*len))-1; int shift= argc<5 ? 0 : atoi(argv[4]); int skip_bytes = argc<6 ? 0 : atoi(argv[5]); + int size0=0; + int size1=0; if(argc<3){ printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\n"); @@ -129,11 +132,11 @@ int main(int argc,char* argv[]){ fseek(f[0],skip_bytes,SEEK_CUR); fseek(f[1],skip_bytes,SEEK_CUR); - for(i=0;;){ - if( fread(buf[0], SIZE, 1, f[0]) != 1) break; - if( fread(buf[1], SIZE, 1, f[1]) != 1) break; + for(;;){ + int s0= fread(buf[0], 1, SIZE, f[0]); + int s1= fread(buf[1], 1, SIZE, f[1]); - for(j=0; j<SIZE; i++,j++){ + for(j=0; j<FFMIN(s0,s1); j++){ int64_t a= buf[0][j]; int64_t b= buf[1][j]; if(len==2){ @@ -142,19 +145,24 @@ int main(int argc,char* argv[]){ } sse += (a-b) * (a-b); } + size0 += s0; + size1 += s1; + if(s0+s1<=0) + break; } + i= FFMIN(size0,size1)/len; if(!i) i=1; dev= int_sqrt( ((sse/i)*F*F) + (((sse%i)*F*F) + i/2)/i ); if(sse) psnr= ((2*log16(max<<16) + log16(i) - log16(sse))*284619LL*F + (1<<31)) / (1LL<<32); else - psnr= 100*F-1; //floating point free infinity :) + psnr= 1000*F-1; //floating point free infinity :) - printf("stddev:%3d.%02d PSNR:%2d.%02d bytes:%d\n", + printf("stddev:%5d.%02d PSNR:%3d.%02d bytes:%9d/%9d\n", (int)(dev/F), (int)(dev%F), (int)(psnr/F), (int)(psnr%F), - i*len); + size0, size1); return 0; } |