FFmpeg
Loading...
Searching...
No Matches
vf_w3fdif.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 British Broadcasting Corporation, All Rights Reserved
3 * Author of de-interlace algorithm: Jim Easterbrook for BBC R&D
4 * Based on the process described by Martin Weston for BBC R&D
5 * Author of FFmpeg filter: Mark Himsley for BBC Broadcast Systems Development
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#include "libavutil/common.h"
25#include "libavutil/imgutils.h"
26#include "libavutil/mem.h"
27#include "libavutil/opt.h"
28#include "libavutil/pixdesc.h"
29#include "avfilter.h"
30#include "filters.h"
31#include "video.h"
32#include "w3fdif.h"
33
34typedef struct W3FDIFContext {
35 const AVClass *class;
36 int filter; ///< 0 is simple, 1 is more complex
37 int mode; ///< 0 is frame, 1 is field
38 int parity; ///< frame field parity
39 int deint; ///< which frames to deinterlace
40 int linesize[4]; ///< bytes of pixel data per line for each plane
41 int planeheight[4]; ///< height of each plane
42 int field; ///< which field are we on, 0 or 1
43 int eof;
45 AVFrame *prev, *cur, *next; ///< previous, current, next frames
46 int32_t **work_line; ///< lines we are calculating
48 int max;
49
52
53#define OFFSET(x) offsetof(W3FDIFContext, x)
54#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
55#define CONST(name, help, val, u) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, .unit = u }
56
57static const AVOption w3fdif_options[] = {
58 { "filter", "specify the filter", OFFSET(filter), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, .unit = "filter" },
59 CONST("simple", NULL, 0, "filter"),
60 CONST("complex", NULL, 1, "filter"),
61 { "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, .unit = "mode"},
62 CONST("frame", "send one frame for each frame", 0, "mode"),
63 CONST("field", "send one frame for each field", 1, "mode"),
64 { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS, .unit = "parity" },
65 CONST("tff", "assume top field first", 0, "parity"),
66 CONST("bff", "assume bottom field first", 1, "parity"),
67 CONST("auto", "auto detect parity", -1, "parity"),
68 { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, .unit = "deint" },
69 CONST("all", "deinterlace all frames", 0, "deint"),
70 CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),
71 { NULL }
72};
73
75
101
102static void filter_simple_low(int32_t *work_line,
103 uint8_t *in_lines_cur[2],
104 const int16_t *coef, int linesize)
105{
106 int i;
107
108 for (i = 0; i < linesize; i++) {
109 *work_line = *in_lines_cur[0]++ * coef[0];
110 *work_line++ += *in_lines_cur[1]++ * coef[1];
111 }
112}
113
114static void filter_complex_low(int32_t *work_line,
115 uint8_t *in_lines_cur[4],
116 const int16_t *coef, int linesize)
117{
118 int i;
119
120 for (i = 0; i < linesize; i++) {
121 *work_line = *in_lines_cur[0]++ * coef[0];
122 *work_line += *in_lines_cur[1]++ * coef[1];
123 *work_line += *in_lines_cur[2]++ * coef[2];
124 *work_line++ += *in_lines_cur[3]++ * coef[3];
125 }
126}
127
128static void filter_simple_high(int32_t *work_line,
129 uint8_t *in_lines_cur[3],
130 uint8_t *in_lines_adj[3],
131 const int16_t *coef, int linesize)
132{
133 int i;
134
135 for (i = 0; i < linesize; i++) {
136 *work_line += *in_lines_cur[0]++ * coef[0];
137 *work_line += *in_lines_adj[0]++ * coef[0];
138 *work_line += *in_lines_cur[1]++ * coef[1];
139 *work_line += *in_lines_adj[1]++ * coef[1];
140 *work_line += *in_lines_cur[2]++ * coef[2];
141 *work_line++ += *in_lines_adj[2]++ * coef[2];
142 }
143}
144
145static void filter_complex_high(int32_t *work_line,
146 uint8_t *in_lines_cur[5],
147 uint8_t *in_lines_adj[5],
148 const int16_t *coef, int linesize)
149{
150 int i;
151
152 for (i = 0; i < linesize; i++) {
153 *work_line += *in_lines_cur[0]++ * coef[0];
154 *work_line += *in_lines_adj[0]++ * coef[0];
155 *work_line += *in_lines_cur[1]++ * coef[1];
156 *work_line += *in_lines_adj[1]++ * coef[1];
157 *work_line += *in_lines_cur[2]++ * coef[2];
158 *work_line += *in_lines_adj[2]++ * coef[2];
159 *work_line += *in_lines_cur[3]++ * coef[3];
160 *work_line += *in_lines_adj[3]++ * coef[3];
161 *work_line += *in_lines_cur[4]++ * coef[4];
162 *work_line++ += *in_lines_adj[4]++ * coef[4];
163 }
164}
165
166static void filter_scale(uint8_t *out_pixel, const int32_t *work_pixel, int linesize, int max)
167{
168 int j;
169
170 for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
171 *out_pixel = av_clip(*work_pixel, 0, 255 * 256 * 128) >> 15;
172}
173
174static void filter16_simple_low(int32_t *work_line,
175 uint8_t *in_lines_cur8[2],
176 const int16_t *coef, int linesize)
177{
178 uint16_t *in_lines_cur[2] = { (uint16_t *)in_lines_cur8[0], (uint16_t *)in_lines_cur8[1] };
179 int i;
180
181 linesize /= 2;
182 for (i = 0; i < linesize; i++) {
183 *work_line = *in_lines_cur[0]++ * coef[0];
184 *work_line++ += *in_lines_cur[1]++ * coef[1];
185 }
186}
187
188static void filter16_complex_low(int32_t *work_line,
189 uint8_t *in_lines_cur8[4],
190 const int16_t *coef, int linesize)
191{
192 uint16_t *in_lines_cur[4] = { (uint16_t *)in_lines_cur8[0],
193 (uint16_t *)in_lines_cur8[1],
194 (uint16_t *)in_lines_cur8[2],
195 (uint16_t *)in_lines_cur8[3] };
196 int i;
197
198 linesize /= 2;
199 for (i = 0; i < linesize; i++) {
200 *work_line = *in_lines_cur[0]++ * coef[0];
201 *work_line += *in_lines_cur[1]++ * coef[1];
202 *work_line += *in_lines_cur[2]++ * coef[2];
203 *work_line++ += *in_lines_cur[3]++ * coef[3];
204 }
205}
206
207static void filter16_simple_high(int32_t *work_line,
208 uint8_t *in_lines_cur8[3],
209 uint8_t *in_lines_adj8[3],
210 const int16_t *coef, int linesize)
211{
212 uint16_t *in_lines_cur[3] = { (uint16_t *)in_lines_cur8[0],
213 (uint16_t *)in_lines_cur8[1],
214 (uint16_t *)in_lines_cur8[2] };
215 uint16_t *in_lines_adj[3] = { (uint16_t *)in_lines_adj8[0],
216 (uint16_t *)in_lines_adj8[1],
217 (uint16_t *)in_lines_adj8[2] };
218 int i;
219
220 linesize /= 2;
221 for (i = 0; i < linesize; i++) {
222 *work_line += *in_lines_cur[0]++ * coef[0];
223 *work_line += *in_lines_adj[0]++ * coef[0];
224 *work_line += *in_lines_cur[1]++ * coef[1];
225 *work_line += *in_lines_adj[1]++ * coef[1];
226 *work_line += *in_lines_cur[2]++ * coef[2];
227 *work_line++ += *in_lines_adj[2]++ * coef[2];
228 }
229}
230
231static void filter16_complex_high(int32_t *work_line,
232 uint8_t *in_lines_cur8[5],
233 uint8_t *in_lines_adj8[5],
234 const int16_t *coef, int linesize)
235{
236 uint16_t *in_lines_cur[5] = { (uint16_t *)in_lines_cur8[0],
237 (uint16_t *)in_lines_cur8[1],
238 (uint16_t *)in_lines_cur8[2],
239 (uint16_t *)in_lines_cur8[3],
240 (uint16_t *)in_lines_cur8[4] };
241 uint16_t *in_lines_adj[5] = { (uint16_t *)in_lines_adj8[0],
242 (uint16_t *)in_lines_adj8[1],
243 (uint16_t *)in_lines_adj8[2],
244 (uint16_t *)in_lines_adj8[3],
245 (uint16_t *)in_lines_adj8[4] };
246 int i;
247
248 linesize /= 2;
249 for (i = 0; i < linesize; i++) {
250 *work_line += *in_lines_cur[0]++ * coef[0];
251 *work_line += *in_lines_adj[0]++ * coef[0];
252 *work_line += *in_lines_cur[1]++ * coef[1];
253 *work_line += *in_lines_adj[1]++ * coef[1];
254 *work_line += *in_lines_cur[2]++ * coef[2];
255 *work_line += *in_lines_adj[2]++ * coef[2];
256 *work_line += *in_lines_cur[3]++ * coef[3];
257 *work_line += *in_lines_adj[3]++ * coef[3];
258 *work_line += *in_lines_cur[4]++ * coef[4];
259 *work_line++ += *in_lines_adj[4]++ * coef[4];
260 }
261}
262
263static void filter16_scale(uint8_t *out_pixel8, const int32_t *work_pixel, int linesize, int max)
264{
265 uint16_t *out_pixel = (uint16_t *)out_pixel8;
266 int j;
267
268 linesize /= 2;
269 for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
270 *out_pixel = av_clip(*work_pixel, 0, max) >> 15;
271}
272
273static int config_input(AVFilterLink *inlink)
274{
275 AVFilterContext *ctx = inlink->dst;
276 W3FDIFContext *s = ctx->priv;
278 int ret, i, depth, nb_threads;
279
280 if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
281 return ret;
282
283 s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
284 s->planeheight[0] = s->planeheight[3] = inlink->h;
285
286 if (inlink->h < 3) {
287 av_log(ctx, AV_LOG_ERROR, "Video of less than 3 lines is not supported\n");
288 return AVERROR(EINVAL);
289 }
290
291 if (s->planeheight[1] < 2) {
292 av_log(ctx, AV_LOG_ERROR, "Video with chroma planes of less than 2 lines is not supported\n");
293 return AVERROR(EINVAL);
294 }
295
296 s->nb_planes = av_pix_fmt_count_planes(inlink->format);
297 nb_threads = ff_filter_get_nb_threads(ctx);
298 s->work_line = av_calloc(nb_threads, sizeof(*s->work_line));
299 if (!s->work_line)
300 return AVERROR(ENOMEM);
301 s->nb_threads = nb_threads;
302
303 for (i = 0; i < s->nb_threads; i++) {
304 s->work_line[i] = av_calloc(FFALIGN(s->linesize[0], 32), sizeof(*s->work_line[0]));
305 if (!s->work_line[i])
306 return AVERROR(ENOMEM);
307 }
308
309 depth = desc->comp[0].depth;
310 s->max = ((1 << depth) - 1) * 256 * 128;
311 if (depth <= 8) {
312 s->dsp.filter_simple_low = filter_simple_low;
313 s->dsp.filter_complex_low = filter_complex_low;
314 s->dsp.filter_simple_high = filter_simple_high;
315 s->dsp.filter_complex_high = filter_complex_high;
316 s->dsp.filter_scale = filter_scale;
317 } else {
318 s->dsp.filter_simple_low = filter16_simple_low;
319 s->dsp.filter_complex_low = filter16_complex_low;
320 s->dsp.filter_simple_high = filter16_simple_high;
321 s->dsp.filter_complex_high = filter16_complex_high;
322 s->dsp.filter_scale = filter16_scale;
323 }
324
325#if ARCH_X86 && HAVE_X86ASM
326 ff_w3fdif_init_x86(&s->dsp, depth);
327#endif
328
329 return 0;
330}
331
332static int config_output(AVFilterLink *outlink)
333{
334 AVFilterContext *ctx = outlink->src;
335 AVFilterLink *inlink = ctx->inputs[0];
336 FilterLink *il = ff_filter_link(inlink);
337 FilterLink *ol = ff_filter_link(outlink);
338 W3FDIFContext *s = ctx->priv;
339
340 outlink->time_base = av_mul_q(inlink->time_base, (AVRational){1, 2});
341 if (s->mode)
342 ol->frame_rate = av_mul_q(il->frame_rate, (AVRational){2, 1});
343
344 return 0;
345}
346
347/*
348 * Filter coefficients from PH-2071, scaled by 256 * 128.
349 * Each set of coefficients has a set for low-frequencies and high-frequencies.
350 * n_coef_lf[] and n_coef_hf[] are the number of coefs for simple and more-complex.
351 * It is important for later that n_coef_lf[] is even and n_coef_hf[] is odd.
352 * coef_lf[][] and coef_hf[][] are the coefficients for low-frequencies
353 * and high-frequencies for simple and more-complex mode.
354 */
355static const int8_t n_coef_lf[2] = { 2, 4 };
356static const int16_t coef_lf[2][4] = {{ 16384, 16384, 0, 0},
357 { -852, 17236, 17236, -852}};
358static const int8_t n_coef_hf[2] = { 3, 5 };
359static const int16_t coef_hf[2][5] = {{ -2048, 4096, -2048, 0, 0},
360 { 1016, -3801, 5570, -3801, 1016}};
361
362typedef struct ThreadData {
364} ThreadData;
365
367 int jobnr, int nb_jobs, int plane)
368{
369 W3FDIFContext *s = ctx->priv;
370 ThreadData *td = arg;
371 AVFrame *out = td->out;
372 AVFrame *cur = td->cur;
373 AVFrame *adj = td->adj;
374 const int filter = s->filter;
375 uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
376 uint8_t *out_line, *out_pixel;
377 int32_t *work_line, *work_pixel;
378 uint8_t *cur_data = cur->data[plane];
379 uint8_t *adj_data = adj->data[plane];
380 uint8_t *dst_data = out->data[plane];
381 const int linesize = s->linesize[plane];
382 const int height = s->planeheight[plane];
383 const int cur_line_stride = cur->linesize[plane];
384 const int adj_line_stride = adj->linesize[plane];
385 const int dst_line_stride = out->linesize[plane];
386 const int start = ff_slice_pos(height, jobnr, nb_jobs);
387 const int end = ff_slice_pos(height, jobnr + 1, nb_jobs);
388 const int max = s->max;
389 const int interlaced = !!(cur->flags & AV_FRAME_FLAG_INTERLACED);
390 const int tff = s->field == (s->parity == -1 ? interlaced ? !!(cur->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1 :
391 s->parity ^ 1);
392 int j, y_in, y_out;
393
394 /* copy unchanged the lines of the field */
395 y_out = start + (tff ^ (start & 1));
396
397 in_line = cur_data + (y_out * cur_line_stride);
398 out_line = dst_data + (y_out * dst_line_stride);
399
400 while (y_out < end) {
401 memcpy(out_line, in_line, linesize);
402 y_out += 2;
403 in_line += cur_line_stride * 2;
404 out_line += dst_line_stride * 2;
405 }
406
407 /* interpolate other lines of the field */
408 y_out = start + ((!tff) ^ (start & 1));
409
410 out_line = dst_data + (y_out * dst_line_stride);
411
412 while (y_out < end) {
413 /* get low vertical frequencies from current field */
414 for (j = 0; j < n_coef_lf[filter]; j++) {
415 y_in = (y_out + 1) + (j * 2) - n_coef_lf[filter];
416
417 while (y_in < 0)
418 y_in += 2;
419 while (y_in >= height)
420 y_in -= 2;
421
422 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
423 }
424
425 work_line = s->work_line[jobnr];
426 switch (n_coef_lf[filter]) {
427 case 2:
428 s->dsp.filter_simple_low(work_line, in_lines_cur,
429 coef_lf[filter], linesize);
430 break;
431 case 4:
432 s->dsp.filter_complex_low(work_line, in_lines_cur,
433 coef_lf[filter], linesize);
434 }
435
436 /* get high vertical frequencies from adjacent fields */
437 for (j = 0; j < n_coef_hf[filter]; j++) {
438 y_in = (y_out + 1) + (j * 2) - n_coef_hf[filter];
439
440 while (y_in < 0)
441 y_in += 2;
442 while (y_in >= height)
443 y_in -= 2;
444
445 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
446 in_lines_adj[j] = adj_data + (y_in * adj_line_stride);
447 }
448
449 work_line = s->work_line[jobnr];
450 switch (n_coef_hf[filter]) {
451 case 3:
452 s->dsp.filter_simple_high(work_line, in_lines_cur, in_lines_adj,
453 coef_hf[filter], linesize);
454 break;
455 case 5:
456 s->dsp.filter_complex_high(work_line, in_lines_cur, in_lines_adj,
457 coef_hf[filter], linesize);
458 }
459
460 /* save scaled result to the output frame, scaling down by 256 * 128 */
461 work_pixel = s->work_line[jobnr];
462 out_pixel = out_line;
463
464 s->dsp.filter_scale(out_pixel, work_pixel, linesize, max);
465
466 /* move on to next line */
467 y_out += 2;
468 out_line += dst_line_stride * 2;
469 }
470
471 return 0;
472}
473
475 int jobnr, int nb_jobs)
476{
477 W3FDIFContext *s = ctx->priv;
478
479 for (int p = 0; p < s->nb_planes; p++)
480 deinterlace_plane_slice(ctx, arg, jobnr, nb_jobs, p);
481
482 return 0;
483}
484
485static int filter(AVFilterContext *ctx, int is_second)
486{
487 W3FDIFContext *s = ctx->priv;
488 AVFilterLink *outlink = ctx->outputs[0];
489 AVFrame *out, *adj;
490 ThreadData td;
491
492 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
493 if (!out)
494 return AVERROR(ENOMEM);
497
498 if (!is_second) {
499 if (out->pts != AV_NOPTS_VALUE)
500 out->pts *= 2;
501 } else {
502 int64_t cur_pts = s->cur->pts;
503 int64_t next_pts = s->next->pts;
504
505 if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
506 out->pts = cur_pts + next_pts;
507 } else {
508 out->pts = AV_NOPTS_VALUE;
509 }
510 }
511
512 adj = s->field ? s->next : s->prev;
513 td.out = out; td.cur = s->cur; td.adj = adj;
515 FFMIN(s->planeheight[1], s->nb_threads));
516
517 if (s->mode)
518 s->field = !s->field;
519
520 return ff_filter_frame(outlink, out);
521}
522
524{
525 AVFilterContext *ctx = inlink->dst;
526 W3FDIFContext *s = ctx->priv;
527 int ret;
528
529 av_frame_free(&s->prev);
530 s->prev = s->cur;
531 s->cur = s->next;
532 s->next = frame;
533
534 if (!s->cur) {
535 s->cur = av_frame_clone(s->next);
536 if (!s->cur)
537 return AVERROR(ENOMEM);
538 }
539
540 if (!s->prev)
541 return 0;
542
543 if ((s->deint && !(s->cur->flags & AV_FRAME_FLAG_INTERLACED)) || ctx->is_disabled) {
544 AVFrame *out = av_frame_clone(s->cur);
545 if (!out)
546 return AVERROR(ENOMEM);
547
548 av_frame_free(&s->prev);
549 if (out->pts != AV_NOPTS_VALUE)
550 out->pts *= 2;
551 return ff_filter_frame(ctx->outputs[0], out);
552 }
553
554 ret = filter(ctx, 0);
555 if (ret < 0 || s->mode == 0)
556 return ret;
557
558 return filter(ctx, 1);
559}
560
561static int request_frame(AVFilterLink *outlink)
562{
563 AVFilterContext *ctx = outlink->src;
564 W3FDIFContext *s = ctx->priv;
565 int ret;
566
567 if (s->eof)
568 return AVERROR_EOF;
569
570 ret = ff_request_frame(ctx->inputs[0]);
571
572 if (ret == AVERROR_EOF && s->cur) {
573 AVFrame *next = av_frame_clone(s->next);
574 if (!next)
575 return AVERROR(ENOMEM);
576 next->pts = s->next->pts * 2 - s->cur->pts;
577 filter_frame(ctx->inputs[0], next);
578 s->eof = 1;
579 } else if (ret < 0) {
580 return ret;
581 }
582
583 return 0;
584}
585
587{
588 W3FDIFContext *s = ctx->priv;
589 int i;
590
591 av_frame_free(&s->prev);
592 av_frame_free(&s->cur );
593 av_frame_free(&s->next);
594
595 for (i = 0; i < s->nb_threads; i++)
596 av_freep(&s->work_line[i]);
597
598 av_freep(&s->work_line);
599}
600
601static const AVFilterPad w3fdif_inputs[] = {
602 {
603 .name = "default",
604 .type = AVMEDIA_TYPE_VIDEO,
605 .filter_frame = filter_frame,
606 .config_props = config_input,
607 },
608};
609
610static const AVFilterPad w3fdif_outputs[] = {
611 {
612 .name = "default",
613 .type = AVMEDIA_TYPE_VIDEO,
614 .config_props = config_output,
615 .request_frame = request_frame,
616 },
617};
618
620 .p.name = "w3fdif",
621 .p.description = NULL_IF_CONFIG_SMALL("Apply Martin Weston three field deinterlace."),
622 .p.priv_class = &w3fdif_class,
624 .priv_size = sizeof(W3FDIFContext),
625 .uninit = uninit,
629 .process_command = ff_filter_process_command,
630};
static int config_input(AVFilterLink *inlink)
static int request_frame(AVFilterLink *outlink)
Definition af_aecho.c:272
const FFFilter ff_vf_w3fdif
Definition vf_w3fdif.c:619
static FILE * out
static AVFormatContext * ctx
int32_t
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1079
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:917
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition avfilter.c:492
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition avfilter.c:1721
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition avfilter.c:857
Main libavfilter public API header.
static const uint16_t coef_hf[3]
Definition bwdifdsp.c:48
static const uint16_t coef_lf[2]
Definition bwdifdsp.c:47
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:596
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define av_clip
Definition common.h:100
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
#define max(a, b)
static AVFrame * frame
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
int ret
Definition ffplay.c:391
@ 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:172
#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:210
#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:702
#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:707
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:65
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:602
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition frame.c:486
#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
@ 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
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
misc image utilities
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
const char * arg
Definition jacosubdec.c:66
#define FILTER_INPUTS(array)
Definition filters.h:279
#define FILTER_OUTPUTS(array)
Definition filters.h:280
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:789
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:259
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:493
#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:97
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
const char * desc
Definition libsvtav1.c:83
#define FFMIN(a, b)
Definition macros.h:49
#define FFALIGN(x, a)
Definition macros.h:78
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:370
Memory handling functions.
uint8_t interlaced
Definition mxfenc.c:2337
AVOptions.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3524
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3484
#define AV_PIX_FMT_GBRAP12
Definition pixfmt.h:572
#define AV_PIX_FMT_YUV420P16
Definition pixfmt.h:559
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:555
#define AV_PIX_FMT_YUV444P9
Definition pixfmt.h:547
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:548
#define AV_PIX_FMT_YUV440P12
Definition pixfmt.h:554
#define AV_PIX_FMT_GRAY9
Definition pixfmt.h:527
#define AV_PIX_FMT_GBRAP16
Definition pixfmt.h:574
#define AV_PIX_FMT_GBRP9
Definition pixfmt.h:566
#define AV_PIX_FMT_YUV422P9
Definition pixfmt.h:546
#define AV_PIX_FMT_YUVA444P10
Definition pixfmt.h:601
#define AV_PIX_FMT_YUVA420P16
Definition pixfmt.h:604
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUVA420P10
Definition pixfmt.h:599
#define AV_PIX_FMT_YUVA422P9
Definition pixfmt.h:597
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:553
#define AV_PIX_FMT_GBRP10
Definition pixfmt.h:567
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:549
#define AV_PIX_FMT_GRAY12
Definition pixfmt.h:529
#define AV_PIX_FMT_GBRP12
Definition pixfmt.h:568
#define AV_PIX_FMT_YUV420P9
Definition pixfmt.h:545
#define AV_PIX_FMT_YUVA420P9
Definition pixfmt.h:596
#define AV_PIX_FMT_YUVA422P10
Definition pixfmt.h:600
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:556
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:602
#define AV_PIX_FMT_YUV422P14
Definition pixfmt.h:557
#define AV_PIX_FMT_GRAY10
Definition pixfmt.h:528
#define AV_PIX_FMT_GRAY14
Definition pixfmt.h:530
#define AV_PIX_FMT_YUV422P16
Definition pixfmt.h:560
#define AV_PIX_FMT_YUV440P10
Definition pixfmt.h:550
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:531
#define AV_PIX_FMT_GBRAP10
Definition pixfmt.h:571
#define AV_PIX_FMT_YUVA444P16
Definition pixfmt.h:606
#define AV_PIX_FMT_YUVA422P16
Definition pixfmt.h:605
#define AV_PIX_FMT_GBRP16
Definition pixfmt.h:570
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:558
#define AV_PIX_FMT_YUVA444P9
Definition pixfmt.h:598
#define AV_PIX_FMT_GBRP14
Definition pixfmt.h:569
#define AV_PIX_FMT_YUVA444P12
Definition pixfmt.h:603
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:561
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:551
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:279
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:479
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition frame.h:581
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:500
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition frame.h:723
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:524
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
Used for passing data between threads.
Definition v210dec.c:35
AVFrame * out
AVFrame * cur
Definition vf_w3fdif.c:363
AVFrame * adj
Definition vf_w3fdif.c:363
int deint
which frames to deinterlace
Definition vf_w3fdif.c:39
int32_t ** work_line
lines we are calculating
Definition vf_w3fdif.c:46
int linesize[4]
bytes of pixel data per line for each plane
Definition vf_w3fdif.c:40
W3FDIFDSPContext dsp
Definition vf_w3fdif.c:50
int mode
0 is frame, 1 is field
Definition vf_w3fdif.c:37
int parity
frame field parity
Definition vf_w3fdif.c:38
AVFrame * prev
Definition vf_w3fdif.c:45
AVFrame * next
previous, current, next frames
Definition vf_w3fdif.c:45
int planeheight[4]
height of each plane
Definition vf_w3fdif.c:41
int filter
0 is simple, 1 is more complex
Definition vf_w3fdif.c:36
int field
which field are we on, 0 or 1
Definition vf_w3fdif.c:42
AVFrame * cur
Definition vf_w3fdif.c:45
Definition swscale.c:85
#define av_freep(p)
#define av_log(a,...)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29
#define height
Definition dsp.h:99
static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_estdif.c:335
mcdeint parity
Definition vf_mcdeint.c:293
static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_w3fdif.c:474
static void filter_complex_low(int32_t *work_line, uint8_t *in_lines_cur[4], const int16_t *coef, int linesize)
Definition vf_w3fdif.c:114
static int deinterlace_plane_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs, int plane)
Definition vf_w3fdif.c:366
static const int8_t n_coef_hf[2]
Definition vf_w3fdif.c:358
static const int8_t n_coef_lf[2]
Definition vf_w3fdif.c:355
static int config_input(AVFilterLink *inlink)
Definition vf_w3fdif.c:273
static const AVOption w3fdif_options[]
Definition vf_w3fdif.c:57
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition vf_w3fdif.c:523
static void filter16_simple_high(int32_t *work_line, uint8_t *in_lines_cur8[3], uint8_t *in_lines_adj8[3], const int16_t *coef, int linesize)
Definition vf_w3fdif.c:207
static int request_frame(AVFilterLink *outlink)
Definition vf_w3fdif.c:561
static const AVFilterPad w3fdif_inputs[]
Definition vf_w3fdif.c:601
static void filter_scale(uint8_t *out_pixel, const int32_t *work_pixel, int linesize, int max)
Definition vf_w3fdif.c:166
static const AVFilterPad w3fdif_outputs[]
Definition vf_w3fdif.c:610
static void filter_simple_high(int32_t *work_line, uint8_t *in_lines_cur[3], uint8_t *in_lines_adj[3], const int16_t *coef, int linesize)
Definition vf_w3fdif.c:128
static void filter16_scale(uint8_t *out_pixel8, const int32_t *work_pixel, int linesize, int max)
Definition vf_w3fdif.c:263
#define CONST(name, help, val, u)
Definition vf_w3fdif.c:55
static void filter16_simple_low(int32_t *work_line, uint8_t *in_lines_cur8[2], const int16_t *coef, int linesize)
Definition vf_w3fdif.c:174
static void filter16_complex_high(int32_t *work_line, uint8_t *in_lines_cur8[5], uint8_t *in_lines_adj8[5], const int16_t *coef, int linesize)
Definition vf_w3fdif.c:231
static av_cold void uninit(AVFilterContext *ctx)
Definition vf_w3fdif.c:586
static void filter16_complex_low(int32_t *work_line, uint8_t *in_lines_cur8[4], const int16_t *coef, int linesize)
Definition vf_w3fdif.c:188
static void filter_complex_high(int32_t *work_line, uint8_t *in_lines_cur[5], uint8_t *in_lines_adj[5], const int16_t *coef, int linesize)
Definition vf_w3fdif.c:145
#define OFFSET(x)
Definition vf_w3fdif.c:53
static int config_output(AVFilterLink *outlink)
Definition vf_w3fdif.c:332
static void filter_simple_low(int32_t *work_line, uint8_t *in_lines_cur[2], const int16_t *coef, int linesize)
Definition vf_w3fdif.c:102
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:120
void ff_w3fdif_init_x86(W3FDIFDSPContext *dsp, int depth)