@@ -147,8 +147,7 @@ class DeepCKeymix : public DeepFilterOp
147
147
if (!input0 ())
148
148
return ;
149
149
150
- ChannelSet requestChannels = channels;
151
- requestChannels += Mask_Deep;
150
+ ChannelSet requestChannels = _processChannelSet;
152
151
requests.push_back (RequestData (input0 (), box, requestChannels, count));
153
152
154
153
if (_aOp != nullptr )
@@ -163,17 +162,20 @@ class DeepCKeymix : public DeepFilterOp
163
162
164
163
bool doDeepEngine (DD::Image::Box box, const ChannelSet &requestedChannels, DeepOutputPlane &plane) override
165
164
{
165
+
166
+ ChannelSet process = requestedChannels;
167
+ process += _processChannelSet;
168
+
166
169
DeepOp *_bOp = input0 ();
167
170
if (!_bOp)
168
171
return true ;
169
172
170
173
DeepPlane bPlane;
171
- if (!_bOp->deepEngine (box, requestedChannels , bPlane))
174
+ if (!_bOp->deepEngine (box, process , bPlane))
172
175
return false ;
173
176
174
- DeepInPlaceOutputPlane outPlane (requestedChannels , box);
177
+ DeepInPlaceOutputPlane outPlane (process , box);
175
178
outPlane.reserveSamples (bPlane.getTotalSampleCount ());
176
-
177
179
if (_bypass)
178
180
{
179
181
for (Box::iterator it = box.begin (), itEnd = box.end (); it != itEnd; ++it)
@@ -200,7 +202,7 @@ class DeepCKeymix : public DeepFilterOp
200
202
else
201
203
{
202
204
DeepPlane aPlane;
203
- if (!_aOp->deepEngine (box, requestedChannels , aPlane))
205
+ if (!_aOp->deepEngine (box, process , aPlane))
204
206
return false ;
205
207
206
208
float maskVal;
@@ -217,13 +219,12 @@ class DeepCKeymix : public DeepFilterOp
217
219
{
218
220
_maskOp->get (it.y , box.x (), box.r (), maskChannel, maskRow);
219
221
maskVal = maskRow[maskChannel][it.x ];
220
- maskVal = clamp (maskVal);
222
+ maskVal = clamp (maskVal, 0 . 0f , 1 . 0f );
221
223
currentYRow = it.y ;
222
224
}
223
225
else
224
226
{
225
- maskVal = maskRow[maskChannel][it.x ];
226
- maskVal = clamp (maskVal);
227
+ maskVal = clamp (maskRow[maskChannel][it.x ], 0 .0f , 1 .0f );
227
228
}
228
229
229
230
if (invertMask)
@@ -235,15 +236,14 @@ class DeepCKeymix : public DeepFilterOp
235
236
DeepPixel bPixel = bPlane.getPixel (it);
236
237
237
238
size_t inPixelSamples;
238
-
239
239
int aSampleNo = aPixel.getSampleCount ();
240
240
int bSampleNo = bPixel.getSampleCount ();
241
241
242
242
if (maskVal == 0 .0f )
243
243
{
244
244
inPixelSamples = bSampleNo;
245
245
}
246
- else if (maskVal * mix = = 1 .0f )
246
+ else if (maskVal * mix > = 1 .0f )
247
247
{
248
248
inPixelSamples = aSampleNo;
249
249
}
@@ -268,26 +268,28 @@ class DeepCKeymix : public DeepFilterOp
268
268
float mixing = maskVal * mix;
269
269
for (size_t sampleNo = 0 ; sampleNo < inPixelSamples; sampleNo++)
270
270
{
271
- foreach (z, requestedChannels )
271
+ foreach (z, process )
272
272
{
273
+ float &outData = outPixel.getWritableUnorderedSample (sampleNo, z);
274
+
273
275
int cIndex = colourIndex (z);
274
276
275
- float &outData = outPixel.getWritableUnorderedSample (sampleNo, z);
276
- if (maskVal == 0 .0f )
277
+ if ((mixing <= 0 .0f ))
277
278
{
278
279
outData = bPixel.getUnorderedSample (sampleNo, z);
279
280
}
280
- else if (mixing == 1 .0f )
281
- {
282
- outData = aPixel.getUnorderedSample (sampleNo, z);
283
- }
284
- else
281
+ if ((mixing > 0 .0f ) && (mixing < 1 .0f ))
285
282
{
283
+ if ((z == Chan_DeepFront) || (z == Chan_DeepBack))
284
+ continue ;
285
+
286
+ float bInData = 0 .0f ;
287
+
286
288
if (sampleNo < bSampleNo)
287
289
{
288
- const float & bInData = bInPixelChannels.contains (z)
289
- ? bPixel.getUnorderedSample (sampleNo, z)
290
- : 0 .0f ;
290
+ bInData = bInPixelChannels.contains (z)
291
+ ? bPixel.getUnorderedSample (sampleNo, z)
292
+ : 0 .0f ;
291
293
292
294
outData = (1 .0f - mixing) * bInData;
293
295
}
@@ -296,9 +298,13 @@ class DeepCKeymix : public DeepFilterOp
296
298
const float &aInData = aInPixelChannels.contains (z)
297
299
? aPixel.getUnorderedSample (sampleNo - bSampleNo, z)
298
300
: 0 .0f ;
299
- outData = aInData * mixing;
301
+ outData = ( aInData * mixing) + bInData ;
300
302
}
301
303
}
304
+ if (mixing >= 1 .0f )
305
+ {
306
+ outData = aPixel.getUnorderedSample (sampleNo, z);
307
+ }
302
308
}
303
309
}
304
310
}
0 commit comments