Commit 6973e22a authored by michael's avatar michael

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]


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@14374 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent caaf99e9
This diff is collapsed.
This diff is collapsed.
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <assert.h> #include <assert.h>
#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
#define F 100 #define F 100
#define SIZE 2048 #define SIZE 2048
...@@ -110,6 +111,8 @@ int main(int argc,char* argv[]){ ...@@ -110,6 +111,8 @@ int main(int argc,char* argv[]){
int64_t max= (1<<(8*len))-1; int64_t max= (1<<(8*len))-1;
int shift= argc<5 ? 0 : atoi(argv[4]); int shift= argc<5 ? 0 : atoi(argv[4]);
int skip_bytes = argc<6 ? 0 : atoi(argv[5]); int skip_bytes = argc<6 ? 0 : atoi(argv[5]);
int size0=0;
int size1=0;
if(argc<3){ if(argc<3){
printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\n"); printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\n");
...@@ -129,11 +132,11 @@ int main(int argc,char* argv[]){ ...@@ -129,11 +132,11 @@ int main(int argc,char* argv[]){
fseek(f[0],skip_bytes,SEEK_CUR); fseek(f[0],skip_bytes,SEEK_CUR);
fseek(f[1],skip_bytes,SEEK_CUR); fseek(f[1],skip_bytes,SEEK_CUR);
for(i=0;;){ for(;;){
if( fread(buf[0], SIZE, 1, f[0]) != 1) break; int s0= fread(buf[0], 1, SIZE, f[0]);
if( fread(buf[1], SIZE, 1, f[1]) != 1) break; 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 a= buf[0][j];
int64_t b= buf[1][j]; int64_t b= buf[1][j];
if(len==2){ if(len==2){
...@@ -142,19 +145,24 @@ int main(int argc,char* argv[]){ ...@@ -142,19 +145,24 @@ int main(int argc,char* argv[]){
} }
sse += (a-b) * (a-b); sse += (a-b) * (a-b);
} }
size0 += s0;
size1 += s1;
if(s0+s1<=0)
break;
} }
i= FFMIN(size0,size1)/len;
if(!i) i=1; if(!i) i=1;
dev= int_sqrt( ((sse/i)*F*F) + (((sse%i)*F*F) + i/2)/i ); dev= int_sqrt( ((sse/i)*F*F) + (((sse%i)*F*F) + i/2)/i );
if(sse) if(sse)
psnr= ((2*log16(max<<16) + log16(i) - log16(sse))*284619LL*F + (1<<31)) / (1LL<<32); psnr= ((2*log16(max<<16) + log16(i) - log16(sse))*284619LL*F + (1<<31)) / (1LL<<32);
else 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)(dev/F), (int)(dev%F),
(int)(psnr/F), (int)(psnr%F), (int)(psnr/F), (int)(psnr%F),
i*len); size0, size1);
return 0; 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