void CLASS parseSamsungMakernotes(int base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer)
{
   int i, c;
   if (tag == 0x0002) {
     if (get4() == 0x2000) {
       imgdata.lens.makernotes.CameraMount = LIBRAW_MOUNT_Samsung_NX;
     } else if (!strncmp(model, "NX mini", 7)) {
       imgdata.lens.makernotes.CameraMount = LIBRAW_MOUNT_Samsung_NX_M;
     } else {
       imgdata.lens.makernotes.CameraMount = LIBRAW_MOUNT_FixedLens;
       imgdata.lens.makernotes.LensMount = LIBRAW_MOUNT_FixedLens;
     }

   } else if (tag == 0x0003) {
     imgdata.lens.makernotes.CamID = unique_id = get4();

   } else if (tag == 0x0043) {
     if ((i = get4())) {
       imgdata.other.CameraTemperature = (float)i;
       if (get4() == 10)
         imgdata.other.CameraTemperature /= 10.0f;
     }

    } else if ((tag == 0xa002) && (dng_writer != AdobeDNG)) {
        stmread(imgdata.shootinginfo.BodySerial, len, ifp);

   } else if (tag == 0xa003) {
     imgdata.lens.makernotes.LensID = get2();
     if (imgdata.lens.makernotes.LensID)
       imgdata.lens.makernotes.LensMount = LIBRAW_MOUNT_Samsung_NX;

   } else if (tag == 0xa005) {
     stmread(imgdata.lens.InternalLensSerial, len, ifp);

   } else if (tag == 0xa010) {
     FORC4 imgdata.makernotes.samsung.ImageSizeFull[c] = get4();
     FORC4 imgdata.makernotes.samsung.ImageSizeCrop[c] = get4();

   } else if ((tag == 0xa011) && ((len == 1) || (len == 2)) && (type == 3)) {
        imgdata.makernotes.samsung.ColorSpace[0] = (int)get2();
        if (len == 2) imgdata.makernotes.samsung.ColorSpace[1] = (int)get2();

   } else if (tag == 0xa019) {
     imgdata.lens.makernotes.CurAp = getreal(type);

   } else if ((tag == 0xa01a) && (!imgdata.lens.FocalLengthIn35mmFormat)) {
     imgdata.lens.makernotes.FocalLengthIn35mmFormat = get4() / 10.0f;

   } else if (tag == 0xa020) {
     FORC(11) imgdata.makernotes.samsung.SamsungKey[c] = get4();

   } else if ((tag == 0xa021)   && (dng_writer == nonDNG)){
     FORC4 cam_mul[c ^ (c >> 1)] =
        get4() - imgdata.makernotes.samsung.SamsungKey[c];

  } else if (tag == 0xa022) {
    FORC4 imgdata.color.WB_Coeffs[LIBRAW_WBI_Auto][c ^ (c >> 1)] =
      get4() - imgdata.makernotes.samsung.SamsungKey[c + 4];
    if (imgdata.color.WB_Coeffs[LIBRAW_WBI_Auto][0] < (imgdata.color.WB_Coeffs[LIBRAW_WBI_Auto][1] >> 1))
    {
      imgdata.color.WB_Coeffs[LIBRAW_WBI_Auto][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Auto][1] >> 4;
      imgdata.color.WB_Coeffs[LIBRAW_WBI_Auto][3] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Auto][3] >> 4;
    }

  } else if (tag == 0xa023) {
    imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][0] =
      get4() - imgdata.makernotes.samsung.SamsungKey[8];
    imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][1] =
      get4() - imgdata.makernotes.samsung.SamsungKey[9];
    imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][3] =
      get4() - imgdata.makernotes.samsung.SamsungKey[10];
    imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][2] =
      get4() - imgdata.makernotes.samsung.SamsungKey[0];
    if (imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][0] < (imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][1] >> 1))
    {
      imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][1] >> 4;
      imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][3] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][3] >> 4;
    }

  } else if (tag == 0xa024) {
    FORC4 imgdata.color.WB_Coeffs[LIBRAW_WBI_D65][c ^ (c >> 1)] =
            get4() - imgdata.makernotes.samsung.SamsungKey[c + 1];
    if (imgdata.color.WB_Coeffs[LIBRAW_WBI_D65][0] < (imgdata.color.WB_Coeffs[LIBRAW_WBI_D65][1] >> 1))
    {
      imgdata.color.WB_Coeffs[LIBRAW_WBI_D65][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_D65][1] >> 4;
      imgdata.color.WB_Coeffs[LIBRAW_WBI_D65][3] = imgdata.color.WB_Coeffs[LIBRAW_WBI_D65][3] >> 4;
    }

  } else if (tag == 0xa025) {
      unsigned t = get4() + imgdata.makernotes.samsung.SamsungKey[0];
      if (t == 4096) imgdata.makernotes.samsung.DigitalGain = 1.0;
      else imgdata.makernotes.samsung.DigitalGain = ((double)t) / 4096.0;

  } else if ((tag == 0xa028)  && (dng_writer == nonDNG)) {
        FORC4 cblack[c ^ (c >> 1)] = get4() - imgdata.makernotes.samsung.SamsungKey[c];

  } else if ((tag == 0xa030) && (len == 9)) {
    for (i = 0; i < 3; i++)
      FORC3 imgdata.color.ccm[i][c] =
        (float)((short)((get4() + imgdata.makernotes.samsung.SamsungKey[i * 3 + c]))) / 256.0;

  } else if ((tag == 0xa032) && (len == 9) && (dng_writer == nonDNG)) {
    double aRGB_cam[3][3];
    FORC(9) ((double *)aRGB_cam)[c] =
        ((double)((short)((get4() + imgdata.makernotes.samsung.SamsungKey[c])))) / 256.0;
    aRGB_coeff(aRGB_cam);
  }

}