mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 03:10:14 +00:00
(SoftFilters) Simplify all Kreed xSaI filters
This commit is contained in:
parent
08ab8a122f
commit
f2fe9b23a1
@ -74,83 +74,11 @@ static void twoxsai_generic_destroy(void *data)
|
||||
free(filt);
|
||||
}
|
||||
|
||||
static inline uint16_t interpolate_rgb565(uint32_t A, uint32_t B)
|
||||
{
|
||||
uint32_t r;
|
||||
#define twoxsai_interpolate_rgb565(A, B) ((((A) & 0xF7DE) >> 1) + (((B) & 0xF7DE) >> 1) + ((A) & (B) & 0x0821));
|
||||
|
||||
A |= (A << 16); /* unpack */
|
||||
A &= 0x7e0f81f;
|
||||
B |= (B << 16);
|
||||
B &= 0x7e0f81f;
|
||||
#define twoxsai_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))
|
||||
|
||||
r = (A + B) >> 1; /* mix */
|
||||
|
||||
r &= 0x7e0f81f; /* repack */
|
||||
return (r | (r >> 16));
|
||||
}
|
||||
|
||||
static inline uint16_t interpolate2_rgb565(uint32_t A, uint32_t B, uint32_t C, uint32_t D)
|
||||
{
|
||||
uint32_t r;
|
||||
|
||||
A |= (A << 16); /* unpack */
|
||||
A &= 0x7e0f81f;
|
||||
B |= (B << 16);
|
||||
B &= 0x7e0f81f;
|
||||
C |= (C << 16);
|
||||
C &= 0x7e0f81f;
|
||||
D |= (D << 16);
|
||||
D &= 0x7e0f81f;
|
||||
|
||||
r = (A + B + C + D) >> 2; /* mix */
|
||||
|
||||
r &= 0x7e0f81f; /* repack */
|
||||
return (r | (r >> 16));
|
||||
}
|
||||
|
||||
static inline int result1_rgb565(uint16_t A, uint16_t B, uint16_t C, uint16_t D)
|
||||
{
|
||||
int x, y, r;
|
||||
x = 0;
|
||||
y = 0;
|
||||
r = 0;
|
||||
|
||||
if (A == C)
|
||||
x += 1;
|
||||
else if (B == C)
|
||||
y += 1;
|
||||
if (A == D)
|
||||
x += 1;
|
||||
else if (B == D)
|
||||
y += 1;
|
||||
if (x <= 1)
|
||||
r += 1;
|
||||
if (y <= 1)
|
||||
r -= 1;
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline int result2_rgb565(uint16_t A, uint16_t B, uint16_t C, uint16_t D)
|
||||
{
|
||||
int x, y, r;
|
||||
x = 0;
|
||||
y = 0;
|
||||
r = 0;
|
||||
|
||||
if (A == C)
|
||||
x += 1;
|
||||
else if (B == C)
|
||||
y += 1;
|
||||
if (A == D)
|
||||
x += 1;
|
||||
else if (B == D)
|
||||
y += 1;
|
||||
if (x <= 1)
|
||||
r -= 1;
|
||||
if (y <= 1)
|
||||
r += 1;
|
||||
return r;
|
||||
}
|
||||
#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)
|
||||
{
|
||||
@ -204,14 +132,14 @@ static void twoxsai_generic_rgb565(unsigned width, unsigned height,
|
||||
colorB != colorE && colorB == colorJ))
|
||||
product = colorA;
|
||||
else
|
||||
product = interpolate_rgb565(colorA, colorB);
|
||||
product = twoxsai_interpolate_rgb565(colorA, colorB);
|
||||
|
||||
if ((colorA == colorG && colorC == colorO) ||
|
||||
(colorA == colorB && colorA == colorH &&
|
||||
colorG != colorC && colorC == colorM))
|
||||
product1 = colorA;
|
||||
else
|
||||
product1 = interpolate_rgb565(colorA, colorC);
|
||||
product1 = twoxsai_interpolate_rgb565(colorA, colorC);
|
||||
|
||||
product2 = colorA;
|
||||
} else if (colorB == colorC && colorA != colorD)
|
||||
@ -221,14 +149,14 @@ static void twoxsai_generic_rgb565(unsigned width, unsigned height,
|
||||
colorA != colorF && colorA == colorI))
|
||||
product = colorB;
|
||||
else
|
||||
product = interpolate_rgb565(colorA, colorB);
|
||||
product = twoxsai_interpolate_rgb565(colorA, colorB);
|
||||
|
||||
if ((colorC == colorH && colorA == colorF) ||
|
||||
(colorC == colorG && colorC == colorD &&
|
||||
colorA != colorH && colorA == colorI))
|
||||
product1 = colorC;
|
||||
else
|
||||
product1 = interpolate_rgb565(colorA, colorC);
|
||||
product1 = twoxsai_interpolate_rgb565(colorA, colorC);
|
||||
|
||||
product2 = colorB;
|
||||
}
|
||||
@ -243,25 +171,25 @@ static void twoxsai_generic_rgb565(unsigned width, unsigned height,
|
||||
else
|
||||
{
|
||||
int r = 0;
|
||||
product1 = interpolate_rgb565(colorA, colorC);
|
||||
product = interpolate_rgb565(colorA, colorB);
|
||||
product1 = twoxsai_interpolate_rgb565(colorA, colorC);
|
||||
product = twoxsai_interpolate_rgb565(colorA, colorB);
|
||||
|
||||
r += result1_rgb565(colorA, colorB, colorG, colorE);
|
||||
r += result2_rgb565(colorB, colorA, colorK, colorF);
|
||||
r += result2_rgb565(colorB, colorA, colorH, colorN);
|
||||
r += result1_rgb565(colorA, colorB, colorL, colorO);
|
||||
r += twoxsai_result1_rgb565(colorA, colorB, colorG, colorE);
|
||||
r += twoxsai_result1_rgb565(colorB, colorA, colorK, colorF);
|
||||
r += twoxsai_result1_rgb565(colorB, colorA, colorH, colorN);
|
||||
r += twoxsai_result1_rgb565(colorA, colorB, colorL, colorO);
|
||||
|
||||
if (r > 0)
|
||||
product2 = colorA;
|
||||
else if (r < 0)
|
||||
product2 = colorB;
|
||||
else
|
||||
product2 = interpolate2_rgb565(colorA, colorB, colorC, colorD);
|
||||
product2 = twoxsai_interpolate2_rgb565(colorA, colorB, colorC, colorD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
product2 = interpolate2_rgb565(colorA, colorB, colorC, colorD);
|
||||
product2 = twoxsai_interpolate2_rgb565(colorA, colorB, colorC, colorD);
|
||||
|
||||
if (colorA == colorC && colorA == colorF &&
|
||||
colorB != colorE && colorB == colorJ)
|
||||
@ -270,7 +198,7 @@ static void twoxsai_generic_rgb565(unsigned width, unsigned height,
|
||||
colorA != colorF && colorA == colorI)
|
||||
product = colorB;
|
||||
else
|
||||
product = interpolate_rgb565(colorA, colorB);
|
||||
product = twoxsai_interpolate_rgb565(colorA, colorB);
|
||||
|
||||
if (colorA == colorB && colorA == colorH &&
|
||||
colorG != colorC && colorC == colorM)
|
||||
@ -279,7 +207,7 @@ static void twoxsai_generic_rgb565(unsigned width, unsigned height,
|
||||
colorA != colorH && colorA == colorI)
|
||||
product1 = colorC;
|
||||
else
|
||||
product1 = interpolate_rgb565(colorA, colorC);
|
||||
product1 = twoxsai_interpolate_rgb565(colorA, colorC);
|
||||
}
|
||||
|
||||
twoxsai_write2_rgb565(out, colorA, product);
|
||||
|
@ -74,11 +74,6 @@ static void supertwoxsai_generic_destroy(void *data)
|
||||
free(filt);
|
||||
}
|
||||
|
||||
static inline uint16_t supertwoxsai_interpolate_rgb565(uint32_t A, uint32_t B)
|
||||
{
|
||||
return (((A & 0xF7DE) >> 1) + ((B & 0xF7DE) >> 1) + (A & B & 0x0821));
|
||||
}
|
||||
|
||||
static inline uint32_t supertwoxsai_interpolate_xrgb8888(uint32_t A, uint32_t B)
|
||||
{
|
||||
return (((A & 0xFEFEFEFE) >> 1) + ((B & 0xFEFEFEFE) >> 1) + (A & B & 0x01010101));
|
||||
@ -90,23 +85,12 @@ static inline uint32_t supertwoxsai_interpolate2_xrgb8888(uint32_t A, uint32_t B
|
||||
+ ((((A & 0x03030303) + (B & 0x03030303) + (C & 0x03030303) + (D & 0x03030303)) >> 2) & 0x03030303));
|
||||
}
|
||||
|
||||
static inline uint16_t supertwoxsai_interpolate2_rgb565(uint32_t A, uint32_t B, uint32_t C, uint32_t D)
|
||||
{
|
||||
return (((A & 0xE79C) >> 2) + ((B & 0xE79C) >> 2) + ((C & 0xE79C) >> 2) + ((D & 0xE79C) >> 2)
|
||||
+ ((((A & 0x1863) + (B & 0x1863) + (C & 0x1863) + (D & 0x1863)) >> 2) & 0x1863));
|
||||
}
|
||||
|
||||
static inline int supertwoxsai_result1_rgb565(uint16_t A, uint16_t B, uint16_t C, uint16_t D)
|
||||
{
|
||||
return ((A != C || A != D) - (B != C || B != D));
|
||||
}
|
||||
|
||||
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 void supertwoxsai_write2_rgb565(uint16_t *out, uint16_t val0, uint16_t val1)
|
||||
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));
|
||||
}
|
||||
@ -116,6 +100,12 @@ static void supertwoxsai_write2_xrgb8888(uint32_t *out, uint32_t val0, uint32_t
|
||||
*(out) = val0 | val1;
|
||||
}
|
||||
|
||||
#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)));
|
||||
|
||||
#ifndef supertwoxsai_declare_variables
|
||||
#define supertwoxsai_declare_variables(typename_t, in, nextline) \
|
||||
typename_t product1a, product1b, product2a, product2b; \
|
||||
@ -173,15 +163,23 @@ static void supertwoxsai_write2_xrgb8888(uint32_t *out, uint32_t val0, uint32_t
|
||||
product1b = interpolate_cb(color5, color6); \
|
||||
} \
|
||||
if (color5 == color3 && color2 != color6 && color4 == color5 && color5 != colorA2) \
|
||||
{ \
|
||||
product2a = interpolate_cb(color2, color5); \
|
||||
} \
|
||||
else if (color5 == color1 && color6 == color5 && color4 != color2 && color5 != colorA0) \
|
||||
{ \
|
||||
product2a = interpolate_cb(color2, color5); \
|
||||
} \
|
||||
else \
|
||||
product2a = color2; \
|
||||
if (color2 == color6 && color5 != color3 && color1 == color2 && color2 != colorB2) \
|
||||
{ \
|
||||
product1a = interpolate_cb(color2, color5); \
|
||||
} \
|
||||
else if (color4 == color2 && color3 == color2 && color1 != color5 && color2 != colorB0) \
|
||||
{ \
|
||||
product1a = interpolate_cb(color2, color5); \
|
||||
} \
|
||||
else \
|
||||
product1a = color5; \
|
||||
write2_cb(out, product1a, product1b); \
|
||||
|
@ -74,61 +74,11 @@ static void supereagle_generic_destroy(void *data)
|
||||
free(filt);
|
||||
}
|
||||
|
||||
static inline uint16_t supereagle_interpolate_rgb565(uint32_t A, uint32_t B)
|
||||
{
|
||||
uint32_t r;
|
||||
#define supereagle_interpolate_rgb565(A, B) ((((A) & 0xF7DE) >> 1) + (((B) & 0xF7DE) >> 1) + ((A) & (B) & 0x0821));
|
||||
|
||||
A |= (A << 16); /* unpack */
|
||||
A &= 0x7e0f81f;
|
||||
B |= (B << 16);
|
||||
B &= 0x7e0f81f;
|
||||
#define supereagle_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))
|
||||
|
||||
r = (A + B) >> 1; /* mix */
|
||||
|
||||
r &= 0x7e0f81f; /* repack */
|
||||
return (r | (r >> 16));
|
||||
}
|
||||
|
||||
static inline uint16_t supereagle_interpolate2_rgb565(uint32_t A, uint32_t B, uint32_t C, uint32_t D)
|
||||
{
|
||||
uint32_t r;
|
||||
|
||||
A |= (A << 16); /* unpack */
|
||||
A &= 0x7e0f81f;
|
||||
B |= (B << 16);
|
||||
B &= 0x7e0f81f;
|
||||
C |= (C << 16);
|
||||
C &= 0x7e0f81f;
|
||||
D |= (D << 16);
|
||||
D &= 0x7e0f81f;
|
||||
|
||||
r = (A + B + C + D) >> 2; /* mix */
|
||||
|
||||
r &= 0x7e0f81f; /* repack */
|
||||
return (r | (r >> 16));
|
||||
}
|
||||
|
||||
static inline int supereagle_result1_rgb565(uint16_t A, uint16_t B, uint16_t C, uint16_t D)
|
||||
{
|
||||
int x, y, r;
|
||||
x = 0;
|
||||
y = 0;
|
||||
r = 0;
|
||||
|
||||
if (A == C)
|
||||
x += 1;
|
||||
else if (B == C)
|
||||
y += 1;
|
||||
if (A == D)
|
||||
x += 1;
|
||||
else if (B == D)
|
||||
y += 1;
|
||||
if (x <= 1)
|
||||
r += 1;
|
||||
if (y <= 1)
|
||||
r -= 1;
|
||||
return r;
|
||||
}
|
||||
#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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user