annotate liba52/compare.c @ 8938:fc21a94f98c6

do not discard cache content at seeking type=STREAMTYPE_STREAM (fixes quicktime streaming at low cache fill)
author arpi
date Mon, 13 Jan 2003 03:08:56 +0000
parents aed9850ca011
children 6ade61b852eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3510
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
1 // File written by Michael Niedermayer and its under GPL
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
2 // simple file compare program, it finds the number of rounding errors
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
3 // and dies if there is a larger error ( ABS(a-b)>1 )
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
4
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
5 #include <stdio.h>
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
6
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
7 // FIXME no checks but its just for debuging so who cares ;)
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
8
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
9 int main(int argc, char **argv)
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
10 {
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
11 FILE *f0, *f1;
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
12 int dif=0;
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
13
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
14 if(argc!=3)
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
15 {
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
16 printf("compare <file1> <file2>\n");
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
17 exit(2);
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
18 }
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
19
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
20 f0= fopen(argv[1], "rb");
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
21 f1= fopen(argv[2], "rb");
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
22
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
23 for(;;)
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
24 {
3524
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
25 short c0;
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
26 short c1;
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
27 int d;
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
28
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
29 int e0= fread(&c0, 2, 1, f0);
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
30 int e1= fread(&c1, 2, 1, f1);
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
31
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
32 d=c0-c1;
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
33 if(e0==0 && e1==0) break;
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
34 if(e0==0 || e1==0)
3510
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
35 {
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
36 printf("FATAL error, files have different size!\n");
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
37 exit(1);
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
38 }
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
39
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
40 if(d<0) d=-d; // ABS
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
41 if(d>1)
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
42 {
3524
aed9850ca011 oops, 8bit instead of 16
michael
parents: 3510
diff changeset
43 printf("FATAL error, too large differnce found (%d)!\n", d);
3510
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
44 exit(1);
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
45 }
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
46
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
47 if(d) dif++;
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
48 }
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
49
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
50 fclose(f0);
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
51 fclose(f1);
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
52
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
53 printf("%d (+/-1)differences found\n", dif);
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
54 exit(0);
0e5829f1fb75 gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
michael
parents:
diff changeset
55 }