Subversion Repositories filter_foundry

Rev

Rev 511 | Rev 515 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 511 Rev 512
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.com.au
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 FF_H_
21
#ifndef FF_H_
22
#define FF_H_
22
#define FF_H_
23
 
23
 
24
#include "world.h"
24
#include "world.h"
25
 
25
 
26
#include "PIFilter.h"
26
#include "PIFilter.h"
27
 
27
 
28
#include "entry.h"
28
#include "entry.h"
29
 
29
 
30
#include "choosefile.h"
30
#include "choosefile.h"
31
#include "ui.h"
31
#include "ui.h"
32
#include "file_compat.h"
32
#include "file_compat.h"
33
#include "symtab.h"
33
#include "symtab.h"
34
#include "PARM.h"
34
#include "PARM.h"
35
#include "preview.h"
35
#include "preview.h"
36
#include "ff_misc.h"
36
#include "ff_misc.h"
37
#include "language.h"
37
#include "language.h"
38
 
38
 
39
#define HOSTSIG_GIMP 'PMIG' // sic: NOT 'GIMP'
39
#define HOSTSIG_GIMP 'PMIG' // sic: NOT 'GIMP'
40
#define HOSTSIG_IRFANVIEW 'UP20'
40
#define HOSTSIG_IRFANVIEW 'UP20'
41
#define HOSTSIG_PHOTOSHOP '8BIM'
41
#define HOSTSIG_PHOTOSHOP '8BIM'
42
//#define HOSTSIG_PLUGINCOMMANDER '8BIM' // meh.
42
//#define HOSTSIG_PLUGINCOMMANDER '8BIM' // meh.
43
//#define HOSTSIG_SERIF_PHOTOPLUS '8BIM' // meh.
43
//#define HOSTSIG_SERIF_PHOTOPLUS '8BIM' // meh.
44
#define HOSTSIG_JASC_PAINTSHOP_PRO_X 'PSP9'
44
#define HOSTSIG_JASC_PAINTSHOP_PRO_X 'PSP9'
45
#define HOSTSIG_PAINT_NET 'NDP.'
45
#define HOSTSIG_PAINT_NET 'NDP.'
46
#define HOSTSIG_ADOBE_PREMIERE '8B)M'/*sic*/
46
#define HOSTSIG_ADOBE_PREMIERE '8B)M'/*sic*/
47
 
47
 
48
enum{
48
enum{
49
        TAB = 011,
49
        TAB = 011,
50
        LF  = 012,
50
        LF  = 012,
51
        CR  = 015,
51
        CR  = 015,
52
 
52
 
53
        CHUNK_ROWS = 64,
53
        CHUNK_ROWS = 64,
54
 
54
 
55
        TEXT_FILETYPE = 'TEXT',
55
        TEXT_FILETYPE = 'TEXT',
56
        SIG_SIMPLETEXT = 'ttxt',
56
        SIG_SIMPLETEXT = 'ttxt',
57
        PS_FILTER_FILETYPE = '8BFM'
57
        PS_FILTER_FILETYPE = '8BFM'
58
};
58
};
59
 
59
 
60
#ifdef _WIN32
60
#ifdef _WIN32
61
typedef struct none_slider_info_ {
61
typedef struct none_slider_info_ {
62
        BOOL initialized;
62
        BOOL initialized;
63
} none_slider_info;
63
} none_slider_info;
64
 
64
 
65
typedef struct comctl_slider_info_ {
65
typedef struct comctl_slider_info_ {
66
        BOOL initialized;
66
        BOOL initialized;
67
        HMODULE hLib;
67
        HMODULE hLib;
68
} comctl_slider_info;
68
} comctl_slider_info;
69
 
69
 
70
typedef struct plugin_dll_slider_info_ {
70
typedef struct plugin_dll_slider_info_ {
71
        BOOL initialized;
71
        BOOL initialized;
72
        HMODULE hLib;
72
        HMODULE hLib;
73
        DWORD messageId;
73
        DWORD messageId;
74
} plugin_dll_slider_info;
74
} plugin_dll_slider_info;
75
#endif
75
#endif
76
 
76
 
77
// The "gdata" structure contains all values which MUST be kept between filter invocations.
77
// The "gdata" structure contains all values which MUST be kept between filter invocations.
78
// All other working-data (which automatically gets calculated etc.) are NOT part of this structure.
78
// All other working-data (which automatically gets calculated etc.) are NOT part of this structure.
79
// To increase performance, the lookup tables *tantab and *costab have been included here, so that
79
// To increase performance, the lookup tables *tantab and *costab have been included here, so that
80
// they only need to be calculated one.
80
// they only need to be calculated one.
81
// size: 0x2098 (8344 Bytes) for 32-bit
81
// size: 0x2098 (8344 Bytes) for 32-bit
82
// size: 0x20AC (8364 Bytes) for 64-bit
82
// size: 0x20AC (8364 Bytes) for 64-bit
83
typedef struct globals_t_ {
83
typedef struct globals_t_ {
84
        PARM_T parm;
84
        PARM_T parm;
85
        Boolean standalone;
85
        Boolean standalone;
86
        Boolean parmloaded; // this means that the filter is loaded, but without PARM (title, author, etc.)
86
        Boolean parmloaded; // this means that the filter is loaded, but without PARM (title, author, etc.)
87
        Boolean obfusc;
87
        Boolean obfusc;
88
        // (padding of 1 byte here)
88
        // (padding of 1 byte here)
89
        OSType lastKnownBufferVersion;
89
        OSType lastKnownBufferVersion;
90
        OSType lastKnownHandleVersion;
90
        OSType lastKnownHandleVersion;
91
        double* tantab;
91
        double* tantab;
92
        double* costab;
92
        double* costab;
93
#ifdef _WIN32
93
#ifdef _WIN32
94
        HWND hWndMainDlg;
94
        HWND hWndMainDlg;
95
        none_slider_info noneSliderInfo;
95
        none_slider_info noneSliderInfo;
96
        comctl_slider_info comctlSliderInfo;
96
        comctl_slider_info comctlSliderInfo;
97
        plugin_dll_slider_info pluginDllSliderInfo;
97
        plugin_dll_slider_info pluginDllSliderInfo;
98
#endif /* _WIN32 */
98
#endif /* _WIN32 */
99
} globals_t;
99
} globals_t;
100
 
100
 
101
extern globals_t *gdata;
101
extern globals_t *gdata;
102
 
102
 
103
#define NUM_CELLS 0x100
103
#define NUM_CELLS 0x100
104
 
104
 
105
extern struct node *tree[4];
105
extern struct node *tree[4];
106
extern TCHAR *err[4];
106
extern TCHAR *err[4];
107
extern int errpos[4],errstart[4];//,nplanes;
107
extern int errpos[4],errstart[4];//,nplanes;
108
extern uint8_t slider[8];
108
extern uint8_t slider[8];
109
extern value_type cell[NUM_CELLS];
109
extern value_type cell[NUM_CELLS];
110
extern char *expr[4];
110
extern char *expr[4];
111
 
111
 
112
extern int tokpos,tokstart,varused[];
112
extern int tokpos,tokstart,varused[];
113
extern TCHAR *errstr;
113
extern TCHAR *errstr;
114
 
114
 
115
//#define DEBUG
115
//#define DEBUG
116
 
116
 
117
typedef struct InternalState_ {
117
typedef struct InternalState_ {
118
        Boolean bak_obfusc;
118
        Boolean bak_obfusc;
119
        Boolean bak_standalone;
119
        Boolean bak_standalone;
120
        Boolean bak_parmloaded;
120
        Boolean bak_parmloaded;
121
        char* bak_expr[4];
121
        char* bak_expr[4];
122
        uint8_t bak_slider[8];
122
        uint8_t bak_slider[8];
123
        PARM_T bak_parm;
123
        PARM_T bak_parm;
124
} InternalState;
124
} InternalState;
125
 
125
 
126
// from main.c
126
// from main.c
127
unsigned long get_parm_hash(PARM_T *parm);
127
unsigned long get_parm_hash(PARM_T *parm);
128
void DoPrepare(FilterRecordPtr epb);
128
void DoPrepare(FilterRecordPtr epb);
129
void DoStart(FilterRecordPtr epb);
129
void DoStart(FilterRecordPtr epb);
130
OSErr DoContinue(FilterRecordPtr epb);
130
OSErr DoContinue(FilterRecordPtr epb);
131
void DoFinish(FilterRecordPtr epb);
131
void DoFinish(FilterRecordPtr epb);
132
void RequestNext(FilterRecordPtr epb);
132
void RequestNext(FilterRecordPtr epb);
133
InternalState saveInternalState();
133
InternalState saveInternalState();
134
void restoreInternalState(InternalState state);
134
void restoreInternalState(InternalState state);
135
 
135
 
136
// from read.c
136
// from read.c
137
Boolean readparams_afs_pff(Handle h, TCHAR**reason);
137
Boolean readparams_afs_pff(Handle h, TCHAR**reason);
138
void convert_premiere_to_photoshop(PARM_T* photoshop, PARM_T_PREMIERE* premiere);
138
void convert_premiere_to_photoshop(PARM_T* photoshop, PARM_T_PREMIERE* premiere);
139
Boolean readfile_8bf(StandardFileReply *sfr, TCHAR**reason);
139
Boolean readfile_8bf(StandardFileReply *sfr, TCHAR**reason);
140
Handle readfileintohandle(FILEREF r);
140
Handle readfileintohandle(FILEREF r);
141
Boolean readfile_afs_pff(StandardFileReply* sfr, TCHAR** reason);
141
Boolean readfile_afs_pff(StandardFileReply* sfr, TCHAR** reason);
142
Boolean readfile_ffx(StandardFileReply* sfr, TCHAR** reason);
142
Boolean readfile_ffx(StandardFileReply* sfr, TCHAR** reason);
143
Boolean readfile_picotxt(StandardFileReply* sfr, TCHAR** reason);
143
Boolean readfile_picotxt(StandardFileReply* sfr, TCHAR** reason);
144
Boolean readPARM(PARM_T* parm,Ptr h);
144
Boolean readPARM(PARM_T* parm,Ptr h);
145
 
145
 
146
// from save.c
146
// from save.c
147
OSErr saveparams_afs_pff(Handle h);
147
OSErr saveparams_afs_pff(Handle h);
148
OSErr saveparams_picotxt(Handle h, Boolean useparm);
148
OSErr saveparams_picotxt(Handle h, Boolean useparm);
149
OSErr savehandleintofile(Handle h,FILEREF r);
149
OSErr savehandleintofile(Handle h,FILEREF r);
150
Boolean savefile_afs_pff_picotxt(StandardFileReply *sfr);
150
Boolean savefile_afs_pff_picotxt(StandardFileReply *sfr);
151
 
151
 
152
// from make_*.c
152
// from make_*.c
153
OSErr make_standalone(StandardFileReply *sfr);
153
OSErr make_standalone(StandardFileReply *sfr);
154
 
154
 
155
// from process.c
155
// from process.c
156
Boolean setup(FilterRecordPtr pb);
156
Boolean setup(FilterRecordPtr pb);
157
void evalpixel(unsigned char *outp,unsigned char *inp);
157
void evalpixel(unsigned char *outp,unsigned char *inp);
158
 
158
 
159
// from ui.c
-
 
160
void strcpy_win_replace_ampersand(char* dst, char* src);
-
 
161
 
-
 
162
// from make.c
159
// from make.c
163
unsigned long printablehash(unsigned long hash);
160
unsigned long printablehash(unsigned long hash);
164
size_t fixpipl(PIPropertyList *pipl,size_t origsize,char* title, char* category, long *event_id);
161
size_t fixpipl(PIPropertyList *pipl,size_t origsize,char* title, char* category, long *event_id);
165
size_t aete_generate(void* aeteptr, PARM_T *pparm, long event_id);
162
size_t aete_generate(void* aeteptr, PARM_T *pparm, long event_id);
166
 
163
 
167
// from obfusc.c
164
// from obfusc.c
168
#ifdef _MSC_VER
165
#ifdef _MSC_VER
169
__declspec(noinline)
166
__declspec(noinline)
170
#endif
167
#endif
171
uint64_t GetObfuscSeed();
168
uint64_t GetObfuscSeed();
172
#ifdef _MSC_VER
169
#ifdef _MSC_VER
173
__declspec(noinline)
170
__declspec(noinline)
174
#endif
171
#endif
175
uint64_t GetObfuscSeed2();
172
uint64_t GetObfuscSeed2();
176
#ifdef WIN_ENV
173
#ifdef WIN_ENV
177
Boolean obfusc_seed_replace(FSSpec* dst, uint64_t search1, uint64_t search2, uint64_t replace1, uint64_t replace2, int maxamount1, int maxamount2);
174
Boolean obfusc_seed_replace(FSSpec* dst, uint64_t search1, uint64_t search2, uint64_t replace1, uint64_t replace2, int maxamount1, int maxamount2);
178
#endif
175
#endif
179
int obfuscation_version(PARM_T* pparm);
176
int obfuscation_version(PARM_T* pparm);
180
void obfusc(PARM_T* pparm, uint64_t* out_initial_seed, uint64_t* out_initial_seed2);
177
void obfusc(PARM_T* pparm, uint64_t* out_initial_seed, uint64_t* out_initial_seed2);
181
void deobfusc(PARM_T* pparm);
178
void deobfusc(PARM_T* pparm);
182
 
179
 
183
// from loadfile_*.c
180
// from loadfile_*.c
184
Boolean loadfile(StandardFileReply *sfr, TCHAR**reason);
181
Boolean loadfile(StandardFileReply *sfr, TCHAR**reason);
185
Boolean readPARMresource(HMODULE hm, TCHAR**reason);
182
Boolean readPARMresource(HMODULE hm, TCHAR**reason);
186
 
183
 
187
// from main.c
184
// from main.c
188
int64_t maxspace();
185
int64_t maxspace();
189
Boolean maxspace_available();
186
Boolean maxspace_available();
190
Boolean host_preserves_parameters();
187
Boolean host_preserves_parameters();
191
 
188
 
192
// from parser.y
189
// from parser.y
193
struct node *parseexpr(char *s);
190
struct node *parseexpr(char *s);
194
 
191
 
195
// from funcs.c
192
// from funcs.c
196
void factory_initialize_rnd_variables();
193
void factory_initialize_rnd_variables();
197
 
194
 
198
// Useful macros
195
// Useful macros
199
 
196
 
200
// Note: "bigDocumentData->PluginUsing32BitCoordinates" will be set by filterSelectorStart, if HAS_BIG_DOC(pb) is true
197
// Note: "bigDocumentData->PluginUsing32BitCoordinates" will be set by filterSelectorStart, if HAS_BIG_DOC(pb) is true
201
#define HAS_BIG_DOC(x) ((x)->bigDocumentData != NULL)
198
#define HAS_BIG_DOC(x) ((x)->bigDocumentData != NULL)
202
 
199
 
203
#define BIGDOC_IMAGE_SIZE(x) ((x)->bigDocumentData->imageSize32)
200
#define BIGDOC_IMAGE_SIZE(x) ((x)->bigDocumentData->imageSize32)
204
#define IMAGE_SIZE(x) ((x)->imageSize)
201
#define IMAGE_SIZE(x) ((x)->imageSize)
205
 
202
 
206
#define BIGDOC_FILTER_RECT(x) ((x)->bigDocumentData->filterRect32)
203
#define BIGDOC_FILTER_RECT(x) ((x)->bigDocumentData->filterRect32)
207
#define FILTER_RECT(x) ((x)->filterRect)
204
#define FILTER_RECT(x) ((x)->filterRect)
208
 
205
 
209
#define BIGDOC_IN_RECT(x) ((x)->bigDocumentData->inRect32)
206
#define BIGDOC_IN_RECT(x) ((x)->bigDocumentData->inRect32)
210
#define IN_RECT(x) ((x)->inRect)
207
#define IN_RECT(x) ((x)->inRect)
211
 
208
 
212
#define BIGDOC_OUT_RECT(x) ((x)->bigDocumentData->outRect32)
209
#define BIGDOC_OUT_RECT(x) ((x)->bigDocumentData->outRect32)
213
#define OUT_RECT(x) ((x)->outRect)
210
#define OUT_RECT(x) ((x)->outRect)
214
 
211
 
215
#define BIGDOC_MASK_RECT(x) ((x)->bigDocumentData->maskRect32)
212
#define BIGDOC_MASK_RECT(x) ((x)->bigDocumentData->maskRect32)
216
#define MASK_RECT(x) ((x)->maskRect)
213
#define MASK_RECT(x) ((x)->maskRect)
217
 
214
 
218
#define BIGDOC_FLOAT_COORD(x) ((x)->bigDocumentData->floatCoord32)
215
#define BIGDOC_FLOAT_COORD(x) ((x)->bigDocumentData->floatCoord32)
219
#define FLOAT_COORD(x) ((x)->floatCoord)
216
#define FLOAT_COORD(x) ((x)->floatCoord)
220
 
217
 
221
#define BIGDOC_WHOLE_SIZE(x) ((x)->bigDocumentData->wholeSize32)
218
#define BIGDOC_WHOLE_SIZE(x) ((x)->bigDocumentData->wholeSize32)
222
#define WHOLE_SIZE(x) ((x)->wholeSize)
219
#define WHOLE_SIZE(x) ((x)->wholeSize)
223
 
220
 
224
#endif
221
#endif
225
 
222