svn-gvsig-desktop / tags / v1_1_1_Build_1016 / libraries / libjni-ecw / include / NCSEcw.h @ 33925
History | View | Annotate | Download (24 KB)
1 | 3538 | nacho | /**********************************************************
|
---|---|---|---|
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: ncsecw.c
|
||
15 | ** CREATED: 1 March 1999
|
||
16 | ** AUTHOR: SNS
|
||
17 | ** PURPOSE: Glue functions to access ECW files from the NCS system
|
||
18 | ** EDITS:
|
||
19 | ** [01] sns 01Mar99 Created file
|
||
20 | ** [02] sns 02Apr99 Not doing Mutex locks during process shutdown
|
||
21 | ** [03] sns 09May99 Using new logic for callback interface
|
||
22 | ** [04] sjc 30Dec99 Changed Sanity check to global func from static
|
||
23 | ** [05] sjc 30Mar00 Modified to use Shared Memory for stats instead of
|
||
24 | ** Shared dataseg in dll. Handles backwards compatibility.
|
||
25 | ** Means NCSEcw.dll can be anywhere in system and still
|
||
26 | ** use global caching stats
|
||
27 | ** [06] sjc 30Apr00 Merged Mac SDK port
|
||
28 | ** [07] ny 12May00 Added bIsConnected field to the NCSFileStruct structure
|
||
29 | ** [08] sjc 20Jun00 Out-of-Order block fix
|
||
30 | ** [09] rdh 04Oct00 Added NCSEcwReadLineType enum type
|
||
31 | ** [10] ddi 14Nov00 Moved NCSECWReadLineType to ecw.h
|
||
32 | ** [11] ny 23Nov00 Added #include "NCSUtil.h" so that MACINTOSH is defined
|
||
33 | ** [12] ny 06Dec00 Change #include "NCSUtil.h" to #include "NCSTypes.h"
|
||
34 | ** [13] jmp 23Jul01 Fix where IDWT thread can become suspended after a SetView.
|
||
35 | ** [14] mjs 26Nov01 Fixed old ermapper include warnings.
|
||
36 | ** [15] sjc 04Feb02 Added MAXOPEN
|
||
37 | ** [16] sjc 19Feb02 Exposed cache purge parameters
|
||
38 | ** [17] rar 17Jun02 Changed NCScbmReadFileBlockLocal() to check if a read failed due to network error
|
||
39 | ** and if so set a flag (pNCSFile->bFileIOError). This was needed so that if the
|
||
40 | ** IWS and ecw_img knows the network file must be closed and reopened.
|
||
41 | ** [18] rar 19Jun02 Added mutex around NCScbmReadFileBlockLocal() and NCScbmGetFileBlockSizeLocal() to
|
||
42 | ** prevent the IWS and ecw_img trying to read from the same file at the same time.
|
||
43 | ** [19] rar 02Sep03 Added option to try ecwp re-connection if connection lost
|
||
44 | **
|
||
45 | ** NOTES
|
||
46 | **
|
||
47 | ********************************************************/
|
||
48 | |||
49 | #ifndef NCSECW_H
|
||
50 | #define NCSECW_H
|
||
51 | |||
52 | #include "NCSTypes.h" /**[12]**/ |
||
53 | #if !defined(_WIN32_WCE)
|
||
54 | #include <time.h> |
||
55 | #endif
|
||
56 | #ifdef MACINTOSH
|
||
57 | #include <MacTypes.h> |
||
58 | #include <stat.h> |
||
59 | #include <stdio.h> |
||
60 | #else /* MACINTOSH */ |
||
61 | #if !defined(_WIN32_WCE)
|
||
62 | #include <sys/types.h> |
||
63 | #include <sys/stat.h> |
||
64 | #endif
|
||
65 | #endif /* MACINTOSH */ |
||
66 | #include <stdio.h> |
||
67 | #include "NCSMemPool.h" // need pool management |
||
68 | #include "NCSThread.h" // we need locks and threads |
||
69 | #include "NCSMutex.h" |
||
70 | #include "NCSPackets.h" // Server Packets |
||
71 | #include "NCScnet.h" // client network layer |
||
72 | #include "ECW.h" |
||
73 | #include "NCSECWClient.h" // [03] to get public structure information |
||
74 | |||
75 | #ifdef __cplusplus
|
||
76 | extern "C" { |
||
77 | #endif
|
||
78 | |||
79 | /*********************************************************
|
||
80 | ** NCSECW Cache management values
|
||
81 | **********************************************************/
|
||
82 | |||
83 | // If a File View currently has a view size (window size) that
|
||
84 | // is smaller than this number, blocks will be cached,
|
||
85 | // otherwise the blocks will be freed as soon as they are used
|
||
86 | |||
87 | #define NCSECW_MAX_VIEW_SIZE_TO_CACHE 4000 |
||
88 | |||
89 | |||
90 | #define NCSECW_MAX_UNUSED_CACHED_FILES 10000 // Maximum number of files that can be open and unused |
||
91 | #define NCSECW_CACHED_BLOCK_POOL_SIZE 1000 // initial size of cached block pointers pool |
||
92 | #define NCSECW_MAX_SEND_PACKET_SIZE 1024 // maximum size of a packet to send |
||
93 | #define NCSECW_IDWT_QUEUE_GRANULARITY 32 // realloc the setview queue every this often |
||
94 | |||
95 | // Time related
|
||
96 | #define NCSECW_PURGE_DELAY_MS 1000 // only purge cache after at least this time has passed since last purge |
||
97 | // These are stored in the global shared application structure, and can be changed by users
|
||
98 | #define NCSECW_BLOCKING_TIME_MS 10000 // wait up to 10 seconds before giving up, for blocking clients |
||
99 | #define NCSECW_QUIET_WAIT_TIME_MS 10000 // wait up to 10 seconds before giving up, for blocking clients |
||
100 | #define NCSECW_REFRESH_TIME_MS 500 // allow 0.5 seconds to pass before issuing a new refresh if new blocks have arrived |
||
101 | #define NCSECW_FILE_PURGE_TIME_MS (30*60*1000) // Ideally keep files for up to 30 minutes when idle |
||
102 | #define NCSECW_FILE_MIN_PURGE_TIME_MS (30*1000) // never purge files in less than 30 seconds |
||
103 | |||
104 | #define NCSECW_MAX_SETVIEW_PENDING 1 // maximum number of SetViews that can be pending |
||
105 | #define NCSECW_MAX_SETVIEW_CANCELS 3 // maximum number of SetViews that will be cancelled, |
||
106 | // before forcing completion regardless of number pending
|
||
107 | #define NCSECW_HIGHMAX_SETVIEW_PENDING 10 // unless this many setviews are pending, in which case |
||
108 | // we flush pending's regardless (if we can)
|
||
109 | #define NCSECW_MAX_OFFSET_CACHE 1024 // Offset cache size for ECW files with RAW block tables |
||
110 | |||
111 | // The type of caching used for a particular file view
|
||
112 | typedef enum { |
||
113 | NCS_CACHE_INVALID = 0, // invalid caching method |
||
114 | NCS_CACHE_DONT = 1, // Don't cache for this file view (typically because a big file view) |
||
115 | NCS_CACHE_VIEW = 2 // A "normal" file view, so cache blocks where possible |
||
116 | } NCSCacheMethod; |
||
117 | |||
118 | // The type of request for a block in a file cache list
|
||
119 | typedef enum { |
||
120 | NCSECW_BLOCK_INVALID = 0, // invalid block request |
||
121 | NCSECW_BLOCK_REQUEST = 1, // Post a Request for the block |
||
122 | NCSECW_BLOCK_CANCEL = 2, // Post a Cancel for the block |
||
123 | NCSECW_BLOCK_RETURN = 3 // Return the block in the cache list |
||
124 | } NCSEcwBlockRequestMethod; |
||
125 | |||
126 | // [03] current thread state
|
||
127 | typedef enum { |
||
128 | NCSECW_THREAD_INVALID = 0, // invalid state |
||
129 | NCSECW_THREAD_DEAD = 1, // Thread is not running |
||
130 | NCSECW_THREAD_ALIVE = 2, // Thread alive and running |
||
131 | NCSECW_THREAD_SUSPENDED = 3 // Thread alive and suspended |
||
132 | } NCSEcwThreadState; |
||
133 | |||
134 | // [03] current view callback state. ONLY used for callback style views
|
||
135 | typedef enum { |
||
136 | NCSECW_VIEW_INVALID = 0, // invalid state |
||
137 | NCSECW_VIEW_QUIET = 1, // open, but no active setview, and not processing the IDWT |
||
138 | NCSECW_VIEW_SET = 2, // Setview done, but not yet reading data |
||
139 | NCSECW_VIEW_QUEUED = 3, // queued to process a iDWT for the view (in Thread queue) |
||
140 | NCSECW_VIEW_IDWT = 4 // processing a IDWT for the view |
||
141 | } NCSEcwViewCallbackState; |
||
142 | |||
143 | // [03] insertion order into a queue. Generally, LIFO is faster than FIFO if you don't care
|
||
144 | typedef enum { |
||
145 | NCSECW_QUEUE_INVALID = 0, // invalid state |
||
146 | NCSECW_QUEUE_LIFO = 1, // Insert into queue in LIFO order |
||
147 | NCSECW_QUEUE_FIFO = 2 // Insert into queue in FIFO order |
||
148 | } NCSEcwQueueInsertOrder; |
||
149 | |||
150 | /*********************************************************
|
||
151 | ** NCSECW Structure definitions
|
||
152 | **********************************************************/
|
||
153 | |||
154 | typedef struct NCSFileCachedBlockStruct { |
||
155 | NCSBlockId nBlockNumber; // block number being cached
|
||
156 | struct NCSFileCachedBlockStruct *pNextCachedBlock; // next block in the cache list for the file |
||
157 | #if defined( MACINTOSH ) && TARGET_API_MAC_OS8
|
||
158 | Handle pPackedECWBlock; |
||
159 | Handle pUnpackedECWBlock; |
||
160 | #else
|
||
161 | UINT8 *pPackedECWBlock; // the packed ECW block that is currently cached (or NULL)
|
||
162 | UINT8 *pUnpackedECWBlock; // the packed ECW block that is currently cached (or NULL)
|
||
163 | #endif
|
||
164 | UINT32 nPackedECWBlockLength; // Length of the packed block
|
||
165 | UINT32 nUnpackedECWBlockLength;// Length of the unpacked block
|
||
166 | UINT32 nUsageCount; // number of times in use by FileViews
|
||
167 | UINT32 nHitCount; // number of times block has been read during inverse DWT operations
|
||
168 | BOOLEAN bRequested; // only TRUE if block request HAS BEEN SENT to the server
|
||
169 | // (so FALSE in every other situation, even if block not loaded yet)
|
||
170 | UINT64 nDecodeMissID; /**[08]**/
|
||
171 | } NCSFileCachedBlock; |
||
172 | |||
173 | // This is used during cache purging. There is one entry per level in the file
|
||
174 | typedef struct NCSFileCachePurgeStruct { |
||
175 | NCSFileCachedBlock *pPreviousBlock; // the block BEFORE the first block at this level
|
||
176 | NCSFileCachedBlock *pLevelBlocks; // the first block at this level
|
||
177 | } NCSFileCachePurge; |
||
178 | |||
179 | typedef struct { |
||
180 | NCSBlockId nID; |
||
181 | UINT32 nLength; |
||
182 | UINT64 nOffset; |
||
183 | NCSTimeStampMs tsLastUsed; |
||
184 | } NCSFileBlockOffsetEntry; |
||
185 | |||
186 | struct NCSFileStruct {
|
||
187 | QmfLevelStruct *pTopQmf; // Pointer to the top level of the ECW QMF structure
|
||
188 | struct NCSFileStruct *pNextNCSFile, *pPrevNCSFile; // NCSECW linked list of NCS files cached |
||
189 | UINT32 nUsageCount; // number of times this file is currently open
|
||
190 | UINT32 SemiUniqueId; // Somewhat unique ID, based on File Name
|
||
191 | BOOLEAN bReadOffsets; // TRUE if the block offsets table has been read and is valid for the QMF
|
||
192 | BOOLEAN bReadMemImage; // TRUE if the NCSFile has a memory image of the header present
|
||
193 | BOOLEAN bLocalFile; // TRUE if this is a local file
|
||
194 | char *szUrlPath; // URL (filename) for this file |
||
195 | BOOLEAN bValid; // File is currently valid (it has not changed on disk since open).
|
||
196 | // Client side information (not valid when file opened at the server end)
|
||
197 | NCSTimeStampMs tLastSetViewTime;// Last time a SetView was done, used to decide when to purge files from cache
|
||
198 | NCSPool *pBlockCachePool; // Pointer to pool of cached blocks
|
||
199 | NCSFileCachedBlock *pFirstCachedBlock; // Pointer to first block in the cached block list
|
||
200 | NCSFileCachedBlock *pWorkingCachedBlock; // Pointer to block last accessed (reduces search times)
|
||
201 | NCSFileCachedBlock *pLastReceivedCachedBlock; // Pointer to last block received to speed list access
|
||
202 | NCSPacket *pSendPacket; // Pointer to Send Packet - only one packet allocated & kept for life of File open
|
||
203 | NCSClientUID nClientUID; // Unique UID for this client file opened
|
||
204 | NCSSequenceNr nServerSequence; // current maximum sequence number read from back from the server
|
||
205 | NCSSequenceNr nClientSequence; // current sequence number client has issued
|
||
206 | UINT8 *pLevel0ZeroBlock; // a level 0 zero block containing all zeros for all bands and sidebands
|
||
207 | UINT8 *pLevelnZeroBlock; // a > level 0 zero block (has one less sideband than level 0)
|
||
208 | struct NCSFileViewStruct *pNCSFileViewList; // list of OPEN file views for this file |
||
209 | struct NCSFileViewStruct *pNCSCachedFileViewList; // CLOSED but Cached File Views for this file |
||
210 | // Client network related information (not valid when file opened at the server end)
|
||
211 | pNCSnetClient pClientNetID; // client network layer file channel NetID
|
||
212 | BOOLEAN bSendInProgress; // if TRUE, a send pack (request and/or cancel) has been made, and callback will be made once complete
|
||
213 | UINT32 nRequestsXmitPending; // if non-zero, number of block read requests waiting to send
|
||
214 | // (NOT requests already sent that responses are waiting for)
|
||
215 | UINT32 nCancelsXmitPending; // if non-zero, number of block cancel requests waiting to sent
|
||
216 | UINT32 nUnpackedBlockBandLength; // length of one band in an unpacked block (always unpacked out to max X&Y block size)
|
||
217 | NCSFileCachePurge *pNCSCachePurge;// an array, one entry per QMF level
|
||
218 | UINT16 nCachePurgeLevelCount; // maximum levels CURRENTLY in the NCSCachePurge array, might be less than max_levels+1
|
||
219 | ECWFileInfoEx *pFileInfo; // Handy collection of information about the file.
|
||
220 | BOOLEAN bIsConnected; // Are we still connected to the server serving this file /**[07]**/
|
||
221 | BOOLEAN bIsCorrupt; // File is corrupt - displayed message for user
|
||
222 | |||
223 | NCSFileBlockOffsetEntry *pOffsetCache; |
||
224 | UINT32 nOffsetCache; |
||
225 | BOOLEAN bFileIOError; //[17]
|
||
226 | NCSMutex mFileAccess; //[18]
|
||
227 | |||
228 | NCSTimeStampMs tsLastReconnectTry; //[19] The time of the last attempt to reconnect to the IWS
|
||
229 | UINT32 nReconnectCount; |
||
230 | }; |
||
231 | |||
232 | struct NCSFileViewStruct {
|
||
233 | NCSFile *pNCSFile; |
||
234 | QmfRegionStruct *pQmfRegion; // pointer to current QMF region
|
||
235 | NCSCacheMethod nCacheMethod; // caching method used by this file view
|
||
236 | struct NCSFileViewStruct *pNextNCSFileView, *pPrevNCSFileView; // list of views for this file |
||
237 | NCSTimeStampMs tLastBlockTime; // Time that the last block was received.
|
||
238 | // Currently only valid for served (not local) files
|
||
239 | NCSEcwReadStatus (*pRefreshCallback)(struct NCSFileViewStruct *pNCSFileView); // Refresh callback function |
||
240 | BOOLEAN bTriggerRefreshCallback; // TRUE if we need to trigger a refresh callback.
|
||
241 | // Deferred so can start in other threads and outside mutex's
|
||
242 | NCSEcwViewCallbackState eCallbackState; |
||
243 | BOOLEAN bGoToQuietState; // TRUE if the view is being forced to quiet (cancelling iDWTs etc)
|
||
244 | NCSFileViewSetInfo info; // public information, and current view values
|
||
245 | NCSFileViewSetInfo pending; // pending SetView, which is waiting for current view to finish processing
|
||
246 | UINT16 nPending; // Number of pending SetView's outstanding
|
||
247 | UINT16 nCancelled; // Number of SetViews cancelled since a successful one
|
||
248 | BOOLEAN bIsRefreshView; // TRUE if the current view is just updating the previous view.
|
||
249 | // If true, the current view will be cancelled when a SetView is done
|
||
250 | UINT64 nNextDecodeMissID; /**[08]**/
|
||
251 | }; |
||
252 | |||
253 | typedef struct NCSecwStatisticsStruct { |
||
254 | // NOTE: DO NOT CHANGE THIS STRUCTURE IN ANY WAY.
|
||
255 | |||
256 | UINT32 nApplicationsOpen; // number of applications currently open
|
||
257 | |||
258 | // Time wait for network server to respond with blocks
|
||
259 | UINT32 nBlockingTime; // Time in ms to block clients that don't support callbacks
|
||
260 | UINT32 nRefreshTime; // Time in ms to wait between refresh callbacks to smart clients
|
||
261 | |||
262 | // Statistics
|
||
263 | |||
264 | UINT32 nFilesOpen; // number of files currently open
|
||
265 | UINT32 nFilesCached; // number of files currently cached but not open
|
||
266 | UINT32 nFilesCacheHits; // number of times an open found an existing cached file
|
||
267 | UINT32 nFilesCacheMisses; // number of times an open could not find the file in cache
|
||
268 | UINT32 nFilesModified; // number of times files were invalidated because they changed on disk while open
|
||
269 | |||
270 | UINT32 nFileViewsOpen; // number of file views currently open
|
||
271 | UINT32 nFileViewsCached; // number of file views cached but not open
|
||
272 | |||
273 | UINT32 nSetViewBlocksCacheHits; // number of times a SetView hit a cached block structure
|
||
274 | UINT32 nSetViewBlocksCacheMisses; // number of times a SetView missed a cached block
|
||
275 | |||
276 | UINT32 nReadBlocksCacheHits; // number of times a read hit a cached block
|
||
277 | UINT32 nReadUnpackedBlocksCacheHits; // number of times a read hit a unpacked cached block
|
||
278 | UINT32 nReadBlocksCacheMisses; // number of times a read missed a cached block
|
||
279 | UINT32 nReadBlocksCacheBypass; // number of times a read bypassed cache (for large view IO)
|
||
280 | |||
281 | UINT32 nRequestsSent; // number of block read requests sent to the server
|
||
282 | UINT32 nCancelsSent; // number of block read request cancels sent to the server
|
||
283 | UINT32 nBlocksReceived; // number of blocks received
|
||
284 | UINT32 nCancelledBlocksReceived; // number of blocks cancelled that were still received
|
||
285 | |||
286 | UINT32 nRequestsXmitPending; // number of block read requests waiting to be sent to server
|
||
287 | UINT32 nCancelsXmitPending; // number of block cancel requests waiting to be sent to server
|
||
288 | |||
289 | UINT32 nPackedBlocksCacheSize; // Size in bytes of packed blocks in cache
|
||
290 | UINT32 nUnpackedBlocksCacheSize; // Size in bytes of unpacked blocks in cache
|
||
291 | UINT32 nMaximumCacheSize; // Maximum allowed size of cache
|
||
292 | } NCSecwStatisticsV1; |
||
293 | |||
294 | // UP this version if you add more fields to structure.
|
||
295 | #define ECW_STATS_STRUCT_VERSION_2 2 |
||
296 | #define ECW_STATS_STRUCT_VERSION 3 |
||
297 | |||
298 | #define ECW_STATS_LOCK_NAME "NCSCBMStatsLock" |
||
299 | #ifdef _DEBUG
|
||
300 | #define NCS_STATUS_STRUCT_NAME_VERSION_2 "NCSEcwSharedStatisticsSHM DEBUG" |
||
301 | #define NCS_STATUS_STRUCT_NAME_VERSION "NCSEcwSharedStatisticsSHM3 DEBUG" |
||
302 | #else
|
||
303 | #define NCS_STATUS_STRUCT_NAME_VERSION_2 "NCSEcwSharedStatisticsSHM" |
||
304 | #define NCS_STATUS_STRUCT_NAME_VERSION "NCSEcwSharedStatisticsSHM3" |
||
305 | #endif
|
||
306 | |||
307 | #ifdef WIN32
|
||
308 | typedef LONG NCSEcwStatsType;
|
||
309 | #else
|
||
310 | typedef INT32 NCSEcwStatsType;
|
||
311 | #endif
|
||
312 | |||
313 | typedef struct tagNCSEcwStatistics { |
||
314 | // NOTE: DO NOT CHANGE ANY OF THESE FIELDS. ADD NEW FIELDS AT END OF STRUCTURE.
|
||
315 | // FIELDS DOWN TO nMaximumCacheSize MUST BE IDENTICAL TO NCSecwStatisticsV1
|
||
316 | |||
317 | NCSEcwStatsType nApplicationsOpen; // number of applications currently open
|
||
318 | |||
319 | // Time wait for network server to respond with blocks
|
||
320 | NCSEcwStatsType nBlockingTime; // Time in ms to block clients that don't support callbacks
|
||
321 | NCSEcwStatsType nRefreshTime; // Time in ms to wait between refresh callbacks to smart clients
|
||
322 | |||
323 | // Statistics
|
||
324 | |||
325 | NCSEcwStatsType nFilesOpen; // number of files currently open
|
||
326 | NCSEcwStatsType nFilesCached; // number of files currently cached but not open
|
||
327 | NCSEcwStatsType nFilesCacheHits; // number of times an open found an existing cached file
|
||
328 | NCSEcwStatsType nFilesCacheMisses; // number of times an open could not find the file in cache
|
||
329 | NCSEcwStatsType nFilesModified; // number of times files were invalidated because they changed on disk while open
|
||
330 | |||
331 | NCSEcwStatsType nFileViewsOpen; // number of file views currently open
|
||
332 | NCSEcwStatsType nFileViewsCached; // number of file views cached but not open
|
||
333 | |||
334 | NCSEcwStatsType nSetViewBlocksCacheHits; // number of times a SetView hit a cached block structure
|
||
335 | NCSEcwStatsType nSetViewBlocksCacheMisses; // number of times a SetView missed a cached block
|
||
336 | |||
337 | NCSEcwStatsType nReadBlocksCacheHits; // number of times a read hit a cached block
|
||
338 | NCSEcwStatsType nReadUnpackedBlocksCacheHits; // number of times a read hit a unpacked cached block
|
||
339 | NCSEcwStatsType nReadBlocksCacheMisses; // number of times a read missed a cached block
|
||
340 | NCSEcwStatsType nReadBlocksCacheBypass; // number of times a read bypassed cache (for large view IO)
|
||
341 | |||
342 | NCSEcwStatsType nRequestsSent; // number of block read requests sent to the server
|
||
343 | NCSEcwStatsType nCancelsSent; // number of block read request cancels sent to the server
|
||
344 | NCSEcwStatsType nBlocksReceived; // number of blocks received
|
||
345 | NCSEcwStatsType nCancelledBlocksReceived; // number of blocks cancelled that were still received
|
||
346 | |||
347 | NCSEcwStatsType nRequestsXmitPending; // number of block read requests waiting to be sent to server
|
||
348 | NCSEcwStatsType nCancelsXmitPending; // number of block cancel requests waiting to be sent to server
|
||
349 | |||
350 | NCSEcwStatsType nPackedBlocksCacheSize; // Size in bytes of packed blocks in cache
|
||
351 | NCSEcwStatsType nUnpackedBlocksCacheSize; // Size in bytes of unpacked blocks in cache
|
||
352 | NCSEcwStatsType nMaximumCacheSize; // Maximum allowed size of cache
|
||
353 | |||
354 | // Add NEW things below ALWAYS AT END!
|
||
355 | //
|
||
356 | // NOTE: If you add extra stats here, increment ECW_STATS_STRUCT_VERSION and always check the nStatsStructVersion global
|
||
357 | // to ensure the new version of the structure is available. If NCSecw.dll exists in the C:\winnt\system32 (NT/2000) or
|
||
358 | // C:\Windows\system (Win9x) directories, that Dll will be loaded and the shared data segment in it used instead of a
|
||
359 | // shared memory segment. This means you may be using an older version of the stats structure than you compiled in, hence
|
||
360 | // the need to check the version (and hence size). This is all done for backwards compatibility due to the move from a
|
||
361 | // shared Dll in the system directory to a local dll but the need to shared global stats across multiple applications.
|
||
362 | } NCSecwStatistics; |
||
363 | |||
364 | |||
365 | // [03] One of these per iDWT thread in the iDWT pool of threads (currently only 1 thread)
|
||
366 | // These threads are ONLY used to process iDWT's for callback based SetViews.
|
||
367 | typedef struct { |
||
368 | NCSThread tIDWT; // Inverse Descrete Wavelet Transform thread ID
|
||
369 | NCSEcwThreadState eIDWTState; // current state of the iDWT thread
|
||
370 | NCSFileView **ppNCSFileView; // array of pointers to FileViews to process callbacks for
|
||
371 | INT32 nQueueAllocLength; // total queue length currently allocated; it might grow
|
||
372 | INT32 nQueueNumber; // number of active items in the queue, could be zero
|
||
373 | } NCSidwt; |
||
374 | |||
375 | typedef struct { |
||
376 | NCSFile *pNCSFileList; // List of NCS files currently open
|
||
377 | NCSSHMInfo *pStatisticsSHM; |
||
378 | UINT8 nStatsStructVersion; |
||
379 | NCSecwStatistics *pStatistics; |
||
380 | #ifdef WIN32
|
||
381 | NCSThreadLSKey StatsLockKey; |
||
382 | #endif
|
||
383 | NCSMutex mutex; |
||
384 | NCSidwt *pIDWT; // iDWT thread. Currently only one thread ever started
|
||
385 | BOOLEAN bShutdown; // [02] true if in process shutdown mode
|
||
386 | BOOLEAN nForceFileReopen; // normally FALSE - only set to TRUE for server load testing
|
||
387 | BOOLEAN bNoTextureDither; // normally FALSE - TRUE for compression, so input compressed files have no texture dither added
|
||
388 | BOOLEAN bForceLowMemCompress; // Force a low memory compressioin
|
||
389 | NCSTimeStampMs tLastCachePurge; // How long ago the last Cache Purge was carried out
|
||
390 | UINT32 nAggressivePurge; // Higher number means previous purge did not reduce down to
|
||
391 | // desired purge budget, so be more aggressive on next purge
|
||
392 | UINT32 nMaximumOpen; // [15] Max # files open in cache
|
||
393 | #ifdef WIN32
|
||
394 | HANDLE m_hSuspendEvent; // /**[13]**/ used to fix bug where IDWT thread can be left suspended after a SetView
|
||
395 | #endif // WIN32 |
||
396 | NCSTimeStampMs nPurgeDelay; // [16] Time delay after last purge before new purge allowed
|
||
397 | NCSTimeStampMs nFilePurgeDelay; // [16] Time delay between last view closing and file being purged from cache
|
||
398 | NCSTimeStampMs nMinFilePurgeDelay; // [16] Min Time delay between last view closing and file being purged from cache
|
||
399 | |||
400 | UINT32 nMaxOffsetCache; // [16] Max size of offset cache for ECW files with RAW block tables.
|
||
401 | |||
402 | BOOLEAN bEcwpReConnect; // [19] normally FALSE - if TRUE the ecw library will try and reconnect if connection has been lost to IWS
|
||
403 | BOOLEAN bJP2ICCManage; // [20] normally TRUE - if FALSE the ecw library does not do ICC management on READ
|
||
404 | UINT32 nMaxJP2FileIOCache; // [20] JP2 file IO cache size
|
||
405 | } NCSEcwInfo; |
||
406 | |||
407 | |||
408 | |||
409 | /**********************************************************
|
||
410 | ** NCS to ECW Glue and wrapper functions
|
||
411 | **********************************************************/
|
||
412 | |||
413 | |||
414 | extern NCSError NCSecwOpenFile(
|
||
415 | NCSFile **ppNCSFile, |
||
416 | char *szInputFilename, // input file name or network path |
||
417 | BOOLEAN bReadOffsets, // TRUE if the client wants the block Offset Table
|
||
418 | BOOLEAN bReadMemImage); // TRUE if the client wants a Memory Image of the Header
|
||
419 | |||
420 | extern int NCSecwCloseFile( NCSFile *pNCSFile); |
||
421 | |||
422 | extern int NCSecwReadLocalBlock( NCSFile *pNCSFile, UINT64 nBlockNumber, |
||
423 | UINT8 **ppBlock, UINT32 *pBlockLength); |
||
424 | extern BOOLEAN NCScbmGetFileBlockSizeLocal(NCSFile *pNCSFile, NCSBlockId nBlock, UINT32 *pBlockLength, UINT64 *pBlockOffset );
|
||
425 | |||
426 | extern NCSecwStatistics *NCSecwGetStatistics( void ); |
||
427 | |||
428 | // Internal functions to the library - not visible to the DLL
|
||
429 | int NCSecwCloseFileCompletely( NCSFile *pNCSFile);
|
||
430 | void NCSEcwStatsLock(void); |
||
431 | void NCSEcwStatsUnLock(void); |
||
432 | void NCSEcwStatsIncrement(NCSEcwStatsType *pVal, INT32 n);
|
||
433 | void NCSEcwStatsDecrement(NCSEcwStatsType *pVal, INT32 n);
|
||
434 | |||
435 | /**********************************************************
|
||
436 | ** Routines internal to the library - not visible to the DLL
|
||
437 | **********************************************************/
|
||
438 | |||
439 | int NCScbmCloseFileViewCompletely(NCSFileView **ppNCSFileViewList, NCSFileView *pNCSFileView);
|
||
440 | UINT8 *NCSecwConstructZeroBlock(QmfLevelStruct *p_qmf, QmfRegionStruct *p_region, |
||
441 | UINT32 x_block, UINT32 y_block); |
||
442 | UINT8 *NCScbmReadViewBlock(QmfRegionLevelStruct *pQmfRegionLevel, |
||
443 | UINT32 nBlockX, UINT32 nBlockY); |
||
444 | void NCScbmFreeViewBlock(QmfRegionLevelStruct *pQmfRegionLevel, UINT8 *pECWBlock);
|
||
445 | BOOLEAN NCScbmNetFileBlockRequest(NCSFile *pNCSFile, NCSBlockId nBlock ); |
||
446 | NCSError NCScbmNetFileOpenInternal(UINT8 **ppHeaderMemImage, UINT32 *pnHeaderMemImageLen, pNCSnetClient *pClientID, NCSClientUID *pClientUID, NCSnetPacketSentCB *pSentCB, NCSnetPacketRecvCB *pRecvCB, void *pCBData, char *szUrlPath); |
||
447 | NCSError NCScbmNetFileOpen(UINT8 **ppHeaderMemImage, UINT32 *pnHeaderMemImageLen, NCSFile *pNCSFile, char *szUrlPath); //[19] |
||
448 | void NCScbmNetFileXmitRequests(NCSError nError, UINT8 *pLastPacketSent, NCSFile *pNCSFile );
|
||
449 | NCSFileCachedBlock *NCScbmGetCacheBlock(NCSFile *pNCSFile, NCSFileCachedBlock *pWorkingCachedBlock, |
||
450 | NCSBlockId nBlock, NCSEcwBlockRequestMethod eRequest); |
||
451 | |||
452 | |||
453 | |||
454 | void NCScbmInitThreadIDWT(NCSidwt *pIDWT);
|
||
455 | void NCScbmFinishThreadIDWT(NCSidwt *pIDWT);
|
||
456 | void NCScbmQueueIDWTCallback(NCSFileView *pNCSFileView, // queue a callback for this file view |
||
457 | NCSEcwQueueInsertOrder eOrder); // insert LIFO or FIFO
|
||
458 | #ifdef _DEBUG
|
||
459 | int NCScbmSanityCheckFileView(NCSFileView *pNCSFileView); /**[04]**/ |
||
460 | #endif
|
||
461 | /**********************************************************
|
||
462 | ** GLOBAL NCSECW variables
|
||
463 | **********************************************************/
|
||
464 | |||
465 | #ifdef NCSECWGLOBAL
|
||
466 | NCSEcwInfo *pNCSEcwInfo = NULL;
|
||
467 | #else
|
||
468 | extern NCSEcwInfo *pNCSEcwInfo;
|
||
469 | #endif
|
||
470 | |||
471 | #ifdef __cplusplus
|
||
472 | } |
||
473 | #endif
|
||
474 | |||
475 | #endif // NCSECW_H |