Merge commit 'b83e9efc53e5491716625aa31c69006b1119b280'

* commit 'b83e9efc53e5491716625aa31c69006b1119b280':
  vf_unsharp: switch to an AVOptions-based system.

Conflicts:
	doc/filters.texi
	libavfilter/vf_unsharp.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-04-11 00:50:53 +02:00
commit c2696dabbb
3 changed files with 35 additions and 46 deletions

View File

@ -5615,14 +5615,7 @@ transpose=1:portrait
Sharpen or blur the input video.
This filter accepts parameters as a list of @var{key}=@var{value} pairs,
separated by ":".
If the key of the first options is omitted, the arguments are
interpreted according to the syntax:
@var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
A description of the accepted options follows.
It accepts the following parameters:
@table @option
@item luma_msize_x, lx
@ -5647,13 +5640,16 @@ Default value is 1.0 for @option{luma_amount}, 0.0 for
@option{chroma_amount}.
@end table
All parameters are optional and default to the
equivalent of the string '5:5:1.0:5:5:0.0'.
@subsection Examples
@itemize
@item
Apply strong luma sharpen effect:
@example
unsharp=7:7:2.5
unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
@end example
@item

View File

@ -704,6 +704,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
!strcmp(filter->filter->name, "subtitles") ||
!strcmp(filter->filter->name, "thumbnail") ||
!strcmp(filter->filter->name, "transpose") ||
!strcmp(filter->filter->name, "unsharp" ) ||
// !strcmp(filter->filter->name, "scale" ) ||
!strcmp(filter->filter->name, "select") ||
0

View File

@ -66,36 +66,13 @@ typedef struct FilterParam {
typedef struct {
const AVClass *class;
int lmsize_x, lmsize_y, cmsize_x, cmsize_y;
float lamount, camount;
FilterParam luma; ///< luma parameters (width, height, amount)
FilterParam chroma; ///< chroma parameters (width, height, amount)
int hsub, vsub;
int luma_msize_x, luma_msize_y, chroma_msize_x, chroma_msize_y;
double luma_amount, chroma_amount;
} UnsharpContext;
#define OFFSET(x) offsetof(UnsharpContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
static const AVOption unsharp_options[] = {
{ "luma_msize_x", "set luma matrix x size", OFFSET(luma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
{ "lx", "set luma matrix x size", OFFSET(luma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
{ "luma_msize_y", "set luma matrix y size", OFFSET(luma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
{ "ly", "set luma matrix y size", OFFSET(luma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
{ "luma_amount", "set luma effect amount", OFFSET(luma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=1.0}, -DBL_MAX, DBL_MAX, .flags=FLAGS },
{ "la", "set luma effect amount", OFFSET(luma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=1.0}, -DBL_MAX, DBL_MAX, .flags=FLAGS },
{ "chroma_msize_x", "set chroma matrix x size", OFFSET(chroma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
{ "cx", "set chroma matrix x size", OFFSET(chroma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
{ "chroma_msize_y", "set chroma matrix y size", OFFSET(chroma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
{ "cy" , "set chroma matrix y size", OFFSET(chroma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
{ "chroma_amount", "set chroma effect strenght", OFFSET(chroma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -DBL_MAX, DBL_MAX, .flags=FLAGS },
{ "ca", "set chroma effect strenght", OFFSET(chroma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -DBL_MAX, DBL_MAX, .flags=FLAGS },
{ NULL }
};
AVFILTER_DEFINE_CLASS(unsharp);
static void apply_unsharp( uint8_t *dst, int dst_stride,
const uint8_t *src, int src_stride,
int width, int height, FilterParam *fp)
@ -154,7 +131,7 @@ static void apply_unsharp( uint8_t *dst, int dst_stride,
}
}
static void set_filter_param(FilterParam *fp, int msize_x, int msize_y, double amount)
static void set_filter_param(FilterParam *fp, int msize_x, int msize_y, float amount)
{
fp->msize_x = msize_x;
fp->msize_y = msize_y;
@ -170,8 +147,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
{
UnsharpContext *unsharp = ctx->priv;
set_filter_param(&unsharp->luma, unsharp->luma_msize_x, unsharp->luma_msize_y, unsharp->luma_amount);
set_filter_param(&unsharp->chroma, unsharp->chroma_msize_x, unsharp->chroma_msize_y, unsharp->chroma_amount);
set_filter_param(&unsharp->luma, unsharp->lmsize_x, unsharp->lmsize_y, unsharp->lamount);
set_filter_param(&unsharp->chroma, unsharp->cmsize_x, unsharp->cmsize_y, unsharp->camount);
return 0;
}
@ -269,6 +247,28 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
return ff_filter_frame(outlink, out);
}
#define OFFSET(x) offsetof(UnsharpContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
#define MIN_SIZE 3
#define MAX_SIZE 63
static const AVOption unsharp_options[] = {
{ "luma_msize_x", "luma matrix horizontal size", OFFSET(lmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "lx", "luma matrix horizontal size", OFFSET(lmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "luma_msize_y", "luma matrix vertical size", OFFSET(lmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "ly", "luma matrix vertical size", OFFSET(lmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "luma_amount", "luma effect strength", OFFSET(lamount), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, -2, 5, FLAGS },
{ "la", "luma effect strength", OFFSET(lamount), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, -2, 5, FLAGS },
{ "chroma_msize_x", "chroma matrix horizontal size", OFFSET(cmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "cx", "chroma matrix horizontal size", OFFSET(cmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "chroma_msize_y", "chroma matrix vertical size", OFFSET(cmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "cy", "chroma matrix vertical size", OFFSET(cmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
{ "chroma_amount", "chroma effect strength", OFFSET(camount), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -2, 5, FLAGS },
{ "ca", "chroma effect strength", OFFSET(camount), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -2, 5, FLAGS },
{ NULL },
};
AVFILTER_DEFINE_CLASS(unsharp);
static const AVFilterPad avfilter_vf_unsharp_inputs[] = {
{
.name = "default",
@ -287,17 +287,12 @@ static const AVFilterPad avfilter_vf_unsharp_outputs[] = {
{ NULL }
};
static const char *const shorthand[] = {
"luma_msize_x", "luma_msize_y", "luma_amount",
"chroma_msize_x", "chroma_msize_y", "chroma_amount",
NULL
};
AVFilter avfilter_vf_unsharp = {
.name = "unsharp",
.description = NULL_IF_CONFIG_SMALL("Sharpen or blur the input video."),
.priv_size = sizeof(UnsharpContext),
.priv_class = &unsharp_class,
.init = init,
.uninit = uninit,
@ -306,7 +301,4 @@ AVFilter avfilter_vf_unsharp = {
.inputs = avfilter_vf_unsharp_inputs,
.outputs = avfilter_vf_unsharp_outputs,
.priv_class = &unsharp_class,
.shorthand = shorthand,
};