275 {
278
279
280 for (fl::size j = 0; j <
height + 2; ++j) {
284 } else {
287 }
288 }
289
290
291 for (fl::size i = 0; i <
width + 2; ++i) {
294 }
295
296 i32 mCourantSq32 =
static_cast<i32
>(
mCourantSq);
297
298
299
300
302
303
304
305
306
307
308
309
310
311
312
313
314
316 for (fl::size j = 1; j <=
height; ++j) {
317 const fl::size row = j *
stride;
322 for (fl::size i = 1; i <=
width; ++i) {
323 const i32 c = row_curr[i];
324 i32 laplacian;
325 if (nine_point) {
326
327
328
329
330
331 const i32 diag = (i32)row_above[i - 1] + row_above[i + 1] +
332 row_below[i - 1] + row_below[i + 1];
333 const i32 nbr = (i32)row_above[i] + row_below[i] +
334 row_curr[i - 1] + row_curr[i + 1];
335 laplacian = diag + (nbr << 2) - 20 * c;
336 } else {
337
338 laplacian = (i32)row_curr[i + 1] + row_curr[i - 1] +
339 row_above[i] + row_below[i] - (c << 2);
340 }
341
342
343
344
345
346 i64 product =
static_cast<i64>(mCourantSq32) * laplacian;
347 i32 term;
348 if (nine_point) {
349
350
351
352
353
354 term = static_cast<i32>((product >> 15) / 6);
355 } else {
356 term = static_cast<i32>(product >> 15);
357 }
358
359 i32 f = -(i32)row_next[i] + (c << 1) + term;
360
361
362
363 f = static_cast<i32>(
365
366
367
368 row_next[i] =
static_cast<i16
>(
fl::clamp(f, q15_min,
static_cast<i32
>(32767)));
369 }
370 }
371
372
374}
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