OpenJPEG 1.5.2
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
40
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
110
111/* ----------------------------------------------------------------------- */
112
120
130
160
166typedef struct opj_tcp {
168 int first;
170 int csty;
176 int mct;
178 float rates[100];
182 int POC;
186 unsigned char *ppt_data;
188 unsigned char *ppt_data_first;
190 int ppt;
196 float distoratio[100];
200
310
370
373/* ----------------------------------------------------------------------- */
391void j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
426void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_t *image);
440
441/* ----------------------------------------------------------------------- */
443
445
446#endif /* __J2K_H */
T2_MODE
T2 encoding mode.
Definition j2k.h:116
@ THRESH_CALC
Definition j2k.h:117
@ FINAL_PASS
Function called in Rate allocation process.
Definition j2k.h:118
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:1944
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:2061
struct opj_j2k opj_j2k_t
JPEG-2000 codestream reader/writer.
void j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters)
Setup the decoder decoding parameters using user parameters.
Definition j2k.c:1924
void j2k_destroy_decompress(opj_j2k_t *j2k)
Destroy a J2K decompressor handle.
Definition j2k.c:1866
enum T2_MODE J2K_T2_MODE
T2 encoding mode.
struct opj_cp opj_cp_t
Coding parameters.
opj_j2k_t * j2k_create_decompress(opj_common_ptr cinfo)
Creates a J2K decompression structure.
Definition j2k.c:1849
void j2k_destroy_compress(opj_j2k_t *j2k)
Destroy a J2K compressor handle.
Definition j2k.c:2159
struct opj_stepsize opj_stepsize_t
Quantization stepsize.
opj_j2k_t * j2k_create_compress(opj_common_ptr cinfo)
Creates a J2K compression structure.
Definition j2k.c:2151
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:2440
char * j2k_convert_progression_order(OPJ_PROG_ORDER prg_order)
Converts an enum type progression order to string type.
Definition j2k.c:270
struct opj_tcp opj_tcp_t
Tile coding parameters : this structure is used to store coding/decoding parameters common to all til...
struct opj_tccp opj_tccp_t
Tile-component coding parameters.
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:2182
J2K_STATUS
Values that specify the status of the decoding process when decoding the main header.
Definition j2k.h:100
@ J2K_STATE_TPHSOT
the decoding process is in a tile part header and expects a SOT marker
Definition j2k.h:104
@ J2K_STATE_TPH
the decoding process is in a tile part header
Definition j2k.h:105
@ J2K_STATE_MHSOC
a SOC marker is expected
Definition j2k.h:101
@ J2K_STATE_MH
the decoding process is in the main header
Definition j2k.h:103
@ J2K_STATE_NEOC
the decoding process must not expect a EOC marker because the codestream is truncated
Definition j2k.h:107
@ J2K_STATE_ERR
the decoding process has encountered an error
Definition j2k.h:108
@ J2K_STATE_MHSIZ
a SIZ marker is expected
Definition j2k.h:102
@ J2K_STATE_MT
the EOC marker has just been read
Definition j2k.h:106
enum RSIZ_CAPABILITIES OPJ_RSIZ_CAPABILITIES
Rsiz Capabilities.
#define JPWL_MAX_NO_TILESPECS
Maximum number of tile parts expected by JPWL: increase at your will.
Definition openjpeg.h:81
struct opj_codestream_info opj_codestream_info_t
Index structure of the codestream.
struct opj_dparameters opj_dparameters_t
Decompression parameters.
enum PROG_ORDER OPJ_PROG_ORDER
Progression order.
struct opj_cparameters opj_cparameters_t
Compression parameters.
#define J2K_MAXBANDS
Number of maximum sub-band linked to number of resolution level.
Definition openjpeg.h:78
int opj_bool
Definition openjpeg.h:63
#define JPWL_MAX_NO_PACKSPECS
Maximum number of packet parts expected by JPWL: increase at your will.
Definition openjpeg.h:82
opj_common_struct_t * opj_common_ptr
Definition openjpeg.h:438
struct opj_poc opj_poc_t
Progression order changes.
struct opj_image opj_image_t
Defines image data and characteristics.
enum LIMIT_DECODING OPJ_LIMIT_DECODING
Limit decoding to certain portions of the codestream.
#define J2K_MAXRLVLS
Number of maximum resolution level authorized.
Definition openjpeg.h:77
enum CINEMA_MODE OPJ_CINEMA_MODE
Digital cinema operation mode.
struct opj_cio opj_cio_t
Byte input-output stream (CIO)
Coding parameters.
Definition j2k.h:204
int fixed_alloc
allocation by fixed layer
Definition j2k.h:222
opj_bool correct
enables JPWL correction at the decoder
Definition j2k.h:302
int ppm
if ppm == 1 --> there was a PPM marker for the present tile
Definition j2k.h:254
int pprot[JPWL_MAX_NO_PACKSPECS]
error protection methods for packets (0,1,16,32,37-128)
Definition j2k.h:288
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
int hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS]
tile number of header protection specification (>=0)
Definition j2k.h:280
int * tileno
ID number of the tiles present in the codestream.
Definition j2k.h:246
unsigned char * ppm_data_first
pointer remaining on the first byte of the first header if ppm is used
Definition j2k.h:252
int hprot_MH
error protection method for MH (0,1,16,32,37-128)
Definition j2k.h:278
int exp_comps
expected number of components at the decoder
Definition j2k.h:304
opj_bool esd_on
enables writing of ESD, in case of activated JPWL
Definition j2k.h:272
char tp_on
Enabling Tile part generation.
Definition j2k.h:214
int pprot_tileno[JPWL_MAX_NO_PACKSPECS]
tile number of packet protection specification (>=0)
Definition j2k.h:284
opj_bool epc_on
enables writing of EPC in MH, thus activating JPWL
Definition j2k.h:268
int pprot_packno[JPWL_MAX_NO_PACKSPECS]
packet number of packet protection specification (>=0)
Definition j2k.h:286
int layer
if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers ...
Definition j2k.h:228
int sens_addr
sensitivity addressing size (0=auto/2/4 bytes)
Definition j2k.h:292
char tp_flag
Flag determining tile part generation.
Definition j2k.h:216
int tp_pos
Position of tile part flag in progression order.
Definition j2k.h:218
unsigned char * ppm_data
packet header store there for futur use in t2_decode_packet
Definition j2k.h:250
int img_size
Size of the image in bits.
Definition j2k.h:210
int max_comp_size
Maximum rate for each component.
Definition j2k.h:208
char * comment
comment for coding
Definition j2k.h:240
int tileno_size
size of the vector tileno
Definition j2k.h:248
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
int max_tiles
maximum number of tiles at the decoder
Definition j2k.h:306
OPJ_RSIZ_CAPABILITIES rsiz
Rsiz.
Definition j2k.h:212
int tw
number of tiles in width
Definition j2k.h:242
int tx0
XTOsiz.
Definition j2k.h:232
opj_bool info_on
enables writing of informative techniques of ESD, in case of activated JPWL
Definition j2k.h:274
int fixed_quality
add fixed_quality
Definition j2k.h:224
int sens_TPH[JPWL_MAX_NO_TILESPECS]
sensitivity methods for TPHs (-1,0-7)
Definition j2k.h:300
int sens_TPH_tileno[JPWL_MAX_NO_TILESPECS]
tile number of sensitivity specification (>=0)
Definition j2k.h:298
int th
number of tiles in heigth
Definition j2k.h:244
int * matrice
fixed layer
Definition j2k.h:264
OPJ_CINEMA_MODE cinema
Digital cinema profile.
Definition j2k.h:206
int tdy
YTsiz.
Definition j2k.h:238
int ppm_len
ppmbug1
Definition j2k.h:260
int ppm_previous
use in case of multiple marker PPM (case on non-finished previous info)
Definition j2k.h:258
opj_tcp_t * tcps
tile coding parameters
Definition j2k.h:262
opj_bool red_on
enables writing of RED, in case of activated JPWL
Definition j2k.h:276
opj_bool epb_on
enables writing of EPB, in case of activated JPWL
Definition j2k.h:270
int sens_range
sensitivity range (0-3)
Definition j2k.h:294
int sens_MH
sensitivity method for MH (-1,0-7)
Definition j2k.h:296
int disto_alloc
allocation by rate/distortion
Definition j2k.h:220
int sens_size
enables writing of ESD, (0/2/4 bytes)
Definition j2k.h:290
int tdx
XTsiz.
Definition j2k.h:236
int ppm_store
use in case of multiple marker PPM (number of info already store)
Definition j2k.h:256
int hprot_TPH[JPWL_MAX_NO_TILESPECS]
error protection methods for TPHs (0,1,16,32,37-128)
Definition j2k.h:282
int ty0
YTOsiz.
Definition j2k.h:234
JPEG-2000 codestream reader/writer.
Definition j2k.h:314
int cur_tp_num
Tilepart number currently coding.
Definition j2k.h:325
unsigned char ** tile_data
array used to store the data of each tile
Definition j2k.h:353
int sot_start
locate the start position of the SOT marker of the current coded tile: after encoding the tile,...
Definition j2k.h:345
int * cur_totnum_tp
Total number of tileparts of the current tile.
Definition j2k.h:327
opj_tcp_t * default_tcp
decompression only : store decoding parameters common to all tiles (information like COD,...
Definition j2k.h:360
opj_common_ptr cinfo
codec context
Definition j2k.h:316
int state
locate in which part of the codestream the decoder is (main header, tile header, end)
Definition j2k.h:319
opj_codestream_info_t * cstr_info
helper used to write the index file
Definition j2k.h:366
int curtileno
number of the tile curently concern by coding/decoding
Definition j2k.h:321
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
int sod_start
Definition j2k.h:346
opj_cp_t * cp
pointer to the coding parameters
Definition j2k.h:364
int tp_num
Tile part number.
Definition j2k.h:323
int * tile_len
array used to store the length of each tile
Definition j2k.h:355
opj_cio_t * cio
pointer to the byte i/o stream
Definition j2k.h:368
int totnum_tp
Total num of tile parts in whole image = num tiles* num tileparts in each tile.
Definition j2k.h:335
int tlm_start
locate the start position of the TLM marker after encoding the tilepart, a jump (in j2k_write_sod) ...
Definition j2k.h:332
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 * image
pointer to the encoded / decoded image
Definition j2k.h:362
Quantization stepsize.
Definition j2k.h:124
int expn
exponent
Definition j2k.h:126
int mant
mantissa
Definition j2k.h:128
Tile-component coding parameters.
Definition j2k.h:134
int prch[J2K_MAXRLVLS]
precinct height
Definition j2k.h:158
int cblkw
code-blocks width
Definition j2k.h:140
int cblkh
code-blocks height
Definition j2k.h:142
int prcw[J2K_MAXRLVLS]
precinct width
Definition j2k.h:156
int roishift
Region Of Interest shift.
Definition j2k.h:154
int qmfbid
discrete wavelet transform identifier
Definition j2k.h:146
int qntsty
quantisation style
Definition j2k.h:148
int numresolutions
number of resolutions
Definition j2k.h:138
int numgbits
number of guard bits
Definition j2k.h:152
opj_stepsize_t stepsizes[J2K_MAXBANDS]
stepsizes used for quantization
Definition j2k.h:150
int cblksty
code-block coding style
Definition j2k.h:144
int csty
coding style
Definition j2k.h:136
Tile coding parameters : this structure is used to store coding/decoding parameters common to all til...
Definition j2k.h:166
int csty
coding style
Definition j2k.h:170
int mct
multi-component transform identifier
Definition j2k.h:176
OPJ_PROG_ORDER prg
progression order
Definition j2k.h:172
opj_tccp_t * tccps
tile-component coding parameters
Definition j2k.h:198
int ppt_len
ppmbug1
Definition j2k.h:194
int numpocs
number of progression order changes
Definition j2k.h:180
int ppt
If ppt == 1 --> there was a PPT marker for the present tile.
Definition j2k.h:190
opj_poc_t pocs[32]
progression order changes
Definition j2k.h:184
int POC
indicates if a POC marker has been used O:NO, 1:YES
Definition j2k.h:182
float distoratio[100]
add fixed_quality
Definition j2k.h:196
unsigned char * ppt_data_first
pointer remaining on the first byte of the first header if ppt is used
Definition j2k.h:188
float rates[100]
rates of layers
Definition j2k.h:178
int numlayers
number of layers
Definition j2k.h:174
unsigned char * ppt_data
packet header store there for futur use in t2_decode_packet
Definition j2k.h:186
int first
1 : first part-tile of a tile
Definition j2k.h:168
int ppt_store
used in case of multiple marker PPT (number of info already stored)
Definition j2k.h:192