[Ffmpeg-devel] [PATCH] Use ff_eval for AVOption parsing

Michael Niedermayer michaelni
Wed Sep 27 15:03:41 CEST 2006


Hi

On Wed, Sep 27, 2006 at 01:27:57PM +0200, Panagiotis Issaris wrote:
> Hi,
> 
> Op woensdag 27 september 2006 00:26, schreef Michael Niedermayer:
> > > [...]
> > > Should I have put this (in mpegvideo.h):
> > >  994 double ff_eval(char *s, double *const_value, const char **const_name,
> > >  995                double (**func1)(void *, double), const char **func1_name,
> > >  996                double (**func2)(void *, double, double), char **func2_name,
> > >  997                void *opaque);
> > > 
> > > Within this too?
> > > #if LIBAVCODEC_VERSION_INT < ((51<<16)+(16<<8)+0)
> > > ...
> > > #endif
> > 
> > yes probably
> The attached patch makes ratecontrol use ff_eval2().
> Regression tests succeed.
[...]

> diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
> index 5c339fa..9243ea5 100644
> --- a/libavcodec/ratecontrol.c
> +++ b/libavcodec/ratecontrol.c
> @@ -259,6 +259,7 @@ static double get_qscale(MpegEncContext 
>      const int pict_type= rce->new_pict_type;
>      const double mb_num= s->mb_num;
>      int i;
> +    char *error = NULL;
>  
>      double const_values[]={
>          M_PI,
> @@ -325,9 +326,12 @@ static double get_qscale(MpegEncContext 
>          NULL
>      };
>  
> -    bits= ff_eval(s->avctx->rc_eq, const_values, const_names, func1, func1_names, NULL, NULL, rce);
> +    bits= ff_eval2(s->avctx->rc_eq, const_values, const_names, func1, func1_names, NULL, NULL, rce, &error);
>      if (isnan(bits)) {
> -        av_log(s->avctx, AV_LOG_ERROR, "Unable to parse rc_eq \"%s\".\n", s->avctx->rc_eq);
> +        if (error)
> +            av_log(s->avctx, AV_LOG_ERROR, "Error evaluating rc_eq \"%s\": %s\n", s->avctx->rc_eq, error);
> +        else
> +            av_log(s->avctx, AV_LOG_ERROR, "Error evaluating rc_eq \"%s\"\n", s->avctx->rc_eq);

id suggest

av_log(s->avctx, AV_LOG_ERROR, "Error evaluating rc_eq \"%s\": %s\n", s->avctx->rc_eq, error ? error : "");

or even char *error = "";

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list