Subversion Repositories filter_foundry

Rev

Rev 297 | Rev 335 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 297 Rev 304
Line 2... Line 2...
2
 
2
 
3
Implementation detail differences
3
Implementation detail differences
4
=================================
4
=================================
5
 
5
 
6
FilterFoundry tries to be as compatible with Filter Factory as possible.
6
Filter Foundry tries to be as compatible with Filter Factory as possible.
7
However, there are some differences which are explained in this documentation.
7
However, there are some differences that are explained in this documentation.
8
 
8
 
9
Various implementations
9
Various implementations
10
-----------------------
10
-----------------------
11
 
11
 
12
In the source-code file funcs.c, some functions are implemented twice:
12
In the source-code file funcs.c, some functions are implemented twice:
Line 15... Line 15...
15
from the "OPER" resource.
15
from the "OPER" resource.
16
(More information at https://misc.daniel-marschall.de/projects/filter_factory/res_oper.html )
16
(More information at https://misc.daniel-marschall.de/projects/filter_factory/res_oper.html )
17
If required, the compiler-definitions `use_filterfactory_implementation_*`
17
If required, the compiler-definitions `use_filterfactory_implementation_*`
18
can be set or unset to select the implementation.
18
can be set or unset to select the implementation.
19
 
19
 
20
In Filter Foundry 1.7.0.8, following functions have been updated to the Filter Factory replica:
20
In Filter Foundry 1.7.0.8, the following functions have been updated to the Filter Factory replica:
21
- `rnd(x)`
21
- `rnd(x)`
22
- `cos(x)`
22
- `cos(x)`
23
- `sin(x)`
23
- `sin(x)`
24
- `tan(x)`
24
- `tan(x)`
25
- `r2x(d,m)`
25
- `r2x(d,m)`
Line 38... Line 38...
38
 
38
 
39
Filter Factory:
39
Filter Factory:
40
 
40
 
41
	sqr(x)=x for x < 0
41
	sqr(x)=x for x < 0
42
	
42
	
43
	Can be tested with following expression:
43
	Can be tested with the following expression:
44
	sqr(-20)+21 == 1
44
	sqr(-20)+21 == 1
45
 
45
 
46
Filter Foundry (prior to 1.7.0.8):
46
Filter Foundry (prior to 1.7.0.8):
47
 
47
 
48
	sqr(x)=0 for x < 0
48
	sqr(x)=0 for x < 0
49
 
49
 
-
 
50
Beginning with Filter Foundry 1.7.0.8, the behavior of Filter Factory was implemented.
-
 
51
 
50
 
52
 
51
i, u, v (Testcase iuv.afs)
53
i, u, v (Testcase iuv.afs)
52
-------
54
-------
53
 
55
 
54
Filter Foundry <1.7 uses the same formulas as in Filter Factory:
56
Filter Foundry <1.7 uses the same formulas as in Filter Factory:
Line 64... Line 66...
64
    v=614777*r-514799*g-99978*b)/2000000     // Output range is -78..78
66
    v=614777*r-514799*g-99978*b)/2000000     // Output range is -78..78
65
 
67
 
66
Both formulas follow the same YUV standard but have different accuracy.
68
Both formulas follow the same YUV standard but have different accuracy.
67
 
69
 
68
 
70
 
-
 
71
I, U, V, imin, umin, vmin (Testcase iuv_minmax.afs)
-
 
72
-------------------------
-
 
73
 
-
 
74
In Filter Foundry 1.7.0.8, the previously undocumented variables I, U, V as well as imin, umin, vmin
-
 
75
have been changed to represent the actual results of the i,u,v variables:
-
 
76
 
-
 
77
    I, imax = 255 (stayed the same)
-
 
78
    U, umax = 55 (was 255 in Filter Factory)
-
 
79
    V, vmax = 78 (was 255 in Filter Factory)
-
 
80
 
-
 
81
    imin = 0 (stayed the same)
-
 
82
    umin = -55 (was 0 in Filter Factory)
-
 
83
    vmin = -78 (was 0 in Filter Factory)
-
 
84
 
-
 
85
 
69
get(i) (Testcase getput.afs)
86
get(i) (Testcase getput.afs)
70
------
87
------
71
 
88
 
72
Filter Foundry:
89
Filter Foundry:
73
 
90
 
Line 103... Line 120...
103
------
120
------
104
 
121
 
105
Filter Factory contains an undocumented function that sets the seed for the random number generator.
122
Filter Factory contains an undocumented function that sets the seed for the random number generator.
106
 
123
 
107
Filter Factory and FilterFoundry beginning with 1.7.0.8 accept a seed between 0 and 32767, inclusively.
124
Filter Factory and Filter Foundry beginning with 1.7.0.8 accept a seed between 0 and 32767, inclusively.
108
If the argument is not within this range, the operation "and 0x7FFF" will be applied to it
125
If the argument is not within this range, the operation lowest 15 bits are taken.
109
to extract the low 15 bits.
-
 
110
 
126
 
111
There are many differences in the implementation between FilterFactory and FilterFoundry in regards rst(i):
127
There are many differences in the implementation between Filter Factory and Filter Foundry in regards rst(i):
112
 
128
 
113
**Filter Factory:**
129
**Filter Factory:**
114
 
130
 
Line 128... Line 144...
128
**Filter Foundry:**
144
**Filter Foundry:**
129
 
145
 
130
In Filter Foundry, the function rnd(a,b) retrieves a random number in "realtime"; therefore, if the
146
In Filter Foundry, the function rnd(a,b) retrieves a random number in "realtime"; therefore, if the
131
seed is changed via rst(i), there is an immediate effect on the next call of the rnd(a,b) function.
147
seed is changed via rst(i), there is an immediate effect on the next call of the rnd(a,b) function.
132
 
148
 
133
For example, following filter would generate an one-colored picture without any randomness:
149
For example, the following filter would generate an one-colored picture without any randomness:
134
        R: rst(123), rnd(0,255)
150
        R: rst(123), rnd(0,255)
135
        G: rnd(0,255)
151
        G: rnd(0,255)
136
        B: rnd(0,255)
152
        B: rnd(0,255)
137
 
153
 
138
If you want to generate a random pixel image with a non-default seed, you need to make sure
154
If you want to generate a random pixel image with a non-default seed, you need to make sure
Line 150... Line 166...
150
 
166
 
151
**Filter Foundry:**
167
**Filter Foundry:**
152
 
168
 
153
Only the branches which will be chosen due to the conditional expression will be evaluated.
169
Only the branches which will be chosen due to the conditional expression will be evaluated.
154
 
170
 
155
This means that following filter would generate a black canvas: (Testcase conditional_eval_1.afs)
171
This means that the following filter would generate a black canvas: (Testcase conditional_eval_1.afs)
156
 
172
 
157
        R: 1==0 ? put(255,0) : 0
173
        R: 1==0 ? put(255,0) : 0
158
        G: get(0)
174
        G: get(0)
159
        B: 0
175
        B: 0
160
 
176
 
Line 172... Line 188...
172
        G: get(0)
188
        G: get(0)
173
        B: 0
189
        B: 0
174
 
190
 
175
**Filter Factory:**
191
**Filter Factory:**
176
 
192
 
177
Each branch inside a if-then-else expression will be evaluated.
193
Each branch inside an if-then-else expression will be evaluated.
178
This means that following filter would generate a green canvas: (Testcase conditional_eval_1.afs)
194
This means that the following filter would generate a green canvas: (Testcase conditional_eval_1.afs)
179
 
195
 
180
        R: 1==0 ? put(255,0) : 0
196
        R: 1==0 ? put(255,0) : 0
181
        G: get(0)
197
        G: get(0)
182
        B: 0
198
        B: 0
183
 
199
 
184
Also, all arguments of an boolean expression will be fully evaluated.
200
Also, all arguments of a boolean expression will be fully evaluated.
185
So, this will also generate a green canvas: (Testcase conditional_eval_2.afs)
201
So, this will also generate a green canvas: (Testcase conditional_eval_2.afs)
186
 
202
 
187
        R: 1==0 && put(255,0) ? 0: 0
203
        R: 1==0 && put(255,0) ? 0: 0
188
        G: get(0)
204
        G: get(0)
189
        B: 0
205
        B: 0