equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
31 */ |
31 */ |
32 |
32 |
33 #include "mlib_image.h" |
33 #include "mlib_image.h" |
34 #include "mlib_SysMath.h" |
34 #include "mlib_SysMath.h" |
35 #include "mlib_ImageAffine.h" |
35 #include "mlib_ImageAffine.h" |
|
36 #include "safe_math.h" |
|
37 |
36 |
38 |
37 /***************************************************************/ |
39 /***************************************************************/ |
38 mlib_status mlib_AffineEdges(mlib_affine_param *param, |
40 mlib_status mlib_AffineEdges(mlib_affine_param *param, |
39 const mlib_image *dst, |
41 const mlib_image *dst, |
40 const mlib_image *src, |
42 const mlib_image *src, |
81 dstHeight = mlib_ImageGetHeight(dst); |
83 dstHeight = mlib_ImageGetHeight(dst); |
82 srcYStride = mlib_ImageGetStride(src); |
84 srcYStride = mlib_ImageGetStride(src); |
83 dstYStride = mlib_ImageGetStride(dst); |
85 dstYStride = mlib_ImageGetStride(dst); |
84 paddings = mlib_ImageGetPaddings(src); |
86 paddings = mlib_ImageGetPaddings(src); |
85 |
87 |
|
88 /* All the transformation matrix parameters should be finite. if not, return failure */ |
|
89 if (!(IS_FINITE(a) && IS_FINITE(b) && IS_FINITE(c) && IS_FINITE(d) && |
|
90 IS_FINITE(tx) && IS_FINITE(ty))) { |
|
91 return MLIB_FAILURE; |
|
92 } |
|
93 |
86 if (srcWidth >= (1 << 15) || srcHeight >= (1 << 15)) { |
94 if (srcWidth >= (1 << 15) || srcHeight >= (1 << 15)) { |
87 return MLIB_FAILURE; |
95 return MLIB_FAILURE; |
88 } |
96 } |
89 |
97 |
90 div = a * d - b * c; |
98 div = a * d - b * c; |
286 mlib_s32 y2; |
294 mlib_s32 y2; |
287 |
295 |
288 if (dY1 == dY2) |
296 if (dY1 == dY2) |
289 continue; |
297 continue; |
290 |
298 |
|
299 if (!(IS_FINITE(slope))) { |
|
300 continue; |
|
301 } |
|
302 |
291 if (dY1 < 0.0) |
303 if (dY1 < 0.0) |
292 y1 = 0; |
304 y1 = 0; |
293 else { |
305 else { |
294 val0 = dY1 + 1; |
306 val0 = dY1 + 1; |
295 SAT32(y1); |
307 SAT32(y1); |
325 mlib_s32 y1; |
337 mlib_s32 y1; |
326 mlib_s32 y2; |
338 mlib_s32 y2; |
327 |
339 |
328 if (dY1 == dY2) |
340 if (dY1 == dY2) |
329 continue; |
341 continue; |
|
342 |
|
343 if (!(IS_FINITE(slope))) { |
|
344 continue; |
|
345 } |
330 |
346 |
331 if (dY1 < 0.0) |
347 if (dY1 < 0.0) |
332 y1 = 0; |
348 y1 = 0; |
333 else { |
349 else { |
334 val0 = dY1 + 1; |
350 val0 = dY1 + 1; |