int LibRaw::subtract_black_internal()
{
  CHECK_ORDER_LOW(LIBRAW_PROGRESS_RAW2_IMAGE);

  try
  {
    if (!is_phaseone_compressed() &&
        (C.cblack[0] || C.cblack[1] || C.cblack[2] || C.cblack[3] ||
         (C.cblack[4] && C.cblack[5])))
    {
      int cblk[4], i;
      for (i = 0; i < 4; i++)
        cblk[i] = C.cblack[i];

      int size = S.iheight * S.iwidth;
      int dmax = 0;
      if (C.cblack[4] && C.cblack[5])
      {
        for (i = 0; i < size * 4; i++)
        {
          int val = imgdata.image[0][i];
          val -= C.cblack[6 + i / 4 / S.iwidth % C.cblack[4] * C.cblack[5] +
                          i / 4 % S.iwidth % C.cblack[5]];
          val -= cblk[i & 3];
          imgdata.image[0][i] = CLIP(val);
          if (dmax < val)
            dmax = val;
        }
      }
      else
      {
        for (i = 0; i < size * 4; i++)
        {
          int val = imgdata.image[0][i];
          val -= cblk[i & 3];
          imgdata.image[0][i] = CLIP(val);
          if (dmax < val)
            dmax = val;
        }
      }
      C.data_maximum = dmax & 0xffff;
      C.maximum -= C.black;
      ZERO(C.cblack); // Yeah, we used cblack[6+] values too!
      C.black = 0;
    }
    else
    {
      // Nothing to Do, maximum is already calculated, black level is 0, so no
      // change only calculate channel maximum;
      int idx;
      ushort *p = (ushort *)imgdata.image;
      int dmax = 0;
      for (idx = 0; idx < S.iheight * S.iwidth * 4; idx++)
        if (dmax < p[idx])
          dmax = p[idx];
      C.data_maximum = dmax;
    }
    return 0;
  }
  catch (LibRaw_exceptions err)
  {
    EXCEPTION_HANDLER(err);
  }
}
Unknown