Mercurial > libavutil.hg
comparison softfloat.c @ 91:04f62b676170 libavutil
floating point "emulation" code
unused currently, but might come in handy for some fpu-less cpus
author | michael |
---|---|
date | Tue, 08 Aug 2006 07:58:10 +0000 |
parents | |
children | 11be8e0d1344 |
comparison
equal
deleted
inserted
replaced
90:b916c714f77b | 91:04f62b676170 |
---|---|
1 #include <inttypes.h> | |
2 #include <stdio.h> | |
3 #include <assert.h> | |
4 #include "softfloat.h" | |
5 #include "common.h" | |
6 #include "log.h" | |
7 | |
8 #undef printf | |
9 | |
10 int main(){ | |
11 SoftFloat one= av_int2sf(1, 0); | |
12 SoftFloat sf1, sf2; | |
13 double d1, d2; | |
14 int i, j; | |
15 av_log_level = AV_LOG_DEBUG; | |
16 | |
17 d1= 1; | |
18 for(i= 0; i<10; i++){ | |
19 d1= 1/(d1+1); | |
20 } | |
21 printf("test1 double=%d\n", (int)(d1 * (1<<24))); | |
22 | |
23 sf1= one; | |
24 for(i= 0; i<10; i++){ | |
25 sf1= av_div_sf(one, av_normalize_sf(av_add_sf(one, sf1))); | |
26 } | |
27 printf("test1 sf =%d\n", av_sf2int(sf1, 24)); | |
28 | |
29 | |
30 for(i= 0; i<100; i++){ | |
31 START_TIMER | |
32 d1= i; | |
33 d2= i/100.0; | |
34 for(j= 0; j<1000; j++){ | |
35 d1= (d1+1)*d2; | |
36 } | |
37 STOP_TIMER("float add mul") | |
38 } | |
39 printf("test2 double=%d\n", (int)(d1 * (1<<24))); | |
40 | |
41 for(i= 0; i<100; i++){ | |
42 START_TIMER | |
43 sf1= av_int2sf(i, 0); | |
44 sf2= av_div_sf(av_int2sf(i, 2), av_int2sf(200, 3)); | |
45 for(j= 0; j<1000; j++){ | |
46 sf1= av_mul_sf(av_add_sf(sf1, one),sf2); | |
47 } | |
48 STOP_TIMER("softfloat add mul") | |
49 } | |
50 printf("test2 sf =%d (%d %d)\n", av_sf2int(sf1, 24), sf1.exp, sf1.mant); | |
51 return 0; | |
52 } |