History

avfilter/vf_estdif: simplify finding minimum score

Paul B Mahol committed 3 years ago

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

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_estdif.c+13−17
@@ -266,11 +266,12 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 265 unmodified lines
266266 const type *const next3_line = (const type *const)nnext3_line; \
267267 const int interp = s->interp; \
268268 const int ecost = s->ecost; \
269− const int dcost = s->dcost * s->max; \
270− const int end = width - 1; \
269+ const int dcost = s->dcost; \
271270 const int mcost = s->mcost; \
272271 atype sd[S], sD[S], di = 0; \
272+ const int end = width - 1; \
273273 atype dmin = amax; \
274+ int id = 0, iD = 0; \
274275 int k = *K; \
275276 \
276277 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
288289 sD[i + rslope] += mcost * cost_##ss(prev_line, next_line, end, x, i);\
289290 sD[i + rslope] += dcost * abs(i); \
290291 \
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+ } \
292297 } \
293298 \
294299 for (int i = -rslope; i <= rslope; i++) { \
@@ -306,23 +311,14 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 11 unmodified lines
306311 sd[i + rslope] += mcost * cost_##ss(prev_line, next_line, end, x, k+i);\
307312 sd[i + rslope] += dcost * abs(k + i); \
308313 \
309− dmin = FFMIN(sd[i + rslope], dmin); \
310− } \
311− \
312− for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \
313− if (dmin == sD[i + rslope]) { \
314− di = 1; \
315− k = i; \
316− break; \
314+ if (dmin > sd[i + rslope]) { \
315+ dmin = sd[i + rslope]; \
316+ di = 0; \
317+ id = i; \
317318 } \
318319 } \
319320 \
320− for (int i = -rslope; i <= rslope && !di; i++) { \
321− if (dmin == sd[i + rslope]) { \
322− k += i; \
323− break; \
324− } \
325− } \
321+ k = di ? iD : k + id; \
326322 \
327323 dst[x] = s->mid_##ss[interp](prev_line, next_line, \
328324 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