From 9ace13b416c77f15464fd8e1a024db8b00ce76f9 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 1 Jun 2010 08:07:07 +0000 Subject: 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. Originally committed as revision 23402 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/ratecontrol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libavcodec/ratecontrol.c') diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index fe6e4b08ab..375815a67f 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -66,7 +66,7 @@ static inline double bits2qp(RateControlEntry *rce, double bits){ 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 @@ int ff_rate_control_init(MpegEncContext *s) }; 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++){ -- cgit v1.2.3