From b2c6a11fb60429c9698b9d1e8538d32d741e68c5 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 27 Aug 2016 13:44:21 +0200 Subject: [PATCH] avfilter/vf_atadenoise: add planes option Make possible filtering only some planes. --- doc/filters.texi | 3 +++ libavfilter/vf_atadenoise.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 15300d8fdc..b50d7a64d2 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -4397,6 +4397,9 @@ threshold B is designed to react on continuous changes in the input signal. @item s Set number of frames filter will use for averaging. Default is 33. Must be odd number in range [5, 129]. + +@item p +Set what planes of frame filter will use for averaging. Default is all. @end table @section bbox diff --git a/libavfilter/vf_atadenoise.c b/libavfilter/vf_atadenoise.c index cdea298a82..07da792a84 100644 --- a/libavfilter/vf_atadenoise.c +++ b/libavfilter/vf_atadenoise.c @@ -25,6 +25,7 @@ * David Bartovčak and Miroslav Vrankić */ +#include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" @@ -44,6 +45,7 @@ typedef struct ATADenoiseContext { float fthra[4], fthrb[4]; int thra[4], thrb[4]; + int planes; int nb_planes; int planewidth[4]; int planeheight[4]; @@ -68,6 +70,7 @@ static const AVOption atadenoise_options[] = { { "2a", "set threshold A for 3rd plane", OFFSET(fthra[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0, 0.3, FLAGS }, { "2b", "set threshold B for 3rd plane", OFFSET(fthrb[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.04}, 0, 5.0, FLAGS }, { "s", "set how many frames to use", OFFSET(size), AV_OPT_TYPE_INT, {.i64=9}, 5, SIZE, FLAGS }, + { "p", "set what planes to filter", OFFSET(planes), AV_OPT_TYPE_FLAGS, {.i64=7}, 0, 15, FLAGS }, { NULL } }; @@ -141,6 +144,12 @@ static int filter_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs const int *linesize = (const int *)s->linesize[p]; const uint8_t *srcf[SIZE]; + if (!((1 << p) & s->planes)) { + av_image_copy_plane(dst, out->linesize[p], src, in->linesize[p], + w, slice_end - slice_start); + continue; + } + for (i = 0; i < size; i++) srcf[i] = data[i] + slice_start * linesize[i]; @@ -212,6 +221,12 @@ static int filter_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_job const int *linesize = (const int *)s->linesize[p]; const uint16_t *srcf[SIZE]; + if (!((1 << p) & s->planes)) { + av_image_copy_plane((uint8_t *)dst, out->linesize[p], (uint8_t *)src, in->linesize[p], + w * 2, slice_end - slice_start); + continue; + } + for (i = 0; i < s->size; i++) srcf[i] = (const uint16_t *)(data[i] + slice_start * linesize[i]);