示例#1
0
        // Initialize IDCT manager.
        static void jinit_inverse_dct(jpeg_decompress cinfo)
        {
            jpeg_lossy_d_codec lossyd = (jpeg_lossy_d_codec)cinfo.coef;
            idct_controller    idct   = null;

            try
            {
                idct = new idct_controller();
            }
            catch
            {
                ERREXIT1(cinfo, J_MESSAGE_CODE.JERR_OUT_OF_MEMORY, 4);
            }

            lossyd.idct_private    = idct;
            lossyd.idct_start_pass = start_pass_idctmgr;

            for (int ci = 0; ci < cinfo.num_components; ci++)
            {
                jpeg_component_info compptr = cinfo.comp_info[ci];

                // Allocate and pre-zero a multiplier table for each component
                try
                {
                    compptr.dct_table = new int[DCTSIZE2];
                }
                catch
                {
                    ERREXIT1(cinfo, J_MESSAGE_CODE.JERR_OUT_OF_MEMORY, 4);
                }

                // Mark multiplier table not yet set up for any method
                idct.cur_method[ci] = -1;
            }
        }
示例#2
0
        // Prepare for an output pass.
        // Here we select the proper IDCT routine for each component and build
        // a matching multiplier table.
        static void start_pass_idctmgr(jpeg_decompress cinfo)
        {
            jpeg_lossy_d_codec lossyd = (jpeg_lossy_d_codec)cinfo.coef;
            idct_controller    idct   = (idct_controller)lossyd.idct_private;

            for (int ci = 0; ci < cinfo.num_components; ci++)
            {
                jpeg_component_info compptr = cinfo.comp_info[ci];

                // Select the proper IDCT routine for this component's scaling
                lossyd.inverse_DCT[ci] = jpeg_idct_ifast;

                // Create multiplier table from quant table.
                // However, we can skip this if the component is uninteresting
                // or if we already built the table. Also, if no quant table
                // has yet been saved for the component, we leave the
                // multiplier table all-zero; we'll be reading zeroes from the
                // coefficient controller's buffer anyway.
                if (!compptr.component_needed || idct.cur_method[ci] == JDCT_IFAST)
                {
                    continue;
                }

                JQUANT_TBL qtbl = compptr.quant_table;
                if (qtbl == null)
                {
                    continue;                                   // happens if no data yet for component
                }
                idct.cur_method[ci] = JDCT_IFAST;
                // For AA&N IDCT method, multipliers are equal to quantization
                // coefficients scaled by scalefactor[row]*scalefactor[col], where
                //	scalefactor[0] = 1
                //	scalefactor[k] = cos(k*PI/16) * sqrt(2)		for k=1..7
                // For integer operation, the multiplier table is to be scaled by 2.
                int[] ifmtbl = compptr.dct_table;

                for (int i = 0; i < DCTSIZE2; i++)
                {
                    ifmtbl[i] = (((int)qtbl.quantval[i] * aanscales[i]) + (1 << 11)) >> 12;
                }
            }
        }