00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef OPJ_TCD_H
00041 #define OPJ_TCD_H
00042
00052
00053
00057 typedef struct opj_tcd_pass {
00058 OPJ_UINT32 rate;
00059 OPJ_FLOAT64 distortiondec;
00060 OPJ_UINT32 len;
00061 OPJ_BITFIELD term : 1;
00062 } opj_tcd_pass_t;
00063
00067 typedef struct opj_tcd_layer {
00068 OPJ_UINT32 numpasses;
00069 OPJ_UINT32 len;
00070 OPJ_FLOAT64 disto;
00071 OPJ_BYTE *data;
00072 } opj_tcd_layer_t;
00073
00077 typedef struct opj_tcd_cblk_enc {
00078 OPJ_BYTE* data;
00079 opj_tcd_layer_t* layers;
00080 opj_tcd_pass_t* passes;
00081 OPJ_INT32 x0, y0, x1,
00082 y1;
00083 OPJ_UINT32 numbps;
00084 OPJ_UINT32 numlenbits;
00085 OPJ_UINT32 data_size;
00086 OPJ_UINT32
00087 numpasses;
00088 OPJ_UINT32 numpassesinlayers;
00089 OPJ_UINT32 totalpasses;
00090 } opj_tcd_cblk_enc_t;
00091
00092
00094 typedef struct opj_tcd_seg_data_chunk {
00095
00096
00097
00098 OPJ_BYTE * data;
00099 OPJ_UINT32 len;
00100 } opj_tcd_seg_data_chunk_t;
00101
00105 typedef struct opj_tcd_seg {
00106 OPJ_UINT32 len;
00107
00108 OPJ_UINT32 numpasses;
00109
00110 OPJ_UINT32 real_num_passes;
00111
00112 OPJ_UINT32 maxpasses;
00113
00114 OPJ_UINT32 numnewpasses;
00115
00116 OPJ_UINT32 newlen;
00117 } opj_tcd_seg_t;
00118
00120 typedef struct opj_tcd_cblk_dec {
00121 opj_tcd_seg_t* segs;
00122 opj_tcd_seg_data_chunk_t* chunks;
00123
00124 OPJ_INT32 x0, y0, x1, y1;
00125 OPJ_UINT32 numbps;
00126
00127 OPJ_UINT32 numlenbits;
00128
00129 OPJ_UINT32 numnewpasses;
00130
00131 OPJ_UINT32 numsegs;
00132
00133 OPJ_UINT32 real_num_segs;
00134 OPJ_UINT32 m_current_max_segs;
00135 OPJ_UINT32 numchunks;
00136 OPJ_UINT32 numchunksalloc;
00137
00138 OPJ_INT32* decoded_data;
00139 } opj_tcd_cblk_dec_t;
00140
00142 typedef struct opj_tcd_precinct {
00143
00144 OPJ_INT32 x0, y0, x1, y1;
00145 OPJ_UINT32 cw, ch;
00146 union {
00147 opj_tcd_cblk_enc_t* enc;
00148 opj_tcd_cblk_dec_t* dec;
00149 void* blocks;
00150 } cblks;
00151 OPJ_UINT32 block_size;
00152 opj_tgt_tree_t *incltree;
00153 opj_tgt_tree_t *imsbtree;
00154 } opj_tcd_precinct_t;
00155
00157 typedef struct opj_tcd_band {
00158
00159 OPJ_INT32 x0, y0, x1, y1;
00160
00161 OPJ_UINT32 bandno;
00162
00163 opj_tcd_precinct_t *precincts;
00164
00165 OPJ_UINT32 precincts_data_size;
00166 OPJ_INT32 numbps;
00167 OPJ_FLOAT32 stepsize;
00168 } opj_tcd_band_t;
00169
00171 typedef struct opj_tcd_resolution {
00172
00173 OPJ_INT32 x0, y0, x1, y1;
00174
00175 OPJ_UINT32 pw, ph;
00176
00177 OPJ_UINT32 numbands;
00178
00179 opj_tcd_band_t bands[3];
00180
00181
00182 OPJ_UINT32 win_x0;
00183 OPJ_UINT32 win_y0;
00184 OPJ_UINT32 win_x1;
00185 OPJ_UINT32 win_y1;
00186 } opj_tcd_resolution_t;
00187
00189 typedef struct opj_tcd_tilecomp {
00190
00191 OPJ_INT32 x0, y0, x1, y1;
00192
00193 OPJ_UINT32 compno;
00194
00195 OPJ_UINT32 numresolutions;
00196
00197 OPJ_UINT32 minimum_num_resolutions;
00198
00199 opj_tcd_resolution_t *resolutions;
00200
00201 OPJ_UINT32 resolutions_size;
00202
00203
00204 OPJ_INT32 *data;
00205
00206 OPJ_BOOL ownsData;
00207
00208 size_t data_size_needed;
00209
00210 size_t data_size;
00211
00213 OPJ_INT32 *data_win;
00214
00215 OPJ_UINT32 win_x0;
00216 OPJ_UINT32 win_y0;
00217 OPJ_UINT32 win_x1;
00218 OPJ_UINT32 win_y1;
00219
00220
00221 OPJ_INT32 numpix;
00222 } opj_tcd_tilecomp_t;
00223
00224
00228 typedef struct opj_tcd_tile {
00229
00230 OPJ_INT32 x0, y0, x1, y1;
00231 OPJ_UINT32 numcomps;
00232 opj_tcd_tilecomp_t *comps;
00233 OPJ_INT32 numpix;
00234 OPJ_FLOAT64 distotile;
00235 OPJ_FLOAT64 distolayer[100];
00236 OPJ_UINT32 packno;
00237 } opj_tcd_tile_t;
00238
00242 typedef struct opj_tcd_image {
00243 opj_tcd_tile_t *tiles;
00244 }
00245 opj_tcd_image_t;
00246
00247
00251 typedef struct opj_tcd {
00253 OPJ_INT32 tp_pos;
00255 OPJ_UINT32 tp_num;
00257 OPJ_UINT32 cur_tp_num;
00259 OPJ_UINT32 cur_totnum_tp;
00261 OPJ_UINT32 cur_pino;
00263 opj_tcd_image_t *tcd_image;
00265 opj_image_t *image;
00267 opj_cp_t *cp;
00269 opj_tcp_t *tcp;
00271 OPJ_UINT32 tcd_tileno;
00273 OPJ_BITFIELD m_is_decoder : 1;
00275 opj_thread_pool_t* thread_pool;
00277 OPJ_UINT32 win_x0;
00278 OPJ_UINT32 win_y0;
00279 OPJ_UINT32 win_x1;
00280 OPJ_UINT32 win_y1;
00282 OPJ_BOOL whole_tile_decoding;
00283
00284 OPJ_BOOL* used_component;
00285 } opj_tcd_t;
00286
00289
00290
00294
00295
00301 opj_tcd_t* opj_tcd_create(OPJ_BOOL p_is_decoder);
00302
00307 void opj_tcd_destroy(opj_tcd_t *tcd);
00308
00318 OPJ_BOOL opj_tcd_init(opj_tcd_t *p_tcd,
00319 opj_image_t * p_image,
00320 opj_cp_t * p_cp,
00321 opj_thread_pool_t* p_tp);
00322
00333 OPJ_BOOL opj_tcd_init_decode_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
00334 opj_event_mgr_t* p_manager);
00335
00336 void opj_tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno,
00337 OPJ_UINT32 final);
00338
00339 void opj_tcd_rateallocate_fixed(opj_tcd_t *tcd);
00340
00341 void opj_tcd_makelayer(opj_tcd_t *tcd,
00342 OPJ_UINT32 layno,
00343 OPJ_FLOAT64 thresh,
00344 OPJ_UINT32 final);
00345
00346 OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd,
00347 OPJ_BYTE *dest,
00348 OPJ_UINT32 * p_data_written,
00349 OPJ_UINT32 len,
00350 opj_codestream_info_t *cstr_info,
00351 opj_event_mgr_t *p_manager);
00352
00356 OPJ_UINT32 opj_tcd_get_decoded_tile_size(opj_tcd_t *p_tcd,
00357 OPJ_BOOL take_into_account_partial_decoding);
00358
00370 OPJ_BOOL opj_tcd_encode_tile(opj_tcd_t *p_tcd,
00371 OPJ_UINT32 p_tile_no,
00372 OPJ_BYTE *p_dest,
00373 OPJ_UINT32 * p_data_written,
00374 OPJ_UINT32 p_len,
00375 struct opj_codestream_info *p_cstr_info,
00376 opj_event_mgr_t *p_manager);
00377
00378
00396 OPJ_BOOL opj_tcd_decode_tile(opj_tcd_t *tcd,
00397 OPJ_UINT32 win_x0,
00398 OPJ_UINT32 win_y0,
00399 OPJ_UINT32 win_x1,
00400 OPJ_UINT32 win_y1,
00401 OPJ_UINT32 numcomps_to_decode,
00402 const OPJ_UINT32 *comps_indices,
00403 OPJ_BYTE *src,
00404 OPJ_UINT32 len,
00405 OPJ_UINT32 tileno,
00406 opj_codestream_index_t *cstr_info,
00407 opj_event_mgr_t *manager);
00408
00409
00413 OPJ_BOOL opj_tcd_update_tile_data(opj_tcd_t *p_tcd,
00414 OPJ_BYTE * p_dest,
00415 OPJ_UINT32 p_dest_length);
00416
00420 OPJ_SIZE_T opj_tcd_get_encoded_tile_size(opj_tcd_t *p_tcd);
00421
00431 OPJ_BOOL opj_tcd_init_encode_tile(opj_tcd_t *p_tcd,
00432 OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager);
00433
00437 OPJ_BOOL opj_tcd_copy_tile_data(opj_tcd_t *p_tcd,
00438 OPJ_BYTE * p_src,
00439 OPJ_SIZE_T p_src_length);
00440
00446 OPJ_BOOL opj_alloc_tile_component_data(opj_tcd_tilecomp_t *l_tilec);
00447
00452 OPJ_BOOL opj_tcd_is_band_empty(opj_tcd_band_t* band);
00453
00455 void opj_tcd_reinit_segment(opj_tcd_seg_t* seg);
00456
00457
00472 OPJ_BOOL opj_tcd_is_subband_area_of_interest(opj_tcd_t *tcd,
00473 OPJ_UINT32 compno,
00474 OPJ_UINT32 resno,
00475 OPJ_UINT32 bandno,
00476 OPJ_UINT32 x0,
00477 OPJ_UINT32 y0,
00478 OPJ_UINT32 x1,
00479 OPJ_UINT32 y1);
00480
00481
00485
00486 #endif