Commit 59707501 authored by Sven Neumann's avatar Sven Neumann

further code cleanup and some documentation

svn path=/trunk/; revision=26752
parent c206db2c
......@@ -38,6 +38,15 @@
(((h) + (TILE_HEIGHT - 1)) / TILE_HEIGHT))
static void scale_determine_levels (PixelRegion *srcPR,
PixelRegion *dstPR,
gint *levelx,
gint *levely);
static gint scale_determine_progress (PixelRegion *srcPR,
PixelRegion *dstPR,
gint levelx,
gint levely);
static void scale_region_buffer (PixelRegion *srcPR,
PixelRegion *dstPR,
GimpInterpolationType interpolation,
......@@ -58,6 +67,7 @@ static void scale (TileManager *srcTM,
static void scale_pr (PixelRegion *srcPR,
PixelRegion *dstPR,
GimpInterpolationType interpolation);
static void interpolate_bilinear (TileManager *srcTM,
const gint x0,
const gint y0,
......@@ -114,14 +124,6 @@ static void interpolate_bilinear_pr (PixelRegion *srcPR,
const gdouble xfrac,
const gdouble yfrac,
guchar *pixel);
static void determine_levels (PixelRegion *srcPR,
PixelRegion *dstPR,
gint *levelx,
gint *levely);
static gint determine_progress (PixelRegion *srcPR,
PixelRegion *dstPR,
gint levelx,
gint levely);
static inline void gaussan_lanczos2 (const guchar *pixels,
const gint bytes,
guchar *pixel);
......@@ -163,7 +165,7 @@ static inline gdouble lanczos3_mul (const guchar *pixels,
static void
determine_levels (PixelRegion *srcPR,
scale_determine_levels (PixelRegion *srcPR,
PixelRegion *dstPR,
gint *levelx,
gint *levely)
......@@ -203,8 +205,12 @@ determine_levels (PixelRegion *srcPR,
}
}
/* This function calculates the number of tiles that are written in
* one scale operation. This number is used as the max_progress
* parameter in calls to GimpProgressFunc.
*/
static gint
determine_progress (PixelRegion *srcPR,
scale_determine_progress (PixelRegion *srcPR,
PixelRegion *dstPR,
gint levelx,
gint levely)
......@@ -213,6 +219,8 @@ determine_progress (PixelRegion *srcPR,
gint height = srcPR->h;
gint tiles = 0;
/* The logic here should be kept in sync with scale_region_buffer(). */
while (levelx < 0 && levely < 0)
{
width <<= 1;
......@@ -287,8 +295,8 @@ scale_region_buffer (PixelRegion *srcPR,
gint levely = 0;
/* determine scaling levels */
determine_levels (srcPR, dstPR, &levelx, &levely);
max_progress = determine_progress (srcPR, dstPR, levelx, levely);
scale_determine_levels (srcPR, dstPR, &levelx, &levely);
max_progress = scale_determine_progress (srcPR, dstPR, levelx, levely);
pixel_region_init_data (&tmpPR0,
g_memdup (srcPR->data, width * height * bytes),
......@@ -431,8 +439,8 @@ scale_region_tile (PixelRegion *srcPR,
gint levely = 0;
/* determine scaling levels */
determine_levels (srcPR, dstPR, &levelx, &levely);
max_progress = determine_progress (srcPR, dstPR, levelx, levely);
scale_determine_levels (srcPR, dstPR, &levelx, &levely);
max_progress = scale_determine_progress (srcPR, dstPR, levelx, levely);
if (levelx == 0 && levely == 0)
{
......@@ -653,8 +661,7 @@ scale (TileManager *srcTM,
decimate_lanczos2 (srcTM, sx0, sy0, pixel);
else
interpolate_lanczos3 (srcTM, sx0, sy0, sx1, sy1,
xfrac, yfrac, pixel,
kernel_lookup);
xfrac, yfrac, pixel, kernel_lookup);
break;
}
......@@ -1234,7 +1241,8 @@ interpolate_bilinear (TileManager *srcTM,
alphasum = weighted_sum (xfrac, yfrac, p1[1], p2[1], p3[1], p4[1]);
if (alphasum > 0)
{
sum = weighted_sum (xfrac, yfrac, p1[0] * p1[1], p2[0] * p2[1],
sum = weighted_sum (xfrac, yfrac,
p1[0] * p1[1], p2[0] * p2[1],
p3[0] * p3[1], p4[0] * p4[1]);
sum /= alphasum;
......@@ -1261,7 +1269,8 @@ interpolate_bilinear (TileManager *srcTM,
{
for (b = 0; b < 3; b++)
{
sum = weighted_sum (xfrac, yfrac, p1[b] * p1[3], p2[b] * p2[3],
sum = weighted_sum (xfrac, yfrac,
p1[b] * p1[3], p2[b] * p2[3],
p3[b] * p3[3], p4[b] * p4[3]);
sum /= alphasum;
pixel[b] = (guchar) CLAMP (sum, 0, 255);
......@@ -1495,7 +1504,8 @@ interpolate_lanczos3 (TileManager *srcTM,
gint b, i;
gint x, y;
gdouble kx_sum, ky_sum;
gdouble x_kernel[6], y_kernel[6];
gdouble x_kernel[6];
gdouble y_kernel[6];
guchar pixels[36 * 4];
gdouble sum, alphasum;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment