Commit 07b7c2a2 authored by Clément Bœsch's avatar Clément Bœsch

lavfi/sine: use standard options parsing.

parent 3ac77f67
...@@ -123,14 +123,7 @@ static void make_sin_table(int16_t *sin) ...@@ -123,14 +123,7 @@ static void make_sin_table(int16_t *sin)
static av_cold int init(AVFilterContext *ctx, const char *args) static av_cold int init(AVFilterContext *ctx, const char *args)
{ {
SineContext *sine = ctx->priv; SineContext *sine = ctx->priv;
static const char *shorthand[] = { "frequency", "beep_factor", NULL };
int ret;
sine->class = &sine_class;
av_opt_set_defaults(sine);
if ((ret = av_opt_set_from_string(sine, args, shorthand, "=", ":")) < 0)
return ret;
if (!(sine->sin = av_malloc(sizeof(*sine->sin) << LOG_PERIOD))) if (!(sine->sin = av_malloc(sizeof(*sine->sin) << LOG_PERIOD)))
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
sine->dphi = ldexp(sine->frequency, 32) / sine->sample_rate + 0.5; sine->dphi = ldexp(sine->frequency, 32) / sine->sample_rate + 0.5;
...@@ -217,6 +210,8 @@ static const AVFilterPad sine_outputs[] = { ...@@ -217,6 +210,8 @@ static const AVFilterPad sine_outputs[] = {
{ NULL } { NULL }
}; };
static const char *const shorthand[] = { "frequency", "beep_factor", NULL };
AVFilter avfilter_asrc_sine = { AVFilter avfilter_asrc_sine = {
.name = "sine", .name = "sine",
.description = NULL_IF_CONFIG_SMALL("Generate sine wave audio signal."), .description = NULL_IF_CONFIG_SMALL("Generate sine wave audio signal."),
...@@ -227,4 +222,5 @@ AVFilter avfilter_asrc_sine = { ...@@ -227,4 +222,5 @@ AVFilter avfilter_asrc_sine = {
.inputs = NULL, .inputs = NULL,
.outputs = sine_outputs, .outputs = sine_outputs,
.priv_class = &sine_class, .priv_class = &sine_class,
.shorthand = shorthand,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment