Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_2_1_Build_1046 / libraries / libjni-readecw-linux / include / NCSECWCompressClient.h @ 44114

History | View | Annotate | Download (9.9 KB)

1
/********************************************************** 
2
** Copyright 1999 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:           NCSECWCompessClient.h
15
** CREATED:        Thu 19/08/1999
16
** AUTHOR:         Simon Cope
17
** PURPOSE:        Public Interface library to compress ECW v2.0 image files
18
** EDITS:
19
** [01] sjc 08Dec1999        Updated comments
20
**
21
********************************************************/
22

    
23
/** @file NCSECWCompressClient.h */
24
#ifndef NCSECWCOMPRESSCLIENT_H
25
#define NCSECWCOMPRESSCLIENT_H
26

    
27
#ifndef NCSECWCLIENT_H
28
#include "NCSECWClient.h"
29
#endif
30

    
31
#ifdef __cplusplus
32
extern "C" {
33
#endif
34

    
35
#ifndef NCSTYPES_H
36
#include "NCSTypes.h"
37
#endif
38
#ifndef NCSERRORS_H
39
#include "NCSErrors.h"
40
#endif
41

    
42
#define ERSWAVE_VERSION 2
43
#define ERSWAVE_VERSION_STRING        "2.0"                /* should be in sync with the above */
44

    
45
/** 
46
 *  @enum
47
 *        An enumerated type specifying the format of the compressed data. Currently greyscale, RGB
48
 *        and luminance-chrominance formats are supported.  This will later need expanding to include 
49
 *        multiband formats such as CMYK.
50
 */
51
typedef enum {
52
        /** The compressed data is unformatted */
53
        COMPRESS_NONE                = NCSCS_NONE,
54
        /** Greyscale format, single band */
55
        COMPRESS_UINT8                = NCSCS_GREYSCALE,
56
        /** JPEG standard YUV digital format, three band */
57
        COMPRESS_YUV                = NCSCS_YUV,
58
        /** Multiband format */
59
        COMPRESS_MULTI                = NCSCS_MULTIBAND,
60
        /** RGB images (converted to COMPRESS_YUV internally) */
61
        COMPRESS_RGB                = NCSCS_sRGB                        
62
} CompressFormat;
63

    
64
/**        
65
 *        @enum
66
 *        An enumerated type allowing the user to hint at an appropriate compression scheme.  The 
67
 *        value is a guideline for the SDK compression functions.
68
 */
69
typedef enum {
70
        /** No compression hint */
71
        COMPRESS_HINT_NONE        = 0,
72
        /** Do the fastest compression possible */
73
        COMPRESS_HINT_FAST        = 1,
74
        /** Try to achieve the maximum possible compression ratio */
75
        COMPRESS_HINT_BEST        = 2,
76
        /** Optimise compression process for later Internet use of the compressed file */
77
        COMPRESS_HINT_INTERNET = 3
78
} CompressHint;
79

    
80
/** @def Maximum length of a datum definition string */
81
#define ECW_MAX_DATUM_LEN                16
82
#ifndef ECW_MAX_PROJECTION_LEN
83
/** @def Maximum length of a projection definition string */
84
#define ECW_MAX_PROJECTION_LEN        16
85
#endif
86

    
87
/** @def X dimension of the default (and preferred) block size */
88
#define X_BLOCK_SIZE        64
89
/** @def Y dimension of the default (and preferred) block size */
90
#define        Y_BLOCK_SIZE        64
91

    
92
/** 
93
 *        @struct
94
 *        This structure contains information used when compressing raster data 
95
 *        to an output ECW file.  Most of the values have sensible defaults so users
96
 *        need only customise those of significance to their application.  Certain 
97
 *        of these values must always be specified in the client code, namely 
98
 *        fTargetCompression, nInOutSizeX, nInOutSizeY, nInputBands, and pReadCallback.
99
 *
100
 *        Once compression is complete certain statistics are calculated and added 
101
 *        to this structure.  These include the time taken, the output file size in 
102
 *        bytes, the actual compression ratio achieved, and the MB/s throughput of the 
103
 *        process.
104
 */
105
typedef struct NCSEcwCompressClient {
106
        /*
107
        ** These fields are populated by the compression client
108
        */
109
        /** If this is specified but the output file is not, a default output filename will be created.
110
         *        Otherwise this field is unused.
111
         */
112
        char        szInputFilename[MAX_PATH];                        
113
        /** An output filename must be specified if no input filename is specified */
114
        char        szOutputFilename[MAX_PATH];        
115
        /** The target compression ratio - must be specified */
116
        IEEE4                        fTargetCompression;
117
        /**        The compression format to use.  See the related enumerated type definition */
118
        CompressFormat        eCompressFormat;
119
        /** A guideline for an appropriate compression scheme to use.  This currently has 
120
         *        no effect, though the default value is COMPRESS_HINT_INTERNET.  Reserved for
121
         *        future use, see the related enumerated type definition 
122
         */
123
        CompressHint        eCompressHint;
124
        /** X dimension of the block size to use.  Can be 64, 128, 256, 512, 1024, or 2048.
125
         *        The default for these is set to 64 which produces preferred performance over the internet.
126
         */
127
        UINT32                        nBlockSizeX;
128
        /** Y dimension of the block size to use.  Can be 64, 128, 256, 512, 1024, or 2048.
129
         *        The default for these is set to 64 which produces preferred performance over the internet.
130
         */
131
        UINT32                        nBlockSizeY;                                /* Y Block size (64, 128, 256, 512)                                        */
132
        /** Number of cells of input data and compressed file in the X direction - must be specified */
133
        UINT32                        nInOutSizeX;
134
        /** Number of cells of input data and compressed file in the Y direction - must be specified */
135
        UINT32                        nInOutSizeY;
136
        /** Number of bands in the input data - must be specified */
137
        UINT32                        nInputBands;
138
        /** Number of bands in the output file - should not generally be specified */
139
        UINT32                        nOutputBands;
140
        /** Size of the input file in bytes - should not be specified, it will be determined automatically. */
141
        UINT64                        nInputSize;
142
        /** Optional field specifying the cell size in the X direction in eCellSizeUnits */
143
        IEEE8                        fCellIncrementX;
144
        /** Optional field specifying the cell size in the Y direction in eCellSizeUnits */
145
        IEEE8                        fCellIncrementY;
146
        /** Optional field specifying the X world origin of the input data in eCellSizeUnits */
147
        IEEE8                        fOriginX;
148
        /** Optional field specifying the Y world origin of the input data in eCellSizeUnits */
149
        IEEE8                        fOriginY;
150
        /** Optional field specifying the units in which world cell sizes are specified, e.g. meters, feet */
151
        CellSizeUnits        eCellSizeUnits;
152
        /** ER Mapper GDT style datum string */
153
        char                        szDatum[ECW_MAX_DATUM_LEN];
154
        /** ER Mapper GDT style projection string */
155
        char                        szProjection[ECW_MAX_PROJECTION_LEN];
156
        /** Callback function used to obtain lines of band data from the input data - must be specified */
157
        BOOLEAN                        (*pReadCallback) (struct NCSEcwCompressClient *pClient,
158
                                                                          UINT32 nNextLine,
159
                                                                          IEEE4 **ppInputArray);
160
        /** Optional status callback function to track the progress of the compression process */
161
        void                        (*pStatusCallback) (struct NCSEcwCompressClient *pClient,
162
                                                                                UINT32 nCurrentLine);                                
163
        /** Optional cancel callback function which can be used to cancel a compression process */
164
        BOOLEAN                        (*pCancelCallback) (struct NCSEcwCompressClient *pClient);
165
        /** (void *) Pointer to any private data you need to access in the three callback functions */
166
        void                        *pClientData;
167
        /** Created by NCSEcwCompressOpen() */
168
        struct                        EcwCompressionTask *pTask;
169
        /*
170
        ** The remaining fields are populated by NCSEcwCompressClose() 
171
        */
172
        /** Actual compression rate achieved - ratio of input data size to output file size */
173
        IEEE4                        fActualCompression;
174
        /** Time taken to perform the complete compression, in seconds */
175
        IEEE8                        fCompressionSeconds;
176
        /** MB/s throughput during the compression process */
177
        IEEE8                        fCompressionMBSec;
178
        /** Total size of the output file in bytes */
179
        UINT64                        nOutputSize;
180
} NCSEcwCompressClient;
181

    
182
/** 
183
 *        Allocate a new CompressionClient structure and fill in defaults 
184
 *
185
 *        @return                                        A pointer to memory allocated to an NCSEcwCompressClient structure
186
 */
187
NCSEcwCompressClient * NCS_CALL NCSEcwCompressAllocClient(void);
188
/**        
189
 *        Having set compression parameters, initialise the compression process
190
 *
191
 *        @param[in,out]        pInfo                                The NCSEcwCompressClient structure containing the compression parameters 
192
 *        @param[in]                bCalculateSizesOnly        Which output statistics to calculate 
193
 *        @return                                                                NCSError value, NCS_SUCCESS or any applicable error code
194
 */
195
NCSError NCS_CALL NCSEcwCompressOpen(NCSEcwCompressClient *pInfo, BOOLEAN bCalculateSizesOnly); 
196
/**        
197
 *        Start the compression process based on these parameters
198
 *
199
 *        @param[in,out]        pInfo                                The NCSEcwCompressClient structure for this compression process
200
 *        @return                                                                NCSError value, NCS_SUCCESS or any applicable error code
201
 */
202
NCSError NCS_CALL NCSEcwCompress(NCSEcwCompressClient *pInfo);
203
/** 
204
 *        Having completed compression, close, calculate output statistics, and clean up
205
 *
206
 *        @param[in,out]        pInfo                                The NCSEcwCompressClient structure for this compression process
207
 *        @return                                                                NCSError value, NCS_SUCCESS or any applicable error code
208
 */
209
NCSError NCS_CALL NCSEcwCompressClose(NCSEcwCompressClient *pInfo);
210
/**        
211
 *        Free the memory allocated to the NCSEcwCompressClient structure
212
 *
213
 *        @param[in,out]        pInfo                                The structure to free
214
 *        @return                                                                NCSError value, NCS_SUCCESS or any applicable error code
215
 */
216
NCSError NCS_CALL NCSEcwCompressFreeClient(NCSEcwCompressClient *pInfo);
217

    
218
typedef struct {
219
        UINT8                                nVersion;                        // ECW file version == ERSWAVE_VERSION
220
        CellSizeUnits                eCellSizeUnits;                // Units used for pixel size
221
        IEEE8                                fCellIncrementX;        // Increment in CellSizeUnits in X direction. May be negative. Will never be zero
222
        IEEE8                                fCellIncrementY;        // Increment in CellSizeUnits in Y direction. May be negative. Will never be zero
223
        IEEE8                                fOriginX;                        // World X origin for top-left corner of top-left cell, in CellSizeUnits
224
        IEEE8                                fOriginY;                        // World Y origin for top-left corner of top-left cell, in CellSizeUnits
225
        char                                *szDatum;                        // ER Mapper style Datum name string, e.g. "RAW" or "NAD27". Will never be NULL
226
        char                                *szProjection;                // ER Mapper style Projection name string, e.g. "RAW" or "WGS84". Will never be NULL
227

    
228
        BOOLEAN                                bCompressedOffsetTable; // Is the block table compressed
229
} NCSEcwEditInfo;
230

    
231
NCSError NCS_CALL NCSEcwEditReadInfo(char *pFilename, NCSEcwEditInfo **ppInfo);
232
NCSError NCS_CALL NCSEcwEditWriteInfo(char *pFilename, NCSEcwEditInfo *pInfo, void (*pProgressFunc)(UINT64 nTotal, UINT64 nWritten, void *pClientData), BOOLEAN (*pCancelFunc)(void *pClientData), void *pClientData);
233
NCSError NCS_CALL NCSEcwEditFreeInfo(NCSEcwEditInfo *pInfo);
234

    
235
#ifdef __cplusplus
236
}
237
#endif
238

    
239
#endif /* NCSECWCOMPRESSCLIENT_H */