Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_904 / libraries / libjni-ecw / include / NCSJPCResolution.h @ 43469

History | View | Annotate | Download (10.1 KB)

1 3538 nacho
/********************************************************
2
** Copyright 2003 Earth Resource Mapping Ltd.
3
** This document contains proprietary source code of
4
** Earth Resource Mapping Ltd, and can only be used under
5
** one of the three licenses as described in the
6
** license.txt file supplied with this distribution.
7
** See separate license.txt file for license details
8
** and conditions.
9
**
10
** This software is covered by US patent #6,442,298,
11
** #6,102,897 and #6,633,688.  Rights to use these patents
12
** is included in the license agreements.
13
**
14
** FILE:     $Archive: /NCS/Source/include/NCSJPCResolution.h $
15
** CREATED:  12/02/2003 3:27:34 PM
16
** AUTHOR:   Simon Cope
17
** PURPOSE:  CNCSJPCResolution class header
18
** EDITS:    [xx] ddMmmyy NAME COMMENTS
19
 *******************************************************/
20
21
#ifndef NCSJPCRESOLUTION_H
22
#define NCSJPCRESOLUTION_H
23
24
#ifndef NCSJPCPRECINCT_H
25
#include "NCSJPCPrecinct.h"
26
#endif // NCSJPCPRECINCT_H
27
#ifndef NCSJPCNODE_H
28
#include "NCSJPCNode.h"
29
#endif // NCSJPCNODE_H
30
#ifndef NCSJPCPLTMARKER_H
31
#include "NCSJPCPLTMarker.h"
32
#endif // NCSJPCPLTMARKER_H
33
34
        /**
35
         * CNCSJPCResolution class - the JPC Resolution level.
36
         *
37
         * @author       Simon Cope
38
         * @version      $Revision$ $Author$ $Date$
39
         */
40
class NCSJPC_EXPORT_ALL CNCSJPCResolution: public CNCSJPCNodeTiler {
41
public:
42
                /** Component for this resolution */
43
        class CNCSJPCComponent *m_pComponent;
44
                /** Resolution level */
45
        UINT8        m_nResolution;
46
                /** Compression target ratio */
47
        UINT16        m_nCompressionRatio;
48
49
                /** Precincts */
50
        CNCSJPCPrecinctMap m_Precincts;
51
        //std::vector<CNCSJPCPrecinct*> m_Precincts;
52
53
//        CNCSJPCIOStreamVector m_EncoderFiles;
54
        //char                        *m_pEncoderFileName;
55
        UINT32                        m_nEncoderPLTStartIndex;
56
//        std::vector<UINT32>        m_EncoderPLTIndex;
57
//        CNCSJPCIOStreamVector m_EncoderPLTFiles;
58
        //char                        *m_pEncoderPLTFileName;
59
60
                /**
61
                 * constructor
62
                 * @param pComponent        Parent component
63
                 * @param nResolution        Resolution level, 0-32
64
                 */
65
        CNCSJPCResolution(class CNCSJPCComponent *pComponent, UINT8 nResolution);
66
                /** Virtual destructor */
67
        virtual ~CNCSJPCResolution();
68
69
                /**
70
                 * Get X0 of this node.
71
                 * @return      INT32                Coordinate value.
72
                 */
73
        virtual INT32 GetX0();
74
                /**
75
                 * Get Y0 of this node.
76
                 * @return      INT32                Coordinate value.
77
                 */
78
        virtual INT32 GetY0();
79
                /**
80
                 * Get X1 of this node.
81
                 * @return      INT32                Coordinate value.
82
                 */
83
        virtual INT32 GetX1();
84
                /**
85
                 * Get Y1 of this node.
86
                 * @return      INT32                Coordinate value.
87
                 */
88
        virtual INT32 GetY1();
89
90
                /**
91
                 * Get Precinct Width.
92
                 * @return      UINT32                Un-clipped Width of precincts.
93
                 */
94
        virtual UINT32 GetPrecinctWidth();
95
                /**
96
                 * Get Precinct Height.
97
                 * @return      UINT32                Un-clipped height of precincts.
98
                 */
99
        virtual UINT32 GetPrecinctHeight();
100
                /**
101
                 * Get number of precincts wide.
102
                 * @return      INT32                Nr of precincts across.
103
                 */
104
        virtual UINT32 GetNumPrecinctsWide();
105
                /**
106
                 * Get number of precincts high.
107
                 * @return      UINT32                Nr of precincts high.
108
                 */
109
        virtual UINT32 GetNumPrecinctsHigh();
110
                /**
111
                 * Get codeblock Width.
112
                 * @return      UINT32                Un-clipped Width of codeblocks.
113
                 */
114
        virtual UINT32 GetCBWidth();
115
                /**
116
                 * Get codeblock Height.
117
                 * @return      UINT32                Un-clipped height of codeblocks.
118
                 */
119
        virtual UINT32 GetCBHeight();
120
121
                /**
122
                 * Get CPRL/PCRL/RPCL Progression resolution multiplier.
123
                 * @return      INT32                Progression resolution multiplier.
124
                 */
125
        virtual INT32 GetResMultiplier();
126
                /**
127
                 * Get CPRL/PCRL/RPCL Progression XRsiz multiplier.
128
                 * @return      INT32                Progression XRsiz multiplier.
129
                 */
130
        virtual INT32 GetXRsizResMultiplier();
131
                /**
132
                 * Get CPRL/PCRL/RPCL Progression YRsiz multiplier.
133
                 * @return      INT32                Progression YRsiz multiplier.
134
                 */
135
        virtual INT32 GetYRsizResMultiplier();
136
                /**
137
                 * Get CPRL/PCRL/RPCL Progression DivX factor.
138
                 * @return      INT32                Progression DixX Factor.
139
                 */
140
        virtual INT32 GetDivX();
141
                /**
142
                 * Get CPRL/PCRL/RPCL Progression DivY factor.
143
                 * @return      INT32                Progression DixY Factor.
144
                 */
145
        virtual INT32 GetDivY();
146
147
                /**
148
                 * Get CPRL/PCRL/RPCL Progression X origin check OK test result.
149
                 * @return      INT32                Progression DixX Factor.
150
                 */
151
        virtual bool XOriginCheckOk();
152
                /**
153
                 * Get CPRL/PCRL/RPCL Progression Y origin check OK test result.
154
                 * @return      INT32                Progression DixY Factor.
155
                 */
156
        virtual bool YOriginCheckOk();
157
                /**
158
                 * Read a BufferType line from the input.
159
                 * @param                nCtx                Read context
160
                 * @param                pDst                Destination buffer.
161
                 * @param                iComponent        Output Component
162
                 * @return      bool                true on succes, else false.
163
                 */
164
                /**
165
                 * Get X0 of top left precinct for this resolution.
166
                 * @return      INT32                Coordinate value.
167
                 */
168
        virtual INT32 GetPX0();
169
                /**
170
                 * Get Y0 of top left precinct for this resolution.
171
                 * @return      INT32                Coordinate value.
172
                 */
173
        virtual INT32 GetPY0();
174
175
        virtual bool ReadLine(ContextID nCtx, CNCSJPCBuffer *pDst, UINT16 iComponent);
176
                /**
177
                 * Write a BufferType line to the output.
178
                 * @param                nCtx                Context
179
                 * @param                pSrc                Source buffer.
180
                 * @param                iComponent        Output Component
181
                 * @return      bool                true on succes, else false.
182
                 */
183
        virtual bool WriteLine(ContextID nCtx, CNCSJPCBuffer *pSrc, UINT16 iComponent);
184
185
                /**
186
                 * UnLink input nodes.
187
                 * @param                nCtx                Read context
188
                 * @return      bool                true on success, else false on error.
189
                 */
190
        virtual bool UnLink(ContextID nCtx, UINT16 nInputs = 0);
191
192
        virtual bool WritePrecinctLayerPLT(CNCSJPC &JPC, CNCSJPCIOStream &Stream, CNCSJPCTilePartHeader &TilePart, CNCSJPCPLTMarker &PLT, CNCSJPCPacketLengthType &Len, INT64 &nSOTOffset, UINT32 &nBytes, UINT32 p, UINT32 l);
193
        virtual bool WriteLayerPLTs(CNCSJPC &JPC, CNCSJPCIOStream &Stream, CNCSJPCTilePartHeader &TilePart, CNCSJPCPLTMarker &PLT, CNCSJPCPacketLengthType &Len, INT64 &nSOTOffset, UINT32 &nBytes, UINT32 l);
194
        virtual bool WritePrecinctLayerPacket(CNCSJPC &JPC, CNCSJPCIOStream &Stream, UINT32 p, UINT32 l);
195
        virtual bool WriteLayerPackets(CNCSJPC &JPC, CNCSJPCIOStream &Stream, UINT32 l);
196
197
protected:
198
        static CNCSJPCNodeTracker        sm_Tracker;
199
200
        CNCSJPCBuffer        m_EncoderLL;
201
        CNCSJPCBuffer        m_EncoderLH;
202
        CNCSJPCBuffer        m_EncoderHL;
203
        CNCSJPCBuffer        m_EncoderHH;
204
205
        class NCSJPC_EXPORT_ALL Context: public CNCSJPCNode::Context {
206
        public:
207
                        /** 2-line Output Buffer */
208
                CNCSJPCBuffer m_OutputBuffer;
209
210
                CNCSJPCBufferCache m_State;
211
                INT32                        m_nStateU0;
212
                INT32                        m_nStateU1;
213
                INT32                        m_nStateV;
214
215
                Context();
216
                virtual ~Context();
217
        };
218
219
                /**
220
                 * Get the context for the given ContextID
221
                 * @param                nCtx                ContextID to retrive context
222
                 * @param                bAutoConstruct Autoconstruct a new context for this ContextID if one doesn't exist
223
                 * @return                Context*        Context for given ID.
224
                 */
225
        virtual CNCSJPCNode::Context *GetContext(ContextID nCtx, bool bAutoConstruct = true);
226
227
                /**
228
                 * Read a BufferType line from the given subband.
229
                 * @param                nCtx                Read Context
230
                 * @param                nX                        X coordinate of node within it's resolution rect.
231
                 * @param                nY                        Y coordinate of node within it's resolution rect.
232
                 * @param                nWidth                Number of pixels to read.
233
                 * @param                eType                Buffer type
234
                 * @param                pBuffer                Pointer to destination buffer.
235
                 * @param                eSubBandType SubBand index enum.
236
                 * @return      bool                true on succes, else false.
237
                 */
238
        bool ReadSubBandLine(ContextID nCtx, CNCSJPCBuffer *pDst, NCSJPCSubBandType eSubBandType);
239
                /**
240
                 * Write a BufferType line to the given subband.
241
                 * @param                nCtx                Context
242
                 * @param                pSrc                Source buffer.
243
                 * @param                eSubBandType SubBand index enum.
244
                 * @return      bool                true on succes, else false.
245
                 */
246
        bool WriteSubBandLine(ContextID nCtx, CNCSJPCBuffer *pSrc, NCSJPCSubBandType eSubBandType);
247
                /**
248
                 * Get normal Node Width.
249
                 * @return      INT32                Un-clipped Width of codeblocks.
250
                 */
251
        virtual UINT32 GetNodeWidth(UINT16 iComponent = 0) { return(GetPrecinctWidth()); };
252
                /**
253
                 * Get normal Node Height.
254
                 * @return      INT32                Un-clipped height of codeblocks.
255
                 */
256
        virtual UINT32 GetNodeHeight(UINT16 iComponent = 0) { return(GetPrecinctHeight()); };
257
                /**
258
                 * Get number of nodes wide.
259
                 * @return      INT32                Nr of codeblocks across.
260
                 */
261
        virtual UINT32 GetNumNodesWide(UINT16 iComponent = 0) { return(GetNumPrecinctsWide()); };
262
                /**
263
                 * Get number of nodes high.
264
                 * @return      INT32                Nr of codeblocks high.
265
                 */
266
        virtual UINT32 GetNumNodesHigh(UINT16 iComponent = 0) { return(GetNumPrecinctsHigh()); };
267
                /**
268
                 * Get pointer to specific node.
269
                 * @param                UINT32                Node nr
270
                 * @return      CNCSJPCNode * Ptr to node.
271
                 */
272
        virtual __inline CNCSJPCNode *GetNodePtr(UINT32 nNode, UINT16 iComponent = 0) {
273
                                        return(m_Precincts.find(nNode));
274
                                }
275
        virtual bool INTERLEAVE_2D(ContextID nCtx,
276
                                                                INT32 u0,
277
                                                                INT32 u1,
278
                                                                INT32 v0,
279
                                                                INT32 v1,
280
                                                                CNCSJPCBuffer &a);
281
        virtual bool SR_2D(ContextID nCtx,
282
                                          INT32 u0,
283
                                          INT32 u1,
284
                                          INT32 v0,
285
                                          INT32 v1,
286
                                          CNCSJPCBuffer &Dst);
287
        virtual bool HOR_SR(ContextID nCtx,
288
                                                CNCSJPCBuffer &a,
289
                                                INT32 u0,
290
                                                INT32 u1,
291
                                                INT32 v0,
292
                                                INT32 v1);
293
        virtual CNCSJPCBuffer *GET_STATE_BUFFER(ContextID nCtx,
294
                                                                                        INT32 u0,
295
                                                                                        INT32 u1,
296
                                                                                        INT32 v,
297
                                                                                        CNCSJPCBuffer::Type eType);
298
        virtual bool VER_SR_INPUT2(ContextID nCtx,
299
                                                          INT32 u0,
300
                                                          INT32 u1,
301
                                                          CNCSJPCBuffer *pDst,
302
                                                          CNCSJPCBuffer::Type eType);
303
        virtual bool VER_SR(ContextID nCtx,
304
                                                INT32 u0,
305
                                                INT32 u1,
306
                                                INT32 v0,
307
                                                INT32 v1,
308
                                                CNCSJPCBuffer &Dst);
309
310
        virtual bool SD_2D_OUTPUT4(ContextID nCtx,
311
                                                           INT32 u0,
312
                                                           INT32 u1,
313
                                                           INT32 v,
314
                                                           CNCSJPCBuffer::Type eType);
315
        virtual bool SD_2D(ContextID nCtx,
316
                                           CNCSJPCBuffer *pSrc);
317
private:
318
        TNCSCachedValue<UINT32> m_CBWidth;
319
        TNCSCachedValue<UINT32> m_CBHeight;
320
        TNCSCachedValue<UINT32> m_PrecinctWidth;
321
        TNCSCachedValue<UINT32> m_PrecinctHeight;
322
        TNCSCachedValue<INT32> m_NumPrecinctsWide;
323
        TNCSCachedValue<INT32> m_NumPrecinctsHigh;
324
325
        TNCSCachedValue<INT32> m_ResMultiplier;
326
        TNCSCachedValue<INT32> m_XRsizResMultiplier;
327
        TNCSCachedValue<INT32> m_YRsizResMultiplier;
328
        TNCSCachedValue<INT32> m_DivX;
329
        TNCSCachedValue<INT32> m_DivY;
330
331
        TNCSCachedValue<bool> m_XOriginCheckOk;
332
        TNCSCachedValue<bool> m_YOriginCheckOk;
333
        TNCSCachedValue<INT32> m_PX0;
334
        TNCSCachedValue<INT32> m_PY0;
335
};
336
337
#endif // !NCSJPCRESOLUTION_H