mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
lavfi/showwaves: switch to an AVOptions-based system.
This commit is contained in:
parent
38788f2de5
commit
3c2e4c2a9b
@ -7140,8 +7140,12 @@ ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
|
|||||||
|
|
||||||
Convert input audio to a video output, representing the samples waves.
|
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
|
@table @option
|
||||||
|
@item size, s
|
||||||
|
Specify the video size for the output. Default value is "600x240".
|
||||||
|
|
||||||
@item mode
|
@item mode
|
||||||
Set display mode.
|
Set display mode.
|
||||||
|
|
||||||
@ -7166,8 +7170,6 @@ is not explicitly specified.
|
|||||||
Set the (approximate) output frame rate. This is done by setting the
|
Set the (approximate) output frame rate. This is done by setting the
|
||||||
option @var{n}. Default value is "25".
|
option @var{n}. Default value is "25".
|
||||||
|
|
||||||
@item size, s
|
|
||||||
Specify the video size for the output. Default value is "600x240".
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@subsection Examples
|
@subsection Examples
|
||||||
|
@ -54,35 +54,19 @@ typedef struct {
|
|||||||
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
|
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
|
||||||
|
|
||||||
static const AVOption showwaves_options[] = {
|
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 },
|
{ "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 },
|
{ "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 },
|
{ "n", "set how many samples to show in the same point", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
|
||||||
|
{ "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
|
||||||
{"mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_POINT}, 0, MODE_NB-1, FLAGS, "mode"},
|
{ "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
|
||||||
{"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"},
|
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
AVFILTER_DEFINE_CLASS(showwaves);
|
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)
|
static av_cold void uninit(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
ShowWavesContext *showwaves = ctx->priv;
|
ShowWavesContext *showwaves = ctx->priv;
|
||||||
@ -133,6 +117,7 @@ static int config_output(AVFilterLink *outlink)
|
|||||||
if (!showwaves->n)
|
if (!showwaves->n)
|
||||||
showwaves->n = FFMAX(1, ((double)inlink->sample_rate / (showwaves->w * av_q2d(showwaves->rate))) + 0.5);
|
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->w = showwaves->w;
|
||||||
outlink->h = showwaves->h;
|
outlink->h = showwaves->h;
|
||||||
outlink->sample_aspect_ratio = (AVRational){1,1};
|
outlink->sample_aspect_ratio = (AVRational){1,1};
|
||||||
@ -261,7 +246,6 @@ static const AVFilterPad showwaves_outputs[] = {
|
|||||||
AVFilter avfilter_avf_showwaves = {
|
AVFilter avfilter_avf_showwaves = {
|
||||||
.name = "showwaves",
|
.name = "showwaves",
|
||||||
.description = NULL_IF_CONFIG_SMALL("Convert input audio to a video output."),
|
.description = NULL_IF_CONFIG_SMALL("Convert input audio to a video output."),
|
||||||
.init = init,
|
|
||||||
.uninit = uninit,
|
.uninit = uninit,
|
||||||
.query_formats = query_formats,
|
.query_formats = query_formats,
|
||||||
.priv_size = sizeof(ShowWavesContext),
|
.priv_size = sizeof(ShowWavesContext),
|
||||||
|
@ -694,7 +694,6 @@ static const char *const filters_left_to_update[] = {
|
|||||||
"sendcmd",
|
"sendcmd",
|
||||||
"setdar",
|
"setdar",
|
||||||
"setsar",
|
"setsar",
|
||||||
"showwaves",
|
|
||||||
"smptebars",
|
"smptebars",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user