001: /*
002: * $RCSfile: WTDecompSpec.java,v $
003: * $Revision: 1.1 $
004: * $Date: 2005/02/11 05:02:27 $
005: * $State: Exp $
006: *
007: * Class: WTDecompSpec
008: *
009: * Description: <short description of class>
010: *
011: *
012: *
013: * COPYRIGHT:
014: *
015: * This software module was originally developed by Raphaël Grosbois and
016: * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
017: * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
018: * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
019: * Centre France S.A) in the course of development of the JPEG2000
020: * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
021: * software module is an implementation of a part of the JPEG 2000
022: * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
023: * Systems AB and Canon Research Centre France S.A (collectively JJ2000
024: * Partners) agree not to assert against ISO/IEC and users of the JPEG
025: * 2000 Standard (Users) any of their rights under the copyright, not
026: * including other intellectual property rights, for this software module
027: * with respect to the usage by ISO/IEC and Users of this software module
028: * or modifications thereof for use in hardware or software products
029: * claiming conformance to the JPEG 2000 Standard. Those intending to use
030: * this software module in hardware or software products are advised that
031: * their use may infringe existing patents. The original developers of
032: * this software module, JJ2000 Partners and ISO/IEC assume no liability
033: * for use of this software module or modifications thereof. No license
034: * or right to this software module is granted for non JPEG 2000 Standard
035: * conforming products. JJ2000 Partners have full right to use this
036: * software module for his/her own purpose, assign or donate this
037: * software module to any third party and to inhibit third parties from
038: * using this software module for non JPEG 2000 Standard conforming
039: * products. This copyright notice must be included in all copies or
040: * derivative works of this software module.
041: *
042: * Copyright (c) 1999/2000 JJ2000 Partners.
043: *
044: *
045: *
046: */
047:
048: package jj2000.j2k.wavelet;
049:
050: import jj2000.j2k.*;
051:
052: /**
053: * This class holds the decomposition type to be used in each part of the
054: * image; the default one, the component specific ones, the tile default ones
055: * and the component-tile specific ones.
056: *
057: * <P>The decomposition type identifiers values are the same as in the
058: * codestream.
059: *
060: * <P>The hierarchy is:<br>
061: * - Tile and component specific decomposition<br>
062: * - Tile specific default decomposition<br>
063: * - Component main default decomposition<br>
064: * - Main default decomposition<br>
065: *
066: * <P>At the moment tiles are not supported by this class.
067: * */
068: public class WTDecompSpec {
069: /**
070: * ID for the dyadic wavelet tree decomposition (also called
071: * "Mallat" in JPEG 2000): 0x00.
072: */
073: public final static int WT_DECOMP_DYADIC = 0;
074:
075: /**
076: * ID for the SPACL (as defined in JPEG 2000) wavelet tree
077: * decomposition (1 level of decomposition in the high bands and
078: * some specified number for the lowest LL band): 0x02. */
079: public final static int WT_DECOMP_SPACL = 2;
080:
081: /**
082: * ID for the PACKET (as defined in JPEG 2000) wavelet tree
083: * decomposition (2 levels of decomposition in the high bands and
084: * some specified number for the lowest LL band): 0x01. */
085: public final static int WT_DECOMP_PACKET = 1;
086:
087: /** The identifier for "main default" specified decomposition */
088: public final static byte DEC_SPEC_MAIN_DEF = 0;
089:
090: /** The identifier for "component default" specified decomposition */
091: public final static byte DEC_SPEC_COMP_DEF = 1;
092:
093: /** The identifier for "tile specific default" specified decomposition */
094: public final static byte DEC_SPEC_TILE_DEF = 2;
095:
096: /** The identifier for "tile and component specific" specified
097: decomposition */
098: public final static byte DEC_SPEC_TILE_COMP = 3;
099:
100: /** The spec type for each tile and component. The first index is the
101: * component index, the second is the tile index. NOTE: The tile specific
102: * things are not supported yet. */
103: // Use byte to save memory (no need for speed here).
104: private byte specValType[];
105:
106: /** The main default decomposition */
107: private int mainDefDecompType;
108:
109: /** The main default number of decomposition levels */
110: private int mainDefLevels;
111:
112: /** The component main default decomposition, for each component. */
113: private int compMainDefDecompType[];
114:
115: /** The component main default decomposition levels, for each component */
116: private int compMainDefLevels[];
117:
118: /**
119: * Constructs a new 'WTDecompSpec' for the specified number of components
120: * and tiles, with the given main default decomposition type and number of
121: * levels.
122: *
123: * <P>NOTE: The tile specific things are not supported yet
124: *
125: * @param nc The number of components
126: *
127: * @param nt The number of tiles
128: *
129: * @param dec The main default decomposition type
130: *
131: * @param lev The main default number of decomposition levels
132: *
133: *
134: * */
135: public WTDecompSpec(int nc, int dec, int lev) {
136: mainDefDecompType = dec;
137: mainDefLevels = lev;
138: specValType = new byte[nc];
139: }
140:
141: /**
142: * Sets the "component main default" decomposition type and number of
143: * levels for the specified component. Both 'dec' and 'lev' can not be
144: * negative at the same time.
145: *
146: * @param n The component index
147: *
148: * @param dec The decomposition type. If negative then the main default is
149: * used.
150: *
151: * @param lev The number of levels. If negative then the main defaul is
152: * used.
153: *
154: *
155: * */
156: public void setMainCompDefDecompType(int n, int dec, int lev) {
157: if (dec < 0 && lev < 0) {
158: throw new IllegalArgumentException();
159: }
160: // Set spec type and decomp
161: specValType[n] = DEC_SPEC_COMP_DEF;
162: if (compMainDefDecompType == null) {
163: compMainDefDecompType = new int[specValType.length];
164: compMainDefLevels = new int[specValType.length];
165: }
166: compMainDefDecompType[n] = (dec >= 0) ? dec : mainDefDecompType;
167: compMainDefLevels[n] = (lev >= 0) ? lev : mainDefLevels;
168: // For the moment disable it since other parts of JJ2000 do not
169: // support this
170: throw new NotImplementedError(
171: "Currently, in JJ2000, all components "
172: + "and tiles must have the same "
173: + "decomposition type and number of "
174: + "levels");
175: }
176:
177: /**
178: * Returns the type of specification for the decomposition in the
179: * specified component and tile. The specification type is one of:
180: * 'DEC_SPEC_MAIN_DEF', 'DEC_SPEC_COMP_DEF', 'DEC_SPEC_TILE_DEF',
181: * 'DEC_SPEC_TILE_COMP'.
182: *
183: * <P>NOTE: The tile specific things are not supported yet
184: *
185: * @param n The component index
186: *
187: * @param t The tile index, in raster scan order.
188: *
189: * @return The specification type for component 'n' and tile 't'.
190: *
191: *
192: * */
193: public byte getDecSpecType(int n) {
194: return specValType[n];
195: }
196:
197: /**
198: * Returns the main default decomposition type.
199: *
200: * @return The main default decomposition type.
201: *
202: *
203: * */
204: public int getMainDefDecompType() {
205: return mainDefDecompType;
206: }
207:
208: /**
209: * Returns the main default decomposition number of levels.
210: *
211: * @return The main default decomposition number of levels.
212: *
213: *
214: * */
215: public int getMainDefLevels() {
216: return mainDefLevels;
217: }
218:
219: /**
220: * Returns the decomposition type to be used in component 'n' and tile
221: * 't'.
222: *
223: * <P>NOTE: The tile specific things are not supported yet
224: *
225: * @param n The component index.
226: *
227: * @param t The tile index, in raster scan order
228: *
229: * @return The decomposition type to be used.
230: *
231: *
232: * */
233: public int getDecompType(int n) {
234: switch (specValType[n]) {
235: case DEC_SPEC_MAIN_DEF:
236: return mainDefDecompType;
237: case DEC_SPEC_COMP_DEF:
238: return compMainDefDecompType[n];
239: case DEC_SPEC_TILE_DEF:
240: throw new NotImplementedError();
241: case DEC_SPEC_TILE_COMP:
242: throw new NotImplementedError();
243: default:
244: throw new Error("Internal JJ2000 error");
245: }
246: }
247:
248: /**
249: * Returns the decomposition number of levels in component 'n' and tile
250: * 't'.
251: *
252: * <P>NOTE: The tile specific things are not supported yet
253: *
254: * @param n The component index.
255: *
256: * @param t The tile index, in raster scan order
257: *
258: * @return The decomposition number of levels.
259: *
260: *
261: * */
262: public int getLevels(int n) {
263: switch (specValType[n]) {
264: case DEC_SPEC_MAIN_DEF:
265: return mainDefLevels;
266: case DEC_SPEC_COMP_DEF:
267: return compMainDefLevels[n];
268: case DEC_SPEC_TILE_DEF:
269: throw new NotImplementedError();
270: case DEC_SPEC_TILE_COMP:
271: throw new NotImplementedError();
272: default:
273: throw new Error("Internal JJ2000 error");
274: }
275: }
276: }
|