Commit d6008a8b authored by Rafaël Carré's avatar Rafaël Carré

Reverts [21943] for galaktos as it is external to vlc.

Just in case it is merged one day with upstream source.
parent c6eafbbb
...@@ -48,13 +48,13 @@ int new; //how many new samples ...@@ -48,13 +48,13 @@ int new; //how many new samples
void initPCM(int samples) void initPCM(int samples)
{ {
int i; int i;
//Allocate memory for PCM data buffer //Allocate memory for PCM data buffer
PCMd = (double **)malloc(2 * sizeof(double *)); PCMd = (double **)malloc(2 * sizeof(double *));
PCMd[0] = (double *)malloc(samples * sizeof(double)); PCMd[0] = (double *)malloc(samples * sizeof(double));
PCMd[1] = (double *)malloc(samples * sizeof(double)); PCMd[1] = (double *)malloc(samples * sizeof(double));
maxsamples=samples; maxsamples=samples;
new=0; new=0;
...@@ -83,15 +83,15 @@ void addPCM(int16_t PCMdata[2][512]) ...@@ -83,15 +83,15 @@ void addPCM(int16_t PCMdata[2][512])
int i,j; int i,j;
int samples=512; int samples=512;
for(i=0;i<samples;i++) for(i=0;i<samples;i++)
{ {
j=i+start; j=i+start;
PCMd[0][j%maxsamples]=(PCMdata[0][i]/16384.0); PCMd[0][j%maxsamples]=(PCMdata[0][i]/16384.0);
PCMd[1][j%maxsamples]=(PCMdata[1][i]/16384.0); PCMd[1][j%maxsamples]=(PCMdata[1][i]/16384.0);
} }
// printf("Added %d samples %d %d %f\n",samples,start,(start+samples)%maxsamples,PCM[0][start+10]); // printf("Added %d samples %d %d %f\n",samples,start,(start+samples)%maxsamples,PCM[0][start+10]);
start+=samples; start+=samples;
start=start%maxsamples; start=start%maxsamples;
...@@ -113,28 +113,28 @@ void addPCM(int16_t PCMdata[2][512]) ...@@ -113,28 +113,28 @@ void addPCM(int16_t PCMdata[2][512])
void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothing, int derive) void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothing, int derive)
{ {
int i,index; int i,index;
index=start-1; index=start-1;
if (index<0) index=maxsamples+index; if (index<0) index=maxsamples+index;
PCMdata[0]=PCMd[channel][index]; PCMdata[0]=PCMd[channel][index];
for(i=1;i<samples;i++) for(i=1;i<samples;i++)
{ {
index=start-1-i; index=start-1-i;
if (index<0) index=maxsamples+index; if (index<0) index=maxsamples+index;
PCMdata[i]=(1-smoothing)*PCMd[channel][index]+smoothing*PCMdata[i-1]; PCMdata[i]=(1-smoothing)*PCMd[channel][index]+smoothing*PCMdata[i-1];
} }
//return derivative of PCM data //return derivative of PCM data
if(derive) if(derive)
{ {
for(i=0;i<samples-1;i++) for(i=0;i<samples-1;i++)
{ {
PCMdata[i]=PCMdata[i]-PCMdata[i+1]; PCMdata[i]=PCMdata[i]-PCMdata[i+1];
} }
PCMdata[samples-1]=0; PCMdata[samples-1]=0;
} }
...@@ -142,7 +142,7 @@ void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothin ...@@ -142,7 +142,7 @@ void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothin
if (freq) rdft(samples, 1, PCMdata, ip, w); if (freq) rdft(samples, 1, PCMdata, ip, w);
} }
//getPCMnew //getPCMnew
...@@ -154,28 +154,28 @@ void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothin ...@@ -154,28 +154,28 @@ void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothin
int getPCMnew(double *PCMdata, int channel, int freq, double smoothing, int derive, int reset) int getPCMnew(double *PCMdata, int channel, int freq, double smoothing, int derive, int reset)
{ {
int i,index; int i,index;
index=start-1; index=start-1;
if (index<0) index=maxsamples+index; if (index<0) index=maxsamples+index;
PCMdata[0]=PCMd[channel][index]; PCMdata[0]=PCMd[channel][index];
for(i=1;i<new;i++) for(i=1;i<new;i++)
{ {
index=start-1-i; index=start-1-i;
if (index<0) index=maxsamples+index; if (index<0) index=maxsamples+index;
PCMdata[i]=(1-smoothing)*PCMd[channel][index]+smoothing*PCMdata[i-1]; PCMdata[i]=(1-smoothing)*PCMd[channel][index]+smoothing*PCMdata[i-1];
} }
//return derivative of PCM data //return derivative of PCM data
if(derive) if(derive)
{ {
for(i=0;i<new-1;i++) for(i=0;i<new-1;i++)
{ {
PCMdata[i]=PCMdata[i]-PCMdata[i+1]; PCMdata[i]=PCMdata[i]-PCMdata[i+1];
} }
PCMdata[new-1]=0; PCMdata[new-1]=0;
} }
......
...@@ -41,7 +41,7 @@ double vol_buffer[80],vol_instant,vol_history; ...@@ -41,7 +41,7 @@ double vol_buffer[80],vol_instant,vol_history;
void initBeatDetect() void initBeatDetect()
{ {
int x,y; int x,y;
vol_instant=0; vol_instant=0;
vol_history=0; vol_history=0;
...@@ -65,12 +65,12 @@ void initBeatDetect() ...@@ -65,12 +65,12 @@ void initBeatDetect()
beat_att[x]=1.0; beat_att[x]=1.0;
beat_variance[x]=0; beat_variance[x]=0;
for (y=0;y<80;y++) for (y=0;y<80;y++)
{ {
beat_buffer[x][y]=0; beat_buffer[x][y]=0;
} }
} }
} }
void getBeatVals(double *vdataL,double *vdataR, double *vol) void getBeatVals(double *vdataL,double *vdataR, double *vol)
{ {
...@@ -80,29 +80,29 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol) ...@@ -80,29 +80,29 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol)
vol_instant=0; vol_instant=0;
for ( x=0;x<16;x++) for ( x=0;x<16;x++)
{ {
beat_instant[x]=0; beat_instant[x]=0;
for ( y=linear*2;y<(linear+8+x)*2;y++) for ( y=linear*2;y<(linear+8+x)*2;y++)
{ {
beat_instant[x]+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/(8+x)); beat_instant[x]+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/(8+x));
vol_instant+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/512.0); vol_instant+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/512.0);
} }
linear=y/2; linear=y/2;
beat_history[x]-=(beat_buffer[x][beat_buffer_pos])*.0125; beat_history[x]-=(beat_buffer[x][beat_buffer_pos])*.0125;
beat_buffer[x][beat_buffer_pos]=beat_instant[x]; beat_buffer[x][beat_buffer_pos]=beat_instant[x];
beat_history[x]+=(beat_instant[x])*.0125; beat_history[x]+=(beat_instant[x])*.0125;
beat_val[x]=(beat_instant[x])/(beat_history[x]); beat_val[x]=(beat_instant[x])/(beat_history[x]);
beat_att[x]+=(beat_instant[x])/(beat_history[x]); beat_att[x]+=(beat_instant[x])/(beat_history[x]);
} }
vol_history-=(vol_buffer[beat_buffer_pos])*.0125; vol_history-=(vol_buffer[beat_buffer_pos])*.0125;
vol_buffer[beat_buffer_pos]=vol_instant; vol_buffer[beat_buffer_pos]=vol_instant;
vol_history+=(vol_instant)*.0125; vol_history+=(vol_instant)*.0125;
...@@ -110,33 +110,33 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol) ...@@ -110,33 +110,33 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol)
double temp2=0; double temp2=0;
mid=0; mid=0;
for(x=1;x<10;x++) for(x=1;x<10;x++)
{ {
mid+=(beat_instant[x]); mid+=(beat_instant[x]);
temp2+=(beat_history[x]); temp2+=(beat_history[x]);
} }
mid=mid/(1.5*temp2); mid=mid/(1.5*temp2);
temp2=0; temp2=0;
treb=0; treb=0;
for(x=10;x<16;x++) for(x=10;x<16;x++)
{ {
treb+=(beat_instant[x]); treb+=(beat_instant[x]);
temp2+=(beat_history[x]); temp2+=(beat_history[x]);
} }
treb=treb/(1.5*temp2); treb=treb/(1.5*temp2);
*vol=vol_instant/(1.5*vol_history); *vol=vol_instant/(1.5*vol_history);
bass=(beat_instant[0])/(1.5*beat_history[0]); bass=(beat_instant[0])/(1.5*beat_history[0]);
treb_att=.6 * treb_att + .4 * treb; treb_att=.6 * treb_att + .4 * treb;
mid_att=.6 * mid_att + .4 * mid; mid_att=.6 * mid_att + .4 * mid;
bass_att=.6 * bass_att + .4 * bass; bass_att=.6 * bass_att + .4 * bass;
//printf("%f %f %f %f\n",bass,mid,treb,*vol); //printf("%f %f %f %f\n",bass,mid,treb,*vol);
// *vol=(beat_instant[3])/(beat_history[3]); // *vol=(beat_instant[3])/(beat_history[3]);
beat_buffer_pos++; beat_buffer_pos++;
if( beat_buffer_pos>79)beat_buffer_pos=0; if( beat_buffer_pos>79)beat_buffer_pos=0;
} }
void freeBeatDetect() void freeBeatDetect()
{ {
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
#include <math.h> #include <math.h>
/* Values to optimize the sigmoid function */ /* Values to optimize the sigmoid function */
#define R 32767 #define R 32767
#define RR 65534 #define RR 65534
inline double int_wrapper(double * arg_list) { inline double int_wrapper(double * arg_list) {
...@@ -36,57 +36,57 @@ inline double int_wrapper(double * arg_list) { ...@@ -36,57 +36,57 @@ inline double int_wrapper(double * arg_list) {
inline double sqr_wrapper(double * arg_list) { inline double sqr_wrapper(double * arg_list) {
return pow(2, arg_list[0]); return pow(2, arg_list[0]);
} }
inline double sign_wrapper(double * arg_list) { inline double sign_wrapper(double * arg_list) {
return -arg_list[0]; return -arg_list[0];
} }
inline double min_wrapper(double * arg_list) { inline double min_wrapper(double * arg_list) {
if (arg_list[0] > arg_list[1]) if (arg_list[0] > arg_list[1])
return arg_list[1]; return arg_list[1];
return arg_list[0]; return arg_list[0];
} }
inline double max_wrapper(double * arg_list) { inline double max_wrapper(double * arg_list) {
if (arg_list[0] > arg_list[1]) if (arg_list[0] > arg_list[1])
return arg_list[0]; return arg_list[0];
return arg_list[1]; return arg_list[1];
} }
/* consult your AI book */ /* consult your AI book */
inline double sigmoid_wrapper(double * arg_list) { inline double sigmoid_wrapper(double * arg_list) {
return (RR / (1 + exp( -(((double)(arg_list[0])) * arg_list[1]) / R) - R)); return (RR / (1 + exp( -(((double)(arg_list[0])) * arg_list[1]) / R) - R));
} }
inline double bor_wrapper(double * arg_list) { inline double bor_wrapper(double * arg_list) {
return (double)((int)arg_list[0] || (int)arg_list[1]); return (double)((int)arg_list[0] || (int)arg_list[1]);
} }
inline double band_wrapper(double * arg_list) { inline double band_wrapper(double * arg_list) {
return (double)((int)arg_list[0] && (int)arg_list[1]); return (double)((int)arg_list[0] && (int)arg_list[1]);
} }
inline double bnot_wrapper(double * arg_list) { inline double bnot_wrapper(double * arg_list) {
return (double)(!(int)arg_list[0]); return (double)(!(int)arg_list[0]);
} }
inline double if_wrapper(double * arg_list) { inline double if_wrapper(double * arg_list) {
if ((int)arg_list[0] == 0) if ((int)arg_list[0] == 0)
return arg_list[2]; return arg_list[2];
return arg_list[1]; return arg_list[1];
} }
inline double rand_wrapper(double * arg_list) { inline double rand_wrapper(double * arg_list) {
...@@ -96,48 +96,48 @@ inline double rand_wrapper(double * arg_list) { ...@@ -96,48 +96,48 @@ inline double rand_wrapper(double * arg_list) {
l = (double)((rand()) % ((int)arg_list[0])); l = (double)((rand()) % ((int)arg_list[0]));
//printf("VAL: %f\n", l); //printf("VAL: %f\n", l);
return l; return l;
} }
inline double equal_wrapper(double * arg_list) { inline double equal_wrapper(double * arg_list) {
return (arg_list[0] == arg_list[1]); return (arg_list[0] == arg_list[1]);
} }
inline double above_wrapper(double * arg_list) { inline double above_wrapper(double * arg_list) {
return (arg_list[0] > arg_list[1]); return (arg_list[0] > arg_list[1]);
} }
inline double below_wrapper(double * arg_list) { inline double below_wrapper(double * arg_list) {
return (arg_list[0] < arg_list[1]); return (arg_list[0] < arg_list[1]);
} }
inline double sin_wrapper(double * arg_list) { inline double sin_wrapper(double * arg_list) {
return (sin (arg_list[0])); return (sin (arg_list[0]));
} }
inline double cos_wrapper(double * arg_list) { inline double cos_wrapper(double * arg_list) {
return (cos (arg_list[0])); return (cos (arg_list[0]));
} }
inline double tan_wrapper(double * arg_list) { inline double tan_wrapper(double * arg_list) {
return (tan(arg_list[0])); return (tan(arg_list[0]));
} }
inline double asin_wrapper(double * arg_list) { inline double asin_wrapper(double * arg_list) {
return (asin (arg_list[0])); return (asin (arg_list[0]));
} }
inline double acos_wrapper(double * arg_list) { inline double acos_wrapper(double * arg_list) {
return (acos (arg_list[0])); return (acos (arg_list[0]));
} }
inline double atan_wrapper(double * arg_list) { inline double atan_wrapper(double * arg_list) {
return (atan (arg_list[0])); return (atan (arg_list[0]));
} }
inline double atan2_wrapper(double * arg_list) { inline double atan2_wrapper(double * arg_list) {
...@@ -193,9 +193,9 @@ inline double fact_wrapper(double * arg_list) { ...@@ -193,9 +193,9 @@ inline double fact_wrapper(double * arg_list) {
int result = 1; int result = 1;
int n = (int)arg_list[0]; int n = (int)arg_list[0];
while (n > 1) { while (n > 1) {
result = result * n; result = result * n;
n--; n--;
......
/* Wrappers for all the builtin functions /* Wrappers for all the builtin functions
The arg_list pointer is a list of doubles. Its The arg_list pointer is a list of doubles. Its
size is equal to the number of arguments the parameter size is equal to the number of arguments the parameter
takes */ takes */
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#endif #endif
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
#endif #endif
#define PROJECTM_FILE_EXTENSION ".prjm" #define PROJECTM_FILE_EXTENSION ".prjm"
#define MILKDROP_FILE_EXTENSION ".milk" #define MILKDROP_FILE_EXTENSION ".milk"
......
...@@ -77,25 +77,25 @@ custom_shape_t * new_custom_shape(int id) { ...@@ -77,25 +77,25 @@ custom_shape_t * new_custom_shape(int id) {
/* Initialize tree data structures */ /* Initialize tree data structures */
if ((custom_shape->param_tree = if ((custom_shape->param_tree =
create_splaytree(compare_string, copy_string, free_string)) == NULL) { create_splaytree(compare_string, copy_string, free_string)) == NULL) {
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
} }
if ((custom_shape->per_frame_eqn_tree = if ((custom_shape->per_frame_eqn_tree =
create_splaytree(compare_int, copy_int, free_int)) == NULL) { create_splaytree(compare_int, copy_int, free_int)) == NULL) {
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
} }
if ((custom_shape->init_cond_tree = if ((custom_shape->init_cond_tree =
create_splaytree(compare_string, copy_string, free_string)) == NULL) { create_splaytree(compare_string, copy_string, free_string)) == NULL) {
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
} }
if ((custom_shape->per_frame_init_eqn_tree = if ((custom_shape->per_frame_init_eqn_tree =
create_splaytree(compare_string, copy_string, free_string)) == NULL) { create_splaytree(compare_string, copy_string, free_string)) == NULL) {
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
...@@ -125,7 +125,7 @@ custom_shape_t * new_custom_shape(int id) { ...@@ -125,7 +125,7 @@ custom_shape_t * new_custom_shape(int id) {
if ((param = new_param_double("b", P_FLAG_NONE, &custom_shape->b, NULL, 1.0, 0.0, .5)) == NULL){ if ((param = new_param_double("b", P_FLAG_NONE, &custom_shape->b, NULL, 1.0, 0.0, .5)) == NULL){
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
} }
if (insert_param(param, custom_shape->param_tree) < 0) { if (insert_param(param, custom_shape->param_tree) < 0) {
...@@ -165,7 +165,7 @@ custom_shape_t * new_custom_shape(int id) { ...@@ -165,7 +165,7 @@ custom_shape_t * new_custom_shape(int id) {
if ((param = new_param_double("border_b", P_FLAG_NONE, &custom_shape->border_b, NULL, 1.0, 0.0, .5)) == NULL){ if ((param = new_param_double("border_b", P_FLAG_NONE, &custom_shape->border_b, NULL, 1.0, 0.0, .5)) == NULL){
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
} }
if (insert_param(param, custom_shape->param_tree) < 0) { if (insert_param(param, custom_shape->param_tree) < 0) {
...@@ -205,7 +205,7 @@ custom_shape_t * new_custom_shape(int id) { ...@@ -205,7 +205,7 @@ custom_shape_t * new_custom_shape(int id) {
if ((param = new_param_double("b2", P_FLAG_NONE, &custom_shape->b2, NULL, 1.0, 0.0, .5)) == NULL){ if ((param = new_param_double("b2", P_FLAG_NONE, &custom_shape->b2, NULL, 1.0, 0.0, .5)) == NULL){
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
} }
if (insert_param(param, custom_shape->param_tree) < 0) { if (insert_param(param, custom_shape->param_tree) < 0) {
...@@ -217,7 +217,7 @@ custom_shape_t * new_custom_shape(int id) { ...@@ -217,7 +217,7 @@ custom_shape_t * new_custom_shape(int id) {
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
} }
if (insert_param(param, custom_shape->param_tree) < 0) { if (insert_param(param, custom_shape->param_tree) < 0) {
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
...@@ -322,7 +322,7 @@ custom_shape_t * new_custom_shape(int id) { ...@@ -322,7 +322,7 @@ custom_shape_t * new_custom_shape(int id) {
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
} }
if ((param = new_param_double("tex_ang", P_FLAG_NONE, &custom_shape->tex_ang, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL) { if ((param = new_param_double("tex_ang", P_FLAG_NONE, &custom_shape->tex_ang, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL) {
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
...@@ -409,7 +409,7 @@ custom_shape_t * new_custom_shape(int id) { ...@@ -409,7 +409,7 @@ custom_shape_t * new_custom_shape(int id) {
} }
/* End of parameter loading. Note that the read only parameters associated /* End of parameter loading. Note that the read only parameters associated
with custom shapes (ie, sample) are global variables, and not specific to with custom shapes (ie, sample) are global variables, and not specific to
the custom shape datastructure. */ the custom shape datastructure. */
...@@ -475,7 +475,7 @@ void free_custom_shape(custom_shape_t * custom_shape) { ...@@ -475,7 +475,7 @@ void free_custom_shape(custom_shape_t * custom_shape) {
destroy_init_cond_tree_shape(custom_shape->init_cond_tree); destroy_init_cond_tree_shape(custom_shape->init_cond_tree);
destroy_param_db_tree_shape(custom_shape->param_tree); destroy_param_db_tree_shape(custom_shape->param_tree);
destroy_per_frame_init_eqn_tree_shape(custom_shape->per_frame_init_eqn_tree); destroy_per_frame_init_eqn_tree_shape(custom_shape->per_frame_init_eqn_tree);
free(custom_shape); free(custom_shape);
return; return;
...@@ -489,32 +489,32 @@ custom_shape_t * find_custom_shape(int id, preset_t * preset, int create_flag) { ...@@ -489,32 +489,32 @@ custom_shape_t * find_custom_shape(int id, preset_t * preset, int create_flag) {
if (preset == NULL) if (preset == NULL)
return NULL; return NULL;
if ((custom_shape = splay_find(&id, preset->custom_shape_tree)) == NULL) { if ((custom_shape = splay_find(&id, preset->custom_shape_tree)) == NULL) {
if (CUSTOM_SHAPE_DEBUG) { printf("find_custom_shape: creating custom shape (id = %d)...", id);fflush(stdout);} if (CUSTOM_SHAPE_DEBUG) { printf("find_custom_shape: creating custom shape (id = %d)...", id);fflush(stdout);}
if (create_flag == FALSE) { if (create_flag == FALSE) {
if (CUSTOM_SHAPE_DEBUG) printf("you specified not to (create flag = false), returning null\n"); if (CUSTOM_SHAPE_DEBUG) printf("you specified not to (create flag = false), returning null\n");
return NULL; return NULL;
} }
if ((custom_shape = new_custom_shape(id)) == NULL) { if ((custom_shape = new_custom_shape(id)) == NULL) {
if (CUSTOM_SHAPE_DEBUG) printf("failed...out of memory?\n"); if (CUSTOM_SHAPE_DEBUG) printf("failed...out of memory?\n");
return NULL; return NULL;
} }
if (CUSTOM_SHAPE_DEBUG) { printf("success.Inserting..."); fflush(stdout);} if (CUSTOM_SHAPE_DEBUG) { printf("success.Inserting..."); fflush(stdout);}
if (splay_insert(custom_shape, &custom_shape->id, preset->custom_shape_tree) < 0) { if (splay_insert(custom_shape, &custom_shape->id, preset->custom_shape_tree) < 0) {
if (CUSTOM_SHAPE_DEBUG) printf("failed, probably a duplicated!!\n"); if (CUSTOM_SHAPE_DEBUG) printf("failed, probably a duplicated!!\n");
free_custom_shape(custom_shape); free_custom_shape(custom_shape);
return NULL; return NULL;
} }
if (CUSTOM_SHAPE_DEBUG) printf("done.\n"); if (CUSTOM_SHAPE_DEBUG) printf("done.\n");
} }
return custom_shape; return custom_shape;
} }
...@@ -555,14 +555,14 @@ void load_unspec_init_cond_shape(param_t * param) { ...@@ -555,14 +555,14 @@ void load_unspec_init_cond_shape(param_t * param) {
/* If initial condition was not defined by the preset file, force a default one /* If initial condition was not defined by the preset file, force a default one
with the following code */ with the following code */
if ((init_cond = splay_find(param->name, interface_shape->init_cond_tree)) == NULL) { if ((init_cond = splay_find(param->name, interface_shape->init_cond_tree)) == NULL) {
/* Make sure initial condition does not exist in the set of per frame initial equations */ /* Make sure initial condition does not exist in the set of per frame initial equations */
if ((init_cond = splay_find(param->name, interface_shape->per_frame_init_eqn_tree)) != NULL) if ((init_cond = splay_find(param->name, interface_shape->per_frame_init_eqn_tree)) != NULL)
return; return;
if (param->type == P_TYPE_BOOL) if (param->type == P_TYPE_BOOL)
init_val.bool_val = 0; init_val.bool_val = 0;
else if (param->type == P_TYPE_INT) else if (param->type == P_TYPE_INT)
init_val.int_val = *(int*)param->engine_val; init_val.int_val = *(int*)param->engine_val;
...@@ -573,13 +573,13 @@ void load_unspec_init_cond_shape(param_t * param) { ...@@ -573,13 +573,13 @@ void load_unspec_init_cond_shape(param_t * param) {
/* Create new initial condition */ /* Create new initial condition */
if ((init_cond = new_init_cond(param, init_val)) == NULL) if ((init_cond = new_init_cond(param, init_val)) == NULL)
return; return;
/* Insert the initial condition into this presets tree */ /* Insert the initial condition into this presets tree */
if (splay_insert(init_cond, init_cond->param->name, interface_shape->init_cond_tree) < 0) { if (splay_insert(init_cond, init_cond->param->name, interface_shape->init_cond_tree) < 0) {
free_init_cond(init_cond); free_init_cond(init_cond);
return; return;
} }
} }
} }
......
...@@ -23,7 +23,7 @@ typedef struct CUSTOM_SHAPE_T { ...@@ -23,7 +23,7 @@ typedef struct CUSTOM_SHAPE_T {
double tex_zoom; double tex_zoom;
double tex_ang; double tex_ang;
double x; /* x position for per point equations */ double x; /* x position for per point equations */
double y; /* y position for per point equations */ double y; /* y position for per point equations */
double rad; double rad;
...@@ -67,8 +67,8 @@ typedef struct CUSTOM_SHAPE_T { ...@@ -67,8 +67,8 @@ typedef struct CUSTOM_SHAPE_T {
char per_frame_eqn_string_buffer[STRING_BUFFER_SIZE]; char per_frame_eqn_string_buffer[STRING_BUFFER_SIZE];
char per_frame_init_eqn_string_buffer[STRING_BUFFER_SIZE]; char per_frame_init_eqn_string_buffer[STRING_BUFFER_SIZE];
/* Per point equation array */ /* Per point equation array */
} custom_shape_t; } custom_shape_t;
......
...@@ -72,7 +72,7 @@ custom_wave_t * new_custom_wave(int id) { ...@@ -72,7 +72,7 @@ custom_wave_t * new_custom_wave(int id) {
custom_wave_t * custom_wave; custom_wave_t * custom_wave;
param_t * param; param_t * param;
if ((custom_wave = (custom_wave_t*)malloc(sizeof(custom_wave_t))) == NULL) if ((custom_wave = (custom_wave_t*)malloc(sizeof(custom_wave_t))) == NULL)
return NULL; return NULL;
...@@ -103,38 +103,38 @@ custom_wave_t * new_custom_wave(int id) { ...@@ -103,38 +103,38 @@ custom_wave_t * new_custom_wave(int id) {
custom_wave->sample_mesh = malloc(MAX_SAMPLE_SIZE*sizeof(double)); custom_wave->sample_mesh = malloc(MAX_SAMPLE_SIZE*sizeof(double));
/* Initialize tree data structures */ /* Initialize tree data structures */
if ((custom_wave->param_tree = if ((custom_wave->param_tree =
create_splaytree(compare_string, copy_string, free_string)) == NULL) { create_splaytree(compare_string, copy_string, free_string)) == NULL) {
free_custom_wave(custom_wave); free_custom_wave(custom_wave);
return NULL; return NULL;
} }
if ((custom_wave->per_point_eqn_tree = if ((custom_wave->per_point_eqn_tree =
create_splaytree(compare_int, copy_int, free_int)) == NULL) { create_splaytree(compare_int, copy_int, free_int)) == NULL) {
free_custom_wave(custom_wave); free_custom_wave(custom_wave);
return NULL; return NULL;
} }
if ((custom_wave->per_frame_eqn_tree = if ((custom_wave->per_frame_eqn_tree =
create_splaytree(compare_int, copy_int, free_int)) == NULL) { create_splaytree(compare_int, copy_int, free_int)) == NULL) {
free_custom_wave(custom_wave); free_custom_wave(custom_wave);
return NULL; return NULL;
} }
if ((custom_wave->init_cond_tree = if ((custom_wave->init_cond_tree =
create_splaytree(compare_string, copy_string, free_string)) == NULL) { create_splaytree(compare_string, copy_string, free_string)) == NULL) {
free_custom_wave(custom_wave); free_custom_wave(custom_wave);
return NULL; return NULL;
} }
if ((custom_wave->per_frame_init_eqn_tree = if ((custom_wave->per_frame_init_eqn_tree =
create_splaytree(compare_string, copy_string, free_string)) == NULL) { create_splaytree(compare_string, copy_string, free_string)) == NULL) {
free_custom_wave(custom_wave); free_custom_wave(custom_wave);
return NULL; return NULL;
} }
/* Start: Load custom wave parameters */ /* Start: Load custom wave parameters */
if ((param = new_param_double("r", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &custom_wave->r, custom_wave->r_mesh, 1.0, 0.0, .5)) == NULL) { if ((param = new_param_double("r", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &custom_wave->r, custom_wave->r_mesh, 1.0, 0.0, .5)) == NULL) {
...@@ -159,7 +159,7 @@ custom_wave_t * new_custom_wave(int id) { ...@@ -159,7 +159,7 @@ custom_wave_t * new_custom_wave(int id) {
if ((param = new_param_double("b", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &custom_wave->b, custom_wave->b_mesh, 1.0, 0.0, .5)) == NULL){ if ((param = new_param_double("b", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &custom_wave->b, custom_wave->b_mesh, 1.0, 0.0, .5)) == NULL){
free_custom_wave(custom_wave); free_custom_wave(custom_wave);
return NULL; return NULL;
} }
if (insert_param(param, custom_wave->param_tree) < 0) { if (insert_param(param, custom_wave->param_tree) < 0) {
...@@ -171,7 +171,7 @@ custom_wave_t * new_custom_wave(int id) { ...@@ -171,7 +171,7 @@ custom_wave_t * new_custom_wave(int id) {
free_custom_wave(custom_wave); free_custom_wave(custom_wave);
return NULL; return NULL;
} }
if (insert_param(param, custom_wave->param_tree) < 0) { if (insert_param(param, custom_wave->param_tree) < 0) {
free_custom_wave(custom_wave); free_custom_wave(custom_wave);
return NULL; return NULL;
...@@ -268,7 +268,7 @@ custom_wave_t * new_custom_wave(int id) { ...@@ -268,7 +268,7 @@ custom_wave_t * new_custom_wave(int id) {
} }
if ((param = new_param_double("sample", P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX | P_FLAG_ALWAYS_MATRIX | P_FLAG_PER_POINT, if ((param = new_param_double("sample", P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX | P_FLAG_ALWAYS_MATRIX | P_FLAG_PER_POINT,
&custom_wave->sample, custom_wave->sample_mesh, 1.0, 0.0, 0.0)) == NULL) { &custom_wave->sample, custom_wave->sample_mesh, 1.0, 0.0, 0.0)) == NULL) {
free_custom_wave(custom_wave); free_custom_wave(custom_wave);
return NULL; return NULL;
} }
...@@ -394,9 +394,9 @@ custom_wave_t * new_custom_wave(int id) { ...@@ -394,9 +394,9 @@ custom_wave_t * new_custom_wave(int id) {
free_custom_wave(custom_wave); free_custom_wave(custom_wave);
return NULL; return NULL;
} }
/* End of parameter loading. Note that the read only parameters associated /* End of parameter loading. Note that the read only parameters associated
with custom waves (ie, sample) are global variables, and not specific to with custom waves (ie, sample) are global variables, and not specific to
the custom wave datastructure. */ the custom wave datastructure. */
...@@ -498,12 +498,12 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom ...@@ -498,12 +498,12 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom
/* Argument checks */ /* Argument checks */
if (custom_wave == NULL) if (custom_wave == NULL)
return FAILURE; return FAILURE;
if (gen_expr == NULL) if (gen_expr == NULL)
return FAILURE; return FAILURE;
if (name == NULL) if (name == NULL)
return FAILURE; return FAILURE;
if (CUSTOM_WAVE_DEBUG) printf("add_per_point_eqn: per pixel equation (name = \"%s\")\n", name); if (CUSTOM_WAVE_DEBUG) printf("add_per_point_eqn: per pixel equation (name = \"%s\")\n", name);
/* Search for the parameter so we know what matrix the per pixel equation is referencing */ /* Search for the parameter so we know what matrix the per pixel equation is referencing */
...@@ -512,7 +512,7 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom ...@@ -512,7 +512,7 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom
if (CUSTOM_WAVE_DEBUG) printf("add_per_point_eqn: failed to allocate a new parameter!\n"); if (CUSTOM_WAVE_DEBUG) printf("add_per_point_eqn: failed to allocate a new parameter!\n");
return FAILURE; return FAILURE;
} }
/* Find most largest index in the splaytree */ /* Find most largest index in the splaytree */
if ((per_point_eqn = splay_find_max(custom_wave->per_point_eqn_tree)) == NULL) if ((per_point_eqn = splay_find_max(custom_wave->per_point_eqn_tree)) == NULL)
...@@ -522,49 +522,49 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom ...@@ -522,49 +522,49 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom
/* Create the per pixel equation given the index, parameter, and general expression */ /* Create the per pixel equation given the index, parameter, and general expression */
if ((per_point_eqn = new_per_point_eqn(index, param, gen_expr)) == NULL) if ((per_point_eqn = new_per_point_eqn(index, param, gen_expr)) == NULL)
return FAILURE; return FAILURE;
if (CUSTOM_WAVE_DEBUG) if (CUSTOM_WAVE_DEBUG)
printf("add_per_point_eqn: created new equation (index = %d) (name = \"%s\")\n", per_point_eqn->index, per_point_eqn->param->name); printf("add_per_point_eqn: created new equation (index = %d) (name = \"%s\")\n", per_point_eqn->index, per_point_eqn->param->name);
/* Insert the per pixel equation into the preset per pixel database */ /* Insert the per pixel equation into the preset per pixel database */
if (splay_insert(per_point_eqn, &per_point_eqn->index, custom_wave->per_point_eqn_tree) < 0) { if (splay_insert(per_point_eqn, &per_point_eqn->index, custom_wave->per_point_eqn_tree) < 0) {
free_per_point_eqn(per_point_eqn); free_per_point_eqn(per_point_eqn);
return FAILURE; return FAILURE;
} }
/* Done */ /* Done */
return SUCCESS; return SUCCESS;
} }
per_point_eqn_t * new_per_point_eqn(int index, param_t * param, gen_expr_t * gen_expr) { per_point_eqn_t * new_per_point_eqn(int index, param_t * param, gen_expr_t * gen_expr) {
per_point_eqn_t * per_point_eqn; per_point_eqn_t * per_point_eqn;
if (param == NULL) if (param == NULL)
return NULL; return NULL;
if (gen_expr == NULL) if (gen_expr == NULL)
return NULL; return NULL;
if ((per_point_eqn = (per_point_eqn_t*)malloc(sizeof(per_point_eqn_t))) == NULL) if ((per_point_eqn = (per_point_eqn_t*)malloc(sizeof(per_point_eqn_t))) == NULL)
return NULL; return NULL;
per_point_eqn->index = index; per_point_eqn->index = index;
per_point_eqn->gen_expr = gen_expr; per_point_eqn->gen_expr = gen_expr;
per_point_eqn->param = param; per_point_eqn->param = param;
return per_point_eqn; return per_point_eqn;
} }
void free_per_point_eqn(per_point_eqn_t * per_point_eqn) { void free_per_point_eqn(per_point_eqn_t * per_point_eqn) {
if (per_point_eqn == NULL) if (per_point_eqn == NULL)
return; return;
free_gen_expr(per_point_eqn->gen_expr); free_gen_expr(per_point_eqn->gen_expr);
free(per_point_eqn); free(per_point_eqn);
return; return;
} }
custom_wave_t * find_custom_wave(int id, preset_t * preset, int create_flag) { custom_wave_t * find_custom_wave(int id, preset_t * preset, int create_flag) {
...@@ -573,7 +573,7 @@ custom_wave_t * find_custom_wave(int id, preset_t * preset, int create_flag) { ...@@ -573,7 +573,7 @@ custom_wave_t * find_custom_wave(int id, preset_t * preset, int create_flag) {
if (preset == NULL) if (preset == NULL)
return NULL; return NULL;
if ((custom_wave = splay_find(&id, preset->custom_wave_tree)) == NULL) { if ((custom_wave = splay_find(&id, preset->custom_wave_tree)) == NULL) {
if (CUSTOM_WAVE_DEBUG) { printf("find_custom_wave: creating custom wave (id = %d)...", id);fflush(stdout);} if (CUSTOM_WAVE_DEBUG) { printf("find_custom_wave: creating custom wave (id = %d)...", id);fflush(stdout);}
...@@ -628,7 +628,7 @@ inline custom_wave_t * nextCustomWave() { ...@@ -628,7 +628,7 @@ inline custom_wave_t * nextCustomWave() {
} }
inline void evalPerPointEqns() { inline void evalPerPointEqns() {
int x; int x;
...@@ -655,8 +655,8 @@ inline void evalPerPointEqns() { ...@@ -655,8 +655,8 @@ inline void evalPerPointEqns() {
/* Evaluates a per point equation for the current custom wave given by interface_wave ptr */ /* Evaluates a per point equation for the current custom wave given by interface_wave ptr */
inline void evalPerPointEqn(per_point_eqn_t * per_point_eqn) { inline void evalPerPointEqn(per_point_eqn_t * per_point_eqn) {
int samples, size; int samples, size;
double * param_matrix; double * param_matrix;
gen_expr_t * eqn_ptr; gen_expr_t * eqn_ptr;
...@@ -669,17 +669,17 @@ inline void evalPerPointEqn(per_point_eqn_t * per_point_eqn) { ...@@ -669,17 +669,17 @@ inline void evalPerPointEqn(per_point_eqn_t * per_point_eqn) {
return; return;
memset(param_matrix, 0, size); memset(param_matrix, 0, size);
} }
else else
param_matrix = (double*)per_point_eqn->param->matrix; param_matrix = (double*)per_point_eqn->param->matrix;
for (mesh_i = 0; mesh_i < samples; mesh_i++) { for (mesh_i = 0; mesh_i < samples; mesh_i++) {
param_matrix[mesh_i] = eval_gen_expr(eqn_ptr); param_matrix[mesh_i] = eval_gen_expr(eqn_ptr);
} }
/* Now that this parameter has been referenced with a per /* Now that this parameter has been referenced with a per
point equation, we let the evaluator know by setting point equation, we let the evaluator know by setting
this flag */ this flag */
per_point_eqn->param->matrix_flag = 1; per_point_eqn->param->matrix_flag = 1;
} }
...@@ -710,14 +710,14 @@ void load_unspec_init_cond(param_t * param) { ...@@ -710,14 +710,14 @@ void load_unspec_init_cond(param_t * param) {
/* If initial condition was not defined by the preset file, force a default one /* If initial condition was not defined by the preset file, force a default one
with the following code */ with the following code */
if ((init_cond = splay_find(param->name, interface_wave->init_cond_tree)) == NULL) { if ((init_cond = splay_find(param->name, interface_wave->init_cond_tree)) == NULL) {
/* Make sure initial condition does not exist in the set of per frame initial equations */ /* Make sure initial condition does not exist in the set of per frame initial equations */
if ((init_cond = splay_find(param->name, interface_wave->per_frame_init_eqn_tree)) != NULL) if ((init_cond = splay_find(param->name, interface_wave->per_frame_init_eqn_tree)) != NULL)
return; return;
if (param->type == P_TYPE_BOOL) if (param->type == P_TYPE_BOOL)
init_val.bool_val = 0; init_val.bool_val = 0;
else if (param->type == P_TYPE_INT) else if (param->type == P_TYPE_INT)
init_val.int_val = *(int*)param->engine_val; init_val.int_val = *(int*)param->engine_val;
...@@ -728,13 +728,13 @@ void load_unspec_init_cond(param_t * param) { ...@@ -728,13 +728,13 @@ void load_unspec_init_cond(param_t * param) {
/* Create new initial condition */ /* Create new initial condition */
if ((init_cond = new_init_cond(param, init_val)) == NULL) if ((init_cond = new_init_cond(param, init_val)) == NULL)
return; return;
/* Insert the initial condition into this presets tree */ /* Insert the initial condition into this presets tree */
if (splay_insert(init_cond, init_cond->param->name, interface_wave->init_cond_tree) < 0) { if (splay_insert(init_cond, init_cond->param->name, interface_wave->init_cond_tree) < 0) {
free_init_cond(init_cond); free_init_cond(init_cond);
return; return;
} }
} }
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
typedef struct PER_POINT_EQN_T { typedef struct PER_POINT_EQN_T {
int index; int index;
param_t * param; param_t * param;
gen_expr_t * gen_expr; gen_expr_t * gen_expr;
} per_point_eqn_t; } per_point_eqn_t;
typedef struct CUSTOM_WAVE_T { typedef struct CUSTOM_WAVE_T {
...@@ -85,7 +85,7 @@ typedef struct CUSTOM_WAVE_T { ...@@ -85,7 +85,7 @@ typedef struct CUSTOM_WAVE_T {
char per_frame_init_eqn_string_buffer[STRING_BUFFER_SIZE]; char per_frame_init_eqn_string_buffer[STRING_BUFFER_SIZE];
/* Per point equation array */ /* Per point equation array */
gen_expr_t * per_point_eqn_array[NUM_POINT_OPS]; gen_expr_t * per_point_eqn_array[NUM_POINT_OPS];
} custom_wave_t; } custom_wave_t;
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
double mv_y = 12.0; double mv_y = 12.0;
double mv_dy = 0.02; double mv_dy = 0.02;
double mv_dx = 0.02; double mv_dx = 0.02;
int meshx = 0; int meshx = 0;
int meshy = 0; int meshy = 0;
......
...@@ -96,7 +96,7 @@ extern int bDarken; ...@@ -96,7 +96,7 @@ extern int bDarken;
extern int bSolarize; extern int bSolarize;
extern int bInvert; extern int bInvert;
extern int bMotionVectorsOn; extern int bMotionVectorsOn;
extern int fps; extern int fps;
extern double fWaveAlpha ; extern double fWaveAlpha ;
extern double fWaveScale; extern double fWaveScale;
......
This diff is collapsed.
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define INFIX_OR 5 #define INFIX_OR 5
#define INFIX_AND 6 #define INFIX_AND 6
//#define EVAL_DEBUG //#define EVAL_DEBUG
inline double eval_gen_expr(gen_expr_t * gen_expr); inline double eval_gen_expr(gen_expr_t * gen_expr);
......
...@@ -25,7 +25,7 @@ typedef struct VAL_EXPR_T { ...@@ -25,7 +25,7 @@ typedef struct VAL_EXPR_T {
/* Infix Operator Function */ /* Infix Operator Function */
typedef struct INFIX_OP_T { typedef struct INFIX_OP_T {
int type; int type;
int precedence; int precedence;
} infix_op_t; } infix_op_t;
/* A binary expression tree ordered by operator precedence */ /* A binary expression tree ordered by operator precedence */
......
This diff is collapsed.
...@@ -24,16 +24,16 @@ void * copy_func_key(char * string); ...@@ -24,16 +24,16 @@ void * copy_func_key(char * string);
void * copy_func_key(char * string) { void * copy_func_key(char * string) {
char * clone_string; char * clone_string;
if ((clone_string = malloc(MAX_TOKEN_SIZE)) == NULL) if ((clone_string = malloc(MAX_TOKEN_SIZE)) == NULL)
return NULL; return NULL;
strncpy(clone_string, string, MAX_TOKEN_SIZE-1); strncpy(clone_string, string, MAX_TOKEN_SIZE-1);
return (void*)clone_string; return (void*)clone_string;
} }
func_t * create_func (char * name, double (*func_ptr)(), int num_args) { func_t * create_func (char * name, double (*func_ptr)(), int num_args) {
...@@ -44,12 +44,12 @@ func_t * create_func (char * name, double (*func_ptr)(), int num_args) { ...@@ -44,12 +44,12 @@ func_t * create_func (char * name, double (*func_ptr)(), int num_args) {
if (func == NULL) if (func == NULL)
return NULL; return NULL;
/* Clear name space */ /* Clear name space */
memset(func->name, 0, MAX_TOKEN_SIZE); memset(func->name, 0, MAX_TOKEN_SIZE);
/* Copy given name into function structure */ /* Copy given name into function structure */
strncpy(func->name, name, MAX_TOKEN_SIZE); strncpy(func->name, name, MAX_TOKEN_SIZE);
/* Assign value pointer */ /* Assign value pointer */
func->func_ptr = func_ptr; func->func_ptr = func_ptr;
...@@ -118,7 +118,7 @@ func_t * find_func(char * name) { ...@@ -118,7 +118,7 @@ func_t * find_func(char * name) {
/* First look in the builtin database */ /* First look in the builtin database */
func = (func_t *)splay_find(name, builtin_func_tree); func = (func_t *)splay_find(name, builtin_func_tree);
return func; return func;
} }
...@@ -130,15 +130,15 @@ int compare_func(char * name, char * name2) { ...@@ -130,15 +130,15 @@ int compare_func(char * name, char * name2) {
/* Uses string comparison function */ /* Uses string comparison function */
cmpval = strncmp(name, name2, MAX_TOKEN_SIZE-1); cmpval = strncmp(name, name2, MAX_TOKEN_SIZE-1);
return cmpval; return cmpval;
} }
/* Loads a builtin function */ /* Loads a builtin function */
int load_builtin_func(char * name, double (*func_ptr)(), int num_args) { int load_builtin_func(char * name, double (*func_ptr)(), int num_args) {
func_t * func; func_t * func;
int retval; int retval;
/* Create new function */ /* Create new function */
func = create_func(name, func_ptr, num_args); func = create_func(name, func_ptr, num_args);
...@@ -155,7 +155,7 @@ int load_builtin_func(char * name, double (*func_ptr)(), int num_args) { ...@@ -155,7 +155,7 @@ int load_builtin_func(char * name, double (*func_ptr)(), int num_args) {
/* Loads all builtin functions */ /* Loads all builtin functions */
int load_all_builtin_func() { int load_all_builtin_func() {
if (load_builtin_func("int", int_wrapper, 1) < 0) if (load_builtin_func("int", int_wrapper, 1) < 0)
return ERROR; return ERROR;
if (load_builtin_func("abs", abs_wrapper, 1) < 0) if (load_builtin_func("abs", abs_wrapper, 1) < 0)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* Function Type */ /* Function Type */
typedef struct FUNC_T { typedef struct FUNC_T {
char name[MAX_TOKEN_SIZE]; char name[MAX_TOKEN_SIZE];
double (*func_ptr)(); double (*func_ptr)();
int num_args; int num_args;
} func_t; } func_t;
......
...@@ -57,28 +57,28 @@ void eval_init_cond(init_cond_t * init_cond) { ...@@ -57,28 +57,28 @@ void eval_init_cond(init_cond_t * init_cond) {
/* Parameter is of boolean type, either a 1 or 0 value integer */ /* Parameter is of boolean type, either a 1 or 0 value integer */
/* Set matrix flag to zero. This ensures /* Set matrix flag to zero. This ensures
its constant value will be used rather than a matrix value its constant value will be used rather than a matrix value
*/ */
init_cond->param->matrix_flag = 0; init_cond->param->matrix_flag = 0;
if (init_cond->param->type == P_TYPE_BOOL) { if (init_cond->param->type == P_TYPE_BOOL) {
if (INIT_COND_DEBUG) printf("init_cond: %s = %d (TYPE BOOL)\n", init_cond->param->name, init_cond->init_val.bool_val); if (INIT_COND_DEBUG) printf("init_cond: %s = %d (TYPE BOOL)\n", init_cond->param->name, init_cond->init_val.bool_val);
*((int*)init_cond->param->engine_val) = init_cond->init_val.bool_val; *((int*)init_cond->param->engine_val) = init_cond->init_val.bool_val;
return; return;
} }
/* Parameter is an integer type, just like C */ /* Parameter is an integer type, just like C */
if (init_cond->param->type == P_TYPE_INT) { if (init_cond->param->type == P_TYPE_INT) {
if (INIT_COND_DEBUG) printf("init_cond: %s = %d (TYPE INT)\n", init_cond->param->name, init_cond->init_val.int_val); if (INIT_COND_DEBUG) printf("init_cond: %s = %d (TYPE INT)\n", init_cond->param->name, init_cond->init_val.int_val);
*((int*)init_cond->param->engine_val) = init_cond->init_val.int_val; *((int*)init_cond->param->engine_val) = init_cond->init_val.int_val;
return; return;
} }
/* Parameter is of a double type, just like C */ /* Parameter is of a double type, just like C */
if (init_cond->param->type == P_TYPE_DOUBLE) { if (init_cond->param->type == P_TYPE_DOUBLE) {
if (INIT_COND_DEBUG) printf("init_cond: %s = %f (TYPE DOUBLE)\n", init_cond->param->name, init_cond->init_val.double_val); if (INIT_COND_DEBUG) printf("init_cond: %s = %f (TYPE DOUBLE)\n", init_cond->param->name, init_cond->init_val.double_val);
*((double*)init_cond->param->engine_val) = init_cond->init_val.double_val; *((double*)init_cond->param->engine_val) = init_cond->init_val.double_val;
return; return;
} }
...@@ -92,7 +92,7 @@ init_cond_t * new_init_cond(param_t * param, value_t init_val) { ...@@ -92,7 +92,7 @@ init_cond_t * new_init_cond(param_t * param, value_t init_val) {
init_cond_t * init_cond; init_cond_t * init_cond;
init_cond = (init_cond_t*)malloc(sizeof(init_cond_t)); init_cond = (init_cond_t*)malloc(sizeof(init_cond_t));
if (init_cond == NULL) if (init_cond == NULL)
return NULL; return NULL;
...@@ -103,59 +103,59 @@ init_cond_t * new_init_cond(param_t * param, value_t init_val) { ...@@ -103,59 +103,59 @@ init_cond_t * new_init_cond(param_t * param, value_t init_val) {
/* WIP */ /* WIP */
void init_cond_to_string(init_cond_t * init_cond) { void init_cond_to_string(init_cond_t * init_cond) {
int string_length; int string_length;
char string[MAX_TOKEN_SIZE]; char string[MAX_TOKEN_SIZE];
if (init_cond == NULL) if (init_cond == NULL)
return; return;
/* Create a string "param_name=val" */ /* Create a string "param_name=val" */
switch (init_cond->param->type) { switch (init_cond->param->type) {
lldiv_t div; lldiv_t div;
case P_TYPE_BOOL: case P_TYPE_BOOL:
sprintf(string, "%s=%d\n", init_cond->param->name, init_cond->init_val.bool_val); sprintf(string, "%s=%d\n", init_cond->param->name, init_cond->init_val.bool_val);
break; break;
case P_TYPE_INT: case P_TYPE_INT:
sprintf(string, "%s=%d\n", init_cond->param->name, init_cond->init_val.int_val); sprintf(string, "%s=%d\n", init_cond->param->name, init_cond->init_val.int_val);
break; break;
case P_TYPE_DOUBLE: case P_TYPE_DOUBLE:
div = lldiv( init_cond->init_val.double_val * 1000000, div = lldiv( init_cond->init_val.double_val * 1000000,
1000000 ); 1000000 );
sprintf(string, "%s="I64Fd".%06u\n", init_cond->param->name, div.quot, (unsigned int) div.rem ); sprintf(string, "%s="I64Fd".%06u\n", init_cond->param->name, div.quot, (unsigned int) div.rem );
break; break;
default: default:
return; return;
} }
/* Compute the length of the string */ /* Compute the length of the string */
string_length = strlen(string); string_length = strlen(string);
/* Buffer overflow check */ /* Buffer overflow check */
if ((init_cond_string_buffer_index + string_length + 1) > (STRING_BUFFER_SIZE - 1)) if ((init_cond_string_buffer_index + string_length + 1) > (STRING_BUFFER_SIZE - 1))
return; return;
/* Copy the string into the initial condition string buffer */ /* Copy the string into the initial condition string buffer */
strncpy(init_cond_string_buffer + init_cond_string_buffer_index, string, string_length); strncpy(init_cond_string_buffer + init_cond_string_buffer_index, string, string_length);
/* Increment the string buffer, offset by one for the null terminator, which will be /* Increment the string buffer, offset by one for the null terminator, which will be
overwritten by the next call to this function */ overwritten by the next call to this function */
init_cond_string_buffer_index+= string_length + 1; init_cond_string_buffer_index+= string_length + 1;
} }
char * create_init_cond_string_buffer(splaytree_t * init_cond_tree) { char * create_init_cond_string_buffer(splaytree_t * init_cond_tree) {
if (init_cond_tree == NULL) if (init_cond_tree == NULL)
return NULL; return NULL;
init_cond_string_buffer_index = 0; init_cond_string_buffer_index = 0;
splay_traverse(init_cond_to_string, init_cond_tree); splay_traverse(init_cond_to_string, init_cond_tree);
return init_cond_string_buffer; return init_cond_string_buffer;
} }
This diff is collapsed.
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
/* Function prototypes */ /* Function prototypes */
param_t * create_param (char * name, short int type, short int flags, void * eqn_val, void * matrix, param_t * create_param (char * name, short int type, short int flags, void * eqn_val, void * matrix,
value_t default_init_val, value_t upper_bound, value_t lower_bound); value_t default_init_val, value_t upper_bound, value_t lower_bound);
param_t * create_user_param(char * name); param_t * create_user_param(char * name);
int init_builtin_param_db(); int init_builtin_param_db();
int init_user_param_db(); int init_user_param_db();
...@@ -23,13 +23,13 @@ int load_all_builtin_param(); ...@@ -23,13 +23,13 @@ int load_all_builtin_param();
int insert_param(param_t * param, splaytree_t * database); int insert_param(param_t * param, splaytree_t * database);
param_t * find_builtin_param(char * name); param_t * find_builtin_param(char * name);
param_t * new_param_double(char * name, short int flags, void * engine_val, void * matrix, param_t * new_param_double(char * name, short int flags, void * engine_val, void * matrix,
double upper_bound, double lower_bound, double init_val); double upper_bound, double lower_bound, double init_val);
param_t * new_param_int(char * name, short int flags, void * engine_val, param_t * new_param_int(char * name, short int flags, void * engine_val,
int upper_bound, int lower_bound, int init_val); int upper_bound, int lower_bound, int init_val);
param_t * new_param_bool(char * name, short int flags, void * engine_val, param_t * new_param_bool(char * name, short int flags, void * engine_val,
int upper_bound, int lower_bound, int init_val); int upper_bound, int lower_bound, int init_val);
param_t * find_param_db(char * name, splaytree_t * database, int create_flag); param_t * find_param_db(char * name, splaytree_t * database, int create_flag);
......
...@@ -21,14 +21,14 @@ ...@@ -21,14 +21,14 @@
typedef union VALUE_T { typedef union VALUE_T {
int bool_val; int bool_val;
int int_val; int int_val;
double double_val; double double_val;
} value_t; } value_t;
/* Parameter Type */ /* Parameter Type */
typedef struct PARAM_T { typedef struct PARAM_T {
char name[MAX_TOKEN_SIZE]; /* name of the parameter, not necessary but useful neverthless */ char name[MAX_TOKEN_SIZE]; /* name of the parameter, not necessary but useful neverthless */
short int type; /* parameter number type (int, bool, or double) */ short int type; /* parameter number type (int, bool, or double) */
short int flags; /* read, write, user defined, etc */ short int flags; /* read, write, user defined, etc */
short int matrix_flag; /* for optimization purposes */ short int matrix_flag; /* for optimization purposes */
void * engine_val; /* pointer to the engine variable */ void * engine_val; /* pointer to the engine variable */
void * matrix; /* per pixel / per point matrix for this variable */ void * matrix; /* per pixel / per point matrix for this variable */
......
This diff is collapsed.
...@@ -39,15 +39,15 @@ void eval_per_frame_eqn(per_frame_eqn_t * per_frame_eqn) { ...@@ -39,15 +39,15 @@ void eval_per_frame_eqn(per_frame_eqn_t * per_frame_eqn) {
if (per_frame_eqn == NULL) if (per_frame_eqn == NULL)
return; return;
if (PER_FRAME_EQN_DEBUG) { if (PER_FRAME_EQN_DEBUG) {
printf("per_frame_%d=%s= ", per_frame_eqn->index, per_frame_eqn->param->name); printf("per_frame_%d=%s= ", per_frame_eqn->index, per_frame_eqn->param->name);
fflush(stdout); fflush(stdout);
} }
//*((double*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr); //*((double*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr);
set_param(per_frame_eqn->param, eval_gen_expr(per_frame_eqn->gen_expr)); set_param(per_frame_eqn->param, eval_gen_expr(per_frame_eqn->gen_expr));
if (PER_FRAME_EQN_DEBUG) printf(" = %.4f\n", *((double*)per_frame_eqn->param->engine_val)); if (PER_FRAME_EQN_DEBUG) printf(" = %.4f\n", *((double*)per_frame_eqn->param->engine_val));
} }
/* /*
...@@ -58,25 +58,25 @@ void eval_per_frame_init_eqn(per_frame_eqn_t * per_frame_eqn) { ...@@ -58,25 +58,25 @@ void eval_per_frame_init_eqn(per_frame_eqn_t * per_frame_eqn) {
if (per_frame_eqn == NULL) if (per_frame_eqn == NULL)
return; return;
if (PER_FRAME_EQN_DEBUG) { if (PER_FRAME_EQN_DEBUG) {
printf("per_frame_init: %s = ", per_frame_eqn->param->name); printf("per_frame_init: %s = ", per_frame_eqn->param->name);
fflush(stdout); fflush(stdout);
} }
val = *((double*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr); val = *((double*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr);
if (PER_FRAME_EQN_DEBUG) printf(" = %f\n", *((double*)per_frame_eqn->param->engine_val)); if (PER_FRAME_EQN_DEBUG) printf(" = %f\n", *((double*)per_frame_eqn->param->engine_val));
if (per_frame_eqn->param->flags & P_FLAG_QVAR) { if (per_frame_eqn->param->flags & P_FLAG_QVAR) {
per_frame_eqn->param->init_val.double_val = val; per_frame_eqn->param->init_val.double_val = val;
if ((init_cond = new_init_cond(per_frame_eqn->param)) == NULL) if ((init_cond = new_init_cond(per_frame_eqn->param)) == NULL)
return; return;
if ((list_append(init_cond_list, init_cond)) < 0) { if ((list_append(init_cond_list, init_cond)) < 0) {
free_init_cond(init_cond); free_init_cond(init_cond);
return; return;
} }
} }
} }
*/ */
...@@ -84,9 +84,9 @@ void eval_per_frame_init_eqn(per_frame_eqn_t * per_frame_eqn) { ...@@ -84,9 +84,9 @@ void eval_per_frame_init_eqn(per_frame_eqn_t * per_frame_eqn) {
/* Frees perframe equation structure */ /* Frees perframe equation structure */
void free_per_frame_eqn(per_frame_eqn_t * per_frame_eqn) { void free_per_frame_eqn(per_frame_eqn_t * per_frame_eqn) {
if (per_frame_eqn == NULL) if (per_frame_eqn == NULL)
return; return;
free_gen_expr(per_frame_eqn->gen_expr); free_gen_expr(per_frame_eqn->gen_expr);
free(per_frame_eqn); free(per_frame_eqn);
} }
......
...@@ -56,40 +56,40 @@ inline void evalPerPixelEqn(per_pixel_eqn_t * per_pixel_eqn) { ...@@ -56,40 +56,40 @@ inline void evalPerPixelEqn(per_pixel_eqn_t * per_pixel_eqn) {
gen_expr_t * eqn_ptr = NULL; gen_expr_t * eqn_ptr = NULL;
int x,y; int x,y;
eqn_ptr = per_pixel_eqn->gen_expr; eqn_ptr = per_pixel_eqn->gen_expr;
if (per_pixel_eqn->param->matrix == NULL) { if (per_pixel_eqn->param->matrix == NULL) {
if (PER_PIXEL_EQN_DEBUG) printf("evalPerPixelEqn: [begin initializing matrix] (index = %d) (name = %s)\n", if (PER_PIXEL_EQN_DEBUG) printf("evalPerPixelEqn: [begin initializing matrix] (index = %d) (name = %s)\n",
per_pixel_eqn->index, per_pixel_eqn->param->name); per_pixel_eqn->index, per_pixel_eqn->param->name);
param_matrix = per_pixel_eqn->param->matrix = (double**)malloc(gx*sizeof(double*)); param_matrix = per_pixel_eqn->param->matrix = (double**)malloc(gx*sizeof(double*));
for(x = 0; x < gx; x++) for(x = 0; x < gx; x++)
param_matrix[x] = (double *)malloc(gy * sizeof(double)); param_matrix[x] = (double *)malloc(gy * sizeof(double));
for (x = 0; x < gx; x++) for (x = 0; x < gx; x++)
for (y = 0; y < gy; y++) for (y = 0; y < gy; y++)
param_matrix[x][y] = 0.0; param_matrix[x][y] = 0.0;
if (per_pixel_eqn->param->name == NULL) if (per_pixel_eqn->param->name == NULL)
printf("null parameter?\n"); printf("null parameter?\n");
// printf("PARAM MATRIX: \"%s\" initialized.\n", per_pixel_eqn->param->name); // printf("PARAM MATRIX: \"%s\" initialized.\n", per_pixel_eqn->param->name);
} }
else else
param_matrix = (double**)per_pixel_eqn->param->matrix; param_matrix = (double**)per_pixel_eqn->param->matrix;
if (eqn_ptr == NULL) if (eqn_ptr == NULL)
printf("something is seriously wrong...\n"); printf("something is seriously wrong...\n");
for (mesh_i = 0; mesh_i < gx; mesh_i++) { for (mesh_i = 0; mesh_i < gx; mesh_i++) {
for (mesh_j = 0; mesh_j < gy; mesh_j++) { for (mesh_j = 0; mesh_j < gy; mesh_j++) {
param_matrix[mesh_i][mesh_j] = eval_gen_expr(eqn_ptr); param_matrix[mesh_i][mesh_j] = eval_gen_expr(eqn_ptr);
} }
} }
/* Now that this parameter has been referenced with a per /* Now that this parameter has been referenced with a per
pixel equation, we let the evaluator know by setting pixel equation, we let the evaluator know by setting
this flag */ this flag */
per_pixel_eqn->param->matrix_flag = 1; per_pixel_eqn->param->matrix_flag = 1;
} }
inline void evalPerPixelEqns() { inline void evalPerPixelEqns() {
...@@ -112,25 +112,25 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) { ...@@ -112,25 +112,25 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) {
/* Argument checks */ /* Argument checks */
if (preset == NULL) if (preset == NULL)
return FAILURE; return FAILURE;
if (gen_expr == NULL) if (gen_expr == NULL)
return FAILURE; return FAILURE;
if (name == NULL) if (name == NULL)
return FAILURE; return FAILURE;
if (PER_PIXEL_EQN_DEBUG) printf("add_per_pixel_eqn: per pixel equation (name = \"%s\")\n", name); if (PER_PIXEL_EQN_DEBUG) printf("add_per_pixel_eqn: per pixel equation (name = \"%s\")\n", name);
if (!strncmp(name, "dx", strlen("dx"))) if (!strncmp(name, "dx", strlen("dx")))
preset->per_pixel_flag[DX_OP] = TRUE; preset->per_pixel_flag[DX_OP] = TRUE;
else if (!strncmp(name, "dy", strlen("dy"))) else if (!strncmp(name, "dy", strlen("dy")))
preset->per_pixel_flag[DY_OP] = TRUE; preset->per_pixel_flag[DY_OP] = TRUE;
else if (!strncmp(name, "cx", strlen("cx"))) else if (!strncmp(name, "cx", strlen("cx")))
preset->per_pixel_flag[CX_OP] = TRUE; preset->per_pixel_flag[CX_OP] = TRUE;
else if (!strncmp(name, "cy", strlen("cy"))) else if (!strncmp(name, "cy", strlen("cy")))
preset->per_pixel_flag[CX_OP] = TRUE; preset->per_pixel_flag[CX_OP] = TRUE;
else if (!strncmp(name, "zoom", strlen("zoom"))) else if (!strncmp(name, "zoom", strlen("zoom")))
preset->per_pixel_flag[ZOOM_OP] = TRUE; preset->per_pixel_flag[ZOOM_OP] = TRUE;
else if (!strncmp(name, "zoomexp", strlen("zoomexp"))) else if (!strncmp(name, "zoomexp", strlen("zoomexp")))
preset->per_pixel_flag[ZOOMEXP_OP] = TRUE; preset->per_pixel_flag[ZOOMEXP_OP] = TRUE;
else if (!strncmp(name, "rot", strlen("rot"))) else if (!strncmp(name, "rot", strlen("rot")))
preset->per_pixel_flag[ROT_OP] = TRUE; preset->per_pixel_flag[ROT_OP] = TRUE;
...@@ -146,14 +146,14 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) { ...@@ -146,14 +146,14 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) {
if (PER_PIXEL_EQN_DEBUG) printf("add_per_pixel_eqn: failed to allocate a new parameter!\n"); if (PER_PIXEL_EQN_DEBUG) printf("add_per_pixel_eqn: failed to allocate a new parameter!\n");
return FAILURE; return FAILURE;
} }
/* Find most largest index in the splaytree */ /* Find most largest index in the splaytree */
// if ((per_pixel_eqn = splay_find_max(active_preset->per_pixel_eqn_tree)) == NULL) // if ((per_pixel_eqn = splay_find_max(active_preset->per_pixel_eqn_tree)) == NULL)
// index = 0; // index = 0;
// else // else
index = splay_size(preset->per_pixel_eqn_tree); index = splay_size(preset->per_pixel_eqn_tree);
/* Create the per pixel equation given the index, parameter, and general expression */ /* Create the per pixel equation given the index, parameter, and general expression */
if ((per_pixel_eqn = new_per_pixel_eqn(index, param, gen_expr)) == NULL) { if ((per_pixel_eqn = new_per_pixel_eqn(index, param, gen_expr)) == NULL) {
if (PER_PIXEL_EQN_DEBUG) printf("add_per_pixel_eqn: failed to create new per pixel equation!\n"); if (PER_PIXEL_EQN_DEBUG) printf("add_per_pixel_eqn: failed to create new per pixel equation!\n");
...@@ -161,56 +161,56 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) { ...@@ -161,56 +161,56 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) {
} }
if (PER_PIXEL_EQN_DEBUG) printf("add_per_pixel_eqn: new equation (index = %d) (param = \"%s\")\n", if (PER_PIXEL_EQN_DEBUG) printf("add_per_pixel_eqn: new equation (index = %d) (param = \"%s\")\n",
per_pixel_eqn->index, per_pixel_eqn->param->name); per_pixel_eqn->index, per_pixel_eqn->param->name);
/* Insert the per pixel equation into the preset per pixel database */ /* Insert the per pixel equation into the preset per pixel database */
if (splay_insert(per_pixel_eqn, &per_pixel_eqn->index, preset->per_pixel_eqn_tree) < 0) { if (splay_insert(per_pixel_eqn, &per_pixel_eqn->index, preset->per_pixel_eqn_tree) < 0) {
free_per_pixel_eqn(per_pixel_eqn); free_per_pixel_eqn(per_pixel_eqn);
printf("failed to add per pixel eqn!\n"); printf("failed to add per pixel eqn!\n");
return FAILURE; return FAILURE;
} }
/* Done */ /* Done */
return SUCCESS; return SUCCESS;
} }
per_pixel_eqn_t * new_per_pixel_eqn(int index, param_t * param, gen_expr_t * gen_expr) { per_pixel_eqn_t * new_per_pixel_eqn(int index, param_t * param, gen_expr_t * gen_expr) {
per_pixel_eqn_t * per_pixel_eqn; per_pixel_eqn_t * per_pixel_eqn;
if (index < 0) if (index < 0)
return NULL; return NULL;
if (param == NULL) if (param == NULL)
return NULL; return NULL;
if (gen_expr == NULL) if (gen_expr == NULL)
return NULL; return NULL;
if ((per_pixel_eqn = (per_pixel_eqn_t*)malloc(sizeof(per_pixel_eqn_t))) == NULL) if ((per_pixel_eqn = (per_pixel_eqn_t*)malloc(sizeof(per_pixel_eqn_t))) == NULL)
return NULL; return NULL;
per_pixel_eqn->index = index; per_pixel_eqn->index = index;
per_pixel_eqn->param = param; per_pixel_eqn->param = param;
per_pixel_eqn->gen_expr = gen_expr; per_pixel_eqn->gen_expr = gen_expr;
return per_pixel_eqn; return per_pixel_eqn;
} }
void free_per_pixel_eqn(per_pixel_eqn_t * per_pixel_eqn) { void free_per_pixel_eqn(per_pixel_eqn_t * per_pixel_eqn) {
if (per_pixel_eqn == NULL) if (per_pixel_eqn == NULL)
return; return;
free_gen_expr(per_pixel_eqn->gen_expr); free_gen_expr(per_pixel_eqn->gen_expr);
free(per_pixel_eqn); free(per_pixel_eqn);
return; return;
} }
inline int isPerPixelEqn(int op) { inline int isPerPixelEqn(int op) {
return active_preset->per_pixel_flag[op]; return active_preset->per_pixel_flag[op];
} }
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
typedef struct PER_PIXEL_EQN_T { typedef struct PER_PIXEL_EQN_T {
int index; /* used for splay tree ordering. */ int index; /* used for splay tree ordering. */
int flags; /* primarily to specify if this variable is user-defined */ int flags; /* primarily to specify if this variable is user-defined */
param_t * param; param_t * param;
gen_expr_t * gen_expr; gen_expr_t * gen_expr;
} per_pixel_eqn_t; } per_pixel_eqn_t;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
typedef struct PER_POINT_EQN { typedef struct PER_POINT_EQN {
custom_wave_t * custom_wave; custom_wave_t * custom_wave;
} per_point_eqn_t; } per_point_eqn_t;
......
This diff is collapsed.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "expr_types.h" #include "expr_types.h"
#include "per_pixel_eqn_types.h" #include "per_pixel_eqn_types.h"
typedef enum { typedef enum {
ALPHA_NEXT, ALPHA_NEXT,
ALPHA_PREVIOUS, ALPHA_PREVIOUS,
RANDOM_NEXT, RANDOM_NEXT,
...@@ -13,14 +13,14 @@ typedef enum { ...@@ -13,14 +13,14 @@ typedef enum {
} switch_mode_t; } switch_mode_t;
typedef struct PRESET_T { typedef struct PRESET_T {
char name[MAX_TOKEN_SIZE]; /* preset name as parsed in file */ char name[MAX_TOKEN_SIZE]; /* preset name as parsed in file */
char file_path[MAX_PATH_SIZE]; /* Points to the preset file name */ char file_path[MAX_PATH_SIZE]; /* Points to the preset file name */
int per_pixel_eqn_string_index; int per_pixel_eqn_string_index;
int per_frame_eqn_string_index; int per_frame_eqn_string_index;
int per_frame_init_eqn_string_index; int per_frame_init_eqn_string_index;
int per_pixel_flag[NUM_OPS]; int per_pixel_flag[NUM_OPS];
char per_pixel_eqn_string_buffer[STRING_BUFFER_SIZE]; char per_pixel_eqn_string_buffer[STRING_BUFFER_SIZE];
char per_frame_eqn_string_buffer[STRING_BUFFER_SIZE]; char per_frame_eqn_string_buffer[STRING_BUFFER_SIZE];
......
This diff is collapsed.
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
/* Compares integer value numbers in 32 bit range */ /* Compares integer value numbers in 32 bit range */
int compare_int(int * num1, int * num2) { int compare_int(int * num1, int * num2) {
if ((*num1) < (*num2)) if ((*num1) < (*num2))
return -1; return -1;
if ((*num1) > (*num2)) if ((*num1) > (*num2))
return 1; return 1;
return 0; return 0;
} }
/* Compares strings in lexographical order */ /* Compares strings in lexographical order */
...@@ -43,8 +43,8 @@ int compare_string(char * str1, char * str2) { ...@@ -43,8 +43,8 @@ int compare_string(char * str1, char * str2) {
// printf("comparing \"%s\" to \"%s\"\n", str1, str2); // printf("comparing \"%s\" to \"%s\"\n", str1, str2);
//return strcmp(str1, str2); //return strcmp(str1, str2);
return strncmp(str1, str2, MAX_TOKEN_SIZE-1); return strncmp(str1, str2, MAX_TOKEN_SIZE-1);
} }
/* Compares a string in version order. That is, file1 < file2 < file10 */ /* Compares a string in version order. That is, file1 < file2 < file10 */
int compare_string_version(char * str1, char * str2) { int compare_string_version(char * str1, char * str2) {
...@@ -55,36 +55,36 @@ int compare_string_version(char * str1, char * str2) { ...@@ -55,36 +55,36 @@ int compare_string_version(char * str1, char * str2) {
void free_int(void * num) { void free_int(void * num) {
free(num); free(num);
} }
void free_string(char * string) { void free_string(char * string) {
free(string); free(string);
} }
void * copy_int(int * num) { void * copy_int(int * num) {
int * new_num; int * new_num;
if ((new_num = (int*)malloc(sizeof(int))) == NULL) if ((new_num = (int*)malloc(sizeof(int))) == NULL)
return NULL; return NULL;
*new_num = *num; *new_num = *num;
return (void*)new_num; return (void*)new_num;
} }
void * copy_string(char * string) { void * copy_string(char * string) {
char * new_string; char * new_string;
if ((new_string = (char*)malloc(MAX_TOKEN_SIZE)) == NULL) if ((new_string = (char*)malloc(MAX_TOKEN_SIZE)) == NULL)
return NULL; return NULL;
strncpy(new_string, string, MAX_TOKEN_SIZE-1); strncpy(new_string, string, MAX_TOKEN_SIZE-1);
return (void*)new_string; return (void*)new_string;
} }
...@@ -43,7 +43,7 @@ extern char *buffer; ...@@ -43,7 +43,7 @@ extern char *buffer;
void setup_opengl( int w, int h ) void setup_opengl( int w, int h )
{ {
/* Our shading model--Gouraud (smooth). */ /* Our shading model--Gouraud (smooth). */
glShadeModel( GL_SMOOTH); glShadeModel( GL_SMOOTH);
/* Culling. */ /* Culling. */
...@@ -60,21 +60,21 @@ void setup_opengl( int w, int h ) ...@@ -60,21 +60,21 @@ void setup_opengl( int w, int h )
*/ */
glMatrixMode(GL_TEXTURE); glMatrixMode(GL_TEXTURE);
glLoadIdentity(); glLoadIdentity();
// gluOrtho2D(0.0, (GLfloat) width, 0.0, (GLfloat) height); // gluOrtho2D(0.0, (GLfloat) width, 0.0, (GLfloat) height);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
// glFrustum(0.0, height, 0.0,width,10,40); // glFrustum(0.0, height, 0.0,width,10,40);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glDrawBuffer(GL_BACK); glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK); glReadBuffer(GL_BACK);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE); // glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
glEnable(GL_POINT_SMOOTH); glEnable(GL_POINT_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
...@@ -83,8 +83,8 @@ glDrawBuffer(GL_BACK); ...@@ -83,8 +83,8 @@ glDrawBuffer(GL_BACK);
// glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB,0,0,texsize,texsize,0); // glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB,0,0,texsize,texsize,0);
//glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,texsize,texsize); //glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,texsize,texsize);
glLineStipple(2, 0xAAAA); glLineStipple(2, 0xAAAA);
} }
void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarget ) void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarget )
...@@ -98,23 +98,23 @@ void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarge ...@@ -98,23 +98,23 @@ void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarge
/* Create the render target */ /* Create the render target */
*RenderTarget = SDL_GL_CreateRenderTarget(texsize,texsize, NULL); *RenderTarget = SDL_GL_CreateRenderTarget(texsize,texsize, NULL);
if ( *RenderTarget ) { if ( *RenderTarget ) {
int value; int value;
//printf("Created render target:\n"); //printf("Created render target:\n");
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_RED_SIZE, &value ); SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_RED_SIZE, &value );
// printf( "SDL_GL_RED_SIZE: %d\n", value); // printf( "SDL_GL_RED_SIZE: %d\n", value);
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_GREEN_SIZE, &value ); SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_GREEN_SIZE, &value );
// printf( "SDL_GL_GREEN_SIZE: %d\n", value); // printf( "SDL_GL_GREEN_SIZE: %d\n", value);
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_BLUE_SIZE, &value ); SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_BLUE_SIZE, &value );
// printf( "SDL_GL_BLUE_SIZE: %d\n", value); // printf( "SDL_GL_BLUE_SIZE: %d\n", value);
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_ALPHA_SIZE, &value ); SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_ALPHA_SIZE, &value );
// printf( "SDL_GL_ALPHA_SIZE: %d\n", value); // printf( "SDL_GL_ALPHA_SIZE: %d\n", value);
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_DEPTH_SIZE, &value ); SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_DEPTH_SIZE, &value );
// printf( "SDL_GL_DEPTH_SIZE: %d\n", value ); // printf( "SDL_GL_DEPTH_SIZE: %d\n", value );
SDL_GL_BindRenderTarget(*RenderTarget, *RenderTargetTextureID); SDL_GL_BindRenderTarget(*RenderTarget, *RenderTargetTextureID);
} else { } else {
#endif #endif
/* We can fake a render target in this demo by rendering to the /* We can fake a render target in this demo by rendering to the
...@@ -124,13 +124,13 @@ void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarge ...@@ -124,13 +124,13 @@ void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarge
glBindTexture(GL_TEXTURE_2D, *RenderTargetTextureID); glBindTexture(GL_TEXTURE_2D, *RenderTargetTextureID);
glTexImage2D(GL_TEXTURE_2D, glTexImage2D(GL_TEXTURE_2D,
0, 0,
GL_RGB, GL_RGB,
texsize, texsize, texsize, texsize,
0, 0,
GL_RGB, GL_RGB,
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
buffer); buffer);
// } // }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment