001/*
002 * $RCSfile: ForwardWT.java,v $
003 * $Revision: 1.1 $
004 * $Date: 2005/02/11 05:02:31 $
005 * $State: Exp $
006 *
007 * Class:                   ForwardWT
008 *
009 * Description:             This interface defines the specifics
010 *                          of forward wavelet transforms
011 *
012 *
013 *
014 * COPYRIGHT:
015 *
016 * This software module was originally developed by Raphaël Grosbois and
017 * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
018 * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
019 * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
020 * Centre France S.A) in the course of development of the JPEG2000
021 * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
022 * software module is an implementation of a part of the JPEG 2000
023 * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
024 * Systems AB and Canon Research Centre France S.A (collectively JJ2000
025 * Partners) agree not to assert against ISO/IEC and users of the JPEG
026 * 2000 Standard (Users) any of their rights under the copyright, not
027 * including other intellectual property rights, for this software module
028 * with respect to the usage by ISO/IEC and Users of this software module
029 * or modifications thereof for use in hardware or software products
030 * claiming conformance to the JPEG 2000 Standard. Those intending to use
031 * this software module in hardware or software products are advised that
032 * their use may infringe existing patents. The original developers of
033 * this software module, JJ2000 Partners and ISO/IEC assume no liability
034 * for use of this software module or modifications thereof. No license
035 * or right to this software module is granted for non JPEG 2000 Standard
036 * conforming products. JJ2000 Partners have full right to use this
037 * software module for his/her own purpose, assign or donate this
038 * software module to any third party and to inhibit third parties from
039 * using this software module for non JPEG 2000 Standard conforming
040 * products. This copyright notice must be included in all copies or
041 * derivative works of this software module.
042 *
043 * Copyright (c) 1999/2000 JJ2000 Partners.
044 *  */
045package jj2000.j2k.wavelet.analysis;
046
047import jj2000.j2k.codestream.writer.*;
048import jj2000.j2k.codestream.*;
049import jj2000.j2k.wavelet.*;
050import jj2000.j2k.image.*;
051import jj2000.j2k.util.*;
052import jj2000.j2k.*;
053
054import java.io.*;
055import java.util.*;
056
057import com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageWriteParamJava;
058/**
059 * This abstract class represents the forward wavelet transform functional
060 * block. The functional block may actually be comprised of several classes
061 * linked together, but a subclass of this abstract class is the one that is
062 * returned as the functional block that performs the forward wavelet
063 * transform.
064 *
065 * <P>This class assumes that data is transferred in code-blocks, as defined
066 * by the 'CBlkWTDataSrc' interface. The internal calculation of the wavelet
067 * transform may be done differently but a buffering class should convert to
068 * that type of transfer.
069 * */
070public abstract class ForwardWT extends ImgDataAdapter
071    implements ForwWT, CBlkWTDataSrc {
072
073    /**
074     * ID for the dyadic wavelet tree decomposition (also called "Mallat" in
075     * JPEG 2000): 0x00.
076     * */
077    public final static int WT_DECOMP_DYADIC = 0;
078
079    /** The prefix for wavelet transform options: 'W' */
080    public final static char OPT_PREFIX = 'W';
081
082    /** The list of parameters that is accepted for wavelet transform. Options
083     * for the wavelet transform start with 'W'. */
084    private final static String [][] pinfo = {
085        { "Wlev", "<number of decomposition levels>",
086          "Specifies the number of wavelet decomposition levels to apply to "+
087          "the image. If 0 no wavelet transform is performed. All components "+
088          "and all tiles have the same number of decomposition levels.","5"},
089        { "Wwt", "[full]",
090          "Specifies the wavelet transform to be used. Possible value is: "+
091          "'full' (full page). The value 'full' performs a normal DWT.",
092          "full"},
093    };
094
095    /**
096     * Initializes this object for the specified number of tiles 'nt' and
097     * components 'nc'.
098     *
099     * @param src The source of ImgData
100     * */
101    protected ForwardWT(ImgData src) {
102        super(src);
103    }
104
105    /**
106     * Returns the parameters that are used in this class and implementing
107     * classes. It returns a 2D String array. Each of the 1D arrays is for a
108     * different option, and they have 3 elements. The first element is the
109     * option name, the second one is the synopsis and the third one is a long
110     * description of what the parameter is. The synopsis or description may
111     * be 'null', in which case it is assumed that there is no synopsis or
112     * description of the option, respectively. Null may be returned if no
113     * options are supported.
114     *
115     * @return the options name, their synopsis and their explanation, or null
116     * if no options are supported.
117     * */
118    public static String[][] getParameterInfo() {
119        return pinfo;
120    }
121
122    /**
123     * Creates a ForwardWT object with the specified filters, and with other
124     * options specified in the parameter list 'pl'.
125     *
126     * @param src The source of data to be transformed
127     *
128     * @param pl The parameter list (or options).
129     *
130     * @param kers The encoder specifications.
131     *
132     * @return A new ForwardWT object with the specified filters and options
133     * from 'pl'.
134     *
135     * @exception IllegalArgumentException If mandatory parameters are missing
136     * or if invalid values are given.
137     * */
138    public static ForwardWT createInstance(BlkImgDataSrc src,
139                                           J2KImageWriteParamJava wp){
140        int defdec,deflev;
141        String decompstr;
142        String wtstr;
143        String pstr;
144        StreamTokenizer stok;
145        StringTokenizer strtok;
146        int prefx,prefy;        // Partitioning reference point coordinates
147/*
148        // Check parameters
149        pl.checkList(OPT_PREFIX, pl.toNameArray(pinfo));
150*/
151        deflev = ((Integer)wp.getDecompositionLevel().getDefault()).intValue();
152
153        // partition reference point
154        prefx = 0;
155        prefy = 0;
156
157        return new ForwWTFull(src, wp, prefx,prefy);
158    }
159
160}