core: restructure main play loop, continue audio after video
[mplayer.git] / TOOLS / compare.c
blob8a48bc82554f27a766acc82fd4196f141709bdee
1 /*
2 * Simple file compare program, it finds the number of rounding errors
3 * and dies if there is too large an error ( ABS(a-b)>1 ).
5 * copyright (c) 2001 Michael Niedermayer
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <stdio.h>
23 #include <stdlib.h>
25 // FIXME: No checks but it is just for debugging so who cares ;)
27 int main(int argc, char **argv)
29 FILE *f0, *f1;
30 int dif=0;
32 if(argc!=3)
34 printf("compare <file1> <file2>\n");
35 exit(2);
38 f0= fopen(argv[1], "rb");
39 f1= fopen(argv[2], "rb");
41 for(;;)
43 short c0;
44 short c1;
45 int d;
47 int e0= fread(&c0, 2, 1, f0);
48 int e1= fread(&c1, 2, 1, f1);
50 d=c0-c1;
51 if(e0==0 && e1==0) break;
52 if(e0==0 || e1==0)
54 printf("FATAL error, files have different size!\n");
55 exit(1);
58 if(d<0) d=-d; // ABS
59 if(d>1)
61 printf("FATAL error, too large a difference found (%d)!\n", d);
62 exit(1);
65 if(d) dif++;
68 fclose(f0);
69 fclose(f1);
71 printf("%d (+/-1)differences found\n", dif);
72 exit(0);