summaryrefslogtreecommitdiff
path: root/Source/DirectFB/src/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/DirectFB/src/gfx')
-rwxr-xr-xSource/DirectFB/src/gfx/Makefile.am29
-rwxr-xr-xSource/DirectFB/src/gfx/Makefile.in676
-rwxr-xr-xSource/DirectFB/src/gfx/clip.c379
-rwxr-xr-xSource/DirectFB/src/gfx/clip.h125
-rwxr-xr-xSource/DirectFB/src/gfx/convert.c1427
-rwxr-xr-xSource/DirectFB/src/gfx/convert.h562
-rwxr-xr-xSource/DirectFB/src/gfx/generic/Makefile.am62
-rwxr-xr-xSource/DirectFB/src/gfx/generic/Makefile.in602
-rwxr-xr-xSource/DirectFB/src/gfx/generic/duffs_device.h89
-rwxr-xr-xSource/DirectFB/src/gfx/generic/generic.c9161
-rwxr-xr-xSource/DirectFB/src/gfx/generic/generic.h174
-rwxr-xr-xSource/DirectFB/src/gfx/generic/generic_64.h207
-rwxr-xr-xSource/DirectFB/src/gfx/generic/generic_dummy.c94
-rwxr-xr-xSource/DirectFB/src/gfx/generic/generic_mmx.h659
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_hvx_16.h469
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_hvx_32.h174
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_hvx_8.h149
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_hvx_88.h152
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_hvx_N.h121
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_up_down_16.h68
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_up_down_32.h68
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_up_down_32_indexed.h82
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_up_down_8.h72
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_up_down_88.h72
-rwxr-xr-xSource/DirectFB/src/gfx/generic/stretch_up_down_table.h59
-rwxr-xr-xSource/DirectFB/src/gfx/generic/template_acc_16.h382
-rwxr-xr-xSource/DirectFB/src/gfx/generic/template_acc_32.h261
-rwxr-xr-xSource/DirectFB/src/gfx/generic/template_colorkey_16.h369
-rwxr-xr-xSource/DirectFB/src/gfx/generic/template_colorkey_32.h206
-rwxr-xr-xSource/DirectFB/src/gfx/generic/yuvtbl-gen.c199
-rwxr-xr-xSource/DirectFB/src/gfx/generic/yuvtbl.h296
-rwxr-xr-xSource/DirectFB/src/gfx/util.c270
-rwxr-xr-xSource/DirectFB/src/gfx/util.h42
33 files changed, 17757 insertions, 0 deletions
diff --git a/Source/DirectFB/src/gfx/Makefile.am b/Source/DirectFB/src/gfx/Makefile.am
new file mode 100755
index 0000000..8cbd6b9
--- /dev/null
+++ b/Source/DirectFB/src/gfx/Makefile.am
@@ -0,0 +1,29 @@
+## Makefile.am for DirectFB/src/misc
+
+SUBDIRS = generic
+
+INCLUDES = \
+ -I$(top_builddir)/lib \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src
+
+
+internalincludedir = $(INTERNALINCLUDEDIR)/gfx
+
+internalinclude_HEADERS = \
+ clip.h \
+ convert.h \
+ util.h
+
+
+noinst_LTLIBRARIES = libdirectfb_gfx.la
+
+libdirectfb_gfx_la_SOURCES = \
+ clip.c \
+ convert.c \
+ util.c
+
+libdirectfb_gfx_la_LIBADD = \
+ generic/libdirectfb_generic.la
diff --git a/Source/DirectFB/src/gfx/Makefile.in b/Source/DirectFB/src/gfx/Makefile.in
new file mode 100755
index 0000000..db7dfa4
--- /dev/null
+++ b/Source/DirectFB/src/gfx/Makefile.in
@@ -0,0 +1,676 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/gfx
+DIST_COMMON = $(internalinclude_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libdirectfb_gfx_la_DEPENDENCIES = generic/libdirectfb_generic.la
+am_libdirectfb_gfx_la_OBJECTS = clip.lo convert.lo util.lo
+libdirectfb_gfx_la_OBJECTS = $(am_libdirectfb_gfx_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libdirectfb_gfx_la_SOURCES)
+DIST_SOURCES = $(libdirectfb_gfx_la_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(internalincludedir)"
+internalincludeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(internalinclude_HEADERS)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+ASFLAGS = @ASFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIR = @DATADIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DFB_CFLAGS_OMIT_FRAME_POINTER = @DFB_CFLAGS_OMIT_FRAME_POINTER@
+DFB_INTERNAL_CFLAGS = @DFB_INTERNAL_CFLAGS@
+DFB_LDFLAGS = @DFB_LDFLAGS@
+DFB_SMOOTH_SCALING = @DFB_SMOOTH_SCALING@
+DIRECTFB_BINARY_AGE = @DIRECTFB_BINARY_AGE@
+DIRECTFB_CSOURCE = @DIRECTFB_CSOURCE@
+DIRECTFB_INTERFACE_AGE = @DIRECTFB_INTERFACE_AGE@
+DIRECTFB_MAJOR_VERSION = @DIRECTFB_MAJOR_VERSION@
+DIRECTFB_MICRO_VERSION = @DIRECTFB_MICRO_VERSION@
+DIRECTFB_MINOR_VERSION = @DIRECTFB_MINOR_VERSION@
+DIRECTFB_VERSION = @DIRECTFB_VERSION@
+DIRECT_BUILD_DEBUG = @DIRECT_BUILD_DEBUG@
+DIRECT_BUILD_DEBUGS = @DIRECT_BUILD_DEBUGS@
+DIRECT_BUILD_GETTID = @DIRECT_BUILD_GETTID@
+DIRECT_BUILD_NETWORK = @DIRECT_BUILD_NETWORK@
+DIRECT_BUILD_STDBOOL = @DIRECT_BUILD_STDBOOL@
+DIRECT_BUILD_TEXT = @DIRECT_BUILD_TEXT@
+DIRECT_BUILD_TRACE = @DIRECT_BUILD_TRACE@
+DSYMUTIL = @DSYMUTIL@
+DYNLIB = @DYNLIB@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+FREETYPE_PROVIDER = @FREETYPE_PROVIDER@
+FUSION_BUILD_KERNEL = @FUSION_BUILD_KERNEL@
+FUSION_BUILD_MULTI = @FUSION_BUILD_MULTI@
+FUSION_MESSAGE_SIZE = @FUSION_MESSAGE_SIZE@
+GIF_PROVIDER = @GIF_PROVIDER@
+GREP = @GREP@
+HAVE_LINUX = @HAVE_LINUX@
+INCLUDEDIR = @INCLUDEDIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTERNALINCLUDEDIR = @INTERNALINCLUDEDIR@
+JPEG_PROVIDER = @JPEG_PROVIDER@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBJPEG = @LIBJPEG@
+LIBOBJS = @LIBOBJS@
+LIBPNG = @LIBPNG@
+LIBPNG_CONFIG = @LIBPNG_CONFIG@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_AGE = @LT_AGE@
+LT_BINARY = @LT_BINARY@
+LT_CURRENT = @LT_CURRENT@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAN2HTML = @MAN2HTML@
+MKDIR_P = @MKDIR_P@
+MODULEDIR = @MODULEDIR@
+MODULEDIRNAME = @MODULEDIRNAME@
+NMEDIT = @NMEDIT@
+OBJEXT = @OBJEXT@
+OSX_LIBS = @OSX_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PNG_PROVIDER = @PNG_PROVIDER@
+RANLIB = @RANLIB@
+RUNTIME_SYSROOT = @RUNTIME_SYSROOT@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOPATH = @SOPATH@
+STRIP = @STRIP@
+SYSCONFDIR = @SYSCONFDIR@
+SYSFS_LIBS = @SYSFS_LIBS@
+THREADFLAGS = @THREADFLAGS@
+THREADLIB = @THREADLIB@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+VERSION = @VERSION@
+VNC_CFLAGS = @VNC_CFLAGS@
+VNC_CONFIG = @VNC_CONFIG@
+VNC_LIBS = @VNC_LIBS@
+X11_CFLAGS = @X11_CFLAGS@
+X11_LIBS = @X11_LIBS@
+ZLIB_LIBS = @ZLIB_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = generic
+INCLUDES = \
+ -I$(top_builddir)/lib \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src
+
+internalincludedir = $(INTERNALINCLUDEDIR)/gfx
+internalinclude_HEADERS = \
+ clip.h \
+ convert.h \
+ util.h
+
+noinst_LTLIBRARIES = libdirectfb_gfx.la
+libdirectfb_gfx_la_SOURCES = \
+ clip.c \
+ convert.c \
+ util.c
+
+libdirectfb_gfx_la_LIBADD = \
+ generic/libdirectfb_generic.la
+
+all: all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/gfx/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/gfx/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libdirectfb_gfx.la: $(libdirectfb_gfx_la_OBJECTS) $(libdirectfb_gfx_la_DEPENDENCIES)
+ $(LINK) $(libdirectfb_gfx_la_OBJECTS) $(libdirectfb_gfx_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clip.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convert.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-internalincludeHEADERS: $(internalinclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(internalincludedir)" || $(MKDIR_P) "$(DESTDIR)$(internalincludedir)"
+ @list='$(internalinclude_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(internalincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(internalincludedir)/$$f'"; \
+ $(internalincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(internalincludedir)/$$f"; \
+ done
+
+uninstall-internalincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(internalinclude_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(internalincludedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(internalincludedir)/$$f"; \
+ done
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+ list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ distdir=`$(am__cd) $(distdir) && pwd`; \
+ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
+ (cd $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$top_distdir" \
+ distdir="$$distdir/$$subdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs: installdirs-recursive
+installdirs-am:
+ for dir in "$(DESTDIR)$(internalincludedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am: install-internalincludeHEADERS
+
+install-dvi: install-dvi-recursive
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-internalincludeHEADERS
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+ install-strip
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+ all all-am check check-am clean clean-generic clean-libtool \
+ clean-noinstLTLIBRARIES ctags ctags-recursive distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am \
+ install-internalincludeHEADERS install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs installdirs-am \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
+ uninstall-internalincludeHEADERS
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/Source/DirectFB/src/gfx/clip.c b/Source/DirectFB/src/gfx/clip.c
new file mode 100755
index 0000000..195dc73
--- /dev/null
+++ b/Source/DirectFB/src/gfx/clip.c
@@ -0,0 +1,379 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <string.h>
+
+#include <directfb.h>
+
+#include <direct/util.h>
+
+#include <misc/util.h>
+
+#include <gfx/clip.h>
+
+#define REGION_CODE(x,y,cx1,cx2,cy1,cy2) ( ( (y) > (cy2) ? 8 : 0) | \
+ ( (y) < (cy1) ? 4 : 0) | \
+ ( (x) > (cx2) ? 2 : 0) | \
+ ( (x) < (cx1) ? 1 : 0) )
+
+
+DFBBoolean
+dfb_clip_line( const DFBRegion *clip, DFBRegion *line )
+{
+ unsigned char region_code1 = REGION_CODE( line->x1, line->y1,
+ clip->x1,
+ clip->x2,
+ clip->y1,
+ clip->y2 );
+
+ unsigned char region_code2 = REGION_CODE( line->x2, line->y2,
+ clip->x1,
+ clip->x2,
+ clip->y1,
+ clip->y2 );
+
+ while (region_code1 | region_code2) {
+ /* line completely outside the clipping rectangle */
+ if (region_code1 & region_code2)
+ return DFB_FALSE;
+
+
+ if (region_code1) {
+ if (region_code1 & 8) { /* divide line at bottom*/
+ line->x1 = line->x1 +(line->x2-line->x1) * (clip->y2 - line->y1) / (line->y2-line->y1);
+ line->y1 = clip->y2;
+ }
+ else
+ if (region_code1 & 4) { /* divide line at top*/
+ line->x1 = line->x1 +(line->x2-line->x1) * (clip->y1 - line->y1) / (line->y2-line->y1);
+ line->y1 = clip->y1;
+ }
+ else
+ if (region_code1 & 2) { /* divide line at right*/
+ line->y1 = line->y1 +(line->y2-line->y1) * (clip->x2 - line->x1) / (line->x2-line->x1);
+ line->x1 = clip->x2;
+ }
+ else
+ if (region_code1 & 1) { /* divide line at right*/
+ line->y1 = line->y1 +(line->y2-line->y1) * (clip->x1 - line->x1) / (line->x2-line->x1);
+ line->x1 = clip->x1;
+ }
+ region_code1 = REGION_CODE( line->x1, line->y1,
+ clip->x1,
+ clip->x2,
+ clip->y1,
+ clip->y2 );
+ }
+ else {
+ if (region_code2 & 8) { /* divide line at bottom*/
+ line->x2 = line->x1 +(line->x2-line->x1) * (clip->y2 - line->y1) / (line->y2-line->y1);
+ line->y2 = clip->y2;
+ }
+ else
+ if (region_code2 & 4) { /* divide line at top*/
+ line->x2 = line->x1 +(line->x2-line->x1) * (clip->y1 - line->y1) / (line->y2-line->y1);
+ line->y2 = clip->y1;
+ }
+ else
+ if (region_code2 & 2) { /* divide line at right*/
+ line->y2 = line->y1 +(line->y2-line->y1) * (clip->x2 - line->x1) / (line->x2-line->x1);
+ line->x2 = clip->x2;
+ }
+ else
+ if (region_code2 & 1) { /* divide line at right*/
+ line->y2 = line->y1 +(line->y2-line->y1) * (clip->x1 - line->x1) / (line->x2-line->x1);
+ line->x2 = clip->x1;
+ }
+ region_code2 = REGION_CODE( line->x2, line->y2, clip->x1,
+ clip->x2,
+ clip->y1,
+ clip->y2 );
+ }
+ }
+
+ /* successfully clipped or clipping not neccessary */
+ return DFB_TRUE;
+}
+
+DFBEdgeFlags
+dfb_clip_edges( const DFBRegion *clip, DFBRectangle *rect )
+{
+ DFBEdgeFlags flags = DFEF_ALL;
+
+ if ((clip->x1 >= rect->x + rect->w) ||
+ (clip->x2 < rect->x) ||
+ (clip->y1 >= rect->y + rect->h) ||
+ (clip->y2 < rect->y))
+ return DFEF_NONE;
+
+ if (clip->x1 > rect->x) {
+ rect->w += rect->x - clip->x1;
+ rect->x = clip->x1;
+
+ flags &= ~DFEF_LEFT;
+ }
+
+ if (clip->y1 > rect->y) {
+ rect->h += rect->y - clip->y1;
+ rect->y = clip->y1;
+
+ flags &= ~DFEF_TOP;
+ }
+
+ if (clip->x2 < rect->x + rect->w - 1) {
+ rect->w = clip->x2 - rect->x + 1;
+
+ flags &= ~DFEF_RIGHT;
+ }
+
+ if (clip->y2 < rect->y + rect->h - 1) {
+ rect->h = clip->y2 - rect->y + 1;
+
+ flags &= ~DFEF_BOTTOM;
+ }
+
+ return flags;
+}
+
+DFBBoolean
+dfb_clip_rectangle( const DFBRegion *clip, DFBRectangle *rect )
+{
+ if ((clip->x1 >= rect->x + rect->w) ||
+ (clip->x2 < rect->x) ||
+ (clip->y1 >= rect->y + rect->h) ||
+ (clip->y2 < rect->y))
+ return DFB_FALSE;
+
+ if (clip->x1 > rect->x) {
+ rect->w += rect->x - clip->x1;
+ rect->x = clip->x1;
+ }
+
+ if (clip->y1 > rect->y) {
+ rect->h += rect->y - clip->y1;
+ rect->y = clip->y1;
+ }
+
+ if (clip->x2 < rect->x + rect->w - 1)
+ rect->w = clip->x2 - rect->x + 1;
+
+ if (clip->y2 < rect->y + rect->h - 1)
+ rect->h = clip->y2 - rect->y + 1;
+
+ return DFB_TRUE;
+}
+
+DFBBoolean
+dfb_clip_triangle_precheck( const DFBRegion *clip, const DFBTriangle *tri )
+{
+ int x, y, w, h;
+
+ x = MIN (MIN (tri->x1, tri->x2), tri->x3);
+ y = MIN (MIN (tri->y1, tri->y2), tri->y3);
+ w = MAX (MAX (tri->x1, tri->x2), tri->x3) - x;
+ h = MAX (MAX (tri->y1, tri->y2), tri->y3) - y;
+
+ if (clip->x1 > x ||
+ clip->x2 < x + w ||
+ clip->y1 > y ||
+ clip->y2 < y + h)
+ return DFB_FALSE;
+
+ return DFB_TRUE;
+}
+
+DFBBoolean
+dfb_clip_triangle( const DFBRegion *clip, const DFBTriangle *tri, DFBPoint p[6], int *num )
+{
+ DFBRegion edges[3];
+ int num_edges;
+ int i, n;
+ DFBPoint p1 = {0, 0}, p2 = {0, 0};
+
+ /* Initialize edges. */
+ edges[0].x1 = tri->x1; edges[0].y1 = tri->y1;
+ edges[0].x2 = tri->x2; edges[0].y2 = tri->y2;
+ edges[1].x1 = tri->x2; edges[1].y1 = tri->y2;
+ edges[1].x2 = tri->x3; edges[1].y2 = tri->y3;
+ edges[2].x1 = tri->x3; edges[2].y1 = tri->y3;
+ edges[2].x2 = tri->x1; edges[2].y2 = tri->y1;
+ num_edges = 3;
+
+ for (i = 0; i < num_edges; i++) {
+ DFBRegion *reg = &edges[i];
+ DFBRegion line;
+ bool i1, i2;
+
+ /* Clip the edge to the clipping region. */
+ line = *reg;
+ if (dfb_clip_line( clip, &line )) {
+ *reg = line;
+ continue;
+ }
+
+ /* If the edge doesn't intersect clipping region, then
+ * intersect the edge with the diagonals of the clipping
+ * rectangle. If intersection point exits, add the nearest
+ * corner of the clipping region to the list of vertices.
+ */
+
+ /* Diagonal (x1,y1) (x2,y2). */
+ line = (DFBRegion) { clip->x1, clip->y1, clip->x2, clip->y2 };
+ i1 = dfb_line_segment_intersect( &line, reg, &p1.x, &p1.y );
+ if (i1) {
+ /* Get nearest corner. */
+ if (p1.x <= clip->x1 || p1.y <= clip->y1) {
+ p1.x = clip->x1;
+ p1.y = clip->y1;
+ } else {
+ p1.x = clip->x2;
+ p1.y = clip->y2;
+ }
+ }
+
+ /* Diagonal (x2,y1) (x1,y2). */
+ line = (DFBRegion) { clip->x2, clip->y1, clip->x1, clip->y2 };
+ i2 = dfb_line_segment_intersect( &line, reg, &p2.x, &p2.y );
+ if (i2) {
+ /* Get nearest corner. */
+ if (p2.x >= clip->x2 || p2.y <= clip->y1) {
+ p2.x = clip->x2;
+ p2.y = clip->y1;
+ } else {
+ p2.x = clip->x1;
+ p2.y = clip->y2;
+ }
+ }
+
+ if (i1 && i2) {
+ reg->x1 = p1.x;
+ reg->y1 = p1.y;
+ reg->x2 = p2.x;
+ reg->y2 = p2.y;
+ }
+ else if (i1) {
+ reg->x1 = reg->x2 = p1.x;
+ reg->y1 = reg->y2 = p1.y;
+ }
+ else if (i2) {
+ reg->x1 = reg->x2 = p2.x;
+ reg->y1 = reg->y2 = p2.y;
+ }
+ else {
+ /* Redudant edge. Remote it. */
+ memmove( reg, &edges[i+1], (num_edges-i-1) * sizeof(DFBRegion) );
+ num_edges--;
+ i--;
+ }
+ }
+
+ if (num_edges < 1) {
+ *num = 0;
+ return DFB_FALSE;
+ }
+
+ /* Get vertices from edges. */
+ p[0].x = edges[0].x1; p[0].y = edges[0].y1;
+ n = 1;
+ if (edges[0].x2 != edges[0].x1 || edges[0].y2 != edges[0].y1) {
+ p[1].x = edges[0].x2; p[1].y = edges[0].y2;
+ n++;
+ }
+
+ for (i = 1; i < num_edges; i++) {
+ if (edges[i].x1 != p[n-1].x || edges[i].y1 != p[n-1].y) {
+ p[n].x = edges[i].x1; p[n].y = edges[i].y1;
+ n++;
+ }
+ if (edges[i].x2 != p[n-1].x || edges[i].y2 != p[n-1].y) {
+ p[n].x = edges[i].x2; p[n].y = edges[i].y2;
+ n++;
+ }
+ }
+
+ if (p[n-1].x == p[0].x && p[n-1].y == p[0].y)
+ n--;
+
+ *num = n;
+
+ /* Actually fail if the number of vertices is below 3. */
+ return (n >= 3);
+}
+
+
+void
+dfb_clip_blit( const DFBRegion *clip,
+ DFBRectangle *srect, int *dx, int *dy )
+{
+ if (clip->x1 > *dx ) {
+ srect->w = MIN( (clip->x2 - clip->x1) + 1,
+ (*dx + srect->w) - clip->x1);
+
+ srect->x+= clip->x1 - *dx;
+ *dx = clip->x1;
+ }
+ else if (clip->x2 < *dx + srect->w - 1) {
+ srect->w = clip->x2 - *dx + 1;
+ }
+
+ if (clip->y1 > *dy ) {
+ srect->h = MIN( (clip->y2 - clip->y1) + 1,
+ (*dy + srect->h) - clip->y1);
+ srect->y+= clip->y1 - *dy;
+ *dy = clip->y1;
+ }
+ else if (clip->y2 < *dy + srect->h - 1) {
+ srect->h = clip->y2 - *dy + 1;
+ }
+}
+
+void
+dfb_clip_stretchblit( const DFBRegion *clip,
+ DFBRectangle *srect, DFBRectangle *drect )
+{
+ DFBRectangle orig_dst = *drect;
+
+ dfb_clip_rectangle( clip, drect );
+
+ if (drect->x != orig_dst.x)
+ srect->x += (int)( (drect->x - orig_dst.x) *
+ (srect->w / (float)orig_dst.w) );
+
+ if (drect->y != orig_dst.y)
+ srect->y += (int)( (drect->y - orig_dst.y) *
+ (srect->h / (float)orig_dst.h) );
+
+ if (drect->w != orig_dst.w)
+ srect->w = (int)( srect->w * (drect->w / (float)orig_dst.w) );
+
+ if (drect->h != orig_dst.h)
+ srect->h = (int)( srect->h * (drect->h / (float)orig_dst.h) );
+}
+
diff --git a/Source/DirectFB/src/gfx/clip.h b/Source/DirectFB/src/gfx/clip.h
new file mode 100755
index 0000000..e1ea261
--- /dev/null
+++ b/Source/DirectFB/src/gfx/clip.h
@@ -0,0 +1,125 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __GFX__CLIP_H__
+#define __GFX__CLIP_H__
+
+#include <directfb.h>
+
+typedef enum {
+ DFEF_NONE = 0x00000000,
+
+ DFEF_LEFT = 0x00000001,
+ DFEF_RIGHT = 0x00000002,
+ DFEF_TOP = 0x00000004,
+ DFEF_BOTTOM = 0x00000008,
+
+ DFEF_ALL = 0x0000000F
+} DFBEdgeFlags;
+
+/*
+ * Clips the line to the clipping region.
+ * Returns DFB_TRUE if at least one pixel of the line resides in the region.
+ */
+DFBBoolean dfb_clip_line( const DFBRegion *clip, DFBRegion *line );
+
+/*
+ * Clips the rectangle to the clipping region.
+ * Returns true if there was an intersection with the clipping region.
+ */
+DFBBoolean dfb_clip_rectangle( const DFBRegion *clip, DFBRectangle *rect );
+
+/*
+ * Clips the rectangle to the clipping region.
+ * Returns a flag for each edge that wasn't cut off.
+ */
+DFBEdgeFlags dfb_clip_edges( const DFBRegion *clip, DFBRectangle *rect );
+
+static inline DFBBoolean
+dfb_clip_needed( const DFBRegion *clip, DFBRectangle *rect )
+{
+ return ((clip->x1 > rect->x) ||
+ (clip->y1 > rect->y) ||
+ (clip->x2 < rect->x + rect->w - 1) ||
+ (clip->y2 < rect->y + rect->h - 1));
+}
+
+/*
+ * Simple check if triangle lies outside the clipping region.
+ * Returns true if the triangle may be visible within the region.
+ */
+DFBBoolean dfb_clip_triangle_precheck( const DFBRegion *clip,
+ const DFBTriangle *tri );
+
+/*
+ * Clips the triangle to the clipping region.
+ * Returns true if the triangle if visible within the region.
+ * The vertices of the polygon resulting from intersection are returned in buf.
+ * The number of vertices is at least 3.
+ */
+DFBBoolean dfb_clip_triangle( const DFBRegion *clip,
+ const DFBTriangle *tri,
+ DFBPoint buf[6],
+ int *num );
+
+/*
+ * Simple check if requested blitting lies outside of the clipping region.
+ * Returns true if blitting may need to be performed.
+ */
+static inline DFBBoolean
+dfb_clip_blit_precheck( const DFBRegion *clip,
+ int w, int h, int dx, int dy )
+{
+ if (w < 1 || h < 1 ||
+ (clip->x1 >= dx + w) ||
+ (clip->x2 < dx) ||
+ (clip->y1 >= dy + h) ||
+ (clip->y2 < dy))
+ return DFB_FALSE;
+
+ return DFB_TRUE;
+}
+
+/*
+ * Clips the blitting request to the clipping region.
+ * This includes adjustment of source AND destination coordinates.
+ */
+void dfb_clip_blit( const DFBRegion *clip,
+ DFBRectangle *srect, int *dx, int *dy );
+
+/*
+ * Clips the stretch blit request to the clipping region.
+ * This includes adjustment of source AND destination coordinates
+ * based on the scaling factor.
+ */
+void dfb_clip_stretchblit( const DFBRegion *clip,
+ DFBRectangle *srect,
+ DFBRectangle *drect );
+
+#endif
+
diff --git a/Source/DirectFB/src/gfx/convert.c b/Source/DirectFB/src/gfx/convert.c
new file mode 100755
index 0000000..484f5a6
--- /dev/null
+++ b/Source/DirectFB/src/gfx/convert.c
@@ -0,0 +1,1427 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <directfb.h>
+#include <directfb_util.h>
+
+#include "convert.h"
+
+/* lookup tables for 2/3bit to 8bit color conversion */
+static const u8 lookup3to8[] = { 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff};
+static const u8 lookup2to8[] = { 0x00, 0x55, 0xaa, 0xff};
+
+#define EXPAND_1to8(v) ((v) ? 0xff : 0x00)
+#define EXPAND_2to8(v) (lookup2to8[v])
+#define EXPAND_3to8(v) (lookup3to8[v])
+#define EXPAND_4to8(v) (((v) << 4) | ((v) ))
+#define EXPAND_5to8(v) (((v) << 3) | ((v) >> 2))
+#define EXPAND_6to8(v) (((v) << 2) | ((v) >> 4))
+#define EXPAND_7to8(v) (((v) << 1) | ((v) >> 6))
+
+
+DFBSurfacePixelFormat
+dfb_pixelformat_for_depth( int depth )
+{
+ switch (depth) {
+ case 2:
+ return DSPF_LUT2;
+ case 8:
+ return DSPF_LUT8;
+ case 12:
+ return DSPF_ARGB4444;
+ case 14:
+ return DSPF_ARGB2554;
+ case 15:
+ return DSPF_ARGB1555;
+ case 16:
+ return DSPF_RGB16;
+ case 18:
+ return DSPF_RGB18;
+ case 24:
+ return DSPF_RGB24;
+ case 32:
+ return DSPF_RGB32;
+ }
+
+ return DSPF_UNKNOWN;
+}
+
+void
+dfb_pixel_to_color( DFBSurfacePixelFormat format,
+ unsigned long pixel,
+ DFBColor *ret_color )
+{
+ ret_color->a = 0xff;
+
+ switch (format) {
+ case DSPF_RGB332:
+ ret_color->r = EXPAND_3to8( (pixel & 0xe0) >> 5 );
+ ret_color->g = EXPAND_3to8( (pixel & 0x1c) >> 2 );
+ ret_color->b = EXPAND_2to8( (pixel & 0x03) );
+ break;
+
+ case DSPF_ARGB1555:
+ ret_color->a = EXPAND_1to8( pixel >> 15 );
+ case DSPF_RGB555:
+ ret_color->r = EXPAND_5to8( (pixel & 0x7c00) >> 10 );
+ ret_color->g = EXPAND_5to8( (pixel & 0x03e0) >> 5 );
+ ret_color->b = EXPAND_5to8( (pixel & 0x001f) );
+ break;
+
+ case DSPF_BGR555:
+ ret_color->r = EXPAND_5to8( (pixel & 0x001f) );
+ ret_color->g = EXPAND_5to8( (pixel & 0x03e0) >> 5 );
+ ret_color->b = EXPAND_5to8( (pixel & 0x7c00) >> 10 );
+ break;
+
+ case DSPF_ARGB2554:
+ ret_color->a = EXPAND_2to8( pixel >> 14 );
+ ret_color->r = EXPAND_5to8( (pixel & 0x3e00) >> 9 );
+ ret_color->g = EXPAND_5to8( (pixel & 0x01f0) >> 4 );
+ ret_color->b = EXPAND_4to8( (pixel & 0x000f) );
+ break;
+
+ case DSPF_ARGB4444:
+ ret_color->a = EXPAND_4to8( pixel >> 12 );
+ case DSPF_RGB444:
+ ret_color->r = EXPAND_4to8( (pixel & 0x0f00) >> 8 );
+ ret_color->g = EXPAND_4to8( (pixel & 0x00f0) >> 4 );
+ ret_color->b = EXPAND_4to8( (pixel & 0x000f) );
+ break;
+
+ case DSPF_RGBA4444:
+ ret_color->r = EXPAND_4to8( (pixel ) >> 12 );
+ ret_color->g = EXPAND_4to8( (pixel & 0x0f00) >> 8 );
+ ret_color->b = EXPAND_4to8( (pixel & 0x00f0) >> 4 );
+ ret_color->a = EXPAND_4to8( (pixel & 0x000f) );
+ break;
+
+ case DSPF_RGB16:
+ ret_color->r = EXPAND_5to8( (pixel & 0xf800) >> 11 );
+ ret_color->g = EXPAND_6to8( (pixel & 0x07e0) >> 5 );
+ ret_color->b = EXPAND_5to8( (pixel & 0x001f) );
+ break;
+
+ case DSPF_ARGB:
+ ret_color->a = pixel >> 24;
+ case DSPF_RGB24:
+ case DSPF_RGB32:
+ ret_color->r = (pixel & 0xff0000) >> 16;
+ ret_color->g = (pixel & 0x00ff00) >> 8;
+ ret_color->b = (pixel & 0x0000ff);
+ break;
+
+ case DSPF_AiRGB:
+ ret_color->a = (pixel >> 24) ^ 0xff;
+ ret_color->r = (pixel & 0xff0000) >> 16;
+ ret_color->g = (pixel & 0x00ff00) >> 8;
+ ret_color->b = (pixel & 0x0000ff);
+ break;
+
+ default:
+ ret_color->r = 0;
+ ret_color->g = 0;
+ ret_color->b = 0;
+ }
+}
+
+unsigned long
+dfb_pixel_from_color( DFBSurfacePixelFormat format,
+ const DFBColor *color )
+{
+ u32 y, cb, cr;
+
+ switch (format) {
+ case DSPF_RGB332:
+ return PIXEL_RGB332( color->r, color->g, color->b );
+
+ case DSPF_ARGB1555:
+ return PIXEL_ARGB1555( color->a, color->r, color->g, color->b );
+
+ case DSPF_RGB555:
+ return PIXEL_RGB555( color->r, color->g, color->b );
+
+ case DSPF_BGR555:
+ return PIXEL_BGR555( color->r, color->g, color->b );
+
+ case DSPF_ARGB2554:
+ return PIXEL_ARGB2554( color->a, color->r, color->g, color->b );
+
+ case DSPF_ARGB4444:
+ return PIXEL_ARGB4444( color->a, color->r, color->g, color->b );
+
+ case DSPF_RGBA4444:
+ return PIXEL_RGBA4444( color->a, color->r, color->g, color->b );
+
+ case DSPF_RGB444:
+ return PIXEL_RGB444( color->r, color->g, color->b );
+
+ case DSPF_RGB16:
+ return PIXEL_RGB16( color->r, color->g, color->b );
+
+ case DSPF_RGB18:
+ return PIXEL_RGB18( color->r, color->g, color->b );
+
+ case DSPF_ARGB1666:
+ return PIXEL_ARGB1666( color->a, color->r, color->g, color->b );
+
+ case DSPF_ARGB6666:
+ return PIXEL_ARGB6666( color->a, color->r, color->g, color->b );
+
+ case DSPF_RGB24:
+ return PIXEL_RGB32( color->r, color->g, color->b );
+
+ case DSPF_RGB32:
+ return PIXEL_RGB32( color->r, color->g, color->b );
+
+ case DSPF_ARGB:
+ return PIXEL_ARGB( color->a, color->r, color->g, color->b );
+
+ case DSPF_AiRGB:
+ return PIXEL_AiRGB( color->a, color->r, color->g, color->b );
+
+ case DSPF_AYUV:
+ RGB_TO_YCBCR( color->r, color->g, color->b, y, cb, cr );
+ return PIXEL_AYUV( color->a, y, cb, cr );
+
+ case DSPF_YUY2:
+ RGB_TO_YCBCR( color->r, color->g, color->b, y, cb, cr );
+ return PIXEL_YUY2( y, cb, cr );
+
+ case DSPF_UYVY:
+ RGB_TO_YCBCR( color->r, color->g, color->b, y, cb, cr );
+ return PIXEL_UYVY( y, cb, cr );
+
+ case DSPF_I420:
+ case DSPF_YV12:
+ RGB_TO_YCBCR( color->r, color->g, color->b, y, cb, cr );
+ return y | (cb << 8) | (cr << 16);
+
+ default:
+ D_WARN( "unknown format 0x%08x", format );
+ }
+
+ return 0x55555555;
+}
+
+const char *
+dfb_pixelformat_name( DFBSurfacePixelFormat format )
+{
+ int i = 0;
+
+ do {
+ if (format == dfb_pixelformat_names[i].format)
+ return dfb_pixelformat_names[i].name;
+ } while (dfb_pixelformat_names[i++].format != DSPF_UNKNOWN);
+
+ return "<invalid>";
+}
+
+void
+dfb_convert_to_rgb16( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u16 *dst,
+ int dpitch,
+ int width,
+ int height )
+{
+ const int dp2 = dpitch / 2;
+ int x;
+
+ switch (format) {
+ case DSPF_RGB16:
+ while (height--) {
+ direct_memcpy( dst, src, width * 2 );
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_NV16:
+ while (height--) {
+ const u8 *src8 = src;
+ const u16 *src16 = src + surface_height * spitch;
+
+ for (x=0; x<width; x++) {
+ int r, g, b;
+
+#ifdef WORDS_BIGENDIAN
+ YCBCR_TO_RGB( src8[x], src16[x>>1] >> 8, src16[x>>1] & 0xff, r, g, b );
+#else
+ YCBCR_TO_RGB( src8[x], src16[x>>1] & 0xff, src16[x>>1] >> 8, r, g, b );
+#endif
+
+ dst[x] = PIXEL_RGB16( r, g, b );
+ }
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_RGB444:
+ case DSPF_ARGB4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_RGB16( EXPAND_4to8( (src16[x] & 0x0f00) >> 8 ),
+ EXPAND_4to8( (src16[x] & 0x00f0) >> 4 ),
+ EXPAND_4to8( (src16[x] & 0x000f) ) );
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_RGBA4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_RGB16( EXPAND_4to8( (src16[x] & 0xf000) >> 12 ),
+ EXPAND_4to8( (src16[x] & 0x0f00) >> 8 ),
+ EXPAND_4to8( (src16[x] & 0x00f0) >> 4 ) );
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_RGB555:
+ case DSPF_ARGB1555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = ((src16[x] & 0x7c00) << 1) | ((src16[x] & 0x03e0) << 1) | (src16[x] & 0x003f);
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_BGR555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = ((src16[x] & 0x7c00) >> 10) | ((src16[x] & 0x03e0) << 1) | ((src16[x] & 0x001f) << 11 );
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_RGB32:
+ case DSPF_ARGB:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_RGB16( (src32[x] & 0xff0000) >> 16,
+ (src32[x] & 0x00ff00) >> 8,
+ (src32[x] & 0x0000ff) );
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_AYUV:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (x=0; x<width; x++) {
+ int r, g, b;
+
+ YCBCR_TO_RGB( (src32[x] >> 16) & 0xff, (src32[x] >> 8) & 0xff, src32[x] & 0xff, r, g, b );
+
+ dst[x] = PIXEL_RGB16( r, g, b );
+ }
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ default:
+ D_ONCE( "unsupported format" );
+ }
+}
+
+void
+dfb_convert_to_rgb555( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u16 *dst,
+ int dpitch,
+ int width,
+ int height )
+{
+ const int dp2 = dpitch / 2;
+ int x;
+
+ switch (format) {
+ case DSPF_RGB555:
+ case DSPF_ARGB1555:
+ while (height--) {
+ direct_memcpy( dst, src, width * 2 );
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_NV16:
+ while (height--) {
+ const u8 *src8 = src;
+ const u16 *src16 = src + surface_height * spitch;
+
+ for (x=0; x<width; x++) {
+ int r, g, b;
+
+#ifdef WORDS_BIGENDIAN
+ YCBCR_TO_RGB( src8[x], src16[x>>1] >> 8, src16[x>>1] & 0xff, r, g, b );
+#else
+ YCBCR_TO_RGB( src8[x], src16[x>>1] & 0xff, src16[x>>1] >> 8, r, g, b );
+#endif
+
+ dst[x] = PIXEL_RGB555( r, g, b );
+ }
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_RGB444:
+ case DSPF_ARGB4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_RGB555( EXPAND_4to8( (src16[x] & 0x0f00) >> 8 ),
+ EXPAND_4to8( (src16[x] & 0x00f0) >> 4 ),
+ EXPAND_4to8( (src16[x] & 0x000f) ) );
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_RGBA4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_RGB555( EXPAND_4to8( (src16[x] & 0xf000) >> 12 ),
+ EXPAND_4to8( (src16[x] & 0x0f00) >> 8 ),
+ EXPAND_4to8( (src16[x] & 0x00f0) >> 4 ) );
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_RGB16:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = ((src16[x] & 0xffc0) >> 1) | (src16[x] & 0x001f);
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_BGR555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = ((src16[x] & 0x7c00) >> 10) | (src16[x] & 0x03e0) | ((src16[x] & 0x001f) << 10 );
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_RGB32:
+ case DSPF_ARGB:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_RGB555( (src32[x] & 0xff0000) >> 16,
+ (src32[x] & 0x00ff00) >> 8,
+ (src32[x] & 0x0000ff) );
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ case DSPF_AYUV:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (x=0; x<width; x++) {
+ int r, g, b;
+
+ YCBCR_TO_RGB( (src32[x] >> 16) & 0xff, (src32[x] >> 8) & 0xff, src32[x] & 0xff, r, g, b );
+
+ dst[x] = PIXEL_RGB555( r, g, b );
+ }
+
+ src += spitch;
+ dst += dp2;
+ }
+ break;
+
+ default:
+ D_ONCE( "unsupported format" );
+ }
+}
+
+void
+dfb_convert_to_rgb32( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u32 *dst,
+ int dpitch,
+ int width,
+ int height )
+{
+ const int dp4 = dpitch / 4;
+ int x;
+
+ switch (format) {
+ case DSPF_RGB32:
+ case DSPF_ARGB:
+ while (height--) {
+ direct_memcpy( dst, src, width * 4 );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGB24:
+ while (height--) {
+ const u8 *src8 = src;
+
+ for (x=0; x<width; x++)
+#ifdef WORDS_BIGENDIAN
+ dst[x] = ( src8[x*3+0] << 16 ) |
+ ( src8[x*3+1] << 8 ) |
+ ( src8[x*3+2] );
+#else
+ dst[x] = ( src8[x*3+2] << 16 ) |
+ ( src8[x*3+1] << 8 ) |
+ ( src8[x*3+0] );
+#endif
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_AYUV:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (x=0; x<width; x++) {
+ int r, g, b;
+
+ YCBCR_TO_RGB( (src32[x] >> 16) & 0xff, (src32[x] >> 8) & 0xff, src32[x] & 0xff, r, g, b );
+
+ dst[x] = PIXEL_RGB32( r, g, b );
+ }
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_NV16:
+ while (height--) {
+ const u8 *src8 = src;
+ const u16 *src16 = src + surface_height * spitch;
+
+ for (x=0; x<width; x++) {
+ int r, g, b;
+
+#ifdef WORDS_BIGENDIAN
+ YCBCR_TO_RGB( src8[x], src16[x>>1] >> 8, src16[x>>1] & 0xff, r, g, b );
+#else
+ YCBCR_TO_RGB( src8[x], src16[x>>1] & 0xff, src16[x>>1] >> 8, r, g, b );
+#endif
+
+ dst[x] = PIXEL_RGB32( r, g, b );
+ }
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGB444:
+ case DSPF_ARGB4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = ARGB4444_TO_RGB32( src16[x] );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGBA4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = RGBA4444_TO_RGB32( src16[x] );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGB555:
+ case DSPF_ARGB1555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_RGB32( ((src16[x] & 0x7c00) >> 7) | ((src16[x] & 0x7000) >> 12),
+ ((src16[x] & 0x03e0) >> 2) | ((src16[x] & 0x0380) >> 7),
+ ((src16[x] & 0x001f) << 3) | ((src16[x] & 0x001c) >> 2) );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_BGR555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_RGB32( ((src16[x] & 0x001f) << 3) | ((src16[x] & 0x001c) >> 2),
+ ((src16[x] & 0x03e0) >> 2) | ((src16[x] & 0x0380) >> 7),
+ ((src16[x] & 0x7c00) >> 7) | ((src16[x] & 0x7000) >> 12) );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGB16:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_RGB32( ((src16[x] & 0xf800) >> 8) | ((src16[x] & 0xe000) >> 13),
+ ((src16[x] & 0x07e0) >> 3) | ((src16[x] & 0x0300) >> 8),
+ ((src16[x] & 0x001f) << 3) | ((src16[x] & 0x001c) >> 2) );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ default:
+ D_ONCE( "unsupported format" );
+ }
+}
+
+void
+dfb_convert_to_argb( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u32 *dst,
+ int dpitch,
+ int width,
+ int height )
+{
+ const int dp4 = dpitch / 4;
+ int x;
+
+ switch (format) {
+ case DSPF_ARGB:
+ while (height--) {
+ direct_memcpy( dst, src, width * 4 );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGB32:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = src32[x] | 0xff000000;
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGB24:
+ while (height--) {
+ const u8 *src8 = src;
+
+ for (x=0; x<width; x++)
+#ifdef WORDS_BIGENDIAN
+ dst[x] = ( src8[x*3+0] << 16 ) |
+ ( src8[x*3+1] << 8 ) |
+ ( src8[x*3+2] ) | 0xff000000;
+#else
+ dst[x] = ( src8[x*3+2] << 16 ) |
+ ( src8[x*3+1] << 8 ) |
+ ( src8[x*3+0] ) | 0xff000000;
+#endif
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_AYUV:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (x=0; x<width; x++) {
+ int r, g, b;
+
+ YCBCR_TO_RGB( (src32[x] >> 16) & 0xff, (src32[x] >> 8) & 0xff, src32[x] & 0xff, r, g, b );
+
+ dst[x] = PIXEL_ARGB( src32[x] >> 24, r, g, b );
+ }
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_NV16:
+ while (height--) {
+ const u8 *src8 = src;
+ const u16 *src16 = src + surface_height * spitch;
+
+ for (x=0; x<width; x++) {
+ int r, g, b;
+
+#ifdef WORDS_BIGENDIAN
+ YCBCR_TO_RGB( src8[x], src16[x>>1] >> 8, src16[x>>1] & 0xff, r, g, b );
+#else
+ YCBCR_TO_RGB( src8[x], src16[x>>1] & 0xff, src16[x>>1] >> 8, r, g, b );
+#endif
+
+ dst[x] = PIXEL_ARGB( 0xff, r, g, b );
+ }
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_ARGB4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = ARGB4444_TO_ARGB( src16[x] );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGBA4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = RGBA4444_TO_ARGB( src16[x] );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGB444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_ARGB( 0xff,
+ ((src16[x] & 0x0f00) >> 4) | ((src16[x] & 0x0f00) >> 8),
+ ((src16[x] & 0x00f0) ) | ((src16[x] & 0x00f0) >> 4),
+ ((src16[x] & 0x000f) << 4) | ((src16[x] & 0x000f) ) );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_ARGB1555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_ARGB( (src16[x] & 0x8000) ? 0xff : 0x00,
+ ((src16[x] & 0x7c00) >> 7) | ((src16[x] & 0x7000) >> 12),
+ ((src16[x] & 0x03e0) >> 2) | ((src16[x] & 0x0380) >> 7),
+ ((src16[x] & 0x001f) << 3) | ((src16[x] & 0x001c) >> 2) );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGB555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_ARGB( 0xff,
+ ((src16[x] & 0x7c00) >> 7) | ((src16[x] & 0x7000) >> 12),
+ ((src16[x] & 0x03e0) >> 2) | ((src16[x] & 0x0380) >> 7),
+ ((src16[x] & 0x001f) << 3) | ((src16[x] & 0x001c) >> 2) );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_BGR555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_ARGB( 0xff,
+ ((src16[x] & 0x001f) << 3) | ((src16[x] & 0x001c) >> 2),
+ ((src16[x] & 0x03e0) >> 2) | ((src16[x] & 0x0380) >> 7),
+ ((src16[x] & 0x7c00) >> 7) | ((src16[x] & 0x7000) >> 12) );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ case DSPF_RGB16:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0; x<width; x++)
+ dst[x] = PIXEL_ARGB( 0xff,
+ ((src16[x] & 0xf800) >> 8) | ((src16[x] & 0xe000) >> 13),
+ ((src16[x] & 0x07e0) >> 3) | ((src16[x] & 0x0300) >> 8),
+ ((src16[x] & 0x001f) << 3) | ((src16[x] & 0x001c) >> 2) );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ default:
+ D_ONCE( "unsupported format" );
+ }
+}
+
+void
+dfb_convert_to_rgb24( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u8 *dst,
+ int dpitch,
+ int width,
+ int height )
+{
+ int n, n3;
+
+ switch (format) {
+ case DSPF_A8:
+ while (height--) {
+ const u8 *src8 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = src8[n];
+ dst[n3+1] = src8[n];
+ dst[n3+2] = src8[n];
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_AiRGB:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = (src32[n] & 0xFF0000) >> 16;
+ dst[n3+1] = (src32[n] & 0x00FF00) >> 8;
+ dst[n3+2] = (src32[n] & 0x0000FF);
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_ARGB:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = (src32[n] & 0xFF0000) >> 16;
+ dst[n3+1] = (src32[n] & 0x00FF00) >> 8;
+ dst[n3+2] = (src32[n] & 0x0000FF);
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_ARGB1555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = (src16[n] & 0x7C00) >> 7;
+ dst[n3+1] = (src16[n] & 0x03E0) >> 2;
+ dst[n3+2] = (src16[n] & 0x001F) << 3;
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_RGB555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = (src16[n] & 0x7C00) >> 7;
+ dst[n3+1] = (src16[n] & 0x03E0) >> 2;
+ dst[n3+2] = (src16[n] & 0x001F) << 3;
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+
+ case DSPF_BGR555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+2] = (src16[n] & 0x7C00) >> 7;
+ dst[n3+1] = (src16[n] & 0x03E0) >> 2;
+ dst[n3+0] = (src16[n] & 0x001F) << 3;
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+
+ case DSPF_ARGB2554:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = (src16[n] & 0x3E00) >> 6;
+ dst[n3+1] = (src16[n] & 0x01F0) >> 1;
+ dst[n3+2] = (src16[n] & 0x000F) << 4;
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_ARGB4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = (src16[n] & 0x0F00) >> 4;
+ dst[n3+1] = (src16[n] & 0x00F0);
+ dst[n3+2] = (src16[n] & 0x000F) << 4;
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_RGBA4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = (src16[n] & 0xF000) >> 8;
+ dst[n3+1] = (src16[n] & 0x0F00) >> 4;
+ dst[n3+2] = (src16[n] & 0x00F0);
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_RGB444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = (src16[n] & 0x0F00) >> 4;
+ dst[n3+1] = (src16[n] & 0x00F0);
+ dst[n3+2] = (src16[n] & 0x000F) << 4;
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_RGB332:
+ while (height--) {
+ const u8 *src8 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = lookup3to8[ (src8[n] >> 5) ];
+ dst[n3+1] = lookup3to8[ (src8[n] >> 2) & 0x07 ];
+ dst[n3+2] = lookup2to8[ (src8[n] ) & 0x03 ];
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_RGB16:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = (src16[n] & 0xF800) >> 8;
+ dst[n3+1] = (src16[n] & 0x07E0) >> 3;
+ dst[n3+2] = (src16[n] & 0x001F) << 3;
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_RGB24:
+ while (height--) {
+ const u8 *src8 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+#ifdef WORDS_BIGENDIAN
+ dst[n3+0] = src8[n3+0];
+ dst[n3+1] = src8[n3+1];
+ dst[n3+2] = src8[n3+2];
+#else
+ dst[n3+0] = src8[n3+2];
+ dst[n3+1] = src8[n3+1];
+ dst[n3+2] = src8[n3+0];
+#endif
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_RGB32:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (n=0, n3=0; n<width; n++, n3+=3) {
+ dst[n3+0] = (src32[n] & 0xFF0000) >> 16;
+ dst[n3+1] = (src32[n] & 0x00FF00) >> 8;
+ dst[n3+2] = (src32[n] & 0x0000FF);
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_YUY2:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (n=0, n3=0; n<width/2; n++, n3+=6) {
+ register u32 y0, cb, y1, cr;
+ y0 = (src32[n] & 0x000000FF);
+ cb = (src32[n] & 0x0000FF00) >> 8;
+ y1 = (src32[n] & 0x00FF0000) >> 16;
+ cr = (src32[n] & 0xFF000000) >> 24;
+ YCBCR_TO_RGB( y0, cb, cr,
+ dst[n3+0], dst[n3+1], dst[n3+2] );
+ YCBCR_TO_RGB( y1, cb, cr,
+ dst[n3+3], dst[n3+4], dst[n3+5] );
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_UYVY:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (n=0, n3=0; n<width/2; n++, n3+=6) {
+ register u32 y0, cb, y1, cr;
+ cb = (src32[n] & 0x000000FF);
+ y0 = (src32[n] & 0x0000FF00) >> 8;
+ cr = (src32[n] & 0x00FF0000) >> 16;
+ y1 = (src32[n] & 0xFF000000) >> 24;
+ YCBCR_TO_RGB( y0, cb, cr,
+ dst[n3+0], dst[n3+1], dst[n3+2] );
+ YCBCR_TO_RGB( y1, cb, cr,
+ dst[n3+3], dst[n3+4], dst[n3+5] );
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_NV16: {
+ while (height--) {
+ const u16 *cbcr = src + surface_height * spitch;
+ const u8 *src8 = src;
+
+ for (n=0, n3=0; n<width/2; n++, n3+=6) {
+#ifdef WORDS_BIGENDIAN
+ YCBCR_TO_RGB( src8[n*2+0], cbcr[n] >> 8, cbcr[n] & 0xff,
+ dst[n3+0], dst[n3+1], dst[n3+2] );
+
+ YCBCR_TO_RGB( src8[n*2+1], cbcr[n] >> 8, cbcr[n] & 0xff,
+ dst[n3+3], dst[n3+4], dst[n3+5] );
+#else
+ YCBCR_TO_RGB( src8[n*2+0], cbcr[n] & 0xff, cbcr[n] >> 8,
+ dst[n3+0], dst[n3+1], dst[n3+2] );
+
+ YCBCR_TO_RGB( src8[n*2+1], cbcr[n] & 0xff, cbcr[n] >> 8,
+ dst[n3+3], dst[n3+4], dst[n3+5] );
+#endif
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ }
+ default:
+ D_ONCE( "unsupported format" );
+ }
+}
+
+void
+dfb_convert_to_a8( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u8 *dst,
+ int dpitch,
+ int width,
+ int height )
+{
+ int n;
+
+ switch (format) {
+ case DSPF_A8:
+ while (height--) {
+ const u8 *src8 = src;
+
+ direct_memcpy( dst, src8, width );
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_AiRGB:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (n=0; n<width; n++) {
+ dst[n] = ~(src32[n] >> 24);
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_ARGB:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (n=0; n<width; n++) {
+ dst[n] = src32[n] >> 24;
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_ARGB1555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0; n<width; n++) {
+ dst[n] = (src16[n] & 0x8000) ? 0xff : 0x00;
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_ARGB2554:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0; n<width; n++) {
+ switch (src16[n] >> 14) {
+ case 0:
+ dst[n] = 0x00;
+ break;
+ case 1:
+ dst[n] = 0x55;
+ break;
+ case 2:
+ dst[n] = 0xAA;
+ break;
+ case 3:
+ dst[n] = 0xFF;
+ break;
+ }
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_ARGB4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0; n<width; n++) {
+ dst[n] = (src16[n] >> 12);
+ dst[n] |= dst[n] << 4;
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+ case DSPF_RGBA4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (n=0; n<width; n++) {
+ dst[n] = EXPAND_4to8(src16[n] & 0xf);
+ }
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+
+ case DSPF_RGB332:
+ case DSPF_RGB444:
+ case DSPF_RGB555:
+ case DSPF_BGR555:
+ case DSPF_RGB16:
+ case DSPF_RGB24:
+ case DSPF_RGB32:
+ case DSPF_YUY2:
+ case DSPF_UYVY:
+ case DSPF_NV16:
+ while (height--) {
+ memset( dst, 0xff, width );
+
+ dst += dpitch;
+ }
+ break;
+ default:
+ D_ONCE( "unsupported format" );
+ }
+}
+
+void
+dfb_convert_to_a4( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u8 *dst,
+ int dpitch,
+ int width,
+ int height )
+{
+ const int w2 = width / 2;
+ int x, n;
+
+ D_ASSUME( (width & 1) == 0 );
+
+ switch (format) {
+ case DSPF_A8:
+ while (height--) {
+ const u8 *src8 = src;
+
+ for (x=0, n=0; x<w2; x++, n+=2)
+ dst[x] = (src8[n] & 0xf0) | ((src8[n+1] & 0xf0) >> 4);
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+
+ case DSPF_ARGB4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0, n=0; x<w2; x++, n+=2)
+ dst[x] = ((src16[n] & 0xf000) >> 8) | (src16[n+1] >> 12);
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+
+ case DSPF_RGBA4444:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0, n=0; x<w2; x++, n+=2)
+ dst[x] = ((src16[n] & 0x000f) << 4) | (src16[n+1] & 0x000f);
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+
+ case DSPF_ARGB1555:
+ while (height--) {
+ const u16 *src16 = src;
+
+ for (x=0, n=0; x<w2; x++, n+=2)
+ dst[x] = ((src16[n] & 0x8000) ? 0xf0 : 0) | ((src16[n+1] & 0x8000) ? 0x0f : 0);
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+
+ case DSPF_ARGB:
+ while (height--) {
+ const u32 *src32 = src;
+
+ for (x=0, n=0; x<w2; x++, n+=2)
+ dst[x] = ((src32[n] & 0xf0000000) >> 24) | ((src32[n+1] & 0xf0000000) >> 28);
+
+ src += spitch;
+ dst += dpitch;
+ }
+ break;
+
+ default:
+ if (DFB_PIXELFORMAT_HAS_ALPHA( format ))
+ D_ONCE( "unsupported format" );
+ }
+}
+
+void
+dfb_convert_to_yuy2( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u32 *dst,
+ int dpitch,
+ int width,
+ int height )
+{
+ const int dp4 = dpitch / 4;
+
+ switch (format) {
+ case DSPF_YUY2:
+ while (height--) {
+ direct_memcpy( dst, src, width * 2 );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ default:
+ D_ONCE( "unsupported format" );
+ }
+}
+
+void
+dfb_convert_to_uyvy( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u32 *dst,
+ int dpitch,
+ int width,
+ int height )
+{
+ const int dp4 = dpitch / 4;
+
+ switch (format) {
+ case DSPF_UYVY:
+ while (height--) {
+ direct_memcpy( dst, src, width * 2 );
+
+ src += spitch;
+ dst += dp4;
+ }
+ break;
+
+ default:
+ D_ONCE( "unsupported format" );
+ }
+}
+
diff --git a/Source/DirectFB/src/gfx/convert.h b/Source/DirectFB/src/gfx/convert.h
new file mode 100755
index 0000000..a831d8c
--- /dev/null
+++ b/Source/DirectFB/src/gfx/convert.h
@@ -0,0 +1,562 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __GFX__CONVERT_H__
+#define __GFX__CONVERT_H__
+
+#include <directfb.h>
+
+#include <direct/memcpy.h>
+#include <direct/util.h>
+
+
+/* pixel packing */
+
+#define PIXEL_RGB332(r,g,b) ( (((r)&0xE0) ) | \
+ (((g)&0xE0) >> 3) | \
+ (((b)&0xC0) >> 6) )
+
+#define PIXEL_ARGB1555(a,r,g,b)( (((a)&0x80) << 8) | \
+ (((r)&0xF8) << 7) | \
+ (((g)&0xF8) << 2) | \
+ (((b)&0xF8) >> 3) )
+
+#define PIXEL_RGB555(r,g,b) ( (((r)&0xF8) << 7) | \
+ (((g)&0xF8) << 2) | \
+ (((b)&0xF8) >> 3) )
+
+#define PIXEL_BGR555(r,g,b) ( (((b)&0xF8) << 7) | \
+ (((g)&0xF8) << 2) | \
+ (((r)&0xF8) >> 3) )
+
+#define PIXEL_ARGB2554(a,r,g,b)( (((a)&0xC0) << 8) | \
+ (((r)&0xF8) << 6) | \
+ (((g)&0xF8) << 1) | \
+ (((b)&0xF0) >> 4) )
+
+#define PIXEL_ARGB4444(a,r,g,b)( (((a)&0xF0) << 8) | \
+ (((r)&0xF0) << 4) | \
+ (((g)&0xF0) ) | \
+ (((b)&0xF0) >> 4) )
+
+#define PIXEL_RGBA4444(a,r,g,b)( (((r)&0xF0) << 8) | \
+ (((g)&0xF0) << 4) | \
+ (((b)&0xF0) ) | \
+ (((a)&0xF0) >> 4) )
+
+#define PIXEL_RGB444(r,g,b) ( (((r)&0xF0) << 4) | \
+ (((g)&0xF0) ) | \
+ (((b)&0xF0) >> 4) )
+
+#define PIXEL_RGB16(r,g,b) ( (((r)&0xF8) << 8) | \
+ (((g)&0xFC) << 3) | \
+ (((b)&0xF8) >> 3) )
+
+#define PIXEL_RGB18(r,g,b) ( (((r)&0xFC) << 10) | \
+ (((g)&0xFC) << 4) | \
+ (((b)&0xFC) >> 2) )
+
+#define PIXEL_RGB32(r,g,b) ( ((r) << 16) | \
+ ((g) << 8) | \
+ (b) )
+
+#define PIXEL_ARGB(a,r,g,b) ( ((a) << 24) | \
+ ((r) << 16) | \
+ ((g) << 8) | \
+ (b) )
+
+#define PIXEL_ARGB1666(a,r,g,b) ( (((a)&0x80) << 11) | \
+ (((r)&0xFC) << 10) | \
+ (((g)&0xFC) << 4) | \
+ (((b)&0xFC) >> 2) )
+
+#define PIXEL_ARGB6666(a,r,g,b) ( (((a)&0xFC) << 16) | \
+ (((r)&0xFC) << 10) | \
+ (((g)&0xFC) << 4) | \
+ (((b)&0xFC) >> 2) )
+
+#define PIXEL_AYUV(a,y,u,v) ( ((a) << 24) | \
+ ((y) << 16) | \
+ ((u) << 8) | \
+ (v) )
+
+#define PIXEL_AiRGB(a,r,g,b) ( (((a) ^ 0xff) << 24) | \
+ ((r) << 16) | \
+ ((g) << 8) | \
+ (b) )
+
+#ifdef WORDS_BIGENDIAN
+
+#define PIXEL_YUY2(y,u,v) ( ((u) << 24) | \
+ ((y) << 16) | \
+ ((v) << 8) | \
+ (y) )
+
+#define PIXEL_UYVY(y,u,v) ( ((y) << 24) | \
+ ((u) << 16) | \
+ ((y) << 8) | \
+ (v) )
+#else /* little endian */
+
+#define PIXEL_YUY2(y,u,v) ( ((v) << 24) | \
+ ((y) << 16) | \
+ ((u) << 8) | \
+ (y) )
+
+#define PIXEL_UYVY(y,u,v) ( ((y) << 24) | \
+ ((v) << 16) | \
+ ((y) << 8) | \
+ (u) )
+
+#endif
+
+
+/* packed pixel conversions */
+
+#define ARGB1555_TO_RGB332(pixel) ( (((pixel) & 0x7000) >> 7) | \
+ (((pixel) & 0x0380) >> 5) | \
+ (((pixel) & 0x0018) >> 3) )
+
+#define ARGB1555_TO_ARGB2554(pixel) ( (((pixel) & 0x8000) ) | \
+ (((pixel) & 0x7FFF) >> 1) )
+
+#define ARGB1555_TO_ARGB4444(pixel) ( (((pixel) & 0x8000) ? 0xf000 : 0 ) | \
+ (((pixel) & 0x7800) >> 3) | \
+ (((pixel) & 0x03C0) >> 2) | \
+ (((pixel) & 0x0018) >> 1) )
+
+#define ARGB1555_TO_RGBA4444(pixel) ( (((pixel) & 0x8000) ? 0x000f : 0 ) | \
+ (((pixel) & 0x7800) << 1) | \
+ (((pixel) & 0x03C0) << 2) | \
+ (((pixel) & 0x0018) << 3) )
+
+#define ARGB1555_TO_RGB16(pixel) ( (((pixel) & 0x7C00) << 1) | \
+ (((pixel) & 0x03E0) << 1) | \
+ (((pixel) & 0x001F)) )
+
+#define ARGB1555_TO_RGB32(pixel) ( (((pixel) & 0x7C00) << 9) | \
+ (((pixel) & 0x03E0) << 6) | \
+ (((pixel) & 0x001F) << 3) )
+
+#define ARGB1555_TO_ARGB(pixel) ( (((pixel) & 0x8000) ? 0xFF000000 : 0) | \
+ (((pixel) & 0x7C00) << 9) | \
+ (((pixel) & 0x03E0) << 6) | \
+ (((pixel) & 0x001F) << 3) )
+
+#define ARGB1555_TO_RGB555(pixel) ( (((pixel) & 0x7C00) << 9) | \
+ (((pixel) & 0x03E0) << 6) | \
+ (((pixel) & 0x001F) << 3) )
+
+#define ARGB1555_TO_RGB444(pixel) ( (((pixel) & 0x7800) >> 3) | \
+ (((pixel) & 0x03C0) >> 2) | \
+ (((pixel) & 0x001E) >> 1) )
+
+/* xRGB to xxRRGGBB, so xRxx left 3, xRGx left 2, xxGB left 1, xxxB */
+#define ARGB4444_TO_RGB32(pixel) ( (((pixel) & 0x0F00) << 12) | \
+ (((pixel) & 0x0FF0) << 8) | \
+ (((pixel) & 0x00FF) << 4) | \
+ (((pixel) & 0x000F) ) )
+
+/* RGBx to xxRRGGBB, so Rxxx left 2, RGxx left 1, xGBx, xxBx right 1 */
+#define RGBA4444_TO_RGB32(pixel) ( (((pixel) & 0xF000) << 8) | \
+ (((pixel) & 0xFF00) << 4) | \
+ (((pixel) & 0x0FF0) ) | \
+ (((pixel) & 0x00F0) >> 4) )
+
+/* ARGB to AARRGGBB, so Axxx left 4, ARxx left 3, xRGx left 2, xxGB left 1, xxxB */
+#define ARGB4444_TO_ARGB(pixel) ( (((pixel) & 0xF000) << 16) | \
+ (((pixel) & 0xFF00) << 12) | \
+ (((pixel) & 0x0FF0) << 8) | \
+ (((pixel) & 0x00FF) << 4) | \
+ (((pixel) & 0x000F) ) )
+
+/* RGBA to AARRGGBB, so Rxxx left 2, RGxx left 1, xGBx, xxBx right 1, A to the left */
+#define RGBA4444_TO_ARGB(pixel) ( (((pixel) & 0x000F) << 28) | \
+ (((pixel) & 0x000F) << 24) | \
+ (((pixel) & 0xF000) << 8) | \
+ (((pixel) & 0xFF00) << 4) | \
+ (((pixel) & 0x0FF0) ) | \
+ (((pixel) & 0x00F0) >> 4) )
+
+#define RGB16_TO_RGB332(pixel) ( (((pixel) & 0xE000) >> 8) | \
+ (((pixel) & 0x0700) >> 6) | \
+ (((pixel) & 0x0018) >> 3) )
+
+#define RGB16_TO_ARGB1555(pixel) ( 0x8000 | \
+ (((pixel) & 0xF800) >> 1) | \
+ (((pixel) & 0x07C0) >> 1) | \
+ (((pixel) & 0x001F)) )
+
+#define RGB16_TO_ARGB2554(pixel) ( 0xC000 | \
+ (((pixel) & 0xF800) >> 2) | \
+ (((pixel) & 0x07C0) >> 2) | \
+ (((pixel) & 0x001F) >> 1) )
+
+#define RGB16_TO_ARGB4444(pixel) ( 0xF000 | \
+ (((pixel) & 0xF000) >> 4) | \
+ (((pixel) & 0x0780) >> 3) | \
+ (((pixel) & 0x001E) >> 1) )
+
+#define RGB16_TO_RGBA4444(pixel) ( 0x000F | \
+ (((pixel) & 0xF000) ) | \
+ (((pixel) & 0x0780) << 1) | \
+ (((pixel) & 0x001E) << 3) )
+
+
+#define RGB16_TO_RGB32(pixel) ( (((pixel) & 0xF800) << 8) | \
+ (((pixel) & 0x07E0) << 5) | \
+ (((pixel) & 0x001F) << 3) )
+
+#define RGB16_TO_ARGB(pixel) ( 0xFF000000 | \
+ (((pixel) & 0xF800) << 8) | \
+ (((pixel) & 0x07E0) << 5) | \
+ (((pixel) & 0x001F) << 3) )
+
+#define RGB16_TO_RGB555(pixel) ( (((pixel) & 0xF800) >> 1) | \
+ (((pixel) & 0x07C0) >> 1) | \
+ (((pixel) & 0x001F)) )
+
+#define RGB16_TO_BGR555(pixel) ( (((pixel) & 0xF800) >> 12) | \
+ (((pixel) & 0x07C0) >> 1) | \
+ (((pixel) & 0x001F) << 10 ) )
+
+#define RGB16_TO_RGB444(pixel) ( (((pixel) & 0xF000) >> 4) | \
+ (((pixel) & 0x0780) >> 3) | \
+ (((pixel) & 0x001F) >> 1) )
+
+#define RGB18_TO_ARGB(pixel) ( 0xFF000000 | \
+ (((pixel) & 0xFC00) << 10) | \
+ (((pixel) & 0x3F00) << 4) | \
+ (((pixel) & 0x00FC) << 2) )
+
+#define RGB32_TO_RGB332(pixel) ( (((pixel) & 0xE00000) >> 16) | \
+ (((pixel) & 0x00E000) >> 11) | \
+ (((pixel) & 0x0000C0) >> 6) )
+
+#define RGB32_TO_ARGB1555(pixel) ( 0x8000 | \
+ (((pixel) & 0xF80000) >> 9) | \
+ (((pixel) & 0x00F800) >> 6) | \
+ (((pixel) & 0x0000F8) >> 3) )
+
+#define RGB32_TO_ARGB2554(pixel) ( 0xC000 | \
+ (((pixel) & 0xF80000) >> 10) | \
+ (((pixel) & 0x00F800) >> 7) | \
+ (((pixel) & 0x0000F0) >> 4) )
+
+#define RGB32_TO_ARGB4444(pixel) ( 0xF000 | \
+ (((pixel) & 0xF00000) >> 12) | \
+ (((pixel) & 0x00F000) >> 8) | \
+ (((pixel) & 0x0000F0) >> 4) )
+
+#define RGB32_TO_RGBA4444(pixel) ( 0x000F | \
+ (((pixel) & 0xF00000) >> 8) | \
+ (((pixel) & 0x00F000) >> 4) | \
+ (((pixel) & 0x0000F0) ) )
+
+#define RGB32_TO_RGB16(pixel) ( (((pixel) & 0xF80000) >> 8) | \
+ (((pixel) & 0x00FC00) >> 5) | \
+ (((pixel) & 0x0000F8) >> 3) )
+
+#define RGB32_TO_ARGB1555(pixel) ( 0x8000 | \
+ (((pixel) & 0xF80000) >> 9) | \
+ (((pixel) & 0x00F800) >> 6) | \
+ (((pixel) & 0x0000F8) >> 3) )
+
+#define RGB32_TO_ARGB(pixel) ( 0xFF000000 | (pixel) )
+
+
+#define RGB32_TO_RGB555(pixel) ( (((pixel) & 0xF80000) >> 9) | \
+ (((pixel) & 0x00F800) >> 6) | \
+ (((pixel) & 0x0000F8) >> 3) )
+
+#define RGB32_TO_BGR555(pixel) ( (((pixel) & 0xF80000) >> 19) | \
+ (((pixel) & 0x00F800) >> 6) | \
+ (((pixel) & 0x0000F8) << 7) )
+
+#define RGB32_TO_RGB444(pixel) ( (((pixel) & 0xF00000) >> 12) | \
+ (((pixel) & 0x00F000) >> 8) | \
+ (((pixel) & 0x0000F0) >> 4) )
+
+#define ARGB_TO_ARGB1555(pixel) ( (((pixel) & 0x80000000) >> 16) | \
+ (((pixel) & 0x00F80000) >> 9) | \
+ (((pixel) & 0x0000F800) >> 6) | \
+ (((pixel) & 0x000000F8) >> 3) )
+
+#define ARGB_TO_ARGB2554(pixel) ( (((pixel) & 0xC0000000) >> 16) | \
+ (((pixel) & 0x00F80000) >> 10) | \
+ (((pixel) & 0x0000F800) >> 7) | \
+ (((pixel) & 0x000000F0) >> 4) )
+
+#define ARGB_TO_ARGB4444(pixel) ( (((pixel) & 0xF0000000) >> 16) | \
+ (((pixel) & 0x00F00000) >> 12) | \
+ (((pixel) & 0x0000F000) >> 8) | \
+ (((pixel) & 0x000000F0) >> 4) )
+
+#define ARGB_TO_RGBA4444(pixel) ( (((pixel) & 0xF0000000) >> 28) | \
+ (((pixel) & 0x00F00000) >> 8) | \
+ (((pixel) & 0x0000F000) >> 4) | \
+ (((pixel) & 0x000000F0) ) )
+
+#define ARGB_TO_RGB444(pixel) ( (((pixel) & 0x00F00000) >> 12) | \
+ (((pixel) & 0x0000F000) >> 8) | \
+ (((pixel) & 0x000000F0) >> 4) )
+
+#define ARGB_TO_RGB555(pixel) ( (((pixel) & 0x00F80000) >> 9) | \
+ (((pixel) & 0x0000F800) >> 6) | \
+ (((pixel) & 0x000000F8) >> 3) )
+
+#define ARGB_TO_BGR555(pixel) ( (((pixel) & 0x00F80000) >> 19) | \
+ (((pixel) & 0x0000F800) >> 6) | \
+ (((pixel) & 0x000000F8) << 7) )
+
+/* RGB <-> YCbCr conversion */
+
+#define YCBCR_TO_RGB( y, cb, cr, r, g, b ) \
+do { \
+ int _y = (y) - 16; \
+ int _cb = (cb) - 128; \
+ int _cr = (cr) - 128; \
+ \
+ int _r = (298 * _y + 409 * _cr + 128) >> 8; \
+ int _g = (298 * _y - 100 * _cb - 208 * _cr + 128) >> 8; \
+ int _b = (298 * _y + 516 * _cb + 128) >> 8; \
+ \
+ (r) = CLAMP( _r, 0, 255 ); \
+ (g) = CLAMP( _g, 0, 255 ); \
+ (b) = CLAMP( _b, 0, 255 ); \
+} while (0)
+
+#define RGB_TO_YCBCR( r, g, b, y, cb, cr ) \
+do { \
+ int _r = (r), _g = (g), _b = (b); \
+ \
+ (y) = ( 66 * _r + 129 * _g + 25 * _b + 16*256 + 128) >> 8; \
+ (cb) = ( - 38 * _r - 74 * _g + 112 * _b + 128*256 + 128) >> 8; \
+ (cr) = ( 112 * _r - 94 * _g - 18 * _b + 128*256 + 128) >> 8; \
+} while (0)
+
+
+DFBSurfacePixelFormat dfb_pixelformat_for_depth( int depth );
+
+
+void dfb_pixel_to_color ( DFBSurfacePixelFormat format,
+ unsigned long pixel,
+ DFBColor *ret_color );
+
+unsigned long dfb_pixel_from_color( DFBSurfacePixelFormat format,
+ const DFBColor *color );
+
+
+static inline u32
+dfb_color_to_pixel( DFBSurfacePixelFormat format,
+ u8 r, u8 g, u8 b )
+{
+ const DFBColor color = { 0, r, g, b };
+
+ return dfb_pixel_from_color( format, &color );
+}
+
+static inline u32
+dfb_color_to_argb( const DFBColor *color )
+{
+ return (color->a << 24) | (color->r << 16) | (color->g << 8) | color->b;
+}
+
+static inline u32
+dfb_color_to_aycbcr( const DFBColor *color )
+{
+ u32 y = ( 66 * color->r + 129 * color->g + 25 * color->b + 16*256 + 128) >> 8;
+ u32 cb = ( - 38 * color->r - 74 * color->g + 112 * color->b + 128*256 + 128) >> 8;
+ u32 cr = ( 112 * color->r - 94 * color->g - 18 * color->b + 128*256 + 128) >> 8;
+
+ return (color->a << 24) | (y << 16) | (cb << 8) | cr;
+}
+
+static inline void
+dfb_argb_to_rgb332( const u32 *src, u8 *dst, int len )
+{
+ int i;
+
+ for (i=0; i<len; i++) {
+ register u32 argb = src[i];
+
+ dst[i] = RGB32_TO_RGB332( argb );
+ }
+}
+
+static inline void
+dfb_argb_to_argb1555( const u32 *src, u16 *dst, int len )
+{
+ int i;
+
+ for (i=0; i<len; i++) {
+ register u32 argb = src[i];
+
+ dst[i] = ARGB_TO_ARGB1555( argb );
+ }
+}
+
+static inline void
+dfb_argb_to_argb2554( const u32 *src, u16 *dst, int len )
+{
+ int i;
+
+ for (i=0; i<len; i++) {
+ register u32 argb = src[i];
+
+ dst[i] = ARGB_TO_ARGB2554( argb );
+ }
+}
+
+static inline void
+dfb_argb_to_argb4444( const u32 *src, u16 *dst, int len )
+{
+ int i;
+
+ for (i=0; i<len; i++) {
+ register u32 argb = src[i];
+
+ dst[i] = ARGB_TO_ARGB4444( argb );
+ }
+}
+
+static inline void
+dfb_argb_to_rgba4444( const u32 *src, u16 *dst, int len )
+{
+ int i;
+
+ for (i=0; i<len; i++) {
+ register u32 rgba = src[i];
+
+ dst[i] = ARGB_TO_RGBA4444( rgba );
+ }
+}
+
+static inline void
+dfb_argb_to_rgb16( const u32 *src, u16 *dst, int len )
+{
+ int i;
+
+ for (i=0; i<len; i++) {
+ register u32 argb = src[i];
+
+ dst[i] = RGB32_TO_RGB16( argb );
+ }
+}
+
+static inline void
+dfb_argb_to_a8( const u32 *src, u8 *dst, int len )
+{
+ int i;
+
+ for (i=0; i<len; i++)
+ dst[i] = src[i] >> 24;
+}
+
+void dfb_convert_to_rgb16( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u16 *dst,
+ int dpitch,
+ int width,
+ int height );
+
+void dfb_convert_to_rgb555( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u16 *dst,
+ int dpitch,
+ int width,
+ int height );
+
+void dfb_convert_to_argb( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u32 *dst,
+ int dpitch,
+ int width,
+ int height );
+
+void dfb_convert_to_rgb32( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u32 *dst,
+ int dpitch,
+ int width,
+ int height );
+
+void dfb_convert_to_rgb24( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u8 *dst,
+ int dpitch,
+ int width,
+ int height );
+
+void dfb_convert_to_a8( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u8 *dst,
+ int dpitch,
+ int width,
+ int height );
+
+void dfb_convert_to_a4( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u8 *dst,
+ int dpitch,
+ int width,
+ int height );
+
+void dfb_convert_to_yuy2( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u32 *dst,
+ int dpitch,
+ int width,
+ int height );
+
+void dfb_convert_to_uyvy( DFBSurfacePixelFormat format,
+ const void *src,
+ int spitch,
+ int surface_height,
+ u32 *dst,
+ int dpitch,
+ int width,
+ int height );
+
+#endif
diff --git a/Source/DirectFB/src/gfx/generic/Makefile.am b/Source/DirectFB/src/gfx/generic/Makefile.am
new file mode 100755
index 0000000..6d80484
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/Makefile.am
@@ -0,0 +1,62 @@
+## Makefile.am for DirectFB/src/gfx/generic
+
+INCLUDES = \
+ -I$(top_builddir)/lib \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src
+
+AM_CFLAGS = $(DFB_CFLAGS_OMIT_FRAME_POINTER)
+
+EXTRA_DIST = \
+ yuvtbl-gen.c
+
+internalincludedir = $(INTERNALINCLUDEDIR)/gfx/generic
+
+internalinclude_HEADERS = \
+ generic.h
+
+noinst_LTLIBRARIES = libdirectfb_generic.la
+
+if SOFTWARE_RENDERING
+GENERIC_C = generic.c
+else
+GENERIC_C = generic_dummy.c
+endif
+
+libdirectfb_generic_la_SOURCES = \
+ duffs_device.h \
+ $(GENERIC_C) \
+ generic.h \
+ generic_mmx.h \
+ generic_64.h \
+ stretch_hvx_N.h \
+ stretch_hvx_16.h \
+ stretch_hvx_32.h \
+ stretch_hvx_8.h \
+ stretch_hvx_88.h \
+ stretch_up_down_16.h \
+ stretch_up_down_32.h \
+ stretch_up_down_32_indexed.h \
+ stretch_up_down_8.h \
+ stretch_up_down_88.h \
+ stretch_up_down_table.h \
+ template_acc_16.h \
+ template_acc_32.h \
+ template_colorkey_16.h \
+ template_colorkey_32.h \
+ yuvtbl.h
+
+generic.c: yuvtbl.h
+generic_dummy.c: yuvtbl.h
+
+yuvtbl-gen: yuvtbl-gen.c
+ $(CC) -O2 yuvtbl-gen.c -o yuvtbl-gen
+
+#yuvtbl.h: yuvtbl-gen
+# ./yuvtbl-gen > $(srcdir)/yuvtbl.h
+
+clean-local:
+ rm -f yuvtbl-gen
+
diff --git a/Source/DirectFB/src/gfx/generic/Makefile.in b/Source/DirectFB/src/gfx/generic/Makefile.in
new file mode 100755
index 0000000..94695ac
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/Makefile.in
@@ -0,0 +1,602 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/gfx/generic
+DIST_COMMON = $(internalinclude_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libdirectfb_generic_la_LIBADD =
+am__libdirectfb_generic_la_SOURCES_DIST = duffs_device.h \
+ generic_dummy.c generic.c generic.h generic_mmx.h generic_64.h \
+ stretch_hvx_N.h stretch_hvx_16.h stretch_hvx_32.h \
+ stretch_hvx_8.h stretch_hvx_88.h stretch_up_down_16.h \
+ stretch_up_down_32.h stretch_up_down_32_indexed.h \
+ stretch_up_down_8.h stretch_up_down_88.h \
+ stretch_up_down_table.h template_acc_16.h template_acc_32.h \
+ template_colorkey_16.h template_colorkey_32.h yuvtbl.h
+@SOFTWARE_RENDERING_FALSE@am__objects_1 = generic_dummy.lo
+@SOFTWARE_RENDERING_TRUE@am__objects_1 = generic.lo
+am_libdirectfb_generic_la_OBJECTS = $(am__objects_1)
+libdirectfb_generic_la_OBJECTS = $(am_libdirectfb_generic_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libdirectfb_generic_la_SOURCES)
+DIST_SOURCES = $(am__libdirectfb_generic_la_SOURCES_DIST)
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(internalincludedir)"
+internalincludeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(internalinclude_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+ASFLAGS = @ASFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIR = @DATADIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DFB_CFLAGS_OMIT_FRAME_POINTER = @DFB_CFLAGS_OMIT_FRAME_POINTER@
+DFB_INTERNAL_CFLAGS = @DFB_INTERNAL_CFLAGS@
+DFB_LDFLAGS = @DFB_LDFLAGS@
+DFB_SMOOTH_SCALING = @DFB_SMOOTH_SCALING@
+DIRECTFB_BINARY_AGE = @DIRECTFB_BINARY_AGE@
+DIRECTFB_CSOURCE = @DIRECTFB_CSOURCE@
+DIRECTFB_INTERFACE_AGE = @DIRECTFB_INTERFACE_AGE@
+DIRECTFB_MAJOR_VERSION = @DIRECTFB_MAJOR_VERSION@
+DIRECTFB_MICRO_VERSION = @DIRECTFB_MICRO_VERSION@
+DIRECTFB_MINOR_VERSION = @DIRECTFB_MINOR_VERSION@
+DIRECTFB_VERSION = @DIRECTFB_VERSION@
+DIRECT_BUILD_DEBUG = @DIRECT_BUILD_DEBUG@
+DIRECT_BUILD_DEBUGS = @DIRECT_BUILD_DEBUGS@
+DIRECT_BUILD_GETTID = @DIRECT_BUILD_GETTID@
+DIRECT_BUILD_NETWORK = @DIRECT_BUILD_NETWORK@
+DIRECT_BUILD_STDBOOL = @DIRECT_BUILD_STDBOOL@
+DIRECT_BUILD_TEXT = @DIRECT_BUILD_TEXT@
+DIRECT_BUILD_TRACE = @DIRECT_BUILD_TRACE@
+DSYMUTIL = @DSYMUTIL@
+DYNLIB = @DYNLIB@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+FREETYPE_PROVIDER = @FREETYPE_PROVIDER@
+FUSION_BUILD_KERNEL = @FUSION_BUILD_KERNEL@
+FUSION_BUILD_MULTI = @FUSION_BUILD_MULTI@
+FUSION_MESSAGE_SIZE = @FUSION_MESSAGE_SIZE@
+GIF_PROVIDER = @GIF_PROVIDER@
+GREP = @GREP@
+HAVE_LINUX = @HAVE_LINUX@
+INCLUDEDIR = @INCLUDEDIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTERNALINCLUDEDIR = @INTERNALINCLUDEDIR@
+JPEG_PROVIDER = @JPEG_PROVIDER@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBJPEG = @LIBJPEG@
+LIBOBJS = @LIBOBJS@
+LIBPNG = @LIBPNG@
+LIBPNG_CONFIG = @LIBPNG_CONFIG@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_AGE = @LT_AGE@
+LT_BINARY = @LT_BINARY@
+LT_CURRENT = @LT_CURRENT@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAN2HTML = @MAN2HTML@
+MKDIR_P = @MKDIR_P@
+MODULEDIR = @MODULEDIR@
+MODULEDIRNAME = @MODULEDIRNAME@
+NMEDIT = @NMEDIT@
+OBJEXT = @OBJEXT@
+OSX_LIBS = @OSX_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PNG_PROVIDER = @PNG_PROVIDER@
+RANLIB = @RANLIB@
+RUNTIME_SYSROOT = @RUNTIME_SYSROOT@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOPATH = @SOPATH@
+STRIP = @STRIP@
+SYSCONFDIR = @SYSCONFDIR@
+SYSFS_LIBS = @SYSFS_LIBS@
+THREADFLAGS = @THREADFLAGS@
+THREADLIB = @THREADLIB@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+VERSION = @VERSION@
+VNC_CFLAGS = @VNC_CFLAGS@
+VNC_CONFIG = @VNC_CONFIG@
+VNC_LIBS = @VNC_LIBS@
+X11_CFLAGS = @X11_CFLAGS@
+X11_LIBS = @X11_LIBS@
+ZLIB_LIBS = @ZLIB_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = \
+ -I$(top_builddir)/lib \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src
+
+AM_CFLAGS = $(DFB_CFLAGS_OMIT_FRAME_POINTER)
+EXTRA_DIST = \
+ yuvtbl-gen.c
+
+internalincludedir = $(INTERNALINCLUDEDIR)/gfx/generic
+internalinclude_HEADERS = \
+ generic.h
+
+noinst_LTLIBRARIES = libdirectfb_generic.la
+@SOFTWARE_RENDERING_FALSE@GENERIC_C = generic_dummy.c
+@SOFTWARE_RENDERING_TRUE@GENERIC_C = generic.c
+libdirectfb_generic_la_SOURCES = \
+ duffs_device.h \
+ $(GENERIC_C) \
+ generic.h \
+ generic_mmx.h \
+ generic_64.h \
+ stretch_hvx_N.h \
+ stretch_hvx_16.h \
+ stretch_hvx_32.h \
+ stretch_hvx_8.h \
+ stretch_hvx_88.h \
+ stretch_up_down_16.h \
+ stretch_up_down_32.h \
+ stretch_up_down_32_indexed.h \
+ stretch_up_down_8.h \
+ stretch_up_down_88.h \
+ stretch_up_down_table.h \
+ template_acc_16.h \
+ template_acc_32.h \
+ template_colorkey_16.h \
+ template_colorkey_32.h \
+ yuvtbl.h
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/gfx/generic/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/gfx/generic/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libdirectfb_generic.la: $(libdirectfb_generic_la_OBJECTS) $(libdirectfb_generic_la_DEPENDENCIES)
+ $(LINK) $(libdirectfb_generic_la_OBJECTS) $(libdirectfb_generic_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/generic.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/generic_dummy.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-internalincludeHEADERS: $(internalinclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(internalincludedir)" || $(MKDIR_P) "$(DESTDIR)$(internalincludedir)"
+ @list='$(internalinclude_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(internalincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(internalincludedir)/$$f'"; \
+ $(internalincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(internalincludedir)/$$f"; \
+ done
+
+uninstall-internalincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(internalinclude_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(internalincludedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(internalincludedir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(internalincludedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-local \
+ clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-internalincludeHEADERS
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-internalincludeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-local clean-noinstLTLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-internalincludeHEADERS install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-internalincludeHEADERS
+
+
+generic.c: yuvtbl.h
+generic_dummy.c: yuvtbl.h
+
+yuvtbl-gen: yuvtbl-gen.c
+ $(CC) -O2 yuvtbl-gen.c -o yuvtbl-gen
+
+#yuvtbl.h: yuvtbl-gen
+# ./yuvtbl-gen > $(srcdir)/yuvtbl.h
+
+clean-local:
+ rm -f yuvtbl-gen
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/Source/DirectFB/src/gfx/generic/duffs_device.h b/Source/DirectFB/src/gfx/generic/duffs_device.h
new file mode 100755
index 0000000..4e31089
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/duffs_device.h
@@ -0,0 +1,89 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __DUFFS_DEVICE_H__
+#define __DUFFS_DEVICE_H__
+
+#define DUFF_1() \
+ case 1:\
+ SET_PIXEL( D[0], S[0] );
+
+#define DUFF_2() \
+ case 3:\
+ SET_PIXEL( D[2], S[2] );\
+ case 2:\
+ SET_PIXEL( D[1], S[1] );\
+ DUFF_1()
+
+#define DUFF_3() \
+ case 7:\
+ SET_PIXEL( D[6], S[6] );\
+ case 6:\
+ SET_PIXEL( D[5], S[5] );\
+ case 5:\
+ SET_PIXEL( D[4], S[4] );\
+ case 4:\
+ SET_PIXEL( D[3], S[3] );\
+ DUFF_2()
+
+#define DUFF_4() \
+ case 15:\
+ SET_PIXEL( D[14], S[14] );\
+ case 14:\
+ SET_PIXEL( D[13], S[13] );\
+ case 13:\
+ SET_PIXEL( D[12], S[12] );\
+ case 12:\
+ SET_PIXEL( D[11], S[11] );\
+ case 11:\
+ SET_PIXEL( D[10], S[10] );\
+ case 10:\
+ SET_PIXEL( D[9], S[9] );\
+ case 9:\
+ SET_PIXEL( D[8], S[8] );\
+ case 8:\
+ SET_PIXEL( D[7], S[7] );\
+ DUFF_3()
+
+#define SET_PIXEL_DUFFS_DEVICE_N( D, S, w, n ) \
+do {\
+ while (w) {\
+ register int l = w & ((1 << n) - 1);\
+ switch (l) {\
+ default:\
+ l = (1 << n);\
+ SET_PIXEL( D[(1 << n)-1], S[(1 << n)-1] );\
+ DUFF_##n()\
+ }\
+ D += l;\
+ S += l;\
+ w -= l;\
+ }\
+} while(0)
+
+#endif
diff --git a/Source/DirectFB/src/gfx/generic/generic.c b/Source/DirectFB/src/gfx/generic/generic.c
new file mode 100755
index 0000000..9b7cdeb
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/generic.c
@@ -0,0 +1,9161 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <dfb_types.h>
+
+#include <pthread.h>
+
+#include <directfb.h>
+
+#include <core/core.h>
+#include <core/coredefs.h>
+#include <core/coretypes.h>
+
+#include <core/gfxcard.h>
+#include <core/state.h>
+#include <core/palette.h>
+
+#include <misc/gfx_util.h>
+#include <misc/util.h>
+#include <misc/conf.h>
+
+#include <direct/clock.h>
+#include <direct/mem.h>
+#include <direct/memcpy.h>
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <gfx/convert.h>
+#include <gfx/util.h>
+
+#include "generic.h"
+#include "duffs_device.h"
+
+
+/* lookup tables for 2/3bit to 8bit color conversion */
+static const u8 lookup3to8[] = { 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff};
+static const u8 lookup2to8[] = { 0x00, 0x55, 0xaa, 0xff};
+
+#define EXPAND_1to8(v) ((v) ? 0xff : 0x00)
+#define EXPAND_2to8(v) (lookup2to8[v])
+#define EXPAND_3to8(v) (lookup3to8[v])
+#define EXPAND_4to8(v) (((v) << 4) | ((v) ))
+#define EXPAND_5to8(v) (((v) << 3) | ((v) >> 2))
+#define EXPAND_6to8(v) (((v) << 2) | ((v) >> 4))
+#define EXPAND_7to8(v) (((v) << 1) | ((v) >> 6))
+
+
+static int use_mmx = 0;
+
+#ifdef USE_MMX
+static void gInit_MMX( void );
+#endif
+
+#if SIZEOF_LONG == 8
+static void gInit_64bit( void );
+#endif
+
+/* RGB16 */
+#define RGB_MASK 0xffff
+#define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_16
+#define Bop_PFI_OP_Aop_PFI( op ) Bop_16_##op##_Aop
+#include "template_colorkey_16.h"
+
+/* ARGB1555 / RGB555 / BGR555 */
+#define RGB_MASK 0x7fff
+#define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_15
+#define Bop_PFI_OP_Aop_PFI( op ) Bop_15_##op##_Aop
+#include "template_colorkey_16.h"
+
+/* ARGB2554 */
+#define RGB_MASK 0x3fff
+#define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_14
+#define Bop_PFI_OP_Aop_PFI( op ) Bop_14_##op##_Aop
+#include "template_colorkey_16.h"
+
+/* ARGB4444 / RGB444*/
+#define RGB_MASK 0x0fff
+#define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_12
+#define Bop_PFI_OP_Aop_PFI( op ) Bop_12_##op##_Aop
+#include "template_colorkey_16.h"
+
+/* RGBA4444 */
+#define RGB_MASK 0xfff0
+#define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_12vv
+#define Bop_PFI_OP_Aop_PFI( op ) Bop_12vv_##op##_Aop
+#include "template_colorkey_16.h"
+
+/* ARGB/RGB32/AiRGB */
+#define RGB_MASK 0x00ffffff
+#define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_32
+#define Bop_PFI_OP_Aop_PFI( op ) Bop_32_##op##_Aop
+#include "template_colorkey_32.h"
+
+/* RGB16 */
+#define EXPAND_Ato8( a ) 0xFF
+#define EXPAND_Rto8( r ) EXPAND_5to8( r )
+#define EXPAND_Gto8( g ) EXPAND_6to8( g )
+#define EXPAND_Bto8( b ) EXPAND_5to8( b )
+#define PIXEL_OUT( a, r, g, b ) PIXEL_RGB16( r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_rgb16_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_rgb16
+#define A_SHIFT 0
+#define R_SHIFT 11
+#define G_SHIFT 5
+#define B_SHIFT 0
+#define A_MASK 0
+#define R_MASK 0xf800
+#define G_MASK 0x07e0
+#define B_MASK 0x001f
+#include "template_acc_16.h"
+
+/* ARGB1555 */
+#define EXPAND_Ato8( a ) EXPAND_1to8( a )
+#define EXPAND_Rto8( r ) EXPAND_5to8( r )
+#define EXPAND_Gto8( g ) EXPAND_5to8( g )
+#define EXPAND_Bto8( b ) EXPAND_5to8( b )
+#define PIXEL_OUT( a, r, g, b ) PIXEL_ARGB1555( a, r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_argb1555_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_argb1555
+#define A_SHIFT 15
+#define R_SHIFT 10
+#define G_SHIFT 5
+#define B_SHIFT 0
+#define A_MASK 0x8000
+#define R_MASK 0x7c00
+#define G_MASK 0x03e0
+#define B_MASK 0x001f
+#include "template_acc_16.h"
+
+/* RGB555 */
+#define EXPAND_Ato8( a ) 0xFF
+#define EXPAND_Rto8( r ) EXPAND_5to8( r )
+#define EXPAND_Gto8( g ) EXPAND_5to8( g )
+#define EXPAND_Bto8( b ) EXPAND_5to8( b )
+#define PIXEL_OUT( a, r, g, b ) PIXEL_RGB555( r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_xrgb1555_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_xrgb1555
+#define A_SHIFT 0
+#define R_SHIFT 10
+#define G_SHIFT 5
+#define B_SHIFT 0
+#define A_MASK 0
+#define R_MASK 0x7c00
+#define G_MASK 0x03e0
+#define B_MASK 0x001f
+#include "template_acc_16.h"
+
+/* BGR555 */
+#define EXPAND_Ato8( a ) 0xFF
+#define EXPAND_Rto8( r ) EXPAND_5to8( r )
+#define EXPAND_Gto8( g ) EXPAND_5to8( g )
+#define EXPAND_Bto8( b ) EXPAND_5to8( b )
+#define PIXEL_OUT( a, r, g, b ) PIXEL_BGR555( r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_xbgr1555_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_xbgr1555
+#define A_SHIFT 0
+#define B_SHIFT 10
+#define G_SHIFT 5
+#define R_SHIFT 0
+#define A_MASK 0
+#define B_MASK 0x7c00
+#define G_MASK 0x03e0
+#define R_MASK 0x001f
+#include "template_acc_16.h"
+
+/* ARGB2554 */
+#define EXPAND_Ato8( a ) EXPAND_2to8( a )
+#define EXPAND_Rto8( r ) EXPAND_5to8( r )
+#define EXPAND_Gto8( g ) EXPAND_5to8( g )
+#define EXPAND_Bto8( b ) EXPAND_4to8( b )
+#define PIXEL_OUT( a, r, g, b ) PIXEL_ARGB2554( a, r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_argb2554_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_argb2554
+#define A_SHIFT 14
+#define R_SHIFT 9
+#define G_SHIFT 4
+#define B_SHIFT 0
+#define A_MASK 0xc000
+#define R_MASK 0x3e00
+#define G_MASK 0x01f0
+#define B_MASK 0x000f
+#include "template_acc_16.h"
+
+/* ARGB4444 */
+#define EXPAND_Ato8( a ) EXPAND_4to8( a )
+#define EXPAND_Rto8( r ) EXPAND_4to8( r )
+#define EXPAND_Gto8( g ) EXPAND_4to8( g )
+#define EXPAND_Bto8( b ) EXPAND_4to8( b )
+#define PIXEL_OUT( a, r, g, b ) PIXEL_ARGB4444( a, r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_argb4444_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_argb4444
+#define A_SHIFT 12
+#define R_SHIFT 8
+#define G_SHIFT 4
+#define B_SHIFT 0
+#define A_MASK 0xf000
+#define R_MASK 0x0f00
+#define G_MASK 0x00f0
+#define B_MASK 0x000f
+#include "template_acc_16.h"
+
+/* ARGB4444 */
+#define EXPAND_Ato8( a ) EXPAND_4to8( a )
+#define EXPAND_Rto8( r ) EXPAND_4to8( r )
+#define EXPAND_Gto8( g ) EXPAND_4to8( g )
+#define EXPAND_Bto8( b ) EXPAND_4to8( b )
+#define PIXEL_OUT( a, r, g, b ) PIXEL_RGBA4444( a, r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_rgba4444_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_rgba4444
+#define A_SHIFT 0
+#define R_SHIFT 12
+#define G_SHIFT 8
+#define B_SHIFT 4
+#define A_MASK 0x000f
+#define R_MASK 0xf000
+#define G_MASK 0x0f00
+#define B_MASK 0x00f0
+#include "template_acc_16.h"
+
+/* RGB444 */
+#define EXPAND_Ato8( a ) 0xFF
+#define EXPAND_Rto8( r ) EXPAND_4to8( r )
+#define EXPAND_Gto8( g ) EXPAND_4to8( g )
+#define EXPAND_Bto8( b ) EXPAND_4to8( b )
+#define PIXEL_OUT( a, r, g, b ) PIXEL_RGB444( r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_xrgb4444_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_xrgb4444
+#define A_SHIFT 0
+#define R_SHIFT 8
+#define G_SHIFT 4
+#define B_SHIFT 0
+#define A_MASK 0
+#define R_MASK 0x0f00
+#define G_MASK 0x00f0
+#define B_MASK 0x000f
+#include "template_acc_16.h"
+
+/* ARGB */
+#define EXPAND_Ato8( a ) (a)
+#define EXPAND_Rto8( r ) (r)
+#define EXPAND_Gto8( g ) (g)
+#define EXPAND_Bto8( b ) (b)
+#define PIXEL_OUT( a, r, g, b ) PIXEL_ARGB( a, r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_argb_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_argb
+#define A_SHIFT 24
+#define R_SHIFT 16
+#define G_SHIFT 8
+#define B_SHIFT 0
+#define A_MASK 0xff000000
+#define R_MASK 0x00ff0000
+#define G_MASK 0x0000ff00
+#define B_MASK 0x000000ff
+#include "template_acc_32.h"
+
+/* RGB32 */
+#define EXPAND_Ato8( a ) 0xFF
+#define EXPAND_Rto8( r ) (r)
+#define EXPAND_Gto8( g ) (g)
+#define EXPAND_Bto8( b ) (b)
+#define PIXEL_OUT( a, r, g, b ) PIXEL_RGB32( r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_rgb32_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_rgb32
+#define A_SHIFT 0
+#define R_SHIFT 16
+#define G_SHIFT 8
+#define B_SHIFT 0
+#define A_MASK 0
+#define R_MASK 0x00ff0000
+#define G_MASK 0x0000ff00
+#define B_MASK 0x000000ff
+#include "template_acc_32.h"
+
+/* AiRGB */
+#define EXPAND_Ato8( a ) ((a) ^ 0xff)
+#define EXPAND_Rto8( r ) (r)
+#define EXPAND_Gto8( g ) (g)
+#define EXPAND_Bto8( b ) (b)
+#define PIXEL_OUT( a, r, g, b ) PIXEL_AiRGB( a, r, g, b )
+#define Sop_PFI_OP_Dacc( op ) Sop_airgb_##op##_Dacc
+#define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_airgb
+#define A_SHIFT 24
+#define R_SHIFT 16
+#define G_SHIFT 8
+#define B_SHIFT 0
+#define A_MASK 0xff000000
+#define R_MASK 0x00ff0000
+#define G_MASK 0x0000ff00
+#define B_MASK 0x000000ff
+#include "template_acc_32.h"
+
+/********************************* Cop_to_Aop_PFI *****************************/
+
+static void Cop_to_Aop_8( GenefxState *gfxs )
+{
+ memset( gfxs->Aop[0], gfxs->Cop, gfxs->length );
+}
+
+static void Cop_to_Aop_16( GenefxState *gfxs )
+{
+ int w;
+ int l = gfxs->length;
+ u32 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+
+ u32 DCop = ((Cop << 16) | Cop);
+
+ if (((long)D)&2) { /* align */
+ u16* tmp = (u16*) D;
+ --l;
+ *tmp = Cop;
+ D = (u32*)(tmp+1);
+ }
+
+ w = (l >> 1);
+ while (w) {
+ *D = DCop;
+ --w;
+ ++D;
+ }
+
+ if (l & 1) /* do the last ential pixel */
+ *((u16*)D) = (u16)Cop;
+}
+
+static void Cop_to_Aop_18( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+
+ while (w) {
+ D[0] = Cop;
+ D[1] = Cop >> 8;
+ D[2] = Cop >> 16;
+ D += 3;
+ --w;
+ }
+}
+
+static void Cop_to_Aop_24( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+
+ while (w) {
+ D[0] = gfxs->color.b;
+ D[1] = gfxs->color.g;
+ D[2] = gfxs->color.r;
+
+ D += 3;
+ --w;
+ }
+}
+
+static void Cop_to_Aop_32( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u32 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+
+ while (w--)
+ *D++ = Cop;
+}
+
+static void Cop_to_Aop_yuv422( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ u16 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+
+ if ((long)D & 2) {
+#ifdef WORDS_BIGENDIAN
+ *D++ = Cop & 0xffff;
+#else
+ *D++ = Cop >> 16;
+#endif
+ w--;
+ }
+
+ for (l = w>>1; l--;) {
+ *((u32*)D) = Cop;
+ D += 2;
+ }
+
+ if (w & 1) {
+#ifdef WORDS_BIGENDIAN
+ *D = Cop >> 16;
+#else
+ *D = Cop & 0xffff;
+#endif
+ }
+}
+
+static void Cop_to_Aop_i420( GenefxState *gfxs )
+{
+ memset( gfxs->Aop[0], gfxs->YCop, gfxs->length );
+ if (gfxs->AopY & 1) {
+ memset( gfxs->Aop[1], gfxs->CbCop, gfxs->length>>1 );
+ memset( gfxs->Aop[2], gfxs->CrCop, gfxs->length>>1 );
+ }
+}
+
+static void Cop_to_Aop_nv12( GenefxState *gfxs )
+{
+ memset( gfxs->Aop[0], gfxs->YCop, gfxs->length );
+
+ if (gfxs->dst_format == DSPF_NV16 || gfxs->AopY & 1) {
+ u16 *D = gfxs->Aop[1];
+ int w = gfxs->length>>1;
+ u16 Cop = gfxs->CbCop | (gfxs->CrCop << 8);
+
+ while (w--)
+ *D++ = Cop;
+ }
+}
+
+static void Cop_to_Aop_nv21( GenefxState *gfxs )
+{
+ memset( gfxs->Aop[0], gfxs->YCop, gfxs->length );
+
+ if (gfxs->AopY & 1) {
+ u16 *D = gfxs->Aop[1];
+ int w = gfxs->length>>1;
+ u16 Cop = gfxs->CrCop | (gfxs->CbCop << 8);
+
+ while (w--)
+ *D++ = Cop;
+ }
+}
+
+static GenefxFunc Cop_to_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Cop_to_Aop_16, /* DSPF_ARGB1555 */
+ Cop_to_Aop_16, /* DSPF_RGB16 */
+ Cop_to_Aop_24, /* DSPF_RGB24 */
+ Cop_to_Aop_32, /* DSPF_RGB32 */
+ Cop_to_Aop_32, /* DSPF_ARGB */
+ Cop_to_Aop_8, /* DSPF_A8 */
+ Cop_to_Aop_yuv422, /* DSPF_YUY2 */
+ Cop_to_Aop_8, /* DSPF_RGB332 */
+ Cop_to_Aop_yuv422, /* DSPF_UYVY */
+ Cop_to_Aop_i420, /* DSPF_I420 */
+ Cop_to_Aop_i420, /* DSPF_YV12 */
+ Cop_to_Aop_8, /* DSPF_LUT8 */
+ Cop_to_Aop_8, /* DSPF_ALUT44 */
+ Cop_to_Aop_32, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ Cop_to_Aop_nv12, /* DSPF_NV12 */
+ Cop_to_Aop_nv12, /* DSPF_NV16 */
+ Cop_to_Aop_16, /* DSPF_ARGB2554 */
+ Cop_to_Aop_16, /* DSPF_ARGB4444 */
+ Cop_to_Aop_16, /* DSPF_RGBA4444 */
+ Cop_to_Aop_nv21, /* DSPF_NV21 */
+ Cop_to_Aop_32, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Cop_to_Aop_18, /* DSPF_ARGB1666 */
+ Cop_to_Aop_18, /* DSPF_ARGB6666 */
+ Cop_to_Aop_18, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Cop_to_Aop_16, /* DSPF_RGB444 */
+ Cop_to_Aop_16, /* DSPF_RGB555 */
+ Cop_to_Aop_16 /* DSPF_BGR555 */
+};
+
+/********************************* Cop_toK_Aop_PFI ****************************/
+
+static void Cop_toK_Aop_8( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+ u32 Dkey = gfxs->Dkey;
+
+ while (w--) {
+ if (Dkey == *D)
+ *D = Cop;
+
+ D++;
+ }
+}
+
+static void Cop_toK_Aop_18( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+ u32 Cop = gfxs->Cop;
+
+ while (w) {
+ if (Dkey == ((u32)(D[2]<<16 | D[1]<<8 | D[0]) & 0x3FFFF)) {
+ D[0] = Cop;
+ D[1] = Cop >> 8;
+ D[2] = Cop >> 16;
+ }
+ D += 3;
+ --w;
+ }
+
+}
+
+static void Cop_toK_Aop_24( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+ u8 Dkr = (gfxs->Dkey & 0xff0000) >> 16;
+ u8 Dkg = (gfxs->Dkey & 0x00ff00) >> 8;
+ u8 Dkb = (gfxs->Dkey & 0x0000ff);
+
+ while (w--) {
+ if (D[0] == Dkb && D[1] == Dkg && D[2] == Dkr) {
+ D[0] = gfxs->color.b;
+ D[1] = gfxs->color.g;
+ D[2] = gfxs->color.r;
+ }
+
+ D += 3;
+ }
+}
+
+static void Cop_toK_Aop_yuv422( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ u16 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+ u32 Dkey = gfxs->Dkey;
+
+ if ((long)D & 2) {
+#ifdef WORDS_BIGENDIAN
+ if (*D == (Dkey & 0xffff))
+ *D = Cop & 0xffff;
+#else
+ if (*D == (Dkey >> 16))
+ *D = Cop >> 16;
+#endif
+ D++;
+ w--;
+ }
+
+ for (l = w>>1; l--;) {
+ if (*((u32*)D) == Dkey)
+ *((u32*)D) = Cop;
+ D += 2;
+ }
+
+ if (w & 1) {
+#ifdef WORDS_BIGENDIAN
+ if (*D == (Dkey >> 16))
+ *D = Cop >> 16;
+#else
+ if (*D == (Dkey & 0xffff))
+ *D = Cop & 0xffff;
+#endif
+ }
+}
+
+static void Cop_toK_Aop_alut44( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+ u32 Dkey = gfxs->Dkey;
+
+ while (w--) {
+ if (Dkey == (*D & 0x0F))
+ *D = Cop;
+
+ D++;
+ }
+}
+
+static GenefxFunc Cop_toK_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Cop_toK_Aop_15, /* DSPF_ARGB1555 */
+ Cop_toK_Aop_16, /* DSPF_RGB16 */
+ Cop_toK_Aop_24, /* DSPF_RGB24 */
+ Cop_toK_Aop_32, /* DSPF_RGB32 */
+ Cop_toK_Aop_32, /* DSPF_ARGB */
+ Cop_toK_Aop_8, /* DSPF_A8 */
+ Cop_toK_Aop_yuv422, /* DSPF_YUY2 */
+ Cop_toK_Aop_8, /* DSPF_RGB332 */
+ Cop_toK_Aop_yuv422, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ Cop_toK_Aop_8, /* DSPF_LUT8 */
+ Cop_toK_Aop_alut44, /* DSPF_ALUT44 */
+ Cop_toK_Aop_32, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Cop_toK_Aop_14, /* DSPF_ARGB2554 */
+ Cop_toK_Aop_12, /* DSPF_ARGB4444 */
+ Cop_toK_Aop_12vv, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ Cop_toK_Aop_32, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Cop_toK_Aop_18, /* DSPF_ARGB1666 */
+ Cop_toK_Aop_18, /* DSPF_ARGB6666 */
+ Cop_toK_Aop_18, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Cop_toK_Aop_12, /* DSPF_RGB444 */
+ Cop_toK_Aop_15, /* DSPF_RGB555 */
+ Cop_toK_Aop_15 /* DSPF_BGR555 */
+};
+
+/********************************* Bop_PFI_to_Aop_PFI *************************/
+
+static void Bop_4_to_Aop( GenefxState *gfxs )
+{
+ direct_memmove( gfxs->Aop[0], gfxs->Bop[0], gfxs->length>>1 );
+}
+
+static void Bop_8_to_Aop( GenefxState *gfxs )
+{
+ direct_memmove( gfxs->Aop[0], gfxs->Bop[0], gfxs->length );
+}
+
+static void Bop_16_to_Aop( GenefxState *gfxs )
+{
+ direct_memmove( gfxs->Aop[0], gfxs->Bop[0], gfxs->length*2 );
+}
+
+static void Bop_24_to_Aop( GenefxState *gfxs )
+{
+ direct_memmove( gfxs->Aop[0], gfxs->Bop[0], gfxs->length*3 );
+}
+
+static void Bop_32_to_Aop( GenefxState *gfxs )
+{
+ direct_memmove( gfxs->Aop[0], gfxs->Bop[0], gfxs->length*4 );
+}
+
+static void Bop_i420_to_Aop( GenefxState *gfxs )
+{
+ direct_memmove( gfxs->Aop[0], gfxs->Bop[0], gfxs->length );
+ if (gfxs->AopY & 1) {
+ direct_memmove( gfxs->Aop[1], gfxs->Bop[1], gfxs->length>>1 );
+ direct_memmove( gfxs->Aop[2], gfxs->Bop[2], gfxs->length>>1 );
+ }
+}
+
+static void Bop_NV_to_Aop( GenefxState *gfxs )
+{
+ direct_memmove( gfxs->Aop[0], gfxs->Bop[0], gfxs->length );
+ if (gfxs->dst_format == DSPF_NV16 || gfxs->AopY & 1)
+ direct_memmove( gfxs->Aop[1], gfxs->Bop[1], gfxs->length&~1 );
+}
+
+static GenefxFunc Bop_PFI_to_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_16_to_Aop, /* DSPF_ARGB1555 */
+ Bop_16_to_Aop, /* DSPF_RGB16 */
+ Bop_24_to_Aop, /* DSPF_RGB24 */
+ Bop_32_to_Aop, /* DSPF_RGB32 */
+ Bop_32_to_Aop, /* DSPF_ARGB */
+ Bop_8_to_Aop, /* DSPF_A8 */
+ Bop_16_to_Aop, /* DSPF_YUY2 */
+ Bop_8_to_Aop, /* DSPF_RGB332 */
+ Bop_16_to_Aop, /* DSPF_UYVY */
+ Bop_i420_to_Aop, /* DSPF_I420 */
+ Bop_i420_to_Aop, /* DSPF_YV12 */
+ Bop_8_to_Aop, /* DSPF_LUT8 */
+ Bop_8_to_Aop, /* DSPF_ALUT44 */
+ Bop_32_to_Aop, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ Bop_NV_to_Aop, /* DSPF_NV12 */
+ Bop_NV_to_Aop, /* DSPF_NV16 */
+ Bop_16_to_Aop, /* DSPF_ARGB2554 */
+ Bop_16_to_Aop, /* DSPF_ARGB4444 */
+ Bop_16_to_Aop, /* DSPF_RGBA4444 */
+ Bop_NV_to_Aop, /* DSPF_NV21 */
+ Bop_32_to_Aop, /* DSPF_AYUV */
+ Bop_4_to_Aop, /* DSPF_A4 */
+ Bop_24_to_Aop, /* DSPF_ARGB1666 */
+ Bop_24_to_Aop, /* DSPF_ARGB6666 */
+ Bop_24_to_Aop, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Bop_16_to_Aop, /* DSPF_RGB444 */
+ Bop_16_to_Aop, /* DSPF_RGB555 */
+ Bop_16_to_Aop /* DSPF_BGR555 */
+};
+
+/********************************* Bop_PFI_toR_Aop_PFI *************************/
+
+static void Bop_4_toR_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ int Dstep = gfxs->Astep;
+ u8 * S = gfxs->Bop[0];
+ u8 * D = gfxs->Aop[0];
+ while(w--)
+ {
+ *D = *S;
+ D += Dstep;
+ S++;
+ }
+}
+
+static void Bop_8_toR_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int Dstep = gfxs->Astep;
+ u8 * S = gfxs->Bop[0];
+ u8 * D = gfxs->Aop[0];
+ while(w--)
+ {
+ *D = *S;
+ D += Dstep;
+ S++;
+ }
+}
+
+static void Bop_16_toR_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int Dstep = gfxs->Astep;
+ u16 * S = gfxs->Bop[0];
+ u16 * D = gfxs->Aop[0];
+ while(w--)
+ {
+ *D = *S;
+ D += Dstep;
+ S++;
+ }
+}
+
+static void Bop_24_toR_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int Dstep = gfxs->Astep;
+ u8 * S = gfxs->Bop[0];
+ u8 * D = gfxs->Aop[0];
+ while(w--)
+ {
+ D[0] = S[0];
+ D[1] = S[1];
+ D[2] = S[2];
+
+ D += Dstep * 3;
+ S += 3;
+ }
+}
+
+static void Bop_32_toR_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int Dstep = gfxs->Astep;
+ u32 * S = gfxs->Bop[0];
+ u32 * D = gfxs->Aop[0];
+ while(w--)
+ {
+ *D = *S;
+ D += Dstep;
+ S++;
+ }
+}
+
+static void Bop_i420_toR_Aop( GenefxState *gfxs )
+{
+ Bop_8_toR_Aop( gfxs );
+ if (gfxs->AopY & 1) {
+ int w = gfxs->length>>1;
+ int Dstep = gfxs->Astep>>1;
+ u8 * S1 = gfxs->Bop[1];
+ u8 * D1 = gfxs->Aop[1];
+ u8 * S2 = gfxs->Bop[2];
+ u8 * D2 = gfxs->Aop[2];
+ while(w--)
+ {
+ *D1 = *S1++;
+ *D2 = *S2++;
+ D1 += Dstep;
+ D2 += Dstep;
+ }
+ }
+}
+
+static void Bop_NV_toR_Aop( GenefxState *gfxs )
+{
+ Bop_8_toR_Aop( gfxs );
+ if (gfxs->dst_format == DSPF_NV16 || gfxs->AopY & 1) {
+ int w = gfxs->length&~1;
+ int Dstep = gfxs->Astep;
+ u8 * S = gfxs->Bop[1];
+ u8 * D = gfxs->Aop[1];
+ while(w--)
+ {
+ *D = *S++;
+ D += Dstep;
+ }
+ }
+}
+
+static GenefxFunc Bop_PFI_toR_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_16_toR_Aop, /* DSPF_ARGB1555 */
+ Bop_16_toR_Aop, /* DSPF_RGB16 */
+ Bop_24_toR_Aop, /* DSPF_RGB24 */
+ Bop_32_toR_Aop, /* DSPF_RGB32 */
+ Bop_32_toR_Aop, /* DSPF_ARGB */
+ Bop_8_toR_Aop, /* DSPF_A8 */
+ Bop_16_toR_Aop, /* DSPF_YUY2 */
+ Bop_8_toR_Aop, /* DSPF_RGB332 */
+ Bop_16_toR_Aop, /* DSPF_UYVY */
+ Bop_i420_toR_Aop, /* DSPF_I420 */
+ Bop_i420_toR_Aop, /* DSPF_YV12 */
+ Bop_8_toR_Aop, /* DSPF_LUT8 */
+ Bop_8_toR_Aop, /* DSPF_ALUT44 */
+ Bop_32_toR_Aop, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ Bop_NV_toR_Aop, /* DSPF_NV12 */
+ Bop_NV_toR_Aop, /* DSPF_NV16 */
+ Bop_16_toR_Aop, /* DSPF_ARGB2554 */
+ Bop_16_toR_Aop, /* DSPF_ARGB4444 */
+ Bop_16_toR_Aop, /* DSPF_RGBA4444 */
+ Bop_NV_toR_Aop, /* DSPF_NV21 */
+ Bop_32_toR_Aop, /* DSPF_AYUV */
+ Bop_4_toR_Aop, /* DSPF_A4 */
+ Bop_24_toR_Aop, /* DSPF_ARGB1666 */
+ Bop_24_toR_Aop, /* DSPF_ARGB6666 */
+ Bop_24_toR_Aop, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Bop_16_toR_Aop, /* DSPF_RGB444 */
+ Bop_16_toR_Aop, /* DSPF_RGB555 */
+ Bop_16_toR_Aop /* DSPF_BGR555 */
+};
+
+/********************************* Bop_PFI_Kto_Aop_PFI ************************/
+
+static void Bop_rgb18_Kto_Aop( GenefxState *gfxs )
+{
+
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+ int Ostep = gfxs->Ostep;
+
+ if (Ostep < 0) {
+ D += (gfxs->length - 1) * 3;
+ S += (gfxs->length - 1) * 3;
+ }
+
+ while (w--) {
+ u8 s0 = S[0];
+ u8 s1 = S[1];
+ u8 s2 = S[2];
+
+ if (Skey != ((u32)(s2<<16 | s1<<8 | s0) & 0x3FFFF)) {
+ D[0] = s0;
+ D[1] = s1;
+ D[2] = s2;
+ }
+
+ S += Ostep * 3;
+ D += Ostep * 3;
+ }
+}
+
+static void Bop_rgb24_Kto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+ int Ostep = gfxs->Ostep;
+
+ if (Ostep < 0) {
+ D += (gfxs->length - 1) * 3;
+ S += (gfxs->length - 1) * 3;
+ }
+
+ while (w--) {
+ u8 b = *S;
+ u8 g = *(S+1);
+ u8 r = *(S+2);
+
+ if (Skey != (u32)(r<<16 | g<<8 | b)) {
+ *D = b;
+ *(D+1) = g;
+ *(D+2) = r;
+ }
+
+ S += Ostep * 3;
+ D += Ostep * 3;
+ }
+}
+
+static void Bop_a8_Kto_Aop( GenefxState *gfxs )
+{
+ /* no color to key */
+ direct_memmove( gfxs->Aop[0], gfxs->Bop[0], gfxs->length );
+}
+
+static void Bop_yuv422_Kto_Aop( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ u16 *D = gfxs->Aop[0];
+ u16 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+ int Ostep = gfxs->Ostep;
+
+ if (Ostep < 0) {
+ D += gfxs->length - 1;
+ S += gfxs->length - 1;
+ }
+
+ if ((long)D & 2) {
+ u16 s = *S;
+#ifdef WORDS_BIGENDIAN
+ if (s != (Skey >> 16))
+ *D = s;
+#else
+ if (s != (Skey & 0xffff))
+ *D = s;
+#endif
+ S += Ostep;
+ D += Ostep;
+ w--;
+ }
+
+ if (Ostep < 0) {
+ S--;
+ D--;
+ }
+
+ for (l = w>>1; l--;) {
+ u32 s = *((u32*)S);
+
+ if (s != Skey)
+ *((u32*)D) = s;
+
+ S += Ostep << 1;
+ D += Ostep << 1;
+ }
+
+ if (w & 1) {
+ u16 s = *S;
+#ifdef WORDS_BIGENDIAN
+ if (s != (Skey & 0xffff))
+ *D = s;
+#else
+ if (s != (Skey >> 16))
+ *D = s;
+#endif
+ }
+}
+
+
+/* change the last value to adjust the size of the device (1-4) */
+#define SET_PIXEL_DUFFS_DEVICE( D, S, w ) \
+ SET_PIXEL_DUFFS_DEVICE_N( D, S, w, 4 )
+
+#define SET_PIXEL( D, S ) \
+ do { \
+ register u32 s = S; \
+ \
+ if (s != Skey) \
+ D = s; \
+ } while (0)
+
+static void Bop_8_Kto_Aop( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+
+ if (gfxs->Ostep > 0) {
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+ }
+ else {
+ for (i=w-1; i>=0; i--)
+ if (S[i] != Skey)
+ D[i] = S[i];
+ }
+}
+
+#undef SET_PIXEL_DUFFS_DEVICE
+#undef SET_PIXEL
+
+static void Bop_alut44_Kto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+ int Ostep = gfxs->Ostep;
+
+ if (Ostep < 0) {
+ D += gfxs->length - 1;
+ S += gfxs->length - 1;
+ }
+
+ while (w--) {
+ u8 spixel = *S;
+
+ if ((spixel & 0x0F) != Skey)
+ *D = spixel;
+
+ S += Ostep;
+ D += Ostep;
+ }
+}
+
+static GenefxFunc Bop_PFI_Kto_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_15_Kto_Aop, /* DSPF_ARGB1555 */
+ Bop_16_Kto_Aop, /* DSPF_RGB16 */
+ Bop_rgb24_Kto_Aop, /* DSPF_RGB24 */
+ Bop_32_Kto_Aop, /* DSPF_RGB32 */
+ Bop_32_Kto_Aop, /* DSPF_ARGB */
+ Bop_a8_Kto_Aop, /* DSPF_A8 */
+ Bop_yuv422_Kto_Aop, /* DSPF_YUY2 */
+ Bop_8_Kto_Aop, /* DSPF_RGB332 */
+ Bop_yuv422_Kto_Aop, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ Bop_8_Kto_Aop, /* DSPF_LUT8 */
+ Bop_alut44_Kto_Aop, /* DSPF_ALUT44 */
+ Bop_32_Kto_Aop, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Bop_14_Kto_Aop, /* DSPF_ARGB2554 */
+ Bop_12_Kto_Aop, /* DSPF_ARGB4444 */
+ Bop_12vv_Kto_Aop, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ Bop_32_Kto_Aop, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Bop_rgb18_Kto_Aop, /* DSPF_ARGB1666 */
+ Bop_rgb18_Kto_Aop, /* DSPF_ARGB6666 */
+ Bop_rgb18_Kto_Aop, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Bop_12_Kto_Aop, /* DSPF_RGB444 */
+ Bop_15_Kto_Aop, /* DSPF_RGB555 */
+ Bop_15_Kto_Aop /* DSPF_BGR555 */
+};
+
+/********************************* Bop_PFI_toK_Aop_PFI ************************/
+
+static void Bop_rgb18_toK_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ u32 Dkey = gfxs->Dkey;
+
+ while (w--) {
+ if (Dkey == ((u32)(D[2]<<16 | D[1]<<8 | D[0]) & 0x3FFFF)) {
+ D[0] = S[0];
+ D[1] = S[1];
+ D[2] = S[2];
+ }
+ S += 3;
+ D += 3;
+ }
+}
+
+static void Bop_rgb24_toK_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ u8 Dkr = (gfxs->Dkey & 0xff0000) >> 16;
+ u8 Dkg = (gfxs->Dkey & 0x00ff00) >> 8;
+ u8 Dkb = (gfxs->Dkey & 0x0000ff);
+
+ while (w--) {
+ if (D[0] == Dkb && D[1] == Dkg && D[2] == Dkr) {
+ D[0] = S[0];
+ D[1] = S[1];
+ D[2] = S[2];
+ }
+ S += 3;
+ D += 3;
+ }
+}
+
+static void Bop_yuv422_toK_Aop( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ u16 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+ int Ostep = gfxs->Ostep;
+
+ if (Ostep < 0) {
+ D += gfxs->length - 1;
+ S += gfxs->length - 1;
+ }
+
+ if ((long)D & 2) {
+#ifdef WORDS_BIGENDIAN
+ if (*D == (Dkey & 0xffff))
+ *D = *S;
+#else
+ if (*D == (Dkey >> 16))
+ *D = *S;
+#endif
+ D += Ostep;
+ S += Ostep;
+ w--;
+ }
+
+ if (Ostep < 0) {
+ S--;
+ D--;
+ }
+
+ for (l = w>>1; l--;) {
+ if (*D == Dkey)
+ *D = *S;
+ D += Ostep << 1;
+ S += Ostep << 1;
+ }
+
+ if (w & 1) {
+#ifdef WORDS_BIGENDIAN
+ if (*D == (Dkey >> 16))
+ *D = *S;
+#else
+ if (*D == (Dkey & 0xffff))
+ *D = *S;
+#endif
+ }
+}
+
+static void Bop_rgb332_toK_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ u8 Dkey = gfxs->Dkey;
+
+ while (w--) {
+ if (*D == Dkey) {
+ *D = *S;
+ }
+ D++;
+ S++;
+ }
+}
+
+static GenefxFunc Bop_PFI_toK_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_15_toK_Aop, /* DSPF_ARGB1555 */
+ Bop_16_toK_Aop, /* DSPF_RGB16 */
+ Bop_rgb24_toK_Aop, /* DSPF_RGB24 */
+ Bop_32_toK_Aop, /* DSPF_RGB32 */
+ Bop_32_toK_Aop, /* DSPF_ARGB */
+ NULL, /* DSPF_A8 */
+ Bop_yuv422_toK_Aop, /* DSPF_YUY2 */
+ Bop_rgb332_toK_Aop, /* DSPF_RGB332 */
+ Bop_yuv422_toK_Aop, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ NULL, /* DSPF_LUT8 */
+ NULL, /* DSPF_ALUT44 */
+ Bop_32_toK_Aop, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Bop_14_toK_Aop, /* DSPF_ARGB2554 */
+ Bop_12_toK_Aop, /* DSPF_ARGB4444 */
+ Bop_12vv_toK_Aop, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ Bop_32_toK_Aop, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Bop_rgb18_toK_Aop, /* DSPF_ARGB1666 */
+ Bop_rgb18_toK_Aop, /* DSPF_ARGB6666 */
+ Bop_rgb18_toK_Aop, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Bop_12_toK_Aop, /* DSPF_RGB444 */
+ Bop_15_toK_Aop, /* DSPF_RGB555 */
+ Bop_15_toK_Aop /* DSPF_BGR555 */
+};
+
+/********************************* Bop_PFI_KtoK_Aop_PFI ***********************/
+
+static GenefxFunc Bop_PFI_KtoK_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_15_KtoK_Aop, /* DSPF_ARGB1555 */
+ Bop_16_KtoK_Aop, /* DSPF_RGB16 */
+ NULL, /* DSPF_RGB24 */
+ Bop_32_KtoK_Aop, /* DSPF_RGB32 */
+ Bop_32_KtoK_Aop, /* DSPF_ARGB */
+ NULL, /* DSPF_A8 */
+ NULL, /* DSPF_YUY2 */
+ NULL, /* DSPF_RGB332 */
+ NULL, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ NULL, /* DSPF_LUT8 */
+ NULL, /* DSPF_ALUT44 */
+ Bop_32_KtoK_Aop, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Bop_14_KtoK_Aop, /* DSPF_ARGB2554 */
+ Bop_12_KtoK_Aop, /* DSPF_ARGB4444 */
+ Bop_12vv_KtoK_Aop, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ NULL, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ NULL, /* DSPF_ARGB1666 */
+ NULL, /* DSPF_ARGB6666 */
+ NULL, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Bop_12_KtoK_Aop, /* DSPF_RGB444 */
+ Bop_15_KtoK_Aop, /* DSPF_RGB555 */
+ Bop_15_KtoK_Aop /* DSPF_BGR555 */
+};
+
+/********************************* Bop_PFI_Sto_Aop_PFI ************************/
+
+static void Bop_16_Sto_Aop( GenefxState *gfxs )
+{
+ int w2;
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u32 *D = gfxs->Aop[0];
+ u16 *S = gfxs->Bop[0];
+ int SperD = gfxs->SperD;
+ int SperD2 = SperD << 1;
+
+ if (((long)D)&2) {
+ *(u16*)D = *S;
+ i += SperD;
+ w--;
+ D = gfxs->Aop[0] + 2;
+ }
+
+ w2 = (w >> 1);
+ while (w2--) {
+#ifdef WORDS_BIGENDIAN
+ *D++ = S[i>>16] << 16 | S[(i+SperD)>>16];
+#else
+ *D++ = (S[(i+SperD)>>16] << 16) | S[i>>16];
+#endif
+ i += SperD2;
+ }
+ if (w&1) {
+ *(u16*)D = S[i>>16];
+ }
+}
+
+static void Bop_24_Sto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ *D++ = S[pixelstart+0];
+ *D++ = S[pixelstart+1];
+ *D++ = S[pixelstart+2];
+
+ i += SperD;
+ }
+}
+
+static void Bop_32_Sto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u32 *D = gfxs->Aop[0];
+ u32 *S = gfxs->Bop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ *D++ = S[i>>16];
+
+ i += SperD;
+ }
+}
+
+static void Bop_yuy2_Sto_Aop( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u16 *D = gfxs->Aop[0];
+ u16 *S = gfxs->Bop[0];
+ int SperD = gfxs->SperD;
+
+ if ((long)D & 2) {
+ *D++ = *S;
+ i = SperD;
+ w--;
+ }
+
+ for (l = w>>1; l--;) {
+ register u32 d;
+
+ d = ((u32*)S)[i>>17] & 0xff00ff00;
+#ifdef WORDS_BIGENDIAN
+ d |= (S[i>>16] & 0x00ff) << 16;
+ d |= (S[(i+SperD)>>16] & 0x00ff);
+#else
+ d |= (S[i>>16] & 0x00ff);
+ d |= (S[(i+SperD)>>16] & 0x00ff) << 16;
+#endif
+ *((u32*)D) = d;
+ D += 2;
+
+ i += SperD << 1;
+ }
+
+ if (w & 1)
+ *D = S[i>>16];
+}
+
+static void Bop_8_Sto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ *D++ = S[i>>16];
+
+ i += SperD;
+ }
+}
+
+static void Bop_uyvy_Sto_Aop( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u16 *D = gfxs->Aop[0];
+ u16 *S = gfxs->Bop[0];
+ int SperD = gfxs->SperD;
+
+ if ((long)D & 2) {
+ *D++ = *S;
+ i = SperD;
+ w--;
+ }
+
+ for (l = w>>1; l--;) {
+ register u32 d;
+
+ d = ((u32*)S)[i>>17] & 0x00ff00ff;
+#ifdef WORDS_BIGENDIAN
+ d |= (S[i>>16] & 0xff00) << 16;
+ d |= (S[(i+SperD)>>16] & 0xff00);
+#else
+ d |= (S[i>>16] & 0xff00);
+ d |= (S[(i+SperD)>>16] & 0xff00) << 16;
+#endif
+ *((u32*)D) = d;
+ D += 2;
+
+ i += SperD << 1;
+ }
+
+ if (w & 1)
+ *D = S[i>>16];
+}
+
+static void Bop_i420_Sto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u8 *Dy = gfxs->Aop[0];
+ u8 *Sy = gfxs->Bop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ *Dy++ = Sy[i>>16];
+
+ i += SperD;
+ }
+
+ if (gfxs->AopY & 1) {
+ u8 *Du = gfxs->Aop[1];
+ u8 *Dv = gfxs->Aop[2];
+ u8 *Su = gfxs->Bop[1];
+ u8 *Sv = gfxs->Bop[2];
+
+ for (w = gfxs->length>>1, i = 0; w--;) {
+ *Du++ = Su[i>>16];
+
+ i += SperD;
+ }
+
+ for (w = gfxs->length>>1, i = 0; w--;) {
+ *Dv++ = Sv[i>>16];
+
+ i += SperD;
+ }
+ }
+}
+
+static void Bop_NV_Sto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u8 *Dy = gfxs->Aop[0];
+ u8 *Sy = gfxs->Bop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ *Dy++ = Sy[i>>16];
+
+ i += SperD;
+ }
+
+ if (gfxs->dst_format == DSPF_NV16 || gfxs->AopY & 1) {
+ u16 *Duv = gfxs->Aop[1];
+ u16 *Suv = gfxs->Bop[1];
+
+ for (w = gfxs->length>>1, i = 0; w--;) {
+ *Duv++ = Suv[i>>16];
+
+ i += SperD;
+ }
+ }
+}
+
+static GenefxFunc Bop_PFI_Sto_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_16_Sto_Aop, /* DSPF_ARGB1555 */
+ Bop_16_Sto_Aop, /* DSPF_RGB16 */
+ Bop_24_Sto_Aop, /* DSPF_RGB24 */
+ Bop_32_Sto_Aop, /* DSPF_RGB32 */
+ Bop_32_Sto_Aop, /* DSPF_ARGB */
+ Bop_8_Sto_Aop, /* DSPF_A8 */
+ Bop_yuy2_Sto_Aop, /* DSPF_YUY2 */
+ Bop_8_Sto_Aop, /* DSPF_RGB332 */
+ Bop_uyvy_Sto_Aop, /* DSPF_UYVY */
+ Bop_i420_Sto_Aop, /* DSPF_I420 */
+ Bop_i420_Sto_Aop, /* DSPF_YV12 */
+ Bop_8_Sto_Aop, /* DSPF_LUT8 */
+ Bop_8_Sto_Aop, /* DSPF_ALUT44 */
+ Bop_32_Sto_Aop, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ Bop_NV_Sto_Aop, /* DSPF_NV12 */
+ Bop_NV_Sto_Aop, /* DSPF_NV16 */
+ Bop_16_Sto_Aop, /* DSPF_ARGB2554 */
+ Bop_16_Sto_Aop, /* DSPF_ARGB4444 */
+ Bop_16_Sto_Aop, /* DSPF_RGBA4444 */
+ Bop_NV_Sto_Aop, /* DSPF_NV21 */
+ Bop_32_Sto_Aop, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Bop_24_Sto_Aop, /* DSPF_ARGB1666 */
+ Bop_24_Sto_Aop, /* DSPF_ARGB6666 */
+ Bop_24_Sto_Aop, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Bop_16_Sto_Aop, /* DSPF_ARGB4444 */
+ Bop_16_Sto_Aop, /* DSPF_ARGB1555 */
+ Bop_16_Sto_Aop /* DSPF_ARGB1555 */
+};
+
+/********************************* Bop_PFI_SKto_Aop_PFI ***********************/
+
+static void Bop_rgb18_SKto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ u8 s0 = S[pixelstart+0];
+ u8 s1 = S[pixelstart+1];
+ u8 s2 = S[pixelstart+2];
+
+ if (Skey != ((u32)(s2<<16 | s1<<8 | s0) & 0x3FFFF)) {
+ D[0] = s0;
+ D[1] = s1;
+ D[2] = s2;
+ }
+ i += SperD;
+ D += 3;
+ }
+}
+
+static void Bop_rgb24_SKto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ u8 b = S[pixelstart+0];
+ u8 g = S[pixelstart+1];
+ u8 r = S[pixelstart+2];
+
+ if (Skey != (u32)(r<<16 | g<<8 | b)) {
+ *D = b;
+ *(D+1) = g;
+ *(D+2) = r;
+ }
+
+ D += 3;
+ i += SperD;
+ }
+}
+
+static void Bop_a8_SKto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ int SperD = gfxs->SperD;
+
+ /* no color to key */
+ while (w--) {
+ *D++ = S[i>>16];
+
+ i += SperD;
+ }
+}
+
+static void Bop_yuy2_SKto_Aop( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u16 *D = gfxs->Aop[0];
+ u16 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+#ifdef WORDS_BIGENDIAN
+ u16 Skey0 = gfxs->Skey >> 16;
+ u16 Skey1 = gfxs->Skey & 0xffff;
+#else
+ u16 Skey0 = gfxs->Skey & 0xffff;
+ u16 Skey1 = gfxs->Skey >> 16;
+#endif
+ int SperD = gfxs->SperD;
+
+ if ((long)D & 2) {
+ u16 s = *S;
+ if (s != Skey0)
+ *D = s;
+ D++;
+ i = SperD;
+ w--;
+ }
+
+ for (l = w>>1; l--;) {
+ register u32 s;
+
+ s = ((u32*)S)[i>>17] & 0xff00ff00;
+#ifdef WORDS_BIGENDIAN
+ s |= (S[i>>16] & 0x00ff) << 16;
+ s |= (S[(i+SperD)>>16] & 0x00ff);
+#else
+ s |= (S[i>>16] & 0x00ff);
+ s |= (S[(i+SperD)>>16] & 0x00ff) << 16;
+#endif
+ if (s != Skey)
+ *((u32*)D) = s;
+ D += 2;
+
+ i += SperD << 1;
+ }
+
+ if (w & 1) {
+ u16 s = S[i>>16];
+ if (i & 0x20000) {
+ if (s != Skey1)
+ *D = s;
+ } else {
+ if (s != Skey0)
+ *D = s;
+ }
+ }
+}
+
+static void Bop_8_SKto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ u8 s = S[i>>16];
+
+ if (s != Skey)
+ *D = s;
+
+ D++;
+ i += SperD;
+ }
+}
+
+static void Bop_uyvy_SKto_Aop( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u16 *D = gfxs->Aop[0];
+ u16 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+#ifdef WORDS_BIGENDIAN
+ u16 Skey0 = gfxs->Skey >> 16;
+ u16 Skey1 = gfxs->Skey & 0xffff;
+#else
+ u16 Skey0 = gfxs->Skey & 0xffff;
+ u16 Skey1 = gfxs->Skey >> 16;
+#endif
+ int SperD = gfxs->SperD;
+
+ if ((long)D & 2) {
+ u16 s = *S;
+ if (s != Skey0)
+ *D = s;
+ D++;
+ i = SperD;
+ w--;
+ }
+
+ for (l = w>>1; l--;) {
+ register u32 s;
+
+ s = ((u32*)S)[i>>17] & 0x00ff00ff;
+#ifdef WORDS_BIGENDIAN
+ s |= (S[i>>16] & 0xff00) << 16;
+ s |= (S[(i+SperD)>>16] & 0xff00);
+#else
+ s |= (S[i>>16] & 0xff00);
+ s |= (S[(i+SperD)>>16] & 0xff00) << 16;
+#endif
+ if (s != Skey)
+ *((u32*)D) = s;
+ D += 2;
+
+ i += SperD << 1;
+ }
+
+ if (w & 1) {
+ u16 s = S[i>>16];
+ if (i & 0x20000) {
+ if (s != Skey1)
+ *D = s;
+ } else {
+ if (s != Skey0)
+ *D = s;
+ }
+ }
+}
+
+static void Bop_alut44_SKto_Aop( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ u8 *D = gfxs->Aop[0];
+ u8 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ u8 s = S[i>>16];
+
+ if ((s & 0x0f) != Skey)
+ *D = s;
+
+ D++;
+ i += SperD;
+ }
+}
+
+static GenefxFunc Bop_PFI_SKto_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_15_SKto_Aop, /* DSPF_ARGB1555 */
+ Bop_16_SKto_Aop, /* DSPF_RGB16 */
+ Bop_rgb24_SKto_Aop, /* DSPF_RGB24 */
+ Bop_32_SKto_Aop, /* DSPF_RGB32 */
+ Bop_32_SKto_Aop, /* DSPF_ARGB */
+ Bop_a8_SKto_Aop, /* DSPF_A8 */
+ Bop_yuy2_SKto_Aop, /* DSPF_YUY2 */
+ Bop_8_SKto_Aop, /* DSPF_RGB332 */
+ Bop_uyvy_SKto_Aop, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ Bop_8_SKto_Aop, /* DSPF_LUT8 */
+ Bop_alut44_SKto_Aop, /* DSPF_ALUT44 */
+ Bop_32_SKto_Aop, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Bop_14_SKto_Aop, /* DSPF_ARGB2554 */
+ Bop_12_SKto_Aop, /* DSPF_ARGB4444 */
+ Bop_12vv_SKto_Aop, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ Bop_32_SKto_Aop, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Bop_rgb18_SKto_Aop, /* DSPF_ARGB1666 */
+ Bop_rgb18_SKto_Aop, /* DSPF_ARGB6666 */
+ Bop_rgb18_SKto_Aop, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Bop_12_SKto_Aop, /* DSPF_RGB444 */
+ Bop_15_SKto_Aop, /* DSPF_RGB555 */
+ Bop_15_SKto_Aop /* DSPF_BGR555 */
+};
+
+/********************************* Bop_PFI_StoK_Aop_PFI ***********************/
+
+static GenefxFunc Bop_PFI_StoK_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_15_StoK_Aop, /* DSPF_ARGB1555 */
+ Bop_16_StoK_Aop, /* DSPF_RGB16 */
+ NULL, /* DSPF_RGB24 */
+ Bop_32_StoK_Aop, /* DSPF_RGB32 */
+ Bop_32_StoK_Aop, /* DSPF_ARGB */
+ NULL, /* DSPF_A8 */
+ NULL, /* DSPF_YUY2 */
+ NULL, /* DSPF_RGB332 */
+ NULL, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ NULL, /* DSPF_LUT8 */
+ NULL, /* DSPF_ALUT44 */
+ Bop_32_StoK_Aop, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Bop_14_StoK_Aop, /* DSPF_ARGB2554 */
+ Bop_12_StoK_Aop, /* DSPF_ARGB4444 */
+ Bop_12vv_StoK_Aop, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ NULL, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ NULL, /* DSPF_ARGB1666 */
+ NULL, /* DSPF_ARGB6666 */
+ NULL, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Bop_12_StoK_Aop, /* DSPF_RGB444 */
+ Bop_15_StoK_Aop, /* DSPF_RGB555 */
+ Bop_15_StoK_Aop /* DSPF_BGR555 */
+};
+
+/********************************* Bop_PFI_SKtoK_Aop_PFI **********************/
+
+static GenefxFunc Bop_PFI_SKtoK_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_15_SKtoK_Aop, /* DSPF_ARGB1555 */
+ Bop_16_SKtoK_Aop, /* DSPF_RGB16 */
+ NULL, /* DSPF_RGB24 */
+ Bop_32_SKtoK_Aop, /* DSPF_RGB32 */
+ Bop_32_SKtoK_Aop, /* DSPF_ARGB */
+ NULL, /* DSPF_A8 */
+ NULL, /* DSPF_YUY2 */
+ NULL, /* DSPF_RGB332 */
+ NULL, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ NULL, /* DSPF_LUT8 */
+ NULL, /* DSPF_ALUT44 */
+ Bop_32_SKtoK_Aop, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Bop_14_SKtoK_Aop, /* DSPF_ARGB2554 */
+ Bop_12_SKtoK_Aop, /* DSPF_ARGB4444 */
+ Bop_12vv_SKtoK_Aop, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ NULL, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ NULL, /* DSPF_ARGB1666 */
+ NULL, /* DSPF_ARGB6666 */
+ NULL, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Bop_12_SKtoK_Aop, /* DSPF_RGB444 */
+ Bop_15_SKtoK_Aop, /* DSPF_RGB555 */
+ Bop_15_SKtoK_Aop /* DSPF_BGR555 */
+};
+
+/********************************* Sop_PFI_Sto_Dacc ***************************/
+
+static void Sop_argb6666_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ u8 b = S[pixelstart+0] & 0x3F;
+ u8 g = ((S[pixelstart+0] & 0xC0) >> 6) | ((S[pixelstart+1] & 0x0F) << 2);
+ u8 r = ((S[pixelstart+1] & 0xF0) >> 4) | ((S[pixelstart+2] & 0x03) << 4);
+ u8 a = (S[pixelstart+2] & 0xFC) >> 2;
+
+ D->RGB.a = EXPAND_6to8( a );
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+ i += SperD;
+ D++;
+ }
+}
+
+static void Sop_argb1666_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ u8 b = S[pixelstart+0] & 0x3F;
+ u8 g = ((S[pixelstart+0] & 0xC0) >> 6) | ((S[pixelstart+1] & 0x0F) << 2);
+ u8 r = ((S[pixelstart+1] & 0xF0) >> 4) | ((S[pixelstart+2] & 0x03) << 4);
+ u8 a = (S[pixelstart+2] & 0x04) >> 2;
+
+ D->RGB.a = EXPAND_1to8( a );
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+ i += SperD;
+ D++;
+ }
+}
+
+static void Sop_rgb18_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ u8 b = S[pixelstart+0] & 0x3F;
+ u8 g = ((S[pixelstart+0] & 0xC0) >> 6) | ((S[pixelstart+1] & 0x0F) << 2);
+ u8 r = ((S[pixelstart+1] & 0xF0) >> 4) | ((S[pixelstart+2] & 0x03) << 4);
+
+ D->RGB.a = 0xFF;
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+ i += SperD;
+ D++;
+ }
+}
+
+static void Sop_rgb24_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ D->RGB.a = 0xFF;
+ D->RGB.r = S[pixelstart+2];
+ D->RGB.g = S[pixelstart+1];
+ D->RGB.b = S[pixelstart+0];
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_a8_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u8 s = S[i>>16];
+
+ D->RGB.a = s;
+ D->RGB.r = 0xFF;
+ D->RGB.g = 0xFF;
+ D->RGB.b = 0xFF;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_yuy2_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u32 s = S[i>>17];
+
+ D[0].YUV.a = D[1].YUV.a = 0xFF;
+#ifdef WORDS_BIGENDIAN
+ D[0].YUV.u = D[1].YUV.u = (s & 0xFF000000) >> 24;
+ D[0].YUV.v = D[1].YUV.v = (s & 0x0000FF00) >> 8;
+#else
+ D[0].YUV.u = D[1].YUV.u = (s & 0x0000FF00) >> 8;
+ D[0].YUV.v = D[1].YUV.v = (s & 0xFF000000) >> 24;
+#endif
+ D[0].YUV.y = ((u16*)S)[i>>16] & 0x00FF;
+ D[1].YUV.y = ((u16*)S)[(i+SperD)>>16] & 0x00FF;
+
+ D += 2;
+ i += SperD << 1;
+ }
+
+ if (gfxs->length & 1) {
+ u16 s = ((u16*)S)[i>>17];
+
+ D->YUV.a = 0xFF;
+ D->YUV.y = s & 0xFF;
+ D->YUV.u = s >> 8;
+ D->YUV.v = 0x00;
+ }
+}
+
+static void Sop_rgb332_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u8 s = S[i>>16];
+
+ D->RGB.a = 0xFF;
+ D->RGB.r = EXPAND_3to8(s >> 5);
+ D->RGB.g = EXPAND_3to8((s & 0x1C) >> 2);
+ D->RGB.b = EXPAND_2to8(s & 0x03);
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_uyvy_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u32 s = S[i>>17];
+
+ D[0].YUV.a = D[1].YUV.a = 0xFF;
+#ifdef WORDS_BIGENDIAN
+ D[0].YUV.u = D[1].YUV.u = (s & 0x00FF0000) >> 16;
+ D[0].YUV.v = D[1].YUV.v = (s & 0x000000FF);
+#else
+ D[0].YUV.u = D[1].YUV.u = (s & 0x000000FF);
+ D[0].YUV.v = D[1].YUV.v = (s & 0x00FF0000) >> 16;
+#endif
+ D[0].YUV.y = (((u16*)S)[i>>16] & 0xFF00) >> 8;
+ D[1].YUV.y = (((u16*)S)[(i+SperD)>>16] & 0xFF00) >> 8;
+
+ D += 2;
+ i += SperD << 1;
+ }
+
+ if (gfxs->length & 1) {
+ u16 s = ((u16*)S)[i>>16];
+
+ D->YUV.a = 0xFF;
+ D->YUV.y = s >> 8;
+ D->YUV.u = s & 0xFF;
+ D->YUV.v = 0x00;
+ }
+}
+
+static void Sop_lut8_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ DFBColor *entries = gfxs->Slut->entries;
+
+ while (w--) {
+ u8 s = S[i>>16];
+
+ D->RGB.a = entries[s].a;
+ D->RGB.r = entries[s].r;
+ D->RGB.g = entries[s].g;
+ D->RGB.b = entries[s].b;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_alut44_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ DFBColor *entries = gfxs->Slut->entries;
+
+ while (w--) {
+ u8 s = S[i>>16];
+
+ D->RGB.a = s & 0xF0;
+ s &= 0x0F;
+ D->RGB.r = entries[s].r;
+ D->RGB.g = entries[s].g;
+ D->RGB.b = entries[s].b;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_i420_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *Sy = gfxs->Sop[0];
+ u8 *Su = gfxs->Sop[1];
+ u8 *Sv = gfxs->Sop[2];
+
+ while (w--) {
+ D->YUV.a = 0xFF;
+ D->YUV.y = Sy[i>>16];
+ D->YUV.u = Su[i>>17];
+ D->YUV.v = Sv[i>>17];
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_nv12_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *Sy = gfxs->Sop[0];
+ u16 *Suv = gfxs->Sop[1];
+
+ while (w--) {
+ D->YUV.a = 0xFF;
+ D->YUV.y = Sy[i>>16];
+ D->YUV.u = Suv[i>>17] & 0xFF;
+ D->YUV.v = Suv[i>>17] >> 8;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_nv21_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *Sy = gfxs->Sop[0];
+ u16 *Svu = gfxs->Sop[1];
+
+ while (w--) {
+ D->YUV.a = 0xFF;
+ D->YUV.y = Sy[i>>16];
+ D->YUV.u = Svu[i>>17] >> 8;
+ D->YUV.v = Svu[i>>17] & 0xFF;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_ayuv_Sto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u32 s = S[i>>16];
+
+ D->YUV.a = (s >> 24);
+ D->YUV.y = (s >> 16) & 0xff;
+ D->YUV.u = (s >> 8) & 0xff;
+ D->YUV.v = (s ) & 0xff;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static GenefxFunc Sop_PFI_Sto_Dacc[DFB_NUM_PIXELFORMATS] = {
+ Sop_argb1555_Sto_Dacc, /* DSPF_ARGB1555 */
+ Sop_rgb16_Sto_Dacc, /* DSPF_RGB16 */
+ Sop_rgb24_Sto_Dacc, /* DSPF_RGB24 */
+ Sop_rgb32_Sto_Dacc, /* DSPF_RGB32 */
+ Sop_argb_Sto_Dacc, /* DSPF_ARGB */
+ Sop_a8_Sto_Dacc, /* DSPF_A8 */
+ Sop_yuy2_Sto_Dacc, /* DSPF_YUY2 */
+ Sop_rgb332_Sto_Dacc, /* DSPF_RGB332 */
+ Sop_uyvy_Sto_Dacc, /* DSPF_UYVY */
+ Sop_i420_Sto_Dacc, /* DSPF_I420 */
+ Sop_i420_Sto_Dacc, /* DSPF_YV12 */
+ Sop_lut8_Sto_Dacc, /* DSPF_LUT8 */
+ Sop_alut44_Sto_Dacc, /* DSPF_ALUT44 */
+ Sop_airgb_Sto_Dacc, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ Sop_nv12_Sto_Dacc, /* DSPF_NV12 */
+ Sop_nv12_Sto_Dacc, /* DSPF_NV16 */
+ Sop_argb2554_Sto_Dacc, /* DSPF_ARGB2554 */
+ Sop_argb4444_Sto_Dacc, /* DSPF_ARGB4444 */
+ Sop_rgba4444_Sto_Dacc, /* DSPF_RGBA4444 */
+ Sop_nv21_Sto_Dacc, /* DSPF_NV21 */
+ Sop_ayuv_Sto_Dacc, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Sop_argb1666_Sto_Dacc, /* DSPF_ARGB1666 */
+ Sop_argb6666_Sto_Dacc, /* DSPF_ARGB6666 */
+ Sop_rgb18_Sto_Dacc, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Sop_xrgb4444_Sto_Dacc, /* DSPF_RGB444 */
+ Sop_xrgb1555_Sto_Dacc, /* DSPF_RGB555 */
+ Sop_xbgr1555_Sto_Dacc /* DSPF_BGR555 */
+};
+
+/********************************* Sop_PFI_SKto_Dacc **************************/
+
+static void Sop_argb6666_SKto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u32 Skey = gfxs->Skey;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ u8 s0 = S[pixelstart+0];
+ u8 s1 = S[pixelstart+1];
+ u8 s2 = S[pixelstart+2];
+
+ if (Skey != ((u32)(s2<<16 | s1<<8 | s0) & 0x3FFFF)) {
+ u8 b = s0 & 0x3F;
+ u8 g = ((s0 & 0xC0) >> 6) | ((s1 & 0x0F) << 2);
+ u8 r = ((s1 & 0xF0) >> 4) | ((s2 & 0x03) << 4);
+ u8 a = (s2 & 0xFC) >> 2;
+
+ D->RGB.a = EXPAND_6to8( a );
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+ }
+ else
+ D->RGB.a = 0xFF00;
+
+ i += SperD;
+ D++;
+ }
+}
+
+static void Sop_argb1666_SKto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ u8 s0 = S[pixelstart+0];
+ u8 s1 = S[pixelstart+1];
+ u8 s2 = S[pixelstart+2];
+
+ if (Skey != ((u32)(s2<<16 | s1<<8 | s0) & 0x3FFFF)) {
+ u8 b = s0 & 0x3F;
+ u8 g = ((s0 & 0xC0) >> 6) | ((s1 & 0x0F) << 2);
+ u8 r = ((s1 & 0xF0) >> 4) | ((s2 & 0x03) << 4);
+ u8 a = (s2 & 0x04) >> 2;
+
+ D->RGB.a = EXPAND_1to8( a );
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+ }
+ else
+ D->RGB.a = 0xFF00;
+ i += SperD;
+ D++;
+ }
+}
+
+static void Sop_rgb18_SKto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u32 Skey = gfxs->Skey;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ u8 s0 = S[pixelstart+0];
+ u8 s1 = S[pixelstart+1];
+ u8 s2 = S[pixelstart+2];
+
+ if (Skey != ((u32)(s2<<16 | s1<<8 | s0) & 0x3FFFF)) {
+ u8 b = s0 & 0x3F;
+ u8 g = ((s0 & 0xC0) >> 6) | ((s1 & 0x0F) << 2);
+ u8 r = ((s1 & 0xF0) >> 4) | ((s2 & 0x03) << 4);
+
+ D->RGB.a = 0xFF;
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+ }
+ else
+ D->RGB.a = 0xFF00;
+
+ i += SperD;
+ D++;
+ }
+}
+
+static void Sop_rgb24_SKto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ while (w--) {
+ int pixelstart = (i>>16)*3;
+
+ u8 b = S[pixelstart+0];
+ u8 g = S[pixelstart+1];
+ u8 r = S[pixelstart+2];
+
+ if (Skey != (u32)(r<<16 | g<<8 | b)) {
+ D->RGB.a = 0xFF;
+ D->RGB.r = r;
+ D->RGB.g = g;
+ D->RGB.b = b;
+ }
+ else
+ D->RGB.a = 0xFF00;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_a8_SKto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ /* no color to key */
+ while (w--) {
+ u8 s = S[i>>16];
+
+ D->RGB.a = s;
+ D->RGB.r = 0xFF;
+ D->RGB.g = 0xFF;
+ D->RGB.b = 0xFF;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_lut8_SKto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ DFBColor *entries = gfxs->Slut->entries;
+
+ while (w--) {
+ u8 s = S[i>>16];
+
+ if (s != Skey) {
+ D->RGB.a = entries[s].a;
+ D->RGB.r = entries[s].r;
+ D->RGB.g = entries[s].g;
+ D->RGB.b = entries[s].b;
+ }
+ else
+ D->RGB.a = 0xF000;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_alut44_SKto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ DFBColor *entries = gfxs->Slut->entries;
+
+ while (w--) {
+ u8 s = S[i>>16];
+
+ if ((s & 0x0F) != Skey) {
+ D->RGB.a = ((s & 0xF0) >> 4) | (s & 0xF0);
+ s &= 0x0F;
+ D->RGB.r = entries[s].r;
+ D->RGB.g = entries[s].g;
+ D->RGB.b = entries[s].b;
+ }
+ else
+ D->RGB.a = 0xF000;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_yuy2_SKto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u32 Ky = (gfxs->Skey & 0x000000FF);
+#ifdef WORDS_BIGENDIAN
+ u32 Kcb = (gfxs->Skey & 0xFF000000) >> 24;
+ u32 Kcr = (gfxs->Skey & 0x0000FF00) >> 8;
+#else
+ u32 Kcb = (gfxs->Skey & 0x0000FF00) >> 8;
+ u32 Kcr = (gfxs->Skey & 0xFF000000) >> 24;
+#endif
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u32 s = S[i>>17];
+ u32 y0, cb, y1, cr;
+
+#ifdef WORDS_BIGENDIAN
+ cb = (s & 0xFF000000) >> 24;
+ cr = (s & 0x0000FF00) >> 8;
+#else
+ cb = (s & 0x0000FF00) >> 8;
+ cr = (s & 0xFF000000) >> 24;
+#endif
+ y0 = ((u16*)S)[i>>16] & 0x00FF;
+ y1 = ((u16*)S)[(i+SperD)>>16] & 0x00FF;
+
+ if (y0 != Ky || cb != Kcb || cr != Kcr) {
+ D[0].YUV.a = 0xFF;
+ D[0].YUV.y = y0;
+ D[0].YUV.u = cb;
+ D[0].YUV.v = cr;
+ }
+ else
+ D[0].YUV.a = 0xF000;
+
+ if (y0 != Ky || cb != Kcb || cr != Kcr) {
+ D[1].YUV.a = 0xFF;
+ D[1].YUV.y = y1;
+ D[1].YUV.u = cb;
+ D[1].YUV.v = cr;
+ }
+ else
+ D[1].YUV.a = 0xF000;
+
+ D += 2;
+ i += SperD << 1;
+ }
+
+ if (gfxs->length & 1) {
+ u16 s = ((u16*)S)[i>>16];
+
+ if (s != (Ky | (Kcb << 8))) {
+ D->YUV.a = 0xFF;
+ D->YUV.y = s & 0xFF;
+ D->YUV.u = s >> 8;
+ D->YUV.v = 0x00;
+ }
+ else
+ D->YUV.a = 0xF000;
+ }
+}
+
+static void Sop_rgb332_SKto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u8 Skey = gfxs->Skey;
+
+ while (w--) {
+ u8 s = S[i>>16];
+
+ if (s != Skey) {
+ D->RGB.a = 0xFF;
+ D->RGB.r = EXPAND_3to8(s >> 5);
+ D->RGB.g = EXPAND_3to8((s & 0x1C) >> 2);
+ D->RGB.b = EXPAND_2to8(s & 0x03);
+ }
+ else
+ D->RGB.a = 0xF000;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
+static void Sop_uyvy_SKto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u32 Ky = (gfxs->Skey & 0x0000FF00) >> 8;
+#ifdef WORDS_BIGENDIAN
+ u32 Kcb = (gfxs->Skey & 0x00FF0000) >> 16;
+ u32 Kcr = (gfxs->Skey & 0x000000FF);
+#else
+ u32 Kcb = (gfxs->Skey & 0x000000FF);
+ u32 Kcr = (gfxs->Skey & 0x00FF0000) >> 16;
+#endif
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u32 s = S[i>>17];
+ u32 cb, y0, cr, y1;
+
+#ifdef WORDS_BIGENDIAN
+ cb = (s & 0x00FF0000) >> 16;
+ cr = (s & 0x000000FF);
+#else
+ cb = (s & 0x000000FF);
+ cr = (s & 0x00FF0000) >> 16;
+#endif
+ y0 = (((u16*)S)[i>>16] & 0xFF00) >> 8;
+ y1 = (((u16*)S)[(i+SperD)>>16] & 0xFF00) >> 8;
+
+ if (y0 != Ky || cb != Kcb || cr != Kcr) {
+ D[0].YUV.a = 0xFF;
+ D[0].YUV.y = y0;
+ D[0].YUV.u = cb;
+ D[0].YUV.v = cr;
+ }
+ else
+ D[0].YUV.a = 0xF000;
+
+ if (y0 != Ky || cb != Kcb || cr != Kcr) {
+ D[1].YUV.a = 0xFF;
+ D[1].YUV.y = y1;
+ D[1].YUV.u = cb;
+ D[1].YUV.v = cr;
+ }
+ else
+ D[1].YUV.a = 0xF000;
+
+ D += 2;
+ i += SperD << 1;
+ }
+
+ if (gfxs->length & 1) {
+ u16 s = ((u16*)S)[i>>16];
+
+ if (s != (Kcb | (Ky << 8))) {
+ D->YUV.a = 0xFF;
+ D->YUV.y = s >> 8;
+ D->YUV.u = s & 0xFF;
+ D->YUV.v = 0x00;
+ }
+ else
+ D->YUV.a = 0xF000;
+ }
+}
+
+static GenefxFunc Sop_PFI_SKto_Dacc[DFB_NUM_PIXELFORMATS] = {
+ Sop_argb1555_SKto_Dacc, /* DSPF_ARGB1555 */
+ Sop_rgb16_SKto_Dacc, /* DSPF_RGB16 */
+ Sop_rgb24_SKto_Dacc, /* DSPF_RGB24 */
+ Sop_rgb32_SKto_Dacc, /* DSPF_RGB32 */
+ Sop_argb_SKto_Dacc, /* DSPF_ARGB */
+ Sop_a8_SKto_Dacc, /* DSPF_A8 */
+ Sop_yuy2_SKto_Dacc, /* DSPF_YUY2 */
+ Sop_rgb332_SKto_Dacc, /* DSPF_RGB332 */
+ Sop_uyvy_SKto_Dacc, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ Sop_lut8_SKto_Dacc, /* DSPF_LUT8 */
+ Sop_alut44_SKto_Dacc, /* DSPF_ALUT44 */
+ Sop_airgb_SKto_Dacc, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Sop_argb2554_SKto_Dacc, /* DSPF_ARGB2554 */
+ Sop_argb4444_SKto_Dacc, /* DSPF_ARGB4444 */
+ Sop_rgba4444_SKto_Dacc, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ NULL, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Sop_argb1666_SKto_Dacc, /* DSPF_ARGB1666 */
+ Sop_argb6666_SKto_Dacc, /* DSPF_ARGB6666 */
+ Sop_rgb18_SKto_Dacc, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Sop_xrgb4444_SKto_Dacc, /* DSPF_RGB444 */
+ Sop_xrgb1555_SKto_Dacc, /* DSPF_RGB555 */
+ Sop_xbgr1555_SKto_Dacc /* DSPF_BGR555 */
+};
+
+/********************************* Sop_PFI_to_Dacc ****************************/
+
+static void Sop_argb6666_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u8 b = S[0] & 0x3F;
+ u8 g = ((S[0] & 0xC0) >> 6) | ((S[1] & 0x0F) << 2);
+ u8 r = ((S[1] & 0xF0) >> 4) | ((S[2] & 0x03) << 4);
+ u8 a = (S[2] & 0xFC) >> 2;
+
+ D->RGB.a = EXPAND_6to8( a );
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+
+ S +=3;
+ D++;
+ }
+}
+
+static void Sop_argb1666_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u8 b = S[0] & 0x3F;
+ u8 g = ((S[0] & 0xC0) >> 6) | ((S[1] & 0x0F) << 2);
+ u8 r = ((S[1] & 0xF0) >> 4) | ((S[2] & 0x03) << 4);
+ u8 a = (S[2] & 0x04) >> 2;
+
+ D->RGB.a = EXPAND_1to8( a );
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+
+ S +=3;
+ D++;
+ }
+}
+
+static void Sop_rgb18_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u8 b = S[0] & 0x3F;
+ u8 g = ((S[0] & 0xC0) >> 6) | ((S[1] & 0x0F) << 2);
+ u8 r = ((S[1] & 0xF0) >> 4) | ((S[2] & 0x03) << 4);
+
+ D->RGB.a = 0xFF;
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+
+ S +=3;
+ D++;
+ }
+}
+
+static void Sop_rgb24_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ D->RGB.a = 0xFF;
+ D->RGB.b = *S++;
+ D->RGB.g = *S++;
+ D->RGB.r = *S++;
+
+ D++;
+ }
+}
+
+static void Sop_a8_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ D->RGB.a = *S++;
+ D->RGB.r = 0xFF;
+ D->RGB.g = 0xFF;
+ D->RGB.b = 0xFF;
+
+ D++;
+ }
+}
+
+static void Sop_a4_to_Dacc( GenefxState *gfxs )
+{
+ int i, n;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ for (i=0, n=0; i<gfxs->length; i+=2, n++) {
+ register int left = S[n] & 0xF0;
+ register int right = S[n] & 0x0F;
+
+ D[i].RGB.a = left | (left >> 4);
+ D[i].RGB.r = 0xFF;
+ D[i].RGB.g = 0xFF;
+ D[i].RGB.b = 0xFF;
+
+ D[i+1].RGB.a = right | (right << 4);
+ D[i+1].RGB.r = 0xFF;
+ D[i+1].RGB.g = 0xFF;
+ D[i+1].RGB.b = 0xFF;
+ }
+}
+
+static void Sop_yuy2_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u32 s = *S++;
+
+ D[0].YUV.a = D[1].YUV.a = 0xFF;
+#ifdef WORDS_BIGENDIAN
+ D[0].YUV.y = (s & 0x00FF0000) >> 16;
+ D[1].YUV.y = (s & 0x000000FF);
+ D[0].YUV.u = D[1].YUV.u = (s & 0xFF000000) >> 24;
+ D[0].YUV.v = D[1].YUV.v = (s & 0x0000FF00) >> 8;
+#else
+ D[0].YUV.y = (s & 0x000000FF);
+ D[1].YUV.y = (s & 0x00FF0000) >> 16;
+ D[0].YUV.u = D[1].YUV.u = (s & 0x0000FF00) >> 8;
+ D[0].YUV.v = D[1].YUV.v = (s & 0xFF000000) >> 24;
+#endif
+
+ D += 2;
+ }
+
+ if (gfxs->length & 1) {
+ u16 s = *((u16*)S);
+
+ D->YUV.a = 0xFF;
+ D->YUV.y = s & 0xFF;
+ D->YUV.u = s >> 8;
+ D->YUV.v = 0x00;
+ }
+}
+
+static void Sop_rgb332_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u8 s = *S++;
+
+ D->RGB.a = 0xFF;
+ D->RGB.r = EXPAND_3to8(s >> 5);
+ D->RGB.g = EXPAND_3to8((s & 0x1C) >> 2);
+ D->RGB.b = EXPAND_2to8(s & 0x03);
+
+ D++;
+ }
+}
+
+static void Sop_uyvy_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u32 s = *S++;
+
+ D[0].YUV.a = D[1].YUV.a = 0xFF;
+#ifdef WORDS_BIGENDIAN
+ D[0].YUV.y = (s & 0xFF000000) >> 24;
+ D[1].YUV.y = (s & 0x0000FF00) >> 8;
+ D[0].YUV.u = D[1].YUV.u = (s & 0x00FF0000) >> 16;
+ D[0].YUV.v = D[1].YUV.v = (s & 0x000000FF);
+#else
+ D[0].YUV.y = (s & 0x0000FF00) >> 8;
+ D[1].YUV.y = (s & 0xFF000000) >> 24;
+ D[0].YUV.u = D[1].YUV.u = (s & 0x000000FF);
+ D[0].YUV.v = D[1].YUV.v = (s & 0x00FF0000) >> 16;
+#endif
+
+ D += 2;
+ }
+
+ if (gfxs->length & 1) {
+ u16 s = *((u16*)S);
+
+ D->YUV.a = 0xFF;
+ D->YUV.y = s >> 8;
+ D->YUV.u = s & 0xFF;
+ D->YUV.v = 0x00;
+ }
+}
+
+static void Sop_lut8_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ DFBColor *entries = gfxs->Slut->entries;
+
+ while (w--) {
+ u8 s = *S++;
+
+ D->RGB.a = entries[s].a;
+ D->RGB.r = entries[s].r;
+ D->RGB.g = entries[s].g;
+ D->RGB.b = entries[s].b;
+
+ D++;
+ }
+}
+
+static void Sop_alut44_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ DFBColor *entries = gfxs->Slut->entries;
+
+ while (w--) {
+ u8 s = *S++;
+
+ D->RGB.a = s & 0xF0;
+ s &= 0x0F;
+ D->RGB.r = entries[s].r;
+ D->RGB.g = entries[s].g;
+ D->RGB.b = entries[s].b;
+
+ D++;
+ }
+}
+
+static void Sop_i420_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *Sy = gfxs->Sop[0];
+ u8 *Su = gfxs->Sop[1];
+ u8 *Sv = gfxs->Sop[2];
+
+ while (w--) {
+ D[1].YUV.a = D[0].YUV.a = 0xFF;
+ D[0].YUV.y = Sy[0];
+ D[1].YUV.y = Sy[1];
+ D[1].YUV.u = D[0].YUV.u = Su[0];
+ D[1].YUV.v = D[0].YUV.v = Sv[0];
+
+ Sy += 2;
+ Su++;
+ Sv++;
+
+ D += 2;
+ }
+}
+
+static void Sop_nv12_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *Sy = gfxs->Sop[0];
+ u16 *Suv = gfxs->Sop[1];
+
+ while (w--) {
+ D[1].YUV.a = D[0].YUV.a = 0xFF;
+ D[0].YUV.y = Sy[0];
+ D[1].YUV.y = Sy[1];
+ D[1].YUV.u = D[0].YUV.u = Suv[0] & 0xFF;
+ D[1].YUV.v = D[0].YUV.v = Suv[0] >> 8;
+
+ Sy += 2;
+ Suv++;
+
+ D += 2;
+ }
+}
+
+static void Sop_nv21_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *Sy = gfxs->Sop[0];
+ u16 *Svu = gfxs->Sop[1];
+
+ while (w--) {
+ D[1].YUV.a = D[0].YUV.a = 0xFF;
+ D[0].YUV.y = Sy[0];
+ D[1].YUV.y = Sy[1];
+ D[1].YUV.u = D[0].YUV.u = Svu[0] >> 8;
+ D[1].YUV.v = D[0].YUV.v = Svu[0] & 0xFF;
+
+ Sy += 2;
+ Svu++;
+
+ D += 2;
+ }
+}
+
+static void Sop_ayuv_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 *S = gfxs->Sop[0];
+
+ while (w--) {
+ u32 s = *S++;
+
+ D->YUV.a = (s >> 24);
+ D->YUV.y = (s >> 16) & 0xff;
+ D->YUV.u = (s >> 8) & 0xff;
+ D->YUV.v = (s ) & 0xff;
+
+ D++;
+ }
+}
+
+static GenefxFunc Sop_PFI_to_Dacc[DFB_NUM_PIXELFORMATS] = {
+ Sop_argb1555_to_Dacc, /* DSPF_ARGB1555 */
+ Sop_rgb16_to_Dacc, /* DSPF_RGB16 */
+ Sop_rgb24_to_Dacc, /* DSPF_RGB24 */
+ Sop_rgb32_to_Dacc, /* DSPF_RGB32 */
+ Sop_argb_to_Dacc, /* DSPF_ARGB */
+ Sop_a8_to_Dacc, /* DSPF_A8 */
+ Sop_yuy2_to_Dacc, /* DSPF_YUY2 */
+ Sop_rgb332_to_Dacc, /* DSPF_RGB332 */
+ Sop_uyvy_to_Dacc, /* DSPF_UYVY */
+ Sop_i420_to_Dacc, /* DSPF_I420 */
+ Sop_i420_to_Dacc, /* DSPF_YV12 */
+ Sop_lut8_to_Dacc, /* DSPF_LUT8 */
+ Sop_alut44_to_Dacc, /* DSPF_ALUT44 */
+ Sop_airgb_to_Dacc, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ Sop_nv12_to_Dacc, /* DSPF_NV12 */
+ Sop_nv12_to_Dacc, /* DSPF_NV16 */
+ Sop_argb2554_to_Dacc, /* DSPF_ARGB2554 */
+ Sop_argb4444_to_Dacc, /* DSPF_ARGB4444 */
+ Sop_rgba4444_to_Dacc, /* DSPF_RGBA4444 */
+ Sop_nv21_to_Dacc, /* DSPF_NV21 */
+ Sop_ayuv_to_Dacc, /* DSPF_AYUV */
+ Sop_a4_to_Dacc, /* DSPF_A4 */
+ Sop_argb1666_to_Dacc, /* DSPF_ARGB1666 */
+ Sop_argb6666_to_Dacc, /* DSPF_ARGB6666 */
+ Sop_rgb18_to_Dacc, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Sop_xrgb4444_to_Dacc, /* DSPF_RGB444 */
+ Sop_xrgb1555_to_Dacc, /* DSPF_RGB555 */
+ Sop_xbgr1555_to_Dacc, /* DSPF_BGR555 */
+};
+
+/********************************* Sop_PFI_Kto_Dacc ***************************/
+
+static void Sop_argb6666_Kto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ while (w--) {
+ u8 s0 = S[0];
+ u8 s1 = S[1];
+ u8 s2 = S[2];
+
+ if (Skey != ((u32)(s2<<16 | s1<<8 | s0) & 0x3FFFF)) {
+ u8 b = s0 & 0x3F;
+ u8 g = ((s0 & 0xC0) >> 6) | ((s1 & 0x0F) << 2);
+ u8 r = ((s1 & 0xF0) >> 4) | ((s2 & 0x03) << 4);
+ u8 a = (s2 & 0xFC) >> 2;
+
+ D->RGB.a = EXPAND_6to8( a );
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+ }
+ else
+ D->RGB.a = 0xF000;
+
+ S += 3;
+ D++;
+ }
+}
+
+static void Sop_argb1666_Kto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ while (w--) {
+ u8 s0 = S[0];
+ u8 s1 = S[1];
+ u8 s2 = S[2];
+
+ if (Skey != ((u32)(s2<<16 | s1<<8 | s0) & 0x3FFFF)) {
+ u8 b = s0 & 0x3F;
+ u8 g = ((s0 & 0xC0) >> 6) | ((s1 & 0x0F) << 2);
+ u8 r = ((s1 & 0xF0) >> 4) | ((s2 & 0x03) << 4);
+ u8 a = (s2 & 0x04) >> 2;
+
+ D->RGB.a = EXPAND_1to8( a );
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+ }
+ else
+ D->RGB.a = 0xF000;
+
+ S += 3;
+ D++;
+ }
+}
+
+static void Sop_rgb18_Kto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ while (w--) {
+ u8 s0 = S[0];
+ u8 s1 = S[1];
+ u8 s2 = S[2];
+
+ if (Skey != ((u32)(s2<<16 | s1<<8 | s0) & 0x3ffff)) {
+ u8 b = s0 & 0x3F;
+ u8 g = ((s0 & 0xC0) >> 6) | ((s1 & 0x0F) << 2);
+ u8 r = ((s1 & 0xF0) >> 4) | ((s2 & 0x03) << 4);
+
+ D->RGB.a = 0xFF;
+ D->RGB.r = EXPAND_6to8( r );
+ D->RGB.g = EXPAND_6to8( g );
+ D->RGB.b = EXPAND_6to8( b );
+ }
+ else
+ D->RGB.a = 0xF000;
+
+ S += 3;
+ D++;
+ }
+}
+
+static void Sop_rgb24_Kto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ while (w--) {
+ u8 b = *S++;
+ u8 g = *S++;
+ u8 r = *S++;
+
+ if (Skey != (u32)(r<<16 | g<<8 | b)) {
+ D->RGB.a = 0xFF;
+ D->RGB.r = r;
+ D->RGB.g = g;
+ D->RGB.b = b;
+ }
+ else
+ D->RGB.a = 0xF000;
+
+ D++;
+ }
+}
+
+static void Sop_a8_Kto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+
+ /* no color to key */
+ while (w--) {
+ D->RGB.a = *S++;
+ D->RGB.r = 0xFF;
+ D->RGB.g = 0xFF;
+ D->RGB.b = 0xFF;
+
+ D++;
+ }
+}
+
+static void Sop_yuy2_Kto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+ u32 Skey0 = gfxs->Skey & 0xFF00FFFF;
+ u32 Skey1 = gfxs->Skey & 0xFFFFFF00;
+
+#ifdef WORDS_BIGENDIAN
+#define S0_MASK 0xFFFFFF00
+#define S1_MASK 0xFF00FFFF
+#else
+#define S0_MASK 0xFF00FFFF
+#define S1_MASK 0xFFFFFF00
+#endif
+
+ while (w--) {
+ u32 s = *S++;
+
+ if (s != Skey) {
+ u32 cb, cr;
+
+#ifdef WORDS_BIGENDIAN
+ cb = (s & 0xFF000000) >> 24;
+ cr = (s & 0x0000FF00) >> 8;
+#else
+ cb = (s & 0x0000FF00) >> 8;
+ cr = (s & 0xFF000000) >> 24;
+#endif
+
+ if ((s & S0_MASK) != Skey0) {
+ D[0].YUV.a = 0xFF;
+#ifdef WORDS_BIGENDIAN
+ D[0].YUV.y = (s & 0x00FF0000) >> 16;
+#else
+ D[0].YUV.y = (s & 0x000000FF);
+#endif
+ D[0].YUV.u = cb;
+ D[0].YUV.v = cr;
+ }
+ else
+ D[0].YUV.a = 0xF000;
+
+ if ((s & S1_MASK) != Skey1) {
+ D[1].YUV.a = 0xFF;
+#ifdef WORDS_BIGENDIAN
+ D[1].YUV.y = (s & 0x000000FF);
+#else
+ D[1].YUV.y = (s & 0x00FF0000) >> 16;
+#endif
+ D[1].YUV.u = cb;
+ D[1].YUV.v = cr;
+ }
+ else
+ D[1].YUV.a = 0xF000;
+ }
+
+ D += 2;
+ }
+
+ if (gfxs->length & 1) {
+ u16 s = *((u16*)S);
+
+ if (s != Skey0) {
+ D->YUV.a = 0xFF;
+ D->YUV.y = s & 0xFF;
+ D->YUV.u = s >> 8;
+ D->YUV.v = 0x00;
+ }
+ else
+ D->YUV.a = 0xF000;
+ }
+#undef S0_MASK
+#undef S1_MASK
+}
+
+static void Sop_rgb332_Kto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ while (w--) {
+ u8 s = *S++;
+
+ if (s != Skey) {
+ D->RGB.a = 0xFF;
+ D->RGB.r = EXPAND_3to8(s >> 5);
+ D->RGB.g = EXPAND_3to8((s & 0x1C) >> 2);
+ D->RGB.b = EXPAND_2to8(s & 0x03);
+ }
+ else
+ D->RGB.a = 0xF000;
+
+ D++;
+ }
+}
+
+static void Sop_uyvy_Kto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+ u32 Skey0 = gfxs->Skey & 0x00FFFFFF;
+ u32 Skey1 = gfxs->Skey & 0xFFFF00FF;
+
+#ifdef WORDS_BIGENDIAN
+#define S0_MASK 0xFFFF00FF
+#define S1_MASK 0x00FFFFFF
+#else
+#define S0_MASK 0x00FFFFFF
+#define S1_MASK 0xFFFF00FF
+#endif
+
+ while (w--) {
+ u32 s = *S++;
+
+ if (s != Skey) {
+ u32 cb, cr;
+
+#ifdef WORDS_BIGENDIAN
+ cb = (s & 0x00FF0000) >> 16;
+ cr = (s & 0x000000FF);
+#else
+ cb = (s & 0x000000FF);
+ cr = (s & 0x00FF0000) >> 16;
+#endif
+
+ if ((s & S0_MASK) != Skey0) {
+ D[0].YUV.a = 0xFF;
+#ifdef WORDS_BIGENDIAN
+ D[0].YUV.y = (s & 0xFF000000) >> 24;
+#else
+ D[0].YUV.y = (s & 0x0000FF00) >> 8;
+#endif
+ D[0].YUV.u = cb;
+ D[0].YUV.v = cr;
+ }
+ else
+ D[0].YUV.a = 0xF000;
+
+ if ((s & S1_MASK) != Skey1) {
+ D[1].YUV.a = 0xFF;
+#ifdef WORDS_BIGENDIAN
+ D[1].YUV.y = (s & 0x0000FF00) >> 8;
+#else
+ D[1].YUV.y = (s & 0xFF000000) >>24;
+#endif
+ D[1].YUV.u = cb;
+ D[1].YUV.v = cr;
+ }
+ else
+ D[1].YUV.a = 0xF000;
+ }
+
+ D += 2;
+ }
+
+ if (gfxs->length & 1) {
+ u16 s = *((u16*)S);
+
+ if (s != Skey0) {
+ D->YUV.a = 0xFF;
+ D->YUV.y = s >> 8;
+ D->YUV.u = s & 0xFF;
+ D->YUV.v = 0x00;
+ }
+ else
+ D->YUV.a = 0xF000;
+ }
+#undef S0_MASK
+#undef S1_MASK
+}
+
+static void Sop_lut8_Kto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ DFBColor *entries = gfxs->Slut->entries;
+
+ while (w--) {
+ u8 s = *S++;
+
+ if (s != Skey) {
+ D->RGB.a = entries[s].a;
+ D->RGB.r = entries[s].r;
+ D->RGB.g = entries[s].g;
+ D->RGB.b = entries[s].b;
+ }
+ else
+ D->RGB.a = 0xF000;
+
+ D++;
+ }
+}
+
+static void Sop_alut44_Kto_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u8 *S = gfxs->Sop[0];
+ u32 Skey = gfxs->Skey;
+
+ DFBColor *entries = gfxs->Slut->entries;
+
+ while (w--) {
+ u8 s = *S++;
+
+ if ((s & 0x0F) != Skey) {
+ D->RGB.a = ((s & 0xF0) >> 4) | (s & 0xF0);
+ s &= 0x0F;
+ D->RGB.r = entries[s].r;
+ D->RGB.g = entries[s].g;
+ D->RGB.b = entries[s].b;
+ }
+ else
+ D->RGB.a = 0xF000;
+
+ D++;
+ }
+}
+
+static GenefxFunc Sop_PFI_Kto_Dacc[DFB_NUM_PIXELFORMATS] = {
+ Sop_argb1555_Kto_Dacc, /* DSPF_ARGB1555 */
+ Sop_rgb16_Kto_Dacc, /* DSPF_RGB16 */
+ Sop_rgb24_Kto_Dacc, /* DSPF_RGB24 */
+ Sop_rgb32_Kto_Dacc, /* DSPF_RGB32 */
+ Sop_argb_Kto_Dacc, /* DSPF_ARGB */
+ Sop_a8_Kto_Dacc, /* DSPF_A8 */
+ Sop_yuy2_Kto_Dacc, /* DSPF_YUY2 */
+ Sop_rgb332_Kto_Dacc, /* DSPF_RGB332 */
+ Sop_uyvy_Kto_Dacc, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ Sop_lut8_Kto_Dacc, /* DSPF_LUT8 */
+ Sop_alut44_Kto_Dacc, /* DSPF_ALUT44 */
+ Sop_airgb_Kto_Dacc, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Sop_argb2554_Kto_Dacc, /* DSPF_ARGB2554 */
+ Sop_argb4444_Kto_Dacc, /* DSPF_ARGB4444 */
+ Sop_rgba4444_Kto_Dacc, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ NULL, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Sop_argb6666_Kto_Dacc, /* DSPF_ARGB1666 */
+ Sop_argb1666_Kto_Dacc, /* DSPF_ARGB6666 */
+ Sop_rgb18_Kto_Dacc, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Sop_xrgb4444_Kto_Dacc, /* DSPF_RGB444 */
+ Sop_xrgb1555_Kto_Dacc, /* DSPF_RGB555 */
+ Sop_xbgr1555_Kto_Dacc, /* DSPF_BGR555 */
+};
+
+/********************************* Sacc_to_Aop_PFI ****************************/
+
+static void Sacc_to_Aop_argb6666( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000)) {
+ u32 pixel = PIXEL_ARGB6666( (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D +=3;
+ S++;
+ }
+}
+
+static void Sacc_to_Aop_argb1666( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000)) {
+ u32 pixel = PIXEL_ARGB1666( (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D +=3;
+ S++;
+ }
+}
+
+static void Sacc_to_Aop_rgb18( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000)) {
+ u32 pixel = PIXEL_RGB18( (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D +=3;
+ S++;
+ }
+}
+
+static void Sacc_to_Aop_rgb24( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000)) {
+ *D++ = (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b;
+ *D++ = (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g;
+ *D++ = (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r;
+ }
+ else
+ D += 3;
+
+ S++;
+ }
+}
+
+static void Sacc_to_Aop_a8( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000))
+ *D = (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a;
+
+ D++;
+ S++;
+ }
+}
+
+static void Sacc_to_Aop_yuy2( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u16 *D = gfxs->Aop[0];
+
+ if ((long)D & 2) {
+ if (!(S->YUV.a & 0xF00)) {
+ *D = ((S->YUV.y & 0xFF00) ? 0x00FF : S->YUV.y) |
+ ((S->YUV.v & 0xFF00) ? 0XFF00 : (S->YUV.v<<8));
+ }
+ S++;
+ D++;
+ w--;
+ }
+
+ for (l = w>>1; l--;) {
+ if (!(S[0].YUV.a & 0xF000) && !(S[1].YUV.a & 0xF000)) {
+ u32 y0, cb, y1, cr;
+
+ y0 = (S[0].YUV.y & 0xFF00) ? 0xFF : S[0].YUV.y;
+ y1 = (S[1].YUV.y & 0xFF00) ? 0xFF : S[1].YUV.y;
+
+ cb = (S[0].YUV.u + S[1].YUV.u) >> 1;
+ if (cb & 0xFF00)
+ cb = 0xFF;
+
+ cr = (S[0].YUV.v + S[1].YUV.v) >> 1;
+ if (cr & 0xFF00)
+ cr = 0xFF;
+
+#ifdef WORDS_BIGENDIAN
+ *((u32*)D) = y1 | (cr << 8) | (y0 << 16) | (cb << 24);
+#else
+ *((u32*)D) = y0 | (cb << 8) | (y1 << 16) | (cr << 24);
+#endif
+ }
+ else if (!(S[0].YUV.a & 0xF000)) {
+ D[0] = ((S[0].YUV.y & 0xFF00) ? 0x00FF : S[0].YUV.y) |
+ ((S[0].YUV.u & 0xFF00) ? 0xFF00 : (S[0].YUV.u<<8));
+ }
+ else if (!(S[1].YUV.a & 0xF000)) {
+ D[1] = ((S[1].YUV.y & 0xFF00) ? 0x00FF : S[1].YUV.y) |
+ ((S[1].YUV.v & 0xFF00) ? 0xFF00 : (S[1].YUV.v<<8));
+ }
+
+ D += 2;
+ S += 2;
+ }
+
+ if (w & 1) {
+ if (!(S->YUV.a & 0xF00)) {
+ *D = ((S->YUV.y & 0xFF00) ? 0x00FF : S->YUV.y) |
+ ((S->YUV.u & 0xFF00) ? 0xFF00 : (S->YUV.u<<8));
+ }
+ }
+}
+
+static void Sacc_to_Aop_rgb332( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000)) {
+ *D = PIXEL_RGB332( (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+ }
+
+ D++;
+ S++;
+ }
+}
+
+static void Sacc_to_Aop_uyvy( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u16 *D = gfxs->Aop[0];
+
+ if ((long)D & 2) {
+ if (!(S->YUV.a & 0xF00)) {
+ *D = ((S->YUV.v & 0xFF00) ? 0x00FF : S->YUV.v) |
+ ((S->YUV.y & 0xFF00) ? 0xFF00 : (S->YUV.y<<8));
+ }
+ S++;
+ D++;
+ w--;
+ }
+
+ for (l = w>>1; l--;) {
+ if (!(S[0].YUV.a & 0xF000) && !(S[1].YUV.a & 0xF000)) {
+ u32 cb, y0, cr, y1;
+
+ y0 = (S[0].YUV.y & 0xFF00) ? 0xFF : S[0].YUV.y;
+ y1 = (S[1].YUV.y & 0xFF00) ? 0xFF : S[1].YUV.y;
+
+ cb = (S[0].YUV.u + S[1].YUV.u) >> 1;
+ if (cb & 0xFF00)
+ cb = 0xFF;
+
+ cr = (S[0].YUV.v + S[1].YUV.v) >> 1;
+ if (cr & 0xFF00)
+ cr = 0xFF;
+
+#ifdef WORDS_BIGENDIAN
+ *((u32*)D) = cr | (y1 << 8) | (cb << 16) | (y0 << 24);
+#else
+ *((u32*)D) = cb | (y0 << 8) | (cr << 16) | (y1 << 24);
+#endif
+ }
+ else if (!(S[0].YUV.a & 0xF000)) {
+ D[0] = ((S[0].YUV.u & 0xFF00) ? 0x00FF : S[0].YUV.u) |
+ ((S[0].YUV.y & 0xFF00) ? 0xFF00 : (S[0].YUV.y<<8));
+ }
+ else if (!(S[1].YUV.a & 0xF000)) {
+ D[1] = ((S[1].YUV.v & 0xFF00) ? 0x00FF : S[1].YUV.v) |
+ ((S[1].YUV.y & 0xFF00) ? 0xFF00 : (S[1].YUV.y<<8));
+ }
+
+ D += 2;
+ S += 2;
+ }
+
+ if (w & 1) {
+ if (!(S->YUV.a & 0xF00)) {
+ *D = ((S->YUV.u & 0xFF00) ? 0x00FF : S->YUV.u) |
+ ((S->YUV.y & 0xFF00) ? 0xFF00 : (S->YUV.y<<8));
+ }
+ }
+}
+
+static void Sacc_to_Aop_lut8( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000)) {
+ *D = dfb_palette_search( gfxs->Alut,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b,
+ (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a );
+ }
+
+ D++;
+ S++;
+ }
+}
+
+static void Sacc_to_Aop_alut44( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000)) {
+ *D = (S->RGB.a & 0xFF00) ? 0xF0 : (S->RGB.a & 0xF0) +
+ dfb_palette_search( gfxs->Alut,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b,
+ 0x80 );
+ }
+
+ D++;
+ S++;
+ }
+}
+
+static void Sacc_to_Aop_i420( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *Dy = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->YUV.a & 0xF000))
+ *Dy = (S->YUV.y & 0xFF00) ? 0xFF : S->YUV.y;
+
+ S++;
+ Dy++;
+ }
+
+ if (gfxs->AopY & 1) {
+ u8 *Du = gfxs->Aop[1];
+ u8 *Dv = gfxs->Aop[2];
+
+ w = gfxs->length>>1;
+ S = gfxs->Sacc;
+
+ while (w--) {
+ if (!(S[0].YUV.a & 0xF000) && !(S[1].YUV.a & 0xF000)) {
+ u32 tmp;
+
+ tmp = (S[0].YUV.u + S[1].YUV.u) >> 1;
+ if (tmp & 0xFF00)
+ tmp = 0xFF;
+ *Du = tmp;
+
+ tmp = (S[0].YUV.v + S[1].YUV.v) >> 1;
+ if (tmp & 0xFF00)
+ tmp = 0xFF;
+ *Dv = tmp;
+
+ }
+ else if (!(S[0].YUV.a & 0xF000)) {
+ *Du = (*Du + ((S[0].YUV.u & 0xFF00) ? 0xFF : S[0].YUV.u)) >> 1;
+ *Dv = (*Dv + ((S[0].YUV.v & 0xFF00) ? 0xFF : S[0].YUV.v)) >> 1;
+ }
+ else if (!(S[1].YUV.a & 0xF000)) {
+ *Du = (*Du + ((S[1].YUV.u & 0xFF00) ? 0xFF : S[1].YUV.u)) >> 1;
+ *Dv = (*Dv + ((S[1].YUV.v & 0xFF00) ? 0xFF : S[1].YUV.v)) >> 1;
+ }
+
+ S += 2;
+ Du++;
+ Dv++;
+ }
+ }
+}
+
+static void Sacc_to_Aop_nv12( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *Dy = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->YUV.a & 0xF000))
+ *Dy = (S->YUV.y & 0xFF00) ? 0xFF : S->YUV.y;
+
+ S++;
+ Dy++;
+ }
+
+ if (gfxs->dst_format == DSPF_NV16 || gfxs->AopY & 1) {
+ u16 *Duv = gfxs->Aop[1];
+
+ w = gfxs->length>>1;
+ S = gfxs->Sacc;
+
+ while (w--) {
+ u32 cb, cr;
+
+ if (!(S[0].YUV.a & 0xF000) && !(S[1].YUV.a & 0xF000)) {
+ cb = (S[0].YUV.u + S[1].YUV.u) >> 1;
+ if (cb & 0xFF00)
+ cb = 0xFF;
+
+ cr = (S[0].YUV.v + S[1].YUV.v) >> 1;
+ if (cr & 0xFF00)
+ cr = 0xFF;
+
+#ifdef WORDS_BIGENDIAN
+ *Duv = cr | (cb << 8);
+ }
+ else if (!(S[0].YUV.a & 0xF000)) {
+ cb = ((*Duv >> 8) + ((S[0].YUV.u & 0xFF00) ? 0xFF : S[0].YUV.u)) >> 1;
+ cr = ((*Duv & 0xFF) + ((S[0].YUV.v & 0xFF00) ? 0xFF : S[0].YUV.v)) >> 1;
+ *Duv = cr | (cb << 8);
+ }
+ else if (!(S[1].YUV.a & 0xF000)) {
+ cb = ((*Duv >> 8) + ((S[1].YUV.u & 0xFF00) ? 0xFF : S[1].YUV.u)) >> 1;
+ cr = ((*Duv & 0xFF) + ((S[1].YUV.v & 0xFF00) ? 0xFF : S[1].YUV.v)) >> 1;
+ *Duv = cr | (cb << 8);
+ }
+#else
+ *Duv = cb | (cr << 8);
+ }
+ else if (!(S[0].YUV.a & 0xF000)) {
+ cb = ((*Duv & 0xFF) + ((S[0].YUV.u & 0xFF00) ? 0xFF : S[0].YUV.u)) >> 1;
+ cr = ((*Duv >> 8) + ((S[0].YUV.v & 0xFF00) ? 0xFF : S[0].YUV.v)) >> 1;
+ *Duv = cb | (cr << 8);
+ }
+ else if (!(S[1].YUV.a & 0xF000)) {
+ cb = ((*Duv & 0xFF) + ((S[1].YUV.u & 0xFF00) ? 0xFF : S[1].YUV.u)) >> 1;
+ cr = ((*Duv >> 8) + ((S[1].YUV.v & 0xFF00) ? 0xFF : S[1].YUV.v)) >> 1;
+ *Duv = cb | (cr << 8);
+ }
+#endif
+
+ S += 2;
+ Duv++;
+ }
+ }
+}
+
+static void Sacc_to_Aop_nv21( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *Dy = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->YUV.a & 0xF000))
+ *Dy = (S->YUV.y & 0xFF00) ? 0xFF : S->YUV.y;
+
+ S++;
+ Dy++;
+ }
+
+ if (gfxs->AopY & 1) {
+ u16 *Dvu = gfxs->Aop[1];
+
+ w = gfxs->length>>1;
+ S = gfxs->Sacc;
+
+ while (w--) {
+ u32 cb, cr;
+
+ if (!(S[0].YUV.a & 0xF000) && !(S[1].YUV.a & 0xF000)) {
+ cb = (S[0].YUV.u + S[1].YUV.u) >> 1;
+ if (cb & 0xFF00)
+ cb = 0xFF;
+
+ cr = (S[0].YUV.v + S[1].YUV.v) >> 1;
+ if (cr & 0xFF00)
+ cr = 0xFF;
+
+ *Dvu = cr | (cb << 8);
+ }
+ else if (!(S[0].YUV.a & 0xF000)) {
+ cb = ((*Dvu >> 8) + ((S[0].YUV.u & 0xFF00) ? 0xFF : S[0].YUV.u)) >> 1;
+ cr = ((*Dvu & 0xFF) + ((S[0].YUV.v & 0xFF00) ? 0xFF : S[0].YUV.v)) >> 1;
+ *Dvu = cr | (cb << 8);
+ }
+ else if (!(S[1].YUV.a & 0xF000)) {
+ cb = ((*Dvu >> 8) + ((S[1].YUV.u & 0xFF00) ? 0xFF : S[1].YUV.u)) >> 1;
+ cr = ((*Dvu & 0xFF) + ((S[1].YUV.v & 0xFF00) ? 0xFF : S[1].YUV.v)) >> 1;
+ *Dvu = cr | (cb << 8);
+ }
+
+ S += 2;
+ Dvu++;
+ }
+ }
+}
+
+static void Sacc_to_Aop_ayuv( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u32 *D = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S->YUV.a & 0xF000)) {
+ *D = PIXEL_AYUV( (S->YUV.a & 0xFF00) ? 0xFF : S->YUV.a,
+ (S->YUV.y & 0xFF00) ? 0xFF : S->YUV.y,
+ (S->YUV.u & 0xFF00) ? 0xFF : S->YUV.u,
+ (S->YUV.v & 0xFF00) ? 0xFF : S->YUV.v );
+ }
+
+ D++;
+ S++;
+ }
+}
+
+static void Sacc_to_Aop_a4( GenefxState *gfxs )
+{
+ int w = gfxs->length>>1;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+
+ while (w--) {
+ if (!(S[0].RGB.a & 0xF000) && !(S[1].RGB.a & 0xF000)) {
+ *D = ((S[0].RGB.a & 0xFF00) ? 0xF0 : (S[0].RGB.a & 0xF0)) |
+ ((S[1].RGB.a & 0XFF00) ? 0x0F : (S[1].RGB.a >> 4));
+ }
+ else if (!(S[0].RGB.a & 0xF000)) {
+ *D = (*D & 0x0F) | ((S[0].RGB.a & 0xFF00) ? 0xF0 : (S[0].RGB.a & 0xF0));
+ }
+ else if (!(S[1].RGB.a & 0xF000)) {
+ *D = (*D & 0xF0) | ((S[1].RGB.a & 0XFF00) ? 0x0F : (S[1].RGB.a >> 4));
+ }
+
+ D++;
+ S += 2;
+ }
+
+ if (gfxs->length & 1) {
+ if (!(S->RGB.a & 0xF000))
+ *D = (*D & 0x0F) | ((S->RGB.a & 0xFF00) ? 0xF0 : (S->RGB.a & 0xF0));
+ }
+}
+
+static GenefxFunc Sacc_to_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Sacc_to_Aop_argb1555, /* DSPF_ARGB1555 */
+ Sacc_to_Aop_rgb16, /* DSPF_RGB16 */
+ Sacc_to_Aop_rgb24, /* DSPF_RGB24 */
+ Sacc_to_Aop_rgb32, /* DSPF_RGB32 */
+ Sacc_to_Aop_argb, /* DSPF_ARGB */
+ Sacc_to_Aop_a8, /* DSPF_A8 */
+ Sacc_to_Aop_yuy2, /* DSPF_YUY2 */
+ Sacc_to_Aop_rgb332, /* DSPF_RGB332 */
+ Sacc_to_Aop_uyvy, /* DSPF_UYVY */
+ Sacc_to_Aop_i420, /* DSPF_I420 */
+ Sacc_to_Aop_i420, /* DSPF_YV12 */
+ Sacc_to_Aop_lut8, /* DSPF_LUT8 */
+ Sacc_to_Aop_alut44, /* DSPF_ALUT44 */
+ Sacc_to_Aop_airgb, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ Sacc_to_Aop_nv12, /* DSPF_NV12 */
+ Sacc_to_Aop_nv12, /* DSPF_NV16 */
+ Sacc_to_Aop_argb2554, /* DSPF_ARGB2554 */
+ Sacc_to_Aop_argb4444, /* DSPF_ARGB4444 */
+ Sacc_to_Aop_rgba4444, /* DSPF_RGBA4444 */
+ Sacc_to_Aop_nv21, /* DSPF_NV21 */
+ Sacc_to_Aop_ayuv, /* DSPF_AYUV */
+ Sacc_to_Aop_a4, /* DSPF_A4 */
+ Sacc_to_Aop_argb1666, /* DSPF_ARGB1666 */
+ Sacc_to_Aop_argb6666, /* DSPF_ARGB6666 */
+ Sacc_to_Aop_rgb18, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Sacc_to_Aop_xrgb4444, /* DSPF_RGB444 */
+ Sacc_to_Aop_xrgb1555, /* DSPF_RGB555 */
+ Sacc_to_Aop_xbgr1555, /* DSPF_BGR555 */
+};
+
+/********************************* Sacc_Sto_Aop_PFI ***************************/
+
+static void Sacc_Sto_Aop_argb6666( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000)) {
+ u32 pixel = PIXEL_ARGB6666( (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D +=3;
+ i += SperD;
+ }
+}
+
+static void Sacc_Sto_Aop_argb1666( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000)) {
+ u32 pixel = PIXEL_ARGB1666( (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D +=3;
+ i += SperD;
+ }
+}
+
+static void Sacc_Sto_Aop_rgb18( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000)) {
+ u32 pixel = PIXEL_RGB18( (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D +=3;
+ i += SperD;
+ }
+}
+
+static void Sacc_Sto_Aop_rgb24( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000)) {
+ *D++ = (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b;
+ *D++ = (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g;
+ *D++ = (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r;
+ }
+ else
+ D += 3;
+
+ i += SperD;
+ }
+}
+
+static void Sacc_Sto_Aop_a8( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000))
+ *D = (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a;
+
+ D++;
+ i += SperD;
+ }
+}
+
+static void Sacc_Sto_Aop_yuy2( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u16 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+ int SperD2 = gfxs->SperD << 1;
+
+ if ((long)D & 2) {
+ GenefxAccumulator *S = Sacc;
+ if (!(S->YUV.a & 0xF00)) {
+ *D = ((S->YUV.y & 0xFF00) ? 0x00FF : S->YUV.y) |
+ ((S->YUV.v & 0xFF00) ? 0XFF00 : (S->YUV.v<<8));
+ }
+ D++;
+ w--;
+ i = SperD;
+ }
+
+ for (l = w>>1; l--;) {
+ GenefxAccumulator *S0 = &Sacc[i>>16];
+ GenefxAccumulator *S1 = &Sacc[(i+SperD)>>16];
+
+ if (!(S0->YUV.a & 0xF000) && !(S1->YUV.a & 0xF000)) {
+ u32 y0, cb, y1, cr;
+
+ y0 = (S0->YUV.y & 0xFF00) ? 0xFF : S0->YUV.y;
+ y1 = (S1->YUV.y & 0xFF00) ? 0xFF : S1->YUV.y;
+
+ cb = (S0->YUV.u + S1->YUV.u) >> 1;
+ if (cb & 0xFF00)
+ cb = 0xFF;
+
+ cr = (S0->YUV.v + S1->YUV.v) >> 1;
+ if (cr & 0xFF00)
+ cr = 0xFF;
+
+#ifdef WORDS_BIGENDIAN
+ *((u32*)D) = y1 | (cr << 8) | (y0 << 16) | (cb << 24);
+#else
+ *((u32*)D) = y0 | (cb << 8) | (y1 << 16) | (cr << 24);
+#endif
+ }
+ else if (!(S0->YUV.a & 0xF000)) {
+ D[0] = ((S0->YUV.y & 0xFF00) ? 0x00FF : S0->YUV.y) |
+ ((S0->YUV.u & 0xFF00) ? 0xFF00 : (S0->YUV.u<<8));
+ }
+ else if (!(S1->YUV.a & 0xF000)) {
+ D[1] = ((S1->YUV.y & 0xFF00) ? 0x00FF : S1->YUV.y) |
+ ((S1->YUV.v & 0xFF00) ? 0xFF00 : (S1->YUV.v<<8));
+ }
+
+ D += 2;
+ i += SperD2;
+ }
+
+ if (w & 1) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+ if (!(S->YUV.a & 0xF00)) {
+ *D = ((S->YUV.y & 0xFF00) ? 0x00FF : S->YUV.y) |
+ ((S->YUV.u & 0xFF00) ? 0xFF00 : (S->YUV.u<<8));
+ }
+ }
+}
+
+static void Sacc_Sto_Aop_rgb332( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000)) {
+ *D = PIXEL_RGB332( (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+ }
+
+ D++;
+ i += SperD;
+ }
+}
+
+static void Sacc_Sto_Aop_uyvy( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u16 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+ int SperD2 = gfxs->SperD << 1;
+
+ if ((long)D & 2) {
+ GenefxAccumulator *S = Sacc;
+ if (!(S->YUV.a & 0xF00)) {
+ *D = ((S->YUV.v & 0xFF00) ? 0x00FF : S->YUV.v) |
+ ((S->YUV.y & 0xFF00) ? 0xFF00 : (S->YUV.y<<8));
+ }
+ D++;
+ w--;
+ i = SperD;
+ }
+
+ for (l = w>>1; l--;) {
+ GenefxAccumulator *S0 = &Sacc[i>>16];
+ GenefxAccumulator *S1 = &Sacc[(i+SperD)>>16];
+
+ if (!(S0->YUV.a & 0xF000) && !(S1->YUV.a & 0xF000)) {
+ u32 cb, y0, cr, y1;
+
+ y0 = (S0->YUV.y & 0xFF00) ? 0xFF : S0->YUV.y;
+ y1 = (S1->YUV.y & 0xFF00) ? 0xFF : S1->YUV.y;
+
+ cb = (S0->YUV.u + S1->YUV.u) >> 1;
+ if (cb & 0xFF00)
+ cb = 0xFF;
+
+ cr = (S0->YUV.v + S1->YUV.v) >> 1;
+ if (cr & 0xFF00)
+ cr = 0xFF;
+
+#ifdef WORDS_BIGENDIAN
+ *((u32*)D) = cr | (y1 << 8) | (cb << 16) | (y0 << 24);
+#else
+ *((u32*)D) = cb | (y0 << 8) | (cr << 16) | (y1 << 24);
+#endif
+ }
+ else if (!(S0->YUV.a & 0xF000)) {
+ D[0] = ((S0->YUV.u & 0xFF00) ? 0x00FF : S0->YUV.u) |
+ ((S0->YUV.y & 0xFF00) ? 0xFF00 : (S0->YUV.y<<8));
+ }
+ else if (!(S1->YUV.a & 0xF000)) {
+ D[1] = ((S1->YUV.v & 0xFF00) ? 0x00FF : S1->YUV.v) |
+ ((S1->YUV.y & 0xFF00) ? 0xFF00 : (S1->YUV.y<<8));
+ }
+
+ D += 2;
+ i += SperD2;
+ }
+
+ if (w & 1) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+ if (!(S->YUV.a & 0xF00)) {
+ *D = ((S->YUV.u & 0xFF00) ? 0x00FF : S->YUV.u) |
+ ((S->YUV.y & 0xFF00) ? 0xFF00 : (S->YUV.y<<8));
+ }
+ }
+}
+
+static void Sacc_Sto_Aop_lut8( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000)) {
+ *D = dfb_palette_search( gfxs->Alut,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b,
+ (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a );
+ }
+
+ D++;
+ i += SperD;
+ }
+}
+
+static void Sacc_Sto_Aop_alut44( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000)) {
+ *D = (S->RGB.a & 0xFF00) ? 0xF0 : (S->RGB.a & 0xF0) +
+ dfb_palette_search( gfxs->Alut,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b,
+ 0x80 );
+ }
+
+ D++;
+ i += SperD;
+ }
+}
+
+static void Sacc_Sto_Aop_i420( GenefxState *gfxs )
+{
+ int i = gfxs->Xphase;
+ int w = gfxs->length;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *Dy = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->YUV.a & 0xF000))
+ *Dy = (S->YUV.y & 0xFF00) ? 0xFF : S->YUV.y;
+
+ Dy++;
+ i += SperD;
+ }
+
+ if (gfxs->AopY & 1) {
+ u8 *Du = gfxs->Aop[1];
+ u8 *Dv = gfxs->Aop[2];
+
+ w = gfxs->length>>1;
+ i = gfxs->Xphase>>1;
+
+ while (w--) {
+ GenefxAccumulator *S0 = &Sacc[i>>16];
+ GenefxAccumulator *S1 = &Sacc[(i+SperD)>>16];
+
+ if (!(S0->YUV.a & 0xF000) && !(S1->YUV.a & 0xF000)) {
+ u32 tmp;
+
+ tmp = (S0->YUV.u + S1->YUV.u) >> 1;
+ if (tmp & 0xFF00)
+ tmp = 0xFF;
+ *Du = tmp;
+
+ tmp = (S0->YUV.v + S1->YUV.v) >> 1;
+ if (tmp & 0xFF00)
+ tmp = 0xFF;
+ *Dv = tmp;
+
+ }
+ else if (!(S0->YUV.a & 0xF000)) {
+ *Du = (*Du + ((S0->YUV.u & 0xFF00) ? 0xFF : S0->YUV.u)) >> 1;
+ *Dv = (*Dv + ((S0->YUV.v & 0xFF00) ? 0xFF : S0->YUV.v)) >> 1;
+ }
+ else if (!(S1->YUV.a & 0xF000)) {
+ *Du = (*Du + ((S1->YUV.u & 0xFF00) ? 0xFF : S1->YUV.u)) >> 1;
+ *Dv = (*Dv + ((S1->YUV.v & 0xFF00) ? 0xFF : S1->YUV.v)) >> 1;
+ }
+
+ Du++;
+ Dv++;
+ i += SperD << 1;
+ }
+ }
+}
+
+static void Sacc_Sto_Aop_nv12( GenefxState *gfxs )
+{
+ int i = gfxs->Xphase;
+ int w = gfxs->length;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *Dy = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->YUV.a & 0xF000))
+ *Dy = (S->YUV.y & 0xFF00) ? 0xFF : S->YUV.y;
+
+ Dy++;
+ i += SperD;
+ }
+
+ if (gfxs->dst_format == DSPF_NV16 || gfxs->AopY & 1) {
+ u16 *Duv = gfxs->Aop[1];
+
+ w = gfxs->length>>1;
+ i = gfxs->Xphase>>1;
+
+ while (w--) {
+ GenefxAccumulator *S0 = &Sacc[i>>16];
+ GenefxAccumulator *S1 = &Sacc[(i+SperD)>>16];
+ u32 cb, cr;
+
+ if (!(S0->YUV.a & 0xF000) && !(S1->YUV.a & 0xF000)) {
+ cb = (S0->YUV.u + S1->YUV.u) >> 1;
+ if (cb & 0xFF00)
+ cb = 0xFF;
+
+ cr = (S0->YUV.v + S1->YUV.v) >> 1;
+ if (cr & 0xFF00)
+ cr = 0xFF;
+
+#ifdef WORDS_BIGENDIAN
+ *Duv = cr | (cb << 8);
+ }
+ else if (!(S0->YUV.a & 0xF000)) {
+ cb = ((*Duv >> 8) + ((S0->YUV.u & 0xFF00) ? 0xFF : S0->YUV.u)) >> 1;
+ cr = ((*Duv & 0xFF) + ((S0->YUV.v & 0xFF00) ? 0xFF : S0->YUV.v)) >> 1;
+ *Duv = cr | (cb << 8);
+ }
+ else if (!(S1->YUV.a & 0xF000)) {
+ cb = ((*Duv >> 8) + ((S1->YUV.u & 0xFF00) ? 0xFF : S1->YUV.u)) >> 1;
+ cr = ((*Duv & 0xFF) + ((S1->YUV.v & 0xFF00) ? 0xFF : S1->YUV.v)) >> 1;
+ *Duv = cr | (cb << 8);
+ }
+#else
+ *Duv = cb | (cr << 8);
+ }
+ else if (!(S0->YUV.a & 0xF000)) {
+ cb = ((*Duv & 0xFF) + ((S0->YUV.u & 0xFF00) ? 0xFF : S0->YUV.u)) >> 1;
+ cr = ((*Duv >> 8) + ((S0->YUV.v & 0xFF00) ? 0xFF : S0->YUV.v)) >> 1;
+ *Duv = cb | (cr << 8);
+ }
+ else if (!(S1->YUV.a & 0xF000)) {
+ cb = ((*Duv & 0xFF) + ((S1->YUV.u & 0xFF00) ? 0xFF : S1->YUV.u)) >> 1;
+ cr = ((*Duv >> 8) + ((S1->YUV.v & 0xFF00) ? 0xFF : S1->YUV.v)) >> 1;
+ *Duv = cb | (cr << 8);
+ }
+#endif
+
+ Duv++;
+
+ i += SperD << 1;
+ }
+ }
+}
+
+static void Sacc_Sto_Aop_nv21( GenefxState *gfxs )
+{
+ int i = gfxs->Xphase;
+ int w = gfxs->length;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u8 *Dy = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->YUV.a & 0xF000))
+ *Dy = (S->YUV.y & 0xFF00) ? 0xFF : S->YUV.y;
+
+ Dy++;
+ i += SperD;
+ }
+
+ if (gfxs->dst_format == DSPF_NV16 || gfxs->AopY & 1) {
+ u16 *Dvu = gfxs->Aop[1];
+
+ w = gfxs->length>>1;
+ i = gfxs->Xphase>>1;
+
+ while (w--) {
+ GenefxAccumulator *S0 = &Sacc[i>>16];
+ GenefxAccumulator *S1 = &Sacc[(i+SperD)>>16];
+ u32 cb, cr;
+
+ if (!(S0->YUV.a & 0xF000) && !(S1->YUV.a & 0xF000)) {
+ cb = (S0->YUV.u + S1->YUV.u) >> 1;
+ if (cb & 0xFF00)
+ cb = 0xFF;
+
+ cr = (S0->YUV.v + S1->YUV.v) >> 1;
+ if (cr & 0xFF00)
+ cr = 0xFF;
+
+#ifdef WORDS_BIGENDIAN
+ *Dvu = cb | (cr << 8);
+ }
+ else if (!(S0->YUV.a & 0xF000)) {
+ cb = ((*Dvu & 0xFF) + ((S0->YUV.u & 0xFF00) ? 0xFF : S0->YUV.u)) >> 1;
+ cr = ((*Dvu >> 8) + ((S0->YUV.v & 0xFF00) ? 0xFF : S0->YUV.v)) >> 1;
+ *Dvu = cb | (cr << 8);
+ }
+ else if (!(S1->YUV.a & 0xF000)) {
+ cb = ((*Dvu & 0xFF) + ((S1->YUV.u & 0xFF00) ? 0xFF : S1->YUV.u)) >> 1;
+ cr = ((*Dvu >> 8) + ((S1->YUV.v & 0xFF00) ? 0xFF : S1->YUV.v)) >> 1;
+ *Dvu = cb | (cr << 8);
+ }
+#else
+ *Dvu = cr | (cb << 8);
+ }
+ else if (!(S0->YUV.a & 0xF000)) {
+ cb = ((*Dvu >> 8) + ((S0->YUV.u & 0xFF00) ? 0xFF : S0->YUV.u)) >> 1;
+ cr = ((*Dvu & 0xFF) + ((S0->YUV.v & 0xFF00) ? 0xFF : S0->YUV.v)) >> 1;
+ *Dvu = cr | (cb << 8);
+ }
+ else if (!(S1->YUV.a & 0xF000)) {
+ cb = ((*Dvu >> 8) + ((S1->YUV.u & 0xFF00) ? 0xFF : S1->YUV.u)) >> 1;
+ cr = ((*Dvu & 0xFF) + ((S1->YUV.v & 0xFF00) ? 0xFF : S1->YUV.v)) >> 1;
+ *Dvu = cr | (cb << 8);
+ }
+#endif
+
+ Dvu++;
+
+ i += SperD << 1;
+ }
+ }
+}
+
+static void Sacc_Sto_Aop_ayuv( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int i = gfxs->Xphase;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u32 *D = gfxs->Aop[0];
+ int SperD = gfxs->SperD;
+
+ while (w--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->YUV.a & 0xF000)) {
+ *D = PIXEL_AYUV( (S->YUV.a & 0xFF00) ? 0xFF : S->YUV.a,
+ (S->YUV.y & 0xFF00) ? 0xFF : S->YUV.y,
+ (S->YUV.u & 0xFF00) ? 0xFF : S->YUV.u,
+ (S->YUV.v & 0xFF00) ? 0xFF : S->YUV.v );
+ }
+
+ D++;
+ i += SperD;
+ }
+}
+
+
+static GenefxFunc Sacc_Sto_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Sacc_Sto_Aop_argb1555, /* DSPF_ARGB1555 */
+ Sacc_Sto_Aop_rgb16, /* DSPF_RGB16 */
+ Sacc_Sto_Aop_rgb24, /* DSPF_RGB24 */
+ Sacc_Sto_Aop_rgb32, /* DSPF_RGB32 */
+ Sacc_Sto_Aop_argb, /* DSPF_ARGB */
+ Sacc_Sto_Aop_a8, /* DSPF_A8 */
+ Sacc_Sto_Aop_yuy2, /* DSPF_YUY2 */
+ Sacc_Sto_Aop_rgb332, /* DSPF_RGB332 */
+ Sacc_Sto_Aop_uyvy, /* DSPF_UYVY */
+ Sacc_Sto_Aop_i420, /* DSPF_I420 */
+ Sacc_Sto_Aop_i420, /* DSPF_YV12 */
+ Sacc_Sto_Aop_lut8, /* DSPF_LUT8 */
+ Sacc_Sto_Aop_alut44, /* DSPF_ALUT44 */
+ Sacc_Sto_Aop_airgb, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ Sacc_Sto_Aop_nv12, /* DSPF_NV12 */
+ Sacc_Sto_Aop_nv12, /* DSPF_NV16 */
+ Sacc_Sto_Aop_argb2554, /* DSPF_ARGB2554 */
+ Sacc_Sto_Aop_argb4444, /* DSPF_ARGB4444 */
+ Sacc_Sto_Aop_rgba4444, /* DSPF_RGBA4444 */
+ Sacc_Sto_Aop_nv21, /* DSPF_NV21 */
+ Sacc_Sto_Aop_ayuv, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Sacc_Sto_Aop_argb1666, /* DSPF_ARGB1666 */
+ Sacc_Sto_Aop_argb6666, /* DSPF_ARGB6666 */
+ Sacc_Sto_Aop_rgb18, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Sacc_Sto_Aop_xrgb4444, /* DSPF_RGB444 */
+ Sacc_Sto_Aop_xrgb1555, /* DSPF_RGB555 */
+ Sacc_Sto_Aop_xbgr1555, /* DSPF_BGR555 */
+};
+
+/********************************* Sacc_toK_Aop_PFI ***************************/
+
+static void Sacc_toK_Aop_argb6666( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000) && Dkey == ((u32)(D[2]<<16 | D[1]<<8 | D[0]) & 0x3FFFF)) {
+ u32 pixel = PIXEL_ARGB6666( (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D +=3;
+ S++;
+ }
+}
+
+static void Sacc_toK_Aop_argb1666( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000) && Dkey == ((u32)(D[2]<<16 | D[1]<<8 | D[0]) & 0x3FFFF)) {
+ u32 pixel = PIXEL_ARGB1666( (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D +=3;
+ S++;
+ }
+}
+
+static void Sacc_toK_Aop_rgb18( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000) && Dkey == ((u32)(D[2]<<16 | D[1]<<8 | D[0]) & 0x3FFFF)) {
+ u32 pixel = PIXEL_RGB18( (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D +=3;
+ S++;
+ }
+}
+
+static void Sacc_toK_Aop_rgb24( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ u8 r = (gfxs->Dkey >> 16);
+ u8 g = (gfxs->Dkey >> 8) & 0xff;
+ u8 b = (gfxs->Dkey ) & 0xff;
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000) && D[0] == b && D[1] == g && D[2] == r) {
+ *D++ = (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b;
+ *D++ = (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g;
+ *D++ = (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r;
+ }
+ else
+ D += 3;
+
+ S++;
+ }
+}
+
+static void Sacc_toK_Aop_a8( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+
+ /* FIXME: do all or do none? */
+ while (w--) {
+ if (!(S->RGB.a & 0xF000))
+ *D = (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a;
+
+ D++;
+ S++;
+ }
+}
+
+static void Sacc_toK_Aop_yuy2( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u16 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+#ifdef WORDS_BIGENDIAN
+ u16 Dkey0 = gfxs->Dkey >> 16;
+ u16 Dkey1 = gfxs->Dkey & 0xFFFF;
+#else
+ u16 Dkey0 = gfxs->Dkey & 0xFFFF;
+ u16 Dkey1 = gfxs->Dkey >> 16;
+#endif
+
+ if ((long)D & 2) {
+ if (!(S->YUV.a & 0xF000) && (*D == Dkey1)) {
+ *D = ((S->YUV.y & 0xFF00) ? 0x00FF : S->YUV.y) |
+ ((S->YUV.v & 0xFF00) ? 0xFF00 : (S->YUV.v<<8));
+ }
+ S++;
+ D++;
+ w--;
+ }
+
+ for (l = w>>1; l--;) {
+ if (*D == Dkey) {
+ if (!(S[0].YUV.a & 0xF000) && !(S[1].YUV.a & 0xF000)) {
+ u32 y0, cb, y1, cr;
+
+ y0 = (S[0].YUV.y & 0xFF00) ? 0xFF : S[0].YUV.y;
+ y1 = (S[1].YUV.y & 0xFF00) ? 0xFF : S[1].YUV.y;
+
+ cb = (S[0].YUV.u + S[1].YUV.u) >> 1;
+ if (cb & 0xFF00)
+ cb = 0xFF;
+
+ cr = (S[0].YUV.v + S[1].YUV.v) >> 1;
+ if (cr & 0xFF00)
+ cr = 0xFF;
+
+#ifdef WORDS_BIGENDIAN
+ *((u32*)D) = y1 | (cr << 8) | (y0 << 16) | (cb << 24);
+#else
+ *((u32*)D) = y0 | (cb << 8) | (y1 << 16) | (cr << 24);
+#endif
+ }
+ else if (!(S[0].YUV.a & 0xF000)) {
+ D[0] = ((S[0].YUV.y & 0xFF00) ? 0x00FF : S[0].YUV.y) |
+ ((S[0].YUV.u & 0xFF00) ? 0xFF00 : (S[0].YUV.u<<8));
+ }
+ else if (!(S[1].YUV.a & 0xF000)) {
+ D[1] = ((S[1].YUV.y & 0xFF00) ? 0x00FF : S[1].YUV.y) |
+ ((S[1].YUV.v & 0xFF00) ? 0xFF00 : (S[1].YUV.v<<8));
+ }
+ }
+
+ D += 2;
+ S += 2;
+ }
+
+ if (w & 1) {
+ if (!(S->YUV.a & 0xF000) && (*D == Dkey0)) {
+ *D = ((S->YUV.y & 0xFF00) ? 0x00FF : S->YUV.y) |
+ ((S->YUV.u & 0xFF00) ? 0xFF00 : (S->YUV.u<<8));
+ }
+ }
+}
+
+static void Sacc_toK_Aop_rgb332( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000) && (*D == Dkey)) {
+ *D = PIXEL_RGB332( (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b );
+ }
+
+ D++;
+ S++;
+ }
+}
+
+static void Sacc_toK_Aop_uyvy( GenefxState *gfxs )
+{
+ int l;
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u16 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+#ifdef WORDS_BIGENDIAN
+ u16 Dkey0 = gfxs->Dkey >> 16;
+ u16 Dkey1 = gfxs->Dkey & 0xFFFF;
+#else
+ u16 Dkey0 = gfxs->Dkey & 0xFFFF;
+ u16 Dkey1 = gfxs->Dkey >> 16;
+#endif
+
+ if ((long)D & 2) {
+ if (!(S->YUV.a & 0xF000) && (*D == Dkey1)) {
+ *D = ((S->YUV.v & 0xFF00) ? 0x00FF : S->YUV.v) |
+ ((S->YUV.y & 0xFF00) ? 0xFF00 : (S->YUV.y<<8));
+ }
+ S++;
+ D++;
+ w--;
+ }
+
+ for (l = w>>1; l--;) {
+ if (*D == Dkey) {
+ if (!(S[0].YUV.a & 0xF000) && !(S[1].YUV.a & 0xF000)) {
+ u32 cb, y0, cr, y1;
+
+ y0 = (S[0].YUV.y & 0xFF00) ? 0xFF : S[0].YUV.y;
+ y1 = (S[1].YUV.y & 0xFF00) ? 0xFF : S[1].YUV.y;
+
+ cb = (S[0].YUV.u + S[1].YUV.u) >> 1;
+ if (cb & 0xFF00)
+ cb = 0xFF;
+
+ cr = (S[0].YUV.v + S[1].YUV.v) >> 1;
+ if (cr & 0xFF00)
+ cr = 0xFF;
+
+#ifdef WORDS_BIGENDIAN
+ *((u32*)D) = cr | (y1 << 8) | (cb << 16) | (y0 << 24);
+#else
+ *((u32*)D) = cb | (y0 << 8) | (cr << 16) | (y1 << 24);
+#endif
+ }
+ else if (!(S[0].YUV.a & 0xF000)) {
+ D[0] = ((S[0].YUV.u & 0xFF00) ? 0x00FF : S[0].YUV.u) |
+ ((S[0].YUV.y & 0xFF00) ? 0xFF00 : (S[0].YUV.y<<8));
+ }
+ else if (!(S[1].YUV.a & 0xF000)) {
+ D[1] = ((S[1].YUV.v & 0xFF00) ? 0x00FF : S[1].YUV.v) |
+ ((S[1].YUV.y & 0xFF00) ? 0xFF00 : (S[1].YUV.y<<8));
+ }
+ }
+
+ D += 2;
+ S += 2;
+ }
+
+ if (w & 1) {
+ if (!(S->YUV.a & 0xF000) && (*D == Dkey0)) {
+ *D = ((S->YUV.u & 0xFF00) ? 0x00FF : S->YUV.u) |
+ ((S->YUV.y & 0xFF00) ? 0xFF00 : (S->YUV.y<<8));
+ }
+ }
+}
+
+static void Sacc_toK_Aop_lut8( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000) && (*D == Dkey)) {
+ *D = dfb_palette_search( gfxs->Alut,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b,
+ (S->RGB.a & 0xFF00) ? 0xFF : S->RGB.a );
+ }
+
+ D++;
+ S++;
+ }
+}
+
+static void Sacc_toK_Aop_alut44( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u8 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+
+ while (w--) {
+ if (!(S->RGB.a & 0xF000) && ((*D & 0x0F) == Dkey)) {
+ *D = (S->RGB.a & 0xFF00) ? 0xF0 : (S->RGB.a & 0xF0) +
+ dfb_palette_search( gfxs->Alut,
+ (S->RGB.r & 0xFF00) ? 0xFF : S->RGB.r,
+ (S->RGB.g & 0xFF00) ? 0xFF : S->RGB.g,
+ (S->RGB.b & 0xFF00) ? 0xFF : S->RGB.b,
+ 0x80 );
+ }
+
+ D++;
+ S++;
+ }
+}
+
+static GenefxFunc Sacc_toK_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Sacc_toK_Aop_argb1555, /* DSPF_ARGB1555 */
+ Sacc_toK_Aop_rgb16, /* DSPF_RGB16 */
+ Sacc_toK_Aop_rgb24, /* DSPF_RGB24 */
+ Sacc_toK_Aop_rgb32, /* DSPF_RGB32 */
+ Sacc_toK_Aop_argb, /* DSPF_ARGB */
+ Sacc_toK_Aop_a8, /* DSPF_A8 */
+ Sacc_toK_Aop_yuy2, /* DSPF_YUY2 */
+ Sacc_toK_Aop_rgb332, /* DSPF_RGB332 */
+ Sacc_toK_Aop_uyvy, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ Sacc_toK_Aop_lut8, /* DSPF_LUT8 */
+ Sacc_toK_Aop_alut44, /* DSPF_ALUT44 */
+ Sacc_toK_Aop_airgb, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Sacc_toK_Aop_argb2554, /* DSPF_ARGB2554 */
+ Sacc_toK_Aop_argb4444, /* DSPF_ARGB4444 */
+ Sacc_toK_Aop_rgba4444, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ NULL, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Sacc_toK_Aop_argb1666, /* DSPF_ARGB1666 */
+ Sacc_toK_Aop_argb6666, /* DSPF_ARGB6666 */
+ Sacc_toK_Aop_rgb18, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Sacc_toK_Aop_xrgb4444, /* DSPF_RGB444 */
+ Sacc_toK_Aop_xrgb1555, /* DSPF_RGB555 */
+ Sacc_toK_Aop_xbgr1555, /* DSPF_BGR555 */
+};
+
+/********************************* Sacc_StoK_Aop_PFI **************************/
+
+static GenefxFunc Sacc_StoK_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Sacc_StoK_Aop_argb1555, /* DSPF_ARGB1555 */
+ Sacc_StoK_Aop_rgb16, /* DSPF_RGB16 */
+ NULL, /* DSPF_RGB24 */
+ Sacc_StoK_Aop_rgb32, /* DSPF_RGB32 */
+ Sacc_StoK_Aop_argb, /* DSPF_ARGB */
+ NULL, /* DSPF_A8 */
+ NULL, /* DSPF_YUY2 */
+ NULL, /* DSPF_RGB332 */
+ NULL, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ NULL, /* DSPF_LUT8 */
+ NULL, /* DSPF_ALUT44 */
+ Sacc_StoK_Aop_airgb, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Sacc_StoK_Aop_argb2554, /* DSPF_ARGB2554 */
+ Sacc_StoK_Aop_argb4444, /* DSPF_ARGB4444 */
+ Sacc_StoK_Aop_rgba4444, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ NULL, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ NULL, /* DSPF_ARGB1666 */
+ NULL, /* DSPF_ARGB6666 */
+ NULL, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ Sacc_StoK_Aop_xrgb4444, /* DSPF_RGB444 */
+ Sacc_StoK_Aop_xrgb1555, /* DSPF_RGB555 */
+ Sacc_StoK_Aop_xbgr1555, /* DSPF_BGR555 */
+};
+
+/************** Bop_a8_set_alphapixel_Aop_PFI *********************************/
+
+/* change the last value to adjust the size of the device (1-4) */
+#define SET_PIXEL_DUFFS_DEVICE( D, S, w ) \
+ SET_PIXEL_DUFFS_DEVICE_N( D, S, w, 3 )
+
+
+static void Bop_a8_set_alphapixel_Aop_argb1555( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+ u32 rb = Cop & 0x7c1f;
+ u32 g = Cop & 0x03e0;
+
+#define SET_PIXEL(d,a) \
+ switch (a) {\
+ case 0xff: d = Cop;\
+ case 0: break;\
+ default: {\
+ register u32 s = (a>>3)+1;\
+ register u32 t1 = (d & 0x7c1f);\
+ register u32 t2 = (d & 0x03e0);\
+ d = ((d) & 0x8000) | ((a & 0x80) << 8) | \
+ ((((rb-t1)*s+(t1<<5)) & 0x000f83e0) + \
+ ((( g-t2)*s+(t2<<5)) & 0x00007c00)) >> 5;\
+ }\
+ }
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+
+static void Bop_a8_set_alphapixel_Aop_rgb16( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+ u32 rb = Cop & 0xf81f;
+ u32 g = Cop & 0x07e0;
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff: d = Cop;\
+ case 0: break;\
+ default: {\
+ register u32 s = (a>>2)+1;\
+ register u32 t1 = (d & 0xf81f);\
+ register u32 t2 = (d & 0x07e0);\
+ d = ((((rb-t1)*s+(t1<<6)) & 0x003e07c0) + \
+ ((( g-t2)*s+(t2<<6)) & 0x0001f800)) >> 6;\
+ }\
+ }
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+static void Bop_a8_set_alphapixel_Aop_argb6666( GenefxState *gfxs )
+{
+
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+
+ u32 Cop = gfxs->Cop;
+ u32 rb = Cop & 0x3f03f;
+ u32 g = Cop & 0xfc0;
+
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff: d = Cop;\
+ case 0: break;\
+ default: {\
+ register u32 s = (a>>2)+1;\
+ register u32 t1 = (d & 0x3f03f);\
+ register u32 t2 = (d & 0xfc0);\
+ d = ((((rb-t1)*s+(t1<<6)) & 0xfc0fc0) + \
+ ((( g-t2)*s+(t2<<6)) & 0xfc000)) >> 6;\
+ }\
+ }
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+
+}
+
+static void Bop_a8_set_alphapixel_Aop_argb1666( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+
+ u32 Cop = gfxs->Cop;
+ u32 rb = Cop & 0x3f03f;
+ u32 g = Cop & 0xfc0;
+
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff: d = Cop;\
+ case 0: break;\
+ default: {\
+ register u32 s = (a>>2)+1;\
+ register u32 t1 = (d & 0x3f03f);\
+ register u32 t2 = (d & 0xfc0);\
+ d = ((((rb-t1)*s+(t1<<6)) & 0xfc0fc0) + \
+ ((( g-t2)*s+(t2<<6)) & 0xfc000)) >> 6;\
+ }\
+ }
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+static void Bop_a8_set_alphapixel_Aop_rgb18( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+
+ u32 Cop = gfxs->Cop;
+ u32 rb = Cop & 0x3f03f;
+ u32 g = Cop & 0xfc0;
+
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff: d = Cop;\
+ case 0: break;\
+ default: {\
+ register u32 s = (a>>2)+1;\
+ register u32 t1 = (d & 0x3f03f);\
+ register u32 t2 = (d & 0xfc0);\
+ d = ((((rb-t1)*s+(t1<<6)) & 0xfc0fc0) + \
+ ((( g-t2)*s+(t2<<6)) & 0xfc000)) >> 6;\
+ }\
+ }
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+
+}
+
+static void Bop_a8_set_alphapixel_Aop_rgb24( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ DFBColor color = gfxs->color;
+
+#define SET_PIXEL(d,r,g,b,a)\
+ switch (a) {\
+ case 0xff:\
+ d[0] = b;\
+ d[1] = g;\
+ d[2] = r;\
+ case 0: break;\
+ default: {\
+ register u16 s = a+1;\
+ d[0] = ((b-d[0]) * s + (d[0] << 8)) >> 8;\
+ d[1] = ((g-d[1]) * s + (d[1] << 8)) >> 8;\
+ d[2] = ((r-d[2]) * s + (d[2] << 8)) >> 8;\
+ }\
+ }
+
+ while (w>4) {
+ SET_PIXEL( D, color.r, color.g, color.b, *S ); D+=3; S++;
+ SET_PIXEL( D, color.r, color.g, color.b, *S ); D+=3; S++;
+ SET_PIXEL( D, color.r, color.g, color.b, *S ); D+=3; S++;
+ SET_PIXEL( D, color.r, color.g, color.b, *S ); D+=3; S++;
+ w-=4;
+ }
+ while (w--) {
+ SET_PIXEL( D, color.r, color.g, color.b, *S ); D+=3, S++;
+ }
+
+#undef SET_PIXEL
+}
+
+static void Bop_a8_set_alphapixel_Aop_rgb32( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+ u32 rb = Cop & 0xff00ff;
+ u32 g = Cop & 0x00ff00;
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff: d = Cop;\
+ case 0: break;\
+ default: {\
+ register u32 s = a+1;\
+ register u32 t1 = (d & 0x00ff00ff);\
+ register u32 t2 = (d & 0x0000ff00);\
+ d = ((((rb-t1)*s+(t1<<8)) & 0xff00ff00) + \
+ ((( g-t2)*s+(t2<<8)) & 0x00ff0000)) >> 8;\
+ }\
+ }
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+
+/* saturating alpha blend */
+
+static void Bop_a8_set_alphapixel_Aop_argb( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop | 0xff000000;
+ u32 rb = Cop & 0x00ff00ff;
+ u32 g = gfxs->color.g;
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff: d = Cop;\
+ case 0: break;\
+ default: {\
+ register u32 s = a+1;\
+ register u32 s1 = 256-a;\
+ register u32 sa = (((d >> 24) * s1) >> 8) + a;\
+ d = (sa << 24) + \
+ (((((d & 0x00ff00ff) * s1) + (rb * s)) >> 8) & 0x00ff00ff) + \
+ (((((d & 0x0000ff00) >> 8) * s1) + ((g) * s)) & 0x0000ff00); \
+ }\
+ }
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+static void Bop_a8_set_alphapixel_Aop_airgb( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+ u32 rb = Cop & 0x00ff00ff;
+ u32 g = gfxs->color.g;
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff: d = Cop;\
+ case 0: break;\
+ default: {\
+ register u32 s = a+1;\
+ register u32 s1 = 256-s;\
+ register s32 sa = (d >> 24) - a;\
+ if (sa < 0) sa = 0;\
+ d = (sa << 24) + \
+ (((((d & 0x00ff00ff) * s1) + (rb * s)) >> 8) & 0x00ff00ff) + \
+ (((((d & 0x0000ff00) >> 8) * s1) + ((g) * s)) & 0x0000ff00); \
+ }\
+ }
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+static void Bop_a8_set_alphapixel_Aop_a8( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff: d = 0xff;\
+ case 0: break; \
+ default: {\
+ register u16 s1 = 255-a;\
+ d = ((d * s1) >> 8) + a;\
+ }\
+ }
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+static void Bop_a8_set_alphapixel_Aop_yuy2( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u32 y = gfxs->YCop;
+ u32 u = gfxs->CbCop;
+ u32 v = gfxs->CrCop;
+
+#ifdef WORDS_BIGENDIAN
+ u16 Cop0 = u | (y << 8);
+ u16 Cop1 = v | (y << 8);
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff:\
+ d = ((long)&(d) & 2) ? Cop1 : Cop0;\
+ case 0x00: break;\
+ default: {\
+ register u32 s = a+1;\
+ register u32 t1 = d & 0xff;\
+ register u32 t2 = d >> 8;\
+ if ((long)&(d) & 2)\
+ d = (((v-t1)*s+(t1<<8)) >> 8) |\
+ (((y-t2)*s+(t2<<8)) & 0xff00);\
+ else\
+ d = (((u-t1)*s+(t1<<8)) >> 8) |\
+ (((y-t2)*s+(t2<<8)) & 0xff00);\
+ } break;\
+ }
+#else
+ u16 Cop0 = y | (u << 8);
+ u16 Cop1 = y | (v << 8);
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff:\
+ d = ((long)&(d) & 2) ? Cop1 : Cop0;\
+ case 0x00: break;\
+ default: {\
+ register u32 s = a+1;\
+ register u32 t1 = d & 0xff;\
+ register u32 t2 = d >> 8;\
+ if ((long)&(d) & 2)\
+ d = (((y-t1)*s+(t1<<8)) >> 8) |\
+ (((v-t2)*s+(t2<<8)) & 0xff00);\
+ else\
+ d = (((y-t1)*s+(t1<<8)) >> 8) |\
+ (((u-t2)*s+(t2<<8)) & 0xff00);\
+ } break;\
+ }
+#endif
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+static void Bop_a8_set_alphapixel_Aop_rgb332( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+ u32 rgb = ((Cop & 0xe0) << 16) | ((Cop & 0x1c) << 8) | (Cop & 0x03);
+
+#define SET_PIXEL(d,a) \
+ switch (a) {\
+ case 0xff: d = Cop;\
+ case 0: break;\
+ default: {\
+ register u32 s = a + 1;\
+ register u32 t = ((d & 0xe0) << 16) | ((d & 0x1c) << 8) | (d & 0x03);\
+ register u32 c = ((rgb-t)*s + (t<<8)) & 0xe01c0300;\
+ d = (c >> 24) | ((c >> 16) & 0xff) | ((c >> 8) & 0xff);\
+ }\
+ }
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+static void Bop_a8_set_alphapixel_Aop_uyvy( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u32 y = gfxs->YCop;
+ u32 u = gfxs->CbCop;
+ u32 v = gfxs->CrCop;
+ u16 Cop0 = u | (y << 8);
+ u16 Cop1 = v | (y << 8);
+
+#define SET_PIXEL(d,a)\
+ switch (a) {\
+ case 0xff: d = ((long)&(d) & 2) ? Cop1 : Cop0;\
+ case 0x00: break;\
+ default: {\
+ register u32 s = a+1;\
+ register u32 t1 = d & 0xff;\
+ register u32 t2 = d >> 8;\
+ if ((long)&(d) & 2)\
+ d = (((v-t1)*s+(t1<<8)) >> 8) |\
+ (((y-t2)*s+(t2<<8)) & 0xff00);\
+ else\
+ d = (((u-t1)*s+(t1<<8)) >> 8) |\
+ (((y-t2)*s+(t2<<8)) & 0xff00);\
+ } break;\
+ }
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+static void Bop_a8_set_alphapixel_Aop_lut8( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+
+#if 0
+ DFBColor color = gfxs->color;
+ DFBColor *entries = gfxs->Alut->entries;
+
+# define SET_PIXEL(d,alpha) \
+ switch (alpha) {\
+ case 0xff: d = Cop;\
+ case 0: break; \
+ default: {\
+ register u16 s = alpha+1;\
+ DFBColor dc = entries[d];\
+ u16 sa = alpha + dc.a;\
+ dc.r = ((color.r - dc.r) * s + (dc.r << 8)) >> 8;\
+ dc.g = ((color.g - dc.g) * s + (dc.g << 8)) >> 8;\
+ dc.b = ((color.b - dc.b) * s + (dc.b << 8)) >> 8;\
+ d = dfb_palette_search( gfxs->Alut, dc.r, dc.g, dc.b,\
+ sa & 0xff00 ? 0xff : sa );\
+ }\
+ }
+#else
+# define SET_PIXEL(d,a) \
+ if (a & 0x80) \
+ d = Cop;
+#endif
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+
+#undef SET_PIXEL
+}
+
+static void Bop_a8_set_alphapixel_Aop_alut44( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+
+ DFBColor color = gfxs->color;
+ DFBColor *entries = gfxs->Alut->entries;
+
+#define SET_PIXEL(d,alpha) \
+ switch (alpha) {\
+ case 0xff: d = Cop;\
+ case 0: break; \
+ default: {\
+ register u16 s = alpha+1;\
+ DFBColor dc = entries[d & 0x0f];\
+ u16 sa = (d & 0xf0) + alpha;\
+ dc.r = ((color.r - dc.r) * s + (dc.r << 8)) >> 8;\
+ dc.g = ((color.g - dc.g) * s + (dc.g << 8)) >> 8;\
+ dc.b = ((color.b - dc.b) * s + (dc.b << 8)) >> 8;\
+ if (sa & 0xff00) sa = 0xf0;\
+ d = (sa & 0xf0) + \
+ dfb_palette_search( gfxs->Alut, dc.r, dc.g, dc.b, 0x80 );\
+ }\
+ }
+
+ while (w--) {
+ SET_PIXEL( *D, *S );
+ D++, S++;
+ }
+
+#undef SET_PIXEL
+}
+
+#undef SET_PIXEL_DUFFS_DEVICE
+
+static GenefxFunc Bop_a8_set_alphapixel_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_a8_set_alphapixel_Aop_argb1555, /* DSPF_ARGB1555 */
+ Bop_a8_set_alphapixel_Aop_rgb16, /* DSPF_RGB16 */
+ Bop_a8_set_alphapixel_Aop_rgb24, /* DSPF_RGB24 */
+ Bop_a8_set_alphapixel_Aop_rgb32, /* DSPF_RGB32 */
+ Bop_a8_set_alphapixel_Aop_argb, /* DSPF_ARGB */
+ Bop_a8_set_alphapixel_Aop_a8, /* DSPF_A8 */
+ Bop_a8_set_alphapixel_Aop_yuy2, /* DSPF_YUY2 */
+ Bop_a8_set_alphapixel_Aop_rgb332, /* DSPF_RGB332 */
+ Bop_a8_set_alphapixel_Aop_uyvy, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ Bop_a8_set_alphapixel_Aop_lut8, /* DSPF_LUT8 */
+ Bop_a8_set_alphapixel_Aop_alut44, /* DSPF_ALUT44 */
+ Bop_a8_set_alphapixel_Aop_airgb, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ NULL, /* DSPF_ARGB2554 */
+ NULL, /* DSPF_ARGB4444 */
+ NULL, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ Bop_a8_set_alphapixel_Aop_argb, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Bop_a8_set_alphapixel_Aop_argb1666, /* DSPF_ARGB1666 */
+ Bop_a8_set_alphapixel_Aop_argb6666, /* DSPF_ARGB6666 */
+ Bop_a8_set_alphapixel_Aop_rgb18, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ NULL, /* DSPF_ARGB4444 */
+ NULL, /* DSPF_ARGB1555 */
+ NULL /* DSPF_ARGB1555 */
+};
+
+/************** Bop_a1_set_alphapixel_Aop_PFI *********************************/
+
+static void Bop_a1_set_alphapixel_Aop_argb1555( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Cop = gfxs->Cop | 0x8000;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_rgb16( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Cop = gfxs->Cop;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_argb6666( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ DFBColor color = gfxs->color;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7))) {
+ u32 pixel = PIXEL_ARGB6666( color.a, color.r, color.g, color.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D += 3;
+ }
+
+}
+
+static void Bop_a1_set_alphapixel_Aop_argb1666( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ DFBColor color = gfxs->color;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7))) {
+ u32 pixel = PIXEL_ARGB1666( color.a, color.r, color.g, color.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D += 3;
+ }
+
+}
+
+static void Bop_a1_set_alphapixel_Aop_rgb18( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ DFBColor color = gfxs->color;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7))) {
+ u32 pixel = PIXEL_RGB18( color.r, color.g, color.b );
+
+ D[0] = pixel;
+ D[1] = pixel >> 8;
+ D[2] = pixel >> 16;
+ }
+ D += 3;
+ }
+
+}
+
+static void Bop_a1_set_alphapixel_Aop_rgb24( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ DFBColor color = gfxs->color;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7))) {
+ D[0] = color.b;
+ D[1] = color.g;
+ D[2] = color.r;
+ }
+
+ D += 3;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_rgb32( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_argb( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop | 0xFF000000;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_airgb( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop & 0x00FFFFFF;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_a8( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = 0xff;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_yuy2( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Cop0 = gfxs->YCop | (gfxs->CbCop << 8);
+ u16 Cop1 = gfxs->YCop | (gfxs->CrCop << 8);
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7))) {
+ D[i] = ((long)&D[i] & 2) ? Cop1 : Cop0;
+ }
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_rgb332( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ u8 Cop = gfxs->Cop;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_uyvy( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Cop0 = gfxs->CbCop | (gfxs->YCop << 8);
+ u16 Cop1 = gfxs->CrCop | (gfxs->YCop << 8);
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7))) {
+ D[i] = ((long)&D[i] & 2) ? Cop1 : Cop0;
+ }
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_lut8( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ u8 Cop = gfxs->Cop;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_alut44( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+ u8 Cop = gfxs->Cop;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_argb2554( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Cop = gfxs->Cop | 0xC000;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_argb4444( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Cop = gfxs->Cop | 0xF000;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static void Bop_a1_set_alphapixel_Aop_rgba4444( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Cop = gfxs->Cop | 0x000F;
+
+ for (i=0; i<w; i++) {
+ if (S[i>>3] & (0x80 >> (i&7)))
+ D[i] = Cop;
+ }
+}
+
+static GenefxFunc Bop_a1_set_alphapixel_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ Bop_a1_set_alphapixel_Aop_argb1555, /* DSPF_ARGB1555 */
+ Bop_a1_set_alphapixel_Aop_rgb16, /* DSPF_RGB16 */
+ Bop_a1_set_alphapixel_Aop_rgb24, /* DSPF_RGB24 */
+ Bop_a1_set_alphapixel_Aop_rgb32, /* DSPF_RGB32 */
+ Bop_a1_set_alphapixel_Aop_argb, /* DSPF_ARGB */
+ Bop_a1_set_alphapixel_Aop_a8, /* DSPF_A8 */
+ Bop_a1_set_alphapixel_Aop_yuy2, /* DSPF_YUY2 */
+ Bop_a1_set_alphapixel_Aop_rgb332, /* DSPF_RGB332 */
+ Bop_a1_set_alphapixel_Aop_uyvy, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ Bop_a1_set_alphapixel_Aop_lut8, /* DSPF_LUT8 */
+ Bop_a1_set_alphapixel_Aop_alut44, /* DSPF_ALUT44 */
+ Bop_a1_set_alphapixel_Aop_airgb, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ Bop_a1_set_alphapixel_Aop_argb2554, /* DSPF_ARGB2554 */
+ Bop_a1_set_alphapixel_Aop_argb4444, /* DSPF_ARGB4444 */
+ Bop_a1_set_alphapixel_Aop_rgba4444, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ Bop_a1_set_alphapixel_Aop_argb, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ Bop_a1_set_alphapixel_Aop_argb1666, /* DSPF_ARGB1666 */
+ Bop_a1_set_alphapixel_Aop_argb6666, /* DSPF_ARGB6666 */
+ Bop_a1_set_alphapixel_Aop_rgb18, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ NULL, /* DSPF_RGB444 */
+ NULL, /* DSPF_RGB555 */
+ NULL, /* DSPF_BGR555 */
+};
+
+
+/**************************** Bop_translate_to_Aop ****************************/
+
+static void Bop_lut2_translate_to_Aop_lut8( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ int W = (w + 3) / 4;
+ u8 *S = gfxs->Bop[0];
+ u8 *D = gfxs->Aop[0];
+
+ for (i=0; i<W; i++, D+=4, w-=4) {
+ u8 index;
+ u8 pixels = S[i];
+
+ switch (w) {
+ default:
+ index = (pixels & 3);
+ if (index < gfxs->num_trans && gfxs->trans[index] >= 0)
+ D[3] = gfxs->trans[index];
+
+ case 3:
+ index = (pixels >> 2) & 3;
+ if (index < gfxs->num_trans && gfxs->trans[index] >= 0)
+ D[2] = gfxs->trans[index];
+
+ case 2:
+ index = (pixels >> 4) & 3;
+ if (index < gfxs->num_trans && gfxs->trans[index] >= 0)
+ D[1] = gfxs->trans[index];
+
+ case 1:
+ index = (pixels >> 6);
+ if (index < gfxs->num_trans && gfxs->trans[index] >= 0)
+ D[0] = gfxs->trans[index];
+ }
+ }
+}
+
+/********************************* Xacc_blend *********************************/
+
+static void Xacc_blend_zero( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+
+ for (i=0; i<w; i++) {
+ if (!(Y[i].RGB.a & 0xF000))
+ X[i].RGB.a = X[i].RGB.r = X[i].RGB.g = X[i].RGB.b = 0;
+ else
+ X[i] = Y[i];
+ }
+}
+
+static void Xacc_blend_one( GenefxState *gfxs )
+{
+ int i;
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+
+ for (i=0; i<w; i++) {
+ X[i] = Y[i];
+ }
+}
+
+static void Xacc_blend_srccolor( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+
+ if (gfxs->Sacc) {
+ GenefxAccumulator *S = gfxs->Sacc;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ X->RGB.r = ((S->RGB.r + 1) * Y->RGB.r) >> 8;
+ X->RGB.g = ((S->RGB.g + 1) * Y->RGB.g) >> 8;
+ X->RGB.b = ((S->RGB.b + 1) * Y->RGB.b) >> 8;
+ X->RGB.a = ((S->RGB.a + 1) * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ S++;
+ }
+ }
+ else {
+ GenefxAccumulator Cacc = gfxs->Cacc;
+ Cacc.RGB.r = Cacc.RGB.r + 1;
+ Cacc.RGB.g = Cacc.RGB.g + 1;
+ Cacc.RGB.b = Cacc.RGB.b + 1;
+ Cacc.RGB.a = Cacc.RGB.a + 1;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ X->RGB.r = (Cacc.RGB.r * Y->RGB.r) >> 8;
+ X->RGB.g = (Cacc.RGB.g * Y->RGB.g) >> 8;
+ X->RGB.b = (Cacc.RGB.b * Y->RGB.b) >> 8;
+ X->RGB.a = (Cacc.RGB.a * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ }
+ }
+}
+
+static void Xacc_blend_invsrccolor( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+
+ if (gfxs->Sacc) {
+ GenefxAccumulator *S = gfxs->Sacc;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ X->RGB.r = ((0x100 - S->RGB.r) * Y->RGB.r) >> 8;
+ X->RGB.g = ((0x100 - S->RGB.g) * Y->RGB.g) >> 8;
+ X->RGB.b = ((0x100 - S->RGB.b) * Y->RGB.b) >> 8;
+ X->RGB.a = ((0x100 - S->RGB.a) * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ S++;
+ }
+ }
+ else {
+ GenefxAccumulator Cacc = gfxs->Cacc;
+ Cacc.RGB.r = 0x100 - Cacc.RGB.r;
+ Cacc.RGB.g = 0x100 - Cacc.RGB.g;
+ Cacc.RGB.b = 0x100 - Cacc.RGB.b;
+ Cacc.RGB.a = 0x100 - Cacc.RGB.a;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ X->RGB.r = (Cacc.RGB.r * Y->RGB.r) >> 8;
+ X->RGB.g = (Cacc.RGB.g * Y->RGB.g) >> 8;
+ X->RGB.b = (Cacc.RGB.b * Y->RGB.b) >> 8;
+ X->RGB.a = (Cacc.RGB.a * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ }
+ }
+}
+
+static void Xacc_blend_srcalpha( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+
+ if (gfxs->Sacc) {
+ GenefxAccumulator *S = gfxs->Sacc;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ register u16 Sa = S->RGB.a + 1;
+
+ X->RGB.r = (Sa * Y->RGB.r) >> 8;
+ X->RGB.g = (Sa * Y->RGB.g) >> 8;
+ X->RGB.b = (Sa * Y->RGB.b) >> 8;
+ X->RGB.a = (Sa * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ S++;
+ }
+ }
+ else {
+ register u16 Sa = gfxs->color.a + 1;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ X->RGB.r = (Sa * Y->RGB.r) >> 8;
+ X->RGB.g = (Sa * Y->RGB.g) >> 8;
+ X->RGB.b = (Sa * Y->RGB.b) >> 8;
+ X->RGB.a = (Sa * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ }
+ }
+}
+
+static void Xacc_blend_invsrcalpha( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+
+ if (gfxs->Sacc) {
+ GenefxAccumulator *S = gfxs->Sacc;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ register u16 Sa = 0x100 - S->RGB.a;
+
+ X->RGB.r = (Sa * Y->RGB.r) >> 8;
+ X->RGB.g = (Sa * Y->RGB.g) >> 8;
+ X->RGB.b = (Sa * Y->RGB.b) >> 8;
+ X->RGB.a = (Sa * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ S++;
+ }
+ }
+ else {
+ register u16 Sa = 0x100 - gfxs->color.a;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ X->RGB.a = (Sa * Y->RGB.a) >> 8;
+ X->RGB.r = (Sa * Y->RGB.r) >> 8;
+ X->RGB.g = (Sa * Y->RGB.g) >> 8;
+ X->RGB.b = (Sa * Y->RGB.b) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ }
+ }
+}
+
+static void Xacc_blend_dstalpha( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ register u16 Da = D->RGB.a + 1;
+
+ X->RGB.r = (Da * Y->RGB.r) >> 8;
+ X->RGB.g = (Da * Y->RGB.g) >> 8;
+ X->RGB.b = (Da * Y->RGB.b) >> 8;
+ X->RGB.a = (Da * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ D++;
+ }
+}
+
+static void Xacc_blend_invdstalpha( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ register u16 Da = 0x100 - D->RGB.a;
+
+ X->RGB.r = (Da * Y->RGB.r) >> 8;
+ X->RGB.g = (Da * Y->RGB.g) >> 8;
+ X->RGB.b = (Da * Y->RGB.b) >> 8;
+ X->RGB.a = (Da * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ D++;
+ }
+}
+
+static void Xacc_blend_destcolor( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ X->RGB.r = ((D->RGB.r + 1) * Y->RGB.r) >> 8;
+ X->RGB.g = ((D->RGB.g + 1) * Y->RGB.g) >> 8;
+ X->RGB.b = ((D->RGB.b + 1) * Y->RGB.b) >> 8;
+ X->RGB.a = ((D->RGB.a + 1) * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ D++;
+ }
+}
+
+static void Xacc_blend_invdestcolor( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ X->RGB.r = ((0x100 - D->RGB.r) * Y->RGB.r) >> 8;
+ X->RGB.g = ((0x100 - D->RGB.g) * Y->RGB.g) >> 8;
+ X->RGB.b = ((0x100 - D->RGB.b) * Y->RGB.b) >> 8;
+ X->RGB.a = ((0x100 - D->RGB.a) * Y->RGB.a) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ D++;
+ }
+}
+
+static void Xacc_blend_srcalphasat( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *X = gfxs->Xacc;
+ GenefxAccumulator *Y = gfxs->Yacc;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ if (gfxs->Sacc) {
+ GenefxAccumulator *S = gfxs->Sacc;
+
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ register u16 Sa = MIN( S->RGB.a + 1, 0x100 - D->RGB.a );
+
+ X->RGB.a = Y->RGB.a;
+ X->RGB.r = (Sa * Y->RGB.r) >> 8;
+ X->RGB.g = (Sa * Y->RGB.g) >> 8;
+ X->RGB.b = (Sa * Y->RGB.b) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ D++;
+ S++;
+ }
+ }
+ else {
+ while (w--) {
+ if (!(Y->RGB.a & 0xF000)) {
+ register u16 Sa = MIN( gfxs->color.a + 1, 0x100 - D->RGB.a );
+
+ X->RGB.a = Y->RGB.a;
+ X->RGB.r = (Sa * Y->RGB.r) >> 8;
+ X->RGB.g = (Sa * Y->RGB.g) >> 8;
+ X->RGB.b = (Sa * Y->RGB.b) >> 8;
+ } else
+ *X = *Y;
+
+ X++;
+ Y++;
+ D++;
+ }
+ }
+}
+
+static GenefxFunc Xacc_blend[] = {
+ Xacc_blend_zero, /* DSBF_ZERO */
+ Xacc_blend_one, /* DSBF_ONE */
+ Xacc_blend_srccolor, /* DSBF_SRCCOLOR */
+ Xacc_blend_invsrccolor, /* DSBF_INVSRCCOLOR */
+ Xacc_blend_srcalpha, /* DSBF_SRCALPHA */
+ Xacc_blend_invsrcalpha, /* DSBF_INVSRCALPHA */
+ Xacc_blend_dstalpha, /* DSBF_DESTALPHA */
+ Xacc_blend_invdstalpha, /* DSBF_INVDESTALPHA */
+ Xacc_blend_destcolor, /* DSBF_DESTCOLOR */
+ Xacc_blend_invdestcolor, /* DSBF_INVDESTCOLOR */
+ Xacc_blend_srcalphasat /* DSBF_SRCALPHASAT */
+};
+
+/********************************* Dacc_modulation ****************************/
+
+static void Dacc_set_alpha( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ int a = gfxs->color.a;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->RGB.a = a;
+ }
+
+ D++;
+ }
+}
+
+static void Dacc_modulate_alpha( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ int a = gfxs->Cacc.RGB.a;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->RGB.a = (a * D->RGB.a) >> 8;
+ }
+
+ D++;
+ }
+}
+
+static void Dacc_modulate_rgb( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ GenefxAccumulator Cacc = gfxs->Cacc;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->RGB.r = (Cacc.RGB.r * D->RGB.r) >> 8;
+ D->RGB.g = (Cacc.RGB.g * D->RGB.g) >> 8;
+ D->RGB.b = (Cacc.RGB.b * D->RGB.b) >> 8;
+ }
+
+ D++;
+ }
+}
+
+static void Dacc_modulate_rgb_set_alpha( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ GenefxAccumulator Cacc = gfxs->Cacc;
+ int a = gfxs->color.a;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->RGB.a = a;
+ D->RGB.r = (Cacc.RGB.r * D->RGB.r) >> 8;
+ D->RGB.g = (Cacc.RGB.g * D->RGB.g) >> 8;
+ D->RGB.b = (Cacc.RGB.b * D->RGB.b) >> 8;
+ }
+
+ D++;
+ }
+}
+
+static void Dacc_modulate_argb( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ GenefxAccumulator Cacc = gfxs->Cacc;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->RGB.a = (Cacc.RGB.a * D->RGB.a) >> 8;
+ D->RGB.r = (Cacc.RGB.r * D->RGB.r) >> 8;
+ D->RGB.g = (Cacc.RGB.g * D->RGB.g) >> 8;
+ D->RGB.b = (Cacc.RGB.b * D->RGB.b) >> 8;
+ }
+
+ D++;
+ }
+}
+
+static GenefxFunc Dacc_modulation[] = {
+ NULL,
+ NULL,
+ Dacc_set_alpha,
+ Dacc_modulate_alpha,
+ Dacc_modulate_rgb,
+ Dacc_modulate_rgb,
+ Dacc_modulate_rgb_set_alpha,
+ Dacc_modulate_argb
+};
+
+/********************************* misc accumulator operations ****************/
+
+static void Dacc_premultiply( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ register u16 Da = D->RGB.a + 1;
+
+ D->RGB.r = (Da * D->RGB.r) >> 8;
+ D->RGB.g = (Da * D->RGB.g) >> 8;
+ D->RGB.b = (Da * D->RGB.b) >> 8;
+ }
+
+ D++;
+ }
+}
+
+static void Dacc_premultiply_color_alpha( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ register u16 Ca = gfxs->Cacc.RGB.a;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->RGB.r = (Ca * D->RGB.r) >> 8;
+ D->RGB.g = (Ca * D->RGB.g) >> 8;
+ D->RGB.b = (Ca * D->RGB.b) >> 8;
+ }
+
+ D++;
+ }
+}
+
+static void Dacc_demultiply( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ register u16 Da = D->RGB.a + 1;
+
+ D->RGB.r = (D->RGB.r << 8) / Da;
+ D->RGB.g = (D->RGB.g << 8) / Da;
+ D->RGB.b = (D->RGB.b << 8) / Da;
+ }
+
+ D++;
+ }
+}
+
+static void Dacc_xor_C( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ DFBColor color = gfxs->color;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->RGB.a ^= color.a;
+ D->RGB.r ^= color.r;
+ D->RGB.g ^= color.g;
+ D->RGB.b ^= color.b;
+ }
+
+ D++;
+ }
+}
+
+static GenefxFunc Dacc_xor = Dacc_xor_C;
+
+static void Sacc_xor_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->RGB.a ^= S->RGB.a;
+ D->RGB.r ^= S->RGB.r;
+ D->RGB.g ^= S->RGB.g;
+ D->RGB.b ^= S->RGB.b;
+ }
+ D++;
+ S++;
+ }
+}
+
+static void Cacc_to_Dacc( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ GenefxAccumulator Cacc = gfxs->Cacc;
+
+ while (w--)
+ *D++ = Cacc;
+}
+
+static void SCacc_add_to_Dacc_C( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ GenefxAccumulator SCacc = gfxs->SCacc;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->RGB.a += SCacc.RGB.a;
+ D->RGB.r += SCacc.RGB.r;
+ D->RGB.g += SCacc.RGB.g;
+ D->RGB.b += SCacc.RGB.b;
+ }
+ D++;
+ }
+}
+
+static GenefxFunc SCacc_add_to_Dacc = SCacc_add_to_Dacc_C;
+
+static void Sacc_add_to_Dacc_C( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->RGB.a += S->RGB.a;
+ D->RGB.r += S->RGB.r;
+ D->RGB.g += S->RGB.g;
+ D->RGB.b += S->RGB.b;
+ }
+ D++;
+ S++;
+ }
+}
+
+static GenefxFunc Sacc_add_to_Dacc = Sacc_add_to_Dacc_C;
+
+/**********************************************************************************************************************/
+
+/* change the last value to adjust the size of the device (1-4) */
+#define SET_PIXEL_DUFFS_DEVICE( D, S, w ) \
+ SET_PIXEL_DUFFS_DEVICE_N( D, S, w, 3 )
+
+#define SET_PIXEL( D, S ) \
+ if (!(S.RGB.a & 0xF000)) { \
+ RGB_TO_YCBCR( S.RGB.r, S.RGB.g, S.RGB.b, \
+ D.YUV.y, D.YUV.u, D.YUV.v ); \
+ }
+
+static void Dacc_RGB_to_YCbCr_C( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ GenefxAccumulator *S = gfxs->Dacc;
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+}
+
+#undef SET_PIXEL_DUFFS_DEVICE
+#undef SET_PIXEL
+
+static GenefxFunc Dacc_RGB_to_YCbCr = Dacc_RGB_to_YCbCr_C;
+
+/**********************************************************************************************************************/
+
+/* change the last value to adjust the size of the device (1-4) */
+#define SET_PIXEL_DUFFS_DEVICE( D, S, w ) \
+ SET_PIXEL_DUFFS_DEVICE_N( D, S, w, 2 )
+
+#define SET_PIXEL( D, S ) \
+ if (!(S.YUV.a & 0xF000)) { \
+ YCBCR_TO_RGB( S.YUV.y, S.YUV.u, S.YUV.v, \
+ D.RGB.r, D.RGB.g, D.RGB.b ); \
+ }
+
+static void Dacc_YCbCr_to_RGB_C( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+ GenefxAccumulator *S = gfxs->Dacc;
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+}
+
+#undef SET_PIXEL_DUFFS_DEVICE
+#undef SET_PIXEL
+
+static GenefxFunc Dacc_YCbCr_to_RGB = Dacc_YCbCr_to_RGB_C;
+
+/**********************************************************************************************************************/
+
+/* change the last value to adjust the size of the device (1-4) */
+#define SET_PIXEL_DUFFS_DEVICE( D, S, w ) \
+ SET_PIXEL_DUFFS_DEVICE_N( D, S, w, 3 )
+
+#define SET_PIXEL( D, S ) \
+ switch (S >> 26) { \
+ case 0: \
+ break; \
+ case 0x3f: \
+ D = RGB32_TO_RGB16( S ); \
+ break; \
+ default: \
+ D = (((( (((S>>8) & 0xf800) | ((S>>3) & 0x001f)) \
+ - (D & 0xf81f)) * ((S>>26)+1) + ((D & 0xf81f)<<6)) & 0x003e07c0) \
+ + \
+ ((( ((S>>5) & 0x07e0) \
+ - (D & 0x07e0)) * ((S>>26)+1) + ((D & 0x07e0)<<6)) & 0x0001f800)) >> 6; \
+ } while (0)
+
+static void Bop_argb_blend_alphachannel_src_invsrc_Aop_rgb16( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u32 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+}
+
+#undef SET_PIXEL_DUFFS_DEVICE
+#undef SET_PIXEL
+
+static void Bop_argb_blend_alphachannel_src_invsrc_Aop_rgb32( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ int Dstep = gfxs->Astep;
+ u32 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+
+ while (w--) {
+ u32 dp32 = *D;
+ u32 sp32 = *S++;
+ int salpha = (sp32 >> 25) + 1;
+
+#define rb (sp32 & 0xff00ff)
+#define g (sp32 & 0x00ff00)
+
+ *D = ((((rb-(dp32 & 0xff00ff))*salpha+((dp32 & 0xff00ff)<<7)) & 0x7f807f80) +
+ ((( g-(dp32 & 0x00ff00))*salpha+((dp32 & 0x00ff00)<<7)) & 0x007f8000)) >> 7;
+ D += Dstep;
+
+#undef rb
+#undef g
+ }
+}
+
+static GenefxFunc Bop_argb_blend_alphachannel_src_invsrc_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ NULL, /* DSPF_ARGB1555 */
+ Bop_argb_blend_alphachannel_src_invsrc_Aop_rgb16, /* DSPF_RGB16 */
+ NULL, /* DSPF_RGB24 */
+ Bop_argb_blend_alphachannel_src_invsrc_Aop_rgb32, /* DSPF_RGB32 */
+ NULL, /* DSPF_ARGB */
+ NULL, /* DSPF_A8 */
+ NULL, /* DSPF_YUY2 */
+ NULL, /* DSPF_RGB332 */
+ NULL, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ NULL, /* DSPF_LUT8 */
+ NULL, /* DSPF_ALUT44 */
+ NULL, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ NULL, /* DSPF_ARGB2554 */
+ NULL, /* DSPF_ARGB4444 */
+ NULL, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ NULL, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ NULL, /* DSPF_ARGB1666 */
+ NULL, /* DSPF_ARGB6666 */
+ NULL, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ NULL, /* DSPF_RGB444 */
+ NULL, /* DSPF_RGB555 */
+ NULL /* DSPF_BGR555 */
+};
+
+/**********************************************************************************************************************/
+
+/* change the last value to adjust the size of the device (1-4) */
+#define SET_PIXEL_DUFFS_DEVICE( D, S, w ) \
+ SET_PIXEL_DUFFS_DEVICE_N( D, S, w, 3 )
+
+#define SET_PIXEL( D, S ) \
+do { \
+ int invsrc = 256 - (S >> 24); \
+ \
+ u32 Drb = ((D & 0x00ff00ff) * invsrc) >> 8; \
+ u32 Dag = ((D & 0xff00ff00) >> 8) * invsrc; \
+ \
+ D = S + (Drb & 0x00ff00ff) + (Dag & 0xff00ff00); \
+} while (0)
+
+static void Bop_argb_blend_alphachannel_one_invsrc_Aop_argb( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u32 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+
+ SET_PIXEL_DUFFS_DEVICE( D, S, w );
+}
+
+#undef SET_PIXEL_DUFFS_DEVICE
+#undef SET_PIXEL
+
+static GenefxFunc Bop_argb_blend_alphachannel_one_invsrc_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
+ NULL, /* DSPF_ARGB1555 */
+ NULL, /* DSPF_RGB16 */
+ NULL, /* DSPF_RGB24 */
+ Bop_argb_blend_alphachannel_one_invsrc_Aop_argb, /* DSPF_RGB32 */
+ Bop_argb_blend_alphachannel_one_invsrc_Aop_argb, /* DSPF_ARGB */
+ NULL, /* DSPF_A8 */
+ NULL, /* DSPF_YUY2 */
+ NULL, /* DSPF_RGB332 */
+ NULL, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ NULL, /* DSPF_LUT8 */
+ NULL, /* DSPF_ALUT44 */
+ NULL, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ NULL, /* DSPF_ARGB2554 */
+ NULL, /* DSPF_ARGB4444 */
+ NULL, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ NULL, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ NULL, /* DSPF_ARGB1666 */
+ NULL, /* DSPF_ARGB6666 */
+ NULL, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ NULL, /* DSPF_RGB444 */
+ NULL, /* DSPF_RGB555 */
+ NULL /* DSPF_BGR555 */
+};
+
+/**********************************************************************************************************************/
+
+/* A8/A1 to YCbCr */
+static void Dacc_Alpha_to_YCbCr( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ while (w--) {
+ if (!(D->RGB.a & 0xF000)) {
+ D->YUV.y = 235;
+ D->YUV.u = 128;
+ D->YUV.v = 128;
+ }
+
+ D++;
+ }
+}
+
+/**********************************************************************************************************************/
+
+static void Sop_is_Aop( GenefxState *gfxs ) { gfxs->Sop = gfxs->Aop; gfxs->Ostep = gfxs->Astep; }
+static void Sop_is_Bop( GenefxState *gfxs ) { gfxs->Sop = gfxs->Bop; gfxs->Ostep = gfxs->Bstep; }
+
+static void Slut_is_Alut( GenefxState *gfxs ) { gfxs->Slut = gfxs->Alut;}
+static void Slut_is_Blut( GenefxState *gfxs ) { gfxs->Slut = gfxs->Blut;}
+
+static void Sacc_is_NULL( GenefxState *gfxs ) { gfxs->Sacc = NULL;}
+static void Sacc_is_Aacc( GenefxState *gfxs ) { gfxs->Sacc = gfxs->Aacc;}
+static void Sacc_is_Bacc( GenefxState *gfxs ) { gfxs->Sacc = gfxs->Bacc;}
+static void Sacc_is_Tacc( GenefxState *gfxs ) { gfxs->Sacc = gfxs->Tacc;}
+
+static void Dacc_is_Aacc( GenefxState *gfxs ) { gfxs->Dacc = gfxs->Aacc;}
+static void Dacc_is_Bacc( GenefxState *gfxs ) { gfxs->Dacc = gfxs->Bacc;}
+
+static void Xacc_is_Aacc( GenefxState *gfxs ) { gfxs->Xacc = gfxs->Aacc;}
+static void Xacc_is_Bacc( GenefxState *gfxs ) { gfxs->Xacc = gfxs->Bacc;}
+static void Xacc_is_Tacc( GenefxState *gfxs ) { gfxs->Xacc = gfxs->Tacc;}
+
+static void Yacc_is_Aacc( GenefxState *gfxs ) { gfxs->Yacc = gfxs->Aacc;}
+static void Yacc_is_Bacc( GenefxState *gfxs ) { gfxs->Yacc = gfxs->Bacc;}
+
+static void Len_is_Slen( GenefxState *gfxs ) { gfxs->length = gfxs->Slen;}
+static void Len_is_Dlen( GenefxState *gfxs ) { gfxs->length = gfxs->Dlen;}
+
+/******************************************************************************/
+
+#ifdef USE_MMX
+static bool has_mmx( void )
+{
+#ifdef ARCH_X86_64
+ return true;
+#else
+ u32 a, b, c, d;
+
+ asm( "pushfl \n"
+ "pushfl \n"
+ "popl %0 \n"
+ "movl %0, %1 \n"
+ "xorl $0x200000, %0 \n"
+ "pushl %0 \n"
+ "popfl \n"
+ "pushfl \n"
+ "popl %0 \n"
+ "popfl"
+ : "=a" (a), "=r" (b)
+ :
+ : "cc" );
+
+ if (a == b)
+ return false;
+
+ asm( "pushl %%ebx \n"
+ "cpuid \n"
+ "movl %%ebx, %1 \n"
+ "popl %%ebx"
+ : "=a" (a), "=r" (b), "=c" (c), "=d" (d)
+ : "a" (0)
+ : "cc" );
+
+ if (!a)
+ return false;
+
+ asm( "pushl %%ebx \n"
+ "cpuid \n"
+ "movl %%ebx, %1 \n"
+ "popl %%ebx"
+ : "=a" (a), "=r" (b), "=c" (c), "=d" (d)
+ : "a" (1)
+ : "cc" );
+
+ return (d & 0x800000) ? true : false;
+#endif /* !ARCH_X86_64 */
+}
+#endif
+
+void gGetDriverInfo( GraphicsDriverInfo *info )
+{
+ snprintf( info->name,
+ DFB_GRAPHICS_DRIVER_INFO_NAME_LENGTH, "Software Driver" );
+
+#if SIZEOF_LONG == 8
+ gInit_64bit();
+#endif
+
+#ifdef USE_MMX
+ if (has_mmx()) {
+ if (!dfb_config->mmx) {
+ D_INFO( "DirectFB/Genefx: MMX detected, but disabled by option 'no-mmx'\n");
+ }
+ else {
+ gInit_MMX();
+
+ snprintf( info->name, DFB_GRAPHICS_DRIVER_INFO_NAME_LENGTH,
+ "MMX Software Driver" );
+
+ D_INFO( "DirectFB/Genefx: MMX detected and enabled\n");
+ }
+ }
+ else {
+ D_INFO( "DirectFB/Genefx: No MMX detected\n" );
+ }
+#endif
+
+ snprintf( info->vendor, DFB_GRAPHICS_DRIVER_INFO_VENDOR_LENGTH, "directfb.org" );
+
+ info->version.major = 0;
+ info->version.minor = 6;
+}
+
+void gGetDeviceInfo( GraphicsDeviceInfo *info )
+{
+ snprintf( info->name, DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH,
+ "Software Rasterizer" );
+
+ snprintf( info->vendor, DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH,
+ use_mmx ? "MMX" : "Generic" );
+
+ info->caps.accel = DFXL_NONE;
+ info->caps.flags = 0;
+ info->caps.drawing = DSDRAW_NOFX;
+ info->caps.blitting = DSBLIT_NOFX;
+}
+
+#define MODULATION_FLAGS (DSBLIT_BLEND_ALPHACHANNEL | \
+ DSBLIT_BLEND_COLORALPHA | \
+ DSBLIT_COLORIZE | \
+ DSBLIT_DST_PREMULTIPLY | \
+ DSBLIT_SRC_PREMULTIPLY | \
+ DSBLIT_SRC_PREMULTCOLOR | \
+ DSBLIT_DEMULTIPLY | \
+ DSBLIT_XOR)
+
+#ifndef WORDS_BIGENDIAN
+#define BGR_TO_RGB16(pixel) ( (((pixel) << 8) & 0xF800) | \
+ (((pixel) >> 5) & 0x07E0) | \
+ (((pixel) >> 19) & 0x001F) )
+
+/*
+ * Fast RGB24 to RGB16 conversion.
+ */
+static void
+Bop_rgb24_to_Aop_rgb16_LE( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u8 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+
+ while ((unsigned long)S & 3) {
+ *D++ = PIXEL_RGB16( S[0], S[1], S[2] );
+
+ S += 3;
+ w -= 1;
+ }
+
+ if ((unsigned long)D & 2) {
+ *D++ = PIXEL_RGB16( S[0], S[1], S[2] );
+
+ w -= 1;
+ S += 3;
+
+ while (w > 1) {
+ *(u32*)D = PIXEL_RGB16( S[0], S[1], S[2] ) | (PIXEL_RGB16( S[3], S[4], S[5] ) << 16);
+
+ w -= 2;
+ D += 2;
+ S += 6;
+ }
+ }
+ else {
+ u32 *S32 = (u32*)S;
+ u32 *D32 = (u32*)D;
+
+ while (w > 3) {
+ D32[0] = BGR_TO_RGB16( S32[0] ) | (BGR_TO_RGB16( (S32[0] >> 24) | (S32[1] << 8) ) << 16);
+ D32[1] = BGR_TO_RGB16( (S32[1] >> 16) | (S32[2] << 16) ) | (BGR_TO_RGB16( S32[2] >> 8 ) << 16);
+
+ D32 += 2;
+ S32 += 3;
+ w -= 4;
+ }
+
+ S = (u8*) S32;
+ D = (u16*) D32;
+ }
+
+ while (w > 0) {
+ *D++ = PIXEL_RGB16( S[0], S[1], S[2] );
+
+ w -= 1;
+ S += 3;
+ }
+}
+
+/*
+ * Fast RGB32 to RGB16 conversion.
+ */
+static void
+Bop_rgb32_to_Aop_rgb16_LE( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u32 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+
+ if ((unsigned long)D & 2) {
+ u16 *d = (u16*)D;
+
+ d[0] = RGB32_TO_RGB16( S[0] );
+
+ w--;
+ S++;
+
+ D = (u32*)(d+1);
+ }
+
+ while (w > 1) {
+ D[0] = RGB32_TO_RGB16( S[0] ) | (RGB32_TO_RGB16( S[1] ) << 16);
+
+ w -= 2;
+ S += 2;
+ D += 1;
+ }
+
+ if (w > 0) {
+ u16 *d = (u16*)D;
+
+ d[0] = RGB32_TO_RGB16( S[0] );
+ }
+}
+#endif /* #ifndef WORDS_BIGENDIAN */
+
+bool gAcquire( CardState *state, DFBAccelerationMask accel )
+{
+ DFBResult ret;
+ GenefxState *gfxs;
+ GenefxFunc *funcs;
+ int dst_pfi;
+ int src_pfi = 0;
+ CoreSurface *destination = state->destination;
+ CoreSurface *source = state->source;
+ DFBColor color = state->color;
+ bool src_ycbcr = false;
+ bool dst_ycbcr = false;
+
+ CoreSurfaceAccessFlags access = CSAF_WRITE;
+
+ if (dfb_config->hardware_only) {
+ if (dfb_config->software_warn) {
+ if (DFB_BLITTING_FUNCTION( accel ))
+ D_WARN( "Ignoring blit (%x) from %s to %s, flags 0x%08x, funcs %d %d", accel,
+ source ? dfb_pixelformat_name(source->config.format) : "NULL SOURCE",
+ destination ? dfb_pixelformat_name(destination->config.format) : "NULL DESTINATION",
+ state->blittingflags, state->src_blend, state->dst_blend );
+ else
+ D_WARN( "Ignoring draw (%x) to %s, flags 0x%08x", accel,
+ destination ? dfb_pixelformat_name(destination->config.format) : "NULL DESTINATION",
+ state->drawingflags );
+ }
+
+ return false;
+ }
+
+ if (!state->gfxs) {
+ gfxs = D_CALLOC( 1, sizeof(GenefxState) );
+ if (!gfxs) {
+ D_ERROR( "DirectFB/Genefx: Couldn't allocate state struct!\n" );
+ return false;
+ }
+
+ state->gfxs = gfxs;
+ }
+
+ gfxs = state->gfxs;
+ funcs = gfxs->funcs;
+
+ /* Destination may have been destroyed. */
+ if (!destination)
+ return false;
+
+ /* Source may have been destroyed. */
+ if (DFB_BLITTING_FUNCTION( accel ) && !source)
+ return false;
+
+ /*
+ * Destination setup
+ */
+
+ if (DFB_BLITTING_FUNCTION( accel )) {
+ if (state->blittingflags & (DSBLIT_BLEND_ALPHACHANNEL |
+ DSBLIT_BLEND_COLORALPHA |
+ DSBLIT_DST_COLORKEY))
+ access |= CSAF_READ;
+ }
+ else if (state->drawingflags & (DSDRAW_BLEND | DSDRAW_DST_COLORKEY))
+ access |= CSAF_READ;
+
+ /* Lock destination */
+ ret = dfb_surface_lock_buffer( destination, state->to, CSAID_CPU, access, &state->dst );
+ if (ret) {
+ D_DERROR( ret, "DirectFB/Genefx: Could not lock destination!\n" );
+ return false;
+ }
+
+ gfxs->dst_caps = destination->config.caps;
+ gfxs->dst_height = destination->config.size.h;
+ gfxs->dst_format = destination->config.format;
+ gfxs->dst_bpp = DFB_BYTES_PER_PIXEL( gfxs->dst_format );
+ dst_pfi = DFB_PIXELFORMAT_INDEX( gfxs->dst_format );
+
+ gfxs->dst_org[0] = state->dst.addr;
+ gfxs->dst_pitch = state->dst.pitch;
+
+ switch (gfxs->dst_format) {
+ case DSPF_I420:
+ gfxs->dst_org[1] = gfxs->dst_org[0] + gfxs->dst_height * gfxs->dst_pitch;
+ gfxs->dst_org[2] = gfxs->dst_org[1] + gfxs->dst_height/2 * gfxs->dst_pitch/2;
+ break;
+ case DSPF_YV12:
+ gfxs->dst_org[2] = gfxs->dst_org[0] + gfxs->dst_height * gfxs->dst_pitch;
+ gfxs->dst_org[1] = gfxs->dst_org[2] + gfxs->dst_height/2 * gfxs->dst_pitch/2;
+ break;
+ case DSPF_NV12:
+ case DSPF_NV21:
+ case DSPF_NV16:
+ gfxs->dst_org[1] = gfxs->dst_org[0] + gfxs->dst_height * gfxs->dst_pitch;
+ break;
+ default:
+ break;
+ }
+
+ gfxs->dst_field_offset = gfxs->dst_height/2 * gfxs->dst_pitch;
+
+
+ /*
+ * Source setup
+ */
+
+ if (DFB_BLITTING_FUNCTION( accel )) {
+#if FIXME_SC_3
+ DFBSurfaceLockFlags flags = DSLF_READ;
+
+ if (accel == DFXL_STRETCHBLIT)
+ flags |= CSLF_FORCE;
+#endif
+
+ /* Lock source */
+ ret = dfb_surface_lock_buffer( source, state->from, CSAID_CPU, CSAF_READ, &state->src );
+ if (ret) {
+ D_DERROR( ret, "DirectFB/Genefx: Could not lock source!\n" );
+ dfb_surface_unlock_buffer( destination, &state->dst );
+ return false;
+ }
+
+ gfxs->src_caps = source->config.caps;
+ gfxs->src_height = source->config.size.h;
+ gfxs->src_format = source->config.format;
+ gfxs->src_bpp = DFB_BYTES_PER_PIXEL( gfxs->src_format );
+ src_pfi = DFB_PIXELFORMAT_INDEX( gfxs->src_format );
+
+ gfxs->src_org[0] = state->src.addr;
+ gfxs->src_pitch = state->src.pitch;
+
+ switch (gfxs->src_format) {
+ case DSPF_I420:
+ gfxs->src_org[1] = gfxs->src_org[0] + gfxs->src_height * gfxs->src_pitch;
+ gfxs->src_org[2] = gfxs->src_org[1] + gfxs->src_height/2 * gfxs->src_pitch/2;
+ break;
+ case DSPF_YV12:
+ gfxs->src_org[2] = gfxs->src_org[0] + gfxs->src_height * gfxs->src_pitch;
+ gfxs->src_org[1] = gfxs->src_org[2] + gfxs->src_height/2 * gfxs->src_pitch/2;
+ break;
+ case DSPF_NV12:
+ case DSPF_NV21:
+ case DSPF_NV16:
+ gfxs->src_org[1] = gfxs->src_org[0] + gfxs->src_height * gfxs->src_pitch;
+ break;
+ default:
+ break;
+ }
+
+ gfxs->src_field_offset = gfxs->src_height/2 * gfxs->src_pitch;
+
+ state->flags |= CSF_SOURCE_LOCKED;
+ }
+
+
+ /* premultiply source (color) */
+ if (DFB_DRAWING_FUNCTION(accel) && (state->drawingflags & DSDRAW_SRC_PREMULTIPLY)) {
+ u16 ca = color.a + 1;
+
+ color.r = (color.r * ca) >> 8;
+ color.g = (color.g * ca) >> 8;
+ color.b = (color.b * ca) >> 8;
+ }
+
+
+ gfxs->color = color;
+
+
+ switch (gfxs->dst_format) {
+ case DSPF_ARGB1555:
+ gfxs->Cop = PIXEL_ARGB1555( color.a, color.r, color.g, color.b );
+ break;
+ case DSPF_RGB16:
+ gfxs->Cop = PIXEL_RGB16( color.r, color.g, color.b );
+ break;
+ case DSPF_RGB18:
+ gfxs->Cop = PIXEL_RGB18( color.r, color.g, color.b );
+ break;
+ case DSPF_RGB24:
+ gfxs->Cop = PIXEL_RGB32( color.r, color.g, color.b );
+ break;
+ case DSPF_RGB32:
+ gfxs->Cop = PIXEL_RGB32( color.r, color.g, color.b );
+ break;
+ case DSPF_ARGB:
+ gfxs->Cop = PIXEL_ARGB( color.a, color.r, color.g, color.b );
+ break;
+ case DSPF_AiRGB:
+ gfxs->Cop = PIXEL_AiRGB( color.a, color.r, color.g, color.b );
+ break;
+ case DSPF_ARGB6666:
+ gfxs->Cop = PIXEL_ARGB6666( color.a, color.r, color.g, color.b );
+ break;
+ case DSPF_ARGB1666:
+ gfxs->Cop = PIXEL_ARGB1666( color.a, color.r, color.g, color.b );
+ break;
+ case DSPF_A1:
+ gfxs->Cop = color.a >> 7;
+ break;
+ case DSPF_A4:
+ gfxs->Cop = color.a >> 4;
+ break;
+ case DSPF_A8:
+ gfxs->Cop = color.a;
+ break;
+ case DSPF_YUY2:
+ RGB_TO_YCBCR( color.r, color.g, color.b,
+ gfxs->YCop, gfxs->CbCop, gfxs->CrCop );
+ gfxs->Cop = PIXEL_YUY2( gfxs->YCop, gfxs->CbCop, gfxs->CrCop );
+ dst_ycbcr = true;
+ break;
+ case DSPF_RGB332:
+ gfxs->Cop = PIXEL_RGB332( color.r, color.g, color.b );
+ break;
+ case DSPF_UYVY:
+ RGB_TO_YCBCR( color.r, color.g, color.b,
+ gfxs->YCop, gfxs->CbCop, gfxs->CrCop );
+ gfxs->Cop = PIXEL_UYVY( gfxs->YCop, gfxs->CbCop, gfxs->CrCop );
+ dst_ycbcr = true;
+ break;
+ case DSPF_I420:
+ case DSPF_YV12:
+ case DSPF_NV12:
+ case DSPF_NV16:
+ RGB_TO_YCBCR( color.r, color.g, color.b,
+ gfxs->YCop, gfxs->CbCop, gfxs->CrCop );
+ gfxs->Cop = gfxs->YCop;
+ dst_ycbcr = true;
+ break;
+ case DSPF_NV21:
+ RGB_TO_YCBCR( color.r, color.g, color.b,
+ gfxs->YCop, gfxs->CrCop, gfxs->CbCop );
+ gfxs->Cop = gfxs->YCop;
+ dst_ycbcr = true;
+ break;
+ case DSPF_LUT2:
+ case DSPF_LUT8:
+ gfxs->Cop = state->color_index;
+ gfxs->Alut = destination->palette;
+ break;
+ case DSPF_ALUT44:
+ gfxs->Cop = (color.a & 0xF0) + state->color_index;
+ gfxs->Alut = destination->palette;
+ break;
+ case DSPF_ARGB2554:
+ gfxs->Cop = PIXEL_ARGB2554( color.a, color.r, color.g, color.b );
+ break;
+ case DSPF_ARGB4444:
+ gfxs->Cop = PIXEL_ARGB4444( color.a, color.r, color.g, color.b );
+ break;
+ case DSPF_RGBA4444:
+ gfxs->Cop = PIXEL_RGBA4444( color.a, color.r, color.g, color.b );
+ break;
+ case DSPF_AYUV:
+ RGB_TO_YCBCR( color.r, color.g, color.b,
+ gfxs->YCop, gfxs->CbCop, gfxs->CrCop );
+ gfxs->Cop = PIXEL_AYUV( color.a, gfxs->YCop, gfxs->CbCop, gfxs->CrCop );
+ dst_ycbcr = true;
+ break;
+ case DSPF_RGB444:
+ gfxs->Cop = PIXEL_RGB444( color.r, color.g, color.b );
+ break;
+ case DSPF_RGB555:
+ gfxs->Cop = PIXEL_RGB555( color.r, color.g, color.b );
+ break;
+ case DSPF_BGR555:
+ gfxs->Cop = PIXEL_BGR555( color.r, color.g, color.b );
+ break;
+ default:
+ D_ONCE("unsupported destination format");
+ return false;
+ }
+
+ if (DFB_BLITTING_FUNCTION( accel )) {
+ switch (gfxs->src_format) {
+ case DSPF_LUT2:
+ case DSPF_LUT8:
+ case DSPF_ALUT44:
+ gfxs->Blut = source->palette;
+ case DSPF_ARGB1555:
+ case DSPF_ARGB2554:
+ case DSPF_ARGB4444:
+ case DSPF_RGBA4444:
+ case DSPF_ARGB1666:
+ case DSPF_ARGB6666:
+ case DSPF_RGB16:
+ case DSPF_RGB18:
+ case DSPF_RGB24:
+ case DSPF_RGB32:
+ case DSPF_ARGB:
+ case DSPF_AiRGB:
+ case DSPF_RGB332:
+ case DSPF_RGB444:
+ case DSPF_RGB555:
+ case DSPF_BGR555:
+ if (dst_ycbcr &&
+ state->blittingflags & (DSBLIT_COLORIZE |
+ DSBLIT_SRC_PREMULTCOLOR))
+ return false;
+ case DSPF_A1:
+ case DSPF_A4:
+ case DSPF_A8:
+ if (DFB_PLANAR_PIXELFORMAT(gfxs->dst_format) &&
+ state->blittingflags & DSBLIT_DST_COLORKEY)
+ return false;
+ break;
+ case DSPF_I420:
+ case DSPF_YV12:
+ case DSPF_NV12:
+ case DSPF_NV21:
+ case DSPF_NV16:
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY)
+ return false;
+ case DSPF_YUY2:
+ case DSPF_UYVY:
+ case DSPF_AYUV:
+ if (dst_ycbcr) {
+ if (state->blittingflags & (DSBLIT_COLORIZE |
+ DSBLIT_SRC_PREMULTCOLOR))
+ return false;
+
+ if (DFB_PLANAR_PIXELFORMAT(gfxs->dst_format) &&
+ state->blittingflags & DSBLIT_DST_COLORKEY)
+ return false;
+ }
+ src_ycbcr = true;
+ break;
+ default:
+ D_ONCE("unsupported source format");
+ return false;
+ }
+ }
+
+ gfxs->need_accumulator = true;
+
+ /* Initialization */
+ gfxs->Astep = gfxs->Bstep = gfxs->Ostep = 1;
+
+ switch (accel) {
+ case DFXL_FILLRECTANGLE:
+ case DFXL_DRAWRECTANGLE:
+ case DFXL_DRAWLINE:
+ case DFXL_FILLTRIANGLE:
+ if (state->drawingflags & ~(DSDRAW_DST_COLORKEY | DSDRAW_SRC_PREMULTIPLY)) {
+ GenefxAccumulator Cacc, SCacc;
+
+ /* not yet completed optimizing checks */
+ if (state->drawingflags & DSDRAW_BLEND) {
+ if (state->src_blend == DSBF_ZERO) {
+ if (state->dst_blend == DSBF_ZERO) {
+ gfxs->Cop = 0;
+ if (state->drawingflags & DSDRAW_DST_COLORKEY) {
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Cop_toK_Aop_PFI[dst_pfi];
+ }
+ else
+ *funcs++ = Cop_to_Aop_PFI[dst_pfi];
+ break;
+ }
+ else if (state->dst_blend == DSBF_ONE) {
+ break;
+ }
+ }
+ else if (state->src_blend == DSBF_ONE && state->dst_blend == DSBF_ZERO) {
+ if (state->drawingflags & DSDRAW_DST_COLORKEY) {
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Cop_toK_Aop_PFI[dst_pfi];
+ }
+ else
+ *funcs++ = Cop_to_Aop_PFI[dst_pfi];
+ break;
+ }
+ }
+
+ /* load from destination */
+ *funcs++ = Sop_is_Aop;
+ if (DFB_PIXELFORMAT_IS_INDEXED(gfxs->dst_format))
+ *funcs++ = Slut_is_Alut;
+ *funcs++ = Dacc_is_Aacc;
+ *funcs++ = Sop_PFI_to_Dacc[dst_pfi];
+
+ /* premultiply destination */
+ if (state->drawingflags & DSDRAW_DST_PREMULTIPLY)
+ *funcs++ = Dacc_premultiply;
+
+ /* xor destination */
+ if (state->drawingflags & DSDRAW_XOR)
+ *funcs++ = Dacc_xor;
+
+ /* load source (color) */
+ Cacc.RGB.a = color.a;
+ if (!dst_ycbcr) {
+ Cacc.RGB.r = color.r;
+ Cacc.RGB.g = color.g;
+ Cacc.RGB.b = color.b;
+ } else {
+ Cacc.YUV.y = gfxs->YCop;
+ Cacc.YUV.u = gfxs->CbCop;
+ Cacc.YUV.v = gfxs->CrCop;
+ }
+
+ /* premultiply source (color) */
+ /*if (state->drawingflags & DSDRAW_SRC_PREMULTIPLY) {
+ u16 ca = color.a + 1;
+
+ Cacc.r = (Cacc.r * ca) >> 8;
+ Cacc.g = (Cacc.g * ca) >> 8;
+ Cacc.b = (Cacc.b * ca) >> 8;
+ }*/
+
+ if (state->drawingflags & DSDRAW_BLEND) {
+ /* source blending */
+ switch (state->src_blend) {
+ case DSBF_ZERO:
+ break;
+ case DSBF_ONE:
+ SCacc = Cacc;
+ break;
+ case DSBF_SRCCOLOR:
+ SCacc.RGB.a = (Cacc.RGB.a * (Cacc.RGB.a + 1)) >> 8;
+ SCacc.RGB.r = (Cacc.RGB.r * (Cacc.RGB.r + 1)) >> 8;
+ SCacc.RGB.g = (Cacc.RGB.g * (Cacc.RGB.g + 1)) >> 8;
+ SCacc.RGB.b = (Cacc.RGB.b * (Cacc.RGB.b + 1)) >> 8;
+ break;
+ case DSBF_INVSRCCOLOR:
+ SCacc.RGB.a = (Cacc.RGB.a * (0x100 - Cacc.RGB.a)) >> 8;
+ SCacc.RGB.r = (Cacc.RGB.r * (0x100 - Cacc.RGB.r)) >> 8;
+ SCacc.RGB.g = (Cacc.RGB.g * (0x100 - Cacc.RGB.g)) >> 8;
+ SCacc.RGB.b = (Cacc.RGB.b * (0x100 - Cacc.RGB.b)) >> 8;
+ break;
+ case DSBF_SRCALPHA: {
+ u16 ca = color.a + 1;
+
+ SCacc.RGB.a = (Cacc.RGB.a * ca) >> 8;
+ SCacc.RGB.r = (Cacc.RGB.r * ca) >> 8;
+ SCacc.RGB.g = (Cacc.RGB.g * ca) >> 8;
+ SCacc.RGB.b = (Cacc.RGB.b * ca) >> 8;
+ break;
+ }
+ case DSBF_INVSRCALPHA: {
+ u16 ca = 0x100 - color.a;
+
+ SCacc.RGB.a = (Cacc.RGB.a * ca) >> 8;
+ SCacc.RGB.r = (Cacc.RGB.r * ca) >> 8;
+ SCacc.RGB.g = (Cacc.RGB.g * ca) >> 8;
+ SCacc.RGB.b = (Cacc.RGB.b * ca) >> 8;
+ break;
+ }
+ case DSBF_SRCALPHASAT:
+ *funcs++ = Sacc_is_NULL;
+ case DSBF_DESTALPHA:
+ case DSBF_INVDESTALPHA:
+ case DSBF_DESTCOLOR:
+ case DSBF_INVDESTCOLOR:
+ *funcs++ = Dacc_is_Bacc;
+ *funcs++ = Cacc_to_Dacc;
+
+ *funcs++ = Dacc_is_Aacc;
+ *funcs++ = Xacc_is_Bacc;
+ *funcs++ = Yacc_is_Bacc;
+ *funcs++ = Xacc_blend[state->src_blend - 1];
+
+ break;
+
+ default:
+ D_BUG( "unknown src_blend %d", state->src_blend );
+ }
+
+
+ /* destination blending */
+ *funcs++ = Sacc_is_NULL;
+ *funcs++ = Xacc_is_Aacc;
+ *funcs++ = Yacc_is_Aacc;
+
+ if (state->dst_blend > D_ARRAY_SIZE(Xacc_blend) || state->dst_blend < 1)
+ D_BUG( "unknown dst_blend %d", state->dst_blend );
+ else
+ *funcs++ = Xacc_blend[state->dst_blend - 1];
+
+ /* add source to destination accumulator */
+ switch (state->src_blend) {
+ case DSBF_ZERO:
+ break;
+ case DSBF_ONE:
+ case DSBF_SRCCOLOR:
+ case DSBF_INVSRCCOLOR:
+ case DSBF_SRCALPHA:
+ case DSBF_INVSRCALPHA:
+ if (SCacc.RGB.a || SCacc.RGB.r ||
+ SCacc.RGB.g || SCacc.RGB.b)
+ *funcs++ = SCacc_add_to_Dacc;
+ break;
+ case DSBF_DESTALPHA:
+ case DSBF_INVDESTALPHA:
+ case DSBF_DESTCOLOR:
+ case DSBF_INVDESTCOLOR:
+ case DSBF_SRCALPHASAT:
+ *funcs++ = Sacc_is_Bacc;
+ *funcs++ = Sacc_add_to_Dacc;
+ break;
+
+ default:
+ D_BUG( "unknown src_blend %d", state->src_blend );
+ }
+ }
+
+ /* demultiply result */
+ if (state->drawingflags & DSDRAW_DEMULTIPLY)
+ *funcs++ = Dacc_demultiply;
+
+ /* write to destination */
+ *funcs++ = Sacc_is_Aacc;
+ if (state->drawingflags & DSDRAW_DST_COLORKEY) {
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Sacc_toK_Aop_PFI[dst_pfi];
+ }
+ else
+ *funcs++ = Sacc_to_Aop_PFI[dst_pfi];
+
+ /* store computed Cacc */
+ gfxs->Cacc = Cacc;
+ gfxs->SCacc = SCacc;
+ }
+ else {
+ gfxs->need_accumulator = false;
+
+ if (state->drawingflags & DSDRAW_DST_COLORKEY) {
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Cop_toK_Aop_PFI[dst_pfi];
+ }
+ else
+ *funcs++ = Cop_to_Aop_PFI[dst_pfi];
+ }
+ break;
+ case DFXL_BLIT:
+ if (state->blittingflags == DSBLIT_BLEND_ALPHACHANNEL &&
+ state->src_blend == DSBF_SRCALPHA &&
+ state->dst_blend == DSBF_INVSRCALPHA)
+ {
+ if (gfxs->src_format == DSPF_ARGB &&
+ Bop_argb_blend_alphachannel_src_invsrc_Aop_PFI[dst_pfi])
+ {
+ *funcs++ = Bop_argb_blend_alphachannel_src_invsrc_Aop_PFI[dst_pfi];
+ break;
+ }
+ }
+ if (state->blittingflags == DSBLIT_BLEND_ALPHACHANNEL &&
+ state->src_blend == DSBF_ONE &&
+ state->dst_blend == DSBF_INVSRCALPHA)
+ {
+ if (gfxs->src_format == DSPF_ARGB &&
+ Bop_argb_blend_alphachannel_one_invsrc_Aop_PFI[dst_pfi])
+ {
+ *funcs++ = Bop_argb_blend_alphachannel_one_invsrc_Aop_PFI[dst_pfi];
+ break;
+ }
+ }
+ if (((state->blittingflags == (DSBLIT_COLORIZE | DSBLIT_BLEND_ALPHACHANNEL |
+ DSBLIT_SRC_PREMULTIPLY) &&
+ state->src_blend == DSBF_ONE)
+ ||
+ (state->blittingflags == (DSBLIT_COLORIZE | DSBLIT_BLEND_ALPHACHANNEL) &&
+ state->src_blend == DSBF_SRCALPHA))
+ &&
+ state->dst_blend == DSBF_INVSRCALPHA)
+ {
+ if (gfxs->src_format == DSPF_A8 && Bop_a8_set_alphapixel_Aop_PFI[dst_pfi]) {
+ *funcs++ = Bop_a8_set_alphapixel_Aop_PFI[dst_pfi];
+ break;
+ }
+ if (gfxs->src_format == DSPF_A1 && Bop_a1_set_alphapixel_Aop_PFI[dst_pfi]) {
+ *funcs++ = Bop_a1_set_alphapixel_Aop_PFI[dst_pfi];
+ break;
+ }
+ }
+#ifndef WORDS_BIGENDIAN
+ if (state->blittingflags == DSBLIT_NOFX &&
+ source->config.format == DSPF_RGB24 &&
+ destination->config.format == DSPF_RGB16)
+ {
+ *funcs++ = Bop_rgb24_to_Aop_rgb16_LE;
+ break;
+ }
+ if (state->blittingflags == DSBLIT_NOFX &&
+ (source->config.format == DSPF_RGB32 || source->config.format == DSPF_ARGB) &&
+ destination->config.format == DSPF_RGB16)
+ {
+ *funcs++ = Bop_rgb32_to_Aop_rgb16_LE;
+ break;
+ }
+#endif
+ /* fallthru */
+ case DFXL_STRETCHBLIT: {
+ int modulation = state->blittingflags & MODULATION_FLAGS;
+
+ if (modulation) {
+ bool read_destination = false;
+ bool source_needs_destination = false;
+ bool scale_from_accumulator;
+
+ /* check if destination has to be read */
+ if (state->blittingflags & (DSBLIT_BLEND_ALPHACHANNEL |
+ DSBLIT_BLEND_COLORALPHA)) {
+ switch (state->src_blend) {
+ case DSBF_DESTALPHA:
+ case DSBF_DESTCOLOR:
+ case DSBF_INVDESTALPHA:
+ case DSBF_INVDESTCOLOR:
+ case DSBF_SRCALPHASAT:
+ source_needs_destination = true;
+ default:
+ ;
+ }
+
+ read_destination = source_needs_destination ||
+ (state->dst_blend != DSBF_ZERO) ||
+ (state->blittingflags & DSBLIT_XOR);
+ }
+ else if (state->blittingflags & DSBLIT_XOR) {
+ read_destination = true;
+ }
+
+ scale_from_accumulator = !read_destination &&
+ (accel == DFXL_STRETCHBLIT);
+
+ /* read the destination if needed */
+ if (read_destination) {
+ *funcs++ = Sop_is_Aop;
+ if (DFB_PIXELFORMAT_IS_INDEXED(gfxs->dst_format))
+ *funcs++ = Slut_is_Alut;
+ *funcs++ = Dacc_is_Aacc;
+ *funcs++ = Sop_PFI_to_Dacc[dst_pfi];
+
+ if (state->blittingflags & DSBLIT_DST_PREMULTIPLY)
+ *funcs++ = Dacc_premultiply;
+ }
+ else if (scale_from_accumulator) {
+ *funcs++ = Len_is_Slen;
+ }
+
+ /* read the source */
+ *funcs++ = Sop_is_Bop;
+ if (DFB_PIXELFORMAT_IS_INDEXED(gfxs->src_format))
+ *funcs++ = Slut_is_Blut;
+ *funcs++ = Dacc_is_Bacc;
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY) {
+ gfxs->Skey = state->src_colorkey;
+ if (accel == DFXL_BLIT || scale_from_accumulator)
+ *funcs++ = Sop_PFI_Kto_Dacc[src_pfi];
+ else
+ *funcs++ = Sop_PFI_SKto_Dacc[src_pfi];
+ }
+ else {
+ if (accel == DFXL_BLIT || scale_from_accumulator)
+ *funcs++ = Sop_PFI_to_Dacc[src_pfi];
+ else
+ *funcs++ = Sop_PFI_Sto_Dacc[src_pfi];
+ }
+
+ if (!src_ycbcr && dst_ycbcr) {
+ if (DFB_COLOR_BITS_PER_PIXEL(gfxs->src_format))
+ *funcs++ = Dacc_RGB_to_YCbCr;
+ /*else
+ *funcs++ = Dacc_Alpha_to_YCbCr;*/
+ }
+ else if (src_ycbcr && !dst_ycbcr) {
+ if (DFB_COLOR_BITS_PER_PIXEL(gfxs->dst_format))
+ *funcs++ = Dacc_YCbCr_to_RGB;
+ }
+
+ /* Premultiply color alpha? */
+ if (state->blittingflags & DSBLIT_SRC_PREMULTCOLOR) {
+ gfxs->Cacc.RGB.a = color.a + 1;
+ *funcs++ = Dacc_premultiply_color_alpha;
+ }
+
+ /* modulate the source if requested */
+ if (Dacc_modulation[modulation & 0x7]) {
+ /* modulation source */
+ gfxs->Cacc.RGB.a = color.a + 1;
+ if (!dst_ycbcr) {
+ gfxs->Cacc.RGB.r = color.r + 1;
+ gfxs->Cacc.RGB.g = color.g + 1;
+ gfxs->Cacc.RGB.b = color.b + 1;
+ } else {
+ gfxs->Cacc.YUV.y = gfxs->YCop + 1;
+ gfxs->Cacc.YUV.u = gfxs->CbCop + 1;
+ gfxs->Cacc.YUV.v = gfxs->CrCop + 1;
+ }
+
+ *funcs++ = Dacc_modulation[modulation & 0x7];
+ }
+
+ /* Premultiply (modulated) source alpha? */
+ if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY)
+ *funcs++ = Dacc_premultiply;
+
+ /* Xor source with destination */
+ if (state->blittingflags & DSBLIT_XOR) {
+ *funcs++ = Sacc_is_Aacc;
+ *funcs++ = Dacc_is_Bacc;
+ *funcs++ = Sacc_xor_Dacc;
+ }
+
+ /* do blend functions and combine both accumulators */
+ if (state->blittingflags & (DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_BLEND_COLORALPHA)) {
+ /* Xacc will be blended and written to while
+ Sacc and Dacc point to the SRC and DST
+ as referenced by the blending functions */
+ *funcs++ = Sacc_is_Bacc;
+ *funcs++ = Dacc_is_Aacc;
+
+ if (source_needs_destination &&
+ state->dst_blend != DSBF_ONE) {
+ /* blend the destination */
+ *funcs++ = Yacc_is_Aacc;
+ *funcs++ = Xacc_is_Tacc;
+ *funcs++ = Xacc_blend[state->dst_blend - 1];
+
+ /* blend the source */
+ *funcs++ = Xacc_is_Bacc;
+ *funcs++ = Yacc_is_Bacc;
+ *funcs++ = Xacc_blend[state->src_blend - 1];
+ }
+ else {
+ /* blend the destination if needed */
+ if (read_destination) {
+ *funcs++ = Yacc_is_Aacc;
+ *funcs++ = Xacc_is_Tacc;
+ *funcs++ = Xacc_blend[state->dst_blend - 1];
+ }
+
+ /* blend the source */
+ *funcs++ = Xacc_is_Bacc;
+ *funcs++ = Yacc_is_Bacc;
+ *funcs++ = Xacc_blend[state->src_blend - 1];
+ }
+
+ /* add the destination to the source */
+ if (read_destination) {
+ *funcs++ = Sacc_is_Tacc;
+ *funcs++ = Dacc_is_Bacc;
+ *funcs++ = Sacc_add_to_Dacc;
+ }
+ }
+
+ if (state->blittingflags & DSBLIT_DEMULTIPLY) {
+ *funcs++ = Dacc_is_Bacc;
+ *funcs++ = Dacc_demultiply;
+ }
+
+ /* write source to destination */
+ *funcs++ = Sacc_is_Bacc;
+ if (scale_from_accumulator) {
+ *funcs++ = Len_is_Dlen;
+ if (state->blittingflags & DSBLIT_DST_COLORKEY ) {
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Sacc_StoK_Aop_PFI[dst_pfi];
+ } else
+ *funcs++ = Sacc_Sto_Aop_PFI[dst_pfi];
+ } else {
+ if (state->blittingflags & DSBLIT_DST_COLORKEY ) {
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Sacc_toK_Aop_PFI[dst_pfi];
+ } else
+ *funcs++ = Sacc_to_Aop_PFI[dst_pfi];
+ }
+ }
+ else if (state->blittingflags == DSBLIT_INDEX_TRANSLATION &&
+ DFB_PIXELFORMAT_IS_INDEXED(gfxs->src_format) &&
+ DFB_PIXELFORMAT_IS_INDEXED(gfxs->dst_format))
+ {
+ gfxs->trans = state->index_translation;
+ gfxs->num_trans = state->num_translation;
+
+ switch (gfxs->src_format) {
+ case DSPF_LUT2:
+ switch (gfxs->dst_format) {
+ case DSPF_LUT8:
+ *funcs++ = Bop_lut2_translate_to_Aop_lut8;
+ break;
+
+ default:
+ D_ONCE( "no index translation to %s implemented",
+ dfb_pixelformat_name( gfxs->dst_format ) );
+ break;
+ }
+ break;
+
+ default:
+ D_ONCE( "no index translation from %s implemented",
+ dfb_pixelformat_name( gfxs->src_format ) );
+ break;
+ }
+ }
+ else if ((gfxs->src_format == gfxs->dst_format &&
+ (!DFB_PIXELFORMAT_IS_INDEXED(gfxs->src_format) ||
+ dfb_palette_equal( gfxs->Alut, gfxs->Blut ))) ||
+ ((gfxs->src_format == DSPF_I420 || gfxs->src_format == DSPF_YV12) &&
+ (gfxs->dst_format == DSPF_I420 || gfxs->dst_format == DSPF_YV12)))
+ {
+ gfxs->need_accumulator = false;
+
+ if (accel == DFXL_BLIT) {
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY &&
+ state->blittingflags & DSBLIT_DST_COLORKEY) {
+ gfxs->Skey = state->src_colorkey;
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Bop_PFI_KtoK_Aop_PFI[dst_pfi];
+ } else if (state->blittingflags & DSBLIT_SRC_COLORKEY) {
+ gfxs->Skey = state->src_colorkey;
+ *funcs++ = Bop_PFI_Kto_Aop_PFI[dst_pfi];
+ } else if (state->blittingflags & DSBLIT_DST_COLORKEY) {
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Bop_PFI_toK_Aop_PFI[dst_pfi];
+ } else if (state->blittingflags & (DSBLIT_ROTATE90 |
+ DSBLIT_ROTATE180 |
+ DSBLIT_ROTATE270)) {
+ *funcs++ = Bop_PFI_toR_Aop_PFI[dst_pfi];
+ } else
+ *funcs++ = Bop_PFI_to_Aop_PFI[dst_pfi];
+ }
+ else {
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY &&
+ state->blittingflags & DSBLIT_DST_COLORKEY) {
+ gfxs->Skey = state->src_colorkey;
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Bop_PFI_SKtoK_Aop_PFI[dst_pfi];
+ } else if (state->blittingflags & DSBLIT_SRC_COLORKEY) {
+ gfxs->Skey = state->src_colorkey;
+ *funcs++ = Bop_PFI_SKto_Aop_PFI[dst_pfi];
+ } else if (state->blittingflags & DSBLIT_DST_COLORKEY) {
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Bop_PFI_StoK_Aop_PFI[dst_pfi];
+ } else
+ *funcs++ = Bop_PFI_Sto_Aop_PFI[dst_pfi];
+ }
+ }
+ else {
+ bool scale_from_accumulator = (src_ycbcr != dst_ycbcr) &&
+ (accel == DFXL_STRETCHBLIT);
+
+ if (scale_from_accumulator)
+ *funcs++ = Len_is_Slen;
+
+ gfxs->Sop = gfxs->Bop;
+
+ if (DFB_PIXELFORMAT_IS_INDEXED(gfxs->src_format))
+ *funcs++ = Slut_is_Blut;
+
+ if (accel == DFXL_BLIT || scale_from_accumulator) {
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY ) {
+ gfxs->Skey = state->src_colorkey;
+ *funcs++ = Sop_PFI_Kto_Dacc[src_pfi];
+ }
+ else
+ *funcs++ = Sop_PFI_to_Dacc[src_pfi];
+ }
+ else { /* DFXL_STRETCHBLIT */
+
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY ) {
+ gfxs->Skey = state->src_colorkey;
+ *funcs++ = Sop_PFI_SKto_Dacc[src_pfi];
+ }
+ else
+ *funcs++ = Sop_PFI_Sto_Dacc[src_pfi];
+
+ }
+
+ if (!src_ycbcr && dst_ycbcr) {
+ if (DFB_COLOR_BITS_PER_PIXEL(gfxs->src_format))
+ *funcs++ = Dacc_RGB_to_YCbCr;
+ else
+ *funcs++ = Dacc_Alpha_to_YCbCr;
+ }
+ else if (src_ycbcr && !dst_ycbcr) {
+ if (DFB_COLOR_BITS_PER_PIXEL(gfxs->dst_format))
+ *funcs++ = Dacc_YCbCr_to_RGB;
+ }
+
+ if (scale_from_accumulator) {
+ *funcs++ = Len_is_Dlen;
+ if (state->blittingflags & DSBLIT_DST_COLORKEY ) {
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Sacc_StoK_Aop_PFI[dst_pfi];
+ } else
+ *funcs++ = Sacc_Sto_Aop_PFI[dst_pfi];
+ } else {
+ if (state->blittingflags & DSBLIT_DST_COLORKEY ) {
+ gfxs->Dkey = state->dst_colorkey;
+ *funcs++ = Sacc_toK_Aop_PFI[dst_pfi];
+ } else
+ *funcs++ = Sacc_to_Aop_PFI[dst_pfi];
+ }
+ }
+ break;
+ }
+ default:
+ D_ONCE("unimplemented drawing/blitting function");
+ gRelease( state );
+ return false;
+ }
+
+ *funcs = NULL;
+
+ dfb_state_update( state, state->flags & CSF_SOURCE_LOCKED );
+
+ return true;
+}
+
+void gRelease( CardState *state )
+{
+ dfb_surface_unlock_buffer( state->destination, &state->dst );
+
+ if (state->flags & CSF_SOURCE_LOCKED) {
+ dfb_surface_unlock_buffer( state->source, &state->src );
+ state->flags &= ~CSF_SOURCE_LOCKED;
+ }
+}
+
+#define CHECK_PIPELINE() \
+ { \
+ if (!gfxs->funcs[0]) \
+ return; \
+ \
+ if (dfb_config->software_trace) { \
+ int i; \
+ GenefxFunc *funcs = gfxs->funcs; \
+ \
+ direct_log_lock( NULL ); \
+ direct_log_printf( NULL, " Software Fallback Pipeline:\n" ); \
+ \
+ for (i=0; funcs[i]; ++i) \
+ direct_log_printf( NULL, " [%2d] %s\n", i, \
+ direct_trace_lookup_symbol_at( funcs[i] ) ); \
+ \
+ direct_log_printf( NULL, "\n" ); \
+ direct_log_unlock( NULL ); \
+ } \
+ }
+
+#define RUN_PIPELINE() \
+ { \
+ int i; \
+ GenefxFunc *funcs = gfxs->funcs; \
+ \
+ for (i=0; funcs[i]; ++i) \
+ funcs[i]( gfxs ); \
+ }
+
+
+static inline void Aop_xy( GenefxState *gfxs, int x, int y )
+{
+ int pitch = gfxs->dst_pitch;
+
+ gfxs->Aop[0] = gfxs->dst_org[0];
+ gfxs->AopY = y;
+
+ if (gfxs->dst_caps & DSCAPS_SEPARATED) {
+ gfxs->Aop_field = y & 1;
+ if (gfxs->Aop_field)
+ gfxs->Aop[0] += gfxs->dst_field_offset;
+
+ y /= 2;
+ }
+
+ D_ASSUME( !(x & DFB_PIXELFORMAT_ALIGNMENT(gfxs->dst_format)) );
+
+ gfxs->Aop[0] += y * pitch + DFB_BYTES_PER_LINE( gfxs->dst_format, x );
+
+ if (DFB_PLANAR_PIXELFORMAT(gfxs->dst_format)) {
+ int dst_field_offset = gfxs->dst_field_offset;
+
+ switch (gfxs->dst_format) {
+ case DSPF_YV12:
+ case DSPF_I420:
+ dst_field_offset /= 4;
+ pitch /= 2;
+ y /= 2;
+ x /= 2;
+ break;
+ case DSPF_NV12:
+ case DSPF_NV21:
+ dst_field_offset /= 2;
+ y /= 2;
+ case DSPF_NV16:
+ x &= ~1;
+ break;
+ default:
+ break;
+ }
+
+ gfxs->Aop[1] = gfxs->dst_org[1];
+ gfxs->Aop[2] = gfxs->dst_org[2];
+
+ if (gfxs->dst_caps & DSCAPS_SEPARATED && gfxs->Aop_field) {
+ gfxs->Aop[1] += dst_field_offset;
+ gfxs->Aop[2] += dst_field_offset;
+ }
+
+ gfxs->Aop[1] += y * pitch + x;
+ gfxs->Aop[2] += y * pitch + x;
+ }
+}
+
+static inline void Aop_crab( GenefxState *gfxs )
+{
+ gfxs->Aop[0] += gfxs->dst_bpp;
+ gfxs->AopY++;
+}
+
+static inline void Aop_next( GenefxState *gfxs )
+{
+ int pitch = gfxs->dst_pitch;
+
+ if (gfxs->dst_caps & DSCAPS_SEPARATED) {
+ gfxs->Aop_field++;
+
+ if (gfxs->Aop_field & 1)
+ gfxs->Aop[0] += gfxs->dst_field_offset;
+ else
+ gfxs->Aop[0] += pitch - gfxs->dst_field_offset;
+ }
+ else
+ gfxs->Aop[0] += pitch;
+
+ if (DFB_PLANAR_PIXELFORMAT(gfxs->dst_format)) {
+ if (gfxs->dst_format == DSPF_YV12 || gfxs->dst_format == DSPF_I420) {
+ if (gfxs->AopY & 1) {
+ if (gfxs->dst_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Aop_field & 2) {
+ gfxs->Aop[1] += gfxs->dst_field_offset/4;
+ gfxs->Aop[2] += gfxs->dst_field_offset/4;
+ }
+ else {
+ gfxs->Aop[1] += pitch/2 - gfxs->dst_field_offset/4;
+ gfxs->Aop[2] += pitch/2 - gfxs->dst_field_offset/4;
+ }
+ }
+ else {
+ gfxs->Aop[1] += pitch/2;
+ gfxs->Aop[2] += pitch/2;
+ }
+ }
+ }
+ else if (gfxs->dst_format == DSPF_NV12 || gfxs->dst_format == DSPF_NV21) {
+ if (gfxs->AopY & 1) {
+ if (gfxs->dst_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Aop_field & 2)
+ gfxs->Aop[1] += gfxs->dst_field_offset/2;
+ else
+ gfxs->Aop[1] += pitch - gfxs->dst_field_offset/2;
+ }
+ else {
+ gfxs->Aop[1] += pitch;
+ }
+ }
+ }
+ else { /* NV16 */
+ if (gfxs->dst_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Aop_field & 1)
+ gfxs->Aop[1] += gfxs->dst_field_offset;
+ else
+ gfxs->Aop[1] += pitch - gfxs->dst_field_offset;
+ }
+ else {
+ gfxs->Aop[1] += pitch;
+ }
+ }
+ }
+
+ gfxs->AopY++;
+}
+
+static inline void Aop_prev( GenefxState *gfxs )
+{
+ int pitch = gfxs->dst_pitch;
+
+ if (gfxs->dst_caps & DSCAPS_SEPARATED) {
+ gfxs->Aop_field++;
+
+ if (gfxs->Aop_field & 1)
+ gfxs->Aop[0] += gfxs->dst_field_offset - pitch;
+ else
+ gfxs->Aop[0] -= gfxs->dst_field_offset;
+ }
+ else
+ gfxs->Aop[0] -= pitch;
+
+ if (DFB_PLANAR_PIXELFORMAT(gfxs->dst_format)) {
+ if (gfxs->dst_format == DSPF_YV12 || gfxs->dst_format == DSPF_I420) {
+ if (gfxs->AopY & 1) {
+ if (gfxs->dst_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Aop_field & 2) {
+ gfxs->Aop[1] += gfxs->dst_field_offset/4 - pitch/2;
+ gfxs->Aop[2] += gfxs->dst_field_offset/4 - pitch/2;
+ }
+ else {
+ gfxs->Aop[1] -= gfxs->dst_field_offset/4;
+ gfxs->Aop[2] -= gfxs->dst_field_offset/4;
+ }
+ }
+ else {
+ gfxs->Aop[1] -= pitch/2;
+ gfxs->Aop[2] -= pitch/2;
+ }
+ }
+ }
+ else if (gfxs->dst_format == DSPF_NV12 || gfxs->dst_format == DSPF_NV21) {
+ if (gfxs->AopY & 1) {
+ if (gfxs->dst_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Aop_field & 2)
+ gfxs->Aop[1] += gfxs->dst_field_offset/2 - pitch;
+ else
+ gfxs->Aop[1] -= gfxs->dst_field_offset/2;
+ }
+ else {
+ gfxs->Aop[1] -= pitch;
+ }
+ }
+ }
+ else { /* NV16 */
+ if (gfxs->dst_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Aop_field & 1)
+ gfxs->Aop[1] += gfxs->dst_field_offset - pitch;
+ else
+ gfxs->Aop[1] -= gfxs->dst_field_offset;
+ }
+ else {
+ gfxs->Aop[1] -= pitch;
+ }
+ }
+ }
+
+ gfxs->AopY--;
+}
+
+
+static inline void Bop_xy( GenefxState *gfxs, int x, int y )
+{
+ int pitch = gfxs->src_pitch;
+
+ gfxs->Bop[0] = gfxs->src_org[0];
+ gfxs->BopY = y;
+
+ if (gfxs->src_caps & DSCAPS_SEPARATED) {
+ gfxs->Bop_field = y & 1;
+ if (gfxs->Bop_field)
+ gfxs->Bop[0] += gfxs->src_field_offset;
+
+ y /= 2;
+ }
+
+ D_ASSUME( !(x & DFB_PIXELFORMAT_ALIGNMENT(gfxs->src_format)) );
+
+ gfxs->Bop[0] += y * pitch + DFB_BYTES_PER_LINE( gfxs->src_format, x );
+
+ if (DFB_PLANAR_PIXELFORMAT(gfxs->src_format)) {
+ int src_field_offset = gfxs->src_field_offset;
+
+ switch (gfxs->src_format) {
+ case DSPF_YV12:
+ case DSPF_I420:
+ src_field_offset /= 4;
+ pitch /= 2;
+ y /= 2;
+ x /= 2;
+ break;
+ case DSPF_NV12:
+ case DSPF_NV21:
+ src_field_offset /= 2;
+ y /= 2;
+ case DSPF_NV16:
+ x &= ~1;
+ break;
+ default:
+ break;
+ }
+
+ gfxs->Bop[1] = gfxs->src_org[1];
+ gfxs->Bop[2] = gfxs->src_org[2];
+
+ if (gfxs->src_caps & DSCAPS_SEPARATED && gfxs->Bop_field) {
+ gfxs->Bop[1] += src_field_offset;
+ gfxs->Bop[2] += src_field_offset;
+ }
+
+ gfxs->Bop[1] += y * pitch + x;
+ gfxs->Bop[2] += y * pitch + x;
+ }
+}
+
+static inline void Bop_next( GenefxState *gfxs )
+{
+ int pitch = gfxs->src_pitch;
+
+ if (gfxs->src_caps & DSCAPS_SEPARATED) {
+ gfxs->Bop_field++;
+
+ if (gfxs->Bop_field & 1)
+ gfxs->Bop[0] += gfxs->src_field_offset;
+ else
+ gfxs->Bop[0] += pitch - gfxs->src_field_offset;
+ }
+ else
+ gfxs->Bop[0] += pitch;
+
+ if (DFB_PLANAR_PIXELFORMAT(gfxs->src_format)) {
+ if (gfxs->src_format == DSPF_YV12 || gfxs->src_format == DSPF_I420) {
+ if (gfxs->BopY & 1) {
+ if (gfxs->src_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Bop_field & 2) {
+ gfxs->Bop[1] += gfxs->src_field_offset/4;
+ gfxs->Bop[2] += gfxs->src_field_offset/4;
+ }
+ else {
+ gfxs->Bop[1] += pitch/2 - gfxs->src_field_offset/4;
+ gfxs->Bop[2] += pitch/2 - gfxs->src_field_offset/4;
+ }
+ }
+ else {
+ gfxs->Bop[1] += pitch/2;
+ gfxs->Bop[2] += pitch/2;
+ }
+ }
+ }
+ else if (gfxs->src_format == DSPF_NV12 || gfxs->src_format == DSPF_NV21) {
+ if (gfxs->BopY & 1) {
+ if (gfxs->src_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Bop_field & 2)
+ gfxs->Bop[1] += gfxs->src_field_offset/2;
+ else
+ gfxs->Bop[1] += pitch - gfxs->src_field_offset/2;
+ }
+ else {
+ gfxs->Bop[1] += pitch;
+ }
+ }
+ }
+ else { /* NV16 */
+ if (gfxs->src_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Bop_field & 1)
+ gfxs->Bop[1] += gfxs->src_field_offset;
+ else
+ gfxs->Bop[1] += pitch - gfxs->src_field_offset;
+ }
+ else {
+ gfxs->Bop[1] += pitch;
+ }
+ }
+ }
+
+ gfxs->BopY++;
+}
+
+static inline void Bop_prev( GenefxState *gfxs )
+{
+ int pitch = gfxs->src_pitch;
+
+ if (gfxs->src_caps & DSCAPS_SEPARATED) {
+ gfxs->Bop_field++;
+
+ if (gfxs->Bop_field & 1)
+ gfxs->Bop[0] += gfxs->src_field_offset - pitch;
+ else
+ gfxs->Bop[0] -= gfxs->src_field_offset;
+ }
+ else
+ gfxs->Bop[0] -= pitch;
+
+ if (DFB_PLANAR_PIXELFORMAT(gfxs->src_format)) {
+ if (gfxs->src_format == DSPF_YV12 || gfxs->src_format == DSPF_I420) {
+ if (gfxs->BopY & 1) {
+ if (gfxs->src_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Bop_field & 2) {
+ gfxs->Bop[1] += gfxs->src_field_offset/4 - pitch/2;
+ gfxs->Bop[2] += gfxs->src_field_offset/4 - pitch/2;
+ }
+ else {
+ gfxs->Bop[1] -= gfxs->src_field_offset/4;
+ gfxs->Bop[2] -= gfxs->src_field_offset/4;
+ }
+ }
+ else {
+ gfxs->Bop[1] -= pitch/2;
+ gfxs->Bop[2] -= pitch/2;
+ }
+ }
+ }
+ else if (gfxs->src_format == DSPF_NV12 || gfxs->src_format == DSPF_NV21) {
+ if (gfxs->BopY & 1) {
+ if (gfxs->src_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Bop_field & 2)
+ gfxs->Bop[1] += gfxs->src_field_offset/2 - pitch;
+ else
+ gfxs->Bop[1] -= gfxs->src_field_offset/2;
+ }
+ else {
+ gfxs->Bop[1] -= pitch;
+ }
+ }
+ }
+ else { /* NV16 */
+ if (gfxs->src_caps & DSCAPS_SEPARATED) {
+ if (gfxs->Bop_field & 1)
+ gfxs->Bop[1] += gfxs->src_field_offset - pitch;
+ else
+ gfxs->Bop[1] -= gfxs->src_field_offset;
+ }
+ else {
+ gfxs->Bop[1] -= pitch;
+ }
+ }
+ }
+
+ gfxs->BopY--;
+}
+
+static bool
+ABacc_prepare( GenefxState *gfxs, int width )
+{
+ int size;
+
+ if (!gfxs->need_accumulator)
+ return true;
+
+ size = (width + 31) & ~31;
+
+ if (gfxs->ABsize < size) {
+ void *ABstart = D_MALLOC( size * sizeof(GenefxAccumulator) * 3 + 31 );
+
+ if (!ABstart) {
+ D_WARN( "out of memory" );
+ return false;
+ }
+
+ if (gfxs->ABstart)
+ D_FREE( gfxs->ABstart );
+
+ gfxs->ABstart = ABstart;
+ gfxs->ABsize = size;
+ gfxs->Aacc = (GenefxAccumulator*) (((unsigned long)ABstart+31) & ~31);
+ gfxs->Bacc = gfxs->Aacc + size;
+ gfxs->Tacc = gfxs->Aacc + size + size;
+ }
+
+ gfxs->Sacc = gfxs->Dacc = gfxs->Aacc;
+
+ return true;
+}
+
+static void
+ABacc_flush( GenefxState *gfxs )
+{
+ if (dfb_config->keep_accumulators >= 0 && gfxs->ABsize > dfb_config->keep_accumulators) {
+ D_FREE( gfxs->ABstart );
+
+ gfxs->ABsize = 0;
+ gfxs->ABstart = NULL;
+ gfxs->Aacc = NULL;
+ gfxs->Bacc = NULL;
+ gfxs->Sacc = NULL;
+ gfxs->Dacc = NULL;
+ }
+}
+
+void gFillRectangle( CardState *state, DFBRectangle *rect )
+{
+ int h;
+ GenefxState *gfxs = state->gfxs;
+
+ D_ASSERT( gfxs != NULL );
+
+ if (dfb_config->software_warn) {
+ D_WARN( "FillRectangle (%4d,%4d-%4dx%4d) %6s, flags 0x%08x, color 0x%02x%02x%02x%02x",
+ DFB_RECTANGLE_VALS(rect), dfb_pixelformat_name(gfxs->dst_format), state->drawingflags,
+ state->color.a, state->color.r, state->color.g, state->color.b );
+ }
+
+ D_ASSERT( state->clip.x1 <= rect->x );
+ D_ASSERT( state->clip.y1 <= rect->y );
+ D_ASSERT( state->clip.x2 >= (rect->x + rect->w - 1) );
+ D_ASSERT( state->clip.y2 >= (rect->y + rect->h - 1) );
+
+ CHECK_PIPELINE();
+
+ if (!ABacc_prepare( gfxs, rect->w ))
+ return;
+
+ gfxs->length = rect->w;
+
+ Aop_xy( gfxs, rect->x, rect->y );
+
+ h = rect->h;
+ while (h--) {
+ RUN_PIPELINE();
+
+ Aop_next( gfxs );
+ }
+
+ ABacc_flush( gfxs );
+}
+
+void gDrawLine( CardState *state, DFBRegion *line )
+{
+ GenefxState *gfxs = state->gfxs;
+
+ int i,dx,dy,sdy,dxabs,dyabs,x,y,px,py;
+
+ D_ASSERT( gfxs != NULL );
+
+ CHECK_PIPELINE();
+
+ /* the horizontal distance of the line */
+ dx = line->x2 - line->x1;
+ dxabs = abs(dx);
+
+ if (!ABacc_prepare( gfxs, dxabs ))
+ return;
+
+ /* the vertical distance of the line */
+ dy = line->y2 - line->y1;
+ dyabs = abs(dy);
+
+ if (!dx || !dy) { /* draw horizontal/vertical line */
+ DFBRectangle rect = {
+ MIN (line->x1, line->x2),
+ MIN (line->y1, line->y2),
+ dxabs + 1, dyabs + 1};
+
+ gFillRectangle( state, &rect );
+ return;
+ }
+
+ if (dfb_config->software_warn) {
+ D_WARN( "DrawLine (%4d,%4d-%4d,%4d) %6s, flags 0x%08x, color 0x%02x%02x%02x%02x",
+ DFB_RECTANGLE_VALS_FROM_REGION(line), dfb_pixelformat_name(gfxs->dst_format), state->drawingflags,
+ state->color.a, state->color.r, state->color.g, state->color.b );
+ }
+
+ sdy = SIGN(dy) * SIGN(dx);
+ x = dyabs >> 1;
+ y = dxabs >> 1;
+
+ if (dx > 0) {
+ px = line->x1;
+ py = line->y1;
+ }
+ else {
+ px = line->x2;
+ py = line->y2;
+ }
+
+ if (dxabs >= dyabs) { /* the line is more horizontal than vertical */
+
+ for (i=0, gfxs->length=1; i<dxabs; i++, gfxs->length++) {
+ y += dyabs;
+ if (y >= dxabs) {
+ Aop_xy( gfxs, px, py );
+ RUN_PIPELINE();
+ px += gfxs->length;
+ gfxs->length = 0;
+ y -= dxabs;
+ py += sdy;
+ }
+ }
+ Aop_xy( gfxs, px, py );
+ RUN_PIPELINE();
+ }
+ else { /* the line is more vertical than horizontal */
+
+ gfxs->length = 1;
+ Aop_xy( gfxs, px, py );
+ RUN_PIPELINE();
+
+ for (i=0; i<dyabs; i++) {
+ x += dxabs;
+ if (x >= dyabs) {
+ x -= dyabs;
+ px++;
+ }
+ py += sdy;
+
+ Aop_xy( gfxs, px, py );
+ RUN_PIPELINE();
+ }
+ }
+
+ ABacc_flush( gfxs );
+}
+
+void gBlit( CardState *state, DFBRectangle *rect, int dx, int dy )
+{
+ GenefxState *gfxs = state->gfxs;
+ int x, h;
+
+ D_ASSERT( gfxs != NULL );
+
+ if (dfb_config->software_warn) {
+ D_WARN( "Blit (%4d,%4d-%4dx%4d) %6s, flags 0x%08x, funcs %d/%d, color 0x%02x%02x%02x%02x, source (%4d,%4d) %6s",
+ dx, dy, rect->w, rect->h, dfb_pixelformat_name(gfxs->dst_format), state->blittingflags,
+ state->src_blend, state->dst_blend,
+ state->color.a, state->color.r, state->color.g, state->color.b, rect->x, rect->y,
+ dfb_pixelformat_name(gfxs->src_format) );
+ }
+
+ D_ASSERT( state->clip.x1 <= dx );
+ D_ASSERT( state->clip.y1 <= dy );
+ D_ASSERT( (state->blittingflags & (DSBLIT_ROTATE90 | DSBLIT_ROTATE270)) || state->clip.x2 >= (dx + rect->w - 1) );
+ D_ASSERT( (state->blittingflags & (DSBLIT_ROTATE90 | DSBLIT_ROTATE270)) || state->clip.y2 >= (dy + rect->h - 1) );
+ D_ASSERT( !(state->blittingflags & (DSBLIT_ROTATE90 | DSBLIT_ROTATE270)) || state->clip.x2 >= (dx + rect->h - 1) );
+ D_ASSERT( !(state->blittingflags & (DSBLIT_ROTATE90 | DSBLIT_ROTATE270)) || state->clip.y2 >= (dy + rect->w - 1) );
+
+ CHECK_PIPELINE();
+
+ if (!ABacc_prepare( gfxs, rect->w ))
+ return;
+
+ if (gfxs->src_org[0] == gfxs->dst_org[0] && dy == rect->y && dx > rect->x)
+ /* we must blit from right to left */
+ gfxs->Astep = gfxs->Bstep = -1;
+ else
+ /* we must blit from left to right*/
+ gfxs->Astep = gfxs->Bstep = 1;
+
+ if (state->blittingflags & DSBLIT_ROTATE90)
+ gfxs->Astep *= -gfxs->dst_pitch / gfxs->dst_bpp;
+ else if (state->blittingflags & DSBLIT_ROTATE180)
+ gfxs->Astep *= -1;
+ else if (state->blittingflags & DSBLIT_ROTATE270)
+ gfxs->Astep *= gfxs->dst_pitch / gfxs->dst_bpp;
+
+ switch (gfxs->src_format) {
+ case DSPF_A4:
+ case DSPF_YUY2:
+ case DSPF_UYVY:
+ rect->x &= ~1;
+ break;
+ default:
+ break;
+ }
+
+ switch (gfxs->dst_format) {
+ case DSPF_A4:
+ case DSPF_YUY2:
+ case DSPF_UYVY:
+ dx &= ~1;
+ break;
+ default:
+ break;
+ }
+
+ gfxs->length = rect->w;
+
+ if (state->blittingflags == DSBLIT_ROTATE180 && gfxs->src_format == gfxs->dst_format) {
+ Aop_xy( gfxs, dx, dy );
+ Bop_xy( gfxs, rect->x + rect->w - 1, rect->y + rect->h - 1 );
+
+ switch (DFB_BYTES_PER_PIXEL(gfxs->dst_format)) {
+ case 4: {
+ for (h = rect->h; h; h--) {
+ u32 *src = gfxs->Bop[0];
+ u32 *dst = gfxs->Aop[0];
+
+ for (x=0; x<rect->w; x++)
+ dst[x] = src[-x];
+
+ Aop_next( gfxs );
+ Bop_prev( gfxs );
+ }
+ return;
+ }
+ case 2: {
+ for (h = rect->h; h; h--) {
+ u16 *src = gfxs->Bop[0];
+ u16 *dst = gfxs->Aop[0];
+
+ for (x=0; x<rect->w; x++)
+ dst[x] = src[-x];
+
+ Aop_next( gfxs );
+ Bop_prev( gfxs );
+ }
+ return;
+ }
+ case 1: {
+ for (h = rect->h; h; h--) {
+ u8 *src = gfxs->Bop[0];
+ u8 *dst = gfxs->Aop[0];
+
+ for (x=0; x<rect->w; x++)
+ dst[x] = src[-x];
+
+ Aop_next( gfxs );
+ Bop_prev( gfxs );
+ }
+ return;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ if (state->blittingflags & DSBLIT_ROTATE180) {
+ Aop_xy( gfxs, dx + rect->w - 1, dy );
+ Bop_xy( gfxs, rect->x, rect->y + rect->h - 1 );
+
+ for (h = rect->h; h; h--) {
+ RUN_PIPELINE();
+
+ Aop_next( gfxs );
+ Bop_prev( gfxs );
+ }
+ return;
+ }
+ else if( state->blittingflags & DSBLIT_ROTATE270 )
+ {
+ Aop_xy( gfxs, dx, dy );
+ Bop_xy( gfxs, rect->x, rect->y + rect->h - 1 );
+
+ for( h = rect->h; h; h-- )
+ {
+ RUN_PIPELINE();
+
+ Aop_crab( gfxs );
+ Bop_prev( gfxs );
+ }
+ return;
+ }
+ else if( state->blittingflags & DSBLIT_ROTATE90 )
+ {
+ Aop_xy( gfxs, dx, dy + rect->w - 1 );
+ Bop_xy( gfxs, rect->x, rect->y );
+
+ for( h = rect->h; h; h-- )
+ {
+ RUN_PIPELINE();
+
+ Aop_crab( gfxs );
+ Bop_next( gfxs );
+ }
+ return;
+ }
+
+ if (gfxs->src_org[0] == gfxs->dst_org[0] && dy > rect->y &&
+ !(state->blittingflags & DSBLIT_DEINTERLACE)) {
+ /* we must blit from bottom to top */
+ Aop_xy( gfxs, dx, dy + rect->h - 1 );
+ Bop_xy( gfxs, rect->x, rect->y + rect->h - 1 );
+
+ for (h = rect->h; h; h--) {
+ RUN_PIPELINE();
+
+ Aop_prev( gfxs );
+ Bop_prev( gfxs );
+ }
+ }
+ else {
+ /* we must blit from top to bottom */
+ Aop_xy( gfxs, dx, dy );
+ Bop_xy( gfxs, rect->x, rect->y );
+
+ if (state->blittingflags & DSBLIT_DEINTERLACE) {
+ if (state->source->field) {
+ Aop_next( gfxs );
+ Bop_next( gfxs );
+ rect->h--;
+ }
+
+ for (h = rect->h/2; h; h--) {
+ RUN_PIPELINE();
+
+ Aop_next( gfxs );
+
+ RUN_PIPELINE();
+
+ Aop_next( gfxs );
+
+ Bop_next( gfxs );
+ Bop_next( gfxs );
+ }
+ } /* ! DSBLIT_DEINTERLACE */
+ else {
+ for (h = rect->h; h; h--) {
+ RUN_PIPELINE();
+
+ Aop_next( gfxs );
+ Bop_next( gfxs );
+ }
+ }
+ }
+
+ ABacc_flush( gfxs );
+}
+
+/**********************************************************************************************************************/
+/********* **************************************************************************************************/
+/*** Smooth scaling routines ******************************************************************************************/
+/********* **************************************************************************************************/
+/**********************************************************************************************************************/
+
+#if DFB_SMOOTH_SCALING
+
+typedef struct {
+ DFBRegion clip;
+ const void *colors;
+ ulong protect;
+ ulong key;
+} StretchCtx;
+
+typedef void (*StretchHVx)( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ const StretchCtx *ctx );
+
+#define STRETCH_NONE 0
+#define STRETCH_SRCKEY 1
+#define STRETCH_PROTECT 2
+#define STRETCH_SRCKEY_PROTECT 3
+#define STRETCH_NUM 4
+
+typedef struct {
+ struct {
+ StretchHVx up[STRETCH_NUM];
+ StretchHVx down[STRETCH_NUM];
+ } f[DFB_NUM_PIXELFORMATS];
+} StretchFunctionTable;
+
+/**********************************************************************************************************************/
+/*** 16 bit RGB 565 scalers *******************************************************************************************/
+/**********************************************************************************************************************/
+
+#define DST_FORMAT DSPF_RGB16
+#define TABLE_NAME stretch_hvx_RGB16
+#define FUNC_NAME(UPDOWN,K,P,F) stretch_hvx_RGB16_ ## UPDOWN ## _ ## K ## P ## _ ## F
+#define SHIFT_R5 5
+#define SHIFT_R6 6
+#define X_F81F 0xf81f
+#define X_07E0 0x07e0
+#define MASK_RGB 0xffff
+
+#define FORMAT_RGB16
+#include "stretch_up_down_16.h"
+#undef FORMAT_RGB16
+
+#undef DST_FORMAT
+#undef TABLE_NAME
+#undef FUNC_NAME
+#undef SHIFT_R5
+#undef SHIFT_R6
+#undef X_F81F
+#undef X_07E0
+#undef MASK_RGB
+
+/**********************************************************************************************************************/
+/*** 16 bit ARGB 4444 scalers *****************************************************************************************/
+/**********************************************************************************************************************/
+
+#define DST_FORMAT DSPF_ARGB4444
+#define TABLE_NAME stretch_hvx_ARGB4444
+#define FUNC_NAME(UPDOWN,K,P,F) stretch_hvx_ARGB4444_ ## UPDOWN ## _ ## K ## P ## _ ## F
+#define SHIFT_R5 4
+#define SHIFT_R6 4
+#define X_F81F 0x0f0f
+#define X_07E0 0xf0f0
+#define MASK_RGB 0x0fff
+#define HAS_ALPHA
+
+#define FORMAT_ARGB4444
+#include "stretch_up_down_16.h"
+#undef FORMAT_ARGB4444
+
+#undef DST_FORMAT
+#undef TABLE_NAME
+#undef FUNC_NAME
+#undef SHIFT_R5
+#undef SHIFT_R6
+#undef X_F81F
+#undef X_07E0
+#undef MASK_RGB
+#undef HAS_ALPHA
+
+/**********************************************************************************************************************/
+/*** 16 bit RGBA 4444 scalers *****************************************************************************************/
+/**********************************************************************************************************************/
+
+#define DST_FORMAT DSPF_RGBA4444
+#define TABLE_NAME stretch_hvx_RGBA4444
+#define FUNC_NAME(UPDOWN,K,P,F) stretch_hvx_RGBA4444_ ## UPDOWN ## _ ## K ## P ## _ ## F
+#define SHIFT_R5 4
+#define SHIFT_R6 4
+#define X_F81F 0x0f0f
+#define X_07E0 0xf0f0
+#define MASK_RGB 0xfff0
+#define HAS_ALPHA
+
+#define FORMAT_RGBA4444
+#include "stretch_up_down_16.h"
+#undef FORMAT_RGBA4444
+
+#undef DST_FORMAT
+#undef TABLE_NAME
+#undef FUNC_NAME
+#undef SHIFT_R5
+#undef SHIFT_R6
+#undef X_F81F
+#undef X_07E0
+#undef MASK_RGB
+#undef HAS_ALPHA
+
+/**********************************************************************************************************************/
+/*** 32 bit ARGB 8888 scalers *****************************************************************************************/
+/**********************************************************************************************************************/
+
+#define DST_FORMAT DSPF_ARGB
+#define TABLE_NAME stretch_hvx_ARGB
+#define FUNC_NAME(UPDOWN,K,P,F) stretch_hvx_ARGB_ ## UPDOWN ## _ ## K ## P ## _ ## F
+#define SHIFT_R8 8
+#define SHIFT_L8 8
+#define X_00FF00FF 0x00ff00ff
+#define X_FF00FF00 0xff00ff00
+#define MASK_RGB 0x00ffffff
+#define HAS_ALPHA
+
+#include "stretch_up_down_32.h"
+
+#undef DST_FORMAT
+#undef TABLE_NAME
+#undef FUNC_NAME
+#undef SHIFT_R8
+#undef SHIFT_L8
+#undef X_00FF00FF
+#undef X_FF00FF00
+#undef MASK_RGB
+#undef HAS_ALPHA
+
+/**********************************************************************************************************************/
+/*** 32 bit RGB 888 scalers *******************************************************************************************/
+/**********************************************************************************************************************/
+
+#define DST_FORMAT DSPF_RGB32
+#define TABLE_NAME stretch_hvx_RGB32
+#define FUNC_NAME(UPDOWN,K,P,F) stretch_hvx_RGB32_ ## UPDOWN ## _ ## K ## P ## _ ## F
+#define SHIFT_R8 8
+#define SHIFT_L8 8
+#define X_00FF00FF 0x00ff00ff
+#define X_FF00FF00 0x0000ff00
+#define MASK_RGB 0x00ffffff
+
+#include "stretch_up_down_32.h"
+
+#undef DST_FORMAT
+#undef TABLE_NAME
+#undef FUNC_NAME
+#undef SHIFT_R8
+#undef SHIFT_L8
+#undef X_00FF00FF
+#undef X_FF00FF00
+#undef MASK_RGB
+
+#if 0
+/**********************************************************************************************************************/
+/*** 16 bit YUV 422 scalers *******************************************************************************************/
+/**********************************************************************************************************************/
+
+#define FUNC_NAME(UPDOWN) stretch_hvx_nv16_ ## UPDOWN
+
+#include "stretch_up_down_8.h"
+
+#undef FUNC_NAME
+
+/**********************************************************************************************************************/
+
+#define FUNC_NAME(UPDOWN) stretch_hvx_nv16_uv_ ## UPDOWN
+
+#include "stretch_up_down_88.h"
+
+#undef FUNC_NAME
+
+#endif
+/**********************************************************************************************************************/
+/**********************************************************************************************************************/
+
+static const StretchFunctionTable *stretch_tables[DFB_NUM_PIXELFORMATS] = {
+ NULL, /* DSPF_ARGB1555 */
+ &stretch_hvx_RGB16, /* DSPF_RGB16 */
+ NULL, /* DSPF_RGB24 */
+ &stretch_hvx_RGB32, /* DSPF_RGB32 */
+ &stretch_hvx_ARGB, /* DSPF_ARGB */
+ NULL, /* DSPF_A8 */
+ NULL, /* DSPF_YUY2 */
+ NULL, /* DSPF_RGB332 */
+ NULL, /* DSPF_UYVY */
+ NULL, /* DSPF_I420 */
+ NULL, /* DSPF_YV12 */
+ NULL, /* DSPF_LUT8 */
+ NULL, /* DSPF_ALUT44 */
+ NULL, /* DSPF_AiRGB */
+ NULL, /* DSPF_A1 */
+ NULL, /* DSPF_NV12 */
+ NULL, /* DSPF_NV16 */
+ NULL, /* DSPF_ARGB2554 */
+ &stretch_hvx_ARGB4444, /* DSPF_ARGB4444 */
+ &stretch_hvx_RGBA4444, /* DSPF_RGBA4444 */
+ NULL, /* DSPF_NV21 */
+ NULL, /* DSPF_AYUV */
+ NULL, /* DSPF_A4 */
+ NULL, /* DSPF_ARGB1666 */
+ NULL, /* DSPF_ARGB6666 */
+ NULL, /* DSPF_RGB18 */
+ NULL, /* DSPF_LUT2 */
+ NULL, /* DSPF_RGB444 */
+ NULL, /* DSPF_RGB555 */
+ NULL /* DSPF_BGR555 */
+};
+
+/**********************************************************************************************************************/
+
+__attribute__((noinline))
+static bool
+stretch_hvx( CardState *state, DFBRectangle *srect, DFBRectangle *drect )
+{
+ GenefxState *gfxs;
+ const StretchFunctionTable *table;
+ StretchHVx stretch;
+ bool down = false;
+ void *dst;
+ void *src;
+ StretchCtx ctx;
+ int idx = STRETCH_NONE;
+ u32 colors[256];
+
+ D_ASSERT( state != NULL );
+ DFB_RECTANGLE_ASSERT( srect );
+ DFB_RECTANGLE_ASSERT( drect );
+
+ gfxs = state->gfxs;
+
+ if (state->blittingflags & ~(DSBLIT_COLORKEY_PROTECT | DSBLIT_SRC_COLORKEY | DSBLIT_SRC_PREMULTIPLY))
+ return false;
+
+ if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY && !DFB_PIXELFORMAT_IS_INDEXED( gfxs->src_format ))
+ return false;
+
+ if (DFB_PIXELFORMAT_INDEX(gfxs->dst_format) >= D_ARRAY_SIZE(stretch_tables))
+ return false;
+
+ if (DFB_PIXELFORMAT_INDEX(gfxs->src_format) >= D_ARRAY_SIZE((stretch_tables[0])->f))
+ return false;
+
+ table = stretch_tables[DFB_PIXELFORMAT_INDEX(gfxs->dst_format)];
+ if (!table)
+ return false;
+
+ if (srect->w > drect->w && srect->h > drect->h)
+ down = true;
+
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY)
+ idx |= STRETCH_SRCKEY;
+
+ if (state->blittingflags & DSBLIT_COLORKEY_PROTECT)
+ idx |= STRETCH_PROTECT;
+
+ if (down) {
+ if (!(state->render_options & DSRO_SMOOTH_DOWNSCALE))
+ return false;
+
+ stretch = table->f[DFB_PIXELFORMAT_INDEX(gfxs->src_format)].down[idx];
+ }
+ else {
+ if (!(state->render_options & DSRO_SMOOTH_UPSCALE))
+ return false;
+
+ stretch = table->f[DFB_PIXELFORMAT_INDEX(gfxs->src_format)].up[idx];
+ }
+
+ if (!stretch)
+ return false;
+
+ ctx.clip = state->clip;
+
+ if (!dfb_region_rectangle_intersect( &ctx.clip, drect ))
+ return false;
+
+ dfb_region_translate( &ctx.clip, - drect->x, - drect->y );
+
+ if (DFB_PIXELFORMAT_IS_INDEXED( gfxs->src_format )) {
+ int i;
+ const DFBColor *entries;
+ u16 *colors16 = (void*) colors;
+
+ D_ASSERT( gfxs->Blut != NULL );
+
+ entries = gfxs->Blut->entries;
+
+ switch (gfxs->dst_format) {
+ case DSPF_ARGB:
+ if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY) {
+ for (i=0; i<gfxs->Blut->num_entries; i++) {
+ int alpha = entries[i].a + 1;
+
+ switch (alpha) {
+ case 0:
+ colors[i] = 0;
+ break;
+
+ case 255:
+ colors[i] = PIXEL_ARGB( entries[i].a,
+ entries[i].r,
+ entries[i].g,
+ entries[i].b );
+ break;
+
+ default:
+ colors[i] = PIXEL_ARGB( entries[i].a,
+ (alpha * entries[i].r) >> 8,
+ (alpha * entries[i].g) >> 8,
+ (alpha * entries[i].b) >> 8 );
+ }
+ }
+ }
+ else {
+ for (i=0; i<gfxs->Blut->num_entries; i++)
+ colors[i] = PIXEL_ARGB( entries[i].a, entries[i].r, entries[i].g, entries[i].b );
+ }
+ break;
+
+ case DSPF_RGB32:
+ for (i=0; i<gfxs->Blut->num_entries; i++)
+ colors[i] = PIXEL_RGB32( entries[i].r, entries[i].g, entries[i].b );
+ break;
+
+ case DSPF_RGB16:
+ for (i=0; i<gfxs->Blut->num_entries; i++)
+ colors16[i] = PIXEL_RGB16( entries[i].r, entries[i].g, entries[i].b );
+ break;
+
+ case DSPF_ARGB4444:
+ if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY) {
+ for (i=0; i<gfxs->Blut->num_entries; i++) {
+ int alpha = entries[i].a + 1;
+
+ switch (alpha) {
+ case 0:
+ colors16[i] = 0;
+ break;
+
+ case 255:
+ colors16[i] = PIXEL_ARGB4444( entries[i].a,
+ entries[i].r,
+ entries[i].g,
+ entries[i].b );
+ break;
+
+ default:
+ colors16[i] = PIXEL_ARGB4444( entries[i].a,
+ (alpha * entries[i].r) >> 8,
+ (alpha * entries[i].g) >> 8,
+ (alpha * entries[i].b) >> 8 );
+ }
+ }
+ }
+ else {
+ for (i=0; i<gfxs->Blut->num_entries; i++)
+ colors16[i] = PIXEL_ARGB4444( entries[i].a, entries[i].r, entries[i].g, entries[i].b );
+ }
+ break;
+
+ case DSPF_RGBA4444:
+ if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY) {
+ for (i=0; i<gfxs->Blut->num_entries; i++) {
+ int alpha = entries[i].a + 1;
+
+ switch (alpha) {
+ case 0:
+ colors16[i] = 0;
+ break;
+
+ case 255:
+ colors16[i] = PIXEL_RGBA4444( entries[i].a,
+ entries[i].r,
+ entries[i].g,
+ entries[i].b );
+ break;
+
+ default:
+ colors16[i] = PIXEL_RGBA4444( entries[i].a,
+ (alpha * entries[i].r) >> 8,
+ (alpha * entries[i].g) >> 8,
+ (alpha * entries[i].b) >> 8 );
+ }
+ }
+ }
+ else {
+ for (i=0; i<gfxs->Blut->num_entries; i++)
+ colors16[i] = PIXEL_RGBA4444( entries[i].a, entries[i].r, entries[i].g, entries[i].b );
+ }
+ break;
+
+ case DSPF_RGB444:
+ for (i=0; i<gfxs->Blut->num_entries; i++)
+ colors16[i] = PIXEL_RGB444( entries[i].r, entries[i].g, entries[i].b );
+ break;
+
+ default:
+ D_UNIMPLEMENTED();
+ }
+
+ ctx.colors = colors;
+
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY) {
+ if (DFB_PIXELFORMAT_IS_INDEXED( gfxs->dst_format ))
+ ctx.key = state->src_colorkey;
+ else {
+ const DFBColor *color = &entries[state->src_colorkey % gfxs->Blut->num_entries];
+
+ ctx.key = dfb_color_to_pixel( gfxs->dst_format, color->r, color->g, color->b );
+ }
+ }
+ }
+ else {
+ ctx.colors = NULL;
+
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY) {
+ DFBColor color;
+
+ dfb_pixel_to_color( gfxs->src_format, state->src_colorkey, &color );
+
+ ctx.key = dfb_color_to_pixel( gfxs->dst_format, color.r, color.g, color.b );
+ }
+ }
+
+ if (state->blittingflags & DSBLIT_COLORKEY_PROTECT) {
+ if (DFB_PIXELFORMAT_IS_INDEXED( gfxs->dst_format ))
+ ctx.protect = state->colorkey.index;
+ else
+ ctx.protect = dfb_color_to_pixel( gfxs->dst_format,
+ state->colorkey.r,
+ state->colorkey.g,
+ state->colorkey.b );
+ }
+
+ dst = gfxs->dst_org[0] + drect->y * gfxs->dst_pitch + DFB_BYTES_PER_LINE( gfxs->dst_format, drect->x );
+ src = gfxs->src_org[0] + srect->y * gfxs->src_pitch + DFB_BYTES_PER_LINE( gfxs->src_format, srect->x );
+
+ stretch( dst, gfxs->dst_pitch, src, gfxs->src_pitch,
+ srect->w, srect->h, drect->w, drect->h, &ctx );
+
+#if 0 /* FIXME: repair */
+ switch (gfxs->dst_format) {
+ case DSPF_NV16:
+ ctx.clip.x1 /= 2;
+ ctx.clip.x2 /= 2;
+ if (srect->w < drect->w || srect->h < drect->h) {
+ stretch_hvx_nv16_uv_up( dst, gfxs->dst_pitch, src, gfxs->src_pitch,
+ srect->w/2, srect->h, drect->w/2, drect->h, &ctx );
+ }
+ else {
+ stretch_hvx_nv16_uv_down( dst, gfxs->dst_pitch, src, gfxs->src_pitch,
+ srect->w/2, srect->h, drect->w/2, drect->h, &ctx );
+ }
+ break;
+
+ default:
+ break;
+ }
+#endif
+
+ return true;
+}
+#endif /* DFB_SMOOTH_SCALING */
+
+void gStretchBlit( CardState *state, DFBRectangle *srect, DFBRectangle *drect )
+{
+ GenefxState *gfxs = state->gfxs;
+ DFBRectangle orect = *drect;
+
+ int fx, fy;
+ int ix, iy;
+ int h;
+
+ D_ASSERT( gfxs != NULL );
+
+ if (dfb_config->software_warn) {
+ D_WARN( "StretchBlit (%4d,%4d-%4dx%4d) %6s, flags 0x%08x, color 0x%02x%02x%02x%02x, source (%4d,%4d-%4dx%4d) %6s",
+ drect->x, drect->y, drect->w, drect->h, dfb_pixelformat_name(gfxs->dst_format), state->blittingflags,
+ state->color.a, state->color.r, state->color.g, state->color.b, srect->x, srect->y, srect->w, srect->h,
+ dfb_pixelformat_name(gfxs->src_format) );
+ }
+
+ CHECK_PIPELINE();
+
+#if DFB_SMOOTH_SCALING
+ if (state->render_options & (DSRO_SMOOTH_UPSCALE | DSRO_SMOOTH_DOWNSCALE) &&
+ stretch_hvx( state, srect, drect ))
+ return;
+#endif
+
+ /* Clip destination rectangle. */
+ if (!dfb_rectangle_intersect_by_region( drect, &state->clip ))
+ return;
+
+ /* Calculate fractions. */
+ fx = (srect->w << 16) / orect.w;
+ fy = (srect->h << 16) / orect.h;
+
+ /* Calculate horizontal phase and offset. */
+ ix = fx * (drect->x - orect.x);
+ srect->x += ix >> 16;
+ ix &= 0xFFFF;
+
+ /* Calculate vertical phase and offset. */
+ iy = fy * (drect->y - orect.y);
+ srect->y += iy >> 16;
+ iy &= 0xFFFF;
+
+ /* Adjust source size. */
+ srect->w = ((drect->w * fx + ix) + 0xFFFF) >> 16;
+ srect->h = ((drect->h * fy + iy) + 0xFFFF) >> 16;
+
+ D_ASSERT( srect->x + srect->w <= state->source->config.size.w );
+ D_ASSERT( srect->y + srect->h <= state->source->config.size.h );
+ D_ASSERT( drect->x + drect->w <= state->clip.x2 + 1 );
+ D_ASSERT( drect->y + drect->h <= state->clip.y2 + 1 );
+
+
+ if (!ABacc_prepare( gfxs, MAX( srect->w, drect->w ) ))
+ return;
+
+
+ switch (gfxs->src_format) {
+ case DSPF_A4:
+ case DSPF_YUY2:
+ case DSPF_UYVY:
+ srect->x &= ~1;
+ break;
+ default:
+ break;
+ }
+
+ switch (gfxs->dst_format) {
+ case DSPF_A4:
+ case DSPF_YUY2:
+ case DSPF_UYVY:
+ drect->x &= ~1;
+ break;
+ default:
+ break;
+ }
+
+ gfxs->Slen = srect->w;
+ gfxs->Dlen = drect->w;
+ gfxs->length = gfxs->Dlen;
+ gfxs->SperD = fx;
+ gfxs->Xphase = ix;
+
+ h = drect->h;
+
+ Aop_xy( gfxs, drect->x, drect->y );
+ Bop_xy( gfxs, srect->x, srect->y );
+
+ while (h--) {
+ RUN_PIPELINE();
+
+ Aop_next( gfxs );
+
+ iy += fy;
+
+ while (iy > 0xFFFF) {
+ iy -= 0x10000;
+ Bop_next( gfxs );
+ }
+ }
+
+ ABacc_flush( gfxs );
+}
+
+
+#ifdef USE_MMX
+
+#include "generic_mmx.h"
+
+/*
+ * patches function pointers to MMX functions
+ */
+static void gInit_MMX( void )
+{
+ use_mmx = 1;
+
+/********************************* Sop_PFI_Sto_Dacc ***************************/
+// Sop_PFI_Sto_Dacc[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)] = Sop_argb_Sto_Dacc_MMX;
+/********************************* Sop_PFI_to_Dacc ****************************/
+// Sop_PFI_to_Dacc[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)] = Sop_rgb16_to_Dacc_MMX;
+// Sop_PFI_to_Dacc[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = Sop_rgb32_to_Dacc_MMX;
+// Sop_PFI_to_Dacc[DFB_PIXELFORMAT_INDEX(DSPF_ARGB )] = Sop_argb_to_Dacc_MMX;
+/********************************* Sacc_to_Aop_PFI ****************************/
+// Sacc_to_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)] = Sacc_to_Aop_rgb16_MMX;
+// Sacc_to_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = Sacc_to_Aop_rgb32_MMX;
+/********************************* Xacc_blend *********************************/
+ Xacc_blend[DSBF_SRCALPHA-1] = Xacc_blend_srcalpha_MMX;
+ Xacc_blend[DSBF_INVSRCALPHA-1] = Xacc_blend_invsrcalpha_MMX;
+/********************************* Dacc_modulation ****************************/
+ Dacc_modulation[DSBLIT_BLEND_ALPHACHANNEL |
+ DSBLIT_BLEND_COLORALPHA |
+ DSBLIT_COLORIZE] = Dacc_modulate_argb_MMX;
+/********************************* misc accumulator operations ****************/
+ SCacc_add_to_Dacc = SCacc_add_to_Dacc_MMX;
+ Sacc_add_to_Dacc = Sacc_add_to_Dacc_MMX;
+ Dacc_YCbCr_to_RGB = Dacc_YCbCr_to_RGB_MMX;
+ Dacc_RGB_to_YCbCr = Dacc_RGB_to_YCbCr_MMX;
+}
+
+#endif
+
+
+#if SIZEOF_LONG == 8
+
+#include "generic_64.h"
+
+/*
+ * patches function pointers to 64bit functions
+ */
+static void gInit_64bit( void )
+{
+/********************************* Cop_to_Aop_PFI ********************************/
+ Cop_to_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = Cop_to_Aop_32_64;
+ Cop_to_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)] = Cop_to_Aop_32_64;
+ Cop_to_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_AiRGB)] = Cop_to_Aop_32_64;
+/********************************* Bop_PFI_Kto_Aop_PFI ***************************/
+ Bop_PFI_Kto_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = Bop_rgb32_Kto_Aop_64;
+ Bop_PFI_Kto_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)] = Bop_rgb32_Kto_Aop_64;
+ Bop_PFI_Kto_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_AiRGB)] = Bop_rgb32_Kto_Aop_64;
+/********************************* Bop_PFI_tKo_Aop_PFI ***************************/
+ Bop_PFI_toK_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = Bop_rgb32_toK_Aop_64;
+ Bop_PFI_toK_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)] = Bop_rgb32_toK_Aop_64;
+ Bop_PFI_toK_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_AiRGB)] = Bop_rgb32_toK_Aop_64;
+/********************************* Bop_PFI_Sto_Aop_PFI ***************************/
+ Bop_PFI_Sto_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = Bop_32_Sto_Aop_64;
+ Bop_PFI_Sto_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)] = Bop_32_Sto_Aop_64;
+ Bop_PFI_Sto_Aop_PFI[DFB_PIXELFORMAT_INDEX(DSPF_AiRGB)] = Bop_32_Sto_Aop_64;
+/********************************* misc accumulator operations *******************/
+ Dacc_xor = Dacc_xor_64;
+}
+
+#endif
diff --git a/Source/DirectFB/src/gfx/generic/generic.h b/Source/DirectFB/src/gfx/generic/generic.h
new file mode 100755
index 0000000..7c73c40
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/generic.h
@@ -0,0 +1,174 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __GENERIC_H__
+#define __GENERIC_H__
+
+#include <dfb_types.h>
+
+#include <directfb.h>
+#include <core/coretypes.h>
+#include <core/gfxcard.h>
+
+/* this order is required for Intel with MMX, how about bigendian? */
+
+typedef union {
+ struct {
+ u16 b;
+ u16 g;
+ u16 r;
+ u16 a;
+ } RGB;
+ struct {
+ u16 u;
+ u16 v;
+ u16 y;
+ u16 a;
+ } YUV;
+} GenefxAccumulator;
+
+
+typedef struct _GenefxState GenefxState;
+
+typedef void (*GenefxFunc)(GenefxState *gfxs);
+
+/*
+ * State of the virtual graphics processing unit "Genefx" (pron. 'genie facts').
+ */
+struct _GenefxState {
+ GenefxFunc funcs[32];
+
+ int length; /* span length */
+ int Slen; /* span length (source) */
+ int Dlen; /* span length (destination) */
+
+ /*
+ * state values
+ */
+ void *dst_org[3];
+ void *src_org[3];
+ int dst_pitch;
+ int src_pitch;
+
+ int dst_bpp;
+ int src_bpp;
+
+ DFBSurfaceCapabilities dst_caps;
+ DFBSurfaceCapabilities src_caps;
+
+ DFBSurfacePixelFormat src_format;
+ DFBSurfacePixelFormat dst_format;
+
+ int dst_height;
+ int src_height;
+
+ int dst_field_offset;
+ int src_field_offset;
+
+ DFBColor color;
+
+ /*
+ * operands
+ */
+ void *Aop[3];
+ void *Bop[3];
+ u32 Cop;
+
+ int Astep;
+ int Bstep;
+
+ u8 YCop;
+ u8 CbCop;
+ u8 CrCop;
+
+ int Aop_field;
+ int Bop_field;
+
+ int AopY;
+ int BopY;
+
+ /*
+ * color keys
+ */
+ u32 Dkey;
+ u32 Skey;
+
+ /*
+ * color lookup tables
+ */
+ CorePalette *Alut;
+ CorePalette *Blut;
+
+ /*
+ * accumulators
+ */
+ void *ABstart;
+ int ABsize;
+ GenefxAccumulator *Aacc;
+ GenefxAccumulator *Bacc;
+ GenefxAccumulator *Tacc; /* for simultaneous S+D blending */
+ GenefxAccumulator Cacc;
+ GenefxAccumulator SCacc;
+
+ /*
+ * dataflow control
+ */
+ GenefxAccumulator *Xacc; /* writing pointer for blending */
+ GenefxAccumulator *Yacc; /* input pointer for blending */
+ GenefxAccumulator *Dacc;
+ GenefxAccumulator *Sacc;
+
+ void **Sop;
+ CorePalette *Slut;
+
+ int Ostep; /* controls horizontal blitting direction */
+
+ int SperD; /* for scaled routines only */
+ int Xphase; /* initial value for fractional steps (zero if not clipped) */
+
+ bool need_accumulator;
+
+ int *trans;
+ int num_trans;
+};
+
+
+void gGetDriverInfo( GraphicsDriverInfo *info );
+void gGetDeviceInfo( GraphicsDeviceInfo *info );
+
+bool gAcquire ( CardState *state, DFBAccelerationMask accel );
+void gRelease ( CardState *state );
+
+void gFillRectangle ( CardState *state, DFBRectangle *rect );
+void gDrawLine ( CardState *state, DFBRegion *line );
+
+void gBlit ( CardState *state, DFBRectangle *rect, int dx, int dy );
+void gStretchBlit ( CardState *state, DFBRectangle *srect, DFBRectangle *drect );
+
+
+#endif
diff --git a/Source/DirectFB/src/gfx/generic/generic_64.h b/Source/DirectFB/src/gfx/generic/generic_64.h
new file mode 100755
index 0000000..b0079ce
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/generic_64.h
@@ -0,0 +1,207 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+
+static void Cop_to_Aop_32_64( GenefxState *gfxs )
+{
+ int w, l = gfxs->length;
+ u32 *D = gfxs->Aop[0];
+ u32 Cop = gfxs->Cop;
+ u64 DCop = ((u64)Cop << 32) | Cop;
+
+ if ((long)D & 4) {
+ *D++ = Cop;
+ l--;
+ }
+
+ for (w = l >> 1; w; w--) {
+ *((u64*)D) = DCop;
+ D += 2;
+ }
+
+ if (l & 1)
+ *D = Cop;
+}
+
+static void Bop_rgb32_Kto_Aop_64( GenefxState *gfxs )
+{
+ int w, l = gfxs->length;
+ u32 *D = gfxs->Aop[0];
+ u32 *S = gfxs->Bop[0];
+ u32 Skey = gfxs->Skey;
+ u64 DSkey = ((u64)Skey << 32) | Skey;
+
+ if ((long)D & 4) {
+ if ((*S & 0x00ffffff) != Skey)
+ *D = *S;
+ D++;
+ S++;
+ l--;
+ }
+
+ for (w = l >> 1; w; w--) {
+ u64 s = *((u64*)S);
+
+ if ((s & 0x00ffffff00ffffffull) != DSkey) {
+ if ((s & 0x00ffffff00000000ull) !=
+ (DSkey & 0x00ffffff00000000ull)) {
+ if ((s & 0x0000000000ffffffull) !=
+ (DSkey & 0x0000000000ffffffull)) {
+ *((u64*)D) = s;
+ }
+ else {
+#ifdef WORDS_BIGENDIAN
+ D[0] = (u32)(s >> 32);
+#else
+ D[1] = (u32)(s >> 32);
+#endif
+ }
+ }
+ else {
+#ifdef WORDS_BIGENDIAN
+ D[1] = (u32)s;
+#else
+ D[0] = (u32)s;
+#endif
+ }
+ }
+ S += 2;
+ D += 2;
+ }
+
+ if (l & 1) { /* do the last potential pixel */
+ if ((*S & 0x00ffffff) != Skey)
+ *D = *S;
+ }
+}
+
+static void Bop_rgb32_toK_Aop_64( GenefxState *gfxs )
+{
+ int w, l = gfxs->length;
+ u32 *D = gfxs->Aop[0];
+ u32 *S = gfxs->Bop[0];
+ u32 Dkey = gfxs->Dkey;
+ u64 DDkey = ((u64)Dkey << 32) | Dkey;
+
+ if ((long)D & 4) {
+ if ((*D & 0x00ffffff) == Dkey)
+ *D = *S;
+ D++;
+ S++;
+ l--;
+ }
+
+ for (w = l >> 1; w; w--) {
+ u64 d = *((u64*)D);
+
+ if ((d & 0x00ffffff00ffffffull) != DDkey) {
+ if ((d & 0x00ffffff00000000ull) ==
+ (DDkey & 0x00ffffff00000000ull)) {
+ if ((d & 0x0000000000ffffffull) ==
+ (DDkey & 0x0000000000ffffffull)) {
+ *((u64*)D) = *((u64*)S);
+ }
+ else {
+#ifdef WORDS_BIGENDIAN
+ D[0] = S[0];
+#else
+ D[1] = S[1];
+#endif
+ }
+ }
+ else {
+#ifdef WORDS_BIGENDIAN
+ D[1] = S[1];
+#else
+ D[0] = S[0];
+#endif
+ }
+ }
+ S += 2;
+ D += 2;
+ }
+
+ if (l & 1) { /* do the last potential pixel */
+ if ((*D & 0x00ffffff) == Dkey)
+ *D = *S;
+ }
+}
+
+static void Bop_32_Sto_Aop_64( GenefxState *gfxs )
+{
+ int w, l = gfxs->length;
+ int i = 0;
+ u32 *D = gfxs->Aop[0];
+ u32 *S = gfxs->Bop[0];
+ int SperD = gfxs->SperD;
+ int SperD2 = SperD << 1;
+
+ if ((long)D & 4) {
+ *D++ = *S;
+ i += SperD;
+ l--;
+ }
+
+ for (w = l >> 1; w; w--) {
+#ifdef WORDS_BIGENDIAN
+ *((u64*)D) = ((u64)S[i>>16] << 32) | S[(i+SperD)>>16];
+#else
+ *((u64*)D) = ((u64)S[(i+SperD)>>16] << 32) | S[i>>16];
+#endif
+ D += 2;
+ i += SperD2;
+ }
+
+ if (l & 1)
+ *D = S[i>>16];
+}
+
+static void Dacc_xor_64( GenefxState *gfxs )
+{
+ int w = gfxs->length;
+ u64 *D = (u64*)gfxs->Dacc;
+ u64 color;
+
+#ifdef WORDS_BIGENDIAN
+ color = ((u64)gfxs->color.b << 48) |
+ ((u64)gfxs->color.g << 32) |
+ ((u64)gfxs->color.r << 16) |
+ ((u64)gfxs->color.a);
+#else
+ color = ((u64)gfxs->color.a << 48) |
+ ((u64)gfxs->color.r << 32) |
+ ((u64)gfxs->color.g << 16) |
+ ((u64)gfxs->color.b);
+#endif
+
+ for (; w; w--) {
+ *D ^= color;
+ D++;
+ }
+}
+
diff --git a/Source/DirectFB/src/gfx/generic/generic_dummy.c b/Source/DirectFB/src/gfx/generic/generic_dummy.c
new file mode 100755
index 0000000..00032a7
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/generic_dummy.c
@@ -0,0 +1,94 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <directfb.h>
+
+#include <core/gfxcard.h>
+
+#include <direct/messages.h>
+
+
+void
+gGetDriverInfo( GraphicsDriverInfo *info )
+{
+ D_INFO( "DirectFB/Genefx: No software fallbacks supported\n" );
+
+ snprintf( info->name, DFB_GRAPHICS_DRIVER_INFO_NAME_LENGTH, "Software Driver" );
+ snprintf( info->vendor, DFB_GRAPHICS_DRIVER_INFO_VENDOR_LENGTH, "directfb.org" );
+
+ info->version.major = 0;
+ info->version.minor = 0;
+}
+
+void
+gGetDeviceInfo( GraphicsDeviceInfo *info )
+{
+ snprintf( info->name, DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH, "Software Rasterizer" );
+ snprintf( info->vendor, DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "Dummy" );
+
+ info->caps.accel = DFXL_NONE;
+ info->caps.flags = 0;
+ info->caps.drawing = DSDRAW_NOFX;
+ info->caps.blitting = DSBLIT_NOFX;
+}
+
+bool
+gAcquire( CardState *state, DFBAccelerationMask accel )
+{
+ return false;
+}
+
+void
+gRelease( CardState *state )
+{
+}
+
+void
+gFillRectangle( CardState *state, DFBRectangle *rect )
+{
+}
+
+void
+gDrawLine( CardState *state, DFBRegion *line )
+{
+}
+
+void
+gBlit( CardState *state, DFBRectangle *rect, int dx, int dy )
+{
+}
+
+void
+gStretchBlit( CardState *state, DFBRectangle *srect, DFBRectangle *drect )
+{
+}
+
diff --git a/Source/DirectFB/src/gfx/generic/generic_mmx.h b/Source/DirectFB/src/gfx/generic/generic_mmx.h
new file mode 100755
index 0000000..57757f3
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/generic_mmx.h
@@ -0,0 +1,659 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+
+#define __aligned( n ) __attribute__ ((aligned((n))))
+
+
+static void SCacc_add_to_Dacc_MMX( GenefxState *gfxs )
+{
+ __asm__ __volatile__ (
+ " movq %2, %%mm0\n"
+ ".align 16\n"
+ "1:\n"
+ " movq (%0), %%mm1\n"
+ " paddw %%mm0, %%mm1\n"
+ " movq %%mm1, (%0)\n"
+ " add $8, %0\n"
+ " dec %1\n"
+ " jnz 1b\n"
+ " emms"
+ : /* no outputs */
+ : "D" (gfxs->Dacc), "c" (gfxs->length), "m" (gfxs->SCacc)
+ : "%st", "memory");
+}
+
+static void Dacc_modulate_argb_MMX( GenefxState *gfxs )
+{
+ __asm__ __volatile__ (
+ "movq %2, %%mm0\n\t"
+ ".align 16\n"
+ "1:\n\t"
+ "testw $0xF000, 6(%0)\n\t"
+ "jnz 2f\n\t"
+ "movq (%0), %%mm1\n\t"
+ "pmullw %%mm0, %%mm1\n\t"
+ "psrlw $8, %%mm1\n\t"
+ "movq %%mm1, (%0)\n"
+ ".align 16\n"
+ "2:\n\t"
+ "add $8, %0\n\t"
+ "dec %1\n\t"
+ "jnz 1b\n\t"
+ "emms"
+ : /* no outputs */
+ : "D" (gfxs->Dacc), "c" (gfxs->length), "m" (gfxs->Cacc)
+ : "%st", "memory");
+}
+
+static void Sacc_add_to_Dacc_MMX( GenefxState *gfxs )
+{
+ __asm__ __volatile__ (
+ ".align 16\n"
+ "1:\n\t"
+ "movq (%2), %%mm0\n\t"
+ "movq (%0), %%mm1\n\t"
+ "paddw %%mm1, %%mm0\n\t"
+ "movq %%mm0, (%0)\n\t"
+ "add $8, %0\n\t"
+ "add $8, %2\n\t"
+ "dec %1\n\t"
+ "jnz 1b\n\t"
+ "emms"
+ : /* no outputs */
+ : "D" (gfxs->Dacc), "c" (gfxs->length), "S" (gfxs->Sacc)
+ : "%st", "memory");
+}
+
+static void Sacc_to_Aop_rgb16_MMX( GenefxState *gfxs )
+{
+ static const u32 preload[] = { 0xFF00FF00, 0x0000FF00 };
+ static const u32 mask[] = { 0x00FC00F8, 0x000000F8 };
+ static const u32 pm[] = { 0x01000004, 0x00000004 };
+
+ __asm__ __volatile__ (
+ "movq %3, %%mm7\n\t"
+ "movq %4, %%mm5\n\t"
+ "movq %5, %%mm4\n\t"
+ ".align 16\n"
+ "1:\n\t"
+ "testw $0xF000, 6(%2)\n\t"
+ "jnz 2f\n\t"
+ "movq (%2), %%mm0\n\t"
+ "paddusw %%mm7, %%mm0\n\t"
+ "pand %%mm5, %%mm0\n\t"
+ "pmaddwd %%mm4, %%mm0\n\t"
+ "psrlq $5, %%mm0\n\t"
+ "movq %%mm0, %%mm1\n\t"
+ "psrlq $21, %%mm0\n\t"
+ "por %%mm1, %%mm0\n\t"
+ "movd %%mm0, %%eax\n\t"
+ "movw %%ax, (%0)\n\t"
+ ".align 16\n"
+ "2:\n\t"
+ "add $8, %2\n\t"
+ "add $2, %0\n\t"
+ "dec %1\n\t"
+ "jnz 1b\n\t"
+ "emms"
+ : /* no outputs */
+ : "D" (gfxs->Aop[0]), "c" (gfxs->length), "S" (gfxs->Sacc),
+ "m" (*preload), "m" (*mask), "m" (*pm)
+ : "%eax", "%st", "memory");
+}
+
+static void Sacc_to_Aop_rgb32_MMX( GenefxState *gfxs )
+{
+ static const u32 preload[] = { 0xFF00FF00, 0x0000FF00 };
+ static const u32 postload[] = { 0x00FF00FF, 0x000000FF };
+ static const u32 pm[] = { 0x01000001, 0x00000001 };
+
+ __asm__ __volatile__ (
+ "movq %3, %%mm1\n\t"
+ "movq %4, %%mm2\n\t"
+ "movq %5, %%mm3\n\t"
+ ".align 16\n"
+ "1:\n\t"
+ "testw $0xF000, 6(%2)\n\t"
+ "jnz 2f\n\t"
+ "movq (%2), %%mm0\n\t"
+ "paddusw %%mm1, %%mm0\n\t"
+ "pand %%mm2, %%mm0\n\t"
+ "pmaddwd %%mm3, %%mm0\n\t"
+ "movq %%mm0, %%mm4\n\t"
+ "psrlq $16, %%mm0\n\t"
+ "por %%mm0, %%mm4\n\t"
+ "movd %%mm4, (%0)\n\t"
+ ".align 16\n"
+ "2:\n\t"
+ "add $8, %2\n\t"
+ "add $4, %0\n\t"
+ "dec %1\n\t"
+ "jnz 1b\n\t"
+ "emms"
+ : /* no outputs */
+ : "D" (gfxs->Aop[0]), "c" (gfxs->length), "S" (gfxs->Sacc),
+ "m" (*preload), "m" (*postload), "m" (*pm)
+ : "%st", "memory");
+}
+
+__attribute__((no_instrument_function))
+static void Sop_argb_Sto_Dacc_MMX( GenefxState *gfxs )
+{
+ static const u32 zeros[] = { 0, 0 };
+ int i = 0;
+
+ __asm__ __volatile__ (
+ "movq %5, %%mm0\n\t"
+ ".align 16\n"
+ "1:\n\t"
+ "movd (%3), %%mm1\n\t"
+ "punpcklbw %%mm0, %%mm1\n\t"
+ ".align 16\n"
+ "2:\n\t"
+ "movq %%mm1, (%1)\n\t"
+ "dec %2\n\t"
+ "jz 3f\n\t"
+ "add $8, %1\n\t"
+ "add %4, %0\n\t"
+ "testl $0xFFFF0000, %0\n\t"
+ "jz 2b\n\t"
+ "movl %0, %%edx\n\t"
+ "andl $0xFFFF0000, %%edx\n\t"
+ "shrl $14, %%edx\n\t"
+#ifdef ARCH_X86_64
+ "addq %%rdx, %3\n\t"
+#else
+ "addl %%edx, %3\n\t"
+#endif
+ "andl $0xFFFF, %0\n\t"
+ "jmp 1b\n"
+ "3:\n\t"
+ "emms"
+ : "=r" (i)
+ : "D" (gfxs->Dacc), "c" (gfxs->length), "S" (gfxs->Sop[0]),
+ "a" (gfxs->SperD), "m" (*zeros), "0" (i)
+ : "%edx", "%st", "memory");
+}
+
+static void Sop_argb_to_Dacc_MMX( GenefxState *gfxs )
+{
+ static const u32 zeros[] = { 0, 0 };
+
+ __asm__ __volatile__ (
+ "movq %3, %%mm0\n\t"
+ ".align 16\n"
+ "1:\n\t"
+ "movd (%2), %%mm1\n\t"
+ "punpcklbw %%mm0, %%mm1\n\t"
+ "movq %%mm1, (%0)\n\t"
+ "add $4, %2\n\t"
+ "add $8, %0\n\t"
+ "dec %1\n\t"
+ "jnz 1b\n\t"
+ "emms"
+ : /* no outputs */
+ : "D" (gfxs->Dacc), "c" (gfxs->length),
+ "S" (gfxs->Sop[0]), "m" (*zeros)
+ : "%st", "memory");
+}
+
+static void Sop_rgb16_to_Dacc_MMX( GenefxState *gfxs )
+{
+ static const u32 mask[] = { 0x07E0001F, 0x0000F800 };
+ static const u32 smul[] = { 0x00200800, 0x00000001 };
+ static const u32 alpha[] = { 0x00000000, 0x00FF0000 };
+
+ __asm__ __volatile__ (
+ "movq %3, %%mm4\n\t"
+ "movq %4, %%mm5\n\t"
+ "movq %5, %%mm7\n\t"
+ ".align 16\n"
+ "1:\n\t"
+ "movq (%2), %%mm0\n\t"
+ /* 1. Konvertierung nach 24 bit interleaved */
+ "movq %%mm0, %%mm3\n\t"
+ "punpcklwd %%mm3, %%mm3\n\t"
+ "punpckldq %%mm3, %%mm3\n\t"
+ "pand %%mm4, %%mm3\n\t"
+ "pmullw %%mm5, %%mm3\n\t"
+ "psrlw $8, %%mm3\n\t"
+ /* mm3 enthaelt jetzt: 0000 00rr 00gg 00bb des alten pixels */
+ "por %%mm7, %%mm3\n\t"
+ "movq %%mm3, (%0)\n\t"
+ "dec %1\n\t"
+ "jz 2f\n\t"
+ "psrlq $16, %%mm0\n\t"
+ "add $8, %0\n\t"
+ /* 2. Konvertierung nach 24 bit interleaved */
+ "movq %%mm0, %%mm3\n\t"
+ "punpcklwd %%mm3, %%mm3\n\t"
+ "punpckldq %%mm3, %%mm3\n\t"
+ "pand %%mm4, %%mm3\n\t"
+ "pmullw %%mm5, %%mm3\n\t"
+ "psrlw $8, %%mm3\n\t"
+ /* mm3 enthaelt jetzt: 0000 00rr 00gg 00bb des alten pixels */
+ "por %%mm7, %%mm3\n\t"
+ "movq %%mm3, (%0)\n\t"
+ "dec %1\n\t"
+ "jz 2f\n\t"
+ "psrlq $16, %%mm0\n\t"
+ "add $8, %0\n\t"
+ /* 3. Konvertierung nach 24 bit interleaved */
+ "movq %%mm0, %%mm3\n\t"
+ "punpcklwd %%mm3, %%mm3\n\t"
+ "punpckldq %%mm3, %%mm3\n\t"
+ "pand %%mm4, %%mm3\n\t"
+ "pmullw %%mm5, %%mm3\n\t"
+ "psrlw $8, %%mm3\n\t"
+ /* mm3 enthaelt jetzt: 0000 00rr 00gg 00bb des alten pixels */
+ "por %%mm7, %%mm3\n\t"
+ "movq %%mm3, (%0)\n\t"
+ "dec %1\n\t"
+ "jz 2f\n\t"
+ "psrlq $16, %%mm0\n\t"
+ "add $8, %0\n\t"
+ /* 4. Konvertierung nach 24 bit interleaved */
+ "movq %%mm0, %%mm3\n\t"
+ "punpcklwd %%mm3, %%mm3\n\t"
+ "punpckldq %%mm3, %%mm3\n\t"
+ "pand %%mm4, %%mm3\n\t"
+ "pmullw %%mm5, %%mm3\n\t"
+ "psrlw $8, %%mm3\n\t"
+ /* mm3 enthaelt jetzt: 0000 00rr 00gg 00bb des alten pixels */
+ "por %%mm7, %%mm3\n\t"
+ "movq %%mm3, (%0)\n\t"
+ "dec %1\n\t"
+ "jz 2f\n\t"
+ "add $8, %0\n\t"
+ "add $8, %2\n\t"
+ "jmp 1b\n"
+ "2:\n\t"
+ "emms"
+ : /* no outputs */
+ : "D" (gfxs->Dacc), "c" (gfxs->length), "S" (gfxs->Sop[0]),
+ "m" (*mask), "m" (*smul), "m" (*alpha)
+ : "%st", "memory");
+}
+
+static void Sop_rgb32_to_Dacc_MMX( GenefxState *gfxs )
+{
+ static const u32 alpha[] = { 0, 0x00FF0000 };
+ static const u32 zeros[] = { 0, 0 };
+
+ __asm__ __volatile__ (
+ "movq %3, %%mm7\n\t"
+ "movq %4, %%mm6\n\t"
+ ".align 16\n"
+ "1:\n\t"
+ "movd (%2), %%mm0\n\t"
+ "punpcklbw %%mm6, %%mm0\n\t"
+ "por %%mm7, %%mm0\n\t"
+ "movq %%mm0, (%0)\n\t"
+ "add $4, %2\n\t"
+ "add $8, %0\n\t"
+ "dec %1\n\t"
+ "jnz 1b\n\t"
+ "emms"
+ : /* no outputs */
+ : "D" (gfxs->Dacc), "c" (gfxs->length), "S" (gfxs->Sop[0]),
+ "m" (*alpha), "m" (*zeros)
+ : "%st", "memory");
+}
+
+static void Xacc_blend_invsrcalpha_MMX( GenefxState *gfxs )
+{
+ static const u32 einser[] = { 0x01000100, 0x01000100 };
+ static const u32 zeros[] = { 0, 0 };
+
+ __asm__ __volatile__ (
+ "movq %3, %%mm7\n\t"
+ "cmp $0, %2\n\t"
+ "jne 1f\n\t"
+ "movq %4, %%mm6\n\t"
+ "movd %5, %%mm0\n\t"
+ "punpcklbw %%mm6, %%mm0\n\t" /* mm0 = 00aa 00rr 00gg 00bb */
+ "punpcklwd %%mm0, %%mm0\n\t" /* mm0 = 00aa 00aa xxxx xxxx */
+ "movq %%mm7, %%mm1\n\t"
+ "punpckldq %%mm0, %%mm0\n\t" /* mm0 = 00aa 00aa 00aa 00aa */
+ "psubw %%mm0, %%mm1\n\t"
+
+ ".align 16\n"
+ "2:\n\t" /* blend from color */
+ "testw $0xF000, 6(%0)\n\t"
+ "jnz 3f\n\t"
+ "movq (%0), %%mm0\n\t"
+ "pmullw %%mm1, %%mm0\n\t"
+ "psrlw $8, %%mm0\n\t"
+ "movq %%mm0, (%6)\n\t"
+ "jmp 4f\n\t"
+ "3:\n\t"
+ "movq (%0), %%mm0\n\t"
+ "movq %%mm0, (%6)\n\t"
+ "4:\n\t"
+ "add $8, %0\n\t"
+ "add $8, %6\n\t"
+ "dec %1\n\t"
+ "jnz 2b\n\t"
+ "jmp 9f\n\t"
+
+ ".align 16\n"
+ "1:\n\t" /* blend from Sacc */
+ "testw $0xF000, 6(%0)\n\t"
+ "jnz 5f\n\t"
+ "movq (%2), %%mm2\n\t"
+ "movq (%0), %%mm0\n\t"
+ "punpckhwd %%mm2, %%mm2\n\t" /* mm2 = 00aa 00aa xxxx xxxx */
+ "movq %%mm7, %%mm1\n\t"
+ "punpckhdq %%mm2, %%mm2\n\t" /* mm2 = 00aa 00aa 00aa 00aa */
+ "psubw %%mm2, %%mm1\n\t"
+ "pmullw %%mm1, %%mm0\n\t"
+ "psrlw $8, %%mm0\n\t"
+ "movq %%mm0, (%6)\n\t"
+ "jmp 6f\n\t"
+ "5:\n\t"
+ "movq (%0), %%mm0\n\t"
+ "movq %%mm0, (%6)\n\t"
+ "6:\n\t"
+ "add $8, %2\n\t"
+ "add $8, %0\n\t"
+ "add $8, %6\n\t"
+ "dec %1\n\t"
+ "jnz 1b\n\t"
+ "9:\n\t"
+ "emms"
+ : /* no outputs */
+ : "D" (gfxs->Yacc), "c" (gfxs->length), "S" (gfxs->Sacc),
+ "m" (*einser), "m" (*zeros), "m" (gfxs->color), "r" (gfxs->Xacc)
+ : "%st", "memory");
+}
+
+static void Xacc_blend_srcalpha_MMX( GenefxState *gfxs )
+{
+ static const u32 ones[] = { 0x00010001, 0x00010001 };
+ static const u32 zeros[] = { 0, 0 };
+
+ __asm__ __volatile__ (
+ "movq %3, %%mm7\n\t"
+ "cmp $0, %2\n\t"
+ "jne 3f\n\t"
+ "movq %4, %%mm6\n\t"
+ "movd %5, %%mm0\n\t"
+ "punpcklbw %%mm6, %%mm0\n\t" /* mm0 = 00aa 00rr 00gg 00bb */
+ "punpcklwd %%mm0, %%mm0\n\t" /* mm0 = 00aa 00aa xxxx xxxx */
+ "punpckldq %%mm0, %%mm0\n\t" /* mm0 = 00aa 00aa 00aa 00aa */
+ "paddw %%mm7, %%mm0\n\t"
+
+ ".align 16\n\t"
+ "4:\n\t" /* blend from color */
+ "testw $0xF000, 6(%0)\n\t"
+ "jnz 6f\n\t"
+ "movq (%0), %%mm1\n\t"
+ "pmullw %%mm0, %%mm1\n\t"
+ "psrlw $8, %%mm1\n\t"
+ "movq %%mm1, (%6)\n\t"
+ "jmp 1f\n\t"
+ "6:\n\t"
+ "movq (%0), %%mm1\n\t"
+ "movq %%mm1, (%6)\n\t"
+ "1:\n\t"
+ "add $8, %0\n\t"
+ "add $8, %6\n\t"
+ "dec %1\n\t"
+ "jnz 4b\n\t"
+ "jmp 2f\n\t"
+
+ ".align 16\n\t"
+ "3:\n\t" /* blend from Sacc */
+ "testw $0xF000, 6(%0)\n\t"
+ "jnz 5f\n\t"
+ "movq (%2), %%mm0\n\t"
+ "movq (%0), %%mm1\n\t"
+ "punpckhwd %%mm0, %%mm0\n\t" /* mm2 = 00aa 00aa xxxx xxxx */
+ "punpckhdq %%mm0, %%mm0\n\t" /* mm2 = 00aa 00aa 00aa 00aa */
+ "paddw %%mm7, %%mm0\n\t"
+ "pmullw %%mm0, %%mm1\n\t"
+ "psrlw $8, %%mm1\n\t"
+ "movq %%mm1, (%6)\n\t"
+ "jmp 7f\n\t"
+ "5:\n\t"
+ "movq (%0), %%mm1\n\t"
+ "movq %%mm1, (%6)\n\t"
+ "7:\n\t"
+ "add $8, %2\n\t"
+ "add $8, %0\n\t"
+ "add $8, %6\n\t"
+ "dec %1\n\t"
+ "jnz 3b\n\t"
+ "2:\n\t"
+ "emms"
+ : /* no outputs */
+ : "D" (gfxs->Yacc), "c" (gfxs->length), "S" (gfxs->Sacc),
+ "m" (*ones), "m" (*zeros), "m" (gfxs->color), "r" (gfxs->Xacc)
+ : "%st", "memory");
+}
+
+static void Dacc_YCbCr_to_RGB_MMX( GenefxState *gfxs )
+{
+ static const u16 __aligned(8) sub0[4] = { 16, 16, 16, 16 };
+ static const u16 __aligned(8) sub1[4] = { 128, 128, 128, 128 };
+ static const s16 __aligned(8) mul[20] = {
+ 0x253F, 0x253F, 0x253F, 0x253F, // Y Coeff.
+ 0x3312, 0x3312, 0x3312, 0x3312, // V Red Coeff.
+ 0x4093, 0x4093, 0x4093, 0x4093, // U Blue Coeff.
+ -0x1A04, -0x1A04, -0x1A04, -0x1A04, // V Green Coeff.
+ -0x0C83, -0x0C83, -0x0C83, -0x0C83 // U Green Coeff.
+ };
+
+ int w = gfxs->length & 3;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ __asm__ __volatile__ (
+ "shrl $2, %1\n\t"
+ "jz 2f\n\t"
+ "pxor %%mm7, %%mm7\n\t"
+ ".align 16\n"
+ "1:\n\t"
+ "movq (%0), %%mm0\n\t" // 00 a0 00 y0 00 v0 00 u0
+ "movq 8(%0), %%mm1\n\t" // 00 a1 00 y1 00 v1 00 u1
+ "movq 16(%0), %%mm2\n\t" // 00 a2 00 y2 00 v2 00 u2
+ "movq 24(%0), %%mm3\n\t" // 00 a3 00 y3 00 v3 00 u3
+ "movq %%mm0, %%mm4\n\t" // 00 a0 00 y0 00 v0 00 u0
+ "movq %%mm2, %%mm5\n\t" // 00 a2 00 y2 00 v2 00 u2
+ "punpcklwd %%mm1, %%mm0\n\t" // 00 v1 00 v0 00 u1 00 u0
+ "punpcklwd %%mm3, %%mm2\n\t" // 00 v3 00 v2 00 u3 00 u2
+ "punpckhwd %%mm1, %%mm4\n\t" // 00 a1 00 a0 00 y1 00 y0
+ "punpckhwd %%mm3, %%mm5\n\t" // 00 a3 00 a2 00 y3 00 y2
+ "movq %%mm0, %%mm1\n\t" // 00 v1 00 v1 00 u1 00 u0
+ "movq %%mm4, %%mm3\n\t" // 00 a1 00 a0 00 y1 00 y0
+ "punpckldq %%mm2, %%mm0\n\t" // 00 u3 00 u2 00 u1 00 u0
+ "punpckldq %%mm5, %%mm3\n\t" // 00 y3 00 y2 00 y1 00 y0
+ "punpckhdq %%mm2, %%mm1\n\t" // 00 v3 00 v2 00 v1 00 v0
+ "punpckhdq %%mm5, %%mm4\n\t" // 00 a3 00 a2 00 a1 00 a0
+ /* mm0 = u, mm1 = v, mm3 = y, mm4 = a */
+ "psubw %2, %%mm3\n\t" // y -= 16
+ "psllw $3, %%mm3\n\t" // precision
+ "pmulhw (%4), %%mm3\n\t"
+ "psubw %3, %%mm1\n\t" // v -= 128
+ "psllw $3, %%mm1\n\t" // precision
+ "movq %%mm1, %%mm2\n\t" // 00 v3 00 v2 00 v1 00 v0
+ "pmulhw 8(%4), %%mm2\n\t" // vr
+ "psubw %3, %%mm0\n\t" // u -= 128
+ "psllw $3, %%mm0\n\t" // precision
+ "movq %%mm0, %%mm5\n\t" // 00 u3 00 u2 00 u1 00 u0
+ "pmulhw 16(%4), %%mm5\n\t" // ub
+ "paddw %%mm3, %%mm2\n\t" // 00 r3 00 r2 00 r1 00 r0
+ "paddw %%mm3, %%mm5\n\t" // 00 b3 00 b2 00 b1 00 b0
+ "pmulhw 24(%4), %%mm1\n\t" // vg
+ "packuswb %%mm2, %%mm2\n\t" // r3 r2 r1 r0 r3 r2 r1 r0
+ "packuswb %%mm5, %%mm5\n\t" // b3 b2 b1 b0 b3 b2 b1 b0
+ "pmulhw 32(%4), %%mm0\n\t" // ug
+ "punpcklbw %%mm7, %%mm2\n\t" // 00 r3 00 r2 00 r1 00 r0
+ "punpcklbw %%mm7, %%mm5\n\t" // 00 b3 00 b2 00 b1 00 b0
+ "paddw %%mm1, %%mm3\n\t" // y + vg
+ "paddw %%mm0, %%mm3\n\t" // 00 g3 00 g2 00 g1 00 g0
+ "packuswb %%mm3, %%mm3\n\t" // g3 g2 g1 g0 g3 g2 g1 g0
+ "punpcklbw %%mm7, %%mm3\n\t" // 00 g3 00 g2 00 g1 00 g0
+ /* mm5 = b, mm3 = g, mm2 = r, mm4 = a */
+ "movq %%mm5, %%mm0\n\t" // 00 b3 00 b2 00 b1 00 b0
+ "movq %%mm3, %%mm1\n\t" // 00 g3 00 g2 00 g1 00 g0
+ "punpcklwd %%mm2, %%mm0\n\t" // 00 r1 00 b1 00 r0 00 b0
+ "punpcklwd %%mm4, %%mm1\n\t" // 00 a1 00 g1 00 a0 00 g0
+ "punpckhwd %%mm2, %%mm5\n\t" // 00 r3 00 b3 00 r2 00 b2
+ "punpckhwd %%mm4, %%mm3\n\t" // 00 a3 00 g3 00 a2 00 g2
+ "movq %%mm0, %%mm2\n\t" // 00 r1 00 b1 00 r0 00 b0
+ "movq %%mm5, %%mm4\n\t" // 00 r3 00 b3 00 r2 00 b2
+ "punpcklwd %%mm1, %%mm0\n\t" // 00 a0 00 r0 00 g0 00 b0
+ "punpcklwd %%mm3, %%mm5\n\t" // 00 a2 00 r2 00 g2 00 b2
+ "punpckhwd %%mm1, %%mm2\n\t" // 00 a1 00 r1 00 g1 00 b1
+ "punpckhwd %%mm3, %%mm4\n\t" // 00 a3 00 r3 00 g3 00 b3
+ "movq %%mm0, (%0)\n\t"
+ "movq %%mm2, 8(%0)\n\t"
+ "movq %%mm5,16(%0)\n\t"
+ "movq %%mm4,24(%0)\n\t"
+ "add $32, %0\n\t"
+ "decl %1\n\t"
+ "jnz 1b\n\t"
+ "emms\n\t"
+ "2:"
+ : "=&D" (D)
+ : "c" (gfxs->length), "m" (*sub0), "m" (*sub1), "r" (mul), "0" (D)
+ : "memory" );
+
+ while (w) {
+ if (!(D->YUV.a & 0xF000))
+ YCBCR_TO_RGB( D->YUV.y, D->YUV.u, D->YUV.v,
+ D->RGB.r, D->RGB.g, D->RGB.b );
+
+ D++;
+ w--;
+ }
+}
+
+static void Dacc_RGB_to_YCbCr_MMX( GenefxState *gfxs )
+{
+ static const u16 __aligned(8) add0[4] = { 128, 128, 128, 128 };
+ static const u16 __aligned(8) add1[4] = { 16, 16, 16, 16 };
+ static const u16 __aligned(8) mul[24] = {
+ 0x03A5, 0x03A5, 0x03A5, 0x03A5, // Eb
+ 0x12C8, 0x12C8, 0x12C8, 0x12C8, // Eg
+ 0x0991, 0x0991, 0x0991, 0x0991, // Er
+ 0x0FE1, 0x0FE1, 0x0FE1, 0x0FE1, // Cb
+ 0x140A, 0x140A, 0x140A, 0x140A, // Cr
+ 0x1B7B, 0x1B7B, 0x1B7B, 0x1B7B // Y
+ };
+
+ int w = gfxs->length & 3;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ __asm__ __volatile__(
+ "shrl $2, %1\n\t"
+ "jz 2f\n\t"
+ "pxor %%mm7, %%mm7\n\t"
+ ".align 16\n"
+ "1:\n\t"
+ "movq (%0), %%mm0\n\t" // 00 a0 00 r0 00 g0 00 b0
+ "movq 8(%0), %%mm1\n\t" // 00 a1 00 r1 00 g1 00 b1
+ "movq 16(%0), %%mm2\n\t" // 00 a2 00 r2 00 g2 00 b2
+ "movq 24(%0), %%mm3\n\t" // 00 a3 00 r3 00 g3 00 b3
+ "movq %%mm0, %%mm4\n\t" // 00 a0 00 r0 00 g0 00 b0
+ "movq %%mm2, %%mm6\n\t" // 00 a2 00 r2 00 g2 00 b2
+ "punpcklwd %%mm1, %%mm0\n\t" // 00 g1 00 g0 00 b1 00 b0
+ "punpcklwd %%mm3, %%mm2\n\t" // 00 g3 00 g2 00 b3 00 b2
+ "movq %%mm0, %%mm5\n\t" // 00 g1 00 g0 00 b1 00 b0
+ "punpckldq %%mm2, %%mm0\n\t" // 00 b3 00 b2 00 b1 00 b0
+ "punpckhdq %%mm2, %%mm5\n\t" // 00 g3 00 g2 00 g1 00 g0
+ "punpckhwd %%mm1, %%mm4\n\t" // 00 a1 00 a0 00 r1 00 r0
+ "punpckhwd %%mm3, %%mm6\n\t" // 00 a3 00 a2 00 r3 00 r2
+ "movq %%mm4, %%mm3\n\t" // 00 a1 00 a0 00 r1 00 r0
+ "punpckldq %%mm6, %%mm4\n\t" // 00 r3 00 r2 00 r1 00 r0
+ "punpckhdq %%mm6, %%mm3\n\t" // 00 a3 00 a2 00 a1 00 a0
+ /* mm0 = b, mm5 = g, mm4 = r, mm3 = a */
+ "movq %%mm0, %%mm1\n\t" // save b
+ "psllw $3, %%mm0\n\t"
+ "pmulhw (%2), %%mm0\n\t"
+ "movq %%mm4, %%mm2\n\t" // save r
+ "psllw $3, %%mm5\n\t"
+ "pmulhw 8(%2), %%mm5\n\t"
+ "psllw $3, %%mm4\n\t"
+ "pmulhw 16(%2), %%mm4\n\t"
+ "paddw %%mm5, %%mm0\n\t"
+ "paddw %%mm4, %%mm0\n\t" // ey
+ "psubw %%mm0, %%mm1\n\t" // b - ey
+ "psllw $3, %%mm1\n\t"
+ "pmulhw 24(%2), %%mm1\n\t" // 00 u3 00 u2 00 u1 00 u0
+ "psubw %%mm0, %%mm2\n\t" // r - ey
+ "psllw $3, %%mm2\n\t"
+ "pmulhw 32(%2), %%mm2\n\t" // 00 v3 00 v2 00 v1 00 v0
+ "paddw %3, %%mm1\n\t" // Cb + 128
+ "packuswb %%mm1, %%mm1\n\t" // u3 u2 u1 u0 u3 u2 u1 u0
+ "psllw $3, %%mm0\n\t"
+ "pmulhw 40(%2), %%mm0\n\t" // 00 y3 00 y2 00 y1 00 y0
+ "paddw %3, %%mm2\n\t" // Cr + 128
+ "packuswb %%mm2, %%mm2\n\t" // v3 v2 v1 v0 v3 v2 v1 v0
+ "paddw %4, %%mm0\n\t" // Y + 16
+ "packuswb %%mm0, %%mm0\n\t" // y3 y2 y1 y0 y3 y2 y1 y0
+ "punpcklbw %%mm7, %%mm2\n\t" // 00 v3 00 v2 00 v1 00 v0
+ "punpcklbw %%mm7, %%mm1\n\t" // 00 u3 00 y2 00 u1 00 u0
+ "punpcklbw %%mm7, %%mm0\n\t" // 00 y3 00 y2 00 y1 00 y0
+ /* mm1 = u, mm2 = v, mm0 = y, mm3 = a */
+ "movq %%mm2, %%mm4\n\t" // 00 v3 00 v2 00 v1 00 v0
+ "movq %%mm1, %%mm5\n\t" // 00 u3 00 y2 00 u1 00 u0
+ "punpcklwd %%mm3, %%mm2\n\t" // 00 a1 00 v1 00 a0 00 v0
+ "punpcklwd %%mm0, %%mm1\n\t" // 00 y1 00 u1 00 y0 00 u0
+ "punpckhwd %%mm3, %%mm4\n\t" // 00 a3 00 v3 00 a2 00 v2
+ "punpckhwd %%mm0, %%mm5\n\t" // 00 y3 00 u3 00 y2 00 u2
+ "movq %%mm1, %%mm3\n\t" // 00 y1 00 u1 00 y0 00 u0
+ "movq %%mm5, %%mm6\n\t" // 00 y3 00 u3 00 y2 00 u2
+ "punpcklwd %%mm2, %%mm1\n\t" // 00 a0 00 y0 00 v0 00 u0
+ "punpcklwd %%mm4, %%mm5\n\t" // 00 a2 00 y2 00 v2 00 u2
+ "punpckhwd %%mm2, %%mm3\n\t" // 00 a1 00 y1 00 v1 00 u1
+ "punpckhwd %%mm4, %%mm6\n\t" // 00 a3 00 y3 00 v3 00 u3
+ "movq %%mm1, (%0)\n\t"
+ "movq %%mm3, 8(%0)\n\t"
+ "movq %%mm5,16(%0)\n\t"
+ "movq %%mm6,24(%0)\n\t"
+ "add $32, %0\n\t"
+ "decl %1\n\t"
+ "jnz 1b\n\t"
+ "emms\n\t"
+ "2:"
+ : "=&D" (D)
+ : "c" (gfxs->length), "r" (mul), "m" (*add0), "m" (*add1), "0" (D)
+ : "memory" );
+
+ while (w) {
+ if (!(D->RGB.a & 0xF000))
+ RGB_TO_YCBCR( D->RGB.r, D->RGB.g, D->RGB.b,
+ D->YUV.y, D->YUV.u, D->YUV.v );
+
+ D++;
+ w--;
+ }
+}
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_hvx_16.h b/Source/DirectFB/src/gfx/generic/stretch_hvx_16.h
new file mode 100755
index 0000000..01cf41f
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_hvx_16.h
@@ -0,0 +1,469 @@
+#ifndef SOURCE_LOOKUP
+#define SOURCE_LOOKUP(x) (x)
+#define SOURCE_LOOKUP_AUTO
+#endif
+
+#ifndef SOURCE_TYPE
+#define SOURCE_TYPE u16
+#define SOURCE_TYPE_AUTO
+#endif
+
+
+#define SHIFT_L5 SHIFT_R5
+#define SHIFT_L6 SHIFT_R6
+#define SHIFT_L10 (16-SHIFT_L6)
+
+#define X_003F (X_07E0>>SHIFT_R5)
+
+#define X_003E07C0 (X_F81F<<SHIFT_L6)
+#define X_0001F800 (X_07E0<<SHIFT_L6)
+
+#define X_07E0F81F ((X_07E0<<16) | X_F81F)
+#define X_F81F07E0 ((X_F81F<<16) | X_07E0)
+
+#define X_F81FF81F ((X_F81F<<16) | X_F81F)
+#define X_07E007E0 ((X_07E0<<16) | X_07E0)
+
+#define X_07C0F83F (X_F81F07E0>>SHIFT_R5)
+
+#if 0
+#define HVX_DEBUG(x...) direct_log_printf( NULL, x )
+#else
+#define HVX_DEBUG(x...) do {} while (0)
+#endif
+
+/* stretch_hvx_up/down_16_KPI */( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ const StretchCtx *ctx )
+{
+ long x, y, r = 0;
+ long head = ((((ulong) dst) & 2) >> 1) ^ (ctx->clip.x1 & 1);
+ long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
+ long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
+ long tail = (cw - head) & 1;
+ long w2 = (cw - head) / 2;
+ long hfraq = ((long)(width - MINUS_1) << 18) / (long)(dst_width);
+ long vfraq = ((long)(height - MINUS_1) << 18) / (long)(dst_height);
+ long dp4 = dpitch / 4;
+ long point0 = POINT_0 + ctx->clip.x1 * hfraq;
+ long point = point0;
+ long line = LINE_0 + ctx->clip.y1 * vfraq;
+ long ratios[cw];
+ u32 *dst32;
+
+#if defined (COLOR_KEY) || defined (KEY_PROTECT)
+ u32 dt;
+ u16 l_, h_;
+#endif
+
+ u32 _lbT[w2+8];
+ u32 _lbB[w2+8];
+
+ u32 *lbX;
+ u32 *lbT = (u32*)((((ulong)(&_lbT[0])) + 31) & ~31);
+ u32 *lbB = (u32*)((((ulong)(&_lbB[0])) + 31) & ~31);
+
+ long lineT = -2000;
+
+ for (x=0; x<cw; x++) {
+ ratios[x] = POINT_TO_RATIO( point, hfraq );
+
+ point += hfraq;
+ }
+
+ HVX_DEBUG(" %s %dx%d -> %dx%d (0x%lx, 0x%lx) prot %lx, key %lx\n",
+ __FUNCTION__, width, height, dst_width, dst_height, hfraq, vfraq, ctx->protect, ctx->key );
+
+ dst += ctx->clip.x1 * 2 + ctx->clip.y1 * dpitch;
+
+ dst32 = dst;
+
+ if (head) {
+ u32 dpT, dpB, L, R;
+
+ u16 *dst16 = dst;
+
+ point = point0;
+
+ for (y=0; y<ch; y++) {
+ long X = LINE_TO_RATIO( line, vfraq );
+
+ const SOURCE_TYPE *srcT = src + spitch * LINE_T( line, vfraq );
+ const SOURCE_TYPE *srcB = src + spitch * LINE_B( line, vfraq );
+
+ /*
+ * Horizontal interpolation
+ */
+ long pl = POINT_L( point, hfraq );
+ HVX_DEBUG("h,%ld %lu (%lu/%lu) 0x%x 0x%x\n", y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+ L = SOURCE_LOOKUP(srcT[pl]);
+ R = SOURCE_LOOKUP(srcT[pl+1]);
+
+ dpT = (((((R & X_F81F)-(L & X_F81F))*ratios[r] + ((L & X_F81F)<<SHIFT_L6)) & X_003E07C0) +
+ ((((R & X_07E0)-(L & X_07E0))*ratios[r] + ((L & X_07E0)<<SHIFT_L6)) & X_0001F800)) >> SHIFT_R6;
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ dpB = (((((R & X_F81F)-(L & X_F81F))*ratios[r] + ((L & X_F81F)<<SHIFT_L6)) & X_003E07C0) +
+ ((((R & X_07E0)-(L & X_07E0))*ratios[r] + ((L & X_07E0)<<SHIFT_L6)) & X_0001F800)) >> SHIFT_R6;
+
+ /*
+ * Vertical interpolation
+ */
+#if defined (COLOR_KEY) || defined (KEY_PROTECT)
+ l_ = ((((((dpB & X_F81F) - (dpT & X_F81F))*X) >> SHIFT_R5) + (dpT & X_F81F)) & X_F81F) +
+ ((((((dpB>>SHIFT_R5) & X_003F) - ((dpT>>SHIFT_R5) & X_003F))*X) + (dpT & X_07E0)) & X_07E0);
+#ifdef COLOR_KEY
+ if ((l_ & MASK_RGB) != (COLOR_KEY))
+#endif
+#ifdef KEY_PROTECT
+ /* Write to destination with color key protection */
+ dst16[0] = ((l_ & MASK_RGB) == KEY_PROTECT) ? l_^1 : l_;
+#else
+ /* Write to destination without color key protection */
+ dst16[0] = l_;
+#endif
+#else
+ /* Write to destination without color key protection */
+ dst16[0] = ((((((dpB & X_F81F) - (dpT & X_F81F))*X) >> SHIFT_R5) + (dpT & X_F81F)) & X_F81F) +
+ ((((((dpB>>SHIFT_R5) & X_003F) - ((dpT>>SHIFT_R5) & X_003F))*X) + (dpT & X_07E0)) & X_07E0);
+#endif
+
+ dst16 += dpitch / 2;
+ line += vfraq;
+ }
+
+ /* Adjust */
+ point0 += hfraq;
+ dst32 = dst + 2;
+
+ /* Reset */
+ line = LINE_0 + ctx->clip.y1 * vfraq;
+ }
+
+ /*
+ * Scale line by line.
+ */
+ for (y=0; y<ch; y++) {
+ long X;
+ long nlT = LINE_T( line, vfraq );
+
+ D_ASSERT( nlT >= 0 );
+ D_ASSERT( nlT < height-1 );
+
+ /*
+ * Fill line buffer(s) ?
+ */
+ if (nlT != lineT) {
+ u32 L, R, dpT, dpB;
+ const SOURCE_TYPE *srcT = src + spitch * nlT;
+ const SOURCE_TYPE *srcB = src + spitch * (nlT + 1);
+ long diff = nlT - lineT;
+
+ if (diff > 1) {
+ /*
+ * Two output pixels per step.
+ */
+ for (x=0, r=head, point=point0; x<w2; x++) {
+ /*
+ * Horizontal interpolation
+ */
+ long pl = POINT_L( point, hfraq );
+ HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+ L = SOURCE_LOOKUP(srcT[pl]);
+ R = SOURCE_LOOKUP(srcT[pl+1]);
+
+ dpT = (((((R & X_F81F)-(L & X_F81F))*ratios[r] + ((L & X_F81F)<<SHIFT_L6)) & X_003E07C0) +
+ ((((R & X_07E0)-(L & X_07E0))*ratios[r] + ((L & X_07E0)<<SHIFT_L6)) & X_0001F800))
+#ifdef WORDS_BIGENDIAN
+ << SHIFT_L10;
+#else
+ >> SHIFT_R6;
+#endif
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ dpB = (((((R & X_F81F)-(L & X_F81F))*ratios[r] + ((L & X_F81F)<<SHIFT_L6)) & X_003E07C0) +
+ ((((R & X_07E0)-(L & X_07E0))*ratios[r] + ((L & X_07E0)<<SHIFT_L6)) & X_0001F800))
+#ifdef WORDS_BIGENDIAN
+ << SHIFT_L10;
+#else
+ >> SHIFT_R6;
+#endif
+
+ point += hfraq;
+ r++;
+
+
+ pl = POINT_L( point, hfraq );
+ HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+
+ L = SOURCE_LOOKUP(srcT[pl]);
+ R = SOURCE_LOOKUP(srcT[pl+1]);
+
+ dpT |= (((((R & X_F81F)-(L & X_F81F))*ratios[r] + ((L & X_F81F)<<SHIFT_L6)) & X_003E07C0) +
+ ((((R & X_07E0)-(L & X_07E0))*ratios[r] + ((L & X_07E0)<<SHIFT_L6)) & X_0001F800))
+#ifdef WORDS_BIGENDIAN
+ >> SHIFT_R6;
+#else
+ << SHIFT_L10;
+#endif
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ dpB |= (((((R & X_F81F)-(L & X_F81F))*ratios[r] + ((L & X_F81F)<<SHIFT_L6)) & X_003E07C0) +
+ ((((R & X_07E0)-(L & X_07E0))*ratios[r] + ((L & X_07E0)<<SHIFT_L6)) & X_0001F800))
+#ifdef WORDS_BIGENDIAN
+ >> SHIFT_R6;
+#else
+ << SHIFT_L10;
+#endif
+
+ point += hfraq;
+ r++;
+
+ /* Store */
+ lbT[x] = dpT;
+ lbB[x] = dpB;
+ }
+ }
+ else {
+ /* Swap */
+ lbX = lbT;
+ lbT = lbB;
+ lbB = lbX;
+
+ /*
+ * Two output pixels per step.
+ */
+ for (x=0, r=head, point=point0; x<w2; x++) {
+ /*
+ * Horizontal interpolation
+ */
+ long pl = POINT_L( point, hfraq );
+ HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ dpB = (((((R & X_F81F)-(L & X_F81F))*ratios[r] + ((L & X_F81F)<<SHIFT_L6)) & X_003E07C0) +
+ ((((R & X_07E0)-(L & X_07E0))*ratios[r] + ((L & X_07E0)<<SHIFT_L6)) & X_0001F800))
+#ifdef WORDS_BIGENDIAN
+ << SHIFT_L10;
+#else
+ >> SHIFT_R6;
+#endif
+
+ point += hfraq;
+ r++;
+
+
+ pl = POINT_L( point, hfraq );
+ HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ dpB |= (((((R & X_F81F)-(L & X_F81F))*ratios[r] + ((L & X_F81F)<<SHIFT_L6)) & X_003E07C0) +
+ ((((R & X_07E0)-(L & X_07E0))*ratios[r] + ((L & X_07E0)<<SHIFT_L6)) & X_0001F800))
+#ifdef WORDS_BIGENDIAN
+ >> SHIFT_R6;
+#else
+ << SHIFT_L10;
+#endif
+
+ point += hfraq;
+ r++;
+
+ /* Store */
+ lbB[x] = dpB;
+ }
+ }
+
+ lineT = nlT;
+ }
+
+ /*
+ * Vertical interpolation
+ */
+ X = LINE_TO_RATIO( line, vfraq );
+
+ for (x=0; x<w2; x++) {
+#if defined (COLOR_KEY) || defined (KEY_PROTECT)
+#ifdef HAS_ALPHA
+ dt = ((((((lbB[x] & X_F81FF81F) - (lbT[x] & X_F81FF81F))*X) >> SHIFT_R5) + (lbT[x] & X_F81FF81F)) & X_F81FF81F) +
+ ((((((lbB[x]>>SHIFT_R5) & X_F81FF81F) - ((lbT[x]>>SHIFT_R5) & X_F81FF81F))*X) + (lbT[x] & X_07E007E0)) & X_07E007E0);
+#else
+ dt = ((((((lbB[x] & X_07E0F81F) - (lbT[x] & X_07E0F81F))*X) >> SHIFT_R5) + (lbT[x] & X_07E0F81F)) & X_07E0F81F) +
+ ((((((lbB[x]>>SHIFT_R5) & X_07C0F83F) - ((lbT[x]>>SHIFT_R5) & X_07C0F83F))*X) + (lbT[x] & X_F81F07E0)) & X_F81F07E0);
+#endif
+
+ /* Get two new pixels. */
+ l_ = dt;
+ h_ = dt >> 16;
+
+#ifdef COLOR_KEY
+ if ((l_ & MASK_RGB) != (COLOR_KEY)) {
+ if ((h_ & MASK_RGB) != (COLOR_KEY)) {
+#ifdef KEY_PROTECT
+ /* Write to destination with color key protection */
+ dst32[x] = ((((h_ & MASK_RGB) == KEY_PROTECT) ? h_^1 : h_) << 16) | (((l_ & MASK_RGB) == KEY_PROTECT) ? l_^1 : l_);
+#else
+ /* Write to destination without color key protection */
+ dst32[x] = dt;
+#endif
+ }
+ else {
+ u16 *_dst16 = (u16*) &dst32[x];
+
+#ifdef KEY_PROTECT
+ /* Write to destination with color key protection */
+ *_dst16 = (((l_ & MASK_RGB) == KEY_PROTECT) ? l_^1 : l_);
+#else
+ /* Write to destination without color key protection */
+ *_dst16 = l_;
+#endif
+ }
+ }
+ else if ((h_ & MASK_RGB) != (COLOR_KEY)) {
+ u16 *_dst16 = ((u16*) &dst32[x]) + 1;
+
+#ifdef KEY_PROTECT
+ /* Write to destination with color key protection */
+ *_dst16 = (((h_ & MASK_RGB) == KEY_PROTECT) ? h_^1 : h_);
+#else
+ /* Write to destination without color key protection */
+ *_dst16 = h_;
+#endif
+ }
+#else
+ /* Write to destination with color key protection */
+ dst32[x] = ((((h_ & MASK_RGB) == KEY_PROTECT) ? h_^1 : h_) << 16) | (((l_ & MASK_RGB) == KEY_PROTECT) ? l_^1 : l_);
+#endif
+#else
+#ifdef HAS_ALPHA
+ dst32[x] = ((((((lbB[x] & X_F81FF81F) - (lbT[x] & X_F81FF81F))*X) >> SHIFT_R5) + (lbT[x] & X_F81FF81F)) & X_F81FF81F) +
+ ((((((lbB[x]>>SHIFT_R5) & X_F81FF81F) - ((lbT[x]>>SHIFT_R5) & X_F81FF81F))*X) + (lbT[x] & X_07E007E0)) & X_07E007E0);
+#else
+ dst32[x] = ((((((lbB[x] & X_07E0F81F) - (lbT[x] & X_07E0F81F))*X) >> SHIFT_R5) + (lbT[x] & X_07E0F81F)) & X_07E0F81F) +
+ ((((((lbB[x]>>SHIFT_R5) & X_07C0F83F) - ((lbT[x]>>SHIFT_R5) & X_07C0F83F))*X) + (lbT[x] & X_F81F07E0)) & X_F81F07E0);
+#endif
+#endif
+ }
+
+ dst32 += dp4;
+ line += vfraq;
+ }
+
+ if (tail) {
+ u32 dpT, dpB, L, R;
+
+ u16 *dst16 = dst + cw * 2 - 2;
+
+ /* Reset */
+ line = LINE_0 + ctx->clip.y1 * vfraq;
+
+ for (y=0; y<ch; y++) {
+ long X = LINE_TO_RATIO( line, vfraq );
+
+ const SOURCE_TYPE *srcT = src + spitch * LINE_T( line, vfraq );
+ const SOURCE_TYPE *srcB = src + spitch * LINE_B( line, vfraq );
+
+ /*
+ * Horizontal interpolation
+ */
+ long pl = POINT_L( point, hfraq );
+ HVX_DEBUG("t,%ld %lu (%lu/%lu) 0x%x 0x%x\n", y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+ L = SOURCE_LOOKUP(srcT[pl]);
+ R = SOURCE_LOOKUP(srcT[pl+1]);
+
+ dpT = (((((R & X_F81F)-(L & X_F81F))*ratios[r] + ((L & X_F81F)<<SHIFT_L6)) & X_003E07C0) +
+ ((((R & X_07E0)-(L & X_07E0))*ratios[r] + ((L & X_07E0)<<SHIFT_L6)) & X_0001F800)) >> SHIFT_R6;
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ dpB = (((((R & X_F81F)-(L & X_F81F))*ratios[r] + ((L & X_F81F)<<SHIFT_L6)) & X_003E07C0) +
+ ((((R & X_07E0)-(L & X_07E0))*ratios[r] + ((L & X_07E0)<<SHIFT_L6)) & X_0001F800)) >> SHIFT_R6;
+
+ /*
+ * Vertical interpolation
+ */
+#if defined (COLOR_KEY) || defined (KEY_PROTECT)
+ l_ = ((((((dpB & X_F81F) - (dpT & X_F81F))*X) >> SHIFT_R5) + (dpT & X_F81F)) & X_F81F) +
+ ((((((dpB>>SHIFT_R5) & X_003F) - ((dpT>>SHIFT_R5) & X_003F))*X) + (dpT & X_07E0)) & X_07E0);
+
+#ifdef COLOR_KEY
+ if ((l_ & MASK_RGB) != (COLOR_KEY))
+#endif
+#ifdef KEY_PROTECT
+ /* Write to destination with color key protection */
+ dst16[0] = ((l_ & MASK_RGB) == KEY_PROTECT) ? l_^1 : l_;
+#else
+ /* Write to destination without color key protection */
+ dst16[0] = l_;
+#endif
+#else
+ /* Write to destination without color key protection */
+ dst16[0] = ((((((dpB & X_F81F) - (dpT & X_F81F))*X) >> SHIFT_R5) + (dpT & X_F81F)) & X_F81F) +
+ ((((((dpB>>SHIFT_R5) & X_003F) - ((dpT>>SHIFT_R5) & X_003F))*X) + (dpT & X_07E0)) & X_07E0);
+#endif
+
+ dst16 += dpitch / 2;
+ line += vfraq;
+ }
+ }
+}
+
+
+#undef SHIFT_L6
+#undef SHIFT_L10
+
+#undef X_003F
+
+#undef X_003E07C0
+#undef X_0001F800
+
+#undef X_07E0F81F
+#undef X_F81F07E0
+
+#undef X_07C0F83F
+
+
+
+#ifdef SOURCE_LOOKUP_AUTO
+#undef SOURCE_LOOKUP_AUTO
+#undef SOURCE_LOOKUP
+#endif
+
+#ifdef SOURCE_TYPE_AUTO
+#undef SOURCE_TYPE_AUTO
+#undef SOURCE_TYPE
+#endif
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_hvx_32.h b/Source/DirectFB/src/gfx/generic/stretch_hvx_32.h
new file mode 100755
index 0000000..289ff2c
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_hvx_32.h
@@ -0,0 +1,174 @@
+#ifndef SOURCE_LOOKUP
+#define SOURCE_LOOKUP(x) (x)
+#define SOURCE_LOOKUP_AUTO
+#endif
+
+#ifndef SOURCE_TYPE
+#define SOURCE_TYPE u32
+#define SOURCE_TYPE_AUTO
+#endif
+
+#if 0
+#define HVX_DEBUG(x...) direct_log_printf( NULL, x )
+#else
+#define HVX_DEBUG(x...) do {} while (0)
+#endif
+
+/* stretch_hvx_up/down_32_KPI */( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ const StretchCtx *ctx )
+{
+ long x, y = 0;
+ long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
+ long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
+ long hfraq = ((long)(width - MINUS_1) << 18) / (long)(dst_width);
+ long vfraq = ((long)(height - MINUS_1) << 18) / (long)(dst_height);
+ long dp4 = dpitch / 4;
+ long point0 = POINT_0 + ctx->clip.x1 * hfraq;
+ long point = point0;
+ long line = LINE_0 + ctx->clip.y1 * vfraq;
+ long ratios[cw];
+ u32 *dst32;
+
+#if defined (COLOR_KEY) || defined (KEY_PROTECT)
+ u32 dt;
+#endif
+
+ u32 _lbT[cw+8];
+ u32 _lbB[cw+8];
+
+ u32 *lbX;
+ u32 *lbT = (u32*)((((ulong)(&_lbT[0])) + 31) & ~31);
+ u32 *lbB = (u32*)((((ulong)(&_lbB[0])) + 31) & ~31);
+
+ long lineT = -2000;
+
+ for (x=0; x<cw; x++) {
+ ratios[x] = POINT_TO_RATIO( point, hfraq );
+
+ point += hfraq;
+ }
+
+ HVX_DEBUG("%dx%d -> %dx%d (0x%x, 0x%x)\n", width, height, dst_width, dst_height, hfraq, vfraq );
+
+ dst += ctx->clip.x1 * 4 + ctx->clip.y1 * dpitch;
+
+ dst32 = dst;
+
+ /*
+ * Scale line by line.
+ */
+ for (y=0; y<ch; y++) {
+ long X;
+ long nlT = LINE_T( line, vfraq );
+
+ D_ASSERT( nlT >= 0 );
+ D_ASSERT( nlT < height-1 );
+
+ /*
+ * Fill line buffer(s) ?
+ */
+ if (nlT != lineT) {
+ u32 L, R;
+ const SOURCE_TYPE *srcT = src + spitch * nlT;
+ const SOURCE_TYPE *srcB = src + spitch * (nlT + 1);
+ long diff = nlT - lineT;
+
+ if (diff > 1) {
+ /*
+ * Horizontal interpolation
+ */
+ for (x=0, point=point0; x<cw; x++, point += hfraq) {
+ long pl = POINT_L( point, hfraq );
+ HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+
+ L = SOURCE_LOOKUP(srcT[pl]);
+ R = SOURCE_LOOKUP(srcT[pl+1]);
+
+ lbT[x]= ((((((R & X_00FF00FF) - (L & X_00FF00FF))*ratios[x]) >> SHIFT_R8) + (L & X_00FF00FF)) & X_00FF00FF) +
+ ((((((R>>SHIFT_R8) & X_00FF00FF) - ((L>>SHIFT_R8) & X_00FF00FF))*ratios[x]) + (L & X_FF00FF00)) & X_FF00FF00);
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ lbB[x] = ((((((R & X_00FF00FF) - (L & X_00FF00FF))*ratios[x]) >> SHIFT_R8) + (L & X_00FF00FF)) & X_00FF00FF) +
+ ((((((R>>SHIFT_R8) & X_00FF00FF) - ((L>>SHIFT_R8) & X_00FF00FF))*ratios[x]) + (L & X_FF00FF00)) & X_FF00FF00);
+ }
+ }
+ else {
+ /* Swap */
+ lbX = lbT;
+ lbT = lbB;
+ lbB = lbX;
+
+ /*
+ * Horizontal interpolation
+ */
+ for (x=0, point=point0; x<cw; x++, point += hfraq) {
+ long pl = POINT_L( point, hfraq );
+ HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ lbB[x] = ((((((R & X_00FF00FF) - (L & X_00FF00FF))*ratios[x]) >> SHIFT_R8) + (L & X_00FF00FF)) & X_00FF00FF) +
+ ((((((R>>SHIFT_R8) & X_00FF00FF) - ((L>>SHIFT_R8) & X_00FF00FF))*ratios[x]) + (L & X_FF00FF00)) & X_FF00FF00);
+ }
+ }
+
+ lineT = nlT;
+ }
+
+ /*
+ * Vertical interpolation
+ */
+ X = LINE_TO_RATIO( line, vfraq );
+
+ for (x=0; x<cw; x++) {
+#if defined (COLOR_KEY) || defined (KEY_PROTECT)
+ dt = ((((((lbB[x] & X_00FF00FF) - (lbT[x] & X_00FF00FF))*X) >> SHIFT_R8) + (lbT[x] & X_00FF00FF)) & X_00FF00FF) +
+ ((((((lbB[x]>>SHIFT_R8) & X_00FF00FF) - ((lbT[x]>>SHIFT_R8) & X_00FF00FF))*X) + (lbT[x] & X_FF00FF00)) & X_FF00FF00);
+#ifdef COLOR_KEY
+ if (dt != (COLOR_KEY))
+#endif
+#ifdef KEY_PROTECT
+ /* Write to destination with color key protection */
+ dst32[x] = ((dt & MASK_RGB) == KEY_PROTECT) ? dt^1 : dt;
+#else
+ /* Write to destination without color key protection */
+ dst32[x] = dt;
+#endif
+#else
+ /* Write to destination without color key protection */
+ dst32[x] = ((((((lbB[x] & X_00FF00FF) - (lbT[x] & X_00FF00FF))*X) >> SHIFT_R8) + (lbT[x] & X_00FF00FF)) & X_00FF00FF) +
+ ((((((lbB[x]>>SHIFT_R8) & X_00FF00FF) - ((lbT[x]>>SHIFT_R8) & X_00FF00FF))*X) + (lbT[x] & X_FF00FF00)) & X_FF00FF00);
+#endif
+ }
+
+ dst32 += dp4;
+ line += vfraq;
+ }
+}
+
+#ifdef SOURCE_LOOKUP_AUTO
+#undef SOURCE_LOOKUP_AUTO
+#undef SOURCE_LOOKUP
+#endif
+
+#ifdef SOURCE_TYPE_AUTO
+#undef SOURCE_TYPE_AUTO
+#undef SOURCE_TYPE
+#endif
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_hvx_8.h b/Source/DirectFB/src/gfx/generic/stretch_hvx_8.h
new file mode 100755
index 0000000..e809304
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_hvx_8.h
@@ -0,0 +1,149 @@
+#ifndef SOURCE_LOOKUP
+#define SOURCE_LOOKUP(x) (x)
+#define SOURCE_LOOKUP_AUTO
+#endif
+
+#ifndef SOURCE_TYPE
+#define SOURCE_TYPE u8
+#define SOURCE_TYPE_AUTO
+#endif
+
+#if 0
+#define HVX_DEBUG(x...) direct_log_printf( NULL, x )
+#else
+#define HVX_DEBUG(x...) do {} while (0)
+#endif
+
+/*** OPTIMIZE by doing four pixels at once (vertically) with a 32 bit line buffer ***/
+
+/*static void STRETCH_HVX_YV12( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ DFBRegion *clip )*/
+{
+ long x, y = 0;
+ long cw = clip->x2 - clip->x1 + 1;
+ long ch = clip->y2 - clip->y1 + 1;
+ long hfraq = ((long)(width - MINUS_1) << 18) / (long)(dst_width);
+ long vfraq = ((long)(height - MINUS_1) << 18) / (long)(dst_height);
+ long point0 = POINT_0 + clip->x1 * hfraq;
+ long point = point0;
+ long line = LINE_0 + clip->y1 * vfraq;
+ long ratios[cw];
+ u8 *dst8;
+
+ u8 _lbT[cw+32];
+ u8 _lbB[cw+32];
+
+ u8 *lbX;
+ u8 *lbT = (u8*)((((ulong)(&_lbT[0])) + 31) & ~31);
+ u8 *lbB = (u8*)((((ulong)(&_lbB[0])) + 31) & ~31);
+
+ long lineT = -2000;
+
+ for (x=0; x<cw; x++) {
+ ratios[x] = POINT_TO_RATIO( point, hfraq );
+
+ point += hfraq;
+ }
+
+ HVX_DEBUG("%dx%d -> %dx%d (0x%x, 0x%x)\n", width, height, dst_width, dst_height, hfraq, vfraq );
+
+ dst += clip->x1 + clip->y1 * dpitch;
+
+ dst8 = dst;
+
+ /*
+ * Scale line by line.
+ */
+ for (y=0; y<ch; y++) {
+ long nlT = LINE_T( line, vfraq );
+
+ D_ASSERT( nlT >= 0 );
+ D_ASSERT( nlT < height-1 );
+
+ /*
+ * Fill line buffer(s) ?
+ */
+ if (nlT != lineT) {
+ u8 L, R;
+ const SOURCE_TYPE *srcT = src + spitch * nlT;
+ const SOURCE_TYPE *srcB = src + spitch * (nlT + 1);
+ long diff = nlT - lineT;
+
+ if (diff > 1) {
+ /*
+ * Horizontal interpolation
+ */
+ for (x=0, point=point0; x<cw; x++, point += hfraq) {
+ long pl = POINT_L( point, hfraq );
+ HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+
+ L = SOURCE_LOOKUP(srcT[pl]);
+ R = SOURCE_LOOKUP(srcT[pl+1]);
+
+ lbT[x] = (((R - L) * ratios[x]) >> 8) + L;
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ lbB[x] = (((R - L) * ratios[x]) >> 8) + L;
+ }
+ }
+ else {
+ /* Swap */
+ lbX = lbT;
+ lbT = lbB;
+ lbB = lbX;
+
+ /*
+ * Horizontal interpolation
+ */
+ for (x=0, point=point0; x<cw; x++, point += hfraq) {
+ long pl = POINT_L( point, hfraq );
+ HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ lbB[x] = (((R - L) * ratios[x]) >> 8) + L;
+ }
+ }
+
+ lineT = nlT;
+ }
+
+ /*
+ * Vertical interpolation
+ */
+ long X = LINE_TO_RATIO( line, vfraq );
+
+ for (x=0; x<cw; x++)
+ dst8[x] = (((lbB[x] - lbT[x]) * X) >> 8) + lbT[x];
+
+ dst8 += dpitch;
+ line += vfraq;
+ }
+}
+
+#ifdef SOURCE_LOOKUP_AUTO
+#undef SOURCE_LOOKUP_AUTO
+#undef SOURCE_LOOKUP
+#endif
+
+#ifdef SOURCE_TYPE_AUTO
+#undef SOURCE_TYPE_AUTO
+#undef SOURCE_TYPE
+#endif
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_hvx_88.h b/Source/DirectFB/src/gfx/generic/stretch_hvx_88.h
new file mode 100755
index 0000000..6394b5b
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_hvx_88.h
@@ -0,0 +1,152 @@
+#ifndef SOURCE_LOOKUP
+#define SOURCE_LOOKUP(x) (x)
+#define SOURCE_LOOKUP_AUTO
+#endif
+
+#ifndef SOURCE_TYPE
+#define SOURCE_TYPE u16
+#define SOURCE_TYPE_AUTO
+#endif
+
+#if 0
+#define HVX_DEBUG(x...) direct_log_printf( NULL, x )
+#else
+#define HVX_DEBUG(x...) do {} while (0)
+#endif
+
+
+/*** OPTIMIZE by doing two pixels at once (vertically) with a 32 bit line buffer ***/
+
+/*static void STRETCH_HVX_NV16( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ DFBRegion *clip )*/
+{
+ long x, y = 0;
+ long cw = clip->x2 - clip->x1 + 1;
+ long ch = clip->y2 - clip->y1 + 1;
+ long hfraq = ((long)(width - MINUS_1) << 18) / (long)(dst_width);
+ long vfraq = ((long)(height - MINUS_1) << 18) / (long)(dst_height);
+ long point0 = POINT_0 + clip->x1 * hfraq;
+ long point = point0;
+ long line = LINE_0 + clip->y1 * vfraq;
+ long ratios[cw];
+ u16 *dst16;
+
+ u16 _lbT[cw+16];
+ u16 _lbB[cw+16];
+
+ u16 *lbX;
+ u16 *lbT = (u16*)((((ulong)(&_lbT[0])) + 31) & ~31);
+ u16 *lbB = (u16*)((((ulong)(&_lbB[0])) + 31) & ~31);
+
+ long lineT = -2000;
+
+ for (x=0; x<cw; x++) {
+ ratios[x] = POINT_TO_RATIO( point, hfraq );
+
+ point += hfraq;
+ }
+
+ dst += clip->x1 * 2 + clip->y1 * dpitch;
+
+ dst16 = dst;
+
+ /*
+ * Scale line by line.
+ */
+ for (y=0; y<ch; y++) {
+ long nlT = LINE_T( line, vfraq );
+
+ D_ASSERT( nlT >= 0 );
+ D_ASSERT( nlT < height-1 );
+
+ /*
+ * Fill line buffer(s) ?
+ */
+ if (nlT != lineT) {
+ u16 L, R;
+ const SOURCE_TYPE *srcT = src + spitch * nlT;
+ const SOURCE_TYPE *srcB = src + spitch * (nlT + 1);
+ long diff = nlT - lineT;
+
+ if (diff > 1) {
+ /*
+ * Horizontal interpolation
+ */
+ for (x=0, point=point0; x<cw; x++, point += hfraq) {
+ long pl = POINT_L( point, hfraq );
+ HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+
+ L = SOURCE_LOOKUP(srcT[pl]);
+ R = SOURCE_LOOKUP(srcT[pl+1]);
+
+ lbT[x] = (((((R & 0x00ff)-(L & 0x00ff))*ratios[x] + ((L & 0x00ff)<<8)) & 0x00ff00) +
+ ((((R & 0xff00)-(L & 0xff00))*ratios[x] + ((L & 0xff00)<<8)) & 0xff0000)) >> 8;
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ lbB[x] = (((((R & 0x00ff)-(L & 0x00ff))*ratios[x] + ((L & 0x00ff)<<8)) & 0x00ff00) +
+ ((((R & 0xff00)-(L & 0xff00))*ratios[x] + ((L & 0xff00)<<8)) & 0xff0000)) >> 8;
+ }
+ }
+ else {
+ /* Swap */
+ lbX = lbT;
+ lbT = lbB;
+ lbB = lbX;
+
+ /*
+ * Horizontal interpolation
+ */
+ for (x=0, point=point0; x<cw; x++, point += hfraq) {
+ long pl = POINT_L( point, hfraq );
+ HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl,
+ POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] );
+ D_ASSERT( pl >= 0 );
+ D_ASSERT( pl < width-1 );
+
+ L = SOURCE_LOOKUP(srcB[pl]);
+ R = SOURCE_LOOKUP(srcB[pl+1]);
+
+ lbB[x] = (((((R & 0x00ff)-(L & 0x00ff))*ratios[x] + ((L & 0x00ff)<<8)) & 0x00ff00) +
+ ((((R & 0xff00)-(L & 0xff00))*ratios[x] + ((L & 0xff00)<<8)) & 0xff0000)) >> 8;
+ }
+ }
+
+ lineT = nlT;
+ }
+
+ /*
+ * Vertical interpolation
+ */
+ long X = LINE_TO_RATIO( line, vfraq );
+
+ for (x=0; x<cw; x++)
+ dst16[x] = (((((lbB[x] & 0x00ff)-(lbT[x] & 0x00ff))*X + ((lbT[x] & 0x00ff)<<8)) & 0x00ff00) +
+ ((((lbB[x] & 0xff00)-(lbT[x] & 0xff00))*X + ((lbT[x] & 0xff00)<<8)) & 0xff0000)) >> 8;
+
+ dst16 += dpitch / 2;
+ line += vfraq;
+ }
+}
+
+#ifdef SOURCE_LOOKUP_AUTO
+#undef SOURCE_LOOKUP_AUTO
+#undef SOURCE_LOOKUP
+#endif
+
+#ifdef SOURCE_TYPE_AUTO
+#undef SOURCE_TYPE_AUTO
+#undef SOURCE_TYPE
+#endif
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_hvx_N.h b/Source/DirectFB/src/gfx/generic/stretch_hvx_N.h
new file mode 100755
index 0000000..c4922e1
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_hvx_N.h
@@ -0,0 +1,121 @@
+#if UPDOWN == 1
+#define FUNC_NAME_(K,P,F) FUNC_NAME(up,K,P,F)
+#else
+#define FUNC_NAME_(K,P,F) FUNC_NAME(down,K,P,F)
+#endif
+
+
+/* NONE */
+static void FUNC_NAME_(_,_,DST_FORMAT)
+#include STRETCH_HVX_N_H
+
+/* SRCKEY */
+#define COLOR_KEY ctx->key
+static void FUNC_NAME_(K,_,DST_FORMAT)
+#include STRETCH_HVX_N_H
+#undef COLOR_KEY
+
+/* PROTECT */
+#define KEY_PROTECT ctx->protect
+static void FUNC_NAME_(_,P,DST_FORMAT)
+#include STRETCH_HVX_N_H
+
+/* PROTECT SRCKEY */
+#define COLOR_KEY ctx->key
+static void FUNC_NAME_(K,P,DST_FORMAT)
+#include STRETCH_HVX_N_H
+#undef COLOR_KEY
+#undef KEY_PROTECT
+
+
+/* INDEXED */
+#define SOURCE_LOOKUP(x) ((const uN*)ctx->colors)[x]
+#define SOURCE_TYPE u8
+static void FUNC_NAME_(_,_,DSPF_LUT8)
+#include STRETCH_HVX_N_H
+
+/* INDEXED SRCKEY */
+#define COLOR_KEY ctx->key
+static void FUNC_NAME_(K,_,DSPF_LUT8)
+#include STRETCH_HVX_N_H
+#undef COLOR_KEY
+
+/* INDEXED PROTECT */
+#define KEY_PROTECT ctx->protect
+static void FUNC_NAME_(_,P,DSPF_LUT8)
+#include STRETCH_HVX_N_H
+
+/* INDEXED PROTECT SRCKEY */
+#define COLOR_KEY ctx->key
+static void FUNC_NAME_(K,P,DSPF_LUT8)
+#include STRETCH_HVX_N_H
+#undef COLOR_KEY
+#undef KEY_PROTECT
+#undef SOURCE_LOOKUP
+#undef SOURCE_TYPE
+
+
+/* FIXME: DST_FORMAT == DSPF_RGB16 doesn't work */
+#ifdef FORMAT_RGB16
+/* ARGB4444 */
+#define SOURCE_LOOKUP(x) PIXEL_RGB16( (((x) & 0x0f00) >> 4) | (((x) & 0x0f00) >> 8), \
+ (((x) & 0x00f0) ) | (((x) & 0x00f0) >> 4), \
+ (((x) & 0x000f) << 4) | (((x) & 0x000f) ) )
+static void FUNC_NAME_(_,_,DSPF_ARGB4444)
+#include STRETCH_HVX_N_H
+
+/* ARGB4444 SRCKEY */
+#define COLOR_KEY ctx->key
+static void FUNC_NAME_(K,_,DSPF_ARGB4444)
+#include STRETCH_HVX_N_H
+#undef COLOR_KEY
+
+/* ARGB4444 PROTECT */
+#define KEY_PROTECT ctx->protect
+static void FUNC_NAME_(_,P,DSPF_ARGB4444)
+#include STRETCH_HVX_N_H
+
+/* ARGB4444 PROTECT SRCKEY */
+#define COLOR_KEY ctx->key
+static void FUNC_NAME_(K,P,DSPF_ARGB4444)
+#include STRETCH_HVX_N_H
+#undef COLOR_KEY
+#undef KEY_PROTECT
+#undef SOURCE_LOOKUP
+#undef SOURCE_TYPE
+#endif
+
+
+/* FIXME: DST_FORMAT == DSPF_ARGB4444 doesn't work */
+#ifdef FORMAT_ARGB4444
+/* RGB16 */
+#define SOURCE_LOOKUP(x) PIXEL_ARGB4444( 0xff, \
+ (((x) & 0xf800) >> 8), \
+ (((x) & 0x07e0) >> 3), \
+ (((x) & 0x001f) << 3) )
+static void FUNC_NAME_(_,_,DSPF_RGB16)
+#include STRETCH_HVX_N_H
+
+/* RGB16 SRCKEY */
+#define COLOR_KEY ctx->key
+static void FUNC_NAME_(K,_,DSPF_RGB16)
+#include STRETCH_HVX_N_H
+#undef COLOR_KEY
+
+/* RGB16 PROTECT */
+#define KEY_PROTECT ctx->protect
+static void FUNC_NAME_(_,P,DSPF_RGB16)
+#include STRETCH_HVX_N_H
+
+/* RGB16 PROTECT SRCKEY */
+#define COLOR_KEY ctx->key
+static void FUNC_NAME_(K,P,DSPF_RGB16)
+#include STRETCH_HVX_N_H
+#undef COLOR_KEY
+#undef KEY_PROTECT
+#undef SOURCE_LOOKUP
+#undef SOURCE_TYPE
+#endif
+
+#undef FUNC_NAME_
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_up_down_16.h b/Source/DirectFB/src/gfx/generic/stretch_up_down_16.h
new file mode 100755
index 0000000..c6e4391
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_up_down_16.h
@@ -0,0 +1,68 @@
+#define STRETCH_HVX_N_H "stretch_hvx_16.h"
+#define uN u16
+
+/**********************************************************************************************************************/
+/* Upscaling */
+
+#define POINT_0 0
+#define LINE_0 0
+#define MINUS_1 1
+#define POINT_TO_RATIO(p,ps) ( ((p) & 0x3ffff) >> (18-SHIFT_L6) )
+#define LINE_TO_RATIO(l,ls) ( ((l) & 0x3ffff) >> (18-SHIFT_L5) )
+
+#define POINT_L(p,ps) ( (((p)) >> 18) )
+#define POINT_R(p,ps) ( (((p)) >> 18) + 1 )
+
+#define LINE_T(l,ls) ( (((l)) >> 18) )
+#define LINE_B(l,ls) ( (((l)) >> 18) + 1 )
+
+#define UPDOWN 1
+#include "stretch_hvx_N.h"
+#undef UPDOWN
+
+#undef POINT_0
+#undef LINE_0
+#undef MINUS_1
+#undef POINT_TO_RATIO
+#undef LINE_TO_RATIO
+#undef POINT_L
+#undef POINT_R
+#undef LINE_T
+#undef LINE_B
+
+/**********************************************************************************************************************/
+/* Downscaling */
+
+#define POINT_0 hfraq
+#define LINE_0 vfraq
+#define MINUS_1 0
+#define POINT_TO_RATIO(p,ps) ( (((((p)) & 0x3ffff) ? : 0x40000) << SHIFT_L6) / (ps) )
+#define LINE_TO_RATIO(l,ls) ( (((((l)) & 0x3ffff) ? : 0x40000) << SHIFT_L5) / (ls) )
+
+#define POINT_L(p,ps) ( (((p)-1) >> 18) - 1 )
+#define POINT_R(p,ps) ( (((p)-1) >> 18) )
+
+#define LINE_T(l,ls) ( (((l)-1) >> 18) - 1 )
+#define LINE_B(l,ls) ( (((l)-1) >> 18) )
+
+#define UPDOWN 0
+#include "stretch_hvx_N.h"
+#undef UPDOWN
+
+#undef POINT_0
+#undef LINE_0
+#undef MINUS_1
+#undef POINT_TO_RATIO
+#undef LINE_TO_RATIO
+#undef POINT_L
+#undef POINT_R
+#undef LINE_T
+#undef LINE_B
+
+/**********************************************************************************************************************/
+
+#undef STRETCH_HVX_N_H
+#undef uN
+
+#include "stretch_up_down_table.h"
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_up_down_32.h b/Source/DirectFB/src/gfx/generic/stretch_up_down_32.h
new file mode 100755
index 0000000..3fca697
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_up_down_32.h
@@ -0,0 +1,68 @@
+#define STRETCH_HVX_N_H "stretch_hvx_32.h"
+#define uN u32
+
+/**********************************************************************************************************************/
+/* Upscaling */
+
+#define POINT_0 0
+#define LINE_0 0
+#define MINUS_1 1
+#define POINT_TO_RATIO(p,ps) ( ((p) & 0x3ffff) >> (18-SHIFT_L8) )
+#define LINE_TO_RATIO(l,ls) ( ((l) & 0x3ffff) >> (18-SHIFT_L8) )
+
+#define POINT_L(p,ps) ( (((p)) >> 18) )
+#define POINT_R(p,ps) ( (((p)) >> 18) + 1 )
+
+#define LINE_T(l,ls) ( (((l)) >> 18) )
+#define LINE_B(l,ls) ( (((l)) >> 18) + 1 )
+
+#define UPDOWN 1
+#include "stretch_hvx_N.h"
+#undef UPDOWN
+
+#undef POINT_0
+#undef LINE_0
+#undef MINUS_1
+#undef POINT_TO_RATIO
+#undef LINE_TO_RATIO
+#undef POINT_L
+#undef POINT_R
+#undef LINE_T
+#undef LINE_B
+
+/**********************************************************************************************************************/
+/* Downscaling */
+
+#define POINT_0 hfraq
+#define LINE_0 vfraq
+#define MINUS_1 0
+#define POINT_TO_RATIO(p,ps) ( (((((p)) & 0x3ffff) ? : 0x40000) << SHIFT_L8) / (ps) )
+#define LINE_TO_RATIO(l,ls) ( (((((l)) & 0x3ffff) ? : 0x40000) << SHIFT_L8) / (ls) )
+
+#define POINT_L(p,ps) ( (((p)-1) >> 18) - 1 )
+#define POINT_R(p,ps) ( (((p)-1) >> 18) )
+
+#define LINE_T(l,ls) ( (((l)-1) >> 18) - 1 )
+#define LINE_B(l,ls) ( (((l)-1) >> 18) )
+
+#define UPDOWN 0
+#include "stretch_hvx_N.h"
+#undef UPDOWN
+
+#undef POINT_0
+#undef LINE_0
+#undef MINUS_1
+#undef POINT_TO_RATIO
+#undef LINE_TO_RATIO
+#undef POINT_L
+#undef POINT_R
+#undef LINE_T
+#undef LINE_B
+
+/**********************************************************************************************************************/
+
+#undef STRETCH_HVX_N_H
+#undef uN
+
+#include "stretch_up_down_table.h"
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_up_down_32_indexed.h b/Source/DirectFB/src/gfx/generic/stretch_up_down_32_indexed.h
new file mode 100755
index 0000000..655bf98
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_up_down_32_indexed.h
@@ -0,0 +1,82 @@
+#define SOURCE_LOOKUP(x) (((const u32*)colors)[x])
+#define SOURCE_TYPE u8
+
+
+#define POINT_0 hfraq
+#define LINE_0 vfraq
+#define MINUS_1 0
+#define POINT_TO_RATIO(p,ps) ( (((((p)) & 0x3ffff) ? : 0x40000) << SHIFT_L8) / (ps) )
+#define LINE_TO_RATIO(l,ls) ( (((((l)) & 0x3ffff) ? : 0x40000) << SHIFT_L8) / (ls) )
+
+#define POINT_L(p,ps) ( (((p)-1) >> 18) - 1 )
+#define POINT_R(p,ps) ( (((p)-1) >> 18) )
+
+#define LINE_T(l,ls) ( (((l)-1) >> 18) - 1 )
+#define LINE_B(l,ls) ( (((l)-1) >> 18) )
+
+static void FUNC_NAME(down)( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ DFBRegion *clip,
+ const void *colors )
+{
+#include "stretch_hvx_32.h"
+}
+
+#undef POINT_0
+#undef LINE_0
+#undef MINUS_1
+#undef POINT_TO_RATIO
+#undef LINE_TO_RATIO
+#undef POINT_L
+#undef POINT_R
+#undef LINE_T
+#undef LINE_B
+
+/**********************************************************************************************************************/
+
+#define POINT_0 0
+#define LINE_0 0
+#define MINUS_1 1
+#define POINT_TO_RATIO(p,ps) ( ((p) & 0x3ffff) >> (18-SHIFT_L8) )
+#define LINE_TO_RATIO(l,ls) ( ((l) & 0x3ffff) >> (18-SHIFT_L8) )
+
+#define POINT_L(p,ps) ( (((p)) >> 18) )
+#define POINT_R(p,ps) ( (((p)) >> 18) + 1 )
+
+#define LINE_T(l,ls) ( (((l)) >> 18) )
+#define LINE_B(l,ls) ( (((l)) >> 18) + 1 )
+
+static void FUNC_NAME(up)( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ DFBRegion *clip,
+ const void *colors )
+{
+#include "stretch_hvx_32.h"
+}
+
+#undef POINT_0
+#undef LINE_0
+#undef MINUS_1
+#undef POINT_TO_RATIO
+#undef LINE_TO_RATIO
+#undef POINT_L
+#undef POINT_R
+#undef LINE_T
+#undef LINE_B
+
+
+#undef SOURCE_LOOKUP
+#undef SOURCE_TYPE
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_up_down_8.h b/Source/DirectFB/src/gfx/generic/stretch_up_down_8.h
new file mode 100755
index 0000000..5b43df9
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_up_down_8.h
@@ -0,0 +1,72 @@
+#define POINT_0 hfraq
+#define LINE_0 vfraq
+#define MINUS_1 0
+#define POINT_TO_RATIO(p,ps) ( (((((p)) & 0x3ffff) ? : 0x40000) << 8) / (ps) )
+#define LINE_TO_RATIO(l,ls) ( (((((l)) & 0x3ffff) ? : 0x40000) << 8) / (ls) )
+
+#define POINT_L(p,ps) ( (((p)-1) >> 18) - 1 )
+#define POINT_R(p,ps) ( (((p)-1) >> 18) )
+
+#define LINE_T(l,ls) ( (((l)-1) >> 18) - 1 )
+#define LINE_B(l,ls) ( (((l)-1) >> 18) )
+
+static void FUNC_NAME(down)( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ DFBRegion *clip )
+{
+#include "stretch_hvx_8.h"
+}
+
+#undef POINT_0
+#undef LINE_0
+#undef MINUS_1
+#undef POINT_TO_RATIO
+#undef LINE_TO_RATIO
+#undef POINT_L
+#undef POINT_R
+#undef LINE_T
+#undef LINE_B
+
+/**********************************************************************************************************************/
+
+#define POINT_0 0
+#define LINE_0 0
+#define MINUS_1 1
+#define POINT_TO_RATIO(p,ps) ( ((p) & 0x3ffff) >> (18-8) )
+#define LINE_TO_RATIO(l,ls) ( ((l) & 0x3ffff) >> (18-8) )
+
+#define POINT_L(p,ps) ( (((p)) >> 18) )
+#define POINT_R(p,ps) ( (((p)) >> 18) + 1 )
+
+#define LINE_T(l,ls) ( (((l)) >> 18) )
+#define LINE_B(l,ls) ( (((l)) >> 18) + 1 )
+
+static void FUNC_NAME(up)( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ DFBRegion *clip )
+{
+#include "stretch_hvx_8.h"
+}
+
+#undef POINT_0
+#undef LINE_0
+#undef MINUS_1
+#undef POINT_TO_RATIO
+#undef LINE_TO_RATIO
+#undef POINT_L
+#undef POINT_R
+#undef LINE_T
+#undef LINE_B
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_up_down_88.h b/Source/DirectFB/src/gfx/generic/stretch_up_down_88.h
new file mode 100755
index 0000000..a91b6c9
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_up_down_88.h
@@ -0,0 +1,72 @@
+#define POINT_0 hfraq
+#define LINE_0 vfraq
+#define MINUS_1 0
+#define POINT_TO_RATIO(p,ps) ( (((((p)) & 0x3ffff) ? : 0x40000) << 8) / (ps) )
+#define LINE_TO_RATIO(l,ls) ( (((((l)) & 0x3ffff) ? : 0x40000) << 8) / (ls) )
+
+#define POINT_L(p,ps) ( (((p)-1) >> 18) - 1 )
+#define POINT_R(p,ps) ( (((p)-1) >> 18) )
+
+#define LINE_T(l,ls) ( (((l)-1) >> 18) - 1 )
+#define LINE_B(l,ls) ( (((l)-1) >> 18) )
+
+static void FUNC_NAME(down)( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ DFBRegion *clip )
+{
+#include "stretch_hvx_88.h"
+}
+
+#undef POINT_0
+#undef LINE_0
+#undef MINUS_1
+#undef POINT_TO_RATIO
+#undef LINE_TO_RATIO
+#undef POINT_L
+#undef POINT_R
+#undef LINE_T
+#undef LINE_B
+
+/**********************************************************************************************************************/
+
+#define POINT_0 0
+#define LINE_0 0
+#define MINUS_1 1
+#define POINT_TO_RATIO(p,ps) ( ((p) & 0x3ffff) >> (18-8) )
+#define LINE_TO_RATIO(l,ls) ( ((l) & 0x3ffff) >> (18-8) )
+
+#define POINT_L(p,ps) ( (((p)) >> 18) )
+#define POINT_R(p,ps) ( (((p)) >> 18) + 1 )
+
+#define LINE_T(l,ls) ( (((l)) >> 18) )
+#define LINE_B(l,ls) ( (((l)) >> 18) + 1 )
+
+static void FUNC_NAME(up)( void *dst,
+ int dpitch,
+ const void *src,
+ int spitch,
+ int width,
+ int height,
+ int dst_width,
+ int dst_height,
+ DFBRegion *clip )
+{
+#include "stretch_hvx_88.h"
+}
+
+#undef POINT_0
+#undef LINE_0
+#undef MINUS_1
+#undef POINT_TO_RATIO
+#undef LINE_TO_RATIO
+#undef POINT_L
+#undef POINT_R
+#undef LINE_T
+#undef LINE_B
+
diff --git a/Source/DirectFB/src/gfx/generic/stretch_up_down_table.h b/Source/DirectFB/src/gfx/generic/stretch_up_down_table.h
new file mode 100755
index 0000000..32f208b
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/stretch_up_down_table.h
@@ -0,0 +1,59 @@
+/**********************************************************************************************************************/
+/* Function table */
+
+static const StretchFunctionTable TABLE_NAME = {
+#define FUNC_NAME_(K,P,F) FUNC_NAME(up,K,P,F)
+ .f[DFB_PIXELFORMAT_INDEX(DST_FORMAT)].up[STRETCH_NONE] = FUNC_NAME_(_,_,DST_FORMAT),
+ .f[DFB_PIXELFORMAT_INDEX(DST_FORMAT)].up[STRETCH_PROTECT] = FUNC_NAME_(_,P,DST_FORMAT),
+ .f[DFB_PIXELFORMAT_INDEX(DST_FORMAT)].up[STRETCH_SRCKEY] = FUNC_NAME_(K,_,DST_FORMAT),
+ .f[DFB_PIXELFORMAT_INDEX(DST_FORMAT)].up[STRETCH_SRCKEY_PROTECT] = FUNC_NAME_(K,P,DST_FORMAT),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_LUT8)].up[STRETCH_NONE] = FUNC_NAME_(_,_,DSPF_LUT8),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_LUT8)].up[STRETCH_PROTECT] = FUNC_NAME_(_,P,DSPF_LUT8),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_LUT8)].up[STRETCH_SRCKEY] = FUNC_NAME_(K,_,DSPF_LUT8),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_LUT8)].up[STRETCH_SRCKEY_PROTECT] = FUNC_NAME_(K,P,DSPF_LUT8),
+#undef FUNC_NAME_
+
+#define FUNC_NAME_(K,P,F) FUNC_NAME(down,K,P,F)
+ .f[DFB_PIXELFORMAT_INDEX(DST_FORMAT)].down[STRETCH_NONE] = FUNC_NAME_(_,_,DST_FORMAT),
+ .f[DFB_PIXELFORMAT_INDEX(DST_FORMAT)].down[STRETCH_PROTECT] = FUNC_NAME_(_,P,DST_FORMAT),
+ .f[DFB_PIXELFORMAT_INDEX(DST_FORMAT)].down[STRETCH_SRCKEY] = FUNC_NAME_(K,_,DST_FORMAT),
+ .f[DFB_PIXELFORMAT_INDEX(DST_FORMAT)].down[STRETCH_SRCKEY_PROTECT] = FUNC_NAME_(K,P,DST_FORMAT),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_LUT8)].down[STRETCH_NONE] = FUNC_NAME_(_,_,DSPF_LUT8),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_LUT8)].down[STRETCH_PROTECT] = FUNC_NAME_(_,P,DSPF_LUT8),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_LUT8)].down[STRETCH_SRCKEY] = FUNC_NAME_(K,_,DSPF_LUT8),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_LUT8)].down[STRETCH_SRCKEY_PROTECT] = FUNC_NAME_(K,P,DSPF_LUT8),
+#undef FUNC_NAME_
+
+/* FIXME: DST_FORMAT == DSPF_RGB16 doesn't work */
+#ifdef FORMAT_RGB16
+#define FUNC_NAME_(K,P,F) FUNC_NAME(up,K,P,F)
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_ARGB4444)].up[STRETCH_NONE] = FUNC_NAME_(_,_,DSPF_ARGB4444),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_ARGB4444)].up[STRETCH_PROTECT] = FUNC_NAME_(_,P,DSPF_ARGB4444),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_ARGB4444)].up[STRETCH_SRCKEY] = FUNC_NAME_(K,_,DSPF_ARGB4444),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_ARGB4444)].up[STRETCH_SRCKEY_PROTECT] = FUNC_NAME_(K,P,DSPF_ARGB4444),
+#undef FUNC_NAME_
+#define FUNC_NAME_(K,P,F) FUNC_NAME(down,K,P,F)
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_ARGB4444)].down[STRETCH_NONE] = FUNC_NAME_(_,_,DSPF_ARGB4444),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_ARGB4444)].down[STRETCH_PROTECT] = FUNC_NAME_(_,P,DSPF_ARGB4444),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_ARGB4444)].down[STRETCH_SRCKEY] = FUNC_NAME_(K,_,DSPF_ARGB4444),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_ARGB4444)].down[STRETCH_SRCKEY_PROTECT] = FUNC_NAME_(K,P,DSPF_ARGB4444),
+#undef FUNC_NAME_
+#endif
+
+/* FIXME: DST_FORMAT == DSPF_ARGB4444 doesn't work */
+#ifdef FORMAT_ARGB4444
+#define FUNC_NAME_(K,P,F) FUNC_NAME(up,K,P,F)
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)].up[STRETCH_NONE] = FUNC_NAME_(_,_,DSPF_RGB16),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)].up[STRETCH_PROTECT] = FUNC_NAME_(_,P,DSPF_RGB16),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)].up[STRETCH_SRCKEY] = FUNC_NAME_(K,_,DSPF_RGB16),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)].up[STRETCH_SRCKEY_PROTECT] = FUNC_NAME_(K,P,DSPF_RGB16),
+#undef FUNC_NAME_
+#define FUNC_NAME_(K,P,F) FUNC_NAME(down,K,P,F)
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)].down[STRETCH_NONE] = FUNC_NAME_(_,_,DSPF_RGB16),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)].down[STRETCH_PROTECT] = FUNC_NAME_(_,P,DSPF_RGB16),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)].down[STRETCH_SRCKEY] = FUNC_NAME_(K,_,DSPF_RGB16),
+ .f[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)].down[STRETCH_SRCKEY_PROTECT] = FUNC_NAME_(K,P,DSPF_RGB16),
+#undef FUNC_NAME_
+#endif
+};
+
diff --git a/Source/DirectFB/src/gfx/generic/template_acc_16.h b/Source/DirectFB/src/gfx/generic/template_acc_16.h
new file mode 100755
index 0000000..05cea6d
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/template_acc_16.h
@@ -0,0 +1,382 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+ * Example:
+ * #define A_SHIFT 15
+ * #define R_SHIFT 10
+ * #define G_SHIFT 5
+ * #define B_SHIFT 0
+ * #define A_MASK 0x8000
+ * #define R_MASK 0x7c00
+ * #define G_MASK 0x03e0
+ * #define B_MASK 0x001f
+ * #define PIXEL_OUT( a, r, g, b ) PIXEL_ARGB1555( a, r, g, b )
+ * #define EXPAND_Ato8( a ) EXPAND_1to8( a )
+ * #define EXPAND_Rto8( r ) EXPAND_5to8( r )
+ * #define EXPAND_Gto8( g ) EXPAND_5to8( g )
+ * #define EXPAND_Bto8( b ) EXPAND_5to8( b )
+ * #define Sop_PFI_OP_Dacc( op ) Sop_argb1555_##op##_Dacc
+ * #define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_argb1555
+ * #include "template_acc_16.h"
+ */
+
+#define RGB_MASK (R_MASK | G_MASK | B_MASK)
+
+#if RGB_MASK == 0xffff
+#define MASK_RGB( p ) (p)
+#else
+#define MASK_RGB( p ) ((p) & RGB_MASK)
+#endif
+
+#define PIXEL( x ) PIXEL_OUT( ((x).RGB.a & 0xFF00) ? 0xFF : (x).RGB.a, \
+ ((x).RGB.r & 0xFF00) ? 0xFF : (x).RGB.r, \
+ ((x).RGB.g & 0xFF00) ? 0xFF : (x).RGB.g, \
+ ((x).RGB.b & 0xFF00) ? 0xFF : (x).RGB.b )
+
+#define EXPAND( d, s ) do { \
+ (d).RGB.a = EXPAND_Ato8( (s & A_MASK) >> A_SHIFT ); \
+ (d).RGB.r = EXPAND_Rto8( (s & R_MASK) >> R_SHIFT ); \
+ (d).RGB.g = EXPAND_Gto8( (s & G_MASK) >> G_SHIFT ); \
+ (d).RGB.b = EXPAND_Bto8( (s & B_MASK) >> B_SHIFT ); \
+} while (0)
+
+/********************************* Sop_PFI_Sto_Dacc ***************************/
+
+static void Sop_PFI_OP_Dacc(Sto)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u16 *S = gfxs->Sop[0];
+ int Ostep = gfxs->Ostep;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ if (Ostep != 1)
+ D_UNIMPLEMENTED();
+
+ while (l--) {
+ u16 s = S[i>>16];
+
+ EXPAND( *D, s );
+
+ D++;
+ i += SperD;
+ }
+}
+
+/********************************* Sop_PFI_SKto_Dacc **************************/
+
+static void Sop_PFI_OP_Dacc(SKto)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u16 *S = gfxs->Sop[0];
+ int Ostep = gfxs->Ostep;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u16 Skey = gfxs->Skey;
+
+ if (Ostep != 1)
+ D_UNIMPLEMENTED();
+
+ while (l--) {
+ u16 s = S[i>>16];
+
+ if (MASK_RGB( s ) != Skey)
+ EXPAND( *D, s );
+ else
+ D->RGB.a = 0xF000;
+
+ D++;
+ i += SperD;
+ }
+}
+
+/********************************* Sop_PFI_to_Dacc ****************************/
+
+static void Sop_PFI_OP_Dacc(to)( GenefxState *gfxs )
+{
+ int w, l = gfxs->length;
+ u16 *S = gfxs->Sop[0];
+ GenefxAccumulator *D = gfxs->Dacc;
+ int Ostep = gfxs->Ostep;
+
+ if (Ostep != 1) {
+ while (l--) {
+ u16 s = *S;
+
+ EXPAND( *D, s );
+
+ S += Ostep;
+
+ D++;
+ }
+ return;
+ }
+
+ if ((long)S & 2) {
+ u16 s = *S++;
+
+ EXPAND( *D, s );
+
+ D++;
+ l--;
+ }
+
+ w = l >> 1;
+ while (w--) {
+ u32 s = *(u32 *) S;
+
+#ifdef WORDS_BIGENDIAN
+ EXPAND( D[0], s >> 16 );
+ EXPAND( D[1], s );
+#else
+ EXPAND( D[0], s );
+ EXPAND( D[1], s >> 16);
+#endif
+
+ S += 2;
+ D += 2;
+ }
+
+ if (l & 1) {
+ u16 s = *S;
+
+ EXPAND( *D, s );
+ }
+}
+
+/********************************* Sop_PFI_Kto_Dacc ***************************/
+
+static void Sop_PFI_OP_Dacc(Kto)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ u16 *S = gfxs->Sop[0];
+ GenefxAccumulator *D = gfxs->Dacc;
+ u16 Skey = gfxs->Skey;
+ int Ostep = gfxs->Ostep;
+
+ while (l--) {
+ u16 s = *S;
+
+ if (MASK_RGB( s ) != Skey)
+ EXPAND( *D, s );
+ else
+ D->RGB.a = 0xF000;
+
+ S += Ostep;
+ D++;
+ }
+}
+
+/********************************* Sacc_to_Aop_PFI ****************************/
+
+static void Sacc_OP_Aop_PFI(to)( GenefxState *gfxs )
+{
+ int w, l = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u16 *D = gfxs->Aop[0];
+ int Dstep = gfxs->Astep;
+
+ if (Dstep != 1) {
+ while (l--) {
+ if (!(S->RGB.a & 0xF000))
+ *D = PIXEL( *S );
+
+ S++;
+ D += Dstep;
+ }
+ return;
+ }
+
+ if ((long)D & 2) {
+ if (!(S->RGB.a & 0xF000))
+ *D = PIXEL( *S );
+
+ S++;
+ D++;
+ l--;
+ }
+
+ w = l >> 1;
+ while (w--) {
+ u32 *D2 = (u32 *) D;
+
+ if (!(S[0].RGB.a & 0xF000) && !(S[1].RGB.a & 0xF000)) {
+#ifdef WORDS_BIGENDIAN
+ *D2 = PIXEL( S[1] ) | PIXEL( S[0] ) << 16;
+#else
+ *D2 = PIXEL( S[0] ) | PIXEL( S[1] ) << 16;
+#endif
+ } else {
+ if (!(S[0].RGB.a & 0xF000))
+ D[0] = PIXEL( S[0] );
+ else if (!(S[1].RGB.a & 0xF000))
+ D[1] = PIXEL( S[1] );
+ }
+
+ S += 2;
+ D += 2;
+ }
+
+ if (l & 1) {
+ if (!(S->RGB.a & 0xF000))
+ *D = PIXEL( *S );
+ }
+}
+
+/********************************* Sacc_Sto_Aop_PFI ***************************/
+
+static void Sacc_OP_Aop_PFI(Sto)( GenefxState *gfxs )
+{
+ int w, l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u16 *D = gfxs->Aop[0];
+ int Dstep = gfxs->Astep;
+
+ if (Dstep != 1) {
+ while (l--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000))
+ *D = PIXEL( *S );
+
+ D += Dstep;
+ i += SperD;
+ }
+ return;
+ }
+ if ((long)D & 2) {
+ GenefxAccumulator *S = Sacc;
+
+ if (!(S->RGB.a & 0xF000))
+ *D = PIXEL( *S );
+
+ D++;
+ l--;
+ i += SperD;
+ }
+
+ w = l >> 1;
+ while (w--) {
+ GenefxAccumulator *S0 = &Sacc[i>>16];
+ GenefxAccumulator *S1 = &Sacc[(i+SperD)>>16];
+ u32 *D2 = (u32 *) D;
+
+ if (!(S0->RGB.a & 0xF000) && !(S1->RGB.a & 0xF000)) {
+#ifdef WORDS_BIGENDIAN
+ *D2 = PIXEL( *S1 ) | PIXEL( *S0 ) << 16;
+#else
+ *D2 = PIXEL( *S0 ) | PIXEL( *S1 ) << 16;
+#endif
+ } else {
+ if (!(S0->RGB.a & 0xF000))
+ D[0] = PIXEL( *S0 );
+ else if (!(S1->RGB.a & 0xF000))
+ D[1] = PIXEL( *S1 );
+ }
+
+ D += 2;
+ i += SperD << 1;
+ }
+
+ if (l & 1) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000))
+ *D = PIXEL( *S );
+ }
+}
+
+/********************************* Sacc_toK_Aop_PFI ***************************/
+
+static void Sacc_OP_Aop_PFI(toK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u16 *D = gfxs->Aop[0];
+ u16 Dkey = gfxs->Dkey;
+ int Dstep = gfxs->Astep;
+
+ while (l--) {
+ if (!(S->RGB.a & 0xF000) && MASK_RGB( *D ) == Dkey)
+ *D = PIXEL( *S );
+
+ S++;
+ D += Dstep;
+ }
+}
+
+/********************************* Sacc_StoK_Aop_PFI **************************/
+
+static void Sacc_OP_Aop_PFI(StoK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u16 *D = gfxs->Aop[0];
+ u16 Dkey = gfxs->Dkey;
+ int Dstep = gfxs->Astep;
+
+ while (l--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000) && MASK_RGB( *D ) == Dkey)
+ *D = PIXEL( *S );
+
+ D += Dstep;
+ i += SperD;
+ }
+}
+
+/******************************************************************************/
+
+#undef RGB_MASK
+#undef MASK_RGB
+#undef PIXEL
+#undef EXPAND
+
+#undef A_SHIFT
+#undef R_SHIFT
+#undef G_SHIFT
+#undef B_SHIFT
+#undef A_MASK
+#undef R_MASK
+#undef G_MASK
+#undef B_MASK
+#undef PIXEL_OUT
+#undef EXPAND_Ato8
+#undef EXPAND_Rto8
+#undef EXPAND_Gto8
+#undef EXPAND_Bto8
+#undef Sop_PFI_OP_Dacc
+#undef Sacc_OP_Aop_PFI
diff --git a/Source/DirectFB/src/gfx/generic/template_acc_32.h b/Source/DirectFB/src/gfx/generic/template_acc_32.h
new file mode 100755
index 0000000..313d568
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/template_acc_32.h
@@ -0,0 +1,261 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+ * Example:
+ * #define A_SHIFT 24
+ * #define R_SHIFT 16
+ * #define G_SHIFT 8
+ * #define B_SHIFT 0
+ * #define A_MASK 0xff000000
+ * #define R_MASK 0x00ff0000
+ * #define G_MASK 0x0000ff00
+ * #define B_MASK 0x000000ff
+ * #define PIXEL_OUT( a, r, g, b ) PIXEL_AiRGB( a, r, g, b )
+ * #define EXPAND_Ato8( a ) ((a) ^ 0xff)
+ * #define EXPAND_Rto8( r ) (r)
+ * #define EXPAND_Gto8( g ) (g)
+ * #define EXPAND_Bto8( b ) (b)
+ * #define Sop_PFI_OP_Dacc( op ) Sop_airgb_##op##_Dacc
+ * #define Sacc_OP_Aop_PFI( op ) Sacc_##op##_Aop_airgb
+ * #include "template_acc_32.h"
+ */
+
+#define RGB_MASK (R_MASK | G_MASK | B_MASK)
+
+#define PIXEL( s ) PIXEL_OUT( ((s).RGB.a & 0xFF00) ? 0xFF : (s).RGB.a, \
+ ((s).RGB.r & 0xFF00) ? 0xFF : (s).RGB.r, \
+ ((s).RGB.g & 0xFF00) ? 0xFF : (s).RGB.g, \
+ ((s).RGB.b & 0xFF00) ? 0xFF : (s).RGB.b )
+
+#define EXPAND( d, s ) \
+do { \
+ (d).RGB.a = EXPAND_Ato8( (s & A_MASK) >> A_SHIFT ); \
+ (d).RGB.r = EXPAND_Rto8( (s & R_MASK) >> R_SHIFT ); \
+ (d).RGB.g = EXPAND_Gto8( (s & G_MASK) >> G_SHIFT ); \
+ (d).RGB.b = EXPAND_Bto8( (s & B_MASK) >> B_SHIFT ); \
+} while (0)
+
+/********************************* Sop_PFI_Sto_Dacc ***************************/
+
+static void Sop_PFI_OP_Dacc(Sto)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u32 *S = gfxs->Sop[0];
+ int Ostep = gfxs->Ostep;
+ GenefxAccumulator *D = gfxs->Dacc;
+
+ if (Ostep != 1)
+ D_UNIMPLEMENTED();
+
+ while (l--) {
+ u32 s = S[i>>16];
+
+ EXPAND( *D, s );
+
+ D++;
+ i += SperD;
+ }
+}
+
+/********************************* Sop_PFI_SKto_Dacc **************************/
+
+static void Sop_PFI_OP_Dacc(SKto)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u32 *S = gfxs->Sop[0];
+ int Ostep = gfxs->Ostep;
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 Skey = gfxs->Skey;
+
+ if (Ostep != 1)
+ D_UNIMPLEMENTED();
+
+ while (l--) {
+ u32 s = S[i>>16];
+
+ if ((s & RGB_MASK) != Skey)
+ EXPAND( *D, s );
+ else
+ D->RGB.a = 0xF000;
+
+ D++;
+ i += SperD;
+ }
+}
+
+/********************************* Sop_PFI_to_Dacc ****************************/
+
+static void Sop_PFI_OP_Dacc(to)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ u32 *S = gfxs->Sop[0];
+ GenefxAccumulator *D = gfxs->Dacc;
+ int Ostep = gfxs->Ostep;
+
+ while (l--) {
+ u32 s = *S;
+
+ EXPAND( *D, s );
+
+ S += Ostep;
+
+ D++;
+ }
+}
+
+/********************************* Sop_PFI_Kto_Dacc ***************************/
+
+static void Sop_PFI_OP_Dacc(Kto)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ u32 *S = gfxs->Sop[0];
+ GenefxAccumulator *D = gfxs->Dacc;
+ u32 Skey = gfxs->Skey;
+ int Ostep = gfxs->Ostep;
+
+ while (l--) {
+ u32 s = *S;
+
+ if ((s & RGB_MASK) != Skey)
+ EXPAND( *D, s );
+ else
+ D->RGB.a = 0xF000;
+
+ S += Ostep;
+ D++;
+ }
+}
+
+/********************************* Sacc_to_Aop_PFI ****************************/
+
+static void Sacc_OP_Aop_PFI(to)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u32 *D = gfxs->Aop[0];
+ int Dstep = gfxs->Astep;
+
+ while (l--) {
+ if (!(S->RGB.a & 0xF000))
+ *D = PIXEL( *S );
+
+ S++;
+ D += Dstep;
+ }
+}
+
+/********************************* Sacc_Sto_Aop_PFI ***************************/
+
+static void Sacc_OP_Aop_PFI(Sto)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u32 *D = gfxs->Aop[0];
+ int Dstep = gfxs->Astep;
+
+ while (l--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000))
+ *D = PIXEL( *S );
+
+ D += Dstep;
+ i += SperD;
+ }
+}
+
+/********************************* Sacc_toK_Aop_PFI ***************************/
+
+static void Sacc_OP_Aop_PFI(toK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ GenefxAccumulator *S = gfxs->Sacc;
+ u32 *D = gfxs->Aop[0];
+ int Dstep = gfxs->Astep;
+ u32 Dkey = gfxs->Dkey;
+
+ while (l--) {
+ if (!(S->RGB.a & 0xF000) && (*D & RGB_MASK) == Dkey)
+ *D = PIXEL( *S );
+
+ S++;
+ D += Dstep;
+ }
+}
+
+/********************************* Sacc_StoK_Aop_PFI **************************/
+
+static void Sacc_OP_Aop_PFI(StoK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ GenefxAccumulator *Sacc = gfxs->Sacc;
+ u32 *D = gfxs->Aop[0];
+ int Dstep = gfxs->Astep;
+ u32 Dkey = gfxs->Dkey;
+
+ while (l--) {
+ GenefxAccumulator *S = &Sacc[i>>16];
+
+ if (!(S->RGB.a & 0xF000) && (*D & RGB_MASK) == Dkey)
+ *D = PIXEL( *S );
+
+ D += Dstep;
+ i += SperD;
+ }
+}
+
+/******************************************************************************/
+
+#undef RGB_MASK
+#undef PIXEL
+#undef EXPAND
+
+#undef A_SHIFT
+#undef R_SHIFT
+#undef G_SHIFT
+#undef B_SHIFT
+#undef A_MASK
+#undef R_MASK
+#undef G_MASK
+#undef B_MASK
+#undef PIXEL_OUT
+#undef EXPAND_Ato8
+#undef EXPAND_Rto8
+#undef EXPAND_Gto8
+#undef EXPAND_Bto8
+#undef Sop_PFI_OP_Dacc
+#undef Sacc_OP_Aop_PFI
diff --git a/Source/DirectFB/src/gfx/generic/template_colorkey_16.h b/Source/DirectFB/src/gfx/generic/template_colorkey_16.h
new file mode 100755
index 0000000..542dad2
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/template_colorkey_16.h
@@ -0,0 +1,369 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+ * Example:
+ * #define RGB_MASK 0x7fff
+ * #define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_15
+ * #define Bop_PFI_OP_Aop_PFI( op ) Bop_15_##op##_Aop_15
+ * #include "template_ckey_16.h"
+ */
+
+#if RGB_MASK == 0xffff
+#define MASK_RGB( p ) (p)
+#else
+#define MASK_RGB( p ) ((p) & RGB_MASK)
+#endif
+
+#define MASK_RGB_L( p ) ((p) & RGB_MASK)
+#define MASK_RGB_H( p ) ((p) & (RGB_MASK << 16))
+#define MASK_RGB_32( p ) ((p) & (RGB_MASK << 16 | RGB_MASK))
+
+/********************************* Cop_toK_Aop_PFI ****************************/
+
+static void Cop_OP_Aop_PFI(toK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ u16 *D = gfxs->Aop[0];
+ u16 Dkey = gfxs->Dkey;
+ u16 Cop = gfxs->Cop;
+
+ while (l--) {
+ if (MASK_RGB( *D ) == Dkey)
+ *D = Cop;
+
+ D++;
+ }
+}
+
+/********************************* Bop_PFI_Kto_Aop_PFI ************************/
+
+static void Bop_PFI_OP_Aop_PFI(Kto)( GenefxState *gfxs )
+{
+ int w, l = gfxs->length;
+ int Ostep = gfxs->Ostep;
+ u16 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Skey = gfxs->Skey;
+ u32 SkeyH = gfxs->Skey << 16;
+
+ /* blit direction */
+ if (Ostep < 0) {
+ S += gfxs->length - 1;
+ D += gfxs->length - 1;
+ }
+
+ if (((long)S & 2) != ((long)D & 2)) {
+ /* source and destination misaligned */
+ while (l--) {
+ u16 s = *S;
+
+ if (MASK_RGB( s ) != Skey)
+ *D = s;
+
+ S += Ostep;
+ D += Ostep;
+ }
+
+ return;
+ }
+
+ /* fix alignment */
+ if (Ostep > 0) {
+ if ((long)D & 2) {
+ /* align / leftmost pixel */
+ u16 s = *S;
+
+ if (MASK_RGB( s ) != Skey)
+ *D = s;
+
+ S++;
+ D++;
+ l--;
+ }
+ } else { /* Ostep < 0 */
+ if ((long)D & 2) {
+ /* align */
+ S--;
+ D--;
+ } else {
+ /* rightmost pixel */
+ u16 s = *S;
+
+ if (MASK_RGB( s ) != Skey)
+ *D = s;
+
+ S -= 2;
+ D -= 2;
+ l--;
+ }
+ }
+
+ /* blit */
+ Ostep <<= 1;
+ w = l >> 1;
+ while (w--) {
+ u32 s = *(u32 *) S;
+
+ if (MASK_RGB_L( s ) != Skey) {
+ if (MASK_RGB_H( s ) != SkeyH) {
+ *(u32 *) D = s;
+ } else {
+#ifdef WORDS_BIGENDIAN
+ D[1] = (u16) s;
+#else
+ D[0] = (u16) s;
+#endif
+ }
+ } else if (MASK_RGB_H( s ) != SkeyH) {
+#ifdef WORDS_BIGENDIAN
+ D[0] = (u16) (s >> 16);
+#else
+ D[1] = (u16) (s >> 16);
+#endif
+ }
+
+ S += Ostep;
+ D += Ostep;
+ }
+
+ /* last potential pixel */
+ if (l & 1) {
+ u16 s;
+
+ if (Ostep < 0) {
+ S++;
+ D++;
+ }
+
+ s = *S;
+ if (MASK_RGB( s ) != Skey)
+ *D = s;
+ }
+}
+
+/********************************* Bop_PFI_toK_Aop_PFI ************************/
+
+static void Bop_PFI_OP_Aop_PFI(toK)( GenefxState *gfxs )
+{
+ int w, l = gfxs->length;
+ int Ostep = gfxs->Ostep;
+ u16 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Dkey = gfxs->Dkey;
+ u32 DkeyH = gfxs->Dkey << 16;
+
+ /* blit direction */
+ if (Ostep < 0) {
+ S += gfxs->length - 1;
+ D += gfxs->length - 1;
+ }
+
+ if (((long)S & 2) != ((long)D & 2)) {
+ /* source and destination misaligned */
+ while (l--) {
+ if (MASK_RGB( *D ) == Dkey)
+ *D = *S;
+
+ S += Ostep;
+ D += Ostep;
+ }
+
+ return;
+ }
+
+ /* fix alignment */
+ if ((Ostep > 0)) {
+ if ((long)D & 2) {
+ /* align / leftmost pixel */
+ if (MASK_RGB( *D ) == Dkey)
+ *D = *S;
+
+ S++;
+ D++;
+ l--;
+ }
+ } else { /* Ostep < 0 */
+ if ((long)D & 2) {
+ /* align */
+ S--;
+ D--;
+ } else {
+ /* rightmost pixel */
+ if (MASK_RGB( *D ) == Dkey)
+ *D = *S;
+
+ S -= 2;
+ D -= 2;
+ l--;
+ }
+ }
+
+ /* blit */
+ Ostep <<= 1;
+ w = l >> 1;
+ while (w--) {
+ u32 d = *(u32 *) D;
+
+ if (MASK_RGB_32( d ) == (DkeyH | Dkey)) {
+ *(u32 *) D = *(u32 *) S;
+ } else {
+ if (MASK_RGB_L( d ) == Dkey) {
+#ifdef WORDS_BIGENDIAN
+ D[0] = S[0];
+#else
+ D[1] = S[1];
+#endif
+ } else
+ if (MASK_RGB_H( d ) == DkeyH) {
+#ifdef WORDS_BIGENDIAN
+ D[1] = S[1];
+#else
+ D[0] = S[0];
+#endif
+ }
+ }
+
+ S += Ostep;
+ D += Ostep;
+ }
+
+ /* last potential pixel */
+ if (l & 1) {
+ if (Ostep < 0) {
+ S++;
+ D++;
+ }
+
+ if (MASK_RGB( *D ) == Dkey)
+ *D = *S;
+ }
+}
+
+/********************************* Bop_PFI_KtoK_Aop_PFI ***********************/
+
+static void Bop_PFI_OP_Aop_PFI(KtoK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int Ostep = gfxs->Ostep;
+ u16 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Skey = gfxs->Skey;
+ u16 Dkey = gfxs->Dkey;
+
+ if (Ostep < 0) {
+ S += gfxs->length - 1;
+ D += gfxs->length - 1;
+ }
+
+ while (l--) {
+ u16 s = *S;
+
+ if (MASK_RGB( s ) != Skey && MASK_RGB( *D ) == Dkey)
+ *D = s;
+
+ S += Ostep;
+ D += Ostep;
+ }
+}
+
+/********************************* Bop_PFI_SKto_Aop_PFI ***********************/
+
+static void Bop_PFI_OP_Aop_PFI(SKto)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u16 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Skey = gfxs->Skey;
+
+ while (l--) {
+ u16 s = S[i>>16];
+
+ if (MASK_RGB( s ) != Skey)
+ *D = s;
+
+ D++;
+ i += SperD;
+ }
+}
+
+/********************************* Bop_PFI_StoK_Aop_PFI ***********************/
+
+static void Bop_PFI_OP_Aop_PFI(StoK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u16 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Dkey = gfxs->Dkey;
+
+ while (l--) {
+ if (MASK_RGB( *D ) != Dkey)
+ *D = S[i>>16];
+
+ D++;
+ i += SperD;
+ }
+}
+
+/********************************* Bop_PFI_SKtoK_Aop_PFI **********************/
+
+static void Bop_PFI_OP_Aop_PFI(SKtoK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u16 *S = gfxs->Bop[0];
+ u16 *D = gfxs->Aop[0];
+ u16 Skey = gfxs->Skey;
+ u16 Dkey = gfxs->Dkey;
+
+ while (l--) {
+ u16 s = S[i>>16];
+
+ if (MASK_RGB( s ) != Skey && MASK_RGB( *D ) == Dkey)
+ *D = s;
+
+ D++;
+ i += SperD;
+ }
+}
+
+/******************************************************************************/
+
+#undef MASK_RGB
+#undef MASK_RGB_L
+#undef MASK_RGB_H
+#undef MASK_RGB_32
+
+#undef RGB_MASK
+#undef Cop_OP_Aop_PFI
+#undef Bop_PFI_OP_Aop_PFI
diff --git a/Source/DirectFB/src/gfx/generic/template_colorkey_32.h b/Source/DirectFB/src/gfx/generic/template_colorkey_32.h
new file mode 100755
index 0000000..7771d43
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/template_colorkey_32.h
@@ -0,0 +1,206 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+ * Example:
+ * #define RGB_MASK 0x00ffffff
+ * #define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_32
+ * #define Bop_PFI_OP_Aop_PFI( op ) Bop_32_##op##_Aop_32
+ * #include "template_colorkey_32.h"
+ */
+
+/********************************* Cop_toK_Aop_PFI ****************************/
+
+static void Cop_OP_Aop_PFI(toK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ u32 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+ u32 Cop = gfxs->Cop;
+
+ while (l--) {
+ if ((*D & RGB_MASK) == Dkey)
+ *D = Cop;
+
+ D++;
+ }
+}
+
+/********************************* Bop_PFI_Kto_Aop_PFI ************************/
+
+static void Bop_PFI_OP_Aop_PFI(Kto)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int Sstep = gfxs->Bstep;
+ int Dstep = gfxs->Astep;
+ u32 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Skey = gfxs->Skey;
+
+ if (Sstep < 0) {
+ S += gfxs->length - 1;
+ D += (gfxs->length - 1) * gfxs->Astep;
+ }
+
+ while (l--) {
+ u32 s = *S;
+
+ if ((s & RGB_MASK) != Skey)
+ *D = s;
+
+ S += Sstep;
+ D += Dstep;
+ }
+}
+
+/********************************* Bop_PFI_toK_Aop_PFI ************************/
+
+static void Bop_PFI_OP_Aop_PFI(toK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int Sstep = gfxs->Bstep;
+ int Dstep = gfxs->Astep;
+ u32 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+
+ if (Sstep < 0) {
+ S += gfxs->length - 1;
+ D += (gfxs->length - 1) * gfxs->Astep;
+ }
+
+ while (l--) {
+ if ((*D & RGB_MASK) == Dkey)
+ *D = *S;
+
+ S += Sstep;
+ D += Dstep;
+ }
+}
+
+/********************************* Bop_PFI_KtoK_Aop_PFI ***********************/
+
+static void Bop_PFI_OP_Aop_PFI(KtoK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int Sstep = gfxs->Bstep;
+ int Dstep = gfxs->Astep;
+ u32 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Skey = gfxs->Skey;
+ u32 Dkey = gfxs->Dkey;
+
+ if (Sstep < 0) {
+ S += gfxs->length - 1;
+ D += (gfxs->length - 1) * gfxs->Astep;
+ }
+
+ while (l--) {
+ u32 s = *S;
+
+ if ((s & RGB_MASK) != Skey && (*D & RGB_MASK) == Dkey)
+ *D = s;
+
+ S += Sstep;
+ D += Dstep;
+ }
+}
+
+/********************************* Bop_PFI_SKto_Aop_PFI ***********************/
+
+static void Bop_PFI_OP_Aop_PFI(SKto)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u32 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ int Dstep = gfxs->Astep;
+ u32 Skey = gfxs->Skey;
+
+ while (l--) {
+ u32 s = S[i>>16];
+
+ if ((s & RGB_MASK) != Skey)
+ *D = s;
+
+ D += Dstep;
+ i += SperD;
+ }
+}
+
+/********************************* Bop_PFI_StoK_Aop_PFI ***********************/
+
+static void Bop_PFI_OP_Aop_PFI(StoK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u32 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Dkey = gfxs->Dkey;
+ int Dstep = gfxs->Astep;
+
+ while (l--) {
+ if ((*D & RGB_MASK) != Dkey)
+ *D = S[i>>16];
+
+ D += Dstep;
+ i += SperD;
+ }
+}
+
+/********************************* Bop_PFI_SKtoK_Aop_PFI **********************/
+
+static void Bop_PFI_OP_Aop_PFI(SKtoK)( GenefxState *gfxs )
+{
+ int l = gfxs->length;
+ int i = gfxs->Xphase;
+ int SperD = gfxs->SperD;
+ u32 *S = gfxs->Bop[0];
+ u32 *D = gfxs->Aop[0];
+ u32 Skey = gfxs->Skey;
+ u32 Dkey = gfxs->Dkey;
+ int Dstep = gfxs->Astep;
+
+ while (l--) {
+ u32 s = S[i>>16];
+
+ if ((s & RGB_MASK) != Skey && (*D & RGB_MASK) == Dkey)
+ *D = s;
+
+ D += Dstep;
+ i += SperD;
+ }
+}
+
+/******************************************************************************/
+
+#undef RGB_MASK
+#undef Cop_OP_Aop_PFI
+#undef Bop_PFI_OP_Aop_PFI
diff --git a/Source/DirectFB/src/gfx/generic/yuvtbl-gen.c b/Source/DirectFB/src/gfx/generic/yuvtbl-gen.c
new file mode 100755
index 0000000..43a487d
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/yuvtbl-gen.c
@@ -0,0 +1,199 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* YCbCr->RGB:
+ * Standard ITU Rec. BT.601 derived coefficients.
+ */
+#define Y_FACTOR 1.16400
+#define VR_FACTOR 1.59600
+#define VG_FACTOR -0.81300
+#define UG_FACTOR -0.39100
+#define UB_FACTOR 2.01800
+
+/* RGB->YCbCr:
+ * ITU Rec. BT.601 defines the following formula for EyEcbEcr:
+ *
+ * Ey = 0.299 * R + 0.587 * G + 0.114 * B
+ * Ecb = (B - Ey) * 0.564
+ * Ecr = (R - Ey) * 0.713
+ *
+ * Relationship between EyEcbEcr and YCbCr:
+ *
+ * Y = Ey * 219 / 255 + 16
+ * Cb = Ecb * 224 / 255 + 128
+ * Cr = Ecr * 224 / 255 + 128
+ *
+ * Therefore, to convert RGB to YCbCr, we compute Ey from R G B,
+ * then we derive Y Cb Cr from Ey using 3 lookup tables.
+ */
+#define ECB_FACTOR 0.56400
+#define ECR_FACTOR 0.71300
+
+
+typedef struct {
+ const char *type;
+ const char *name;
+ int size;
+ struct {
+ int min;
+ int max;
+ } range;
+ struct {
+ int min;
+ int max;
+ } clamp;
+ float sub;
+ float mul;
+ float add;
+} GenTable;
+
+
+#define N_PER_LINE 10
+
+static void
+dump_table( GenTable *gt )
+{
+ int i, n;
+
+ printf( "\n%s %s[%i] = {\n", gt->type, gt->name, gt->size );
+
+ for (i = 0, n = 0; i < gt->size; i++) {
+ float num;
+
+ num = (i < gt->range.min)
+ ? gt->range.min
+ : ((i > gt->range.max) ? gt->range.max : i);
+ num = ((num - gt->sub) * gt->mul) + gt->add;
+ num = (num < gt->clamp.min)
+ ? gt->clamp.min
+ : ((num > gt->clamp.max) ? gt->clamp.max : num);
+
+ if (n == 0)
+ printf( " " );
+
+ printf( "%4i", (int) num );
+
+ if (i < (gt->size-1)) {
+ if (++n == N_PER_LINE) {
+ printf( ",\n" );
+ n = 0;
+ } else
+ printf( ", " );
+ } else
+ printf( "\n" );
+ }
+
+ printf( "};\n\n" );
+}
+
+int
+main( int argc, char **argv )
+{
+ GenTable gt = {
+ .size = 256,
+ .range.min = 16,
+ .clamp.min = -1000,
+ .clamp.max = +1000,
+ };
+
+ /* headers */
+ puts( "#ifndef __YUV_TABLES_H__" );
+ puts( "#define __YUV_TABLES_H__" );
+ puts( "" );
+
+/* YUV->RGB */
+ /* luma */
+ gt.type = "const u16";
+ gt.name = "y_for_rgb";
+ gt.range.max = 235;
+ gt.sub = 16;
+ gt.mul = Y_FACTOR;
+ gt.add = 0;
+ dump_table( &gt );
+
+ /* chroma */
+ gt.type = "const s16";
+ gt.range.max = 240;
+ gt.sub = 128;
+
+ gt.name = "cr_for_r";
+ gt.mul = VR_FACTOR;
+ dump_table( &gt );
+
+ gt.name = "cr_for_g";
+ gt.mul = VG_FACTOR;
+ dump_table( &gt );
+
+ gt.name = "cb_for_g";
+ gt.mul = UG_FACTOR;
+ dump_table( &gt );
+
+ gt.name = "cb_for_b";
+ gt.mul = UB_FACTOR;
+ dump_table( &gt );
+
+/* RGB->YUV */
+ gt.size = 256;
+ gt.range.min = 0;
+ gt.range.max = 255;
+ gt.clamp.min = 16;
+ gt.sub = 0;
+
+ /* luma */
+ gt.type = "const u16";
+ gt.name = "y_from_ey";
+ gt.clamp.max = 235;
+ gt.mul = 219.0/255.0;
+ gt.add = 16;
+ dump_table( &gt );
+
+ /* chroma */
+ gt.size = 512;
+ gt.range.max = 511;
+ gt.clamp.max = 240;
+ gt.sub = 255;
+ gt.add = 128;
+
+ /* cb */
+ gt.type = "const u16";
+ gt.name = "cb_from_bey";
+ gt.mul = ECB_FACTOR * 224.0 / 255.0;
+ dump_table( &gt );
+
+ /* cr */
+ gt.type = "const u16";
+ gt.name = "cr_from_rey";
+ gt.mul = ECR_FACTOR * 224.0 / 255.0;
+ dump_table( &gt );
+
+ /* end headers */
+ puts( "#endif /* __YUV_TABLES_H__ */" );
+
+ return 0;
+ }
diff --git a/Source/DirectFB/src/gfx/generic/yuvtbl.h b/Source/DirectFB/src/gfx/generic/yuvtbl.h
new file mode 100755
index 0000000..3769a35
--- /dev/null
+++ b/Source/DirectFB/src/gfx/generic/yuvtbl.h
@@ -0,0 +1,296 @@
+#ifndef __YUV_TABLES_H__
+#define __YUV_TABLES_H__
+
+
+const u16 y_for_rgb[256] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 1, 2, 3,
+ 4, 5, 6, 8, 9, 10, 11, 12, 13, 15,
+ 16, 17, 18, 19, 20, 22, 23, 24, 25, 26,
+ 27, 29, 30, 31, 32, 33, 34, 36, 37, 38,
+ 39, 40, 41, 43, 44, 45, 46, 47, 48, 50,
+ 51, 52, 53, 54, 55, 57, 58, 59, 60, 61,
+ 62, 64, 65, 66, 67, 68, 69, 71, 72, 73,
+ 74, 75, 76, 77, 79, 80, 81, 82, 83, 84,
+ 86, 87, 88, 89, 90, 91, 93, 94, 95, 96,
+ 97, 98, 100, 101, 102, 103, 104, 105, 107, 108,
+ 109, 110, 111, 112, 114, 115, 116, 117, 118, 119,
+ 121, 122, 123, 124, 125, 126, 128, 129, 130, 131,
+ 132, 133, 135, 136, 137, 138, 139, 140, 142, 143,
+ 144, 145, 146, 147, 148, 150, 151, 152, 153, 154,
+ 155, 157, 158, 159, 160, 161, 162, 164, 165, 166,
+ 167, 168, 169, 171, 172, 173, 174, 175, 176, 178,
+ 179, 180, 181, 182, 183, 185, 186, 187, 188, 189,
+ 190, 192, 193, 194, 195, 196, 197, 199, 200, 201,
+ 202, 203, 204, 206, 207, 208, 209, 210, 211, 213,
+ 214, 215, 216, 217, 218, 219, 221, 222, 223, 224,
+ 225, 226, 228, 229, 230, 231, 232, 233, 235, 236,
+ 237, 238, 239, 240, 242, 243, 244, 245, 246, 247,
+ 249, 250, 251, 252, 253, 254, 254, 254, 254, 254,
+ 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
+ 254, 254, 254, 254, 254, 254
+};
+
+
+const s16 cr_for_r[256] = {
+ -178, -178, -178, -178, -178, -178, -178, -178, -178, -178,
+ -178, -178, -178, -178, -178, -178, -178, -177, -175, -173,
+ -172, -170, -169, -167, -165, -164, -162, -161, -159, -158,
+ -156, -154, -153, -151, -150, -148, -146, -145, -143, -142,
+ -140, -138, -137, -135, -134, -132, -130, -129, -127, -126,
+ -124, -122, -121, -119, -118, -116, -114, -113, -111, -110,
+ -108, -106, -105, -103, -102, -100, -98, -97, -95, -94,
+ -92, -90, -89, -87, -86, -84, -82, -81, -79, -78,
+ -76, -75, -73, -71, -70, -68, -67, -65, -63, -62,
+ -60, -59, -57, -55, -54, -52, -51, -49, -47, -46,
+ -44, -43, -41, -39, -38, -36, -35, -33, -31, -30,
+ -28, -27, -25, -23, -22, -20, -19, -17, -15, -14,
+ -12, -11, -9, -7, -6, -4, -3, -1, 0, 1,
+ 3, 4, 6, 7, 9, 11, 12, 14, 15, 17,
+ 19, 20, 22, 23, 25, 27, 28, 30, 31, 33,
+ 35, 36, 38, 39, 41, 43, 44, 46, 47, 49,
+ 51, 52, 54, 55, 57, 59, 60, 62, 63, 65,
+ 67, 68, 70, 71, 73, 75, 76, 78, 79, 81,
+ 82, 84, 86, 87, 89, 90, 92, 94, 95, 97,
+ 98, 100, 102, 103, 105, 106, 108, 110, 111, 113,
+ 114, 116, 118, 119, 121, 122, 124, 126, 127, 129,
+ 130, 132, 134, 135, 137, 138, 140, 142, 143, 145,
+ 146, 148, 150, 151, 153, 154, 156, 158, 159, 161,
+ 162, 164, 165, 167, 169, 170, 172, 173, 175, 177,
+ 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
+ 178, 178, 178, 178, 178, 178
+};
+
+
+const s16 cr_for_g[256] = {
+ 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
+ 91, 91, 91, 91, 91, 91, 91, 90, 89, 88,
+ 87, 86, 86, 85, 84, 83, 82, 82, 81, 80,
+ 79, 78, 78, 77, 76, 75, 74, 73, 73, 72,
+ 71, 70, 69, 69, 68, 67, 66, 65, 65, 64,
+ 63, 62, 61, 60, 60, 59, 58, 57, 56, 56,
+ 55, 54, 53, 52, 52, 51, 50, 49, 48, 47,
+ 47, 46, 45, 44, 43, 43, 42, 41, 40, 39,
+ 39, 38, 37, 36, 35, 34, 34, 33, 32, 31,
+ 30, 30, 29, 28, 27, 26, 26, 25, 24, 23,
+ 22, 21, 21, 20, 19, 18, 17, 17, 16, 15,
+ 14, 13, 13, 12, 11, 10, 9, 8, 8, 7,
+ 6, 5, 4, 4, 3, 2, 1, 0, 0, 0,
+ -1, -2, -3, -4, -4, -5, -6, -7, -8, -8,
+ -9, -10, -11, -12, -13, -13, -14, -15, -16, -17,
+ -17, -18, -19, -20, -21, -21, -22, -23, -24, -25,
+ -26, -26, -27, -28, -29, -30, -30, -31, -32, -33,
+ -34, -34, -35, -36, -37, -38, -39, -39, -40, -41,
+ -42, -43, -43, -44, -45, -46, -47, -47, -48, -49,
+ -50, -51, -52, -52, -53, -54, -55, -56, -56, -57,
+ -58, -59, -60, -60, -61, -62, -63, -64, -65, -65,
+ -66, -67, -68, -69, -69, -70, -71, -72, -73, -73,
+ -74, -75, -76, -77, -78, -78, -79, -80, -81, -82,
+ -82, -83, -84, -85, -86, -86, -87, -88, -89, -90,
+ -91, -91, -91, -91, -91, -91, -91, -91, -91, -91,
+ -91, -91, -91, -91, -91, -91
+};
+
+
+const s16 cb_for_g[256] = {
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 42,
+ 42, 41, 41, 41, 40, 40, 39, 39, 39, 38,
+ 38, 37, 37, 37, 36, 36, 35, 35, 35, 34,
+ 34, 34, 33, 33, 32, 32, 32, 31, 31, 30,
+ 30, 30, 29, 29, 28, 28, 28, 27, 27, 26,
+ 26, 26, 25, 25, 25, 24, 24, 23, 23, 23,
+ 22, 22, 21, 21, 21, 20, 20, 19, 19, 19,
+ 18, 18, 17, 17, 17, 16, 16, 16, 15, 15,
+ 14, 14, 14, 13, 13, 12, 12, 12, 11, 11,
+ 10, 10, 10, 9, 9, 8, 8, 8, 7, 7,
+ 7, 6, 6, 5, 5, 5, 4, 4, 3, 3,
+ 3, 2, 2, 1, 1, 1, 0, 0, 0, 0,
+ 0, -1, -1, -1, -2, -2, -3, -3, -3, -4,
+ -4, -5, -5, -5, -6, -6, -7, -7, -7, -8,
+ -8, -8, -9, -9, -10, -10, -10, -11, -11, -12,
+ -12, -12, -13, -13, -14, -14, -14, -15, -15, -16,
+ -16, -16, -17, -17, -17, -18, -18, -19, -19, -19,
+ -20, -20, -21, -21, -21, -22, -22, -23, -23, -23,
+ -24, -24, -25, -25, -25, -26, -26, -26, -27, -27,
+ -28, -28, -28, -29, -29, -30, -30, -30, -31, -31,
+ -32, -32, -32, -33, -33, -34, -34, -34, -35, -35,
+ -35, -36, -36, -37, -37, -37, -38, -38, -39, -39,
+ -39, -40, -40, -41, -41, -41, -42, -42, -43, -43,
+ -43, -43, -43, -43, -43, -43, -43, -43, -43, -43,
+ -43, -43, -43, -43, -43, -43
+};
+
+
+const s16 cb_for_b[256] = {
+ -226, -226, -226, -226, -226, -226, -226, -226, -226, -226,
+ -226, -226, -226, -226, -226, -226, -226, -223, -221, -219,
+ -217, -215, -213, -211, -209, -207, -205, -203, -201, -199,
+ -197, -195, -193, -191, -189, -187, -185, -183, -181, -179,
+ -177, -175, -173, -171, -169, -167, -165, -163, -161, -159,
+ -157, -155, -153, -151, -149, -147, -145, -143, -141, -139,
+ -137, -135, -133, -131, -129, -127, -125, -123, -121, -119,
+ -117, -115, -113, -110, -108, -106, -104, -102, -100, -98,
+ -96, -94, -92, -90, -88, -86, -84, -82, -80, -78,
+ -76, -74, -72, -70, -68, -66, -64, -62, -60, -58,
+ -56, -54, -52, -50, -48, -46, -44, -42, -40, -38,
+ -36, -34, -32, -30, -28, -26, -24, -22, -20, -18,
+ -16, -14, -12, -10, -8, -6, -4, -2, 0, 2,
+ 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,
+ 24, 26, 28, 30, 32, 34, 36, 38, 40, 42,
+ 44, 46, 48, 50, 52, 54, 56, 58, 60, 62,
+ 64, 66, 68, 70, 72, 74, 76, 78, 80, 82,
+ 84, 86, 88, 90, 92, 94, 96, 98, 100, 102,
+ 104, 106, 108, 110, 113, 115, 117, 119, 121, 123,
+ 125, 127, 129, 131, 133, 135, 137, 139, 141, 143,
+ 145, 147, 149, 151, 153, 155, 157, 159, 161, 163,
+ 165, 167, 169, 171, 173, 175, 177, 179, 181, 183,
+ 185, 187, 189, 191, 193, 195, 197, 199, 201, 203,
+ 205, 207, 209, 211, 213, 215, 217, 219, 221, 223,
+ 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
+ 226, 226, 226, 226, 226, 226
+};
+
+
+const u16 y_from_ey[256] = {
+ 16, 16, 17, 18, 19, 20, 21, 22, 22, 23,
+ 24, 25, 26, 27, 28, 28, 29, 30, 31, 32,
+ 33, 34, 34, 35, 36, 37, 38, 39, 40, 40,
+ 41, 42, 43, 44, 45, 46, 46, 47, 48, 49,
+ 50, 51, 52, 52, 53, 54, 55, 56, 57, 58,
+ 58, 59, 60, 61, 62, 63, 64, 64, 65, 66,
+ 67, 68, 69, 70, 70, 71, 72, 73, 74, 75,
+ 76, 76, 77, 78, 79, 80, 81, 82, 82, 83,
+ 84, 85, 86, 87, 88, 89, 89, 90, 91, 92,
+ 93, 94, 95, 95, 96, 97, 98, 99, 100, 101,
+ 101, 102, 103, 104, 105, 106, 107, 107, 108, 109,
+ 110, 111, 112, 113, 113, 114, 115, 116, 117, 118,
+ 119, 119, 120, 121, 122, 123, 124, 125, 125, 126,
+ 127, 128, 129, 130, 131, 131, 132, 133, 134, 135,
+ 136, 137, 137, 138, 139, 140, 141, 142, 143, 143,
+ 144, 145, 146, 147, 148, 149, 149, 150, 151, 152,
+ 153, 154, 155, 155, 156, 157, 158, 159, 160, 161,
+ 162, 162, 163, 164, 165, 166, 167, 168, 168, 169,
+ 170, 171, 172, 173, 174, 174, 175, 176, 177, 178,
+ 179, 180, 180, 181, 182, 183, 184, 185, 186, 186,
+ 187, 188, 189, 190, 191, 192, 192, 193, 194, 195,
+ 196, 197, 198, 198, 199, 200, 201, 202, 203, 204,
+ 204, 205, 206, 207, 208, 209, 210, 210, 211, 212,
+ 213, 214, 215, 216, 216, 217, 218, 219, 220, 221,
+ 222, 222, 223, 224, 225, 226, 227, 228, 228, 229,
+ 230, 231, 232, 233, 234, 235
+};
+
+
+const u16 cb_from_bey[512] = {
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 17, 17, 18, 18, 19, 19, 19, 20, 20,
+ 21, 21, 22, 22, 23, 23, 24, 24, 25, 25,
+ 26, 26, 27, 27, 28, 28, 29, 29, 30, 30,
+ 31, 31, 32, 32, 33, 33, 34, 34, 35, 35,
+ 36, 36, 37, 37, 38, 38, 39, 39, 40, 40,
+ 41, 41, 42, 42, 43, 43, 44, 44, 45, 45,
+ 46, 46, 47, 47, 48, 48, 49, 49, 50, 50,
+ 51, 51, 52, 52, 53, 53, 54, 54, 55, 55,
+ 56, 56, 57, 57, 58, 58, 59, 59, 60, 60,
+ 61, 61, 62, 62, 63, 63, 64, 64, 65, 65,
+ 66, 66, 67, 67, 68, 68, 69, 69, 70, 70,
+ 71, 71, 72, 72, 73, 73, 73, 74, 74, 75,
+ 75, 76, 76, 77, 77, 78, 78, 79, 79, 80,
+ 80, 81, 81, 82, 82, 83, 83, 84, 84, 85,
+ 85, 86, 86, 87, 87, 88, 88, 89, 89, 90,
+ 90, 91, 91, 92, 92, 93, 93, 94, 94, 95,
+ 95, 96, 96, 97, 97, 98, 98, 99, 99, 100,
+ 100, 101, 101, 102, 102, 103, 103, 104, 104, 105,
+ 105, 106, 106, 107, 107, 108, 108, 109, 109, 110,
+ 110, 111, 111, 112, 112, 113, 113, 114, 114, 115,
+ 115, 116, 116, 117, 117, 118, 118, 119, 119, 120,
+ 120, 121, 121, 122, 122, 123, 123, 124, 124, 125,
+ 125, 126, 126, 127, 127, 128, 128, 128, 129, 129,
+ 130, 130, 131, 131, 132, 132, 133, 133, 134, 134,
+ 135, 135, 136, 136, 137, 137, 138, 138, 139, 139,
+ 140, 140, 141, 141, 142, 142, 143, 143, 144, 144,
+ 145, 145, 146, 146, 147, 147, 148, 148, 149, 149,
+ 150, 150, 151, 151, 152, 152, 153, 153, 154, 154,
+ 155, 155, 156, 156, 157, 157, 158, 158, 159, 159,
+ 160, 160, 161, 161, 162, 162, 163, 163, 164, 164,
+ 165, 165, 166, 166, 167, 167, 168, 168, 169, 169,
+ 170, 170, 171, 171, 172, 172, 173, 173, 174, 174,
+ 175, 175, 176, 176, 177, 177, 178, 178, 179, 179,
+ 180, 180, 181, 181, 182, 182, 182, 183, 183, 184,
+ 184, 185, 185, 186, 186, 187, 187, 188, 188, 189,
+ 189, 190, 190, 191, 191, 192, 192, 193, 193, 194,
+ 194, 195, 195, 196, 196, 197, 197, 198, 198, 199,
+ 199, 200, 200, 201, 201, 202, 202, 203, 203, 204,
+ 204, 205, 205, 206, 206, 207, 207, 208, 208, 209,
+ 209, 210, 210, 211, 211, 212, 212, 213, 213, 214,
+ 214, 215, 215, 216, 216, 217, 217, 218, 218, 219,
+ 219, 220, 220, 221, 221, 222, 222, 223, 223, 224,
+ 224, 225, 225, 226, 226, 227, 227, 228, 228, 229,
+ 229, 230, 230, 231, 231, 232, 232, 233, 233, 234,
+ 234, 235, 235, 236, 236, 236, 237, 237, 238, 238,
+ 239, 239, 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240
+};
+
+
+const u16 cr_from_rey[512] = {
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17,
+ 18, 19, 19, 20, 20, 21, 22, 22, 23, 24,
+ 24, 25, 25, 26, 27, 27, 28, 29, 29, 30,
+ 30, 31, 32, 32, 33, 34, 34, 35, 35, 36,
+ 37, 37, 38, 39, 39, 40, 40, 41, 42, 42,
+ 43, 44, 44, 45, 45, 46, 47, 47, 48, 49,
+ 49, 50, 50, 51, 52, 52, 53, 54, 54, 55,
+ 55, 56, 57, 57, 58, 59, 59, 60, 60, 61,
+ 62, 62, 63, 64, 64, 65, 65, 66, 67, 67,
+ 68, 69, 69, 70, 71, 71, 72, 72, 73, 74,
+ 74, 75, 76, 76, 77, 77, 78, 79, 79, 80,
+ 81, 81, 82, 82, 83, 84, 84, 85, 86, 86,
+ 87, 87, 88, 89, 89, 90, 91, 91, 92, 92,
+ 93, 94, 94, 95, 96, 96, 97, 97, 98, 99,
+ 99, 100, 101, 101, 102, 102, 103, 104, 104, 105,
+ 106, 106, 107, 107, 108, 109, 109, 110, 111, 111,
+ 112, 112, 113, 114, 114, 115, 116, 116, 117, 117,
+ 118, 119, 119, 120, 121, 121, 122, 122, 123, 124,
+ 124, 125, 126, 126, 127, 128, 128, 129, 129, 130,
+ 131, 131, 132, 133, 133, 134, 134, 135, 136, 136,
+ 137, 138, 138, 139, 139, 140, 141, 141, 142, 143,
+ 143, 144, 144, 145, 146, 146, 147, 148, 148, 149,
+ 149, 150, 151, 151, 152, 153, 153, 154, 154, 155,
+ 156, 156, 157, 158, 158, 159, 159, 160, 161, 161,
+ 162, 163, 163, 164, 164, 165, 166, 166, 167, 168,
+ 168, 169, 169, 170, 171, 171, 172, 173, 173, 174,
+ 174, 175, 176, 176, 177, 178, 178, 179, 179, 180,
+ 181, 181, 182, 183, 183, 184, 184, 185, 186, 186,
+ 187, 188, 188, 189, 190, 190, 191, 191, 192, 193,
+ 193, 194, 195, 195, 196, 196, 197, 198, 198, 199,
+ 200, 200, 201, 201, 202, 203, 203, 204, 205, 205,
+ 206, 206, 207, 208, 208, 209, 210, 210, 211, 211,
+ 212, 213, 213, 214, 215, 215, 216, 216, 217, 218,
+ 218, 219, 220, 220, 221, 221, 222, 223, 223, 224,
+ 225, 225, 226, 226, 227, 228, 228, 229, 230, 230,
+ 231, 231, 232, 233, 233, 234, 235, 235, 236, 236,
+ 237, 238, 238, 239, 240, 240, 240, 240, 240, 240,
+ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240
+};
+
+#endif /* __YUV_TABLES_H__ */
diff --git a/Source/DirectFB/src/gfx/util.c b/Source/DirectFB/src/gfx/util.c
new file mode 100755
index 0000000..9e59b84
--- /dev/null
+++ b/Source/DirectFB/src/gfx/util.c
@@ -0,0 +1,270 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <pthread.h>
+
+#include <directfb.h>
+
+#include <direct/util.h>
+
+#include <core/coretypes.h>
+
+#include <core/state.h>
+#include <core/gfxcard.h>
+
+#include <gfx/util.h>
+
+#include <misc/util.h>
+
+
+static bool copy_state_inited;
+static CardState copy_state;
+
+static bool btf_state_inited;
+static CardState btf_state;
+
+#if FIXME_SC_3
+static bool cd_state_inited;
+static CardState cd_state;
+#endif
+
+static pthread_mutex_t copy_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t btf_lock = PTHREAD_MUTEX_INITIALIZER;
+#if FIXME_SC_3
+static pthread_mutex_t cd_lock = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
+
+void
+dfb_gfx_copy( CoreSurface *source, CoreSurface *destination, const DFBRectangle *rect )
+{
+ dfb_gfx_copy_to( source, destination, rect, rect ? rect->x : 0, rect ? rect->y : 0, false );
+}
+
+void
+dfb_gfx_copy_to( CoreSurface *source, CoreSurface *destination, const DFBRectangle *rect, int x, int y, bool from_back )
+{
+ DFBRectangle sourcerect = { 0, 0, source->config.size.w, source->config.size.h };
+
+ pthread_mutex_lock( &copy_lock );
+
+ if (!copy_state_inited) {
+ dfb_state_init( &copy_state, NULL );
+ copy_state_inited = true;
+ }
+
+ copy_state.modified |= SMF_CLIP | SMF_SOURCE | SMF_DESTINATION;
+
+ copy_state.clip.x2 = destination->config.size.w - 1;
+ copy_state.clip.y2 = destination->config.size.h - 1;
+ copy_state.source = source;
+ copy_state.destination = destination;
+ copy_state.from = from_back ? CSBR_BACK : CSBR_FRONT;
+
+ if (rect) {
+ if (dfb_rectangle_intersect( &sourcerect, rect ))
+ dfb_gfxcard_blit( &sourcerect,
+ x + sourcerect.x - rect->x,
+ y + sourcerect.y - rect->y, &copy_state );
+ }
+ else
+ dfb_gfxcard_blit( &sourcerect, x, y, &copy_state );
+
+ /* Signal end of sequence. */
+ dfb_state_stop_drawing( &copy_state );
+
+ pthread_mutex_unlock( &copy_lock );
+}
+
+static void
+back_to_front_copy( CoreSurface *surface, const DFBRegion *region, DFBSurfaceBlittingFlags flags, int rotation)
+{
+ DFBRectangle rect;
+ int dx, dy;
+
+ if (region) {
+ rect.x = region->x1;
+ rect.y = region->y1;
+ rect.w = region->x2 - region->x1 + 1;
+ rect.h = region->y2 - region->y1 + 1;
+ }
+ else {
+ rect.x = 0;
+ rect.y = 0;
+ rect.w = surface->config.size.w;
+ rect.h = surface->config.size.h;
+ }
+
+ dx = rect.x;
+ dy = rect.y;
+
+ pthread_mutex_lock( &btf_lock );
+
+ if (!btf_state_inited) {
+ dfb_state_init( &btf_state, NULL );
+
+ btf_state.from = CSBR_BACK;
+ btf_state.to = CSBR_FRONT;
+
+ btf_state_inited = true;
+ }
+
+ btf_state.modified |= SMF_CLIP | SMF_SOURCE | SMF_DESTINATION;
+
+ btf_state.clip.x2 = surface->config.size.w - 1;
+ btf_state.clip.y2 = surface->config.size.h - 1;
+ btf_state.source = surface;
+ btf_state.destination = surface;
+
+
+ if (rotation == 90) {
+ dx = rect.y;
+ dy = surface->config.size.w - rect.w - rect.x;
+
+ flags |= DSBLIT_ROTATE90;
+ }
+ else if (rotation == 180) {
+ dx = surface->config.size.w - rect.w - rect.x;
+ dy = surface->config.size.h - rect.h - rect.y;
+
+ flags |= DSBLIT_ROTATE180;
+ }
+ else if (rotation == 270) {
+ dx = surface->config.size.h - rect.h - rect.y;
+ dy = rect.x;
+
+ flags |= DSBLIT_ROTATE270;
+ }
+
+
+ dfb_state_set_blitting_flags( &btf_state, flags );
+
+ dfb_gfxcard_blit( &rect, dx, dy, &btf_state );
+
+ /* Signal end of sequence. */
+ dfb_state_stop_drawing( &btf_state );
+
+ pthread_mutex_unlock( &btf_lock );
+}
+
+void
+dfb_back_to_front_copy( CoreSurface *surface, const DFBRegion *region )
+{
+ back_to_front_copy( surface, region, DSBLIT_NOFX, 0);
+}
+
+void
+dfb_back_to_front_copy_rotation( CoreSurface *surface, const DFBRegion *region, int rotation )
+{
+ back_to_front_copy( surface, region, DSBLIT_NOFX, rotation );
+}
+
+void
+dfb_clear_depth( CoreSurface *surface, const DFBRegion *region )
+{
+#if FIXME_SC_3
+ SurfaceBuffer *tmp;
+ DFBRectangle rect = { 0, 0, surface->config.size.w - 1, surface->config.size.h - 1 };
+
+ if (region && !dfb_rectangle_intersect_by_region( &rect, region ))
+ return;
+
+ pthread_mutex_lock( &cd_lock );
+
+ if (!cd_state_inited) {
+ dfb_state_init( &cd_state, NULL );
+
+ cd_state.color.r = 0xff;
+ cd_state.color.g = 0xff;
+ cd_state.color.b = 0xff;
+
+ cd_state_inited = true;
+ }
+
+ cd_state.modified |= SMF_CLIP | SMF_DESTINATION;
+
+ cd_state.clip.x2 = surface->config.size.w - 1;
+ cd_state.clip.y2 = surface->config.size.h - 1;
+ cd_state.destination = surface;
+
+ dfb_surfacemanager_lock( surface->manager );
+
+ tmp = surface->back_buffer;
+ surface->back_buffer = surface->depth_buffer;
+
+ dfb_gfxcard_fillrectangles( &rect, 1, &cd_state );
+
+ surface->back_buffer = tmp;
+
+ dfb_surfacemanager_unlock( surface->manager );
+
+ /* Signal end of sequence. */
+ dfb_state_stop_drawing( &cd_state );
+
+ pthread_mutex_unlock( &cd_lock );
+#endif
+}
+
+
+void dfb_sort_triangle( DFBTriangle *tri )
+{
+ int temp;
+
+ if (tri->y1 > tri->y2) {
+ temp = tri->x1;
+ tri->x1 = tri->x2;
+ tri->x2 = temp;
+
+ temp = tri->y1;
+ tri->y1 = tri->y2;
+ tri->y2 = temp;
+ }
+
+ if (tri->y2 > tri->y3) {
+ temp = tri->x2;
+ tri->x2 = tri->x3;
+ tri->x3 = temp;
+
+ temp = tri->y2;
+ tri->y2 = tri->y3;
+ tri->y3 = temp;
+ }
+
+ if (tri->y1 > tri->y2) {
+ temp = tri->x1;
+ tri->x1 = tri->x2;
+ tri->x2 = temp;
+
+ temp = tri->y1;
+ tri->y1 = tri->y2;
+ tri->y2 = temp;
+ }
+}
+
diff --git a/Source/DirectFB/src/gfx/util.h b/Source/DirectFB/src/gfx/util.h
new file mode 100755
index 0000000..79cbd6d
--- /dev/null
+++ b/Source/DirectFB/src/gfx/util.h
@@ -0,0 +1,42 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __GFX__UTIL_H__
+#define __GFX__UTIL_H__
+
+#include <core/surface.h>
+
+void dfb_gfx_copy( CoreSurface *source, CoreSurface *destination, const DFBRectangle *rect );
+void dfb_gfx_copy_to( CoreSurface *source, CoreSurface *destination, const DFBRectangle *rect, int x, int y, bool from_back );
+void dfb_back_to_front_copy( CoreSurface *surface, const DFBRegion *region );
+void dfb_back_to_front_copy_rotation( CoreSurface *surface, const DFBRegion *region, int rotation );
+void dfb_clear_depth( CoreSurface *surface, const DFBRegion *region );
+
+void dfb_sort_triangle( DFBTriangle *tri );
+
+#endif