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 2397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2408 p_j2k->m_specific_param.m_decoder.m_default_tcp; | 2408 p_j2k->m_specific_param.m_decoder.m_default_tcp; |
2409 | 2409 |
2410 /* Make sure room is sufficient */ | 2410 /* Make sure room is sufficient */ |
2411 if (p_header_size < 5) { | 2411 if (p_header_size < 5) { |
2412 opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n"
); | 2412 opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n"
); |
2413 return OPJ_FALSE; | 2413 return OPJ_FALSE; |
2414 } | 2414 } |
2415 | 2415 |
2416 opj_read_bytes(p_header_data,&l_tcp->csty,1); /* Scod */ | 2416 opj_read_bytes(p_header_data,&l_tcp->csty,1); /* Scod */ |
2417 ++p_header_data; | 2417 ++p_header_data; |
| 2418 /* Make sure we know how to decode this */ |
| 2419 if ((l_tcp->csty & ~(OPJ_UINT32)(J2K_CP_CSTY_PRT | J2K_CP_CSTY_SOP | J2K
_CP_CSTY_EPH)) != 0U) { |
| 2420 opj_event_msg(p_manager, EVT_ERROR, "Unknown Scod value in COD m
arker\n"); |
| 2421 return OPJ_FALSE; |
| 2422 } |
2418 opj_read_bytes(p_header_data,&l_tmp,1); /* SGcod
(A) */ | 2423 opj_read_bytes(p_header_data,&l_tmp,1); /* SGcod
(A) */ |
2419 ++p_header_data; | 2424 ++p_header_data; |
2420 l_tcp->prg = (OPJ_PROG_ORDER) l_tmp; | 2425 l_tcp->prg = (OPJ_PROG_ORDER) l_tmp; |
| 2426 /* Make sure progression order is valid */ |
| 2427 if (l_tcp->prg > OPJ_CPRL ) { |
| 2428 opj_event_msg(p_manager, EVT_ERROR, "Unknown progression order i
n COD marker\n"); |
| 2429 l_tcp->prg = OPJ_PROG_UNKNOWN; |
| 2430 } |
2421 opj_read_bytes(p_header_data,&l_tcp->numlayers,2); /* SGcod (B) */ | 2431 opj_read_bytes(p_header_data,&l_tcp->numlayers,2); /* SGcod (B) */ |
2422 p_header_data+=2; | 2432 p_header_data+=2; |
2423 | 2433 |
2424 /* If user didn't set a number layer to decode take the max specify in t
he codestream. */ | 2434 /* If user didn't set a number layer to decode take the max specify in t
he codestream. */ |
2425 if (l_cp->m_specific_param.m_dec.m_layer) { | 2435 if (l_cp->m_specific_param.m_dec.m_layer) { |
2426 l_tcp->num_layers_to_decode = l_cp->m_specific_param.m_dec.m_lay
er; | 2436 l_tcp->num_layers_to_decode = l_cp->m_specific_param.m_dec.m_lay
er; |
2427 } | 2437 } |
2428 else { | 2438 else { |
2429 l_tcp->num_layers_to_decode = l_tcp->numlayers; | 2439 l_tcp->num_layers_to_decode = l_tcp->numlayers; |
2430 } | 2440 } |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3537 | 3547 |
3538 l_cp = &(p_j2k->m_cp); | 3548 l_cp = &(p_j2k->m_cp); |
3539 l_cp->ppm = 1; | 3549 l_cp->ppm = 1; |
3540 | 3550 |
3541 opj_read_bytes(p_header_data,&l_Z_ppm,1); /* Z_ppm */ | 3551 opj_read_bytes(p_header_data,&l_Z_ppm,1); /* Z_ppm */ |
3542 ++p_header_data; | 3552 ++p_header_data; |
3543 --p_header_size; | 3553 --p_header_size; |
3544 | 3554 |
3545 /* First PPM marker */ | 3555 /* First PPM marker */ |
3546 if (l_Z_ppm == 0) { | 3556 if (l_Z_ppm == 0) { |
| 3557 if (l_cp->ppm_data != NULL) { |
| 3558 opj_event_msg(p_manager, EVT_ERROR, "Zppm O already proc
essed. Found twice.\n"); |
| 3559 opj_free(l_cp->ppm_data); |
| 3560 l_cp->ppm_data = NULL; |
| 3561 l_cp->ppm_buffer = NULL; |
| 3562 l_cp->ppm = 0; /* do not use PPM */ |
| 3563 return OPJ_FALSE; |
| 3564 } |
3547 /* We need now at least the Nppm^0 element */ | 3565 /* We need now at least the Nppm^0 element */ |
3548 if (p_header_size < 4) { | 3566 if (p_header_size < 4) { |
3549 opj_event_msg(p_manager, EVT_ERROR, "Error reading PPM m
arker\n"); | 3567 opj_event_msg(p_manager, EVT_ERROR, "Error reading PPM m
arker\n"); |
3550 return OPJ_FALSE; | 3568 return OPJ_FALSE; |
3551 } | 3569 } |
3552 | 3570 |
3553 opj_read_bytes(p_header_data,&l_N_ppm,4); /* First
N_ppm */ | 3571 opj_read_bytes(p_header_data,&l_N_ppm,4); /* First
N_ppm */ |
3554 p_header_data+=4; | 3572 p_header_data+=4; |
3555 p_header_size-=4; | 3573 p_header_size-=4; |
3556 | 3574 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3634 while (l_remaining_data >= l_N_ppm) { | 3652 while (l_remaining_data >= l_N_ppm) { |
3635 /* read a complete Ippm series*/ | 3653 /* read a complete Ippm series*/ |
3636 memcpy(l_cp->ppm_data_current, p_header_data, l_N_ppm); | 3654 memcpy(l_cp->ppm_data_current, p_header_data, l_N_ppm); |
3637 p_header_size -= l_N_ppm; | 3655 p_header_size -= l_N_ppm; |
3638 p_header_data += l_N_ppm; | 3656 p_header_data += l_N_ppm; |
3639 | 3657 |
3640 l_cp->ppm_data_read += l_N_ppm; /* Increase the number of data r
ead*/ | 3658 l_cp->ppm_data_read += l_N_ppm; /* Increase the number of data r
ead*/ |
3641 | 3659 |
3642 if (p_header_size) | 3660 if (p_header_size) |
3643 { | 3661 { |
| 3662 if (p_header_size < 4) { |
| 3663 opj_free(l_cp->ppm_data); |
| 3664 l_cp->ppm_data = NULL; |
| 3665 l_cp->ppm_buffer = NULL; /* TODO: no need for a
new local variable: ppm_buffer and ppm_data are enough */ |
| 3666 l_cp->ppm_len = 0; |
| 3667 l_cp->ppm = 0; |
| 3668 opj_event_msg(p_manager, EVT_ERROR, "Error readi
ng PPM marker\n"); |
| 3669 return OPJ_FALSE; |
| 3670 } |
3644 opj_read_bytes(p_header_data,&l_N_ppm,4);
/* N_ppm^i */ | 3671 opj_read_bytes(p_header_data,&l_N_ppm,4);
/* N_ppm^i */ |
3645 p_header_data+=4; | 3672 p_header_data+=4; |
3646 p_header_size-=4; | 3673 p_header_size-=4; |
3647 } | 3674 } |
3648 else { | 3675 else { |
3649 l_remaining_data = p_header_size; | 3676 l_remaining_data = p_header_size; |
3650 break; | 3677 break; |
3651 } | 3678 } |
3652 | 3679 |
3653 l_remaining_data = p_header_size; | 3680 l_remaining_data = p_header_size; |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4310 else { | 4337 else { |
4311 /* MSD: case commented to support empty SOT marker (PHR data) */ | 4338 /* MSD: case commented to support empty SOT marker (PHR data) */ |
4312 } | 4339 } |
4313 } | 4340 } |
4314 | 4341 |
4315 l_current_data = &(l_tcp->m_data); | 4342 l_current_data = &(l_tcp->m_data); |
4316 l_tile_len = &l_tcp->m_data_size; | 4343 l_tile_len = &l_tcp->m_data_size; |
4317 | 4344 |
4318 /* Patch to support new PHR data */ | 4345 /* Patch to support new PHR data */ |
4319 if (p_j2k->m_specific_param.m_decoder.m_sot_length) { | 4346 if (p_j2k->m_specific_param.m_decoder.m_sot_length) { |
| 4347 /* If we are here, we'll try to read the data after allocation */ |
| 4348 /* Check enough bytes left in stream before allocation */ |
| 4349 if ((OPJ_OFF_T)p_j2k->m_specific_param.m_decoder.m_sot_length > opj_
stream_get_number_byte_left(p_stream)) { |
| 4350 opj_event_msg(p_manager, EVT_ERROR, "Tile part length size incon
sistent with stream length\n"); |
| 4351 return OPJ_FALSE; |
| 4352 } |
4320 if (! *l_current_data) { | 4353 if (! *l_current_data) { |
4321 /* LH: oddly enough, in this path, l_tile_len!=0. | 4354 /* LH: oddly enough, in this path, l_tile_len!=0. |
4322 * TODO: If this was consistant, we could simplify the code to o
nly use realloc(), as realloc(0,...) default to malloc(0,...). | 4355 * TODO: If this was consistant, we could simplify the code to o
nly use realloc(), as realloc(0,...) default to malloc(0,...). |
4323 */ | 4356 */ |
4324 *l_current_data = (OPJ_BYTE*) opj_malloc(p_j2k->m_specific_param
.m_decoder.m_sot_length); | 4357 *l_current_data = (OPJ_BYTE*) opj_malloc(p_j2k->m_specific_param
.m_decoder.m_sot_length); |
4325 } | 4358 } |
4326 else { | 4359 else { |
4327 OPJ_BYTE *l_new_current_data = (OPJ_BYTE *) opj_realloc(*l_curre
nt_data, *l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_length); | 4360 OPJ_BYTE *l_new_current_data = (OPJ_BYTE *) opj_realloc(*l_curre
nt_data, *l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_length); |
4328 if (! l_new_current_data) { | 4361 if (! l_new_current_data) { |
4329 opj_free(*l_current_data); | 4362 opj_free(*l_current_data); |
(...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6110 opj_image_t *image, | 6143 opj_image_t *image, |
6111 opj_event_mgr_t * p_manager) | 6144 opj_event_mgr_t * p_manager) |
6112 { | 6145 { |
6113 OPJ_UINT32 i, j, tileno, numpocs_tile; | 6146 OPJ_UINT32 i, j, tileno, numpocs_tile; |
6114 opj_cp_t *cp = 00; | 6147 opj_cp_t *cp = 00; |
6115 | 6148 |
6116 if(!p_j2k || !parameters || ! image) { | 6149 if(!p_j2k || !parameters || ! image) { |
6117 return OPJ_FALSE; | 6150 return OPJ_FALSE; |
6118 } | 6151 } |
6119 | 6152 |
| 6153 if ((parameters->numresolution <= 0) || (parameters->numresolution > OPJ
_J2K_MAXRLVLS)) { |
| 6154 opj_event_msg(p_manager, EVT_ERROR, "Invalid number of resolutions :
%d not in range [1,%d]\n", parameters->numresolution, OPJ_J2K_MAXRLVLS); |
| 6155 return OPJ_FALSE; |
| 6156 } |
| 6157 |
6120 /* keep a link to cp so that we can destroy it later in j2k_destroy_comp
ress */ | 6158 /* keep a link to cp so that we can destroy it later in j2k_destroy_comp
ress */ |
6121 cp = &(p_j2k->m_cp); | 6159 cp = &(p_j2k->m_cp); |
6122 | 6160 |
6123 /* set default values for cp */ | 6161 /* set default values for cp */ |
6124 cp->tw = 1; | 6162 cp->tw = 1; |
6125 cp->th = 1; | 6163 cp->th = 1; |
6126 | 6164 |
6127 /* FIXME ADE: to be removed once deprecated cp_cinema and cp_rsiz have b
een removed */ | 6165 /* FIXME ADE: to be removed once deprecated cp_cinema and cp_rsiz have b
een removed */ |
6128 if (parameters->rsiz == OPJ_PROFILE_NONE) { /* consider deprecated field
s only if RSIZ has not been set */ | 6166 if (parameters->rsiz == OPJ_PROFILE_NONE) { /* consider deprecated field
s only if RSIZ has not been set */ |
6129 OPJ_BOOL deprecated_used = OPJ_FALSE; | 6167 OPJ_BOOL deprecated_used = OPJ_FALSE; |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6497 tccp->m_dc_level_shift = l_dc_shift[i]; | 6535 tccp->m_dc_level_shift = l_dc_shift[i]; |
6498 } | 6536 } |
6499 | 6537 |
6500 if (opj_j2k_setup_mct_encoding(tcp,image) == OPJ_FALSE) { | 6538 if (opj_j2k_setup_mct_encoding(tcp,image) == OPJ_FALSE) { |
6501 /* free will be handled by opj_j2k_destroy */ | 6539 /* free will be handled by opj_j2k_destroy */ |
6502
opj_event_msg(p_manager, EVT_ERROR, "Failed to setup j2k mct enc
oding\n"); | 6540
opj_event_msg(p_manager, EVT_ERROR, "Failed to setup j2k mct enc
oding\n"); |
6503 return OPJ_FALSE; | 6541 return OPJ_FALSE; |
6504 } | 6542 } |
6505 } | 6543 } |
6506 else { | 6544 else { |
6507 if(tcp->mct==1 && image->numcomps == 3) { // RGB->YCC MCT is
enabled | 6545 if(tcp->mct==1 && image->numcomps == 3) { /* RGB->YCC MCT is
enabled */ |
6508 if ((image->comps[0].dx != image->comps[1].dx) || | 6546 if ((image->comps[0].dx != image->comps[1].dx) || |
6509 (image->comps[0].dx != image->comps[2].dx) || | 6547 (image->comps[0].dx != image->comps[2].dx) || |
6510 (image->comps[0].dy != image->comps[1].dy) || | 6548 (image->comps[0].dy != image->comps[1].dy) || |
6511 (image->comps[0].dy != image->comps[2].dy)) { | 6549 (image->comps[0].dy != image->comps[2].dy)) { |
6512 opj_event_msg(p_manager, EVT_WARNING, "Cannot perfor
m MCT on components with different sizes. Disabling MCT.\n"); | 6550 opj_event_msg(p_manager, EVT_WARNING, "Cannot perfor
m MCT on components with different sizes. Disabling MCT.\n"); |
6513 tcp->mct = 0; | 6551 tcp->mct = 0; |
6514 } | 6552 } |
6515 } | 6553 } |
6516 for (i = 0; i < image->numcomps; i++) { | 6554 for (i = 0; i < image->numcomps; i++) { |
6517 opj_tccp_t *tccp = &tcp->tccps[i]; | 6555 opj_tccp_t *tccp = &tcp->tccps[i]; |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6985 /* STATE checking */ | 7023 /* STATE checking */ |
6986 /* make sure the state is at 0 */ | 7024 /* make sure the state is at 0 */ |
6987 l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NO
NE); | 7025 l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NO
NE); |
6988 | 7026 |
6989 /* POINTER validation */ | 7027 /* POINTER validation */ |
6990 /* make sure a p_j2k codec is present */ | 7028 /* make sure a p_j2k codec is present */ |
6991 l_is_valid &= (p_j2k->m_procedure_list != 00); | 7029 l_is_valid &= (p_j2k->m_procedure_list != 00); |
6992 /* make sure a validation list is present */ | 7030 /* make sure a validation list is present */ |
6993 l_is_valid &= (p_j2k->m_validation_list != 00); | 7031 l_is_valid &= (p_j2k->m_validation_list != 00); |
6994 | 7032 |
| 7033 /* ISO 15444-1:2004 states between 1 & 33 (0 -> 32) */ |
| 7034 /* 33 (32) would always fail the 2 checks below (if a cast to 64bi
ts was done) */ |
| 7035 /* 32 (31) would always fail the 2 checks below (if a cast to 64bi
ts was done) */ |
| 7036 /* FIXME Shall we change OPJ_J2K_MAXRLVLS to 31 ? */ |
| 7037 if ((p_j2k->m_cp.tcps->tccps->numresolutions <= 0) || (p_j2k->m_cp.tcps-
>tccps->numresolutions > 31)) { |
| 7038 opj_event_msg(p_manager, EVT_ERROR, "Number of resolutions is to
o high in comparison to the size of tiles\n"); |
| 7039 return OPJ_FALSE; |
| 7040 } |
| 7041 |
6995 if ((p_j2k->m_cp.tdx) < (OPJ_UINT32) (1 << p_j2k->m_cp.tcps->tccps->numr
esolutions)) { | 7042 if ((p_j2k->m_cp.tdx) < (OPJ_UINT32) (1 << p_j2k->m_cp.tcps->tccps->numr
esolutions)) { |
6996 opj_event_msg(p_manager, EVT_ERROR, "Number of resolutions is to
o high in comparison to the size of tiles\n"); | 7043 opj_event_msg(p_manager, EVT_ERROR, "Number of resolutions is to
o high in comparison to the size of tiles\n"); |
6997 return OPJ_FALSE; | 7044 return OPJ_FALSE; |
6998 } | 7045 } |
6999 | 7046 |
7000 if ((p_j2k->m_cp.tdy) < (OPJ_UINT32) (1 << p_j2k->m_cp.tcps->tccps->numr
esolutions)) { | 7047 if ((p_j2k->m_cp.tdy) < (OPJ_UINT32) (1 << p_j2k->m_cp.tcps->tccps->numr
esolutions)) { |
7001 opj_event_msg(p_manager, EVT_ERROR, "Number of resolutions is to
o high in comparison to the size of tiles\n"); | 7048 opj_event_msg(p_manager, EVT_ERROR, "Number of resolutions is to
o high in comparison to the size of tiles\n"); |
7002 return OPJ_FALSE; | 7049 return OPJ_FALSE; |
7003 } | 7050 } |
7004 | 7051 |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7583 | 7630 |
7584 /* Try to read 2 bytes (the marker size) from stream and
copy them into the buffer */ | 7631 /* Try to read 2 bytes (the marker size) from stream and
copy them into the buffer */ |
7585 if (opj_stream_read_data(p_stream,p_j2k->m_specific_para
m.m_decoder.m_header_data,2,p_manager) != 2) { | 7632 if (opj_stream_read_data(p_stream,p_j2k->m_specific_para
m.m_decoder.m_header_data,2,p_manager) != 2) { |
7586 opj_event_msg(p_manager, EVT_ERROR, "Stream too
short\n"); | 7633 opj_event_msg(p_manager, EVT_ERROR, "Stream too
short\n"); |
7587 return OPJ_FALSE; | 7634 return OPJ_FALSE; |
7588 } | 7635 } |
7589 | 7636 |
7590 /* Read 2 bytes from the buffer as the marker size */ | 7637 /* Read 2 bytes from the buffer as the marker size */ |
7591 opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_heade
r_data,&l_marker_size,2); | 7638 opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_heade
r_data,&l_marker_size,2); |
7592 | 7639 |
| 7640 /* Check marker size (does not include marker ID but inc
ludes marker size) */ |
| 7641 if (l_marker_size < 2) { |
| 7642 opj_event_msg(p_manager, EVT_ERROR, "Inconsisten
t marker size\n"); |
| 7643 return OPJ_FALSE; |
| 7644 } |
| 7645 |
7593 /* cf. https://code.google.com/p/openjpeg/issues/detail?
id=226 */ | 7646 /* cf. https://code.google.com/p/openjpeg/issues/detail?
id=226 */ |
7594 if (l_current_marker == 0x8080 && opj_stream_get_number_
byte_left(p_stream) == 0) { | 7647 if (l_current_marker == 0x8080 && opj_stream_get_number_
byte_left(p_stream) == 0) { |
7595 p_j2k->m_specific_param.m_decoder.m_state = J2K_
STATE_NEOC; | 7648 p_j2k->m_specific_param.m_decoder.m_state = J2K_
STATE_NEOC; |
7596 break; | 7649 break; |
7597 } | 7650 } |
7598 | 7651 |
7599 /* Why this condition? FIXME */ | 7652 /* Why this condition? FIXME */ |
7600 if (p_j2k->m_specific_param.m_decoder.m_state & J2K_STAT
E_TPH){ | 7653 if (p_j2k->m_specific_param.m_decoder.m_state & J2K_STAT
E_TPH){ |
7601 p_j2k->m_specific_param.m_decoder.m_sot_length -
= (l_marker_size + 2); | 7654 p_j2k->m_specific_param.m_decoder.m_sot_length -
= (l_marker_size + 2); |
7602 } | 7655 } |
7603 l_marker_size -= 2; /* Subtract the size of the marker I
D already read */ | 7656 l_marker_size -= 2; /* Subtract the size of the marker I
D already read */ |
7604 | 7657 |
7605 /* Get the marker handler from the marker ID */ | 7658 /* Get the marker handler from the marker ID */ |
7606 l_marker_handler = opj_j2k_get_marker_handler(l_current_
marker); | 7659 l_marker_handler = opj_j2k_get_marker_handler(l_current_
marker); |
7607 | 7660 |
7608 /* Check if the marker is known and if it is the right p
lace to find it */ | 7661 /* Check if the marker is known and if it is the right p
lace to find it */ |
7609 if (! (p_j2k->m_specific_param.m_decoder.m_state & l_mar
ker_handler->states) ) { | 7662 if (! (p_j2k->m_specific_param.m_decoder.m_state & l_mar
ker_handler->states) ) { |
7610 opj_event_msg(p_manager, EVT_ERROR, "Marker is n
ot compliant with its position\n"); | 7663 opj_event_msg(p_manager, EVT_ERROR, "Marker is n
ot compliant with its position\n"); |
7611 return OPJ_FALSE; | 7664 return OPJ_FALSE; |
7612 } | 7665 } |
7613 /* FIXME manage case of unknown marker as in the main header ? */ | 7666 /* FIXME manage case of unknown marker as in the main header ? */ |
7614 | 7667 |
7615 /* Check if the marker size is compatible with the heade
r data size */ | 7668 /* Check if the marker size is compatible with the heade
r data size */ |
7616 if (l_marker_size > p_j2k->m_specific_param.m_decoder.m_
header_data_size) { | 7669 if (l_marker_size > p_j2k->m_specific_param.m_decoder.m_
header_data_size) { |
7617 OPJ_BYTE *new_header_data = (OPJ_BYTE *) opj_rea
lloc(p_j2k->m_specific_param.m_decoder.m_header_data, l_marker_size); | 7670 OPJ_BYTE *new_header_data = NULL; |
| 7671 /* If we are here, this means we consider this m
arker as known & we will read it */ |
| 7672 /* Check enough bytes left in stream before allo
cation */ |
| 7673 if ((OPJ_OFF_T)l_marker_size > opj_stream_get_n
umber_byte_left(p_stream)) { |
| 7674 opj_event_msg(p_manager, EVT_ERROR, "Mar
ker size inconsistent with stream length\n"); |
| 7675 return OPJ_FALSE; |
| 7676 } |
| 7677 new_header_data = (OPJ_BYTE *) opj_realloc(p_j2k
->m_specific_param.m_decoder.m_header_data, l_marker_size); |
7618 if (! new_header_data) { | 7678 if (! new_header_data) { |
7619 opj_free(p_j2k->m_specific_param.m_decod
er.m_header_data); | 7679 opj_free(p_j2k->m_specific_param.m_decod
er.m_header_data); |
7620 p_j2k->m_specific_param.m_decoder.m_head
er_data = NULL; | 7680 p_j2k->m_specific_param.m_decoder.m_head
er_data = NULL; |
7621 p_j2k->m_specific_param.m_decoder.m_head
er_data_size = 0; | 7681 p_j2k->m_specific_param.m_decoder.m_head
er_data_size = 0; |
7622 opj_event_msg(p_manager, EVT_ERROR, "Not
enough memory to read header\n"); | 7682 opj_event_msg(p_manager, EVT_ERROR, "Not
enough memory to read header\n"); |
7623 return OPJ_FALSE; | 7683 return OPJ_FALSE; |
7624 } | 7684 } |
7625 p_j2k->m_specific_param.m_decoder.m_header_data
= new_header_data; | 7685 p_j2k->m_specific_param.m_decoder.m_header_data
= new_header_data; |
7626 p_j2k->m_specific_param.m_decoder.m_header_data_
size = l_marker_size; | 7686 p_j2k->m_specific_param.m_decoder.m_header_data_
size = l_marker_size; |
7627 } | 7687 } |
(...skipping 2750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10378 } | 10438 } |
10379 else { | 10439 else { |
10380 if (! opj_j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream,
p_manager)) { | 10440 if (! opj_j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream,
p_manager)) { |
10381 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k
_post_write_tile with tile index = %d\n", p_tile_index); | 10441 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k
_post_write_tile with tile index = %d\n", p_tile_index); |
10382 return OPJ_FALSE; | 10442 return OPJ_FALSE; |
10383 } | 10443 } |
10384 } | 10444 } |
10385 | 10445 |
10386 return OPJ_TRUE; | 10446 return OPJ_TRUE; |
10387 } | 10447 } |
OLD | NEW |