BitMiracle.LibJpeg.Classic.Internal.jpeg_d_main_controller.make_funny_pointers C# (CSharp) Method

make_funny_pointers() private method

Create the funny pointer lists discussed in the comments above. The actual workspace is already allocated (in main.buffer), and the space for the pointer lists is allocated too. This routine just fills in the curiously ordered lists. This will be repeated at the beginning of each pass.
private make_funny_pointers ( ) : void
return void
        private void make_funny_pointers()
        {
            int M = m_cinfo.min_DCT_v_scaled_size;
            for (int ci = 0; ci < m_cinfo.m_num_components; ci++)
            {
                /* height of a row group of component */
                int rgroup = (m_cinfo.Comp_info[ci].V_samp_factor * m_cinfo.Comp_info[ci].DCT_v_scaled_size) / m_cinfo.min_DCT_v_scaled_size;

                int[] ind0 = m_funnyIndices[0][ci];
                int[] ind1 = m_funnyIndices[1][ci];

                /* First copy the workspace pointers as-is */
                for (int i = 0; i < rgroup * (M + 2); i++)
                {
                    ind0[i + rgroup] = i;
                    ind1[i + rgroup] = i;
                }

                /* In the second list, put the last four row groups in swapped order */
                for (int i = 0; i < rgroup * 2; i++)
                {
                    ind1[rgroup * (M - 1) + i] = rgroup * M + i;
                    ind1[rgroup * (M + 1) + i] = rgroup * (M - 2) + i;
                }

                /* The wraparound pointers at top and bottom will be filled later
                 * (see set_wraparound_pointers, below).  Initially we want the "above"
                 * pointers to duplicate the first actual data line.  This only needs
                 * to happen in xbuffer[0].
                 */
                for (int i = 0; i < rgroup; i++)
                    ind0[i] = ind0[rgroup];
            }
        }