summaryrefslogtreecommitdiff
path: root/src/lib/openjp2/t2.c
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2017-07-06 19:34:21 +0200
committerEven Rouault <even.rouault@spatialys.com>2017-08-07 18:32:52 +0200
commit92114694a48638e86c07e4adf11b78878045c8a9 (patch)
tree2d6210b5bd12c7e1b1494be1e9dee99dcb4461f1 /src/lib/openjp2/t2.c
parentca34d13e76a588a00171e57690c1deeaf068723a (diff)
Slight improvement in management of code block chunks
Instead of having the chunk array at the segment level, we can move it down to the codeblock itself since segments are filled in sequential order. Limit the number of memory allocation, and decrease slightly the memory usage. On MAPA_005.jp2 n4: 1871312549 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. n1: 1610689344 0x4E781E7: opj_aligned_malloc (opj_malloc.c:61) n1: 1610689344 0x4E71D1B: opj_alloc_tile_component_data (tcd.c:676) n1: 1610689344 0x4E726CF: opj_tcd_init_decode_tile (tcd.c:816) n1: 1610689344 0x4E4BE39: opj_j2k_read_tile_header (j2k.c:8617) n1: 1610689344 0x4E4C902: opj_j2k_decode_tiles (j2k.c:10348) n1: 1610689344 0x4E4E3CE: opj_j2k_decode (j2k.c:7846) n1: 1610689344 0x4E53002: opj_jp2_decode (jp2.c:1564) n0: 1610689344 0x40374E: main (opj_decompress.c:1459) n1: 219232541 0x4E4BC50: opj_j2k_read_tile_header (j2k.c:4683) n1: 219232541 0x4E4C902: opj_j2k_decode_tiles (j2k.c:10348) n1: 219232541 0x4E4E3CE: opj_j2k_decode (j2k.c:7846) n1: 219232541 0x4E53002: opj_jp2_decode (jp2.c:1564) n0: 219232541 0x40374E: main (opj_decompress.c:1459) n1: 23893200 0x4E72735: opj_tcd_init_decode_tile (tcd.c:1225) n1: 23893200 0x4E4BE39: opj_j2k_read_tile_header (j2k.c:8617) n1: 23893200 0x4E4C902: opj_j2k_decode_tiles (j2k.c:10348) n1: 23893200 0x4E4E3CE: opj_j2k_decode (j2k.c:7846) n1: 23893200 0x4E53002: opj_jp2_decode (jp2.c:1564) n0: 23893200 0x40374E: main (opj_decompress.c:1459) n0: 17497464 in 52 places, all below massif's threshold (1.00%)
Diffstat (limited to 'src/lib/openjp2/t2.c')
-rw-r--r--src/lib/openjp2/t2.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/lib/openjp2/t2.c b/src/lib/openjp2/t2.c
index 5d5e33ea..c8cfcc26 100644
--- a/src/lib/openjp2/t2.c
+++ b/src/lib/openjp2/t2.c
@@ -1287,25 +1287,26 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
#endif /* USE_JPWL */
- if (l_seg->numchunks == l_seg->numchunksalloc) {
- OPJ_UINT32 l_numchunksalloc = l_seg->numchunksalloc * 2 + 1;
+ if (l_cblk->numchunks == l_cblk->numchunksalloc) {
+ OPJ_UINT32 l_numchunksalloc = l_cblk->numchunksalloc * 2 + 1;
opj_tcd_seg_data_chunk_t* l_chunks =
- (opj_tcd_seg_data_chunk_t*)opj_realloc(l_seg->chunks,
+ (opj_tcd_seg_data_chunk_t*)opj_realloc(l_cblk->chunks,
l_numchunksalloc * sizeof(opj_tcd_seg_data_chunk_t));
if (l_chunks == NULL) {
opj_event_msg(p_manager, EVT_ERROR,
"cannot allocate opj_tcd_seg_data_chunk_t* array");
return OPJ_FALSE;
}
- l_seg->chunks = l_chunks;
- l_seg->numchunksalloc = l_numchunksalloc;
+ l_cblk->chunks = l_chunks;
+ l_cblk->numchunksalloc = l_numchunksalloc;
}
- l_seg->chunks[l_seg->numchunks].data = l_current_data;
- l_seg->chunks[l_seg->numchunks].len = l_seg->newlen;
- l_seg->numchunks ++;
+ l_cblk->chunks[l_cblk->numchunks].data = l_current_data;
+ l_cblk->chunks[l_cblk->numchunks].len = l_seg->newlen;
+ l_cblk->numchunks ++;
l_current_data += l_seg->newlen;
+ l_seg->len += l_seg->newlen;
l_seg->numpasses += l_seg->numnewpasses;
l_cblk->numnewpasses -= l_seg->numnewpasses;