You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

602 lines
20KB

  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. #include "libavutil/common.h"
  24. #include "libavutil/imgutils.h"
  25. #include "libavutil/opt.h"
  26. #include "libavutil/pixdesc.h"
  27. #include "avfilter.h"
  28. #include "formats.h"
  29. #include "internal.h"
  30. #include "video.h"
  31. #include "w3fdif.h"
  32. typedef struct W3FDIFContext {
  33. const AVClass *class;
  34. int filter; ///< 0 is simple, 1 is more complex
  35. int deint; ///< which frames to deinterlace
  36. int linesize[4]; ///< bytes of pixel data per line for each plane
  37. int planeheight[4]; ///< height of each plane
  38. int field; ///< which field are we on, 0 or 1
  39. int eof;
  40. int nb_planes;
  41. AVFrame *prev, *cur, *next; ///< previous, current, next frames
  42. int32_t **work_line; ///< lines we are calculating
  43. int nb_threads;
  44. int max;
  45. W3FDIFDSPContext dsp;
  46. } W3FDIFContext;
  47. #define OFFSET(x) offsetof(W3FDIFContext, x)
  48. #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
  49. #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
  50. static const AVOption w3fdif_options[] = {
  51. { "filter", "specify the filter", OFFSET(filter), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "filter" },
  52. CONST("simple", NULL, 0, "filter"),
  53. CONST("complex", NULL, 1, "filter"),
  54. { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" },
  55. CONST("all", "deinterlace all frames", 0, "deint"),
  56. CONST("interlaced", "only deinterlace frames marked as interlaced", 1, "deint"),
  57. { NULL }
  58. };
  59. AVFILTER_DEFINE_CLASS(w3fdif);
  60. static int query_formats(AVFilterContext *ctx)
  61. {
  62. static const enum AVPixelFormat pix_fmts[] = {
  63. AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
  64. AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
  65. AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
  66. AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P,
  67. AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,
  68. AV_PIX_FMT_YUVJ411P,
  69. AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
  70. AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
  71. AV_PIX_FMT_GRAY8,
  72. AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
  73. AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
  74. AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12,
  75. AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14,
  76. AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14,
  77. AV_PIX_FMT_NONE
  78. };
  79. AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
  80. if (!fmts_list)
  81. return AVERROR(ENOMEM);
  82. return ff_set_common_formats(ctx, fmts_list);
  83. }
  84. static void filter_simple_low(int32_t *work_line,
  85. uint8_t *in_lines_cur[2],
  86. const int16_t *coef, int linesize)
  87. {
  88. int i;
  89. for (i = 0; i < linesize; i++) {
  90. *work_line = *in_lines_cur[0]++ * coef[0];
  91. *work_line++ += *in_lines_cur[1]++ * coef[1];
  92. }
  93. }
  94. static void filter_complex_low(int32_t *work_line,
  95. uint8_t *in_lines_cur[4],
  96. const int16_t *coef, int linesize)
  97. {
  98. int i;
  99. for (i = 0; i < linesize; i++) {
  100. *work_line = *in_lines_cur[0]++ * coef[0];
  101. *work_line += *in_lines_cur[1]++ * coef[1];
  102. *work_line += *in_lines_cur[2]++ * coef[2];
  103. *work_line++ += *in_lines_cur[3]++ * coef[3];
  104. }
  105. }
  106. static void filter_simple_high(int32_t *work_line,
  107. uint8_t *in_lines_cur[3],
  108. uint8_t *in_lines_adj[3],
  109. const int16_t *coef, int linesize)
  110. {
  111. int i;
  112. for (i = 0; i < linesize; i++) {
  113. *work_line += *in_lines_cur[0]++ * coef[0];
  114. *work_line += *in_lines_adj[0]++ * coef[0];
  115. *work_line += *in_lines_cur[1]++ * coef[1];
  116. *work_line += *in_lines_adj[1]++ * coef[1];
  117. *work_line += *in_lines_cur[2]++ * coef[2];
  118. *work_line++ += *in_lines_adj[2]++ * coef[2];
  119. }
  120. }
  121. static void filter_complex_high(int32_t *work_line,
  122. uint8_t *in_lines_cur[5],
  123. uint8_t *in_lines_adj[5],
  124. const int16_t *coef, int linesize)
  125. {
  126. int i;
  127. for (i = 0; i < linesize; i++) {
  128. *work_line += *in_lines_cur[0]++ * coef[0];
  129. *work_line += *in_lines_adj[0]++ * coef[0];
  130. *work_line += *in_lines_cur[1]++ * coef[1];
  131. *work_line += *in_lines_adj[1]++ * coef[1];
  132. *work_line += *in_lines_cur[2]++ * coef[2];
  133. *work_line += *in_lines_adj[2]++ * coef[2];
  134. *work_line += *in_lines_cur[3]++ * coef[3];
  135. *work_line += *in_lines_adj[3]++ * coef[3];
  136. *work_line += *in_lines_cur[4]++ * coef[4];
  137. *work_line++ += *in_lines_adj[4]++ * coef[4];
  138. }
  139. }
  140. static void filter_scale(uint8_t *out_pixel, const int32_t *work_pixel, int linesize, int max)
  141. {
  142. int j;
  143. for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
  144. *out_pixel = av_clip(*work_pixel, 0, 255 * 256 * 128) >> 15;
  145. }
  146. static void filter16_simple_low(int32_t *work_line,
  147. uint8_t *in_lines_cur8[2],
  148. const int16_t *coef, int linesize)
  149. {
  150. uint16_t *in_lines_cur[2] = { (uint16_t *)in_lines_cur8[0], (uint16_t *)in_lines_cur8[1] };
  151. int i;
  152. linesize /= 2;
  153. for (i = 0; i < linesize; i++) {
  154. *work_line = *in_lines_cur[0]++ * coef[0];
  155. *work_line++ += *in_lines_cur[1]++ * coef[1];
  156. }
  157. }
  158. static void filter16_complex_low(int32_t *work_line,
  159. uint8_t *in_lines_cur8[4],
  160. const int16_t *coef, int linesize)
  161. {
  162. uint16_t *in_lines_cur[4] = { (uint16_t *)in_lines_cur8[0],
  163. (uint16_t *)in_lines_cur8[1],
  164. (uint16_t *)in_lines_cur8[2],
  165. (uint16_t *)in_lines_cur8[3] };
  166. int i;
  167. linesize /= 2;
  168. for (i = 0; i < linesize; i++) {
  169. *work_line = *in_lines_cur[0]++ * coef[0];
  170. *work_line += *in_lines_cur[1]++ * coef[1];
  171. *work_line += *in_lines_cur[2]++ * coef[2];
  172. *work_line++ += *in_lines_cur[3]++ * coef[3];
  173. }
  174. }
  175. static void filter16_simple_high(int32_t *work_line,
  176. uint8_t *in_lines_cur8[3],
  177. uint8_t *in_lines_adj8[3],
  178. const int16_t *coef, int linesize)
  179. {
  180. uint16_t *in_lines_cur[3] = { (uint16_t *)in_lines_cur8[0],
  181. (uint16_t *)in_lines_cur8[1],
  182. (uint16_t *)in_lines_cur8[2] };
  183. uint16_t *in_lines_adj[3] = { (uint16_t *)in_lines_adj8[0],
  184. (uint16_t *)in_lines_adj8[1],
  185. (uint16_t *)in_lines_adj8[2] };
  186. int i;
  187. linesize /= 2;
  188. for (i = 0; i < linesize; i++) {
  189. *work_line += *in_lines_cur[0]++ * coef[0];
  190. *work_line += *in_lines_adj[0]++ * coef[0];
  191. *work_line += *in_lines_cur[1]++ * coef[1];
  192. *work_line += *in_lines_adj[1]++ * coef[1];
  193. *work_line += *in_lines_cur[2]++ * coef[2];
  194. *work_line++ += *in_lines_adj[2]++ * coef[2];
  195. }
  196. }
  197. static void filter16_complex_high(int32_t *work_line,
  198. uint8_t *in_lines_cur8[5],
  199. uint8_t *in_lines_adj8[5],
  200. const int16_t *coef, int linesize)
  201. {
  202. uint16_t *in_lines_cur[5] = { (uint16_t *)in_lines_cur8[0],
  203. (uint16_t *)in_lines_cur8[1],
  204. (uint16_t *)in_lines_cur8[2],
  205. (uint16_t *)in_lines_cur8[3],
  206. (uint16_t *)in_lines_cur8[4] };
  207. uint16_t *in_lines_adj[5] = { (uint16_t *)in_lines_adj8[0],
  208. (uint16_t *)in_lines_adj8[1],
  209. (uint16_t *)in_lines_adj8[2],
  210. (uint16_t *)in_lines_adj8[3],
  211. (uint16_t *)in_lines_adj8[4] };
  212. int i;
  213. linesize /= 2;
  214. for (i = 0; i < linesize; i++) {
  215. *work_line += *in_lines_cur[0]++ * coef[0];
  216. *work_line += *in_lines_adj[0]++ * coef[0];
  217. *work_line += *in_lines_cur[1]++ * coef[1];
  218. *work_line += *in_lines_adj[1]++ * coef[1];
  219. *work_line += *in_lines_cur[2]++ * coef[2];
  220. *work_line += *in_lines_adj[2]++ * coef[2];
  221. *work_line += *in_lines_cur[3]++ * coef[3];
  222. *work_line += *in_lines_adj[3]++ * coef[3];
  223. *work_line += *in_lines_cur[4]++ * coef[4];
  224. *work_line++ += *in_lines_adj[4]++ * coef[4];
  225. }
  226. }
  227. static void filter16_scale(uint8_t *out_pixel8, const int32_t *work_pixel, int linesize, int max)
  228. {
  229. uint16_t *out_pixel = (uint16_t *)out_pixel8;
  230. int j;
  231. linesize /= 2;
  232. for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
  233. *out_pixel = av_clip(*work_pixel, 0, max) >> 15;
  234. }
  235. static int config_input(AVFilterLink *inlink)
  236. {
  237. AVFilterContext *ctx = inlink->dst;
  238. W3FDIFContext *s = ctx->priv;
  239. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
  240. int ret, i, depth;
  241. if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
  242. return ret;
  243. s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
  244. s->planeheight[0] = s->planeheight[3] = inlink->h;
  245. if (inlink->h < 3) {
  246. av_log(ctx, AV_LOG_ERROR, "Video of less than 3 lines is not supported\n");
  247. return AVERROR(EINVAL);
  248. }
  249. s->nb_planes = av_pix_fmt_count_planes(inlink->format);
  250. s->nb_threads = ff_filter_get_nb_threads(ctx);
  251. s->work_line = av_calloc(s->nb_threads, sizeof(*s->work_line));
  252. if (!s->work_line)
  253. return AVERROR(ENOMEM);
  254. for (i = 0; i < s->nb_threads; i++) {
  255. s->work_line[i] = av_calloc(FFALIGN(s->linesize[0], 32), sizeof(*s->work_line[0]));
  256. if (!s->work_line[i])
  257. return AVERROR(ENOMEM);
  258. }
  259. depth = desc->comp[0].depth;
  260. s->max = ((1 << depth) - 1) * 256 * 128;
  261. if (depth <= 8) {
  262. s->dsp.filter_simple_low = filter_simple_low;
  263. s->dsp.filter_complex_low = filter_complex_low;
  264. s->dsp.filter_simple_high = filter_simple_high;
  265. s->dsp.filter_complex_high = filter_complex_high;
  266. s->dsp.filter_scale = filter_scale;
  267. } else {
  268. s->dsp.filter_simple_low = filter16_simple_low;
  269. s->dsp.filter_complex_low = filter16_complex_low;
  270. s->dsp.filter_simple_high = filter16_simple_high;
  271. s->dsp.filter_complex_high = filter16_complex_high;
  272. s->dsp.filter_scale = filter16_scale;
  273. }
  274. if (ARCH_X86)
  275. ff_w3fdif_init_x86(&s->dsp, depth);
  276. return 0;
  277. }
  278. static int config_output(AVFilterLink *outlink)
  279. {
  280. AVFilterLink *inlink = outlink->src->inputs[0];
  281. outlink->time_base.num = inlink->time_base.num;
  282. outlink->time_base.den = inlink->time_base.den * 2;
  283. outlink->frame_rate.num = inlink->frame_rate.num * 2;
  284. outlink->frame_rate.den = inlink->frame_rate.den;
  285. return 0;
  286. }
  287. /*
  288. * Filter coefficients from PH-2071, scaled by 256 * 128.
  289. * Each set of coefficients has a set for low-frequencies and high-frequencies.
  290. * n_coef_lf[] and n_coef_hf[] are the number of coefs for simple and more-complex.
  291. * It is important for later that n_coef_lf[] is even and n_coef_hf[] is odd.
  292. * coef_lf[][] and coef_hf[][] are the coefficients for low-frequencies
  293. * and high-frequencies for simple and more-complex mode.
  294. */
  295. static const int8_t n_coef_lf[2] = { 2, 4 };
  296. static const int16_t coef_lf[2][4] = {{ 16384, 16384, 0, 0},
  297. { -852, 17236, 17236, -852}};
  298. static const int8_t n_coef_hf[2] = { 3, 5 };
  299. static const int16_t coef_hf[2][5] = {{ -2048, 4096, -2048, 0, 0},
  300. { 1016, -3801, 5570, -3801, 1016}};
  301. typedef struct ThreadData {
  302. AVFrame *out, *cur, *adj;
  303. int plane;
  304. } ThreadData;
  305. static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
  306. {
  307. W3FDIFContext *s = ctx->priv;
  308. ThreadData *td = arg;
  309. AVFrame *out = td->out;
  310. AVFrame *cur = td->cur;
  311. AVFrame *adj = td->adj;
  312. const int plane = td->plane;
  313. const int filter = s->filter;
  314. uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
  315. uint8_t *out_line, *out_pixel;
  316. int32_t *work_line, *work_pixel;
  317. uint8_t *cur_data = cur->data[plane];
  318. uint8_t *adj_data = adj->data[plane];
  319. uint8_t *dst_data = out->data[plane];
  320. const int linesize = s->linesize[plane];
  321. const int height = s->planeheight[plane];
  322. const int cur_line_stride = cur->linesize[plane];
  323. const int adj_line_stride = adj->linesize[plane];
  324. const int dst_line_stride = out->linesize[plane];
  325. const int start = (height * jobnr) / nb_jobs;
  326. const int end = (height * (jobnr+1)) / nb_jobs;
  327. const int max = s->max;
  328. int j, y_in, y_out;
  329. /* copy unchanged the lines of the field */
  330. y_out = start + ((s->field == cur->top_field_first) ^ (start & 1));
  331. in_line = cur_data + (y_out * cur_line_stride);
  332. out_line = dst_data + (y_out * dst_line_stride);
  333. while (y_out < end) {
  334. memcpy(out_line, in_line, linesize);
  335. y_out += 2;
  336. in_line += cur_line_stride * 2;
  337. out_line += dst_line_stride * 2;
  338. }
  339. /* interpolate other lines of the field */
  340. y_out = start + ((s->field != cur->top_field_first) ^ (start & 1));
  341. out_line = dst_data + (y_out * dst_line_stride);
  342. while (y_out < end) {
  343. /* get low vertical frequencies from current field */
  344. for (j = 0; j < n_coef_lf[filter]; j++) {
  345. y_in = (y_out + 1) + (j * 2) - n_coef_lf[filter];
  346. while (y_in < 0)
  347. y_in += 2;
  348. while (y_in >= height)
  349. y_in -= 2;
  350. in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
  351. }
  352. work_line = s->work_line[jobnr];
  353. switch (n_coef_lf[filter]) {
  354. case 2:
  355. s->dsp.filter_simple_low(work_line, in_lines_cur,
  356. coef_lf[filter], linesize);
  357. break;
  358. case 4:
  359. s->dsp.filter_complex_low(work_line, in_lines_cur,
  360. coef_lf[filter], linesize);
  361. }
  362. /* get high vertical frequencies from adjacent fields */
  363. for (j = 0; j < n_coef_hf[filter]; j++) {
  364. y_in = (y_out + 1) + (j * 2) - n_coef_hf[filter];
  365. while (y_in < 0)
  366. y_in += 2;
  367. while (y_in >= height)
  368. y_in -= 2;
  369. in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
  370. in_lines_adj[j] = adj_data + (y_in * adj_line_stride);
  371. }
  372. work_line = s->work_line[jobnr];
  373. switch (n_coef_hf[filter]) {
  374. case 3:
  375. s->dsp.filter_simple_high(work_line, in_lines_cur, in_lines_adj,
  376. coef_hf[filter], linesize);
  377. break;
  378. case 5:
  379. s->dsp.filter_complex_high(work_line, in_lines_cur, in_lines_adj,
  380. coef_hf[filter], linesize);
  381. }
  382. /* save scaled result to the output frame, scaling down by 256 * 128 */
  383. work_pixel = s->work_line[jobnr];
  384. out_pixel = out_line;
  385. s->dsp.filter_scale(out_pixel, work_pixel, linesize, max);
  386. /* move on to next line */
  387. y_out += 2;
  388. out_line += dst_line_stride * 2;
  389. }
  390. return 0;
  391. }
  392. static int filter(AVFilterContext *ctx, int is_second)
  393. {
  394. W3FDIFContext *s = ctx->priv;
  395. AVFilterLink *outlink = ctx->outputs[0];
  396. AVFrame *out, *adj;
  397. ThreadData td;
  398. int plane;
  399. out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
  400. if (!out)
  401. return AVERROR(ENOMEM);
  402. av_frame_copy_props(out, s->cur);
  403. out->interlaced_frame = 0;
  404. if (!is_second) {
  405. if (out->pts != AV_NOPTS_VALUE)
  406. out->pts *= 2;
  407. } else {
  408. int64_t cur_pts = s->cur->pts;
  409. int64_t next_pts = s->next->pts;
  410. if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
  411. out->pts = cur_pts + next_pts;
  412. } else {
  413. out->pts = AV_NOPTS_VALUE;
  414. }
  415. }
  416. adj = s->field ? s->next : s->prev;
  417. td.out = out; td.cur = s->cur; td.adj = adj;
  418. for (plane = 0; plane < s->nb_planes; plane++) {
  419. td.plane = plane;
  420. ctx->internal->execute(ctx, deinterlace_slice, &td, NULL, FFMIN(s->planeheight[plane], s->nb_threads));
  421. }
  422. s->field = !s->field;
  423. return ff_filter_frame(outlink, out);
  424. }
  425. static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
  426. {
  427. AVFilterContext *ctx = inlink->dst;
  428. W3FDIFContext *s = ctx->priv;
  429. int ret;
  430. av_frame_free(&s->prev);
  431. s->prev = s->cur;
  432. s->cur = s->next;
  433. s->next = frame;
  434. if (!s->cur) {
  435. s->cur = av_frame_clone(s->next);
  436. if (!s->cur)
  437. return AVERROR(ENOMEM);
  438. }
  439. if ((s->deint && !s->cur->interlaced_frame) || ctx->is_disabled) {
  440. AVFrame *out = av_frame_clone(s->cur);
  441. if (!out)
  442. return AVERROR(ENOMEM);
  443. av_frame_free(&s->prev);
  444. if (out->pts != AV_NOPTS_VALUE)
  445. out->pts *= 2;
  446. return ff_filter_frame(ctx->outputs[0], out);
  447. }
  448. if (!s->prev)
  449. return 0;
  450. ret = filter(ctx, 0);
  451. if (ret < 0)
  452. return ret;
  453. return filter(ctx, 1);
  454. }
  455. static int request_frame(AVFilterLink *outlink)
  456. {
  457. AVFilterContext *ctx = outlink->src;
  458. W3FDIFContext *s = ctx->priv;
  459. int ret;
  460. if (s->eof)
  461. return AVERROR_EOF;
  462. ret = ff_request_frame(ctx->inputs[0]);
  463. if (ret == AVERROR_EOF && s->cur) {
  464. AVFrame *next = av_frame_clone(s->next);
  465. if (!next)
  466. return AVERROR(ENOMEM);
  467. next->pts = s->next->pts * 2 - s->cur->pts;
  468. filter_frame(ctx->inputs[0], next);
  469. s->eof = 1;
  470. } else if (ret < 0) {
  471. return ret;
  472. }
  473. return 0;
  474. }
  475. static av_cold void uninit(AVFilterContext *ctx)
  476. {
  477. W3FDIFContext *s = ctx->priv;
  478. int i;
  479. av_frame_free(&s->prev);
  480. av_frame_free(&s->cur );
  481. av_frame_free(&s->next);
  482. for (i = 0; i < s->nb_threads; i++)
  483. av_freep(&s->work_line[i]);
  484. av_freep(&s->work_line);
  485. }
  486. static const AVFilterPad w3fdif_inputs[] = {
  487. {
  488. .name = "default",
  489. .type = AVMEDIA_TYPE_VIDEO,
  490. .filter_frame = filter_frame,
  491. .config_props = config_input,
  492. },
  493. { NULL }
  494. };
  495. static const AVFilterPad w3fdif_outputs[] = {
  496. {
  497. .name = "default",
  498. .type = AVMEDIA_TYPE_VIDEO,
  499. .config_props = config_output,
  500. .request_frame = request_frame,
  501. },
  502. { NULL }
  503. };
  504. AVFilter ff_vf_w3fdif = {
  505. .name = "w3fdif",
  506. .description = NULL_IF_CONFIG_SMALL("Apply Martin Weston three field deinterlace."),
  507. .priv_size = sizeof(W3FDIFContext),
  508. .priv_class = &w3fdif_class,
  509. .uninit = uninit,
  510. .query_formats = query_formats,
  511. .inputs = w3fdif_inputs,
  512. .outputs = w3fdif_outputs,
  513. .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
  514. };