corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /* |
2 | * CVS identifier: |
||
3 | * |
||
4 | * $Id: InvWTAdapter.java,v 1.14 2002/07/25 15:11:03 grosbois Exp $ |
||
5 | * |
||
6 | * Class: InvWTAdapter |
||
7 | * |
||
8 | * Description: <short description of class> |
||
9 | * |
||
10 | * |
||
11 | * |
||
12 | * COPYRIGHT: |
||
13 | * |
||
14 | * This software module was originally developed by Raphaël Grosbois and |
||
15 | * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel |
||
16 | * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David |
||
17 | * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research |
||
18 | * Centre France S.A) in the course of development of the JPEG2000 |
||
19 | * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This |
||
20 | * software module is an implementation of a part of the JPEG 2000 |
||
21 | * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio |
||
22 | * Systems AB and Canon Research Centre France S.A (collectively JJ2000 |
||
23 | * Partners) agree not to assert against ISO/IEC and users of the JPEG |
||
24 | * 2000 Standard (Users) any of their rights under the copyright, not |
||
25 | * including other intellectual property rights, for this software module |
||
26 | * with respect to the usage by ISO/IEC and Users of this software module |
||
27 | * or modifications thereof for use in hardware or software products |
||
28 | * claiming conformance to the JPEG 2000 Standard. Those intending to use |
||
29 | * this software module in hardware or software products are advised that |
||
30 | * their use may infringe existing patents. The original developers of |
||
31 | * this software module, JJ2000 Partners and ISO/IEC assume no liability |
||
32 | * for use of this software module or modifications thereof. No license |
||
33 | * or right to this software module is granted for non JPEG 2000 Standard |
||
34 | * conforming products. JJ2000 Partners have full right to use this |
||
35 | * software module for his/her own purpose, assign or donate this |
||
36 | * software module to any third party and to inhibit third parties from |
||
37 | * using this software module for non JPEG 2000 Standard conforming |
||
38 | * products. This copyright notice must be included in all copies or |
||
39 | * derivative works of this software module. |
||
40 | * |
||
41 | * Copyright (c) 1999/2000 JJ2000 Partners. |
||
42 | * */ |
||
43 | using System; |
||
44 | using CSJ2K.j2k.decoder; |
||
45 | using CSJ2K.j2k.image; |
||
46 | namespace CSJ2K.j2k.wavelet.synthesis |
||
47 | { |
||
48 | |||
49 | /// <summary> This class provides default implementation of the methods in the 'InvWT' |
||
50 | /// interface. The source is always a 'MultiResImgData', which is a |
||
51 | /// multi-resolution image. The default implementation is just to return the |
||
52 | /// value of the source at the current image resolution level, which is set by |
||
53 | /// the 'setImgResLevel()' method. |
||
54 | /// |
||
55 | /// <p>This abstract class can be used to facilitate the development of other |
||
56 | /// classes that implement the 'InvWT' interface, because most of the trivial |
||
57 | /// methods are already implemented.</p> |
||
58 | /// |
||
59 | /// <p>If the default implementation of a method provided in this class does |
||
60 | /// not suit a particular implementation of the 'InvWT' interface, the method |
||
61 | /// can be overriden to implement the proper behaviour.</p> |
||
62 | /// |
||
63 | /// <p>If the 'setImgResLevel()' method is overriden then it is very important |
||
64 | /// that the one of this class is called from the overriding method, so that |
||
65 | /// the other methods in this class return the correct values.</p> |
||
66 | /// |
||
67 | /// </summary> |
||
68 | /// <seealso cref="InvWT"> |
||
69 | /// |
||
70 | /// </seealso> |
||
71 | public abstract class InvWTAdapter : InvWT |
||
72 | { |
||
73 | /// <summary> Sets the image reconstruction resolution level. A value of 0 means |
||
74 | /// reconstruction of an image with the lowest resolution (dimension) |
||
75 | /// available. |
||
76 | /// |
||
77 | /// <p>Note: Image resolution level indexes may differ from tile-component |
||
78 | /// resolution index. They are indeed indexed starting from the lowest |
||
79 | /// number of decomposition levels of each component of each tile.</p> |
||
80 | /// |
||
81 | /// <p>Example: For an image (1 tile) with 2 components (component 0 having |
||
82 | /// 2 decomposition levels and component 1 having 3 decomposition levels), |
||
83 | /// the first (tile-) component has 3 resolution levels and the second one |
||
84 | /// has 4 resolution levels, whereas the image has only 3 resolution levels |
||
85 | /// available.</p> |
||
86 | /// |
||
87 | /// </summary> |
||
88 | /// <param name="rl">The image resolution level. |
||
89 | /// |
||
90 | /// </param> |
||
91 | /// <returns> The vertical coordinate of the image origin in the canvas |
||
92 | /// system, on the reference grid. |
||
93 | /// |
||
94 | /// </returns> |
||
95 | virtual public int ImgResLevel |
||
96 | { |
||
97 | set |
||
98 | { |
||
99 | if (value < 0) |
||
100 | { |
||
101 | throw new System.ArgumentException("Resolution level index " + "cannot be negative."); |
||
102 | } |
||
103 | reslvl = value; |
||
104 | } |
||
105 | |||
106 | } |
||
107 | /// <summary> Returns the overall width of the current tile in pixels. This is the |
||
108 | /// tile's width without accounting for any component subsampling. This is |
||
109 | /// also referred as the reference grid width in the current tile. |
||
110 | /// |
||
111 | /// <p>This default implementation returns the value of the source at the |
||
112 | /// current reconstruction resolution level.</p> |
||
113 | /// |
||
114 | /// </summary> |
||
115 | /// <returns> The total current tile's width in pixels. |
||
116 | /// |
||
117 | /// </returns> |
||
118 | virtual public int TileWidth |
||
119 | { |
||
120 | get |
||
121 | { |
||
122 | // Retrieves the tile maximum resolution level index and request the |
||
123 | // width from the source module. |
||
124 | int tIdx = TileIdx; |
||
125 | int rl = 10000; |
||
126 | int mrl; |
||
127 | int nc = mressrc.NumComps; |
||
128 | for (int c = 0; c < nc; c++) |
||
129 | { |
||
130 | mrl = mressrc.getSynSubbandTree(tIdx, c).resLvl; |
||
131 | if (mrl < rl) |
||
132 | rl = mrl; |
||
133 | } |
||
134 | return mressrc.getTileWidth(rl); |
||
135 | } |
||
136 | |||
137 | } |
||
138 | /// <summary> Returns the overall height of the current tile in pixels. This |
||
139 | /// is the tile's height without accounting for any component |
||
140 | /// subsampling. This is also referred as the reference grid height |
||
141 | /// in the current tile. |
||
142 | /// |
||
143 | /// <p>This default implementation returns the value of the source at the |
||
144 | /// current reconstruction resolution level.</p> |
||
145 | /// |
||
146 | /// </summary> |
||
147 | /// <returns> The total current tile's height in pixels. |
||
148 | /// |
||
149 | /// </returns> |
||
150 | virtual public int TileHeight |
||
151 | { |
||
152 | get |
||
153 | { |
||
154 | // Retrieves the tile maximum resolution level index and request the |
||
155 | // height from the source module. |
||
156 | int tIdx = TileIdx; |
||
157 | int rl = 10000; |
||
158 | int mrl; |
||
159 | int nc = mressrc.NumComps; |
||
160 | for (int c = 0; c < nc; c++) |
||
161 | { |
||
162 | mrl = mressrc.getSynSubbandTree(tIdx, c).resLvl; |
||
163 | if (mrl < rl) |
||
164 | rl = mrl; |
||
165 | } |
||
166 | return mressrc.getTileHeight(rl); |
||
167 | } |
||
168 | |||
169 | } |
||
170 | /// <summary>Returns the nominal width of tiles </summary> |
||
171 | virtual public int NomTileWidth |
||
172 | { |
||
173 | get |
||
174 | { |
||
175 | return mressrc.NomTileWidth; |
||
176 | } |
||
177 | |||
178 | } |
||
179 | /// <summary>Returns the nominal height of tiles </summary> |
||
180 | virtual public int NomTileHeight |
||
181 | { |
||
182 | get |
||
183 | { |
||
184 | return mressrc.NomTileHeight; |
||
185 | } |
||
186 | |||
187 | } |
||
188 | /// <summary> Returns the overall width of the image in pixels. This is the |
||
189 | /// image's width without accounting for any component subsampling |
||
190 | /// or tiling. |
||
191 | /// |
||
192 | /// </summary> |
||
193 | /// <returns> The total image's width in pixels. |
||
194 | /// |
||
195 | /// </returns> |
||
196 | virtual public int ImgWidth |
||
197 | { |
||
198 | get |
||
199 | { |
||
200 | return mressrc.getImgWidth(reslvl); |
||
201 | } |
||
202 | |||
203 | } |
||
204 | /// <summary> Returns the overall height of the image in pixels. This is the |
||
205 | /// image's height without accounting for any component subsampling |
||
206 | /// or tiling. |
||
207 | /// |
||
208 | /// </summary> |
||
209 | /// <returns> The total image's height in pixels. |
||
210 | /// |
||
211 | /// </returns> |
||
212 | virtual public int ImgHeight |
||
213 | { |
||
214 | get |
||
215 | { |
||
216 | return mressrc.getImgHeight(reslvl); |
||
217 | } |
||
218 | |||
219 | } |
||
220 | /// <summary> Returns the number of components in the image. |
||
221 | /// |
||
222 | /// </summary> |
||
223 | /// <returns> The number of components in the image. |
||
224 | /// |
||
225 | /// </returns> |
||
226 | virtual public int NumComps |
||
227 | { |
||
228 | get |
||
229 | { |
||
230 | return mressrc.NumComps; |
||
231 | } |
||
232 | |||
233 | } |
||
234 | /// <summary> Returns the index of the current tile, relative to a standard scan-line |
||
235 | /// order. |
||
236 | /// |
||
237 | /// <p>This default implementation returns the value of the source.</p> |
||
238 | /// |
||
239 | /// </summary> |
||
240 | /// <returns> The current tile's index (starts at 0). |
||
241 | /// |
||
242 | /// </returns> |
||
243 | virtual public int TileIdx |
||
244 | { |
||
245 | get |
||
246 | { |
||
247 | return mressrc.TileIdx; |
||
248 | } |
||
249 | |||
250 | } |
||
251 | /// <summary> Returns the horizontal coordinate of the image origin, the top-left |
||
252 | /// corner, in the canvas system, on the reference grid. |
||
253 | /// |
||
254 | /// <p>This default implementation returns the value of the source at the |
||
255 | /// current reconstruction resolution level.</p> |
||
256 | /// |
||
257 | /// </summary> |
||
258 | /// <returns> The horizontal coordinate of the image origin in the canvas |
||
259 | /// system, on the reference grid. |
||
260 | /// |
||
261 | /// </returns> |
||
262 | virtual public int ImgULX |
||
263 | { |
||
264 | get |
||
265 | { |
||
266 | return mressrc.getImgULX(reslvl); |
||
267 | } |
||
268 | |||
269 | } |
||
270 | /// <summary> Returns the vertical coordinate of the image origin, the top-left |
||
271 | /// corner, in the canvas system, on the reference grid. |
||
272 | /// |
||
273 | /// <p>This default implementation returns the value of the source at the |
||
274 | /// current reconstruction resolution level.</p> |
||
275 | /// |
||
276 | /// </summary> |
||
277 | /// <returns> The vertical coordinate of the image origin in the canvas |
||
278 | /// system, on the reference grid. |
||
279 | /// |
||
280 | /// </returns> |
||
281 | virtual public int ImgULY |
||
282 | { |
||
283 | get |
||
284 | { |
||
285 | return mressrc.getImgULY(reslvl); |
||
286 | } |
||
287 | |||
288 | } |
||
289 | /// <summary>Returns the horizontal tile partition offset in the reference grid </summary> |
||
290 | virtual public int TilePartULX |
||
291 | { |
||
292 | get |
||
293 | { |
||
294 | return mressrc.TilePartULX; |
||
295 | } |
||
296 | |||
297 | } |
||
298 | /// <summary>Returns the vertical tile partition offset in the reference grid </summary> |
||
299 | virtual public int TilePartULY |
||
300 | { |
||
301 | get |
||
302 | { |
||
303 | return mressrc.TilePartULY; |
||
304 | } |
||
305 | |||
306 | } |
||
307 | |||
308 | /// <summary>The decoder specifications </summary> |
||
309 | protected internal DecoderSpecs decSpec; |
||
310 | |||
311 | /// <summary>The 'MultiResImgData' source </summary> |
||
312 | protected internal MultiResImgData mressrc; |
||
313 | |||
314 | /// <summary>The resquested image resolution level for reconstruction. </summary> |
||
315 | protected internal int reslvl; |
||
316 | |||
317 | /// <summary>The maximum available image resolution level </summary> |
||
318 | protected internal int maxImgRes; |
||
319 | |||
320 | /// <summary> Instantiates the 'InvWTAdapter' object using the specified |
||
321 | /// 'MultiResImgData' source. The reconstruction resolution level is set to |
||
322 | /// full resolution (i.e. the maximum resolution level). |
||
323 | /// |
||
324 | /// </summary> |
||
325 | /// <param name="src">From where to obtain the values to return |
||
326 | /// |
||
327 | /// </param> |
||
328 | /// <param name="decSpec">The decoder specifications |
||
329 | /// |
||
330 | /// </param> |
||
331 | protected internal InvWTAdapter(MultiResImgData src, DecoderSpecs decSpec) |
||
332 | { |
||
333 | mressrc = src; |
||
334 | this.decSpec = decSpec; |
||
335 | maxImgRes = decSpec.dls.Min; |
||
336 | } |
||
337 | |||
338 | /// <summary> Returns the component subsampling factor in the horizontal |
||
339 | /// direction, for the specified component. This is, approximately, |
||
340 | /// the ratio of dimensions between the reference grid and the |
||
341 | /// component itself, see the 'ImgData' interface desription for |
||
342 | /// details. |
||
343 | /// |
||
344 | /// </summary> |
||
345 | /// <param name="c">The index of the component (between 0 and N-1). |
||
346 | /// |
||
347 | /// </param> |
||
348 | /// <returns> The horizontal subsampling factor of component 'c'. |
||
349 | /// |
||
350 | /// </returns> |
||
351 | /// <seealso cref="jj2000.j2k.image.ImgData"> |
||
352 | /// |
||
353 | /// </seealso> |
||
354 | public virtual int getCompSubsX(int c) |
||
355 | { |
||
356 | return mressrc.getCompSubsX(c); |
||
357 | } |
||
358 | |||
359 | /// <summary> Returns the component subsampling factor in the vertical |
||
360 | /// direction, for the specified component. This is, approximately, |
||
361 | /// the ratio of dimensions between the reference grid and the |
||
362 | /// component itself, see the 'ImgData' interface desription for |
||
363 | /// details. |
||
364 | /// |
||
365 | /// </summary> |
||
366 | /// <param name="c">The index of the component (between 0 and N-1). |
||
367 | /// |
||
368 | /// </param> |
||
369 | /// <returns> The vertical subsampling factor of component 'c'. |
||
370 | /// |
||
371 | /// </returns> |
||
372 | /// <seealso cref="jj2000.j2k.image.ImgData"> |
||
373 | /// |
||
374 | /// </seealso> |
||
375 | public virtual int getCompSubsY(int c) |
||
376 | { |
||
377 | return mressrc.getCompSubsY(c); |
||
378 | } |
||
379 | |||
380 | /// <summary> Returns the width in pixels of the specified tile-component |
||
381 | /// |
||
382 | /// </summary> |
||
383 | /// <param name="t">Tile index |
||
384 | /// |
||
385 | /// </param> |
||
386 | /// <param name="c">The index of the component, from 0 to N-1. |
||
387 | /// |
||
388 | /// </param> |
||
389 | /// <returns> The width in pixels of component <tt>n</tt> in tile <tt>t</tt>. |
||
390 | /// |
||
391 | /// </returns> |
||
392 | public virtual int getTileCompWidth(int t, int c) |
||
393 | { |
||
394 | // Retrieves the tile-component maximum resolution index and gets the |
||
395 | // width from the source. |
||
396 | int rl = mressrc.getSynSubbandTree(t, c).resLvl; |
||
397 | return mressrc.getTileCompWidth(t, c, rl); |
||
398 | } |
||
399 | |||
400 | /// <summary> Returns the height in pixels of the specified tile-component. |
||
401 | /// |
||
402 | /// <p>This default implementation returns the value of the source at the |
||
403 | /// current reconstruction resolution level.</p> |
||
404 | /// |
||
405 | /// </summary> |
||
406 | /// <param name="t">The tile index. |
||
407 | /// |
||
408 | /// </param> |
||
409 | /// <param name="c">The index of the component, from 0 to N-1. |
||
410 | /// |
||
411 | /// </param> |
||
412 | /// <returns> The height in pixels of component <tt>n</tt> in tile |
||
413 | /// <tt>t</tt>. |
||
414 | /// |
||
415 | /// </returns> |
||
416 | public virtual int getTileCompHeight(int t, int c) |
||
417 | { |
||
418 | // Retrieves the tile-component maximum resolution index and gets the |
||
419 | // height from the source. |
||
420 | int rl = mressrc.getSynSubbandTree(t, c).resLvl; |
||
421 | return mressrc.getTileCompHeight(t, c, rl); |
||
422 | } |
||
423 | |||
424 | /// <summary> Returns the width in pixels of the specified component in the overall |
||
425 | /// image. |
||
426 | /// |
||
427 | /// </summary> |
||
428 | /// <param name="c">The index of the component, from 0 to N-1. |
||
429 | /// |
||
430 | /// </param> |
||
431 | /// <returns> The width in pixels of component <tt>c</tt> in the overall |
||
432 | /// image. |
||
433 | /// |
||
434 | /// </returns> |
||
435 | public virtual int getCompImgWidth(int c) |
||
436 | { |
||
437 | // Retrieves the component maximum resolution index and gets the width |
||
438 | // from the source module. |
||
439 | int rl = decSpec.dls.getMinInComp(c); |
||
440 | return mressrc.getCompImgWidth(c, rl); |
||
441 | } |
||
442 | |||
443 | /// <summary> Returns the height in pixels of the specified component in the overall |
||
444 | /// image. |
||
445 | /// |
||
446 | /// <p>This default implementation returns the value of the source at the |
||
447 | /// current reconstruction resolution level.</p> |
||
448 | /// |
||
449 | /// </summary> |
||
450 | /// <param name="c">The index of the component, from 0 to N-1. |
||
451 | /// |
||
452 | /// </param> |
||
453 | /// <returns> The height in pixels of component <tt>n</tt> in the overall |
||
454 | /// image. |
||
455 | /// |
||
456 | /// </returns> |
||
457 | public virtual int getCompImgHeight(int c) |
||
458 | { |
||
459 | // Retrieves the component maximum resolution index and gets the |
||
460 | // height from the source module. |
||
461 | int rl = decSpec.dls.getMinInComp(c); |
||
462 | return mressrc.getCompImgHeight(c, rl); |
||
463 | } |
||
464 | |||
465 | /// <summary> Changes the current tile, given the new indices. An |
||
466 | /// IllegalArgumentException is thrown if the coordinates do not correspond |
||
467 | /// to a valid tile. |
||
468 | /// |
||
469 | /// <p>This default implementation calls the same method on the source.</p> |
||
470 | /// |
||
471 | /// </summary> |
||
472 | /// <param name="x">The horizontal index of the tile. |
||
473 | /// |
||
474 | /// </param> |
||
475 | /// <param name="y">The vertical index of the new tile. |
||
476 | /// |
||
477 | /// </param> |
||
478 | public virtual void setTile(int x, int y) |
||
479 | { |
||
480 | mressrc.setTile(x, y); |
||
481 | } |
||
482 | |||
483 | /// <summary> Advances to the next tile, in standard scan-line order (by rows then |
||
484 | /// columns). An NoNextElementException is thrown if the current tile is |
||
485 | /// the last one (i.e. there is no next tile). |
||
486 | /// |
||
487 | /// <p>This default implementation calls the same method on the source.</p> |
||
488 | /// |
||
489 | /// </summary> |
||
490 | public virtual void nextTile() |
||
491 | { |
||
492 | mressrc.nextTile(); |
||
493 | } |
||
494 | |||
495 | /// <summary> Returns the indixes of the current tile. These are the horizontal and |
||
496 | /// vertical indexes of the current tile. |
||
497 | /// |
||
498 | /// <p>This default implementation returns the value of the source.</p> |
||
499 | /// |
||
500 | /// </summary> |
||
501 | /// <param name="co">If not null this object is used to return the information. If |
||
502 | /// null a new one is created and returned. |
||
503 | /// |
||
504 | /// </param> |
||
505 | /// <returns> The current tile's indices (vertical and horizontal indexes). |
||
506 | /// |
||
507 | /// </returns> |
||
508 | public virtual Coord getTile(Coord co) |
||
509 | { |
||
510 | return mressrc.getTile(co); |
||
511 | } |
||
512 | |||
513 | /// <summary> Returns the horizontal coordinate of the upper-left corner of the |
||
514 | /// specified component in the current tile. |
||
515 | /// |
||
516 | /// </summary> |
||
517 | /// <param name="c">The component index. |
||
518 | /// |
||
519 | /// </param> |
||
520 | public virtual int getCompULX(int c) |
||
521 | { |
||
522 | // Find tile-component maximum resolution index and gets information |
||
523 | // from the source module. |
||
524 | int tIdx = TileIdx; |
||
525 | int rl = mressrc.getSynSubbandTree(tIdx, c).resLvl; |
||
526 | return mressrc.getResULX(c, rl); |
||
527 | } |
||
528 | |||
529 | /// <summary> Returns the vertical coordinate of the upper-left corner of the |
||
530 | /// specified component in the current tile. |
||
531 | /// |
||
532 | /// </summary> |
||
533 | /// <param name="c">The component index. |
||
534 | /// |
||
535 | /// </param> |
||
536 | public virtual int getCompULY(int c) |
||
537 | { |
||
538 | // Find tile-component maximum resolution index and gets information |
||
539 | // from the source module. |
||
540 | int tIdx = TileIdx; |
||
541 | int rl = mressrc.getSynSubbandTree(tIdx, c).resLvl; |
||
542 | return mressrc.getResULY(c, rl); |
||
543 | } |
||
544 | |||
545 | /// <summary> Returns the number of tiles in the horizontal and vertical directions. |
||
546 | /// |
||
547 | /// <p>This default implementation returns the value of the source.</p> |
||
548 | /// |
||
549 | /// </summary> |
||
550 | /// <param name="co">If not null this object is used to return the information. If |
||
551 | /// null a new one is created and returned. |
||
552 | /// |
||
553 | /// </param> |
||
554 | /// <returns> The number of tiles in the horizontal (Coord.x) and vertical |
||
555 | /// (Coord.y) directions. |
||
556 | /// |
||
557 | /// </returns> |
||
558 | public virtual Coord getNumTiles(Coord co) |
||
559 | { |
||
560 | return mressrc.getNumTiles(co); |
||
561 | } |
||
562 | |||
563 | /// <summary> Returns the total number of tiles in the image. |
||
564 | /// |
||
565 | /// <p>This default implementation returns the value of the source.</p> |
||
566 | /// |
||
567 | /// </summary> |
||
568 | /// <returns> The total number of tiles in the image. |
||
569 | /// |
||
570 | /// </returns> |
||
571 | public virtual int getNumTiles() |
||
572 | { |
||
573 | return mressrc.getNumTiles(); |
||
574 | } |
||
575 | |||
576 | /// <summary> Returns the specified synthesis subband tree |
||
577 | /// |
||
578 | /// </summary> |
||
579 | /// <param name="t">Tile index. |
||
580 | /// |
||
581 | /// </param> |
||
582 | /// <param name="c">Component index. |
||
583 | /// |
||
584 | /// </param> |
||
585 | public virtual SubbandSyn getSynSubbandTree(int t, int c) |
||
586 | { |
||
587 | return mressrc.getSynSubbandTree(t, c); |
||
588 | } |
||
589 | public abstract bool isReversible(int param1, int param2); |
||
590 | public abstract int getNomRangeBits(int param1); |
||
591 | public abstract int getImplementationType(int param1); |
||
592 | } |
||
593 | } |