diff --git a/ChangeLog b/ChangeLog index 48349f98..5f65d583 100644 --- a/ChangeLog +++ b/ChangeLog @@ -54,6 +54,8 @@ - meta, header, callback, error, REGION gtkdocs - removed printlines tool, vips2csv is much better - removed other useless tools as well: debugim, binfile +- fix up addr calcs on 64-bit machines with >2gb images and inplace ops + (thanks Christoph) 25/3/09 started 7.18.0 - revised version numbers diff --git a/libvips/include/vips/image.h b/libvips/include/vips/image.h index fb28395f..88805daa 100644 --- a/libvips/include/vips/image.h +++ b/libvips/include/vips/image.h @@ -228,11 +228,14 @@ typedef struct _VipsImage { /* Pixel address calculation macros. */ -#define IM_IMAGE_SIZEOF_ELEMENT(I) ((I)->Bbits >> 3) -#define IM_IMAGE_SIZEOF_PEL(I) \ - (IM_IMAGE_SIZEOF_ELEMENT(I) * (I)->Bands) -#define IM_IMAGE_SIZEOF_LINE(I) (IM_IMAGE_SIZEOF_PEL(I) * (I)->Xsize) -#define IM_IMAGE_N_ELEMENTS(I) ((I)->Bands * (I)->Xsize) +#define IM_IMAGE_SIZEOF_ELEMENT(I) \ + ((size_t)((I)->Bbits >> 3)) +#define IM_IMAGE_SIZEOF_PEL(I) \ + ((size_t)(IM_IMAGE_SIZEOF_ELEMENT(I) * (I)->Bands)) +#define IM_IMAGE_SIZEOF_LINE(I) \ + ((size_t)(IM_IMAGE_SIZEOF_PEL(I) * (I)->Xsize)) +#define IM_IMAGE_N_ELEMENTS(I) \ + ((size_t)((I)->Bands * (I)->Xsize)) /* If DEBUG is defined, add bounds checking. */ @@ -240,7 +243,8 @@ typedef struct _VipsImage { #define IM_IMAGE_ADDR(I,X,Y) \ ( ((X) >= 0 && (X) < (I)->Xsize && \ (Y) >= 0 && (Y) < (I)->Ysize) ? \ - ((I)->data + (Y) * IM_IMAGE_SIZEOF_LINE(I) + \ + ((I)->data + \ + (Y) * IM_IMAGE_SIZEOF_LINE(I) + \ (X) * IM_IMAGE_SIZEOF_PEL(I)) : \ (fprintf( stderr, \ "IM_IMAGE_ADDR: point out of bounds, " \ diff --git a/libvips/include/vips/region.h b/libvips/include/vips/region.h index 4df613a7..61f7d6d9 100644 --- a/libvips/include/vips/region.h +++ b/libvips/include/vips/region.h @@ -131,18 +131,20 @@ int im_wrapmany( IMAGE **in, IMAGE *out, * IM_REGION_SIZEOF_LINE() sizeof width of region * IM_REGION_ADDR() address of pixel in region */ -#define IM_REGION_LSKIP(R) ((R)->bpl) -#define IM_REGION_N_ELEMENTS(R) ((R)->valid.width*(R)->im->Bands) +#define IM_REGION_LSKIP(R) \ + ((size_t)((R)->bpl)) +#define IM_REGION_N_ELEMENTS(R) \ + ((size_t)((R)->valid.width * (R)->im->Bands)) #define IM_REGION_SIZEOF_LINE(R) \ - ((R)->valid.width * IM_IMAGE_SIZEOF_PEL((R)->im)) + ((size_t)((R)->valid.width * IM_IMAGE_SIZEOF_PEL((R)->im))) /* If DEBUG is defined, add bounds checking. */ #ifdef DEBUG #define IM_REGION_ADDR(B,X,Y) \ ( (im_rect_includespoint( &(B)->valid, (X), (Y) ))? \ - ((B)->data + ((Y) - (B)->valid.top)*IM_REGION_LSKIP(B) + \ - ((X) - (B)->valid.left)*IM_IMAGE_SIZEOF_PEL((B)->im)): \ + ((B)->data + ((Y) - (B)->valid.top) * IM_REGION_LSKIP(B) + \ + ((X) - (B)->valid.left) * IM_IMAGE_SIZEOF_PEL((B)->im)): \ (fprintf( stderr, \ "IM_REGION_ADDR: point out of bounds, " \ "file \"%s\", line %d\n" \ diff --git a/libvips/iofuncs/im_open_vips.c b/libvips/iofuncs/im_open_vips.c index 623ca25b..4caebdff 100644 --- a/libvips/iofuncs/im_open_vips.c +++ b/libvips/iofuncs/im_open_vips.c @@ -228,7 +228,7 @@ * IM_IMAGE_N_ELEMENTS: * @I: a #VipsImage * - * Returns: the number of band elements in a scanline. + * Returns: The number of band elements in a scanline. */ /** @@ -243,7 +243,7 @@ * * If DEBUG is defined, you get a version that checks bounds for you. * - * Returns: the address of pixel (x,y) in the image. + * Returns: The address of pixel (x,y) in the image. */ /** diff --git a/libvips/iofuncs/region.c b/libvips/iofuncs/region.c index d2084bdb..1a10e15b 100644 --- a/libvips/iofuncs/region.c +++ b/libvips/iofuncs/region.c @@ -132,21 +132,21 @@ * IM_REGION_LSKIP: * @R: a #REGION * - * Returns: the number of bytes to add to move down a scanline. + * Returns: The number of bytes to add to move down a scanline. */ /** * IM_REGION_N_ELEMENTS: * @R: a #REGION * - * Returns: the number of band elements across a region. + * Returns: The number of band elements across a region. */ /** * IM_REGION_SIZEOF_LINE: * @R: a #REGION * - * Returns: the number of bytes across a region. + * Returns: The number of bytes across a region. */ /** @@ -160,7 +160,7 @@ * * If DEBUG is defined, you get a version that checks bounds for you. * - * Returns: the address of pixel (x,y) in the region. + * Returns: The address of pixel (x,y) in the region. */ /** @@ -170,7 +170,7 @@ * This macro returns a pointer to the top-left pixel in the #REGION, that is, * the pixel at (@R->valid.left, @R->valid.top). * - * Returns: the address of the top-left pixel in the region. + * Returns: The address of the top-left pixel in the region. */ #ifdef DEBUG