[FFmpeg-devel] [PATCH] avfilter/af_volume: add support for command

Stefano Sabatini stefasab at gmail.com
Fri Sep 27 09:24:33 CEST 2013


On date Tuesday 2013-09-24 19:27:49 +0200, Stefano Sabatini encoded:
> On date Tuesday 2013-09-24 15:50:09 +0000, Paul B Mahol encoded:
> > Signed-off-by: Paul B Mahol <onemda at gmail.com>
> > ---
> > 
> > I would prefer that there is much simpler way to do same.
> > 
> > ---
> > 
> >  libavfilter/af_volume.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> 
> Reminder: add missing docs, bump micro
> 
> > diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
> > index a777249..fc9afb7 100644
> > --- a/libavfilter/af_volume.c
> > +++ b/libavfilter/af_volume.c
> > @@ -269,6 +269,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
> >      return ff_filter_frame(outlink, out_buf);
> >  }
> >  
> > +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
> > +                           char *res, int res_len, int flags)
> > +{
> > +    VolumeContext *vol = ctx->priv;
> > +    int ret;
> > +
> > +    if (!strcmp(cmd, "volume")) {
> > +        scanf("%lf", &vol->volume);
> > +        init(ctx);
> > +        ret = 0;
> 
> I know that it sucks, but sscanf is not the equivalent of
> av_opt_set(). Ideally we should have an expression and use some common
> code for init and process.

Possible solution: call av_opt_get(), store the value, and call
av_opt_set(), and re-set the old value in case of error (since IIRC
av_opt_set() is destructive).

Adding this feature at the framework level (non-destructive flag in
av_opt_set) would be probably a good idea.
-- 
FFmpeg = Frightening Fierce Multimedia Problematic Enlightened God


More information about the ffmpeg-devel mailing list