summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-05-09 10:20:03 +0200
committerPaul B Mahol <onemda@gmail.com>2023-05-09 12:12:46 +0200
commit57f264e78cb06fd8686b78f93b057122afdb3d44 (patch)
tree9364ba015283738ab4252d894eee6c8bc3376acf /libavfilter
parent16a86b443dba748ccbe174b9895a21fc8378889c (diff)
downloadffmpeg-57f264e78cb06fd8686b78f93b057122afdb3d44.tar.gz
avfilter/vf_estdif: simplify finding minimum score
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_estdif.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c
index 452361d717..91e8431e35 100644
--- a/libavfilter/vf_estdif.c
+++ b/libavfilter/vf_estdif.c
@@ -266,11 +266,12 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \
const type *const next3_line = (const type *const)nnext3_line; \
const int interp = s->interp; \
const int ecost = s->ecost; \
- const int dcost = s->dcost * s->max; \
- const int end = width - 1; \
+ const int dcost = s->dcost; \
const int mcost = s->mcost; \
atype sd[S], sD[S], di = 0; \
+ const int end = width - 1; \
atype dmin = amax; \
+ int id = 0, iD = 0; \
int k = *K; \
\
for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \
@@ -288,7 +289,11 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \
sD[i + rslope] += mcost * cost_##ss(prev_line, next_line, end, x, i);\
sD[i + rslope] += dcost * abs(i); \
\
- dmin = FFMIN(sD[i + rslope], dmin); \
+ if (dmin > sD[i + rslope]) { \
+ dmin = sD[i + rslope]; \
+ di = 1; \
+ iD = i; \
+ } \
} \
\
for (int i = -rslope; i <= rslope; i++) { \
@@ -306,23 +311,14 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \
sd[i + rslope] += mcost * cost_##ss(prev_line, next_line, end, x, k+i);\
sd[i + rslope] += dcost * abs(k + i); \
\
- dmin = FFMIN(sd[i + rslope], dmin); \
- } \
- \
- for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \
- if (dmin == sD[i + rslope]) { \
- di = 1; \
- k = i; \
- break; \
+ if (dmin > sd[i + rslope]) { \
+ dmin = sd[i + rslope]; \
+ di = 0; \
+ id = i; \
} \
} \
\
- for (int i = -rslope; i <= rslope && !di; i++) { \
- if (dmin == sd[i + rslope]) { \
- k += i; \
- break; \
- } \
- } \
+ k = di ? iD : k + id; \
\
dst[x] = s->mid_##ss[interp](prev_line, next_line, \
prev2_line, next2_line, \