Changeset 3564


Ignore:
Timestamp:
Jul 22, 2009 3:39:07 PM (5 years ago)
Author:
sam
Message:

That optimisation sucked. Reverted median filter to something that works
both on Linux and Windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/filter/median.c

    r3563 r3564  
    2727#include "pipi_internals.h"
    2828
    29 static int cmpint(void const *i1, void const *i2)
     29static int cmpdouble(void const *i1, void const *i2)
    3030{
    31     /* On Linux amd64, this is 20 to 30 % faster than using a real
    32      * comparison (which wouldn't work on Windows since it expects both
    33      * negative and positive values), a ternary operator, or floats instead
    34      * of doubles. */
    35     union { int32_t i; double d; } u;
    36     u.d = *(double const *)i1 - *(double const *)i2;
    37     return u.i;
     31    double a = *(double const *)i1;
     32    double b = *(double const *)i2;
     33
     34    return (a > b) - (a < b);
    3835}
    3936
     
    110107
    111108            /* Sort the list */
    112             qsort(list, size, sizeof(double), cmpint);
     109            qsort(list, size, sizeof(double), cmpdouble);
    113110            if(!gray)
    114111            {
    115                 qsort(list + size, size, sizeof(double), cmpint);
    116                 qsort(list + 2 * size, size, sizeof(double), cmpint);
    117                 qsort(list + 3 * size, size, sizeof(double), cmpint);
     112                qsort(list + size, size, sizeof(double), cmpdouble);
     113                qsort(list + 2 * size, size, sizeof(double), cmpdouble);
     114                qsort(list + 3 * size, size, sizeof(double), cmpdouble);
    118115            }
    119116
Note: See TracChangeset for help on using the changeset viewer.