| 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 3666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3677 break; | 3677 break; |
| 3678 } | 3678 } |
| 3679 | 3679 |
| 3680 l_remaining_data = p_header_size; | 3680 l_remaining_data = p_header_size; |
| 3681 | 3681 |
| 3682 /* Next Ippm series is a complete series ?*/ | 3682 /* Next Ippm series is a complete series ?*/ |
| 3683 if (l_remaining_data >= l_N_ppm) { | 3683 if (l_remaining_data >= l_N_ppm) { |
| 3684 OPJ_BYTE *new_ppm_data; | 3684 OPJ_BYTE *new_ppm_data; |
| 3685 /* Increase the size of ppm_data to add the new Ippm ser
ies*/ | 3685 /* Increase the size of ppm_data to add the new Ippm ser
ies*/ |
| 3686 assert(l_cp->ppm_data == l_cp->ppm_buffer && "We need pp
m_data and ppm_buffer to be the same when reallocating"); | 3686 assert(l_cp->ppm_data == l_cp->ppm_buffer && "We need pp
m_data and ppm_buffer to be the same when reallocating"); |
| 3687 /* Overflow check */ |
| 3688 if ((l_cp->ppm_len + l_N_ppm) < l_N_ppm) { |
| 3689 opj_free(l_cp->ppm_data); |
| 3690 l_cp->ppm_data = NULL; |
| 3691 l_cp->ppm_buffer = NULL; /* TODO: no need for a
new local variable: ppm_buffer and ppm_data are enough */ |
| 3692 l_cp->ppm_len = 0; |
| 3693 opj_event_msg(p_manager, EVT_ERROR, "Not enough
memory to increase the size of ppm_data to add the new (complete) Ippm series\n"
); |
| 3694 return OPJ_FALSE; |
| 3695 } |
| 3687 new_ppm_data = (OPJ_BYTE *) opj_realloc(l_cp->ppm_data,
l_cp->ppm_len + l_N_ppm); | 3696 new_ppm_data = (OPJ_BYTE *) opj_realloc(l_cp->ppm_data,
l_cp->ppm_len + l_N_ppm); |
| 3688 if (! new_ppm_data) { | 3697 if (! new_ppm_data) { |
| 3689 opj_free(l_cp->ppm_data); | 3698 opj_free(l_cp->ppm_data); |
| 3690 l_cp->ppm_data = NULL; | 3699 l_cp->ppm_data = NULL; |
| 3691 l_cp->ppm_buffer = NULL; /* TODO: no need for a
new local variable: ppm_buffer and ppm_data are enough */ | 3700 l_cp->ppm_buffer = NULL; /* TODO: no need for a
new local variable: ppm_buffer and ppm_data are enough */ |
| 3692 l_cp->ppm_len = 0; | 3701 l_cp->ppm_len = 0; |
| 3693 opj_event_msg(p_manager, EVT_ERROR, "Not enough
memory to increase the size of ppm_data to add the new (complete) Ippm series\n"
); | 3702 opj_event_msg(p_manager, EVT_ERROR, "Not enough
memory to increase the size of ppm_data to add the new (complete) Ippm series\n"
); |
| 3694 return OPJ_FALSE; | 3703 return OPJ_FALSE; |
| 3695 } | 3704 } |
| 3696 l_cp->ppm_data = new_ppm_data; | 3705 l_cp->ppm_data = new_ppm_data; |
| 3697 l_cp->ppm_buffer = l_cp->ppm_data; | 3706 l_cp->ppm_buffer = l_cp->ppm_data; |
| 3698 | 3707 |
| 3699 /* Keep the position of the place where concatenate the
new series */ | 3708 /* Keep the position of the place where concatenate the
new series */ |
| 3700 l_cp->ppm_data_current = &(l_cp->ppm_data[l_cp->ppm_len]
); | 3709 l_cp->ppm_data_current = &(l_cp->ppm_data[l_cp->ppm_len]
); |
| 3701 l_cp->ppm_len += l_N_ppm; | 3710 l_cp->ppm_len += l_N_ppm; |
| 3702 } | 3711 } |
| 3703 | 3712 |
| 3704 } | 3713 } |
| 3705 | 3714 |
| 3706 /* Need to read an incomplete Ippm series*/ | 3715 /* Need to read an incomplete Ippm series*/ |
| 3707 if (l_remaining_data) { | 3716 if (l_remaining_data) { |
| 3708 OPJ_BYTE *new_ppm_data; | 3717 OPJ_BYTE *new_ppm_data; |
| 3709 assert(l_cp->ppm_data == l_cp->ppm_buffer && "We need ppm_data a
nd ppm_buffer to be the same when reallocating"); | 3718 assert(l_cp->ppm_data == l_cp->ppm_buffer && "We need ppm_data a
nd ppm_buffer to be the same when reallocating"); |
| 3719 |
| 3720 /* Overflow check */ |
| 3721 if ((l_cp->ppm_len + l_N_ppm) < l_N_ppm) { |
| 3722 opj_free(l_cp->ppm_data); |
| 3723 l_cp->ppm_data = NULL; |
| 3724 l_cp->ppm_buffer = NULL; /* TODO: no need for a new loc
al variable: ppm_buffer and ppm_data are enough */ |
| 3725 l_cp->ppm_len = 0; |
| 3726 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory t
o increase the size of ppm_data to add the new (complete) Ippm series\n"); |
| 3727 return OPJ_FALSE; |
| 3728 } |
| 3710 new_ppm_data = (OPJ_BYTE *) opj_realloc(l_cp->ppm_data, l_cp->pp
m_len + l_N_ppm); | 3729 new_ppm_data = (OPJ_BYTE *) opj_realloc(l_cp->ppm_data, l_cp->pp
m_len + l_N_ppm); |
| 3711 if (! new_ppm_data) { | 3730 if (! new_ppm_data) { |
| 3712 opj_free(l_cp->ppm_data); | 3731 opj_free(l_cp->ppm_data); |
| 3713 l_cp->ppm_data = NULL; | 3732 l_cp->ppm_data = NULL; |
| 3714 l_cp->ppm_buffer = NULL; /* TODO: no need for a new loc
al variable: ppm_buffer and ppm_data are enough */ | 3733 l_cp->ppm_buffer = NULL; /* TODO: no need for a new loc
al variable: ppm_buffer and ppm_data are enough */ |
| 3715 l_cp->ppm_len = 0; | 3734 l_cp->ppm_len = 0; |
| 3716 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory t
o increase the size of ppm_data to add the new (incomplete) Ippm series\n"); | 3735 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory t
o increase the size of ppm_data to add the new (incomplete) Ippm series\n"); |
| 3717 return OPJ_FALSE; | 3736 return OPJ_FALSE; |
| 3718 } | 3737 } |
| 3719 l_cp->ppm_data = new_ppm_data; | 3738 l_cp->ppm_data = new_ppm_data; |
| (...skipping 4871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8591 /* use custom precinct size ? */ | 8610 /* use custom precinct size ? */ |
| 8592 if (l_tccp->csty & J2K_CCP_CSTY_PRT) { | 8611 if (l_tccp->csty & J2K_CCP_CSTY_PRT) { |
| 8593 if (*p_header_size < l_tccp->numresolutions) { | 8612 if (*p_header_size < l_tccp->numresolutions) { |
| 8594 opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod
SPCoc element\n"); | 8613 opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod
SPCoc element\n"); |
| 8595 return OPJ_FALSE; | 8614 return OPJ_FALSE; |
| 8596 } | 8615 } |
| 8597 | 8616 |
| 8598 for (i = 0; i < l_tccp->numresolutions; ++i) { | 8617 for (i = 0; i < l_tccp->numresolutions; ++i) { |
| 8599 opj_read_bytes(l_current_ptr,&l_tmp ,1);
/* SPcoc (I_i) */ | 8618 opj_read_bytes(l_current_ptr,&l_tmp ,1);
/* SPcoc (I_i) */ |
| 8600 ++l_current_ptr; | 8619 ++l_current_ptr; |
| 8620 /* Precinct exponent 0 is only allowed for lowest resolu
tion level (Table A.21) */ |
| 8621 if ((i != 0) && (((l_tmp & 0xf) == 0) || ((l_tmp >> 4) =
= 0))) { |
| 8622 opj_event_msg(p_manager, EVT_ERROR, "Invalid pre
cinct size\n"); |
| 8623 return OPJ_FALSE; |
| 8624 } |
| 8601 l_tccp->prcw[i] = l_tmp & 0xf; | 8625 l_tccp->prcw[i] = l_tmp & 0xf; |
| 8602 l_tccp->prch[i] = l_tmp >> 4; | 8626 l_tccp->prch[i] = l_tmp >> 4; |
| 8603 } | 8627 } |
| 8604 | 8628 |
| 8605 *p_header_size = *p_header_size - l_tccp->numresolutions; | 8629 *p_header_size = *p_header_size - l_tccp->numresolutions; |
| 8606 } | 8630 } |
| 8607 else { | 8631 else { |
| 8608 /* set default size for the precinct width and height */ | 8632 /* set default size for the precinct width and height */ |
| 8609 for (i = 0; i < l_tccp->numresolutions; ++i) { | 8633 for (i = 0; i < l_tccp->numresolutions; ++i) { |
| 8610 l_tccp->prcw[i] = 15; | 8634 l_tccp->prcw[i] = 15; |
| (...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10467 } | 10491 } |
| 10468 else { | 10492 else { |
| 10469 if (! opj_j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream,
p_manager)) { | 10493 if (! opj_j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream,
p_manager)) { |
| 10470 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k
_post_write_tile with tile index = %d\n", p_tile_index); | 10494 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k
_post_write_tile with tile index = %d\n", p_tile_index); |
| 10471 return OPJ_FALSE; | 10495 return OPJ_FALSE; |
| 10472 } | 10496 } |
| 10473 } | 10497 } |
| 10474 | 10498 |
| 10475 return OPJ_TRUE; | 10499 return OPJ_TRUE; |
| 10476 } | 10500 } |
| OLD | NEW |