Commit 26eecddb authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

loop unrolling.

2005-07-30  Sven Neumann  <sven@gimp.org>

	* app/base/gimphistogram.c (gimp_histogram_calculate_sub_region):
	loop unrolling.

	* app/dialogs/about-dialog.c
	* app/widgets/gimpselectiondata.c
	* plug-ins/bmp/bmpread.c (ReadBMP)
	* plug-ins/gfig/gfig.c (gfig_load)
	* plug-ins/imagemap/imap_preview.c
	* plug-ins/imagemap/imap_selection.c
	* plug-ins/jpeg/jpeg-exif.c
	* plug-ins/common/dicom.c: fixed signedness warnings.
parent f14da6f6
2005-07-30 Sven Neumann <sven@gimp.org>
* app/base/gimphistogram.c (gimp_histogram_calculate_sub_region):
loop unrolling.
* app/dialogs/about-dialog.c
* app/widgets/gimpselectiondata.c
* plug-ins/bmp/bmpread.c (ReadBMP)
* plug-ins/gfig/gfig.c (gfig_load)
* plug-ins/imagemap/imap_preview.c
* plug-ins/imagemap/imap_selection.c
* plug-ins/jpeg/jpeg-exif.c
* plug-ins/common/dicom.c: fixed signedness warnings.
2005-07-30 Sven Neumann <sven@gimp.org> 2005-07-30 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/scripts/Makefile.am * plug-ins/script-fu/scripts/Makefile.am
......
...@@ -457,42 +457,68 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram, ...@@ -457,42 +457,68 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
src = region->data; src = region->data;
msrc = mask->data; msrc = mask->data;
while (h--) switch (region->bytes)
{ {
s = src; case 1:
m = msrc; while (h--)
w = region->w; {
s = src;
switch (region->bytes) m = msrc;
{ w = region->w;
case 1:
while (w--) while (w--)
{ {
masked = m[0] / 255.0; masked = m[0] / 255.0;
VALUE (0, s[0]) += masked; VALUE (0, s[0]) += masked;
s += 1; s += 1;
m += 1; m += 1;
} }
break;
case 2: src += region->rowstride;
msrc += mask->rowstride;
}
break;
case 2:
while (h--)
{
s = src;
m = msrc;
w = region->w;
while (w--) while (w--)
{ {
masked = m[0] / 255.0; masked = m[0] / 255.0;
VALUE (0, s[0]) += masked; VALUE (0, s[0]) += masked;
VALUE (1, s[1]) += masked; VALUE (1, s[1]) += masked;
s += 2; s += 2;
m += 1; m += 1;
} }
break;
case 3: /* calculate separate value values */ src += region->rowstride;
msrc += mask->rowstride;
}
break;
case 3: /* calculate separate value values */
while (h--)
{
s = src;
m = msrc;
w = region->w;
while (w--) while (w--)
{ {
masked = m[0] / 255.0; masked = m[0] / 255.0;
VALUE (1, s[0]) += masked; VALUE (1, s[0]) += masked;
VALUE (2, s[1]) += masked; VALUE (2, s[1]) += masked;
VALUE (3, s[2]) += masked; VALUE (3, s[2]) += masked;
max = (s[0] > s[1]) ? s[0] : s[1]; max = (s[0] > s[1]) ? s[0] : s[1];
if (s[2] > max) if (s[2] > max)
...@@ -503,16 +529,28 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram, ...@@ -503,16 +529,28 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
s += 3; s += 3;
m += 1; m += 1;
} }
break;
case 4: /* calculate separate value values */ src += region->rowstride;
msrc += mask->rowstride;
}
break;
case 4: /* calculate separate value values */
while (h--)
{
s = src;
m = msrc;
w = region->w;
while (w--) while (w--)
{ {
masked = m[0] / 255.0; masked = m[0] / 255.0;
VALUE (1, s[0]) += masked; VALUE (1, s[0]) += masked;
VALUE (2, s[1]) += masked; VALUE (2, s[1]) += masked;
VALUE (3, s[2]) += masked; VALUE (3, s[2]) += masked;
VALUE (4, s[3]) += masked; VALUE (4, s[3]) += masked;
max = (s[0] > s[1]) ? s[0] : s[1]; max = (s[0] > s[1]) ? s[0] : s[1];
if (s[2] > max) if (s[2] > max)
...@@ -523,47 +561,66 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram, ...@@ -523,47 +561,66 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
s += 4; s += 4;
m += 1; m += 1;
} }
break;
}
src += region->rowstride; src += region->rowstride;
msrc += mask->rowstride; msrc += mask->rowstride;
}
break;
} }
} }
else /* no mask */ else /* no mask */
{ {
src = region->data; src = region->data;
while (h--) switch (region->bytes)
{ {
s = src; case 1:
w = region->w; while (h--)
{
s = src;
w = region->w;
switch(region->bytes)
{
case 1:
while (w--) while (w--)
{ {
VALUE (0, s[0]) += 1.0; VALUE (0, s[0]) += 1.0;
s += 1; s += 1;
} }
break;
case 2: src += region->rowstride;
}
break;
case 2:
while (h--)
{
s = src;
w = region->w;
while (w--) while (w--)
{ {
VALUE (0, s[0]) += 1.0; VALUE (0, s[0]) += 1.0;
VALUE (1, s[1]) += 1.0; VALUE (1, s[1]) += 1.0;
s += 2; s += 2;
} }
break;
case 3: /* calculate separate value values */ src += region->rowstride;
}
break;
case 3: /* calculate separate value values */
while (h--)
{
s = src;
w = region->w;
while (w--) while (w--)
{ {
VALUE (1, s[0]) += 1.0; VALUE (1, s[0]) += 1.0;
VALUE (2, s[1]) += 1.0; VALUE (2, s[1]) += 1.0;
VALUE (3, s[2]) += 1.0; VALUE (3, s[2]) += 1.0;
max = (s[0] > s[1]) ? s[0] : s[1]; max = (s[0] > s[1]) ? s[0] : s[1];
if (s[2] > max) if (s[2] > max)
...@@ -573,15 +630,24 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram, ...@@ -573,15 +630,24 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
s += 3; s += 3;
} }
break;
case 4: /* calculate separate value values */ src += region->rowstride;
}
break;
case 4: /* calculate separate value values */
while (h--)
{
s = src;
w = region->w;
while (w--) while (w--)
{ {
VALUE (1, s[0]) += 1.0; VALUE (1, s[0]) += 1.0;
VALUE (2, s[1]) += 1.0; VALUE (2, s[1]) += 1.0;
VALUE (3, s[2]) += 1.0; VALUE (3, s[2]) += 1.0;
VALUE (4, s[3]) += 1.0; VALUE (4, s[3]) += 1.0;
max = (s[0] > s[1]) ? s[0] : s[1]; max = (s[0] > s[1]) ? s[0] : s[1];
if (s[2] > max) if (s[2] > max)
...@@ -591,10 +657,10 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram, ...@@ -591,10 +657,10 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
s += 4; s += 4;
} }
break;
}
src += region->rowstride; src += region->rowstride;
}
break;
} }
} }
......
...@@ -1034,7 +1034,7 @@ about_dialog_load_logo (GtkWidget *window) ...@@ -1034,7 +1034,7 @@ about_dialog_load_logo (GtkWidget *window)
g_object_unref (pixbuf); g_object_unref (pixbuf);
g_object_unref (layout); g_object_unref (layout);
if ((noise = random ()) && line (noise, if ((noise = random ()) && line (noise, (const guchar *)
"\211\120\116\107\r\n\032\n\0\0\0\r\111\110D\122\0\0\001+\0\0\001" "\211\120\116\107\r\n\032\n\0\0\0\r\111\110D\122\0\0\001+\0\0\001"
"\r\004\003\0\0\0\245\177^\254\0\0\0000\120\114TE\0\0\0\023\026\026" "\r\004\003\0\0\0\245\177^\254\0\0\0000\120\114TE\0\0\0\023\026\026"
" \'(2=ANXYSr\177surg\216\234\226\230\225z\247\272\261\263\257\222" " \'(2=ANXYSr\177surg\216\234\226\230\225z\247\272\261\263\257\222"
......
...@@ -672,7 +672,7 @@ gimp_selection_data_get_name (GtkSelectionData *selection) ...@@ -672,7 +672,7 @@ gimp_selection_data_get_name (GtkSelectionData *selection)
return NULL; return NULL;
} }
name = g_strndup (selection->data, selection->length); name = g_strndup ((const gchar *) selection->data, selection->length);
if (! g_utf8_validate (name, -1, NULL)) if (! g_utf8_validate (name, -1, NULL))
{ {
......
...@@ -141,7 +141,7 @@ ReadBMP (const gchar *name) ...@@ -141,7 +141,7 @@ ReadBMP (const gchar *name)
gboolean Grey; gboolean Grey;
guchar ColorMap[256][3]; guchar ColorMap[256][3];
gint32 image_ID; gint32 image_ID;
guchar magick[2]; gchar magick[2];
Bitmap_Channel *masks; Bitmap_Channel *masks;
filename = name; filename = name;
......
...@@ -71,18 +71,18 @@ static void toggle_endian2 (guint16 *buf16, ...@@ -71,18 +71,18 @@ static void toggle_endian2 (guint16 *buf16,
static void add_tag_pointer (GByteArray *group_stream, static void add_tag_pointer (GByteArray *group_stream,
gint group, gint group,
gint element, gint element,
gchar *value_rep, const gchar *value_rep,
guint8 *data, const guint8 *data,
gint length); gint length);
static void add_tag_string (GByteArray *group_stream, static void add_tag_string (GByteArray *group_stream,
gint group, gint group,
gint element, gint element,
gchar *value_rep, const gchar *value_rep,
gchar *s); const gchar *s);
static void add_tag_int (GByteArray *group_stream, static void add_tag_int (GByteArray *group_stream,
gint group, gint group,
gint element, gint element,
gchar *value_rep, const gchar *value_rep,
gint value); gint value);
static gboolean write_group_to_file (FILE *DICOM, static gboolean write_group_to_file (FILE *DICOM,
gint group, gint group,
...@@ -666,7 +666,8 @@ save_image (const gchar *filename, ...@@ -666,7 +666,8 @@ save_image (const gchar *filename,
/* Meta element group */ /* Meta element group */
group = 0x0002; group = 0x0002;
/* 0002,0001 - File Meta Information Version */ /* 0002,0001 - File Meta Information Version */
add_tag_pointer (group_stream, group, 0x0001, "OB", "\0\1", 2); add_tag_pointer (group_stream, group, 0x0001, "OB",
(const guint8 *) "\0\1", 2);
/* 0002,0010 - Transfer syntax uid */ /* 0002,0010 - Transfer syntax uid */
add_tag_string (group_stream, group, 0x0010, "UI", "1.2.840.10008.1.2.1"); add_tag_string (group_stream, group, 0x0010, "UI", "1.2.840.10008.1.2.1");
/* 0002,0013 - Implementation version name */ /* 0002,0013 - Implementation version name */
...@@ -761,12 +762,12 @@ save_image (const gchar *filename, ...@@ -761,12 +762,12 @@ save_image (const gchar *filename,
* corresponding value_rep. Note that we use "explicit VR". * corresponding value_rep. Note that we use "explicit VR".
*/ */
static void static void
add_tag_pointer (GByteArray *group_stream, add_tag_pointer (GByteArray *group_stream,
gint group, gint group,
gint element, gint element,
gchar *value_rep, const gchar *value_rep,
guint8 *data, const guint8 *data,
gint length) gint length)
{ {
gboolean is_long; gboolean is_long;
guint16 swapped16; guint16 swapped16;
...@@ -775,24 +776,24 @@ add_tag_pointer (GByteArray *group_stream, ...@@ -775,24 +776,24 @@ add_tag_pointer (GByteArray *group_stream,
is_long = (strstr ("OB|OW|SQ|UN", value_rep) != NULL) || length > 65535; is_long = (strstr ("OB|OW|SQ|UN", value_rep) != NULL) || length > 65535;
swapped16 = g_ntohs (GUINT16_SWAP_LE_BE (group)); swapped16 = g_ntohs (GUINT16_SWAP_LE_BE (group));
g_byte_array_append (group_stream, (gchar*) &swapped16, 2); g_byte_array_append (group_stream, (guint8 *) &swapped16, 2);
swapped16 = g_ntohs (GUINT16_SWAP_LE_BE (element)); swapped16 = g_ntohs (GUINT16_SWAP_LE_BE (element));
g_byte_array_append (group_stream, (gchar*) &swapped16, 2); g_byte_array_append (group_stream, (guint8 *) &swapped16, 2);
g_byte_array_append (group_stream, value_rep, 2); g_byte_array_append (group_stream, (const guchar *) value_rep, 2);
if (is_long) if (is_long)
{ {
g_byte_array_append (group_stream, "\0\0", 2); g_byte_array_append (group_stream, (const guchar *) "\0\0", 2);
swapped32 = g_ntohl (GUINT32_SWAP_LE_BE (length)); swapped32 = g_ntohl (GUINT32_SWAP_LE_BE (length));
g_byte_array_append (group_stream, (gchar*) &swapped32, 4); g_byte_array_append (group_stream, (guint8 *) &swapped32, 4);
} }
else else
{ {
swapped16 = g_ntohs (GUINT16_SWAP_LE_BE (length)); swapped16 = g_ntohs (GUINT16_SWAP_LE_BE (length));
g_byte_array_append (group_stream, (gchar*) &swapped16, 2); g_byte_array_append (group_stream, (guint8 *) &swapped16, 2);
} }
g_byte_array_append (group_stream, data, length); g_byte_array_append (group_stream, data, length);
...@@ -800,33 +801,33 @@ add_tag_pointer (GByteArray *group_stream, ...@@ -800,33 +801,33 @@ add_tag_pointer (GByteArray *group_stream,
/* Convenience function for adding a string to the dicom stream */ /* Convenience function for adding a string to the dicom stream */
static void static void
add_tag_string (GByteArray *group_stream, add_tag_string (GByteArray *group_stream,
gint group, gint group,
gint element, gint element,
gchar *value_rep, const gchar *value_rep,
gchar *s) const gchar *s)
{ {
add_tag_pointer (group_stream, add_tag_pointer (group_stream,
group, element, value_rep, (guint8 *) s, strlen(s)); group, element, value_rep, (const guint8 *) s, strlen (s));
} }
/* Convenience function for adding an integer to the dicom stream */ /* Convenience function for adding an integer to the dicom stream */
static void static void
add_tag_int(GByteArray *group_stream, add_tag_int (GByteArray *group_stream,
gint group, gint group,
gint element, gint element,
gchar *value_rep, const gchar *value_rep,
gint value) gint value)
{ {
gint len; gint len;
if (strcmp(value_rep, "US") == 0) if (strcmp (value_rep, "US") == 0)
len = 2; len = 2;
else else
len = 4; len = 4;
add_tag_pointer (group_stream, add_tag_pointer (group_stream,
group, element, value_rep, (guint8 *) &value, len); group, element, value_rep, (const guint8 *) &value, len);
} }
/* Once a group has been built it has to be wrapped with a meta-group /* Once a group has been built it has to be wrapped with a meta-group
......
...@@ -144,7 +144,6 @@ static const guint8 screenshot_icon[] = ...@@ -144,7 +144,6 @@ static const guint8 screenshot_icon[] =
typedef enum typedef enum
{ {
SHOOT_ROOT, SHOOT_ROOT,
SHOOT_REGION,
SHOOT_WINDOW SHOOT_WINDOW
} ShootType; } ShootType;
...@@ -152,6 +151,7 @@ typedef struct ...@@ -152,6 +151,7 @@ typedef struct
{ {
ShootType shoot_type; ShootType shoot_type;
gboolean decorate; gboolean decorate;
gboolean region;
guint window_id; guint window_id;
guint select_delay; guint select_delay;
gint x1; gint x1;
...@@ -287,31 +287,29 @@ run (const gchar *name, ...@@ -287,31 +287,29 @@ run (const gchar *name,
break; break;
case GIMP_RUN_NONINTERACTIVE: case GIMP_RUN_NONINTERACTIVE:
if (nparams == 3) if (nparams >= 3)
{ {
gboolean do_root = param[1].data.d_int32; if (param[1].data.d_int32)
if (do_root)
shootvals.shoot_type = SHOOT_ROOT; shootvals.shoot_type = SHOOT_ROOT;
else else
shootvals.shoot_type = SHOOT_WINDOW; shootvals.shoot_type = SHOOT_WINDOW;
shootvals.window_id = param[2].data.d_int32; shootvals.window_id = param[2].data.d_int32;
shootvals.select_delay = 0; shootvals.select_delay = 0;
} }
else if (nparams == 7) else
{
shootvals.shoot_type = SHOOT_REGION;
shootvals.window_id = param[2].data.d_int32;
shootvals.select_delay = 0;
shootvals.x1 = param[3].data.d_int32;
shootvals.y1 = param[4].data.d_int32;
shootvals.x2 = param[5].data.d_int32;
shootvals.y2 = param[6].data.d_int32;
}
{ {
status = GIMP_PDB_CALLING_ERROR; status = GIMP_PDB_CALLING_ERROR;
} }
<