Debian Codegraph @

src/filter/autothresh0ld/variance.h

raw symbols SCIP
1 #cxx . . $ `<file>/src/filter/autothresh0ld/variance.h`/ifdef __SSE2__cxx . . $ `<built-in>:383:9`!
2 #include <emmintrin.h>
3 #endif
4
5 static float find_variancecxx . . $ find_variance(779de2cc40116283).(float *hist, int thresh)
6 {
7 float w_0 = 0.0, mu_0 = 0.0, w_1 = 0.0, mu_1 = 0.0;
8
9 for (int i = 0; i < thresh; ++i)
10 {
11 w_0 += hist[i];
12 mu_0 += i * hist[i];
13 }
14 for (int i = thresh; i < 256; ++i)
15 {
16 w_1 += hist[i];
17 mu_1 += i * hist[i];
18 }
19
20 float mu_diff = (mu_0/w_0 - mu_1/w_1);
21 return w_0*w_1*mu_diff*mu_diff;
22 }
23
24 #ifdef __SSE2__cxx . . $ `<built-in>:383:9`!
25 static float _sse1_hadd_pscxx . . $ _sse1_hadd_ps(ed160c24a2b465d1).(__m128cxx . . $ __m128# v)
26 {
27 // Based on a StackOverflow answer.
28 __m128cxx . . $ __m128# shuf = _mm_shuffle_pscxx . . $ _mm_shuffle_ps(898c5aeb8aa6e818).(v, v, _MM_SHUFFLEcxx . . $ `<external>/17230393460817704243/xmmintrin.h:82:9`!(2, 3, 0, 1));
29 __m128cxx . . $ __m128# sums = _mm_add_pscxx . . $ _mm_add_ps(359170f1c294161a).(v, shuf);
30 shuf = _mm_movehl_pscxx . . $ _mm_movehl_ps(359170f1c294161a).(shuf, sums);
31 sums = _mm_add_sscxx . . $ _mm_add_ss(359170f1c294161a).(sums, shuf);
32 return _mm_cvtss_f32cxx . . $ _mm_cvtss_f32(ed160c24a2b465d1).(sums);
33 }
34
35 static float find_variance_sse2cxx . . $ find_variance_sse2(779de2cc40116283).(float *hist, int thresh)
36 {
37 __m128cxx . . $ __m128# vw_0 = _mm_setzero_pscxx . . $ _mm_setzero_ps(6f56d86985015e33).(), vmu_0 = _mm_setzero_pscxx . . $ _mm_setzero_ps(6f56d86985015e33).(),
38 vw_1 = _mm_setzero_pscxx . . $ _mm_setzero_ps(6f56d86985015e33).(), vmu_1 = _mm_setzero_pscxx . . $ _mm_setzero_ps(6f56d86985015e33).();
39 __m128cxx . . $ __m128# vcnt = _mm_set_pscxx . . $ _mm_set_ps(a665d513d3d90c15).(0, 1, 2, 3);
40
41 int thresh_low = (thresh / 4 + 0) * 4,
42 thresh_up = (thresh / 4 + 1) * 4;
43
44 for (int i = 0; i < thresh_low; i+=4)
45 {
46 __m128cxx . . $ __m128# vhist = _mm_castsi128_pscxx . . $ _mm_castsi128_ps(9be10ac41b2a5a4c).(_mm_loadu_si128cxx . . $ _mm_loadu_si128(e4f8d56e727a1fa4).((void*)&hist[i]));
47
48 vw_0 = _mm_add_pscxx . . $ _mm_add_ps(359170f1c294161a).(vhist, vw_0);
49 vmu_0 = _mm_add_pscxx . . $ _mm_add_ps(359170f1c294161a).(_mm_mul_pscxx . . $ _mm_mul_ps(359170f1c294161a).(vcnt, vhist), vw_0);
50 vcnt = _mm_add_pscxx . . $ _mm_add_ps(359170f1c294161a).(vcnt, _mm_set1_pscxx . . $ _mm_set1_ps(975dd02a9c095bb9).(4));
51 }
52
53 // This is skipped, and handled as an edge case by non-SSE code.
54 vcnt = _mm_add_pscxx . . $ _mm_add_ps(359170f1c294161a).(vcnt, _mm_set1_pscxx . . $ _mm_set1_ps(975dd02a9c095bb9).(4));
55
56 for (int i = thresh_up; i < 256; i+=4)
57 {
58 __m128cxx . . $ __m128# vhist = _mm_castsi128_pscxx . . $ _mm_castsi128_ps(9be10ac41b2a5a4c).(_mm_loadu_si128cxx . . $ _mm_loadu_si128(e4f8d56e727a1fa4).((void*)&hist[i]));
59
60 vw_1 = _mm_add_pscxx . . $ _mm_add_ps(359170f1c294161a).(vhist, vw_1);
61 vmu_1 = _mm_add_pscxx . . $ _mm_add_ps(359170f1c294161a).(_mm_mul_pscxx . . $ _mm_mul_ps(359170f1c294161a).(vcnt, vhist), vw_1);
62 vcnt = _mm_add_pscxx . . $ _mm_add_ps(359170f1c294161a).(vcnt, _mm_set1_pscxx . . $ _mm_set1_ps(975dd02a9c095bb9).(4));
63 }
64
65 float w_0 = _sse1_hadd_pscxx . . $ _sse1_hadd_ps(ed160c24a2b465d1).(vw_0), mu_0 = _sse1_hadd_pscxx . . $ _sse1_hadd_ps(ed160c24a2b465d1).(vmu_0),
66 w_1 = _sse1_hadd_pscxx . . $ _sse1_hadd_ps(ed160c24a2b465d1).(vw_1), mu_1 = _sse1_hadd_pscxx . . $ _sse1_hadd_ps(ed160c24a2b465d1).(vmu_1);
67
68 // This edge case is here, because thresh may not be a multiple of 4.
69 for (int i = thresh_low; i < thresh; ++i)
70 {
71 w_0 += hist[i];
72 mu_0 += i * hist[i];
73 }
74
75 for (int i = thresh; i < thresh_up; ++i)
76 {
77 w_1 += hist[i];
78 mu_1 += i * hist[i];
79 }
80
81 float mu_diff = (mu_0/w_0 - mu_1/w_1);
82 return w_0*w_1*mu_diff*mu_diff;
83 }
84 #endif