0

Fix C extension build warnings the painful way

Some bad distributions (Debian) apparently are not good enough to
have a Pillow version from this decade packaged.

Therefore, we need to do it the painful way of prefixing our
symbols and refactoring everything to use them.

A new header file called "utils.h" has been added for this purpose,
and it is included in "overviewer.h".

The following macros have been prefixed with "OV_":
- MIN
- MAX
- CLAMP
- BLEND
- MULDIV255

Additionally, the C extension version was bumped to 56 because 55
was reverted back to 54.
This commit is contained in:
Nicolas F
2019-02-22 12:53:47 +01:00
parent 53fa463838
commit b70f1a012f
8 changed files with 65 additions and 61 deletions

View File

@@ -0,0 +1,17 @@
#ifndef __OV_UTILS_H_INCLUDED__
#define __OV_UTILS_H_INCLUDED__
/* generally useful MAX / MIN macros */
#define OV_MAX(a, b) ((a) > (b) ? (a) : (b))
#define OV_MIN(a, b) ((a) < (b) ? (a) : (b))
#define OV_CLAMP(x, a, b) (OV_MIN(OV_MAX(x, a), b))
/* like (a * b + 127) / 255), but much faster on most platforms
from PIL's _imaging.c */
#define OV_MULDIV255(a, b, tmp)\
(tmp = (a) * (b) + 128, ((((tmp) >> 8) + (tmp)) >> 8))
#define OV_BLEND(mask, in1, in2, tmp1, tmp2)\
(OV_MULDIV255(in1, 255 - mask, tmp1) + OV_MULDIV255(in2, mask, tmp2))
#endif