History

lavfi/showwaves: switch to an AVOptions-based system.

Clément Bœsch committed 13 years ago

Commit 3c2e4c21 parent 38788f23 files · +11 −26Browse files

Unified · Split

3 files
  1. doc/filters.texi +5 −3
  2. libavfilter/avf_showwaves.c +6 −22
  3. libavfilter/avfilter.c +0 −1
doc/filters.texi+5−3
@@ -7140,8 +7140,12 @@ ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1]; · 7139 unmodified lines
7140 7140
7141Convert input audio to a video output, representing the samples waves.7141Convert input audio to a video output, representing the samples waves.
7142 7142
7143The filter accepts the following named parameters:7143The filter accepts the following options:
7144
7144@table @option7145@table @option
7146@item size, s
7147Specify the video size for the output. Default value is "600x240".
7148
7145@item mode7149@item mode
7146Set display mode.7150Set display mode.
7147 7151
@@ -7166,8 +7170,6 @@ is not explicitly specified. · 18 unmodified lines
7166Set the (approximate) output frame rate. This is done by setting the7170Set the (approximate) output frame rate. This is done by setting the
7167option @var{n}. Default value is "25".7171option @var{n}. Default value is "25".
7168 7172
7169@item size, s
7170Specify the video size for the output. Default value is "600x240".
7171@end table7173@end table
7172 7174
7173@subsection Examples7175@subsection Examples
libavfilter/avf_showwaves.c+6−22
@@ -54,35 +54,19 @@ typedef struct { · 53 unmodified lines
54#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM54#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
55 55
56static const AVOption showwaves_options[] = {56static const AVOption showwaves_options[] = {
57 { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
58 { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
59 { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "600x240"}, 0, 0, FLAGS },57 { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "600x240"}, 0, 0, FLAGS },
60 { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "600x240"}, 0, 0, FLAGS },58 { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "600x240"}, 0, 0, FLAGS },
59 { "mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"},
60 { "point", "draw a point for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_POINT}, .flags=FLAGS, .unit="mode"},
61 { "line", "draw a line for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_LINE}, .flags=FLAGS, .unit="mode"},
61 { "n", "set how many samples to show in the same point", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },62 { "n", "set how many samples to show in the same point", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
62 63 { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
63 {"mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"},64 { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
64 {"point", "draw a point for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_POINT}, .flags=FLAGS, .unit="mode"},
65 {"line", "draw a line for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_LINE}, .flags=FLAGS, .unit="mode"},
66 { NULL },65 { NULL },
67};66};
68 67
69AVFILTER_DEFINE_CLASS(showwaves);68AVFILTER_DEFINE_CLASS(showwaves);
70 69
71static av_cold int init(AVFilterContext *ctx, const char *args)
72{
73 ShowWavesContext *showwaves = ctx->priv;
74 int err;
75
76 showwaves->class = &showwaves_class;
77 av_opt_set_defaults(showwaves);
78 showwaves->buf_idx = 0;
79
80 if ((err = av_set_options_string(showwaves, args, "=", ":")) < 0)
81 return err;
82
83 return 0;
84}
85
86static av_cold void uninit(AVFilterContext *ctx)70static av_cold void uninit(AVFilterContext *ctx)
87{71{
88 ShowWavesContext *showwaves = ctx->priv;72 ShowWavesContext *showwaves = ctx->priv;
@@ -133,6 +117,7 @@ static int config_output(AVFilterLink *outlink) · 44 unmodified lines
133 if (!showwaves->n)117 if (!showwaves->n)
134 showwaves->n = FFMAX(1, ((double)inlink->sample_rate / (showwaves->w * av_q2d(showwaves->rate))) + 0.5);118 showwaves->n = FFMAX(1, ((double)inlink->sample_rate / (showwaves->w * av_q2d(showwaves->rate))) + 0.5);
135 119
120 showwaves->buf_idx = 0;
136 outlink->w = showwaves->w;121 outlink->w = showwaves->w;
137 outlink->h = showwaves->h;122 outlink->h = showwaves->h;
138 outlink->sample_aspect_ratio = (AVRational){1,1};123 outlink->sample_aspect_ratio = (AVRational){1,1};
@@ -261,7 +246,6 @@ static const AVFilterPad showwaves_outputs[] = { · 122 unmodified lines
261AVFilter avfilter_avf_showwaves = {246AVFilter avfilter_avf_showwaves = {
262 .name = "showwaves",247 .name = "showwaves",
263 .description = NULL_IF_CONFIG_SMALL("Convert input audio to a video output."),248 .description = NULL_IF_CONFIG_SMALL("Convert input audio to a video output."),
264 .init = init,
265 .uninit = uninit,249 .uninit = uninit,
266 .query_formats = query_formats,250 .query_formats = query_formats,
267 .priv_size = sizeof(ShowWavesContext),251 .priv_size = sizeof(ShowWavesContext),
libavfilter/avfilter.c+0−1
@@ -694,7 +694,6 @@ static const char *const filters_left_to_update[] = { · 693 unmodified lines
694 "sendcmd",694 "sendcmd",
695 "setdar",695 "setdar",
696 "setsar",696 "setsar",
697 "showwaves",
698 "smptebars",697 "smptebars",
699};698};
700 699

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