diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2017-09-01 16:30:29 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2017-09-01 16:30:29 +0200 |
| commit | f9e9942330f476b66ac4a35d0ae521200878f343 (patch) | |
| tree | 49cd4ab4a3d05d148a03052fdb856b2c58a88412 /src/lib/openjp2/tcd.h | |
| parent | aa7198146b995fe2993ce24f5715057b7da0386d (diff) | |
Sub-tile decoding: only allocate tile component buffer of the needed dimension
Instead of being the full tile size.
* Use a sparse array mechanism to store code-blocks and intermediate stages of
IDWT.
* IDWT, DC level shift and MCT stages are done just on that smaller array.
* Improve copy of tile component array to final image, by saving an intermediate
buffer.
* For full-tile decoding at reduced resolution, only allocate the tile buffer to
the reduced size, instead of the full-resolution size.
Diffstat (limited to 'src/lib/openjp2/tcd.h')
| -rw-r--r-- | src/lib/openjp2/tcd.h | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/src/lib/openjp2/tcd.h b/src/lib/openjp2/tcd.h index bf3c457e..8ad57e07 100644 --- a/src/lib/openjp2/tcd.h +++ b/src/lib/openjp2/tcd.h @@ -134,6 +134,8 @@ typedef struct opj_tcd_cblk_dec { 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 */ + /* Decoded code-block. Only used for subtile decoding. Otherwise tilec->data is directly updated */ + OPJ_INT32* decoded_data; } opj_tcd_cblk_dec_t; /** Precinct structure */ @@ -175,6 +177,12 @@ typedef struct opj_tcd_resolution { OPJ_UINT32 numbands; /* subband information */ opj_tcd_band_t bands[3]; + + /* dimension of the resolution limited to window of interest. Only valid if tcd->whole_tile_decoding is set */ + OPJ_UINT32 win_x0; + OPJ_UINT32 win_y0; + OPJ_UINT32 win_x1; + OPJ_UINT32 win_y1; } opj_tcd_resolution_t; /** Tile-component structure */ @@ -191,7 +199,8 @@ typedef struct opj_tcd_tilecomp { opj_tcd_resolution_t *resolutions; /* size of data for resolutions (in bytes) */ OPJ_UINT32 resolutions_size; - /* data of the component */ + + /* data of the component. For decoding, only valid if tcd->whole_tile_decoding is set (so exclusive of data_win member) */ OPJ_INT32 *data; /* if true, then need to free after usage, otherwise do not free */ OPJ_BOOL ownsData; @@ -199,6 +208,15 @@ typedef struct opj_tcd_tilecomp { OPJ_UINT32 data_size_needed; /* size of the data of the component */ OPJ_UINT32 data_size; + + /** data of the component limited to window of interest. Only valid for decoding and if tcd->whole_tile_decoding is NOT set (so exclusive of data member) */ + OPJ_INT32 *data_win; + /* dimension of the component limited to window of interest. Only valid for decoding and if tcd->whole_tile_decoding is NOT set */ + OPJ_UINT32 win_x0; + OPJ_UINT32 win_y0; + OPJ_UINT32 win_x1; + OPJ_UINT32 win_y1; + /* add fixed_quality */ OPJ_INT32 numpix; } opj_tcd_tilecomp_t; @@ -256,10 +274,12 @@ typedef struct opj_tcd { /** Thread pool */ opj_thread_pool_t* thread_pool; /** Coordinates of the window of interest, in grid reference space */ - OPJ_UINT32 decoded_x0; - OPJ_UINT32 decoded_y0; - OPJ_UINT32 decoded_x1; - OPJ_UINT32 decoded_y1; + OPJ_UINT32 win_x0; + OPJ_UINT32 win_y0; + OPJ_UINT32 win_x1; + OPJ_UINT32 win_y1; + /** Only valid for decoding. Whether the whole tile is decoded, or just the region in win_x0/win_y0/win_x1/win_y1 */ + OPJ_BOOL whole_tile_decoding; } opj_tcd_t; /** @name Exported functions */ @@ -331,7 +351,8 @@ OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd, /** * Gets the maximum tile size that will be taken by the tile once decoded. */ -OPJ_UINT32 opj_tcd_get_decoded_tile_size(opj_tcd_t *p_tcd); +OPJ_UINT32 opj_tcd_get_decoded_tile_size(opj_tcd_t *p_tcd, + OPJ_BOOL take_into_account_partial_decoding); /** * Encodes a tile from the raw image into the given buffer. @@ -356,10 +377,10 @@ OPJ_BOOL opj_tcd_encode_tile(opj_tcd_t *p_tcd, /** Decode a tile from a buffer into a raw image @param tcd TCD handle -@param decoded_x0 Upper left x of region to decode (in grid coordinates) -@param decoded_y0 Upper left y of region to decode (in grid coordinates) -@param decoded_x1 Lower right x of region to decode (in grid coordinates) -@param decoded_y1 Lower right y of region to decode (in grid coordinates) +@param win_x0 Upper left x of region to decode (in grid coordinates) +@param win_y0 Upper left y of region to decode (in grid coordinates) +@param win_x1 Lower right x of region to decode (in grid coordinates) +@param win_y1 Lower right y of region to decode (in grid coordinates) @param src Source buffer @param len Length of source buffer @param tileno Number that identifies one of the tiles to be decoded @@ -367,10 +388,10 @@ Decode a tile from a buffer into a raw image @param manager the event manager. */ OPJ_BOOL opj_tcd_decode_tile(opj_tcd_t *tcd, - OPJ_UINT32 decoded_x0, - OPJ_UINT32 decoded_y0, - OPJ_UINT32 decoded_x1, - OPJ_UINT32 decoded_y1, + OPJ_UINT32 win_x0, + OPJ_UINT32 win_y0, + OPJ_UINT32 win_x1, + OPJ_UINT32 win_y1, OPJ_BYTE *src, OPJ_UINT32 len, OPJ_UINT32 tileno, @@ -427,7 +448,7 @@ void opj_tcd_reinit_segment(opj_tcd_seg_t* seg); /** Returns whether a sub-band region contributes to the area of interest - * tcd->decoded_x0,tcd->decoded_y0,tcd->decoded_x1,tcd->decoded_y1. + * tcd->win_x0,tcd->win_y0,tcd->win_x1,tcd->win_y1. * * @param tcd TCD handle. * @param compno Component number @@ -449,7 +470,6 @@ OPJ_BOOL opj_tcd_is_subband_area_of_interest(opj_tcd_t *tcd, OPJ_UINT32 x1, OPJ_UINT32 y1); - /* ----------------------------------------------------------------------- */ /*@}*/ |
