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.

588 lines
27KB

  1. /*
  2. * Copyright (c) 2015 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. * @file
  22. * Adaptive Temporal Averaging Denoiser,
  23. * based on paper "Video Denoising Based on Adaptive Temporal Averaging" by
  24. * David Bartovčak and Miroslav Vrankić
  25. */
  26. #include "libavutil/imgutils.h"
  27. #include "libavutil/opt.h"
  28. #include "libavutil/pixdesc.h"
  29. #include "avfilter.h"
  30. #define FF_BUFQUEUE_SIZE 129
  31. #include "bufferqueue.h"
  32. #include "atadenoise.h"
  33. #include "formats.h"
  34. #include "internal.h"
  35. #include "video.h"
  36. #define SIZE FF_BUFQUEUE_SIZE
  37. typedef struct ATADenoiseContext {
  38. const AVClass *class;
  39. float fthra[4], fthrb[4];
  40. float sigma[4];
  41. int thra[4], thrb[4];
  42. int algorithm;
  43. int planes;
  44. int nb_planes;
  45. int planewidth[4];
  46. int planeheight[4];
  47. struct FFBufQueue q;
  48. void *data[4][SIZE];
  49. int linesize[4][SIZE];
  50. float weights[4][SIZE];
  51. int size, mid, radius;
  52. int available;
  53. int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
  54. ATADenoiseDSPContext dsp;
  55. } ATADenoiseContext;
  56. #define OFFSET(x) offsetof(ATADenoiseContext, x)
  57. #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
  58. #define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
  59. static const AVOption atadenoise_options[] = {
  60. { "0a", "set threshold A for 1st plane", OFFSET(fthra[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0, 0.3, FLAGS },
  61. { "0b", "set threshold B for 1st plane", OFFSET(fthrb[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.04}, 0, 5.0, FLAGS },
  62. { "1a", "set threshold A for 2nd plane", OFFSET(fthra[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0, 0.3, FLAGS },
  63. { "1b", "set threshold B for 2nd plane", OFFSET(fthrb[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.04}, 0, 5.0, FLAGS },
  64. { "2a", "set threshold A for 3rd plane", OFFSET(fthra[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0, 0.3, FLAGS },
  65. { "2b", "set threshold B for 3rd plane", OFFSET(fthrb[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.04}, 0, 5.0, FLAGS },
  66. { "s", "set how many frames to use", OFFSET(size), AV_OPT_TYPE_INT, {.i64=9}, 5, SIZE, VF },
  67. { "p", "set what planes to filter", OFFSET(planes), AV_OPT_TYPE_FLAGS, {.i64=7}, 0, 15, FLAGS },
  68. { "a", "set variant of algorithm", OFFSET(algorithm),AV_OPT_TYPE_INT, {.i64=PARALLEL}, 0, NB_ATAA-1, FLAGS, "a" },
  69. { "p", "parallel", 0, AV_OPT_TYPE_CONST, {.i64=PARALLEL}, 0, 0, FLAGS, "a" },
  70. { "s", "serial", 0, AV_OPT_TYPE_CONST, {.i64=SERIAL}, 0, 0, FLAGS, "a" },
  71. { "0s", "set sigma for 1st plane", OFFSET(sigma[0]), AV_OPT_TYPE_FLOAT, {.dbl=INT16_MAX}, 0, INT16_MAX, FLAGS },
  72. { "1s", "set sigma for 2nd plane", OFFSET(sigma[1]), AV_OPT_TYPE_FLOAT, {.dbl=INT16_MAX}, 0, INT16_MAX, FLAGS },
  73. { "2s", "set sigma for 3rd plane", OFFSET(sigma[2]), AV_OPT_TYPE_FLOAT, {.dbl=INT16_MAX}, 0, INT16_MAX, FLAGS },
  74. { NULL }
  75. };
  76. AVFILTER_DEFINE_CLASS(atadenoise);
  77. static int query_formats(AVFilterContext *ctx)
  78. {
  79. static const enum AVPixelFormat pixel_fmts[] = {
  80. AV_PIX_FMT_GRAY8,
  81. AV_PIX_FMT_GRAY9,
  82. AV_PIX_FMT_GRAY10,
  83. AV_PIX_FMT_GRAY12,
  84. AV_PIX_FMT_GRAY14,
  85. AV_PIX_FMT_GRAY16,
  86. AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
  87. AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
  88. AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
  89. AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
  90. AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
  91. AV_PIX_FMT_YUVJ411P,
  92. AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
  93. AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
  94. AV_PIX_FMT_YUV440P10,
  95. AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12,
  96. AV_PIX_FMT_YUV440P12,
  97. AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV420P14,
  98. AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
  99. AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
  100. AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
  101. AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
  102. AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16,
  103. AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA422P16,
  104. AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA420P16,
  105. AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
  106. AV_PIX_FMT_NONE
  107. };
  108. AVFilterFormats *formats = ff_make_format_list(pixel_fmts);
  109. if (!formats)
  110. return AVERROR(ENOMEM);
  111. return ff_set_common_formats(ctx, formats);
  112. }
  113. static av_cold int init(AVFilterContext *ctx)
  114. {
  115. ATADenoiseContext *s = ctx->priv;
  116. if (!(s->size & 1)) {
  117. av_log(ctx, AV_LOG_WARNING, "size %d is invalid. Must be an odd value, setting it to %d.\n", s->size, s->size|1);
  118. s->size |= 1;
  119. }
  120. s->radius = s->size / 2;
  121. s->mid = s->radius;
  122. return 0;
  123. }
  124. typedef struct ThreadData {
  125. AVFrame *in, *out;
  126. } ThreadData;
  127. #define WFILTER_ROW(type, name) \
  128. static void fweight_row##name(const uint8_t *ssrc, uint8_t *ddst, \
  129. const uint8_t *ssrcf[SIZE], \
  130. int w, int mid, int size, \
  131. int thra, int thrb, const float *weights) \
  132. { \
  133. const type *src = (const type *)ssrc; \
  134. const type **srcf = (const type **)ssrcf; \
  135. type *dst = (type *)ddst; \
  136. \
  137. for (int x = 0; x < w; x++) { \
  138. const int srcx = src[x]; \
  139. unsigned lsumdiff = 0, rsumdiff = 0; \
  140. unsigned ldiff, rdiff; \
  141. float sum = srcx; \
  142. float wsum = 1.f; \
  143. int l = 0, r = 0; \
  144. int srcjx, srcix; \
  145. \
  146. for (int j = mid - 1, i = mid + 1; j >= 0 && i < size; j--, i++) { \
  147. srcjx = srcf[j][x]; \
  148. \
  149. ldiff = FFABS(srcx - srcjx); \
  150. lsumdiff += ldiff; \
  151. if (ldiff > thra || \
  152. lsumdiff > thrb) \
  153. break; \
  154. l++; \
  155. sum += srcjx * weights[j]; \
  156. wsum += weights[j]; \
  157. \
  158. srcix = srcf[i][x]; \
  159. \
  160. rdiff = FFABS(srcx - srcix); \
  161. rsumdiff += rdiff; \
  162. if (rdiff > thra || \
  163. rsumdiff > thrb) \
  164. break; \
  165. r++; \
  166. sum += srcix * weights[i]; \
  167. wsum += weights[i]; \
  168. } \
  169. \
  170. dst[x] = lrintf(sum / wsum); \
  171. } \
  172. }
  173. WFILTER_ROW(uint8_t, 8)
  174. WFILTER_ROW(uint16_t, 16)
  175. #define WFILTER_ROW_SERIAL(type, name) \
  176. static void fweight_row##name##_serial(const uint8_t *ssrc, uint8_t *ddst, \
  177. const uint8_t *ssrcf[SIZE], \
  178. int w, int mid, int size, \
  179. int thra, int thrb, \
  180. const float *weights) \
  181. { \
  182. const type *src = (const type *)ssrc; \
  183. const type **srcf = (const type **)ssrcf; \
  184. type *dst = (type *)ddst; \
  185. \
  186. for (int x = 0; x < w; x++) { \
  187. const int srcx = src[x]; \
  188. unsigned lsumdiff = 0, rsumdiff = 0; \
  189. unsigned ldiff, rdiff; \
  190. float sum = srcx; \
  191. float wsum = 1.f; \
  192. int l = 0, r = 0; \
  193. int srcjx, srcix; \
  194. \
  195. for (int j = mid - 1; j >= 0; j--) { \
  196. srcjx = srcf[j][x]; \
  197. \
  198. ldiff = FFABS(srcx - srcjx); \
  199. lsumdiff += ldiff; \
  200. if (ldiff > thra || \
  201. lsumdiff > thrb) \
  202. break; \
  203. l++; \
  204. sum += srcjx * weights[j]; \
  205. wsum += weights[j]; \
  206. } \
  207. \
  208. for (int i = mid + 1; i < size; i++) { \
  209. srcix = srcf[i][x]; \
  210. \
  211. rdiff = FFABS(srcx - srcix); \
  212. rsumdiff += rdiff; \
  213. if (rdiff > thra || \
  214. rsumdiff > thrb) \
  215. break; \
  216. r++; \
  217. sum += srcix * weights[i]; \
  218. wsum += weights[i]; \
  219. } \
  220. \
  221. dst[x] = lrintf(sum / wsum); \
  222. } \
  223. }
  224. WFILTER_ROW_SERIAL(uint8_t, 8)
  225. WFILTER_ROW_SERIAL(uint16_t, 16)
  226. #define FILTER_ROW(type, name) \
  227. static void filter_row##name(const uint8_t *ssrc, uint8_t *ddst, \
  228. const uint8_t *ssrcf[SIZE], \
  229. int w, int mid, int size, \
  230. int thra, int thrb, const float *weights) \
  231. { \
  232. const type *src = (const type *)ssrc; \
  233. const type **srcf = (const type **)ssrcf; \
  234. type *dst = (type *)ddst; \
  235. \
  236. for (int x = 0; x < w; x++) { \
  237. const int srcx = src[x]; \
  238. unsigned lsumdiff = 0, rsumdiff = 0; \
  239. unsigned ldiff, rdiff; \
  240. unsigned sum = srcx; \
  241. int l = 0, r = 0; \
  242. int srcjx, srcix; \
  243. \
  244. for (int j = mid - 1, i = mid + 1; j >= 0 && i < size; j--, i++) { \
  245. srcjx = srcf[j][x]; \
  246. \
  247. ldiff = FFABS(srcx - srcjx); \
  248. lsumdiff += ldiff; \
  249. if (ldiff > thra || \
  250. lsumdiff > thrb) \
  251. break; \
  252. l++; \
  253. sum += srcjx; \
  254. \
  255. srcix = srcf[i][x]; \
  256. \
  257. rdiff = FFABS(srcx - srcix); \
  258. rsumdiff += rdiff; \
  259. if (rdiff > thra || \
  260. rsumdiff > thrb) \
  261. break; \
  262. r++; \
  263. sum += srcix; \
  264. } \
  265. \
  266. dst[x] = (sum + ((r + l + 1) >> 1)) / (r + l + 1); \
  267. } \
  268. }
  269. FILTER_ROW(uint8_t, 8)
  270. FILTER_ROW(uint16_t, 16)
  271. #define FILTER_ROW_SERIAL(type, name) \
  272. static void filter_row##name##_serial(const uint8_t *ssrc, uint8_t *ddst, \
  273. const uint8_t *ssrcf[SIZE], \
  274. int w, int mid, int size, \
  275. int thra, int thrb, \
  276. const float *weights) \
  277. { \
  278. const type *src = (const type *)ssrc; \
  279. const type **srcf = (const type **)ssrcf; \
  280. type *dst = (type *)ddst; \
  281. \
  282. for (int x = 0; x < w; x++) { \
  283. const int srcx = src[x]; \
  284. unsigned lsumdiff = 0, rsumdiff = 0; \
  285. unsigned ldiff, rdiff; \
  286. unsigned sum = srcx; \
  287. int l = 0, r = 0; \
  288. int srcjx, srcix; \
  289. \
  290. for (int j = mid - 1; j >= 0; j--) { \
  291. srcjx = srcf[j][x]; \
  292. \
  293. ldiff = FFABS(srcx - srcjx); \
  294. lsumdiff += ldiff; \
  295. if (ldiff > thra || \
  296. lsumdiff > thrb) \
  297. break; \
  298. l++; \
  299. sum += srcjx; \
  300. } \
  301. \
  302. for (int i = mid + 1; i < size; i++) { \
  303. srcix = srcf[i][x]; \
  304. \
  305. rdiff = FFABS(srcx - srcix); \
  306. rsumdiff += rdiff; \
  307. if (rdiff > thra || \
  308. rsumdiff > thrb) \
  309. break; \
  310. r++; \
  311. sum += srcix; \
  312. } \
  313. \
  314. dst[x] = (sum + ((r + l + 1) >> 1)) / (r + l + 1); \
  315. } \
  316. }
  317. FILTER_ROW_SERIAL(uint8_t, 8)
  318. FILTER_ROW_SERIAL(uint16_t, 16)
  319. static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
  320. {
  321. ATADenoiseContext *s = ctx->priv;
  322. ThreadData *td = arg;
  323. AVFrame *in = td->in;
  324. AVFrame *out = td->out;
  325. const int size = s->size;
  326. const int mid = s->mid;
  327. int p, y, i;
  328. for (p = 0; p < s->nb_planes; p++) {
  329. const float *weights = s->weights[p];
  330. const int h = s->planeheight[p];
  331. const int w = s->planewidth[p];
  332. const int slice_start = (h * jobnr) / nb_jobs;
  333. const int slice_end = (h * (jobnr+1)) / nb_jobs;
  334. const uint8_t *src = in->data[p] + slice_start * in->linesize[p];
  335. uint8_t *dst = out->data[p] + slice_start * out->linesize[p];
  336. const int thra = s->thra[p];
  337. const int thrb = s->thrb[p];
  338. const uint8_t **data = (const uint8_t **)s->data[p];
  339. const int *linesize = (const int *)s->linesize[p];
  340. const uint8_t *srcf[SIZE];
  341. if (!((1 << p) & s->planes)) {
  342. av_image_copy_plane(dst, out->linesize[p], src, in->linesize[p],
  343. w, slice_end - slice_start);
  344. continue;
  345. }
  346. for (i = 0; i < size; i++)
  347. srcf[i] = data[i] + slice_start * linesize[i];
  348. for (y = slice_start; y < slice_end; y++) {
  349. s->dsp.filter_row[p](src, dst, srcf, w, mid, size, thra, thrb, weights);
  350. dst += out->linesize[p];
  351. src += in->linesize[p];
  352. for (i = 0; i < size; i++)
  353. srcf[i] += linesize[i];
  354. }
  355. }
  356. return 0;
  357. }
  358. static int config_input(AVFilterLink *inlink)
  359. {
  360. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
  361. AVFilterContext *ctx = inlink->dst;
  362. ATADenoiseContext *s = ctx->priv;
  363. int depth;
  364. s->nb_planes = desc->nb_components;
  365. s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
  366. s->planeheight[0] = s->planeheight[3] = inlink->h;
  367. s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
  368. s->planewidth[0] = s->planewidth[3] = inlink->w;
  369. depth = desc->comp[0].depth;
  370. s->filter_slice = filter_slice;
  371. for (int p = 0; p < s->nb_planes; p++) {
  372. if (depth == 8 && s->sigma[p] == INT16_MAX)
  373. s->dsp.filter_row[p] = s->algorithm == PARALLEL ? filter_row8 : filter_row8_serial;
  374. else if (s->sigma[p] == INT16_MAX)
  375. s->dsp.filter_row[p] = s->algorithm == PARALLEL ? filter_row16 : filter_row16_serial;
  376. else if (depth == 8 && s->sigma[p] < INT16_MAX)
  377. s->dsp.filter_row[p] = s->algorithm == PARALLEL ? fweight_row8 : fweight_row8_serial;
  378. else if (s->sigma[p] < INT16_MAX)
  379. s->dsp.filter_row[p] = s->algorithm == PARALLEL ? fweight_row16 : fweight_row16_serial;
  380. }
  381. s->thra[0] = s->fthra[0] * (1 << depth) - 1;
  382. s->thra[1] = s->fthra[1] * (1 << depth) - 1;
  383. s->thra[2] = s->fthra[2] * (1 << depth) - 1;
  384. s->thrb[0] = s->fthrb[0] * (1 << depth) - 1;
  385. s->thrb[1] = s->fthrb[1] * (1 << depth) - 1;
  386. s->thrb[2] = s->fthrb[2] * (1 << depth) - 1;
  387. for (int p = 0; p < s->nb_planes; p++) {
  388. float sigma = s->radius * s->sigma[p];
  389. s->weights[p][s->radius] = 1.f;
  390. for (int n = 1; n <= s->radius; n++) {
  391. s->weights[p][s->radius + n] =
  392. s->weights[p][s->radius - n] = expf(-0.5 * (n + 1) * (n + 1) / (sigma * sigma));
  393. }
  394. }
  395. if (ARCH_X86)
  396. ff_atadenoise_init_x86(&s->dsp, depth, s->algorithm, s->sigma);
  397. return 0;
  398. }
  399. static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
  400. {
  401. AVFilterContext *ctx = inlink->dst;
  402. AVFilterLink *outlink = ctx->outputs[0];
  403. ATADenoiseContext *s = ctx->priv;
  404. AVFrame *out, *in;
  405. int i;
  406. if (s->q.available != s->size) {
  407. if (s->q.available < s->mid) {
  408. for (i = 0; i < s->mid; i++) {
  409. out = av_frame_clone(buf);
  410. if (!out) {
  411. av_frame_free(&buf);
  412. return AVERROR(ENOMEM);
  413. }
  414. ff_bufqueue_add(ctx, &s->q, out);
  415. }
  416. }
  417. if (s->q.available < s->size) {
  418. ff_bufqueue_add(ctx, &s->q, buf);
  419. s->available++;
  420. }
  421. return 0;
  422. }
  423. in = ff_bufqueue_peek(&s->q, s->mid);
  424. if (!ctx->is_disabled) {
  425. ThreadData td;
  426. out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
  427. if (!out) {
  428. av_frame_free(&buf);
  429. return AVERROR(ENOMEM);
  430. }
  431. for (i = 0; i < s->size; i++) {
  432. AVFrame *frame = ff_bufqueue_peek(&s->q, i);
  433. s->data[0][i] = frame->data[0];
  434. s->data[1][i] = frame->data[1];
  435. s->data[2][i] = frame->data[2];
  436. s->linesize[0][i] = frame->linesize[0];
  437. s->linesize[1][i] = frame->linesize[1];
  438. s->linesize[2][i] = frame->linesize[2];
  439. }
  440. td.in = in; td.out = out;
  441. ctx->internal->execute(ctx, s->filter_slice, &td, NULL,
  442. FFMIN3(s->planeheight[1],
  443. s->planeheight[2],
  444. ff_filter_get_nb_threads(ctx)));
  445. av_frame_copy_props(out, in);
  446. } else {
  447. out = av_frame_clone(in);
  448. if (!out) {
  449. av_frame_free(&buf);
  450. return AVERROR(ENOMEM);
  451. }
  452. }
  453. in = ff_bufqueue_get(&s->q);
  454. av_frame_free(&in);
  455. ff_bufqueue_add(ctx, &s->q, buf);
  456. return ff_filter_frame(outlink, out);
  457. }
  458. static int request_frame(AVFilterLink *outlink)
  459. {
  460. AVFilterContext *ctx = outlink->src;
  461. ATADenoiseContext *s = ctx->priv;
  462. int ret = 0;
  463. ret = ff_request_frame(ctx->inputs[0]);
  464. if (ret == AVERROR_EOF && !ctx->is_disabled && s->available) {
  465. AVFrame *buf = av_frame_clone(ff_bufqueue_peek(&s->q, s->available));
  466. if (!buf)
  467. return AVERROR(ENOMEM);
  468. ret = filter_frame(ctx->inputs[0], buf);
  469. s->available--;
  470. }
  471. return ret;
  472. }
  473. static av_cold void uninit(AVFilterContext *ctx)
  474. {
  475. ATADenoiseContext *s = ctx->priv;
  476. ff_bufqueue_discard_all(&s->q);
  477. }
  478. static int process_command(AVFilterContext *ctx,
  479. const char *cmd,
  480. const char *arg,
  481. char *res,
  482. int res_len,
  483. int flags)
  484. {
  485. int ret = ff_filter_process_command(ctx, cmd, arg, res, res_len, flags);
  486. if (ret < 0)
  487. return ret;
  488. return config_input(ctx->inputs[0]);
  489. }
  490. static const AVFilterPad inputs[] = {
  491. {
  492. .name = "default",
  493. .type = AVMEDIA_TYPE_VIDEO,
  494. .filter_frame = filter_frame,
  495. .config_props = config_input,
  496. },
  497. { NULL }
  498. };
  499. static const AVFilterPad outputs[] = {
  500. {
  501. .name = "default",
  502. .type = AVMEDIA_TYPE_VIDEO,
  503. .request_frame = request_frame,
  504. },
  505. { NULL }
  506. };
  507. AVFilter ff_vf_atadenoise = {
  508. .name = "atadenoise",
  509. .description = NULL_IF_CONFIG_SMALL("Apply an Adaptive Temporal Averaging Denoiser."),
  510. .priv_size = sizeof(ATADenoiseContext),
  511. .priv_class = &atadenoise_class,
  512. .init = init,
  513. .uninit = uninit,
  514. .query_formats = query_formats,
  515. .inputs = inputs,
  516. .outputs = outputs,
  517. .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
  518. .process_command = process_command,
  519. };