Message ID | 20200313134912.3702-1-marshallmax1991@gmail.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,v2,GSOC] Audio Tones Source Filter | expand |
Context | Check | Description |
---|---|---|
andriy/ffmpeg-patchwork | warning | Failed to apply patch |
Patch should not be difference from previous sent patch. But always difference to current ffmpeg master tree. So use git to rebase your work correctly. On 3/13/20, Marshall Murmu <marshallmax1991@gmail.com> wrote: > Renamed the filter from fluidsynth to atone > --- > Changelog | 2 +- > configure | 2 +- > doc/filters.texi | 5 +- > libavfilter/Makefile | 2 +- > libavfilter/allfilters.c | 2 +- > .../{asrc_fluidsynth.c => asrc_atone.c} | 47 +++++++++---------- > 6 files changed, 29 insertions(+), 31 deletions(-) > rename libavfilter/{asrc_fluidsynth.c => asrc_atone.c} (86%) > > diff --git a/Changelog b/Changelog > index 2a22599969..f9770f8857 100644 > --- a/Changelog > +++ b/Changelog > @@ -46,7 +46,7 @@ version <next>: > - High Voltage Software ADPCM decoder > - LEGO Racers ALP (.tun & .pcm) demuxer > - AMQP 0-9-1 protocol (RabbitMQ) > -- fluidsynth filter > +- atone filter > > > version 4.2: > diff --git a/configure b/configure > index b22a09fac1..23c0ea6df3 100755 > --- a/configure > +++ b/configure > @@ -3466,6 +3466,7 @@ asr_filter_deps="pocketsphinx" > ass_filter_deps="libass" > atempo_filter_deps="avcodec" > atempo_filter_select="rdft" > +atone_filter_deps="libfluidsynth" > avgblur_opencl_filter_deps="opencl" > avgblur_vulkan_filter_deps="vulkan libglslang" > azmq_filter_deps="libzmq" > @@ -3511,7 +3512,6 @@ find_rect_filter_deps="avcodec avformat gpl" > firequalizer_filter_deps="avcodec" > firequalizer_filter_select="rdft" > flite_filter_deps="libflite" > -fluidsynth_filter_deps="libfluidsynth" > framerate_filter_select="scene_sad" > freezedetect_filter_select="scene_sad" > frei0r_filter_deps="frei0r libdl" > diff --git a/doc/filters.texi b/doc/filters.texi > index cdf96d1ba1..92f132ec9a 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -6010,7 +6010,7 @@ ffplay -f lavfi flite=text='No more be grieved for > which that thou hast done.' > For more information about libflite, check: > @url{http://www.festvox.org/flite/} > > -@section fluidsynth > +@section atone > > Synthesize random notes using libfluidsynth library. > > @@ -6034,6 +6034,9 @@ Enter the location of the soundfont. Without loading > the soundfont fluidsynth wo > > @item chan > Set the MIDI channel. Default value is 0. > + > +@item seed > +Set the seed value for the PRNG > @end table > > @section anoisesrc > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 626d7c0f09..020c4553cb 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -147,8 +147,8 @@ OBJS-$(CONFIG_AEVALSRC_FILTER) += aeval.o > OBJS-$(CONFIG_AFIRSRC_FILTER) += asrc_afirsrc.o > OBJS-$(CONFIG_ANOISESRC_FILTER) += asrc_anoisesrc.o > OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o > +OBJS-$(CONFIG_ATONE_FILTER) += asrc_atone.o > OBJS-$(CONFIG_FLITE_FILTER) += asrc_flite.o > -OBJS-$(CONFIG_FLUIDSYNTH_FILTER) += asrc_fluidsynth.o > OBJS-$(CONFIG_HILBERT_FILTER) += asrc_hilbert.o > OBJS-$(CONFIG_SINC_FILTER) += asrc_sinc.o > OBJS-$(CONFIG_SINE_FILTER) += asrc_sine.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index a1e812093c..d167499cf1 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -141,8 +141,8 @@ extern AVFilter ff_asrc_aevalsrc; > extern AVFilter ff_asrc_afirsrc; > extern AVFilter ff_asrc_anoisesrc; > extern AVFilter ff_asrc_anullsrc; > +extern AVFilter ff_asrc_atone; > extern AVFilter ff_asrc_flite; > -extern AVFilter ff_asrc_fluidsynth; > extern AVFilter ff_asrc_hilbert; > extern AVFilter ff_asrc_sinc; > extern AVFilter ff_asrc_sine; > diff --git a/libavfilter/asrc_fluidsynth.c b/libavfilter/asrc_atone.c > similarity index 86% > rename from libavfilter/asrc_fluidsynth.c > rename to libavfilter/asrc_atone.c > index be98815c56..f3ebab906e 100644 > --- a/libavfilter/asrc_fluidsynth.c > +++ b/libavfilter/asrc_atone.c > @@ -26,7 +26,7 @@ > #include "formats.h" > #include "internal.h" > > -typedef struct FluidSynthContext { > +typedef struct AToneContext { > const AVClass *class; > fluid_settings_t *settings; > fluid_synth_t *synth; > @@ -37,13 +37,14 @@ typedef struct FluidSynthContext { > char *soundfont; > int64_t pts; > int64_t duration; > + int64_t seed; > AVLFG c; > -} FluidSynthContext; > +} AToneContext; > > -#define OFFSET(x) offsetof(FluidSynthContext, x) > +#define OFFSET(x) offsetof(AToneContext, x) > #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM > > -static const AVOption fluidsynth_options[] = { > +static const AVOption atone_options[] = { > {"sample_rate", "set sample rate", > OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, > INT_MAX, FLAGS}, > {"r", "set sample rate", > OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, > INT_MAX, FLAGS}, > {"nb_samples", "set number of samples per requested frame", > OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, > INT64_MAX, FLAGS}, > @@ -52,14 +53,15 @@ static const AVOption fluidsynth_options[] = { > {"d", "set duration", > OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=10000000}, 0, > INT64_MAX, FLAGS}, > {"soundfont", "location of soundfont", > OFFSET(soundfont), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, > CHAR_MAX, FLAGS}, > {"chan", "set MIDI channel", > OFFSET(chan), AV_OPT_TYPE_INT, {.str=0}, 0, 15, > FLAGS}, > + {"seed", "set random seed", > OFFSET(seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, > INT64_MAX, FLAGS}, > { NULL } > }; > > -AVFILTER_DEFINE_CLASS(fluidsynth); > +AVFILTER_DEFINE_CLASS(atone); > > static av_cold int init(AVFilterContext *ctx) > { > - FluidSynthContext *fluidsynth = ctx->priv; > + AToneContext *fluidsynth = ctx->priv; > fluidsynth->soundfont_id = -1; > /// Initialize the fluidsynth setting > fluidsynth->settings = new_fluid_settings(); > @@ -78,26 +80,21 @@ static av_cold int init(AVFilterContext *ctx) > if(fluidsynth->soundfont_id < 0) { > av_log(ctx, AV_LOG_ERROR, "Failed to load soundfont\n"); > } > - > return 0; > } > > static av_cold void uninit(AVFilterContext *ctx) > { > - FluidSynthContext *fluidsynth = ctx->priv; > - > + AToneContext *fluidsynth = ctx->priv; > delete_fluid_synth(fluidsynth->synth); > delete_fluid_settings(fluidsynth->settings); > - > } > > static int query_formats(AVFilterContext *ctx) > { > - FluidSynthContext *fluidsynth = ctx->priv; > - > + AToneContext *fluidsynth = ctx->priv; > AVFilterChannelLayouts *chanlayout = NULL; > int64_t chanlayouts = > av_get_default_channel_layout(2*fluid_synth_count_audio_channels(fluidsynth->synth)); > - > AVFilterFormats *formats = NULL; > AVFilterFormats *sample_rate = NULL; > int ret; > @@ -112,13 +109,14 @@ static int query_formats(AVFilterContext *ctx) > return 0; > } > > - > static int config_output(AVFilterLink *outlink) > { > AVFilterContext *ctx = outlink->src; > - FluidSynthContext *fluidsynth = ctx->priv; > + AToneContext *fluidsynth = ctx->priv; > > - av_lfg_init(&fluidsynth->c, av_get_random_seed()); > + if(fluidsynth->seed == -1) > + fluidsynth->seed = av_get_random_seed(); > + av_lfg_init(&fluidsynth->c, fluidsynth->seed); > > outlink->sample_rate = fluidsynth->sample_rate; > fluidsynth->duration = av_rescale(fluidsynth->duration, > fluidsynth->sample_rate, AV_TIME_BASE); > @@ -129,7 +127,7 @@ static int config_output(AVFilterLink *outlink) > static int request_frame(AVFilterLink *outlink) > { > AVFrame *frame; > - FluidSynthContext *fluidsynth = outlink->src->priv; > + AToneContext *fluidsynth = outlink->src->priv; > int nb_samples, key; > > if (fluidsynth->duration) { > @@ -143,18 +141,15 @@ static int request_frame(AVFilterLink *outlink) > return AVERROR(ENOMEM); > > key = av_lfg_get(&fluidsynth->c) % 128 ; > - > fluid_synth_noteon(fluidsynth->synth, fluidsynth->chan, key, 100); > fluid_synth_write_float(fluidsynth->synth, nb_samples, frame->data[0], > 0, 2, frame->data[0], 1, 2); > fluid_synth_noteoff(fluidsynth->synth, fluidsynth->chan, key); > - > frame->pts = fluidsynth->pts; > fluidsynth->pts += nb_samples; > - > return ff_filter_frame(outlink, frame); > } > > -static const AVFilterPad fluidsynth_outputs[] = { > +static const AVFilterPad atone_outputs[] = { > { > .name = "default", > .type = AVMEDIA_TYPE_AUDIO, > @@ -164,14 +159,14 @@ static const AVFilterPad fluidsynth_outputs[] = { > { NULL } > }; > > -AVFilter ff_asrc_fluidsynth = { > - .name = "fluidsynth", > +AVFilter ff_asrc_atone = { > + .name = "atone", > .description = NULL_IF_CONFIG_SMALL("Synthesize tones using > libfluidsynth."), > .query_formats = query_formats, > .init = init, > .uninit = uninit, > - .priv_size = sizeof(FluidSynthContext), > + .priv_size = sizeof(AToneContext), > .inputs = NULL, > - .outputs = fluidsynth_outputs, > - .priv_class = &fluidsynth_class, > + .outputs = atone_outputs, > + .priv_class = &atone_class, > }; > -- > 2.25.0 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff --git a/Changelog b/Changelog index 2a22599969..f9770f8857 100644 --- a/Changelog +++ b/Changelog @@ -46,7 +46,7 @@ version <next>: - High Voltage Software ADPCM decoder - LEGO Racers ALP (.tun & .pcm) demuxer - AMQP 0-9-1 protocol (RabbitMQ) -- fluidsynth filter +- atone filter version 4.2: diff --git a/configure b/configure index b22a09fac1..23c0ea6df3 100755 --- a/configure +++ b/configure @@ -3466,6 +3466,7 @@ asr_filter_deps="pocketsphinx" ass_filter_deps="libass" atempo_filter_deps="avcodec" atempo_filter_select="rdft" +atone_filter_deps="libfluidsynth" avgblur_opencl_filter_deps="opencl" avgblur_vulkan_filter_deps="vulkan libglslang" azmq_filter_deps="libzmq" @@ -3511,7 +3512,6 @@ find_rect_filter_deps="avcodec avformat gpl" firequalizer_filter_deps="avcodec" firequalizer_filter_select="rdft" flite_filter_deps="libflite" -fluidsynth_filter_deps="libfluidsynth" framerate_filter_select="scene_sad" freezedetect_filter_select="scene_sad" frei0r_filter_deps="frei0r libdl" diff --git a/doc/filters.texi b/doc/filters.texi index cdf96d1ba1..92f132ec9a 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6010,7 +6010,7 @@ ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.' For more information about libflite, check: @url{http://www.festvox.org/flite/} -@section fluidsynth +@section atone Synthesize random notes using libfluidsynth library. @@ -6034,6 +6034,9 @@ Enter the location of the soundfont. Without loading the soundfont fluidsynth wo @item chan Set the MIDI channel. Default value is 0. + +@item seed +Set the seed value for the PRNG @end table @section anoisesrc diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 626d7c0f09..020c4553cb 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -147,8 +147,8 @@ OBJS-$(CONFIG_AEVALSRC_FILTER) += aeval.o OBJS-$(CONFIG_AFIRSRC_FILTER) += asrc_afirsrc.o OBJS-$(CONFIG_ANOISESRC_FILTER) += asrc_anoisesrc.o OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o +OBJS-$(CONFIG_ATONE_FILTER) += asrc_atone.o OBJS-$(CONFIG_FLITE_FILTER) += asrc_flite.o -OBJS-$(CONFIG_FLUIDSYNTH_FILTER) += asrc_fluidsynth.o OBJS-$(CONFIG_HILBERT_FILTER) += asrc_hilbert.o OBJS-$(CONFIG_SINC_FILTER) += asrc_sinc.o OBJS-$(CONFIG_SINE_FILTER) += asrc_sine.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index a1e812093c..d167499cf1 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -141,8 +141,8 @@ extern AVFilter ff_asrc_aevalsrc; extern AVFilter ff_asrc_afirsrc; extern AVFilter ff_asrc_anoisesrc; extern AVFilter ff_asrc_anullsrc; +extern AVFilter ff_asrc_atone; extern AVFilter ff_asrc_flite; -extern AVFilter ff_asrc_fluidsynth; extern AVFilter ff_asrc_hilbert; extern AVFilter ff_asrc_sinc; extern AVFilter ff_asrc_sine; diff --git a/libavfilter/asrc_fluidsynth.c b/libavfilter/asrc_atone.c similarity index 86% rename from libavfilter/asrc_fluidsynth.c rename to libavfilter/asrc_atone.c index be98815c56..f3ebab906e 100644 --- a/libavfilter/asrc_fluidsynth.c +++ b/libavfilter/asrc_atone.c @@ -26,7 +26,7 @@ #include "formats.h" #include "internal.h" -typedef struct FluidSynthContext { +typedef struct AToneContext { const AVClass *class; fluid_settings_t *settings; fluid_synth_t *synth; @@ -37,13 +37,14 @@ typedef struct FluidSynthContext { char *soundfont; int64_t pts; int64_t duration; + int64_t seed; AVLFG c; -} FluidSynthContext; +} AToneContext; -#define OFFSET(x) offsetof(FluidSynthContext, x) +#define OFFSET(x) offsetof(AToneContext, x) #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM -static const AVOption fluidsynth_options[] = { +static const AVOption atone_options[] = { {"sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT_MAX, FLAGS}, {"r", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT_MAX, FLAGS}, {"nb_samples", "set number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT64_MAX, FLAGS}, @@ -52,14 +53,15 @@ static const AVOption fluidsynth_options[] = { {"d", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=10000000}, 0, INT64_MAX, FLAGS}, {"soundfont", "location of soundfont", OFFSET(soundfont), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS}, {"chan", "set MIDI channel", OFFSET(chan), AV_OPT_TYPE_INT, {.str=0}, 0, 15, FLAGS}, + {"seed", "set random seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, INT64_MAX, FLAGS}, { NULL } }; -AVFILTER_DEFINE_CLASS(fluidsynth); +AVFILTER_DEFINE_CLASS(atone); static av_cold int init(AVFilterContext *ctx) { - FluidSynthContext *fluidsynth = ctx->priv; + AToneContext *fluidsynth = ctx->priv; fluidsynth->soundfont_id = -1; /// Initialize the fluidsynth setting fluidsynth->settings = new_fluid_settings(); @@ -78,26 +80,21 @@ static av_cold int init(AVFilterContext *ctx) if(fluidsynth->soundfont_id < 0) { av_log(ctx, AV_LOG_ERROR, "Failed to load soundfont\n"); } - return 0; } static av_cold void uninit(AVFilterContext *ctx) { - FluidSynthContext *fluidsynth = ctx->priv; - + AToneContext *fluidsynth = ctx->priv; delete_fluid_synth(fluidsynth->synth); delete_fluid_settings(fluidsynth->settings); - } static int query_formats(AVFilterContext *ctx) { - FluidSynthContext *fluidsynth = ctx->priv; - + AToneContext *fluidsynth = ctx->priv; AVFilterChannelLayouts *chanlayout = NULL; int64_t chanlayouts = av_get_default_channel_layout(2*fluid_synth_count_audio_channels(fluidsynth->synth)); - AVFilterFormats *formats = NULL; AVFilterFormats *sample_rate = NULL; int ret; @@ -112,13 +109,14 @@ static int query_formats(AVFilterContext *ctx) return 0; } - static int config_output(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; - FluidSynthContext *fluidsynth = ctx->priv; + AToneContext *fluidsynth = ctx->priv; - av_lfg_init(&fluidsynth->c, av_get_random_seed()); + if(fluidsynth->seed == -1) + fluidsynth->seed = av_get_random_seed(); + av_lfg_init(&fluidsynth->c, fluidsynth->seed); outlink->sample_rate = fluidsynth->sample_rate; fluidsynth->duration = av_rescale(fluidsynth->duration, fluidsynth->sample_rate, AV_TIME_BASE); @@ -129,7 +127,7 @@ static int config_output(AVFilterLink *outlink) static int request_frame(AVFilterLink *outlink) { AVFrame *frame; - FluidSynthContext *fluidsynth = outlink->src->priv; + AToneContext *fluidsynth = outlink->src->priv; int nb_samples, key; if (fluidsynth->duration) { @@ -143,18 +141,15 @@ static int request_frame(AVFilterLink *outlink) return AVERROR(ENOMEM); key = av_lfg_get(&fluidsynth->c) % 128 ; - fluid_synth_noteon(fluidsynth->synth, fluidsynth->chan, key, 100); fluid_synth_write_float(fluidsynth->synth, nb_samples, frame->data[0], 0, 2, frame->data[0], 1, 2); fluid_synth_noteoff(fluidsynth->synth, fluidsynth->chan, key); - frame->pts = fluidsynth->pts; fluidsynth->pts += nb_samples; - return ff_filter_frame(outlink, frame); } -static const AVFilterPad fluidsynth_outputs[] = { +static const AVFilterPad atone_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_AUDIO, @@ -164,14 +159,14 @@ static const AVFilterPad fluidsynth_outputs[] = { { NULL } }; -AVFilter ff_asrc_fluidsynth = { - .name = "fluidsynth", +AVFilter ff_asrc_atone = { + .name = "atone", .description = NULL_IF_CONFIG_SMALL("Synthesize tones using libfluidsynth."), .query_formats = query_formats, .init = init, .uninit = uninit, - .priv_size = sizeof(FluidSynthContext), + .priv_size = sizeof(AToneContext), .inputs = NULL, - .outputs = fluidsynth_outputs, - .priv_class = &fluidsynth_class, + .outputs = atone_outputs, + .priv_class = &atone_class, };