[babl/wip/pippin/fish-reference-to-double] babl: make conversion to model double more generic
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl/wip/pippin/fish-reference-to-double] babl: make conversion to model double more generic
- Date: Sat, 18 Nov 2017 00:38:23 +0000 (UTC)
commit fc88d82325cc8618389559d78a14d424db285995
Author: Øyvind Kolås <pippin gimp org>
Date: Sat Nov 18 01:35:09 2017 +0100
babl: make conversion to model double more generic
Iterate over the components of the model, and fetch the relevant component from
the source format, or - and this is new zero the memory.
babl/babl-fish-reference.c | 30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c
index d97cca3..f8d53b8 100644
--- a/babl/babl-fish-reference.c
+++ b/babl/babl-fish-reference.c
@@ -153,7 +153,7 @@ babl_fish_reference (const Babl *source,
static void
convert_to_double (BablFormat *source_fmt,
const char *source_buf,
- char *source_double_buf,
+ char *double_buf,
int n)
{
int i;
@@ -171,36 +171,46 @@ convert_to_double (BablFormat *source_fmt,
(dst_img->type[0]->bits / 8) * source_fmt->model->components;
dst_img->stride[0] = 0;
-
src_img->data[0] = (char *)source_buf;
src_img->type[0] = (BablType *) babl_type_from_id (BABL_DOUBLE);
src_img->pitch[0] = source_fmt->bytes_per_pixel;
src_img->stride[0] = 0;
{
- /* i is source position */
- for (i = 0; i < source_fmt->components; i++)
+ /* i is dest position */
+ for (i = 0; i < source_fmt->model->components; i++)
{
int j;
+ int found = 0;
+
+ dst_img->data[0] =
+ double_buf + (dst_img->type[0]->bits / 8) * i;
src_img->type[0] = source_fmt->type[i];
/* j is source position */
- for (j = 0; j < source_fmt->model->components; j++)
+ for (j = 0; j < source_fmt->components; j++)
{
- if (source_fmt->component[i] ==
- source_fmt->model->component[j])
+ if (source_fmt->component[j] ==
+ source_fmt->model->component[i])
{
- dst_img->data[0] =
- source_double_buf + (dst_img->type[0]->bits / 8) * j;
+ src_img->data[0] =
+ (char*)(source_buf) + (src_img->type[0]->bits / 8) * j;
babl_process (assert_conversion_find (src_img->type[0],
dst_img->type[0]),
src_img, dst_img, n);
+ found = 1;
break;
}
}
- src_img->data[0] += src_img->type[0]->bits / 8;
+ if (!found)
+ {
+ for (j = 0; j < n; j++)
+ {
+ memset (dst_img->data[0] + (source_fmt->components * dst_img->type[0]->bits/8) * j, 0,
dst_img->type[0]->bits/8);
+ }
+ }
}
}
babl_free (src_img);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]