summaryrefslogtreecommitdiff
path: root/src/lib/openjp2/tcd.h
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/tcd.h
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/tcd.h')
-rw-r--r--src/lib/openjp2/tcd.h58
1 files changed, 30 insertions, 28 deletions
diff --git a/src/lib/openjp2/tcd.h b/src/lib/openjp2/tcd.h
index 0de888d5..29cd8829 100644
--- a/src/lib/openjp2/tcd.h
+++ b/src/lib/openjp2/tcd.h
@@ -89,12 +89,12 @@ typedef struct opj_tcd_cblk_enc {
} opj_tcd_cblk_enc_t;
-/** Chunk of codestream data that is part of a T1 segment */
+/** Chunk of codestream data that is part of a code block */
typedef struct opj_tcd_seg_data_chunk {
- OPJ_BYTE *
- data; /* Point to tilepart buffer. We don't make a copy !
- So the tilepart buffer must be kept alive
- as long as we need to decode the codeblocks */
+ /* Point to tilepart buffer. We don't make a copy !
+ So the tilepart buffer must be kept alive
+ as long as we need to decode the codeblocks */
+ OPJ_BYTE * data;
OPJ_UINT32 len; /* Usable length of data */
} opj_tcd_seg_data_chunk_t;
@@ -102,35 +102,37 @@ typedef struct opj_tcd_seg_data_chunk {
* A segment represent a number of consecutive coding passes, without termination
* of MQC or RAW between them. */
typedef struct opj_tcd_seg {
- opj_tcd_seg_data_chunk_t* chunks; /* Array of chunks */
- OPJ_UINT32 numchunks; /* Number of valid chunks items */
- OPJ_UINT32 numchunksalloc; /* Number of chunks item allocated */
- OPJ_UINT32
- numpasses; /* Number of passes decoded. Including those that we skip */
- OPJ_UINT32
- real_num_passes; /* Number of passes actually to be decoded. To be used for code-block decoding */
- OPJ_UINT32 maxpasses; /* Maximum number of passes for this segment */
- OPJ_UINT32
- numnewpasses; /* Number of new passes for current packed. Transitory value */
- OPJ_UINT32
- newlen; /* Codestream length for this segment for current packed. Transitory value */
+ OPJ_UINT32 len; /* Size of data related to this segment */
+ /* Number of passes decoded. Including those that we skip */
+ OPJ_UINT32 numpasses;
+ /* Number of passes actually to be decoded. To be used for code-block decoding */
+ OPJ_UINT32 real_num_passes;
+ /* Maximum number of passes for this segment */
+ OPJ_UINT32 maxpasses;
+ /* Number of new passes for current packed. Transitory value */
+ OPJ_UINT32 numnewpasses;
+ /* Codestream length for this segment for current packed. Transitory value */
+ OPJ_UINT32 newlen;
} opj_tcd_seg_t;
/* Code-block for decoding */
typedef struct opj_tcd_cblk_dec {
opj_tcd_seg_t* segs; /* segments information */
- OPJ_INT32 x0, y0, x1,
- y1; /* position of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
+ opj_tcd_seg_data_chunk_t* chunks; /* Array of chunks */
+ /* position of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
+ OPJ_INT32 x0, y0, x1, y1;
OPJ_UINT32 numbps;
- OPJ_UINT32
- numlenbits; /* number of bits for len,, for the current packet. Transitory value */
- OPJ_UINT32
- numnewpasses; /* number of pass added to the code-blocks, for the current packet. Transitory value */
- OPJ_UINT32
- numsegs; /* number of segments, including those of packet we skip */
- OPJ_UINT32
- real_num_segs; /* number of segments, to be used for code block decoding */
+ /* number of bits for len, for the current packet. Transitory value */
+ OPJ_UINT32 numlenbits;
+ /* number of pass added to the code-blocks, for the current packet. Transitory value */
+ OPJ_UINT32 numnewpasses;
+ /* number of segments, including those of packet we skip */
+ OPJ_UINT32 numsegs;
+ /* number of segments, to be used for code block decoding */
+ OPJ_UINT32 real_num_segs;
OPJ_UINT32 m_current_max_segs; /* allocated number of segs[] items */
+ OPJ_UINT32 numchunks; /* Number of valid chunks items */
+ OPJ_UINT32 numchunksalloc; /* Number of chunks item allocated */
} opj_tcd_cblk_dec_t;
/**
@@ -397,7 +399,7 @@ OPJ_BOOL opj_alloc_tile_component_data(opj_tcd_tilecomp_t *l_tilec);
*/
OPJ_BOOL opj_tcd_is_band_empty(opj_tcd_band_t* band);
-/** Reinitialize a segment, without deallocating its chunks array */
+/** Reinitialize a segment */
void opj_tcd_reinit_segment(opj_tcd_seg_t* seg);
/* ----------------------------------------------------------------------- */