From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] avfilter/adelay: Add command support Date: Wed, 19 Jan 2022 20:14:36 +0100 Message-ID: <AM7PR03MB66606B6E9D4D05211F8F2E6B8F599@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw) In-Reply-To: <20220119184332.289047-1-deiwo101@gmail.com> David Lacko: > Adds command 'delays' to the adelay filter. > This command accepts same values as option with one difference, to apply > delay to all channels prefix 'all:' to the arguments is accepted. > > Signed-off-by: David Lacko <deiwo101@gmail.com> > --- > libavfilter/af_adelay.c | 183 ++++++++++++++++++++++++++++++++++------ > 1 file changed, 157 insertions(+), 26 deletions(-) > > diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c > index ed8a8ae739..1e13cf7fb0 100644 > --- a/libavfilter/af_adelay.c > +++ b/libavfilter/af_adelay.c > @@ -31,6 +31,7 @@ typedef struct ChanDelay { > int64_t delay; > size_t delay_index; > size_t index; > + unsigned int samples_size; > uint8_t *samples; > } ChanDelay; > > @@ -48,13 +49,14 @@ typedef struct AudioDelayContext { > > void (*delay_channel)(ChanDelay *d, int nb_samples, > const uint8_t *src, uint8_t *dst); > + int (*resize_channel_samples)(ChanDelay *d, int64_t new_delay); > } AudioDelayContext; > > #define OFFSET(x) offsetof(AudioDelayContext, x) > #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM > > static const AVOption adelay_options[] = { > - { "delays", "set list of delays for each channel", OFFSET(delays), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, A }, > + { "delays", "set list of delays for each channel", OFFSET(delays), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, A | AV_OPT_FLAG_RUNTIME_PARAM }, > { "all", "use last available delay for remained channels", OFFSET(all), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, A }, > { NULL } > }; > @@ -96,11 +98,92 @@ DELAY(s32, int32_t, 0) > DELAY(flt, float, 0) > DELAY(dbl, double, 0) > > +#define CHANGE_DELAY(name, type, fill) \ > +static int resize_samples_## name ##p(ChanDelay *d, int64_t new_delay) \ > +{ \ > + type *samples = (type *)d->samples; \ > + \ > + if (new_delay == d->delay) { \ > + return 0; \ > + } \ > + \ > + if (new_delay == 0) { \ > + av_freep(&d->samples); \ > + d->samples_size = 0; \ > + d->delay = 0; \ > + d->index = 0; \ > + return 0; \ > + } \ > + \ > + d->samples = av_fast_realloc(d->samples, &d->samples_size, new_delay * sizeof(type)); \ > + if (!d->samples) { \ > + av_freep(samples); \ av_free(samples) or av_freep(&samples), but not av_freep(samples). The typical way to write this is btw tmp = av_fast_realloc(buf,...) (in your case samples = av_fast_realloc(d->samples, ...) with av_freep(&d->samples); in the error branch and d->samples = samples in the non-error-case. > + return AVERROR(ENOMEM); \ > + } \ _______________________________________________ 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".
next prev parent reply other threads:[~2022-01-19 19:14 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-19 18:43 David Lacko 2022-01-19 19:14 ` Andreas Rheinhardt [this message] 2022-01-20 9:53 ` David Lacko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AM7PR03MB66606B6E9D4D05211F8F2E6B8F599@AM7PR03MB6660.eurprd03.prod.outlook.com \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git