|
1 /* |
|
2 * Copyright (c) 2003, 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Collection of structs used to store and represent |
|
15 * the metadata in the JP2 file format. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __JP2KFORMAT_H__ |
|
21 #define __JP2KFORMAT_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <icl/imageprocessor.h> |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // BlockSizeInBytes returns this value. |
|
29 const TInt KJ2kInputBufferSize = 8192; |
|
30 |
|
31 // JPEG 2000 signature box information |
|
32 const TUint32 KJ2kSigBoxLength = ( (TUint32) 0x0000000c ); |
|
33 const TUint32 KJ2kSigBoxType = ( (TUint32) 0x6a502020 ); |
|
34 const TUint32 KJ2kSigBoxContent = ( (TUint32) 0x0d0a870a ); |
|
35 |
|
36 // Length for both box length and type fields together |
|
37 const TUint32 KJ2kBoxTypeLength = ( (TUint32)8 ); |
|
38 |
|
39 // JPEG 2000 signaturebox length + next box type and length fields |
|
40 const TInt KJ2kFileInformationSize = KJ2kSigBoxLength + KJ2kBoxTypeLength; |
|
41 |
|
42 // File type box |
|
43 const TUint32 KJ2kFileTypeBox = ( (TUint32) 0x66747970 ); |
|
44 const TUint32 KJ2kFileTypeBrand = ( (TUint32) 0x6a703220 ); |
|
45 const TUint32 KJ2kFileTypeMinV = ( (TUint32) 0x00000000 ); |
|
46 const TUint32 KJ2kFileTypeProfile0 = ( (TUint32) 0x4a325030 ); |
|
47 const TUint32 KJ2kFileTypeProfile1 = ( (TUint32) 0x4a325031 ); |
|
48 // Restrict the file type box's length to be 1024, this is more than enough |
|
49 // and helps detect corrupted codestreams |
|
50 const TUint32 KJ2kFileTypeBoxMaxLength = ( (TUint32) 1024); |
|
51 |
|
52 // JP2 Header Box |
|
53 const TUint32 KJ2kJP2HeaderBoxType = ( (TUint32) 0x6a703268 ); |
|
54 |
|
55 // Image Header Box(JP2 Header Box's sub-box) type and length in bytes |
|
56 const TUint32 KJ2kImageHeaderBoxType = ( (TUint32) 0x69686472 ); |
|
57 const TUint32 KJ2kImageHeaderBoxLength = ( (TUint32) 22 ); |
|
58 const TUint8 KJ2kImageHeaderCompressionType = ( (TUint8)7 ); |
|
59 |
|
60 // Bits Per Component Box(JP2 Header Box's sub-box) type and length |
|
61 const TUint32 KJ2kBitsPerCompBoxType = ( (TUint32) 0x62706363 ); |
|
62 const TUint8 KJ2kIsBPCBoxExist = ( (TUint8) 0xff ); |
|
63 |
|
64 // Colour Specification Box(JP2 Header Box's sub-box) type and length |
|
65 const TUint32 KJ2kColourSpecBoxType = ( (TUint32) 0x636f6c72 ); |
|
66 const TUint32 KJ2kColourSpecGrayScale = ( (TUint32) 17 ); |
|
67 |
|
68 // Palette Box(JP2 Header Box's sub-box) type and length |
|
69 const TUint32 KJ2kPaletterBoxType = ( (TUint32) 0x70636c72 ); |
|
70 |
|
71 // Component Mapping Box(JP2 Header Box's sub-box) type and length |
|
72 const TUint32 KJ2kComponentMapBoxType = ( (TUint32) 0x636d6170 ); |
|
73 |
|
74 // Channel Definition Box(JP2 Header Box's sub-box) type and length |
|
75 const TUint32 KJ2kChannelDefBoxType = ( (TUint32) 0x63646566 ); |
|
76 |
|
77 // Resolution Box(JP2 Header Box's sub-box) type and length |
|
78 const TUint32 KJ2kResolutionBoxType = ( (TUint32) 0x72657320 ); |
|
79 const TUint32 KJ2kCaptureResBoxType = ( (TUint32) 0x72657363 ); |
|
80 const TUint32 KJ2kDisplayResBoxType = ( (TUint32) 0x72657364 ); |
|
81 const TUint32 KJ2kResSubBoxLength = ( (TUint32)18 ); |
|
82 |
|
83 // Contiguous Codestream Box type |
|
84 const TUint32 KJ2kCodestreamBoxType = ( (TUint32) 0x6a703263 ); |
|
85 const TUint32 KJ2kIPRBoxType = ( (TUint32) 0x6a703269 ); |
|
86 const TUint32 KJ2kXMLBoxType = ( (TUint32) 0x786d6c20 ); |
|
87 const TUint32 KJ2kUUIDBoxType = ( (TUint32) 0x75756964 ); |
|
88 const TUint32 KJ2kUUIDInfoBoxType = ( (TUint32) 0x75696e66 ); |
|
89 const TUint32 KJ2kUUIDListBoxType = ( (TUint32) 0x756c7374 ); |
|
90 const TUint32 KJ2kUUIDUrlBoxType = ( (TUint32) 0x75726c20 ); |
|
91 |
|
92 // Reader Requirements Box |
|
93 const TUint32 KJ2kReaderReqBox = ( (TUint32) 0x72726571 ); |
|
94 |
|
95 // JP2 Codestream only - SOC + SIZ marker |
|
96 const TUint32 KJ2kSOCType = ( (TUint32) 0xff4fff51 ); |
|
97 |
|
98 // Twip = 1/1440inch. 1/1440*0,0254 meters |
|
99 const TReal KJ2kTwipM = 0.000017638; //( (TReal)( 1 / 1440.0 ) * 0.0254 ); |
|
100 |
|
101 // Maximum number of palette entries |
|
102 const TInt KMaxPaletteEntries = 1024; |
|
103 |
|
104 // Maximum number of components possible |
|
105 const TInt KMaxComponents = 16384; |
|
106 |
|
107 // Maximum bitdepth supported |
|
108 const TInt KMaxBitdepth = 32; |
|
109 |
|
110 |
|
111 // MACROS |
|
112 |
|
113 // DATA TYPES |
|
114 |
|
115 /** |
|
116 * Collection of structs used to store and represent |
|
117 * the metadata in the JP2 file format. |
|
118 * |
|
119 * JP2KCodec.dll |
|
120 * @since 7.0 |
|
121 */ |
|
122 struct TPalette |
|
123 { |
|
124 /** |
|
125 * Destructor |
|
126 * @since 7.0 |
|
127 */ |
|
128 ~TPalette(); |
|
129 |
|
130 // Bi list |
|
131 RArray<TUint> iBList; |
|
132 |
|
133 // Cij matrix |
|
134 RPointerArray<RArray<TUint> > iC2DArray; |
|
135 }; |
|
136 |
|
137 struct TComponentMap |
|
138 { |
|
139 /** |
|
140 * Constructor |
|
141 * @since 7.0 |
|
142 * @param aCmp: the CMP field. |
|
143 * @param aMtyp: the MTYP field. |
|
144 * @param aPcol: the PCOL field. |
|
145 */ |
|
146 TComponentMap( TUint16 aCmp, TUint8 aMtyp, TUint8 aPcol ); |
|
147 |
|
148 // CMP field |
|
149 TUint16 iCmp; |
|
150 |
|
151 // MTYP field |
|
152 TUint8 iMtyp; |
|
153 |
|
154 // PCOL field |
|
155 TUint8 iPcol; |
|
156 }; |
|
157 |
|
158 struct TChannelDefinition |
|
159 { |
|
160 /** |
|
161 * Constructor |
|
162 * @since 7.0 |
|
163 * @param aCn: the Cn field. |
|
164 * @param aTyp: the Typ field. |
|
165 * @param aAsoc: the Asoc field. |
|
166 */ |
|
167 TChannelDefinition( TUint16 aCn, TUint16 aTyp, TUint16 aAsoc ); |
|
168 |
|
169 // Cn field |
|
170 TUint16 iCn; |
|
171 |
|
172 // Typ field |
|
173 TUint16 iTyp; |
|
174 |
|
175 // Asoc field |
|
176 TUint16 iAsoc; |
|
177 }; |
|
178 |
|
179 // FUNCTION PROTOTYPES |
|
180 |
|
181 // FORWARD DECLARATIONS |
|
182 |
|
183 // CLASS DECLARATION |
|
184 |
|
185 /** |
|
186 * TJ2kInfo class is used to gather and store the |
|
187 * JP2 file format information |
|
188 * |
|
189 * JP2KCodec.dll |
|
190 * @since 2.6 |
|
191 */ |
|
192 class TJ2kInfo |
|
193 { |
|
194 public: // Constructors and destructor |
|
195 |
|
196 /** |
|
197 * C++ default constructor. |
|
198 */ |
|
199 TJ2kInfo(); |
|
200 |
|
201 /** |
|
202 * Destructor. |
|
203 */ |
|
204 ~TJ2kInfo(); |
|
205 |
|
206 public: // New functions |
|
207 |
|
208 public: // Functions from base classes |
|
209 |
|
210 protected: // New functions |
|
211 |
|
212 protected: // Functions from base classes |
|
213 |
|
214 private: |
|
215 |
|
216 public: // Data |
|
217 |
|
218 // Flags to indicate the existance of some parameters |
|
219 enum TOption |
|
220 { |
|
221 EIPR = 0x01, // To indicate that IPR Box exists //lint !e769 will be referenced in next release. |
|
222 EProfile0 = 0x02, // To indicate the JP2 is restricted to Profile 0 |
|
223 EProfile1 = 0x04, // To indicate the JP2 is restricted to Profile 1 |
|
224 EJP2file = 0x08, // To indicate that JP2 file format exists |
|
225 EJP2Header= 0x10, // To indicate that JP2 Header processed |
|
226 EColorSpec= 0x20 // To indicate that Colour Spec Box exists |
|
227 }; |
|
228 |
|
229 // Image size |
|
230 TSize iImageSize; |
|
231 |
|
232 // Number of components |
|
233 TUint16 iNC; |
|
234 |
|
235 // Bits per component |
|
236 TUint8 iBPC; |
|
237 |
|
238 // Bit vector of flags |
|
239 TUint8 iOption; |
|
240 |
|
241 // Length of the first codestream box |
|
242 TUint32 iCSBoxLength; |
|
243 |
|
244 // Colour spec |
|
245 TUint32 iEnumCS; |
|
246 |
|
247 // Start position of codestream in file |
|
248 TUint32 iCSOffset; |
|
249 |
|
250 // Display resolution |
|
251 TSize iImageSizeInTwips; |
|
252 |
|
253 // Bits per component list |
|
254 RArray<TUint> iBPCList; |
|
255 |
|
256 // ICC Profile |
|
257 HBufC8 *iICCProfile; |
|
258 |
|
259 // Component Mapping list |
|
260 RArray<TComponentMap> iCMPList; |
|
261 |
|
262 // Channel Definition list |
|
263 RArray<TChannelDefinition> iCNList; |
|
264 |
|
265 // Palette |
|
266 TPalette iPalette; |
|
267 |
|
268 // Intellectual Property box |
|
269 RPointerArray<HBufC8> iIPRList; |
|
270 |
|
271 // XML box |
|
272 RPointerArray<HBufC8> iXMLList; |
|
273 |
|
274 // UUID box |
|
275 RPointerArray<HBufC8> iUUIDList; |
|
276 |
|
277 // UUIDInfo List box |
|
278 RPointerArray<HBufC8> iUUIDInfoListList; |
|
279 |
|
280 // UUIDInfo Data Entry Url box |
|
281 RPointerArray<HBufC8> iUUIDInfoUrlList; |
|
282 |
|
283 protected: // Data |
|
284 |
|
285 private: // Data |
|
286 |
|
287 public: // Friend classes |
|
288 |
|
289 protected: // Friend classes |
|
290 |
|
291 private: // Friend classes |
|
292 }; |
|
293 |
|
294 #endif // __JP2KFORMAT_H__ |
|
295 |