OpenJPEG  1.5.1
j2k.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
3  * Copyright (c) 2002-2007, Professor Benoit Macq
4  * Copyright (c) 2001-2003, David Janssens
5  * Copyright (c) 2002-2003, Yannick Verschueren
6  * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
7  * Copyright (c) 2005, Herve Drolon, FreeImage Team
8  * Copyright (c) 2006-2007, Parvatha Elangovan
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 #ifndef __J2K_H
33 #define __J2K_H
34 
43 
44 #define J2K_CP_CSTY_PRT 0x01
45 #define J2K_CP_CSTY_SOP 0x02
46 #define J2K_CP_CSTY_EPH 0x04
47 #define J2K_CCP_CSTY_PRT 0x01
48 #define J2K_CCP_CBLKSTY_LAZY 0x01
49 #define J2K_CCP_CBLKSTY_RESET 0x02
50 #define J2K_CCP_CBLKSTY_TERMALL 0x04
51 #define J2K_CCP_CBLKSTY_VSC 0x08
52 #define J2K_CCP_CBLKSTY_PTERM 0x10
53 #define J2K_CCP_CBLKSTY_SEGSYM 0x20
54 #define J2K_CCP_QNTSTY_NOQNT 0
55 #define J2K_CCP_QNTSTY_SIQNT 1
56 #define J2K_CCP_QNTSTY_SEQNT 2
57 
58 /* ----------------------------------------------------------------------- */
59 
60 #define J2K_MS_SOC 0xff4f
61 #define J2K_MS_SOT 0xff90
62 #define J2K_MS_SOD 0xff93
63 #define J2K_MS_EOC 0xffd9
64 #define J2K_MS_SIZ 0xff51
65 #define J2K_MS_COD 0xff52
66 #define J2K_MS_COC 0xff53
67 #define J2K_MS_RGN 0xff5e
68 #define J2K_MS_QCD 0xff5c
69 #define J2K_MS_QCC 0xff5d
70 #define J2K_MS_POC 0xff5f
71 #define J2K_MS_TLM 0xff55
72 #define J2K_MS_PLM 0xff57
73 #define J2K_MS_PLT 0xff58
74 #define J2K_MS_PPM 0xff60
75 #define J2K_MS_PPT 0xff61
76 #define J2K_MS_SOP 0xff91
77 #define J2K_MS_EPH 0xff92
78 #define J2K_MS_CRG 0xff63
79 #define J2K_MS_COM 0xff64
80 /* UniPG>> */
81 #ifdef USE_JPWL
82 #define J2K_MS_EPC 0xff68
83 #define J2K_MS_EPB 0xff66
84 #define J2K_MS_ESD 0xff67
85 #define J2K_MS_RED 0xff69
86 #endif /* USE_JPWL */
87 #ifdef USE_JPSEC
88 #define J2K_MS_SEC 0xff65
89 #define J2K_MS_INSEC 0xff94
90 #endif /* USE_JPSEC */
91 /* <<UniPG */
92 
93 
94 /* ----------------------------------------------------------------------- */
95 
100 typedef enum J2K_STATUS {
101  J2K_STATE_MHSOC = 0x0001,
102  J2K_STATE_MHSIZ = 0x0002,
103  J2K_STATE_MH = 0x0004,
104  J2K_STATE_TPHSOT = 0x0008,
105  J2K_STATE_TPH = 0x0010,
106  J2K_STATE_MT = 0x0020,
107  J2K_STATE_NEOC = 0x0040,
108  J2K_STATE_ERR = 0x0080
109 } J2K_STATUS;
110 
111 /* ----------------------------------------------------------------------- */
112 
116 typedef enum T2_MODE {
119 }J2K_T2_MODE;
120 
124 typedef struct opj_stepsize {
126  int expn;
128  int mant;
130 
134 typedef struct opj_tccp {
136  int csty;
140  int cblkw;
142  int cblkh;
144  int cblksty;
146  int qmfbid;
148  int qntsty;
152  int numgbits;
154  int roishift;
159 } opj_tccp_t;
160 
166 typedef struct opj_tcp {
168  int first;
170  int csty;
176  int mct;
178  float rates[100];
180  int numpocs;
182  int POC;
186  unsigned char *ppt_data;
188  unsigned char *ppt_data_first;
190  int ppt;
194  int ppt_len;
196  float distoratio[100];
199 } opj_tcp_t;
200 
204 typedef struct opj_cp {
210  int img_size;
214  char tp_on;
216  char tp_flag;
218  int tp_pos;
226  int reduce;
228  int layer;
232  int tx0;
234  int ty0;
236  int tdx;
238  int tdy;
240  char *comment;
242  int tw;
244  int th;
246  int *tileno;
250  unsigned char *ppm_data;
252  unsigned char *ppm_data_first;
254  int ppm;
260  int ppm_len;
264  int *matrice;
265 /* UniPG>> */
266 #ifdef USE_JPWL
267 
278  int hprot_MH;
296  int sens_MH;
307 #endif /* USE_JPWL */
308 /* <<UniPG */
309 } opj_cp_t;
310 
314 typedef struct opj_j2k {
317 
319  int state;
323  int tp_num;
335  int totnum_tp;
340  unsigned char *eot;
353  unsigned char **tile_data;
355  int *tile_len;
369 } opj_j2k_t;
370 
373 /* ----------------------------------------------------------------------- */
391 void j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
426 void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_t *image);
440 
441 /* ----------------------------------------------------------------------- */
445 
446 #endif /* __J2K_H */
opj_cio_t * cio
pointer to the byte i/o stream
Definition: j2k.h:368
int max_comp_size
Maximum rate for each component.
Definition: j2k.h:208
int img_size
Size of the image in bits.
Definition: j2k.h:210
int ppt_store
used in case of multiple marker PPT (number of info already stored)
Definition: j2k.h:192
struct opj_cp opj_cp_t
Coding parameters.
unsigned char * ppm_data
packet header store there for futur use in t2_decode_packet
Definition: j2k.h:250
#define JPWL_MAX_NO_TILESPECS
Maximum number of tile parts expected by JPWL: increase at your will.
Definition: openjpeg.h:81
T2_MODE
T2 encoding mode.
Definition: j2k.h:116
int tx0
XTOsiz.
Definition: j2k.h:232
int first
1 : first part-tile of a tile
Definition: j2k.h:168
int fixed_quality
add fixed_quality
Definition: j2k.h:224
opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info)
Encode an image into a JPEG-2000 codestream.
Definition: j2k.c:2426
int qntsty
quantisation style
Definition: j2k.h:148
int ppm_len
ppmbug1
Definition: j2k.h:260
void j2k_destroy_decompress(opj_j2k_t *j2k)
Destroy a J2K decompressor handle.
Definition: j2k.c:1852
int numlayers
number of layers
Definition: j2k.h:174
int tp_pos
Position of tile part flag in progression order.
Definition: j2k.h:218
Progression order changes.
Definition: openjpeg.h:202
int prch[J2K_MAXRLVLS]
precinct height
Definition: j2k.h:158
int ppm_store
use in case of multiple marker PPM (number of info already store)
Definition: j2k.h:256
opj_bool red_on
enables writing of RED, in case of activated JPWL
Definition: j2k.h:276
opj_cp_t * cp
pointer to the coding parameters
Definition: j2k.h:364
JPEG-2000 codestream reader/writer.
Definition: j2k.h:314
opj_bool correct
enables JPWL correction at the decoder
Definition: j2k.h:302
opj_tccp_t * tccps
tile-component coding parameters
Definition: j2k.h:198
int sod_start
Definition: j2k.h:346
int qmfbid
discrete wavelet transform identifier
Definition: j2k.h:146
int * tileno
ID number of the tiles present in the codestream.
Definition: j2k.h:246
Tile-component coding parameters.
Definition: j2k.h:134
int cblkw
code-blocks width
Definition: j2k.h:140
opj_bool esd_on
enables writing of ESD, in case of activated JPWL
Definition: j2k.h:272
int cblkh
code-blocks height
Definition: j2k.h:142
opj_bool epb_on
enables writing of EPB, in case of activated JPWL
Definition: j2k.h:270
the EOC marker has just been read
Definition: j2k.h:106
int tp_num
Tile part number.
Definition: j2k.h:323
int sens_TPH[JPWL_MAX_NO_TILESPECS]
sensitivity methods for TPHs (-1,0-7)
Definition: j2k.h:300
int hprot_TPH[JPWL_MAX_NO_TILESPECS]
error protection methods for TPHs (0,1,16,32,37-128)
Definition: j2k.h:282
the decoding process is in the main header
Definition: j2k.h:103
int POC
indicates if a POC marker has been used O:NO, 1:YES
Definition: j2k.h:182
int cur_tp_num
Tilepart number currently coding.
Definition: j2k.h:325
the decoding process must not expect a EOC marker because the codestream is truncated ...
Definition: j2k.h:107
int roishift
Region Of Interest shift.
Definition: j2k.h:154
int tdy
YTsiz.
Definition: j2k.h:238
int mct
multi-component transform identifier
Definition: j2k.h:176
int csty
coding style
Definition: j2k.h:136
opj_poc_t pocs[32]
progression order changes
Definition: j2k.h:184
opj_bool info_on
enables writing of informative techniques of ESD, in case of activated JPWL
Definition: j2k.h:274
OPJ_CINEMA_MODE cinema
Digital cinema profile.
Definition: j2k.h:206
struct opj_j2k opj_j2k_t
JPEG-2000 codestream reader/writer.
int tileno_size
size of the vector tileno
Definition: j2k.h:248
char * j2k_convert_progression_order(OPJ_PROG_ORDER prg_order)
Converts an enum type progression order to string type.
Definition: j2k.c:269
int reduce
if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the ...
Definition: j2k.h:226
the decoding process has encountered an error
Definition: j2k.h:108
a SOC marker is expected
Definition: j2k.h:101
char * comment
comment for coding
Definition: j2k.h:240
Defines image data and characteristics.
Definition: openjpeg.h:533
opj_j2k_t * j2k_create_decompress(opj_common_ptr cinfo)
Creates a J2K decompression structure.
Definition: j2k.c:1835
OPJ_LIMIT_DECODING limit_decoding
if == NO_LIMITATION, decode entire codestream; if == LIMIT_TO_MAIN_HEADER then only decode the main h...
Definition: j2k.h:230
opj_tcp_t * default_tcp
decompression only : store decoding parameters common to all tiles (information like COD...
Definition: j2k.h:360
unsigned char * ppm_data_first
pointer remaining on the first byte of the first header if ppm is used
Definition: j2k.h:252
the decoding process is in a tile part header
Definition: j2k.h:105
int max_tiles
maximum number of tiles at the decoder
Definition: j2k.h:306
int disto_alloc
allocation by rate/distortion
Definition: j2k.h:220
char tp_flag
Flag determining tile part generation.
Definition: j2k.h:216
int numgbits
number of guard bits
Definition: j2k.h:152
enum T2_MODE J2K_T2_MODE
T2 encoding mode.
unsigned char ** tile_data
array used to store the data of each tile
Definition: j2k.h:353
int exp_comps
expected number of components at the decoder
Definition: j2k.h:304
Decompression parameters.
Definition: openjpeg.h:363
void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_t *image)
Setup the encoder parameters using the current image and using user parameters.
Definition: j2k.c:2168
enum LIMIT_DECODING OPJ_LIMIT_DECODING
Limit decoding to certain portions of the codestream.
struct opj_stepsize opj_stepsize_t
Quantization stepsize.
Definition: j2k.h:117
int expn
exponent
Definition: j2k.h:126
Byte input-output stream (CIO)
Definition: openjpeg.h:475
int totnum_tp
Total num of tile parts in whole image = num tiles* num tileparts in each tile.
Definition: j2k.h:335
int numresolutions
number of resolutions
Definition: j2k.h:138
opj_image_t * j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info)
Decode an image form a JPT-stream (JPEG 2000, JPIP)
Definition: j2k.c:2047
int cblksty
code-block coding style
Definition: j2k.h:144
int ppt_len
ppmbug1
Definition: j2k.h:194
enum PROG_ORDER OPJ_PROG_ORDER
Progression order.
int layer
if != 0, then only the first &quot;layer&quot; layers are decoded; if == 0 or not used, all the quality layers ...
Definition: j2k.h:228
unsigned char * ppt_data
packet header store there for futur use in t2_decode_packet
Definition: j2k.h:186
int sens_TPH_tileno[JPWL_MAX_NO_TILESPECS]
tile number of sensitivity specification (&gt;=0)
Definition: j2k.h:298
opj_stepsize_t stepsizes[J2K_MAXBANDS]
stepsizes used for quantization
Definition: j2k.h:150
int ppm
if ppm == 1 –&gt; there was a PPM marker for the present tile
Definition: j2k.h:254
enum RSIZ_CAPABILITIES OPJ_RSIZ_CAPABILITIES
Rsiz Capabilities.
int mant
mantissa
Definition: j2k.h:128
float distoratio[100]
add fixed_quality
Definition: j2k.h:196
OPJ_PROG_ORDER prg
progression order
Definition: j2k.h:172
Coding parameters.
Definition: j2k.h:204
void j2k_destroy_compress(opj_j2k_t *j2k)
Destroy a J2K compressor handle.
Definition: j2k.c:2145
#define J2K_MAXBANDS
Number of maximum sub-band linked to number of resolution level.
Definition: openjpeg.h:78
int * matrice
fixed layer
Definition: j2k.h:264
float rates[100]
rates of layers
Definition: j2k.h:178
Quantization stepsize.
Definition: j2k.h:124
void j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters)
Setup the decoder decoding parameters using user parameters.
Definition: j2k.c:1909
int hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS]
tile number of header protection specification (&gt;=0)
Definition: j2k.h:280
opj_image_t * image
pointer to the encoded / decoded image
Definition: j2k.h:362
unsigned char * eot
locate the position of the end of the tile in the codestream, used to detect a truncated codestream (...
Definition: j2k.h:340
J2K_STATUS
Values that specify the status of the decoding process when decoding the main header.
Definition: j2k.h:100
int numpocs
number of progression order changes
Definition: j2k.h:180
int sens_MH
sensitivity method for MH (-1,0-7)
Definition: j2k.h:296
int sot_start
locate the start position of the SOT marker of the current coded tile: after encoding the tile...
Definition: j2k.h:345
char tp_on
Enabling Tile part generation.
Definition: j2k.h:214
int sens_addr
sensitivity addressing size (0=auto/2/4 bytes)
Definition: j2k.h:292
int * cur_totnum_tp
Total number of tileparts of the current tile.
Definition: j2k.h:327
int sens_size
enables writing of ESD, (0/2/4 bytes)
Definition: j2k.h:290
Function called in Rate allocation process.
Definition: j2k.h:118
int opj_bool
Definition: openjpeg.h:63
int fixed_alloc
allocation by fixed layer
Definition: j2k.h:222
opj_j2k_t * j2k_create_compress(opj_common_ptr cinfo)
Creates a J2K compression structure.
Definition: j2k.c:2137
int tw
number of tiles in width
Definition: j2k.h:242
int ppm_previous
use in case of multiple marker PPM (case on non-finished previous info)
Definition: j2k.h:258
int sens_range
sensitivity range (0-3)
Definition: j2k.h:294
#define J2K_MAXRLVLS
Number of maximum resolution level authorized.
Definition: openjpeg.h:77
int state
locate in which part of the codestream the decoder is (main header, tile header, end) ...
Definition: j2k.h:319
opj_common_ptr cinfo
codec context
Definition: j2k.h:316
int ty0
YTOsiz.
Definition: j2k.h:234
int pprot_tileno[JPWL_MAX_NO_PACKSPECS]
tile number of packet protection specification (&gt;=0)
Definition: j2k.h:284
unsigned char * ppt_data_first
pointer remaining on the first byte of the first header if ppt is used
Definition: j2k.h:188
opj_codestream_info_t * cstr_info
helper used to write the index file
Definition: j2k.h:366
struct opj_tcp opj_tcp_t
Tile coding parameters : this structure is used to store coding/decoding parameters common to all til...
int * tile_len
array used to store the length of each tile
Definition: j2k.h:355
Tile coding parameters : this structure is used to store coding/decoding parameters common to all til...
Definition: j2k.h:166
int tlm_start
locate the start position of the TLM marker after encoding the tilepart, a jump (in j2k_write_sod) is...
Definition: j2k.h:332
Compression parameters.
Definition: openjpeg.h:230
int hprot_MH
error protection method for MH (0,1,16,32,37-128)
Definition: j2k.h:278
opj_bool epc_on
enables writing of EPC in MH, thus activating JPWL
Definition: j2k.h:268
OPJ_RSIZ_CAPABILITIES rsiz
Rsiz.
Definition: j2k.h:212
int tdx
XTsiz.
Definition: j2k.h:236
int prcw[J2K_MAXRLVLS]
precinct width
Definition: j2k.h:156
enum CINEMA_MODE OPJ_CINEMA_MODE
Digital cinema operation mode.
int csty
coding style
Definition: j2k.h:170
int ppt
If ppt == 1 –&gt; there was a PPT marker for the present tile.
Definition: j2k.h:190
#define JPWL_MAX_NO_PACKSPECS
Maximum number of packet parts expected by JPWL: increase at your will.
Definition: openjpeg.h:82
int pprot_packno[JPWL_MAX_NO_PACKSPECS]
packet number of packet protection specification (&gt;=0)
Definition: j2k.h:286
int curtileno
number of the tile curently concern by coding/decoding
Definition: j2k.h:321
a SIZ marker is expected
Definition: j2k.h:102
Index structure of the codestream.
Definition: openjpeg.h:672
the decoding process is in a tile part header and expects a SOT marker
Definition: j2k.h:104
int pprot[JPWL_MAX_NO_PACKSPECS]
error protection methods for packets (0,1,16,32,37-128)
Definition: j2k.h:288
int th
number of tiles in heigth
Definition: j2k.h:244
opj_tcp_t * tcps
tile coding parameters
Definition: j2k.h:262
int pos_correction
as the J2K-file is written in several parts during encoding, it enables to make the right correction ...
Definition: j2k.h:351
opj_image_t * j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info)
Decode an image from a JPEG-2000 codestream.
Definition: j2k.c:1929
struct opj_tccp opj_tccp_t
Tile-component coding parameters.
Definition: openjpeg.h:430