[FFmpeg-devel] [PATCH 1/5] Change eval internal functions, ff_parse_expr() and ff_parse_and_eval_expr() interface.

Stefano Sabatini stefano.sabatini-lala
Tue May 18 20:38:23 CEST 2010


On date Tuesday 2010-05-18 17:27:37 +0200, Michael Niedermayer encoded:
> On Tue, May 18, 2010 at 12:56:53AM +0200, Stefano Sabatini wrote:
> [...]
> >  opt.c |    2 ++
> >  1 file changed, 2 insertions(+)
> > 11b07e9a34d65b8e88f47b5fd2d9af456258620b  0002-Silence-logging-when-evaluating-the-expression-for-b.patch
> > >From c18ac9ee11ca03ab36e5acf2b72ecfc537caaced Mon Sep 17 00:00:00 2001
> > From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> > Date: Tue, 18 May 2010 00:31:01 +0200
> > Subject: [PATCH 2/4] Silence logging when evaluating the expression for buf in
> >  av_set_string3().
> > 
> > ---
> >  libavcodec/opt.c |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/libavcodec/opt.c b/libavcodec/opt.c
> > index 5b56bc8..844c0ec 100644
> > --- a/libavcodec/opt.c
> > +++ b/libavcodec/opt.c
> > @@ -155,7 +155,9 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons
> >                  buf[i]= val[i];
> >              buf[i]=0;
> >  
> > +            av_set_int(obj, "log_level_offset", AV_LOG_DEBUG - AV_LOG_QUIET);
> >              d = ff_parse_and_eval_expr(buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, obj);
> > +            av_set_int(obj, "log_level_offset", 0);
> 
> not ok, obj is not owned by this code. Other code might via a seperate
> thread print via obj at the same time.

So please suggest what to do.

Currently I see this solutions, in order of my personal perference:

1) avoid to log the error in case it is a spurious error, this can be
done by trying to interpret the string using the special values "min",
"max", etc., if that fails then using ff_parse_and_eval_expr(), which
has also the advantage of showing potentially useful error messages
(and that also looks like the more correct behavior to implement).
2) use a log_on_error flag or a log_level_offset param
3) keep the current interface

In general setting the log_level_offset from the library seems not
possible, only an application can do that if it knows that the access
to the obj context is thread safe.

Regards.
-- 
FFmpeg = Funny Fiendish Mournful Programmable Excellent Generator



More information about the ffmpeg-devel mailing list