VSHelper.h¶
Table of contents¶
Introduction¶
This is a collection of helpful macros and functions.
Macros¶
inline¶
It’s defined to _inline
for Visual Studio’s C mode.
VS_RESTRICT¶
Attempts to provide a portable definition of the C99 restrict
keyword,
or its C++ counterpart.
VS_ALIGNED_MALLOC¶
VS_ALIGNED_MALLOC(pptr, size, alignment)
Expands to _aligned_malloc() in Windows, and posix_memalign() elsewhere. Note that the arguments are in the style of posix_memalign().
pptr is a pointer to a pointer.
VS_ALIGNED_FREE¶
VS_ALIGNED_FREE(ptr)
Expands to _aligned_free() in Windows, and free() elsewhere.
ptr is a pointer.
Functions¶
vs_aligned_malloc¶
-
T *vs_aligned_malloc(size_t size, size_t alignment)¶
A templated aligned malloc for C++. It uses the same functions as the VS_ALIGNED_MALLOC macro but is easier to use.
vs_aligned_free¶
-
void vs_aligned_free(void *ptr)¶
This simply uses the VS_ALIGNED_FREE macro.
isConstantFormat¶
-
static inline int isConstantFormat(const VSVideoInfo *vi)¶
Checks if a clip’s format and dimensions are known (and therefore constant).
isSameFormat¶
-
static inline int isSameFormat(const VSVideoInfo *v1, const VSVideoInfo *v2)¶
Checks if two clips have the same format and dimensions. If the format is unknown in both, it will be considered the same. This is also true for the dimensions.
muldivRational¶
-
static inline void muldivRational(int64_t *num, int64_t *den, int64_t mul, int64_t div)¶
Multiplies two rational numbers and reduces the result, i.e. num/den * mul/div. The result is stored in num and den.
The caller must ensure that div is not 0.
vs_addRational¶
-
static inline void vs_addRational(int64_t *num, int64_t *den, int64_t addnum, int64_t addden)¶
Adds two rational numbers and reduces the result, i.e. num/den + addnum/addden. The result is stored in num and den.
vs_normalizeRational¶
-
static inline void vs_normalizeRational(int64_t *num, int64_t *den)¶
Reduces a rational number.
int64ToIntS¶
-
static inline int int64ToIntS(int64_t i)¶
Converts an int64_t to int with signed saturation. It’s useful to silence warnings when reading integer properties from a VSMap and to avoid unexpected behavior on int overflow.