private void h2v2_merged_upsample(ComponentBuffer[] input_buf, int in_row_group_ctr, byte[][] output_buf)
{
int inputRow00 = in_row_group_ctr * 2;
int inputIndex00 = 0;
int inputRow01 = in_row_group_ctr * 2 + 1;
int inputIndex01 = 0;
int inputIndex1 = 0;
int inputIndex2 = 0;
int outIndex0 = 0;
int outIndex1 = 0;
byte[] limit = m_cinfo.m_sample_range_limit;
int limitOffset = m_cinfo.m_sampleRangeLimitOffset;
/* Loop for each group of output pixels */
for (int col = m_cinfo.m_output_width >> 1; col > 0; col--)
{
/* Do the chroma part of the calculation */
int cb = input_buf[1][in_row_group_ctr][inputIndex1];
inputIndex1++;
int cr = input_buf[2][in_row_group_ctr][inputIndex2];
inputIndex2++;
int cred = m_Cr_r_tab[cr];
int cgreen = JpegUtils.RIGHT_SHIFT(m_Cb_g_tab[cb] + m_Cr_g_tab[cr], SCALEBITS);
int cblue = m_Cb_b_tab[cb];
/* Fetch 4 Y values and emit 4 pixels */
int y = input_buf[0][inputRow00][inputIndex00];
inputIndex00++;
output_buf[0][outIndex0 + JpegConstants.RGB_RED] = limit[limitOffset + y + cred];
output_buf[0][outIndex0 + JpegConstants.RGB_GREEN] = limit[limitOffset + y + cgreen];
output_buf[0][outIndex0 + JpegConstants.RGB_BLUE] = limit[limitOffset + y + cblue];
outIndex0 += JpegConstants.RGB_PIXELSIZE;
y = input_buf[0][inputRow00][inputIndex00];
inputIndex00++;
output_buf[0][outIndex0 + JpegConstants.RGB_RED] = limit[limitOffset + y + cred];
output_buf[0][outIndex0 + JpegConstants.RGB_GREEN] = limit[limitOffset + y + cgreen];
output_buf[0][outIndex0 + JpegConstants.RGB_BLUE] = limit[limitOffset + y + cblue];
outIndex0 += JpegConstants.RGB_PIXELSIZE;
y = input_buf[0][inputRow01][inputIndex01];
inputIndex01++;
output_buf[1][outIndex1 + JpegConstants.RGB_RED] = limit[limitOffset + y + cred];
output_buf[1][outIndex1 + JpegConstants.RGB_GREEN] = limit[limitOffset + y + cgreen];
output_buf[1][outIndex1 + JpegConstants.RGB_BLUE] = limit[limitOffset + y + cblue];
outIndex1 += JpegConstants.RGB_PIXELSIZE;
y = input_buf[0][inputRow01][inputIndex01];
inputIndex01++;
output_buf[1][outIndex1 + JpegConstants.RGB_RED] = limit[limitOffset + y + cred];
output_buf[1][outIndex1 + JpegConstants.RGB_GREEN] = limit[limitOffset + y + cgreen];
output_buf[1][outIndex1 + JpegConstants.RGB_BLUE] = limit[limitOffset + y + cblue];
outIndex1 += JpegConstants.RGB_PIXELSIZE;
}
/* If image width is odd, do the last output column separately */
if ((m_cinfo.m_output_width & 1) != 0)
{
int cb = input_buf[1][in_row_group_ctr][inputIndex1];
int cr = input_buf[2][in_row_group_ctr][inputIndex2];
int cred = m_Cr_r_tab[cr];
int cgreen = JpegUtils.RIGHT_SHIFT(m_Cb_g_tab[cb] + m_Cr_g_tab[cr], SCALEBITS);
int cblue = m_Cb_b_tab[cb];
int y = input_buf[0][inputRow00][inputIndex00];
output_buf[0][outIndex0 + JpegConstants.RGB_RED] = limit[limitOffset + y + cred];
output_buf[0][outIndex0 + JpegConstants.RGB_GREEN] = limit[limitOffset + y + cgreen];
output_buf[0][outIndex0 + JpegConstants.RGB_BLUE] = limit[limitOffset + y + cblue];
y = input_buf[0][inputRow01][inputIndex01];
output_buf[1][outIndex1 + JpegConstants.RGB_RED] = limit[limitOffset + y + cred];
output_buf[1][outIndex1 + JpegConstants.RGB_GREEN] = limit[limitOffset + y + cgreen];
output_buf[1][outIndex1 + JpegConstants.RGB_BLUE] = limit[limitOffset + y + cblue];
}
}