#if GEGL_CHANT_PROPERTIES
/* no properties */
#else

#define GEGL_CHANT_POINT_COMPOSER
#define GEGL_CHANT_NAME          over_simd
#define GEGL_CHANT_DESCRIPTION   "Porter Duff operation over (c = cA + cB * (1.0 - aA))"
#define GEGL_CHANT_CATEGORIES    "compositors:porter duff"
#define GEGL_CHANT_SELF          "over_simd.c"
#define GEGL_CHANT_INIT
#include "gegl-chant.h"

static void init (GeglChantOperation *self)
{
  GEGL_OPERATION_POINT_COMPOSER (self)->format = babl_format ("RaGaBaA float");
  GEGL_OPERATION_POINT_COMPOSER (self)->aux_format = babl_format ("RaGaBaA float");

}

static gboolean
process (GeglOperation *op,
          void          *in_buf,
          void          *aux_buf,
          void          *out_buf,
          glong          n_pixels)
{
  Vector ONE = {{1.0,1.0,1.0,1.0}};

  gint i;
  gfloat *in  = in_buf;
  gfloat *aux = aux_buf;
  gfloat *out = out_buf;

  if (aux==NULL)
    return TRUE;

  for (i=0; i<n_pixels; i++)
    {
      #define IN  (*((Vector*)in))
      #define AUX (*((Vector*)aux))
      #define OUT (*((Vector*)out))
      
      gfloat aux_alpha=AUX.a[3];
      Vector AUX_ALPHA = {{aux_alpha,aux_alpha,aux_alpha,aux_alpha}};

      OUT.v = AUX.v + IN.v * (ONE.v-AUX_ALPHA.v);

      in  += 4;
      aux += 4;
      out += 4;
    }
  return TRUE;
}

#endif
