Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2134)

Unified Diff: core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_intmath.h

Issue 960183004: Upgrade openjpeg to revision 2997. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_intmath.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_intmath.h b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_intmath.h
index dc89895301f8a63e585d3504fdb681c25e2b9074..4e299469dee73420b473bc56d5523c62dbe6fbf3 100644
--- a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_intmath.h
+++ b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_intmath.h
@@ -82,6 +82,15 @@ static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b) {
}
/**
+ Get the saturated sum of two unsigned integers
+ @return Returns saturated sum of a+b
+ */
+static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b) {
+ OPJ_UINT64 sum = (OPJ_UINT64)a + (OPJ_UINT64)b;
+ return -(OPJ_UINT32)(sum >> 32) | (OPJ_UINT32)sum;
+}
+
+/**
Clamp an integer inside an interval
@return
<ul>
@@ -108,7 +117,7 @@ Divide an integer and round upwards
@return Returns a divided by b
*/
static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) {
- assert(b);
+ assert(b);
return (a + b - 1) / b;
}
@@ -117,6 +126,7 @@ Divide an integer and round upwards
@return Returns a divided by b
*/
static INLINE OPJ_UINT32 opj_uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b) {
+ assert(b);
return (a + b - 1) / b;
}
@@ -165,9 +175,19 @@ Multiply two fixed-precision rational numbers.
@return Returns a * b
*/
static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
- OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
- temp += temp & 4096;
- return (OPJ_INT32) (temp >> 13) ;
+ OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
+ temp += 4096;
+ assert((temp >> 13) <= (OPJ_INT64)0x7FFFFFFF);
+ assert((temp >> 13) >= (-(OPJ_INT64)0x7FFFFFFF - (OPJ_INT64)1));
+ return (OPJ_INT32) (temp >> 13);
+}
+
+static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b) {
+ OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
+ temp += 4096;
+ assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) <= (OPJ_INT64)0x7FFFFFFF);
+ assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) >= (-(OPJ_INT64)0x7FFFFFFF - (OPJ_INT64)1));
+ return (OPJ_INT32) (temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) ;
}
/* ----------------------------------------------------------------------- */

Powered by Google App Engine
This is Rietveld 408576698