-
Reimar Döffinger authored
Originally committed as revision 8122 to svn://svn.ffmpeg.org/ffmpeg/trunk
Reimar Döffinger authoredOriginally committed as revision 8122 to svn://svn.ffmpeg.org/ffmpeg/trunk
eval.c 13.58 KiB
/*
* simple arithmetic expression evaluator
*
* Copyright (c) 2002-2006 Michael Niedermayer <michaelni@gmx.at>
* Copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.org>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/**
* @file eval.c
* simple arithmetic expression evaluator.
*
* see http://joe.hotchkiss.com/programming/eval/eval.html
*/
#include "avcodec.h"
#include "mpegvideo.h"
#include "eval.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#ifndef NAN
#define NAN 0.0/0.0
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
typedef struct Parser{
int stack_index;
char *s;
double *const_value;
const char **const_name; // NULL terminated
double (**func1)(void *, double a); // NULL terminated
const char **func1_name; // NULL terminated
double (**func2)(void *, double a, double b); // NULL terminated
char **func2_name; // NULL terminated
void *opaque;
char **error;
#define VARS 10
double var[VARS];
} Parser;
static int8_t si_prefixes['z' - 'E' + 1]={
['y'-'E']= -24,
['z'-'E']= -21,
['a'-'E']= -18,
['f'-'E']= -15,
['p'-'E']= -12,
['n'-'E']= - 9,