Author: post
Date: 2010-01-16 11:02:07 +0100 (Sat, 16 Jan 2010)
New Revision: 3003
Modified:
branches/rawstudio-ng-color/plugins/dcp/dcp-sse2.c
branches/rawstudio-ng-color/plugins/dcp/dcp-sse4.c
branches/rawstudio-ng-color/plugins/dcp/dcp.c
branches/rawstudio-ng-color/plugins/dcp/dcp.h
Log:
DCP: Allocate aligned precalc tables ourselves, 32 bit GCC 4.3 doesn't always
respect aligned struct members.
Modified: branches/rawstudio-ng-color/plugins/dcp/dcp-sse2.c
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp-sse2.c 2010-01-16 08:28:00 UTC
(rev 3002)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp-sse2.c 2010-01-16 10:02:07 UTC
(rev 3003)
@@ -199,7 +199,6 @@
/* SSE2 implementation, matches the reference implementation pretty closely */
-
void
calc_hsm_constants(const RSHuesatMap *map, PrecalcHSM* table)
{
@@ -662,7 +661,7 @@
if (dcp->huesatmap)
{
- huesat_map_SSE2(dcp->huesatmap,
&dcp->huesatmap_precalc, &h, &s, &v);
+ huesat_map_SSE2(dcp->huesatmap,
dcp->huesatmap_precalc, &h, &s, &v);
}
/* Saturation */
@@ -771,7 +770,7 @@
/* Apply looktable */
if (dcp->looktable) {
- huesat_map_SSE2(dcp->looktable,
&dcp->looktable_precalc, &h, &s, &v);
+ huesat_map_SSE2(dcp->looktable,
dcp->looktable_precalc, &h, &s, &v);
}
/* Ensure that hue is within range */
Modified: branches/rawstudio-ng-color/plugins/dcp/dcp-sse4.c
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp-sse4.c 2010-01-16 08:28:00 UTC
(rev 3002)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp-sse4.c 2010-01-16 10:02:07 UTC
(rev 3003)
@@ -590,7 +590,7 @@
if (dcp->huesatmap)
{
- huesat_map_SSE4(dcp->huesatmap,
&dcp->huesatmap_precalc, &h, &s, &v);
+ huesat_map_SSE4(dcp->huesatmap,
dcp->huesatmap_precalc, &h, &s, &v);
}
/* Saturation */
@@ -689,7 +689,7 @@
/* Apply looktable */
if (dcp->looktable) {
- huesat_map_SSE4(dcp->looktable,
&dcp->looktable_precalc, &h, &s, &v);
+ huesat_map_SSE4(dcp->looktable,
dcp->looktable_precalc, &h, &s, &v);
}
/* Ensure that hue is within range */
Modified: branches/rawstudio-ng-color/plugins/dcp/dcp.c
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp.c 2010-01-16 08:28:00 UTC
(rev 3002)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp.c 2010-01-16 10:02:07 UTC
(rev 3003)
@@ -57,6 +57,8 @@
RSDcp *dcp = RS_DCP(object);
g_free(dcp->curve_samples);
+ g_free(dcp->_huesatmap_precalc_unaligned);
+ g_free(dcp->_looktable_precalc_unaligned);
free_dcp_profile(dcp);
}
@@ -231,6 +233,8 @@
dcp->use_profile = FALSE;
}
+#define ALIGNTO16(PTR) ((guintptr)PTR + ((16 - ((guintptr)PTR % 16)) % 16))
+
static void
rs_dcp_init(RSDcp *dcp)
{
@@ -248,8 +252,17 @@
* be loaded yet at that time :( */
if (!klass->prophoto)
klass->prophoto = rs_color_space_new_singleton("RSProphoto");
+
+ /* Allocate aligned precalc tables */
+ dcp->_huesatmap_precalc_unaligned = g_malloc(sizeof(PrecalcHSM)+16);
+ dcp->_looktable_precalc_unaligned = g_malloc(sizeof(PrecalcHSM)+16);
+ dcp->huesatmap_precalc =
(PrecalcHSM*)ALIGNTO16(dcp->_huesatmap_precalc_unaligned);
+ dcp->looktable_precalc =
(PrecalcHSM*)ALIGNTO16(dcp->_looktable_precalc_unaligned);
+
}
+#undef ALIGNTO16
+
static void
init_exposure(RSDcp *dcp)
{
@@ -1050,9 +1063,9 @@
/* Camera to ProPhoto */
matrix3_multiply(&xyz_to_prophoto, &dcp->camera_to_pcs,
&dcp->camera_to_prophoto); /* verified by SDK */
if (dcp->huesatmap)
- calc_hsm_constants(dcp->huesatmap, &dcp->huesatmap_precalc);
+ calc_hsm_constants(dcp->huesatmap, dcp->huesatmap_precalc);
if (dcp->looktable)
- calc_hsm_constants(dcp->looktable, &dcp->looktable_precalc);
+ calc_hsm_constants(dcp->looktable, dcp->looktable_precalc);
}
Modified: branches/rawstudio-ng-color/plugins/dcp/dcp.h
===================================================================
--- branches/rawstudio-ng-color/plugins/dcp/dcp.h 2010-01-16 08:28:00 UTC
(rev 3002)
+++ branches/rawstudio-ng-color/plugins/dcp/dcp.h 2010-01-16 10:02:07 UTC
(rev 3003)
@@ -32,15 +32,15 @@
typedef struct _RSDcpClass RSDcpClass;
typedef struct {
- /* Precalc: */
- gfloat hScale[4] __attribute__ ((aligned (16)));
- gfloat sScale[4] __attribute__ ((aligned (16)));
- gfloat vScale[4] __attribute__ ((aligned (16)));
- gint maxHueIndex0[4] __attribute__ ((aligned (16)));
- gint maxSatIndex0[4] __attribute__ ((aligned (16)));
- gint maxValIndex0[4] __attribute__ ((aligned (16)));
- gint hueStep[4] __attribute__ ((aligned (16)));
- gint valStep[4] __attribute__ ((aligned (16)));
+ /* Precalc: all sizes must be 16 byte aligned */
+ gfloat hScale[4];
+ gfloat sScale[4];
+ gfloat vScale[4];
+ gint maxHueIndex0[4];
+ gint maxSatIndex0[4];
+ gint maxValIndex0[4];
+ gint hueStep[4];
+ gint valStep[4];
} PrecalcHSM;
@@ -97,8 +97,10 @@
gfloat exposure_radius;
gfloat exposure_qscale;
- PrecalcHSM huesatmap_precalc;
- PrecalcHSM looktable_precalc;
+ PrecalcHSM *huesatmap_precalc;
+ PrecalcHSM *looktable_precalc;
+ void* _huesatmap_precalc_unaligned;
+ void* _looktable_precalc_unaligned;
};
struct _RSDcpClass {
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit