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;
}
}
}