annotate ffmpeg/libavutil/eval.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
yading@11 3 *
yading@11 4 * This file is part of FFmpeg.
yading@11 5 *
yading@11 6 * FFmpeg is free software; you can redistribute it and/or
yading@11 7 * modify it under the terms of the GNU Lesser General Public
yading@11 8 * License as published by the Free Software Foundation; either
yading@11 9 * version 2.1 of the License, or (at your option) any later version.
yading@11 10 *
yading@11 11 * FFmpeg is distributed in the hope that it will be useful,
yading@11 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 14 * Lesser General Public License for more details.
yading@11 15 *
yading@11 16 * You should have received a copy of the GNU Lesser General Public
yading@11 17 * License along with FFmpeg; if not, write to the Free Software
yading@11 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 19 */
yading@11 20
yading@11 21 /**
yading@11 22 * @file
yading@11 23 * simple arithmetic expression evaluator
yading@11 24 */
yading@11 25
yading@11 26 #ifndef AVUTIL_EVAL_H
yading@11 27 #define AVUTIL_EVAL_H
yading@11 28
yading@11 29 #include "avutil.h"
yading@11 30
yading@11 31 typedef struct AVExpr AVExpr;
yading@11 32
yading@11 33 /**
yading@11 34 * Parse and evaluate an expression.
yading@11 35 * Note, this is significantly slower than av_expr_eval().
yading@11 36 *
yading@11 37 * @param res a pointer to a double where is put the result value of
yading@11 38 * the expression, or NAN in case of error
yading@11 39 * @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
yading@11 40 * @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
yading@11 41 * @param const_values a zero terminated array of values for the identifiers from const_names
yading@11 42 * @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
yading@11 43 * @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
yading@11 44 * @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
yading@11 45 * @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
yading@11 46 * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
yading@11 47 * @param log_ctx parent logging context
yading@11 48 * @return 0 in case of success, a negative value corresponding to an
yading@11 49 * AVERROR code otherwise
yading@11 50 */
yading@11 51 int av_expr_parse_and_eval(double *res, const char *s,
yading@11 52 const char * const *const_names, const double *const_values,
yading@11 53 const char * const *func1_names, double (* const *funcs1)(void *, double),
yading@11 54 const char * const *func2_names, double (* const *funcs2)(void *, double, double),
yading@11 55 void *opaque, int log_offset, void *log_ctx);
yading@11 56
yading@11 57 /**
yading@11 58 * Parse an expression.
yading@11 59 *
yading@11 60 * @param expr a pointer where is put an AVExpr containing the parsed
yading@11 61 * value in case of successful parsing, or NULL otherwise.
yading@11 62 * The pointed to AVExpr must be freed with av_expr_free() by the user
yading@11 63 * when it is not needed anymore.
yading@11 64 * @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
yading@11 65 * @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
yading@11 66 * @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
yading@11 67 * @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
yading@11 68 * @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
yading@11 69 * @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
yading@11 70 * @param log_ctx parent logging context
yading@11 71 * @return 0 in case of success, a negative value corresponding to an
yading@11 72 * AVERROR code otherwise
yading@11 73 */
yading@11 74 int av_expr_parse(AVExpr **expr, const char *s,
yading@11 75 const char * const *const_names,
yading@11 76 const char * const *func1_names, double (* const *funcs1)(void *, double),
yading@11 77 const char * const *func2_names, double (* const *funcs2)(void *, double, double),
yading@11 78 int log_offset, void *log_ctx);
yading@11 79
yading@11 80 /**
yading@11 81 * Evaluate a previously parsed expression.
yading@11 82 *
yading@11 83 * @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names
yading@11 84 * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
yading@11 85 * @return the value of the expression
yading@11 86 */
yading@11 87 double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
yading@11 88
yading@11 89 /**
yading@11 90 * Free a parsed expression previously created with av_expr_parse().
yading@11 91 */
yading@11 92 void av_expr_free(AVExpr *e);
yading@11 93
yading@11 94 /**
yading@11 95 * Parse the string in numstr and return its value as a double. If
yading@11 96 * the string is empty, contains only whitespaces, or does not contain
yading@11 97 * an initial substring that has the expected syntax for a
yading@11 98 * floating-point number, no conversion is performed. In this case,
yading@11 99 * returns a value of zero and the value returned in tail is the value
yading@11 100 * of numstr.
yading@11 101 *
yading@11 102 * @param numstr a string representing a number, may contain one of
yading@11 103 * the International System number postfixes, for example 'K', 'M',
yading@11 104 * 'G'. If 'i' is appended after the postfix, powers of 2 are used
yading@11 105 * instead of powers of 10. The 'B' postfix multiplies the value for
yading@11 106 * 8, and can be appended after another postfix or used alone. This
yading@11 107 * allows using for example 'KB', 'MiB', 'G' and 'B' as postfix.
yading@11 108 * @param tail if non-NULL puts here the pointer to the char next
yading@11 109 * after the last parsed character
yading@11 110 */
yading@11 111 double av_strtod(const char *numstr, char **tail);
yading@11 112
yading@11 113 #endif /* AVUTIL_EVAL_H */