Class EncoderRAWColor

  • All Implemented Interfaces:
    java.lang.Runnable

    public class EncoderRAWColor
    extends java.lang.Object
    implements java.lang.Runnable
    This class is the main class of JJ2000's encoder. It instantiates all objects of the chain and launchs the encoding process. It then writes the header and the compressed bit stream to the output file. Finally, packed packet headers (through codestream post-manipulation) and file-format may be created if needed.

    First the encoder should be initialized with a ParameterList object provided through the constructor. Then, the run() method is invoked and the encoder executes. The exit code of the class can be obtained with the getExitCode() method, after the constructor and after the run method. A non-zero value indicates that an error has occurred.

    The modules are inserted in the encoding chain with the following order:

    • ImgReader
    • ImgDataJoiner (if multiple image readers)
    • Tiler
    • ForwCompTransf
    • ImgDataConverter
    • ForwardWT
    • Quantizer
    • ROIScaler
    • EntropyCoder
    • PostCompRateAllocator

    The encoder uses a pull model. This means that the last module (PostCompRateAllocator) requests data from its source (EntropyCoder), ...

    Writing of the codestream writing (header+bit stream) is realized by HeaderEncoder and CodestreamWriter modules.

    Packed packet headers and file-format creation are carried out by CodestreamManipulator and FileFormatWriter modules respectively.

    Many modules of the encoder may behave differently depending on the tile-component. The specifications of their behaviour are kept in specialized modules extending ModuleSpec class. All these modules are accessible through an instance of EncoderSpecs class.

    See Also:
    ImgReader, ImgDataJoiner, ForwCompTransf, Tiler, ImgDataConverter, ForwardWT, Quantizer, ROIScaler, EntropyCoder, PostCompRateAllocator, HeaderEncoder, CodestreamWriter, CodestreamManipulator, FileFormatWriter, ModuleSpec, EncoderSpecs
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private jj2000.j2k.util.ParameterList defpl
      The default parameter list (arguments)
      private int exitCode
      The exit code of the run method
      private ModelImage image  
      private static java.lang.String[][] pinfo
      The parameter information for this class
      private jj2000.j2k.util.ParameterList pl
      The parameter list (arguments)
      static char[] vprfxs
      The valid list of options prefixes
    • Constructor Summary

      Constructors 
      Constructor Description
      EncoderRAWColor​(jj2000.j2k.util.ParameterList pl)
      Instantiates an encoder object, width the ParameterList object given as argument.
      EncoderRAWColor​(jj2000.j2k.util.ParameterList pl, ModelImage image)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void error​(java.lang.String msg, int code)
      Prints the error message 'msg' to standard err, prepending "ERROR" to it, and sets the exitCode to 'code'.
      static java.lang.String[][] getAllParameters()
      Returns all the parameters used in the encoding chain.
      int getExitCode()
      Returns the exit code of the class.
      static java.lang.String[][] getParameterInfo()
      Returns the parameters that are used in this class and implementing classes.
      private void printParamInfo​(jj2000.j2k.util.MsgLogger out, java.lang.String[][] pinfo)
      Prints the parameters in 'pinfo' to the provided output, 'out', showing the existing defaults.
      private void printUsage()
      Prints the usage information to stdout.
      private void printVersionAndCopyright()
      Prints version and copyright information to stdout, using the MsgPrinter.
      void run()
      Runs the encoder.
      java.io.ByteArrayOutputStream run1Slice​(ImgReaderRAWColorSlice img)
      Runs the encoder.
      void runAllSlices​(int startSlice, int endSlice, boolean useModImage, ViewJProgressBar progressBar, FileWriteOptions options, int timeSlice)
      Now see what happens.
      private void warning​(java.lang.String msg)
      Prints the warning message 'msg' to standard err, prepending "WARNING" to it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • exitCode

        private int exitCode
        The exit code of the run method
      • pl

        private jj2000.j2k.util.ParameterList pl
        The parameter list (arguments)
      • defpl

        private jj2000.j2k.util.ParameterList defpl
        The default parameter list (arguments)
      • vprfxs

        public static final char[] vprfxs
        The valid list of options prefixes
      • pinfo

        private static final java.lang.String[][] pinfo
        The parameter information for this class
    • Constructor Detail

      • EncoderRAWColor

        public EncoderRAWColor​(jj2000.j2k.util.ParameterList pl)
        Instantiates an encoder object, width the ParameterList object given as argument. It also retrieves the default ParameterList.
        Parameters:
        pl - The ParameterList for this decoder (contains also defaults values);
      • EncoderRAWColor

        public EncoderRAWColor​(jj2000.j2k.util.ParameterList pl,
                               ModelImage image)
    • Method Detail

      • getExitCode

        public int getExitCode()
        Returns the exit code of the class. This is only initialized after the constructor and when the run method returns.
        Returns:
        The exit code of the constructor and the run() method.
      • run

        public void run()
        Runs the encoder. After completion the exit code is set, a non-zero value indicates that an error ocurred.
        Specified by:
        run in interface java.lang.Runnable
        See Also:
        getExitCode()
      • run1Slice

        public java.io.ByteArrayOutputStream run1Slice​(ImgReaderRAWColorSlice img)
        Runs the encoder. After completion the exit code is set, a non-zero value indicates that an error ocurred.
        See Also:
        getExitCode()
      • runAllSlices

        public void runAllSlices​(int startSlice,
                                 int endSlice,
                                 boolean useModImage,
                                 ViewJProgressBar progressBar,
                                 FileWriteOptions options,
                                 int timeSlice)
        Now see what happens.
      • getParameterInfo

        public static java.lang.String[][] getParameterInfo()
        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 4 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.
        Returns:
        the options name, their synopsis and their explanation, or null if no options are supported.
      • getAllParameters

        public static java.lang.String[][] getAllParameters()
        Returns all the parameters used in the encoding chain. It calls parameter from each module and store them in one array (one row per parameter and 4 columns).
        Returns:
        All encoding parameters
        See Also:
        getParameterInfo()
      • error

        private void error​(java.lang.String msg,
                           int code)
        Prints the error message 'msg' to standard err, prepending "ERROR" to it, and sets the exitCode to 'code'. An exit code different than 0 indicates that there where problems.
        Parameters:
        msg - The error message
        code - The exit code to set
      • warning

        private void warning​(java.lang.String msg)
        Prints the warning message 'msg' to standard err, prepending "WARNING" to it.
        Parameters:
        msg - The error message
      • printVersionAndCopyright

        private void printVersionAndCopyright()
        Prints version and copyright information to stdout, using the MsgPrinter.
      • printUsage

        private void printUsage()
        Prints the usage information to stdout. The usage information is written for all modules in the encoder.
      • printParamInfo

        private void printParamInfo​(jj2000.j2k.util.MsgLogger out,
                                    java.lang.String[][] pinfo)
        Prints the parameters in 'pinfo' to the provided output, 'out', showing the existing defaults. The 'pinfo' argument is a 2D String array. The first dimension contains String arrays, 1 for each parameter. Each of these arrays has 3 elements, the first element is the parameter name, the second element is the synopsis for the parameter and the third one is a long description of the parameter. If the synopsis or description is 'null' then no synopsis or description is printed, respectively. If there is a default value for a parameter it is also printed.
        Parameters:
        out - Where to print.
        pinfo - The parameter information to write.