svn-gvsig-desktop / tags / tmp_build_del / libraries / libjni-mrsid-macosx / include / base / lti_imageStage.h @ 44691
History | View | Annotate | Download (11.9 KB)
1 | 9099 | mija | /* $Id$ */
|
---|---|---|---|
2 | /* //////////////////////////////////////////////////////////////////////////
|
||
3 | // //
|
||
4 | // This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue, //
|
||
5 | // Suite 200, Seattle, WA 98104. Unauthorized use or distribution //
|
||
6 | // prohibited. Access to and use of this code is permitted only under //
|
||
7 | // license from LizardTech, Inc. Portions of the code are protected by //
|
||
8 | // US and foreign patents and other filings. All Rights Reserved. //
|
||
9 | // //
|
||
10 | ////////////////////////////////////////////////////////////////////////// */
|
||
11 | /* PUBLIC */
|
||
12 | |||
13 | #ifndef LTI_IMAGESTAGE_H
|
||
14 | #define LTI_IMAGESTAGE_H
|
||
15 | |||
16 | // lt_lib_mrsid_core
|
||
17 | #include "lti_image.h" |
||
18 | |||
19 | |||
20 | LT_BEGIN_NAMESPACE(LizardTech) |
||
21 | |||
22 | #if defined(LT_COMPILER_MS)
|
||
23 | #pragma warning(push,4) |
||
24 | #endif
|
||
25 | |||
26 | |||
27 | class LTIProgressDelegate; |
||
28 | class LTIInterruptDelegate; |
||
29 | class LTIScene; |
||
30 | class LTIBufferProps; |
||
31 | class LTISceneBuffer; |
||
32 | |||
33 | |||
34 | |||
35 | /**
|
||
36 | * abstract class for decoding from an image
|
||
37 | *
|
||
38 | * The LTIImageStage abstract class extends the LTIImage class by adding
|
||
39 | * decode functionality, including read methods and progress and interrupt
|
||
40 | * functions.
|
||
41 | */
|
||
42 | class LTIImageStage : public LTIImage |
||
43 | { |
||
44 | public:
|
||
45 | /**
|
||
46 | * default constructor
|
||
47 | */
|
||
48 | LTIImageStage(); |
||
49 | |||
50 | /**
|
||
51 | * destructor
|
||
52 | */
|
||
53 | virtual ~LTIImageStage(); |
||
54 | |||
55 | /**
|
||
56 | * initializer
|
||
57 | */
|
||
58 | virtual LT_STATUS initialize(); |
||
59 | |||
60 | /**
|
||
61 | * set progress delegate
|
||
62 | *
|
||
63 | * This function sets the progress delegate, which is used in a callback-like
|
||
64 | * fashion to report percent-complete of a read() operation back to the
|
||
65 | * calling application.
|
||
66 | *
|
||
67 | * Passing NULL to this function should remove the LTIImageReader's current delegate,
|
||
68 | * if any.
|
||
69 | *
|
||
70 | * Note this function does not take ownership of the delegate object.
|
||
71 | *
|
||
72 | * @param delegate a pointer to the delegate object to be used by the image reader
|
||
73 | */
|
||
74 | virtual void setProgressDelegate(LTIProgressDelegate* delegate);
|
||
75 | |||
76 | /**
|
||
77 | * set interrupt delegate
|
||
78 | *
|
||
79 | * This function sets the interrupt delegate, which is used in a callback-like
|
||
80 | * fashion by the calling application to asynchronously indicate that a read()
|
||
81 | * operation should be halted without completing.
|
||
82 | *
|
||
83 | * Passing NULL to this function should remove the LTIImageReader's current delegate,
|
||
84 | * if any.
|
||
85 | *
|
||
86 | * Note this function does not take ownership of the delegate object.
|
||
87 | *
|
||
88 | * @param delegate a pointer to the delegate object to be used by the image reader
|
||
89 | */
|
||
90 | virtual void setInterruptDelegate(LTIInterruptDelegate* delegate);
|
||
91 | |||
92 | /**
|
||
93 | * read (decode) a scene from the image
|
||
94 | *
|
||
95 | * This function decodes a scene from the image and puts the pixels into the
|
||
96 | * given buffer.
|
||
97 | *
|
||
98 | * The scene may NOT extend beyond the boundaries of the image.
|
||
99 | *
|
||
100 | * This function calls readBegin(), then calls readStrip() repeatedly
|
||
101 | * until all the rows of the scene are done, then calls readEnd().
|
||
102 | *
|
||
103 | * Derived classes should not override this method.
|
||
104 | *
|
||
105 | * @param scene the region (and scale) of the image to be read
|
||
106 | * @param buffer the buffer to read the pixels into
|
||
107 | * @return status code indicating success or failure
|
||
108 | */
|
||
109 | LT_STATUS read(const LTIScene& scene,
|
||
110 | LTISceneBuffer& buffer); |
||
111 | |||
112 | /**
|
||
113 | * start strip-based read
|
||
114 | *
|
||
115 | * This function is called by read() before readStrip() is called. It
|
||
116 | * should not be called directly except in certain rare circumstances.
|
||
117 | *
|
||
118 | * Derived classes should not override.
|
||
119 | *
|
||
120 | * @param scene the full scene to be read
|
||
121 | * @return status code indicating success or failure
|
||
122 | */
|
||
123 | virtual LT_STATUS readBegin(const LTIScene& scene);
|
||
124 | |||
125 | /**
|
||
126 | * finish strip-based read
|
||
127 | *
|
||
128 | * This function is called by read() after readStrip() is called. It
|
||
129 | * should not be called directly except in certain rare circumstances.
|
||
130 | *
|
||
131 | * Derived classes should not override.
|
||
132 | *
|
||
133 | * @return status code indicating success or failure
|
||
134 | */
|
||
135 | virtual LT_STATUS readEnd(); |
||
136 | |||
137 | /**
|
||
138 | * read a strip from the image
|
||
139 | *
|
||
140 | * This function decodes a scene from the image and puts the pixels into the
|
||
141 | * given buffer. It is called by read(), and should not be called directly
|
||
142 | * except in certain rare circumstances.
|
||
143 | *
|
||
144 | * The scene must lie within the boundaries of the image.
|
||
145 | *
|
||
146 | * Derived classes should not override this method.
|
||
147 | *
|
||
148 | * Derived classes should use the progress and interrupt delegates when
|
||
149 | * the read operation can be expected to take a significant amount of time
|
||
150 | * to complete.
|
||
151 | *
|
||
152 | * @param buffer the buffer to read the pixels into
|
||
153 | * @param stripScene the scene for this strip being decoded
|
||
154 | * @return status code indicating success or failure
|
||
155 | */
|
||
156 | virtual LT_STATUS readStrip(LTISceneBuffer& buffer, const LTIScene& stripScene);
|
||
157 | |||
158 | |||
159 | /**
|
||
160 | * get strip height
|
||
161 | *
|
||
162 | * Returns the strip height used in read() calls.
|
||
163 | *
|
||
164 | * Reader classes should set this. Filter classes should inherit the
|
||
165 | * stripheight of their pipeline predecessor. A writer class will
|
||
166 | * force the stripheight of the pipeline to match its stripheight.
|
||
167 | *
|
||
168 | * @return the strip height
|
||
169 | */
|
||
170 | virtual lt_uint32 getStripHeight() const = 0; |
||
171 | |||
172 | /**
|
||
173 | * set the strip height
|
||
174 | *
|
||
175 | * Sets the strip height to be used in decoding. This is the number
|
||
176 | * of rows to be decoded in each strip of the read() sequence.
|
||
177 | *
|
||
178 | * Reader classes should implement this directly. (LTIImageFilter
|
||
179 | * implements this as a call to setStripHeight() on the previous stage.)
|
||
180 | *
|
||
181 | * @param stripHeight the number of rows to decode at one time
|
||
182 | * @return status code indicating success or failure
|
||
183 | */
|
||
184 | virtual LT_STATUS setStripHeight(lt_uint32 stripHeight) = 0;
|
||
185 | |||
186 | virtual lt_int64 getPhysicalFileSize() const = 0; |
||
187 | |||
188 | |||
189 | /**
|
||
190 | * get the cost to encode this scene
|
||
191 | *
|
||
192 | * Returns the "cost" to encode this scene, for use by those image writers
|
||
193 | * which have usage metering enabled. The typical cost is equal to the
|
||
194 | * nominal image size (width * height * numBands * bytesPerSample), but
|
||
195 | * this is overridden for special situations, e.g. the mosaic filter.
|
||
196 | *
|
||
197 | * @param scene the scene to be charged for
|
||
198 | * @return the cost to encode the given scene
|
||
199 | */
|
||
200 | virtual lt_int64 getEncodingCost(const LTIScene& scene) const=0; |
||
201 | |||
202 | /**
|
||
203 | * get the underlying scene to be used
|
||
204 | *
|
||
205 | * Get the scene that will be sent to the underlying LTIImageReader. This
|
||
206 | * is useful in some complex pipelines.
|
||
207 | *
|
||
208 | * @param decodeScene the scene that would be given to read()
|
||
209 | * @param readerScene the scene that is the actual scene passed
|
||
210 | * the underlying image reader
|
||
211 | * @return true if readerScene is not empty
|
||
212 | */
|
||
213 | virtual bool getReaderScene(const LTIScene &decodeScene, |
||
214 | LTIScene &readerScene) const = 0; |
||
215 | |||
216 | /**
|
||
217 | * get number of strips in scene
|
||
218 | *
|
||
219 | * After readBegin() has been called, this will return the number of
|
||
220 | * strips in the given scene.
|
||
221 | *
|
||
222 | * @return number of strips in the current scene
|
||
223 | */
|
||
224 | virtual lt_uint32 getNumStrips() const;
|
||
225 | |||
226 | /**
|
||
227 | * get a strip for current scene
|
||
228 | *
|
||
229 | * After readBegin() has been called, this function can be used to return
|
||
230 | * the scene corresponding to the given strip number for the current scene
|
||
231 | * being decoded.
|
||
232 | *
|
||
233 | * @param stripNumber the strip to compute the scene for
|
||
234 | * @return the scene representing the strip
|
||
235 | */
|
||
236 | virtual LTIScene getStripScene(lt_uint32 stripNumber) const;
|
||
237 | |||
238 | protected:
|
||
239 | /**
|
||
240 | * fill the background of the scene
|
||
241 | *
|
||
242 | * This function sets the buffer to the background pixel, if any.
|
||
243 | *
|
||
244 | * Derived classes may choose to override this.
|
||
245 | *
|
||
246 | * @param scene the region (and scale) of the image to be read
|
||
247 | * @param buffer the buffer to read the pixels into
|
||
248 | * @return status code indicating success or failure
|
||
249 | */
|
||
250 | LT_STATUS fillBackground(const LTIScene& scene,
|
||
251 | LTISceneBuffer& buffer); |
||
252 | |||
253 | /**
|
||
254 | * fill the scene to given pixel
|
||
255 | *
|
||
256 | * This function sets the buffer to the given pixel.
|
||
257 | *
|
||
258 | * Derived classes may choose to override this.
|
||
259 | *
|
||
260 | * @param scene the region (and scale) of the image to be read
|
||
261 | * @param buffer the buffer to read the pixels into
|
||
262 | * @return status code indicating success or failure
|
||
263 | */
|
||
264 | LT_STATUS fillBackground(const LTIScene& scene,
|
||
265 | LTISceneBuffer& buffer, |
||
266 | const LTIPixel&);
|
||
267 | |||
268 | /**
|
||
269 | * read a strip from the image
|
||
270 | *
|
||
271 | * This function is called by readStrip() to implement the actual
|
||
272 | * class-specific work for decoding a strip of the scene.
|
||
273 | *
|
||
274 | * Derived classes must implement this function.
|
||
275 | *
|
||
276 | * This function should never be called directly.
|
||
277 | *
|
||
278 | * @param stripBuffer the buffer to read the pixels into
|
||
279 | * @param stripScene the scene for this strip being decoded
|
||
280 | * @return status code indicating success or failure
|
||
281 | */
|
||
282 | virtual LT_STATUS decodeStrip(LTISceneBuffer& stripBuffer, const LTIScene& stripScene) =0; |
||
283 | |||
284 | /**
|
||
285 | * start strip-based read
|
||
286 | *
|
||
287 | * This function is called by readBegin() to start the actual
|
||
288 | * class-specific work for decoding a scene.
|
||
289 | *
|
||
290 | * Derived classes must implement this function.
|
||
291 | *
|
||
292 | * This function should never be called directly.
|
||
293 | *
|
||
294 | * @param scene the full scene to be read
|
||
295 | * @return status code indicating success or failure
|
||
296 | */
|
||
297 | virtual LT_STATUS decodeBegin(const LTIScene& scene) =0; |
||
298 | |||
299 | /**
|
||
300 | * finish strip-based read
|
||
301 | *
|
||
302 | * This function is called by readEnd() to complete the actual
|
||
303 | * class-specific work for decoding a scene.
|
||
304 | *
|
||
305 | * Derived classes must implement this function.
|
||
306 | *
|
||
307 | * This function should never be called directly.
|
||
308 | *
|
||
309 | * @return status code indicating success or failure
|
||
310 | */
|
||
311 | virtual LT_STATUS decodeEnd() =0;
|
||
312 | |||
313 | /**
|
||
314 | * get progress delegate
|
||
315 | *
|
||
316 | * This function returns the object's progress delegate.
|
||
317 | *
|
||
318 | * The function will return NULL if no delegate has been set.
|
||
319 | *
|
||
320 | * Derived classes should call this method from within their read()
|
||
321 | * methods so that they can inform the user of the progress of the read
|
||
322 | * operation.
|
||
323 | *
|
||
324 | * @return a pointer to the delegate object (or NULL if no delegate has been set)
|
||
325 | */
|
||
326 | virtual LTIProgressDelegate* getProgressDelegate() const;
|
||
327 | |||
328 | /**
|
||
329 | * get interrupt delegate
|
||
330 | *
|
||
331 | * This function returns the object's interrupt delegate.
|
||
332 | *
|
||
333 | * The function will return NULL if no delegate has been set.
|
||
334 | *
|
||
335 | * Derived classes should call this method from within their read()
|
||
336 | * methods so that they can determine if the user has requested that the read
|
||
337 | * operation should be aborted.
|
||
338 | *
|
||
339 | * @return a pointer to the delegate object (or NULL if no delegate has been set)
|
||
340 | */
|
||
341 | virtual LTIInterruptDelegate* getInterruptDelegate() const;
|
||
342 | |||
343 | private:
|
||
344 | LT_STATUS validateReadRequest(const LTIScene& fullScene,
|
||
345 | LTISceneBuffer& fullData) const;
|
||
346 | |||
347 | LT_STATUS checkDelegates(const LTIScene*, bool); |
||
348 | |||
349 | //
|
||
350 | // helper functions
|
||
351 | //
|
||
352 | class StripMarcher; |
||
353 | StripMarcher* m_stripMarcher; |
||
354 | |||
355 | void getCurrentStripProps(const LTISceneBuffer& fullProps, |
||
356 | const LTIScene&,
|
||
357 | lt_uint32& xOffset, |
||
358 | lt_uint32& yOffset, |
||
359 | lt_uint32& windowWidth, |
||
360 | lt_uint32& windowHeight) const;
|
||
361 | |||
362 | LTIScene *m_fullScene; |
||
363 | |||
364 | LTIProgressDelegate* m_progressDelegate; |
||
365 | LTIInterruptDelegate* m_interruptDelegate; |
||
366 | |||
367 | // nope
|
||
368 | LTIImageStage(LTIImageStage&); |
||
369 | LTIImageStage& operator=(const LTIImageStage&);
|
||
370 | }; |
||
371 | |||
372 | |||
373 | LT_END_NAMESPACE(LizardTech) |
||
374 | |||
375 | #if defined(LT_COMPILER_MS)
|
||
376 | #pragma warning(pop)
|
||
377 | #endif
|
||
378 | |||
379 | #endif // LTI_IMAGESTAGE_H |