j2k.c: remove hardcoded constants related to m_state, and useless FIXME

This commit is contained in:
Even Rouault 2017-07-30 17:26:03 +02:00
parent e23e0c94d0
commit 4748318136
2 changed files with 12 additions and 17 deletions

View File

@ -2431,8 +2431,7 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
++l_current_tile_param; ++l_current_tile_param;
} }
p_j2k->m_specific_param.m_decoder.m_state = p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MH;
J2K_STATE_MH; /* FIXME J2K_DEC_STATE_MH; */
opj_image_comp_header_update(l_image, l_cp); opj_image_comp_header_update(l_image, l_cp);
return OPJ_TRUE; return OPJ_TRUE;
@ -2890,7 +2889,7 @@ static OPJ_BOOL opj_j2k_read_coc(opj_j2k_t *p_j2k,
l_cp = &(p_j2k->m_cp); l_cp = &(p_j2k->m_cp);
l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH)
? /*FIXME J2K_DEC_STATE_TPH*/ ?
&l_cp->tcps[p_j2k->m_current_tile_number] : &l_cp->tcps[p_j2k->m_current_tile_number] :
p_j2k->m_specific_param.m_decoder.m_default_tcp; p_j2k->m_specific_param.m_decoder.m_default_tcp;
l_image = p_j2k->m_private_image; l_image = p_j2k->m_private_image;
@ -8664,8 +8663,7 @@ OPJ_BOOL opj_j2k_read_tile_header(opj_j2k_t * p_j2k,
*p_tile_y1 = p_j2k->m_tcd->tcd_image->tiles->y1; *p_tile_y1 = p_j2k->m_tcd->tcd_image->tiles->y1;
*p_nb_comps = p_j2k->m_tcd->tcd_image->tiles->numcomps; *p_nb_comps = p_j2k->m_tcd->tcd_image->tiles->numcomps;
p_j2k->m_specific_param.m_decoder.m_state |= p_j2k->m_specific_param.m_decoder.m_state |= J2K_STATE_DATA;
0x0080;/* FIXME J2K_DEC_STATE_DATA;*/
return OPJ_TRUE; return OPJ_TRUE;
} }
@ -8686,8 +8684,7 @@ OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t * p_j2k,
assert(p_j2k != 00); assert(p_j2k != 00);
assert(p_manager != 00); assert(p_manager != 00);
if (!(p_j2k->m_specific_param.m_decoder.m_state & if (!(p_j2k->m_specific_param.m_decoder.m_state & J2K_STATE_DATA)
0x0080/*FIXME J2K_DEC_STATE_DATA*/)
|| (p_tile_index != p_j2k->m_current_tile_number)) { || (p_tile_index != p_j2k->m_current_tile_number)) {
return OPJ_FALSE; return OPJ_FALSE;
} }
@ -8704,7 +8701,7 @@ OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t * p_j2k,
p_tile_index, p_tile_index,
p_j2k->cstr_index, p_manager)) { p_j2k->cstr_index, p_manager)) {
opj_j2k_tcp_destroy(l_tcp); opj_j2k_tcp_destroy(l_tcp);
p_j2k->m_specific_param.m_decoder.m_state |= 0x8000;/*FIXME J2K_DEC_STATE_ERR;*/ p_j2k->m_specific_param.m_decoder.m_state |= J2K_STATE_ERR;
opj_event_msg(p_manager, EVT_ERROR, "Failed to decode.\n"); opj_event_msg(p_manager, EVT_ERROR, "Failed to decode.\n");
return OPJ_FALSE; return OPJ_FALSE;
} }
@ -8720,16 +8717,14 @@ OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t * p_j2k,
opj_j2k_tcp_data_destroy(l_tcp); opj_j2k_tcp_data_destroy(l_tcp);
p_j2k->m_specific_param.m_decoder.m_can_decode = 0; p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
p_j2k->m_specific_param.m_decoder.m_state &= (~ p_j2k->m_specific_param.m_decoder.m_state &= (~(OPJ_UINT32)J2K_STATE_DATA);
(0x0080u)); /* FIXME J2K_DEC_STATE_DATA);*/
if (opj_stream_get_number_byte_left(p_stream) == 0 if (opj_stream_get_number_byte_left(p_stream) == 0
&& p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC) { && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC) {
return OPJ_TRUE; return OPJ_TRUE;
} }
if (p_j2k->m_specific_param.m_decoder.m_state != if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_EOC) {
0x0100) { /*FIXME J2K_DEC_STATE_EOC)*/
if (opj_stream_read_data(p_stream, l_data, 2, p_manager) != 2) { if (opj_stream_read_data(p_stream, l_data, 2, p_manager) != 2) {
opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n"); opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
return OPJ_FALSE; return OPJ_FALSE;
@ -8739,7 +8734,7 @@ OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t * p_j2k,
if (l_current_marker == J2K_MS_EOC) { if (l_current_marker == J2K_MS_EOC) {
p_j2k->m_current_tile_number = 0; p_j2k->m_current_tile_number = 0;
p_j2k->m_specific_param.m_decoder.m_state = 0x0100;/*FIXME J2K_DEC_STATE_EOC;*/ p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC;
} else if (l_current_marker != J2K_MS_SOT) { } else if (l_current_marker != J2K_MS_SOT) {
if (opj_stream_get_number_byte_left(p_stream) == 0) { if (opj_stream_get_number_byte_left(p_stream) == 0) {
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC; p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
@ -9039,8 +9034,7 @@ OPJ_BOOL opj_j2k_set_decode_area(opj_j2k_t *p_j2k,
opj_image_comp_t* l_img_comp = NULL; opj_image_comp_t* l_img_comp = NULL;
/* Check if we are read the main header */ /* Check if we are read the main header */
if (p_j2k->m_specific_param.m_decoder.m_state != if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_TPHSOT) {
J2K_STATE_TPHSOT) { /* FIXME J2K_DEC_STATE_TPHSOT)*/
opj_event_msg(p_manager, EVT_ERROR, opj_event_msg(p_manager, EVT_ERROR,
"Need to decode the main header before begin to decode the remaining codestream"); "Need to decode the main header before begin to decode the remaining codestream");
return OPJ_FALSE; return OPJ_FALSE;
@ -9583,7 +9577,7 @@ static void opj_j2k_copy_tile_component_parameters(opj_j2k_t *p_j2k)
l_cp = &(p_j2k->m_cp); l_cp = &(p_j2k->m_cp);
l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH)
? /* FIXME J2K_DEC_STATE_TPH*/ ?
&l_cp->tcps[p_j2k->m_current_tile_number] : &l_cp->tcps[p_j2k->m_current_tile_number] :
p_j2k->m_specific_param.m_decoder.m_default_tcp; p_j2k->m_specific_param.m_decoder.m_default_tcp;
@ -9780,7 +9774,7 @@ static OPJ_BOOL opj_j2k_read_SQcd_SQcc(opj_j2k_t *p_j2k,
l_cp = &(p_j2k->m_cp); l_cp = &(p_j2k->m_cp);
/* come from tile part header or main header ?*/ /* come from tile part header or main header ?*/
l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH)
? /*FIXME J2K_DEC_STATE_TPH*/ ?
&l_cp->tcps[p_j2k->m_current_tile_number] : &l_cp->tcps[p_j2k->m_current_tile_number] :
p_j2k->m_specific_param.m_decoder.m_default_tcp; p_j2k->m_specific_param.m_decoder.m_default_tcp;

View File

@ -122,6 +122,7 @@ typedef enum J2K_STATUS {
J2K_STATE_TPH = 0x0010, /**< the decoding process is in a tile part header */ J2K_STATE_TPH = 0x0010, /**< the decoding process is in a tile part header */
J2K_STATE_MT = 0x0020, /**< the EOC marker has just been read */ J2K_STATE_MT = 0x0020, /**< the EOC marker has just been read */
J2K_STATE_NEOC = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */ J2K_STATE_NEOC = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */
J2K_STATE_DATA = 0x0080, /**< a tile header has been successfully read and codestream is expected */
J2K_STATE_EOC = 0x0100, /**< the decoding process has encountered the EOC marker */ J2K_STATE_EOC = 0x0100, /**< the decoding process has encountered the EOC marker */
J2K_STATE_ERR = 0x8000 /**< the decoding process has encountered an error (FIXME warning V1 = 0x0080)*/ J2K_STATE_ERR = 0x8000 /**< the decoding process has encountered an error (FIXME warning V1 = 0x0080)*/