Subversion Repositories filter_foundry

Rev

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

Rev 293 Rev 301
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-2021 Daniel Marschall, ViaThinkSoft
4
    Copyright (C) 2018-2021 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
#include "world.h"
21
#include "world.h"
22
 
22
 
23
#include "PIFilter.h"
23
#include "PIFilter.h"
24
 
24
 
25
#include "entry.h"
25
#include "entry.h"
26
 
26
 
27
#include "choosefile.h"
27
#include "choosefile.h"
28
#include "ui.h"
28
#include "ui.h"
29
#include "file_compat.h"
29
#include "file_compat.h"
30
#include "symtab.h"
30
#include "symtab.h"
31
#include "PARM.h"
31
#include "PARM.h"
32
#include "preview.h"
32
#include "preview.h"
33
#include "misc.h"
33
#include "misc.h"
34
 
34
 
35
#ifndef INCLUDED_FF_H
35
#ifndef INCLUDED_FF_H
36
#define INCLUDED_FF_H
36
#define INCLUDED_FF_H
37
 
37
 
38
#define HOSTSIG_GIMP 'PMIG' // sic: NOT 'GIMP'
38
#define HOSTSIG_GIMP 'PMIG' // sic: NOT 'GIMP'
39
#define HOSTSIG_IRFANVIEW 'UP20'
39
#define HOSTSIG_IRFANVIEW 'UP20'
40
#define HOSTSIG_PHOTOSHOP '8BIM'
40
#define HOSTSIG_PHOTOSHOP '8BIM'
41
//#define HOSTSIG_PLUGINCOMMANDER '8BIM' // meh.
41
//#define HOSTSIG_PLUGINCOMMANDER '8BIM' // meh.
42
//#define HOSTSIG_SERIF_PHOTOPLUS '8BIM' // meh.
42
//#define HOSTSIG_SERIF_PHOTOPLUS '8BIM' // meh.
43
#define HOSTSIG_JASC_PAINTSHOP_PRO_X 'PSP9'
43
#define HOSTSIG_JASC_PAINTSHOP_PRO_X 'PSP9'
44
#define HOSTSIG_PAINT_NET 'NDP.'
44
#define HOSTSIG_PAINT_NET 'NDP.'
45
#define HOSTSIG_ADOBE_PREMIERE '8B)M'/*sic*/
45
#define HOSTSIG_ADOBE_PREMIERE '8B)M'/*sic*/
46
 
46
 
47
enum{
47
enum{
48
        TAB = 011,
48
        TAB = 011,
49
        LF  = 012,
49
        LF  = 012,
50
        CR  = 015,
50
        CR  = 015,
51
 
51
 
52
        CHUNK_ROWS = 64,
52
        CHUNK_ROWS = 64,
53
 
53
 
54
        PARM_TYPE = 'PARM',
54
        PARM_TYPE = 'PARM',
55
        PARM_ID = 16000,
55
        PARM_ID = 16000,
56
        OBFUSCDATA_ID = 16001,
56
        OBFUSCDATA_ID = 16001,
57
        TEXT_FILETYPE = 'TEXT',
57
        TEXT_FILETYPE = 'TEXT',
58
        SIG_SIMPLETEXT = 'ttxt',
58
        SIG_SIMPLETEXT = 'ttxt',
59
        PS_FILTER_FILETYPE = '8BFM',
59
        PS_FILTER_FILETYPE = '8BFM',
60
 
60
 
61
        // Obfuscated data will be read, but it will not be read if it is additionally protected
61
        // Obfuscated data will be read, but it will not be read if it is additionally protected
62
        READ_OBFUSC = 1
62
        READ_OBFUSC = 1
63
};
63
};
64
 
64
 
65
typedef struct{
65
typedef struct{
66
        Boolean standalone,parmloaded,obfusc;
66
        Boolean standalone,parmloaded,obfusc;
67
        PARM_T parm;
67
        PARM_T parm;
68
        #ifdef _WIN32
68
        #ifdef _WIN32
69
        HWND hWndMainDlg;
69
        HWND hWndMainDlg;
70
        #endif /* _WIN32 */
70
        #endif /* _WIN32 */
71
} globals_t;
71
} globals_t;
72
 
72
 
73
extern globals_t *gdata;
73
extern globals_t *gdata;
74
 
74
 
75
#define NUM_CELLS 0x100
75
#define NUM_CELLS 0x100
76
 
76
 
77
extern struct node *tree[4];
77
extern struct node *tree[4];
78
extern char *err[4];
78
extern char *err[4];
79
extern int errpos[4],errstart[4];//,nplanes;
79
extern int errpos[4],errstart[4];//,nplanes;
80
extern value_type slider[8],cell[NUM_CELLS],map[4][0x100];
80
extern uint8_t slider[8],map[4][0x100];
-
 
81
extern value_type cell[NUM_CELLS];
81
extern char *expr[4];
82
extern char *expr[4];
82
// extern long maxSpace;
83
// extern long maxSpace;
83
 
84
 
84
extern int tokpos,tokstart,varused[];
85
extern int tokpos,tokstart,varused[];
85
extern char *errstr;
86
extern char *errstr;
86
 
87
 
87
#define DBG(x) {}
88
#define DBG(x) {}
88
//#define DEBUG
89
//#define DEBUG
89
 
90
 
90
// from main.c
91
// from main.c
91
unsigned long get_parm_hash(PARM_T *parm);
92
unsigned long get_parm_hash(PARM_T *parm);
92
void DoPrepare (FilterRecordPtr epb);
93
void DoPrepare (FilterRecordPtr epb);
93
void DoStart (FilterRecordPtr epb);
94
void DoStart (FilterRecordPtr epb);
94
OSErr DoContinue (FilterRecordPtr epb);
95
OSErr DoContinue (FilterRecordPtr epb);
95
void DoFinish (FilterRecordPtr epb);
96
void DoFinish (FilterRecordPtr epb);
96
void RequestNext (FilterRecordPtr epb,long);
97
void RequestNext (FilterRecordPtr epb,long);
97
 
98
 
98
// from read.c
99
// from read.c
99
Boolean readparams(Handle h,Boolean alerts,char **reason);
100
Boolean readparams(Handle h,Boolean alerts,char **reason);
100
void convert_premiere_to_photoshop(PARM_T* photoshop, PARM_T_PREMIERE* premiere);
101
void convert_premiere_to_photoshop(PARM_T* photoshop, PARM_T_PREMIERE* premiere);
101
Boolean read8bfplugin(StandardFileReply *sfr,char **reason);
102
Boolean read8bfplugin(StandardFileReply *sfr,char **reason);
102
Handle readfileintohandle(FILEREF r);
103
Handle readfileintohandle(FILEREF r);
103
Boolean readfile(StandardFileReply *sfr,char **reason);
104
Boolean readfile(StandardFileReply *sfr,char **reason);
104
Boolean readPARM(Ptr h,PARM_T *parm,char **reasonstr,int fromwin);
105
Boolean readPARM(Ptr h,PARM_T *parm,char **reasonstr,int fromwin);
105
 
106
 
106
// from save.c
107
// from save.c
107
OSErr saveparams(Handle h);
108
OSErr saveparams(Handle h);
108
OSErr savehandleintofile(Handle h,FILEREF r);
109
OSErr savehandleintofile(Handle h,FILEREF r);
109
Boolean savefile(StandardFileReply *sfr);
110
Boolean savefile(StandardFileReply *sfr);
110
 
111
 
111
// from make_*.c
112
// from make_*.c
112
OSErr make_standalone(StandardFileReply *sfr);
113
OSErr make_standalone(StandardFileReply *sfr);
113
 
114
 
114
// from process.c
115
// from process.c
115
Boolean setup(FilterRecordPtr pb);
116
Boolean setup(FilterRecordPtr pb);
116
void evalpixel(unsigned char *outp,unsigned char *inp);
117
void evalpixel(unsigned char *outp,unsigned char *inp);
117
 
118
 
118
// from make.c
119
// from make.c
119
unsigned long printablehash(unsigned long hash);
120
unsigned long printablehash(unsigned long hash);
120
size_t fixpipl(PIPropertyList *pipl,size_t origsize,StringPtr title, long *event_id);
121
size_t fixpipl(PIPropertyList *pipl,size_t origsize,StringPtr title, long *event_id);
121
size_t aete_generate(void* aeteptr, PARM_T *pparm, long event_id);
122
size_t aete_generate(void* aeteptr, PARM_T *pparm, long event_id);
122
 
123
 
123
// from obfusc.c
124
// from obfusc.c
124
extern const volatile uint32_t cObfuscV4Seed; // this value will be manipulated during the building of each individual filter (see make_win.c)
125
extern const volatile uint32_t cObfuscV4Seed; // this value will be manipulated during the building of each individual filter (see make_win.c)
125
int obfuscation_version(PARM_T* pparm);
126
int obfuscation_version(PARM_T* pparm);
126
unsigned int obfusc(PARM_T* pparm);
127
unsigned int obfusc(PARM_T* pparm);
127
void deobfusc(PARM_T* pparm);
128
void deobfusc(PARM_T* pparm);
128
 
129
 
129
// from loadfile_*.c
130
// from loadfile_*.c
130
Boolean loadfile(StandardFileReply *sfr,char **reason);
131
Boolean loadfile(StandardFileReply *sfr,char **reason);
131
Boolean readPARMresource(HMODULE hm,char **reason,int readobfusc);
132
Boolean readPARMresource(HMODULE hm,char **reason,int readobfusc);
132
 
133
 
133
// from main.c
134
// from main.c
134
int64_t maxspace();
135
int64_t maxspace();
135
Boolean maxspace_available();
136
Boolean maxspace_available();
136
Boolean host_preserves_parameters();
137
Boolean host_preserves_parameters();
137
 
138
 
138
// from parser.y
139
// from parser.y
139
struct node *parseexpr(char *s);
140
struct node *parseexpr(char *s);
140
 
141
 
141
// from funcs.c
142
// from funcs.c
142
void factory_initialize_rnd_variables();
143
void factory_initialize_rnd_variables();
143
 
144
 
144
// Useful macros
145
// Useful macros
145
#define HAS_BIG_DOC(x) ((x)->bigDocumentData != NULL)
146
#define HAS_BIG_DOC(x) ((x)->bigDocumentData != NULL)
146
 
147
 
147
#define BIGDOC_IMAGE_SIZE(x) ((x)->bigDocumentData->imageSize32)
148
#define BIGDOC_IMAGE_SIZE(x) ((x)->bigDocumentData->imageSize32)
148
#define IMAGE_SIZE(x) ((x)->imageSize)
149
#define IMAGE_SIZE(x) ((x)->imageSize)
149
 
150
 
150
#define BIGDOC_FILTER_RECT(x) ((x)->bigDocumentData->filterRect32)
151
#define BIGDOC_FILTER_RECT(x) ((x)->bigDocumentData->filterRect32)
151
#define FILTER_RECT(x) ((x)->filterRect)
152
#define FILTER_RECT(x) ((x)->filterRect)
152
 
153
 
153
#define BIGDOC_IN_RECT(x) ((x)->bigDocumentData->inRect32)
154
#define BIGDOC_IN_RECT(x) ((x)->bigDocumentData->inRect32)
154
#define IN_RECT(x) ((x)->inRect)
155
#define IN_RECT(x) ((x)->inRect)
155
 
156
 
156
#define BIGDOC_OUT_RECT(x) ((x)->bigDocumentData->outRect32)
157
#define BIGDOC_OUT_RECT(x) ((x)->bigDocumentData->outRect32)
157
#define OUT_RECT(x) ((x)->outRect)
158
#define OUT_RECT(x) ((x)->outRect)
158
 
159
 
159
#define BIGDOC_MASK_RECT(x) ((x)->bigDocumentData->maskRect32)
160
#define BIGDOC_MASK_RECT(x) ((x)->bigDocumentData->maskRect32)
160
#define MASK_RECT(x) ((x)->maskRect)
161
#define MASK_RECT(x) ((x)->maskRect)
161
 
162
 
162
#define BIGDOC_FLOAT_COORD(x) ((x)->bigDocumentData->floatCoord32)
163
#define BIGDOC_FLOAT_COORD(x) ((x)->bigDocumentData->floatCoord32)
163
#define FLOAT_COORD(x) ((x)->floatCoord)
164
#define FLOAT_COORD(x) ((x)->floatCoord)
164
 
165
 
165
#define BIGDOC_WHOLE_SIZE(x) ((x)->bigDocumentData->wholeSize32)
166
#define BIGDOC_WHOLE_SIZE(x) ((x)->bigDocumentData->wholeSize32)
166
#define WHOLE_SIZE(x) ((x)->wholeSize)
167
#define WHOLE_SIZE(x) ((x)->wholeSize)
167
 
168
 
168
 
169
 
169
#ifdef _MSC_VER
170
#ifdef _MSC_VER
170
        // Microsoft dumbassery
171
        // Microsoft dumbassery
171
        #define strcasecmp _stricmp
172
        #define strcasecmp _stricmp
172
        #define snprintf _snprintf
173
        #define snprintf _snprintf
173
#endif /* _MSC_VER */
174
#endif /* _MSC_VER */
174
 
175
 
175
#endif /* INCLUDED_FF_H */
176
#endif /* INCLUDED_FF_H */
176
 
177
 
177
 
178