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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * The copyright in this software is being made available under the 2-clauses 2 * The copyright in this software is being made available under the 2-clauses
3 * BSD License, included below. This software may be subject to other third 3 * BSD License, included below. This software may be subject to other third
4 * party and contributor rights, including patent rights, and no such rights 4 * party and contributor rights, including patent rights, and no such rights
5 * are granted under this license. 5 * are granted under this license.
6 * 6 *
7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium 7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
8 * Copyright (c) 2002-2014, Professor Benoit Macq 8 * Copyright (c) 2002-2014, Professor Benoit Macq
9 * Copyright (c) 2001-2003, David Janssens 9 * Copyright (c) 2001-2003, David Janssens
10 * Copyright (c) 2002-2003, Yannick Verschueren 10 * Copyright (c) 2002-2003, Yannick Verschueren
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 /** 76 /**
77 Get the maximum of two integers 77 Get the maximum of two integers
78 @return Returns a if a > b else b 78 @return Returns a if a > b else b
79 */ 79 */
80 static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b) { 80 static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b) {
81 return (a > b) ? a : b; 81 return (a > b) ? a : b;
82 } 82 }
83 83
84 /** 84 /**
85 Get the saturated sum of two unsigned integers
86 @return Returns saturated sum of a+b
87 */
88 static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b) {
89 OPJ_UINT64 sum = (OPJ_UINT64)a + (OPJ_UINT64)b;
90 return -(OPJ_UINT32)(sum >> 32) | (OPJ_UINT32)sum;
91 }
92
93 /**
85 Clamp an integer inside an interval 94 Clamp an integer inside an interval
86 @return 95 @return
87 <ul> 96 <ul>
88 <li>Returns a if (min < a < max) 97 <li>Returns a if (min < a < max)
89 <li>Returns max if (a > max) 98 <li>Returns max if (a > max)
90 <li>Returns min if (a < min) 99 <li>Returns min if (a < min)
91 </ul> 100 </ul>
92 */ 101 */
93 static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max) { 102 static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max) {
94 if (a < min) 103 if (a < min)
95 return min; 104 return min;
96 if (a > max) 105 if (a > max)
97 return max; 106 return max;
98 return a; 107 return a;
99 } 108 }
100 /** 109 /**
101 @return Get absolute value of integer 110 @return Get absolute value of integer
102 */ 111 */
103 static INLINE OPJ_INT32 opj_int_abs(OPJ_INT32 a) { 112 static INLINE OPJ_INT32 opj_int_abs(OPJ_INT32 a) {
104 return a < 0 ? -a : a; 113 return a < 0 ? -a : a;
105 } 114 }
106 /** 115 /**
107 Divide an integer and round upwards 116 Divide an integer and round upwards
108 @return Returns a divided by b 117 @return Returns a divided by b
109 */ 118 */
110 static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) { 119 static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) {
111 assert(b); 120 » assert(b);
112 return (a + b - 1) / b; 121 return (a + b - 1) / b;
113 } 122 }
114 123
115 /** 124 /**
116 Divide an integer and round upwards 125 Divide an integer and round upwards
117 @return Returns a divided by b 126 @return Returns a divided by b
118 */ 127 */
119 static INLINE OPJ_UINT32 opj_uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b) { 128 static INLINE OPJ_UINT32 opj_uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b) {
129 assert(b);
120 return (a + b - 1) / b; 130 return (a + b - 1) / b;
121 } 131 }
122 132
123 /** 133 /**
124 Divide an integer by a power of 2 and round upwards 134 Divide an integer by a power of 2 and round upwards
125 @return Returns a divided by 2^b 135 @return Returns a divided by 2^b
126 */ 136 */
127 static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) { 137 static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
128 return (OPJ_INT32)((a + (OPJ_INT64)(1 << b) - 1) >> b); 138 return (OPJ_INT32)((a + (OPJ_INT64)(1 << b) - 1) >> b);
129 } 139 }
(...skipping 28 matching lines...) Expand all
158 return l; 168 return l;
159 } 169 }
160 170
161 /** 171 /**
162 Multiply two fixed-precision rational numbers. 172 Multiply two fixed-precision rational numbers.
163 @param a 173 @param a
164 @param b 174 @param b
165 @return Returns a * b 175 @return Returns a * b
166 */ 176 */
167 static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) { 177 static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
168 OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ; 178 » OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
169 temp += temp & 4096; 179 » temp += 4096;
170 return (OPJ_INT32) (temp >> 13) ; 180 » assert((temp >> 13) <= (OPJ_INT64)0x7FFFFFFF);
181 » assert((temp >> 13) >= (-(OPJ_INT64)0x7FFFFFFF - (OPJ_INT64)1));
182 » return (OPJ_INT32) (temp >> 13);
183 }
184
185 static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b) {
186 » OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
187 » temp += 4096;
188 » assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) <= (OPJ_INT64)0x7FFFFFF F);
189 » assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) >= (-(OPJ_INT64)0x7FFFF FFF - (OPJ_INT64)1));
190 » return (OPJ_INT32) (temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) ;
171 } 191 }
172 192
173 /* ----------------------------------------------------------------------- */ 193 /* ----------------------------------------------------------------------- */
174 /*@}*/ 194 /*@}*/
175 195
176 /*@}*/ 196 /*@}*/
177 197
178 #endif 198 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698