Fix incorrect decoding of image with large number of progression levels
[openjpeg.git] / src / lib / openjp2 / opj_intmath.h
index f8cc6139a11bed063e367e5ecb0ed9f567977bd9..cce7a3cafa720d5cae928fad7d317d20edf58aee 100644 (file)
@@ -173,6 +173,17 @@ static INLINE OPJ_UINT32  opj_uint_ceildiv(OPJ_UINT32  a, OPJ_UINT32  b)
     return (OPJ_UINT32)(((OPJ_UINT64)a + b - 1) / b);
 }
 
+/**
+Divide an integer and round upwards
+@return Returns a divided by b
+*/
+static INLINE OPJ_UINT32  opj_uint64_ceildiv_res_uint32(OPJ_UINT64 a,
+        OPJ_UINT64 b)
+{
+    assert(b);
+    return (OPJ_UINT32)((a + b - 1) / b);
+}
+
 /**
 Divide an integer by a power of 2 and round upwards
 @return Returns a divided by 2^b
@@ -277,7 +288,7 @@ static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b)
 }
 
 /**
-Addtion two signed integers with a wrap-around behaviour.
+Addition two signed integers with a wrap-around behaviour.
 Assumes complement-to-two signed integers.
 @param a
 @param b