278 {
281
282
283 for (fl::size j = 0; j <
height + 2; ++j) {
287 } else {
290 }
291 }
292
293
294 for (fl::size i = 0; i <
width + 2; ++i) {
297 }
298
299 i32 mCourantSq32 =
static_cast<i32
>(
mCourantSq);
300
301
302
303
305
306
307
308
309
310
311
312
313
314
315
316
317
319 for (fl::size j = 1; j <=
height; ++j) {
320 const fl::size row = j *
stride;
325 for (fl::size i = 1; i <=
width; ++i) {
326 const i32 c = row_curr[i];
327 i32 laplacian;
328 if (nine_point) {
329
330
331
332
333
334 const i32 diag = (i32)row_above[i - 1] + row_above[i + 1] +
335 row_below[i - 1] + row_below[i + 1];
336 const i32 nbr = (i32)row_above[i] + row_below[i] +
337 row_curr[i - 1] + row_curr[i + 1];
338 laplacian = diag + nbr * 4 - 20 * c;
339 } else {
340
341 laplacian = (i32)row_curr[i + 1] + row_curr[i - 1] +
342 row_above[i] + row_below[i] - c * 4;
343 }
344
345
346
347
348
349 i64 product =
static_cast<i64>(mCourantSq32) * laplacian;
350 i32 term;
351 if (nine_point) {
352
353
354
355
356
357 term = static_cast<i32>((product >> 15) / 6);
358 } else {
359 term = static_cast<i32>(product >> 15);
360 }
361
362 i32 f = -(i32)row_next[i] + c * 2 + term;
363
364
365
366 f = static_cast<i32>(
368
369
370
371 row_next[i] =
static_cast<i16
>(
fl::clamp(f, q15_min,
static_cast<i32
>(32767)));
372 }
373 }
374
375
377}
LaplacianStencil mStencil
#define FL_RESTRICT_PARAM
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NO_EXCEPT