Commit 1ee9eaca authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '7ed833d7'

* commit '7ed833d7':
  vf_gradfun: switch to an AVOptions-based system.

Conflicts:
	doc/filters.texi
	libavfilter/gradfun.h
	libavfilter/vf_gradfun.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 85f115b5 7ed833d7
...@@ -3412,22 +3412,21 @@ This filter is designed for playback only. Do not use it prior to ...@@ -3412,22 +3412,21 @@ This filter is designed for playback only. Do not use it prior to
lossy compression, because compression tends to lose the dither and lossy compression, because compression tends to lose the dither and
bring back the bands. bring back the bands.
The filter accepts a list of options in the form of @var{key}=@var{value} pairs This filter accepts the following options:
separated by ":". A description of the accepted options follows.
@table @option @table @option
@item strength @item strength
The maximum amount by which the filter will change The maximum amount by which the filter will change any one pixel. Also the
any one pixel. Also the threshold for detecting nearly flat threshold for detecting nearly flat regions. Acceptable values range from .51 to
regions. Acceptable values range from @code{0.51} to @code{64}, default value 64, default value is 1.2, out-of-range values will be clipped to the valid
is @code{1.2}. range.
@item radius @item radius
The neighborhood to fit the gradient to. A larger The neighborhood to fit the gradient to. A larger radius makes for smoother
radius makes for smoother gradients, but also prevents the filter from gradients, but also prevents the filter from modifying the pixels near detailed
modifying the pixels near detailed regions. Acceptable values are regions. Acceptable values are 8-32, default value is 16, out-of-range values
@code{8-32}, default value is @code{16}. will be clipped to the valid range.
@end table @end table
......
...@@ -669,6 +669,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque ...@@ -669,6 +669,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
!strcmp(filter->filter->name, "fps" ) || !strcmp(filter->filter->name, "fps" ) ||
!strcmp(filter->filter->name, "frei0r" ) || !strcmp(filter->filter->name, "frei0r" ) ||
!strcmp(filter->filter->name, "frei0r_src") || !strcmp(filter->filter->name, "frei0r_src") ||
!strcmp(filter->filter->name, "gradfun" ) ||
!strcmp(filter->filter->name, "format") || !strcmp(filter->filter->name, "format") ||
!strcmp(filter->filter->name, "noformat") || !strcmp(filter->filter->name, "noformat") ||
!strcmp(filter->filter->name, "resample") || !strcmp(filter->filter->name, "resample") ||
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
/// Holds instance-specific information for gradfun. /// Holds instance-specific information for gradfun.
typedef struct GradFunContext { typedef struct GradFunContext {
const AVClass *class; const AVClass *class;
double strength; ///< user specified strength, used to define thresh float strength;
int thresh; ///< threshold for gradient algorithm int thresh; ///< threshold for gradient algorithm
int radius; ///< blur radius int radius; ///< blur radius
int chroma_w; ///< width of the chroma planes int chroma_w; ///< width of the chroma planes
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/common.h" #include "libavutil/common.h"
#include "libavutil/cpu.h" #include "libavutil/cpu.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h" #include "libavutil/pixdesc.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "avfilter.h" #include "avfilter.h"
...@@ -43,17 +44,6 @@ ...@@ -43,17 +44,6 @@
#include "internal.h" #include "internal.h"
#include "video.h" #include "video.h"
#define OFFSET(x) offsetof(GradFunContext, x)
#define F AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static const AVOption gradfun_options[] = {
{ "strength", "set the maximum amount by which the filter will change any one pixel", OFFSET(strength), AV_OPT_TYPE_DOUBLE, {.dbl = 1.2}, 0.51, 64, F },
{ "radius", "set the neighborhood to fit the gradient to", OFFSET(radius), AV_OPT_TYPE_INT, {.i64 = 16}, 4, 32, F },
{ NULL }
};
AVFILTER_DEFINE_CLASS(gradfun);
DECLARE_ALIGNED(16, static const uint16_t, dither)[8][8] = { DECLARE_ALIGNED(16, static const uint16_t, dither)[8][8] = {
{0x00,0x60,0x18,0x78,0x06,0x66,0x1E,0x7E}, {0x00,0x60,0x18,0x78,0x06,0x66,0x1E,0x7E},
{0x40,0x20,0x58,0x38,0x46,0x26,0x5E,0x3E}, {0x40,0x20,0x58,0x38,0x46,0x26,0x5E,0x3E},
...@@ -135,8 +125,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args) ...@@ -135,8 +125,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
{ {
GradFunContext *gf = ctx->priv; GradFunContext *gf = ctx->priv;
gf->thresh = (1 << 15) / gf->strength; gf->thresh = (1 << 15) / gf->strength;
gf->radius = av_clip((gf->radius + 1) & ~1, 4, 32); gf->radius = av_clip((gf->radius + 1) & ~1, 4, 32);
gf->blur_line = ff_gradfun_blur_line_c; gf->blur_line = ff_gradfun_blur_line_c;
gf->filter_line = ff_gradfun_filter_line_c; gf->filter_line = ff_gradfun_filter_line_c;
...@@ -231,6 +221,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) ...@@ -231,6 +221,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return ff_filter_frame(outlink, out); return ff_filter_frame(outlink, out);
} }
#define OFFSET(x) offsetof(GradFunContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static const AVOption gradfun_options[] = {
{ "strength", "The maximum amount by which the filter will change any one pixel.", OFFSET(strength), AV_OPT_TYPE_FLOAT, { .dbl = 1.2 }, 0.51, 64, FLAGS },
{ "radius", "The neighborhood to fit the gradient to.", OFFSET(radius), AV_OPT_TYPE_INT, { .i64 = 16 }, 4, 32, FLAGS },
{ NULL },
};
AVFILTER_DEFINE_CLASS(gradfun);
static const AVFilterPad avfilter_vf_gradfun_inputs[] = { static const AVFilterPad avfilter_vf_gradfun_inputs[] = {
{ {
.name = "default", .name = "default",
...@@ -249,17 +250,14 @@ static const AVFilterPad avfilter_vf_gradfun_outputs[] = { ...@@ -249,17 +250,14 @@ static const AVFilterPad avfilter_vf_gradfun_outputs[] = {
{ NULL } { NULL }
}; };
static const char *const shorthand[] = { "strength", "radius", NULL };
AVFilter avfilter_vf_gradfun = { AVFilter avfilter_vf_gradfun = {
.name = "gradfun", .name = "gradfun",
.description = NULL_IF_CONFIG_SMALL("Debands video quickly using gradients."), .description = NULL_IF_CONFIG_SMALL("Debands video quickly using gradients."),
.priv_size = sizeof(GradFunContext), .priv_size = sizeof(GradFunContext),
.priv_class = &gradfun_class,
.init = init, .init = init,
.uninit = uninit, .uninit = uninit,
.query_formats = query_formats, .query_formats = query_formats,
.inputs = avfilter_vf_gradfun_inputs, .inputs = avfilter_vf_gradfun_inputs,
.outputs = avfilter_vf_gradfun_outputs, .outputs = avfilter_vf_gradfun_outputs,
.priv_class = &gradfun_class,
.shorthand = shorthand,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment