-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathff.h
271 lines (214 loc) · 7.99 KB
/
ff.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*
This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.net
Copyright (C) 2018-2024 Daniel Marschall, ViaThinkSoft
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-1307 USA
*/
#ifndef FF_H_
#define FF_H_
#include "world.h"
#include "PIFilter.h"
#include "entry.h"
#include "choosefile.h"
#include "ui.h"
#include "file_compat.h"
#include "symtab.h"
#include "PARM.h"
#include "preview.h"
#include "ff_misc.h"
#include "language.h"
#define HOSTSIG_GIMP 'PMIG' // sic: NOT 'GIMP'
#define HOSTSIG_IRFANVIEW 'UP20'
#define HOSTSIG_PHOTOSHOP '8BIM'
//#define HOSTSIG_PLUGINCOMMANDER '8BIM' // illegal usage of signature
//#define HOSTSIG_SERIF_PHOTOPLUS '8BIM' // illegal usage of signature
#define HOSTSIG_JASC_PAINTSHOP_PRO_X 'PSP9'
#define HOSTSIG_PAINT_NET 'NDP.'
#define HOSTSIG_ADOBE_PREMIERE '8B)M'/*sic*/
// see also PiPL.rc
#define kViaThinkSoftSignature 'ViaT' // 0x56696154 (inofficial creator code)
#define PIOIDProperty 'ObId' // 0x4f624964
#define TEXT_FILETYPE 'TEXT'
#define SIG_SIMPLETEXT 'ttxt'
#define PS_FILTER_FILETYPE '8BFM'
#define CHUNK_ROWS 64
enum{
TAB = 011,
LF = 012,
CR = 015,
};
#ifdef _WIN32
typedef struct none_slider_info_ {
BOOL initialized;
} none_slider_info;
typedef struct comctl_slider_info_ {
BOOL initialized;
HMODULE hLib;
} comctl_slider_info;
typedef struct plugin_dll_slider_info_ {
BOOL initialized;
HMODULE hLib;
DWORD messageId;
} plugin_dll_slider_info;
#endif
/**
The "gdata" structure contains all values which MUST be kept between filter invocations.
All other working-data (which automatically gets calculated etc.) are NOT part of this structure.
To increase performance, the lookup tables *tantab and *costab have been included here, so that
they only need to be calculated once.
size: 0x2098 (8344 Bytes) for 32-bit
size: 0x20AC (8364 Bytes) for 64-bit
*/
typedef struct globals_t_ {
PARM_T parm;
Boolean obfusc;
// (padding of 3 bytes here)
OSType lastKnownBufferVersion;
OSType lastKnownHandleVersion;
double* tantab;
double* costab;
#ifdef _WIN32
HWND hWndMainDlg;
none_slider_info noneSliderInfo;
comctl_slider_info comctlSliderInfo;
plugin_dll_slider_info pluginDllSliderInfo;
#endif /* _WIN32 */
} globals_t;
extern globals_t *gdata;
#define NUM_CELLS 0x100
extern struct node *tree[4];
extern TCHAR *err[4];
extern int errpos[4],errstart[4];//,nplanes;
extern value_type cell[NUM_CELLS];
extern int tokpos,tokstart,varused[];
extern TCHAR *errstr;
extern int bytesPerPixelChannelIn;
extern int bytesPerPixelChannelOut;
extern value_type maxChannelValueIn;
extern value_type maxChannelValueOut;
#ifndef LOADING_OK
#define LOADING_OK 0
typedef struct {
int msgid; // 0: success, >0: Error, message ID as described in language.h
} FFLoadingResult;
#ifdef __WATCOMC__
static inline FFLoadingResult createFFLoadingResult(int msg_id) {
FFLoadingResult result;
result.msgid = msg_id;
return result;
}
#define FF_LOADING_RESULT(msg_id) createFFLoadingResult(msg_id)
#else
#define FF_LOADING_RESULT(msg_id) ((FFLoadingResult){(msg_id)})
#endif
#endif
#ifndef SAVING_OK
#define SAVING_OK 0
typedef struct {
int msgid; // 0: success, >0: Error, message ID as described in language.h
} FFSavingResult;
#ifdef __WATCOMC__
static inline FFSavingResult createFFSavingResult(int msg_id) {
FFSavingResult result;
result.msgid = msg_id;
return result;
}
#define FF_SAVING_RESULT(msg_id) createFFSavingResult(msg_id)
#else
#define FF_SAVING_RESULT(msg_id) ((FFSavingResult){(msg_id)})
#endif
#endif
//#define DEBUG
typedef struct InternalState_ {
PARM_T bak_parm;
Boolean bak_obfusc;
} InternalState;
// from main.c:
void DoPrepare(FilterRecordPtr epb);
void DoStart(FilterRecordPtr epb);
OSErr DoContinue(FilterRecordPtr epb);
void DoFinish(FilterRecordPtr epb);
void RequestNext(FilterRecordPtr epb);
InternalState saveInternalState(void);
void restoreInternalState(InternalState state);
unsigned long parm_hash(PARM_T* parm);
void parm_reset(Boolean resetMetadata, Boolean resetSliderValues, Boolean resetSliderNames, Boolean resetFormulas);
void parm_cleanup();
// from read.c:
FFLoadingResult readparams_afs_pff(Handle h, Boolean premiereOrder);
void convert_premiere_to_photoshop(PARM_T* photoshop, PARM_T_PREMIERE* premiere);
FFLoadingResult readfile_8bf(StandardFileReply *sfr);
Handle readfileintohandle(FILEREF r);
FFLoadingResult readfile_afs_pff(StandardFileReply* sfr);
FFLoadingResult readfile_ffl(StandardFileReply* sfr);
FFLoadingResult readfile_ffx(StandardFileReply* sfr);
FFLoadingResult readfile_picotxt_or_ffdecomp(StandardFileReply* sfr);
FFLoadingResult readfile_guf(StandardFileReply* sfr);
FFLoadingResult readPARM(PARM_T* parm,Ptr h);
// from save.c:
FFSavingResult saveparams_afs_pff(Handle h, Boolean premiereOrder);
FFSavingResult saveparams_picotxt(Handle h, TCHAR* filename);
FFSavingResult saveparams_guf(Handle h, TCHAR* filename);
OSErr savehandleintofile(Handle h,FILEREF r);
FFSavingResult savefile_afs_pff_picotxt_guf(StandardFileReply *sfr);
// from make_*.c:
OSErr make_standalone(StandardFileReply *sfr);
// from process.c:
Boolean setup(FilterRecordPtr pb);
void evalpixel(unsigned char *outp,unsigned char *inp);
// from make.c:
unsigned long printablehash(unsigned long hash);
size_t fixpipl(PIPropertyList *pipl,size_t origsize,char* title, char* component, char* category, long *event_id);
size_t aete_generate(void* aeteptr, PARM_T *pparm, long event_id);
// from obfusc.c:
#ifdef _MSC_VER
__declspec(noinline)
#endif
uint64_t GetObfuscSeed(void);
#ifdef _MSC_VER
__declspec(noinline)
#endif
uint64_t GetObfuscSeed2(void);
#ifdef WIN_ENV
Boolean obfusc_seed_replace(FSSpec* dst, uint64_t search1, uint64_t search2, uint64_t replace1, uint64_t replace2, int maxamount1, int maxamount2);
#endif
int obfuscation_version(PARM_T* pparm);
void obfusc(PARM_T* pparm, uint64_t* out_initial_seed, uint64_t* out_initial_seed2);
void deobfusc(PARM_T* pparm);
// from loadfile_*.c:
FFLoadingResult loadfile(StandardFileReply *sfr);
FFLoadingResult readPARMresource(HMODULE hm);
// from main.c:
int64_t maxspace(void);
Boolean maxspace_available(void);
Boolean host_preserves_parameters(void);
// from parser.y:
struct node *parseexpr(char *s);
// Useful macros
// Note: "bigDocumentData->PluginUsing32BitCoordinates" will be set by filterSelectorStart, if HAS_BIG_DOC(pb) is true
#define HAS_BIG_DOC(x) ((x)->bigDocumentData != NULL)
#define BIGDOC_IMAGE_SIZE(x) ((x)->bigDocumentData->imageSize32)
#define IMAGE_SIZE(x) ((x)->imageSize)
#define BIGDOC_FILTER_RECT(x) ((x)->bigDocumentData->filterRect32)
#define FILTER_RECT(x) ((x)->filterRect)
#define BIGDOC_IN_RECT(x) ((x)->bigDocumentData->inRect32)
#define IN_RECT(x) ((x)->inRect)
#define BIGDOC_OUT_RECT(x) ((x)->bigDocumentData->outRect32)
#define OUT_RECT(x) ((x)->outRect)
#define BIGDOC_MASK_RECT(x) ((x)->bigDocumentData->maskRect32)
#define MASK_RECT(x) ((x)->maskRect)
#define BIGDOC_FLOAT_COORD(x) ((x)->bigDocumentData->floatCoord32)
#define FLOAT_COORD(x) ((x)->floatCoord)
#define BIGDOC_WHOLE_SIZE(x) ((x)->bigDocumentData->wholeSize32)
#define WHOLE_SIZE(x) ((x)->wholeSize)
#endif