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