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.

607 lines
20KB

  1. /*
  2. * Copyright (C) 2006-2011 Michael Niedermayer <michaelni@gmx.at>
  3. * 2010 James Darnley <james.darnley@gmail.com>
  4. *
  5. * FFmpeg is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * FFmpeg is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. */
  19. #include "libavutil/avassert.h"
  20. #include "libavutil/cpu.h"
  21. #include "libavutil/common.h"
  22. #include "libavutil/opt.h"
  23. #include "libavutil/pixdesc.h"
  24. #include "libavutil/imgutils.h"
  25. #include "libavutil/x86/asm.h"
  26. #include "libavutil/x86/cpu.h"
  27. #include "avfilter.h"
  28. #include "formats.h"
  29. #include "internal.h"
  30. #include "video.h"
  31. #include "yadif.h"
  32. typedef struct ThreadData {
  33. AVFrame *frame;
  34. int plane;
  35. int w, h;
  36. int parity;
  37. int tff;
  38. } ThreadData;
  39. typedef struct YADIFContext {
  40. const AVClass *class;
  41. enum YADIFMode mode;
  42. enum YADIFParity parity;
  43. enum YADIFDeint deint;
  44. int frame_pending;
  45. AVFrame *cur;
  46. AVFrame *next;
  47. AVFrame *prev;
  48. AVFrame *out;
  49. /**
  50. * Required alignment for filter_line
  51. */
  52. void (*filter_line)(void *dst,
  53. void *prev, void *cur, void *next,
  54. int w, int prefs, int mrefs, int parity, int mode);
  55. void (*filter_edges)(void *dst, void *prev, void *cur, void *next,
  56. int w, int prefs, int mrefs, int parity, int mode);
  57. const AVPixFmtDescriptor *csp;
  58. int eof;
  59. uint8_t *temp_line;
  60. int temp_line_size;
  61. } YADIFContext;
  62. #define CHECK(j)\
  63. { int score = FFABS(cur[mrefs - 1 + j] - cur[prefs - 1 - j])\
  64. + FFABS(cur[mrefs + j] - cur[prefs - j])\
  65. + FFABS(cur[mrefs + 1 + j] - cur[prefs + 1 - j]);\
  66. if (score < spatial_score) {\
  67. spatial_score= score;\
  68. spatial_pred= (cur[mrefs + j] + cur[prefs - j])>>1;\
  69. /* The is_not_edge argument here controls when the code will enter a branch
  70. * which reads up to and including x-3 and x+3. */
  71. #define FILTER(start, end, is_not_edge) \
  72. for (x = start; x < end; x++) { \
  73. int c = cur[mrefs]; \
  74. int d = (prev2[0] + next2[0])>>1; \
  75. int e = cur[prefs]; \
  76. int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
  77. int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
  78. int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
  79. int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
  80. int spatial_pred = (c+e) >> 1; \
  81. \
  82. if (is_not_edge) {\
  83. int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
  84. + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
  85. CHECK(-1) CHECK(-2) }} }} \
  86. CHECK( 1) CHECK( 2) }} }} \
  87. }\
  88. \
  89. if (!(mode&2)) { \
  90. int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
  91. int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
  92. int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
  93. int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
  94. \
  95. diff = FFMAX3(diff, min, -max); \
  96. } \
  97. \
  98. if (spatial_pred > d + diff) \
  99. spatial_pred = d + diff; \
  100. else if (spatial_pred < d - diff) \
  101. spatial_pred = d - diff; \
  102. \
  103. dst[0] = spatial_pred; \
  104. \
  105. dst++; \
  106. cur++; \
  107. prev++; \
  108. next++; \
  109. prev2++; \
  110. next2++; \
  111. }
  112. static void filter_line_c(void *dst1,
  113. void *prev1, void *cur1, void *next1,
  114. int w, int prefs, int mrefs, int parity, int mode)
  115. {
  116. uint8_t *dst = dst1;
  117. uint8_t *prev = prev1;
  118. uint8_t *cur = cur1;
  119. uint8_t *next = next1;
  120. int x;
  121. uint8_t *prev2 = parity ? prev : cur ;
  122. uint8_t *next2 = parity ? cur : next;
  123. /* The function is called with the pointers already pointing to data[3] and
  124. * with 6 subtracted from the width. This allows the FILTER macro to be
  125. * called so that it processes all the pixels normally. A constant value of
  126. * true for is_not_edge lets the compiler ignore the if statement. */
  127. FILTER(0, w, 1)
  128. }
  129. #define MAX_ALIGN 8
  130. static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1,
  131. int w, int prefs, int mrefs, int parity, int mode)
  132. {
  133. uint8_t *dst = dst1;
  134. uint8_t *prev = prev1;
  135. uint8_t *cur = cur1;
  136. uint8_t *next = next1;
  137. int x;
  138. uint8_t *prev2 = parity ? prev : cur ;
  139. uint8_t *next2 = parity ? cur : next;
  140. /* Only edge pixels need to be processed here. A constant value of false
  141. * for is_not_edge should let the compiler ignore the whole branch. */
  142. FILTER(0, 3, 0)
  143. dst = (uint8_t*)dst1 + w - (MAX_ALIGN-1);
  144. prev = (uint8_t*)prev1 + w - (MAX_ALIGN-1);
  145. cur = (uint8_t*)cur1 + w - (MAX_ALIGN-1);
  146. next = (uint8_t*)next1 + w - (MAX_ALIGN-1);
  147. prev2 = (uint8_t*)(parity ? prev : cur);
  148. next2 = (uint8_t*)(parity ? cur : next);
  149. FILTER(w - (MAX_ALIGN-1), w - 3, 1)
  150. FILTER(w - 3, w, 0)
  151. }
  152. static void filter_line_c_16bit(void *dst1,
  153. void *prev1, void *cur1, void *next1,
  154. int w, int prefs, int mrefs, int parity,
  155. int mode)
  156. {
  157. uint16_t *dst = dst1;
  158. uint16_t *prev = prev1;
  159. uint16_t *cur = cur1;
  160. uint16_t *next = next1;
  161. int x;
  162. uint16_t *prev2 = parity ? prev : cur ;
  163. uint16_t *next2 = parity ? cur : next;
  164. mrefs /= 2;
  165. prefs /= 2;
  166. FILTER(0, w, 1)
  167. }
  168. static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1,
  169. int w, int prefs, int mrefs, int parity, int mode)
  170. {
  171. uint16_t *dst = dst1;
  172. uint16_t *prev = prev1;
  173. uint16_t *cur = cur1;
  174. uint16_t *next = next1;
  175. int x;
  176. uint16_t *prev2 = parity ? prev : cur ;
  177. uint16_t *next2 = parity ? cur : next;
  178. mrefs /= 2;
  179. prefs /= 2;
  180. FILTER(0, 3, 0)
  181. dst = (uint16_t*)dst1 + w - (MAX_ALIGN/2-1);
  182. prev = (uint16_t*)prev1 + w - (MAX_ALIGN/2-1);
  183. cur = (uint16_t*)cur1 + w - (MAX_ALIGN/2-1);
  184. next = (uint16_t*)next1 + w - (MAX_ALIGN/2-1);
  185. prev2 = (uint16_t*)(parity ? prev : cur);
  186. next2 = (uint16_t*)(parity ? cur : next);
  187. FILTER(w - (MAX_ALIGN/2-1), w - 3, 1)
  188. FILTER(w - 3, w, 0)
  189. }
  190. static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
  191. {
  192. YADIFContext *s = ctx->priv;
  193. ThreadData *td = arg;
  194. int refs = s->cur->linesize[td->plane];
  195. int df = (s->csp->comp[td->plane].depth_minus1 + 8) / 8;
  196. int pix_3 = 3 * df;
  197. int slice_start = (td->h * jobnr ) / nb_jobs;
  198. int slice_end = (td->h * (jobnr+1)) / nb_jobs;
  199. int y;
  200. /* filtering reads 3 pixels to the left/right; to avoid invalid reads,
  201. * we need to call the c variant which avoids this for border pixels
  202. */
  203. for (y = slice_start; y < slice_end; y++) {
  204. if ((y ^ td->parity) & 1) {
  205. uint8_t *prev = &s->prev->data[td->plane][y * refs];
  206. uint8_t *cur = &s->cur ->data[td->plane][y * refs];
  207. uint8_t *next = &s->next->data[td->plane][y * refs];
  208. uint8_t *dst = &td->frame->data[td->plane][y * td->frame->linesize[td->plane]];
  209. int mode = y == 1 || y + 2 == td->h ? 2 : s->mode;
  210. s->filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
  211. next + pix_3, td->w - (3 + MAX_ALIGN/df-1),
  212. y + 1 < td->h ? refs : -refs,
  213. y ? -refs : refs,
  214. td->parity ^ td->tff, mode);
  215. s->filter_edges(dst, prev, cur, next, td->w,
  216. y + 1 < td->h ? refs : -refs,
  217. y ? -refs : refs,
  218. td->parity ^ td->tff, mode);
  219. } else {
  220. memcpy(&td->frame->data[td->plane][y * td->frame->linesize[td->plane]],
  221. &s->cur->data[td->plane][y * refs], td->w * df);
  222. }
  223. }
  224. return 0;
  225. }
  226. static void filter(AVFilterContext *ctx, AVFrame *dstpic,
  227. int parity, int tff)
  228. {
  229. YADIFContext *yadif = ctx->priv;
  230. ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff };
  231. int i;
  232. for (i = 0; i < yadif->csp->nb_components; i++) {
  233. int w = dstpic->width;
  234. int h = dstpic->height;
  235. if (i == 1 || i == 2) {
  236. w = FF_CEIL_RSHIFT(w, yadif->csp->log2_chroma_w);
  237. h = FF_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h);
  238. }
  239. td.w = w;
  240. td.h = h;
  241. td.plane = i;
  242. ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ctx->graph->nb_threads));
  243. }
  244. emms_c();
  245. }
  246. static int return_frame(AVFilterContext *ctx, int is_second)
  247. {
  248. YADIFContext *yadif = ctx->priv;
  249. AVFilterLink *link = ctx->outputs[0];
  250. int tff, ret;
  251. if (yadif->parity == -1) {
  252. tff = yadif->cur->interlaced_frame ?
  253. yadif->cur->top_field_first : 1;
  254. } else {
  255. tff = yadif->parity ^ 1;
  256. }
  257. if (is_second) {
  258. yadif->out = ff_get_video_buffer(link, link->w, link->h);
  259. if (!yadif->out)
  260. return AVERROR(ENOMEM);
  261. av_frame_copy_props(yadif->out, yadif->cur);
  262. yadif->out->interlaced_frame = 0;
  263. }
  264. filter(ctx, yadif->out, tff ^ !is_second, tff);
  265. if (is_second) {
  266. int64_t cur_pts = yadif->cur->pts;
  267. int64_t next_pts = yadif->next->pts;
  268. if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
  269. yadif->out->pts = cur_pts + next_pts;
  270. } else {
  271. yadif->out->pts = AV_NOPTS_VALUE;
  272. }
  273. }
  274. ret = ff_filter_frame(ctx->outputs[0], yadif->out);
  275. yadif->frame_pending = (yadif->mode&1) && !is_second;
  276. return ret;
  277. }
  278. static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
  279. {
  280. int i;
  281. for (i = 0; i < yadif->csp->nb_components; i++)
  282. if (a->linesize[i] != b->linesize[i])
  283. return 1;
  284. return 0;
  285. }
  286. static void fixstride(AVFilterLink *link, AVFrame *f)
  287. {
  288. AVFrame *dst = ff_default_get_video_buffer(link, f->width, f->height);
  289. if(!dst)
  290. return;
  291. av_frame_copy_props(dst, f);
  292. av_image_copy(dst->data, dst->linesize,
  293. (const uint8_t **)f->data, f->linesize,
  294. dst->format, dst->width, dst->height);
  295. av_frame_unref(f);
  296. av_frame_move_ref(f, dst);
  297. av_frame_free(&dst);
  298. }
  299. static int filter_frame(AVFilterLink *link, AVFrame *frame)
  300. {
  301. AVFilterContext *ctx = link->dst;
  302. YADIFContext *yadif = ctx->priv;
  303. av_assert0(frame);
  304. if (yadif->frame_pending)
  305. return_frame(ctx, 1);
  306. if (yadif->prev)
  307. av_frame_free(&yadif->prev);
  308. yadif->prev = yadif->cur;
  309. yadif->cur = yadif->next;
  310. yadif->next = frame;
  311. if (!yadif->cur)
  312. return 0;
  313. if (checkstride(yadif, yadif->next, yadif->cur)) {
  314. av_log(ctx, AV_LOG_VERBOSE, "Reallocating frame due to differing stride\n");
  315. fixstride(link, yadif->next);
  316. }
  317. if (checkstride(yadif, yadif->next, yadif->cur))
  318. fixstride(link, yadif->cur);
  319. if (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))
  320. fixstride(link, yadif->prev);
  321. if (checkstride(yadif, yadif->next, yadif->cur) || (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))) {
  322. av_log(ctx, AV_LOG_ERROR, "Failed to reallocate frame\n");
  323. return -1;
  324. }
  325. if ((yadif->deint && !yadif->cur->interlaced_frame) || ctx->is_disabled) {
  326. yadif->out = av_frame_clone(yadif->cur);
  327. if (!yadif->out)
  328. return AVERROR(ENOMEM);
  329. av_frame_free(&yadif->prev);
  330. if (yadif->out->pts != AV_NOPTS_VALUE)
  331. yadif->out->pts *= 2;
  332. return ff_filter_frame(ctx->outputs[0], yadif->out);
  333. }
  334. if (!yadif->prev &&
  335. !(yadif->prev = av_frame_clone(yadif->cur)))
  336. return AVERROR(ENOMEM);
  337. yadif->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h);
  338. if (!yadif->out)
  339. return AVERROR(ENOMEM);
  340. av_frame_copy_props(yadif->out, yadif->cur);
  341. yadif->out->interlaced_frame = 0;
  342. if (yadif->out->pts != AV_NOPTS_VALUE)
  343. yadif->out->pts *= 2;
  344. return return_frame(ctx, 0);
  345. }
  346. static int request_frame(AVFilterLink *link)
  347. {
  348. AVFilterContext *ctx = link->src;
  349. YADIFContext *yadif = ctx->priv;
  350. if (yadif->frame_pending) {
  351. return_frame(ctx, 1);
  352. return 0;
  353. }
  354. do {
  355. int ret;
  356. if (yadif->eof)
  357. return AVERROR_EOF;
  358. ret = ff_request_frame(link->src->inputs[0]);
  359. if (ret == AVERROR_EOF && yadif->cur) {
  360. AVFrame *next = av_frame_clone(yadif->next);
  361. if (!next)
  362. return AVERROR(ENOMEM);
  363. next->pts = yadif->next->pts * 2 - yadif->cur->pts;
  364. filter_frame(link->src->inputs[0], next);
  365. yadif->eof = 1;
  366. } else if (ret < 0) {
  367. return ret;
  368. }
  369. } while (!yadif->cur);
  370. return 0;
  371. }
  372. static av_cold void uninit(AVFilterContext *ctx)
  373. {
  374. YADIFContext *yadif = ctx->priv;
  375. av_frame_free(&yadif->prev);
  376. av_frame_free(&yadif->cur );
  377. av_frame_free(&yadif->next);
  378. }
  379. static int query_formats(AVFilterContext *ctx)
  380. {
  381. static const enum AVPixelFormat pix_fmts[] = {
  382. AV_PIX_FMT_YUV420P,
  383. AV_PIX_FMT_YUV422P,
  384. AV_PIX_FMT_YUV444P,
  385. AV_PIX_FMT_YUV410P,
  386. AV_PIX_FMT_YUV411P,
  387. AV_PIX_FMT_GRAY8,
  388. AV_PIX_FMT_YUVJ420P,
  389. AV_PIX_FMT_YUVJ422P,
  390. AV_PIX_FMT_YUVJ444P,
  391. AV_PIX_FMT_GRAY16,
  392. AV_PIX_FMT_YUV440P,
  393. AV_PIX_FMT_YUVJ440P,
  394. AV_PIX_FMT_YUV420P9,
  395. AV_PIX_FMT_YUV422P9,
  396. AV_PIX_FMT_YUV444P9,
  397. AV_PIX_FMT_YUV420P10,
  398. AV_PIX_FMT_YUV422P10,
  399. AV_PIX_FMT_YUV444P10,
  400. AV_PIX_FMT_YUV420P12,
  401. AV_PIX_FMT_YUV422P12,
  402. AV_PIX_FMT_YUV444P12,
  403. AV_PIX_FMT_YUV420P14,
  404. AV_PIX_FMT_YUV422P14,
  405. AV_PIX_FMT_YUV444P14,
  406. AV_PIX_FMT_YUV420P16,
  407. AV_PIX_FMT_YUV422P16,
  408. AV_PIX_FMT_YUV444P16,
  409. AV_PIX_FMT_YUVA420P,
  410. AV_PIX_FMT_YUVA422P,
  411. AV_PIX_FMT_YUVA444P,
  412. AV_PIX_FMT_GBRP,
  413. AV_PIX_FMT_GBRAP,
  414. AV_PIX_FMT_NONE
  415. };
  416. ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
  417. return 0;
  418. }
  419. static int config_props(AVFilterLink *link)
  420. {
  421. AVFilterContext *ctx = link->src;
  422. YADIFContext *s = link->src->priv;
  423. int cpu_flags = av_get_cpu_flags();
  424. int bit_depth = (!s->csp) ? 8
  425. : s->csp->comp[0].depth_minus1 + 1;
  426. link->time_base.num = link->src->inputs[0]->time_base.num;
  427. link->time_base.den = link->src->inputs[0]->time_base.den * 2;
  428. link->w = link->src->inputs[0]->w;
  429. link->h = link->src->inputs[0]->h;
  430. if(s->mode&1)
  431. link->frame_rate = av_mul_q(link->src->inputs[0]->frame_rate, (AVRational){2,1});
  432. if (link->w < 3 || link->h < 3) {
  433. av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or lines is not supported\n");
  434. return AVERROR(EINVAL);
  435. }
  436. s->csp = av_pix_fmt_desc_get(link->format);
  437. if (s->csp->comp[0].depth_minus1 / 8 == 1) {
  438. s->filter_line = filter_line_c_16bit;
  439. s->filter_edges = filter_edges_16bit;
  440. } else {
  441. s->filter_line = filter_line_c;
  442. s->filter_edges = filter_edges;
  443. }
  444. #if HAVE_YASM
  445. if (bit_depth >= 15) {
  446. if (EXTERNAL_SSE4(cpu_flags))
  447. s->filter_line = ff_yadif_filter_line_16bit_sse4;
  448. else if (EXTERNAL_SSSE3(cpu_flags))
  449. s->filter_line = ff_yadif_filter_line_16bit_ssse3;
  450. else if (EXTERNAL_SSE2(cpu_flags))
  451. s->filter_line = ff_yadif_filter_line_16bit_sse2;
  452. #if ARCH_X86_32
  453. else if (EXTERNAL_MMXEXT(cpu_flags))
  454. s->filter_line = ff_yadif_filter_line_16bit_mmxext;
  455. #endif /* ARCH_X86_32 */
  456. } else if ( bit_depth >= 9 && bit_depth <= 14) {
  457. if (EXTERNAL_SSSE3(cpu_flags))
  458. s->filter_line = ff_yadif_filter_line_10bit_ssse3;
  459. else if (EXTERNAL_SSE2(cpu_flags))
  460. s->filter_line = ff_yadif_filter_line_10bit_sse2;
  461. #if ARCH_X86_32
  462. else if (EXTERNAL_MMXEXT(cpu_flags))
  463. s->filter_line = ff_yadif_filter_line_10bit_mmxext;
  464. #endif /* ARCH_X86_32 */
  465. } else {
  466. if (EXTERNAL_SSSE3(cpu_flags))
  467. s->filter_line = ff_yadif_filter_line_ssse3;
  468. else if (EXTERNAL_SSE2(cpu_flags))
  469. s->filter_line = ff_yadif_filter_line_sse2;
  470. #if ARCH_X86_32
  471. else if (EXTERNAL_MMXEXT(cpu_flags))
  472. s->filter_line = ff_yadif_filter_line_mmxext;
  473. #endif /* ARCH_X86_32 */
  474. }
  475. #endif /* HAVE_YASM */
  476. return 0;
  477. }
  478. #define OFFSET(x) offsetof(YADIFContext, x)
  479. #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
  480. #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
  481. static const AVOption yadif_options[] = {
  482. { "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=YADIF_MODE_SEND_FRAME}, 0, 3, FLAGS, "mode"},
  483. CONST("send_frame", "send one frame for each frame", YADIF_MODE_SEND_FRAME, "mode"),
  484. CONST("send_field", "send one frame for each field", YADIF_MODE_SEND_FIELD, "mode"),
  485. CONST("send_frame_nospatial", "send one frame for each frame, but skip spatial interlacing check", YADIF_MODE_SEND_FRAME_NOSPATIAL, "mode"),
  486. CONST("send_field_nospatial", "send one frame for each field, but skip spatial interlacing check", YADIF_MODE_SEND_FIELD_NOSPATIAL, "mode"),
  487. { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=YADIF_PARITY_AUTO}, -1, 1, FLAGS, "parity" },
  488. CONST("tff", "assume top field first", YADIF_PARITY_TFF, "parity"),
  489. CONST("bff", "assume bottom field first", YADIF_PARITY_BFF, "parity"),
  490. CONST("auto", "auto detect parity", YADIF_PARITY_AUTO, "parity"),
  491. { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=YADIF_DEINT_ALL}, 0, 1, FLAGS, "deint" },
  492. CONST("all", "deinterlace all frames", YADIF_DEINT_ALL, "deint"),
  493. CONST("interlaced", "only deinterlace frames marked as interlaced", YADIF_DEINT_INTERLACED, "deint"),
  494. { NULL }
  495. };
  496. AVFILTER_DEFINE_CLASS(yadif);
  497. AVFilter ff_vf_yadif = {
  498. .name = "yadif",
  499. .description = NULL_IF_CONFIG_SMALL("Deinterlace the input image."),
  500. .priv_size = sizeof(YADIFContext),
  501. .priv_class = &yadif_class,
  502. .uninit = uninit,
  503. .query_formats = query_formats,
  504. .inputs = (const AVFilterPad[]) {{ .name = "default",
  505. .type = AVMEDIA_TYPE_VIDEO,
  506. .filter_frame = filter_frame,
  507. },
  508. { .name = NULL}},
  509. .outputs = (const AVFilterPad[]) {{ .name = "default",
  510. .type = AVMEDIA_TYPE_VIDEO,
  511. .request_frame = request_frame,
  512. .config_props = config_props,
  513. },
  514. { .name = NULL}},
  515. .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
  516. };