Subversion Repositories filter_foundry

Rev

Rev 532 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 532 Rev 536
1
/*
1
/*
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
3
    Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au
3
    Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.net
4
    Copyright (C) 2018-2022 Daniel Marschall, ViaThinkSoft
4
    Copyright (C) 2018-2022 Daniel Marschall, ViaThinkSoft
5
 
5
 
6
    This program is free software; you can redistribute it and/or modify
6
    This program is free software; you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
7
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation; either version 2 of the License, or
8
    the Free Software Foundation; either version 2 of the License, or
9
    (at your option) any later version.
9
    (at your option) any later version.
10
 
10
 
11
    This program is distributed in the hope that it will be useful,
11
    This program is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
14
    GNU General Public License for more details.
15
 
15
 
16
    You should have received a copy of the GNU General Public License
16
    You should have received a copy of the GNU General Public License
17
    along with this program; if not, write to the Free Software
17
    along with this program; if not, write to the Free Software
18
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
*/
19
*/
20
 
20
 
21
#ifndef FUNCS_H_
21
#ifndef FUNCS_H_
22
#define FUNCS_H_
22
#define FUNCS_H_
23
 
23
 
24
#include <math.h>
24
#include <math.h>
25
 
25
 
26
// Strict compatibility to Filter Factory by using an alternative
26
// Strict compatibility to Filter Factory by using an alternative
27
// implementation which is a 100% replica of the Filter Factory 3.0.4
27
// implementation which is a 100% replica of the Filter Factory 3.0.4
28
// for Windows.
28
// for Windows.
29
#ifdef WIN_ENV
29
#ifdef WIN_ENV
30
// i, u, and v are intentionally not equal to Filter Factory (this has been documented).
30
// i, u, and v are intentionally not equal to Filter Factory (this has been documented).
31
//#define use_filterfactory_implementation_i
31
//#define use_filterfactory_implementation_i
32
//#define use_filterfactory_implementation_u
32
//#define use_filterfactory_implementation_u
33
//#define use_filterfactory_implementation_v
33
//#define use_filterfactory_implementation_v
34
// umin, umax, vmin, and vmax are intentionally not equal to Filter Factory (this has been documented).
34
// umin, umax, vmin, and vmax are intentionally not equal to Filter Factory (this has been documented).
35
//#define use_filterfactory_implementation_u_minmax
35
//#define use_filterfactory_implementation_u_minmax
36
//#define use_filterfactory_implementation_v_minmax
36
//#define use_filterfactory_implementation_v_minmax
37
// U and V are intentionally not equal to Filter Factory (this has been documented).
37
// U and V are intentionally not equal to Filter Factory (this has been documented).
38
//#define use_filterfactory_implementation_U
38
//#define use_filterfactory_implementation_U
39
//#define use_filterfactory_implementation_V
39
//#define use_filterfactory_implementation_V
40
// dmin and dmax are intentionally not equal to Filter Factory (this has been documented).
40
// dmin and dmax are intentionally not equal to Filter Factory (this has been documented).
41
//#define use_filterfactory_implementation_d_minmax
41
//#define use_filterfactory_implementation_d_minmax
42
// D is intentionally not equal to Filter Factory (this has been documented).
42
// D is intentionally not equal to Filter Factory (this has been documented).
43
//#define use_filterfactory_implementation_D
43
//#define use_filterfactory_implementation_D
44
// get(i) is intentionally not equal to Filter Factory (this has been documented).
44
// get(i) is intentionally not equal to Filter Factory (this has been documented).
45
//#define use_filterfactory_implementation_get
45
//#define use_filterfactory_implementation_get
46
// The following functions are implemented as 100% replicas:
46
// The following functions are implemented as 100% replicas:
47
#define use_filterfactory_implementation_rad
47
#define use_filterfactory_implementation_rad
48
#define use_filterfactory_implementation_rnd
48
#define use_filterfactory_implementation_rnd
49
#define use_filterfactory_implementation_c2d
49
#define use_filterfactory_implementation_c2d
50
#define use_filterfactory_implementation_c2m
50
#define use_filterfactory_implementation_c2m
51
#define use_filterfactory_implementation_r2x
51
#define use_filterfactory_implementation_r2x
52
#define use_filterfactory_implementation_r2y
52
#define use_filterfactory_implementation_r2y
53
#define use_filterfactory_implementation_cos
53
#define use_filterfactory_implementation_cos
54
#define use_filterfactory_implementation_sin
54
#define use_filterfactory_implementation_sin
55
#define use_filterfactory_implementation_tan
55
#define use_filterfactory_implementation_tan
56
#define use_filterfactory_implementation_sqr
56
#define use_filterfactory_implementation_sqr
57
#define use_filterfactory_implementation_d
57
#define use_filterfactory_implementation_d
58
#define use_filterfactory_implementation_m
58
#define use_filterfactory_implementation_m
59
#define use_filterfactory_implementation_M
59
#define use_filterfactory_implementation_M
60
#define use_filterfactory_implementation_val
60
#define use_filterfactory_implementation_val
61
#endif
61
#endif
62
 
62
 
63
 
63
 
64
#ifndef M_PI
64
#ifndef M_PI
65
#define M_PI 3.14159265358979323846264338327
65
#define M_PI 3.14159265358979323846264338327
66
#endif
66
#endif
67
 
67
 
68
 
68
 
69
#include "symtab.h"
69
#include "symtab.h"
70
 
70
 
71
#define TANTABSIZE 512
71
#define TANTABSIZE 512
72
#define COSTABSIZE 1024
72
#define COSTABSIZE 1024
73
 
73
 
74
void init_trigtab(void);
74
void init_trigtab(void);
75
 
75
 
76
#define DEG2RAD(x) ((x)*M_PI/180.)
76
#define DEG2RAD(x) ((x)*M_PI/180.)
77
#define RAD2DEG(x) ((x)*180./M_PI)
77
#define RAD2DEG(x) ((x)*180./M_PI)
78
 
78
 
79
/* [trig functions return] an integer between -512 and 512, inclusive (Windows)
79
/* [trig functions return] an integer between -512 and 512, inclusive (Windows)
80
    or -1024 and 1024, inclusive (Mac OS) */
80
    or -1024 and 1024, inclusive (Mac OS) */
81
#ifdef WIN_ENV
81
#ifdef WIN_ENV
82
#define TRIGAMP 512
82
#define TRIGAMP 512
83
#else
83
#else
84
#define TRIGAMP 1024
84
#define TRIGAMP 1024
85
#endif
85
#endif
86
#define FFANGLE(v) ((v)*M_PI/512.)
86
#define FFANGLE(v) ((v)*M_PI/512.)
87
#define TO_FFANGLE(v) ((v)*512./M_PI)
87
#define TO_FFANGLE(v) ((v)*512./M_PI)
88
 
88
 
89
void initialize_rnd_variables(void);
89
void initialize_rnd_variables(void);
90
 
90
 
91
// Functions
91
// Functions
92
value_type ff_src(value_type x,value_type y,value_type z);
92
value_type ff_src(value_type x,value_type y,value_type z);
93
value_type ff_rad(value_type d,value_type m,value_type z);
93
value_type ff_rad(value_type d,value_type m,value_type z);
94
value_type ff_ctl(value_type i);
94
value_type ff_ctl(value_type i);
95
value_type ff_val(value_type i,value_type a,value_type b);
95
value_type ff_val(value_type i,value_type a,value_type b);
96
value_type ff_map(value_type i,value_type n);
96
value_type ff_map(value_type i,value_type n);
97
value_type ff_min(value_type a,value_type b);
97
value_type ff_min(value_type a,value_type b);
98
value_type ff_max(value_type a,value_type b);
98
value_type ff_max(value_type a,value_type b);
99
value_type ff_abs(value_type a);
99
value_type ff_abs(value_type a);
100
value_type ff_add(value_type a,value_type b,value_type c);
100
value_type ff_add(value_type a,value_type b,value_type c);
101
value_type ff_sub(value_type a,value_type b,value_type c);
101
value_type ff_sub(value_type a,value_type b,value_type c);
102
value_type ff_dif(value_type a,value_type b);
102
value_type ff_dif(value_type a,value_type b);
103
value_type ff_rnd(value_type a,value_type b);
103
value_type ff_rnd(value_type a,value_type b);
104
value_type ff_mix(value_type a,value_type b,value_type n,value_type d);
104
value_type ff_mix(value_type a,value_type b,value_type n,value_type d);
105
value_type ff_scl(value_type a,value_type il,value_type ih,
105
value_type ff_scl(value_type a,value_type il,value_type ih,
106
                                  value_type ol,value_type oh);
106
                                  value_type ol,value_type oh);
107
value_type ff_sqr(value_type x);
107
value_type ff_sqr(value_type x);
108
value_type ff_sin(value_type x);
108
value_type ff_sin(value_type x);
109
value_type ff_cos(value_type x);
109
value_type ff_cos(value_type x);
110
value_type ff_tan(value_type x);
110
value_type ff_tan(value_type x);
111
value_type ff_r2x(value_type d,value_type m);
111
value_type ff_r2x(value_type d,value_type m);
112
value_type ff_r2y(value_type d,value_type m);
112
value_type ff_r2y(value_type d,value_type m);
113
value_type ff_c2d(value_type d,value_type m);
113
value_type ff_c2d(value_type d,value_type m);
114
value_type ff_c2m(value_type d,value_type m);
114
value_type ff_c2m(value_type d,value_type m);
115
value_type ff_get(value_type i);
115
value_type ff_get(value_type i);
116
value_type ff_put(value_type v,value_type i);
116
value_type ff_put(value_type v,value_type i);
117
value_type ff_cnv(value_type m11,value_type m12,value_type m13,
117
value_type ff_cnv(value_type m11,value_type m12,value_type m13,
118
                                  value_type m21,value_type m22,value_type m23,
118
                                  value_type m21,value_type m22,value_type m23,
119
                                  value_type m31,value_type m32,value_type m33,
119
                                  value_type m31,value_type m32,value_type m33,
120
                                  value_type d );
120
                                  value_type d );
121
value_type ff_rst(value_type seed);
121
value_type ff_rst(value_type seed);
122
 
122
 
123
// Variables
123
// Variables
124
value_type ff_i(void);
124
value_type ff_i(void);
125
value_type ff_u(void);
125
value_type ff_u(void);
126
value_type ff_v(void);
126
value_type ff_v(void);
127
value_type ff_D(void);
127
value_type ff_D(void);
128
value_type ff_d(void);
128
value_type ff_d(void);
129
value_type ff_M(void);
129
value_type ff_M(void);
130
value_type ff_m(void);
130
value_type ff_m(void);
131
 
131
 
132
extern value_type min_val_i;
132
extern value_type min_val_i;
133
extern value_type max_val_i;
133
extern value_type max_val_i;
134
extern value_type min_val_u;
134
extern value_type min_val_u;
135
extern value_type max_val_u;
135
extern value_type max_val_u;
136
extern value_type min_val_v;
136
extern value_type min_val_v;
137
extern value_type max_val_v;
137
extern value_type max_val_v;
138
extern value_type min_val_d;
138
extern value_type min_val_d;
139
extern value_type max_val_d;
139
extern value_type max_val_d;
140
extern value_type val_D;
140
extern value_type val_D;
141
extern value_type val_I;
141
extern value_type val_I;
142
extern value_type val_U;
142
extern value_type val_U;
143
extern value_type val_V;
143
extern value_type val_V;
144
 
144
 
145
#endif
145
#endif
146
 
146