From 8c2d8bc85f1e7b7717434d56e355cf1ef3890131 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Wed, 30 Nov 2011 17:31:47 +0000 Subject: [PATCH] [trunk] fix bug during random access to tile (tile already decoded) --- CHANGES | 1 + libopenjpeg/j2k.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index a372c2b8..0a018b1a 100644 --- a/CHANGES +++ b/CHANGES @@ -14,6 +14,7 @@ November 30, 2011 - change types related to size of stream to OPJ_UINT64_T - change calls to fseek/ftell to LFS-capable OPJ_SEEK/OPJ_TELL * [mickael] fix error about the way to detect the additional test suite +* [mickael] fix bug during random access to tile (tile already decoded) November 29, 2011 * [mickael] fix error with new way to detect kdu_expand diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c index 19b4d2b4..a3c14c3b 100644 --- a/libopenjpeg/j2k.c +++ b/libopenjpeg/j2k.c @@ -125,6 +125,12 @@ static const struct opj_dec_memory_marker_handler * j2k_get_marker_handler (OPJ_ */ static void j2k_tcp_destroy (opj_tcp_v2_t *p_tcp); +/** + * Destroys the data inside a tile coding parameter structure. + * + * @param p_tcp the tile coding parameter which contain data to destroy. + */ +static void j2k_tcp_data_destroy (opj_tcp_v2_t *p_tcp); /** * Destroys a coding parameter structure. @@ -6488,12 +6494,23 @@ void j2k_tcp_destroy (opj_tcp_v2_t *p_tcp) p_tcp->mct_norms = 00; } - if (p_tcp->m_data) { - opj_free(p_tcp->m_data); - p_tcp->m_data = 00; - } + j2k_tcp_data_destroy(p_tcp); + } +/** + * Destroys the data inside a tile coding parameter structure. + * + * @param p_tcp the tile coding parameter which contain data to destroy. + */ +void j2k_tcp_data_destroy (opj_tcp_v2_t *p_tcp) +{ + if (p_tcp->m_data) { + opj_free(p_tcp->m_data); + p_tcp->m_data = NULL; + p_tcp->m_data_size = 0; + } +} /** * Destroys a coding parameter structure. @@ -6803,8 +6820,11 @@ opj_bool j2k_decode_tile ( opj_j2k_v2_t * p_j2k, return OPJ_FALSE; } - j2k_tcp_destroy(l_tcp); - p_j2k->m_tcd->tcp = 0; + /* To avoid to destroy the tcp which can be useful when we try to decode a tile decoded before (cf j2k_random_tile_access) + * we destroy just the data which will be re-read in read_tile_header*/ + /*j2k_tcp_destroy(l_tcp); + p_j2k->m_tcd->tcp = 0;*/ + 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_state &= (~ (0x0080));// FIXME J2K_DEC_STATE_DATA);