private void ycc_rgb_convert(ComponentBuffer[] input_buf, int input_row, byte[][] output_buf, int output_row, int num_rows)
{
int component0RowOffset = m_perComponentOffsets[0];
int component1RowOffset = m_perComponentOffsets[1];
int component2RowOffset = m_perComponentOffsets[2];
byte[] limit = m_cinfo.m_sample_range_limit;
int limitOffset = m_cinfo.m_sampleRangeLimitOffset;
for (int row = 0; row < num_rows; row++)
{
int columnOffset = 0;
for (int col = 0; col < m_cinfo.m_output_width; col++)
{
int y = input_buf[0][input_row + component0RowOffset][col];
int cb = input_buf[1][input_row + component1RowOffset][col];
int cr = input_buf[2][input_row + component2RowOffset][col];
/* Range-limiting is essential due to noise introduced by DCT losses.
* for extended gamut (sYCC) and wide gamut (bg-sYCC) encodings.
*/
output_buf[output_row + row][columnOffset + JpegConstants.RGB_RED] = limit[limitOffset + y + m_Cr_r_tab[cr]];
output_buf[output_row + row][columnOffset + JpegConstants.RGB_GREEN] = limit[limitOffset + y + JpegUtils.RIGHT_SHIFT(m_Cb_g_tab[cb] + m_Cr_g_tab[cr], SCALEBITS)];
output_buf[output_row + row][columnOffset + JpegConstants.RGB_BLUE] = limit[limitOffset + y + m_Cb_b_tab[cb]];
columnOffset += JpegConstants.RGB_PIXELSIZE;
}
input_row++;
}
}