OpenJPEG  2.3.1
j2k.h
Go to the documentation of this file.
1 /*
2  * The copyright in this software is being made available under the 2-clauses
3  * BSD License, included below. This software may be subject to other third
4  * party and contributor rights, including patent rights, and no such rights
5  * are granted under this license.
6  *
7  * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
8  * Copyright (c) 2002-2014, Professor Benoit Macq
9  * Copyright (c) 2001-2003, David Janssens
10  * Copyright (c) 2002-2003, Yannick Verschueren
11  * Copyright (c) 2003-2007, Francois-Olivier Devaux
12  * Copyright (c) 2003-2014, Antonin Descampe
13  * Copyright (c) 2005, Herve Drolon, FreeImage Team
14  * Copyright (c) 2006-2007, Parvatha Elangovan
15  * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
16  * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
17  * Copyright (c) 2012, CS Systemes d'Information, France
18  *
19  * All rights reserved.
20  *
21  * Redistribution and use in source and binary forms, with or without
22  * modification, are permitted provided that the following conditions
23  * are met:
24  * 1. Redistributions of source code must retain the above copyright
25  * notice, this list of conditions and the following disclaimer.
26  * 2. Redistributions in binary form must reproduce the above copyright
27  * notice, this list of conditions and the following disclaimer in the
28  * documentation and/or other materials provided with the distribution.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
31  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40  * POSSIBILITY OF SUCH DAMAGE.
41  */
42 #ifndef OPJ_J2K_H
43 #define OPJ_J2K_H
44 
53 
54 #define J2K_CP_CSTY_PRT 0x01
55 #define J2K_CP_CSTY_SOP 0x02
56 #define J2K_CP_CSTY_EPH 0x04
57 #define J2K_CCP_CSTY_PRT 0x01
58 #define J2K_CCP_CBLKSTY_LAZY 0x01
59 #define J2K_CCP_CBLKSTY_RESET 0x02
60 #define J2K_CCP_CBLKSTY_TERMALL 0x04
61 #define J2K_CCP_CBLKSTY_VSC 0x08
62 #define J2K_CCP_CBLKSTY_PTERM 0x10
63 #define J2K_CCP_CBLKSTY_SEGSYM 0x20
64 #define J2K_CCP_QNTSTY_NOQNT 0
65 #define J2K_CCP_QNTSTY_SIQNT 1
66 #define J2K_CCP_QNTSTY_SEQNT 2
67 
68 /* ----------------------------------------------------------------------- */
69 
70 #define J2K_MS_SOC 0xff4f
71 #define J2K_MS_SOT 0xff90
72 #define J2K_MS_SOD 0xff93
73 #define J2K_MS_EOC 0xffd9
74 #define J2K_MS_SIZ 0xff51
75 #define J2K_MS_COD 0xff52
76 #define J2K_MS_COC 0xff53
77 #define J2K_MS_RGN 0xff5e
78 #define J2K_MS_QCD 0xff5c
79 #define J2K_MS_QCC 0xff5d
80 #define J2K_MS_POC 0xff5f
81 #define J2K_MS_TLM 0xff55
82 #define J2K_MS_PLM 0xff57
83 #define J2K_MS_PLT 0xff58
84 #define J2K_MS_PPM 0xff60
85 #define J2K_MS_PPT 0xff61
86 #define J2K_MS_SOP 0xff91
87 #define J2K_MS_EPH 0xff92
88 #define J2K_MS_CRG 0xff63
89 #define J2K_MS_COM 0xff64
90 #define J2K_MS_CBD 0xff78
91 #define J2K_MS_MCC 0xff75
92 #define J2K_MS_MCT 0xff74
93 #define J2K_MS_MCO 0xff77
95 #define J2K_MS_UNK 0
97 /* UniPG>> */
98 #ifdef USE_JPWL
99 #define J2K_MS_EPC 0xff68
100 #define J2K_MS_EPB 0xff66
101 #define J2K_MS_ESD 0xff67
102 #define J2K_MS_RED 0xff69
103 #endif /* USE_JPWL */
104 #ifdef USE_JPSEC
105 #define J2K_MS_SEC 0xff65
106 #define J2K_MS_INSEC 0xff94
107 #endif /* USE_JPSEC */
108 /* <<UniPG */
109 
110 #define J2K_MAX_POCS 32
112 /* ----------------------------------------------------------------------- */
113 
118 typedef enum J2K_STATUS {
119  J2K_STATE_NONE = 0x0000,
120  J2K_STATE_MHSOC = 0x0001,
121  J2K_STATE_MHSIZ = 0x0002,
122  J2K_STATE_MH = 0x0004,
123  J2K_STATE_TPHSOT = 0x0008,
124  J2K_STATE_TPH = 0x0010,
125  J2K_STATE_MT = 0x0020,
126  J2K_STATE_NEOC = 0x0040,
127  J2K_STATE_DATA = 0x0080,
129  J2K_STATE_EOC = 0x0100,
130  J2K_STATE_ERR = 0x8000
131 } J2K_STATUS;
132 
136 typedef enum MCT_ELEMENT_TYPE {
142 
146 typedef enum MCT_ARRAY_TYPE {
151 
152 /* ----------------------------------------------------------------------- */
153 
157 typedef enum T2_MODE {
160 } J2K_T2_MODE;
161 
165 typedef struct opj_stepsize {
171 
175 typedef struct opj_tccp {
202 }
203 opj_tccp_t;
204 
205 
206 
210 typedef struct opj_mct_data {
216 }
218 
228 }
230 
231 typedef struct opj_ppx_struct {
232  OPJ_BYTE* m_data; /* m_data == NULL => Zppx not read yet */
234 } opj_ppx;
235 
241 typedef struct opj_tcp {
257 
262 
301 
302 
303  /***** FLAGS *******/
310 } opj_tcp_t;
311 
312 
313 
314 
315 typedef struct opj_encoding_param {
332 }
334 
335 typedef struct opj_decoding_param {
340 }
342 
343 
347 typedef struct opj_cp {
349  /*int img_size;*/
353  OPJ_UINT32 tx0; /* MSD see norm */
355  OPJ_UINT32 ty0; /* MSD see norm */
366 
371 
378 
380 
391 
394 
395  union {
398  }
400 
401 
402  /* UniPG>> */
403 #ifdef USE_JPWL
404 
415  int hprot_MH;
433  int sens_MH;
444 #endif /* USE_JPWL */
445 
446  /******** FLAGS *********/
453  /* <<UniPG */
454 } opj_cp_t;
455 
456 
457 typedef struct opj_j2k_dec {
473 
478 
485 
488 
496 
497 } opj_j2k_dec_t;
498 
499 typedef struct opj_j2k_enc {
502 
505 
519 
523 
524  /* encoded data for a tile */
526 
527  /* size of the encoded_data */
529 
530  /* encoded data for a tile */
532 
533  /* size of the encoded_data */
535 
536 
537 } opj_j2k_enc_t;
538 
539 
540 
541 struct opj_tcd;
545 typedef struct opj_j2k {
546  /* J2K codestream is decoded*/
548 
549  /* FIXME DOC*/
550  union {
553  }
555 
558 
559  /* pointer to the output image (decoded)*/
561 
564 
567 
570 
573 
576 
578  struct opj_tcd * m_tcd;
579 
582 
585 
589  unsigned int dump_state;
590 }
591 opj_j2k_t;
592 
593 
594 
595 
598 /* ----------------------------------------------------------------------- */
599 
606 void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
607 
609 
616 
617 
619  opj_cparameters_t *parameters,
621  opj_event_mgr_t * p_manager);
622 
627 
628 /* ----------------------------------------------------------------------- */
632 
638  opj_stream_private_t *p_stream,
639  opj_event_mgr_t * p_manager);
640 
652  opj_j2k_t* p_j2k,
653  opj_image_t** p_image,
654  opj_event_mgr_t* p_manager);
655 
656 
662 void opj_j2k_destroy(opj_j2k_t *p_j2k);
663 
670 
681  OPJ_UINT32 p_tile_index,
682  OPJ_BYTE * p_data,
683  OPJ_UINT32 p_data_size,
684  opj_stream_private_t *p_stream,
685  opj_event_mgr_t * p_manager);
686 
702  OPJ_UINT32 * p_tile_index,
703  OPJ_UINT32 * p_data_size,
704  OPJ_INT32 * p_tile_x0,
705  OPJ_INT32 * p_tile_y0,
706  OPJ_INT32 * p_tile_x1,
707  OPJ_INT32 * p_tile_y1,
708  OPJ_UINT32 * p_nb_comps,
709  OPJ_BOOL * p_go_on,
710  opj_stream_private_t *p_stream,
711  opj_event_mgr_t * p_manager);
712 
713 
725  OPJ_UINT32 numcomps,
726  const OPJ_UINT32* comps_indices,
727  opj_event_mgr_t * p_manager);
728 
743  opj_image_t* p_image,
744  OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
745  OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
746  opj_event_mgr_t * p_manager);
747 
754 
755 
764 void j2k_dump(opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream);
765 
766 
767 
775 void j2k_dump_image_header(opj_image_t* image, OPJ_BOOL dev_dump_flag,
776  FILE* out_stream);
777 
785 void j2k_dump_image_comp_header(opj_image_comp_t* comp, OPJ_BOOL dev_dump_flag,
786  FILE* out_stream);
787 
796 
805 
815  opj_stream_private_t *p_stream,
816  opj_image_t *p_image,
817  opj_event_mgr_t *p_manager);
818 
819 
821  opj_stream_private_t *p_stream,
822  opj_image_t* p_image,
823  opj_event_mgr_t * p_manager,
824  OPJ_UINT32 tile_index);
825 
827  OPJ_UINT32 res_factor,
828  opj_event_mgr_t * p_manager);
829 
830 
841  OPJ_UINT32 p_tile_index,
842  OPJ_BYTE * p_data,
843  OPJ_UINT32 p_data_size,
844  opj_stream_private_t *p_stream,
845  opj_event_mgr_t * p_manager);
846 
852  opj_event_mgr_t * p_manager);
853 
865  opj_stream_private_t *p_stream,
866  opj_image_t * p_image,
867  opj_event_mgr_t * p_manager);
868 
875  opj_event_mgr_t * p_manager);
876 
878 
879 
880 #endif /* OPJ_J2K_H */