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.

658 lines
20KB

  1. /*
  2. * Copyright (c) 2017 Ronald S. Bultje <rsbultje@gmail.com>
  3. * Copyright (c) 2017 Ashish Pratap Singh <ashk43712@gmail.com>
  4. * Copyright (c) 2021 Paul B Mahol
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file
  24. * Calculate VIF between two input videos.
  25. */
  26. #include <float.h>
  27. #include "libavutil/avstring.h"
  28. #include "libavutil/opt.h"
  29. #include "libavutil/pixdesc.h"
  30. #include "avfilter.h"
  31. #include "framesync.h"
  32. #include "drawutils.h"
  33. #include "formats.h"
  34. #include "internal.h"
  35. #include "vif.h"
  36. #include "video.h"
  37. typedef struct VIFContext {
  38. const AVClass *class;
  39. FFFrameSync fs;
  40. const AVPixFmtDescriptor *desc;
  41. int width;
  42. int height;
  43. int nb_threads;
  44. float factor;
  45. float *data_buf[13];
  46. float **temp;
  47. float *ref_data;
  48. float *main_data;
  49. double vif_sum[4];
  50. double vif_min[4];
  51. double vif_max[4];
  52. uint64_t nb_frames;
  53. } VIFContext;
  54. #define OFFSET(x) offsetof(VIFContext, x)
  55. static const AVOption vif_options[] = {
  56. { NULL }
  57. };
  58. AVFILTER_DEFINE_CLASS(vif);
  59. static const uint8_t vif_filter1d_width1[4] = { 17, 9, 5, 3 };
  60. static const float vif_filter1d_table[4][17] =
  61. {
  62. {
  63. 0.00745626912, 0.0142655009, 0.0250313189, 0.0402820669, 0.0594526194,
  64. 0.0804751068, 0.0999041125, 0.113746084, 0.118773937, 0.113746084,
  65. 0.0999041125, 0.0804751068, 0.0594526194, 0.0402820669, 0.0250313189,
  66. 0.0142655009, 0.00745626912
  67. },
  68. {
  69. 0.0189780835, 0.0558981746, 0.120920904, 0.192116052, 0.224173605,
  70. 0.192116052, 0.120920904, 0.0558981746, 0.0189780835
  71. },
  72. {
  73. 0.054488685, 0.244201347, 0.402619958, 0.244201347, 0.054488685
  74. },
  75. {
  76. 0.166378498, 0.667243004, 0.166378498
  77. }
  78. };
  79. typedef struct ThreadData {
  80. const float *filter;
  81. const float *src;
  82. float *dst;
  83. int w, h;
  84. int src_stride;
  85. int dst_stride;
  86. int filter_width;
  87. float **temp;
  88. } ThreadData;
  89. static void vif_dec2(const float *src, float *dst, int w, int h,
  90. int src_stride, int dst_stride)
  91. {
  92. const int dst_px_stride = dst_stride / 2;
  93. for (int i = 0; i < h / 2; i++) {
  94. for (int j = 0; j < w / 2; j++)
  95. dst[i * dst_px_stride + j] = src[(i * 2) * src_stride + (j * 2)];
  96. }
  97. }
  98. static void vif_statistic(const float *mu1_sq, const float *mu2_sq,
  99. const float *mu1_mu2, const float *xx_filt,
  100. const float *yy_filt, const float *xy_filt,
  101. float *num, float *den, int w, int h)
  102. {
  103. static const float sigma_nsq = 2;
  104. float mu1_sq_val, mu2_sq_val, mu1_mu2_val, xx_filt_val, yy_filt_val, xy_filt_val;
  105. float sigma1_sq, sigma2_sq, sigma12, g, sv_sq, eps = 1.0e-10f;
  106. float gain_limit = 100.f;
  107. float num_val, den_val;
  108. float accum_num = 0.0f;
  109. float accum_den = 0.0f;
  110. for (int i = 0; i < h; i++) {
  111. float accum_inner_num = 0.f;
  112. float accum_inner_den = 0.f;
  113. for (int j = 0; j < w; j++) {
  114. mu1_sq_val = mu1_sq[i * w + j];
  115. mu2_sq_val = mu2_sq[i * w + j];
  116. mu1_mu2_val = mu1_mu2[i * w + j];
  117. xx_filt_val = xx_filt[i * w + j];
  118. yy_filt_val = yy_filt[i * w + j];
  119. xy_filt_val = xy_filt[i * w + j];
  120. sigma1_sq = xx_filt_val - mu1_sq_val;
  121. sigma2_sq = yy_filt_val - mu2_sq_val;
  122. sigma12 = xy_filt_val - mu1_mu2_val;
  123. sigma1_sq = FFMAX(sigma1_sq, 0.0f);
  124. sigma2_sq = FFMAX(sigma2_sq, 0.0f);
  125. sigma12 = FFMAX(sigma12, 0.0f);
  126. g = sigma12 / (sigma1_sq + eps);
  127. sv_sq = sigma2_sq - g * sigma12;
  128. if (sigma1_sq < eps) {
  129. g = 0.0f;
  130. sv_sq = sigma2_sq;
  131. sigma1_sq = 0.0f;
  132. }
  133. if (sigma2_sq < eps) {
  134. g = 0.0f;
  135. sv_sq = 0.0f;
  136. }
  137. if (g < 0.0f) {
  138. sv_sq = sigma2_sq;
  139. g = 0.0f;
  140. }
  141. sv_sq = FFMAX(sv_sq, eps);
  142. g = FFMIN(g, gain_limit);
  143. num_val = log2f(1.0f + g * g * sigma1_sq / (sv_sq + sigma_nsq));
  144. den_val = log2f(1.0f + sigma1_sq / sigma_nsq);
  145. if (isnan(den_val))
  146. num_val = den_val = 1.f;
  147. accum_inner_num += num_val;
  148. accum_inner_den += den_val;
  149. }
  150. accum_num += accum_inner_num;
  151. accum_den += accum_inner_den;
  152. }
  153. num[0] = accum_num;
  154. den[0] = accum_den;
  155. }
  156. static void vif_xx_yy_xy(const float *x, const float *y, float *xx, float *yy,
  157. float *xy, int w, int h)
  158. {
  159. for (int i = 0; i < h; i++) {
  160. for (int j = 0; j < w; j++) {
  161. float xval = x[j];
  162. float yval = y[j];
  163. float xxval = xval * xval;
  164. float yyval = yval * yval;
  165. float xyval = xval * yval;
  166. xx[j] = xxval;
  167. yy[j] = yyval;
  168. xy[j] = xyval;
  169. }
  170. xx += w;
  171. yy += w;
  172. xy += w;
  173. x += w;
  174. y += w;
  175. }
  176. }
  177. static int vif_filter1d(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
  178. {
  179. ThreadData *td = arg;
  180. const float *filter = td->filter;
  181. const float *src = td->src;
  182. float *dst = td->dst;
  183. int w = td->w;
  184. int h = td->h;
  185. int src_stride = td->src_stride;
  186. int dst_stride = td->dst_stride;
  187. int filt_w = td->filter_width;
  188. float *temp = td->temp[jobnr];
  189. const int slice_start = (h * jobnr) / nb_jobs;
  190. const int slice_end = (h * (jobnr+1)) / nb_jobs;
  191. for (int i = slice_start; i < slice_end; i++) {
  192. /** Vertical pass. */
  193. for (int j = 0; j < w; j++) {
  194. float sum = 0.f;
  195. if (i >= filt_w / 2 && i < h - filt_w / 2 - 1) {
  196. for (int filt_i = 0; filt_i < filt_w; filt_i++) {
  197. const float filt_coeff = filter[filt_i];
  198. float img_coeff;
  199. int ii = i - filt_w / 2 + filt_i;
  200. img_coeff = src[ii * src_stride + j];
  201. sum += filt_coeff * img_coeff;
  202. }
  203. } else {
  204. for (int filt_i = 0; filt_i < filt_w; filt_i++) {
  205. const float filt_coeff = filter[filt_i];
  206. int ii = i - filt_w / 2 + filt_i;
  207. float img_coeff;
  208. ii = ii < 0 ? -ii : (ii >= h ? 2 * h - ii - 1 : ii);
  209. img_coeff = src[ii * src_stride + j];
  210. sum += filt_coeff * img_coeff;
  211. }
  212. }
  213. temp[j] = sum;
  214. }
  215. /** Horizontal pass. */
  216. for (int j = 0; j < w; j++) {
  217. float sum = 0.f;
  218. if (j >= filt_w / 2 && j < w - filt_w / 2 - 1) {
  219. for (int filt_j = 0; filt_j < filt_w; filt_j++) {
  220. const float filt_coeff = filter[filt_j];
  221. int jj = j - filt_w / 2 + filt_j;
  222. float img_coeff;
  223. img_coeff = temp[jj];
  224. sum += filt_coeff * img_coeff;
  225. }
  226. } else {
  227. for (int filt_j = 0; filt_j < filt_w; filt_j++) {
  228. const float filt_coeff = filter[filt_j];
  229. int jj = j - filt_w / 2 + filt_j;
  230. float img_coeff;
  231. jj = jj < 0 ? -jj : (jj >= w ? 2 * w - jj - 1 : jj);
  232. img_coeff = temp[jj];
  233. sum += filt_coeff * img_coeff;
  234. }
  235. }
  236. dst[i * dst_stride + j] = sum;
  237. }
  238. }
  239. return 0;
  240. }
  241. int ff_compute_vif2(AVFilterContext *ctx,
  242. const float *ref, const float *main, int w, int h,
  243. int ref_stride, int main_stride, float *score,
  244. float *data_buf[14], float **temp,
  245. int gnb_threads)
  246. {
  247. ThreadData td;
  248. float *ref_scale = data_buf[0];
  249. float *main_scale = data_buf[1];
  250. float *ref_sq = data_buf[2];
  251. float *main_sq = data_buf[3];
  252. float *ref_main = data_buf[4];
  253. float *mu1 = data_buf[5];
  254. float *mu2 = data_buf[6];
  255. float *mu1_sq = data_buf[7];
  256. float *mu2_sq = data_buf[8];
  257. float *mu1_mu2 = data_buf[9];
  258. float *ref_sq_filt = data_buf[10];
  259. float *main_sq_filt = data_buf[11];
  260. float *ref_main_filt = data_buf[12];
  261. float *curr_ref_scale = (float *)ref;
  262. float *curr_main_scale = (float *)main;
  263. int curr_ref_stride = ref_stride;
  264. int curr_main_stride = main_stride;
  265. float num = 0.f;
  266. float den = 0.f;
  267. for (int scale = 0; scale < 4; scale++) {
  268. const float *filter = vif_filter1d_table[scale];
  269. int filter_width = vif_filter1d_width1[scale];
  270. const int nb_threads = FFMIN(h, gnb_threads);
  271. int buf_valid_w = w;
  272. int buf_valid_h = h;
  273. td.filter = filter;
  274. td.filter_width = filter_width;
  275. if (scale > 0) {
  276. td.src = curr_ref_scale;
  277. td.dst = mu1;
  278. td.w = w;
  279. td.h = h;
  280. td.src_stride = curr_ref_stride;
  281. td.dst_stride = w;
  282. td.temp = temp;
  283. ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
  284. td.src = curr_main_scale;
  285. td.dst = mu2;
  286. td.src_stride = curr_main_stride;
  287. ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
  288. vif_dec2(mu1, ref_scale, buf_valid_w, buf_valid_h, w, w);
  289. vif_dec2(mu2, main_scale, buf_valid_w, buf_valid_h, w, w);
  290. w = buf_valid_w / 2;
  291. h = buf_valid_h / 2;
  292. buf_valid_w = w;
  293. buf_valid_h = h;
  294. curr_ref_scale = ref_scale;
  295. curr_main_scale = main_scale;
  296. curr_ref_stride = w;
  297. curr_main_stride = w;
  298. }
  299. td.src = curr_ref_scale;
  300. td.dst = mu1;
  301. td.w = w;
  302. td.h = h;
  303. td.src_stride = curr_ref_stride;
  304. td.dst_stride = w;
  305. td.temp = temp;
  306. ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
  307. td.src = curr_main_scale;
  308. td.dst = mu2;
  309. td.src_stride = curr_main_stride;
  310. ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
  311. vif_xx_yy_xy(mu1, mu2, mu1_sq, mu2_sq, mu1_mu2, w, h);
  312. vif_xx_yy_xy(curr_ref_scale, curr_main_scale, ref_sq, main_sq, ref_main, w, h);
  313. td.src = ref_sq;
  314. td.dst = ref_sq_filt;
  315. td.src_stride = w;
  316. ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
  317. td.src = main_sq;
  318. td.dst = main_sq_filt;
  319. td.src_stride = w;
  320. ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
  321. td.src = ref_main;
  322. td.dst = ref_main_filt;
  323. ctx->internal->execute(ctx, vif_filter1d, &td, NULL, nb_threads);
  324. vif_statistic(mu1_sq, mu2_sq, mu1_mu2, ref_sq_filt, main_sq_filt,
  325. ref_main_filt, &num, &den, w, h);
  326. score[scale] = den <= FLT_EPSILON ? 1.f : num / den;
  327. }
  328. return 0;
  329. }
  330. #define offset_fn(type, bits) \
  331. static void offset_##bits##bit(VIFContext *s, \
  332. const AVFrame *ref, \
  333. AVFrame *main, int stride)\
  334. { \
  335. int w = s->width; \
  336. int h = s->height; \
  337. \
  338. int ref_stride = ref->linesize[0]; \
  339. int main_stride = main->linesize[0]; \
  340. \
  341. const type *ref_ptr = (const type *) ref->data[0]; \
  342. const type *main_ptr = (const type *) main->data[0]; \
  343. \
  344. const float factor = s->factor; \
  345. \
  346. float *ref_ptr_data = s->ref_data; \
  347. float *main_ptr_data = s->main_data; \
  348. \
  349. for (int i = 0; i < h; i++) { \
  350. for (int j = 0; j < w; j++) { \
  351. ref_ptr_data[j] = ref_ptr[j] * factor - 128.f; \
  352. main_ptr_data[j] = main_ptr[j] * factor - 128.f; \
  353. } \
  354. ref_ptr += ref_stride / sizeof(type); \
  355. ref_ptr_data += w; \
  356. main_ptr += main_stride / sizeof(type); \
  357. main_ptr_data += w; \
  358. } \
  359. }
  360. offset_fn(uint8_t, 8)
  361. offset_fn(uint16_t, 16)
  362. static void set_meta(AVDictionary **metadata, const char *key, float d)
  363. {
  364. char value[257];
  365. snprintf(value, sizeof(value), "%f", d);
  366. av_dict_set(metadata, key, value, 0);
  367. }
  368. static AVFrame *do_vif(AVFilterContext *ctx, AVFrame *main, const AVFrame *ref)
  369. {
  370. VIFContext *s = ctx->priv;
  371. AVDictionary **metadata = &main->metadata;
  372. float score[4];
  373. s->factor = 1.f / (1 << (s->desc->comp[0].depth - 8));
  374. if (s->desc->comp[0].depth <= 8) {
  375. offset_8bit(s, ref, main, s->width);
  376. } else {
  377. offset_16bit(s, ref, main, s->width);
  378. }
  379. ff_compute_vif2(ctx,
  380. s->ref_data, s->main_data, s->width,
  381. s->height, s->width, s->width,
  382. score, s->data_buf, s->temp,
  383. s->nb_threads);
  384. set_meta(metadata, "lavfi.vif.scale.0", score[0]);
  385. set_meta(metadata, "lavfi.vif.scale.1", score[1]);
  386. set_meta(metadata, "lavfi.vif.scale.2", score[2]);
  387. set_meta(metadata, "lavfi.vif.scale.3", score[3]);
  388. for (int i = 0; i < 4; i++) {
  389. s->vif_min[i] = FFMIN(s->vif_min[i], score[i]);
  390. s->vif_max[i] = FFMAX(s->vif_max[i], score[i]);
  391. s->vif_sum[i] += score[i];
  392. }
  393. s->nb_frames++;
  394. return main;
  395. }
  396. static int query_formats(AVFilterContext *ctx)
  397. {
  398. static const enum AVPixelFormat pix_fmts[] = {
  399. AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10,
  400. AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,
  401. AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,
  402. AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
  403. AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
  404. AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
  405. #define PF(suf) AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
  406. PF(P9), PF(P10), PF(P12), PF(P14), PF(P16),
  407. AV_PIX_FMT_NONE
  408. };
  409. AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
  410. if (!fmts_list)
  411. return AVERROR(ENOMEM);
  412. return ff_set_common_formats(ctx, fmts_list);
  413. }
  414. static int config_input_ref(AVFilterLink *inlink)
  415. {
  416. AVFilterContext *ctx = inlink->dst;
  417. VIFContext *s = ctx->priv;
  418. if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
  419. ctx->inputs[0]->h != ctx->inputs[1]->h) {
  420. av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
  421. return AVERROR(EINVAL);
  422. }
  423. if (ctx->inputs[0]->format != ctx->inputs[1]->format) {
  424. av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n");
  425. return AVERROR(EINVAL);
  426. }
  427. s->desc = av_pix_fmt_desc_get(inlink->format);
  428. s->width = ctx->inputs[0]->w;
  429. s->height = ctx->inputs[0]->h;
  430. s->nb_threads = ff_filter_get_nb_threads(ctx);
  431. for (int i = 0; i < 4; i++) {
  432. s->vif_min[i] = DBL_MAX;
  433. s->vif_max[i] = -DBL_MAX;
  434. }
  435. for (int i = 0; i < 13; i++) {
  436. if (!(s->data_buf[i] = av_calloc(s->width, s->height * sizeof(float))))
  437. return AVERROR(ENOMEM);
  438. }
  439. if (!(s->ref_data = av_calloc(s->width, s->height * sizeof(float))))
  440. return AVERROR(ENOMEM);
  441. if (!(s->main_data = av_calloc(s->width, s->height * sizeof(float))))
  442. return AVERROR(ENOMEM);
  443. if (!(s->temp = av_calloc(s->nb_threads, sizeof(s->temp[0]))))
  444. return AVERROR(ENOMEM);
  445. for (int i = 0; i < s->nb_threads; i++) {
  446. if (!(s->temp[i] = av_calloc(s->width, sizeof(float))))
  447. return AVERROR(ENOMEM);
  448. }
  449. return 0;
  450. }
  451. static int process_frame(FFFrameSync *fs)
  452. {
  453. AVFilterContext *ctx = fs->parent;
  454. VIFContext *s = fs->opaque;
  455. AVFilterLink *outlink = ctx->outputs[0];
  456. AVFrame *out_frame, *main_frame = NULL, *ref_frame = NULL;
  457. int ret;
  458. ret = ff_framesync_dualinput_get(fs, &main_frame, &ref_frame);
  459. if (ret < 0)
  460. return ret;
  461. if (ctx->is_disabled || !ref_frame) {
  462. out_frame = main_frame;
  463. } else {
  464. out_frame = do_vif(ctx, main_frame, ref_frame);
  465. }
  466. out_frame->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
  467. return ff_filter_frame(outlink, out_frame);
  468. }
  469. static int config_output(AVFilterLink *outlink)
  470. {
  471. AVFilterContext *ctx = outlink->src;
  472. VIFContext *s = ctx->priv;
  473. AVFilterLink *mainlink = ctx->inputs[0];
  474. FFFrameSyncIn *in;
  475. int ret;
  476. outlink->w = mainlink->w;
  477. outlink->h = mainlink->h;
  478. outlink->time_base = mainlink->time_base;
  479. outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
  480. outlink->frame_rate = mainlink->frame_rate;
  481. if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
  482. return ret;
  483. in = s->fs.in;
  484. in[0].time_base = mainlink->time_base;
  485. in[1].time_base = ctx->inputs[1]->time_base;
  486. in[0].sync = 2;
  487. in[0].before = EXT_STOP;
  488. in[0].after = EXT_STOP;
  489. in[1].sync = 1;
  490. in[1].before = EXT_STOP;
  491. in[1].after = EXT_STOP;
  492. s->fs.opaque = s;
  493. s->fs.on_event = process_frame;
  494. return ff_framesync_configure(&s->fs);
  495. }
  496. static int activate(AVFilterContext *ctx)
  497. {
  498. VIFContext *s = ctx->priv;
  499. return ff_framesync_activate(&s->fs);
  500. }
  501. static av_cold void uninit(AVFilterContext *ctx)
  502. {
  503. VIFContext *s = ctx->priv;
  504. if (s->nb_frames > 0) {
  505. for (int i = 0; i < 4; i++)
  506. av_log(ctx, AV_LOG_INFO, "VIF scale=%d average:%f min:%f: max:%f\n",
  507. i, s->vif_sum[i] / s->nb_frames, s->vif_min[i], s->vif_max[i]);
  508. }
  509. for (int i = 0; i < 13; i++)
  510. av_freep(&s->data_buf[i]);
  511. av_freep(&s->ref_data);
  512. av_freep(&s->main_data);
  513. for (int i = 0; i < s->nb_threads && s->temp; i++)
  514. av_freep(&s->temp[i]);
  515. av_freep(&s->temp);
  516. ff_framesync_uninit(&s->fs);
  517. }
  518. static const AVFilterPad vif_inputs[] = {
  519. {
  520. .name = "main",
  521. .type = AVMEDIA_TYPE_VIDEO,
  522. },{
  523. .name = "reference",
  524. .type = AVMEDIA_TYPE_VIDEO,
  525. .config_props = config_input_ref,
  526. },
  527. { NULL }
  528. };
  529. static const AVFilterPad vif_outputs[] = {
  530. {
  531. .name = "default",
  532. .type = AVMEDIA_TYPE_VIDEO,
  533. .config_props = config_output,
  534. },
  535. { NULL }
  536. };
  537. AVFilter ff_vf_vif = {
  538. .name = "vif",
  539. .description = NULL_IF_CONFIG_SMALL("Calculate the VIF between two video streams."),
  540. .uninit = uninit,
  541. .query_formats = query_formats,
  542. .priv_size = sizeof(VIFContext),
  543. .priv_class = &vif_class,
  544. .activate = activate,
  545. .inputs = vif_inputs,
  546. .outputs = vif_outputs,
  547. .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
  548. };