convert some printfs to mp_msg
[mplayer/glamo.git] / liba52 / compare.c
blob96463bcfd40f25b100531dafe98a117f29f9e3a1
1 // File written by Michael Niedermayer and its under GPL
2 // simple file compare program, it finds the number of rounding errors
3 // and dies if there is a larger error ( ABS(a-b)>1 )
5 #include <stdio.h>
7 // FIXME no checks but its just for debuging so who cares ;)
9 int main(int argc, char **argv)
11 FILE *f0, *f1;
12 int dif=0;
14 if(argc!=3)
16 printf("compare <file1> <file2>\n");
17 exit(2);
20 f0= fopen(argv[1], "rb");
21 f1= fopen(argv[2], "rb");
23 for(;;)
25 short c0;
26 short c1;
27 int d;
29 int e0= fread(&c0, 2, 1, f0);
30 int e1= fread(&c1, 2, 1, f1);
32 d=c0-c1;
33 if(e0==0 && e1==0) break;
34 if(e0==0 || e1==0)
36 printf("FATAL error, files have different size!\n");
37 exit(1);
40 if(d<0) d=-d; // ABS
41 if(d>1)
43 printf("FATAL error, too large differnce found (%d)!\n", d);
44 exit(1);
47 if(d) dif++;
50 fclose(f0);
51 fclose(f1);
53 printf("%d (+/-1)differences found\n", dif);
54 exit(0);