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
71407140
71417141 Convert input audio to a video output, representing the samples waves.
71427142
7143−The filter accepts the following named parameters:
7143+The filter accepts the following options:
7144+
71447145 @table @option
7146+@item size, s
7147+Specify the video size for the output. Default value is "600x240".
7148+
71457149 @item mode
71467150 Set display mode.
71477151
@@ -7166,8 +7170,6 @@ is not explicitly specified. · 18 unmodified lines
71667170 Set the (approximate) output frame rate. This is done by setting the
71677171 option @var{n}. Default value is "25".
71687172
7169−@item size, s
7170−Specify the video size for the output. Default value is "600x240".
71717173 @end table
71727174
71737175 @subsection Examples
libavfilter/avf_showwaves.c+6−22
@@ -54,35 +54,19 @@ typedef struct { · 53 unmodified lines
5454 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
5555
5656 static 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 },
5957 { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "600x240"}, 0, 0, FLAGS },
6058 { "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"},
6162 { "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− {"mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"},
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"},
63+ { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
64+ { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
6665 { NULL },
6766 };
6867
6968 AVFILTER_DEFINE_CLASS(showwaves);
7069
71−static 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−
8670 static av_cold void uninit(AVFilterContext *ctx)
8771 {
8872 ShowWavesContext *showwaves = ctx->priv;
@@ -133,6 +117,7 @@ static int config_output(AVFilterLink *outlink) · 44 unmodified lines
133117 if (!showwaves->n)
134118 showwaves->n = FFMAX(1, ((double)inlink->sample_rate / (showwaves->w * av_q2d(showwaves->rate))) + 0.5);
135119
120+ showwaves->buf_idx = 0;
136121 outlink->w = showwaves->w;
137122 outlink->h = showwaves->h;
138123 outlink->sample_aspect_ratio = (AVRational){1,1};
@@ -261,7 +246,6 @@ static const AVFilterPad showwaves_outputs[] = { · 122 unmodified lines
261246 AVFilter avfilter_avf_showwaves = {
262247 .name = "showwaves",
263248 .description = NULL_IF_CONFIG_SMALL("Convert input audio to a video output."),
264− .init = init,
265249 .uninit = uninit,
266250 .query_formats = query_formats,
267251 .priv_size = sizeof(ShowWavesContext),
libavfilter/avfilter.c+0−1
@@ -694,7 +694,6 @@ static const char *const filters_left_to_update[] = { · 693 unmodified lines
694694 "sendcmd",
695695 "setdar",
696696 "setsar",
697− "showwaves",
698697 "smptebars",
699698 };
700699

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