Mercurial > libavcodec.hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 11800:966aa6b53dcf | 11801:026edf66e3a9 |
|---|---|
| 64 } | 64 } |
| 65 | 65 |
| 66 int ff_rate_control_init(MpegEncContext *s) | 66 int ff_rate_control_init(MpegEncContext *s) |
| 67 { | 67 { |
| 68 RateControlContext *rcc= &s->rc_context; | 68 RateControlContext *rcc= &s->rc_context; |
| 69 int i; | 69 int i, res; |
| 70 static const char * const const_names[]={ | 70 static const char * const const_names[]={ |
| 71 "PI", | 71 "PI", |
| 72 "E", | 72 "E", |
| 73 "iTex", | 73 "iTex", |
| 74 "pTex", | 74 "pTex", |
| 104 "qp2bits", | 104 "qp2bits", |
| 105 NULL | 105 NULL |
| 106 }; | 106 }; |
| 107 emms_c(); | 107 emms_c(); |
| 108 | 108 |
| 109 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); | 109 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); |
| 110 if (!rcc->rc_eq_eval) { | 110 if (res < 0) { |
| 111 av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->avctx->rc_eq); | 111 av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->avctx->rc_eq); |
| 112 return -1; | 112 return res; |
| 113 } | 113 } |
| 114 | 114 |
| 115 for(i=0; i<5; i++){ | 115 for(i=0; i<5; i++){ |
| 116 rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0; | 116 rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0; |
| 117 rcc->pred[i].count= 1.0; | 117 rcc->pred[i].count= 1.0; |
