BitMiracle.LibJpeg.Classic.Internal.jpeg_forward_dct.forwardDCTFloatImpl C# (CSharp) Method

forwardDCTFloatImpl() private method

private forwardDCTFloatImpl ( jpeg_component_info compptr, byte sample_data, JBLOCK coef_blocks, int start_row, int start_col, int num_blocks ) : void
compptr jpeg_component_info
sample_data byte
coef_blocks JBLOCK
start_row int
start_col int
num_blocks int
return void
        private void forwardDCTFloatImpl(jpeg_component_info compptr, byte[][] sample_data, JBLOCK[] coef_blocks, int start_row, int start_col, int num_blocks)
        {
            /* This routine is heavily used, so it's worth coding it tightly. */
            float_DCT_method_ptr do_dct = do_float_dct[compptr.Component_index];
            float[] divisors = m_dctTables[compptr.Component_index].float_array;
            float[] workspace = new float[JpegConstants.DCTSIZE2]; /* work area for FDCT subroutine */
            for (int bi = 0; bi < num_blocks; bi++, start_col += compptr.DCT_h_scaled_size)
            {
                /* Perform the DCT */
                do_dct(workspace, sample_data, start_row, start_col);

                /* Quantize/descale the coefficients, and store into coef_blocks[] */
                for (int i = 0; i < JpegConstants.DCTSIZE2; i++)
                {
                    /* Apply the quantization and scaling factor */
                    float temp = workspace[i] * divisors[i];

                    /* Round to nearest integer.
                     * Since C does not specify the direction of rounding for negative
                     * quotients, we have to force the dividend positive for portability.
                     * The maximum coefficient size is +-16K (for 12-bit data), so this
                     * code should work for either 16-bit or 32-bit ints.
                     */
                    coef_blocks[bi][i] = (short)((int)(temp + (float)16384.5) - 16384);
                }
            }
        }