OLD | NEW |
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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 l_image_comp = p_tcd->image->comps; | 699 l_image_comp = p_tcd->image->comps; |
700 | 700 |
701 p = p_tile_no % l_cp->tw; /* tile coordinates */ | 701 p = p_tile_no % l_cp->tw; /* tile coordinates */ |
702 q = p_tile_no / l_cp->tw; | 702 q = p_tile_no / l_cp->tw; |
703 /*fprintf(stderr, "Tile coordinate = %d,%d\n", p, q);*/ | 703 /*fprintf(stderr, "Tile coordinate = %d,%d\n", p, q);*/ |
704 | 704 |
705 /* 4 borders of the tile rescale on the image if necessary */ | 705 /* 4 borders of the tile rescale on the image if necessary */ |
706 l_tx0 = l_cp->tx0 + p * l_cp->tdx; /* can't be greater than l_image->x1
so won't overflow */ | 706 l_tx0 = l_cp->tx0 + p * l_cp->tdx; /* can't be greater than l_image->x1
so won't overflow */ |
707 l_tile->x0 = (OPJ_INT32)opj_uint_max(l_tx0, l_image->x0); | 707 l_tile->x0 = (OPJ_INT32)opj_uint_max(l_tx0, l_image->x0); |
708 l_tile->x1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_tx0, l_cp->tdx), l_
image->x1); | 708 l_tile->x1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_tx0, l_cp->tdx), l_
image->x1); |
| 709 if (l_tile->x0 < 0 || l_tile->x1 < 0) { |
| 710 return OPJ_FALSE; |
| 711 } |
| 712 |
709 l_ty0 = l_cp->ty0 + q * l_cp->tdy; /* can't be greater than l_image->y1
so won't overflow */ | 713 l_ty0 = l_cp->ty0 + q * l_cp->tdy; /* can't be greater than l_image->y1
so won't overflow */ |
710 l_tile->y0 = (OPJ_INT32)opj_uint_max(l_ty0, l_image->y0); | 714 l_tile->y0 = (OPJ_INT32)opj_uint_max(l_ty0, l_image->y0); |
711 l_tile->y1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_ty0, l_cp->tdy), l_
image->y1); | 715 l_tile->y1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_ty0, l_cp->tdy), l_
image->y1); |
| 716 if (l_tile->y0 < 0 || l_tile->y1 < 0) { |
| 717 return OPJ_FALSE; |
| 718 } |
712 | 719 |
713 /* testcase 1888.pdf.asan.35.988 */ | 720 /* testcase 1888.pdf.asan.35.988 */ |
714 if (l_tccp->numresolutions == 0) { | 721 if (l_tccp->numresolutions == 0) { |
715 opj_event_msg(manager, EVT_ERROR, "tiles require at least one re
solution\n"); | 722 opj_event_msg(manager, EVT_ERROR, "tiles require at least one re
solution\n"); |
716 return OPJ_FALSE; | 723 return OPJ_FALSE; |
717 } | 724 } |
718 /*fprintf(stderr, "Tile border = %d,%d,%d,%d\n", l_tile->x0, l_tile->y0,
l_tile->x1,l_tile->y1);*/ | 725 /*fprintf(stderr, "Tile border = %d,%d,%d,%d\n", l_tile->x0, l_tile->y0,
l_tile->x1,l_tile->y1);*/ |
719 | 726 |
720 /*tile->numcomps = image->numcomps; */ | 727 /*tile->numcomps = image->numcomps; */ |
721 for (compno = 0; compno < l_tile->numcomps; ++compno) { | 728 for (compno = 0; compno < l_tile->numcomps; ++compno) { |
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2222 } | 2229 } |
2223 break; | 2230 break; |
2224 } | 2231 } |
2225 | 2232 |
2226 ++l_img_comp; | 2233 ++l_img_comp; |
2227 ++l_tilec; | 2234 ++l_tilec; |
2228 } | 2235 } |
2229 | 2236 |
2230 return OPJ_TRUE; | 2237 return OPJ_TRUE; |
2231 } | 2238 } |
OLD | NEW |