1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@videolan.org>
8 * code from projectM http://xmms-projectm.sourceforge.net
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
30 #include "per_frame_eqn_types.h"
31 #include "per_frame_eqn.h"
33 #include "expr_types.h"
36 /* Evaluate an equation */
37 void eval_per_frame_eqn(per_frame_eqn_t * per_frame_eqn) {
39 if (per_frame_eqn == NULL)
42 if (PER_FRAME_EQN_DEBUG) {
43 printf("per_frame_%d=%s= ", per_frame_eqn->index, per_frame_eqn->param->name);
47 //*((double*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr);
48 set_param(per_frame_eqn->param, eval_gen_expr(per_frame_eqn->gen_expr));
49 if (PER_FRAME_EQN_DEBUG) printf(" = %.4f\n", *((double*)per_frame_eqn->param->engine_val));
54 void eval_per_frame_init_eqn(per_frame_eqn_t * per_frame_eqn) {
57 init_cond_t * init_cond;
58 if (per_frame_eqn == NULL)
61 if (PER_FRAME_EQN_DEBUG) {
62 printf("per_frame_init: %s = ", per_frame_eqn->param->name);
67 val = *((double*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr);
68 if (PER_FRAME_EQN_DEBUG) printf(" = %f\n", *((double*)per_frame_eqn->param->engine_val));
70 if (per_frame_eqn->param->flags & P_FLAG_QVAR) {
72 per_frame_eqn->param->init_val.double_val = val;
73 if ((init_cond = new_init_cond(per_frame_eqn->param)) == NULL)
76 if ((list_append(init_cond_list, init_cond)) < 0) {
77 free_init_cond(init_cond);
84 /* Frees perframe equation structure */
85 void free_per_frame_eqn(per_frame_eqn_t * per_frame_eqn) {
87 if (per_frame_eqn == NULL)
90 free_gen_expr(per_frame_eqn->gen_expr);
94 /* Create a new per frame equation */
95 per_frame_eqn_t * new_per_frame_eqn(int index, param_t * param, gen_expr_t * gen_expr) {
97 per_frame_eqn_t * per_frame_eqn;
99 per_frame_eqn = (per_frame_eqn_t*)malloc(sizeof(per_frame_eqn_t));
101 if (per_frame_eqn == NULL)
104 per_frame_eqn->param = param;
105 per_frame_eqn->gen_expr = gen_expr;
106 per_frame_eqn->index = index;
107 /* Set per frame eqn name */
108 // memset(per_frame_eqn->name, 0, MAX_TOKEN_SIZE);
109 //strncpy(per_frame_eqn->name, name, MAX_TOKEN_SIZE-1);
110 return per_frame_eqn;