Browse Source

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

tags/n2.0
Clément Bœsch 13 years ago
parent
commit
3c2e4c2a9b
3 changed files with 11 additions and 26 deletions
  1. +5
    -3
      doc/filters.texi
  2. +6
    -22
      libavfilter/avf_showwaves.c
  3. +0
    -1
      libavfilter/avfilter.c

+ 5
- 3
doc/filters.texi View File

@@ -7140,8 +7140,12 @@ ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];

Convert input audio to a video output, representing the samples waves.

The filter accepts the following named parameters:
The filter accepts the following options:

@table @option
@item size, s
Specify the video size for the output. Default value is "600x240".

@item mode
Set display mode.

@@ -7166,8 +7170,6 @@ is not explicitly specified.
Set the (approximate) output frame rate. This is done by setting the
option @var{n}. Default value is "25".

@item size, s
Specify the video size for the output. Default value is "600x240".
@end table

@subsection Examples


+ 6
- 22
libavfilter/avf_showwaves.c View File

@@ -54,35 +54,19 @@ typedef struct {
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM

static const AVOption showwaves_options[] = {
{ "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
{ "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
{ "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "600x240"}, 0, 0, FLAGS },
{ "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "600x240"}, 0, 0, FLAGS },
{ "mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"},
{ "point", "draw a point for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_POINT}, .flags=FLAGS, .unit="mode"},
{ "line", "draw a line for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_LINE}, .flags=FLAGS, .unit="mode"},
{ "n", "set how many samples to show in the same point", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },

{"mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"},
{"point", "draw a point for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_POINT}, .flags=FLAGS, .unit="mode"},
{"line", "draw a line for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_LINE}, .flags=FLAGS, .unit="mode"},
{ "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
{ "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
{ NULL },
};

AVFILTER_DEFINE_CLASS(showwaves);

static av_cold int init(AVFilterContext *ctx, const char *args)
{
ShowWavesContext *showwaves = ctx->priv;
int err;

showwaves->class = &showwaves_class;
av_opt_set_defaults(showwaves);
showwaves->buf_idx = 0;

if ((err = av_set_options_string(showwaves, args, "=", ":")) < 0)
return err;

return 0;
}

static av_cold void uninit(AVFilterContext *ctx)
{
ShowWavesContext *showwaves = ctx->priv;
@@ -133,6 +117,7 @@ static int config_output(AVFilterLink *outlink)
if (!showwaves->n)
showwaves->n = FFMAX(1, ((double)inlink->sample_rate / (showwaves->w * av_q2d(showwaves->rate))) + 0.5);

showwaves->buf_idx = 0;
outlink->w = showwaves->w;
outlink->h = showwaves->h;
outlink->sample_aspect_ratio = (AVRational){1,1};
@@ -261,7 +246,6 @@ static const AVFilterPad showwaves_outputs[] = {
AVFilter avfilter_avf_showwaves = {
.name = "showwaves",
.description = NULL_IF_CONFIG_SMALL("Convert input audio to a video output."),
.init = init,
.uninit = uninit,
.query_formats = query_formats,
.priv_size = sizeof(ShowWavesContext),


+ 0
- 1
libavfilter/avfilter.c View File

@@ -694,7 +694,6 @@ static const char *const filters_left_to_update[] = {
"sendcmd",
"setdar",
"setsar",
"showwaves",
"smptebars",
};



Loading…
Cancel
Save