--- gegl/buffer/gegl-buffer-access.c +++ gegl/buffer/gegl-buffer-access.c @@ -46,16 +46,6 @@ GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT; #endif -#ifdef BABL -#undef BABL -#endif - -#define BABL(o) ((Babl *) (o)) - -#ifdef FMTPXS -#undef FMTPXS -#endif -#define FMTPXS(fmt) (BABL (fmt)->format.bytes_per_pixel) #if 0 static inline void @@ -68,7 +58,7 @@ pset (GeglBuffer *buffer, gint tile_width = buffer->tile_storage->tile_width; gint tile_height = buffer->tile_storage->tile_width; gint px_size = gegl_buffer_px_size (buffer); - gint bpx_size = FMTPXS (format); + gint bpx_size = babl_format_get_bytes_per_pixel (format); Babl *fish = NULL; gint abyss_x_total = buffer->abyss.x + buffer->abyss.width; @@ -134,7 +124,7 @@ pset (GeglBuffer *buffer, guchar *buf = data; gint tile_width = buffer->tile_storage->tile_width; gint tile_height = buffer->tile_storage->tile_height; - gint bpx_size = FMTPXS (format); + gint bpx_size = babl_format_get_bytes_per_pixel (format); Babl *fish = NULL; gint buffer_shift_x = buffer->shift_x; @@ -143,7 +133,7 @@ pset (GeglBuffer *buffer, gint buffer_abyss_y = buffer->abyss.y + buffer_shift_y; gint abyss_x_total = buffer_abyss_x + buffer->abyss.width; gint abyss_y_total = buffer_abyss_y + buffer->abyss.height; - gint px_size = FMTPXS (buffer->format); + gint px_size = babl_format_get_bytes_per_pixel (buffer->format); if (format != buffer->format) { @@ -218,7 +208,7 @@ pget (GeglBuffer *buffer, guchar *buf = data; gint tile_width = buffer->tile_storage->tile_width; gint tile_height = buffer->tile_storage->tile_height; - gint bpx_size = FMTPXS (format); + gint bpx_size = babl_format_get_bytes_per_pixel (format); Babl *fish = NULL; gint buffer_shift_x = buffer->shift_x; @@ -227,7 +217,7 @@ pget (GeglBuffer *buffer, gint buffer_abyss_y = buffer->abyss.y + buffer_shift_y; gint abyss_x_total = buffer_abyss_x + buffer->abyss.width; gint abyss_y_total = buffer_abyss_y + buffer->abyss.height; - gint px_size = FMTPXS (buffer->format); + gint px_size = babl_format_get_bytes_per_pixel (buffer->format); if (format != buffer->format) { @@ -330,8 +320,8 @@ gegl_buffer_iterate (GeglBuffer *buffer, gint tile_width = buffer->tile_storage->tile_width; gint tile_height = buffer->tile_storage->tile_height; - gint px_size = FMTPXS (buffer->format); - gint bpx_size = FMTPXS (format); + gint px_size = babl_format_get_bytes_per_pixel (buffer->format); + gint bpx_size = babl_format_get_bytes_per_pixel (format); gint tile_stride = px_size * tile_width; gint buf_stride; gint bufy = 0; @@ -994,7 +984,7 @@ gegl_buffer_get (GeglBuffer *buffer, gint level = 0; gint buf_width = rect->width / scale; gint buf_height = rect->height / scale; - gint bpp = BABL (format)->format.bytes_per_pixel; + gint bpp = babl_format_get_bytes_per_pixel (format); GeglRectangle sample_rect = { floor(rect->x/scale), floor(rect->y/scale), buf_width, @@ -1030,7 +1020,7 @@ gegl_buffer_get (GeglBuffer *buffer, * no time to make a fast implementation */ - if (BABL (format)->format.type[0] == (BablType *) babl_type ("u8") + if (babl_format_get_type (format, 0) == babl_type ("u8") && !(level == 0 && scale > 1.99)) { /* do box-filter resampling if we're 8bit (which projections are) */ @@ -1201,7 +1191,7 @@ gegl_buffer_clear (GeglBuffer *dst, dst_rect->height == 0) return; - pxsize = dst->format->format.bytes_per_pixel; + pxsize = babl_format_get_bytes_per_pixel (dst->format); /* FIXME: this can be even further optimized by special casing it so * that fully voided tiles are dropped. --- gegl/buffer/gegl-buffer-iterator.c +++ gegl/buffer/gegl-buffer-iterator.c @@ -191,7 +191,7 @@ gulp: i->data = gegl_tile_get_data (i->tile); { - gint bpp = i->buffer->format->format.bytes_per_pixel; + gint bpp = babl_format_get_bytes_per_pixel (i->buffer->format); i->rowstride = bpp * tile_width; i->sub_data = (guchar*)(i->data) + bpp * (i->subrect.y * tile_width + i->subrect.x); } @@ -356,7 +356,7 @@ static void ensure_buf (GeglBufferIterators *i, gint no) * would probably improve performance */ if (i->buf[no]==NULL) - i->buf[no] = iterator_buf_pool_get (i->format[no]->format.bytes_per_pixel * + i->buf[no] = iterator_buf_pool_get (babl_format_get_bytes_per_pixel (i->format[no]) * i->i[0].max_size); } --- gegl/buffer/gegl-buffer-linear.c +++ gegl/buffer/gegl-buffer-linear.c @@ -77,7 +77,7 @@ gegl_buffer_linear_new_from_data (const gpointer data, */ rowstride = extent->width; else - rowstride = rowstride / format->format.bytes_per_pixel; + rowstride = rowstride / babl_format_get_bytes_per_pixel (format); buffer = gegl_buffer_linear_new2 (extent, format, rowstride); { @@ -90,7 +90,7 @@ gegl_buffer_linear_new_from_data (const gpointer data, tile->y = 0; tile->z = 0; tile->data = (gpointer)data; - tile->size = format->format.bytes_per_pixel * rowstride * extent->height; + tile->size = babl_format_get_bytes_per_pixel (format) * rowstride * extent->height; tile->next_shared = tile; tile->prev_shared = tile; @@ -155,7 +155,7 @@ gegl_buffer_linear_open (GeglBuffer *buffer, g_object_set_data (G_OBJECT (buffer), "linear-tile", tile); - if(rowstride)*rowstride = buffer->tile_storage->tile_width * format->format.bytes_per_pixel; + if(rowstride)*rowstride = buffer->tile_storage->tile_width * babl_format_get_bytes_per_pixel (format); return (gpointer)gegl_tile_get_data (tile); } /* first check if there is a linear buffer, share the existing buffer if one @@ -194,7 +194,7 @@ gegl_buffer_linear_open (GeglBuffer *buffer, info->extent = buffer->extent; info->format = format; - rs = info->extent.width * format->format.bytes_per_pixel; + rs = info->extent.width * babl_format_get_bytes_per_pixel (format); if(rowstride)*rowstride = rs; info->buf = gegl_malloc (rs * info->extent.height); --- gegl/buffer/gegl-buffer-load.c +++ gegl/buffer/gegl-buffer-load.c @@ -372,7 +372,7 @@ gegl_buffer_load (const gchar *path) /* sanity check, should probably report error condition and return safely instead */ - g_assert (info->format->format.bytes_per_pixel == info->header.bytes_per_pixel); + g_assert (babl_format_get_bytes_per_pixel (info->format) == info->header.bytes_per_pixel); info->tiles = gegl_buffer_read_index (info->i, &info->offset); --- gegl/buffer/gegl-buffer-save.c +++ gegl/buffer/gegl-buffer-save.c @@ -204,7 +204,7 @@ gegl_buffer_header_init (GeglBufferHeader *header, { gchar buf[64]; g_snprintf (buf, 64, "%s%c\n%i×%i %ibpp\n%ix%i\n\n\n\n\n\n\n\n\n", - format->instance.name, 0, + babl_get_name (format), 0, header->tile_width, header->tile_height, header->bytes_per_pixel, --- gegl/buffer/gegl-sampler.c +++ gegl/buffer/gegl-sampler.c @@ -215,7 +215,7 @@ gegl_sampler_get_ptr (GeglSampler *sampler, gint bpp; gint sof; - bpp = sampler->interpolate_format->format.bytes_per_pixel; + bpp = babl_format_get_bytes_per_pixel (sampler->interpolate_format); if (sampler->sampler_buffer == NULL || @@ -284,7 +284,7 @@ gegl_sampler_get_from_buffer (GeglSampler *sampler, gint bpp; gint sof; - bpp = sampler->interpolate_format->format.bytes_per_pixel; + bpp = babl_format_get_bytes_per_pixel (sampler->interpolate_format); if (sampler->sampler_buffer == NULL || --- gegl/buffer/gegl-tile-backend-file.c +++ gegl/buffer/gegl-tile-backend-file.c @@ -917,7 +917,7 @@ gegl_tile_backend_file_constructor (GType type, backend->tile_width = self->header.tile_width; backend->tile_height = self->header.tile_height; backend->format = babl_format (self->header.description); - backend->px_size = backend->format->format.bytes_per_pixel; + backend->px_size = babl_format_get_bytes_per_pixel (backend->format); backend->tile_size = backend->tile_width * backend->tile_height * backend->px_size; /* insert each of the entries into the hash table */ --- gegl/buffer/gegl-tile-backend.c +++ gegl/buffer/gegl-tile-backend.c @@ -114,7 +114,7 @@ constructor (GType type, g_assert (backend->tile_width > 0 && backend->tile_height > 0); g_assert (backend->format); - backend->px_size = backend->format->format.bytes_per_pixel; + backend->px_size = babl_format_get_bytes_per_pixel (backend->format); backend->tile_size = backend->tile_width * backend->tile_height * backend->px_size; return object; --- gegl/buffer/gegl-tile-handler-zoom.c +++ gegl/buffer/gegl-tile-handler-zoom.c @@ -50,7 +50,7 @@ static inline void set_blank (GeglTile *dst_tile, gint j) { guchar *dst_data = gegl_tile_get_data (dst_tile); - gint bpp = format->format.bytes_per_pixel; + gint bpp = babl_format_get_bytes_per_pixel (format); gint rowstride = width * bpp; gint scanline; @@ -76,7 +76,7 @@ static inline void set_half_nearest (GeglTile *dst_tile, { guchar *dst_data = gegl_tile_get_data (dst_tile); guchar *src_data = gegl_tile_get_data (src_tile); - gint bpp = format->format.bytes_per_pixel; + gint bpp = babl_format_get_bytes_per_pixel (format); gint x, y; for (y = 0; y < height / 2; y++) @@ -177,17 +177,17 @@ static void inline set_half (GeglTile * dst_tile, { guchar *dst_data = gegl_tile_get_data (dst_tile); guchar *src_data = gegl_tile_get_data (src_tile); - gint components = format->format.components; - gint bpp = format->format.bytes_per_pixel; + gint components = babl_format_get_n_components (format); + gint bpp = babl_format_get_bytes_per_pixel (format); if (i) dst_data += bpp * width / 2; if (j) dst_data += bpp * width * height / 2; - if (format->format.type[0] == (BablType *) babl_type ("float")) + if (babl_format_get_type (format, 0) == babl_type ("float")) { downscale_float (components, width, height, width * bpp, src_data, dst_data); } - else if (format->format.type[0] == (BablType *) babl_type ("u8")) + else if (babl_format_get_type (format, 0) == babl_type ("u8")) { downscale_u8 (components, width, height, width * bpp, src_data, dst_data); } --- operations/core/convert-format.c +++ operations/core/convert-format.c @@ -56,7 +56,7 @@ process (GeglOperation *op, glong samples, const GeglRectangle *roi) { - int bpp = gegl_operation_get_format(op, "output")->format.bytes_per_pixel; + int bpp = babl_format_get_bytes_per_pixel (gegl_operation_get_format (op, "output")); memcpy(out_buf, in_buf, samples * bpp); return TRUE; } --- operations/external/png-save.c +++ operations/external/png-save.c @@ -89,14 +89,11 @@ gegl_buffer_export_png (GeglBuffer *gegl_buffer, { const Babl *babl; /*= gegl_buffer->format;*/ - BablType **type; g_object_get (gegl_buffer, "format", &babl, NULL); - type = babl->format.type; - for (i=0; iformat.components; i++) - if ((*type)->bits > 8) - bit_depth = 16; + if (babl_format_get_type (babl, 0) != babl_type ("u8")) + bit_depth = 16; if (bd == 16) bit_depth = 16; --- operations/external/save-pixbuf.c +++ operations/external/save-pixbuf.c @@ -17,6 +17,9 @@ */ #include "config.h" + +#include + #include @@ -44,21 +47,16 @@ process (GeglOperation *operation, { GdkPixbuf **pixbuf = o->pixbuf; const Babl *babl; - const BablFormat *format; + const Babl *format; guchar *temp; GeglRectangle *rect = gegl_operation_source_get_bounding_box (operation, "input"); gchar *name; gboolean has_alpha; gint bps; - guint i; - g_object_get (input, "format", &babl, NULL); - format = (BablFormat*) babl; + g_object_get (input, "format", &format, NULL); - has_alpha = FALSE; - for (i = 0; i < format->components; i++) { - has_alpha = has_alpha || format->component[i]->alpha != 0; - } + has_alpha = babl_format_has_alpha (format); /* pixbuf from data only support 8bit bps */ bps = 8; --- bin/export.c 2008-06-14 12:40:05.000000000 -0400 +++ bin/export.c.new 2009-06-04 15:39:42.898669573 -0400 @@ -308,12 +308,11 @@ strcpy (format_string, "R'G'B'A "); { - const Babl *babl = gegl_buffer->format; - BablType **type = babl->format.type; + const Babl *babl; /* = gegl_buffer->format;*/ - for (i=0; iformat.components; i++) - if ((*type)->bits > 8) - bit_depth = 16; + g_object_get (gegl_buffer, "format", &babl, NULL); + if (babl_format_get_type (babl, 0) != babl_type ("u8")) + bit_depth = 16; } if (bit_depth == 16)