public override void upsample(ComponentBuffer[] input_buf, ref int in_row_group_ctr, int in_row_groups_avail, byte[][] output_buf, ref int out_row_ctr, int out_rows_avail)
{
/* Fill the conversion buffer, if it's empty */
if (m_next_row_out >= m_cinfo.m_max_v_samp_factor)
{
for (int ci = 0; ci < m_cinfo.m_num_components; ci++)
{
m_perComponentOffsets[ci] = 0;
/* Invoke per-component upsample method.*/
m_currentComponent = ci;
m_upsampleRowOffset = in_row_group_ctr * m_rowgroup_height[ci];
upsampleComponent(ref input_buf[ci]);
}
m_next_row_out = 0;
}
/* Color-convert and emit rows */
/* How many we have in the buffer: */
int num_rows = m_cinfo.m_max_v_samp_factor - m_next_row_out;
/* Not more than the distance to the end of the image. Need this test
* in case the image height is not a multiple of max_v_samp_factor:
*/
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;
m_cinfo.m_cconvert.color_convert(m_color_buf, m_perComponentOffsets, m_next_row_out, output_buf, out_row_ctr, num_rows);
/* Adjust counts */
out_row_ctr += num_rows;
m_rows_to_go -= num_rows;
m_next_row_out += num_rows;
/* When the buffer is emptied, declare this input row group consumed */
if (m_next_row_out >= m_cinfo.m_max_v_samp_factor)
in_row_group_ctr++;
}