History

avfilter/vf_estdif: export distance cost as filter option

Paul B Mahol committed 5 years ago

Commit dcf83fd1 parent 45dc6682 files · +16 −10Browse files

Unified · Split

2 files
  1. doc/filters.texi +4 −0
  2. libavfilter/vf_estdif.c +12 −10
doc/filters.texi+4−0
@@ -11711,6 +11711,10 @@ Allowed range is from 1 to 15. · 11710 unmodified lines
11711Specify the search radius for best edge matching. Default value is 2.11711Specify the search radius for best edge matching. Default value is 2.
11712Allowed range is from 0 to 15.11712Allowed range is from 0 to 15.
11713 11713
11714@item dcost
11715Specify the distance cost for edge matching. Default value is 0.5.
11716Allowed range is from 0 to 1.
11717
11714@item interp11718@item interp
11715Specify the interpolation used. Default is 4-point interpolation. It accepts one11719Specify the interpolation used. Default is 4-point interpolation. It accepts one
11716of the following values:11720of the following values:
libavfilter/vf_estdif.c+12−10
@@ -35,6 +35,7 @@ typedef struct ESTDIFContext { · 34 unmodified lines
35 int deint; ///< which frames to deinterlace35 int deint; ///< which frames to deinterlace
36 int rslope; ///< best edge slope search radius36 int rslope; ///< best edge slope search radius
37 int redge; ///< best edge match search radius37 int redge; ///< best edge match search radius
38 float dcost; ///< distance cost for edge matching
38 int interp; ///< type of interpolation39 int interp; ///< type of interpolation
39 int linesize[4]; ///< bytes of pixel data per line for each plane40 int linesize[4]; ///< bytes of pixel data per line for each plane
40 int planewidth[4]; ///< width of each plane41 int planewidth[4]; ///< width of each plane
@@ -42,7 +43,7 @@ typedef struct ESTDIFContext { · 1 unmodified line
42 int field; ///< which field are we on, 0 or 143 int field; ///< which field are we on, 0 or 1
43 int eof;44 int eof;
44 int depth;45 int depth;
45 int half;46 int max;
46 int nb_planes;47 int nb_planes;
47 int nb_threads;48 int nb_threads;
48 int64_t pts;49 int64_t pts;
@@ -52,7 +53,7 @@ typedef struct ESTDIFContext { · 3 unmodified lines
52 const uint8_t *prev_line, const uint8_t *next_line,53 const uint8_t *prev_line, const uint8_t *next_line,
53 const uint8_t *prev2_line, const uint8_t *next2_line,54 const uint8_t *prev2_line, const uint8_t *next2_line,
54 const uint8_t *prev3_line, const uint8_t *next3_line,55 const uint8_t *prev3_line, const uint8_t *next3_line,
55 int x, int width, int rslope, int redge, unsigned half,56 int x, int width, int rslope, int redge,
56 int depth, int *K);57 int depth, int *K);
57 58
58 unsigned (*mid_8[3])(const uint8_t *const prev,59 unsigned (*mid_8[3])(const uint8_t *const prev,
@@ -92,6 +93,7 @@ static const AVOption estdif_options[] = { · 33 unmodified lines
92 CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),93 CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),
93 { "rslope", "specify the search radius for edge slope tracing", OFFSET(rslope), AV_OPT_TYPE_INT, {.i64=1}, 1, MAX_R, FLAGS, },94 { "rslope", "specify the search radius for edge slope tracing", OFFSET(rslope), AV_OPT_TYPE_INT, {.i64=1}, 1, MAX_R, FLAGS, },
94 { "redge", "specify the search radius for best edge matching", OFFSET(redge), AV_OPT_TYPE_INT, {.i64=2}, 0, MAX_R, FLAGS, },95 { "redge", "specify the search radius for best edge matching", OFFSET(redge), AV_OPT_TYPE_INT, {.i64=2}, 0, MAX_R, FLAGS, },
96 { "dcost", "specify the distance cost for edge matching", OFFSET(dcost), AV_OPT_TYPE_FLOAT,{.dbl=0.5}, 0, 1, FLAGS, },
95 { "interp", "specify the type of interpolation", OFFSET(interp), AV_OPT_TYPE_INT, {.i64=1}, 0, 2, FLAGS, "interp" },97 { "interp", "specify the type of interpolation", OFFSET(interp), AV_OPT_TYPE_INT, {.i64=1}, 0, 2, FLAGS, "interp" },
96 CONST("2p", "two-point interpolation", 0, "interp"),98 CONST("2p", "two-point interpolation", 0, "interp"),
97 CONST("4p", "four-point interpolation", 1, "interp"),99 CONST("4p", "four-point interpolation", 1, "interp"),
@@ -239,7 +241,7 @@ static unsigned cost_##ss(const type *const prev, \ · 141 unmodified lines
239COST(uint8_t, 8)241COST(uint8_t, 8)
240COST(uint16_t, 16)242COST(uint16_t, 16)
241 243
242#define INTERPOLATE(type, atype, max, ss) \244#define INTERPOLATE(type, atype, amax, ss) \
243static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \245static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \
244 const uint8_t *const pprev_line, \246 const uint8_t *const pprev_line, \
245 const uint8_t *const nnext_line, \247 const uint8_t *const nnext_line, \
@@ -248,7 +250,7 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 2 unmodified lines
248 const uint8_t *const pprev3_line, \250 const uint8_t *const pprev3_line, \
249 const uint8_t *const nnext3_line, \251 const uint8_t *const nnext3_line, \
250 int x, int width, int rslope, \252 int x, int width, int rslope, \
251 int redge, unsigned h, int depth, \253 int redge, int depth, \
252 int *K) \254 int *K) \
253{ \255{ \
254 type *dst = (type *)ddst; \256 type *dst = (type *)ddst; \
@@ -259,10 +261,11 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 4 unmodified lines
259 const type *const next2_line = (const type *const)nnext2_line; \261 const type *const next2_line = (const type *const)nnext2_line; \
260 const type *const next3_line = (const type *const)nnext3_line; \262 const type *const next3_line = (const type *const)nnext3_line; \
261 const int interp = s->interp; \263 const int interp = s->interp; \
264 const int dcost = s->dcost * s->max; \
262 const int end = width - 1; \265 const int end = width - 1; \
263 const atype f = redge + 2; \266 const atype f = redge + 2; \
264 atype sd[S], sD[S], di = 0; \267 atype sd[S], sD[S], di = 0; \
265 atype dmin = max; \268 atype dmin = amax; \
266 int k = *K; \269 int k = *K; \
267 \270 \
268 for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \271 for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \
@@ -276,7 +279,7 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 7 unmodified lines
276 \279 \
277 sD[i + rslope] = sum; \280 sD[i + rslope] = sum; \
278 sD[i + rslope] += f * cost_##ss(prev_line, next_line, end, x, i); \281 sD[i + rslope] += f * cost_##ss(prev_line, next_line, end, x, i); \
279 sD[i + rslope] += h * abs(i); \282 sD[i + rslope] += dcost * abs(i); \
280 \283 \
281 dmin = FFMIN(sD[i + rslope], dmin); \284 dmin = FFMIN(sD[i + rslope], dmin); \
282 } \285 } \
@@ -292,7 +295,7 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 9 unmodified lines
292 \295 \
293 sd[i + rslope] = sum; \296 sd[i + rslope] = sum; \
294 sd[i + rslope] += f * cost_##ss(prev_line, next_line, end, x, k + i); \297 sd[i + rslope] += f * cost_##ss(prev_line, next_line, end, x, k + i); \
295 sd[i + rslope] += h * abs(k + i); \298 sd[i + rslope] += dcost * abs(k + i); \
296 \299 \
297 dmin = FFMIN(sd[i + rslope], dmin); \300 dmin = FFMIN(sd[i + rslope], dmin); \
298 } \301 } \
@@ -332,7 +335,6 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg, · 33 unmodified lines
332 AVFrame *in = td->in;335 AVFrame *in = td->in;
333 const int rslope = s->rslope;336 const int rslope = s->rslope;
334 const int redge = s->redge;337 const int redge = s->redge;
335 const int half = s->half;
336 const int depth = s->depth;338 const int depth = s->depth;
337 const int interlaced = in->interlaced_frame;339 const int interlaced = in->interlaced_frame;
338 const int tff = (s->field == (s->parity == -1 ? interlaced ? in->top_field_first : 1 :340 const int tff = (s->field == (s->parity == -1 ? interlaced ? in->top_field_first : 1 :
@@ -411,7 +413,7 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg, · 72 unmodified lines
411 prev_line, next_line,413 prev_line, next_line,
412 prev2_line, next2_line,414 prev2_line, next2_line,
413 prev3_line, next3_line,415 prev3_line, next3_line,
414 x, width, rslope, redge, half, depth, &k);416 x, width, rslope, redge, depth, &k);
415 }417 }
416 418
417 out_line += 2 * dst_linesize;419 out_line += 2 * dst_linesize;
@@ -475,7 +477,7 @@ static int config_input(AVFilterLink *inlink) · 57 unmodified lines
475 s->mid_16[0] = mid2_16;477 s->mid_16[0] = mid2_16;
476 s->mid_16[1] = mid4_16;478 s->mid_16[1] = mid4_16;
477 s->mid_16[2] = mid6_16;479 s->mid_16[2] = mid6_16;
478 s->half = 1 << (s->depth - 1);480 s->max = (1 << (s->depth)) - 1;
479 481
480 return 0;482 return 0;
481}483}

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