[babl] extensions/16bit: add a couple 16 bit alpha adding fast paths
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] extensions/16bit: add a couple 16 bit alpha adding fast paths
- Date: Thu, 8 Dec 2016 19:04:09 +0000 (UTC)
commit 13b1adcf7f2d70a52f872d39776c60f077c53c7a
Author: Øyvind Kolås <pippin gimp org>
Date: Thu Dec 8 20:03:27 2016 +0100
extensions/16bit: add a couple 16 bit alpha adding fast paths
extensions/16bit.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++
extensions/Makefile.am | 1 +
2 files changed, 104 insertions(+), 0 deletions(-)
---
diff --git a/extensions/16bit.c b/extensions/16bit.c
new file mode 100644
index 0000000..96701ef
--- /dev/null
+++ b/extensions/16bit.c
@@ -0,0 +1,103 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2016, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <stdint.h>
+
+#include "babl.h"
+
+#include "base/util.h"
+#include "extensions/util.h"
+
+static inline long
+conv_rgbu16_rgbau16 (unsigned char *src,
+ unsigned char *dst,
+ long samples)
+
+
+{
+ uint16_t *src16 = (uint16_t*) src;
+ uint16_t *dst16 = (uint16_t*) dst;
+ long n = samples;
+
+ while (n--)
+ {
+ *dst16++ = *src16++;
+ *dst16++ = *src16++;
+ *dst16++ = *src16++;
+ *dst16++ = 0xffff;
+ }
+
+ return samples;
+}
+
+static inline long
+conv_yu16_yau16 (unsigned char *src,
+ unsigned char *dst,
+ long samples)
+
+
+{
+ uint16_t *src16 = (uint16_t*) src;
+ uint16_t *dst16 = (uint16_t*) dst;
+ long n = samples;
+
+ while (n--)
+ {
+ *dst16++ = *src16++;
+ *dst16++ = 0xffff;
+ }
+
+ return samples;
+}
+
+int init (void);
+
+int
+init (void)
+{
+ babl_conversion_new (
+ babl_format ("R'G'B' u16"),
+ babl_format ("R'G'B'A u16"),
+ "linear",
+ conv_rgbu16_rgbau16,
+ NULL);
+
+ babl_conversion_new (
+ babl_format ("Y' u16"),
+ babl_format ("Y'A u16"),
+ "linear",
+ conv_yu16_yau16,
+ NULL);
+
+ babl_conversion_new (
+ babl_format ("RGB u16"),
+ babl_format ("RGBA u16"),
+ "linear",
+ conv_rgbu16_rgbau16,
+ NULL);
+
+ babl_conversion_new (
+ babl_format ("Y u16"),
+ babl_format ("YA u16"),
+ "linear",
+ conv_yu16_yau16,
+ NULL);
+ return 0;
+}
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index 0aeb9b7..923ddad 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -15,6 +15,7 @@ AM_CPPFLAGS = \
extdir = $(libdir)/babl-@BABL_API_VERSION@
ext_LTLIBRARIES = \
+ 16bit.la \
cairo.la \
CIE.la \
float-half.la \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]