fixed lt_version in configure.ac
[openjpeg.git] / libjp3dvm / t1_3d.h
1 /*\r
2  * Copyrigth (c) 2006, M�nica D�ez, LPI-UVA, Spain\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  * 1. Redistributions of source code must retain the above copyright\r
9  *    notice, this list of conditions and the following disclaimer.\r
10  * 2. Redistributions in binary form must reproduce the above copyright\r
11  *    notice, this list of conditions and the following disclaimer in the\r
12  *    documentation and/or other materials provided with the distribution.\r
13  *\r
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'\r
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\r
18  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
24  * POSSIBILITY OF SUCH DAMAGE.\r
25  */\r
26 #ifndef __T1_3D_H\r
27 #define __T1_3D_H\r
28 /**\r
29 @file t1_3d.h\r
30 @brief Implementation of the tier-1 coding (coding of code-block coefficients) (T1)\r
31 \r
32 The functions in T1_3D.C have for goal to realize the tier-1 coding operation of 3D-EBCOT.\r
33 The functions in T1_3D.C are used by some function in TCD.C.\r
34 */\r
35 \r
36 /** @defgroup T1_3D T1_3D - Implementation of the tier-1 coding */\r
37 /*@{*/\r
38 \r
39 /* ----------------------------------------------------------------------- */\r
40 \r
41 /* Neighbourhood of 3D EBCOT (Significance context)*/\r
42 #define T1_3D_SIG_NE  0x00000001        /*< Context orientation : North-East direction */\r
43 #define T1_3D_SIG_SE  0x00000002        /*< Context orientation : South-East direction */\r
44 #define T1_3D_SIG_SW  0x00000004        /*< Context orientation : South-West direction */\r
45 #define T1_3D_SIG_NW  0x00000008        /* Context orientation : North-West direction */\r
46 #define T1_3D_SIG_N   0x00000010        /*< Context orientation : North direction */\r
47 #define T1_3D_SIG_E   0x00000020        /*< Context orientation : East direction */\r
48 #define T1_3D_SIG_S   0x00000040        /*< Context orientation : South direction */\r
49 #define T1_3D_SIG_W   0x00000080        /*< Context orientation : West direction */\r
50 #define T1_3D_SIG_FC  0x00000100        /*< Context orientation : Forward Central direction */          \r
51 #define T1_3D_SIG_BC  0x00000200        /*< Context orientation : Backward Central direction */ \r
52 #define T1_3D_SIG_FNE 0x00000400        /*< Context orientation : Forward North-East direction */       \r
53 #define T1_3D_SIG_FSE 0x00000800        /*< Context orientation : Forward South-East direction */       \r
54 #define T1_3D_SIG_FSW 0x00001000        /*< Context orientation : Forward South-West direction */       \r
55 #define T1_3D_SIG_FNW 0x00002000        /*< Context orientation : Forward North-West direction */       \r
56 #define T1_3D_SIG_FN  0x00004000        /*< Context orientation : Forward North direction */            \r
57 #define T1_3D_SIG_FE  0x00008000        /*< Context orientation : Forward East direction */             \r
58 #define T1_3D_SIG_FS  0x00010000        /*< Context orientation : Forward South direction */            \r
59 #define T1_3D_SIG_FW  0x00020000        /*< Context orientation : Forward West direction */             \r
60 #define T1_3D_SIG_BNE 0x00040000        /*< Context orientation : Backward North-East direction */      \r
61 #define T1_3D_SIG_BSE 0x00080000        /*< Context orientation : Backward South-East direction */      \r
62 #define T1_3D_SIG_BSW 0x00100000        /*< Context orientation : Backward South-West direction */      \r
63 #define T1_3D_SIG_BNW 0x00200000        /*< Context orientation : Backward North-West direction */      \r
64 #define T1_3D_SIG_BN  0x00400000        /*< Context orientation : Backward North direction */           \r
65 #define T1_3D_SIG_BE  0x00800000        /*< Context orientation : Backward East direction */            \r
66 #define T1_3D_SIG_BS  0x01000000        /*< Context orientation : Backward South direction */           \r
67 #define T1_3D_SIG_BW  0x02000000        /*< Context orientation : Backward West direction */            \r
68 #define T1_3D_SIG_COTH  (T1_3D_SIG_N|T1_3D_SIG_NE|T1_3D_SIG_E|T1_3D_SIG_SE|T1_3D_SIG_S|T1_3D_SIG_SW|T1_3D_SIG_W|T1_3D_SIG_NW)\r
69 #define T1_3D_SIG_BOTH  (T1_3D_SIG_BN|T1_3D_SIG_BNE|T1_3D_SIG_BE|T1_3D_SIG_BSE|T1_3D_SIG_BS|T1_3D_SIG_BSW|T1_3D_SIG_BW|T1_3D_SIG_BNW|T1_3D_SIG_BC)\r
70 #define T1_3D_SIG_FOTH  (T1_3D_SIG_FN|T1_3D_SIG_FNE|T1_3D_SIG_FE|T1_3D_SIG_FSE|T1_3D_SIG_FS|T1_3D_SIG_FSW|T1_3D_SIG_FW|T1_3D_SIG_FNW|T1_3D_SIG_FC)\r
71 #define T1_3D_SIG_OTH   (T1_3D_SIG_FOTH|T1_3D_SIG_BOTH|T1_3D_SIG_COTH)\r
72 #define T1_3D_SIG_PRIM  (T1_3D_SIG_N|T1_3D_SIG_E|T1_3D_SIG_S|T1_3D_SIG_W|T1_3D_SIG_FC|T1_3D_SIG_BC)\r
73 \r
74 #define T1_3D_SGN_N             0x0400          \r
75 #define T1_3D_SGN_E             0x0800          \r
76 #define T1_3D_SGN_S             0x1000          \r
77 #define T1_3D_SGN_W             0x2000          \r
78 #define T1_3D_SGN_F             0x4000  \r
79 #define T1_3D_SGN_B             0x8000\r
80 #define T1_3D_SGN               (T1_3D_SGN_N|T1_3D_SGN_E|T1_3D_SGN_S|T1_3D_SGN_W|T1_3D_SGN_F|T1_3D_SGN_B)\r
81 \r
82 #define T1_3D_SIG               0x0001  //Significance state\r
83 #define T1_3D_REFINE    0x0002  //Delayed significance\r
84 #define T1_3D_VISIT             0x0004  //First-pass membership\r
85 \r
86 #define T1_3D_NUMCTXS_AGG       1\r
87 #define T1_3D_NUMCTXS_ZC        16\r
88 #define T1_3D_NUMCTXS_MAG       3\r
89 #define T1_3D_NUMCTXS_SC        6\r
90 #define T1_3D_NUMCTXS_UNI       1\r
91 \r
92 #define T1_3D_CTXNO_AGG 0\r
93 #define T1_3D_CTXNO_ZC  (T1_3D_CTXNO_AGG+T1_3D_NUMCTXS_AGG) //1\r
94 #define T1_3D_CTXNO_MAG (T1_3D_CTXNO_ZC+T1_3D_NUMCTXS_ZC)       //17\r
95 #define T1_3D_CTXNO_SC  (T1_3D_CTXNO_MAG+T1_3D_NUMCTXS_MAG)     //20\r
96 #define T1_3D_CTXNO_UNI (T1_3D_CTXNO_SC+T1_3D_NUMCTXS_SC)       //26\r
97 #define T1_3D_NUMCTXS   (T1_3D_CTXNO_UNI+T1_3D_NUMCTXS_UNI) //27\r
98 \r
99 \r
100 /* ----------------------------------------------------------------------- */\r
101 \r
102 /**\r
103 Tier-1 coding (coding of code-block coefficients)\r
104 */\r
105 typedef struct opj_t1_3d {\r
106         /** Codec context */\r
107         opj_common_ptr cinfo;\r
108         /** MQC component */\r
109         opj_mqc_t *mqc;\r
110         /** RAW component */\r
111         opj_raw_t *raw;\r
112         /** LUTs for decoding normalised MSE */\r
113         int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS];\r
114         int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];\r
115         int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];\r
116         int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS];\r
117         /** Codeblock data */\r
118         int data[T1_CBLKD][T1_CBLKH][T1_CBLKW];\r
119         /** Context information for each voxel in codeblock */\r
120         unsigned int flags[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2];\r
121         /** Voxel information (significance/visited/refined) */\r
122         int flagSVR[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2];\r
123 } opj_t1_3d_t;\r
124 \r
125 /** @name Exported functions */\r
126 /*@{*/\r
127 /* ----------------------------------------------------------------------- */\r
128 /**\r
129 Create a new T1_3D handle \r
130 and initialize the look-up tables of the Tier-1 coder/decoder\r
131 @return Returns a new T1 handle if successful, returns NULL otherwise\r
132 @see t1_init_luts\r
133 */\r
134 opj_t1_3d_t* t1_3d_create(opj_common_ptr cinfo);\r
135 /**\r
136 Destroy a previously created T1_3D handle\r
137 @param t1 T1_3D handle to destroy\r
138 */\r
139 void t1_3d_destroy(opj_t1_3d_t *t1);\r
140 /**\r
141 Encode the code-blocks of a tile\r
142 @param t1 T1_3D handle\r
143 @param tile The tile to encode\r
144 @param tcp Tile coding parameters\r
145 */\r
146 void t1_3d_encode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);\r
147 /**\r
148 Decode the code-blocks of a tile\r
149 @param t1 T1_3D handle\r
150 @param tile The tile to decode\r
151 @param tcp Tile coding parameters\r
152 */\r
153 void t1_3d_decode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);\r
154 /**\r
155 Get weigths of MSE decoding\r
156 @param nmsedec The normalized MSE reduction\r
157 @param compno \r
158 @param level \r
159 @param orient\r
160 @param bpno\r
161 @param reversible\r
162 @param stepsize\r
163 @param numcomps\r
164 @param dwtid\r
165 returns MSE associated to decoding pass\r
166 double t1_3d_getwmsedec(int nmsedec, int compno, int levelxy, int levelz, int orient, int bpno, int reversible, double stepsize, int numcomps, int dwtid);\r
167 */\r
168 /* ----------------------------------------------------------------------- */\r
169 /*@}*/\r
170 \r
171 /*@}*/\r
172 \r
173 #endif /* __T1_H */\r