[FFmpeg-devel] [WIP] av_expr_is_const()
Clément Bœsch
ubitux at gmail.com
Fri Mar 8 21:34:19 CET 2013
On Thu, Mar 07, 2013 at 02:33:58AM +0100, Stefano Sabatini wrote:
[...]
> From 31f48477513134e51531b1683e5ebe7639026fac Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Tue, 5 Mar 2013 14:51:56 +0100
> Subject: [PATCH] lavu/eval: refactor function handling code
>
> In particular:
> - create an ExprType and a separate native function list
> - do not treat simple libc wrapper especially
>
> The function names are now looked with a binary search, which reduces
> procedural logic and avoids chained else-if.
> ---
> libavutil/eval.c | 201 +++++++++++++++++++++++++++++++++++++++---------------
> 1 file changed, 147 insertions(+), 54 deletions(-)
>
This is interesting :-)
[...]
> From 4ad1744ed813af6331ecf71c8d9738601fdcdd4b Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Tue, 5 Mar 2013 22:34:42 +0100
> Subject: [PATCH] lavu/eval: add is_const info to function definitions
>
> It will be used in a later patch.
> ---
> libavutil/eval.c | 92 ++++++++++++++++++++++++++++--------------------------
> 1 file changed, 47 insertions(+), 45 deletions(-)
>
> diff --git a/libavutil/eval.c b/libavutil/eval.c
> index 612c8b5..4994db5 100644
> --- a/libavutil/eval.c
> +++ b/libavutil/eval.c
> @@ -109,54 +109,56 @@ enum ExprType {
> typedef struct {
> const char *name;
> enum ExprType type;
> + int is_const;
> } Function;
>
> static Function functions[] = {
> - { "abs", e_abs },
> - { "acos", e_acos },
> - { "asin", e_asin },
> - { "atan", e_atan },
> - { "ceil", e_ceil },
> - { "cos", e_cos },
> - { "cosh", e_cosh },
> - { "div", e_div },
> - { "eq", e_eq },
> - { "exp", e_exp },
> - { "floor", e_floor },
> - { "gauss", e_gauss },
> - { "gcd", e_gcd },
> - { "gt", e_gt },
> - { "gte", e_gte },
> - { "hypot", e_hypot },
> - { "if", e_if },
> - { "ifnot", e_ifnot },
> - { "isinf", e_isinf },
> - { "isnan", e_isnan },
> - { "last", e_last },
> - { "ld", e_ld },
> - { "log", e_log },
> - { "lt", e_lt },
> - { "lte", e_lte },
> - { "max", e_max },
> - { "min", e_min },
> - { "mod", e_mod },
> - { "mul", e_mul },
> - { "not", e_not },
> - { "pow", e_pow },
> - { "print", e_print },
> - { "random", e_random },
> - { "root", e_root },
> - { "sin", e_sin },
> - { "sinh", e_sinh },
> - { "sqrt", e_sqrt },
> - { "squish", e_squish },
> - { "st", e_st },
> - { "tan", e_tan },
> - { "tanh", e_tanh },
> - { "taylor", e_taylor },
> - { "time", e_time },
> - { "trunc", e_trunc },
> - { "while", e_while },
> + { "abs", e_abs, 1 },
> + { "add", e_add, 1 },
> + { "acos", e_acos, 1 },
> + { "asin", e_asin, 1 },
> + { "atan", e_atan, 1 },
> + { "ceil", e_ceil, 1 },
> + { "cos", e_cos, 1 },
> + { "cosh", e_cosh, 1 },
> + { "div", e_div, 1 },
> + { "eq", e_eq, 1 },
> + { "exp", e_exp, 1 },
> + { "floor", e_floor, 1 },
> + { "gauss", e_gauss, 1 },
> + { "gcd", e_gcd, 1 },
> + { "gt", e_gt, 1 },
> + { "gte", e_gte, 1 },
> + { "hypot", e_hypot, 1 },
> + { "if", e_if, 1 },
> + { "ifnot", e_ifnot, 1 },
> + { "isinf", e_isinf, 1 },
> + { "isnan", e_isnan, 1 },
> + { "last", e_last, 1 },
> + { "ld", e_ld, 1 },
while this one might be ok...
> + { "log", e_log, 1 },
> + { "lt", e_lt, 1 },
> + { "lte", e_lte, 1 },
> + { "max", e_max, 1 },
> + { "min", e_min, 1 },
> + { "mod", e_mod, 1 },
> + { "mul", e_mul, 1 },
> + { "not", e_not, 1 },
> + { "pow", e_pow, 1 },
> + { "print", e_print, 1 },
> + { "random", e_random, 0 },
> + { "root", e_root, 1 },
> + { "sin", e_sin, 1 },
> + { "sinh", e_sinh, 1 },
> + { "sqrt", e_sqrt, 1 },
> + { "squish", e_squish, 1 },
> + { "st", e_st, 1 },
...I don't think this is. "st(0,ld(0)+1)" will be evaluated differently
after each call. Any function writing to registers should not be
considered const.
This might be also true for root() and taylor().
> + { "tan", e_tan, 1 },
> + { "tanh", e_tanh, 1 },
> + { "taylor", e_taylor, 1 },
> + { "time", e_time, 0 },
> + { "trunc", e_trunc, 1 },
> + { "while", e_while, 1 },
> };
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130308/5d68cfd2/attachment.asc>
More information about the ffmpeg-devel
mailing list