LJ Archive
#define CAT(v,x) ((u_long)(v)<<8 | (x))
#define VEC(x)
  CAT(CAT(CAT(CAT(CAT(CAT(CAT(x,x),x),x),x),x),x),x)

void byte_avg2 (u_long size, u_char *ca,
   u_char *cb, u_char *cc)
  {
    u_long *a = (u_long*) ca;
    u_long *b = (u_long*) cb;
    u_long *c = (u_long*) cc;
    u_long A0 = a[0], B0 = b[0], A1, B1, CC, i,
    count = size / sizeof(u_long);
    for (i = 1; i < count; )
    {
      A1 = a[i];
      /* read ahead */
      B1 = b[i]; ++i;
      CC = (A0 & B0) & VEC(0x01);
      A0 = (A0 >> 1) & VEC(0x7f);
      B0 = (B0 >> 1) & VEC(0x7f);
      c[i - 2] = A0 + B0 + CC;

      /* read ahead */
      A0 = a[i]; B0 = b[i]; ++i;
      CC = (A1 & B1) & VEC(0x01);
      A1 = (A1 >> 1) & VEC(0x7f);
      B1 = (B1 >> 1) & VEC(0x7f);
      c[i - 2] = A1 + B1 + CC;
    }
  }
LJ Archive