API public.
Originally committed as revision 23485 to svn://svn.ffmpeg.org/ffmpeg/trunk
bitstream.o \
bitstream_filter.o \
dsputil.o \
- eval.o \
faanidct.o \
imgconvert.o \
jrevdct.o \
#define LIBAVCODEC_VERSION_MAJOR 52
#define LIBAVCODEC_VERSION_MINOR 74
-#define LIBAVCODEC_VERSION_MICRO 0
+#define LIBAVCODEC_VERSION_MICRO 1
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
#include "avcodec.h"
#include "opt.h"
-#include "eval.h"
+#include "libavutil/eval.h"
//FIXME order them and do a bin search
const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mask, int flags){
else if(!strcmp(buf, "none" )) d= 0;
else if(!strcmp(buf, "all" )) d= ~0;
else {
- int res = ff_parse_and_eval_expr(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
+ int res = av_parse_and_eval_expr(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
if (res < 0) {
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val);
return res;
#include "dsputil.h"
#include "ratecontrol.h"
#include "mpegvideo.h"
-#include "eval.h"
+#include "libavutil/eval.h"
#undef NDEBUG // Always check asserts, the speed effect is far too small to disable them.
#include <assert.h>
};
emms_c();
- 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);
+ res = av_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 res;
RateControlContext *rcc= &s->rc_context;
emms_c();
- ff_free_expr(rcc->rc_eq_eval);
+ av_free_expr(rcc->rc_eq_eval);
av_freep(&rcc->entry);
#if CONFIG_LIBXVID
0
};
- bits= ff_eval_expr(rcc->rc_eq_eval, const_values, rce);
+ bits = av_eval_expr(rcc->rc_eq_eval, const_values, rce);
if (isnan(bits)) {
av_log(s->avctx, AV_LOG_ERROR, "Error evaluating rc_eq \"%s\"\n", s->avctx->rc_eq);
return -1;
#include <stdio.h>
#include <stdint.h>
-#include "eval.h"
+#include "libavutil/eval.h"
typedef struct Predictor{
double coeff;
common.h \
crc.h \
error.h \
+ eval.h \
fifo.h \
intfloat_readwrite.h \
log.h \
crc.o \
des.o \
error.o \
+ eval.o \
fifo.o \
intfloat_readwrite.o \
lfg.o \
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
#define LIBAVUTIL_VERSION_MAJOR 50
-#define LIBAVUTIL_VERSION_MINOR 17
+#define LIBAVUTIL_VERSION_MINOR 18
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
static int parse_expr(AVExpr **e, Parser *p);
-void ff_free_expr(AVExpr *e)
+void av_free_expr(AVExpr *e)
{
if (!e) return;
- ff_free_expr(e->param[0]);
- ff_free_expr(e->param[1]);
+ av_free_expr(e->param[0]);
+ av_free_expr(e->param[1]);
av_freep(&e);
}
if (p->s==NULL) {
av_log(p, AV_LOG_ERROR, "undefined constant or missing (\n");
p->s= next;
- ff_free_expr(d);
+ av_free_expr(d);
return AVERROR(EINVAL);
}
p->s++; // "("
return ret;
if (p->s[0] != ')') {
av_log(p, AV_LOG_ERROR, "missing )\n");
- ff_free_expr(d);
+ av_free_expr(d);
return AVERROR(EINVAL);
}
p->s++; // ")"
return 0;
}
if ((ret = parse_expr(&(d->param[0]), p)) < 0) {
- ff_free_expr(d);
+ av_free_expr(d);
return ret;
}
if (p->s[0]== ',') {
}
if (p->s[0] != ')') {
av_log(p, AV_LOG_ERROR, "missing )\n");
- ff_free_expr(d);
+ av_free_expr(d);
return AVERROR(EINVAL);
}
p->s++; // ")"
}
av_log(p, AV_LOG_ERROR, "unknown function\n");
- ff_free_expr(d);
+ av_free_expr(d);
return AVERROR(EINVAL);
}
e1 = e0;
p->s++;
if ((ret = parse_pow(&e2, p, &sign2)) < 0) {
- ff_free_expr(e1);
+ av_free_expr(e1);
return ret;
}
e0 = new_eval_expr(e_pow, 1, e1, e2);
if (!e0) {
- ff_free_expr(e1);
- ff_free_expr(e2);
+ av_free_expr(e1);
+ av_free_expr(e2);
return AVERROR(ENOMEM);
}
if (e0->param[1]) e0->param[1]->value *= (sign2|1);
int c= *p->s++;
e1 = e0;
if ((ret = parse_factor(&e2, p)) < 0) {
- ff_free_expr(e1);
+ av_free_expr(e1);
return ret;
}
e0 = new_eval_expr(c == '*' ? e_mul : e_div, 1, e1, e2);
if (!e0) {
- ff_free_expr(e1);
- ff_free_expr(e2);
+ av_free_expr(e1);
+ av_free_expr(e2);
return AVERROR(ENOMEM);
}
}
while (*p->s == '+' || *p->s == '-') {
e1 = e0;
if ((ret = parse_term(&e2, p)) < 0) {
- ff_free_expr(e1);
+ av_free_expr(e1);
return ret;
}
e0 = new_eval_expr(e_add, 1, e1, e2);
if (!e0) {
- ff_free_expr(e1);
- ff_free_expr(e2);
+ av_free_expr(e1);
+ av_free_expr(e2);
return AVERROR(ENOMEM);
}
};
while (*p->s == ';') {
e1 = e0;
if ((ret = parse_subexpr(&e2, p)) < 0) {
- ff_free_expr(e1);
+ av_free_expr(e1);
return ret;
}
p->s++;
e0 = new_eval_expr(e_last, 1, e1, e2);
if (!e0) {
- ff_free_expr(e1);
- ff_free_expr(e2);
+ av_free_expr(e1);
+ av_free_expr(e2);
return AVERROR(ENOMEM);
}
};
}
}
-int ff_parse_expr(AVExpr **expr, const char *s,
+int av_parse_expr(AVExpr **expr, const char *s,
const char * const *const_names,
const char * const *func1_names, double (* const *funcs1)(void *, double),
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
if ((ret = parse_expr(&e, &p)) < 0)
goto end;
if (!verify_expr(e)) {
- ff_free_expr(e);
+ av_free_expr(e);
ret = AVERROR(EINVAL);
goto end;
}
return ret;
}
-double ff_eval_expr(AVExpr *e, const double *const_values, void *opaque)
+double av_eval_expr(AVExpr *e, const double *const_values, void *opaque)
{
Parser p;
return eval_expr(&p, e);
}
-int ff_parse_and_eval_expr(double *d, const char *s,
+int av_parse_and_eval_expr(double *d, const char *s,
const char * const *const_names, const double *const_values,
const char * const *func1_names, double (* const *funcs1)(void *, double),
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
void *opaque, int log_offset, void *log_ctx)
{
AVExpr *e = NULL;
- int ret = ff_parse_expr(&e, s, const_names, func1_names, funcs1, func2_names, funcs2, log_offset, log_ctx);
+ int ret = av_parse_expr(&e, s, const_names, func1_names, funcs1, func2_names, funcs2, log_offset, log_ctx);
if (ret < 0) {
*d = NAN;
return ret;
}
- *d = ff_eval_expr(e, const_values, opaque);
- ff_free_expr(e);
+ *d = av_eval_expr(e, const_values, opaque);
+ av_free_expr(e);
return isnan(*d) ? AVERROR(EINVAL) : 0;
}
{
int i;
double d;
- ff_parse_and_eval_expr(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
+ av_parse_and_eval_expr(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
const_names, const_values,
NULL, NULL, NULL, NULL, NULL, 0, NULL);
printf("%f == 12.7\n", d);
- ff_parse_and_eval_expr(&d, "80G/80Gi",
+ av_parse_and_eval_expr(&d, "80G/80Gi",
const_names, const_values,
NULL, NULL, NULL, NULL, NULL, 0, NULL);
printf("%f == 0.931322575\n", d);
for (i=0; i<1050; i++) {
START_TIMER
- ff_parse_and_eval_expr(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
+ av_parse_and_eval_expr(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
const_names, const_values,
NULL, NULL, NULL, NULL, NULL, 0, NULL);
- STOP_TIMER("ff_parse_and_eval_expr")
+ STOP_TIMER("av_parse_and_eval_expr")
}
return 0;
}
* simple arithmetic expression evaluator
*/
-#ifndef AVCODEC_EVAL_H
-#define AVCODEC_EVAL_H
+#ifndef AVUTIL_EVAL_H
+#define AVUTIL_EVAL_H
typedef struct AVExpr AVExpr;
/**
* Parses and evaluates an expression.
- * Note, this is significantly slower than ff_eval_expr().
+ * Note, this is significantly slower than av_eval_expr().
*
* @param res a pointer to a double where is put the result value of
* the expression, or NAN in case of error
* @return 0 in case of success, a negative value corresponding to an
* AVERROR code otherwise
*/
-int ff_parse_and_eval_expr(double *res, const char *s,
+int av_parse_and_eval_expr(double *res, const char *s,
const char * const *const_names, const double *const_values,
const char * const *func1_names, double (* const *funcs1)(void *, double),
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
*
* @param expr a pointer where is put an AVExpr containing the parsed
* value in case of successfull parsing, or NULL otherwise.
- * The pointed to AVExpr must be freed with ff_free_expr() by the user
+ * The pointed to AVExpr must be freed with av_free_expr() by the user
* when it is not needed anymore.
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
* @return 0 in case of success, a negative value corresponding to an
* AVERROR code otherwise
*/
-int ff_parse_expr(AVExpr **expr, const char *s,
+int av_parse_expr(AVExpr **expr, const char *s,
const char * const *const_names,
const char * const *func1_names, double (* const *funcs1)(void *, double),
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
/**
* Evaluates a previously parsed expression.
*
- * @param const_values a zero terminated array of values for the identifiers from ff_parse() const_names
+ * @param const_values a zero terminated array of values for the identifiers from av_parse_expr() const_names
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
* @return the value of the expression
*/
-double ff_eval_expr(AVExpr *e, const double *const_values, void *opaque);
+double av_eval_expr(AVExpr *e, const double *const_values, void *opaque);
/**
- * Frees a parsed expression previously created with ff_parse_expr().
+ * Frees a parsed expression previously created with av_parse_expr().
*/
-void ff_free_expr(AVExpr *e);
+void av_free_expr(AVExpr *e);
/**
* Parses the string in numstr and returns its value as a double. If
*/
double av_strtod(const char *numstr, char **tail);
-#endif /* AVCODEC_EVAL_H */
+#endif /* AVUTIL_EVAL_H */