svn-gvsig-desktop / branches / v1_0_2 / libraries / libjni-ecwcompress / include / NCSECWCompressClient.h @ 39946
History | View | Annotate | Download (9.65 KB)
1 | 1429 | igbrotru | /**********************************************************
|
---|---|---|---|
2 | ** Copyright 1999 Earth Resource Mapping Pty Ltd.
|
||
3 | ** This document contains unpublished source code of
|
||
4 | ** Earth Resource Mapping Pty Ltd. This notice does
|
||
5 | ** not indicate any intention to publish the source
|
||
6 | ** code contained herein.
|
||
7 | **
|
||
8 | ** FILE: NCSECWCompessClient.h
|
||
9 | ** CREATED: Thu 19/08/1999
|
||
10 | ** AUTHOR: Simon Cope
|
||
11 | ** PURPOSE: Public Interface library to compress ECW v2.0 image files
|
||
12 | ** EDITS:
|
||
13 | ** [01] sjc 08Dec1999 Updated comments
|
||
14 | **
|
||
15 | ********************************************************/
|
||
16 | |||
17 | /** @file NCSECWCompressClient.h */
|
||
18 | #ifndef NCSECWCOMPRESSCLIENT_H
|
||
19 | #define NCSECWCOMPRESSCLIENT_H
|
||
20 | |||
21 | #ifndef NCSECWCLIENT_H
|
||
22 | #include "NCSECWClient.h" |
||
23 | #endif
|
||
24 | |||
25 | #ifdef __cplusplus
|
||
26 | extern "C" { |
||
27 | #endif
|
||
28 | |||
29 | #ifndef NCSTYPES_H
|
||
30 | #include "NCSTypes.h" |
||
31 | #endif
|
||
32 | #ifndef NCSERRORS_H
|
||
33 | #include "NCSErrors.h" |
||
34 | #endif
|
||
35 | |||
36 | #define ERSWAVE_VERSION 2 |
||
37 | #define ERSWAVE_VERSION_STRING "2.0" /* should be in sync with the above */ |
||
38 | |||
39 | /**
|
||
40 | * @enum
|
||
41 | * An enumerated type specifying the format of the compressed data. Currently greyscale, RGB
|
||
42 | * and luminance-chrominance formats are supported. This will later need expanding to include
|
||
43 | * multiband formats such as CMYK.
|
||
44 | */
|
||
45 | typedef enum { |
||
46 | /** The compressed data is unformatted */
|
||
47 | COMPRESS_NONE = NCSCS_NONE, |
||
48 | /** Greyscale format, single band */
|
||
49 | COMPRESS_UINT8 = NCSCS_GREYSCALE, |
||
50 | /** JPEG standard YUV digital format, three band */
|
||
51 | COMPRESS_YUV = NCSCS_YUV, |
||
52 | /** Multiband format */
|
||
53 | COMPRESS_MULTI = NCSCS_MULTIBAND, |
||
54 | /** RGB images (converted to COMPRESS_YUV internally) */
|
||
55 | COMPRESS_RGB = NCSCS_sRGB |
||
56 | } CompressFormat; |
||
57 | |||
58 | /**
|
||
59 | * @enum
|
||
60 | * An enumerated type allowing the user to hint at an appropriate compression scheme. The
|
||
61 | * value is a guideline for the SDK compression functions.
|
||
62 | */
|
||
63 | typedef enum { |
||
64 | /** No compression hint */
|
||
65 | COMPRESS_HINT_NONE = 0,
|
||
66 | /** Do the fastest compression possible */
|
||
67 | COMPRESS_HINT_FAST = 1,
|
||
68 | /** Try to achieve the maximum possible compression ratio */
|
||
69 | COMPRESS_HINT_BEST = 2,
|
||
70 | /** Optimise compression process for later Internet use of the compressed file */
|
||
71 | COMPRESS_HINT_INTERNET = 3
|
||
72 | } CompressHint; |
||
73 | |||
74 | /** @def Maximum length of a datum definition string */
|
||
75 | #define ECW_MAX_DATUM_LEN 16 |
||
76 | /** @def Maximum length of a projection definition string */
|
||
77 | #ifndef ECW_MAX_PROJECTION_LEN
|
||
78 | #define ECW_MAX_PROJECTION_LEN 16 |
||
79 | #endif
|
||
80 | |||
81 | /** @def X dimension of the default (and preferred) block size */
|
||
82 | #define X_BLOCK_SIZE 64 |
||
83 | /** @def Y dimension of the default (and preferred) block size */
|
||
84 | #define Y_BLOCK_SIZE 64 |
||
85 | |||
86 | /**
|
||
87 | * @struct
|
||
88 | * This structure contains information used when compressing raster data
|
||
89 | * to an output ECW file. Most of the values have sensible defaults so users
|
||
90 | * need only customise those of significance to their application. Certain
|
||
91 | * of these values must always be specified in the client code, namely
|
||
92 | * fTargetCompression, nInOutSizeX, nInOutSizeY, nInputBands, and pReadCallback.
|
||
93 | *
|
||
94 | * Once compression is complete certain statistics are calculated and added
|
||
95 | * to this structure. These include the time taken, the output file size in
|
||
96 | * bytes, the actual compression ratio achieved, and the MB/s throughput of the
|
||
97 | * process.
|
||
98 | */
|
||
99 | typedef struct NCSEcwCompressClient { |
||
100 | /*
|
||
101 | ** These fields are populated by the compression client
|
||
102 | */
|
||
103 | /** If this is specified but the output file is not, a default output filename will be created.
|
||
104 | * Otherwise this field is unused.
|
||
105 | */
|
||
106 | char szInputFilename[MAX_PATH];
|
||
107 | /** An output filename must be specified if no input filename is specified */
|
||
108 | char szOutputFilename[MAX_PATH];
|
||
109 | /** The target compression ratio - must be specified */
|
||
110 | IEEE4 fTargetCompression; |
||
111 | /** The compression format to use. See the related enumerated type definition */
|
||
112 | CompressFormat eCompressFormat; |
||
113 | /** A guideline for an appropriate compression scheme to use. This currently has
|
||
114 | * no effect, though the default value is COMPRESS_HINT_INTERNET. Reserved for
|
||
115 | * future use, see the related enumerated type definition
|
||
116 | */
|
||
117 | CompressHint eCompressHint; |
||
118 | /** X dimension of the block size to use. Can be 64, 128, 256, 512, 1024, or 2048.
|
||
119 | * The default for these is set to 64 which produces preferred performance over the internet.
|
||
120 | */
|
||
121 | UINT32 nBlockSizeX; |
||
122 | /** Y dimension of the block size to use. Can be 64, 128, 256, 512, 1024, or 2048.
|
||
123 | * The default for these is set to 64 which produces preferred performance over the internet.
|
||
124 | */
|
||
125 | UINT32 nBlockSizeY; /* Y Block size (64, 128, 256, 512) */
|
||
126 | /** Number of cells of input data and compressed file in the X direction - must be specified */
|
||
127 | UINT32 nInOutSizeX; |
||
128 | /** Number of cells of input data and compressed file in the Y direction - must be specified */
|
||
129 | UINT32 nInOutSizeY; |
||
130 | /** Number of bands in the input data - must be specified */
|
||
131 | UINT32 nInputBands; |
||
132 | /** Number of bands in the output file - should not generally be specified */
|
||
133 | UINT32 nOutputBands; |
||
134 | /** Size of the input file in bytes - should not be specified, it will be determined automatically. */
|
||
135 | UINT64 nInputSize; |
||
136 | /** Optional field specifying the cell size in the X direction in eCellSizeUnits */
|
||
137 | IEEE8 fCellIncrementX; |
||
138 | /** Optional field specifying the cell size in the Y direction in eCellSizeUnits */
|
||
139 | IEEE8 fCellIncrementY; |
||
140 | /** Optional field specifying the X world origin of the input data in eCellSizeUnits */
|
||
141 | IEEE8 fOriginX; |
||
142 | /** Optional field specifying the Y world origin of the input data in eCellSizeUnits */
|
||
143 | IEEE8 fOriginY; |
||
144 | /** Optional field specifying the units in which world cell sizes are specified, e.g. meters, feet */
|
||
145 | CellSizeUnits eCellSizeUnits; |
||
146 | /** ER Mapper GDT style datum string */
|
||
147 | char szDatum[ECW_MAX_DATUM_LEN];
|
||
148 | /** ER Mapper GDT style projection string */
|
||
149 | char szProjection[ECW_MAX_PROJECTION_LEN];
|
||
150 | /** Callback function used to obtain lines of band data from the input data - must be specified */
|
||
151 | BOOLEAN (*pReadCallback) (struct NCSEcwCompressClient *pClient,
|
||
152 | UINT32 nNextLine, |
||
153 | IEEE4 **ppInputArray); |
||
154 | /** Optional status callback function to track the progress of the compression process */
|
||
155 | void (*pStatusCallback) (struct NCSEcwCompressClient *pClient, |
||
156 | UINT32 nCurrentLine); |
||
157 | /** Optional cancel callback function which can be used to cancel a compression process */
|
||
158 | BOOLEAN (*pCancelCallback) (struct NCSEcwCompressClient *pClient);
|
||
159 | /** (void *) Pointer to any private data you need to access in the three callback functions */
|
||
160 | void *pClientData;
|
||
161 | /** Created by NCSEcwCompressOpen() */
|
||
162 | struct EcwCompressionTask *pTask;
|
||
163 | /*
|
||
164 | ** The remaining fields are populated by NCSEcwCompressClose()
|
||
165 | */
|
||
166 | /** Actual compression rate achieved - ratio of input data size to output file size */
|
||
167 | IEEE4 fActualCompression; |
||
168 | /** Time taken to perform the complete compression, in seconds */
|
||
169 | IEEE8 fCompressionSeconds; |
||
170 | /** MB/s throughput during the compression process */
|
||
171 | IEEE8 fCompressionMBSec; |
||
172 | /** Total size of the output file in bytes */
|
||
173 | UINT64 nOutputSize; |
||
174 | } NCSEcwCompressClient; |
||
175 | |||
176 | /**
|
||
177 | * Allocate a new CompressionClient structure and fill in defaults
|
||
178 | *
|
||
179 | * @return A pointer to memory allocated to an NCSEcwCompressClient structure
|
||
180 | */
|
||
181 | NCSEcwCompressClient * NCS_CALL NCSEcwCompressAllocClient(void);
|
||
182 | /**
|
||
183 | * Having set compression parameters, initialise the compression process
|
||
184 | *
|
||
185 | * @param[in,out] pInfo The NCSEcwCompressClient structure containing the compression parameters
|
||
186 | * @param[in] bCalculateSizesOnly Which output statistics to calculate
|
||
187 | * @return NCSError value, NCS_SUCCESS or any applicable error code
|
||
188 | */
|
||
189 | NCSError NCS_CALL NCSEcwCompressOpen(NCSEcwCompressClient *pInfo, BOOLEAN bCalculateSizesOnly); |
||
190 | /**
|
||
191 | * Start the compression process based on these parameters
|
||
192 | *
|
||
193 | * @param[in,out] pInfo The NCSEcwCompressClient structure for this compression process
|
||
194 | * @return NCSError value, NCS_SUCCESS or any applicable error code
|
||
195 | */
|
||
196 | NCSError NCS_CALL NCSEcwCompress(NCSEcwCompressClient *pInfo); |
||
197 | /**
|
||
198 | * Having completed compression, close, calculate output statistics, and clean up
|
||
199 | *
|
||
200 | * @param[in,out] pInfo The NCSEcwCompressClient structure for this compression process
|
||
201 | * @return NCSError value, NCS_SUCCESS or any applicable error code
|
||
202 | */
|
||
203 | NCSError NCS_CALL NCSEcwCompressClose(NCSEcwCompressClient *pInfo); |
||
204 | /**
|
||
205 | * Free the memory allocated to the NCSEcwCompressClient structure
|
||
206 | *
|
||
207 | * @param[in,out] pInfo The structure to free
|
||
208 | * @return NCSError value, NCS_SUCCESS or any applicable error code
|
||
209 | */
|
||
210 | NCSError NCS_CALL NCSEcwCompressFreeClient(NCSEcwCompressClient *pInfo); |
||
211 | |||
212 | typedef struct { |
||
213 | UINT8 nVersion; // ECW file version == ERSWAVE_VERSION
|
||
214 | CellSizeUnits eCellSizeUnits; // Units used for pixel size
|
||
215 | IEEE8 fCellIncrementX; // Increment in CellSizeUnits in X direction. May be negative. Will never be zero
|
||
216 | IEEE8 fCellIncrementY; // Increment in CellSizeUnits in Y direction. May be negative. Will never be zero
|
||
217 | IEEE8 fOriginX; // World X origin for top-left corner of top-left cell, in CellSizeUnits
|
||
218 | IEEE8 fOriginY; // World Y origin for top-left corner of top-left cell, in CellSizeUnits
|
||
219 | char *szDatum; // ER Mapper style Datum name string, e.g. "RAW" or "NAD27". Will never be NULL |
||
220 | char *szProjection; // ER Mapper style Projection name string, e.g. "RAW" or "WGS84". Will never be NULL |
||
221 | |||
222 | BOOLEAN bCompressedOffsetTable; // Is the block table compressed
|
||
223 | } NCSEcwEditInfo; |
||
224 | |||
225 | NCSError NCS_CALL NCSEcwEditReadInfo(char *pFilename, NCSEcwEditInfo **ppInfo);
|
||
226 | NCSError NCS_CALL NCSEcwEditWriteInfo(char *pFilename, NCSEcwEditInfo *pInfo, void (*pProgressFunc)(UINT64 nTotal, UINT64 nWritten, void *pClientData), BOOLEAN (*pCancelFunc)(void *pClientData), void *pClientData); |
||
227 | NCSError NCS_CALL NCSEcwEditFreeInfo(NCSEcwEditInfo *pInfo); |
||
228 | |||
229 | #ifdef __cplusplus
|
||
230 | } |
||
231 | #endif
|
||
232 | |||
233 | #endif /* NCSECWCOMPRESSCLIENT_H */ |