mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-11 17:56:18 +03:00
MIN and MAX macros in ImagingUtils
This commit is contained in:
parent
7097a9a3b8
commit
7b3179161f
|
@ -63,8 +63,8 @@
|
|||
#define SUB(type, v1, v2) (v1) - (v2)
|
||||
#define MUL(type, v1, v2) (v1) * (v2)
|
||||
|
||||
#define MIN(type, v1, v2) ((v1) < (v2)) ? (v1) : (v2)
|
||||
#define MAX(type, v1, v2) ((v1) > (v2)) ? (v1) : (v2)
|
||||
#define MINOP(type, v1, v2) ((v1) < (v2)) ? (v1) : (v2)
|
||||
#define MAXOP(type, v1, v2) ((v1) > (v2)) ? (v1) : (v2)
|
||||
|
||||
#define AND(type, v1, v2) (v1) & (v2)
|
||||
#define OR(type, v1, v2) (v1) | (v2)
|
||||
|
@ -134,8 +134,8 @@ BINOP(xor_I, XOR, INT32)
|
|||
BINOP(lshift_I, LSHIFT, INT32)
|
||||
BINOP(rshift_I, RSHIFT, INT32)
|
||||
|
||||
BINOP(min_I, MIN, INT32)
|
||||
BINOP(max_I, MAX, INT32)
|
||||
BINOP(min_I, MINOP, INT32)
|
||||
BINOP(max_I, MAXOP, INT32)
|
||||
|
||||
BINOP(eq_I, EQ, INT32)
|
||||
BINOP(ne_I, NE, INT32)
|
||||
|
@ -155,8 +155,8 @@ BINOP(mod_F, MOD_F, FLOAT32)
|
|||
BINOP(pow_F, POW_F, FLOAT32)
|
||||
BINOP(diff_F, DIFF_F, FLOAT32)
|
||||
|
||||
BINOP(min_F, MIN, FLOAT32)
|
||||
BINOP(max_F, MAX, FLOAT32)
|
||||
BINOP(min_F, MINOP, FLOAT32)
|
||||
BINOP(max_F, MAXOP, FLOAT32)
|
||||
|
||||
BINOP(eq_F, EQ, FLOAT32)
|
||||
BINOP(ne_F, NE, FLOAT32)
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
#include "Imaging.h"
|
||||
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
|
||||
typedef UINT8 pixel[4];
|
||||
|
||||
void static inline ImagingLineBoxBlur32(
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
|
||||
#include "Imaging.h"
|
||||
|
||||
#define MAX(a, b) (a) > (b) ? (a) : (b)
|
||||
#define MIN(a, b) (a) < (b) ? (a) : (b)
|
||||
|
||||
#define CLIP16(v) ((v) <= 0 ? 0 : (v) >= 65535 ? 65535 : (v))
|
||||
|
||||
/* ITU-R Recommendation 601-2 (assuming nonlinear RGB) */
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
#define MASK_UINT32_CHANNEL_3 0xff000000
|
||||
#endif
|
||||
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
|
||||
#define SHIFTFORDIV255(a) ((((a) >> 8) + a) >> 8)
|
||||
|
||||
/* like (a * b + 127) / 255), but much faster on most platforms */
|
||||
|
|
|
@ -49,8 +49,6 @@ typedef struct _ColorCube {
|
|||
ColorBucket buckets;
|
||||
} *ColorCube;
|
||||
|
||||
#define MAX(a, b) (a) > (b) ? (a) : (b)
|
||||
|
||||
static ColorCube
|
||||
new_color_cube(int r, int g, int b, int a) {
|
||||
ColorCube cube;
|
||||
|
|
|
@ -69,7 +69,7 @@ _tiffReadProc(thandle_t hdata, tdata_t buf, tsize_t size) {
|
|||
);
|
||||
return 0;
|
||||
}
|
||||
to_read = min(size, min(state->size, (tsize_t)state->eof) - (tsize_t)state->loc);
|
||||
to_read = MIN(size, MIN(state->size, (tsize_t)state->eof) - (tsize_t)state->loc);
|
||||
TRACE(("to_read: %d\n", (int)to_read));
|
||||
|
||||
_TIFFmemcpy(buf, (UINT8 *)state->data + state->loc, to_read);
|
||||
|
@ -87,7 +87,7 @@ _tiffWriteProc(thandle_t hdata, tdata_t buf, tsize_t size) {
|
|||
TRACE(("_tiffWriteProc: %d \n", (int)size));
|
||||
dump_state(state);
|
||||
|
||||
to_write = min(size, state->size - (tsize_t)state->loc);
|
||||
to_write = MIN(size, state->size - (tsize_t)state->loc);
|
||||
if (state->flrealloc && size > to_write) {
|
||||
tdata_t new_data;
|
||||
tsize_t newsize = state->size;
|
||||
|
@ -114,7 +114,7 @@ _tiffWriteProc(thandle_t hdata, tdata_t buf, tsize_t size) {
|
|||
|
||||
_TIFFmemcpy((UINT8 *)state->data + state->loc, buf, to_write);
|
||||
state->loc += (toff_t)to_write;
|
||||
state->eof = max(state->loc, state->eof);
|
||||
state->eof = MAX(state->loc, state->eof);
|
||||
|
||||
dump_state(state);
|
||||
return to_write;
|
||||
|
@ -333,7 +333,7 @@ _decodeAsRGBA(Imaging im, ImagingCodecState state, TIFF *tiff) {
|
|||
|
||||
for (; state->y < state->ysize; state->y += rows_per_block) {
|
||||
img.row_offset = state->y;
|
||||
rows_to_read = min(rows_per_block, img.height - state->y);
|
||||
rows_to_read = MIN(rows_per_block, img.height - state->y);
|
||||
|
||||
if (!TIFFRGBAImageGet(&img, (UINT32 *)state->buffer, img.width, rows_to_read)) {
|
||||
TRACE(("Decode Error, y: %d\n", state->y));
|
||||
|
@ -349,7 +349,7 @@ _decodeAsRGBA(Imaging im, ImagingCodecState state, TIFF *tiff) {
|
|||
|
||||
// iterate over each row in the strip and stuff data into image
|
||||
for (current_row = 0;
|
||||
current_row < min((INT32)rows_per_block, state->ysize - state->y);
|
||||
current_row < MIN((INT32)rows_per_block, state->ysize - state->y);
|
||||
current_row++) {
|
||||
TRACE(("Writing data into line %d ; \n", state->y + current_row));
|
||||
|
||||
|
@ -452,8 +452,8 @@ _decodeTile(
|
|||
|
||||
TRACE(("Read tile at %dx%d; \n\n", x, y));
|
||||
|
||||
current_tile_width = min((INT32)tile_width, state->xsize - x);
|
||||
current_tile_length = min((INT32)tile_length, state->ysize - y);
|
||||
current_tile_width = MIN((INT32)tile_width, state->xsize - x);
|
||||
current_tile_length = MIN((INT32)tile_length, state->ysize - y);
|
||||
// iterate over each line in the tile and stuff data into image
|
||||
for (tile_y = 0; tile_y < current_tile_length; tile_y++) {
|
||||
TRACE(
|
||||
|
@ -566,7 +566,7 @@ _decodeStrip(
|
|||
|
||||
// iterate over each row in the strip and stuff data into image
|
||||
for (strip_row = 0;
|
||||
strip_row < min((INT32)rows_per_strip, state->ysize - state->y);
|
||||
strip_row < MIN((INT32)rows_per_strip, state->ysize - state->y);
|
||||
strip_row++) {
|
||||
TRACE(("Writing data into line %d ; \n", state->y + strip_row));
|
||||
|
||||
|
|
|
@ -13,11 +13,6 @@
|
|||
#include <tiff.h>
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(x, y) ((x > y) ? y : x)
|
||||
#define max(x, y) ((x < y) ? y : x)
|
||||
#endif
|
||||
|
||||
#ifndef _PIL_LIBTIFF_
|
||||
#define _PIL_LIBTIFF_
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user