/// <summary> Calculates the maximum amount of magnitude bits for each
        /// tile-component, and stores it in the 'maxMagBits' array. This is called
        /// by the constructor
        ///
        /// </summary>
        /// <param name="encSpec">The encoder specifications for addition of roi specs
        ///
        /// </param>
        private void  calcMaxMagBits(EncoderSpecs encSpec)
        {
            int          tmp;
            MaxShiftSpec rois = encSpec.rois;

            int nt = src.getNumTiles();
            int nc = src.NumComps;

            maxMagBits = new int[nt][];
            for (int i = 0; i < nt; i++)
            {
                maxMagBits[i] = new int[nc];
            }

            src.setTile(0, 0);
            for (int t = 0; t < nt; t++)
            {
                for (int c = nc - 1; c >= 0; c--)
                {
                    tmp = src.getMaxMagBits(c);
                    maxMagBits[t][c] = tmp;
                    rois.setTileCompVal(t, c, (System.Object)tmp);
                }
                if (t < nt - 1)
                {
                    src.nextTile();
                }
            }
            // Reset to current initial tile position
            src.setTile(0, 0);
        }
Exemple #2
0
        /// <summary> Initialize all members with the given number of tiles and components
        /// and the command-line arguments stored in a ParameterList instance
        ///
        /// </summary>
        /// <param name="nt">Number of tiles
        ///
        /// </param>
        /// <param name="nc">Number of components
        ///
        /// </param>
        /// <param name="imgsrc">The image source (used to get the image size)
        ///
        /// </param>
        /// <param name="pl">The ParameterList instance
        ///
        /// </param>
        public EncoderSpecs(int nt, int nc, BlkImgDataSrc imgsrc, ParameterList pl)
        {
            nTiles = nt;
            nComp  = nc;

            // ROI
            rois = new MaxShiftSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP);

            // Quantization
            pl.checkList(Quantizer.OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(Quantizer.ParameterInfo));
            qts  = new QuantTypeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
            qsss = new QuantStepSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);
            gbs  = new GuardBitsSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);

            // Wavelet transform
            wfs = new AnWTFilterSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, qts, pl);
            dls = new IntegerSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl, "Wlev");

            // Component transformation
            cts = new ForwCompTransfSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE, wfs, pl);

            // Entropy coder
            System.String[] strLcs = new System.String[] { "near_opt", "lazy_good", "lazy" };
            lcs = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Clen_calc", strLcs, pl);
            System.String[] strTerm = new System.String[] { "near_opt", "easy", "predict", "full" };
            tts = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cterm_type", strTerm, pl);
            System.String[] strBoolean = new System.String[] { "on", "off" };
            sss   = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cseg_symbol", strBoolean, pl);
            css   = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Ccausal", strBoolean, pl);
            rts   = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cterminate", strBoolean, pl);
            mqrs  = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "CresetMQ", strBoolean, pl);
            bms   = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, "Cbypass", strBoolean, pl);
            cblks = new CBlkSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, pl);

            // Precinct partition
            pss = new PrecinctSizeSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE_COMP, imgsrc, dls, pl);

            // Codestream
            sops = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE, "Psop", strBoolean, pl);
            ephs = new StringSpec(nt, nc, ModuleSpec.SPEC_TYPE_TILE, "Peph", strBoolean, pl);
        }