# HG changeset patch
# User Edouard Gomez <[EMAIL PROTECTED]>
# Date 1209654405 -7200
# Node ID 60e607d0ae640d63abd743dd1ce0f40ad06ab16d
# Parent  9bf0268fa0d3839f408bceae30b255cc1d89b8ad
color: fix 3dnow on x86_64

On an amd64, 3dnow code was segfaulting.

The main reason is the use of glong instead of gint.

Batched fixes:
- Fixed gint/glong usage in all transform code
- Moved a "femms" before calling littleCMS. There is no guarantee
  that this lib doesn't need a valid context FPU. So we have to make
  sure the FPU context is right.
- Removed two "femms" because entering MMX/3dNow code doesn't require femms

diff --git a/src/rs-color-transform.c b/src/rs-color-transform.c
--- a/src/rs-color-transform.c
+++ b/src/rs-color-transform.c
@@ -461,7 +461,7 @@
 
 COLOR_TRANSFORM(transform_nocms8_sse)
 {
-       register glong r,g,b;
+       register gint r,g,b;
        gint destoffset;
        gint col;
        RS_DECLARE_ALIGNED(gfloat, mat, 4, 3, 16);
@@ -561,7 +561,7 @@
 {
        gint destoffset;
        gint col;
-       register glong r=0,g=0,b=0;
+       register gint r=0,g=0,b=0;
        RS_DECLARE_ALIGNED(gfloat, mat, 4, 3, 8);
 
        if ((rct==NULL) || (width<1) || (height<1) || (in == NULL) || 
(in_rowstride<8) || (out == NULL) || (out_rowstride<1))
@@ -583,7 +583,6 @@
        mat[11] = 0.f;
 
        asm volatile (
-               "femms\n\t"
                "pxor %%mm7, %%mm7\n\t" /* 0x0 */
                "movq (%0), %%mm2\n\t" /* pre_mul R | pre_mul G */
                "movq 8(%0), %%mm3\n\t" /* pre_mul B | pre_mul G2 */
@@ -667,7 +666,7 @@
 COLOR_TRANSFORM(transform_cms8_sse)
 {
        gushort *buffer = g_malloc(width*3*sizeof(gushort));
-       register glong r,g,b;
+       register gint r,g,b;
        gint destoffset;
        gint col;
        RS_DECLARE_ALIGNED(gfloat, mat, 4, 3, 16);
@@ -767,7 +766,7 @@
        gushort *buffer = g_malloc(width*3*sizeof(gushort));
        gint destoffset;
        gint col;
-       register glong r=0,g=0,b=0;
+       register gint r=0,g=0,b=0;
        RS_DECLARE_ALIGNED(gfloat, mat, 4, 3, 8);
 
        if ((rct==NULL) || (width<1) || (height<1) || (in == NULL) || 
(in_rowstride<8) || (out == NULL) || (out_rowstride<1))
@@ -789,7 +788,6 @@
        mat[11] = 0.f;
 
        asm volatile (
-               "femms\n\t"
                "pxor %%mm7, %%mm7\n\t" /* 0x0 */
                "movq (%0), %%mm2\n\t" /* pre_mul R | pre_mul G */
                "movq 8(%0), %%mm3\n\t" /* pre_mul B | pre_mul G2 */
@@ -863,9 +861,9 @@
                        buffer[destoffset++] = rct->priv->table16[g];
                        buffer[destoffset++] = rct->priv->table16[b];
                }
+               asm volatile ("femms\n\t");
                cmsDoTransform((cmsHPROFILE) rct->priv->transform, buffer, 
out+height * out_rowstride, width);
        }
-       asm volatile ("femms\n\t");
        g_free(buffer);
        return;
 }

_______________________________________________
Rawstudio-dev mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-dev

Reply via email to