(SoftFilter) Fixed XRGB8888 for Super2xSaI - got rid of 'sai_write' function
This commit is contained in:
parent
f2fe9b23a1
commit
2f250d804a
|
@ -80,11 +80,6 @@ static void twoxsai_generic_destroy(void *data)
|
|||
|
||||
#define twoxsai_result1_rgb565(A, B, C, D) (((A) != (C) || (A) != (D)) - ((B) != (C) || (B) != (D)));
|
||||
|
||||
static void twoxsai_write2_rgb565(uint16_t *out, uint16_t val0, uint16_t val1)
|
||||
{
|
||||
*((uint32_t*)out) = ((uint32_t)(val0) | ((uint32_t)(val1) << 16));
|
||||
}
|
||||
|
||||
#define twoxsai_declare_variables(typename_t, in, nextline) \
|
||||
typename_t product, product1, product2; \
|
||||
typename_t colorI = *(in - nextline - 1); \
|
||||
|
@ -127,36 +122,36 @@ static void twoxsai_generic_rgb565(unsigned width, unsigned height,
|
|||
|
||||
if (colorA == colorD && colorB != colorC)
|
||||
{
|
||||
if ((colorA == colorE && colorB == colorL) ||
|
||||
(colorA == colorC && colorA == colorF &&
|
||||
colorB != colorE && colorB == colorJ))
|
||||
if ((colorA == colorE && colorB == colorL) || (colorA == colorC && colorA == colorF && colorB != colorE && colorB == colorJ))
|
||||
product = colorA;
|
||||
else
|
||||
{
|
||||
product = twoxsai_interpolate_rgb565(colorA, colorB);
|
||||
}
|
||||
|
||||
if ((colorA == colorG && colorC == colorO) ||
|
||||
(colorA == colorB && colorA == colorH &&
|
||||
colorG != colorC && colorC == colorM))
|
||||
if ((colorA == colorG && colorC == colorO) || (colorA == colorB && colorA == colorH && colorG != colorC && colorC == colorM))
|
||||
product1 = colorA;
|
||||
else
|
||||
{
|
||||
product1 = twoxsai_interpolate_rgb565(colorA, colorC);
|
||||
}
|
||||
|
||||
product2 = colorA;
|
||||
} else if (colorB == colorC && colorA != colorD)
|
||||
{
|
||||
if ((colorB == colorF && colorA == colorH) ||
|
||||
(colorB == colorE && colorB == colorD &&
|
||||
colorA != colorF && colorA == colorI))
|
||||
if ((colorB == colorF && colorA == colorH) || (colorB == colorE && colorB == colorD && colorA != colorF && colorA == colorI))
|
||||
product = colorB;
|
||||
else
|
||||
{
|
||||
product = twoxsai_interpolate_rgb565(colorA, colorB);
|
||||
}
|
||||
|
||||
if ((colorC == colorH && colorA == colorF) ||
|
||||
(colorC == colorG && colorC == colorD &&
|
||||
colorA != colorH && colorA == colorI))
|
||||
if ((colorC == colorH && colorA == colorF) || (colorC == colorG && colorC == colorD && colorA != colorH && colorA == colorI))
|
||||
product1 = colorC;
|
||||
else
|
||||
{
|
||||
product1 = twoxsai_interpolate_rgb565(colorA, colorC);
|
||||
}
|
||||
|
||||
product2 = colorB;
|
||||
}
|
||||
|
@ -184,34 +179,38 @@ static void twoxsai_generic_rgb565(unsigned width, unsigned height,
|
|||
else if (r < 0)
|
||||
product2 = colorB;
|
||||
else
|
||||
{
|
||||
product2 = twoxsai_interpolate2_rgb565(colorA, colorB, colorC, colorD);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
product2 = twoxsai_interpolate2_rgb565(colorA, colorB, colorC, colorD);
|
||||
|
||||
if (colorA == colorC && colorA == colorF &&
|
||||
colorB != colorE && colorB == colorJ)
|
||||
if (colorA == colorC && colorA == colorF && colorB != colorE && colorB == colorJ)
|
||||
product = colorA;
|
||||
else if (colorB == colorE && colorB == colorD &&
|
||||
colorA != colorF && colorA == colorI)
|
||||
else if (colorB == colorE && colorB == colorD && colorA != colorF && colorA == colorI)
|
||||
product = colorB;
|
||||
else
|
||||
{
|
||||
product = twoxsai_interpolate_rgb565(colorA, colorB);
|
||||
}
|
||||
|
||||
if (colorA == colorB && colorA == colorH &&
|
||||
colorG != colorC && colorC == colorM)
|
||||
if (colorA == colorB && colorA == colorH && colorG != colorC && colorC == colorM)
|
||||
product1 = colorA;
|
||||
else if (colorC == colorG && colorC == colorD &&
|
||||
colorA != colorH && colorA == colorI)
|
||||
else if (colorC == colorG && colorC == colorD && colorA != colorH && colorA == colorI)
|
||||
product1 = colorC;
|
||||
else
|
||||
{
|
||||
product1 = twoxsai_interpolate_rgb565(colorA, colorC);
|
||||
}
|
||||
}
|
||||
|
||||
twoxsai_write2_rgb565(out, colorA, product);
|
||||
twoxsai_write2_rgb565(out + dst_stride, product1, product2);
|
||||
out[0] = colorA;
|
||||
out[1] = product;
|
||||
out[dst_stride] = product1;
|
||||
out[dst_stride + 1] = product2;
|
||||
|
||||
++in;
|
||||
out += 2;
|
||||
|
|
|
@ -74,37 +74,15 @@ static void supertwoxsai_generic_destroy(void *data)
|
|||
free(filt);
|
||||
}
|
||||
|
||||
static inline uint32_t supertwoxsai_interpolate_xrgb8888(uint32_t A, uint32_t B)
|
||||
{
|
||||
return (((A & 0xFEFEFEFE) >> 1) + ((B & 0xFEFEFEFE) >> 1) + (A & B & 0x01010101));
|
||||
}
|
||||
#define supertwoxsai_interpolate_xrgb8888(A, B) ((((A) & 0xFEFEFEFE) >> 1) + (((B) & 0xFEFEFEFE) >> 1) + ((A) & (B) & 0x01010101))
|
||||
|
||||
static inline uint32_t supertwoxsai_interpolate2_xrgb8888(uint32_t A, uint32_t B, uint32_t C, uint32_t D)
|
||||
{
|
||||
return (((A & 0xFCFCFCFC) >> 2) + ((B & 0xFCFCFCFC) >> 2) + ((C & 0xFCFCFCFC) >> 2) + ((D & 0xFCFCFCFC) >> 2)
|
||||
+ ((((A & 0x03030303) + (B & 0x03030303) + (C & 0x03030303) + (D & 0x03030303)) >> 2) & 0x03030303));
|
||||
}
|
||||
|
||||
static inline int supertwoxsai_result1_xrgb8888(uint32_t A, uint32_t B, uint32_t C, uint32_t D)
|
||||
{
|
||||
return ((A != C || A != D) - (B != C || B != D));
|
||||
}
|
||||
|
||||
static inline void supertwoxsai_write2_rgb565(uint16_t *out, uint16_t val0, uint16_t val1)
|
||||
{
|
||||
*((uint32_t*)out) = ((uint32_t)(val0) | ((uint32_t)(val1) << 16));
|
||||
}
|
||||
|
||||
static void supertwoxsai_write2_xrgb8888(uint32_t *out, uint32_t val0, uint32_t val1)
|
||||
{
|
||||
*(out) = val0 | val1;
|
||||
}
|
||||
#define supertwoxsai_interpolate2_xrgb8888(A, B, C, D) ((((A) & 0xFCFCFCFC) >> 2) + (((B) & 0xFCFCFCFC) >> 2) + (((C) & 0xFCFCFCFC) >> 2) + (((D) & 0xFCFCFCFC) >> 2) + (((((A) & 0x03030303) + ((B) & 0x03030303) + ((C) & 0x03030303) + ((D) & 0x03030303)) >> 2) & 0x03030303))
|
||||
|
||||
#define supertwoxsai_interpolate_rgb565(A, B) ((((A) & 0xF7DE) >> 1) + (((B) & 0xF7DE) >> 1) + ((A) & (B) & 0x0821));
|
||||
|
||||
#define supertwoxsai_interpolate2_rgb565(A, B, C, D) ((((A) & 0xE79C) >> 2) + (((B) & 0xE79C) >> 2) + (((C) & 0xE79C) >> 2) + (((D) & 0xE79C) >> 2) + (((((A) & 0x1863) + ((B) & 0x1863) + ((C) & 0x1863) + ((D) & 0x1863)) >> 2) & 0x1863))
|
||||
|
||||
#define supertwoxsai_result1_rgb565(A, B, C, D) (((A) != (C) || (A) != (D)) - ((B) != (C) || (B) != (D)));
|
||||
#define supertwoxsai_result1(A, B, C, D) (((A) != (C) || (A) != (D)) - ((B) != (C) || (B) != (D)))
|
||||
|
||||
#ifndef supertwoxsai_declare_variables
|
||||
#define supertwoxsai_declare_variables(typename_t, in, nextline) \
|
||||
|
@ -128,7 +106,7 @@ static void supertwoxsai_write2_xrgb8888(uint32_t *out, uint32_t val0, uint32_t
|
|||
#endif
|
||||
|
||||
#ifndef supertwoxsai_function
|
||||
#define supertwoxsai_function(result1_cb, interpolate_cb, interpolate2_cb, write2_cb) \
|
||||
#define supertwoxsai_function(result1_cb, interpolate_cb, interpolate2_cb) \
|
||||
if (color2 == color6 && color5 != color3) \
|
||||
product2b = product1b = color2; \
|
||||
else if (color5 == color3 && color2 != color6) \
|
||||
|
@ -182,8 +160,10 @@ static void supertwoxsai_write2_xrgb8888(uint32_t *out, uint32_t val0, uint32_t
|
|||
} \
|
||||
else \
|
||||
product1a = color5; \
|
||||
write2_cb(out, product1a, product1b); \
|
||||
write2_cb(out + dst_stride, product2a, product2b); \
|
||||
out[0] = product1a; \
|
||||
out[1] = product1b; \
|
||||
out[dst_stride] = product2a; \
|
||||
out[dst_stride + 1] = product2b; \
|
||||
++in; \
|
||||
out += 2
|
||||
#endif
|
||||
|
@ -209,7 +189,7 @@ static void supertwoxsai_generic_xrgb8888(unsigned width, unsigned height,
|
|||
// A1 A2
|
||||
//--------------------------------------
|
||||
|
||||
supertwoxsai_function(supertwoxsai_result1_xrgb8888, supertwoxsai_interpolate_xrgb8888, supertwoxsai_interpolate2_xrgb8888, supertwoxsai_write2_xrgb8888);
|
||||
supertwoxsai_function(supertwoxsai_result1, supertwoxsai_interpolate_xrgb8888, supertwoxsai_interpolate2_xrgb8888);
|
||||
}
|
||||
|
||||
src += src_stride;
|
||||
|
@ -238,7 +218,7 @@ static void supertwoxsai_generic_rgb565(unsigned width, unsigned height,
|
|||
// A1 A2
|
||||
//--------------------------------------
|
||||
|
||||
supertwoxsai_function(supertwoxsai_result1_rgb565, supertwoxsai_interpolate_rgb565, supertwoxsai_interpolate2_rgb565, supertwoxsai_write2_rgb565);
|
||||
supertwoxsai_function(supertwoxsai_result1, supertwoxsai_interpolate_rgb565, supertwoxsai_interpolate2_rgb565);
|
||||
}
|
||||
|
||||
src += src_stride;
|
||||
|
|
|
@ -80,11 +80,6 @@ static void supereagle_generic_destroy(void *data)
|
|||
|
||||
#define supereagle_result1_rgb565(A, B, C, D) (((A) != (C) || (A) != (D)) - ((B) != (C) || (B) != (D)));
|
||||
|
||||
static void supereagle_write2_rgb565(uint16_t *out, uint16_t val0, uint16_t val1)
|
||||
{
|
||||
*((uint32_t*)out) = ((uint32_t)(val0) | ((uint32_t)(val1) << 16));
|
||||
}
|
||||
|
||||
#define supereagle_declare_variables(typename_t, in, nextline) \
|
||||
typename_t product1a, product1b, product2a, product2b; \
|
||||
const typename_t colorB1 = *(in - nextline + 0); \
|
||||
|
@ -190,8 +185,10 @@ static void supereagle_generic_rgb565(unsigned width, unsigned height,
|
|||
product1b = supereagle_interpolate2_rgb565(color6, color6, color6, product1b);
|
||||
}
|
||||
|
||||
supereagle_write2_rgb565(out, product1a, product1b);
|
||||
supereagle_write2_rgb565(out + dst_stride, product2a, product2b);
|
||||
out[0] = product1a;
|
||||
out[1] = product1b;
|
||||
out[dst_stride] = product2a;
|
||||
out[dst_stride + 1] = product2b;
|
||||
|
||||
++in;
|
||||
out += 2;
|
||||
|
|
Loading…
Reference in New Issue