libcamera: utils: Add alignUp and alignDown functions
Add to libcamera utils library two functions to round up or down a value to an alignment and add a test in test/utils.cpp for the two new functions. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
@@ -200,6 +200,16 @@ details::StringSplitter split(const std::string &str, const std::string &delim);
|
||||
std::string libcameraBuildPath();
|
||||
std::string libcameraSourcePath();
|
||||
|
||||
constexpr unsigned int alignDown(unsigned int value, unsigned int alignment)
|
||||
{
|
||||
return value / alignment * alignment;
|
||||
}
|
||||
|
||||
constexpr unsigned int alignUp(unsigned int value, unsigned int alignment)
|
||||
{
|
||||
return (value + alignment - 1) / alignment * alignment;
|
||||
}
|
||||
|
||||
} /* namespace utils */
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
Reference in New Issue
Block a user