corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * CVS identifier:
3 *
4 * $Id: BitstreamReaderAgent.java,v 1.27 2002/07/25 14:59:32 grosbois Exp $
5 *
6 * Class: BitstreamReaderAgent
7 *
8 * Description: The generic interface for bit stream
9 * transport agents.
10 *
11 *
12 *
13 * COPYRIGHT:
14 *
15 * This software module was originally developed by Raphaël Grosbois and
16 * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
17 * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
18 * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
19 * Centre France S.A) in the course of development of the JPEG2000
20 * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
21 * software module is an implementation of a part of the JPEG 2000
22 * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
23 * Systems AB and Canon Research Centre France S.A (collectively JJ2000
24 * Partners) agree not to assert against ISO/IEC and users of the JPEG
25 * 2000 Standard (Users) any of their rights under the copyright, not
26 * including other intellectual property rights, for this software module
27 * with respect to the usage by ISO/IEC and Users of this software module
28 * or modifications thereof for use in hardware or software products
29 * claiming conformance to the JPEG 2000 Standard. Those intending to use
30 * this software module in hardware or software products are advised that
31 * their use may infringe existing patents. The original developers of
32 * this software module, JJ2000 Partners and ISO/IEC assume no liability
33 * for use of this software module or modifications thereof. No license
34 * or right to this software module is granted for non JPEG 2000 Standard
35 * conforming products. JJ2000 Partners have full right to use this
36 * software module for his/her own purpose, assign or donate this
37 * software module to any third party and to inhibit third parties from
38 * using this software module for non JPEG 2000 Standard conforming
39 * products. This copyright notice must be included in all copies or
40 * derivative works of this software module.
41 *
42 * Copyright (c) 1999/2000 JJ2000 Partners.
43 * */
44 using System;
45 using CSJ2K.j2k.quantization.dequantizer;
46 using CSJ2K.j2k.wavelet.synthesis;
47 using CSJ2K.j2k.entropy.decoder;
48 using CSJ2K.j2k.codestream;
49 using CSJ2K.j2k.wavelet;
50 using CSJ2K.j2k.decoder;
51 using CSJ2K.j2k.image;
52 using CSJ2K.j2k.util;
53 using CSJ2K.j2k.io;
54 using CSJ2K.j2k;
55 namespace CSJ2K.j2k.codestream.reader
56 {
57  
58 /// <summary> This is the generic interface for bit stream reader agents. A bit stream
59 /// reader agent is an entity that allows reading from a bit stream and
60 /// requesting compressed code-blocks. It can be a simple file reader, or a
61 /// network connection, or anything else.
62 ///
63 /// <p>The bit stream reader agent allows to make request for compressed block
64 /// data in any order. The amount of data returned would normally depend on the
65 /// data available at the time of the request, be it from a file or from a
66 /// network connection.</p>
67 ///
68 /// <p>The bit stream reader agent has the notion of a current tile, and
69 /// coordinates are relative to the current tile, where applicable.</p>
70 ///
71 /// <p>Resolution level 0 is the lowest resolution level, i.e. the LL subband
72 /// alone.</p>
73 ///
74 /// </summary>
75 public abstract class BitstreamReaderAgent : CodedCBlkDataSrcDec
76 {
77 /// <summary> Returns the horizontal code-block partition origin. Allowable values
78 /// are 0 and 1, nothing else.
79 ///
80 /// </summary>
81 virtual public int CbULX
82 {
83 get
84 {
85 return hd.CbULX;
86 }
87  
88 }
89 /// <summary> Returns the vertical code-block partition origin. Allowable values are
90 /// 0 and 1, nothing else.
91 ///
92 /// </summary>
93 virtual public int CbULY
94 {
95 get
96 {
97 return hd.CbULY;
98 }
99  
100 }
101 /// <summary> Returns the number of components in the image.
102 ///
103 /// </summary>
104 /// <returns> The number of components in the image.
105 ///
106 /// </returns>
107 virtual public int NumComps
108 {
109 get
110 {
111 return nc;
112 }
113  
114 }
115 /// <summary> Returns the index of the current tile, relative to a standard scan-line
116 /// order.
117 ///
118 /// </summary>
119 /// <returns> The current tile's index (starts at 0).
120 ///
121 /// </returns>
122 virtual public int TileIdx
123 {
124 get
125 {
126 return ctY * ntX + ctX;
127 }
128  
129 }
130 /// <summary> Returns the parameters that are used in this class and implementing
131 /// classes. It returns a 2D String array. Each of the 1D arrays is for a
132 /// different option, and they have 3 elements. The first element is the
133 /// option name, the second one is the synopsis and the third one is a long
134 /// description of what the parameter is. The synopsis or description may
135 /// be 'null', in which case it is assumed that there is no synopsis or
136 /// description of the option, respectively. Null may be returned if no
137 /// options are supported.
138 ///
139 /// </summary>
140 /// <returns> the options name, their synopsis and their explanation, or null
141 /// if no options are supported.
142 ///
143 /// </returns>
144 public static System.String[][] ParameterInfo
145 {
146 get
147 {
148 return pinfo;
149 }
150  
151 }
152 /// <summary> Returns the image resolution level to reconstruct from the
153 /// codestream. This value cannot be computed before every main and tile
154 /// headers are read.
155 ///
156 /// </summary>
157 /// <returns> The image resolution level
158 ///
159 /// </returns>
160 virtual public int ImgRes
161 {
162 get
163 {
164 return targetRes;
165 }
166  
167 }
168 /// <summary> Return the target decoding rate in bits per pixel.
169 ///
170 /// </summary>
171 /// <returns> Target decoding rate in bpp.
172 ///
173 /// </returns>
174 virtual public float TargetRate
175 {
176 get
177 {
178 return trate;
179 }
180  
181 }
182 /// <summary> Return the actual decoding rate in bits per pixel.
183 ///
184 /// </summary>
185 /// <returns> Actual decoding rate in bpp.
186 ///
187 /// </returns>
188 virtual public float ActualRate
189 {
190 get
191 {
192 arate = anbytes * 8f / hd.MaxCompImgWidth / hd.MaxCompImgHeight;
193 return arate;
194 }
195  
196 }
197 /// <summary> Return the target number of read bytes.
198 ///
199 /// </summary>
200 /// <returns> Target decoding rate in bytes.
201 ///
202 /// </returns>
203 virtual public int TargetNbytes
204 {
205 get
206 {
207 return tnbytes;
208 }
209  
210 }
211 /// <summary> Return the actual number of read bytes.
212 ///
213 /// </summary>
214 /// <returns> Actual decoding rate in bytes.
215 ///
216 /// </returns>
217 virtual public int ActualNbytes
218 {
219 get
220 {
221 return anbytes;
222 }
223  
224 }
225 /// <summary>Returns the horizontal offset of tile partition </summary>
226 virtual public int TilePartULX
227 {
228 get
229 {
230 return hd.getTilingOrigin(null).x;
231 }
232  
233 }
234 /// <summary>Returns the vertical offset of tile partition </summary>
235 virtual public int TilePartULY
236 {
237 get
238 {
239 return hd.getTilingOrigin(null).y;
240 }
241  
242 }
243 /// <summary>Returns the nominal tile width </summary>
244 virtual public int NomTileWidth
245 {
246 get
247 {
248 return hd.NomTileWidth;
249 }
250  
251 }
252 /// <summary>Returns the nominal tile height </summary>
253 virtual public int NomTileHeight
254 {
255 get
256 {
257 return hd.NomTileHeight;
258 }
259  
260 }
261  
262 /// <summary>The decoder specifications </summary>
263 protected internal DecoderSpecs decSpec;
264  
265 /// <summary> Whether or not the components in the current tile uses a derived
266 /// quantization step size (only relevant in non reversible quantization
267 /// mode). This field is actualized by the setTile method in
268 /// FileBitstreamReaderAgent.
269 ///
270 /// </summary>
271 /// <seealso cref="FileBitstreamReaderAgent.initSubbandsFields">
272 ///
273 /// </seealso>
274 protected internal bool[] derived = null;
275  
276 /// <summary> Number of guard bits off all component in the current tile. This field
277 /// is actualized by the setTile method in FileBitstreamReaderAgent.
278 ///
279 /// </summary>
280 /// <seealso cref="FileBitstreamReaderAgent.initSubbandsFields">
281 ///
282 /// </seealso>
283 protected internal int[] gb = null;
284  
285 /// <summary> Dequantization parameters of all subbands and all components in the
286 /// current tile. The value is actualized by the setTile method in
287 /// FileBitstreamReaderAgent.
288 ///
289 /// </summary>
290 /// <seealso cref="FileBitstreamReaderAgent.initSubbandsFields">
291 ///
292 /// </seealso>
293 protected internal StdDequantizerParams[] params_Renamed = null;
294  
295 /// <summary>The prefix for bit stream reader options: 'B' </summary>
296 public const char OPT_PREFIX = 'B';
297  
298 /// <summary>The list of parameters that is accepted by the bit stream
299 /// readers. They start with 'B'.
300 /// </summary>
301 //UPGRADE_NOTE: Final was removed from the declaration of 'pinfo'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
302 private static readonly System.String[][] pinfo = null;
303  
304 /// <summary> The maximum number of decompostion levels for each component of the
305 /// current tile. It means that component c has mdl[c]+1 resolution levels
306 /// (indexed from 0 to mdl[c])
307 ///
308 /// </summary>
309 protected internal int[] mdl;
310  
311 /// <summary>The number of components </summary>
312 //UPGRADE_NOTE: Final was removed from the declaration of 'nc '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
313 protected internal int nc;
314  
315 /// <summary>Image resolution level to generate </summary>
316 protected internal int targetRes;
317  
318 /// <summary> The subband trees for each component in the current tile. Each element
319 /// in the array is the root element of the subband tree for a
320 /// component. The number of magnitude bits in each subband (magBits member
321 /// variable) is not initialized.
322 ///
323 /// </summary>
324 protected internal SubbandSyn[] subbTrees;
325  
326 /// <summary>The image width on the hi-res reference grid </summary>
327 //UPGRADE_NOTE: Final was removed from the declaration of 'imgW '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
328 protected internal int imgW;
329  
330 /// <summary>The image width on the hi-res reference grid </summary>
331 //UPGRADE_NOTE: Final was removed from the declaration of 'imgH '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
332 protected internal int imgH;
333  
334 /// <summary>The horizontal coordinate of the image origin in the canvas system, on
335 /// the reference grid.
336 /// </summary>
337 //UPGRADE_NOTE: Final was removed from the declaration of 'ax '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
338 protected internal int ax;
339  
340 /// <summary>The vertical coordinate of the image origin in the canvas system, on
341 /// the reference grid.
342 /// </summary>
343 //UPGRADE_NOTE: Final was removed from the declaration of 'ay '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
344 protected internal int ay;
345  
346 /// <summary>The horizontal coordinate of the tiling origin in the canvas system, on
347 /// the reference grid.
348 /// </summary>
349 //UPGRADE_NOTE: Final was removed from the declaration of 'px '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
350 protected internal int px;
351  
352 /// <summary>The vertical coordinate of the tiling origin in the canvas system, on
353 /// the reference grid.
354 /// </summary>
355 //UPGRADE_NOTE: Final was removed from the declaration of 'py '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
356 protected internal int py;
357  
358 /// <summary>The horizontal offsets of the upper-left corner of the current tile
359 /// (not active tile) with respect to the canvas origin, in the component
360 /// hi-res grid, for each component.
361 /// </summary>
362 //UPGRADE_NOTE: Final was removed from the declaration of 'offX '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
363 protected internal int[] offX;
364  
365 /// <summary>The vertical offsets of the upper-left corner of the current tile (not
366 /// active tile) with respect to the canvas origin, in the component hi-res
367 /// grid, for each component.
368 /// </summary>
369 //UPGRADE_NOTE: Final was removed from the declaration of 'offY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
370 protected internal int[] offY;
371  
372 /// <summary>The horizontal coordinates of the upper-left corner of the active
373 /// tile, with respect to the canvas origin, in the component hi-res grid,
374 /// for each component.
375 /// </summary>
376 //UPGRADE_NOTE: Final was removed from the declaration of 'culx '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
377 protected internal int[] culx;
378  
379 /// <summary>The vertical coordinates of the upper-left corner of the active tile,
380 /// with respect to the canvas origin, in the component hi-res grid, for
381 /// each component.
382 /// </summary>
383 //UPGRADE_NOTE: Final was removed from the declaration of 'culy '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
384 protected internal int[] culy;
385  
386 /// <summary>The nominal tile width, in the hi-res reference grid </summary>
387 //UPGRADE_NOTE: Final was removed from the declaration of 'ntW '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
388 protected internal int ntW;
389  
390 /// <summary>The nominal tile height, in the hi-res reference grid </summary>
391 //UPGRADE_NOTE: Final was removed from the declaration of 'ntH '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
392 protected internal int ntH;
393  
394 /// <summary>The number of tile in the horizontal direction </summary>
395 //UPGRADE_NOTE: Final was removed from the declaration of 'ntX '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
396 protected internal int ntX;
397  
398 /// <summary>The number of tiles in the vertical direction </summary>
399 //UPGRADE_NOTE: Final was removed from the declaration of 'ntY '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
400 protected internal int ntY;
401  
402 /// <summary>The total number of tiles </summary>
403 //UPGRADE_NOTE: Final was removed from the declaration of 'nt '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
404 protected internal int nt;
405  
406 /// <summary>The current tile horizontal index </summary>
407 protected internal int ctX;
408  
409 /// <summary>The current tile vertical index </summary>
410 protected internal int ctY;
411  
412 /// <summary>The decoded bit stream header </summary>
413 //UPGRADE_NOTE: Final was removed from the declaration of 'hd '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
414 protected internal HeaderDecoder hd;
415  
416 /// <summary>Number of bytes targeted to be read </summary>
417 protected internal int tnbytes;
418  
419 /// <summary>Actual number of read bytes </summary>
420 protected internal int anbytes;
421  
422 /// <summary>Target decoding rate in bpp </summary>
423 protected internal float trate;
424  
425 /// <summary>Actual decoding rate in bpp </summary>
426 protected internal float arate;
427  
428 /// <summary> Initializes members of this class. This constructor takes a
429 /// HeaderDecoder object. This object must be initialized by the
430 /// constructor of the implementing class from the header of the bit
431 /// stream.
432 ///
433 /// </summary>
434 /// <param name="hd">The decoded header of the bit stream from where to initialize
435 /// the values.
436 ///
437 /// </param>
438 /// <param name="decSpec">The decoder specifications
439 ///
440 /// </param>
441 protected internal BitstreamReaderAgent(HeaderDecoder hd, DecoderSpecs decSpec)
442 {
443 Coord co;
444 //int i, j, max;
445  
446 this.decSpec = decSpec;
447 this.hd = hd;
448  
449 // Number of components
450 nc = hd.NumComps;
451 offX = new int[nc];
452 offY = new int[nc];
453 culx = new int[nc];
454 culy = new int[nc];
455  
456 // Image size and origin
457 imgW = hd.ImgWidth;
458 imgH = hd.ImgHeight;
459 ax = hd.ImgULX;
460 ay = hd.ImgULY;
461  
462 // Tiles
463 co = hd.getTilingOrigin(null);
464 px = co.x;
465 py = co.y;
466 ntW = hd.NomTileWidth;
467 ntH = hd.NomTileHeight;
468 ntX = (ax + imgW - px + ntW - 1) / ntW;
469 ntY = (ay + imgH - py + ntH - 1) / ntH;
470 nt = ntX * ntY;
471 }
472  
473 /// <summary> Returns the component subsampling factor in the horizontal direction,
474 /// for the specified component. This is, approximately, the ratio of
475 /// dimensions between the reference grid and the component itself, see the
476 /// 'ImgData' interface desription for details.
477 ///
478 /// </summary>
479 /// <param name="c">The index of the component (between 0 and N-1)
480 ///
481 /// </param>
482 /// <returns> The horizontal subsampling factor of component 'c'
483 ///
484 /// </returns>
485 /// <seealso cref="jj2000.j2k.image.ImgData">
486 ///
487 /// </seealso>
488 public int getCompSubsX(int c)
489 {
490 return hd.getCompSubsX(c);
491 }
492  
493 /// <summary> Returns the component subsampling factor in the vertical direction, for
494 /// the specified component. This is, approximately, the ratio of
495 /// dimensions between the reference grid and the component itself, see the
496 /// 'ImgData' interface desription for details.
497 ///
498 /// </summary>
499 /// <param name="c">The index of the component (between 0 and C-1)
500 ///
501 /// </param>
502 /// <returns> The vertical subsampling factor of component 'c'
503 ///
504 /// </returns>
505 /// <seealso cref="jj2000.j2k.image.ImgData">
506 ///
507 /// </seealso>
508 public virtual int getCompSubsY(int c)
509 {
510 return hd.getCompSubsY(c);
511 }
512  
513 /// <summary> Returns the overall width of the current tile in pixels for the given
514 /// (tile) resolution level. This is the tile's width without accounting
515 /// for any component subsampling.
516 ///
517 /// <p>Note: Tile resolution level indexes may be different from
518 /// tile-component resolution index. They are indeed indexed starting from
519 /// the lowest number of decomposition levels of each component of the
520 /// tile.</p>
521 ///
522 /// <p>For an image (1 tile) with 2 components (component 0 having 2
523 /// decomposition levels and component 1 having 3 decomposition levels),
524 /// the first (tile-)component has 3 resolution levels and the second one
525 /// has 4 resolution levels, whereas the tile has only 3 resolution levels
526 /// available.</p>
527 ///
528 /// </summary>
529 /// <param name="rl">The (tile) resolution level.
530 ///
531 /// </param>
532 /// <returns> The current tile's width in pixels.
533 ///
534 /// </returns>
535 public virtual int getTileWidth(int rl)
536 {
537 // The minumum number of decomposition levels between all the
538 // components
539 int mindl = decSpec.dls.getMinInTile(TileIdx);
540 if (rl > mindl)
541 {
542 throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one component in " + "tile: " + ctX + "x" + ctY);
543 }
544 int ctulx, ntulx;
545 int dl = mindl - rl; // Number of decomposition to obtain this
546 // resolution
547  
548 // Calculate starting X of current tile at hi-res
549 ctulx = (ctX == 0)?ax:px + ctX * ntW;
550 // Calculate starting X of next tile X-wise at hi-res
551 ntulx = (ctX < ntX - 1)?px + (ctX + 1) * ntW:ax + imgW;
552  
553 // The difference at the rl resolution level is the width
554 return (ntulx + (1 << dl) - 1) / (1 << dl) - (ctulx + (1 << dl) - 1) / (1 << dl);
555 }
556  
557 /// <summary> Returns the overall height of the current tile in pixels, for the given
558 /// resolution level. This is the tile's height without accounting for any
559 /// component subsampling.
560 ///
561 /// <p>Note: Tile resolution level indexes may be different from
562 /// tile-component resolution index. They are indeed indexed starting from
563 /// the lowest number of decomposition levels of each component of the
564 /// tile.</p>
565 ///
566 /// <p>For an image (1 tile) with 2 components (component 0 having 2
567 /// decomposition levels and component 1 having 3 decomposition levels),
568 /// the first (tile-)component has 3 resolution levels and the second one
569 /// has 4 resolution levels, whereas the tile has only 3 resolution levels
570 /// available.</p>
571 ///
572 /// </summary>
573 /// <param name="rl">The (tile) resolution level.
574 ///
575 /// </param>
576 /// <returns> The total current tile's height in pixels.
577 ///
578 /// </returns>
579 public virtual int getTileHeight(int rl)
580 {
581 // The minumum number of decomposition levels between all the
582 // components
583 int mindl = decSpec.dls.getMinInTile(TileIdx);
584 if (rl > mindl)
585 {
586 throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one component in" + " tile: " + ctX + "x" + ctY);
587 }
588  
589 int ctuly, ntuly;
590 int dl = mindl - rl; // Number of decomposition to obtain this
591 // resolution
592  
593 // Calculate starting Y of current tile at hi-res
594 ctuly = (ctY == 0)?ay:py + ctY * ntH;
595 // Calculate starting Y of next tile Y-wise at hi-res
596 ntuly = (ctY < ntY - 1)?py + (ctY + 1) * ntH:ay + imgH;
597 // The difference at the rl level is the height
598 return (ntuly + (1 << dl) - 1) / (1 << dl) - (ctuly + (1 << dl) - 1) / (1 << dl);
599 }
600  
601 /// <summary> Returns the overall width of the image in pixels, for the given (image)
602 /// resolution level. This is the image's width without accounting for any
603 /// component subsampling or tiling.
604 ///
605 /// <p>Note: Image resolution level indexes may differ from tile-component
606 /// resolution index. They are indeed indexed starting from the lowest
607 /// number of decomposition levels of each component of each tile.</p>
608 ///
609 /// <p>Example: For an image (1 tile) with 2 components (component 0 having
610 /// 2 decomposition levels and component 1 having 3 decomposition levels),
611 /// the first (tile-) component has 3 resolution levels and the second one
612 /// has 4 resolution levels, whereas the image has only 3 resolution levels
613 /// available.</p>
614 ///
615 /// </summary>
616 /// <param name="rl">The image resolution level.
617 ///
618 /// </param>
619 /// <returns> The total image's width in pixels.
620 ///
621 /// </returns>
622 public virtual int getImgWidth(int rl)
623 {
624 // The minimum number of decomposition levels of each
625 // tile-component
626 int mindl = decSpec.dls.Min;
627 if (rl > mindl)
628 {
629 throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one tile-component");
630 }
631 // Retrieve number of decomposition levels corresponding to
632 // this resolution level
633 int dl = mindl - rl;
634 return (ax + imgW + (1 << dl) - 1) / (1 << dl) - (ax + (1 << dl) - 1) / (1 << dl);
635 }
636  
637 /// <summary> Returns the overall height of the image in pixels, for the given
638 /// resolution level. This is the image's height without accounting for any
639 /// component subsampling or tiling.
640 ///
641 /// <p>Note: Image resolution level indexes may differ from tile-component
642 /// resolution index. They are indeed indexed starting from the lowest
643 /// number of decomposition levels of each component of each tile.</p>
644 ///
645 /// <p>Example: For an image (1 tile) with 2 components (component 0 having
646 /// 2 decomposition levels and component 1 having 3 decomposition levels),
647 /// the first (tile-) component has 3 resolution levels and the second one
648 /// has 4 resolution levels, whereas the image has only 3 resolution levels
649 /// available.</p>
650 ///
651 /// </summary>
652 /// <param name="rl">The image resolution level, from 0 to L.
653 ///
654 /// </param>
655 /// <returns> The total image's height in pixels.
656 ///
657 /// </returns>
658 public virtual int getImgHeight(int rl)
659 {
660 int mindl = decSpec.dls.Min;
661 if (rl > mindl)
662 {
663 throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one tile-component");
664 }
665 // Retrieve number of decomposition levels corresponding to this
666 // resolution level
667 int dl = mindl - rl;
668 return (ay + imgH + (1 << dl) - 1) / (1 << dl) - (ay + (1 << dl) - 1) / (1 << dl);
669 }
670  
671 /// <summary> Returns the horizontal coordinate of the image origin, the top-left
672 /// corner, in the canvas system, on the reference grid at the specified
673 /// resolution level.
674 ///
675 /// <p>Note: Image resolution level indexes may differ from tile-component
676 /// resolution index. They are indeed indexed starting from the lowest
677 /// number of decomposition levels of each component of each tile.</p>
678 ///
679 /// <p>Example: For an image (1 tile) with 2 components (component 0 having
680 /// 2 decomposition levels and component 1 having 3 decomposition levels),
681 /// the first (tile-) component has 3 resolution levels and the second one
682 /// has 4 resolution levels, whereas the image has only 3 resolution levels
683 /// available.</p>
684 ///
685 /// </summary>
686 /// <param name="rl">The resolution level, from 0 to L.
687 ///
688 /// </param>
689 /// <returns> The horizontal coordinate of the image origin in the canvas
690 /// system, on the reference grid.
691 ///
692 /// </returns>
693 public virtual int getImgULX(int rl)
694 {
695 int mindl = decSpec.dls.Min;
696 if (rl > mindl)
697 {
698 throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one tile-component");
699 }
700 // Retrieve number of decomposition levels corresponding to this
701 // resolution level
702 int dl = mindl - rl;
703 return (ax + (1 << dl) - 1) / (1 << dl);
704 }
705  
706 /// <summary> Returns the vertical coordinate of the image origin, the top-left
707 /// corner, in the canvas system, on the reference grid at the specified
708 /// resolution level.
709 ///
710 /// <p>Note: Image resolution level indexes may differ from tile-component
711 /// resolution index. They are indeed indexed starting from the lowest
712 /// number of decomposition levels of each component of each tile.</p>
713 ///
714 /// <p>Example: For an image (1 tile) with 2 components (component 0 having
715 /// 2 decomposition levels and component 1 having 3 decomposition levels),
716 /// the first (tile-) component has 3 resolution levels and the second one
717 /// has 4 resolution levels, whereas the image has only 3 resolution levels
718 /// available.</p>
719 ///
720 /// </summary>
721 /// <param name="rl">The resolution level, from 0 to L.
722 ///
723 /// </param>
724 /// <returns> The vertical coordinate of the image origin in the canvas
725 /// system, on the reference grid.
726 ///
727 /// </returns>
728 public virtual int getImgULY(int rl)
729 {
730 int mindl = decSpec.dls.Min;
731 if (rl > mindl)
732 {
733 throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one tile-component");
734 }
735 // Retrieve number of decomposition levels corresponding to this
736 // resolution level
737 int dl = mindl - rl;
738 return (ay + (1 << dl) - 1) / (1 << dl);
739 }
740  
741 /// <summary> Returns the width in pixels of the specified tile-component for the
742 /// given (tile-component) resolution level.
743 ///
744 /// </summary>
745 /// <param name="t">The tile index
746 ///
747 /// </param>
748 /// <param name="c">The index of the component, from 0 to N-1.
749 ///
750 /// </param>
751 /// <param name="rl">The resolution level, from 0 to L.
752 ///
753 /// </param>
754 /// <returns> The width in pixels of component <tt>c</tt> in tile <tt>t</tt>
755 /// for resolution level <tt>rl</tt>.
756 ///
757 /// </returns>
758 public int getTileCompWidth(int t, int c, int rl)
759 {
760 int tIdx = TileIdx;
761 if (t != tIdx)
762 {
763 throw new System.ApplicationException("Asking the tile-component width of a tile " + "different from the current one.");
764 }
765 int ntulx;
766 int dl = mdl[c] - rl;
767 // Calculate starting X of next tile X-wise at reference grid hi-res
768 ntulx = (ctX < ntX - 1)?px + (ctX + 1) * ntW:ax + imgW;
769 // Convert reference grid hi-res to component grid hi-res
770 ntulx = (ntulx + hd.getCompSubsX(c) - 1) / hd.getCompSubsX(c);
771 // Starting X of current tile at component grid hi-res is culx[c]
772 // The difference at the rl level is the width
773 return (ntulx + (1 << dl) - 1) / (1 << dl) - (culx[c] + (1 << dl) - 1) / (1 << dl);
774 }
775  
776 /// <summary> Returns the height in pixels of the specified tile-component for the
777 /// given (tile-component) resolution level.
778 ///
779 /// </summary>
780 /// <param name="t">The tile index.
781 ///
782 /// </param>
783 /// <param name="c">The index of the component, from 0 to N-1.
784 ///
785 /// </param>
786 /// <param name="rl">The resolution level, from 0 to L.
787 ///
788 /// </param>
789 /// <returns> The height in pixels of component <tt>c</tt> in the current
790 /// tile.
791 ///
792 /// </returns>
793 public int getTileCompHeight(int t, int c, int rl)
794 {
795 int tIdx = TileIdx;
796 if (t != tIdx)
797 {
798 throw new System.ApplicationException("Asking the tile-component width of a tile " + "different from the current one.");
799 }
800 int ntuly;
801 int dl = mdl[c] - rl; // Revert level indexation (0 is hi-res)
802 // Calculate starting Y of next tile Y-wise at reference grid hi-res
803 ntuly = (ctY < ntY - 1)?py + (ctY + 1) * ntH:ay + imgH;
804 // Convert reference grid hi-res to component grid hi-res
805 ntuly = (ntuly + hd.getCompSubsY(c) - 1) / hd.getCompSubsY(c);
806 // Starting Y of current tile at component grid hi-res is culy[c]
807 // The difference at the rl level is the height
808 return (ntuly + (1 << dl) - 1) / (1 << dl) - (culy[c] + (1 << dl) - 1) / (1 << dl);
809 }
810  
811 /// <summary> Returns the width in pixels of the specified component in the overall
812 /// image, for the given (component) resolution level.
813 ///
814 /// <p>Note: Component resolution level indexes may differ from
815 /// tile-component resolution index. They are indeed indexed starting from
816 /// the lowest number of decomposition levels of same component of each
817 /// tile.</p>
818 ///
819 /// <p>Example: For an image (2 tiles) with 1 component (tile 0 having 2
820 /// decomposition levels and tile 1 having 3 decomposition levels), the
821 /// first tile(-component) has 3 resolution levels and the second one has 4
822 /// resolution levels, whereas the component has only 3 resolution levels
823 /// available.</p>
824 ///
825 /// </summary>
826 /// <param name="c">The index of the component, from 0 to N-1.
827 ///
828 /// </param>
829 /// <param name="rl">The resolution level, from 0 to L.
830 ///
831 /// </param>
832 /// <returns> The width in pixels of component <tt>c</tt> in the overall
833 /// image.
834 ///
835 /// </returns>
836 public int getCompImgWidth(int c, int rl)
837 {
838 int sx, ex;
839 int dl = decSpec.dls.getMinInComp(c) - rl;
840 // indexation (0 is hi-res)
841 // Calculate image starting x at component hi-res grid
842 sx = (ax + hd.getCompSubsX(c) - 1) / hd.getCompSubsX(c);
843 // Calculate image ending (excluding) x at component hi-res grid
844 ex = (ax + imgW + hd.getCompSubsX(c) - 1) / hd.getCompSubsX(c);
845 // The difference at the rl level is the width
846 return (ex + (1 << dl) - 1) / (1 << dl) - (sx + (1 << dl) - 1) / (1 << dl);
847 }
848  
849 /// <summary> Returns the height in pixels of the specified component in the overall
850 /// image, for the given (component) resolution level.
851 ///
852 /// <p>Note: Component resolution level indexes may differ from
853 /// tile-component resolution index. They are indeed indexed starting from
854 /// the lowest number of decomposition levels of same component of each
855 /// tile.</p>
856 ///
857 /// <p>Example: For an image (2 tiles) with 1 component (tile 0 having 2
858 /// decomposition levels and tile 1 having 3 decomposition levels), the
859 /// first tile(-component) has 3 resolution levels and the second one has 4
860 /// resolution levels, whereas the component has only 3 resolution levels
861 /// available.</p>
862 ///
863 /// </summary>
864 /// <param name="c">The index of the component, from 0 to N-1.
865 ///
866 /// </param>
867 /// <param name="rl">The resolution level, from 0 to L.
868 ///
869 /// </param>
870 /// <returns> The height in pixels of component <tt>c</tt> in the overall
871 /// image.
872 ///
873 /// </returns>
874 public int getCompImgHeight(int c, int rl)
875 {
876 int sy, ey;
877 int dl = decSpec.dls.getMinInComp(c) - rl;
878 // indexation (0 is hi-res)
879 // Calculate image starting x at component hi-res grid
880 sy = (ay + hd.getCompSubsY(c) - 1) / hd.getCompSubsY(c);
881 // Calculate image ending (excluding) x at component hi-res grid
882 ey = (ay + imgH + hd.getCompSubsY(c) - 1) / hd.getCompSubsY(c);
883 // The difference at the rl level is the width
884 return (ey + (1 << dl) - 1) / (1 << dl) - (sy + (1 << dl) - 1) / (1 << dl);
885 }
886  
887 /// <summary> Changes the current tile, given the new indexes. An
888 /// IllegalArgumentException is thrown if the indexes do not correspond to
889 /// a valid tile.
890 ///
891 /// </summary>
892 /// <param name="x">The horizontal indexes the tile.
893 ///
894 /// </param>
895 /// <param name="y">The vertical indexes of the new tile.
896 ///
897 /// </param>
898 public abstract void setTile(int x, int y);
899  
900 /// <summary> Advances to the next tile, in standard scan-line order (by rows then
901 /// columns). An NoNextElementException is thrown if the current tile is
902 /// the last one (i.e. there is no next tile).
903 ///
904 /// </summary>
905 public abstract void nextTile();
906  
907 /// <summary> Returns the indexes of the current tile. These are the horizontal and
908 /// vertical indexes of the current tile.
909 ///
910 /// </summary>
911 /// <param name="co">If not null this object is used to return the information. If
912 /// null a new one is created and returned.
913 ///
914 /// </param>
915 /// <returns> The current tile's indexes (vertical and horizontal indexes).
916 ///
917 /// </returns>
918 public Coord getTile(Coord co)
919 {
920 if (co != null)
921 {
922 co.x = ctX;
923 co.y = ctY;
924 return co;
925 }
926 else
927 {
928 return new Coord(ctX, ctY);
929 }
930 }
931  
932 /// <summary> Returns the horizontal coordinate of the upper-left corner of the
933 /// specified resolution in the given component of the current tile.
934 ///
935 /// </summary>
936 /// <param name="c">The component index.
937 ///
938 /// </param>
939 /// <param name="rl">The resolution level index.
940 ///
941 /// </param>
942 public int getResULX(int c, int rl)
943 {
944 int dl = mdl[c] - rl;
945 if (dl < 0)
946 {
947 throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one component in " + "tile: " + ctX + "x" + ctY);
948 }
949 int tx0 = (int) System.Math.Max(px + ctX * ntW, ax);
950 //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
951 int tcx0 = (int) System.Math.Ceiling(tx0 / (double) getCompSubsX(c));
952 //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
953 return (int) System.Math.Ceiling(tcx0 / (double) (1 << dl));
954 }
955  
956 /// <summary> Returns the vertical coordinate of the upper-left corner of the
957 /// specified component in the given component of the current tile.
958 ///
959 /// </summary>
960 /// <param name="c">The component index.
961 ///
962 /// </param>
963 /// <param name="rl">The resolution level index.
964 ///
965 /// </param>
966 public int getResULY(int c, int rl)
967 {
968 int dl = mdl[c] - rl;
969 if (dl < 0)
970 {
971 throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one component in " + "tile: " + ctX + "x" + ctY);
972 }
973 int ty0 = (int) System.Math.Max(py + ctY * ntH, ay);
974 //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
975 int tcy0 = (int) System.Math.Ceiling(ty0 / (double) getCompSubsY(c));
976 //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
977 return (int) System.Math.Ceiling(tcy0 / (double) (1 << dl));
978 }
979  
980 /// <summary> Returns the number of tiles in the horizontal and vertical directions.
981 ///
982 /// </summary>
983 /// <param name="co">If not null this object is used to return the information. If
984 /// null a new one is created and returned.
985 ///
986 /// </param>
987 /// <returns> The number of tiles in the horizontal (Coord.x) and vertical
988 /// (Coord.y) directions.
989 ///
990 /// </returns>
991 public Coord getNumTiles(Coord co)
992 {
993 if (co != null)
994 {
995 co.x = ntX;
996 co.y = ntY;
997 return co;
998 }
999 else
1000 {
1001 return new Coord(ntX, ntY);
1002 }
1003 }
1004  
1005 /// <summary> Returns the total number of tiles in the image.
1006 ///
1007 /// </summary>
1008 /// <returns> The total number of tiles in the image.
1009 ///
1010 /// </returns>
1011 public int getNumTiles()
1012 {
1013 return ntX * ntY;
1014 }
1015  
1016 /// <summary> Returns the subband tree, for the specified tile-component. This method
1017 /// returns the root element of the subband tree structure, see Subband and
1018 /// SubbandSyn. The tree comprises all the available resolution levels.
1019 ///
1020 /// <p>Note: this method is not able to return subband tree for a tile
1021 /// different than the current one.</p>
1022 ///
1023 /// <p>The number of magnitude bits ('magBits' member variable) for each
1024 /// subband is not initialized.</p>
1025 ///
1026 /// </summary>
1027 /// <param name="t">The tile index
1028 ///
1029 /// </param>
1030 /// <param name="c">The index of the component, from 0 to C-1.
1031 ///
1032 /// </param>
1033 /// <returns> The root of the tree structure.
1034 ///
1035 /// </returns>
1036 public SubbandSyn getSynSubbandTree(int t, int c)
1037 {
1038 if (t != TileIdx)
1039 {
1040 throw new System.ArgumentException("Can not request subband" + " tree of a different tile" + " than the current one");
1041 }
1042 if (c < 0 || c >= nc)
1043 {
1044 throw new System.ArgumentException("Component index out of range");
1045 }
1046 return subbTrees[c];
1047 }
1048  
1049 /// <summary> Creates a bit stream reader of the correct type that works on the
1050 /// provided RandomAccessIO, with the special parameters from the parameter
1051 /// list.
1052 ///
1053 /// </summary>
1054 /// <param name="in">The RandomAccessIO source from which to read the bit stream.
1055 ///
1056 /// </param>
1057 /// <param name="hd">Header of the codestream.
1058 ///
1059 /// </param>
1060 /// <param name="pl">The parameter list containing parameters applicable to the
1061 /// bit stream read (other parameters may also be present).
1062 ///
1063 /// </param>
1064 /// <param name="decSpec">The decoder specifications
1065 ///
1066 /// </param>
1067 /// <param name="cdstrInfo">Whether or not to print information found in
1068 /// codestream.
1069 ///
1070 /// </param>
1071 /// <param name="hi">Reference to the HeaderInfo instance.
1072 ///
1073 /// </param>
1074 /// <exception cref="IOException">If an I/O error occurs while reading initial
1075 /// data from the bit stream.
1076 /// </exception>
1077 /// <exception cref="IllegalArgumentException">If an unrecognised bit stream
1078 /// reader option is present.
1079 ///
1080 /// </exception>
1081 public static BitstreamReaderAgent createInstance(RandomAccessIO in_Renamed, HeaderDecoder hd, ParameterList pl, DecoderSpecs decSpec, bool cdstrInfo, HeaderInfo hi)
1082 {
1083  
1084 // Check parameters
1085 pl.checkList(BitstreamReaderAgent.OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(BitstreamReaderAgent.ParameterInfo));
1086  
1087 return new FileBitstreamReaderAgent(hd, in_Renamed, decSpec, pl, cdstrInfo, hi);
1088 }
1089  
1090 /// <summary> Returns the precinct partition width for the specified tile-component
1091 /// and (tile-component) resolution level.
1092 ///
1093 /// </summary>
1094 /// <param name="t">the tile index
1095 ///
1096 /// </param>
1097 /// <param name="c">The index of the component (between 0 and N-1)
1098 ///
1099 /// </param>
1100 /// <param name="rl">The resolution level, from 0 to L.
1101 ///
1102 /// </param>
1103 /// <returns> the precinct partition width for the specified component,
1104 /// resolution level and tile.
1105 ///
1106 /// </returns>
1107 public int getPPX(int t, int c, int rl)
1108 {
1109 return decSpec.pss.getPPX(t, c, rl);
1110 }
1111  
1112 /// <summary> Returns the precinct partition height for the specified tile-component
1113 /// and (tile-component) resolution level.
1114 ///
1115 /// </summary>
1116 /// <param name="t">The tile index
1117 ///
1118 /// </param>
1119 /// <param name="c">The index of the component (between 0 and N-1)
1120 ///
1121 /// </param>
1122 /// <param name="rl">The resolution level, from 0 to L.
1123 ///
1124 /// </param>
1125 /// <returns> The precinct partition height in the specified component, for
1126 /// the specified resolution level, for the current tile.
1127 ///
1128 /// </returns>
1129 public int getPPY(int t, int c, int rl)
1130 {
1131 return decSpec.pss.getPPY(t, c, rl);
1132 }
1133  
1134 /// <summary> Initialises subbands fields, such as number of code-blocks, code-blocks
1135 /// dimension and number of magnitude bits, in the subband tree. The
1136 /// nominal code-block width/height depends on the precincts dimensions if
1137 /// used. The way the number of magnitude bits is computed depends on the
1138 /// quantization type (reversible, derived, expounded).
1139 ///
1140 /// </summary>
1141 /// <param name="c">The component index
1142 ///
1143 /// </param>
1144 /// <param name="sb">The subband tree to be initialised.
1145 ///
1146 /// </param>
1147 protected internal virtual void initSubbandsFields(int c, SubbandSyn sb)
1148 {
1149 int t = TileIdx;
1150 int rl = sb.resLvl;
1151 int cbw, cbh;
1152  
1153 cbw = decSpec.cblks.getCBlkWidth(ModuleSpec.SPEC_TILE_COMP, t, c);
1154 cbh = decSpec.cblks.getCBlkHeight(ModuleSpec.SPEC_TILE_COMP, t, c);
1155  
1156 if (!sb.isNode)
1157 {
1158 // Code-block dimensions
1159 if (hd.precinctPartitionUsed())
1160 {
1161 // The precinct partition is used
1162 int ppxExp, ppyExp, cbwExp, cbhExp;
1163  
1164 // Get exponents
1165 ppxExp = MathUtil.log2(getPPX(t, c, rl));
1166 ppyExp = MathUtil.log2(getPPY(t, c, rl));
1167 cbwExp = MathUtil.log2(cbw);
1168 cbhExp = MathUtil.log2(cbh);
1169  
1170 switch (sb.resLvl)
1171 {
1172  
1173 case 0:
1174 sb.nomCBlkW = (cbwExp < ppxExp?(1 << cbwExp):(1 << ppxExp));
1175 sb.nomCBlkH = (cbhExp < ppyExp?(1 << cbhExp):(1 << ppyExp));
1176 break;
1177  
1178  
1179 default:
1180 sb.nomCBlkW = (cbwExp < ppxExp - 1?(1 << cbwExp):(1 << (ppxExp - 1)));
1181 sb.nomCBlkH = (cbhExp < ppyExp - 1?(1 << cbhExp):(1 << (ppyExp - 1)));
1182 break;
1183  
1184 }
1185 }
1186 else
1187 {
1188 sb.nomCBlkW = cbw;
1189 sb.nomCBlkH = cbh;
1190 }
1191  
1192 // Number of code-blocks
1193 if (sb.numCb == null)
1194 sb.numCb = new Coord();
1195 if (sb.w == 0 || sb.h == 0)
1196 {
1197 sb.numCb.x = 0;
1198 sb.numCb.y = 0;
1199 }
1200 else
1201 {
1202 int cb0x = CbULX;
1203 int cb0y = CbULY;
1204 int tmp;
1205  
1206 // Projects code-block partition origin to subband. Since the
1207 // origin is always 0 or 1, it projects to the low-pass side
1208 // (throught the ceil operator) as itself (i.e. no change) and
1209 // to the high-pass side (through the floor operator) as 0,
1210 // always.
1211 int acb0x = cb0x;
1212 int acb0y = cb0y;
1213  
1214 switch (sb.sbandIdx)
1215 {
1216  
1217 case Subband.WT_ORIENT_LL:
1218 // No need to project since all low-pass => nothing to do
1219 break;
1220  
1221 case Subband.WT_ORIENT_HL:
1222 acb0x = 0;
1223 break;
1224  
1225 case Subband.WT_ORIENT_LH:
1226 acb0y = 0;
1227 break;
1228  
1229 case Subband.WT_ORIENT_HH:
1230 acb0x = 0;
1231 acb0y = 0;
1232 break;
1233  
1234 default:
1235 throw new System.ApplicationException("Internal JJ2000 error");
1236  
1237 }
1238 if (sb.ulcx - acb0x < 0 || sb.ulcy - acb0y < 0)
1239 {
1240 throw new System.ArgumentException("Invalid code-blocks " + "partition origin or " + "image offset in the " + "reference grid.");
1241 }
1242  
1243 // NOTE: when calculating "floor()" by integer division the
1244 // dividend and divisor must be positive, we ensure that by
1245 // adding the divisor to the dividend and then substracting 1
1246 // to the result of the division
1247  
1248 tmp = sb.ulcx - acb0x + sb.nomCBlkW;
1249 sb.numCb.x = (tmp + sb.w - 1) / sb.nomCBlkW - (tmp / sb.nomCBlkW - 1);
1250  
1251 tmp = sb.ulcy - acb0y + sb.nomCBlkH;
1252 sb.numCb.y = (tmp + sb.h - 1) / sb.nomCBlkH - (tmp / sb.nomCBlkH - 1);
1253 }
1254  
1255 // Number of magnitude bits
1256 if (derived[c])
1257 {
1258 sb.magbits = gb[c] + (params_Renamed[c].exp[0][0] - (mdl[c] - sb.level)) - 1;
1259 }
1260 else
1261 {
1262 sb.magbits = gb[c] + params_Renamed[c].exp[sb.resLvl][sb.sbandIdx] - 1;
1263 }
1264 }
1265 else
1266 {
1267 initSubbandsFields(c, (SubbandSyn) sb.LL);
1268 initSubbandsFields(c, (SubbandSyn) sb.HL);
1269 initSubbandsFields(c, (SubbandSyn) sb.LH);
1270 initSubbandsFields(c, (SubbandSyn) sb.HH);
1271 }
1272 }
1273 public abstract CSJ2K.j2k.entropy.decoder.DecLyrdCBlk getCodeBlock(int param1, int param2, int param3, CSJ2K.j2k.wavelet.synthesis.SubbandSyn param4, int param5, int param6, CSJ2K.j2k.entropy.decoder.DecLyrdCBlk param7);
1274 }
1275 }