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
5615 5615
5616Sharpen or blur the input video.5616Sharpen or blur the input video.
5617 5617
5618This filter accepts parameters as a list of @var{key}=@var{value} pairs,5618It accepts the following parameters:
5619separated by ":".
5620
5621If the key of the first options is omitted, the arguments are
5622interpreted 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
5625A description of the accepted options follows.
5626 5619
5627@table @option5620@table @option
5628@item luma_msize_x, lx5621@item luma_msize_x, lx
@@ -5647,13 +5640,16 @@ Default value is 1.0 for @option{luma_amount}, 0.0 for · 18 unmodified lines
5647@option{chroma_amount}.5640@option{chroma_amount}.
5648@end table5641@end table
5649 5642
5643All parameters are optional and default to the
5644equivalent of the string '5:5:1.0:5:5:0.0'.
5645
5650@subsection Examples5646@subsection Examples
5651 5647
5652@itemize5648@itemize
5653@item5649@item
5654Apply strong luma sharpen effect:5650Apply strong luma sharpen effect:
5655@example5651@example
5656unsharp=7:7:2.55652unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
5657@end example5653@end example
5658 5654
5659@item5655@item
libavfilter/avfilter.c+1−0
@@ -704,6 +704,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 703 unmodified lines
704 !strcmp(filter->filter->name, "subtitles") ||704 !strcmp(filter->filter->name, "subtitles") ||
705 !strcmp(filter->filter->name, "thumbnail") ||705 !strcmp(filter->filter->name, "thumbnail") ||
706 !strcmp(filter->filter->name, "transpose") ||706 !strcmp(filter->filter->name, "transpose") ||
707 !strcmp(filter->filter->name, "unsharp" ) ||
707// !strcmp(filter->filter->name, "scale" ) ||708// !strcmp(filter->filter->name, "scale" ) ||
708 !strcmp(filter->filter->name, "select") ||709 !strcmp(filter->filter->name, "select") ||
709 0710 0
libavfilter/vf_unsharp.c+29−37
@@ -66,36 +66,13 @@ typedef struct FilterParam { · 65 unmodified lines
66 66
67typedef struct {67typedef struct {
68 const AVClass *class;68 const AVClass *class;
69 int lmsize_x, lmsize_y, cmsize_x, cmsize_y;
70 float lamount, camount;
69 FilterParam luma; ///< luma parameters (width, height, amount)71 FilterParam luma; ///< luma parameters (width, height, amount)
70 FilterParam chroma; ///< chroma parameters (width, height, amount)72 FilterParam chroma; ///< chroma parameters (width, height, amount)
71 int hsub, vsub;73 int hsub, vsub;
72 int luma_msize_x, luma_msize_y, chroma_msize_x, chroma_msize_y;
73 double luma_amount, chroma_amount;
74} UnsharpContext;74} UnsharpContext;
75 75
76#define OFFSET(x) offsetof(UnsharpContext, x)
77#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
78
79static 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
97AVFILTER_DEFINE_CLASS(unsharp);
98
99static void apply_unsharp( uint8_t *dst, int dst_stride,76static void apply_unsharp( uint8_t *dst, int dst_stride,
100 const uint8_t *src, int src_stride,77 const uint8_t *src, int src_stride,
101 int width, int height, FilterParam *fp)78 int width, int height, FilterParam *fp)
@@ -154,7 +131,7 @@ static void apply_unsharp( uint8_t *dst, int dst_stride, · 52 unmodified lines
154 }131 }
155}132}
156 133
157static void set_filter_param(FilterParam *fp, int msize_x, int msize_y, double amount)134static void set_filter_param(FilterParam *fp, int msize_x, int msize_y, float amount)
158{135{
159 fp->msize_x = msize_x;136 fp->msize_x = msize_x;
160 fp->msize_y = msize_y;137 fp->msize_y = msize_y;
@@ -170,8 +147,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 9 unmodified lines
170{147{
171 UnsharpContext *unsharp = ctx->priv;148 UnsharpContext *unsharp = ctx->priv;
172 149
173 set_filter_param(&unsharp->luma, unsharp->luma_msize_x, unsharp->luma_msize_y, unsharp->luma_amount);150
174 set_filter_param(&unsharp->chroma, unsharp->chroma_msize_x, unsharp->chroma_msize_y, unsharp->chroma_amount);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);
175 153
176 return 0;154 return 0;
177}155}
@@ -269,6 +247,28 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) · 91 unmodified lines
269 return ff_filter_frame(outlink, out);247 return ff_filter_frame(outlink, out);
270}248}
271 249
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
254static 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
270AVFILTER_DEFINE_CLASS(unsharp);
271
272static const AVFilterPad avfilter_vf_unsharp_inputs[] = {272static const AVFilterPad avfilter_vf_unsharp_inputs[] = {
273 {273 {
274 .name = "default",274 .name = "default",
@@ -287,17 +287,12 @@ static const AVFilterPad avfilter_vf_unsharp_outputs[] = { · 12 unmodified lines
287 { NULL }287 { NULL }
288};288};
289 289
290static 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
296AVFilter avfilter_vf_unsharp = {290AVFilter avfilter_vf_unsharp = {
297 .name = "unsharp",291 .name = "unsharp",
298 .description = NULL_IF_CONFIG_SMALL("Sharpen or blur the input video."),292 .description = NULL_IF_CONFIG_SMALL("Sharpen or blur the input video."),
299 293
300 .priv_size = sizeof(UnsharpContext),294 .priv_size = sizeof(UnsharpContext),
295 .priv_class = &unsharp_class,
301 296
302 .init = init,297 .init = init,
303 .uninit = uninit,298 .uninit = uninit,
@@ -306,7 +301,4 @@ AVFilter avfilter_vf_unsharp = { · 2 unmodified lines
306 .inputs = avfilter_vf_unsharp_inputs,301 .inputs = avfilter_vf_unsharp_inputs,
307 302
308 .outputs = avfilter_vf_unsharp_outputs,303 .outputs = avfilter_vf_unsharp_outputs,
309
310 .priv_class = &unsharp_class,
311 .shorthand = shorthand,
312};304};

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