FFmpeg
Loading...
Searching...
No Matches
vf_estdif.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Paul B Mahol
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "libavutil/common.h"
22#include "libavutil/imgutils.h"
23#include "libavutil/opt.h"
24#include "libavutil/pixdesc.h"
25#include "avfilter.h"
26#include "filters.h"
27#include "video.h"
28
29typedef struct ESTDIFContext {
30 const AVClass *class;
31
32 int mode; ///< 0 is frame, 1 is field
33 int parity; ///< frame field parity
34 int deint; ///< which frames to deinterlace
35 int rslope; ///< best edge slope search radius
36 int redge; ///< best edge match search radius
37 int ecost; ///< edge cost for edge matching
38 int mcost; ///< middle cost for edge matching
39 int dcost; ///< distance cost for edge matching
40 int interp; ///< type of interpolation
41 int linesize[4]; ///< bytes of pixel data per line for each plane
42 int planewidth[4]; ///< width of each plane
43 int planeheight[4]; ///< height of each plane
44 int field; ///< which field are we on, 0 or 1
45 int eof;
46 int depth;
47 int max;
51
52 void (*interpolate)(struct ESTDIFContext *s, uint8_t *dst,
53 const uint8_t *prev_line, const uint8_t *next_line,
54 const uint8_t *prev2_line, const uint8_t *next2_line,
55 const uint8_t *prev3_line, const uint8_t *next3_line,
56 int x, int width, int rslope, int redge,
57 int depth, int *K);
58
59 unsigned (*mid_8[3])(const uint8_t *const prev,
60 const uint8_t *const next,
61 const uint8_t *const prev2,
62 const uint8_t *const next2,
63 const uint8_t *const prev3,
64 const uint8_t *const next3,
65 int end, int x, int k, int depth);
66
67 unsigned (*mid_16[3])(const uint16_t *const prev,
68 const uint16_t *const next,
69 const uint16_t *const prev2,
70 const uint16_t *const next2,
71 const uint16_t *const prev3,
72 const uint16_t *const next3,
73 int end, int x, int k, int depth);
75
76#define MAX_R 15
77#define S (MAX_R * 2 + 1)
78
79#define OFFSET(x) offsetof(ESTDIFContext, x)
80#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
81#define CONST(name, help, val, u) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, .unit = u }
82
83static const AVOption estdif_options[] = {
84 { "mode", "specify the mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, .unit = "mode" },
85 CONST("frame", "send one frame for each frame", 0, "mode"),
86 CONST("field", "send one frame for each field", 1, "mode"),
87 { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS, .unit = "parity" },
88 CONST("tff", "assume top field first", 0, "parity"),
89 CONST("bff", "assume bottom field first", 1, "parity"),
90 CONST("auto", "auto detect parity", -1, "parity"),
91 { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, .unit = "deint" },
92 CONST("all", "deinterlace all frames", 0, "deint"),
93 CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),
94 { "rslope", "specify the search radius for edge slope tracing", OFFSET(rslope), AV_OPT_TYPE_INT, {.i64=1}, 1, 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 { "ecost", "specify the edge cost for edge matching", OFFSET(ecost), AV_OPT_TYPE_INT, {.i64=2}, 0, 50, FLAGS },
97 { "mcost", "specify the middle cost for edge matching", OFFSET(mcost), AV_OPT_TYPE_INT, {.i64=1}, 0, 50, FLAGS },
98 { "dcost", "specify the distance cost for edge matching", OFFSET(dcost), AV_OPT_TYPE_INT, {.i64=1}, 0, 50, FLAGS },
99 { "interp", "specify the type of interpolation", OFFSET(interp), AV_OPT_TYPE_INT, {.i64=1}, 0, 2, FLAGS, .unit = "interp" },
100 CONST("2p", "two-point interpolation", 0, "interp"),
101 CONST("4p", "four-point interpolation", 1, "interp"),
102 CONST("6p", "six-point interpolation", 2, "interp"),
103 { NULL }
104};
105
107
133
134static int config_output(AVFilterLink *outlink)
135{
136 FilterLink *outl = ff_filter_link(outlink);
137 AVFilterContext *ctx = outlink->src;
138 AVFilterLink *inlink = ctx->inputs[0];
139 FilterLink *inl = ff_filter_link(inlink);
140 ESTDIFContext *s = ctx->priv;
141
142 outlink->time_base = av_mul_q(inlink->time_base, (AVRational){1, 2});
143 if (s->mode)
144 outl->frame_rate = av_mul_q(inl->frame_rate, (AVRational){2, 1});
145
146 return 0;
147}
148
149typedef struct ThreadData {
150 AVFrame *out, *in;
151} ThreadData;
152
153#define MIDL(type, ss) \
154static unsigned midl_##ss(const type *const prev, \
155 const type *const next, \
156 int end, int x, int k) \
157{ \
158 return (prev[av_clip(x + k, 0, end)] + \
159 next[av_clip(x - k, 0, end)] + 1) >> 1; \
160}
161
162MIDL(uint8_t, 8)
163MIDL(uint16_t, 16)
164
165#define MID2(type, ss) \
166static unsigned mid2_##ss(const type *const prev, \
167 const type *const next, \
168 const type *const prev2, \
169 const type *const next2, \
170 const type *const prev3, \
171 const type *const next3, \
172 int end, int x, int k, int depth) \
173{ \
174 return (prev[av_clip(x + k, 0, end)] + \
175 next[av_clip(x - k, 0, end)] + 1) >> 1; \
176}
177
178MID2(uint8_t, 8)
179MID2(uint16_t, 16)
180
181#define MID4(type, ss) \
182static unsigned mid4_##ss(const type *const prev, \
183 const type *const next, \
184 const type *const prev2, \
185 const type *const next2, \
186 const type *const prev3, \
187 const type *const next3, \
188 int end, int x, int k, int depth) \
189{ \
190 return av_clip_uintp2_c(( \
191 9 * (prev[av_clip(x + k, 0, end)] + \
192 next[av_clip(x - k, 0, end)]) - \
193 1 * (prev2[av_clip(x + k*3, 0, end)] + \
194 next2[av_clip(x - k*3, 0, end)]) + 8) >> 4, \
195 depth); \
196}
197
198MID4(uint8_t, 8)
199MID4(uint16_t, 16)
200
201#define MID6(type, ss) \
202static unsigned mid6_##ss(const type *const prev, \
203 const type *const next, \
204 const type *const prev2, \
205 const type *const next2, \
206 const type *const prev3, \
207 const type *const next3, \
208 int end, int x, int k, int depth) \
209{ \
210 return av_clip_uintp2_c(( \
211 20 * (prev[av_clip(x + k, 0, end)] + \
212 next[av_clip(x - k, 0, end)]) - \
213 5 * (prev2[av_clip(x + k*3, 0, end)] + \
214 next2[av_clip(x - k*3, 0, end)]) + \
215 1 * (prev3[av_clip(x + k*5, 0, end)] + \
216 next3[av_clip(x - k*5, 0, end)]) + 16) >> 5, \
217 depth); \
218}
219
220MID6(uint8_t, 8)
221MID6(uint16_t, 16)
222
223#define DIFF(type, ss) \
224static unsigned diff_##ss(const type *const prev, \
225 const type *const next, \
226 int x, int y) \
227{ \
228 return FFABS(prev[x] - next[y]); \
229}
230
231DIFF(uint8_t, 8)
232DIFF(uint16_t, 16)
233
234#define COST(type, ss) \
235static unsigned cost_##ss(const type *const prev, \
236 const type *const next, \
237 int end, int x, int k) \
238{ \
239 const int m = midl_##ss(prev, next, end, x, k); \
240 const int p = prev[x]; \
241 const int n = next[x]; \
242 \
243 return FFABS(p - m) + FFABS(n - m); \
244}
245
246COST(uint8_t, 8)
247COST(uint16_t, 16)
248
249#define INTERPOLATE(type, atype, amax, ss) \
250static void interpolate_##ss(ESTDIFContext *s, uint8_t *ddst, \
251 const uint8_t *const pprev_line, \
252 const uint8_t *const nnext_line, \
253 const uint8_t *const pprev2_line, \
254 const uint8_t *const nnext2_line, \
255 const uint8_t *const pprev3_line, \
256 const uint8_t *const nnext3_line, \
257 int x, int width, int rslope, \
258 int redge, int depth, \
259 int *K) \
260{ \
261 type *dst = (type *)ddst; \
262 const type *const prev_line = (const type *const)pprev_line; \
263 const type *const prev2_line = (const type *const)pprev2_line; \
264 const type *const prev3_line = (const type *const)pprev3_line; \
265 const type *const next_line = (const type *const)nnext_line; \
266 const type *const next2_line = (const type *const)nnext2_line; \
267 const type *const next3_line = (const type *const)nnext3_line; \
268 const int interp = s->interp; \
269 const int ecost = s->ecost; \
270 const int dcost = s->dcost; \
271 const int mcost = s->mcost; \
272 atype sd[S], sD[S], di = 0; \
273 const int end = width - 1; \
274 atype dmin = amax; \
275 int id = 0, iD = 0; \
276 int k = *K; \
277 \
278 for (int i = -rslope; i <= rslope && abs(k) > rslope; i++) { \
279 atype sum = 0; \
280 \
281 for (int j = -redge; j <= redge; j++) { \
282 const int xx = av_clip(x + i + j, 0, end); \
283 const int yy = av_clip(x - i + j, 0, end); \
284 sum += diff_##ss(prev_line, next_line, xx, yy); \
285 sum += diff_##ss(prev2_line, prev_line, xx, yy); \
286 sum += diff_##ss(next_line, next2_line, xx, yy); \
287 } \
288 \
289 sD[i + rslope] = ecost * sum; \
290 sD[i + rslope] += mcost * cost_##ss(prev_line, next_line, end, x, i);\
291 sD[i + rslope] += dcost * abs(i); \
292 \
293 if (dmin > sD[i + rslope]) { \
294 dmin = sD[i + rslope]; \
295 di = 1; \
296 iD = i; \
297 } \
298 } \
299 \
300 for (int i = -rslope; i <= rslope; i++) { \
301 atype sum = 0; \
302 \
303 for (int j = -redge; j <= redge; j++) { \
304 const int xx = av_clip(x + k + i + j, 0, end); \
305 const int yy = av_clip(x - k - i + j, 0, end); \
306 sum += diff_##ss(prev_line, next_line, xx, yy); \
307 sum += diff_##ss(prev2_line, prev_line, xx, yy); \
308 sum += diff_##ss(next_line, next2_line, xx, yy); \
309 } \
310 \
311 sd[i + rslope] = ecost * sum; \
312 sd[i + rslope] += mcost * cost_##ss(prev_line, next_line, end, x, k+i);\
313 sd[i + rslope] += dcost * abs(k + i); \
314 \
315 if (dmin > sd[i + rslope]) { \
316 dmin = sd[i + rslope]; \
317 di = 0; \
318 id = i; \
319 } \
320 } \
321 \
322 k = di ? iD : k + id; \
323 \
324 dst[x] = s->mid_##ss[interp](prev_line, next_line, \
325 prev2_line, next2_line, \
326 prev3_line, next3_line, \
327 end, x, k, depth); \
328 \
329 *K = k; \
330}
331
332INTERPOLATE(uint8_t, unsigned, UINT_MAX, 8)
333INTERPOLATE(uint16_t, uint64_t, UINT64_MAX, 16)
334
336 int jobnr, int nb_jobs)
337{
338 ESTDIFContext *s = ctx->priv;
339 ThreadData *td = arg;
340 AVFrame *out = td->out;
341 AVFrame *in = td->in;
342 const int rslope = s->rslope;
343 const int redge = s->redge;
344 const int depth = s->depth;
345 const int interlaced = !!(in->flags & AV_FRAME_FLAG_INTERLACED);
346 const int tff = (s->field == (s->parity == -1 ? interlaced ? !!(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1 :
347 s->parity ^ 1));
348
349 for (int plane = 0; plane < s->nb_planes; plane++) {
350 const uint8_t *src_data = in->data[plane];
351 uint8_t *dst_data = out->data[plane];
352 const int linesize = s->linesize[plane];
353 const int width = s->planewidth[plane];
354 const int height = s->planeheight[plane];
355 const int src_linesize = in->linesize[plane];
356 const int dst_linesize = out->linesize[plane];
357 const int start = ff_slice_pos(height, jobnr, nb_jobs);
358 const int end = ff_slice_pos(height, jobnr + 1, nb_jobs);
359 const uint8_t *prev_line, *prev2_line, *next_line, *next2_line, *in_line;
360 const uint8_t *prev3_line, *next3_line;
361 uint8_t *out_line;
362 int y_out;
363
364 y_out = start + (tff ^ (start & 1));
365
366 in_line = src_data + (y_out * src_linesize);
367 out_line = dst_data + (y_out * dst_linesize);
368
369 while (y_out < end) {
370 memcpy(out_line, in_line, linesize);
371 y_out += 2;
372 in_line += src_linesize * 2;
373 out_line += dst_linesize * 2;
374 }
375
376 y_out = start + ((!tff) ^ (start & 1));
377 out_line = dst_data + (y_out * dst_linesize);
378
379 for (int y = y_out; y < end; y += 2) {
380 int y_prev3_in = y - 5;
381 int y_next3_in = y + 5;
382 int y_prev2_in = y - 3;
383 int y_next2_in = y + 3;
384 int y_prev_in = y - 1;
385 int y_next_in = y + 1;
386 int k;
387
388 while (y_prev3_in < 0)
389 y_prev3_in += 2;
390
391 while (y_next3_in >= height)
392 y_next3_in -= 2;
393
394 while (y_prev2_in < 0)
395 y_prev2_in += 2;
396
397 while (y_next2_in >= height)
398 y_next2_in -= 2;
399
400 while (y_prev_in < 0)
401 y_prev_in += 2;
402
403 while (y_next_in >= height)
404 y_next_in -= 2;
405
406 prev3_line = src_data + (y_prev3_in * src_linesize);
407 next3_line = src_data + (y_next3_in * src_linesize);
408
409 prev2_line = src_data + (y_prev2_in * src_linesize);
410 next2_line = src_data + (y_next2_in * src_linesize);
411
412 prev_line = src_data + (y_prev_in * src_linesize);
413 next_line = src_data + (y_next_in * src_linesize);
414
415 k = 0;
416
417 for (int x = 0; x < width; x++) {
418 s->interpolate(s, out_line,
419 prev_line, next_line,
420 prev2_line, next2_line,
421 prev3_line, next3_line,
422 x, width, rslope, redge, depth, &k);
423 }
424
425 out_line += 2 * dst_linesize;
426 }
427 }
428
429 return 0;
430}
431
433{
434 ESTDIFContext *s = ctx->priv;
435 AVFilterLink *outlink = ctx->outputs[0];
436 AVFrame *out;
437 ThreadData td;
438
439 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
440 if (!out)
441 return AVERROR(ENOMEM);
444 out->pts = pts;
445 out->duration = duration;
446
447 td.out = out; td.in = in;
449 FFMIN(s->planeheight[1] / 2, s->nb_threads));
450
451 if (s->mode)
452 s->field = !s->field;
453
454 return ff_filter_frame(outlink, out);
455}
456
457static int config_input(AVFilterLink *inlink)
458{
459 AVFilterContext *ctx = inlink->dst;
460 ESTDIFContext *s = ctx->priv;
462 int ret;
463
464 if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
465 return ret;
466
467 s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
468 s->planeheight[0] = s->planeheight[3] = inlink->h;
469 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
470 s->planewidth[0] = s->planewidth[3] = inlink->w;
471
472 if (inlink->h < 3) {
473 av_log(ctx, AV_LOG_ERROR, "Video of less than 3 lines is not supported\n");
474 return AVERROR(EINVAL);
475 }
476
477 s->nb_planes = av_pix_fmt_count_planes(inlink->format);
478 s->nb_threads = ff_filter_get_nb_threads(ctx);
479 s->depth = desc->comp[0].depth;
480 s->interpolate = s->depth <= 8 ? interpolate_8 : interpolate_16;
481 s->mid_8[0] = mid2_8;
482 s->mid_8[1] = mid4_8;
483 s->mid_8[2] = mid6_8;
484 s->mid_16[0] = mid2_16;
485 s->mid_16[1] = mid4_16;
486 s->mid_16[2] = mid6_16;
487 s->max = (1 << (s->depth)) - 1;
488
489 return 0;
490}
491 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
492{
493 AVFilterContext *ctx = inlink->dst;
494 ESTDIFContext *s = ctx->priv;
495 int ret;
496
497 if (!s->prev) {
498 s->prev = in;
499 return 0;
500 }
501
502 if ((s->deint && !(s->prev->flags & AV_FRAME_FLAG_INTERLACED)) || ctx->is_disabled) {
503 s->prev->pts *= 2;
504 s->prev->duration *= 2;
505 ret = ff_filter_frame(ctx->outputs[0], s->prev);
506 s->prev = in;
507 return ret;
508 }
509
510 ret = filter(ctx, s->prev, s->prev->pts * 2,
511 s->prev->duration * (s->mode ? 1 : 2));
512 if (ret < 0 || s->mode == 0) {
513 av_frame_free(&s->prev);
514 s->prev = in;
515 return ret;
516 }
517
518 ret = filter(ctx, s->prev, s->prev->pts + in->pts, in->duration);
519 av_frame_free(&s->prev);
520 s->prev = in;
521 return ret;
522}
523
525{
526 FilterLink *l = ff_filter_link(link);
527 AVFilterContext *ctx = link->src;
528 ESTDIFContext *s = ctx->priv;
529 int ret;
530
531 if (s->eof)
532 return AVERROR_EOF;
533
534 ret = ff_request_frame(ctx->inputs[0]);
535
536 if (ret == AVERROR_EOF && s->prev) {
537 AVFrame *next = av_frame_clone(s->prev);
538
539 if (!next)
540 return AVERROR(ENOMEM);
541
542 next->pts = s->prev->pts + av_rescale_q(1, av_inv_q(l->frame_rate),
543 ctx->outputs[0]->time_base);
544 s->eof = 1;
545 ret = filter_frame(ctx->inputs[0], next);
546 } else if (ret < 0) {
547 return ret;
548 }
549
550 return ret;
551}
552
554{
555 ESTDIFContext *s = ctx->priv;
556
557 av_frame_free(&s->prev);
558}
559
560static const AVFilterPad estdif_inputs[] = {
561 {
562 .name = "default",
563 .type = AVMEDIA_TYPE_VIDEO,
564 .filter_frame = filter_frame,
565 .config_props = config_input,
566 },
567};
568
569static const AVFilterPad estdif_outputs[] = {
570 {
571 .name = "default",
572 .type = AVMEDIA_TYPE_VIDEO,
573 .config_props = config_output,
574 .request_frame = request_frame,
575 },
576};
577
579 .p.name = "estdif",
580 .p.description = NULL_IF_CONFIG_SMALL("Apply Edge Slope Tracing deinterlace."),
581 .p.priv_class = &estdif_class,
583 .priv_size = sizeof(ESTDIFContext),
584 .uninit = uninit,
588 .process_command = ff_filter_process_command,
589};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static int config_input(AVFilterLink *inlink)
static int request_frame(AVFilterLink *outlink)
Definition af_aecho.c:272
const FFFilter ff_vf_estdif
Definition vf_estdif.c:578
#define INTERPOLATE(old, new, nsample)
Definition atrac3.c:469
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition avfilter.c:906
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition avfilter.c:483
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition avfilter.c:1696
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition avfilter.c:846
Main libavfilter public API header.
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:598
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
static int64_t duration
Definition ffplay.c:330
#define COST(old, new)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition avfilter.h:204
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition frame.h:695
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
Definition frame.h:700
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:599
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition frame.c:483
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition rational.c:80
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition rational.h:159
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition imgutils.c:89
misc image utilities
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
const char * arg
Definition jacosubdec.c:65
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition filters.h:763
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
const char * desc
Definition libsvtav1.c:83
#define FFMIN(a, b)
Definition macros.h:49
uint8_t interlaced
Definition mxfenc.c:2336
AVOptions.
#define K
Definition palette.c:25
#define DIFF(a, as, b, bs)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3500
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
#define AV_PIX_FMT_GBRAP12
Definition pixfmt.h:569
#define AV_PIX_FMT_YUV420P16
Definition pixfmt.h:556
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUV444P9
Definition pixfmt.h:544
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:545
#define AV_PIX_FMT_YUV440P12
Definition pixfmt.h:551
#define AV_PIX_FMT_GRAY9
Definition pixfmt.h:524
#define AV_PIX_FMT_GBRAP16
Definition pixfmt.h:571
#define AV_PIX_FMT_GBRP9
Definition pixfmt.h:563
#define AV_PIX_FMT_YUV422P9
Definition pixfmt.h:543
#define AV_PIX_FMT_YUVA444P10
Definition pixfmt.h:598
#define AV_PIX_FMT_YUVA420P16
Definition pixfmt.h:601
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:549
#define AV_PIX_FMT_YUVA420P10
Definition pixfmt.h:596
#define AV_PIX_FMT_YUVA422P9
Definition pixfmt.h:594
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:550
#define AV_PIX_FMT_GBRP10
Definition pixfmt.h:564
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:546
#define AV_PIX_FMT_GRAY12
Definition pixfmt.h:526
#define AV_PIX_FMT_GBRP12
Definition pixfmt.h:565
#define AV_PIX_FMT_YUV420P9
Definition pixfmt.h:542
#define AV_PIX_FMT_YUVA420P9
Definition pixfmt.h:593
#define AV_PIX_FMT_YUVA422P10
Definition pixfmt.h:597
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:553
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition pixfmt.h:108
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition pixfmt.h:107
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition pixfmt.h:174
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition pixfmt.h:283
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition pixfmt.h:212
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition pixfmt.h:86
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition pixfmt.h:173
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition pixfmt.h:87
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition pixfmt.h:85
#define AV_PIX_FMT_YUVA422P12
Definition pixfmt.h:599
#define AV_PIX_FMT_YUV422P14
Definition pixfmt.h:554
#define AV_PIX_FMT_GRAY10
Definition pixfmt.h:525
#define AV_PIX_FMT_GRAY14
Definition pixfmt.h:527
#define AV_PIX_FMT_YUV422P16
Definition pixfmt.h:557
#define AV_PIX_FMT_YUV440P10
Definition pixfmt.h:547
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:528
#define AV_PIX_FMT_GBRAP10
Definition pixfmt.h:568
#define AV_PIX_FMT_YUVA444P16
Definition pixfmt.h:603
#define AV_PIX_FMT_YUVA422P16
Definition pixfmt.h:602
#define AV_PIX_FMT_GBRP16
Definition pixfmt.h:567
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:555
#define AV_PIX_FMT_YUVA444P9
Definition pixfmt.h:595
#define AV_PIX_FMT_GBRP14
Definition pixfmt.h:566
#define AV_PIX_FMT_YUVA444P12
Definition pixfmt.h:600
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:273
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition frame.h:574
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:493
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition frame.h:716
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition frame.h:517
int64_t duration
Duration of the frame, in the same units as pts.
Definition frame.h:820
AVOption.
Definition opt.h:428
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
Rational number (pair of numerator and denominator).
Definition rational.h:58
int planewidth[4]
width of each plane
Definition vf_estdif.c:42
int ecost
edge cost for edge matching
Definition vf_estdif.c:37
int dcost
distance cost for edge matching
Definition vf_estdif.c:39
int interp
type of interpolation
Definition vf_estdif.c:40
unsigned(* mid_16[3])(const uint16_t *const prev, const uint16_t *const next, const uint16_t *const prev2, const uint16_t *const next2, const uint16_t *const prev3, const uint16_t *const next3, int end, int x, int k, int depth)
Definition vf_estdif.c:67
int mode
0 is frame, 1 is field
Definition vf_estdif.c:32
AVFrame * prev
Definition vf_estdif.c:50
int parity
frame field parity
Definition vf_estdif.c:33
int field
which field are we on, 0 or 1
Definition vf_estdif.c:44
int redge
best edge match search radius
Definition vf_estdif.c:36
void(* interpolate)(struct ESTDIFContext *s, uint8_t *dst, const uint8_t *prev_line, const uint8_t *next_line, const uint8_t *prev2_line, const uint8_t *next2_line, const uint8_t *prev3_line, const uint8_t *next3_line, int x, int width, int rslope, int redge, int depth, int *K)
Definition vf_estdif.c:52
int mcost
middle cost for edge matching
Definition vf_estdif.c:38
unsigned(* mid_8[3])(const uint8_t *const prev, const uint8_t *const next, const uint8_t *const prev2, const uint8_t *const next2, const uint8_t *const prev3, const uint8_t *const next3, int end, int x, int k, int depth)
Definition vf_estdif.c:59
int linesize[4]
bytes of pixel data per line for each plane
Definition vf_estdif.c:41
int rslope
best edge slope search radius
Definition vf_estdif.c:35
int deint
which frames to deinterlace
Definition vf_estdif.c:34
int planeheight[4]
height of each plane
Definition vf_estdif.c:43
Used for passing data between threads.
Definition dsddec.c:71
AVFrame * out
Definition swscale.c:71
#define av_log(a,...)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29
static FILE * out
Definition movenc.c:55
static AVFormatContext * ctx
Definition movenc.c:49
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
static int64_t pts
interp
Definition vf_curves.c:62
#define MAX_R
Definition vf_deshake.c:87
static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_estdif.c:335
static const AVFilterPad estdif_outputs[]
Definition vf_estdif.c:569
#define MID2(type, ss)
Definition vf_estdif.c:165
static int config_input(AVFilterLink *inlink)
Definition vf_estdif.c:457
#define MID4(type, ss)
Definition vf_estdif.c:181
static int request_frame(AVFilterLink *link)
Definition vf_estdif.c:524
static const AVOption estdif_options[]
Definition vf_estdif.c:83
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition vf_estdif.c:491
#define MIDL(type, ss)
Definition vf_estdif.c:153
#define MID6(type, ss)
Definition vf_estdif.c:201
#define CONST(name, help, val, u)
Definition vf_estdif.c:81
static av_cold void uninit(AVFilterContext *ctx)
Definition vf_estdif.c:553
#define DIFF(type, ss)
Definition vf_estdif.c:223
#define INTERPOLATE(type, atype, amax, ss)
Definition vf_estdif.c:249
#define OFFSET(x)
Definition vf_estdif.c:79
static int config_output(AVFilterLink *outlink)
Definition vf_estdif.c:134
static const AVFilterPad estdif_inputs[]
Definition vf_estdif.c:560
#define COST(type, ss)
Definition vf_estdif.c:234
mcdeint parity
Definition vf_mcdeint.c:293
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:89