Fix some calculations in tcd_malloc_encode and tcd_malloc_decode_tile
Fix #388
This commit is contained in:
parent
9cf9018ffc
commit
46440fe368
|
@ -113,8 +113,17 @@ Divide an integer by a power of 2 and round upwards
|
||||||
@return Returns a divided by 2^b
|
@return Returns a divided by 2^b
|
||||||
*/
|
*/
|
||||||
static INLINE int int_ceildivpow2(int a, int b) {
|
static INLINE int int_ceildivpow2(int a, int b) {
|
||||||
return (int)((a + (int64_t)(1 << b) - 1) >> b);
|
return (int)((a + ((int64_t)1 << b) - 1) >> b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
+ Divide a 64bits integer by a power of 2 and round upwards
|
||||||
|
+ @return Returns a divided by 2^b
|
||||||
|
+ */
|
||||||
|
static INLINE int int64_ceildivpow2(int64_t a, int b) {
|
||||||
|
return (int)((a + ((int64_t)1 << b) - 1) >> b);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Divide an integer by a power of 2 and round downwards
|
Divide an integer by a power of 2 and round downwards
|
||||||
@return Returns a divided by 2^b
|
@return Returns a divided by 2^b
|
||||||
|
|
|
@ -276,10 +276,10 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int c
|
||||||
band->y1 = int_ceildivpow2(tilec->y1, levelno);
|
band->y1 = int_ceildivpow2(tilec->y1, levelno);
|
||||||
} else {
|
} else {
|
||||||
/* band border (global) */
|
/* band border (global) */
|
||||||
band->x0 = int_ceildivpow2(tilec->x0 - (1 << levelno) * x0b, levelno + 1);
|
band->x0 = int64_ceildivpow2(tilec->x0 - ((int64_t)x0b << levelno), levelno + 1);
|
||||||
band->y0 = int_ceildivpow2(tilec->y0 - (1 << levelno) * y0b, levelno + 1);
|
band->y0 = int64_ceildivpow2(tilec->y0 - ((int64_t)y0b << levelno), levelno + 1);
|
||||||
band->x1 = int_ceildivpow2(tilec->x1 - (1 << levelno) * x0b, levelno + 1);
|
band->x1 = int64_ceildivpow2(tilec->x1 - ((int64_t)x0b << levelno), levelno + 1);
|
||||||
band->y1 = int_ceildivpow2(tilec->y1 - (1 << levelno) * y0b, levelno + 1);
|
band->y1 = int64_ceildivpow2(tilec->y1 - ((int64_t)y0b << levelno), levelno + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ss = &tccp->stepsizes[resno == 0 ? 0 : 3 * (resno - 1) + bandno + 1];
|
ss = &tccp->stepsizes[resno == 0 ? 0 : 3 * (resno - 1) + bandno + 1];
|
||||||
|
@ -789,10 +789,10 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp,
|
||||||
band->y1 = int_ceildivpow2(tilec->y1, levelno);
|
band->y1 = int_ceildivpow2(tilec->y1, levelno);
|
||||||
} else {
|
} else {
|
||||||
/* band border (global) */
|
/* band border (global) */
|
||||||
band->x0 = int_ceildivpow2(tilec->x0 - (1 << levelno) * x0b, levelno + 1);
|
band->x0 = int64_ceildivpow2(tilec->x0 - ((int64_t)x0b << levelno), levelno + 1);
|
||||||
band->y0 = int_ceildivpow2(tilec->y0 - (1 << levelno) * y0b, levelno + 1);
|
band->y0 = int64_ceildivpow2(tilec->y0 - ((int64_t)y0b << levelno), levelno + 1);
|
||||||
band->x1 = int_ceildivpow2(tilec->x1 - (1 << levelno) * x0b, levelno + 1);
|
band->x1 = int64_ceildivpow2(tilec->x1 - ((int64_t)x0b << levelno), levelno + 1);
|
||||||
band->y1 = int_ceildivpow2(tilec->y1 - (1 << levelno) * y0b, levelno + 1);
|
band->y1 = int64_ceildivpow2(tilec->y1 - ((int64_t)y0b << levelno), levelno + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ss = &tccp->stepsizes[resno == 0 ? 0 : 3 * (resno - 1) + bandno + 1];
|
ss = &tccp->stepsizes[resno == 0 ? 0 : 3 * (resno - 1) + bandno + 1];
|
||||||
|
|
Loading…
Reference in New Issue