minor cleanup, inline pixel_intensity() and pixel_copy().

2005-03-11  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/despeckle.c: minor cleanup, inline
	pixel_intensity() and pixel_copy().
This commit is contained in:
Sven Neumann 2005-03-11 12:52:12 +00:00 committed by Sven Neumann
parent 1dde12fb00
commit 133d55070a
2 changed files with 53 additions and 40 deletions

View File

@ -1,3 +1,8 @@
2005-03-11 Sven Neumann <sven@gimp.org>
* plug-ins/common/despeckle.c: minor cleanup, inline
pixel_intensity() and pixel_copy().
2005-03-10 Manish Singh <yosh@gimp.org>
* plug-ins/uri/url-backend-wget.c: force the server-response wget

View File

@ -99,11 +99,11 @@ static void preview_update (GtkWidget *preview);
static gint quick_median_select (guchar **p,
guchar *i,
gint n);
static guchar pixel_intensity (const guchar *p,
static inline guchar pixel_intensity (const guchar *p,
gint bpp);
static void pixel_copy (guchar *dest,
static inline void pixel_copy (guchar *dest,
const guchar *src,
gint n);
gint bpp);
/*
* Globals...
@ -737,29 +737,28 @@ despeckle_median (guchar *src,
g_free (ibuf);
}
/* * This Quickselect routine is based on the algorithm described in
/*
* This Quickselect routine is based on the algorithm described in
* "Numerical recipes in C", Second Edition,
* Cambridge University Press, 1992, Section 8.5, ISBN 0-521-43108-5
* This code by Nicolas Devillard - 1998. Public domain.
*
* modified to swap pointers: swap is done by comparing intensity value
* for the pointer to RGB
* Modified to swap pointers: swap is done by comparing intensity
* value for the pointer to RGB.
*/
static gint
quick_median_select (guchar **p,
guchar *i,
gint n)
{
gint low, high ;
gint median;
gint low = 0;
gint high = n - 1;
gint median = (low + high) / 2;
while (TRUE)
{
gint middle, ll, hh;
low = 0 ;
high = n-1 ;
median = (low + high) / 2;
for (;;)
{
if (high <= low) /* One element only */
return median;
@ -798,13 +797,13 @@ quick_median_select (guchar **p,
/* Swap low item (now in position middle) into position (low+1) */
VALUE_SWAP (i[middle], i[low+1]);
POINTER_SWAP (p[middle], p[low+1])
POINTER_SWAP (p[middle], p[low+1]);
/* Nibble from each end towards middle, swapping items when stuck */
ll = low + 1;
hh = high;
for (;;)
while (TRUE)
{
do ll++;
while (i[low] > i[ll]);
@ -833,19 +832,28 @@ quick_median_select (guchar **p,
static guchar
pixel_intensity (const guchar *p,
gint n)
gint bpp)
{
if (n != 3)
switch (bpp)
{
case 1:
case 2:
return p[0];
case 3:
case 4:
return GIMP_RGB_INTENSITY (p[0], p[1], p[2]);
default:
return 0; /* should not be reached */
}
}
static void
static inline void
pixel_copy (guchar *dest,
const guchar *src,
gint n)
gint bpp)
{
for (; n > 0; n--, dest++, src++)
for (; bpp > 0; bpp--, dest++, src++)
*dest = *src;
}