History

avfilter/vf_estdif: simplify finding minimum score

Paul B Mahol committed 3 years ago

Commit 57f264e1 parent 16a86b41 file · +13 −17Browse files

Unified · Split

libavfilter/vf_estdif.c+13−17
@@ -266,11 +266,12 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 265 unmodified lines
266 const type *const next3_line = (const type *const)nnext3_line; \266 const type *const next3_line = (const type *const)nnext3_line; \
267 const int interp = s->interp; \267 const int interp = s->interp; \
268 const int ecost = s->ecost; \268 const int ecost = s->ecost; \
269 const int dcost = s->dcost * s->max; \269 const int dcost = s->dcost; \
270 const int end = width - 1; \
271 const int mcost = s->mcost; \270 const int mcost = s->mcost; \
272 atype sd[S], sD[S], di = 0; \271 atype sd[S], sD[S], di = 0; \
272 const int end = width - 1; \
273 atype dmin = amax; \273 atype dmin = amax; \
274 int id = 0, iD = 0; \
274 int k = *K; \275 int k = *K; \
275 \276 \
276 for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \277 for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \
@@ -288,7 +289,11 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 11 unmodified lines
288 sD[i + rslope] += mcost * cost_##ss(prev_line, next_line, end, x, i);\289 sD[i + rslope] += mcost * cost_##ss(prev_line, next_line, end, x, i);\
289 sD[i + rslope] += dcost * abs(i); \290 sD[i + rslope] += dcost * abs(i); \
290 \291 \
291 dmin = FFMIN(sD[i + rslope], dmin); \292 if (dmin > sD[i + rslope]) { \
293 dmin = sD[i + rslope]; \
294 di = 1; \
295 iD = i; \
296 } \
292 } \297 } \
293 \298 \
294 for (int i = -rslope; i <= rslope; i++) { \299 for (int i = -rslope; i <= rslope; i++) { \
@@ -306,23 +311,14 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 11 unmodified lines
306 sd[i + rslope] += mcost * cost_##ss(prev_line, next_line, end, x, k+i);\311 sd[i + rslope] += mcost * cost_##ss(prev_line, next_line, end, x, k+i);\
307 sd[i + rslope] += dcost * abs(k + i); \312 sd[i + rslope] += dcost * abs(k + i); \
308 \313 \
309 dmin = FFMIN(sd[i + rslope], dmin); \314 if (dmin > sd[i + rslope]) { \
310 } \315 dmin = sd[i + rslope]; \
311 \316 di = 0; \
312 for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \317 id = i; \
313 if (dmin == sD[i + rslope]) { \
314 di = 1; \
315 k = i; \
316 break; \
317 } \318 } \
318 } \319 } \
319 \320 \
320 for (int i = -rslope; i <= rslope && !di; i++) { \321 k = di ? iD : k + id; \
321 if (dmin == sd[i + rslope]) { \
322 k += i; \
323 break; \
324 } \
325 } \
326 \322 \
327 dst[x] = s->mid_##ss[interp](prev_line, next_line, \323 dst[x] = s->mid_##ss[interp](prev_line, next_line, \
328 prev2_line, next2_line, \324 prev2_line, next2_line, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t