-// NORMAL [Sa * Sa + Da * (1 - Sa), Sc * Sa + Dc * (1 - Sa)])
-#define ALPHA_NORMAL(mx, Sa, Da) ((Sa * Sa + Da * (mx - Sa)) / mx)
+// NORMAL [Sa + Da * (1 - Sa), Sc * Sa + Dc * (1 - Sa)])
+#define ALPHA_NORMAL(mx, Sa, Da) (Sa + (Da * (mx - Sa)) / mx)
#define COLOR_NORMAL(mx, Sc, Sa, Dc, Da) ((Sc * Sa + Dc * (mx - Sa)) / mx)
#define CHROMA_NORMAL COLOR_NORMAL
#define COLOR_NORMAL(mx, Sc, Sa, Dc, Da) ((Sc * Sa + Dc * (mx - Sa)) / mx)
#define CHROMA_NORMAL COLOR_NORMAL
#define ALPHA3_BLEND(FN, typ, inp, out, mx, ofs, rnd) \
typ inp0 = (typ)inp[0], inp1 = (typ)inp[1] - ofs; \
#define ALPHA3_BLEND(FN, typ, inp, out, mx, ofs, rnd) \
typ inp0 = (typ)inp[0], inp1 = (typ)inp[1] - ofs; \
typ out0 = (typ)out[0], out1 = (typ)out[1] - ofs; \
typ out2 = (typ)out[2] - ofs, out3 = mx; \
r = COLOR_##FN(mx, inp0, inp3, out0, out3); \
typ out0 = (typ)out[0], out1 = (typ)out[1] - ofs; \
typ out2 = (typ)out[2] - ofs, out3 = mx; \
r = COLOR_##FN(mx, inp0, inp3, out0, out3); \
#define ALPHA4_BLEND(FN, typ, inp, out, mx, ofs, rnd) \
typ inp0 = (typ)inp[0], inp1 = (typ)inp[1] - ofs; \
#define ALPHA4_BLEND(FN, typ, inp, out, mx, ofs, rnd) \
typ inp0 = (typ)inp[0], inp1 = (typ)inp[1] - ofs; \
typ out0 = (typ)out[0], out1 = (typ)out[1] - ofs; \
typ out2 = (typ)out[2] - ofs, out3 = out[3]; \
r = COLOR_##FN(mx, inp0, inp3, out0, out3); \
typ out0 = (typ)out[0], out1 = (typ)out[1] - ofs; \
typ out2 = (typ)out[2] - ofs, out3 = out[3]; \
r = COLOR_##FN(mx, inp0, inp3, out0, out3); \
out[3] = aclip(a, mx)
#define XBLEND(FN, temp_type, type, max, components, chroma_offset, round) { \
out[3] = aclip(a, mx)
#define XBLEND(FN, temp_type, type, max, components, chroma_offset, round) { \
type** output_rows = (type**)output->get_rows(); \
type** input_rows = (type**)input->get_rows(); \
ix *= components; ox *= components; \
type** output_rows = (type**)output->get_rows(); \
type** input_rows = (type**)input->get_rows(); \
ix *= components; ox *= components; \
/* Nearest Neighbor scale / translate / blend ********************/
#define XBLEND_3NN(FN, temp_type, type, max, components, chroma_offset, round) { \
/* Nearest Neighbor scale / translate / blend ********************/
#define XBLEND_3NN(FN, temp_type, type, max, components, chroma_offset, round) { \
#define XSAMPLE(FN, temp_type, type, max, components, chroma_offset, round) { \
float temp[oh*components]; \
#define XSAMPLE(FN, temp_type, type, max, components, chroma_offset, round) { \
float temp[oh*components]; \
type **output_rows = (type**)voutput->get_rows() + o1i; \
type **input_rows = (type**)vinput->get_rows(); \
\
type **output_rows = (type**)voutput->get_rows() + o1i; \
type **input_rows = (type**)vinput->get_rows(); \
\