BitMiracle.LibJpeg.Classic.Internal.my_2pass_cquantizer.prescan_quantize C# (CSharp) Method

prescan_quantize() private method

Prescan some rows of pixels. In this module the prescan simply updates the histogram, which has been initialized to zeroes by start_pass. An output_buf parameter is required by the method signature, but no data is actually output (in fact the buffer controller is probably passing a null pointer).
private prescan_quantize ( byte input_buf, int in_row, int num_rows ) : void
input_buf byte
in_row int
num_rows int
return void
        private void prescan_quantize(byte[][] input_buf, int in_row, int num_rows)
        {
            for (int row = 0; row < num_rows; row++)
            {
                int inputIndex = 0;
                for (int col = m_cinfo.m_output_width; col > 0; col--)
                {
                    int rowIndex = (int)input_buf[in_row + row][inputIndex] >> C0_SHIFT;
                    int columnIndex = ((int)input_buf[in_row + row][inputIndex + 1] >> C1_SHIFT) * HIST_C2_ELEMS +
                        ((int)input_buf[in_row + row][inputIndex + 2] >> C2_SHIFT);

                    /* increment pixel value, check for overflow and undo increment if so. */
                    m_histogram[rowIndex][columnIndex]++;
                    if (m_histogram[rowIndex][columnIndex] <= 0)
                        m_histogram[rowIndex][columnIndex]--;

                    inputIndex += 3;
                }
            }
        }