and now i added "line dither". what is this. it's only for non-rotated 16bpp

565. what it does is it's a half-way house between no dither and "small
dither mask". what is does is change the "rounding" between odd and even
lines. the resolt is not as nice as small (or large) dither mask - but its
almost "good". it gives a horizontal-blinds like look to dithering. it's
almost as fast as no-dither in my tests on a core2 (of course making lots of
use of branch prediction or conditional instructins - whihc arm nd x86 have).



SVN revision: 36373
This commit is contained in:
Carsten Haitzler 2008-10-01 06:37:31 +00:00
parent c36f11f8ea
commit 6dfb74c54a
2 changed files with 113 additions and 1 deletions

View File

@ -1555,6 +1555,29 @@ AC_ARG_ENABLE(small-dither-mask,
]
)
#######################################
## Alternate Line dither mask instead of big one (lower quality - but fastest)
conv_line_dither="no"
AC_MSG_CHECKING(whether to build line dither mask code)
AC_ARG_ENABLE(line-dither-mask,
AC_HELP_STRING([--enable-line-dither-mask], [enable line dither mask code]),
[
if test "x$enableval" = "xyes" ; then
AC_MSG_RESULT(yes)
AC_DEFINE(BUILD_LINE_DITHER_MASK, 1, [Line Dither Mask Support])
conv_line_dither="yes"
else
AC_MSG_RESULT(no)
conv_line_dither="no"
fi
], [
AC_MSG_RESULT($conv_line_dither)
if test "x$conv_line_dither" = "xyes" ; then
AC_DEFINE(BUILD_LINE_DITHER_MASK, 1, [Line Dither Mask Support])
fi
]
)
#######################################
## No dither mask at all for 16bpp
conv_no_dither="no"
@ -1904,6 +1927,7 @@ echo " YUV Converter...........: $conv_yuv"
echo
echo "ARGB Conversion Options:"
echo " Smaller Dither Mask.....: $conv_small_dither"
echo " Line Dither Mask........: $conv_line_dither"
echo " No Dither Mask for 16bpp: $conv_no_dither"
echo " 8bpp RGB 332............: $conv_8_rgb_332"
echo " 8bpp RGB 666............: $conv_8_rgb_666"

View File

@ -26,6 +26,60 @@ evas_common_convert_rgba2_to_16bpp_rgb_565_dith (DATA32 *src, DATA8 *dst, int sr
int dith, dith2;
int x, y;
#ifdef BUILD_LINE_DITHER_MASK
for (y = 0; y < h; y++)
{
if ((y + dith_y) & 0x1)
{
for (x = 0; x < w; x+=2)
{
DATA32 p = *src++, q = *src++;
r1 = ((p & 0xff0000) + 0x030000) >> 19;
if (r1 > 0x1f) r1 = 0x1f;
g1 = ((p & 0xff00) + 0x000100) >> 10;
if (g1 > 0x3f) g1 = 0x3f;
b1 = ((p & 0xff) + 0x000003) >> 3;
if (b1 > 0x1f) b1 = 0x1f;
r2 = ((q & 0xff0000) + 0x030000) >> 19;
if (r2 > 0x1f) r2 = 0x1f;
g2 = ((q & 0xff00) + 0x000100) >> 10;
if (g2 > 0x3f) g2 = 0x3f;
b2 = ((q & 0xff) + 0x000003) >> 3;
if (b2 > 0x1f) b2 = 0x1f;
#ifndef WORDS_BIGENDIAN
*((DATA32 *)d) = (r2 << 27) | (g2 << 21) | (b2 << 16) |
(r1 << 11) | (g1 << 5) | (b1);
#else
*((DATA32 *)d) = (r1 << 27) | (g1 << 21) | (b1 << 16) |
(r2 << 11) | (g2 << 5) | (b2);
#endif
d += 2;
}
}
else
{
x = w;
while (w > 0)
{
DATA32 p = *src++, q = *src++;
#ifndef WORDS_BIGENDIAN
*((DATA32 *)d) =
(((q & 0xff0000) >> 19) << 27) | (((q & 0xff00) >> 10) << 21) | (((q & 0xff) >> 3) << 16) |
(((p & 0xff0000) >> 19) << 11) | (((p & 0xff00) >> 10) << 5) | ((p & 0xff) >> 3);
#else
*((DATA32 *)d) =
(((p & 0xff0000) >> 19) << 27) | (((p & 0xff00) >> 10) << 21) | (((p & 0xff) >> 3) << 16) |
(((q & 0xff0000) >> 19) << 11) | (((q & 0xff00) >> 10) << 5) | ((q & 0xff) >> 3);
#endif
d += 2; w -= 2;
}
w = x;
}
src += src_jump;
d += dst_jump;
}
#else
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
@ -52,7 +106,7 @@ evas_common_convert_rgba2_to_16bpp_rgb_565_dith (DATA32 *src, DATA8 *dst, int sr
if ((r2 < 0x1f) && ((((q & 0xff0000) >> 16) - (r2 << 3)) >= dith )) r2++;
if ((g2 < 0x3f) && ((((q & 0xff00) >> 8) - (g2 << 2)) >= dith2)) g2++;
if ((b2 < 0x1f) && (((q & 0xff) - (b2 << 3)) >= dith )) b2++;
#ifndef WORDS_BIGENDIAN
*((DATA32 *)d) = (r2 << 27) | (g2 << 21) | (b2 << 16) |
(r1 << 11) | (g1 << 5) | (b1);
@ -65,6 +119,7 @@ evas_common_convert_rgba2_to_16bpp_rgb_565_dith (DATA32 *src, DATA8 *dst, int sr
src += src_jump;
d += dst_jump;
}
#endif
return;
pal = 0;
#else
@ -110,6 +165,38 @@ evas_common_convert_rgba_to_16bpp_rgb_565_dith (DATA32 *src, DATA8 *dst, int src
int dith, dith2;
int x, y;
#ifdef BUILD_LINE_DITHER_MASK
for (y = 0; y < h; y++)
{
if ((y + dith_y) & 0x1)
{
for (x = 0; x < w; x++)
{
DATA32 p = *src++;
r = (p & 0xff0000) >> 19;
if (r > 0x1f) r = 0x1f;
g = (p & 0xff00) >> 10;
if (g > 0x3f) g = 0x3f;
b = (p & 0xff) >> 3;
if (b > 0x1f) b = 0x1f;
*d++ = (r << 11) | (g << 5) | b;
}
}
else
{
x = w;
while (w--)
{
*d++ = (((*src & 0xff0000) >> 19) << 11) | (((*src & 0xff00) >> 10) << 5) | ((*src & 0xff) >> 3);
src++;
}
w = x;
}
src += src_jump;
d += dst_jump;
}
#else
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
@ -131,6 +218,7 @@ evas_common_convert_rgba_to_16bpp_rgb_565_dith (DATA32 *src, DATA8 *dst, int src
src += src_jump;
d += dst_jump;
}
#endif
return;
pal = 0;
#else