/* Convert some rows of samples to the JPEG colorspace. This version handles grayscale output with no conversion. The source can be either plain grayscale or YCC (since Y == gray).  */
grayscale_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
/* Convert some rows of samples to the JPEG colorspace. This version handles grayscale output with no conversion. The source can be either plain grayscale or YCC (since Y == gray).  */
grayscale_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
{
  int instride = cinfo->input_components;
  register JSAMPROW inptr;
  register JSAMPROW outptr;
  register JDIMENSION col;
  JDIMENSION num_cols = cinfo->image_width;
  while (--num_rows >= 0) {
    inptr = *input_buf++;
    outptr = output_buf[0][output_row++];
    for (col = 0; col < num_cols; col++) {
      outptr[col] = inptr[0];
      inptr += instride;
    }
  }
}