Commit 1e90317b authored by Michael Niedermayer's avatar Michael Niedermayer

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
parent ac5057c2
This diff is collapsed.
This diff is collapsed.
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment