libcamera/include
Laurent Pinchart f413f944d7 libcamera: base: utils: Add abs_diff() utility function
The abs_diff() function computes the absolute difference of two
elements. This may seem trivial at first, but can lead to unexpected
results when operating on unsigned operands. A common implementation
of the absolute difference of two unsigned int (used through the
libcamera code base) is

	std::abs(static_cast<int>(a - b))

but doesn't return the expected result when either a or b is larger than
UINT_MAX / 2 due to overflows. The abs_diff() function offers a safe
alternative.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-12-07 19:09:31 +02:00
..
android android: Update Android headers 2021-05-31 19:26:59 +03:00
libcamera libcamera: base: utils: Add abs_diff() utility function 2021-12-07 19:09:31 +02:00
linux include: drm_fourcc: Add R10 and R12 FourCC 2021-11-02 12:06:09 +00:00
meson.build libcamera: Fix base and ipa include dir 2021-09-28 20:09:39 +03:00