From daed8cc9195555e101ab708a501af2dfe6d5e001 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Tue, 19 May 2015 20:13:37 +0000 Subject: [trunk] Add check for at most 1 COD marker per tile. 1 COD marker for MH (fixes issue 476) --- src/lib/openjp2/j2k.c | 10 +++++++++- src/lib/openjp2/j2k.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index f944ad1a..0be00aa6 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -2431,7 +2431,14 @@ static OPJ_BOOL opj_j2k_read_cod ( opj_j2k_t *p_j2k, l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp; - + + /* Only one COD per tile */ + if (l_tcp->cod) { + opj_event_msg(p_manager, EVT_ERROR, "COD marker already read. No more than one COD marker per tile.\n"); + return OPJ_FALSE; + } + l_tcp->cod = 1; + /* Make sure room is sufficient */ if (p_header_size < 5) { opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n"); @@ -7350,6 +7357,7 @@ static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd ( opj_j2k_t * p_j2 /*Copy default coding parameters into the current tile coding parameters*/ memcpy(l_tcp, l_default_tcp, sizeof(opj_tcp_t)); /* Initialize some values of the current tile coding parameters*/ + l_tcp->cod = 0; l_tcp->ppt = 0; l_tcp->ppt_data = 00; /* Reconnect the tile-compo coding parameters pointer to the current tile coding parameters*/ diff --git a/src/lib/openjp2/j2k.h b/src/lib/openjp2/j2k.h index 909e3511..10e22aa6 100644 --- a/src/lib/openjp2/j2k.h +++ b/src/lib/openjp2/j2k.h @@ -293,6 +293,8 @@ typedef struct opj_tcp /***** FLAGS *******/ + /** If cod == 1 --> there was a COD marker for the present tile */ + OPJ_UINT32 cod : 1; /** If ppt == 1 --> there was a PPT marker for the present tile */ OPJ_UINT32 ppt : 1; /** indicates if a POC marker has been used O:NO, 1:YES */ -- cgit v1.2.3