History

Merge commit 'b83e9efc53e5491716625aa31c69006b1119b280'

* commit 'b83e9efc53e5491716625aa31c69006b1119b280': vf_unsharp: switch to an AVOptions-based system. Conflicts: doc/filters.texi libavfilter/vf_unsharp.c

Michael Niedermayer committed 13 years ago

Commit c2696da2 parents b4ffc35 b83e9ef3 files · +35 −46Browse files

Unified · Split

3 files
  1. doc/filters.texi +5 −9
  2. libavfilter/avfilter.c +1 −0
  3. libavfilter/vf_unsharp.c +29 −37
doc/filters.texi+5−9
@@ -5615,14 +5615,7 @@ transpose=1:portrait · 5614 unmodified lines
56155615
56165616 Sharpen or blur the input video.
56175617
5618−This filter accepts parameters as a list of @var{key}=@var{value} pairs,
5619−separated by ":".
5620−
5621−If the key of the first options is omitted, the arguments are
5622−interpreted according to the syntax:
5623−@var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
5624−
5625−A description of the accepted options follows.
5618+It accepts the following parameters:
56265619
56275620 @table @option
56285621 @item luma_msize_x, lx
@@ -5647,13 +5640,16 @@ Default value is 1.0 for @option{luma_amount}, 0.0 for · 18 unmodified lines
56475640 @option{chroma_amount}.
56485641 @end table
56495642
5643+All parameters are optional and default to the
5644+equivalent of the string '5:5:1.0:5:5:0.0'.
5645+
56505646 @subsection Examples
56515647
56525648 @itemize
56535649 @item
56545650 Apply strong luma sharpen effect:
56555651 @example
5656−unsharp=7:7:2.5
5652+unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
56575653 @end example
56585654
56595655 @item
libavfilter/avfilter.c+1−0
@@ -704,6 +704,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 703 unmodified lines
704704 !strcmp(filter->filter->name, "subtitles") ||
705705 !strcmp(filter->filter->name, "thumbnail") ||
706706 !strcmp(filter->filter->name, "transpose") ||
707+ !strcmp(filter->filter->name, "unsharp" ) ||
707708 // !strcmp(filter->filter->name, "scale" ) ||
708709 !strcmp(filter->filter->name, "select") ||
709710 0
libavfilter/vf_unsharp.c+29−37
@@ -66,36 +66,13 @@ typedef struct FilterParam { · 65 unmodified lines
6666
6767 typedef struct {
6868 const AVClass *class;
69+ int lmsize_x, lmsize_y, cmsize_x, cmsize_y;
70+ float lamount, camount;
6971 FilterParam luma; ///< luma parameters (width, height, amount)
7072 FilterParam chroma; ///< chroma parameters (width, height, amount)
7173 int hsub, vsub;
72− int luma_msize_x, luma_msize_y, chroma_msize_x, chroma_msize_y;
73− double luma_amount, chroma_amount;
7474 } UnsharpContext;
7575
76−#define OFFSET(x) offsetof(UnsharpContext, x)
77−#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
78−
79−static const AVOption unsharp_options[] = {
80− { "luma_msize_x", "set luma matrix x size", OFFSET(luma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
81− { "lx", "set luma matrix x size", OFFSET(luma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
82− { "luma_msize_y", "set luma matrix y size", OFFSET(luma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
83− { "ly", "set luma matrix y size", OFFSET(luma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
84− { "luma_amount", "set luma effect amount", OFFSET(luma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=1.0}, -DBL_MAX, DBL_MAX, .flags=FLAGS },
85− { "la", "set luma effect amount", OFFSET(luma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=1.0}, -DBL_MAX, DBL_MAX, .flags=FLAGS },
86−
87− { "chroma_msize_x", "set chroma matrix x size", OFFSET(chroma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
88− { "cx", "set chroma matrix x size", OFFSET(chroma_msize_x), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
89− { "chroma_msize_y", "set chroma matrix y size", OFFSET(chroma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
90− { "cy" , "set chroma matrix y size", OFFSET(chroma_msize_y), AV_OPT_TYPE_INT, {.i64=5}, 3, 63, .flags=FLAGS },
91− { "chroma_amount", "set chroma effect strenght", OFFSET(chroma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -DBL_MAX, DBL_MAX, .flags=FLAGS },
92− { "ca", "set chroma effect strenght", OFFSET(chroma_amount), AV_OPT_TYPE_DOUBLE, {.dbl=0.0}, -DBL_MAX, DBL_MAX, .flags=FLAGS },
93−
94− { NULL }
95−};
96−
97−AVFILTER_DEFINE_CLASS(unsharp);
98−
9976 static void apply_unsharp( uint8_t *dst, int dst_stride,
10077 const uint8_t *src, int src_stride,
10178 int width, int height, FilterParam *fp)
@@ -154,7 +131,7 @@ static void apply_unsharp( uint8_t *dst, int dst_stride, · 52 unmodified lines
154131 }
155132 }
156133
157−static void set_filter_param(FilterParam *fp, int msize_x, int msize_y, double amount)
134+static void set_filter_param(FilterParam *fp, int msize_x, int msize_y, float amount)
158135 {
159136 fp->msize_x = msize_x;
160137 fp->msize_y = msize_y;
@@ -170,8 +147,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 9 unmodified lines
170147 {
171148 UnsharpContext *unsharp = ctx->priv;
172149
173− set_filter_param(&unsharp->luma, unsharp->luma_msize_x, unsharp->luma_msize_y, unsharp->luma_amount);
174− set_filter_param(&unsharp->chroma, unsharp->chroma_msize_x, unsharp->chroma_msize_y, unsharp->chroma_amount);
150+
151+ set_filter_param(&unsharp->luma, unsharp->lmsize_x, unsharp->lmsize_y, unsharp->lamount);
152+ set_filter_param(&unsharp->chroma, unsharp->cmsize_x, unsharp->cmsize_y, unsharp->camount);
175153
176154 return 0;
177155 }
@@ -269,6 +247,28 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) · 91 unmodified lines
269247 return ff_filter_frame(outlink, out);
270248 }
271249
250+#define OFFSET(x) offsetof(UnsharpContext, x)
251+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
252+#define MIN_SIZE 3
253+#define MAX_SIZE 63
254+static const AVOption unsharp_options[] = {
255+ { "luma_msize_x", "luma matrix horizontal size", OFFSET(lmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
256+ { "lx", "luma matrix horizontal size", OFFSET(lmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
257+ { "luma_msize_y", "luma matrix vertical size", OFFSET(lmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
258+ { "ly", "luma matrix vertical size", OFFSET(lmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
259+ { "luma_amount", "luma effect strength", OFFSET(lamount), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, -2, 5, FLAGS },
260+ { "la", "luma effect strength", OFFSET(lamount), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, -2, 5, FLAGS },
261+ { "chroma_msize_x", "chroma matrix horizontal size", OFFSET(cmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
262+ { "cx", "chroma matrix horizontal size", OFFSET(cmsize_x), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
263+ { "chroma_msize_y", "chroma matrix vertical size", OFFSET(cmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
264+ { "cy", "chroma matrix vertical size", OFFSET(cmsize_y), AV_OPT_TYPE_INT, { .i64 = 5 }, MIN_SIZE, MAX_SIZE, FLAGS },
265+ { "chroma_amount", "chroma effect strength", OFFSET(camount), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -2, 5, FLAGS },
266+ { "ca", "chroma effect strength", OFFSET(camount), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -2, 5, FLAGS },
267+ { NULL },
268+};
269+
270+AVFILTER_DEFINE_CLASS(unsharp);
271+
272272 static const AVFilterPad avfilter_vf_unsharp_inputs[] = {
273273 {
274274 .name = "default",
@@ -287,17 +287,12 @@ static const AVFilterPad avfilter_vf_unsharp_outputs[] = { · 12 unmodified lines
287287 { NULL }
288288 };
289289
290−static const char *const shorthand[] = {
291− "luma_msize_x", "luma_msize_y", "luma_amount",
292− "chroma_msize_x", "chroma_msize_y", "chroma_amount",
293− NULL
294−};
295−
296290 AVFilter avfilter_vf_unsharp = {
297291 .name = "unsharp",
298292 .description = NULL_IF_CONFIG_SMALL("Sharpen or blur the input video."),
299293
300294 .priv_size = sizeof(UnsharpContext),
295+ .priv_class = &unsharp_class,
301296
302297 .init = init,
303298 .uninit = uninit,
@@ -306,7 +301,4 @@ AVFilter avfilter_vf_unsharp = { · 2 unmodified lines
306301 .inputs = avfilter_vf_unsharp_inputs,
307302
308303 .outputs = avfilter_vf_unsharp_outputs,
309−
310− .priv_class = &unsharp_class,
311− .shorthand = shorthand,
312304 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t