cv::alignPtr()
template<T> T* cv::alignPtr( // Return aligned pointer of type T*
T* ptr, // pointer, unaligned
int n = sizeof(T) // align to block size, a power of 2
);
Given a pointer of any type, this function computes an aligned pointer of the same type according to the
following computation:
(T*)(((size_t)ptr + n+1) & -n)
On some architectures, it is not even possible to read a multi-byte object from an address
that is not evenly divisible by the size of the object (i.e.,.,, by 4 for a 32-bit integer). On
architectures such as x86, this is handled for you automatically by the CPU by using
multiple reads and assembling your value from those reads at the cost of a substantial
penalty in performance.
cv::alignSize()
size_t cv::alignSize( // minimum size >=’sz’ divisible by ‘n’
size_t sz, // size of buffer
int n = sizeof(T) // align to block size, a power of 2
);
Given a number n (typically a return value from sizeof()), and a size ...