Move WORDS_BIGENDIAN to ImagingUtils.h

This commit is contained in:
Alexander 2017-08-19 15:30:41 +03:00
parent 00b65ce1c3
commit 58542fdfb9
5 changed files with 18 additions and 22 deletions

View File

@ -22,13 +22,6 @@
#define CLIP(x) ((x) <= 0 ? 0 : (x) < 256 ? (x) : 255)
#ifdef WORDS_BIGENDIAN
#define MAKE_UINT32(u0, u1, u2, u3) (u3 | (u2<<8) | (u1<<16) | (u0<<24))
#else
#define MAKE_UINT32(u0, u1, u2, u3) (u0 | (u1<<8) | (u2<<16) | (u3<<24))
#endif
Imaging
ImagingGetBand(Imaging imIn, int band)
{

View File

@ -509,6 +509,10 @@ extern Py_ssize_t _imaging_tell_pyFd(PyObject *fd);
#define IMAGING_CODEC_CONFIG -8
#define IMAGING_CODEC_MEMORY -9
#include "ImagingUtils.h"
#if defined(__cplusplus)
}
#endif

13
libImaging/ImagingUtils.h Normal file
View File

@ -0,0 +1,13 @@
#ifdef WORDS_BIGENDIAN
#define MAKE_UINT32(u0, u1, u2, u3) (u3 | (u2<<8) | (u1<<16) | (u0<<24))
#define MASK_UINT32_CHANNEL_0 0xff000000
#define MASK_UINT32_CHANNEL_1 0x00ff0000
#define MASK_UINT32_CHANNEL_2 0x0000ff00
#define MASK_UINT32_CHANNEL_3 0x000000ff
#else
#define MAKE_UINT32(u0, u1, u2, u3) (u0 | (u1<<8) | (u2<<16) | (u3<<24))
#define MASK_UINT32_CHANNEL_0 0x000000ff
#define MASK_UINT32_CHANNEL_1 0x0000ff00
#define MASK_UINT32_CHANNEL_2 0x00ff0000
#define MASK_UINT32_CHANNEL_3 0xff000000
#endif

View File

@ -5,12 +5,6 @@
#define ROUND_UP(f) ((int) ((f) >= 0.0 ? (f) + 0.5F : (f) - 0.5F))
#ifdef WORDS_BIGENDIAN
#define MAKE_UINT32(u0, u1, u2, u3) (u3 | (u2<<8) | (u1<<16) | (u0<<24))
#else
#define MAKE_UINT32(u0, u1, u2, u3) (u0 | (u1<<8) | (u2<<16) | (u3<<24))
#endif
struct filter {
double (*filter)(double x);

View File

@ -464,14 +464,6 @@ unpackP4L(UINT8* out, const UINT8* in, int pixels)
}
#ifdef WORDS_BIGENDIAN
#define MAKE_UINT32(u0, u1, u2, u3) (u3 | (u2<<8) | (u1<<16) | (u0<<24))
#define CHANNEL_4_MASK 0x000000ff
#else
#define MAKE_UINT32(u0, u1, u2, u3) (u0 | (u1<<8) | (u2<<16) | (u3<<24))
#define CHANNEL_4_MASK 0xff000000
#endif
/* Unpack to "RGB" image */
void
@ -481,7 +473,7 @@ ImagingUnpackRGB(UINT8* _out, const UINT8* in, int pixels)
UINT32* out = (UINT32*) _out;
/* RGB triplets */
for (; i < pixels-1; i++) {
out[i] = CHANNEL_4_MASK | *(UINT32*)&in[0];
out[i] = MASK_UINT32_CHANNEL_3 | *(UINT32*)&in[0];
in += 3;
}
for (; i < pixels; i++) {