private void merged_2v_upsample(ComponentBuffer[] input_buf, ref int in_row_group_ctr, byte[][] output_buf, ref int out_row_ctr, int out_rows_avail)
{
int num_rows; /* number of rows returned to caller */
if (m_spare_full)
{
/* If we have a spare row saved from a previous cycle, just return it. */
byte[][] temp = new byte[1][];
temp[0] = m_spare_row;
JpegUtils.jcopy_sample_rows(temp, 0, output_buf, out_row_ctr, 1, m_out_row_width);
num_rows = 1;
m_spare_full = false;
}
else
{
/* Figure number of rows to return to caller. */
num_rows = 2;
/* Not more than the distance to the end of the image. */
if (num_rows > m_rows_to_go)
num_rows = m_rows_to_go;
/* And not more than what the client can accept: */
out_rows_avail -= out_row_ctr;
if (num_rows > out_rows_avail)
num_rows = out_rows_avail;
/* Create output pointer array for upsampler. */
byte[][] work_ptrs = new byte[2][];
work_ptrs[0] = output_buf[out_row_ctr];
if (num_rows > 1)
{
work_ptrs[1] = output_buf[out_row_ctr + 1];
}
else
{
work_ptrs[1] = m_spare_row;
m_spare_full = true;
}
/* Now do the upsampling. */
h2v2_merged_upsample(input_buf, in_row_group_ctr, work_ptrs);
}
/* Adjust counts */
out_row_ctr += num_rows;
m_rows_to_go -= num_rows;
/* When the buffer is emptied, declare this input row group consumed */
if (!m_spare_full)
in_row_group_ctr++;
}