| 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 7990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8001 OPJ_INT32 * l_dest_ptr; | 8001 OPJ_INT32 * l_dest_ptr; |
| 8002 opj_tcd_resolution_t* l_res= 00; | 8002 opj_tcd_resolution_t* l_res= 00; |
| 8003 | 8003 |
| 8004 l_tilec = p_tcd->tcd_image->tiles->comps; | 8004 l_tilec = p_tcd->tcd_image->tiles->comps; |
| 8005 l_image_src = p_tcd->image; | 8005 l_image_src = p_tcd->image; |
| 8006 l_img_comp_src = l_image_src->comps; | 8006 l_img_comp_src = l_image_src->comps; |
| 8007 | 8007 |
| 8008 l_img_comp_dest = p_output_image->comps; | 8008 l_img_comp_dest = p_output_image->comps; |
| 8009 | 8009 |
| 8010 for (i=0; i<l_image_src->numcomps; i++) { | 8010 for (i=0; i<l_image_src->numcomps; i++) { |
| 8011 | |
| 8012 /* Allocate output component buffer if necessary */ | 8011 /* Allocate output component buffer if necessary */ |
| 8013 if (!l_img_comp_dest->data) { | 8012 if (!l_img_comp_dest->data) { |
| 8014 | 8013 OPJ_UINT32 width = l_img_comp_dest->w; |
| 8015 l_img_comp_dest->data = (OPJ_INT32*) opj_calloc(l_img_co
mp_dest->w * l_img_comp_dest->h, sizeof(OPJ_INT32)); | 8014 OPJ_UINT32 height = l_img_comp_dest->h; |
| 8016 if (! l_img_comp_dest->data) { | 8015 const OPJ_UINT32 MAX_SIZE = UINT32_MAX / sizeof(OPJ_INT32); |
| 8017 return OPJ_FALSE; | 8016 if (height == 0 || width > MAX_SIZE / height) { |
| 8018 } | 8017 return OPJ_FALSE; |
| 8018 } |
| 8019 l_img_comp_dest->data = (OPJ_INT32*) opj_calloc(width * heig
ht, sizeof(OPJ_INT32)); |
| 8020 if (!l_img_comp_dest->data) { |
| 8021 return OPJ_FALSE; |
| 8022 } |
| 8019 } | 8023 } |
| 8020 | 8024 |
| 8021 /* Copy info from decoded comp image to output image */ | 8025 /* Copy info from decoded comp image to output image */ |
| 8022 l_img_comp_dest->resno_decoded = l_img_comp_src->resno_decoded; | 8026 l_img_comp_dest->resno_decoded = l_img_comp_src->resno_decoded; |
| 8023 | 8027 |
| 8024 /*-----*/ | 8028 /*-----*/ |
| 8025 /* Compute the precision of the output buffer */ | 8029 /* Compute the precision of the output buffer */ |
| 8026 l_size_comp = l_img_comp_src->prec >> 3; /*(/ 8)*/ | 8030 l_size_comp = l_img_comp_src->prec >> 3; /*(/ 8)*/ |
| 8027 l_remaining = l_img_comp_src->prec & 7; /* (%8) */ | 8031 l_remaining = l_img_comp_src->prec & 7; /* (%8) */ |
| 8028 l_res = l_tilec->resolutions + l_img_comp_src->resno_decoded; | 8032 l_res = l_tilec->resolutions + l_img_comp_src->resno_decoded; |
| (...skipping 2545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10574 return OPJ_FALSE; | 10578 return OPJ_FALSE; |
| 10575 } | 10579 } |
| 10576 if (! opj_j2k_post_write_tile(p_j2k,p_stream,p_manager)) { | 10580 if (! opj_j2k_post_write_tile(p_j2k,p_stream,p_manager)) { |
| 10577 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k
_post_write_tile with tile index = %d\n", p_tile_index); | 10581 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k
_post_write_tile with tile index = %d\n", p_tile_index); |
| 10578 return OPJ_FALSE; | 10582 return OPJ_FALSE; |
| 10579 } | 10583 } |
| 10580 } | 10584 } |
| 10581 | 10585 |
| 10582 return OPJ_TRUE; | 10586 return OPJ_TRUE; |
| 10583 } | 10587 } |
| OLD | NEW |