diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c | 29 | ||||
-rw-r--r-- | core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tcd.c | 25 |
2 files changed, 46 insertions, 8 deletions
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c index 93f8a3db63..66db53b4db 100644 --- a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c +++ b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c @@ -7090,6 +7090,9 @@ OPJ_BOOL opj_j2k_read_header_procedure( opj_j2k_t *p_j2k, OPJ_UINT32 l_current_marker; OPJ_UINT32 l_marker_size; const opj_dec_memory_marker_handler_t * l_marker_handler = 00; + OPJ_BOOL l_has_siz = 0; + OPJ_BOOL l_has_cod = 0; + OPJ_BOOL l_has_qcd = 0; /* preconditions */ assert(p_stream != 00); @@ -7139,6 +7142,19 @@ OPJ_BOOL opj_j2k_read_header_procedure( opj_j2k_t *p_j2k, l_marker_handler = opj_j2k_get_marker_handler(l_current_marker); } + if (l_marker_handler->id == J2K_MS_SIZ) { + /* Mark required SIZ marker as found */ + l_has_siz = 1; + } + if (l_marker_handler->id == J2K_MS_COD) { + /* Mark required COD marker as found */ + l_has_cod = 1; + } + if (l_marker_handler->id == J2K_MS_QCD) { + /* Mark required QCD marker as found */ + l_has_qcd = 1; + } + /* Check if the marker is known and if it is the right place to find it */ if (! (p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states) ) { opj_event_msg(p_manager, EVT_ERROR, "Marker is not compliant with its position\n"); @@ -7201,6 +7217,19 @@ OPJ_BOOL opj_j2k_read_header_procedure( opj_j2k_t *p_j2k, opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2); } + if (l_has_siz == 0) { + opj_event_msg(p_manager, EVT_ERROR, "required SIZ marker not found in main header\n"); + return OPJ_FALSE; + } + if (l_has_cod == 0) { + opj_event_msg(p_manager, EVT_ERROR, "required COD marker not found in main header\n"); + return OPJ_FALSE; + } + if (l_has_qcd == 0) { + opj_event_msg(p_manager, EVT_ERROR, "required QCD marker not found in main header\n"); + return OPJ_FALSE; + } + opj_event_msg(p_manager, EVT_INFO, "Main header has been correctly decoded.\n"); /* Position of the last element if the main header */ diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tcd.c b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tcd.c index 7dd93e9916..1720b8efa5 100644 --- a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tcd.c +++ b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tcd.c @@ -676,7 +676,7 @@ OPJ_BOOL FUNCTION ( opj_tcd_t *p_tcd, \ /*tile->numcomps = image->numcomps; */ \ for(compno = 0; compno < l_tile->numcomps; ++compno) { \ /*fprintf(stderr, "compno = %d/%d\n", compno, l_tile->numcomps);*/ \ - \ + l_image_comp->resno_decoded = 0; \ /* border of each l_tile component (global) */ \ l_tilec->x0 = opj_int_ceildiv(l_tile->x0, (OPJ_INT32)l_image_comp->dx); \ l_tilec->y0 = opj_int_ceildiv(l_tile->y0, (OPJ_INT32)l_image_comp->dy); \ @@ -970,15 +970,14 @@ OPJ_BOOL FUNCTION ( opj_tcd_t *p_tcd, \ OPJ_INT32 cblkxend = cblkxstart + (1 << cblkwidthexpn); \ OPJ_INT32 cblkyend = cblkystart + (1 << cblkheightexpn); \ \ + if (! FUNCTION_ELEMENT(l_code_block)) { \ + return OPJ_FALSE; \ + } \ /* code-block size (global) */ \ l_code_block->x0 = opj_int_max(cblkxstart, l_current_precinct->x0); \ l_code_block->y0 = opj_int_max(cblkystart, l_current_precinct->y0); \ l_code_block->x1 = opj_int_min(cblkxend, l_current_precinct->x1); \ l_code_block->y1 = opj_int_min(cblkyend, l_current_precinct->y1); \ - \ - if (! FUNCTION_ELEMENT(l_code_block)) { \ - return OPJ_FALSE; \ - } \ ++l_code_block; \ } \ ++l_current_precinct; \ @@ -1054,9 +1053,19 @@ OPJ_BOOL opj_tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_block) p_code_block->m_current_max_segs = OPJ_J2K_DEFAULT_NB_SEGS; /*fprintf(stderr, "m_current_max_segs of code_block->data = %d\n", p_code_block->m_current_max_segs);*/ - } - /* TODO */ - /*p_code_block->numsegs = 0; */ + } else { + /* sanitize */ + OPJ_BYTE* l_data = p_code_block->data; + OPJ_UINT32 l_data_max_size = p_code_block->data_max_size; + opj_tcd_seg_t * l_segs = p_code_block->segs; + OPJ_UINT32 l_current_max_segs = p_code_block->m_current_max_segs; + + memset(p_code_block, 0, sizeof(opj_tcd_cblk_dec_t)); + p_code_block->data = l_data; + p_code_block->data_max_size = l_data_max_size; + p_code_block->segs = l_segs; + p_code_block->m_current_max_segs = l_current_max_segs; + } return OPJ_TRUE; } |