summaryrefslogtreecommitdiff
path: root/src/lib/openjp2/opj_intmath.h
diff options
context:
space:
mode:
authormayeut <mayeut@users.noreply.github.com>2015-08-23 11:38:04 +0200
committermayeut <mayeut@users.noreply.github.com>2015-08-23 11:38:04 +0200
commit38770403d49528936fae44de5fc6089f0bf0c3e9 (patch)
tree93ad0e4855905d63054b8d253c70531e4b913944 /src/lib/openjp2/opj_intmath.h
parent589cc547b9f32afe7832665f3ec26e73e3452772 (diff)
Fix some calculations in opj_tcd_init_tile
Fixes #486 Fixes #394 Update #480 Update #388
Diffstat (limited to 'src/lib/openjp2/opj_intmath.h')
-rw-r--r--src/lib/openjp2/opj_intmath.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/openjp2/opj_intmath.h b/src/lib/openjp2/opj_intmath.h
index f39f6843..3f7934c4 100644
--- a/src/lib/openjp2/opj_intmath.h
+++ b/src/lib/openjp2/opj_intmath.h
@@ -135,7 +135,15 @@ Divide an integer by a power of 2 and round upwards
@return Returns a divided by 2^b
*/
static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
- return (OPJ_INT32)((a + (OPJ_INT64)(1 << b) - 1) >> b);
+ return (OPJ_INT32)((a + ((OPJ_INT64)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 OPJ_INT32 opj_int64_ceildivpow2(OPJ_INT64 a, OPJ_INT32 b) {
+ return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b);
}
/**
@@ -143,7 +151,7 @@ static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
@return Returns a divided by 2^b
*/
static INLINE OPJ_UINT32 opj_uint_ceildivpow2(OPJ_UINT32 a, OPJ_UINT32 b) {
- return (OPJ_UINT32)((a + (OPJ_UINT64)(1U << b) - 1U) >> b);
+ return (OPJ_UINT32)((a + ((OPJ_UINT64)1U << b) - 1U) >> b);
}
/**
@@ -184,8 +192,8 @@ Multiply two fixed-precision rational numbers.
@return Returns a * b
*/
static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
- OPJ_INT64 temp = __emul(a, b);
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
+ OPJ_INT64 temp = __emul(a, b);
#else
OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
#endif
@@ -196,8 +204,8 @@ static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
}
static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b) {
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
- OPJ_INT64 temp = __emul(a, b);
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
+ OPJ_INT64 temp = __emul(a, b);
#else
OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
#endif