Browse code

avfilter/xbr: refactor px calculation in FILT[234]

Clément Bœsch authored on 2014/12/26 07:34:25
Showing 1 changed files
... ...
@@ -90,6 +90,8 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
90 90
     if (PE != PH && PE != PF) {                                                                     \
91 91
         const unsigned e = df(PE,PC) + df(PE,PG) + df(PI,H5) + df(PI,F4) + (df(PH,PF)<<2);          \
92 92
         const unsigned i = df(PH,PD) + df(PH,I5) + df(PF,I4) + df(PF,PB) + (df(PE,PI)<<2);          \
93
+        if (e <= i) {                                                                               \
94
+            const unsigned px = df(PE,PF) <= df(PE,PH) ? PF : PH;                                   \
93 95
         if (e < i && (!eq(PF,PB) && !eq(PH,PD) || eq(PE,PI)                                         \
94 96
                       && (!eq(PF,I4) && !eq(PH,I5))                                                 \
95 97
                       || eq(PE,PG) || eq(PE,PC))) {                                                 \
... ...
@@ -97,7 +99,6 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
97 97
             const unsigned ki = df(PH,PC);                                                          \
98 98
             const int left    = ke<<1 <= ki && PE != PG && PD != PG;                                \
99 99
             const int up      = ke >= ki<<1 && PE != PC && PB != PC;                                \
100
-            const unsigned px = df(PE,PF) <= df(PE,PH) ? PF : PH;                                   \
101 100
             if (left && up) {                                                                       \
102 101
                 E[N3] = ALPHA_BLEND_224_W(E[N3], px);                                               \
103 102
                 E[N2] = ALPHA_BLEND_64_W( E[N2], px);                                               \
... ...
@@ -111,8 +112,9 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
111 111
             } else { /* diagonal */                                                                 \
112 112
                 E[N3] = ALPHA_BLEND_128_W(E[N3], px);                                               \
113 113
             }                                                                                       \
114
-        } else if (e <= i) {                                                                        \
115
-            E[N3] = ALPHA_BLEND_128_W(E[N3], ((df(PE,PF) <= df(PE,PH)) ? PF : PH));                 \
114
+        } else {                                                                                    \
115
+            E[N3] = ALPHA_BLEND_128_W(E[N3], px);                                                   \
116
+        }                                                                                           \
116 117
         }                                                                                           \
117 118
     }                                                                                               \
118 119
 } while (0)
... ...
@@ -122,6 +124,8 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
122 122
     if (PE != PH && PE != PF) {                                                                     \
123 123
         const unsigned e = df(PE,PC) + df(PE,PG) + df(PI,H5) + df(PI,F4) + (df(PH,PF)<<2);          \
124 124
         const unsigned i = df(PH,PD) + df(PH,I5) + df(PF,I4) + df(PF,PB) + (df(PE,PI)<<2);          \
125
+        if (e <= i) {                                                                               \
126
+            const unsigned px = df(PE,PF) <= df(PE,PH) ? PF : PH;                                   \
125 127
         if (e < i && (!eq(PF,PB) && !eq(PF,PC) || !eq(PH,PD) && !eq(PH,PG) || eq(PE,PI)             \
126 128
                       && (!eq(PF,F4) && !eq(PF,I4) || !eq(PH,H5) && !eq(PH,I5))                     \
127 129
                       || eq(PE,PG) || eq(PE,PC))) {                                                 \
... ...
@@ -129,7 +133,6 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
129 129
             const unsigned ki = df(PH,PC);                                                          \
130 130
             const int left    = ke<<1 <= ki && PE != PG && PD != PG;                                \
131 131
             const int up      = ke >= ki<<1 && PE != PC && PB != PC;                                \
132
-            const unsigned px = df(PE,PF) <= df(PE,PH) ? PF : PH;                                   \
133 132
             if (left && up) {                                                                       \
134 133
                 E[N7] = ALPHA_BLEND_192_W(E[N7], px);                                               \
135 134
                 E[N6] = ALPHA_BLEND_64_W( E[N6], px);                                               \
... ...
@@ -151,8 +154,9 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
151 151
                 E[N5] = ALPHA_BLEND_32_W( E[N5], px);                                               \
152 152
                 E[N7] = ALPHA_BLEND_32_W( E[N7], px);                                               \
153 153
             }                                                                                       \
154
-        } else if (e <= i) {                                                                        \
155
-            E[N8] = ALPHA_BLEND_128_W(E[N8], ((df(PE,PF) <= df(PE,PH)) ? PF : PH));                 \
154
+        } else {                                                                                    \
155
+            E[N8] = ALPHA_BLEND_128_W(E[N8], px);                                                   \
156
+        }                                                                                           \
156 157
         }                                                                                           \
157 158
     }                                                                                               \
158 159
 } while (0)
... ...
@@ -162,6 +166,8 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
162 162
     if (PE != PH && PE != PF) {                                                                     \
163 163
         const unsigned e = df(PE,PC) + df(PE,PG) + df(PI,H5) + df(PI,F4) + (df(PH,PF)<<2);          \
164 164
         const unsigned i = df(PH,PD) + df(PH,I5) + df(PF,I4) + df(PF,PB) + (df(PE,PI)<<2);          \
165
+        if (e <= i) {                                                                               \
166
+            const unsigned px = df(PE,PF) <= df(PE,PH) ? PF : PH;                                   \
165 167
         if (e < i && (!eq(PF,PB) && !eq(PH,PD) || eq(PE,PI)                                         \
166 168
                       && (!eq(PF,I4) && !eq(PH,I5))                                                 \
167 169
                       || eq(PE,PG) || eq(PE,PC))) {                                                 \
... ...
@@ -169,7 +175,6 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
169 169
             const unsigned ki = df(PH,PC);                                                          \
170 170
             const int left    = ke<<1 <= ki && PE != PG && PD != PG;                                \
171 171
             const int up      = ke >= ki<<1 && PE != PC && PB != PC;                                \
172
-            const unsigned px = df(PE,PF) <= df(PE,PH) ? PF : PH;                                   \
173 172
             if (left && up) {                                                                       \
174 173
                 E[N13] = ALPHA_BLEND_192_W(E[N13], px);                                             \
175 174
                 E[N12] = ALPHA_BLEND_64_W( E[N12], px);                                             \
... ...
@@ -195,8 +200,9 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
195 195
                 E[N14] = ALPHA_BLEND_128_W(E[N14], px);                                             \
196 196
                 E[N15] = px;                                                                        \
197 197
             }                                                                                       \
198
-        } else if (e <= i) {                                                                        \
199
-            E[N15] = ALPHA_BLEND_128_W(E[N15], ((df(PE,PF) <= df(PE,PH)) ? PF : PH));               \
198
+        } else {                                                                                    \
199
+            E[N15] = ALPHA_BLEND_128_W(E[N15], px);                                                 \
200
+        }                                                                                           \
200 201
         }                                                                                           \
201 202
     }                                                                                               \
202 203
 } while (0)