From 4156a436e37fb387da60fd919d6efa8ee71e1a0f Mon Sep 17 00:00:00 2001 From: Panagiotis Issaris Date: Tue, 26 Sep 2006 14:04:36 +0000 Subject: Handle possible failure of ff_eval. Originally committed as revision 6338 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/ratecontrol.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libavcodec/ratecontrol.c') diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 02108248ec..5c339fa152 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -326,6 +326,10 @@ static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_f }; bits= ff_eval(s->avctx->rc_eq, const_values, const_names, func1, func1_names, NULL, NULL, rce); + if (isnan(bits)) { + av_log(s->avctx, AV_LOG_ERROR, "Unable to parse rc_eq \"%s\".\n", s->avctx->rc_eq); + return -1; + } rcc->pass1_rc_eq_output_sum+= bits; bits*=rate_factor; @@ -726,6 +730,8 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run) rate_factor= rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum * br_compensation; q= get_qscale(s, rce, rate_factor, picture_number); + if (q < 0) + return -1; assert(q>0.0); //printf("%f ", q); -- cgit v1.2.3