MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / main

Function main

libavutil/tests/softfloat.c:36–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36int main(void){
37 SoftFloat one= av_int2sf(1, 0);
38 SoftFloat sf1, sf2, sf3;
39 double d1, d2, d3;
40 int i, j;
41 av_log_set_level(AV_LOG_DEBUG);
42
43 d1= 1;
44 for(i= 0; i<10; i++){
45 d1= 1/(d1+1);
46 }
47 printf("test1 double=%d\n", (int)(d1 * (1<<24)));
48
49 sf1= one;
50 for(i= 0; i<10; i++){
51 sf1= av_div_sf(one, av_normalize_sf(av_add_sf(one, sf1)));
52 }
53 printf("test1 sf =%d\n", av_sf2int(sf1, 24));
54
55
56 for(i= 0; i<100; i++){
57 START_TIMER
58 d1= i;
59 d2= i/100.0;
60 for(j= 0; j<1000; j++){
61 d1= (d1+1)*d2;
62 }
63 STOP_TIMER("float add mul")
64 }
65 printf("test2 double=%d\n", (int)(d1 * (1<<24)));
66
67 for(i= 0; i<100; i++){
68 START_TIMER
69 sf1= av_int2sf(i, 0);
70 sf2= av_div_sf(av_int2sf(i, 2), av_int2sf(200, 3));
71 for(j= 0; j<1000; j++){
72 sf1= av_mul_sf(av_add_sf(sf1, one),sf2);
73 }
74 STOP_TIMER("softfloat add mul")
75 }
76 printf("test2 sf =%d (%d %d)\n", av_sf2int(sf1, 24), sf1.exp, sf1.mant);
77
78 d1 = 0.0177764893;
79 d2 = 1374.40625;
80 d3 = 0.1249694824;
81 d2 += d1;
82 d3 += d2;
83 printf("test3 double: %.10lf\n", d3);
84
85 sf1 = FLOAT_0_017776489257;
86 sf2 = FLOAT_1374_40625;
87 sf3 = FLOAT_0_1249694824218;
88 sf2 = av_add_sf(sf1, sf2);
89 sf3 = av_add_sf(sf3, sf2);
90 printf("test3 softfloat: %.10lf (0x%08x %d)\n", (double)av_sf2double(sf3), sf3.mant, sf3.exp);
91
92 sf1 = av_int2sf(0xFFFFFFF0, 0);
93 printf("test4 softfloat: %.10lf (0x%08x %d)\n", (double)av_sf2double(sf1), sf1.mant, sf1.exp);

Callers

nothing calls this directly

Calls 12

av_int2sfFunction · 0.85
av_log_set_levelFunction · 0.85
av_div_sfFunction · 0.85
av_normalize_sfFunction · 0.85
av_add_sfFunction · 0.85
av_sf2intFunction · 0.85
av_mul_sfFunction · 0.85
av_sf2doubleFunction · 0.85
av_cmp_sfFunction · 0.85
av_gt_sfFunction · 0.85
av_sincos_sfFunction · 0.85
fabsFunction · 0.85

Tested by

no test coverage detected