?? precinctsizespec.java
字號:
/* * CVS identifier: * * $Id: PrecinctSizeSpec.java,v 1.17 2001/02/14 10:33:00 grosbois Exp $ * * Class: PrecinctSizeSpec * * Description: Specification of the precinct sizes * * * * COPYRIGHT: * * This software module was originally developed by Rapha雔 Grosbois and * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel * Askel鰂 (Ericsson Radio Systems AB); and Bertrand Berthelot, David * Bouchard, F閘ix Henry, Gerard Mozelle and Patrice Onno (Canon Research * Centre France S.A) in the course of development of the JPEG2000 * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This * software module is an implementation of a part of the JPEG 2000 * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio * Systems AB and Canon Research Centre France S.A (collectively JJ2000 * Partners) agree not to assert against ISO/IEC and users of the JPEG * 2000 Standard (Users) any of their rights under the copyright, not * including other intellectual property rights, for this software module * with respect to the usage by ISO/IEC and Users of this software module * or modifications thereof for use in hardware or software products * claiming conformance to the JPEG 2000 Standard. Those intending to use * this software module in hardware or software products are advised that * their use may infringe existing patents. The original developers of * this software module, JJ2000 Partners and ISO/IEC assume no liability * for use of this software module or modifications thereof. No license * or right to this software module is granted for non JPEG 2000 Standard * conforming products. JJ2000 Partners have full right to use this * software module for his/her own purpose, assign or donate this * software module to any third party and to inhibit third parties from * using this software module for non JPEG 2000 Standard conforming * products. This copyright notice must be included in all copies or * derivative works of this software module. * * Copyright (c) 1999/2000 JJ2000 Partners. * */package jj2000.j2k.entropy;import jj2000.j2k.codestream.*;import jj2000.j2k.wavelet.*;import jj2000.j2k.image.*;import jj2000.j2k.util.*;import jj2000.j2k.*;import java.util.*;/** * This class extends ModuleSpec class for precinct partition sizes holding * purposes. * * <p>It stores the size a of precinct when precinct partition is used or not. * If precinct partition is used, we can have several packets for a given * resolution level whereas there is only one packet per resolution level if * no precinct partition is used. * */public class PrecinctSizeSpec extends ModuleSpec { /** Name of the option */ private static final String optName = "Cpp"; /** Reference to wavelet number of decomposition levels for each * tile-component. */ private IntegerSpec dls; /** * Creates a new PrecinctSizeSpec object for the specified number of tiles * and components. * * @param nt The number of tiles * * @param nc The number of components * * @param type the type of the specification module i.e. tile specific, * component specific or both. * * @param dls Reference to the number of decomposition levels * specification * */ public PrecinctSizeSpec(int nt, int nc, byte type, IntegerSpec dls) { super(nt, nc, type); this.dls = dls; } /** * Creates a new PrecinctSizeSpec object for the specified number of tiles * and components and the ParameterList instance. * * @param nt The number of tiles * * @param nc The number of components * * @param type the type of the specification module i.e. tile specific, * component specific or both. * * @param imgsrc The image source (used to get the image size) * * @param pl The ParameterList instance * */ public PrecinctSizeSpec(int nt, int nc, byte type, BlkImgDataSrc imgsrc, IntegerSpec dls, ParameterList pl) { super(nt, nc, type); this.dls = dls; // The precinct sizes are stored in a 2 elements vector array, the // first element containing a vector for the precincts width for each // resolution level and the second element containing a vector for the // precincts height for each resolution level. The precincts sizes are // specified from the highest resolution level to the lowest one // (i.e. 0). If there are less elements than the number of // decomposition levels, the last element is used for all remaining // resolution levels (i.e. if the precincts sizes are specified only // for resolutions levels 5, 4 and 3, then the precincts size for // resolution levels 2, 1 and 0 will be the same as the size used for // resolution level 3). // Boolean used to know if we were previously reading a precinct's // size or if we were reading something else. boolean wasReadingPrecinctSize = false; String param = pl.getParameter(optName); // Set precinct sizes to default i.e. 2^15 = // Markers.PRECINCT_PARTITION_DEF_SIZE Vector tmpv[] = new Vector[2]; tmpv[0] = new Vector(); // ppx tmpv[0].addElement(new Integer(Markers.PRECINCT_PARTITION_DEF_SIZE)); tmpv[1] = new Vector(); // ppy tmpv[1].addElement(new Integer(Markers.PRECINCT_PARTITION_DEF_SIZE)); setDefault(tmpv); if ( param==null ) { // No precinct size specified in the command line so we do not try // to parse it. return; } // Precinct partition is used : parse arguments StringTokenizer stk = new StringTokenizer(param); byte curSpecType = SPEC_DEF; // Specification type of the // current parameter boolean[] tileSpec = null; // Tiles concerned by the specification boolean[] compSpec = null; // Components concerned by the specification int i, xIdx, ci, ti; boolean endOfParamList = false; String word = null; // current word Integer w, h; String errMsg = null; while((stk.hasMoreTokens() || wasReadingPrecinctSize) && !endOfParamList){ Vector v[] = new Vector[2]; // v[0] : ppx, v[1] : ppy // We do not read the next token if we were reading a precinct's // size argument as we have already read the next token into word. if ( !wasReadingPrecinctSize ) { word = stk.nextToken(); } wasReadingPrecinctSize = false; switch(word.charAt(0)){ case 't': // Tiles specification tileSpec = parseIdx(word,nTiles); if(curSpecType==SPEC_COMP_DEF) { curSpecType = SPEC_TILE_COMP; } else { curSpecType = SPEC_TILE_DEF; } break; case 'c': // Components specification compSpec = parseIdx(word,nComp); if(curSpecType==SPEC_TILE_DEF) { curSpecType = SPEC_TILE_COMP; } else { curSpecType = SPEC_COMP_DEF; } break; default: if ( !Character.isDigit(word.charAt(0)) ) { errMsg = "Bad construction for parameter: "+word; throw new IllegalArgumentException(errMsg); } // Initialises Vector objects v[0] = new Vector(); // ppx v[1] = new Vector(); // ppy while ( true ) { // Now get the precinct dimensions try { // Get precinct width w = new Integer(word); // Get next word in argument list try { word = stk.nextToken(); } catch (NoSuchElementException e) {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -