그냥 평균함수는


void Average2(uint8_t *dstint dstPitchconst uint8_t *src0int srcPitch0const uint8_t *src1int srcPitch1int widthint height)
{
  for(int y = 0 ; y < heighty++)
  {
    for(int x = 0 ; x < widthx++)
    {
      dst[x] = (src0[x] + src1[x] + 1) >> 1;
    }
    
    dst += dstPitch;
    src0 += srcPitch0;
    src1 += srcPitch1;
  }
}


요렇게 짜면 된다. 근데 사이즈 커지면 은근히 시간 잡아먹음.


그래서 


void Average2_AVX2(uint8_t *dstint dstPitchconst uint8_t *src0int srcPitch0const uint8_t *src1int srcPitch1int widthint height)
{
  for (int y = 0y < heighty++)
  {
    for (int x = 0x < widthx += 32)
    {
      auto s0 = Simd::Load256iAligned(src0 + x);
      auto s1 = Simd::Load256iAligned(src1 + x);
      Simd::StoreAligned(dst + x_mm256_avg_epu8(s0s1));
    }

    dst += dstPitch;
    src0 += srcPitch0;
    src1 += srcPitch1;
  }
}


요렇게만 바꿔줘도 성능 체감 5배 이상은 빠름 ㅇㅅㅇ