⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 entropycoder.java

📁 jpeg2000算法实现
💻 JAVA
字号:
/* * CVS identifier: * * $Id: EntropyCoder.java,v 1.54 2001/02/14 10:47:33 grosbois Exp $ * * Class:                   EntropyCoder * * Description:             The abstract class for entropy encoders * * * * 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.encoder;import jj2000.j2k.quantization.quantizer.*;import jj2000.j2k.codestream.writer.*;import jj2000.j2k.wavelet.analysis.*;import jj2000.j2k.wavelet.*;import jj2000.j2k.encoder.*;import jj2000.j2k.entropy.*;import jj2000.j2k.image.*;import jj2000.j2k.util.*;import jj2000.j2k.roi.*;import java.util.*;import java.io.*;/** * This abstract class provides the general interface for block-based entropy * encoders. The input to the entropy coder is the quantized wavelet * coefficients, or codewords, represented in sign magnitude. The output is a * compressed code-block with rate-distortion information. * * <P>The source of data for objects of this class are 'CBlkQuantDataSrcEnc' * objects. * * <P>For more details on the sign magnitude representation used see the * Quantizer class. * * <P>This class provides default implemenations for most of the methods * (wherever it makes sense), under the assumption that the image and * component dimensions, and the tiles, are not modifed by the entropy * coder. If that is not the case for a particular implementation then the * methods should be overriden. * * @see Quantizer * @see CBlkQuantDataSrcEnc * */public abstract class EntropyCoder extends ImgDataAdapter    implements CodedCBlkDataSrcEnc, StdEntropyCoderOptions {    /** The prefix for entropy coder options: 'C' */    public final static char OPT_PREFIX = 'C';    /** The list of parameters that is accepted for entropy coding. Options      * for entropy coding start with 'C'. */    private final static String [][] pinfo = {        {"Cblksiz", "[<tile-component idx>] <width> <height> "+         "[[<tile-component idx>] <width> <height>]",         "Specifies the maximum code-block size to use for tile-component. "+         "The maximum width and height is 1024, however the surface area "+         "(i.e. width x height) must not exceed 4096. The minimum width and "+         "height is 4.","64 64"},        {"Cbypass", "[<tile-component idx>] on|off"+         "[ [<tile-component idx>] on|off ...]",         "Uses the lazy coding mode with the entropy coder. This will bypass "+         "the MQ coder for some of the coding passes, where the distribution "+         "is often close to uniform. Since the MQ codeword will be "+         "terminated "+         "at least once per lazy pass, it is important to use an efficient "+         "termination algorithm, see the 'Cterm' option."+         "'on' enables, 'off' disables it.","off"},        {"CresetMQ", "[<tile-component idx>] on|off"+         "[ [<tile-component idx>] on|off ...]",         "If this is enabled the probability estimates of the MQ coder are "+         "reset after each arithmetically coded (i.e. non-lazy) coding pass. "+         "'on' enables, 'off' disables it.","off"},        {"Creg_term", "[<tile-component idx>] on|off"+         "[ [<tile-component idx>] on|off ...]",         "If this is enabled the codeword (raw or MQ) is terminated on a "+         "byte boundary after each coding pass. In this case it is important "+         "to use an efficient termination algorithm, see the 'Cterm' option. "+         "'on' enables, 'off' disables it.","off"},        {"Ccausal","[<tile-component idx>] on|off"+         "[ [<tile-component idx>] on|off ...]",          "Uses vertically stripe causal context formation. If this is "+         "enabled "+         "the context formation process in one stripe is independant of the "+         "next stripe (i.e. the one below it). 'on' "+         "enables, 'off' disables it.","off"},        {"Cseg_symbol","[<tile-component idx>] on|off"+         "[ [<tile-component idx>] on|off ...]",         "Inserts an error resilience segmentation symbol in the MQ "+         "codeword at the end of "+         "each bit-plane (cleanup pass). Decoders can use this "+         "information to detect and "+         "conceal errors.'on' enables, 'off' disables "+         "it.","off"},        {"Cterm", "[<tile-component idx>] near_opt|easy|predict|full"+         "[ [<tile-component idx>] near_opt|easy|predict|full ...]",         "Specifies the algorithm used to terminate the MQ codeword. "+         "The most efficient one is 'near_opt', which delivers a codeword "+         "which in almost all cases is the shortest possible. The 'easy' is "+         "a simpler algorithm that delivers a codeword length that is close "+         "to the previous one (in average 1 bit longer). The 'predict' is"+         " almost "+         "the same as the 'easy' but it leaves error resilient information "+         "on "+         "the spare least significant bits (in average 3.5 bits), which can "+         "be used by a decoder to detect errors. The 'full' algorithm "+         "performs a full flush of the MQ coder and is highly inefficient.\n"+         "It is important to use a good termination policy since the MQ "+         "codeword can be terminated quite often, specially if the 'Cbypass'"+         " or "+         "'Creg_term' options are enabled (in the normal case it would be "+         "terminated once per code-block, while if 'Creg_term' is specified "+         "it will be done almost 3 times per bit-plane in each code-block).",	 "near_opt"},        {"Clen_calc","[<tile-component idx>] near_opt|lazy_good|lazy"+         "[ [<tile-component idx>] ...]",         "Specifies the algorithm to use in calculating the necessary MQ "+         "length for each decoding pass. The best one is 'near_opt', which "+         "performs a rather sophisticated calculation and provides the best "+         "results. The 'lazy_good' and 'lazy' are very simple algorithms "+         "that "+         "provide rather conservative results, 'lazy_good' one being "+         "slightly "+         "better. Do not change this option unless you want to experiment "+         "the effect of different length calculation algorithms.","near_opt"},        {"Cpp","[<tile-component idx>] <dim> <dim> [<dim> <dim>] " +         "[ [<tile-component idx>] ...]",         "Specifies precinct partition dimensions for tile-component. The "+         "first "+         "two values apply to the highest resolution and the following ones "+         "(if "+         "any) apply to the remaining resolutions in decreasing order. If "+         "less "+         "values than the number of decomposition levels are specified, "+         "then the "+         "last two values are used for the remaining resolutions.", null},    };    /** The source of quantized wavelet coefficients */    protected CBlkQuantDataSrcEnc src;    /**     * Initializes the source of quantized wavelet coefficients.     *     * @param src The source of quantized wavelet coefficients.     * */    public EntropyCoder(CBlkQuantDataSrcEnc src) {        super(src);        this.src = src;    }    /**     * Returns the code-block width for the specified tile and component.     *     * @param t The tile index     *      * @param c the component index     *     * @return The code-block width for the specified tile and component     * */    public abstract int getCBlkWidth(int t, int c);        /**     * Returns the code-block height for the specified tile and component.     *     * @param t The tile index     *      * @param c the component index     *     * @return The code-block height for the specified tile and component     * */    public abstract int getCBlkHeight(int t, int c);    /**     * Returns the reversibility of the tile-component data that is provided     * by the object.  Data is reversible when it is suitable for lossless and     * lossy-to-lossless compression.     *     * <P>Since entropy coders themselves are always reversible, it returns     * the reversibility of the data that comes from the 'CBlkQuantDataSrcEnc'     * source object (i.e. ROIScaler).     *     * @param t Tile index     *     * @param c Component index     *     * @return true is the data is reversible, false if not.     *     * @see jj2000.j2k.roi.encoder.ROIScaler     * */    public boolean isReversible(int t,int c) {        return src.isReversible(t,c);    }    /**     * Returns a reference to the root of subband tree structure representing     * the subband decomposition for the specified tile-component.     *     * @param t The index of the tile.     *     * @param c The index of the component.     *     * @return The root of the subband tree structure, see Subband.     *     * @see SubbandAn     *     * @see Subband     * */    public SubbandAn getSubbandTree(int t,int c) {        return src.getSubbandTree(t,c);    }    /**     * Returns the horizontal coordinate of the origin of the cell and     * code-block partition, with respect to the canvas origin, on the     * reference grid. Allowable values are 0 and 1, nothing else.     *     * @return The horizontal coordinate of the origin of the cell and     * code-block partitions, with respect to the canvas origin, on the     * reference grid.     * */    public int getPartitionULX() {        return src.getPartitionULX();    }    /**     * Returns the vertical coordinate of the origin of the cell and     * code-block partition, with respect to the canvas origin, on the     * reference grid. Allowable values are 0 and 1, nothing else.     *     * @return The vertical coordinate of the origin of the cell and     * code-block partitions, with respect to the canvas origin, on the     * reference grid.     * */    public int getPartitionULY() {        return src.getPartitionULY();    }    /**     * Returns the parameters that are used in this class and     * implementing classes. It returns a 2D String array. Each of the     * 1D arrays is for a different option, and they have 3     * elements. The first element is the option name, the second one     * is the synopsis, the third one is a long description of what     * the parameter is and the fourth is its default value. The     * synopsis or description may be 'null', in which case it is     * assumed that there is no synopsis or description of the option,     * respectively. Null may be returned if no options are supported.     *     * @return the options name, their synopsis and their explanation,      * or null if no options are supported.     * */    public static String[][] getParameterInfo() {        return pinfo;    }    /**     * Creates a EntropyCoder object for the appropriate entropy coding     * parameters in the parameter list 'pl', and having 'src' as the source     * of quantized data.     *     * @param src The source of data to be entropy coded     *     * @param encSpec The encoder specifications     *     * @param pl The parameter list (or options).     *     * @exception IllegalArgumentException If an error occurs while parsing     * the options in 'pl'     * */    public static EntropyCoder createInstance(CBlkQuantDataSrcEnc src,                                              EncoderSpecs encSpec,                                              ParameterList pl) {        // Check parameters        pl.checkList(OPT_PREFIX,pl.toNameArray(pinfo));        return new StdEntropyCoder(src, encSpec);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -