Mercurial > libavcodec.hg
diff ratecontrol.c @ 11801:026edf66e3a9 libavcodec
Make ff_parse_expr() and ff_parse_and_eval_expr() return an int
containing an error code.
Allow these functions to convey the reason of the failure to the
calling function, failure which is not always due to a parsing error
but it may depend for example on a memory problem.
Also fix several potential memleaks.
author | stefano |
---|---|
date | Tue, 01 Jun 2010 08:07:07 +0000 |
parents | c6368258b694 |
children | e522dbf60abd |
line wrap: on
line diff
--- a/ratecontrol.c Mon May 31 22:01:31 2010 +0000 +++ b/ratecontrol.c Tue Jun 01 08:07:07 2010 +0000 @@ -66,7 +66,7 @@ int ff_rate_control_init(MpegEncContext *s) { RateControlContext *rcc= &s->rc_context; - int i; + int i, res; static const char * const const_names[]={ "PI", "E", @@ -106,10 +106,10 @@ }; emms_c(); - rcc->rc_eq_eval = ff_parse_expr(s->avctx->rc_eq ? s->avctx->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx); - if (!rcc->rc_eq_eval) { + res = ff_parse_expr(&rcc->rc_eq_eval, s->avctx->rc_eq ? s->avctx->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx); + if (res < 0) { av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->avctx->rc_eq); - return -1; + return res; } for(i=0; i<5; i++){