void dng_opcode_GainMap::ProcessArea (dng_negative & /* negative */, uint32 /* threadIndex */, dng_pixel_buffer &buffer, const dng_rect &dstArea, const dng_rect &imageBounds) { dng_rect overlap = fAreaSpec.Overlap (dstArea); if (overlap.NotEmpty ()) { uint32 cols = overlap.W (); uint32 colPitch = fAreaSpec.ColPitch (); for (uint32 plane = fAreaSpec.Plane (); plane < fAreaSpec.Plane () + fAreaSpec.Planes () && plane < buffer.Planes (); plane++) { uint32 mapPlane = Min_uint32 (plane, fGainMap->Planes () - 1); for (int32 row = overlap.t; row < overlap.b; row += fAreaSpec.RowPitch ()) { real32 *dPtr = buffer.DirtyPixel_real32 (row, overlap.l, plane); dng_gain_map_interpolator interp (*fGainMap, imageBounds, row, overlap.l, mapPlane); for (uint32 col = 0; col < cols; col += colPitch) { real32 gain = interp.Interpolate (); dPtr [col] = Min_real32 (dPtr [col] * gain, 1.0f); for (uint32 j = 0; j < colPitch; j++) { interp.Increment (); } } } } } }
void dng_opcode_ScalePerColumn::ProcessArea (dng_negative & /* negative */, uint32 /* threadIndex */, dng_pixel_buffer &buffer, const dng_rect &dstArea, const dng_rect & /* imageBounds */) { dng_rect overlap = fAreaSpec.Overlap (dstArea); if (overlap.NotEmpty ()) { uint32 rows = (overlap.W () + fAreaSpec.RowPitch () - 1) / fAreaSpec.RowPitch (); int32 rowStep = buffer.RowStep () * fAreaSpec.RowPitch (); for (uint32 plane = fAreaSpec.Plane (); plane < fAreaSpec.Plane () + fAreaSpec.Planes () && plane < buffer.Planes (); plane++) { const real32 *table = fTable->Buffer_real32 () + ((overlap.l - fAreaSpec.Area ().l) / fAreaSpec.ColPitch ()); for (int32 col = overlap.l; col < overlap.r; col += fAreaSpec.ColPitch ()) { real32 colScale = *(table++); real32 *dPtr = buffer.DirtyPixel_real32 (overlap.t, col, plane); for (uint32 row = 0; row < rows; row++) { real32 x = dPtr [0]; real32 y = x * colScale; dPtr [0] = Min_real32 (y, 1.0f); dPtr += rowStep; } } } } }
void dng_opcode_ScalePerRow::ProcessArea (dng_negative & /* negative */, uint32 /* threadIndex */, dng_pixel_buffer &buffer, const dng_rect &dstArea, const dng_rect & /* imageBounds */) { dng_rect overlap = fAreaSpec.Overlap (dstArea); if (overlap.NotEmpty ()) { uint32 cols = overlap.W (); uint32 colPitch = fAreaSpec.ColPitch (); for (uint32 plane = fAreaSpec.Plane (); plane < fAreaSpec.Plane () + fAreaSpec.Planes () && plane < buffer.Planes (); plane++) { const real32 *table = fTable->Buffer_real32 () + ((overlap.t - fAreaSpec.Area ().t) / fAreaSpec.RowPitch ()); for (int32 row = overlap.t; row < overlap.b; row += fAreaSpec.RowPitch ()) { real32 rowScale = *(table++); real32 *dPtr = buffer.DirtyPixel_real32 (row, overlap.l, plane); for (uint32 col = 0; col < cols; col += colPitch) { real32 x = dPtr [col]; real32 y = x * rowScale; dPtr [col] = Min_real32 (y, 1.0f); } } } } }
void dng_opcode_MapPolynomial::ProcessArea (dng_negative & /* negative */, uint32 /* threadIndex */, dng_pixel_buffer &buffer, const dng_rect &dstArea, const dng_rect & /* imageBounds */) { dng_rect overlap = fAreaSpec.Overlap (dstArea); if (overlap.NotEmpty ()) { uint32 cols = overlap.W (); uint32 colPitch = fAreaSpec.ColPitch (); for (uint32 plane = fAreaSpec.Plane (); plane < fAreaSpec.Plane () + fAreaSpec.Planes () && plane < buffer.Planes (); plane++) { for (int32 row = overlap.t; row < overlap.b; row += fAreaSpec.RowPitch ()) { real32 *dPtr = buffer.DirtyPixel_real32 (row, overlap.l, plane); switch (fDegree) { case 0: { real32 y = Pin_real32 (0.0f, fCoefficient32 [0], 1.0f); for (uint32 col = 0; col < cols; col += colPitch) { dPtr [col] = y; } break; } case 1: { real32 c0 = fCoefficient32 [0]; real32 c1 = fCoefficient32 [1]; if (c0 == 0.0f) { if (c1 > 0.0f) { for (uint32 col = 0; col < cols; col += colPitch) { real32 x = dPtr [col]; real32 y = c1 * x; dPtr [col] = Min_real32 (y, 1.0f); } } else { for (uint32 col = 0; col < cols; col += colPitch) { dPtr [col] = 0.0f; } } } else { for (uint32 col = 0; col < cols; col += colPitch) { real32 x = dPtr [col]; real32 y = c0 + c1 * x; dPtr [col] = Pin_real32 (0.0f, y, 1.0f); } } break; } case 2: { for (uint32 col = 0; col < cols; col += colPitch) { real32 x = dPtr [col]; real32 y = fCoefficient32 [0] + x * (fCoefficient32 [1] + x * (fCoefficient32 [2])); dPtr [col] = Pin_real32 (0.0f, y, 1.0f); } break; } case 3: { for (uint32 col = 0; col < cols; col += colPitch) { real32 x = dPtr [col]; real32 y = fCoefficient32 [0] + x * (fCoefficient32 [1] + x * (fCoefficient32 [2] + x * (fCoefficient32 [3]))); dPtr [col] = Pin_real32 (0.0f, y, 1.0f); } break; } case 4: { for (uint32 col = 0; col < cols; col += colPitch) { real32 x = dPtr [col]; real32 y = fCoefficient32 [0] + x * (fCoefficient32 [1] + x * (fCoefficient32 [2] + x * (fCoefficient32 [3] + x * (fCoefficient32 [4])))); dPtr [col] = Pin_real32 (0.0f, y, 1.0f); } break; } default: { for (uint32 col = 0; col < cols; col += colPitch) { real32 x = dPtr [col]; real32 y = fCoefficient32 [0]; real32 xx = x; for (uint32 j = 1; j <= fDegree; j++) { y += fCoefficient32 [j] * xx; xx *= x; } dPtr [col] = Pin_real32 (0.0f, y, 1.0f); } break; } } } } } }