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>
* plug-ins/script-fu/scripts/Makefile.am
......
......@@ -457,42 +457,68 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
src = region->data;
msrc = mask->data;
switch (region->bytes)
{
case 1:
while (h--)
{
s = src;
m = msrc;
w = region->w;
switch (region->bytes)
{
case 1:
while (w--)
{
masked = m[0] / 255.0;
VALUE (0, s[0]) += masked;
s += 1;
m += 1;
}
src += region->rowstride;
msrc += mask->rowstride;
}
break;
case 2:
while (h--)
{
s = src;
m = msrc;
w = region->w;
while (w--)
{
masked = m[0] / 255.0;
VALUE (0, s[0]) += masked;
VALUE (1, s[1]) += masked;
s += 2;
m += 1;
}
src += region->rowstride;
msrc += mask->rowstride;
}
break;
case 3: /* calculate separate value values */
while (h--)
{
s = src;
m = msrc;
w = region->w;
while (w--)
{
masked = m[0] / 255.0;
VALUE (1, s[0]) += masked;
VALUE (2, s[1]) += masked;
VALUE (3, s[2]) += masked;
max = (s[0] > s[1]) ? s[0] : s[1];
if (s[2] > max)
......@@ -503,16 +529,28 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
s += 3;
m += 1;
}
src += region->rowstride;
msrc += mask->rowstride;
}
break;
case 4: /* calculate separate value values */
while (h--)
{
s = src;
m = msrc;
w = region->w;
while (w--)
{
masked = m[0] / 255.0;
VALUE (1, s[0]) += masked;
VALUE (2, s[1]) += masked;
VALUE (3, s[2]) += masked;
VALUE (4, s[3]) += masked;
max = (s[0] > s[1]) ? s[0] : s[1];
if (s[2] > max)
......@@ -523,47 +561,66 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
s += 4;
m += 1;
}
break;
}
src += region->rowstride;
msrc += mask->rowstride;
}
break;
}
}
else /* no mask */
{
src = region->data;
switch (region->bytes)
{
case 1:
while (h--)
{
s = src;
w = region->w;
switch(region->bytes)
{
case 1:
while (w--)
{
VALUE (0, s[0]) += 1.0;
s += 1;
}
src += region->rowstride;
}
break;
case 2:
while (h--)
{
s = src;
w = region->w;
while (w--)
{
VALUE (0, s[0]) += 1.0;
VALUE (1, s[1]) += 1.0;
s += 2;
}
src += region->rowstride;
}
break;
case 3: /* calculate separate value values */
while (h--)
{
s = src;
w = region->w;
while (w--)
{
VALUE (1, s[0]) += 1.0;
VALUE (2, s[1]) += 1.0;
VALUE (3, s[2]) += 1.0;
max = (s[0] > s[1]) ? s[0] : s[1];
if (s[2] > max)
......@@ -573,15 +630,24 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
s += 3;
}
src += region->rowstride;
}
break;
case 4: /* calculate separate value values */
while (h--)
{
s = src;
w = region->w;
while (w--)
{
VALUE (1, s[0]) += 1.0;
VALUE (2, s[1]) += 1.0;
VALUE (3, s[2]) += 1.0;
VALUE (4, s[3]) += 1.0;
max = (s[0] > s[1]) ? s[0] : s[1];
if (s[2] > max)
......@@ -591,11 +657,11 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
s += 4;
}
break;
}
src += region->rowstride;
}
break;
}
}
#ifdef ENABLE_MP
......
......@@ -1034,7 +1034,7 @@ about_dialog_load_logo (GtkWidget *window)
g_object_unref (pixbuf);
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"
"\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"
......
......@@ -672,7 +672,7 @@ gimp_selection_data_get_name (GtkSelectionData *selection)
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))
{
......
......@@ -141,7 +141,7 @@ ReadBMP (const gchar *name)
gboolean Grey;
guchar ColorMap[256][3];
gint32 image_ID;
guchar magick[2];
gchar magick[2];
Bitmap_Channel *masks;
filename = name;
......
......@@ -71,18 +71,18 @@ static void toggle_endian2 (guint16 *buf16,
static void add_tag_pointer (GByteArray *group_stream,
gint group,
gint element,
gchar *value_rep,
guint8 *data,
const gchar *value_rep,
const guint8 *data,
gint length);
static void add_tag_string (GByteArray *group_stream,
gint group,
gint element,
gchar *value_rep,
gchar *s);
const gchar *value_rep,
const gchar *s);
static void add_tag_int (GByteArray *group_stream,
gint group,
gint element,
gchar *value_rep,
const gchar *value_rep,
gint value);
static gboolean write_group_to_file (FILE *DICOM,
gint group,
......@@ -666,7 +666,8 @@ save_image (const gchar *filename,
/* Meta element group */
group = 0x0002;
/* 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 */
add_tag_string (group_stream, group, 0x0010, "UI", "1.2.840.10008.1.2.1");
/* 0002,0013 - Implementation version name */
......@@ -764,8 +765,8 @@ static void
add_tag_pointer (GByteArray *group_stream,
gint group,
gint element,
gchar *value_rep,
guint8 *data,
const gchar *value_rep,
const guint8 *data,
gint length)
{
gboolean is_long;
......@@ -775,24 +776,24 @@ add_tag_pointer (GByteArray *group_stream,
is_long = (strstr ("OB|OW|SQ|UN", value_rep) != NULL) || length > 65535;
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));
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)
{
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));
g_byte_array_append (group_stream, (gchar*) &swapped32, 4);
g_byte_array_append (group_stream, (guint8 *) &swapped32, 4);
}
else
{
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);
......@@ -803,30 +804,30 @@ static void
add_tag_string (GByteArray *group_stream,
gint group,
gint element,
gchar *value_rep,
gchar *s)
const gchar *value_rep,
const gchar *s)
{
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 */
static void
add_tag_int(GByteArray *group_stream,
add_tag_int (GByteArray *group_stream,
gint group,
gint element,
gchar *value_rep,
const gchar *value_rep,
gint value)
{
gint len;
if (strcmp(value_rep, "US") == 0)
if (strcmp (value_rep, "US") == 0)
len = 2;
else
len = 4;
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
......
......@@ -144,7 +144,6 @@ static const guint8 screenshot_icon[] =
typedef enum
{
SHOOT_ROOT,
SHOOT_REGION,
SHOOT_WINDOW
} ShootType;
......@@ -152,6 +151,7 @@ typedef struct
{
ShootType shoot_type;
gboolean decorate;
gboolean region;
guint window_id;
guint select_delay;
gint x1;
......@@ -287,31 +287,29 @@ run (const gchar *name,
break;
case GIMP_RUN_NONINTERACTIVE:
if (nparams == 3)
if (nparams >= 3)
{
gboolean do_root = param[1].data.d_int32;
if (do_root)
if (param[1].data.d_int32)
shootvals.shoot_type = SHOOT_ROOT;
else
shootvals.shoot_type = SHOOT_WINDOW;
shootvals.window_id = param[2].data.d_int32;
shootvals.select_delay = 0;
}
else if (nparams == 7)
else
{
status = GIMP_PDB_CALLING_ERROR;
}
if (nparams == 7)
{
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;
}
if (! gdk_init_check (NULL, NULL))
status = GIMP_PDB_CALLING_ERROR;
break;
......@@ -386,7 +384,7 @@ select_window_x11 (GdkScreen *screen)
x_cursor = XCreateFontCursor (x_dpy, GDK_CROSSHAIR);
buttons = 0;
if (shootvals.shoot_type == SHOOT_REGION)
if (shootvals.region)
{
mask |= PointerMotionMask;
......@@ -462,7 +460,8 @@ select_window_x11 (GdkScreen *screen)
case ButtonRelease:
if (buttons > 0)
buttons--;
if (! buttons && shootvals.shoot_type == SHOOT_REGION)
if (! buttons && shootvals.region)
{
x = MIN (shootvals.x1, shootvals.x2);
y = MIN (shootvals.y1, shootvals.y2);
......@@ -690,19 +689,17 @@ shoot (GdkScreen *screen)
screen_rect.width = gdk_screen_get_width (screen);
screen_rect.height = gdk_screen_get_height (screen);
if (shootvals.shoot_type == SHOOT_ROOT)
{
window = gdk_screen_get_root_window (screen);
if (shootvals.shoot_type == SHOOT_REGION)
if (shootvals.region)
{
rect.x = MIN (shootvals.x1, shootvals.x2);
rect.y = MIN (shootvals.y1, shootvals.y2);
rect.width = ABS (shootvals.x2 - shootvals.x1);
rect.height = ABS (shootvals.y2 - shootvals.y1);
}
else
{
if (shootvals.shoot_type == SHOOT_ROOT)
{
window = gdk_screen_get_root_window (screen);
}
else
{
......@@ -723,7 +720,6 @@ shoot (GdkScreen *screen)
rect.x = x;
rect.y = y;
}
window = gdk_screen_get_root_window (screen);
gdk_window_get_origin (window, &x, &y);
......@@ -767,15 +763,8 @@ shoot_dialog (GdkScreen **screen)
GdkPixbuf *pixbuf;
GSList *radio_group = NULL;
GtkObject *adj;
gboolean region = FALSE;
gboolean run;
if (shootvals.shoot_type == SHOOT_REGION)
{
shootvals.shoot_type = SHOOT_ROOT;
region = TRUE;
}
gimp_ui_init ("screenshot", FALSE);
dialog = gimp_dialog_new (_("Screenshot"), "screenshot",
......@@ -867,7 +856,7 @@ shoot_dialog (GdkScreen **screen)
gtk_widget_show (hbox);
toggle = gtk_check_button_new_with_label (_("Select a region"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), region);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), shootvals.region);
gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, TRUE, 24);
gtk_widget_show (toggle);
......@@ -879,7 +868,7 @@ shoot_dialog (GdkScreen **screen)
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&region);
&shootvals.region);
/* grab delay */
hbox = gtk_hbox_new (FALSE, 6);
......@@ -913,9 +902,6 @@ shoot_dialog (GdkScreen **screen)
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
if (shootvals.shoot_type == SHOOT_ROOT && region)
shootvals.shoot_type = SHOOT_REGION;
if (run)
{
/* get the screen on which we are running */
......@@ -932,7 +918,7 @@ shoot_dialog (GdkScreen **screen)
g_timeout_add (100, (GSourceFunc) gtk_main_quit, NULL);
gtk_main ();
if (shootvals.shoot_type != SHOOT_ROOT && ! shootvals.window_id)
if (shootvals.shoot_type == SHOOT_WINDOW && ! shootvals.window_id)
{
shootvals.window_id = select_window (*screen);
......
......@@ -414,8 +414,8 @@ gfig_load (const gchar *filename,
gint chk_count;
gint load_count = 0;
gdouble version;
guchar magic1[20];
guchar magic2[20];
gchar magic1[20];
gchar magic2[20];
g_assert (filename != NULL);
......
......@@ -380,7 +380,7 @@ handle_drop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
obj = object_list_find(list, x, y);
if (obj && !obj->locked) {
command_list_add(edit_object_command_new(obj));
object_set_url(obj, data->data);
object_set_url(obj, (const gchar *) data->data);
object_emit_update_signal(obj);
success = TRUE;
}
......
......@@ -279,7 +279,7 @@ handle_drop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
Object_t *obj = selection_get_object (model, &iter);
if (!obj->locked) {
command_list_add(edit_object_command_new (obj));
object_set_url (obj, data->data);
object_set_url (obj, (const gchar *) data->data);
object_emit_update_signal (obj);
success = TRUE;
}
......
......@@ -171,7 +171,7 @@ jpeg_setup_exif_for_save (ExifData *exif_data,
if ((entry = exif_content_get_entry (exif_data->ifd[EXIF_IFD_0],
EXIF_TAG_SOFTWARE)))
{
entry->data = g_strdup ("The GIMP");
entry->data = (guchar *) g_strdup ("The GIMP");
entry->size = strlen ("The GIMP") + 1;
entry->components = entry->size;
}
......
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