[babl] improve how RGBA buffers are copied to n_component
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] improve how RGBA buffers are copied to n_component
- Date: Mon, 28 Apr 2014 13:55:50 +0000 (UTC)
commit 5285d4587d41363ffe58b15a585618fc0e9e7316
Author: Øyvind Kolås <pippin gimp org>
Date: Mon Apr 28 15:34:51 2014 +0200
improve how RGBA buffers are copied to n_component
babl/babl-fish-reference.c | 61 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c
index 05172da..6d0f270 100644
--- a/babl/babl-fish-reference.c
+++ b/babl/babl-fish-reference.c
@@ -270,6 +270,60 @@ ncomponent_convert_from_double (BablFormat *destination_fmt,
}
+static int
+process_same_model2 (const Babl *babl,
+ const char *source,
+ char *destination,
+ long n)
+{
+ void *double_buf;
+
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
+ double_buf = babl_malloc (sizeof (double) * n *
+ MAX (BABL (babl->fish.source)->format.model->components,
+ BABL (babl->fish.source)->format.components));
+#undef MAX
+
+ if (1)
+ {
+ /* FIXME: should recursively invoke babl and look up an appropriate fish
+ * for the conversion and multiply n by the number of components.
+ */
+ ncomponent_convert_to_double (
+ (BablFormat *) BABL (babl->fish.source),
+ (char *) source,
+ double_buf,
+ n
+ );
+
+ ncomponent_convert_from_double (
+ (BablFormat *) BABL (babl->fish.destination),
+ double_buf,
+ (char *) destination,
+ n
+ );
+ }
+ else
+ {
+ convert_to_double (
+ (BablFormat *) BABL (babl->fish.source),
+ (char *) source,
+ double_buf,
+ n
+ );
+
+ convert_from_double (
+ (BablFormat *) BABL (babl->fish.destination),
+ double_buf,
+ (char *) destination,
+ n
+ );
+ }
+ babl_free (double_buf);
+ return 0;
+}
+
static int
process_same_model (const Babl *babl,
@@ -347,6 +401,13 @@ babl_fish_reference_process (const Babl *babl,
BABL (babl->fish.destination)->format.model)
return process_same_model (babl, source, destination, n);
+ if (babl_format_is_format_n (BABL (babl->fish.destination)))
+ {
+ return process_same_model2 (babl, source, destination, n);
+ }
+
+
+
source_double_buf = babl_malloc (sizeof (double) * n *
BABL (babl->fish.source)->format.model->components);
rgba_double_buf = babl_malloc (sizeof (double) * n * 4);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]