Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -35,6 +35,7 @@ typedef struct ESTDIFContext { · 34 unmodified lines | ||
| 35 | 35 | int deint; ///< which frames to deinterlace |
| 36 | 36 | int rslope; ///< best edge slope search radius |
| 37 | 37 | int redge; ///< best edge match search radius |
| 38 | + float dcost; ///< distance cost for edge matching | |
| 38 | 39 | int interp; ///< type of interpolation |
| 39 | 40 | int linesize[4]; ///< bytes of pixel data per line for each plane |
| 40 | 41 | int planewidth[4]; ///< width of each plane |
| @@ -42,7 +43,7 @@ typedef struct ESTDIFContext { · 1 unmodified line | ||
| 42 | 43 | int field; ///< which field are we on, 0 or 1 |
| 43 | 44 | int eof; |
| 44 | 45 | int depth; |
| 45 | − int half; | |
| 46 | + int max; | |
| 46 | 47 | int nb_planes; |
| 47 | 48 | int nb_threads; |
| 48 | 49 | int64_t pts; |
| @@ -52,7 +53,7 @@ typedef struct ESTDIFContext { · 3 unmodified lines | ||
| 52 | 53 | const uint8_t *prev_line, const uint8_t *next_line, |
| 53 | 54 | const uint8_t *prev2_line, const uint8_t *next2_line, |
| 54 | 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 | 57 | int depth, int *K); |
| 57 | 58 | |
| 58 | 59 | unsigned (*mid_8[3])(const uint8_t *const prev, |
| @@ -92,6 +93,7 @@ static const AVOption estdif_options[] = { · 33 unmodified lines | ||
| 92 | 93 | CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"), |
| 93 | 94 | { "rslope", "specify the search radius for edge slope tracing", OFFSET(rslope), AV_OPT_TYPE_INT, {.i64=1}, 1, MAX_R, FLAGS, }, |
| 94 | 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 | 97 | { "interp", "specify the type of interpolation", OFFSET(interp), AV_OPT_TYPE_INT, {.i64=1}, 0, 2, FLAGS, "interp" }, |
| 96 | 98 | CONST("2p", "two-point interpolation", 0, "interp"), |
| 97 | 99 | CONST("4p", "four-point interpolation", 1, "interp"), |
| @@ -239,7 +241,7 @@ static unsigned cost_##ss(const type *const prev, \ · 141 unmodified lines | ||
| 239 | 241 | COST(uint8_t, 8) |
| 240 | 242 | COST(uint16_t, 16) |
| 241 | 243 | |
| 242 | −#define INTERPOLATE(type, atype, max, ss) \ | |
| 244 | +#define INTERPOLATE(type, atype, amax, ss) \ | |
| 243 | 245 | static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ |
| 244 | 246 | const uint8_t *const pprev_line, \ |
| 245 | 247 | const uint8_t *const nnext_line, \ |
| @@ -248,7 +250,7 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 2 unmodified lines | ||
| 248 | 250 | const uint8_t *const pprev3_line, \ |
| 249 | 251 | const uint8_t *const nnext3_line, \ |
| 250 | 252 | int x, int width, int rslope, \ |
| 251 | − int redge, unsigned h, int depth, \ | |
| 253 | + int redge, int depth, \ | |
| 252 | 254 | int *K) \ |
| 253 | 255 | { \ |
| 254 | 256 | type *dst = (type *)ddst; \ |
| @@ -259,10 +261,11 @@ static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \ · 4 unmodified lines | ||
| 259 | 261 | const type *const next2_line = (const type *const)nnext2_line; \ |
| 260 | 262 | const type *const next3_line = (const type *const)nnext3_line; \ |
| 261 | 263 | const int interp = s->interp; \ |
| 264 | + const int dcost = s->dcost * s->max; \ | |
| 262 | 265 | const int end = width - 1; \ |
| 263 | 266 | const atype f = redge + 2; \ |
| 264 | 267 | atype sd[S], sD[S], di = 0; \ |
| 265 | − atype dmin = max; \ | |
| 268 | + atype dmin = amax; \ | |
| 266 | 269 | int k = *K; \ |
| 267 | 270 | \ |
| 268 | 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 | 280 | sD[i + rslope] = sum; \ |
| 278 | 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 | 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 | 296 | sd[i + rslope] = sum; \ |
| 294 | 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 | 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 | 335 | AVFrame *in = td->in; |
| 333 | 336 | const int rslope = s->rslope; |
| 334 | 337 | const int redge = s->redge; |
| 335 | − const int half = s->half; | |
| 336 | 338 | const int depth = s->depth; |
| 337 | 339 | const int interlaced = in->interlaced_frame; |
| 338 | 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 | 413 | prev_line, next_line, |
| 412 | 414 | prev2_line, next2_line, |
| 413 | 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 | 419 | out_line += 2 * dst_linesize; |
| @@ -475,7 +477,7 @@ static int config_input(AVFilterLink *inlink) · 57 unmodified lines | ||
| 475 | 477 | s->mid_16[0] = mid2_16; |
| 476 | 478 | s->mid_16[1] = mid4_16; |
| 477 | 479 | s->mid_16[2] = mid6_16; |
| 478 | − s->half = 1 << (s->depth - 1); | |
| 480 | + s->max = (1 << (s->depth)) - 1; | |
| 479 | 481 | |
| 480 | 482 | return 0; |
| 481 | 483 | } |