Subversion Repositories filter_foundry

Rev

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

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