private void int_downsample(int componentIndex, byte[][] input_data, int startInputRow, byte[][] output_data, int startOutRow)
{
/* Expand input data enough to let all the output samples be generated
* by the standard loop. Special-casing padded output would be more
* efficient.
*/
jpeg_component_info compptr = m_cinfo.Component_info[componentIndex];
int output_cols = compptr.Width_in_blocks * compptr.DCT_h_scaled_size;
int h_expand = this.h_expand[compptr.Component_index];
expand_right_edge(input_data, startInputRow, m_cinfo.m_max_v_samp_factor, m_cinfo.m_image_width, output_cols * h_expand);
int v_expand = this.v_expand[compptr.Component_index];
int numpix = h_expand * v_expand;
int numpix2 = numpix / 2;
int inrow = 0;
int outrow = 0;
while (inrow < m_cinfo.m_max_v_samp_factor)
{
for (int outcol = 0, outcol_h = 0; outcol < output_cols; outcol++, outcol_h += h_expand)
{
int outvalue = 0;
for (int v = 0; v < v_expand; v++)
{
for (int h = 0; h < h_expand; h++)
outvalue += input_data[startInputRow + inrow + v][outcol_h + h];
}
output_data[startOutRow + outrow][outcol] = (byte)((outvalue + numpix2) / numpix);
}
inrow += v_expand;
outrow++;
}
}