Commit b45ccdd5 authored by Cyril Deguet's avatar Cyril Deguet

* all: first implementation of a MilkDrop-compatible visualization plugin,

    based on ProjectM (xmms-projectm.sourceforge.net), without the
    dependency on SDL 1.3. At the moment it only works on X11 with GLX 1.3,
    I didn't manage to have it working with the 1.2 API :(
    SGI Pbuffers are not used yet, I didn't manage to have them working
    well either :(
    Milkdrop presets are searched in /etc/projectM/presets (guess why ;)
    With projectM presets, colours look a bit "flashy", I wonder if it
    is normal...
    To compile the plugin, add --enable-galaktos in configure. The only
    dependencies are on X11 and OpenGL libs.
    Enjoy !
parent 918eef52
......@@ -3,4 +3,23 @@ SOURCES_galaktos = plugin.c \
glx.c \
glx.h \
main.c \
main.h
main.h \
preset.c \
preset.h \
beat_detect.c \
param.c \
engine_vars.c \
parser.c \
builtin_funcs.c \
eval.c \
init_cond.c \
PCM.c \
fftsg.c \
per_frame_eqn.c \
splaytree.c \
custom_shape.c \
func.c \
per_pixel_eqn.c \
tree_types.c \
custom_wave.c \
video_init.c
/*****************************************************************************
* PCM.c:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
* code from projectM http://xmms-projectm.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
//PCM.c - Sound data handler
//
//by Peter Sperl
//
//Takes sound data from wherever and hands it back out.
//Returns PCM Data or spectrum data, or the derivative of the PCM data
#include <stdlib.h>
#include <stdio.h>
double **PCMd; //data structure to store PCM data PCM[channels][maxsamples]
int maxsamples; //size of PCM buffer
int start; //where to add data next
int *ip; //working space for FFT routines
double *w; //lookup table for FFT routines
int new; //how many new samples
//initPCM(int samples)
//
//Initializes the PCM buffer to
// number of samples specified.
void initPCM(int samples)
{
int i;
//Allocate memory for PCM data buffer
PCMd = (double **)malloc(2 * sizeof(double *));
PCMd[0] = (double *)malloc(samples * sizeof(double));
PCMd[1] = (double *)malloc(samples * sizeof(double));
maxsamples=samples;
new=0;
//Initialize buffers to 0
for (i=0;i<samples;i++)
{
PCMd[0][i]=0;
PCMd[1][i]=0;
}
start=0;
//Allocate FFT workspace
w= (double *)malloc(maxsamples*sizeof(double));
ip= (int *)malloc(maxsamples*sizeof(int));
ip[0]=0;
}
//The only current addPCM function, can support more
//
//Takes in a 2x512 array of PCM samples
//and stores them
void addPCM(int16_t PCMdata[2][512])
{
int i,j;
int samples=512;
for(i=0;i<samples;i++)
{
j=i+start;
PCMd[0][j%maxsamples]=(PCMdata[0][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]);
start+=samples;
start=start%maxsamples;
new+=samples;
if (new>maxsamples) new=maxsamples;
}
//puts sound data requested at provided pointer
//
//samples is number of PCM samples to return
//freq = 0 gives PCM data
//freq = 1 gives FFT data
//smoothing is the smoothing coefficient
//returned values are normalized from -1 to 1
void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothing, int derive)
{
int i,index;
index=start-1;
if (index<0) index=maxsamples+index;
PCMdata[0]=PCMd[channel][index];
for(i=1;i<samples;i++)
{
index=start-1-i;
if (index<0) index=maxsamples+index;
PCMdata[i]=(1-smoothing)*PCMd[channel][index]+smoothing*PCMdata[i-1];
}
//return derivative of PCM data
if(derive)
{
for(i=0;i<samples-1;i++)
{
PCMdata[i]=PCMdata[i]-PCMdata[i+1];
}
PCMdata[samples-1]=0;
}
//return frequency data instead of PCM (perform FFT)
if (freq) rdft(samples, 1, PCMdata, ip, w);
}
//getPCMnew
//
//Like getPCM except it returns all new samples in the buffer
//the actual return value is the number of samples, up to maxsamples.
//the passed pointer, PCMData, must bee able to hold up to maxsamples
int getPCMnew(double *PCMdata, int channel, int freq, double smoothing, int derive, int reset)
{
int i,index;
index=start-1;
if (index<0) index=maxsamples+index;
PCMdata[0]=PCMd[channel][index];
for(i=1;i<new;i++)
{
index=start-1-i;
if (index<0) index=maxsamples+index;
PCMdata[i]=(1-smoothing)*PCMd[channel][index]+smoothing*PCMdata[i-1];
}
//return derivative of PCM data
if(derive)
{
for(i=0;i<new-1;i++)
{
PCMdata[i]=PCMdata[i]-PCMdata[i+1];
}
PCMdata[new-1]=0;
}
//return frequency data instead of PCM (perform FFT)
// if (freq) rdft(samples, 1, PCMdata, ip, w);
i=new;
if (reset) new=0;
return i;
}
//Free stuff
void freePCM()
{
free(PCMd[0]);
free(PCMd[1]);
free(PCMd);
free(ip);
free(w);
}
void initPCM(int maxsamples);
void addPCM(int16_t [2][512]);
void getPCM(double *data, int samples, int channel, int freq, double smoothing, int derive);
void freePCM();
int getPCMnew(double *PCMdata, int channel, int freq, double smoothing, int derive,int reset);
/*****************************************************************************
* beat_detect.c: basic beat detection algorithm
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
* code from projectM http://xmms-projectm.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
//
//by Peter Sperl
//
//Takes sound data from wherever and returns beat detection values
//Uses statistical Energy-Based methods. Very simple
//
//Some stuff was taken from Frederic Patin's beat-detection article, you'll find it online
#include <stdlib.h>
#include <stdio.h>
#include "engine_vars.h"
double beat_buffer[32][80],beat_instant[32],beat_history[32];
double *beat_val,*beat_att,*beat_variance;
int beat_buffer_pos;
double vol_buffer[80],vol_instant,vol_history;
void initBeatDetect()
{
int x,y;
vol_instant=0;
vol_history=0;
for (y=0;y<80;y++)
{
vol_buffer[y]=0;
}
beat_buffer_pos=0;
beat_val=(double *)malloc(32*sizeof(double));
beat_att=(double *)malloc(32*sizeof(double));
beat_variance=(double *)malloc(32*sizeof(double));
for (x=0;x<32;x++)
{
beat_instant[x]=0;
beat_history[x]=0;
beat_val[x]=1.0;
beat_att[x]=1.0;
beat_variance[x]=0;
for (y=0;y<80;y++)
{
beat_buffer[x][y]=0;
}
}
}
void getBeatVals(double *vdataL,double *vdataR, double *vol)
{
int linear=0;
int x,y;
vol_instant=0;
for ( x=0;x<16;x++)
{
beat_instant[x]=0;
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));
vol_instant+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/512.0);
}
linear=y/2;
beat_history[x]-=(beat_buffer[x][beat_buffer_pos])*.0125;
beat_buffer[x][beat_buffer_pos]=beat_instant[x];
beat_history[x]+=(beat_instant[x])*.0125;
beat_val[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_buffer[beat_buffer_pos]=vol_instant;
vol_history+=(vol_instant)*.0125;
double temp2=0;
mid=0;
for(x=1;x<10;x++)
{
mid+=(beat_instant[x]);
temp2+=(beat_history[x]);
}
mid=mid/(1.5*temp2);
temp2=0;
treb=0;
for(x=10;x<16;x++)
{
treb+=(beat_instant[x]);
temp2+=(beat_history[x]);
}
treb=treb/(1.5*temp2);
*vol=vol_instant/(1.5*vol_history);
bass=(beat_instant[0])/(1.5*beat_history[0]);
treb_att=.6 * treb_att + .4 * treb;
mid_att=.6 * mid_att + .4 * mid;
bass_att=.6 * bass_att + .4 * bass;
//printf("%f %f %f %f\n",bass,mid,treb,*vol);
// *vol=(beat_instant[3])/(beat_history[3]);
beat_buffer_pos++;
if( beat_buffer_pos>79)beat_buffer_pos=0;
}
void freeBeatDetect()
{
free(beat_att);
free(beat_val);
free(beat_variance);
}
void initBeatDetect();
void getBeatVals(double *vdataL,double *vdataR,double *vol);
void freeBeatDetect();
/*****************************************************************************
* builtin_funcs.c:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
* code from projectM http://xmms-projectm.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
/* Values to optimize the sigmoid function */
#define R 32767
#define RR 65534
inline double int_wrapper(double * arg_list) {
return floor(arg_list[0]);
}
inline double sqr_wrapper(double * arg_list) {
return pow(2, arg_list[0]);
}
inline double sign_wrapper(double * arg_list) {
return -arg_list[0];
}
inline double min_wrapper(double * arg_list) {
if (arg_list[0] > arg_list[1])
return arg_list[1];
return arg_list[0];
}
inline double max_wrapper(double * arg_list) {
if (arg_list[0] > arg_list[1])
return arg_list[0];
return arg_list[1];
}
/* consult your AI book */
inline double sigmoid_wrapper(double * arg_list) {
return (RR / (1 + exp( -(((double)(arg_list[0])) * arg_list[1]) / R) - R));
}
inline double bor_wrapper(double * arg_list) {
return (double)((int)arg_list[0] || (int)arg_list[1]);
}
inline double band_wrapper(double * arg_list) {
return (double)((int)arg_list[0] && (int)arg_list[1]);
}
inline double bnot_wrapper(double * arg_list) {
return (double)(!(int)arg_list[0]);
}
inline double if_wrapper(double * arg_list) {
if ((int)arg_list[0] == 0)
return arg_list[2];
return arg_list[1];
}
inline double rand_wrapper(double * arg_list) {
double l;
// printf("RAND ARG:(%d)\n", (int)arg_list[0]);
l = (double)((rand()) % ((int)arg_list[0]));
//printf("VAL: %f\n", l);
return l;
}
inline double equal_wrapper(double * arg_list) {
return (arg_list[0] == arg_list[1]);
}
inline double above_wrapper(double * arg_list) {
return (arg_list[0] > arg_list[1]);
}
inline double below_wrapper(double * arg_list) {
return (arg_list[0] < arg_list[1]);
}
inline double sin_wrapper(double * arg_list) {
return (sin (arg_list[0]));
}
inline double cos_wrapper(double * arg_list) {
return (cos (arg_list[0]));
}
inline double tan_wrapper(double * arg_list) {
return (tan(arg_list[0]));
}
inline double asin_wrapper(double * arg_list) {
return (asin (arg_list[0]));
}
inline double acos_wrapper(double * arg_list) {
return (acos (arg_list[0]));
}
inline double atan_wrapper(double * arg_list) {
return (atan (arg_list[0]));
}
inline double atan2_wrapper(double * arg_list) {
return (atan2 (arg_list[0], arg_list[1]));
}
inline double pow_wrapper(double * arg_list) {
return (pow (arg_list[0], arg_list[1]));
}
inline double exp_wrapper(double * arg_list) {
return (exp(arg_list[0]));
}
inline double abs_wrapper(double * arg_list) {
return (fabs(arg_list[0]));
}
inline double log_wrapper(double *arg_list) {
return (log (arg_list[0]));
}
inline double log10_wrapper(double * arg_list) {
return (log10 (arg_list[0]));
}
inline double sqrt_wrapper(double * arg_list) {
return (sqrt (arg_list[0]));
}
inline double nchoosek_wrapper(double * arg_list) {
unsigned long cnm = 1UL;
int i, f;
int n, m;
n = (int)arg_list[0];
m = (int)arg_list[1];
if (m*2 >n) m = n-m;
for (i=1 ; i <= m; n--, i++)
{
if ((f=n) % i == 0)
f /= i;
else cnm /= i;
cnm *= f;
}
return (double)cnm;
}
inline double fact_wrapper(double * arg_list) {
int result = 1;
int n = (int)arg_list[0];
while (n > 1) {
result = result * n;
n--;
}
return (double)result;
}
/* Wrappers for all the builtin functions
The arg_list pointer is a list of doubles. Its
size is equal to the number of arguments the parameter
takes */
inline double below_wrapper(double * arg_list);
inline double above_wrapper(double * arg_list);
inline double equal_wrapper(double * arg_list);
inline double if_wrapper(double * arg_list);
inline double bnot_wrapper(double * arg_list);
inline double rand_wrapper(double * arg_list);
inline double bor_wrapper(double * arg_list);
inline double band_wrapper(double * arg_list);
inline double sigmoid_wrapper(double * arg_list);
inline double max_wrapper(double * arg_list);
inline double min_wrapper(double * arg_list);
inline double sign_wrapper(double * arg_list);
inline double sqr_wrapper(double * arg_list);
inline double int_wrapper(double * arg_list);
inline double nchoosek_wrapper(double * arg_list);
inline double sin_wrapper(double * arg_list);
inline double cos_wrapper(double * arg_list);
inline double tan_wrapper(double * arg_list);
inline double fact_wrapper(double * arg_list);
inline double asin_wrapper(double * arg_list);
inline double acos_wrapper(double * arg_list);
inline double atan_wrapper(double * arg_list);
inline double atan2_wrapper(double * arg_list);
inline double pow_wrapper(double * arg_list);
inline double exp_wrapper(double * arg_list);
inline double abs_wrapper(double * arg_list);
inline double log_wrapper(double *arg_list);
inline double log10_wrapper(double * arg_list);
inline double sqrt_wrapper(double * arg_list);
#ifndef COMMON_H
#define COMMON_H
#define DEFAULT_FONT_PATH "/home/carm/fonts/courier1.glf"
#define MAX_TOKEN_SIZE 512
#define MAX_PATH_SIZE 4096
#define STRING_BUFFER_SIZE 1024*150
#define STRING_LINE_SIZE 1024
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define PROJECTM_FILE_EXTENSION ".prjm"
#define MILKDROP_FILE_EXTENSION ".milk"
#define MAX_DOUBLE_SIZE 10000000.0
#define MIN_DOUBLE_SIZE -10000000.0
#define MAX_INT_SIZE 10000000
#define MIN_INT_SIZE -10000000
#define DEFAULT_DOUBLE_IV 0.0 /* default double initial value */
#define DEFAULT_DOUBLE_LB MIN_DOUBLE_SIZE /* default double lower bound */
#define DEFAULT_DOUBLE_UB MAX_DOUBLE_SIZE /* default double upper bound */
#endif
int compare_int(int * num1, int * num2);
int compare_string(char * string1, char * string2);
This diff is collapsed.
#ifndef CUSTOM_SHAPE_H
#define CUSTOM_SHAPE_H
#define CUSTOM_SHAPE_DEBUG 0
#include "expr_types.h"
#include "custom_shape_types.h"
#include "preset_types.h"
void free_custom_shape(custom_shape_t * custom_shape);
custom_shape_t * new_custom_shape(int id);
custom_shape_t * find_custom_shape(int id, preset_t * preset, int create_flag);
void load_unspecified_init_conds_shape(custom_shape_t * custom_shape);
inline void evalCustomShapeInitConditions();
inline custom_shape_t * nextCustomShape();
#endif
#ifndef CUSTOM_SHAPE_TYPES_H
#define CUSTOM_SHAPE_TYPES_H
#include "common.h"
#include "splaytree_types.h"
#include "expr_types.h"
typedef struct CUSTOM_SHAPE_T {
/* Numerical id */
int id;
int per_frame_count;
/* Parameter tree associated with this custom shape */
splaytree_t * param_tree;
/* Engine variables */
int sides;
int thickOutline;
int enabled;
int additive;
int textured;
double tex_zoom;
double tex_ang;
double x; /* x position for per point equations */
double y; /* y position for per point equations */
double rad;
double ang;
double r; /* red color value */
double g; /* green color value */
double b; /* blue color value */
double a; /* alpha color value */
double r2; /* red color value */
double g2; /* green color value */
double b2; /* blue color value */
double a2; /* alpha color value */
double border_r; /* red color value */
double border_g; /* green color value */
double border_b; /* blue color value */
double border_a; /* alpha color value */
/* stupid t variables */
double t1;
double t2;
double t3;
double t4;
double t5;
double t6;
double t7;
double t8;
/* Data structure to hold per frame / per frame init equations */
splaytree_t * init_cond_tree;
splaytree_t * per_frame_eqn_tree;
splaytree_t * per_frame_init_eqn_tree;
/* Denotes the index of the last character for each string buffer */
int per_frame_eqn_string_index;
int per_frame_init_eqn_string_index;
/* String buffers for per frame / per frame init equations */
char per_frame_eqn_string_buffer[STRING_BUFFER_SIZE];
char per_frame_init_eqn_string_buffer[STRING_BUFFER_SIZE];
/* Per point equation array */
} custom_shape_t;
#endif
This diff is collapsed.
#ifndef CUSTOM_WAVE_H
#define CUSTOM_WAVE_H
#define CUSTOM_WAVE_DEBUG 0
#include "expr_types.h"
#include "custom_wave_types.h"
#include "preset_types.h"
void free_custom_wave(custom_wave_t * custom_wave);
custom_wave_t * new_custom_wave(int id);
void free_per_point_eqn(per_point_eqn_t * per_point_eqn);
per_point_eqn_t * new_per_point_eqn(int index, param_t * param,gen_expr_t * gen_expr);
void reset_per_point_eqn_array(custom_wave_t * custom_wave);
custom_wave_t * find_custom_wave(int id, preset_t * preset, int create_flag);
int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom_wave);
inline void evalCustomWaveInitConditions();
inline void evalPerPointEqns();
inline custom_wave_t * nextCustomWave();
void load_unspecified_init_conds(custom_wave_t * custom_wave);
#endif
#ifndef CUSTOM_WAVE_TYPES_H
#define CUSTOM_WAVE_TYPES_H
#include "common.h"
#include "splaytree_types.h"
#include "expr_types.h"
#define X_POINT_OP 0
#define Y_POINT_OP 1
#define R_POINT_OP 2
#define G_POINT_OP 3
#define B_POINT_OP 4
#define A_POINT_OP 5
#define NUM_POINT_OPS 6
typedef struct PER_POINT_EQN_T {
int index;
param_t * param;
gen_expr_t * gen_expr;
} per_point_eqn_t;
typedef struct CUSTOM_WAVE_T {
/* Numerical id */
int id;
int per_frame_count;
/* Parameter tree associated with this custom wave */
splaytree_t * param_tree;
/* Engine variables */
double x; /* x position for per point equations */
double y; /* y position for per point equations */
double r; /* red color value */
double g; /* green color value */
double b; /* blue color value */
double a; /* alpha color value */
double * x_mesh;
double * y_mesh;
double * r_mesh;
double * b_mesh;
double * g_mesh;
double * a_mesh;
double * value1;
double * value2;
double * sample_mesh;
int enabled; /* if nonzero then wave is visible, hidden otherwise */
int samples; /* number of samples associated with this wave form. Usually powers of 2 */
double sample;
int bSpectrum; /* spectrum data or pcm data */
int bUseDots; /* draw wave as dots or lines */
int bDrawThick; /* draw thicker lines */
int bAdditive; /* add color values together */
double scaling; /* scale factor of waveform */
double smoothing; /* smooth factor of waveform */
int sep; /* no idea what this is yet... */
/* stupid t variables */
double t1;
double t2;
double t3;
double t4;
double t5;
double t6;
double t7;
double t8;
double v1,v2;
/* Data structure to hold per frame and per point equations */
splaytree_t * init_cond_tree;
splaytree_t * per_frame_eqn_tree;
splaytree_t * per_point_eqn_tree;
splaytree_t * per_frame_init_eqn_tree;
/* Denotes the index of the last character for each string buffer */
int per_point_eqn_string_index;
int per_frame_eqn_string_index;
int per_frame_init_eqn_string_index;
/* String buffers for per point and per frame equations */
char per_point_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];
/* Per point equation array */
gen_expr_t * per_point_eqn_array[NUM_POINT_OPS];
} custom_wave_t;
#endif
/*****************************************************************************
* engine_vars.c:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
* code from projectM http://xmms-projectm.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* Include engine_vars.h to use these variables */
char preset_name[256];
/* PER FRAME CONSTANTS BEGIN */
double zoom=1.0;
double zoomexp= 1.0;
double rot= 0.0;
double warp= 0.0;
double sx= 1.0;
double sy= 1.0;
double dx= 0.0;
double dy= 0.0;
double cx= 0.5;
double cy= 0.5;
int gx = 32;
int gy = 24;
double decay=.98;
double wave_r= 1.0;
double wave_g= 0.2;
double wave_b= 0.0;
double wave_x= 0.5;
double wave_y= 0.5;
double wave_mystery= 0.0;
double ob_size= 0.0;
double ob_r= 0.0;
double ob_g= 0.0;
double ob_b= 0.0;
double ob_a= 0.0;
double ib_size = 0.0;
double ib_r = 0.0;
double ib_g = 0.0;
double ib_b = 0.0;
double ib_a = 0.0;
double mv_a = 0.0;
double mv_r = 0.0;
double mv_g = 0.0;
double mv_b = 0.0;
double mv_l = 1.0;
double mv_x = 16.0;
double mv_y = 12.0;
double mv_dy = 0.02;
double mv_dx = 0.02;
int meshx = 0;
int meshy = 0;
double Time = 0;
double treb = 0;
double mid = 0;
double bass = 0;
double treb_att = 0;
double mid_att = 0;
double bass_att = 0;
double progress = 0;
int frame = 0;
int fps = 30;
//double bass_thresh = 0;
/* PER_FRAME CONSTANTS END */
double fRating = 0;
double fGammaAdj = 1.0;
double fVideoEchoZoom = 1.0;
double fVideoEchoAlpha = 0;
double nVideoEchoOrientation = 0;
int nWaveMode = 7;
int bAdditiveWaves = 0;
int bWaveDots = 0;
int bWaveThick = 0;
int bModWaveAlphaByVolume = 0;
int bMaximizeWaveColor = 0;
int bTexWrap = 0;
int bDarkenCenter = 0;
int bRedBlueStereo = 0;
int bBrighten = 0;
int bDarken = 0;
int bSolarize = 0;
int bInvert = 0;
int bMotionVectorsOn = 1;
double fWaveAlpha =1.0;
double fWaveScale = 1.0;
double fWaveSmoothing = 0;
double fWaveParam = 0;
double fModWaveAlphaStart = 0;
double fModWaveAlphaEnd = 0;
double fWarpAnimSpeed = 0;
double fWarpScale = 0;
double fShader = 0;
/* PER_PIXEL CONSTANTS BEGIN */
double x_per_pixel = 0;
double y_per_pixel = 0;
double rad_per_pixel = 0;
double ang_per_pixel = 0;
/* PER_PIXEL CONSTANT END */
/* Q AND T VARIABLES START */
double q1 = 0;
double q2 = 0;
double q3 = 0;
double q4 = 0;
double q5 = 0;
double q6 = 0;
double q7 = 0;
double q8 = 0;
/* Q AND T VARIABLES END */
//per pixel meshes
double **zoom_mesh;
double **zoomexp_mesh;
double **rot_mesh;
double **sx_mesh;
double **sy_mesh;
double **dx_mesh;
double **dy_mesh;
double **cx_mesh;
double **cy_mesh;
double **x_mesh;
double **y_mesh;
double **rad_mesh;
double **theta_mesh;
//custom wave per point meshes
/* Temporay file until these variables are all externed */
#ifndef ENGINE_VARS_H
#define ENGINE_VARS_H
extern char preset_name[256];
/* PER FRAME CONSTANTS BEGIN */
extern double zoom;
extern double zoomexp;
extern double rot;
extern double warp;
extern double sx;
extern double sy;
extern double dx;
extern double dy;
extern double cx;
extern double cy;
extern int gy;
extern int gx;
extern double decay;
extern double wave_r;
extern double wave_g;
extern double wave_b;
extern double wave_x;
extern double wave_y;
extern double wave_mystery;
extern double ob_size;
extern double ob_r;
extern double ob_g;
extern double ob_b;
extern double ob_a;
extern double ib_size;
extern double ib_r;
extern double ib_g;
extern double ib_b;
extern double ib_a;
extern int meshx;
extern int meshy;
extern double mv_a ;
extern double mv_r ;
extern double mv_g ;
extern double mv_b ;
extern double mv_l;
extern double mv_x;
extern double mv_y;
extern double mv_dy;
extern double mv_dx;
extern double Time;
extern double treb ;
extern double mid ;
extern double bass ;
extern double treb_att ;
extern double mid_att ;
extern double bass_att ;
extern double progress ;
extern int frame ;
/* PER_FRAME CONSTANTS END */
/* PER_PIXEL CONSTANTS BEGIN */
extern double x_per_pixel;
extern double y_per_pixel;
extern double rad_per_pixel;
extern double ang_per_pixel;
/* PER_PIXEL CONSTANT END */
extern double fRating;
extern double fGammaAdj;
extern double fVideoEchoZoom;
extern double fVideoEchoAlpha;
extern int nVideoEchoOrientation;
extern int nWaveMode;
extern int bAdditiveWaves;
extern int bWaveDots;
extern int bWaveThick;
extern int bModWaveAlphaByVolume;
extern int bMaximizeWaveColor;
extern int bTexWrap;
extern int bDarkenCenter;
extern int bRedBlueStereo;
extern int bBrighten;
extern int bDarken;
extern int bSolarize;
extern int bInvert;
extern int bMotionVectorsOn;
extern int fps;
extern double fWaveAlpha ;
extern double fWaveScale;
extern double fWaveSmoothing;
extern double fWaveParam;
extern double fModWaveAlphaStart;
extern double fModWaveAlphaEnd;
extern double fWarpAnimSpeed;
extern double fWarpScale;
extern double fShader;
/* Q VARIABLES START */
extern double q1;
extern double q2;
extern double q3;
extern double q4;
extern double q5;
extern double q6;
extern double q7;
extern double q8;
/* Q VARIABLES END */
extern double **zoom_mesh;
extern double **zoomexp_mesh;
extern double **rot_mesh;
extern double **sx_mesh;
extern double **sy_mesh;
extern double **dx_mesh;
extern double **dy_mesh;
extern double **cx_mesh;
extern double **cy_mesh;
extern double **x_mesh;
extern double **y_mesh;
extern double **rad_mesh;
extern double **theta_mesh;
#endif
This diff is collapsed.
/* eval.h: evaluation functions of expressions */
#ifndef EVAL_H
#define EVAL_H
#include "func_types.h"
#include "param_types.h"
#define VAL_T 1
#define PREFUN_T 3
#define TREE_T 4
#define NONE_T 0
#define CONSTANT_TERM_T 0
#define PARAM_TERM_T 1
#define INFIX_ADD 0
#define INFIX_MINUS 1
#define INFIX_MOD 2
#define INFIX_DIV 3
#define INFIX_MULT 4
#define INFIX_OR 5
#define INFIX_AND 6
//#define EVAL_DEBUG
inline double eval_gen_expr(gen_expr_t * gen_expr);
inline gen_expr_t * opt_gen_expr(gen_expr_t * gen_expr, int ** param_list);
gen_expr_t * const_to_expr(double val);
gen_expr_t * param_to_expr(struct PARAM_T * param);
gen_expr_t * prefun_to_expr(double (*func_ptr)(), gen_expr_t ** expr_list, int num_args);
tree_expr_t * new_tree_expr(infix_op_t * infix_op, gen_expr_t * gen_expr, tree_expr_t * left, tree_expr_t * right);
gen_expr_t * new_gen_expr(int type, void * item);
val_expr_t * new_val_expr(int type, term_t term);
int free_gen_expr(gen_expr_t * gen_expr);
int free_prefun_expr(prefun_expr_t * prefun_expr);
int free_tree_expr(tree_expr_t * tree_expr);
int free_val_expr(val_expr_t * val_expr);
infix_op_t * new_infix_op(int type, int precedence);
int init_infix_ops();
int destroy_infix_ops();
void reset_engine_vars();
gen_expr_t * clone_gen_expr(gen_expr_t * gen_expr);
tree_expr_t * clone_tree_expr(tree_expr_t * tree_expr);
val_expr_t * clone_val_expr(val_expr_t * val_expr);
prefun_expr_t * clone_prefun_expr(prefun_expr_t * prefun_expr);
#endif
#ifndef EXPR_TYPES_H
#define EXPR_TYPES_H
#include "param_types.h"
#define CONST_STACK_ELEMENT 0
#define EXPR_STACK_ELEMENT 1
/* General Expression Type */
typedef struct GEN_EXPR_T {
int type;
void * item;
} gen_expr_t;
typedef union TERM_T {
double constant; /* static variable */
struct PARAM_T * param; /* pointer to a changing variable */
} term_t;
/* Value expression, contains a term union */
typedef struct VAL_EXPR_T {
int type;
term_t term;
} val_expr_t;
/* Infix Operator Function */
typedef struct INFIX_OP_T {
int type;
int precedence;
} infix_op_t;
/* A binary expression tree ordered by operator precedence */
typedef struct TREE_EXPR_T {
infix_op_t * infix_op; /* null if leaf */
gen_expr_t * gen_expr;
struct TREE_EXPR_T * left, * right;
} tree_expr_t;
/* A function expression in prefix form */
typedef struct PREFUN_EXPR_T {
double (*func_ptr)();
int num_args;
gen_expr_t ** expr_list;
} prefun_expr_t;
#endif
/* Fatal Error Definitions */
#define OUTOFMEM_ERROR -7; /* out of memory */
#define ERROR -1 /* non specific error */
#define SUCCESS 1
#define FAILURE -1
#define PARSE_ERROR -11
#define DIV_BY_ZERO -3
#define OK 2
This diff is collapsed.
/* Function management */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "common.h"
#include "fatal.h"
#include "func_types.h"
#include "func.h"
#include "splaytree_types.h"
#include "splaytree.h"
#include "tree_types.h"
#include "builtin_funcs.h"
/* A splay tree of builtin functions */
splaytree_t * builtin_func_tree;
/* Private function prototypes */
int compare_func(char * name, char * name2);
int insert_func(func_t * name);
void * copy_func_key(char * string);
void * copy_func_key(char * string) {
char * clone_string;
if ((clone_string = malloc(MAX_TOKEN_SIZE)) == NULL)
return NULL;
strncpy(clone_string, string, MAX_TOKEN_SIZE-1);
return (void*)clone_string;
}
func_t * create_func (char * name, double (*func_ptr)(), int num_args) {
func_t * func;
func = (func_t*)malloc(sizeof(func_t));
if (func == NULL)
return NULL;
/* Clear name space */
memset(func->name, 0, MAX_TOKEN_SIZE);
/* Copy given name into function structure */
strncpy(func->name, name, MAX_TOKEN_SIZE);
/* Assign value pointer */
func->func_ptr = func_ptr;
func->num_args = num_args;
/* Return instantiated function */
return func;
}
/* Initialize the builtin function database.
Should only be necessary once */
int init_builtin_func_db() {
int retval;
builtin_func_tree = create_splaytree(compare_string, copy_string, free_string);
if (builtin_func_tree == NULL)
return OUTOFMEM_ERROR;
retval = load_all_builtin_func();
return SUCCESS;
}
/* Destroy the builtin function database.
Generally, do this on projectm exit */
int destroy_builtin_func_db() {
splay_traverse(free_func, builtin_func_tree);
destroy_splaytree(builtin_func_tree);
return SUCCESS;
}
/* Insert a function into the database */
int insert_func(func_t * func) {
if (func == NULL)
return ERROR;
splay_insert(func, func->name, builtin_func_tree);
return SUCCESS;
}
/* Frees a function type, real complicated... */
void free_func(func_t * func) {
free(func);
}
/* Remove a function from the database */
int remove_func(func_t * func) {
if (func == NULL)
return ERROR;
splay_delete(func->name, builtin_func_tree);
return SUCCESS;
}
/* Find a function given its name */
func_t * find_func(char * name) {
func_t * func = NULL;
/* First look in the builtin database */
func = (func_t *)splay_find(name, builtin_func_tree);
return func;
}
/* Compare string name with function name */
int compare_func(char * name, char * name2) {
int cmpval;
/* Uses string comparison function */
cmpval = strncmp(name, name2, MAX_TOKEN_SIZE-1);
return cmpval;
}
/* Loads a builtin function */
int load_builtin_func(char * name, double (*func_ptr)(), int num_args) {
func_t * func;
int retval;
/* Create new function */
func = create_func(name, func_ptr, num_args);
if (func == NULL)
return OUTOFMEM_ERROR;
retval = insert_func(func);
return retval;
}
/* Loads all builtin functions */
int load_all_builtin_func() {
if (load_builtin_func("int", int_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("abs", abs_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("sin", sin_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("cos", cos_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("tan", tan_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("asin", asin_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("acos", acos_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("atan", atan_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("sqr", sqr_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("sqrt", sqrt_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("pow", pow_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("exp", exp_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("log", log_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("log10", log10_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("sign", sign_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("min", min_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("max", max_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("sigmoid", sigmoid_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("atan2", atan2_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("rand", rand_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("band", band_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("bor", bor_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("bnot", bnot_wrapper, 1) < 0)
return ERROR;
if (load_builtin_func("if", if_wrapper, 3) < 0)
return ERROR;
if (load_builtin_func("equal", equal_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("above", above_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("below", below_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("nchoosek", nchoosek_wrapper, 2) < 0)
return ERROR;
if (load_builtin_func("fact", fact_wrapper, 1) < 0)
return ERROR;
return SUCCESS;
}
#ifndef FUNC_H
#define FUNC_H
/* Public Prototypes */
func_t * create_func (char * name, double (*func_ptr)(), int num_args);
int remove_func(func_t * func);
func_t * find_func(char * name);
int init_builtin_func_db();
int destroy_builtin_func_db();
int load_all_builtin_func();
int load_builtin_func(char * name, double (*func_ptr)(), int num_args);
void free_func(func_t * func);
#endif
#ifndef FUNC_TYPES_H
#define FUNC_TYPES_H
#include "common.h"
/* Function Type */
typedef struct FUNC_T {
char name[MAX_TOKEN_SIZE];
double (*func_ptr)();
int num_args;
} func_t;
#endif
......@@ -5,6 +5,7 @@
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
* based on Scivi http://xmms-scivi.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -27,8 +28,8 @@
#include <GL/glx.h>
/* Local prototypes */
static int CreateWindow( galaktos_thread_t *p_thread, XVisualInfo *p_vi,
int i_width, int i_height );
static void CreateWindow( galaktos_thread_t *p_thread, XVisualInfo *p_vi,
int i_width, int i_height, int b_fullscreen );
typedef struct
......@@ -45,20 +46,28 @@ glx_data_t;
#define OS_DATA ((glx_data_t*)(p_thread->p_os_data))
int galaktos_glx_init( galaktos_thread_t *p_thread, int i_width, int i_height )
int galaktos_glx_init( galaktos_thread_t *p_thread, int i_width, int i_height,
int b_fullscreen )
{
Display *p_display;
int i_opcode, i_evt, i_err;
int i_maj, i_min;
int i_nbelem;
GLXFBConfig *p_fbconfs, fbconf;
XSetWindowAttributes xattr;
XVisualInfo *p_vi;
GLXContext gwctx;
int i;
GLXPbuffer gpbuf;
#if 1
int p_attr[] = { GLX_RED_SIZE, 5, GLX_GREEN_SIZE, 5,
GLX_BLUE_SIZE, 5, GLX_DOUBLEBUFFER, True,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, 0 };
#else
int p_attr[] = { GLX_RGBA, GLX_RED_SIZE, 5, GLX_GREEN_SIZE, 5,
GLX_BLUE_SIZE, 5, GLX_DOUBLEBUFFER,
0 };
#endif
/* Initialize OS data */
p_thread->p_os_data = malloc( sizeof( glx_data_t ) );
......@@ -89,6 +98,7 @@ int galaktos_glx_init( galaktos_thread_t *p_thread, int i_width, int i_height )
msg_Err( p_thread, "glXQueryVersion failed" );
return -1;
}
#if 1
if( i_maj <= 0 || ((i_maj == 1) && (i_min < 3)) )
{
msg_Err( p_thread, "GLX 1.3 is needed" );
......@@ -116,16 +126,21 @@ int galaktos_glx_init( galaktos_thread_t *p_thread, int i_width, int i_height )
XFree( p_fbconfs );
return -1;
}
/* Create the window */
if( CreateWindow( p_thread, p_vi, i_width, i_height ) == -1 )
#else
p_vi = glXChooseVisual( p_display, DefaultScreen( p_display), p_attr );
if(! p_vi )
{
XFree( p_fbconfs );
XFree( p_vi );
msg_Err( p_thread, "Cannot get GLX 1.2 visual" );
return -1;
}
#endif
/* Create the window */
CreateWindow( p_thread, p_vi, i_width, i_height, b_fullscreen );
XFree( p_vi );
#if 1
/* Create the GLX window */
OS_DATA->gwnd = glXCreateWindow( p_display, fbconf, OS_DATA->wnd, NULL );
if( OS_DATA->gwnd == None )
......@@ -191,10 +206,26 @@ int galaktos_glx_init( galaktos_thread_t *p_thread, int i_width, int i_height )
}
XFree( p_fbconfs );
#else
/* Create an OpenGL context */
OS_DATA->gwctx = gwctx = glXCreateContext( p_display, p_vi, 0, True );
if( !gwctx )
{
msg_Err( p_thread, "Cannot create OpenGL context");
XFree( p_fbconfs );
return -1;
}
XFree( p_vi );
#endif
XMapWindow( p_display, OS_DATA->wnd );
if( b_fullscreen )
{
XMoveWindow( p_display, OS_DATA->wnd, 0, 0 );
}
XFlush( p_display );
glXMakeContextCurrent( p_display, OS_DATA->gwnd, OS_DATA->gwnd, gwctx );
// glXMakeContextCurrent( p_display, OS_DATA->gwnd, OS_DATA->gwnd, gwctx );
// glXMakeCurrent( p_display, OS_DATA->wnd, OS_DATA->gwctx );
return 0;
}
......@@ -229,6 +260,21 @@ int galaktos_glx_handle_events( galaktos_thread_t *p_thread )
}
void galaktos_glx_activate_pbuffer( galaktos_thread_t *p_thread )
{
glXMakeContextCurrent( OS_DATA->p_display, OS_DATA->gpbuf, OS_DATA->gpbuf,
OS_DATA->gpctx );
}
void galaktos_glx_activate_window( galaktos_thread_t *p_thread )
{
glXMakeContextCurrent( OS_DATA->p_display, OS_DATA->gwnd, OS_DATA->gwnd,
OS_DATA->gwctx );
// glXMakeCurrent( OS_DATA->p_display, OS_DATA->wnd, OS_DATA->gwctx );
}
void galaktos_glx_swap( galaktos_thread_t *p_thread )
{
glXSwapBuffers( OS_DATA->p_display, OS_DATA->gwnd );
......@@ -249,13 +295,15 @@ void galaktos_glx_done( galaktos_thread_t *p_thread )
}
int CreateWindow( galaktos_thread_t *p_thread, XVisualInfo *p_vi,
int i_width, int i_height )
void CreateWindow( galaktos_thread_t *p_thread, XVisualInfo *p_vi,
int i_width, int i_height, int b_fullscreen )
{
Display *p_display;
XSetWindowAttributes xattr;
Window wnd;
XSizeHints* p_size_hints;
Atom prop;
mwmhints_t mwmhints;
p_display = OS_DATA->p_display;
/* Create the window */
......@@ -269,17 +317,26 @@ int CreateWindow( galaktos_thread_t *p_thread, XVisualInfo *p_vi,
OS_DATA->wm_delete = XInternAtom( p_display, "WM_DELETE_WINDOW", False );
XSetWMProtocols( p_display, wnd, &OS_DATA->wm_delete, 1 );
/* Prevent the window from being resized */
p_size_hints = XAllocSizeHints();
p_size_hints->flags = PMinSize | PMaxSize;
p_size_hints->min_width = i_width;
p_size_hints->min_height = i_height;
p_size_hints->max_width = i_width;
p_size_hints->max_height = i_height;
XSetWMNormalHints( p_display, wnd, p_size_hints );
XFree( p_size_hints );
if( b_fullscreen )
{
mwmhints.flags = MWM_HINTS_DECORATIONS;
mwmhints.decorations = False;
prop = XInternAtom( p_display, "_MOTIF_WM_HINTS", False );
XChangeProperty( p_display, wnd, prop, prop, 32, PropModeReplace,
(unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS );
}
else
{
/* Prevent the window from being resized */
p_size_hints = XAllocSizeHints();
p_size_hints->flags = PMinSize | PMaxSize;
p_size_hints->min_width = i_width;
p_size_hints->min_height = i_height;
p_size_hints->max_width = i_width;
p_size_hints->max_height = i_height;
XSetWMNormalHints( p_display, wnd, p_size_hints );
XFree( p_size_hints );
}
XSelectInput( p_display, wnd, KeyPressMask );
return 0;
}
......@@ -26,9 +26,29 @@
#include "plugin.h"
int galaktos_glx_init( galaktos_thread_t *p_thread, int i_width, int i_height );
int galaktos_glx_init( galaktos_thread_t *p_thread, int i_width, int i_height,
int b_fullscreen );
void galaktos_glx_done( galaktos_thread_t *p_thread );
int galaktos_glx_handle_events( galaktos_thread_t *p_thread );
void galaktos_glx_activate_pbuffer( galaktos_thread_t *p_thread );
void galaktos_glx_activate_window( galaktos_thread_t *p_thread );
void galaktos_glx_swap( galaktos_thread_t *p_thread );
/*****************************************************************************
* mwmhints_t: window manager hints
*****************************************************************************
* Fullscreen needs to be able to hide the wm decorations so we provide
* this structure to make it easier.
*****************************************************************************/
#define MWM_HINTS_DECORATIONS (1L << 1)
#define PROP_MWM_HINTS_ELEMENTS 5
typedef struct mwmhints_t
{
uint32_t flags;
uint32_t functions;
uint32_t decorations;
int32_t input_mode;
uint32_t status;
} mwmhints_t;
#endif
#ifndef IDLE_PRESET_H
#include "preset_types.h"
#define IDLE_PRESET_H
#define IDLE_PRESET_STRING "[idlepreset]\n"
preset_t * idle_preset;
#endif
/*****************************************************************************
* init_cond.:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
* code from projectM http://xmms-projectm.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* Library functions to manipulate initial condition values */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "fatal.h"
#include "param_types.h"
#include "expr_types.h"
#include "init_cond_types.h"
#include "init_cond.h"
#include "splaytree_types.h"
#include "splaytree.h"
char init_cond_string_buffer[STRING_BUFFER_SIZE];
int init_cond_string_buffer_index = 0;
void init_cond_to_string(init_cond_t * init_cond);
/* Frees initial condition structure */
void free_init_cond(init_cond_t * init_cond) {
free(init_cond);
}
/* Evaluate an initial conditon */
void eval_init_cond(init_cond_t * init_cond) {
if (init_cond == NULL)
return;
/* Parameter is of boolean type, either a 1 or 0 value integer */
/* Set matrix flag to zero. This ensures
its constant value will be used rather than a matrix value
*/
init_cond->param->matrix_flag = 0;
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);
*((int*)init_cond->param->engine_val) = init_cond->init_val.bool_val;
return;
}
/* Parameter is an integer type, just like C */
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);
*((int*)init_cond->param->engine_val) = init_cond->init_val.int_val;
return;
}
/* Parameter is of a double type, just like C */
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);
*((double*)init_cond->param->engine_val) = init_cond->init_val.double_val;
return;
}
/* Unknown type of parameter */
return;
}
/* Creates a new initial condition */
init_cond_t * new_init_cond(param_t * param, value_t init_val) {
init_cond_t * init_cond;
init_cond = (init_cond_t*)malloc(sizeof(init_cond_t));
if (init_cond == NULL)
return NULL;
init_cond->param = param;
init_cond->init_val = init_val;
return init_cond;
}
/* WIP */
void init_cond_to_string(init_cond_t * init_cond) {
int string_length;
char string[MAX_TOKEN_SIZE];
if (init_cond == NULL)
return;
/* Create a string "param_name=val" */
switch (init_cond->param->type) {
case P_TYPE_BOOL:
sprintf(string, "%s=%d\n", init_cond->param->name, init_cond->init_val.bool_val);
break;
case P_TYPE_INT:
sprintf(string, "%s=%d\n", init_cond->param->name, init_cond->init_val.int_val);
break;
case P_TYPE_DOUBLE:
sprintf(string, "%s=%f\n", init_cond->param->name, init_cond->init_val.double_val);
break;
default:
return;
}
/* Compute the length of the string */
string_length = strlen(string);
/* Buffer overflow check */
if ((init_cond_string_buffer_index + string_length + 1) > (STRING_BUFFER_SIZE - 1))
return;
/* Copy the string into the initial condition string buffer */
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
overwritten by the next call to this function */
init_cond_string_buffer_index+= string_length + 1;
}
char * create_init_cond_string_buffer(splaytree_t * init_cond_tree) {
if (init_cond_tree == NULL)
return NULL;
init_cond_string_buffer_index = 0;
splay_traverse(init_cond_to_string, init_cond_tree);
return init_cond_string_buffer;
}
#ifndef INIT_COND_H
#define INIT_COND_H
#define INIT_COND_DEBUG 0
#include "param_types.h"
#include "splaytree_types.h"
void eval_init_cond(init_cond_t * init_cond);
init_cond_t * new_init_cond(param_t * param, value_t init_val);
void free_init_cond(init_cond_t * init_cond);
char * create_init_cond_string_buffer(splaytree_t * init_cond_tree);
#endif
#ifndef INIT_COND_TYPES_H
#define INIT_COND_TYPES_H
#include "param_types.h"
#include "expr_types.h"
typedef struct INIT_COND_T {
struct PARAM_T * param;
value_t init_val;
} init_cond_t;
#endif
#ifndef INTERFACE_TYPES_H
#define INTERFACE_TYPES_H
typedef enum {
MENU_INTERFACE,
SHELL_INTERFACE,
EDITOR_INTERFACE,
DEFAULT_INTERFACE,
BROWSER_INTERFACE
} interface_t;
#endif
This diff is collapsed.
......@@ -24,6 +24,8 @@
#ifndef _GALAKTOS_MAIN_H_
#define _GALAKTOS_MAIN_H_
int galaktos_update( galaktos_thread_t *p_thread, int16_t p_data[2][512] );
int galaktos_init( galaktos_thread_t *p_thread );
void galaktos_done( galaktos_thread_t *p_thread );
int galaktos_update( galaktos_thread_t *p_thread );
#endif
This diff is collapsed.
#ifndef PARAM_H
#define PARAM_H
#include "preset_types.h"
#include "splaytree_types.h"
/* Debug level, zero for none */
#define PARAM_DEBUG 0
/* Used to store a number of decidable type */
/* Function prototypes */
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);
param_t * create_user_param(char * name);
int init_builtin_param_db();
int init_user_param_db();
int destroy_user_param_db();
int destroy_builtin_param_db();
void set_param(param_t * param, double val);
int remove_param(param_t * param);
param_t * find_param(char * name, struct PRESET_T * preset, int flags);
void free_param(param_t * param);
int load_all_builtin_param();
int insert_param(param_t * param, splaytree_t * database);
param_t * find_builtin_param(char * name);
param_t * new_param_double(char * name, short int flags, void * engine_val, void * matrix,
double upper_bound, double lower_bound, double init_val);
param_t * new_param_int(char * name, short int flags, void * engine_val,
int upper_bound, int lower_bound, int init_val);
param_t * new_param_bool(char * name, short int flags, void * engine_val,
int upper_bound, int lower_bound, int init_val);
param_t * find_param_db(char * name, splaytree_t * database, int create_flag);
#endif
#ifndef PARAM_TYPES_H
#define PARAM_TYPES_H
#include "expr_types.h"
#define P_CREATE 1
#define P_NONE 0
#define P_TYPE_BOOL 0
#define P_TYPE_INT 1
#define P_TYPE_DOUBLE 2
#define P_FLAG_NONE 0
#define P_FLAG_READONLY 1
#define P_FLAG_USERDEF (1 << 1)
#define P_FLAG_QVAR (1 << 2)
#define P_FLAG_TVAR (1 << 3)
#define P_FLAG_ALWAYS_MATRIX (1 << 4)
#define P_FLAG_DONT_FREE_MATRIX (1 << 5)
#define P_FLAG_PER_PIXEL (1 << 6)
#define P_FLAG_PER_POINT (1 << 7)
typedef union VALUE_T {
int bool_val;
int int_val;
double double_val;
} value_t;
/* Parameter Type */
typedef struct PARAM_T {
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 flags; /* read, write, user defined, etc */
short int matrix_flag; /* for optimization purposes */
void * engine_val; /* pointer to the engine variable */
void * matrix; /* per pixel / per point matrix for this variable */
value_t default_init_val; /* a default initial condition value */
value_t upper_bound; /* this parameter's upper bound */
value_t lower_bound; /* this parameter's lower bound */
} param_t;
#endif
This diff is collapsed.
#ifndef PARSER_H
#define PARSER_H
#define PARSE_DEBUG 0
#include "expr_types.h"
#include "per_frame_eqn_types.h"
#include "init_cond_types.h"
#include "preset_types.h"
per_frame_eqn_t * parse_per_frame_eqn(FILE * fs, int index, struct PRESET_T * preset);
int parse_per_pixel_eqn(FILE * fs, preset_t * preset);
init_cond_t * parse_init_cond(FILE * fs, char * name, struct PRESET_T * preset);
int parse_preset_name(FILE * fs, char * name);
int parse_top_comment(FILE * fs);
int parse_line(FILE * fs, struct PRESET_T * preset);
#endif
This diff is collapsed.
#ifndef PER_FRAME_EQN_H
#define PER_FRAME_EQN_H
#define PER_FRAME_EQN_DEBUG 0
per_frame_eqn_t * new_per_frame_eqn(int index, param_t * param, struct GEN_EXPR_T * gen_expr);
void eval_per_frame_eqn(per_frame_eqn_t * per_frame_eqn);
void free_per_frame_eqn(per_frame_eqn_t * per_frame_eqn);
void eval_per_frame_init_eqn(per_frame_eqn_t * per_frame_eqn);
#endif
#ifndef PER_FRAME_EQN_TYPES_H
#define PER_FRAME_EQN_TYPES_H
#include "param_types.h"
#include "expr_types.h"
typedef struct PER_FRAME_EQN_T {
int index;
struct PARAM_T * param; /* parameter to be assigned a value */
struct GEN_EXPR_T * gen_expr; /* expression that paremeter is equal to */
} per_frame_eqn_t;
#endif
This diff is collapsed.
#ifndef PER_PIXEL_EQN_H
#define PER_PIXEL_EQN_H
#include "expr_types.h"
#include "preset_types.h"
#define PER_PIXEL_EQN_DEBUG 0
inline void evalPerPixelEqns();
inline int isPerPixelEqn(int index);
int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, struct PRESET_T * preset);
void free_per_pixel_eqn(per_pixel_eqn_t * per_pixel_eqn);
per_pixel_eqn_t * new_per_pixel_eqn(int index, param_t * param, gen_expr_t * gen_expr);
inline int resetPerPixelEqnFlags();
#endif
#ifndef PER_PIXEL_EQN_TYPES_H
#define PER_PIXEL_EQN_TYPES_H
/* This is sort of ugly, but it is also the fastest way to access the per pixel equations */
#include "common.h"
#include "expr_types.h"
typedef struct PER_PIXEL_EQN_T {
int index; /* used for splay tree ordering. */
int flags; /* primarily to specify if this variable is user-defined */
param_t * param;
gen_expr_t * gen_expr;
} per_pixel_eqn_t;
#define ZOOM_OP 0
#define ZOOMEXP_OP 1
#define ROT_OP 2
#define CX_OP 3
#define CY_OP 4
#define SX_OP 5
#define SY_OP 6
#define DX_OP 7
#define DY_OP 8
#define WARP_OP 9
#define NUM_OPS 10 /* obviously, this number is dependent on the number of existing per pixel operations */
#endif
#ifndef PER_POINT_EQN_TYPES_H
#define PER_POINT_EQN_TYPES_H
#include "custom_wave_types.h"
typedef struct PER_POINT_EQN {
custom_wave_t * custom_wave;
} per_point_eqn_t;
#endif
This diff is collapsed.
......@@ -32,21 +32,14 @@
typedef struct
{
VLC_COMMON_MEMBERS
vout_thread_t *p_vout;
char *psz_title;
vlc_mutex_t lock;
vlc_cond_t wait;
/* Audio properties */
int i_channels;
/* Audio samples queue */
block_t *pp_blocks[MAX_BLOCKS];
int i_blocks;
int i_channels;
audio_date_t date;
int16_t p_data[2][512];
int i_cur_sample;
/* OS specific data */
void *p_os_data;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
void setup_opengl( int w, int h );
void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarget);
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