]> granicus.if.org Git - openjpeg/commitdiff
[trunk] fix bug during random access to tile (tile already decoded)
authorMickael Savinaud <savmickael@users.noreply.github.com>
Wed, 30 Nov 2011 17:31:47 +0000 (17:31 +0000)
committerMickael Savinaud <savmickael@users.noreply.github.com>
Wed, 30 Nov 2011 17:31:47 +0000 (17:31 +0000)
CHANGES
libopenjpeg/j2k.c

diff --git a/CHANGES b/CHANGES
index a372c2b8e3d74604dff2d277fa76d049f4067fde..0a018b1ac83dd2d09119af8efe9869862c04280a 100644 (file)
--- 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
index 19b4d2b4dc9aabed8d43d944dda01c37b38f322a..a3c14c3badacefe7b6c359028c3dda359e4e3744 100644 (file)
@@ -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,13 +6494,24 @@ void j2k_tcp_destroy (opj_tcp_v2_t *p_tcp)
                p_tcp->mct_norms = 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 = 00;
+               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);