diff options
Diffstat (limited to 'gst/videomixer')
-rw-r--r-- | gst/videomixer/Makefile.am | 43 | ||||
-rwxr-xr-x | gst/videomixer/Makefile.in | 1043 | ||||
-rw-r--r-- | gst/videomixer/README | 27 | ||||
-rwxr-xr-x | gst/videomixer/blend.c | 1059 | ||||
-rw-r--r-- | gst/videomixer/blend.h | 103 | ||||
-rwxr-xr-x | gst/videomixer/gstcms.c | 577 | ||||
-rwxr-xr-x | gst/videomixer/gstcms.h | 71 | ||||
-rwxr-xr-x | gst/videomixer/videoconvert.c | 1505 | ||||
-rwxr-xr-x | gst/videomixer/videoconvert.h | 80 | ||||
-rwxr-xr-x | gst/videomixer/videomixer2.c | 2377 | ||||
-rwxr-xr-x | gst/videomixer/videomixer2.h | 133 | ||||
-rw-r--r-- | gst/videomixer/videomixer2pad.h | 85 | ||||
-rwxr-xr-x | gst/videomixer/videomixerorc-dist.c | 11255 | ||||
-rwxr-xr-x | gst/videomixer/videomixerorc-dist.h | 131 | ||||
-rwxr-xr-x | gst/videomixer/videomixerorc.orc | 952 |
15 files changed, 19441 insertions, 0 deletions
diff --git a/gst/videomixer/Makefile.am b/gst/videomixer/Makefile.am new file mode 100644 index 0000000..483ac90 --- /dev/null +++ b/gst/videomixer/Makefile.am @@ -0,0 +1,43 @@ +plugin_LTLIBRARIES = libgstvideomixer.la + +ORC_SOURCE=videomixerorc + +include $(top_srcdir)/common/orc.mak + +libgstvideomixer_la_SOURCES = \ + blend.c \ + videoconvert.c \ + gstcms.c \ + videomixer2.c + +nodist_libgstvideomixer_la_SOURCES = $(ORC_NODIST_SOURCES) +libgstvideomixer_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \ + $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(ORC_CFLAGS) +libgstvideomixer_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ + -lgstvideo-@GST_API_VERSION@ \ + $(GST_BASE_LIBS) $(GST_LIBS) $(ORC_LIBS) $(LIBM) +libgstvideomixer_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) +libgstvideomixer_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) + +# headers we need but don't want installed +noinst_HEADERS = \ + blend.h \ + videomixer2.h \ + videomixer2pad.h \ + videoconvert.h \ + gstcms.h + +Android.mk: Makefile.am $(BUILT_SOURCES) + androgenizer \ + -:PROJECT libgstvideomixer -:SHARED libgstvideomixer \ + -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(libgstvideomixer_la_SOURCES) \ + $(nodist_libgstvideomixer_la_SOURCES) \ + -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstvideomixer_la_CFLAGS) \ + -:LDFLAGS $(libgstvideomixer_la_LDFLAGS) \ + $(libgstvideomixer_la_LIBADD) \ + -ldl \ + -:PASSTHROUGH LOCAL_ARM_MODE:=arm \ + LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \ + > $@ diff --git a/gst/videomixer/Makefile.in b/gst/videomixer/Makefile.in new file mode 100755 index 0000000..7f59ab7 --- /dev/null +++ b/gst/videomixer/Makefile.in @@ -0,0 +1,1043 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 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@ + +# +# This is a makefile.am fragment to build Orc code. +# +# Define ORC_SOURCE and then include this file, such as: +# +# ORC_SOURCE=gstadderorc +# include $(top_srcdir)/common/orc.mak +# +# This fragment will create tmp-orc.c and gstadderorc.h from +# gstadderorc.orc. +# +# When 'make dist' is run at the top level, or 'make orc-update' +# in a directory including this fragment, the generated source +# files will be copied to $(ORC_SOURCE)-dist.[ch]. These files +# should be checked in to git, since they are used if Orc is +# disabled. +# +# Note that this file defines BUILT_SOURCES, so any later usage +# of BUILT_SOURCES in the Makefile.am that includes this file +# must use '+='. +# + + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@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@ +DIST_COMMON = $(top_srcdir)/common/orc.mak $(srcdir)/Makefile.in \ + $(srcdir)/Makefile.am $(top_srcdir)/depcomp $(noinst_HEADERS) \ + README +subdir = gst/videomixer +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \ + $(top_srcdir)/common/m4/as-auto-alt.m4 \ + $(top_srcdir)/common/m4/as-compiler-flag.m4 \ + $(top_srcdir)/common/m4/as-gcc-inline-assembly.m4 \ + $(top_srcdir)/common/m4/as-libtool.m4 \ + $(top_srcdir)/common/m4/as-version.m4 \ + $(top_srcdir)/common/m4/ax_create_stdint_h.m4 \ + $(top_srcdir)/common/m4/gst-arch.m4 \ + $(top_srcdir)/common/m4/gst-args.m4 \ + $(top_srcdir)/common/m4/gst-check.m4 \ + $(top_srcdir)/common/m4/gst-default.m4 \ + $(top_srcdir)/common/m4/gst-dowhile.m4 \ + $(top_srcdir)/common/m4/gst-error.m4 \ + $(top_srcdir)/common/m4/gst-feature.m4 \ + $(top_srcdir)/common/m4/gst-gettext.m4 \ + $(top_srcdir)/common/m4/gst-glib2.m4 \ + $(top_srcdir)/common/m4/gst-package-release-datetime.m4 \ + $(top_srcdir)/common/m4/gst-platform.m4 \ + $(top_srcdir)/common/m4/gst-plugin-docs.m4 \ + $(top_srcdir)/common/m4/gst-plugindir.m4 \ + $(top_srcdir)/common/m4/gst-x11.m4 \ + $(top_srcdir)/common/m4/gst.m4 \ + $(top_srcdir)/common/m4/gtk-doc.m4 \ + $(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \ + $(top_srcdir)/m4/aalib.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/gst-fionread.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +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 = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(plugindir)" +LTLIBRARIES = $(plugin_LTLIBRARIES) +am__DEPENDENCIES_1 = +libgstvideomixer_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am_libgstvideomixer_la_OBJECTS = libgstvideomixer_la-blend.lo \ + libgstvideomixer_la-videoconvert.lo \ + libgstvideomixer_la-gstcms.lo \ + libgstvideomixer_la-videomixer2.lo +am__objects_1 = libgstvideomixer_la-tmp-orc.lo +nodist_libgstvideomixer_la_OBJECTS = $(am__objects_1) +libgstvideomixer_la_OBJECTS = $(am_libgstvideomixer_la_OBJECTS) \ + $(nodist_libgstvideomixer_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libgstvideomixer_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) \ + $(libgstvideomixer_la_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libgstvideomixer_la_SOURCES) \ + $(nodist_libgstvideomixer_la_SOURCES) +DIST_SOURCES = $(libgstvideomixer_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +AALIB_CFLAGS = @AALIB_CFLAGS@ +AALIB_CONFIG = @AALIB_CONFIG@ +AALIB_LIBS = @AALIB_LIBS@ +ACLOCAL = @ACLOCAL@ +ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BZ2_LIBS = @BZ2_LIBS@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_LIBS = @CAIRO_LIBS@ +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@ +DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@ +DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@ +DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@ +DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@ +DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@ +DIRECTSOUND_CFLAGS = @DIRECTSOUND_CFLAGS@ +DIRECTSOUND_LDFLAGS = @DIRECTSOUND_LDFLAGS@ +DIRECTSOUND_LIBS = @DIRECTSOUND_LIBS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DV1394_CFLAGS = @DV1394_CFLAGS@ +DV1394_LIBS = @DV1394_LIBS@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ERROR_CFLAGS = @ERROR_CFLAGS@ +ERROR_CXXFLAGS = @ERROR_CXXFLAGS@ +ERROR_OBJCFLAGS = @ERROR_OBJCFLAGS@ +EXEEXT = @EXEEXT@ +FFLAGS = @FFLAGS@ +FGREP = @FGREP@ +FLAC_CFLAGS = @FLAC_CFLAGS@ +FLAC_LIBS = @FLAC_LIBS@ +GCOV = @GCOV@ +GCOV_CFLAGS = @GCOV_CFLAGS@ +GCOV_LIBS = @GCOV_LIBS@ +GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@ +GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GIO_CFLAGS = @GIO_CFLAGS@ +GIO_LDFLAGS = @GIO_LDFLAGS@ +GIO_LIBS = @GIO_LIBS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GLIB_PREFIX = @GLIB_PREFIX@ +GLIB_REQ = @GLIB_REQ@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@ +GSTPB_PREFIX = @GSTPB_PREFIX@ +GST_AGE = @GST_AGE@ +GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@ +GST_API_VERSION = @GST_API_VERSION@ +GST_BASE_CFLAGS = @GST_BASE_CFLAGS@ +GST_BASE_LIBS = @GST_BASE_LIBS@ +GST_CFLAGS = @GST_CFLAGS@ +GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@ +GST_CHECK_LIBS = @GST_CHECK_LIBS@ +GST_CONTROLLER_CFLAGS = @GST_CONTROLLER_CFLAGS@ +GST_CONTROLLER_LIBS = @GST_CONTROLLER_LIBS@ +GST_CURRENT = @GST_CURRENT@ +GST_CXXFLAGS = @GST_CXXFLAGS@ +GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@ +GST_LIBS = @GST_LIBS@ +GST_LIBVERSION = @GST_LIBVERSION@ +GST_LICENSE = @GST_LICENSE@ +GST_LT_LDFLAGS = @GST_LT_LDFLAGS@ +GST_NET_CFLAGS = @GST_NET_CFLAGS@ +GST_NET_LIBS = @GST_NET_LIBS@ +GST_OBJCFLAGS = @GST_OBJCFLAGS@ +GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@ +GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@ +GST_OPTION_OBJCFLAGS = @GST_OPTION_OBJCFLAGS@ +GST_PACKAGE_NAME = @GST_PACKAGE_NAME@ +GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@ +GST_PLUGINS_ALL = @GST_PLUGINS_ALL@ +GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@ +GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@ +GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@ +GST_PLUGINS_DIR = @GST_PLUGINS_DIR@ +GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@ +GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@ +GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@ +GST_PLUGIN_LIBTOOLFLAGS = @GST_PLUGIN_LIBTOOLFLAGS@ +GST_PREFIX = @GST_PREFIX@ +GST_REVISION = @GST_REVISION@ +GST_TOOLS_DIR = @GST_TOOLS_DIR@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_LIBS = @GTK_LIBS@ +GTK_X11_CFLAGS = @GTK_X11_CFLAGS@ +GTK_X11_LIBS = @GTK_X11_LIBS@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HAVE_AVC1394 = @HAVE_AVC1394@ +HAVE_CXX = @HAVE_CXX@ +HAVE_DIRECTSOUND = @HAVE_DIRECTSOUND@ +HAVE_ROM1394 = @HAVE_ROM1394@ +HAVE_SPEEX = @HAVE_SPEEX@ +HAVE_X = @HAVE_X@ +HAVE_XSHM = @HAVE_XSHM@ +HAVE_ZLIB = @HAVE_ZLIB@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +JACK_0_120_1_CFLAGS = @JACK_0_120_1_CFLAGS@ +JACK_0_120_1_LIBS = @JACK_0_120_1_LIBS@ +JACK_1_9_7_CFLAGS = @JACK_1_9_7_CFLAGS@ +JACK_1_9_7_LIBS = @JACK_1_9_7_LIBS@ +JACK_CFLAGS = @JACK_CFLAGS@ +JACK_LIBS = @JACK_LIBS@ +JPEG_LIBS = @JPEG_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBCACA_CFLAGS = @LIBCACA_CFLAGS@ +LIBCACA_LIBS = @LIBCACA_LIBS@ +LIBDV_CFLAGS = @LIBDV_CFLAGS@ +LIBDV_LIBS = @LIBDV_LIBS@ +LIBICONV = @LIBICONV@ +LIBIEC61883_CFLAGS = @LIBIEC61883_CFLAGS@ +LIBIEC61883_LIBS = @LIBIEC61883_LIBS@ +LIBINTL = @LIBINTL@ +LIBM = @LIBM@ +LIBOBJS = @LIBOBJS@ +LIBPNG_CFLAGS = @LIBPNG_CFLAGS@ +LIBPNG_LIBS = @LIBPNG_LIBS@ +LIBRT = @LIBRT@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBV4L2_CFLAGS = @LIBV4L2_CFLAGS@ +LIBV4L2_LIBS = @LIBV4L2_LIBS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LOCALEDIR = @LOCALEDIR@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORCC = @ORCC@ +ORCC_FLAGS = @ORCC_FLAGS@ +ORC_CFLAGS = @ORC_CFLAGS@ +ORC_LIBS = @ORC_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ +PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@ +PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ +PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@ +PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PLUGINDIR = @PLUGINDIR@ +POSUB = @POSUB@ +PROFILE_CFLAGS = @PROFILE_CFLAGS@ +PULSE_CFLAGS = @PULSE_CFLAGS@ +PULSE_LIBS = @PULSE_LIBS@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +RAW1394_CFLAGS = @RAW1394_CFLAGS@ +RAW1394_LIBS = @RAW1394_LIBS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SHOUT2_CFLAGS = @SHOUT2_CFLAGS@ +SHOUT2_LIBS = @SHOUT2_LIBS@ +SOUP_CFLAGS = @SOUP_CFLAGS@ +SOUP_LIBS = @SOUP_LIBS@ +SPEEX_CFLAGS = @SPEEX_CFLAGS@ +SPEEX_LIBS = @SPEEX_LIBS@ +STRIP = @STRIP@ +TAGLIB_CFLAGS = @TAGLIB_CFLAGS@ +TAGLIB_CXXFLAGS = @TAGLIB_CXXFLAGS@ +TAGLIB_LIBS = @TAGLIB_LIBS@ +USE_NLS = @USE_NLS@ +VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ +VALGRIND_LIBS = @VALGRIND_LIBS@ +VALGRIND_PATH = @VALGRIND_PATH@ +VERSION = @VERSION@ +VPX_130_CFLAGS = @VPX_130_CFLAGS@ +VPX_130_LIBS = @VPX_130_LIBS@ +VPX_CFLAGS = @VPX_CFLAGS@ +VPX_LIBS = @VPX_LIBS@ +WARNING_CFLAGS = @WARNING_CFLAGS@ +WARNING_CXXFLAGS = @WARNING_CXXFLAGS@ +WARNING_OBJCFLAGS = @WARNING_OBJCFLAGS@ +WAVPACK_CFLAGS = @WAVPACK_CFLAGS@ +WAVPACK_LIBS = @WAVPACK_LIBS@ +XDAMAGE_CFLAGS = @XDAMAGE_CFLAGS@ +XDAMAGE_LIBS = @XDAMAGE_LIBS@ +XFIXES_CFLAGS = @XFIXES_CFLAGS@ +XFIXES_LIBS = @XFIXES_LIBS@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +XMKMF = @XMKMF@ +XSHM_LIBS = @XSHM_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_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_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +ac_ct_OBJC = @ac_ct_OBJC@ +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@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +plugindir = @plugindir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +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_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +plugin_LTLIBRARIES = libgstvideomixer.la +ORC_SOURCE = videomixerorc +EXTRA_DIST = $(ORC_SOURCE).orc +ORC_NODIST_SOURCES = tmp-orc.c $(ORC_SOURCE).h +BUILT_SOURCES = tmp-orc.c $(ORC_SOURCE).h +orcc_v_gen = $(orcc_v_gen_$(V)) +orcc_v_gen_ = $(orcc_v_gen_$(AM_DEFAULT_VERBOSITY)) +orcc_v_gen_0 = @echo " ORCC $@"; +cp_v_gen = $(cp_v_gen_$(V)) +cp_v_gen_ = $(cp_v_gen_$(AM_DEFAULT_VERBOSITY)) +cp_v_gen_0 = @echo " CP $@"; +libgstvideomixer_la_SOURCES = \ + blend.c \ + videoconvert.c \ + gstcms.c \ + videomixer2.c + +nodist_libgstvideomixer_la_SOURCES = $(ORC_NODIST_SOURCES) +libgstvideomixer_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \ + $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(ORC_CFLAGS) + +libgstvideomixer_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ + -lgstvideo-@GST_API_VERSION@ \ + $(GST_BASE_LIBS) $(GST_LIBS) $(ORC_LIBS) $(LIBM) + +libgstvideomixer_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) +libgstvideomixer_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) + +# headers we need but don't want installed +noinst_HEADERS = \ + blend.h \ + videomixer2.h \ + videomixer2pad.h \ + videoconvert.h \ + gstcms.h + +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/common/orc.mak $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu gst/videomixer/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu gst/videomixer/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_srcdir)/common/orc.mak: + +$(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 +$(am__aclocal_m4_deps): + +install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(plugindir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \ + } + +uninstall-pluginLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \ + done + +clean-pluginLTLIBRARIES: + -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES) + @list='$(plugin_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libgstvideomixer.la: $(libgstvideomixer_la_OBJECTS) $(libgstvideomixer_la_DEPENDENCIES) $(EXTRA_libgstvideomixer_la_DEPENDENCIES) + $(AM_V_CCLD)$(libgstvideomixer_la_LINK) -rpath $(plugindir) $(libgstvideomixer_la_OBJECTS) $(libgstvideomixer_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvideomixer_la-blend.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvideomixer_la-gstcms.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvideomixer_la-tmp-orc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvideomixer_la-videoconvert.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvideomixer_la-videomixer2.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libgstvideomixer_la-blend.lo: blend.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) -MT libgstvideomixer_la-blend.lo -MD -MP -MF $(DEPDIR)/libgstvideomixer_la-blend.Tpo -c -o libgstvideomixer_la-blend.lo `test -f 'blend.c' || echo '$(srcdir)/'`blend.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvideomixer_la-blend.Tpo $(DEPDIR)/libgstvideomixer_la-blend.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='blend.c' object='libgstvideomixer_la-blend.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) -c -o libgstvideomixer_la-blend.lo `test -f 'blend.c' || echo '$(srcdir)/'`blend.c + +libgstvideomixer_la-videoconvert.lo: videoconvert.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) -MT libgstvideomixer_la-videoconvert.lo -MD -MP -MF $(DEPDIR)/libgstvideomixer_la-videoconvert.Tpo -c -o libgstvideomixer_la-videoconvert.lo `test -f 'videoconvert.c' || echo '$(srcdir)/'`videoconvert.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvideomixer_la-videoconvert.Tpo $(DEPDIR)/libgstvideomixer_la-videoconvert.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='videoconvert.c' object='libgstvideomixer_la-videoconvert.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) -c -o libgstvideomixer_la-videoconvert.lo `test -f 'videoconvert.c' || echo '$(srcdir)/'`videoconvert.c + +libgstvideomixer_la-gstcms.lo: gstcms.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) -MT libgstvideomixer_la-gstcms.lo -MD -MP -MF $(DEPDIR)/libgstvideomixer_la-gstcms.Tpo -c -o libgstvideomixer_la-gstcms.lo `test -f 'gstcms.c' || echo '$(srcdir)/'`gstcms.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvideomixer_la-gstcms.Tpo $(DEPDIR)/libgstvideomixer_la-gstcms.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstcms.c' object='libgstvideomixer_la-gstcms.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) -c -o libgstvideomixer_la-gstcms.lo `test -f 'gstcms.c' || echo '$(srcdir)/'`gstcms.c + +libgstvideomixer_la-videomixer2.lo: videomixer2.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) -MT libgstvideomixer_la-videomixer2.lo -MD -MP -MF $(DEPDIR)/libgstvideomixer_la-videomixer2.Tpo -c -o libgstvideomixer_la-videomixer2.lo `test -f 'videomixer2.c' || echo '$(srcdir)/'`videomixer2.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvideomixer_la-videomixer2.Tpo $(DEPDIR)/libgstvideomixer_la-videomixer2.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='videomixer2.c' object='libgstvideomixer_la-videomixer2.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) -c -o libgstvideomixer_la-videomixer2.lo `test -f 'videomixer2.c' || echo '$(srcdir)/'`videomixer2.c + +libgstvideomixer_la-tmp-orc.lo: tmp-orc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) -MT libgstvideomixer_la-tmp-orc.lo -MD -MP -MF $(DEPDIR)/libgstvideomixer_la-tmp-orc.Tpo -c -o libgstvideomixer_la-tmp-orc.lo `test -f 'tmp-orc.c' || echo '$(srcdir)/'`tmp-orc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvideomixer_la-tmp-orc.Tpo $(DEPDIR)/libgstvideomixer_la-tmp-orc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tmp-orc.c' object='libgstvideomixer_la-tmp-orc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvideomixer_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvideomixer_la_CFLAGS) $(CFLAGS) -c -o libgstvideomixer_la-tmp-orc.lo `test -f 'tmp-orc.c' || echo '$(srcdir)/'`tmp-orc.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +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 "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(plugindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) 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: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-local \ + clean-pluginLTLIBRARIES 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 + +html-am: + +info: info-am + +info-am: + +install-data-am: install-pluginLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +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-pluginLTLIBRARIES + +.MAKE: all check install install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-local clean-pluginLTLIBRARIES \ + cscopelist-am ctags ctags-am dist-hook 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-man \ + install-pdf install-pdf-am install-pluginLTLIBRARIES \ + 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 tags-am uninstall uninstall-am \ + uninstall-pluginLTLIBRARIES + + +orc-update: tmp-orc.c $(ORC_SOURCE).h + $(top_srcdir)/common/gst-indent tmp-orc.c + cp tmp-orc.c $(srcdir)/$(ORC_SOURCE)-dist.c + cp $(ORC_SOURCE).h $(srcdir)/$(ORC_SOURCE)-dist.h + +@HAVE_ORCC_TRUE@tmp-orc.c: $(srcdir)/$(ORC_SOURCE).orc +@HAVE_ORCC_TRUE@ $(orcc_v_gen)$(ORCC) $(ORCC_FLAGS) --implementation --include glib.h -o tmp-orc.c $(srcdir)/$(ORC_SOURCE).orc + +@HAVE_ORCC_TRUE@$(ORC_SOURCE).h: $(srcdir)/$(ORC_SOURCE).orc +@HAVE_ORCC_TRUE@ $(orcc_v_gen)$(ORCC) $(ORCC_FLAGS) --header --include glib.h -o $(ORC_SOURCE).h $(srcdir)/$(ORC_SOURCE).orc +@HAVE_ORCC_FALSE@tmp-orc.c: $(srcdir)/$(ORC_SOURCE).orc $(srcdir)/$(ORC_SOURCE)-dist.c +@HAVE_ORCC_FALSE@ $(cp_v_gen)cp $(srcdir)/$(ORC_SOURCE)-dist.c tmp-orc.c + +@HAVE_ORCC_FALSE@$(ORC_SOURCE).h: $(srcdir)/$(ORC_SOURCE).orc $(srcdir)/$(ORC_SOURCE)-dist.c +@HAVE_ORCC_FALSE@ $(cp_v_gen)cp $(srcdir)/$(ORC_SOURCE)-dist.h $(ORC_SOURCE).h + +clean-local: clean-orc +.PHONY: clean-orc +clean-orc: + rm -f tmp-orc.c $(ORC_SOURCE).h + +dist-hook: dist-hook-orc +.PHONY: dist-hook-orc + +# we try and copy updated orc -dist files below, but don't fail if it +# doesn't work as the srcdir might not be writable +dist-hook-orc: tmp-orc.c $(ORC_SOURCE).h + $(top_srcdir)/common/gst-indent tmp-orc.c + rm -f tmp-orc.c~ + cmp -s tmp-orc.c $(srcdir)/$(ORC_SOURCE)-dist.c || \ + cp tmp-orc.c $(srcdir)/$(ORC_SOURCE)-dist.c || true + cmp -s $(ORC_SOURCE).h $(srcdir)/$(ORC_SOURCE)-dist.h || \ + cp $(ORC_SOURCE).h $(srcdir)/$(ORC_SOURCE)-dist.h || true + cp -p tmp-orc.c $(distdir)/$(ORC_SOURCE)-dist.c + cp -p $(ORC_SOURCE).h $(distdir)/$(ORC_SOURCE)-dist.h + +Android.mk: Makefile.am $(BUILT_SOURCES) + androgenizer \ + -:PROJECT libgstvideomixer -:SHARED libgstvideomixer \ + -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(libgstvideomixer_la_SOURCES) \ + $(nodist_libgstvideomixer_la_SOURCES) \ + -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstvideomixer_la_CFLAGS) \ + -:LDFLAGS $(libgstvideomixer_la_LDFLAGS) \ + $(libgstvideomixer_la_LIBADD) \ + -ldl \ + -:PASSTHROUGH LOCAL_ARM_MODE:=arm \ + LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \ + > $@ + +# 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/gst/videomixer/README b/gst/videomixer/README new file mode 100644 index 0000000..6794a48 --- /dev/null +++ b/gst/videomixer/README @@ -0,0 +1,27 @@ +Video Mixer +----------- + +A generice video mixer, it blends the ayuv buffers from all pads onto +a new buffer. The new buffer has by default a checkerboard pattern but +its color can be changed with a property. +The mixer can mix streams with different framerates and video sizes. It +uses the duration value of the buffer to schedule the rendering of the +buffers. For streams with a different resoltion than the final output +resolution one can specify the position of the top left corner where this +image should be placed with the pad properties xpos and ypos. +The overall alpha value of a stream can also be specified with a pad +property. +By default, the streams are blended in the order that the pads were +requested from the element. This can be overridden by changing the +zorder pad property of the stream, a stream with lower zorder gets +drawn first. + + +TODO +---- + +- really implement zorder +- take I420 yuv as well +- output AYUV if possible. +- implement different blend modes, some code is already done +- use filter caps on srcpad to decide on the final output size diff --git a/gst/videomixer/blend.c b/gst/videomixer/blend.c new file mode 100755 index 0000000..f17300e --- /dev/null +++ b/gst/videomixer/blend.c @@ -0,0 +1,1059 @@ +/* + * Copyright (C) 2004 Wim Taymans <wim@fluendo.com> + * Copyright (C) 2006 Mindfruit Bv. + * Author: Sjoerd Simons <sjoerd@luon.net> + * Author: Alex Ugarte <alexugarte@gmail.com> + * Copyright (C) 2009 Alex Ugarte <augarte@vicomtech.org> + * Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "blend.h" +#include "videomixerorc.h" + +#include <string.h> + +#include <gst/video/video.h> + +#define BLEND(D,S,alpha) (((D) * (256 - (alpha)) + (S) * (alpha)) >> 8) + +GST_DEBUG_CATEGORY_STATIC (gst_videomixer_blend_debug); +#define GST_CAT_DEFAULT gst_videomixer_blend_debug + +/* Below are the implementations of everything */ + +/* A32 is for AYUV, ARGB and BGRA */ +#define BLEND_A32(name, method, LOOP) \ +static void \ +method##_ ##name (GstVideoFrame * srcframe, gint xpos, gint ypos, \ + gdouble src_alpha, GstVideoFrame * destframe) \ +{ \ + guint s_alpha; \ + gint src_stride, dest_stride; \ + gint dest_width, dest_height; \ + guint8 *src, *dest; \ + gint src_width, src_height; \ + \ + src_width = GST_VIDEO_FRAME_WIDTH (srcframe); \ + src_height = GST_VIDEO_FRAME_HEIGHT (srcframe); \ + src = GST_VIDEO_FRAME_PLANE_DATA (srcframe, 0); \ + src_stride = GST_VIDEO_FRAME_COMP_STRIDE (srcframe, 0); \ + dest = GST_VIDEO_FRAME_PLANE_DATA (destframe, 0); \ + dest_stride = GST_VIDEO_FRAME_COMP_STRIDE (destframe, 0); \ + dest_width = GST_VIDEO_FRAME_COMP_WIDTH (destframe, 0); \ + dest_height = GST_VIDEO_FRAME_COMP_HEIGHT (destframe, 0); \ + \ + s_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \ + \ + /* If it's completely transparent... we just return */ \ + if (G_UNLIKELY (s_alpha == 0)) \ + return; \ + \ + /* adjust src pointers for negative sizes */ \ + if (xpos < 0) { \ + src += -xpos * 4; \ + src_width -= -xpos; \ + xpos = 0; \ + } \ + if (ypos < 0) { \ + src += -ypos * src_stride; \ + src_height -= -ypos; \ + ypos = 0; \ + } \ + /* adjust width/height if the src is bigger than dest */ \ + if (xpos + src_width > dest_width) { \ + src_width = dest_width - xpos; \ + } \ + if (ypos + src_height > dest_height) { \ + src_height = dest_height - ypos; \ + } \ + \ + dest = dest + 4 * xpos + (ypos * dest_stride); \ + \ + LOOP (dest, src, src_height, src_width, src_stride, dest_stride, s_alpha); \ +} + +#define BLEND_A32_LOOP(name, method) \ +static inline void \ +_##method##_loop_##name (guint8 * dest, const guint8 * src, gint src_height, \ + gint src_width, gint src_stride, gint dest_stride, guint s_alpha) \ +{ \ + s_alpha = MIN (255, s_alpha); \ + video_mixer_orc_##method##_##name (dest, dest_stride, src, src_stride, \ + s_alpha, src_width, src_height); \ +} + +BLEND_A32_LOOP (argb, blend); +BLEND_A32_LOOP (bgra, blend); +BLEND_A32_LOOP (argb, overlay); +BLEND_A32_LOOP (bgra, overlay); + +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +BLEND_A32 (argb, blend, _blend_loop_argb); +BLEND_A32 (bgra, blend, _blend_loop_bgra); +BLEND_A32 (argb, overlay, _overlay_loop_argb); +BLEND_A32 (bgra, overlay, _overlay_loop_bgra); +#else +BLEND_A32 (argb, blend, _blend_loop_bgra); +BLEND_A32 (bgra, blend, _blend_loop_argb); +BLEND_A32 (argb, overlay, _overlay_loop_bgra); +BLEND_A32 (bgra, overlay, _overlay_loop_argb); +#endif + +#define A32_CHECKER_C(name, RGB, A, C1, C2, C3) \ +static void \ +fill_checker_##name##_c (GstVideoFrame * frame) \ +{ \ + gint i, j; \ + gint val; \ + static const gint tab[] = { 80, 160, 80, 160 }; \ + gint width, height; \ + guint8 *dest; \ + \ + dest = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); \ + width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); \ + height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); \ + \ + if (!RGB) { \ + for (i = 0; i < height; i++) { \ + for (j = 0; j < width; j++) { \ + dest[A] = 0xff; \ + dest[C1] = tab[((i & 0x8) >> 3) + ((j & 0x8) >> 3)]; \ + dest[C2] = 128; \ + dest[C3] = 128; \ + dest += 4; \ + } \ + } \ + } else { \ + for (i = 0; i < height; i++) { \ + for (j = 0; j < width; j++) { \ + val = tab[((i & 0x8) >> 3) + ((j & 0x8) >> 3)]; \ + dest[A] = 0xFF; \ + dest[C1] = val; \ + dest[C2] = val; \ + dest[C3] = val; \ + dest += 4; \ + } \ + } \ + } \ +} + +A32_CHECKER_C (argb, TRUE, 0, 1, 2, 3); +A32_CHECKER_C (bgra, TRUE, 3, 2, 1, 0); +A32_CHECKER_C (ayuv, FALSE, 0, 1, 2, 3); + +#define YUV_TO_R(Y,U,V) (CLAMP (1.164 * (Y - 16) + 1.596 * (V - 128), 0, 255)) +#define YUV_TO_G(Y,U,V) (CLAMP (1.164 * (Y - 16) - 0.813 * (V - 128) - 0.391 * (U - 128), 0, 255)) +#define YUV_TO_B(Y,U,V) (CLAMP (1.164 * (Y - 16) + 2.018 * (U - 128), 0, 255)) + +#define A32_COLOR(name, RGB, A, C1, C2, C3) \ +static void \ +fill_color_##name (GstVideoFrame * frame, gint Y, gint U, gint V) \ +{ \ + gint c1, c2, c3; \ + guint32 val; \ + gint width, height; \ + guint8 *dest; \ + \ + dest = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); \ + width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); \ + height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); \ + \ + if (RGB) { \ + c1 = YUV_TO_R (Y, U, V); \ + c2 = YUV_TO_G (Y, U, V); \ + c3 = YUV_TO_B (Y, U, V); \ + } else { \ + c1 = Y; \ + c2 = U; \ + c3 = V; \ + } \ + val = GUINT32_FROM_BE ((0xff << A) | (c1 << C1) | (c2 << C2) | (c3 << C3)); \ + \ + video_mixer_orc_splat_u32 ((guint32 *) dest, val, height * width); \ +} + +A32_COLOR (argb, TRUE, 24, 16, 8, 0); +A32_COLOR (bgra, TRUE, 0, 8, 16, 24); +A32_COLOR (abgr, TRUE, 24, 0, 8, 16); +A32_COLOR (rgba, TRUE, 0, 24, 16, 8); +A32_COLOR (ayuv, FALSE, 24, 16, 8, 0); + +/* Y444, Y42B, I420, YV12, Y41B */ +#define PLANAR_YUV_BLEND(format_name,format_enum,x_round,y_round,MEMCPY,BLENDLOOP) \ +inline static void \ +_blend_##format_name (const guint8 * src, guint8 * dest, \ + gint src_stride, gint dest_stride, gint src_width, gint src_height, \ + gdouble src_alpha) \ +{ \ + gint i; \ + gint b_alpha; \ + \ + /* If it's completely transparent... we just return */ \ + if (G_UNLIKELY (src_alpha == 0.0)) { \ + GST_INFO ("Fast copy (alpha == 0.0)"); \ + return; \ + } \ + \ + /* If it's completely opaque, we do a fast copy */ \ + if (G_UNLIKELY (src_alpha == 1.0)) { \ + GST_INFO ("Fast copy (alpha == 1.0)"); \ + for (i = 0; i < src_height; i++) { \ + MEMCPY (dest, src, src_width); \ + src += src_stride; \ + dest += dest_stride; \ + } \ + return; \ + } \ + \ + b_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \ + \ + BLENDLOOP(dest, dest_stride, src, src_stride, b_alpha, src_width, src_height); \ +} \ +\ +static void \ +blend_##format_name (GstVideoFrame * srcframe, gint xpos, gint ypos, \ + gdouble src_alpha, GstVideoFrame * destframe) \ +{ \ + const guint8 *b_src; \ + guint8 *b_dest; \ + gint b_src_width; \ + gint b_src_height; \ + gint xoffset = 0; \ + gint yoffset = 0; \ + gint src_comp_rowstride, dest_comp_rowstride; \ + gint src_comp_height; \ + gint src_comp_width; \ + gint comp_ypos, comp_xpos; \ + gint comp_yoffset, comp_xoffset; \ + gint dest_width, dest_height; \ + const GstVideoFormatInfo *info; \ + gint src_width, src_height; \ + \ + src_width = GST_VIDEO_FRAME_WIDTH (srcframe); \ + src_height = GST_VIDEO_FRAME_HEIGHT (srcframe); \ + \ + info = srcframe->info.finfo; \ + dest_width = GST_VIDEO_FRAME_WIDTH (destframe); \ + dest_height = GST_VIDEO_FRAME_HEIGHT (destframe); \ + \ + xpos = x_round (xpos); \ + ypos = y_round (ypos); \ + \ + b_src_width = src_width; \ + b_src_height = src_height; \ + \ + /* adjust src pointers for negative sizes */ \ + if (xpos < 0) { \ + xoffset = -xpos; \ + b_src_width -= -xpos; \ + xpos = 0; \ + } \ + if (ypos < 0) { \ + yoffset += -ypos; \ + b_src_height -= -ypos; \ + ypos = 0; \ + } \ + /* If x or y offset are larger then the source it's outside of the picture */ \ + if (xoffset > src_width || yoffset > src_height) { \ + return; \ + } \ + \ + /* adjust width/height if the src is bigger than dest */ \ + if (xpos + src_width > dest_width) { \ + b_src_width = dest_width - xpos; \ + } \ + if (ypos + src_height > dest_height) { \ + b_src_height = dest_height - ypos; \ + } \ + if (b_src_width < 0 || b_src_height < 0) { \ + return; \ + } \ + \ + /* First mix Y, then U, then V */ \ + b_src = GST_VIDEO_FRAME_COMP_DATA (srcframe, 0); \ + b_dest = GST_VIDEO_FRAME_COMP_DATA (destframe, 0); \ + src_comp_rowstride = GST_VIDEO_FRAME_COMP_STRIDE (srcframe, 0); \ + dest_comp_rowstride = GST_VIDEO_FRAME_COMP_STRIDE (destframe, 0); \ + src_comp_width = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH(info, 0, b_src_width); \ + src_comp_height = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT(info, 0, b_src_height); \ + comp_xpos = (xpos == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (info, 0, xpos); \ + comp_ypos = (ypos == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, 0, ypos); \ + comp_xoffset = (xoffset == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (info, 0, xoffset); \ + comp_yoffset = (yoffset == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, 0, yoffset); \ + _blend_##format_name (b_src + comp_xoffset + comp_yoffset * src_comp_rowstride, \ + b_dest + comp_xpos + comp_ypos * dest_comp_rowstride, \ + src_comp_rowstride, \ + dest_comp_rowstride, src_comp_width, src_comp_height, \ + src_alpha); \ + \ + b_src = GST_VIDEO_FRAME_COMP_DATA (srcframe, 1); \ + b_dest = GST_VIDEO_FRAME_COMP_DATA (destframe, 1); \ + src_comp_rowstride = GST_VIDEO_FRAME_COMP_STRIDE (srcframe, 1); \ + dest_comp_rowstride = GST_VIDEO_FRAME_COMP_STRIDE (destframe, 1); \ + src_comp_width = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH(info, 1, b_src_width); \ + src_comp_height = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT(info, 1, b_src_height); \ + comp_xpos = (xpos == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (info, 1, xpos); \ + comp_ypos = (ypos == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, 1, ypos); \ + comp_xoffset = (xoffset == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (info, 1, xoffset); \ + comp_yoffset = (yoffset == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, 1, yoffset); \ + _blend_##format_name (b_src + comp_xoffset + comp_yoffset * src_comp_rowstride, \ + b_dest + comp_xpos + comp_ypos * dest_comp_rowstride, \ + src_comp_rowstride, \ + dest_comp_rowstride, src_comp_width, src_comp_height, \ + src_alpha); \ + \ + b_src = GST_VIDEO_FRAME_COMP_DATA (srcframe, 2); \ + b_dest = GST_VIDEO_FRAME_COMP_DATA (destframe, 2); \ + src_comp_rowstride = GST_VIDEO_FRAME_COMP_STRIDE (srcframe, 2); \ + dest_comp_rowstride = GST_VIDEO_FRAME_COMP_STRIDE (destframe, 2); \ + src_comp_width = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH(info, 2, b_src_width); \ + src_comp_height = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT(info, 2, b_src_height); \ + comp_xpos = (xpos == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (info, 2, xpos); \ + comp_ypos = (ypos == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, 2, ypos); \ + comp_xoffset = (xoffset == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (info, 2, xoffset); \ + comp_yoffset = (yoffset == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, 2, yoffset); \ + _blend_##format_name (b_src + comp_xoffset + comp_yoffset * src_comp_rowstride, \ + b_dest + comp_xpos + comp_ypos * dest_comp_rowstride, \ + src_comp_rowstride, \ + dest_comp_rowstride, src_comp_width, src_comp_height, \ + src_alpha); \ +} + +#define PLANAR_YUV_FILL_CHECKER(format_name, format_enum, MEMSET) \ +static void \ +fill_checker_##format_name (GstVideoFrame * frame) \ +{ \ + gint i, j; \ + static const int tab[] = { 80, 160, 80, 160 }; \ + guint8 *p; \ + gint comp_width, comp_height; \ + gint rowstride; \ + \ + p = GST_VIDEO_FRAME_COMP_DATA (frame, 0); \ + comp_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); \ + comp_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); \ + rowstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); \ + \ + for (i = 0; i < comp_height; i++) { \ + for (j = 0; j < comp_width; j++) { \ + *p++ = tab[((i & 0x8) >> 3) + ((j & 0x8) >> 3)]; \ + } \ + p += rowstride - comp_width; \ + } \ + \ + p = GST_VIDEO_FRAME_COMP_DATA (frame, 1); \ + comp_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 1); \ + comp_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 1); \ + rowstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 1); \ + \ + for (i = 0; i < comp_height; i++) { \ + MEMSET (p, 0x80, comp_width); \ + p += rowstride; \ + } \ + \ + p = GST_VIDEO_FRAME_COMP_DATA (frame, 2); \ + comp_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 2); \ + comp_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 2); \ + rowstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 2); \ + \ + for (i = 0; i < comp_height; i++) { \ + MEMSET (p, 0x80, comp_width); \ + p += rowstride; \ + } \ +} + +#define PLANAR_YUV_FILL_COLOR(format_name,format_enum,MEMSET) \ +static void \ +fill_color_##format_name (GstVideoFrame * frame, \ + gint colY, gint colU, gint colV) \ +{ \ + guint8 *p; \ + gint comp_width, comp_height; \ + gint rowstride; \ + gint i; \ + \ + p = GST_VIDEO_FRAME_COMP_DATA (frame, 0); \ + comp_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); \ + comp_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); \ + rowstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); \ + \ + for (i = 0; i < comp_height; i++) { \ + MEMSET (p, colY, comp_width); \ + p += rowstride; \ + } \ + \ + p = GST_VIDEO_FRAME_COMP_DATA (frame, 1); \ + comp_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 1); \ + comp_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 1); \ + rowstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 1); \ + \ + for (i = 0; i < comp_height; i++) { \ + MEMSET (p, colU, comp_width); \ + p += rowstride; \ + } \ + \ + p = GST_VIDEO_FRAME_COMP_DATA (frame, 2); \ + comp_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 2); \ + comp_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 2); \ + rowstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 2); \ + \ + for (i = 0; i < comp_height; i++) { \ + MEMSET (p, colV, comp_width); \ + p += rowstride; \ + } \ +} + +#define GST_ROUND_UP_1(x) (x) + +PLANAR_YUV_BLEND (i420, GST_VIDEO_FORMAT_I420, GST_ROUND_UP_2, + GST_ROUND_UP_2, memcpy, video_mixer_orc_blend_u8); +PLANAR_YUV_FILL_CHECKER (i420, GST_VIDEO_FORMAT_I420, memset); +PLANAR_YUV_FILL_COLOR (i420, GST_VIDEO_FORMAT_I420, memset); +PLANAR_YUV_FILL_COLOR (yv12, GST_VIDEO_FORMAT_YV12, memset); +PLANAR_YUV_BLEND (y444, GST_VIDEO_FORMAT_Y444, GST_ROUND_UP_1, + GST_ROUND_UP_1, memcpy, video_mixer_orc_blend_u8); +PLANAR_YUV_FILL_CHECKER (y444, GST_VIDEO_FORMAT_Y444, memset); +PLANAR_YUV_FILL_COLOR (y444, GST_VIDEO_FORMAT_Y444, memset); +PLANAR_YUV_BLEND (y42b, GST_VIDEO_FORMAT_Y42B, GST_ROUND_UP_2, + GST_ROUND_UP_1, memcpy, video_mixer_orc_blend_u8); +PLANAR_YUV_FILL_CHECKER (y42b, GST_VIDEO_FORMAT_Y42B, memset); +PLANAR_YUV_FILL_COLOR (y42b, GST_VIDEO_FORMAT_Y42B, memset); +PLANAR_YUV_BLEND (y41b, GST_VIDEO_FORMAT_Y41B, GST_ROUND_UP_4, + GST_ROUND_UP_1, memcpy, video_mixer_orc_blend_u8); +PLANAR_YUV_FILL_CHECKER (y41b, GST_VIDEO_FORMAT_Y41B, memset); +PLANAR_YUV_FILL_COLOR (y41b, GST_VIDEO_FORMAT_Y41B, memset); + +/* NV12, NV21 */ +#define NV_YUV_BLEND(format_name,MEMCPY,BLENDLOOP) \ +inline static void \ +_blend_##format_name (const guint8 * src, guint8 * dest, \ + gint src_stride, gint dest_stride, gint src_width, gint src_height, \ + gdouble src_alpha) \ +{ \ + gint i; \ + gint b_alpha; \ + \ + /* If it's completely transparent... we just return */ \ + if (G_UNLIKELY (src_alpha == 0.0)) { \ + GST_INFO ("Fast copy (alpha == 0.0)"); \ + return; \ + } \ + \ + /* If it's completely opaque, we do a fast copy */ \ + if (G_UNLIKELY (src_alpha == 1.0)) { \ + GST_INFO ("Fast copy (alpha == 1.0)"); \ + for (i = 0; i < src_height; i++) { \ + MEMCPY (dest, src, src_width); \ + src += src_stride; \ + dest += dest_stride; \ + } \ + return; \ + } \ + \ + b_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \ + \ + BLENDLOOP(dest, dest_stride, src, src_stride, b_alpha, src_width, src_height); \ +} \ +\ +static void \ +blend_##format_name (GstVideoFrame * srcframe, gint xpos, gint ypos, \ + gdouble src_alpha, GstVideoFrame * destframe) \ +{ \ + const guint8 *b_src; \ + guint8 *b_dest; \ + gint b_src_width; \ + gint b_src_height; \ + gint xoffset = 0; \ + gint yoffset = 0; \ + gint src_comp_rowstride, dest_comp_rowstride; \ + gint src_comp_height; \ + gint src_comp_width; \ + gint comp_ypos, comp_xpos; \ + gint comp_yoffset, comp_xoffset; \ + gint dest_width, dest_height; \ + const GstVideoFormatInfo *info; \ + gint src_width, src_height; \ + \ + src_width = GST_VIDEO_FRAME_WIDTH (srcframe); \ + src_height = GST_VIDEO_FRAME_HEIGHT (srcframe); \ + \ + info = srcframe->info.finfo; \ + dest_width = GST_VIDEO_FRAME_WIDTH (destframe); \ + dest_height = GST_VIDEO_FRAME_HEIGHT (destframe); \ + \ + xpos = GST_ROUND_UP_2 (xpos); \ + ypos = GST_ROUND_UP_2 (ypos); \ + \ + b_src_width = src_width; \ + b_src_height = src_height; \ + \ + /* adjust src pointers for negative sizes */ \ + if (xpos < 0) { \ + xoffset = -xpos; \ + b_src_width -= -xpos; \ + xpos = 0; \ + } \ + if (ypos < 0) { \ + yoffset += -ypos; \ + b_src_height -= -ypos; \ + ypos = 0; \ + } \ + /* If x or y offset are larger then the source it's outside of the picture */ \ + if (xoffset > src_width || yoffset > src_height) { \ + return; \ + } \ + \ + /* adjust width/height if the src is bigger than dest */ \ + if (xpos + src_width > dest_width) { \ + b_src_width = dest_width - xpos; \ + } \ + if (ypos + src_height > dest_height) { \ + b_src_height = dest_height - ypos; \ + } \ + if (b_src_width < 0 || b_src_height < 0) { \ + return; \ + } \ + \ + /* First mix Y, then UV */ \ + b_src = GST_VIDEO_FRAME_COMP_DATA (srcframe, 0); \ + b_dest = GST_VIDEO_FRAME_COMP_DATA (destframe, 0); \ + src_comp_rowstride = GST_VIDEO_FRAME_COMP_STRIDE (srcframe, 0); \ + dest_comp_rowstride = GST_VIDEO_FRAME_COMP_STRIDE (destframe, 0); \ + src_comp_width = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH(info, 0, b_src_width); \ + src_comp_height = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT(info, 0, b_src_height); \ + comp_xpos = (xpos == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (info, 0, xpos); \ + comp_ypos = (ypos == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, 0, ypos); \ + comp_xoffset = (xoffset == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (info, 0, xoffset); \ + comp_yoffset = (yoffset == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, 0, yoffset); \ + _blend_##format_name (b_src + comp_xoffset + comp_yoffset * src_comp_rowstride, \ + b_dest + comp_xpos + comp_ypos * dest_comp_rowstride, \ + src_comp_rowstride, \ + dest_comp_rowstride, src_comp_width, src_comp_height, \ + src_alpha); \ + \ + b_src = GST_VIDEO_FRAME_PLANE_DATA (srcframe, 1); \ + b_dest = GST_VIDEO_FRAME_PLANE_DATA (destframe, 1); \ + src_comp_rowstride = GST_VIDEO_FRAME_COMP_STRIDE (srcframe, 1); \ + dest_comp_rowstride = GST_VIDEO_FRAME_COMP_STRIDE (destframe, 1); \ + src_comp_width = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH(info, 1, b_src_width); \ + src_comp_height = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT(info, 1, b_src_height); \ + comp_xpos = (xpos == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (info, 1, xpos); \ + comp_ypos = (ypos == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, 1, ypos); \ + comp_xoffset = (xoffset == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (info, 1, xoffset); \ + comp_yoffset = (yoffset == 0) ? 0 : GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, 1, yoffset); \ + _blend_##format_name (b_src + comp_xoffset * 2 + comp_yoffset * src_comp_rowstride, \ + b_dest + comp_xpos * 2 + comp_ypos * dest_comp_rowstride, \ + src_comp_rowstride, \ + dest_comp_rowstride, 2 * src_comp_width, src_comp_height, \ + src_alpha); \ +} + +#define NV_YUV_FILL_CHECKER(format_name, MEMSET) \ +static void \ +fill_checker_##format_name (GstVideoFrame * frame) \ +{ \ + gint i, j; \ + static const int tab[] = { 80, 160, 80, 160 }; \ + guint8 *p; \ + gint comp_width, comp_height; \ + gint rowstride; \ + \ + p = GST_VIDEO_FRAME_COMP_DATA (frame, 0); \ + comp_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); \ + comp_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); \ + rowstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); \ + \ + for (i = 0; i < comp_height; i++) { \ + for (j = 0; j < comp_width; j++) { \ + *p++ = tab[((i & 0x8) >> 3) + ((j & 0x8) >> 3)]; \ + } \ + p += rowstride - comp_width; \ + } \ + \ + p = GST_VIDEO_FRAME_PLANE_DATA (frame, 1); \ + comp_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 1); \ + comp_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 1); \ + rowstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 1); \ + \ + for (i = 0; i < comp_height; i++) { \ + MEMSET (p, 0x80, comp_width * 2); \ + p += rowstride; \ + } \ +} + +#define NV_YUV_FILL_COLOR(format_name,MEMSET) \ +static void \ +fill_color_##format_name (GstVideoFrame * frame, \ + gint colY, gint colU, gint colV) \ +{ \ + guint8 *y, *u, *v; \ + gint comp_width, comp_height; \ + gint rowstride; \ + gint i, j; \ + \ + y = GST_VIDEO_FRAME_COMP_DATA (frame, 0); \ + comp_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); \ + comp_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); \ + rowstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); \ + \ + for (i = 0; i < comp_height; i++) { \ + MEMSET (y, colY, comp_width); \ + y += rowstride; \ + } \ + \ + u = GST_VIDEO_FRAME_COMP_DATA (frame, 1); \ + v = GST_VIDEO_FRAME_COMP_DATA (frame, 2); \ + comp_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 1); \ + comp_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 1); \ + rowstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 1); \ + \ + for (i = 0; i < comp_height; i++) { \ + for (j = 0; j < comp_width; j++) { \ + u[j*2] = colU; \ + v[j*2] = colV; \ + } \ + u += rowstride; \ + v += rowstride; \ + } \ +} + +NV_YUV_BLEND (nv12, memcpy, video_mixer_orc_blend_u8); +NV_YUV_FILL_CHECKER (nv12, memset); +NV_YUV_FILL_COLOR (nv12, memset); +NV_YUV_BLEND (nv21, memcpy, video_mixer_orc_blend_u8); +NV_YUV_FILL_CHECKER (nv21, memset); + +/* RGB, BGR, xRGB, xBGR, RGBx, BGRx */ + +#define RGB_BLEND(name, bpp, MEMCPY, BLENDLOOP) \ +static void \ +blend_##name (GstVideoFrame * srcframe, gint xpos, gint ypos, \ + gdouble src_alpha, GstVideoFrame * destframe) \ +{ \ + gint b_alpha; \ + gint i; \ + gint src_stride, dest_stride; \ + gint dest_width, dest_height; \ + guint8 *dest, *src; \ + gint src_width, src_height; \ + \ + src_width = GST_VIDEO_FRAME_WIDTH (srcframe); \ + src_height = GST_VIDEO_FRAME_HEIGHT (srcframe); \ + \ + src = GST_VIDEO_FRAME_PLANE_DATA (srcframe, 0); \ + dest = GST_VIDEO_FRAME_PLANE_DATA (destframe, 0); \ + \ + dest_width = GST_VIDEO_FRAME_WIDTH (destframe); \ + dest_height = GST_VIDEO_FRAME_HEIGHT (destframe); \ + \ + src_stride = GST_VIDEO_FRAME_COMP_STRIDE (srcframe, 0); \ + dest_stride = GST_VIDEO_FRAME_COMP_STRIDE (destframe, 0); \ + \ + b_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \ + \ + /* adjust src pointers for negative sizes */ \ + if (xpos < 0) { \ + src += -xpos * bpp; \ + src_width -= -xpos; \ + xpos = 0; \ + } \ + if (ypos < 0) { \ + src += -ypos * src_stride; \ + src_height -= -ypos; \ + ypos = 0; \ + } \ + /* adjust width/height if the src is bigger than dest */ \ + if (xpos + src_width > dest_width) { \ + src_width = dest_width - xpos; \ + } \ + if (ypos + src_height > dest_height) { \ + src_height = dest_height - ypos; \ + } \ + \ + dest = dest + bpp * xpos + (ypos * dest_stride); \ + /* If it's completely transparent... we just return */ \ + if (G_UNLIKELY (src_alpha == 0.0)) { \ + GST_INFO ("Fast copy (alpha == 0.0)"); \ + return; \ + } \ + \ + /* If it's completely opaque, we do a fast copy */ \ + if (G_UNLIKELY (src_alpha == 1.0)) { \ + GST_INFO ("Fast copy (alpha == 1.0)"); \ + for (i = 0; i < src_height; i++) { \ + MEMCPY (dest, src, bpp * src_width); \ + src += src_stride; \ + dest += dest_stride; \ + } \ + return; \ + } \ + \ + BLENDLOOP(dest, dest_stride, src, src_stride, b_alpha, src_width * bpp, src_height); \ +} + +#define RGB_FILL_CHECKER_C(name, bpp, r, g, b) \ +static void \ +fill_checker_##name##_c (GstVideoFrame * frame) \ +{ \ + gint i, j; \ + static const int tab[] = { 80, 160, 80, 160 }; \ + gint stride, dest_add, width, height; \ + guint8 *dest; \ + \ + width = GST_VIDEO_FRAME_WIDTH (frame); \ + height = GST_VIDEO_FRAME_HEIGHT (frame); \ + dest = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); \ + stride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); \ + dest_add = stride - width * bpp; \ + \ + for (i = 0; i < height; i++) { \ + for (j = 0; j < width; j++) { \ + dest[r] = tab[((i & 0x8) >> 3) + ((j & 0x8) >> 3)]; /* red */ \ + dest[g] = tab[((i & 0x8) >> 3) + ((j & 0x8) >> 3)]; /* green */ \ + dest[b] = tab[((i & 0x8) >> 3) + ((j & 0x8) >> 3)]; /* blue */ \ + dest += bpp; \ + } \ + dest += dest_add; \ + } \ +} + +#define RGB_FILL_COLOR(name, bpp, MEMSET_RGB) \ +static void \ +fill_color_##name (GstVideoFrame * frame, \ + gint colY, gint colU, gint colV) \ +{ \ + gint red, green, blue; \ + gint i; \ + gint dest_stride; \ + gint width, height; \ + guint8 *dest; \ + \ + width = GST_VIDEO_FRAME_WIDTH (frame); \ + height = GST_VIDEO_FRAME_HEIGHT (frame); \ + dest = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); \ + dest_stride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); \ + \ + red = YUV_TO_R (colY, colU, colV); \ + green = YUV_TO_G (colY, colU, colV); \ + blue = YUV_TO_B (colY, colU, colV); \ + \ + for (i = 0; i < height; i++) { \ + MEMSET_RGB (dest, red, green, blue, width); \ + dest += dest_stride; \ + } \ +} + +#define MEMSET_RGB_C(name, r, g, b) \ +static inline void \ +_memset_##name##_c (guint8* dest, gint red, gint green, gint blue, gint width) { \ + gint j; \ + \ + for (j = 0; j < width; j++) { \ + dest[r] = red; \ + dest[g] = green; \ + dest[b] = blue; \ + dest += 3; \ + } \ +} + +#define MEMSET_XRGB(name, r, g, b) \ +static inline void \ +_memset_##name (guint8* dest, gint red, gint green, gint blue, gint width) { \ + guint32 val; \ + \ + val = GUINT32_FROM_BE ((red << r) | (green << g) | (blue << b)); \ + video_mixer_orc_splat_u32 ((guint32 *) dest, val, width); \ +} + +#define _orc_memcpy_u32(dest,src,len) video_mixer_orc_memcpy_u32((guint32 *) dest, (const guint32 *) src, len/4) + +RGB_BLEND (rgb, 3, memcpy, video_mixer_orc_blend_u8); +RGB_FILL_CHECKER_C (rgb, 3, 0, 1, 2); +MEMSET_RGB_C (rgb, 0, 1, 2); +RGB_FILL_COLOR (rgb_c, 3, _memset_rgb_c); + +MEMSET_RGB_C (bgr, 2, 1, 0); +RGB_FILL_COLOR (bgr_c, 3, _memset_bgr_c); + +RGB_BLEND (xrgb, 4, _orc_memcpy_u32, video_mixer_orc_blend_u8); +RGB_FILL_CHECKER_C (xrgb, 4, 1, 2, 3); +MEMSET_XRGB (xrgb, 24, 16, 0); +RGB_FILL_COLOR (xrgb, 4, _memset_xrgb); + +MEMSET_XRGB (xbgr, 0, 16, 24); +RGB_FILL_COLOR (xbgr, 4, _memset_xbgr); + +MEMSET_XRGB (rgbx, 24, 16, 8); +RGB_FILL_COLOR (rgbx, 4, _memset_rgbx); + +MEMSET_XRGB (bgrx, 8, 16, 24); +RGB_FILL_COLOR (bgrx, 4, _memset_bgrx); + +/* YUY2, YVYU, UYVY */ + +#define PACKED_422_BLEND(name, MEMCPY, BLENDLOOP) \ +static void \ +blend_##name (GstVideoFrame * srcframe, gint xpos, gint ypos, \ + gdouble src_alpha, GstVideoFrame * destframe) \ +{ \ + gint b_alpha; \ + gint i; \ + gint src_stride, dest_stride; \ + gint dest_width, dest_height; \ + guint8 *src, *dest; \ + gint src_width, src_height; \ + \ + src_width = GST_VIDEO_FRAME_WIDTH (srcframe); \ + src_height = GST_VIDEO_FRAME_HEIGHT (srcframe); \ + \ + dest_width = GST_VIDEO_FRAME_WIDTH (destframe); \ + dest_height = GST_VIDEO_FRAME_HEIGHT (destframe); \ + \ + src = GST_VIDEO_FRAME_PLANE_DATA (srcframe, 0); \ + dest = GST_VIDEO_FRAME_PLANE_DATA (destframe, 0); \ + \ + src_stride = GST_VIDEO_FRAME_COMP_STRIDE (srcframe, 0); \ + dest_stride = GST_VIDEO_FRAME_COMP_STRIDE (destframe, 0); \ + \ + b_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \ + \ + xpos = GST_ROUND_UP_2 (xpos); \ + \ + /* adjust src pointers for negative sizes */ \ + if (xpos < 0) { \ + src += -xpos * 2; \ + src_width -= -xpos; \ + xpos = 0; \ + } \ + if (ypos < 0) { \ + src += -ypos * src_stride; \ + src_height -= -ypos; \ + ypos = 0; \ + } \ + \ + /* adjust width/height if the src is bigger than dest */ \ + if (xpos + src_width > dest_width) { \ + src_width = dest_width - xpos; \ + } \ + if (ypos + src_height > dest_height) { \ + src_height = dest_height - ypos; \ + } \ + \ + dest = dest + 2 * xpos + (ypos * dest_stride); \ + /* If it's completely transparent... we just return */ \ + if (G_UNLIKELY (src_alpha == 0.0)) { \ + GST_INFO ("Fast copy (alpha == 0.0)"); \ + return; \ + } \ + \ + /* If it's completely opaque, we do a fast copy */ \ + if (G_UNLIKELY (src_alpha == 1.0)) { \ + GST_INFO ("Fast copy (alpha == 1.0)"); \ + for (i = 0; i < src_height; i++) { \ + MEMCPY (dest, src, 2 * src_width); \ + src += src_stride; \ + dest += dest_stride; \ + } \ + return; \ + } \ + \ + BLENDLOOP(dest, dest_stride, src, src_stride, b_alpha, 2 * src_width, src_height); \ +} + +#define PACKED_422_FILL_CHECKER_C(name, Y1, U, Y2, V) \ +static void \ +fill_checker_##name##_c (GstVideoFrame * frame) \ +{ \ + gint i, j; \ + static const int tab[] = { 80, 160, 80, 160 }; \ + gint dest_add; \ + gint width, height; \ + guint8 *dest; \ + \ + width = GST_VIDEO_FRAME_WIDTH (frame); \ + width = GST_ROUND_UP_2 (width); \ + height = GST_VIDEO_FRAME_HEIGHT (frame); \ + dest = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); \ + dest_add = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0) - width * 2; \ + width /= 2; \ + \ + for (i = 0; i < height; i++) { \ + for (j = 0; j < width; j++) { \ + dest[Y1] = tab[((i & 0x8) >> 3) + ((j & 0x8) >> 3)]; \ + dest[Y2] = tab[((i & 0x8) >> 3) + ((j & 0x8) >> 3)]; \ + dest[U] = 128; \ + dest[V] = 128; \ + dest += 4; \ + } \ + dest += dest_add; \ + } \ +} + +#define PACKED_422_FILL_COLOR(name, Y1, U, Y2, V) \ +static void \ +fill_color_##name (GstVideoFrame * frame, \ + gint colY, gint colU, gint colV) \ +{ \ + gint i; \ + gint dest_stride; \ + guint32 val; \ + gint width, height; \ + guint8 *dest; \ + \ + width = GST_VIDEO_FRAME_WIDTH (frame); \ + width = GST_ROUND_UP_2 (width); \ + height = GST_VIDEO_FRAME_HEIGHT (frame); \ + dest = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); \ + dest_stride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); \ + width /= 2; \ + \ + val = GUINT32_FROM_BE ((colY << Y1) | (colY << Y2) | (colU << U) | (colV << V)); \ + \ + for (i = 0; i < height; i++) { \ + video_mixer_orc_splat_u32 ((guint32 *) dest, val, width); \ + dest += dest_stride; \ + } \ +} + +PACKED_422_BLEND (yuy2, memcpy, video_mixer_orc_blend_u8); +PACKED_422_FILL_CHECKER_C (yuy2, 0, 1, 2, 3); +PACKED_422_FILL_CHECKER_C (uyvy, 1, 0, 3, 2); +PACKED_422_FILL_COLOR (yuy2, 24, 16, 8, 0); +PACKED_422_FILL_COLOR (yvyu, 24, 0, 8, 16); +PACKED_422_FILL_COLOR (uyvy, 16, 24, 0, 8); + +/* Init function */ +BlendFunction gst_video_mixer_blend_argb; +BlendFunction gst_video_mixer_blend_bgra; +BlendFunction gst_video_mixer_overlay_argb; +BlendFunction gst_video_mixer_overlay_bgra; +/* AYUV/ABGR is equal to ARGB, RGBA is equal to BGRA */ +BlendFunction gst_video_mixer_blend_y444; +BlendFunction gst_video_mixer_blend_y42b; +BlendFunction gst_video_mixer_blend_i420; +/* I420 is equal to YV12 */ +BlendFunction gst_video_mixer_blend_nv12; +BlendFunction gst_video_mixer_blend_nv21; +BlendFunction gst_video_mixer_blend_y41b; +BlendFunction gst_video_mixer_blend_rgb; +/* BGR is equal to RGB */ +BlendFunction gst_video_mixer_blend_rgbx; +/* BGRx, xRGB, xBGR are equal to RGBx */ +BlendFunction gst_video_mixer_blend_yuy2; +/* YVYU and UYVY are equal to YUY2 */ + +FillCheckerFunction gst_video_mixer_fill_checker_argb; +FillCheckerFunction gst_video_mixer_fill_checker_bgra; +/* ABGR is equal to ARGB, RGBA is equal to BGRA */ +FillCheckerFunction gst_video_mixer_fill_checker_ayuv; +FillCheckerFunction gst_video_mixer_fill_checker_y444; +FillCheckerFunction gst_video_mixer_fill_checker_y42b; +FillCheckerFunction gst_video_mixer_fill_checker_i420; +/* I420 is equal to YV12 */ +FillCheckerFunction gst_video_mixer_fill_checker_nv12; +FillCheckerFunction gst_video_mixer_fill_checker_nv21; +FillCheckerFunction gst_video_mixer_fill_checker_y41b; +FillCheckerFunction gst_video_mixer_fill_checker_rgb; +/* BGR is equal to RGB */ +FillCheckerFunction gst_video_mixer_fill_checker_xrgb; +/* BGRx, xRGB, xBGR are equal to RGBx */ +FillCheckerFunction gst_video_mixer_fill_checker_yuy2; +/* YVYU is equal to YUY2 */ +FillCheckerFunction gst_video_mixer_fill_checker_uyvy; + +FillColorFunction gst_video_mixer_fill_color_argb; +FillColorFunction gst_video_mixer_fill_color_bgra; +FillColorFunction gst_video_mixer_fill_color_abgr; +FillColorFunction gst_video_mixer_fill_color_rgba; +FillColorFunction gst_video_mixer_fill_color_ayuv; +FillColorFunction gst_video_mixer_fill_color_y444; +FillColorFunction gst_video_mixer_fill_color_y42b; +FillColorFunction gst_video_mixer_fill_color_i420; +FillColorFunction gst_video_mixer_fill_color_yv12; +FillColorFunction gst_video_mixer_fill_color_nv12; +/* NV21 is equal to NV12 */ +FillColorFunction gst_video_mixer_fill_color_y41b; +FillColorFunction gst_video_mixer_fill_color_rgb; +FillColorFunction gst_video_mixer_fill_color_bgr; +FillColorFunction gst_video_mixer_fill_color_xrgb; +FillColorFunction gst_video_mixer_fill_color_xbgr; +FillColorFunction gst_video_mixer_fill_color_rgbx; +FillColorFunction gst_video_mixer_fill_color_bgrx; +FillColorFunction gst_video_mixer_fill_color_yuy2; +FillColorFunction gst_video_mixer_fill_color_yvyu; +FillColorFunction gst_video_mixer_fill_color_uyvy; + +void +gst_video_mixer_init_blend (void) +{ + GST_DEBUG_CATEGORY_INIT (gst_videomixer_blend_debug, "videomixer_blend", 0, + "video mixer blending functions"); + + gst_video_mixer_blend_argb = blend_argb; + gst_video_mixer_blend_bgra = blend_bgra; + gst_video_mixer_overlay_argb = overlay_argb; + gst_video_mixer_overlay_bgra = overlay_bgra; + gst_video_mixer_blend_i420 = blend_i420; + gst_video_mixer_blend_nv12 = blend_nv12; + gst_video_mixer_blend_nv21 = blend_nv21; + gst_video_mixer_blend_y444 = blend_y444; + gst_video_mixer_blend_y42b = blend_y42b; + gst_video_mixer_blend_y41b = blend_y41b; + gst_video_mixer_blend_rgb = blend_rgb; + gst_video_mixer_blend_xrgb = blend_xrgb; + gst_video_mixer_blend_yuy2 = blend_yuy2; + + gst_video_mixer_fill_checker_argb = fill_checker_argb_c; + gst_video_mixer_fill_checker_bgra = fill_checker_bgra_c; + gst_video_mixer_fill_checker_ayuv = fill_checker_ayuv_c; + gst_video_mixer_fill_checker_i420 = fill_checker_i420; + gst_video_mixer_fill_checker_nv12 = fill_checker_nv12; + gst_video_mixer_fill_checker_nv21 = fill_checker_nv21; + gst_video_mixer_fill_checker_y444 = fill_checker_y444; + gst_video_mixer_fill_checker_y42b = fill_checker_y42b; + gst_video_mixer_fill_checker_y41b = fill_checker_y41b; + gst_video_mixer_fill_checker_rgb = fill_checker_rgb_c; + gst_video_mixer_fill_checker_xrgb = fill_checker_xrgb_c; + gst_video_mixer_fill_checker_yuy2 = fill_checker_yuy2_c; + gst_video_mixer_fill_checker_uyvy = fill_checker_uyvy_c; + + gst_video_mixer_fill_color_argb = fill_color_argb; + gst_video_mixer_fill_color_bgra = fill_color_bgra; + gst_video_mixer_fill_color_abgr = fill_color_abgr; + gst_video_mixer_fill_color_rgba = fill_color_rgba; + gst_video_mixer_fill_color_ayuv = fill_color_ayuv; + gst_video_mixer_fill_color_i420 = fill_color_i420; + gst_video_mixer_fill_color_yv12 = fill_color_yv12; + gst_video_mixer_fill_color_nv12 = fill_color_nv12; + gst_video_mixer_fill_color_y444 = fill_color_y444; + gst_video_mixer_fill_color_y42b = fill_color_y42b; + gst_video_mixer_fill_color_y41b = fill_color_y41b; + gst_video_mixer_fill_color_rgb = fill_color_rgb_c; + gst_video_mixer_fill_color_bgr = fill_color_bgr_c; + gst_video_mixer_fill_color_xrgb = fill_color_xrgb; + gst_video_mixer_fill_color_xbgr = fill_color_xbgr; + gst_video_mixer_fill_color_rgbx = fill_color_rgbx; + gst_video_mixer_fill_color_bgrx = fill_color_bgrx; + gst_video_mixer_fill_color_yuy2 = fill_color_yuy2; + gst_video_mixer_fill_color_yvyu = fill_color_yvyu; + gst_video_mixer_fill_color_uyvy = fill_color_uyvy; +} diff --git a/gst/videomixer/blend.h b/gst/videomixer/blend.h new file mode 100644 index 0000000..7d16c56 --- /dev/null +++ b/gst/videomixer/blend.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __BLEND_H__ +#define __BLEND_H__ + +#include <gst/gst.h> +#include <gst/video/video.h> + +typedef void (*BlendFunction) (GstVideoFrame *srcframe, gint xpos, gint ypos, gdouble src_alpha, GstVideoFrame * destframe); +typedef void (*FillCheckerFunction) (GstVideoFrame * frame); +typedef void (*FillColorFunction) (GstVideoFrame * frame, gint c1, gint c2, gint c3); + +extern BlendFunction gst_video_mixer_blend_argb; +extern BlendFunction gst_video_mixer_blend_bgra; +#define gst_video_mixer_blend_ayuv gst_video_mixer_blend_argb +#define gst_video_mixer_blend_abgr gst_video_mixer_blend_argb +#define gst_video_mixer_blend_rgba gst_video_mixer_blend_bgra +extern BlendFunction gst_video_mixer_overlay_argb; +extern BlendFunction gst_video_mixer_overlay_bgra; +#define gst_video_mixer_overlay_ayuv gst_video_mixer_overlay_argb +#define gst_video_mixer_overlay_abgr gst_video_mixer_overlay_argb +#define gst_video_mixer_overlay_rgba gst_video_mixer_overlay_bgra +extern BlendFunction gst_video_mixer_blend_i420; +#define gst_video_mixer_blend_yv12 gst_video_mixer_blend_i420 +extern BlendFunction gst_video_mixer_blend_nv12; +extern BlendFunction gst_video_mixer_blend_nv21; +extern BlendFunction gst_video_mixer_blend_y41b; +extern BlendFunction gst_video_mixer_blend_y42b; +extern BlendFunction gst_video_mixer_blend_y444; +extern BlendFunction gst_video_mixer_blend_rgb; +#define gst_video_mixer_blend_bgr gst_video_mixer_blend_rgb +extern BlendFunction gst_video_mixer_blend_rgbx; +#define gst_video_mixer_blend_bgrx gst_video_mixer_blend_rgbx +#define gst_video_mixer_blend_xrgb gst_video_mixer_blend_rgbx +#define gst_video_mixer_blend_xbgr gst_video_mixer_blend_rgbx +extern BlendFunction gst_video_mixer_blend_yuy2; +#define gst_video_mixer_blend_uyvy gst_video_mixer_blend_yuy2; +#define gst_video_mixer_blend_yvyu gst_video_mixer_blend_yuy2; + +extern FillCheckerFunction gst_video_mixer_fill_checker_argb; +#define gst_video_mixer_fill_checker_abgr gst_video_mixer_fill_checker_argb +extern FillCheckerFunction gst_video_mixer_fill_checker_bgra; +#define gst_video_mixer_fill_checker_rgba gst_video_mixer_fill_checker_bgra +extern FillCheckerFunction gst_video_mixer_fill_checker_ayuv; +extern FillCheckerFunction gst_video_mixer_fill_checker_i420; +#define gst_video_mixer_fill_checker_yv12 gst_video_mixer_fill_checker_i420 +extern FillCheckerFunction gst_video_mixer_fill_checker_nv12; +extern FillCheckerFunction gst_video_mixer_fill_checker_nv21; +extern FillCheckerFunction gst_video_mixer_fill_checker_y41b; +extern FillCheckerFunction gst_video_mixer_fill_checker_y42b; +extern FillCheckerFunction gst_video_mixer_fill_checker_y444; +extern FillCheckerFunction gst_video_mixer_fill_checker_rgb; +#define gst_video_mixer_fill_checker_bgr gst_video_mixer_fill_checker_rgb +extern FillCheckerFunction gst_video_mixer_fill_checker_rgbx; +#define gst_video_mixer_fill_checker_bgrx gst_video_mixer_fill_checker_rgbx +#define gst_video_mixer_fill_checker_xrgb gst_video_mixer_fill_checker_rgbx +#define gst_video_mixer_fill_checker_xbgr gst_video_mixer_fill_checker_rgbx +extern FillCheckerFunction gst_video_mixer_fill_checker_yuy2; +#define gst_video_mixer_fill_checker_yvyu gst_video_mixer_fill_checker_yuy2; +extern FillCheckerFunction gst_video_mixer_fill_checker_uyvy; + +extern FillColorFunction gst_video_mixer_fill_color_argb; +extern FillColorFunction gst_video_mixer_fill_color_abgr; +extern FillColorFunction gst_video_mixer_fill_color_bgra; +extern FillColorFunction gst_video_mixer_fill_color_rgba; +extern FillColorFunction gst_video_mixer_fill_color_ayuv; +extern FillColorFunction gst_video_mixer_fill_color_i420; +extern FillColorFunction gst_video_mixer_fill_color_yv12; +extern FillColorFunction gst_video_mixer_fill_color_nv12; +#define gst_video_mixer_fill_color_nv21 gst_video_mixer_fill_color_nv12; +extern FillColorFunction gst_video_mixer_fill_color_y41b; +extern FillColorFunction gst_video_mixer_fill_color_y42b; +extern FillColorFunction gst_video_mixer_fill_color_y444; +extern FillColorFunction gst_video_mixer_fill_color_rgb; +extern FillColorFunction gst_video_mixer_fill_color_bgr; +extern FillColorFunction gst_video_mixer_fill_color_xrgb; +extern FillColorFunction gst_video_mixer_fill_color_xbgr; +extern FillColorFunction gst_video_mixer_fill_color_rgbx; +extern FillColorFunction gst_video_mixer_fill_color_bgrx; +extern FillColorFunction gst_video_mixer_fill_color_yuy2; +extern FillColorFunction gst_video_mixer_fill_color_yvyu; +extern FillColorFunction gst_video_mixer_fill_color_uyvy; + +void gst_video_mixer_init_blend (void); + +#endif /* __BLEND_H__ */ diff --git a/gst/videomixer/gstcms.c b/gst/videomixer/gstcms.c new file mode 100755 index 0000000..c46bd56 --- /dev/null +++ b/gst/videomixer/gstcms.c @@ -0,0 +1,577 @@ +/* GStreamer + * Copyright (C) 2008 David Schleef <ds@entropywave.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gst/gst.h> +#include <gst/math-compat.h> +#include "gstcms.h" + +#include <stdio.h> +#include <string.h> +#include <math.h> + + +/* our simple CMS */ + +void +videomixer_color_xyY_to_XYZ (Color * c) +{ + if (c->v[1] == 0) { + c->v[0] = 0; + c->v[1] = 0; + c->v[2] = 0; + } else { + double X, Y, Z; + X = c->v[0] * c->v[2] / c->v[1]; + Y = c->v[2]; + Z = (1.0 - c->v[0] - c->v[1]) * c->v[2] / c->v[1]; + c->v[0] = X; + c->v[1] = Y; + c->v[2] = Z; + } +} + +void +videomixer_color_XYZ_to_xyY (Color * c) +{ + double d; + d = c->v[0] + c->v[1] + c->v[2]; + if (d == 0) { + c->v[0] = 0.3128; + c->v[1] = 0.3290; + c->v[2] = 0; + } else { + double x, y, Y; + x = c->v[0] / d; + y = c->v[1] / d; + Y = c->v[1]; + c->v[0] = x; + c->v[1] = y; + c->v[2] = Y; + } +} + +void +videomixer_color_set (Color * c, double x, double y, double z) +{ + c->v[0] = x; + c->v[1] = y; + c->v[2] = z; +} + +void +videomixer_color_matrix_set_identity (ColorMatrix * m) +{ + int i, j; + + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + m->m[i][j] = (i == j); + } + } +} + +/* Prettyprint a 4x4 matrix @m@ */ +void +videomixer_color_matrix_dump (ColorMatrix * m) +{ + int i, j; + + printf ("[\n"); + for (i = 0; i < 4; i++) { + printf (" "); + for (j = 0; j < 4; j++) { + printf (" %8.5g", m->m[i][j]); + } + printf ("\n"); + } + printf ("]\n"); +} + +/* Perform 4x4 matrix multiplication: + * - @dst@ = @a@ * @b@ + * - @dst@ may be a pointer to @a@ andor @b@ + */ +void +videomixer_color_matrix_multiply (ColorMatrix * dst, ColorMatrix * a, + ColorMatrix * b) +{ + ColorMatrix tmp; + int i, j, k; + + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + double x = 0; + for (k = 0; k < 4; k++) { + x += a->m[i][k] * b->m[k][j]; + } + tmp.m[i][j] = x; + } + } + + memcpy (dst, &tmp, sizeof (ColorMatrix)); +} + +void +videomixer_color_matrix_apply (ColorMatrix * m, Color * dest, Color * src) +{ + int i; + Color tmp; + + for (i = 0; i < 3; i++) { + double x = 0; + x += m->m[i][0] * src->v[0]; + x += m->m[i][1] * src->v[1]; + x += m->m[i][2] * src->v[2]; + x += m->m[i][3]; + tmp.v[i] = x; + } + memcpy (dest, &tmp, sizeof (tmp)); +} + +void +videomixer_color_matrix_offset_components (ColorMatrix * m, double a1, + double a2, double a3) +{ + ColorMatrix a; + + videomixer_color_matrix_set_identity (&a); + a.m[0][3] = a1; + a.m[1][3] = a2; + a.m[2][3] = a3; + videomixer_color_matrix_multiply (m, &a, m); +} + +void +videomixer_color_matrix_scale_components (ColorMatrix * m, double a1, double a2, + double a3) +{ + ColorMatrix a; + + videomixer_color_matrix_set_identity (&a); + a.m[0][0] = a1; + a.m[1][1] = a2; + a.m[2][2] = a3; + videomixer_color_matrix_multiply (m, &a, m); +} + +void +videomixer_color_matrix_YCbCr_to_RGB (ColorMatrix * m, double Kr, double Kb) +{ + double Kg = 1.0 - Kr - Kb; + ColorMatrix k = { + { + {1., 0., 2 * (1 - Kr), 0.}, + {1., -2 * Kb * (1 - Kb) / Kg, -2 * Kr * (1 - Kr) / Kg, 0.}, + {1., 2 * (1 - Kb), 0., 0.}, + {0., 0., 0., 1.}, + } + }; + + videomixer_color_matrix_multiply (m, &k, m); +} + +void +videomixer_color_matrix_RGB_to_YCbCr (ColorMatrix * m, double Kr, double Kb) +{ + double Kg = 1.0 - Kr - Kb; + ColorMatrix k; + double x; + + k.m[0][0] = Kr; + k.m[0][1] = Kg; + k.m[0][2] = Kb; + k.m[0][3] = 0; + + x = 1 / (2 * (1 - Kb)); + k.m[1][0] = -x * Kr; + k.m[1][1] = -x * Kg; + k.m[1][2] = x * (1 - Kb); + k.m[1][3] = 0; + + x = 1 / (2 * (1 - Kr)); + k.m[2][0] = x * (1 - Kr); + k.m[2][1] = -x * Kg; + k.m[2][2] = -x * Kb; + k.m[2][3] = 0; + + k.m[3][0] = 0; + k.m[3][1] = 0; + k.m[3][2] = 0; + k.m[3][3] = 1; + + videomixer_color_matrix_multiply (m, &k, m); +} + +void +videomixer_color_matrix_build_yuv_to_rgb_601 (ColorMatrix * dst) +{ + /* + * At this point, everything is in YCbCr + * All components are in the range [0,255] + */ + videomixer_color_matrix_set_identity (dst); + + /* offset required to get input video black to (0.,0.,0.) */ + videomixer_color_matrix_offset_components (dst, -16, -128, -128); + + /* scale required to get input video black to (0.,0.,0.) */ + videomixer_color_matrix_scale_components (dst, (1 / 219.0), (1 / 224.0), + (1 / 224.0)); + + /* colour matrix, YCbCr -> RGB */ + /* Requires Y in [0,1.0], Cb&Cr in [-0.5,0.5] */ + videomixer_color_matrix_YCbCr_to_RGB (dst, 0.2990, 0.1140); /* SD */ + + /* + * We are now in RGB space + */ + +#if 0 + /* scale to output range. */ + videomixer_color_matrix_scale_components (dst, 255.0, 255.0, 255.0); +#endif +} + +void +videomixer_color_matrix_build_bt709_to_bt601 (ColorMatrix * dst) +{ + videomixer_color_matrix_set_identity (dst); + + /* offset required to get input video black to (0.,0.,0.) */ + videomixer_color_matrix_offset_components (dst, -16, -128, -128); + + /* scale required to get input video black to (0.,0.,0.) */ + videomixer_color_matrix_scale_components (dst, (1 / 219.0), (1 / 224.0), + (1 / 224.0)); + + /* colour matrix, YCbCr -> RGB */ + /* Requires Y in [0,1.0], Cb&Cr in [-0.5,0.5] */ + videomixer_color_matrix_YCbCr_to_RGB (dst, 0.2126, 0.0722); /* HD */ + + videomixer_color_matrix_RGB_to_YCbCr (dst, 0.2990, 0.1140); /* SD */ + + videomixer_color_matrix_scale_components (dst, 219.0, 224.0, 224.0); + + videomixer_color_matrix_offset_components (dst, 16, 128, 128); +} + +void +videomixer_color_matrix_build_rgb_to_yuv_601 (ColorMatrix * dst) +{ + videomixer_color_matrix_set_identity (dst); + + videomixer_color_matrix_RGB_to_YCbCr (dst, 0.2990, 0.1140); /* SD */ + + videomixer_color_matrix_scale_components (dst, 219.0, 224.0, 224.0); + + videomixer_color_matrix_offset_components (dst, 16, 128, 128); + + { + Color c; + int i; + for (i = 7; i >= 0; i--) { + videomixer_color_set (&c, (i & 2) ? 0.75 : 0.0, (i & 4) ? 0.75 : 0.0, + (i & 1) ? 0.75 : 0.0); + videomixer_color_matrix_apply (dst, &c, &c); + g_print (" { %g, %g, %g },\n", rint (c.v[0]), rint (c.v[1]), + rint (c.v[2])); + } + videomixer_color_set (&c, -0.075, -0.075, -0.075); + videomixer_color_matrix_apply (dst, &c, &c); + g_print (" { %g, %g, %g },\n", rint (c.v[0]), rint (c.v[1]), + rint (c.v[2])); + videomixer_color_set (&c, 0.075, 0.075, 0.075); + videomixer_color_matrix_apply (dst, &c, &c); + g_print (" { %g, %g, %g },\n", rint (c.v[0]), rint (c.v[1]), + rint (c.v[2])); + } +} + +void +videomixer_color_matrix_invert (ColorMatrix * m) +{ + ColorMatrix tmp; + int i, j; + double det; + + videomixer_color_matrix_set_identity (&tmp); + for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) { + tmp.m[j][i] = + m->m[(i + 1) % 3][(j + 1) % 3] * m->m[(i + 2) % 3][(j + 2) % 3] - + m->m[(i + 1) % 3][(j + 2) % 3] * m->m[(i + 2) % 3][(j + 1) % 3]; + } + } + det = + tmp.m[0][0] * m->m[0][0] + tmp.m[0][1] * m->m[1][0] + + tmp.m[0][2] * m->m[2][0]; + for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) { + tmp.m[i][j] /= det; + } + } + memcpy (m, &tmp, sizeof (tmp)); +} + +void +videomixer_color_matrix_copy (ColorMatrix * dest, ColorMatrix * src) +{ + memcpy (dest, src, sizeof (ColorMatrix)); +} + +void +videomixer_color_matrix_transpose (ColorMatrix * m) +{ + int i, j; + ColorMatrix tmp; + + videomixer_color_matrix_set_identity (&tmp); + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + tmp.m[i][j] = m->m[j][i]; + } + } + memcpy (m, &tmp, sizeof (ColorMatrix)); +} + +void +videomixer_color_matrix_build_XYZ (ColorMatrix * dst, + double rx, double ry, + double gx, double gy, double bx, double by, double wx, double wy) +{ + Color r, g, b, w, scale; + ColorMatrix m; + + videomixer_color_set (&r, rx, ry, 1.0); + videomixer_color_xyY_to_XYZ (&r); + videomixer_color_set (&g, gx, gy, 1.0); + videomixer_color_xyY_to_XYZ (&g); + videomixer_color_set (&b, bx, by, 1.0); + videomixer_color_xyY_to_XYZ (&b); + videomixer_color_set (&w, wx, wy, 1.0); + videomixer_color_xyY_to_XYZ (&w); + + videomixer_color_matrix_set_identity (dst); + + dst->m[0][0] = r.v[0]; + dst->m[0][1] = r.v[1]; + dst->m[0][2] = r.v[2]; + dst->m[1][0] = g.v[0]; + dst->m[1][1] = g.v[1]; + dst->m[1][2] = g.v[2]; + dst->m[2][0] = b.v[0]; + dst->m[2][1] = b.v[1]; + dst->m[2][2] = b.v[2]; + + videomixer_color_matrix_dump (dst); + videomixer_color_matrix_copy (&m, dst); + videomixer_color_matrix_invert (&m); + videomixer_color_matrix_dump (&m); + + videomixer_color_matrix_transpose (&m); + videomixer_color_matrix_apply (&m, &scale, &w); + g_print ("%g %g %g\n", scale.v[0], scale.v[1], scale.v[2]); + + dst->m[0][0] = r.v[0] * scale.v[0]; + dst->m[0][1] = r.v[1] * scale.v[0]; + dst->m[0][2] = r.v[2] * scale.v[0]; + dst->m[1][0] = g.v[0] * scale.v[1]; + dst->m[1][1] = g.v[1] * scale.v[1]; + dst->m[1][2] = g.v[2] * scale.v[1]; + dst->m[2][0] = b.v[0] * scale.v[2]; + dst->m[2][1] = b.v[1] * scale.v[2]; + dst->m[2][2] = b.v[2] * scale.v[2]; + + videomixer_color_matrix_transpose (dst); + videomixer_color_matrix_dump (dst); + + videomixer_color_set (&scale, 1, 1, 1); + videomixer_color_matrix_apply (dst, &scale, &scale); + videomixer_color_XYZ_to_xyY (&scale); + g_print ("white %g %g %g\n", scale.v[0], scale.v[1], scale.v[2]); + +} + +void +videomixer_color_matrix_build_rgb_to_XYZ_601 (ColorMatrix * dst) +{ + /* SMPTE C primaries, SMPTE 170M-2004 */ + videomixer_color_matrix_build_XYZ (dst, + 0.630, 0.340, 0.310, 0.595, 0.155, 0.070, 0.3127, 0.3290); +#if 0 + /* NTSC 1953 primaries, SMPTE 170M-2004 */ + videomixer_color_matrix_build_XYZ (dst, + 0.67, 0.33, 0.21, 0.71, 0.14, 0.08, 0.3127, 0.3290); +#endif +} + +void +videomixer_color_matrix_build_XYZ_to_rgb_709 (ColorMatrix * dst) +{ + /* Rec. ITU-R BT.709-5 */ + videomixer_color_matrix_build_XYZ (dst, + 0.640, 0.330, 0.300, 0.600, 0.150, 0.060, 0.3127, 0.3290); +} + +void +videomixer_color_matrix_build_XYZ_to_rgb_dell (ColorMatrix * dst) +{ + /* Dell monitor */ +#if 1 + videomixer_color_matrix_build_XYZ (dst, + 0.662, 0.329, 0.205, 0.683, 0.146, 0.077, 0.3135, 0.3290); +#endif +#if 0 + videomixer_color_matrix_build_XYZ (dst, + 0.630, 0.340, 0.310, 0.595, 0.155, 0.070, 0.3127, 0.3290); +#endif + videomixer_color_matrix_invert (dst); +} + +void +videomixer_color_transfer_function_apply (Color * dest, Color * src) +{ + int i; + + for (i = 0; i < 3; i++) { + if (src->v[i] < 0.0812) { + dest->v[i] = src->v[i] / 4.500; + } else { + dest->v[i] = pow (src->v[i] + 0.099, 1 / 0.4500); + } + } +} + +void +videomixer_color_transfer_function_unapply (Color * dest, Color * src) +{ + int i; + + for (i = 0; i < 3; i++) { + if (src->v[i] < 0.0812 / 4.500) { + dest->v[i] = src->v[i] * 4.500; + } else { + dest->v[i] = pow (src->v[i], 0.4500) - 0.099; + } + } +} + +void +videomixer_color_gamut_clamp (Color * dest, Color * src) +{ + dest->v[0] = CLAMP (src->v[0], 0.0, 1.0); + dest->v[1] = CLAMP (src->v[1], 0.0, 1.0); + dest->v[2] = CLAMP (src->v[2], 0.0, 1.0); +} + +#if 0 +static guint8 * +get_color_transform_table (void) +{ + static guint8 *color_transform_table = NULL; + +#if 1 + if (!color_transform_table) { + ColorMatrix bt601_to_rgb; + ColorMatrix bt601_to_yuv; + ColorMatrix bt601_rgb_to_XYZ; + ColorMatrix dell_XYZ_to_rgb; + guint8 *table_y; + guint8 *table_u; + guint8 *table_v; + int y, u, v; + + videomixer_color_matrix_build_yuv_to_rgb_601 (&bt601_to_rgb); + videomixer_color_matrix_build_rgb_to_yuv_601 (&bt601_to_yuv); + videomixer_color_matrix_build_rgb_to_XYZ_601 (&bt601_rgb_to_XYZ); + videomixer_color_matrix_build_XYZ_to_rgb_dell (&dell_XYZ_to_rgb); + + color_transform_table = g_malloc (0x1000000 * 3); + + table_y = COG_OFFSET (color_transform_table, 0 * 0x1000000); + table_u = COG_OFFSET (color_transform_table, 1 * 0x1000000); + table_v = COG_OFFSET (color_transform_table, 2 * 0x1000000); + + for (y = 0; y < 256; y++) { + for (u = 0; u < 256; u++) { + for (v = 0; v < 256; v++) { + Color c; + + c.v[0] = y; + c.v[1] = u; + c.v[2] = v; + videomixer_color_matrix_apply (&bt601_to_rgb, &c, &c); + color_gamut_clamp (&c, &c); + color_transfer_function_apply (&c, &c); + videomixer_color_matrix_apply (&bt601_rgb_to_XYZ, &c, &c); + videomixer_color_matrix_apply (&dell_XYZ_to_rgb, &c, &c); + color_transfer_function_unapply (&c, &c); + color_gamut_clamp (&c, &c); + videomixer_color_matrix_apply (&bt601_to_yuv, &c, &c); + + table_y[(y << 16) | (u << 8) | (v)] = rint (c.v[0]); + table_u[(y << 16) | (u << 8) | (v)] = rint (c.v[1]); + table_v[(y << 16) | (u << 8) | (v)] = rint (c.v[2]); + } + } + } + } +#endif +#if 0 + if (!color_transform_table) { + ColorMatrix bt709_to_bt601; + guint8 *table_y; + guint8 *table_u; + guint8 *table_v; + int y, u, v; + + videomixer_color_matrix_build_bt709_to_bt601 (&bt709_to_bt601); + + color_transform_table = g_malloc (0x1000000 * 3); + + table_y = COG_OFFSET (color_transform_table, 0 * 0x1000000); + table_u = COG_OFFSET (color_transform_table, 1 * 0x1000000); + table_v = COG_OFFSET (color_transform_table, 2 * 0x1000000); + + for (y = 0; y < 256; y++) { + for (u = 0; u < 256; u++) { + for (v = 0; v < 256; v++) { + Color c; + + c.v[0] = y; + c.v[1] = u; + c.v[2] = v; + videomixer_color_matrix_apply (&bt709_to_bt601, &c, &c); + + table_y[(y << 16) | (u << 8) | (v)] = rint (c.v[0]); + table_u[(y << 16) | (u << 8) | (v)] = rint (c.v[1]); + table_v[(y << 16) | (u << 8) | (v)] = rint (c.v[2]); + } + } + } + } +#endif + + return color_transform_table; +} +#endif diff --git a/gst/videomixer/gstcms.h b/gst/videomixer/gstcms.h new file mode 100755 index 0000000..7cc5d5a --- /dev/null +++ b/gst/videomixer/gstcms.h @@ -0,0 +1,71 @@ +/* GStreamer + * Copyright (C) 2008 David Schleef <ds@entropywave.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GST_CMS_H_ +#define _GST_CMS_H_ + +#include <gst/gst.h> + +G_BEGIN_DECLS + +typedef struct _Color Color; +typedef struct _ColorMatrix ColorMatrix; + +struct _Color +{ + double v[3]; +}; + +struct _ColorMatrix +{ + double m[4][4]; +}; + +void videomixer_color_xyY_to_XYZ (Color * c); +void videomixer_color_XYZ_to_xyY (Color * c); +void videomixer_color_set (Color * c, double x, double y, double z); +void videomixer_color_matrix_set_identity (ColorMatrix * m); +void videomixer_color_matrix_dump (ColorMatrix * m); +void videomixer_color_matrix_multiply (ColorMatrix * dst, ColorMatrix * a, ColorMatrix * b); +void videomixer_color_matrix_apply (ColorMatrix * m, Color * dest, Color * src); +void videomixer_color_matrix_offset_components (ColorMatrix * m, double a1, double a2, + double a3); +void videomixer_color_matrix_scale_components (ColorMatrix * m, double a1, double a2, double a3); +void videomixer_color_matrix_YCbCr_to_RGB (ColorMatrix * m, double Kr, double Kb); +void videomixer_color_matrix_RGB_to_YCbCr (ColorMatrix * m, double Kr, double Kb); +void videomixer_color_matrix_build_yuv_to_rgb_601 (ColorMatrix * dst); +void videomixer_color_matrix_build_bt709_to_bt601 (ColorMatrix * dst); +void videomixer_color_matrix_build_rgb_to_yuv_601 (ColorMatrix * dst); +void videomixer_color_matrix_invert (ColorMatrix * m); +void videomixer_color_matrix_copy (ColorMatrix * dest, ColorMatrix * src); +void videomixer_color_matrix_transpose (ColorMatrix * m); +void videomixer_color_matrix_build_XYZ (ColorMatrix * dst, + double rx, double ry, + double gx, double gy, double bx, double by, double wx, double wy); +void videomixer_color_matrix_build_rgb_to_XYZ_601 (ColorMatrix * dst); +void videomixer_color_matrix_build_XYZ_to_rgb_709 (ColorMatrix * dst); +void videomixer_color_matrix_build_XYZ_to_rgb_dell (ColorMatrix * dst); +void videomixer_color_transfer_function_apply (Color * dest, Color * src); +void videomixer_color_transfer_function_unapply (Color * dest, Color * src); +void videomixer_color_gamut_clamp (Color * dest, Color * src); + +G_END_DECLS + +#endif + diff --git a/gst/videomixer/videoconvert.c b/gst/videomixer/videoconvert.c new file mode 100755 index 0000000..05565d7 --- /dev/null +++ b/gst/videomixer/videoconvert.c @@ -0,0 +1,1505 @@ +/* GStreamer + * Copyright (C) 2010 David Schleef <ds@schleef.org> + * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "videoconvert.h" + +#include <glib.h> +#include <string.h> +#include <math.h> + +#include "videomixerorc.h" + + +static void videoconvert_convert_generic (VideoConvert * convert, + GstVideoFrame * dest, const GstVideoFrame * src); +static void videoconvert_convert_matrix8 (VideoConvert * convert, + gpointer pixels); +static void videoconvert_convert_matrix16 (VideoConvert * convert, + gpointer pixels); +static gboolean videoconvert_convert_lookup_fastpath (VideoConvert * convert); +static gboolean videoconvert_convert_compute_matrix (VideoConvert * convert); +static gboolean videoconvert_convert_compute_resample (VideoConvert * convert); +static void videoconvert_dither_verterr (VideoConvert * convert, + guint16 * pixels, int j); +static void videoconvert_dither_halftone (VideoConvert * convert, + guint16 * pixels, int j); + + +VideoConvert * +videomixer_videoconvert_convert_new (GstVideoInfo * in_info, + GstVideoInfo * out_info) +{ + VideoConvert *convert; + gint width; + + convert = g_malloc0 (sizeof (VideoConvert)); + + convert->in_info = *in_info; + convert->out_info = *out_info; + convert->dither16 = NULL; + + convert->width = GST_VIDEO_INFO_WIDTH (in_info); + convert->height = GST_VIDEO_INFO_HEIGHT (in_info); + + if (!videoconvert_convert_lookup_fastpath (convert)) { + convert->convert = videoconvert_convert_generic; + if (!videoconvert_convert_compute_matrix (convert)) + goto no_convert; + + if (!videoconvert_convert_compute_resample (convert)) + goto no_convert; + } + + width = convert->width; + + convert->lines = out_info->finfo->pack_lines; + convert->errline = g_malloc0 (sizeof (guint16) * width * 4); + + return convert; + + /* ERRORS */ +no_convert: + { + videomixer_videoconvert_convert_free (convert); + return NULL; + } +} + +void +videomixer_videoconvert_convert_free (VideoConvert * convert) +{ + gint i; + + if (convert->upsample) + gst_video_chroma_resample_free (convert->upsample); + if (convert->downsample) + gst_video_chroma_resample_free (convert->downsample); + + for (i = 0; i < convert->n_tmplines; i++) + g_free (convert->tmplines[i]); + g_free (convert->tmplines); + g_free (convert->errline); + + g_free (convert); +} + +void +videomixer_videoconvert_convert_set_dither (VideoConvert * convert, int type) +{ + switch (type) { + case 0: + default: + convert->dither16 = NULL; + break; + case 1: + convert->dither16 = videoconvert_dither_verterr; + break; + case 2: + convert->dither16 = videoconvert_dither_halftone; + break; + } +} + +void +videomixer_videoconvert_convert_convert (VideoConvert * convert, + GstVideoFrame * dest, const GstVideoFrame * src) +{ + convert->convert (convert, dest, src); +} + +#define SCALE (8) +#define SCALE_F ((float) (1 << SCALE)) + +static void +videoconvert_convert_matrix8 (VideoConvert * convert, gpointer pixels) +{ + int i; + int r, g, b; + int y, u, v; + guint8 *p = pixels; + + for (i = 0; i < convert->width; i++) { + r = p[i * 4 + 1]; + g = p[i * 4 + 2]; + b = p[i * 4 + 3]; + + y = (convert->cmatrix[0][0] * r + convert->cmatrix[0][1] * g + + convert->cmatrix[0][2] * b + convert->cmatrix[0][3]) >> SCALE; + u = (convert->cmatrix[1][0] * r + convert->cmatrix[1][1] * g + + convert->cmatrix[1][2] * b + convert->cmatrix[1][3]) >> SCALE; + v = (convert->cmatrix[2][0] * r + convert->cmatrix[2][1] * g + + convert->cmatrix[2][2] * b + convert->cmatrix[2][3]) >> SCALE; + + p[i * 4 + 1] = CLAMP (y, 0, 255); + p[i * 4 + 2] = CLAMP (u, 0, 255); + p[i * 4 + 3] = CLAMP (v, 0, 255); + } +} + +static void +videoconvert_convert_matrix16 (VideoConvert * convert, gpointer pixels) +{ + int i; + int r, g, b; + int y, u, v; + guint16 *p = pixels; + + for (i = 0; i < convert->width; i++) { + r = p[i * 4 + 1]; + g = p[i * 4 + 2]; + b = p[i * 4 + 3]; + + y = (convert->cmatrix[0][0] * r + convert->cmatrix[0][1] * g + + convert->cmatrix[0][2] * b + convert->cmatrix[0][3]) >> SCALE; + u = (convert->cmatrix[1][0] * r + convert->cmatrix[1][1] * g + + convert->cmatrix[1][2] * b + convert->cmatrix[1][3]) >> SCALE; + v = (convert->cmatrix[2][0] * r + convert->cmatrix[2][1] * g + + convert->cmatrix[2][2] * b + convert->cmatrix[2][3]) >> SCALE; + + p[i * 4 + 1] = CLAMP (y, 0, 65535); + p[i * 4 + 2] = CLAMP (u, 0, 65535); + p[i * 4 + 3] = CLAMP (v, 0, 65535); + } +} + +static gboolean +get_Kr_Kb (GstVideoColorMatrix matrix, gdouble * Kr, gdouble * Kb) +{ + gboolean res = TRUE; + + switch (matrix) { + /* RGB */ + default: + case GST_VIDEO_COLOR_MATRIX_RGB: + res = FALSE; + break; + /* YUV */ + case GST_VIDEO_COLOR_MATRIX_FCC: + *Kr = 0.30; + *Kb = 0.11; + break; + case GST_VIDEO_COLOR_MATRIX_BT709: + *Kr = 0.2126; + *Kb = 0.0722; + break; + case GST_VIDEO_COLOR_MATRIX_BT601: + *Kr = 0.2990; + *Kb = 0.1140; + break; + case GST_VIDEO_COLOR_MATRIX_SMPTE240M: + *Kr = 0.212; + *Kb = 0.087; + break; + } + GST_DEBUG ("matrix: %d, Kr %f, Kb %f", matrix, *Kr, *Kb); + return res; +} + +static gboolean +videoconvert_convert_compute_matrix (VideoConvert * convert) +{ + GstVideoInfo *in_info, *out_info; + ColorMatrix dst; + gint i, j; + const GstVideoFormatInfo *sfinfo, *dfinfo; + const GstVideoFormatInfo *suinfo, *duinfo; + gint offset[4], scale[4]; + gdouble Kr = 0, Kb = 0; + + in_info = &convert->in_info; + out_info = &convert->out_info; + + sfinfo = in_info->finfo; + dfinfo = out_info->finfo; + + if (sfinfo->unpack_func == NULL) + goto no_unpack_func; + + if (dfinfo->pack_func == NULL) + goto no_pack_func; + + suinfo = gst_video_format_get_info (sfinfo->unpack_format); + duinfo = gst_video_format_get_info (dfinfo->unpack_format); + + convert->in_bits = GST_VIDEO_FORMAT_INFO_DEPTH (suinfo, 0); + convert->out_bits = GST_VIDEO_FORMAT_INFO_DEPTH (duinfo, 0); + + GST_DEBUG ("in bits %d, out bits %d", convert->in_bits, convert->out_bits); + + if (in_info->colorimetry.range == out_info->colorimetry.range && + in_info->colorimetry.matrix == out_info->colorimetry.matrix) { + GST_DEBUG ("using identity color transform"); + convert->matrix = NULL; + return TRUE; + } + + /* calculate intermediate format for the matrix. When unpacking, we expand + * input to 16 when one of the inputs is 16 bits */ + if (convert->in_bits == 16 || convert->out_bits == 16) { + convert->matrix = videoconvert_convert_matrix16; + + if (GST_VIDEO_FORMAT_INFO_IS_RGB (suinfo)) + suinfo = gst_video_format_get_info (GST_VIDEO_FORMAT_ARGB64); + else + suinfo = gst_video_format_get_info (GST_VIDEO_FORMAT_AYUV64); + + if (GST_VIDEO_FORMAT_INFO_IS_RGB (duinfo)) + duinfo = gst_video_format_get_info (GST_VIDEO_FORMAT_ARGB64); + else + duinfo = gst_video_format_get_info (GST_VIDEO_FORMAT_AYUV64); + } else { + convert->matrix = videoconvert_convert_matrix8; + } + + videomixer_color_matrix_set_identity (&dst); + + /* 1, bring color components to [0..1.0] range */ + gst_video_color_range_offsets (in_info->colorimetry.range, suinfo, offset, + scale); + + videomixer_color_matrix_offset_components (&dst, -offset[0], -offset[1], + -offset[2]); + + videomixer_color_matrix_scale_components (&dst, 1 / ((float) scale[0]), + 1 / ((float) scale[1]), 1 / ((float) scale[2])); + + /* 2. bring components to R'G'B' space */ + if (get_Kr_Kb (in_info->colorimetry.matrix, &Kr, &Kb)) + videomixer_color_matrix_YCbCr_to_RGB (&dst, Kr, Kb); + + /* 3. inverse transfer function. R'G'B' to linear RGB */ + + /* 4. from RGB to XYZ using the primaries */ + + /* 5. from XYZ to RGB using the primaries */ + + /* 6. transfer function. linear RGB to R'G'B' */ + + /* 7. bring components to YCbCr space */ + if (get_Kr_Kb (out_info->colorimetry.matrix, &Kr, &Kb)) + videomixer_color_matrix_RGB_to_YCbCr (&dst, Kr, Kb); + + /* 8, bring color components to nominal range */ + gst_video_color_range_offsets (out_info->colorimetry.range, duinfo, offset, + scale); + + videomixer_color_matrix_scale_components (&dst, (float) scale[0], + (float) scale[1], (float) scale[2]); + + videomixer_color_matrix_offset_components (&dst, offset[0], offset[1], + offset[2]); + + /* because we're doing fixed point matrix coefficients */ + videomixer_color_matrix_scale_components (&dst, SCALE_F, SCALE_F, SCALE_F); + + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++) + convert->cmatrix[i][j] = rint (dst.m[i][j]); + + GST_DEBUG ("[%6d %6d %6d %6d]", convert->cmatrix[0][0], + convert->cmatrix[0][1], convert->cmatrix[0][2], convert->cmatrix[0][3]); + GST_DEBUG ("[%6d %6d %6d %6d]", convert->cmatrix[1][0], + convert->cmatrix[1][1], convert->cmatrix[1][2], convert->cmatrix[1][3]); + GST_DEBUG ("[%6d %6d %6d %6d]", convert->cmatrix[2][0], + convert->cmatrix[2][1], convert->cmatrix[2][2], convert->cmatrix[2][3]); + GST_DEBUG ("[%6d %6d %6d %6d]", convert->cmatrix[3][0], + convert->cmatrix[3][1], convert->cmatrix[3][2], convert->cmatrix[3][3]); + + return TRUE; + + /* ERRORS */ +no_unpack_func: + { + GST_ERROR ("no unpack_func for format %s", + gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (in_info))); + return FALSE; + } +no_pack_func: + { + GST_ERROR ("no pack_func for format %s", + gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (out_info))); + return FALSE; + } +} + +static void +videoconvert_dither_verterr (VideoConvert * convert, guint16 * pixels, int j) +{ + int i; + guint16 *errline = convert->errline; + unsigned int mask = 0xff; + + for (i = 0; i < 4 * convert->width; i++) { + int x = pixels[i] + errline[i]; + if (x > 65535) + x = 65535; + pixels[i] = x; + errline[i] = x & mask; + } +} + +static void +videoconvert_dither_halftone (VideoConvert * convert, guint16 * pixels, int j) +{ + int i; + static guint16 halftone[8][8] = { + {0, 128, 32, 160, 8, 136, 40, 168}, + {192, 64, 224, 96, 200, 72, 232, 104}, + {48, 176, 16, 144, 56, 184, 24, 152}, + {240, 112, 208, 80, 248, 120, 216, 88}, + {12, 240, 44, 172, 4, 132, 36, 164}, + {204, 76, 236, 108, 196, 68, 228, 100}, + {60, 188, 28, 156, 52, 180, 20, 148}, + {252, 142, 220, 92, 244, 116, 212, 84} + }; + + for (i = 0; i < convert->width * 4; i++) { + int x; + x = pixels[i] + halftone[(i >> 2) & 7][j & 7]; + if (x > 65535) + x = 65535; + pixels[i] = x; + } +} + +static void +alloc_tmplines (VideoConvert * convert, guint lines, gint width) +{ + gint i; + + convert->n_tmplines = lines; + convert->tmplines = g_malloc (lines * sizeof (gpointer)); + for (i = 0; i < lines; i++) + convert->tmplines[i] = g_malloc (sizeof (guint16) * (width + 8) * 4); +} + +static gboolean +videoconvert_convert_compute_resample (VideoConvert * convert) +{ + GstVideoInfo *in_info, *out_info; + const GstVideoFormatInfo *sfinfo, *dfinfo; + gint width; + + in_info = &convert->in_info; + out_info = &convert->out_info; + + sfinfo = in_info->finfo; + dfinfo = out_info->finfo; + + width = convert->width; + + if (sfinfo->w_sub[2] != dfinfo->w_sub[2] || + sfinfo->h_sub[2] != dfinfo->h_sub[2] || + in_info->chroma_site != out_info->chroma_site) { + convert->upsample = gst_video_chroma_resample_new (0, + in_info->chroma_site, 0, sfinfo->unpack_format, sfinfo->w_sub[2], + sfinfo->h_sub[2]); + + + convert->downsample = gst_video_chroma_resample_new (0, + out_info->chroma_site, 0, dfinfo->unpack_format, -dfinfo->w_sub[2], + -dfinfo->h_sub[2]); + + } else { + convert->upsample = NULL; + convert->downsample = NULL; + } + + if (convert->upsample) { + gst_video_chroma_resample_get_info (convert->upsample, + &convert->up_n_lines, &convert->up_offset); + } else { + convert->up_n_lines = 1; + convert->up_offset = 0; + } + if (convert->downsample) { + gst_video_chroma_resample_get_info (convert->downsample, + &convert->down_n_lines, &convert->down_offset); + } else { + convert->down_n_lines = 1; + convert->down_offset = 0; + } + GST_DEBUG ("upsample: %p, site: %d, offset %d, n_lines %d", convert->upsample, + in_info->chroma_site, convert->up_offset, convert->up_n_lines); + GST_DEBUG ("downsample: %p, site: %d, offset %d, n_lines %d", + convert->downsample, out_info->chroma_site, convert->down_offset, + convert->down_n_lines); + + alloc_tmplines (convert, convert->down_n_lines + convert->up_n_lines, width); + + return TRUE; +} + +#define TO_16(x) (((x)<<8) | (x)) + +static void +convert_to16 (gpointer line, gint width) +{ + guint8 *line8 = line; + guint16 *line16 = line; + gint i; + + for (i = (width - 1) * 4; i >= 0; i--) + line16[i] = TO_16 (line8[i]); +} + +static void +convert_to8 (gpointer line, gint width) +{ + guint8 *line8 = line; + guint16 *line16 = line; + gint i; + + for (i = 0; i < width * 4; i++) + line8[i] = line16[i] >> 8; +} + +#define UNPACK_FRAME(frame,dest,line,width) \ + frame->info.finfo->unpack_func (frame->info.finfo, \ + (GST_VIDEO_FRAME_IS_INTERLACED (frame) ? \ + GST_VIDEO_PACK_FLAG_INTERLACED : \ + GST_VIDEO_PACK_FLAG_NONE), \ + dest, frame->data, frame->info.stride, 0, \ + line, width) +#define PACK_FRAME(frame,dest,line,width) \ + frame->info.finfo->pack_func (frame->info.finfo, \ + (GST_VIDEO_FRAME_IS_INTERLACED (frame) ? \ + GST_VIDEO_PACK_FLAG_INTERLACED : \ + GST_VIDEO_PACK_FLAG_NONE), \ + dest, 0, frame->data, frame->info.stride, \ + frame->info.chroma_site, line, width); + +static void +videoconvert_convert_generic (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + int j, k; + gint width, height, lines, max_lines; + guint in_bits, out_bits; + gconstpointer pal; + gsize palsize; + guint up_n_lines, down_n_lines; + gint up_offset, down_offset; + gint in_lines, out_lines; + gint up_line, down_line; + gint start_offset, stop_offset; + gpointer in_tmplines[8]; + gpointer out_tmplines[8]; + + height = convert->height; + width = convert->width; + + in_bits = convert->in_bits; + out_bits = convert->out_bits; + + lines = convert->lines; + up_n_lines = convert->up_n_lines; + up_offset = convert->up_offset; + down_n_lines = convert->down_n_lines; + down_offset = convert->down_offset; + max_lines = convert->n_tmplines; + + in_lines = 0; + out_lines = 0; + + GST_DEBUG ("up_offset %d, up_n_lines %u", up_offset, up_n_lines); + + start_offset = MIN (up_offset, down_offset); + stop_offset = height + start_offset + MAX (up_n_lines, down_n_lines); + + for (; start_offset < stop_offset; start_offset++) { + guint idx, start; + + idx = CLAMP (start_offset, 0, height); + in_tmplines[in_lines] = convert->tmplines[idx % max_lines]; + out_tmplines[out_lines] = in_tmplines[in_lines]; + GST_DEBUG ("start_offset %d/%d, %d, idx %u, in %d, out %d", start_offset, + stop_offset, up_offset, idx, in_lines, out_lines); + + up_line = up_offset + in_lines; + + /* extract the next line */ + if (up_line >= 0 && up_line < height) { + GST_DEBUG ("unpack line %d into %d", up_line, in_lines); + UNPACK_FRAME (src, in_tmplines[in_lines], up_line, width); + } + + if (start_offset >= up_offset) + in_lines++; + + if (start_offset >= down_offset) + out_lines++; + + if (in_lines < up_n_lines) + continue; + + in_lines = 0; + + /* we have enough lines to upsample */ + if (convert->upsample) { + GST_DEBUG ("doing upsample"); + gst_video_chroma_resample (convert->upsample, in_tmplines, width); + } + + /* convert upsampled lines */ + for (k = 0; k < up_n_lines; k++) { + down_line = up_offset + k; + + /* only takes lines with valid output */ + if (down_line < 0 || down_line >= height) + continue; + + GST_DEBUG ("handle line %d, %d/%d, down_line %d", k, out_lines, + down_n_lines, down_line); + + if (out_bits == 16 || in_bits == 16) { + /* FIXME, we can scale in the conversion matrix */ + if (in_bits == 8) + convert_to16 (in_tmplines[k], width); + + if (convert->matrix) + convert->matrix (convert, in_tmplines[k]); + if (convert->dither16) + convert->dither16 (convert, in_tmplines[k], down_line); + + if (out_bits == 8) + convert_to8 (in_tmplines[k], width); + } else { + if (convert->matrix) + convert->matrix (convert, in_tmplines[k]); + } + } + + start = 0; + while (out_lines >= down_n_lines) { + if (convert->downsample) { + GST_DEBUG ("doing downsample %u", start); + gst_video_chroma_resample (convert->downsample, + &out_tmplines[start], width); + } + + for (j = 0; j < down_n_lines; j += lines) { + idx = down_offset + j; + + if (idx < height) { + GST_DEBUG ("packing line %d %d %d", j + start, down_offset, idx); + /* FIXME, not correct if lines > 1 */ + PACK_FRAME (dest, out_tmplines[j + start], idx, width); + } + } + down_offset += down_n_lines; + start += down_n_lines; + out_lines -= down_n_lines; + } + /* we didn't process these lines, move them up for the next round */ + for (j = 0; j < out_lines; j++) { + GST_DEBUG ("move line %d->%d", j + start, j); + out_tmplines[j] = out_tmplines[j + start]; + } + + up_offset += up_n_lines; + } + if ((pal = + gst_video_format_get_palette (GST_VIDEO_FRAME_FORMAT (dest), + &palsize))) { + memcpy (GST_VIDEO_FRAME_PLANE_DATA (dest, 1), pal, palsize); + } +} + +#define FRAME_GET_PLANE_STRIDE(frame, plane) \ + GST_VIDEO_FRAME_PLANE_STRIDE (frame, plane) +#define FRAME_GET_PLANE_LINE(frame, plane, line) \ + (gpointer)(((guint8*)(GST_VIDEO_FRAME_PLANE_DATA (frame, plane))) + \ + FRAME_GET_PLANE_STRIDE (frame, plane) * (line)) + +#define FRAME_GET_COMP_STRIDE(frame, comp) \ + GST_VIDEO_FRAME_COMP_STRIDE (frame, comp) +#define FRAME_GET_COMP_LINE(frame, comp, line) \ + (gpointer)(((guint8*)(GST_VIDEO_FRAME_COMP_DATA (frame, comp))) + \ + FRAME_GET_COMP_STRIDE (frame, comp) * (line)) + +#define FRAME_GET_STRIDE(frame) FRAME_GET_PLANE_STRIDE (frame, 0) +#define FRAME_GET_LINE(frame,line) FRAME_GET_PLANE_LINE (frame, 0, line) + +#define FRAME_GET_Y_LINE(frame,line) FRAME_GET_COMP_LINE(frame, GST_VIDEO_COMP_Y, line) +#define FRAME_GET_U_LINE(frame,line) FRAME_GET_COMP_LINE(frame, GST_VIDEO_COMP_U, line) +#define FRAME_GET_V_LINE(frame,line) FRAME_GET_COMP_LINE(frame, GST_VIDEO_COMP_V, line) +#define FRAME_GET_A_LINE(frame,line) FRAME_GET_COMP_LINE(frame, GST_VIDEO_COMP_A, line) + +#define FRAME_GET_Y_STRIDE(frame) FRAME_GET_COMP_STRIDE(frame, GST_VIDEO_COMP_Y) +#define FRAME_GET_U_STRIDE(frame) FRAME_GET_COMP_STRIDE(frame, GST_VIDEO_COMP_U) +#define FRAME_GET_V_STRIDE(frame) FRAME_GET_COMP_STRIDE(frame, GST_VIDEO_COMP_V) +#define FRAME_GET_A_STRIDE(frame) FRAME_GET_COMP_STRIDE(frame, GST_VIDEO_COMP_A) + +/* Fast paths */ + +#define GET_LINE_OFFSETS(interlaced,line,l1,l2) \ + if (interlaced) { \ + l1 = (line & 2 ? line - 1 : line); \ + l2 = l1 + 2; \ + } else { \ + l1 = line; \ + l2 = l1 + 1; \ + } + + +static void +convert_I420_YUY2 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + int i; + gint width = convert->width; + gint height = convert->height; + gboolean interlaced = GST_VIDEO_FRAME_IS_INTERLACED (src); + gint l1, l2; + + for (i = 0; i < GST_ROUND_DOWN_2 (height); i += 2) { + GET_LINE_OFFSETS (interlaced, i, l1, l2); + + videomixer_video_convert_orc_convert_I420_YUY2 (FRAME_GET_LINE (dest, l1), + FRAME_GET_LINE (dest, l2), + FRAME_GET_Y_LINE (src, l1), + FRAME_GET_Y_LINE (src, l2), + FRAME_GET_U_LINE (src, i >> 1), + FRAME_GET_V_LINE (src, i >> 1), (width + 1) / 2); + } + + /* now handle last line */ + if (height & 1) { + UNPACK_FRAME (src, convert->tmplines[0], height - 1, width); + PACK_FRAME (dest, convert->tmplines[0], height - 1, width); + } +} + +static void +convert_I420_UYVY (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + int i; + gint width = convert->width; + gint height = convert->height; + gboolean interlaced = GST_VIDEO_FRAME_IS_INTERLACED (src); + gint l1, l2; + + for (i = 0; i < GST_ROUND_DOWN_2 (height); i += 2) { + GET_LINE_OFFSETS (interlaced, i, l1, l2); + + videomixer_video_convert_orc_convert_I420_UYVY (FRAME_GET_LINE (dest, l1), + FRAME_GET_LINE (dest, l2), + FRAME_GET_Y_LINE (src, l1), + FRAME_GET_Y_LINE (src, l2), + FRAME_GET_U_LINE (src, i >> 1), + FRAME_GET_V_LINE (src, i >> 1), (width + 1) / 2); + } + + /* now handle last line */ + if (height & 1) { + UNPACK_FRAME (src, convert->tmplines[0], height - 1, width); + PACK_FRAME (dest, convert->tmplines[0], height - 1, width); + } +} + +static void +convert_I420_AYUV (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + int i; + gint width = convert->width; + gint height = convert->height; + gboolean interlaced = GST_VIDEO_FRAME_IS_INTERLACED (src); + gint l1, l2; + + for (i = 0; i < GST_ROUND_DOWN_2 (height); i += 2) { + GET_LINE_OFFSETS (interlaced, i, l1, l2); + + videomixer_video_convert_orc_convert_I420_AYUV (FRAME_GET_LINE (dest, l1), + FRAME_GET_LINE (dest, l2), + FRAME_GET_Y_LINE (src, l1), + FRAME_GET_Y_LINE (src, l2), + FRAME_GET_U_LINE (src, i >> 1), FRAME_GET_V_LINE (src, i >> 1), width); + } + + /* now handle last line */ + if (height & 1) { + UNPACK_FRAME (src, convert->tmplines[0], height - 1, width); + PACK_FRAME (dest, convert->tmplines[0], height - 1, width); + } +} + +static void +convert_I420_Y42B (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_memcpy_2d (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), width, height); + + videomixer_video_convert_orc_planar_chroma_420_422 (FRAME_GET_U_LINE (dest, + 0), 2 * FRAME_GET_U_STRIDE (dest), FRAME_GET_U_LINE (dest, 1), + 2 * FRAME_GET_U_STRIDE (dest), FRAME_GET_U_LINE (src, 0), + FRAME_GET_U_STRIDE (src), (width + 1) / 2, height / 2); + + videomixer_video_convert_orc_planar_chroma_420_422 (FRAME_GET_V_LINE (dest, + 0), 2 * FRAME_GET_V_STRIDE (dest), FRAME_GET_V_LINE (dest, 1), + 2 * FRAME_GET_V_STRIDE (dest), FRAME_GET_V_LINE (src, 0), + FRAME_GET_V_STRIDE (src), (width + 1) / 2, height / 2); +} + +static void +convert_I420_Y444 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_memcpy_2d (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), width, height); + + videomixer_video_convert_orc_planar_chroma_420_444 (FRAME_GET_U_LINE (dest, + 0), 2 * FRAME_GET_U_STRIDE (dest), FRAME_GET_U_LINE (dest, 1), + 2 * FRAME_GET_U_STRIDE (dest), FRAME_GET_U_LINE (src, 0), + FRAME_GET_U_STRIDE (src), (width + 1) / 2, height / 2); + + videomixer_video_convert_orc_planar_chroma_420_444 (FRAME_GET_V_LINE (dest, + 0), 2 * FRAME_GET_V_STRIDE (dest), FRAME_GET_V_LINE (dest, 1), + 2 * FRAME_GET_V_STRIDE (dest), FRAME_GET_V_LINE (src, 0), + FRAME_GET_V_STRIDE (src), (width + 1) / 2, height / 2); + + /* now handle last line */ + if (height & 1) { + UNPACK_FRAME (src, convert->tmplines[0], height - 1, width); + PACK_FRAME (dest, convert->tmplines[0], height - 1, width); + } +} + +static void +convert_YUY2_I420 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + int i; + gint width = convert->width; + gint height = convert->height; + gboolean interlaced = GST_VIDEO_FRAME_IS_INTERLACED (src); + gint l1, l2; + + for (i = 0; i < GST_ROUND_DOWN_2 (height); i += 2) { + GET_LINE_OFFSETS (interlaced, i, l1, l2); + + videomixer_video_convert_orc_convert_YUY2_I420 (FRAME_GET_Y_LINE (dest, l1), + FRAME_GET_Y_LINE (dest, l2), + FRAME_GET_U_LINE (dest, i >> 1), + FRAME_GET_V_LINE (dest, i >> 1), + FRAME_GET_LINE (src, l1), FRAME_GET_LINE (src, l2), (width + 1) / 2); + } + + /* now handle last line */ + if (height & 1) { + UNPACK_FRAME (src, convert->tmplines[0], height - 1, width); + PACK_FRAME (dest, convert->tmplines[0], height - 1, width); + } +} + +static void +convert_YUY2_AYUV (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_YUY2_AYUV (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), (width + 1) / 2, height); +} + +static void +convert_YUY2_Y42B (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_YUY2_Y42B (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_U_LINE (dest, 0), + FRAME_GET_U_STRIDE (dest), FRAME_GET_V_LINE (dest, 0), + FRAME_GET_V_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), (width + 1) / 2, height); +} + +static void +convert_YUY2_Y444 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_YUY2_Y444 (FRAME_GET_COMP_LINE (dest, 0, + 0), FRAME_GET_COMP_STRIDE (dest, 0), FRAME_GET_COMP_LINE (dest, 1, 0), + FRAME_GET_COMP_STRIDE (dest, 1), FRAME_GET_COMP_LINE (dest, 2, 0), + FRAME_GET_COMP_STRIDE (dest, 2), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), (width + 1) / 2, height); +} + + +static void +convert_UYVY_I420 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + int i; + gint width = convert->width; + gint height = convert->height; + gboolean interlaced = GST_VIDEO_FRAME_IS_INTERLACED (src); + gint l1, l2; + + for (i = 0; i < GST_ROUND_DOWN_2 (height); i += 2) { + GET_LINE_OFFSETS (interlaced, i, l1, l2); + + videomixer_video_convert_orc_convert_UYVY_I420 (FRAME_GET_COMP_LINE (dest, + 0, l1), FRAME_GET_COMP_LINE (dest, 0, l2), + FRAME_GET_COMP_LINE (dest, 1, i >> 1), FRAME_GET_COMP_LINE (dest, 2, + i >> 1), FRAME_GET_LINE (src, l1), FRAME_GET_LINE (src, l2), + (width + 1) / 2); + } + + /* now handle last line */ + if (height & 1) { + UNPACK_FRAME (src, convert->tmplines[0], height - 1, width); + PACK_FRAME (dest, convert->tmplines[0], height - 1, width); + } +} + +static void +convert_UYVY_AYUV (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_UYVY_AYUV (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), (width + 1) / 2, height); +} + +static void +convert_UYVY_YUY2 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_UYVY_YUY2 (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), (width + 1) / 2, height); +} + +static void +convert_UYVY_Y42B (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_UYVY_Y42B (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_U_LINE (dest, 0), + FRAME_GET_U_STRIDE (dest), FRAME_GET_V_LINE (dest, 0), + FRAME_GET_V_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), (width + 1) / 2, height); +} + +static void +convert_UYVY_Y444 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_UYVY_Y444 (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_U_LINE (dest, 0), + FRAME_GET_U_STRIDE (dest), FRAME_GET_V_LINE (dest, 0), + FRAME_GET_V_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), (width + 1) / 2, height); +} + +static void +convert_AYUV_I420 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + /* only for even width/height */ + videomixer_video_convert_orc_convert_AYUV_I420 (FRAME_GET_Y_LINE (dest, 0), + 2 * FRAME_GET_Y_STRIDE (dest), FRAME_GET_Y_LINE (dest, 1), + 2 * FRAME_GET_Y_STRIDE (dest), FRAME_GET_U_LINE (dest, 0), + FRAME_GET_U_STRIDE (dest), FRAME_GET_V_LINE (dest, 0), + FRAME_GET_V_STRIDE (dest), FRAME_GET_LINE (src, 0), + 2 * FRAME_GET_STRIDE (src), FRAME_GET_LINE (src, 1), + 2 * FRAME_GET_STRIDE (src), width / 2, height / 2); +} + +static void +convert_AYUV_YUY2 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + /* only for even width */ + videomixer_video_convert_orc_convert_AYUV_YUY2 (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), width / 2, height); +} + +static void +convert_AYUV_UYVY (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + /* only for even width */ + videomixer_video_convert_orc_convert_AYUV_UYVY (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), width / 2, height); +} + +static void +convert_AYUV_Y42B (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + /* only works for even width */ + videomixer_video_convert_orc_convert_AYUV_Y42B (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_U_LINE (dest, 0), + FRAME_GET_U_STRIDE (dest), FRAME_GET_V_LINE (dest, 0), + FRAME_GET_V_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), width / 2, height); +} + +static void +convert_AYUV_Y444 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_AYUV_Y444 (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_U_LINE (dest, 0), + FRAME_GET_U_STRIDE (dest), FRAME_GET_V_LINE (dest, 0), + FRAME_GET_V_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), width, height); +} + +static void +convert_Y42B_I420 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_memcpy_2d (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), width, height); + + videomixer_video_convert_orc_planar_chroma_422_420 (FRAME_GET_U_LINE (dest, + 0), FRAME_GET_U_STRIDE (dest), FRAME_GET_U_LINE (src, 0), + 2 * FRAME_GET_U_STRIDE (src), FRAME_GET_U_LINE (src, 1), + 2 * FRAME_GET_U_STRIDE (src), (width + 1) / 2, height / 2); + + videomixer_video_convert_orc_planar_chroma_422_420 (FRAME_GET_V_LINE (dest, + 0), FRAME_GET_V_STRIDE (dest), FRAME_GET_V_LINE (src, 0), + 2 * FRAME_GET_V_STRIDE (src), FRAME_GET_V_LINE (src, 1), + 2 * FRAME_GET_V_STRIDE (src), (width + 1) / 2, height / 2); + + /* now handle last line */ + if (height & 1) { + UNPACK_FRAME (src, convert->tmplines[0], height - 1, width); + PACK_FRAME (dest, convert->tmplines[0], height - 1, width); + } +} + +static void +convert_Y42B_Y444 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_memcpy_2d (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), width, height); + + videomixer_video_convert_orc_planar_chroma_422_444 (FRAME_GET_U_LINE (dest, + 0), FRAME_GET_U_STRIDE (dest), FRAME_GET_U_LINE (src, 0), + FRAME_GET_U_STRIDE (src), (width + 1) / 2, height); + + videomixer_video_convert_orc_planar_chroma_422_444 (FRAME_GET_V_LINE (dest, + 0), FRAME_GET_V_STRIDE (dest), FRAME_GET_V_LINE (src, 0), + FRAME_GET_V_STRIDE (src), (width + 1) / 2, height); +} + +static void +convert_Y42B_YUY2 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_Y42B_YUY2 (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), FRAME_GET_U_LINE (src, 0), + FRAME_GET_U_STRIDE (src), FRAME_GET_V_LINE (src, 0), + FRAME_GET_V_STRIDE (src), (width + 1) / 2, height); +} + +static void +convert_Y42B_UYVY (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_Y42B_UYVY (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), FRAME_GET_U_LINE (src, 0), + FRAME_GET_U_STRIDE (src), FRAME_GET_V_LINE (src, 0), + FRAME_GET_V_STRIDE (src), (width + 1) / 2, height); +} + +static void +convert_Y42B_AYUV (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + /* only for even width */ + videomixer_video_convert_orc_convert_Y42B_AYUV (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), FRAME_GET_U_LINE (src, 0), + FRAME_GET_U_STRIDE (src), FRAME_GET_V_LINE (src, 0), + FRAME_GET_V_STRIDE (src), width / 2, height); +} + +static void +convert_Y444_I420 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_memcpy_2d (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), width, height); + + videomixer_video_convert_orc_planar_chroma_444_420 (FRAME_GET_U_LINE (dest, + 0), FRAME_GET_U_STRIDE (dest), FRAME_GET_U_LINE (src, 0), + 2 * FRAME_GET_U_STRIDE (src), FRAME_GET_U_LINE (src, 1), + 2 * FRAME_GET_U_STRIDE (src), width / 2, height / 2); + + videomixer_video_convert_orc_planar_chroma_444_420 (FRAME_GET_V_LINE (dest, + 0), FRAME_GET_V_STRIDE (dest), FRAME_GET_V_LINE (src, 0), + 2 * FRAME_GET_V_STRIDE (src), FRAME_GET_V_LINE (src, 1), + 2 * FRAME_GET_V_STRIDE (src), width / 2, height / 2); + + /* now handle last line */ + if (height & 1) { + UNPACK_FRAME (src, convert->tmplines[0], height - 1, width); + PACK_FRAME (dest, convert->tmplines[0], height - 1, width); + } +} + +static void +convert_Y444_Y42B (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_memcpy_2d (FRAME_GET_Y_LINE (dest, 0), + FRAME_GET_Y_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), width, height); + + videomixer_video_convert_orc_planar_chroma_444_422 (FRAME_GET_U_LINE (dest, + 0), FRAME_GET_U_STRIDE (dest), FRAME_GET_U_LINE (src, 0), + FRAME_GET_U_STRIDE (src), width / 2, height); + + videomixer_video_convert_orc_planar_chroma_444_422 (FRAME_GET_V_LINE (dest, + 0), FRAME_GET_V_STRIDE (dest), FRAME_GET_V_LINE (src, 0), + FRAME_GET_V_STRIDE (src), width / 2, height); +} + +static void +convert_Y444_YUY2 (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_Y444_YUY2 (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), FRAME_GET_U_LINE (src, 0), + FRAME_GET_U_STRIDE (src), FRAME_GET_V_LINE (src, 0), + FRAME_GET_V_STRIDE (src), width / 2, height); +} + +static void +convert_Y444_UYVY (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_Y444_UYVY (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), FRAME_GET_U_LINE (src, 0), + FRAME_GET_U_STRIDE (src), FRAME_GET_V_LINE (src, 0), + FRAME_GET_V_STRIDE (src), width / 2, height); +} + +static void +convert_Y444_AYUV (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_Y444_AYUV (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_Y_LINE (src, 0), + FRAME_GET_Y_STRIDE (src), FRAME_GET_U_LINE (src, 0), + FRAME_GET_U_STRIDE (src), FRAME_GET_V_LINE (src, 0), + FRAME_GET_V_STRIDE (src), width, height); +} + +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +static void +convert_AYUV_ARGB (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_AYUV_ARGB (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), convert->cmatrix[0][0], convert->cmatrix[0][2], + convert->cmatrix[2][1], convert->cmatrix[1][1], convert->cmatrix[1][2], + width, height); +} + +static void +convert_AYUV_BGRA (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_AYUV_BGRA (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), convert->cmatrix[0][0], convert->cmatrix[0][2], + convert->cmatrix[2][1], convert->cmatrix[1][1], convert->cmatrix[1][2], + width, height); +} + +static void +convert_AYUV_ABGR (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_AYUV_ABGR (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), convert->cmatrix[0][0], convert->cmatrix[0][2], + convert->cmatrix[2][1], convert->cmatrix[1][1], convert->cmatrix[1][2], + width, height); +} + +static void +convert_AYUV_RGBA (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + gint width = convert->width; + gint height = convert->height; + + videomixer_video_convert_orc_convert_AYUV_RGBA (FRAME_GET_LINE (dest, 0), + FRAME_GET_STRIDE (dest), FRAME_GET_LINE (src, 0), + FRAME_GET_STRIDE (src), convert->cmatrix[0][0], convert->cmatrix[0][2], + convert->cmatrix[2][1], convert->cmatrix[1][1], convert->cmatrix[1][2], + width, height); +} + +static void +convert_I420_BGRA (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src) +{ + int i; + gint width = convert->width; + gint height = convert->height; + + for (i = 0; i < height; i++) { + videomixer_video_convert_orc_convert_I420_BGRA (FRAME_GET_LINE (dest, i), + FRAME_GET_Y_LINE (src, i), + FRAME_GET_U_LINE (src, i >> 1), FRAME_GET_V_LINE (src, i >> 1), + convert->cmatrix[0][0], convert->cmatrix[0][2], + convert->cmatrix[2][1], convert->cmatrix[1][1], convert->cmatrix[1][2], + width); + } +} +#endif + + + +/* Fast paths */ + +typedef struct +{ + GstVideoFormat in_format; + GstVideoColorMatrix in_matrix; + GstVideoFormat out_format; + GstVideoColorMatrix out_matrix; + gboolean keeps_color_matrix; + gboolean keeps_interlaced; + gboolean needs_color_matrix; + gint width_align, height_align; + void (*convert) (VideoConvert * convert, GstVideoFrame * dest, + const GstVideoFrame * src); +} VideoTransform; + +static const VideoTransform transforms[] = { + {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_I420_YUY2}, + {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_I420_UYVY}, + {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_I420_AYUV}, + {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0, + convert_I420_Y42B}, + {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0, + convert_I420_Y444}, + + {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_I420_YUY2}, + {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_I420_UYVY}, + {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_I420_AYUV}, + {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0, + convert_I420_Y42B}, + {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0, + convert_I420_Y444}, + + {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_I420, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_YUY2_I420}, + {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YV12, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_YUY2_I420}, + {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, convert_UYVY_YUY2}, /* alias */ + {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_YUY2_AYUV}, + {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_YUY2_Y42B}, + {GST_VIDEO_FORMAT_YUY2, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_YUY2_Y444}, + + {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_I420, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_UYVY_I420}, + {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YV12, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_UYVY_I420}, + {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_UYVY_YUY2}, + {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_UYVY_AYUV}, + {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_UYVY_Y42B}, + {GST_VIDEO_FORMAT_UYVY, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_UYVY_Y444}, + + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_I420, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 1, 1, + convert_AYUV_I420}, + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YV12, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 1, 1, + convert_AYUV_I420}, + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0, + convert_AYUV_YUY2}, + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0, + convert_AYUV_UYVY}, + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0, + convert_AYUV_Y42B}, + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_AYUV_Y444}, + + {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_I420, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0, + convert_Y42B_I420}, + {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YV12, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 0, 0, + convert_Y42B_I420}, + {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_Y42B_YUY2}, + {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_Y42B_UYVY}, + {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0, + convert_Y42B_AYUV}, + {GST_VIDEO_FORMAT_Y42B, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y444, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_Y42B_Y444}, + + {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_I420, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 1, 0, + convert_Y444_I420}, + {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YV12, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, FALSE, 1, 0, + convert_Y444_I420}, + {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_YUY2, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0, + convert_Y444_YUY2}, + {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_UYVY, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0, + convert_Y444_UYVY}, + {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_AYUV, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 0, 0, + convert_Y444_AYUV}, + {GST_VIDEO_FORMAT_Y444, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_Y42B, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, FALSE, 1, 0, + convert_Y444_Y42B}, + +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_ARGB, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, + convert_AYUV_ARGB}, + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRA, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, + convert_AYUV_BGRA}, + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_xRGB, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, convert_AYUV_ARGB}, /* alias */ + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRx, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, convert_AYUV_BGRA}, /* alias */ + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_ABGR, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, + convert_AYUV_ABGR}, + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_RGBA, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, + convert_AYUV_RGBA}, + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_xBGR, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, convert_AYUV_ABGR}, /* alias */ + {GST_VIDEO_FORMAT_AYUV, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_RGBx, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, TRUE, TRUE, 0, 0, convert_AYUV_RGBA}, /* alias */ + + {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRA, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, TRUE, 0, 0, + convert_I420_BGRA}, + {GST_VIDEO_FORMAT_I420, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRx, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, TRUE, 0, 0, + convert_I420_BGRA}, + {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRA, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, TRUE, 0, 0, + convert_I420_BGRA}, + {GST_VIDEO_FORMAT_YV12, GST_VIDEO_COLOR_MATRIX_UNKNOWN, GST_VIDEO_FORMAT_BGRx, + GST_VIDEO_COLOR_MATRIX_UNKNOWN, TRUE, FALSE, TRUE, 0, 0, + convert_I420_BGRA}, +#endif +}; + +static gboolean +videoconvert_convert_lookup_fastpath (VideoConvert * convert) +{ + int i; + GstVideoFormat in_format, out_format; + GstVideoColorMatrix in_matrix, out_matrix; + gboolean interlaced; + gint width, height; + + in_format = GST_VIDEO_INFO_FORMAT (&convert->in_info); + out_format = GST_VIDEO_INFO_FORMAT (&convert->out_info); + + width = GST_VIDEO_INFO_WIDTH (&convert->in_info); + height = GST_VIDEO_INFO_HEIGHT (&convert->in_info); + + in_matrix = convert->in_info.colorimetry.matrix; + out_matrix = convert->out_info.colorimetry.matrix; + + interlaced = GST_VIDEO_INFO_IS_INTERLACED (&convert->in_info); + interlaced |= GST_VIDEO_INFO_IS_INTERLACED (&convert->out_info); + + for (i = 0; i < sizeof (transforms) / sizeof (transforms[0]); i++) { + if (transforms[i].in_format == in_format && + transforms[i].out_format == out_format && + (transforms[i].keeps_color_matrix || + (transforms[i].in_matrix == in_matrix && + transforms[i].out_matrix == out_matrix)) && + (transforms[i].keeps_interlaced || !interlaced) && + (transforms[i].width_align & width) == 0 && + (transforms[i].height_align & height) == 0) { + GST_DEBUG ("using fastpath"); + if (transforms[i].needs_color_matrix) + if (!videoconvert_convert_compute_matrix (convert)) + goto no_convert; + convert->convert = transforms[i].convert; + alloc_tmplines (convert, 1, GST_VIDEO_INFO_WIDTH (&convert->in_info)); + return TRUE; + } + } + GST_DEBUG ("no fastpath found"); + return FALSE; + +no_convert: + { + GST_DEBUG ("can't create matrix"); + return FALSE; + } +} diff --git a/gst/videomixer/videoconvert.h b/gst/videomixer/videoconvert.h new file mode 100755 index 0000000..e27bc0a --- /dev/null +++ b/gst/videomixer/videoconvert.h @@ -0,0 +1,80 @@ +/* Video conversion functions + * Copyright (C) 2010 David Schleef <ds@schleef.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __COLORSPACE_H__ +#define __COLORSPACE_H__ + +#include <gst/video/video.h> +#include "gstcms.h" + +G_BEGIN_DECLS + +typedef struct _VideoConvert VideoConvert; + +typedef enum { + DITHER_NONE, + DITHER_VERTERR, + DITHER_HALFTONE +} ColorSpaceDitherMethod; + +struct _VideoConvert { + GstVideoInfo in_info; + GstVideoInfo out_info; + + gint width; + gint height; + + gint in_bits; + gint out_bits; + gint cmatrix[4][4]; + + ColorSpaceDitherMethod dither; + + guint lines; + + guint n_tmplines; + gpointer *tmplines; + guint16 *errline; + + GstVideoChromaResample *upsample; + guint up_n_lines; + gint up_offset; + GstVideoChromaResample *downsample; + guint down_n_lines; + gint down_offset; + + void (*convert) (VideoConvert *convert, GstVideoFrame *dest, const GstVideoFrame *src); + void (*matrix) (VideoConvert *convert, gpointer pixels); + void (*dither16) (VideoConvert *convert, guint16 * pixels, int j); + +}; + +VideoConvert * videomixer_videoconvert_convert_new (GstVideoInfo *in_info, + GstVideoInfo *out_info); +void videomixer_videoconvert_convert_free (VideoConvert * convert); + +void videomixer_videoconvert_convert_set_dither (VideoConvert * convert, int type); + +void videomixer_videoconvert_convert_convert (VideoConvert * convert, + GstVideoFrame *dest, const GstVideoFrame *src); + + +G_END_DECLS + +#endif /* __GST_COLORSPACE_H__ */ diff --git a/gst/videomixer/videomixer2.c b/gst/videomixer/videomixer2.c new file mode 100755 index 0000000..52edb4d --- /dev/null +++ b/gst/videomixer/videomixer2.c @@ -0,0 +1,2377 @@ +/* Generic video mixer plugin + * Copyright (C) 2004, 2008 Wim Taymans <wim@fluendo.com> + * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/** + * SECTION:element-videomixer + * + * Videomixer2 can accept AYUV, ARGB and BGRA video streams. For each of the requested + * sink pads it will compare the incoming geometry and framerate to define the + * output parameters. Indeed output video frames will have the geometry of the + * biggest incoming video stream and the framerate of the fastest incoming one. + * + * Videomixer will do colorspace conversion. + * + * Individual parameters for each input stream can be configured on the + * #GstVideoMixer2Pad. + * + * <refsect2> + * <title>Sample pipelines</title> + * |[ + * gst-launch-1.0 \ + * videotestsrc pattern=1 ! \ + * video/x-raw,format=AYUV,framerate=\(fraction\)10/1,width=100,height=100 ! \ + * videobox border-alpha=0 top=-70 bottom=-70 right=-220 ! \ + * videomixer name=mix sink_0::alpha=0.7 sink_1::alpha=0.5 ! \ + * videoconvert ! xvimagesink \ + * videotestsrc ! \ + * video/x-raw,format=AYUV,framerate=\(fraction\)5/1,width=320,height=240 ! mix. + * ]| A pipeline to demonstrate videomixer used together with videobox. + * This should show a 320x240 pixels video test source with some transparency + * showing the background checker pattern. Another video test source with just + * the snow pattern of 100x100 pixels is overlayed on top of the first one on + * the left vertically centered with a small transparency showing the first + * video test source behind and the checker pattern under it. Note that the + * framerate of the output video is 10 frames per second. + * |[ + * gst-launch-1.0 videotestsrc pattern=1 ! \ + * video/x-raw, framerate=\(fraction\)10/1, width=100, height=100 ! \ + * videomixer name=mix ! videoconvert ! ximagesink \ + * videotestsrc ! \ + * video/x-raw, framerate=\(fraction\)5/1, width=320, height=240 ! mix. + * ]| A pipeline to demostrate bgra mixing. (This does not demonstrate alpha blending). + * |[ + * gst-launch-1.0 videotestsrc pattern=1 ! \ + * video/x-raw,format =I420, framerate=\(fraction\)10/1, width=100, height=100 ! \ + * videomixer name=mix ! videoconvert ! ximagesink \ + * videotestsrc ! \ + * video/x-raw,format=I420, framerate=\(fraction\)5/1, width=320, height=240 ! mix. + * ]| A pipeline to test I420 + * |[ + * gst-launch-1.0 videomixer name=mixer sink_1::alpha=0.5 sink_1::xpos=50 sink_1::ypos=50 ! \ + * videoconvert ! ximagesink \ + * videotestsrc pattern=snow timestamp-offset=3000000000 ! \ + * "video/x-raw,format=AYUV,width=640,height=480,framerate=(fraction)30/1" ! \ + * timeoverlay ! queue2 ! mixer. \ + * videotestsrc pattern=smpte ! \ + * "video/x-raw,format=AYUV,width=800,height=600,framerate=(fraction)10/1" ! \ + * timeoverlay ! queue2 ! mixer. + * ]| A pipeline to demonstrate synchronized mixing (the second stream starts after 3 seconds) + * </refsect2> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> + +#include "videomixer2.h" +#include "videomixer2pad.h" +#include "videoconvert.h" + +#ifdef DISABLE_ORC +#define orc_memset memset +#else +#include <orc/orcfunctions.h> +#endif + +GST_DEBUG_CATEGORY_STATIC (gst_videomixer2_debug); +#define GST_CAT_DEFAULT gst_videomixer2_debug + +#define GST_VIDEO_MIXER2_GET_LOCK(mix) \ + (&GST_VIDEO_MIXER2(mix)->lock) +#define GST_VIDEO_MIXER2_LOCK(mix) \ + (g_mutex_lock(GST_VIDEO_MIXER2_GET_LOCK (mix))) +#define GST_VIDEO_MIXER2_UNLOCK(mix) \ + (g_mutex_unlock(GST_VIDEO_MIXER2_GET_LOCK (mix))) +#define GST_VIDEO_MIXER2_GET_SETCAPS_LOCK(mix) \ + (&GST_VIDEO_MIXER2(mix)->setcaps_lock) +#define GST_VIDEO_MIXER2_SETCAPS_LOCK(mix) \ + (g_mutex_lock(GST_VIDEO_MIXER2_GET_SETCAPS_LOCK (mix))) +#define GST_VIDEO_MIXER2_SETCAPS_UNLOCK(mix) \ + (g_mutex_unlock(GST_VIDEO_MIXER2_GET_SETCAPS_LOCK (mix))) + +#define FORMATS " { AYUV, BGRA, ARGB, RGBA, ABGR, Y444, Y42B, YUY2, UYVY, "\ + " YVYU, I420, YV12, NV12, NV21, Y41B, RGB, BGR, xRGB, xBGR, "\ + " RGBx, BGRx } " + +static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (FORMATS)) + ); + +static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%u", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (FORMATS)) + ); + +static void gst_videomixer2_child_proxy_init (gpointer g_iface, + gpointer iface_data); +static gboolean gst_videomixer2_push_sink_event (GstVideoMixer2 * mix, + GstEvent * event); +static void gst_videomixer2_release_pad (GstElement * element, GstPad * pad); +static void gst_videomixer2_reset_qos (GstVideoMixer2 * mix); + +struct _GstVideoMixer2Collect +{ + GstCollectData collect; /* we extend the CollectData */ + + GstVideoMixer2Pad *mixpad; + + GstBuffer *queued; /* buffer for which we don't know the end time yet */ + GstVideoInfo queued_vinfo; + + GstBuffer *buffer; /* buffer that should be blended now */ + GstVideoInfo buffer_vinfo; + + GstClockTime start_time; + GstClockTime end_time; +}; + +#define DEFAULT_PAD_ZORDER 0 +#define DEFAULT_PAD_XPOS 0 +#define DEFAULT_PAD_YPOS 0 +#define DEFAULT_PAD_ALPHA 1.0 +enum +{ + PROP_PAD_0, + PROP_PAD_ZORDER, + PROP_PAD_XPOS, + PROP_PAD_YPOS, + PROP_PAD_ALPHA +}; + +G_DEFINE_TYPE (GstVideoMixer2Pad, gst_videomixer2_pad, GST_TYPE_PAD); + +static void +gst_videomixer2_collect_free (GstCollectData * data) +{ + GstVideoMixer2Collect *cdata = (GstVideoMixer2Collect *) data; + + gst_buffer_replace (&cdata->buffer, NULL); +} + +static gboolean gst_videomixer2_src_setcaps (GstPad * pad, GstVideoMixer2 * mix, + GstCaps * caps); + +static gboolean +gst_videomixer2_update_src_caps (GstVideoMixer2 * mix) +{ + GSList *l; + gint best_width = -1, best_height = -1; + gdouble best_fps = -1, cur_fps; + gint best_fps_n = -1, best_fps_d = -1; + gboolean ret = TRUE; + + GST_VIDEO_MIXER2_SETCAPS_LOCK (mix); + GST_VIDEO_MIXER2_LOCK (mix); + + for (l = mix->sinkpads; l; l = l->next) { + GstVideoMixer2Pad *mpad = l->data; + gint this_width, this_height; + gint fps_n, fps_d; + gint width, height; + + fps_n = GST_VIDEO_INFO_FPS_N (&mpad->info); + fps_d = GST_VIDEO_INFO_FPS_D (&mpad->info); + width = GST_VIDEO_INFO_WIDTH (&mpad->info); + height = GST_VIDEO_INFO_HEIGHT (&mpad->info); + + if (width == 0 || height == 0) + continue; + + this_width = width + MAX (mpad->xpos, 0); + this_height = height + MAX (mpad->ypos, 0); + + if (best_width < this_width) + best_width = this_width; + if (best_height < this_height) + best_height = this_height; + + if (fps_d == 0) + cur_fps = 0.0; + else + gst_util_fraction_to_double (fps_n, fps_d, &cur_fps); + + if (best_fps < cur_fps) { + best_fps = cur_fps; + best_fps_n = fps_n; + best_fps_d = fps_d; + } + } + + if (best_fps_n <= 0 || best_fps_d <= 0 || best_fps == 0.0) { + best_fps_n = 25; + best_fps_d = 1; + best_fps = 25.0; + } + + if (best_width > 0 && best_height > 0 && best_fps > 0) { + GstCaps *caps, *peercaps; + GstStructure *s; + GstVideoInfo info; + + if (GST_VIDEO_INFO_FPS_N (&mix->info) != best_fps_n || + GST_VIDEO_INFO_FPS_D (&mix->info) != best_fps_d) { + if (mix->segment.position != -1) { + mix->ts_offset = mix->segment.position - mix->segment.start; + mix->nframes = 0; + } + } + gst_video_info_init (&info); + gst_video_info_set_format (&info, GST_VIDEO_INFO_FORMAT (&mix->info), + best_width, best_height); + info.fps_n = best_fps_n; + info.fps_d = best_fps_d; + info.par_n = GST_VIDEO_INFO_PAR_N (&mix->info); + info.par_d = GST_VIDEO_INFO_PAR_D (&mix->info); + + caps = gst_video_info_to_caps (&info); + + peercaps = gst_pad_peer_query_caps (mix->srcpad, NULL); + if (peercaps && !gst_caps_can_intersect (peercaps, caps)) { + GstCaps *tmp; + + s = gst_caps_get_structure (caps, 0); + gst_structure_set (s, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT, "height", + GST_TYPE_INT_RANGE, 1, G_MAXINT, "framerate", GST_TYPE_FRACTION_RANGE, + 0, 1, G_MAXINT, 1, NULL); + + tmp = gst_caps_intersect (caps, peercaps); + gst_caps_unref (caps); + gst_caps_unref (peercaps); + caps = tmp; + if (gst_caps_is_empty (caps)) { + GST_DEBUG_OBJECT (mix, "empty caps"); + ret = FALSE; + GST_VIDEO_MIXER2_UNLOCK (mix); + goto done; + } + + caps = gst_caps_truncate (caps); + s = gst_caps_get_structure (caps, 0); + gst_structure_fixate_field_nearest_int (s, "width", best_width); + gst_structure_fixate_field_nearest_int (s, "height", best_height); + gst_structure_fixate_field_nearest_fraction (s, "framerate", best_fps_n, + best_fps_d); + + gst_structure_get_int (s, "width", &info.width); + gst_structure_get_int (s, "height", &info.height); + gst_structure_get_fraction (s, "fraction", &info.fps_n, &info.fps_d); + } + + gst_caps_unref (caps); + caps = gst_video_info_to_caps (&info); + + GST_VIDEO_MIXER2_UNLOCK (mix); + ret = gst_videomixer2_src_setcaps (mix->srcpad, mix, caps); + gst_caps_unref (caps); + } else { + GST_VIDEO_MIXER2_UNLOCK (mix); + } + +done: + GST_VIDEO_MIXER2_SETCAPS_UNLOCK (mix); + + return ret; +} + +static gboolean +gst_videomixer2_update_converters (GstVideoMixer2 * mix) +{ + GSList *tmp; + GstVideoFormat best_format; + GstVideoInfo best_info; + GstVideoMixer2Pad *pad; + gboolean need_alpha = FALSE; + gboolean at_least_one_alpha = FALSE; + GstCaps *downstream_caps; + GstCaps *possible_caps; + gchar *best_colorimetry; + const gchar *best_chroma; + GHashTable *formats_table; + gint best_format_number = 0; + + best_format = GST_VIDEO_FORMAT_UNKNOWN; + gst_video_info_init (&best_info); + + downstream_caps = gst_pad_get_allowed_caps (mix->srcpad); + + if (!downstream_caps || gst_caps_is_empty (downstream_caps)) { + if (downstream_caps) + gst_caps_unref (downstream_caps); + return FALSE; + } + + formats_table = g_hash_table_new (g_direct_hash, g_direct_equal); + + /* first find new preferred format */ + for (tmp = mix->sinkpads; tmp; tmp = tmp->next) { + GstStructure *s; + gint format_number; + + pad = tmp->data; + + if (!pad->info.finfo) + continue; + + if (pad->info.finfo->flags & GST_VIDEO_FORMAT_FLAG_ALPHA) + at_least_one_alpha = TRUE; + + /* If we want alpha, disregard all the other formats */ + if (need_alpha && !(pad->info.finfo->flags & GST_VIDEO_FORMAT_FLAG_ALPHA)) + continue; + + /* This can happen if we release a pad and another pad hasn't been negotiated yet */ + if (GST_VIDEO_INFO_FORMAT (&pad->info) == GST_VIDEO_FORMAT_UNKNOWN) + continue; + + possible_caps = gst_video_info_to_caps (&pad->info); + + s = gst_caps_get_structure (possible_caps, 0); + gst_structure_remove_fields (s, "width", "height", "framerate", + "pixel-aspect-ratio", "interlace-mode", NULL); + + /* Can downstream accept this format ? */ + if (!gst_caps_can_intersect (downstream_caps, possible_caps)) { + gst_caps_unref (possible_caps); + continue; + } + + gst_caps_unref (possible_caps); + + format_number = + GPOINTER_TO_INT (g_hash_table_lookup (formats_table, + GINT_TO_POINTER (GST_VIDEO_INFO_FORMAT (&pad->info)))); + format_number += 1; + + g_hash_table_replace (formats_table, + GINT_TO_POINTER (GST_VIDEO_INFO_FORMAT (&pad->info)), + GINT_TO_POINTER (format_number)); + + /* If that pad is the first with alpha, set it as the new best format */ + if (!need_alpha && (pad->info.finfo->flags & GST_VIDEO_FORMAT_FLAG_ALPHA)) { + need_alpha = TRUE; + best_format = GST_VIDEO_INFO_FORMAT (&pad->info); + best_info = pad->info; + best_format_number = format_number; + } else if (format_number > best_format_number) { + best_format = GST_VIDEO_INFO_FORMAT (&pad->info); + best_info = pad->info; + best_format_number = format_number; + } + } + + g_hash_table_unref (formats_table); + + if (best_format == GST_VIDEO_FORMAT_UNKNOWN) { + downstream_caps = gst_caps_fixate (downstream_caps); + gst_video_info_from_caps (&best_info, downstream_caps); + best_format = GST_VIDEO_INFO_FORMAT (&best_info); + } + + gst_caps_unref (downstream_caps); + + if (at_least_one_alpha + && !(best_info.finfo->flags & GST_VIDEO_FORMAT_FLAG_ALPHA)) { + GST_ELEMENT_ERROR (mix, CORE, NEGOTIATION, + ("At least one of the input pads contains alpha, but downstream can't support alpha."), + ("Either convert your inputs to not contain alpha or add a videoconvert after the mixer")); + return FALSE; + } + + best_colorimetry = gst_video_colorimetry_to_string (&(best_info.colorimetry)); + best_chroma = gst_video_chroma_to_string (best_info.chroma_site); + + if (GST_VIDEO_INFO_FPS_N (&mix->info) != GST_VIDEO_INFO_FPS_N (&best_info) || + GST_VIDEO_INFO_FPS_D (&mix->info) != GST_VIDEO_INFO_FPS_D (&best_info)) { + if (mix->segment.position != -1) { + mix->ts_offset = mix->segment.position - mix->segment.start; + mix->nframes = 0; + } else { + mix->ts_offset += gst_util_uint64_scale_round (mix->nframes, + GST_SECOND * GST_VIDEO_INFO_FPS_D (&mix->info), + GST_VIDEO_INFO_FPS_N (&mix->info)); + mix->nframes = 0; + } + } + + mix->info = best_info; + + GST_DEBUG_OBJECT (mix, + "The output format will now be : %d with colorimetry : %s and chroma : %s", + best_format, best_colorimetry, best_chroma); + + /* Then browse the sinks once more, setting or unsetting conversion if needed */ + for (tmp = mix->sinkpads; tmp; tmp = tmp->next) { + gchar *colorimetry; + const gchar *chroma; + + pad = tmp->data; + + if (!pad->info.finfo) + continue; + + if (GST_VIDEO_INFO_FORMAT (&pad->info) == GST_VIDEO_FORMAT_UNKNOWN) + continue; + + if (pad->convert) + videomixer_videoconvert_convert_free (pad->convert); + + pad->convert = NULL; + + colorimetry = gst_video_colorimetry_to_string (&(pad->info.colorimetry)); + chroma = gst_video_chroma_to_string (pad->info.chroma_site); + + if (best_format != GST_VIDEO_INFO_FORMAT (&pad->info) || + g_strcmp0 (colorimetry, best_colorimetry) || + g_strcmp0 (chroma, best_chroma)) { + GST_DEBUG_OBJECT (pad, "This pad will be converted from %d to %d", + GST_VIDEO_INFO_FORMAT (&pad->info), + GST_VIDEO_INFO_FORMAT (&best_info)); + pad->convert = + videomixer_videoconvert_convert_new (&pad->info, &best_info); + pad->need_conversion_update = TRUE; + if (!pad->convert) { + g_free (colorimetry); + g_free (best_colorimetry); + GST_WARNING ("No path found for conversion"); + return FALSE; + } + } else { + GST_DEBUG_OBJECT (pad, "This pad will not need conversion"); + } + g_free (colorimetry); + } + + g_free (best_colorimetry); + return TRUE; +} + +static gboolean +gst_videomixer2_pad_sink_setcaps (GstPad * pad, GstObject * parent, + GstCaps * caps) +{ + GstVideoMixer2 *mix; + GstVideoMixer2Pad *mixpad; + GstVideoInfo info; + gboolean ret = FALSE; + + GST_INFO_OBJECT (pad, "Setting caps %" GST_PTR_FORMAT, caps); + + mix = GST_VIDEO_MIXER2 (parent); + mixpad = GST_VIDEO_MIXER2_PAD (pad); + + if (!gst_video_info_from_caps (&info, caps)) { + GST_ERROR_OBJECT (pad, "Failed to parse caps"); + goto beach; + } + + GST_VIDEO_MIXER2_LOCK (mix); + if (GST_VIDEO_INFO_FORMAT (&mix->info) != GST_VIDEO_FORMAT_UNKNOWN) { + if (GST_VIDEO_INFO_PAR_N (&mix->info) != GST_VIDEO_INFO_PAR_N (&info) + || GST_VIDEO_INFO_PAR_D (&mix->info) != GST_VIDEO_INFO_PAR_D (&info) || + GST_VIDEO_INFO_INTERLACE_MODE (&mix->info) != + GST_VIDEO_INFO_INTERLACE_MODE (&info)) { + GST_DEBUG_OBJECT (pad, + "got input caps %" GST_PTR_FORMAT ", but " "current caps are %" + GST_PTR_FORMAT, caps, mix->current_caps); + GST_VIDEO_MIXER2_UNLOCK (mix); + return FALSE; + } + } + + mixpad->info = info; + + GST_COLLECT_PADS_STREAM_LOCK (mix->collect); + + ret = gst_videomixer2_update_converters (mix); + + GST_VIDEO_MIXER2_UNLOCK (mix); + if (ret) + ret = gst_videomixer2_update_src_caps (mix); + GST_COLLECT_PADS_STREAM_UNLOCK (mix->collect); + +beach: + return ret; +} + +static GstCaps * +gst_videomixer2_pad_sink_getcaps (GstPad * pad, GstVideoMixer2 * mix, + GstCaps * filter) +{ + GstCaps *srccaps; + GstCaps *template_caps; + GstCaps *filtered_caps; + GstCaps *returned_caps; + GstStructure *s; + gboolean had_current_caps = TRUE; + gint i, n; + + template_caps = gst_pad_get_pad_template_caps (GST_PAD (mix->srcpad)); + + srccaps = gst_pad_get_current_caps (GST_PAD (mix->srcpad)); + if (srccaps == NULL) { + had_current_caps = FALSE; + srccaps = template_caps; + } + + srccaps = gst_caps_make_writable (srccaps); + + n = gst_caps_get_size (srccaps); + for (i = 0; i < n; i++) { + s = gst_caps_get_structure (srccaps, i); + gst_structure_set (s, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT, + "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, + "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL); + if (!gst_structure_has_field (s, "pixel-aspect-ratio")) + gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, + NULL); + + gst_structure_remove_fields (s, "colorimetry", "chroma-site", "format", + NULL); + } + + filtered_caps = srccaps; + if (filter) + filtered_caps = gst_caps_intersect (srccaps, filter); + returned_caps = gst_caps_intersect (filtered_caps, template_caps); + + gst_caps_unref (srccaps); + if (filter) + gst_caps_unref (filtered_caps); + if (had_current_caps) + gst_caps_unref (template_caps); + + return returned_caps; +} + +static gboolean +gst_videomixer2_pad_sink_acceptcaps (GstPad * pad, GstVideoMixer2 * mix, + GstCaps * caps) +{ + gboolean ret; + GstCaps *modified_caps; + GstCaps *accepted_caps; + GstCaps *template_caps; + gboolean had_current_caps = TRUE; + gint i, n; + GstStructure *s; + + GST_DEBUG_OBJECT (pad, "%" GST_PTR_FORMAT, caps); + + accepted_caps = gst_pad_get_current_caps (GST_PAD (mix->srcpad)); + + template_caps = gst_pad_get_pad_template_caps (GST_PAD (mix->srcpad)); + + if (accepted_caps == NULL) { + accepted_caps = template_caps; + had_current_caps = FALSE; + } + + accepted_caps = gst_caps_make_writable (accepted_caps); + + GST_LOG_OBJECT (pad, "src caps %" GST_PTR_FORMAT, accepted_caps); + + n = gst_caps_get_size (accepted_caps); + for (i = 0; i < n; i++) { + s = gst_caps_get_structure (accepted_caps, i); + gst_structure_set (s, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT, + "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, + "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL); + if (!gst_structure_has_field (s, "pixel-aspect-ratio")) + gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, + NULL); + + gst_structure_remove_fields (s, "colorimetry", "chroma-site", "format", + NULL); + } + + modified_caps = gst_caps_intersect (accepted_caps, template_caps); + + ret = gst_caps_can_intersect (caps, accepted_caps); + GST_DEBUG_OBJECT (pad, "%saccepted caps %" GST_PTR_FORMAT, + (ret ? "" : "not "), caps); + GST_DEBUG_OBJECT (pad, "acceptable caps are %" GST_PTR_FORMAT, accepted_caps); + gst_caps_unref (accepted_caps); + gst_caps_unref (modified_caps); + if (had_current_caps) + gst_caps_unref (template_caps); + return ret; +} + +static gboolean +gst_videomixer2_sink_query (GstCollectPads * pads, GstCollectData * cdata, + GstQuery * query, GstVideoMixer2 * mix) +{ + GstVideoMixer2Pad *pad = GST_VIDEO_MIXER2_PAD (cdata->pad); + gboolean ret = FALSE; + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_CAPS: + { + GstCaps *filter, *caps; + + gst_query_parse_caps (query, &filter); + caps = gst_videomixer2_pad_sink_getcaps (GST_PAD (pad), mix, filter); + gst_query_set_caps_result (query, caps); + gst_caps_unref (caps); + ret = TRUE; + break; + } + case GST_QUERY_ACCEPT_CAPS: + { + GstCaps *caps; + + gst_query_parse_accept_caps (query, &caps); + ret = gst_videomixer2_pad_sink_acceptcaps (GST_PAD (pad), mix, caps); + gst_query_set_accept_caps_result (query, ret); + ret = TRUE; + break; + } + default: + ret = gst_collect_pads_query_default (pads, cdata, query, FALSE); + break; + } + return ret; +} + +static void +gst_videomixer2_pad_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) +{ + GstVideoMixer2Pad *pad = GST_VIDEO_MIXER2_PAD (object); + + switch (prop_id) { + case PROP_PAD_ZORDER: + g_value_set_uint (value, pad->zorder); + break; + case PROP_PAD_XPOS: + g_value_set_int (value, pad->xpos); + break; + case PROP_PAD_YPOS: + g_value_set_int (value, pad->ypos); + break; + case PROP_PAD_ALPHA: + g_value_set_double (value, pad->alpha); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static int +pad_zorder_compare (const GstVideoMixer2Pad * pad1, + const GstVideoMixer2Pad * pad2) +{ + return pad1->zorder - pad2->zorder; +} + +static void +gst_videomixer2_pad_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstVideoMixer2Pad *pad = GST_VIDEO_MIXER2_PAD (object); + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (gst_pad_get_parent (GST_PAD (pad))); + + switch (prop_id) { + case PROP_PAD_ZORDER: + GST_VIDEO_MIXER2_LOCK (mix); + pad->zorder = g_value_get_uint (value); + + mix->sinkpads = g_slist_sort (mix->sinkpads, + (GCompareFunc) pad_zorder_compare); + GST_VIDEO_MIXER2_UNLOCK (mix); + break; + case PROP_PAD_XPOS: + pad->xpos = g_value_get_int (value); + break; + case PROP_PAD_YPOS: + pad->ypos = g_value_get_int (value); + break; + case PROP_PAD_ALPHA: + pad->alpha = g_value_get_double (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } + + gst_object_unref (mix); +} + +static void +gst_videomixer2_pad_class_init (GstVideoMixer2PadClass * klass) +{ + GObjectClass *gobject_class = (GObjectClass *) klass; + + gobject_class->set_property = gst_videomixer2_pad_set_property; + gobject_class->get_property = gst_videomixer2_pad_get_property; + + g_object_class_install_property (gobject_class, PROP_PAD_ZORDER, + g_param_spec_uint ("zorder", "Z-Order", "Z Order of the picture", + 0, 10000, DEFAULT_PAD_ZORDER, + G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_PAD_XPOS, + g_param_spec_int ("xpos", "X Position", "X Position of the picture", + G_MININT, G_MAXINT, DEFAULT_PAD_XPOS, + G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_PAD_YPOS, + g_param_spec_int ("ypos", "Y Position", "Y Position of the picture", + G_MININT, G_MAXINT, DEFAULT_PAD_YPOS, + G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_PAD_ALPHA, + g_param_spec_double ("alpha", "Alpha", "Alpha of the picture", 0.0, 1.0, + DEFAULT_PAD_ALPHA, + G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS)); +} + +static void +gst_videomixer2_pad_init (GstVideoMixer2Pad * mixerpad) +{ + mixerpad->zorder = DEFAULT_PAD_ZORDER; + mixerpad->xpos = DEFAULT_PAD_XPOS; + mixerpad->ypos = DEFAULT_PAD_YPOS; + mixerpad->alpha = DEFAULT_PAD_ALPHA; + mixerpad->convert = NULL; + mixerpad->need_conversion_update = FALSE; +} + +/* GstVideoMixer2 */ +#define DEFAULT_BACKGROUND VIDEO_MIXER2_BACKGROUND_CHECKER +enum +{ + PROP_0, + PROP_BACKGROUND +}; + +#define GST_TYPE_VIDEO_MIXER2_BACKGROUND (gst_videomixer2_background_get_type()) +static GType +gst_videomixer2_background_get_type (void) +{ + static GType video_mixer_background_type = 0; + + static const GEnumValue video_mixer_background[] = { + {VIDEO_MIXER2_BACKGROUND_CHECKER, "Checker pattern", "checker"}, + {VIDEO_MIXER2_BACKGROUND_BLACK, "Black", "black"}, + {VIDEO_MIXER2_BACKGROUND_WHITE, "White", "white"}, + {VIDEO_MIXER2_BACKGROUND_TRANSPARENT, + "Transparent Background to enable further mixing", "transparent"}, + {0, NULL, NULL}, + }; + + if (!video_mixer_background_type) { + video_mixer_background_type = + g_enum_register_static ("GstVideoMixer2Background", + video_mixer_background); + } + return video_mixer_background_type; +} + +#define gst_videomixer2_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstVideoMixer2, gst_videomixer2, GST_TYPE_ELEMENT, + G_IMPLEMENT_INTERFACE (GST_TYPE_CHILD_PROXY, + gst_videomixer2_child_proxy_init)); + +static void +gst_videomixer2_update_qos (GstVideoMixer2 * mix, gdouble proportion, + GstClockTimeDiff diff, GstClockTime timestamp) +{ + GST_DEBUG_OBJECT (mix, + "Updating QoS: proportion %lf, diff %s%" GST_TIME_FORMAT ", timestamp %" + GST_TIME_FORMAT, proportion, (diff < 0) ? "-" : "", + GST_TIME_ARGS (ABS (diff)), GST_TIME_ARGS (timestamp)); + + GST_OBJECT_LOCK (mix); + mix->proportion = proportion; + if (G_LIKELY (timestamp != GST_CLOCK_TIME_NONE)) { + if (!mix->live && G_UNLIKELY (diff > 0)) + mix->earliest_time = + timestamp + 2 * diff + gst_util_uint64_scale_int_round (GST_SECOND, + GST_VIDEO_INFO_FPS_D (&mix->info), GST_VIDEO_INFO_FPS_N (&mix->info)); + else + mix->earliest_time = timestamp + diff; + } else { + mix->earliest_time = GST_CLOCK_TIME_NONE; + } + GST_OBJECT_UNLOCK (mix); +} + +static void +gst_videomixer2_reset_qos (GstVideoMixer2 * mix) +{ + gst_videomixer2_update_qos (mix, 0.5, 0, GST_CLOCK_TIME_NONE); + mix->qos_processed = mix->qos_dropped = 0; +} + +static void +gst_videomixer2_read_qos (GstVideoMixer2 * mix, gdouble * proportion, + GstClockTime * time) +{ + GST_OBJECT_LOCK (mix); + *proportion = mix->proportion; + *time = mix->earliest_time; + GST_OBJECT_UNLOCK (mix); +} + +static void +gst_videomixer2_reset (GstVideoMixer2 * mix) +{ + GSList *l; + + gst_video_info_init (&mix->info); + mix->ts_offset = 0; + mix->nframes = 0; + + gst_segment_init (&mix->segment, GST_FORMAT_TIME); + mix->segment.position = -1; + + gst_videomixer2_reset_qos (mix); + + for (l = mix->sinkpads; l; l = l->next) { + GstVideoMixer2Pad *p = l->data; + GstVideoMixer2Collect *mixcol = p->mixcol; + + gst_buffer_replace (&mixcol->buffer, NULL); + mixcol->start_time = -1; + mixcol->end_time = -1; + + gst_video_info_init (&p->info); + } + + mix->newseg_pending = TRUE; +} + +/* 1 == OK + * 0 == need more data + * -1 == EOS + * -2 == error + */ +static gint +gst_videomixer2_fill_queues (GstVideoMixer2 * mix, + GstClockTime output_start_time, GstClockTime output_end_time) +{ + GSList *l; + gboolean eos = TRUE; + gboolean need_more_data = FALSE; + + for (l = mix->sinkpads; l; l = l->next) { + GstVideoMixer2Pad *pad = l->data; + GstVideoMixer2Collect *mixcol = pad->mixcol; + GstSegment *segment = &pad->mixcol->collect.segment; + GstBuffer *buf; + GstVideoInfo *vinfo; + + buf = gst_collect_pads_peek (mix->collect, &mixcol->collect); + if (buf) { + GstClockTime start_time, end_time; + + start_time = GST_BUFFER_TIMESTAMP (buf); + if (start_time == -1) { + gst_buffer_unref (buf); + GST_ERROR_OBJECT (pad, "Need timestamped buffers!"); + return -2; + } + + vinfo = &pad->info; + + /* FIXME: Make all this work with negative rates */ + + if ((mixcol->buffer && start_time < GST_BUFFER_TIMESTAMP (mixcol->buffer)) + || (mixcol->queued + && start_time < GST_BUFFER_TIMESTAMP (mixcol->queued))) { + GST_WARNING_OBJECT (pad, "Buffer from the past, dropping"); + gst_buffer_unref (buf); + buf = gst_collect_pads_pop (mix->collect, &mixcol->collect); + gst_buffer_unref (buf); + need_more_data = TRUE; + continue; + } + + if (mixcol->queued) { + end_time = start_time - GST_BUFFER_TIMESTAMP (mixcol->queued); + start_time = GST_BUFFER_TIMESTAMP (mixcol->queued); + gst_buffer_unref (buf); + buf = gst_buffer_ref (mixcol->queued); + vinfo = &mixcol->queued_vinfo; + } else { + end_time = GST_BUFFER_DURATION (buf); + + if (end_time == -1) { + mixcol->queued = buf; + buf = gst_collect_pads_pop (mix->collect, &mixcol->collect); + gst_buffer_unref (buf); + mixcol->queued_vinfo = pad->info; + need_more_data = TRUE; + continue; + } + } + + g_assert (start_time != -1 && end_time != -1); + end_time += start_time; /* convert from duration to position */ + + /* Check if it's inside the segment */ + if (start_time >= segment->stop || end_time < segment->start) { + GST_DEBUG_OBJECT (pad, "Buffer outside the segment"); + + if (buf == mixcol->queued) { + gst_buffer_unref (buf); + gst_buffer_replace (&mixcol->queued, NULL); + } else { + gst_buffer_unref (buf); + buf = gst_collect_pads_pop (mix->collect, &mixcol->collect); + gst_buffer_unref (buf); + } + + need_more_data = TRUE; + continue; + } + + /* Clip to segment and convert to running time */ + start_time = MAX (start_time, segment->start); + if (segment->stop != -1) + end_time = MIN (end_time, segment->stop); + start_time = + gst_segment_to_running_time (segment, GST_FORMAT_TIME, start_time); + end_time = + gst_segment_to_running_time (segment, GST_FORMAT_TIME, end_time); + g_assert (start_time != -1 && end_time != -1); + + /* Convert to the output segment rate */ + if (ABS (mix->segment.rate) != 1.0) { + start_time *= ABS (mix->segment.rate); + end_time *= ABS (mix->segment.rate); + } + + if (mixcol->end_time != -1 && mixcol->end_time > end_time) { + GST_DEBUG_OBJECT (pad, "Buffer from the past, dropping"); + if (buf == mixcol->queued) { + gst_buffer_unref (buf); + gst_buffer_replace (&mixcol->queued, NULL); + } else { + gst_buffer_unref (buf); + buf = gst_collect_pads_pop (mix->collect, &mixcol->collect); + gst_buffer_unref (buf); + } + + need_more_data = TRUE; + continue; + } + + if (end_time >= output_start_time && start_time < output_end_time) { + GST_DEBUG_OBJECT (pad, + "Taking new buffer with start time %" GST_TIME_FORMAT, + GST_TIME_ARGS (start_time)); + gst_buffer_replace (&mixcol->buffer, buf); + mixcol->buffer_vinfo = *vinfo; + mixcol->start_time = start_time; + mixcol->end_time = end_time; + + if (buf == mixcol->queued) { + gst_buffer_unref (buf); + gst_buffer_replace (&mixcol->queued, NULL); + } else { + gst_buffer_unref (buf); + buf = gst_collect_pads_pop (mix->collect, &mixcol->collect); + gst_buffer_unref (buf); + } + eos = FALSE; + } else if (start_time >= output_end_time) { + GST_DEBUG_OBJECT (pad, "Keeping buffer until %" GST_TIME_FORMAT, + GST_TIME_ARGS (start_time)); + gst_buffer_unref (buf); + eos = FALSE; + } else { + GST_DEBUG_OBJECT (pad, "Too old buffer -- dropping"); + if (buf == mixcol->queued) { + gst_buffer_unref (buf); + gst_buffer_replace (&mixcol->queued, NULL); + } else { + gst_buffer_unref (buf); + buf = gst_collect_pads_pop (mix->collect, &mixcol->collect); + gst_buffer_unref (buf); + } + + need_more_data = TRUE; + continue; + } + } else { + if (mixcol->end_time != -1) { + if (mixcol->end_time <= output_start_time) { + gst_buffer_replace (&mixcol->buffer, NULL); + mixcol->start_time = mixcol->end_time = -1; + if (!GST_COLLECT_PADS_STATE_IS_SET (mixcol, + GST_COLLECT_PADS_STATE_EOS)) + need_more_data = TRUE; + } else if (!GST_COLLECT_PADS_STATE_IS_SET (mixcol, + GST_COLLECT_PADS_STATE_EOS)) { + eos = FALSE; + } + } + } + } + + if (need_more_data) + return 0; + if (eos) + return -1; + + return 1; +} + +static GstFlowReturn +gst_videomixer2_blend_buffers (GstVideoMixer2 * mix, + GstClockTime output_start_time, GstClockTime output_end_time, + GstBuffer ** outbuf) +{ + GSList *l; + guint outsize; + BlendFunction composite; + GstVideoFrame outframe; + static GstAllocationParams params = { 0, 15, 0, 0, }; + + outsize = GST_VIDEO_INFO_SIZE (&mix->info); + + *outbuf = gst_buffer_new_allocate (NULL, outsize, ¶ms); + GST_BUFFER_TIMESTAMP (*outbuf) = output_start_time; + GST_BUFFER_DURATION (*outbuf) = output_end_time - output_start_time; + + gst_video_frame_map (&outframe, &mix->info, *outbuf, GST_MAP_READWRITE); + + /* default to blending */ + composite = mix->blend; + switch (mix->background) { + case VIDEO_MIXER2_BACKGROUND_CHECKER: + mix->fill_checker (&outframe); + break; + case VIDEO_MIXER2_BACKGROUND_BLACK: + mix->fill_color (&outframe, 16, 128, 128); + break; + case VIDEO_MIXER2_BACKGROUND_WHITE: + mix->fill_color (&outframe, 240, 128, 128); + break; + case VIDEO_MIXER2_BACKGROUND_TRANSPARENT: + { + guint i, plane, num_planes, height; + + num_planes = GST_VIDEO_FRAME_N_PLANES (&outframe); + for (plane = 0; plane < num_planes; ++plane) { + guint8 *pdata; + gsize rowsize, plane_stride; + + pdata = GST_VIDEO_FRAME_PLANE_DATA (&outframe, plane); + plane_stride = GST_VIDEO_FRAME_PLANE_STRIDE (&outframe, plane); + rowsize = GST_VIDEO_FRAME_COMP_WIDTH (&outframe, plane) + * GST_VIDEO_FRAME_COMP_PSTRIDE (&outframe, plane); + height = GST_VIDEO_FRAME_COMP_HEIGHT (&outframe, plane); + for (i = 0; i < height; ++i) { + memset (pdata, 0, rowsize); + pdata += plane_stride; + } + } + + /* use overlay to keep background transparent */ + composite = mix->overlay; + break; + } + } + + for (l = mix->sinkpads; l; l = l->next) { + GstVideoMixer2Pad *pad = l->data; + GstVideoMixer2Collect *mixcol = pad->mixcol; + + if (mixcol->buffer != NULL) { + GstClockTime timestamp; + gint64 stream_time; + GstSegment *seg; + GstVideoFrame converted_frame; + GstBuffer *converted_buf = NULL; + GstVideoFrame frame; + + seg = &mixcol->collect.segment; + + timestamp = GST_BUFFER_TIMESTAMP (mixcol->buffer); + + stream_time = + gst_segment_to_stream_time (seg, GST_FORMAT_TIME, timestamp); + + /* sync object properties on stream time */ + if (GST_CLOCK_TIME_IS_VALID (stream_time)) + gst_object_sync_values (GST_OBJECT (pad), stream_time); + + gst_video_frame_map (&frame, &mixcol->buffer_vinfo, mixcol->buffer, + GST_MAP_READ); + + if (pad->convert) { + gint converted_size; + + /* We wait until here to set the conversion infos, in case mix->info changed */ + if (pad->need_conversion_update) { + pad->conversion_info = mix->info; + gst_video_info_set_format (&(pad->conversion_info), + GST_VIDEO_INFO_FORMAT (&mix->info), pad->info.width, + pad->info.height); + pad->need_conversion_update = FALSE; + } + + converted_size = pad->conversion_info.size; + converted_size = converted_size > outsize ? converted_size : outsize; + converted_buf = gst_buffer_new_allocate (NULL, converted_size, ¶ms); + + gst_video_frame_map (&converted_frame, &(pad->conversion_info), + converted_buf, GST_MAP_READWRITE); + videomixer_videoconvert_convert_convert (pad->convert, &converted_frame, + &frame); + gst_video_frame_unmap (&frame); + } else { + converted_frame = frame; + } + + composite (&converted_frame, pad->xpos, pad->ypos, pad->alpha, &outframe); + + if (pad->convert) + gst_buffer_unref (converted_buf); + + gst_video_frame_unmap (&converted_frame); + } + } + gst_video_frame_unmap (&outframe); + + return GST_FLOW_OK; +} + +/* Perform qos calculations before processing the next frame. Returns TRUE if + * the frame should be processed, FALSE if the frame can be dropped entirely */ +static gint64 +gst_videomixer2_do_qos (GstVideoMixer2 * mix, GstClockTime timestamp) +{ + GstClockTime qostime, earliest_time; + gdouble proportion; + gint64 jitter; + + /* no timestamp, can't do QoS => process frame */ + if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (timestamp))) { + GST_LOG_OBJECT (mix, "invalid timestamp, can't do QoS, process frame"); + return -1; + } + + /* get latest QoS observation values */ + gst_videomixer2_read_qos (mix, &proportion, &earliest_time); + + /* skip qos if we have no observation (yet) => process frame */ + if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (earliest_time))) { + GST_LOG_OBJECT (mix, "no observation yet, process frame"); + return -1; + } + + /* qos is done on running time */ + qostime = + gst_segment_to_running_time (&mix->segment, GST_FORMAT_TIME, timestamp); + + /* see how our next timestamp relates to the latest qos timestamp */ + GST_LOG_OBJECT (mix, "qostime %" GST_TIME_FORMAT ", earliest %" + GST_TIME_FORMAT, GST_TIME_ARGS (qostime), GST_TIME_ARGS (earliest_time)); + + jitter = GST_CLOCK_DIFF (qostime, earliest_time); + if (qostime != GST_CLOCK_TIME_NONE && jitter > 0) { + GST_DEBUG_OBJECT (mix, "we are late, drop frame"); + return jitter; + } + + GST_LOG_OBJECT (mix, "process frame"); + return jitter; +} + +static GstFlowReturn +gst_videomixer2_collected (GstCollectPads * pads, GstVideoMixer2 * mix) +{ + GstFlowReturn ret; + GstClockTime output_start_time, output_end_time; + GstBuffer *outbuf = NULL; + gint res; + gint64 jitter; + + /* If we're not negotiated yet... */ + if (GST_VIDEO_INFO_FORMAT (&mix->info) == GST_VIDEO_FORMAT_UNKNOWN) + return GST_FLOW_NOT_NEGOTIATED; + + if (mix->send_stream_start) { + gchar s_id[32]; + + /* stream-start (FIXME: create id based on input ids) */ + g_snprintf (s_id, sizeof (s_id), "mix-%08x", g_random_int ()); + if (!gst_pad_push_event (mix->srcpad, gst_event_new_stream_start (s_id))) { + GST_WARNING_OBJECT (mix->srcpad, "Sending stream start event failed"); + } + mix->send_stream_start = FALSE; + } + + if (gst_pad_check_reconfigure (mix->srcpad)) + gst_videomixer2_update_src_caps (mix); + + if (mix->send_caps) { + if (!gst_pad_push_event (mix->srcpad, + gst_event_new_caps (mix->current_caps))) { + GST_WARNING_OBJECT (mix->srcpad, "Sending caps event failed"); + } + mix->send_caps = FALSE; + } + + GST_VIDEO_MIXER2_LOCK (mix); + + if (mix->newseg_pending) { + GST_DEBUG_OBJECT (mix, "Sending NEWSEGMENT event"); + GST_VIDEO_MIXER2_UNLOCK (mix); + if (!gst_pad_push_event (mix->srcpad, + gst_event_new_segment (&mix->segment))) { + ret = GST_FLOW_ERROR; + goto done_unlocked; + } + GST_VIDEO_MIXER2_LOCK (mix); + mix->newseg_pending = FALSE; + } + + if (mix->segment.position == -1) + output_start_time = mix->segment.start; + else + output_start_time = mix->segment.position; + + output_end_time = + mix->ts_offset + gst_util_uint64_scale_round (mix->nframes + 1, + GST_SECOND * GST_VIDEO_INFO_FPS_D (&mix->info), + GST_VIDEO_INFO_FPS_N (&mix->info)) + mix->segment.start; + + if (output_end_time >= mix->segment.stop) { + GST_DEBUG_OBJECT (mix, "Segment done"); + if (!(mix->segment.flags & GST_SEGMENT_FLAG_SEGMENT)) { + GST_VIDEO_MIXER2_UNLOCK (mix); + gst_pad_push_event (mix->srcpad, gst_event_new_eos ()); + + ret = GST_FLOW_EOS; + goto done_unlocked; + } + } + + if (G_UNLIKELY (mix->pending_tags)) { + gst_pad_push_event (mix->srcpad, gst_event_new_tag (mix->pending_tags)); + mix->pending_tags = NULL; + } + + if (mix->segment.stop != -1) + output_end_time = MIN (output_end_time, mix->segment.stop); + + res = gst_videomixer2_fill_queues (mix, output_start_time, output_end_time); + + if (res == 0) { + GST_DEBUG_OBJECT (mix, "Need more data for decisions"); + ret = GST_FLOW_OK; + goto done; + } else if (res == -1) { + GST_VIDEO_MIXER2_UNLOCK (mix); + GST_DEBUG_OBJECT (mix, "All sinkpads are EOS -- forwarding"); + gst_pad_push_event (mix->srcpad, gst_event_new_eos ()); + ret = GST_FLOW_EOS; + goto done_unlocked; + } else if (res == -2) { + GST_ERROR_OBJECT (mix, "Error collecting buffers"); + ret = GST_FLOW_ERROR; + goto done; + } + + jitter = gst_videomixer2_do_qos (mix, output_start_time); + if (jitter <= 0) { + ret = + gst_videomixer2_blend_buffers (mix, output_start_time, + output_end_time, &outbuf); + mix->qos_processed++; + } else { + GstMessage *msg; + + mix->qos_dropped++; + + /* TODO: live */ + msg = + gst_message_new_qos (GST_OBJECT_CAST (mix), FALSE, + gst_segment_to_running_time (&mix->segment, GST_FORMAT_TIME, + output_start_time), gst_segment_to_stream_time (&mix->segment, + GST_FORMAT_TIME, output_start_time), output_start_time, + output_end_time - output_start_time); + gst_message_set_qos_values (msg, jitter, mix->proportion, 1000000); + gst_message_set_qos_stats (msg, GST_FORMAT_BUFFERS, mix->qos_processed, + mix->qos_dropped); + gst_element_post_message (GST_ELEMENT_CAST (mix), msg); + + ret = GST_FLOW_OK; + } + + mix->segment.position = output_end_time; + mix->nframes++; + + GST_VIDEO_MIXER2_UNLOCK (mix); + if (outbuf) { + GST_LOG_OBJECT (mix, + "Pushing buffer with ts %" GST_TIME_FORMAT " and duration %" + GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)), + GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf))); + ret = gst_pad_push (mix->srcpad, outbuf); + } + goto done_unlocked; + +done: + GST_VIDEO_MIXER2_UNLOCK (mix); + +done_unlocked: + return ret; +} + +/* FIXME, the duration query should reflect how long you will produce + * data, that is the amount of stream time until you will emit EOS. + * + * For synchronized mixing this is always the max of all the durations + * of upstream since we emit EOS when all of them finished. + * + * We don't do synchronized mixing so this really depends on where the + * streams where punched in and what their relative offsets are against + * eachother which we can get from the first timestamps we see. + * + * When we add a new stream (or remove a stream) the duration might + * also become invalid again and we need to post a new DURATION + * message to notify this fact to the parent. + * For now we take the max of all the upstream elements so the simple + * cases work at least somewhat. + */ +static gboolean +gst_videomixer2_query_duration (GstVideoMixer2 * mix, GstQuery * query) +{ + GValue item = { 0 }; + gint64 max; + gboolean res; + GstFormat format; + GstIterator *it; + gboolean done; + + /* parse format */ + gst_query_parse_duration (query, &format, NULL); + + max = -1; + res = TRUE; + done = FALSE; + + /* Take maximum of all durations */ + it = gst_element_iterate_sink_pads (GST_ELEMENT_CAST (mix)); + while (!done) { + switch (gst_iterator_next (it, &item)) { + case GST_ITERATOR_DONE: + done = TRUE; + break; + case GST_ITERATOR_OK: + { + GstPad *pad; + gint64 duration; + + pad = g_value_get_object (&item); + + /* ask sink peer for duration */ + res &= gst_pad_peer_query_duration (pad, format, &duration); + /* take max from all valid return values */ + if (res) { + /* valid unknown length, stop searching */ + if (duration == -1) { + max = duration; + done = TRUE; + } + /* else see if bigger than current max */ + else if (duration > max) + max = duration; + } + g_value_reset (&item); + break; + } + case GST_ITERATOR_RESYNC: + max = -1; + res = TRUE; + gst_iterator_resync (it); + break; + default: + res = FALSE; + done = TRUE; + break; + } + } + g_value_unset (&item); + gst_iterator_free (it); + + if (res) { + /* and store the max */ + GST_DEBUG_OBJECT (mix, "Total duration in format %s: %" + GST_TIME_FORMAT, gst_format_get_name (format), GST_TIME_ARGS (max)); + gst_query_set_duration (query, format, max); + } + + return res; +} + +static gboolean +gst_videomixer2_query_latency (GstVideoMixer2 * mix, GstQuery * query) +{ + GstClockTime min, max; + gboolean live; + gboolean res; + GstIterator *it; + gboolean done; + GValue item = { 0 }; + + res = TRUE; + done = FALSE; + live = FALSE; + min = 0; + max = GST_CLOCK_TIME_NONE; + + /* Take maximum of all latency values */ + it = gst_element_iterate_sink_pads (GST_ELEMENT_CAST (mix)); + while (!done) { + switch (gst_iterator_next (it, &item)) { + case GST_ITERATOR_DONE: + done = TRUE; + break; + case GST_ITERATOR_OK: + { + GstPad *pad = g_value_get_object (&item); + GstQuery *peerquery; + GstClockTime min_cur, max_cur; + gboolean live_cur; + + peerquery = gst_query_new_latency (); + + /* Ask peer for latency */ + res &= gst_pad_peer_query (pad, peerquery); + + /* take max from all valid return values */ + if (res) { + gst_query_parse_latency (peerquery, &live_cur, &min_cur, &max_cur); + + if (min_cur > min) + min = min_cur; + + if (max_cur != GST_CLOCK_TIME_NONE && + ((max != GST_CLOCK_TIME_NONE && max_cur > max) || + (max == GST_CLOCK_TIME_NONE))) + max = max_cur; + + live = live || live_cur; + } + + gst_query_unref (peerquery); + g_value_reset (&item); + break; + } + case GST_ITERATOR_RESYNC: + live = FALSE; + min = 0; + max = GST_CLOCK_TIME_NONE; + res = TRUE; + gst_iterator_resync (it); + break; + default: + res = FALSE; + done = TRUE; + break; + } + } + g_value_unset (&item); + gst_iterator_free (it); + + mix->live = live; + + if (res) { + /* store the results */ + GST_DEBUG_OBJECT (mix, "Calculated total latency: live %s, min %" + GST_TIME_FORMAT ", max %" GST_TIME_FORMAT, + (live ? "yes" : "no"), GST_TIME_ARGS (min), GST_TIME_ARGS (max)); + gst_query_set_latency (query, live, min, max); + } + + return res; +} + +static gboolean +gst_videomixer2_src_query (GstPad * pad, GstObject * parent, GstQuery * query) +{ + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (parent); + gboolean res = FALSE; + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_POSITION: + { + GstFormat format; + + gst_query_parse_position (query, &format, NULL); + + switch (format) { + case GST_FORMAT_TIME: + gst_query_set_position (query, format, + gst_segment_to_stream_time (&mix->segment, GST_FORMAT_TIME, + mix->segment.position)); + res = TRUE; + break; + default: + break; + } + break; + } + case GST_QUERY_DURATION: + res = gst_videomixer2_query_duration (mix, query); + break; + case GST_QUERY_LATENCY: + res = gst_videomixer2_query_latency (mix, query); + break; + case GST_QUERY_CAPS: + res = gst_pad_query_default (pad, parent, query); + break; + default: + /* FIXME, needs a custom query handler because we have multiple + * sinkpads */ + res = FALSE; + break; + } + return res; +} + +static gboolean +gst_videomixer2_src_event (GstPad * pad, GstObject * parent, GstEvent * event) +{ + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (parent); + gboolean result; + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_QOS: + { + GstQOSType type; + GstClockTimeDiff diff; + GstClockTime timestamp; + gdouble proportion; + + gst_event_parse_qos (event, &type, &proportion, &diff, ×tamp); + + gst_videomixer2_update_qos (mix, proportion, diff, timestamp); + + result = gst_videomixer2_push_sink_event (mix, event); + break; + } + case GST_EVENT_SEEK: + { + gdouble rate; + GstFormat fmt; + GstSeekFlags flags; + GstSeekType start_type, stop_type; + gint64 start, stop; + GSList *l; + gdouble abs_rate; + + /* parse the seek parameters */ + gst_event_parse_seek (event, &rate, &fmt, &flags, &start_type, + &start, &stop_type, &stop); + + if (rate <= 0.0) { + GST_ERROR_OBJECT (mix, "Negative rates not supported yet"); + result = FALSE; + gst_event_unref (event); + break; + } + + GST_DEBUG_OBJECT (mix, "Handling SEEK event"); + + abs_rate = ABS (rate); + + GST_VIDEO_MIXER2_LOCK (mix); + for (l = mix->sinkpads; l; l = l->next) { + GstVideoMixer2Pad *p = l->data; + + if (flags & GST_SEEK_FLAG_FLUSH) { + gst_buffer_replace (&p->mixcol->buffer, NULL); + p->mixcol->start_time = p->mixcol->end_time = -1; + continue; + } + + /* Convert to the output segment rate */ + if (ABS (mix->segment.rate) != abs_rate) { + if (ABS (mix->segment.rate) != 1.0 && p->mixcol->buffer) { + p->mixcol->start_time /= ABS (mix->segment.rate); + p->mixcol->end_time /= ABS (mix->segment.rate); + } + if (abs_rate != 1.0 && p->mixcol->buffer) { + p->mixcol->start_time *= abs_rate; + p->mixcol->end_time *= abs_rate; + } + } + } + GST_VIDEO_MIXER2_UNLOCK (mix); + + gst_segment_do_seek (&mix->segment, rate, fmt, flags, start_type, start, + stop_type, stop, NULL); + mix->segment.position = -1; + mix->ts_offset = 0; + mix->nframes = 0; + mix->newseg_pending = TRUE; + + gst_videomixer2_reset_qos (mix); + + result = gst_collect_pads_src_event_default (mix->collect, pad, event); + break; + } + case GST_EVENT_NAVIGATION: + /* navigation is rather pointless. */ + result = FALSE; + gst_event_unref (event); + break; + default: + /* just forward the rest for now */ + result = gst_videomixer2_push_sink_event (mix, event); + break; + } + + return result; +} + +static gboolean +gst_videomixer2_src_setcaps (GstPad * pad, GstVideoMixer2 * mix, GstCaps * caps) +{ + gboolean ret = FALSE; + GstVideoInfo info; + + GST_INFO_OBJECT (pad, "set src caps: %" GST_PTR_FORMAT, caps); + + if (!gst_video_info_from_caps (&info, caps)) + goto done; + + GST_VIDEO_MIXER2_LOCK (mix); + + mix->blend = NULL; + mix->overlay = NULL; + mix->fill_checker = NULL; + mix->fill_color = NULL; + + if (GST_VIDEO_INFO_FPS_N (&mix->info) != GST_VIDEO_INFO_FPS_N (&info) || + GST_VIDEO_INFO_FPS_D (&mix->info) != GST_VIDEO_INFO_FPS_D (&info)) { + if (mix->segment.position != -1) { + mix->ts_offset = mix->segment.position - mix->segment.start; + mix->nframes = 0; + } + gst_videomixer2_reset_qos (mix); + } + + mix->info = info; + + switch (GST_VIDEO_INFO_FORMAT (&mix->info)) { + case GST_VIDEO_FORMAT_AYUV: + mix->blend = gst_video_mixer_blend_ayuv; + mix->overlay = gst_video_mixer_overlay_ayuv; + mix->fill_checker = gst_video_mixer_fill_checker_ayuv; + mix->fill_color = gst_video_mixer_fill_color_ayuv; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_ARGB: + mix->blend = gst_video_mixer_blend_argb; + mix->overlay = gst_video_mixer_overlay_argb; + mix->fill_checker = gst_video_mixer_fill_checker_argb; + mix->fill_color = gst_video_mixer_fill_color_argb; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_BGRA: + mix->blend = gst_video_mixer_blend_bgra; + mix->overlay = gst_video_mixer_overlay_bgra; + mix->fill_checker = gst_video_mixer_fill_checker_bgra; + mix->fill_color = gst_video_mixer_fill_color_bgra; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_ABGR: + mix->blend = gst_video_mixer_blend_abgr; + mix->overlay = gst_video_mixer_overlay_abgr; + mix->fill_checker = gst_video_mixer_fill_checker_abgr; + mix->fill_color = gst_video_mixer_fill_color_abgr; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_RGBA: + mix->blend = gst_video_mixer_blend_rgba; + mix->overlay = gst_video_mixer_overlay_rgba; + mix->fill_checker = gst_video_mixer_fill_checker_rgba; + mix->fill_color = gst_video_mixer_fill_color_rgba; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_Y444: + mix->blend = gst_video_mixer_blend_y444; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_y444; + mix->fill_color = gst_video_mixer_fill_color_y444; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_Y42B: + mix->blend = gst_video_mixer_blend_y42b; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_y42b; + mix->fill_color = gst_video_mixer_fill_color_y42b; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_YUY2: + mix->blend = gst_video_mixer_blend_yuy2; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_yuy2; + mix->fill_color = gst_video_mixer_fill_color_yuy2; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_UYVY: + mix->blend = gst_video_mixer_blend_uyvy; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_uyvy; + mix->fill_color = gst_video_mixer_fill_color_uyvy; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_YVYU: + mix->blend = gst_video_mixer_blend_yvyu; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_yvyu; + mix->fill_color = gst_video_mixer_fill_color_yvyu; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_I420: + mix->blend = gst_video_mixer_blend_i420; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_i420; + mix->fill_color = gst_video_mixer_fill_color_i420; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_YV12: + mix->blend = gst_video_mixer_blend_yv12; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_yv12; + mix->fill_color = gst_video_mixer_fill_color_yv12; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_NV12: + mix->blend = gst_video_mixer_blend_nv12; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_nv12; + mix->fill_color = gst_video_mixer_fill_color_nv12; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_NV21: + mix->blend = gst_video_mixer_blend_nv21; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_nv21; + mix->fill_color = gst_video_mixer_fill_color_nv21; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_Y41B: + mix->blend = gst_video_mixer_blend_y41b; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_y41b; + mix->fill_color = gst_video_mixer_fill_color_y41b; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_RGB: + mix->blend = gst_video_mixer_blend_rgb; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_rgb; + mix->fill_color = gst_video_mixer_fill_color_rgb; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_BGR: + mix->blend = gst_video_mixer_blend_bgr; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_bgr; + mix->fill_color = gst_video_mixer_fill_color_bgr; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_xRGB: + mix->blend = gst_video_mixer_blend_xrgb; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_xrgb; + mix->fill_color = gst_video_mixer_fill_color_xrgb; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_xBGR: + mix->blend = gst_video_mixer_blend_xbgr; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_xbgr; + mix->fill_color = gst_video_mixer_fill_color_xbgr; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_RGBx: + mix->blend = gst_video_mixer_blend_rgbx; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_rgbx; + mix->fill_color = gst_video_mixer_fill_color_rgbx; + ret = TRUE; + break; + case GST_VIDEO_FORMAT_BGRx: + mix->blend = gst_video_mixer_blend_bgrx; + mix->overlay = mix->blend; + mix->fill_checker = gst_video_mixer_fill_checker_bgrx; + mix->fill_color = gst_video_mixer_fill_color_bgrx; + ret = TRUE; + break; + default: + break; + } + GST_VIDEO_MIXER2_UNLOCK (mix); + + if (mix->current_caps == NULL || + gst_caps_is_equal (caps, mix->current_caps) == FALSE) { + gst_caps_replace (&mix->current_caps, caps); + mix->send_caps = TRUE; + } + +done: + return ret; +} + +static GstFlowReturn +gst_videomixer2_sink_clip (GstCollectPads * pads, + GstCollectData * data, GstBuffer * buf, GstBuffer ** outbuf, + GstVideoMixer2 * mix) +{ + GstVideoMixer2Pad *pad = GST_VIDEO_MIXER2_PAD (data->pad); + GstVideoMixer2Collect *mixcol = pad->mixcol; + GstClockTime start_time, end_time; + + start_time = GST_BUFFER_TIMESTAMP (buf); + if (start_time == -1) { + GST_ERROR_OBJECT (pad, "Timestamped buffers required!"); + gst_buffer_unref (buf); + return GST_FLOW_ERROR; + } + + end_time = GST_BUFFER_DURATION (buf); + if (end_time == -1 && GST_VIDEO_INFO_FPS_N (&pad->info) != 0) + end_time = + gst_util_uint64_scale_int_round (GST_SECOND, + GST_VIDEO_INFO_FPS_D (&pad->info), GST_VIDEO_INFO_FPS_N (&pad->info)); + if (end_time == -1) { + *outbuf = buf; + return GST_FLOW_OK; + } + + start_time = MAX (start_time, mixcol->collect.segment.start); + start_time = + gst_segment_to_running_time (&mixcol->collect.segment, + GST_FORMAT_TIME, start_time); + + end_time += GST_BUFFER_TIMESTAMP (buf); + if (mixcol->collect.segment.stop != -1) + end_time = MIN (end_time, mixcol->collect.segment.stop); + end_time = + gst_segment_to_running_time (&mixcol->collect.segment, + GST_FORMAT_TIME, end_time); + + /* Convert to the output segment rate */ + if (ABS (mix->segment.rate) != 1.0) { + start_time *= ABS (mix->segment.rate); + end_time *= ABS (mix->segment.rate); + } + + if (mixcol->buffer != NULL && end_time < mixcol->end_time) { + gst_buffer_unref (buf); + *outbuf = NULL; + return GST_FLOW_OK; + } + + *outbuf = buf; + return GST_FLOW_OK; +} + +static void +gst_videomixer2_flush (GstCollectPads * pads, GstVideoMixer2 * mix) +{ + if (mix->pending_tags) { + gst_tag_list_unref (mix->pending_tags); + mix->pending_tags = NULL; + } +} + +static gboolean +gst_videomixer2_sink_event (GstCollectPads * pads, GstCollectData * cdata, + GstEvent * event, GstVideoMixer2 * mix) +{ + GstVideoMixer2Pad *pad = GST_VIDEO_MIXER2_PAD (cdata->pad); + gboolean ret = TRUE, discard = FALSE; + + GST_DEBUG_OBJECT (pad, "Got %s event: %" GST_PTR_FORMAT, + GST_EVENT_TYPE_NAME (event), event); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_CAPS: + { + GstCaps *caps; + + gst_event_parse_caps (event, &caps); + ret = + gst_videomixer2_pad_sink_setcaps (GST_PAD (pad), GST_OBJECT (mix), + caps); + gst_event_unref (event); + event = NULL; + break; + } + case GST_EVENT_SEGMENT:{ + GstSegment seg; + gst_event_copy_segment (event, &seg); + + g_assert (seg.format == GST_FORMAT_TIME); + gst_videomixer2_reset_qos (mix); + break; + } + case GST_EVENT_FLUSH_STOP: + mix->newseg_pending = TRUE; + + gst_videomixer2_reset_qos (mix); + gst_buffer_replace (&pad->mixcol->buffer, NULL); + pad->mixcol->start_time = -1; + pad->mixcol->end_time = -1; + + mix->segment.position = -1; + mix->ts_offset = 0; + mix->nframes = 0; + break; + case GST_EVENT_TAG: + { + /* collect tags here so we can push them out when we collect data */ + GstTagList *tags; + + gst_event_parse_tag (event, &tags); + tags = gst_tag_list_merge (mix->pending_tags, tags, GST_TAG_MERGE_APPEND); + if (mix->pending_tags) + gst_tag_list_unref (mix->pending_tags); + mix->pending_tags = tags; + event = NULL; + break; + } + default: + break; + } + + if (event != NULL) + return gst_collect_pads_event_default (pads, cdata, event, discard); + + return ret; +} + +static gboolean +forward_event_func (GValue * item, GValue * ret, GstEvent * event) +{ + GstPad *pad = g_value_get_object (item); + gst_event_ref (event); + GST_LOG_OBJECT (pad, "About to send event %s", GST_EVENT_TYPE_NAME (event)); + if (!gst_pad_push_event (pad, event)) { + g_value_set_boolean (ret, FALSE); + GST_WARNING_OBJECT (pad, "Sending event %p (%s) failed.", + event, GST_EVENT_TYPE_NAME (event)); + } else { + GST_LOG_OBJECT (pad, "Sent event %p (%s).", + event, GST_EVENT_TYPE_NAME (event)); + } + return TRUE; +} + +static gboolean +gst_videomixer2_push_sink_event (GstVideoMixer2 * mix, GstEvent * event) +{ + GstIterator *it; + GValue vret = { 0 }; + + GST_LOG_OBJECT (mix, "Forwarding event %p (%s)", event, + GST_EVENT_TYPE_NAME (event)); + + g_value_init (&vret, G_TYPE_BOOLEAN); + g_value_set_boolean (&vret, TRUE); + it = gst_element_iterate_sink_pads (GST_ELEMENT_CAST (mix)); + gst_iterator_fold (it, (GstIteratorFoldFunction) forward_event_func, &vret, + event); + gst_iterator_free (it); + gst_event_unref (event); + + return g_value_get_boolean (&vret); +} + +/* GstElement vmethods */ +static GstStateChangeReturn +gst_videomixer2_change_state (GstElement * element, GstStateChange transition) +{ + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (element); + GstStateChangeReturn ret; + + switch (transition) { + case GST_STATE_CHANGE_READY_TO_PAUSED: + mix->send_stream_start = TRUE; + mix->send_caps = TRUE; + gst_segment_init (&mix->segment, GST_FORMAT_TIME); + gst_caps_replace (&mix->current_caps, NULL); + GST_LOG_OBJECT (mix, "starting collectpads"); + gst_collect_pads_start (mix->collect); + break; + case GST_STATE_CHANGE_PAUSED_TO_READY: + GST_LOG_OBJECT (mix, "stopping collectpads"); + gst_collect_pads_stop (mix->collect); + break; + default: + break; + } + + ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + + switch (transition) { + case GST_STATE_CHANGE_PAUSED_TO_READY: + gst_videomixer2_reset (mix); + break; + default: + break; + } + + return ret; +} + +static GstPad * +gst_videomixer2_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps) +{ + GstVideoMixer2 *mix; + GstVideoMixer2Pad *mixpad; + GstElementClass *klass = GST_ELEMENT_GET_CLASS (element); + + mix = GST_VIDEO_MIXER2 (element); + + if (templ == gst_element_class_get_pad_template (klass, "sink_%u")) { + guint serial = 0; + gchar *name = NULL; + GstVideoMixer2Collect *mixcol = NULL; + + GST_VIDEO_MIXER2_LOCK (mix); + if (req_name == NULL || strlen (req_name) < 6 + || !g_str_has_prefix (req_name, "sink_")) { + /* no name given when requesting the pad, use next available int */ + serial = mix->next_sinkpad++; + } else { + /* parse serial number from requested padname */ + serial = g_ascii_strtoull (&req_name[5], NULL, 10); + if (serial >= mix->next_sinkpad) + mix->next_sinkpad = serial + 1; + } + /* create new pad with the name */ + name = g_strdup_printf ("sink_%u", serial); + mixpad = g_object_new (GST_TYPE_VIDEO_MIXER2_PAD, "name", name, "direction", + templ->direction, "template", templ, NULL); + g_free (name); + + mixpad->zorder = mix->numpads; + mixpad->xpos = DEFAULT_PAD_XPOS; + mixpad->ypos = DEFAULT_PAD_YPOS; + mixpad->alpha = DEFAULT_PAD_ALPHA; + + mixcol = (GstVideoMixer2Collect *) + gst_collect_pads_add_pad (mix->collect, GST_PAD (mixpad), + sizeof (GstVideoMixer2Collect), + (GstCollectDataDestroyNotify) gst_videomixer2_collect_free, TRUE); + + /* Keep track of each other */ + mixcol->mixpad = mixpad; + mixpad->mixcol = mixcol; + + mixcol->start_time = -1; + mixcol->end_time = -1; + + /* Keep an internal list of mixpads for zordering */ + mix->sinkpads = g_slist_insert_sorted (mix->sinkpads, mixpad, + (GCompareFunc) pad_zorder_compare); + mix->numpads++; + GST_VIDEO_MIXER2_UNLOCK (mix); + } else { + return NULL; + } + + GST_DEBUG_OBJECT (element, "Adding pad %s", GST_PAD_NAME (mixpad)); + + /* add the pad to the element */ + gst_element_add_pad (element, GST_PAD (mixpad)); + gst_child_proxy_child_added (GST_CHILD_PROXY (mix), G_OBJECT (mixpad), + GST_OBJECT_NAME (mixpad)); + + return GST_PAD (mixpad); +} + +static void +gst_videomixer2_release_pad (GstElement * element, GstPad * pad) +{ + GstVideoMixer2 *mix = NULL; + GstVideoMixer2Pad *mixpad; + gboolean update_caps; + + mix = GST_VIDEO_MIXER2 (element); + + GST_VIDEO_MIXER2_LOCK (mix); + if (G_UNLIKELY (g_slist_find (mix->sinkpads, pad) == NULL)) { + g_warning ("Unknown pad %s", GST_PAD_NAME (pad)); + goto error; + } + + mixpad = GST_VIDEO_MIXER2_PAD (pad); + + if (mixpad->convert) + videomixer_videoconvert_convert_free (mixpad->convert); + mixpad->convert = NULL; + + mix->sinkpads = g_slist_remove (mix->sinkpads, pad); + gst_child_proxy_child_removed (GST_CHILD_PROXY (mix), G_OBJECT (mixpad), + GST_OBJECT_NAME (mixpad)); + mix->numpads--; + + GST_COLLECT_PADS_STREAM_LOCK (mix->collect); + gst_videomixer2_update_converters (mix); + GST_COLLECT_PADS_STREAM_UNLOCK (mix->collect); + + update_caps = GST_VIDEO_INFO_FORMAT (&mix->info) != GST_VIDEO_FORMAT_UNKNOWN; + GST_VIDEO_MIXER2_UNLOCK (mix); + + gst_collect_pads_remove_pad (mix->collect, pad); + + if (update_caps) + gst_videomixer2_update_src_caps (mix); + + gst_element_remove_pad (element, pad); + return; +error: + GST_VIDEO_MIXER2_UNLOCK (mix); +} + +/* GObject vmethods */ +static void +gst_videomixer2_finalize (GObject * o) +{ + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (o); + + gst_object_unref (mix->collect); + g_mutex_clear (&mix->lock); + g_mutex_clear (&mix->setcaps_lock); + + G_OBJECT_CLASS (parent_class)->finalize (o); +} + +static void +gst_videomixer2_dispose (GObject * o) +{ + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (o); + GSList *tmp; + + for (tmp = mix->sinkpads; tmp; tmp = tmp->next) { + GstVideoMixer2Pad *mixpad = tmp->data; + + if (mixpad->convert) + videomixer_videoconvert_convert_free (mixpad->convert); + mixpad->convert = NULL; + } + + if (mix->pending_tags) { + gst_tag_list_unref (mix->pending_tags); + mix->pending_tags = NULL; + } + + gst_caps_replace (&mix->current_caps, NULL); + + G_OBJECT_CLASS (parent_class)->dispose (o); +} + +static void +gst_videomixer2_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec) +{ + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (object); + + switch (prop_id) { + case PROP_BACKGROUND: + g_value_set_enum (value, mix->background); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_videomixer2_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec) +{ + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (object); + + switch (prop_id) { + case PROP_BACKGROUND: + mix->background = g_value_get_enum (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/* GstChildProxy implementation */ +static GObject * +gst_videomixer2_child_proxy_get_child_by_index (GstChildProxy * child_proxy, + guint index) +{ + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (child_proxy); + GObject *obj; + + GST_VIDEO_MIXER2_LOCK (mix); + if ((obj = g_slist_nth_data (mix->sinkpads, index))) + g_object_ref (obj); + GST_VIDEO_MIXER2_UNLOCK (mix); + return obj; +} + +static guint +gst_videomixer2_child_proxy_get_children_count (GstChildProxy * child_proxy) +{ + guint count = 0; + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (child_proxy); + + GST_VIDEO_MIXER2_LOCK (mix); + count = mix->numpads; + GST_VIDEO_MIXER2_UNLOCK (mix); + GST_INFO_OBJECT (mix, "Children Count: %d", count); + return count; +} + +static void +gst_videomixer2_child_proxy_init (gpointer g_iface, gpointer iface_data) +{ + GstChildProxyInterface *iface = g_iface; + + GST_INFO ("intializing child proxy interface"); + iface->get_child_by_index = gst_videomixer2_child_proxy_get_child_by_index; + iface->get_children_count = gst_videomixer2_child_proxy_get_children_count; +} + +static void +gst_videomixer2_constructed (GObject * obj) +{ + GstVideoMixer2 *mix = GST_VIDEO_MIXER2 (obj); + gchar *cp_name; + + cp_name = g_strconcat (GST_OBJECT_NAME (obj), "-collectpads", NULL); + gst_object_set_name (GST_OBJECT (mix->collect), cp_name); + g_free (cp_name); + + G_OBJECT_CLASS (gst_videomixer2_parent_class)->constructed (obj); +} + +/* GObject boilerplate */ +static void +gst_videomixer2_class_init (GstVideoMixer2Class * klass) +{ + GObjectClass *gobject_class = (GObjectClass *) klass; + GstElementClass *gstelement_class = (GstElementClass *) klass; + + gobject_class->constructed = gst_videomixer2_constructed; + gobject_class->finalize = gst_videomixer2_finalize; + gobject_class->dispose = gst_videomixer2_dispose; + + gobject_class->get_property = gst_videomixer2_get_property; + gobject_class->set_property = gst_videomixer2_set_property; + + g_object_class_install_property (gobject_class, PROP_BACKGROUND, + g_param_spec_enum ("background", "Background", "Background type", + GST_TYPE_VIDEO_MIXER2_BACKGROUND, + DEFAULT_BACKGROUND, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_videomixer2_request_new_pad); + gstelement_class->release_pad = + GST_DEBUG_FUNCPTR (gst_videomixer2_release_pad); + gstelement_class->change_state = + GST_DEBUG_FUNCPTR (gst_videomixer2_change_state); + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&src_factory)); + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&sink_factory)); + + gst_element_class_set_static_metadata (gstelement_class, "Video mixer 2", + "Filter/Editor/Video/Compositor", + "Mix multiple video streams", "Wim Taymans <wim@fluendo.com>, " + "Sebastian Dröge <sebastian.droege@collabora.co.uk>"); + + /* Register the pad class */ + g_type_class_ref (GST_TYPE_VIDEO_MIXER2_PAD); +} + +static void +gst_videomixer2_init (GstVideoMixer2 * mix) +{ + GstElementClass *klass = GST_ELEMENT_GET_CLASS (mix); + + mix->srcpad = + gst_pad_new_from_template (gst_element_class_get_pad_template (klass, + "src"), "src"); + gst_pad_set_query_function (GST_PAD (mix->srcpad), + GST_DEBUG_FUNCPTR (gst_videomixer2_src_query)); + gst_pad_set_event_function (GST_PAD (mix->srcpad), + GST_DEBUG_FUNCPTR (gst_videomixer2_src_event)); + gst_element_add_pad (GST_ELEMENT (mix), mix->srcpad); + + mix->collect = gst_collect_pads_new (); + gst_collect_pads_set_flush_function (mix->collect, + (GstCollectPadsFlushFunction) gst_videomixer2_flush, mix); + mix->background = DEFAULT_BACKGROUND; + mix->current_caps = NULL; + mix->pending_tags = NULL; + + gst_collect_pads_set_function (mix->collect, + (GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_videomixer2_collected), + mix); + gst_collect_pads_set_event_function (mix->collect, + (GstCollectPadsEventFunction) gst_videomixer2_sink_event, mix); + gst_collect_pads_set_query_function (mix->collect, + (GstCollectPadsQueryFunction) gst_videomixer2_sink_query, mix); + gst_collect_pads_set_clip_function (mix->collect, + (GstCollectPadsClipFunction) gst_videomixer2_sink_clip, mix); + + g_mutex_init (&mix->lock); + g_mutex_init (&mix->setcaps_lock); + /* initialize variables */ + gst_videomixer2_reset (mix); +} + +/* Element registration */ +static gboolean +plugin_init (GstPlugin * plugin) +{ + GST_DEBUG_CATEGORY_INIT (gst_videomixer2_debug, "videomixer", 0, + "video mixer"); + + gst_video_mixer_init_blend (); + + return gst_element_register (plugin, "videomixer", GST_RANK_PRIMARY, + GST_TYPE_VIDEO_MIXER2); +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + videomixer, + "Video mixer", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, + GST_PACKAGE_ORIGIN) diff --git a/gst/videomixer/videomixer2.h b/gst/videomixer/videomixer2.h new file mode 100755 index 0000000..8c6a65f --- /dev/null +++ b/gst/videomixer/videomixer2.h @@ -0,0 +1,133 @@ +/* Generic video mixer plugin + * Copyright (C) 2008 Wim Taymans <wim@fluendo.com> + * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_VIDEO_MIXER2_H__ +#define __GST_VIDEO_MIXER2_H__ + +#include <gst/gst.h> +#include <gst/video/video.h> + +#include "blend.h" +#include <gst/base/gstcollectpads.h> + +G_BEGIN_DECLS + +#define GST_TYPE_VIDEO_MIXER2 (gst_videomixer2_get_type()) +#define GST_VIDEO_MIXER2(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_MIXER2, GstVideoMixer2)) +#define GST_VIDEO_MIXER2_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_MIXER2, GstVideoMixer2Class)) +#define GST_IS_VIDEO_MIXER2(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_MIXER2)) +#define GST_IS_VIDEO_MIXER2_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_MIXER2)) + +typedef struct _GstVideoMixer2 GstVideoMixer2; +typedef struct _GstVideoMixer2Class GstVideoMixer2Class; + +/** + * GstVideoMixer2Background: + * @VIDEO_MIXER2_BACKGROUND_CHECKER: checker pattern background + * @VIDEO_MIXER2_BACKGROUND_BLACK: solid color black background + * @VIDEO_MIXER2_BACKGROUND_WHITE: solid color white background + * @VIDEO_MIXER2_BACKGROUND_TRANSPARENT: background is left transparent and layers are composited using "A OVER B" composition rules. This is only applicable to AYUV and ARGB (and variants) as it preserves the alpha channel and allows for further mixing. + * + * The different backgrounds videomixer can blend over. + */ +typedef enum +{ + VIDEO_MIXER2_BACKGROUND_CHECKER, + VIDEO_MIXER2_BACKGROUND_BLACK, + VIDEO_MIXER2_BACKGROUND_WHITE, + VIDEO_MIXER2_BACKGROUND_TRANSPARENT, +} +GstVideoMixer2Background; + +/** + * GstVideoMixer2: + * + * The opaque #GstVideoMixer2 structure. + */ +struct _GstVideoMixer2 +{ + GstElement element; + + /* < private > */ + + /* pad */ + GstPad *srcpad; + + /* Lock to prevent the state to change while blending */ + GMutex lock; + + /* Lock to prevent two src setcaps from happening at the same time */ + GMutex setcaps_lock; + + /* Sink pads using Collect Pads 2*/ + GstCollectPads *collect; + + /* sinkpads, a GSList of GstVideoMixer2Pads */ + GSList *sinkpads; + gint numpads; + /* Next available sinkpad index */ + guint next_sinkpad; + + /* Output caps */ + GstVideoInfo info; + + /* current caps */ + GstCaps *current_caps; + gboolean send_caps; + + gboolean newseg_pending; + + GstVideoMixer2Background background; + + /* Current downstream segment */ + GstSegment segment; + GstClockTime ts_offset; + guint64 nframes; + + /* QoS stuff */ + gdouble proportion; + GstClockTime earliest_time; + guint64 qos_processed, qos_dropped; + + BlendFunction blend, overlay; + FillCheckerFunction fill_checker; + FillColorFunction fill_color; + + gboolean send_stream_start; + + /* latency */ + gboolean live; + + GstTagList *pending_tags; +}; + +struct _GstVideoMixer2Class +{ + GstElementClass parent_class; +}; + +GType gst_videomixer2_get_type (void); + +G_END_DECLS +#endif /* __GST_VIDEO_MIXER2_H__ */ diff --git a/gst/videomixer/videomixer2pad.h b/gst/videomixer/videomixer2pad.h new file mode 100644 index 0000000..bce0aee --- /dev/null +++ b/gst/videomixer/videomixer2pad.h @@ -0,0 +1,85 @@ +/* Generic video mixer plugin + * Copyright (C) 2008 Wim Taymans <wim@fluendo.com> + * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_VIDEO_MIXER2_PAD_H__ +#define __GST_VIDEO_MIXER2_PAD_H__ + +#include <gst/gst.h> +#include <gst/video/video.h> + +#include <gst/base/gstcollectpads.h> + +#include "videoconvert.h" + +G_BEGIN_DECLS + +#define GST_TYPE_VIDEO_MIXER2_PAD (gst_videomixer2_pad_get_type()) +#define GST_VIDEO_MIXER2_PAD(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_MIXER2_PAD, GstVideoMixer2Pad)) +#define GST_VIDEO_MIXER2_PAD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_MIXER_PAD, GstVideoMixer2PadClass)) +#define GST_IS_VIDEO_MIXER2_PAD(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_MIXER2_PAD)) +#define GST_IS_VIDEO_MIXER2_PAD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_MIXER2_PAD)) + +typedef struct _GstVideoMixer2Pad GstVideoMixer2Pad; +typedef struct _GstVideoMixer2PadClass GstVideoMixer2PadClass; +typedef struct _GstVideoMixer2Collect GstVideoMixer2Collect; + +/** + * GstVideoMixer2Pad: + * + * The opaque #GstVideoMixer2Pad structure. + */ +struct _GstVideoMixer2Pad +{ + GstPad parent; + + /* < private > */ + + /* caps */ + GstVideoInfo info; + + /* properties */ + gint xpos, ypos; + guint zorder; + gdouble alpha; + + GstVideoMixer2Collect *mixcol; + + /* caps used for conversion if needed */ + GstVideoInfo conversion_info; + + /* Converter, if NULL no conversion is done */ + VideoConvert *convert; + + gboolean need_conversion_update; +}; + +struct _GstVideoMixer2PadClass +{ + GstPadClass parent_class; +}; + +GType gst_videomixer2_pad_get_type (void); + +G_END_DECLS +#endif /* __GST_VIDEO_MIXER2_PAD_H__ */ diff --git a/gst/videomixer/videomixerorc-dist.c b/gst/videomixer/videomixerorc-dist.c new file mode 100755 index 0000000..b114731 --- /dev/null +++ b/gst/videomixer/videomixerorc-dist.c @@ -0,0 +1,11255 @@ + +/* autogenerated from videomixerorc.orc */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <glib.h> + +#ifndef _ORC_INTEGER_TYPEDEFS_ +#define _ORC_INTEGER_TYPEDEFS_ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include <stdint.h> +typedef int8_t orc_int8; +typedef int16_t orc_int16; +typedef int32_t orc_int32; +typedef int64_t orc_int64; +typedef uint8_t orc_uint8; +typedef uint16_t orc_uint16; +typedef uint32_t orc_uint32; +typedef uint64_t orc_uint64; +#define ORC_UINT64_C(x) UINT64_C(x) +#elif defined(_MSC_VER) +typedef signed __int8 orc_int8; +typedef signed __int16 orc_int16; +typedef signed __int32 orc_int32; +typedef signed __int64 orc_int64; +typedef unsigned __int8 orc_uint8; +typedef unsigned __int16 orc_uint16; +typedef unsigned __int32 orc_uint32; +typedef unsigned __int64 orc_uint64; +#define ORC_UINT64_C(x) (x##Ui64) +#define inline __inline +#else +#include <limits.h> +typedef signed char orc_int8; +typedef short orc_int16; +typedef int orc_int32; +typedef unsigned char orc_uint8; +typedef unsigned short orc_uint16; +typedef unsigned int orc_uint32; +#if INT_MAX == LONG_MAX +typedef long long orc_int64; +typedef unsigned long long orc_uint64; +#define ORC_UINT64_C(x) (x##ULL) +#else +typedef long orc_int64; +typedef unsigned long orc_uint64; +#define ORC_UINT64_C(x) (x##UL) +#endif +#endif +typedef union +{ + orc_int16 i; + orc_int8 x2[2]; +} orc_union16; +typedef union +{ + orc_int32 i; + float f; + orc_int16 x2[2]; + orc_int8 x4[4]; +} orc_union32; +typedef union +{ + orc_int64 i; + double f; + orc_int32 x2[2]; + float x2f[2]; + orc_int16 x4[4]; +} orc_union64; +#endif +#ifndef ORC_RESTRICT +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define ORC_RESTRICT restrict +#elif defined(__GNUC__) && __GNUC__ >= 4 +#define ORC_RESTRICT __restrict__ +#else +#define ORC_RESTRICT +#endif +#endif + +#ifndef ORC_INTERNAL +#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) +#define ORC_INTERNAL __attribute__((visibility("hidden"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) +#define ORC_INTERNAL __hidden +#elif defined (__GNUC__) +#define ORC_INTERNAL __attribute__((visibility("hidden"))) +#else +#define ORC_INTERNAL +#endif +#endif + + +#ifndef DISABLE_ORC +#include <orc/orc.h> +#endif +void video_mixer_orc_splat_u32 (guint32 * ORC_RESTRICT d1, int p1, int n); +void video_mixer_orc_memcpy_u32 (guint32 * ORC_RESTRICT d1, + const guint32 * ORC_RESTRICT s1, int n); +void video_mixer_orc_blend_u8 (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m); +void video_mixer_orc_blend_argb (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m); +void video_mixer_orc_blend_bgra (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m); +void video_mixer_orc_overlay_argb (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m); +void video_mixer_orc_overlay_bgra (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m); +void videomixer_video_convert_orc_memcpy_2d (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_I420_UYVY (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, + const guint8 * ORC_RESTRICT s4, int n); +void videomixer_video_convert_orc_convert_I420_YUY2 (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, + const guint8 * ORC_RESTRICT s4, int n); +void videomixer_video_convert_orc_convert_I420_AYUV (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, + const guint8 * ORC_RESTRICT s4, int n); +void videomixer_video_convert_orc_convert_YUY2_I420 (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, guint8 * ORC_RESTRICT d3, + guint8 * ORC_RESTRICT d4, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, int n); +void videomixer_video_convert_orc_convert_UYVY_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_420_422 (guint8 * + ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_420_444 (guint8 * + ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_422_444 (guint8 * + ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_444_422 (guint8 * + ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_444_420 (guint8 * + ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_422_420 (guint8 * + ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m); +void videomixer_video_convert_orc_convert_YUY2_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_UYVY_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_YUY2_Y42B (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_UYVY_Y42B (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_YUY2_Y444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_UYVY_Y444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_UYVY_I420 (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, guint8 * ORC_RESTRICT d3, + guint8 * ORC_RESTRICT d4, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, int n); +void videomixer_video_convert_orc_convert_AYUV_I420 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, guint8 * ORC_RESTRICT d4, + int d4_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_UYVY (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_Y42B (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_Y444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y42B_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y42B_UYVY (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y42B_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y444_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y444_UYVY (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y444_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_ARGB (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_BGRA (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_ABGR (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_RGBA (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m); +void videomixer_video_convert_orc_convert_I420_BGRA (guint8 * ORC_RESTRICT d1, + const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, + const guint8 * ORC_RESTRICT s3, int p1, int p2, int p3, int p4, int p5, + int n); + + +/* begin Orc C target preamble */ +#define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x))) +#define ORC_ABS(a) ((a)<0 ? -(a) : (a)) +#define ORC_MIN(a,b) ((a)<(b) ? (a) : (b)) +#define ORC_MAX(a,b) ((a)>(b) ? (a) : (b)) +#define ORC_SB_MAX 127 +#define ORC_SB_MIN (-1-ORC_SB_MAX) +#define ORC_UB_MAX 255 +#define ORC_UB_MIN 0 +#define ORC_SW_MAX 32767 +#define ORC_SW_MIN (-1-ORC_SW_MAX) +#define ORC_UW_MAX 65535 +#define ORC_UW_MIN 0 +#define ORC_SL_MAX 2147483647 +#define ORC_SL_MIN (-1-ORC_SL_MAX) +#define ORC_UL_MAX 4294967295U +#define ORC_UL_MIN 0 +#define ORC_CLAMP_SB(x) ORC_CLAMP(x,ORC_SB_MIN,ORC_SB_MAX) +#define ORC_CLAMP_UB(x) ORC_CLAMP(x,ORC_UB_MIN,ORC_UB_MAX) +#define ORC_CLAMP_SW(x) ORC_CLAMP(x,ORC_SW_MIN,ORC_SW_MAX) +#define ORC_CLAMP_UW(x) ORC_CLAMP(x,ORC_UW_MIN,ORC_UW_MAX) +#define ORC_CLAMP_SL(x) ORC_CLAMP(x,ORC_SL_MIN,ORC_SL_MAX) +#define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX) +#define ORC_SWAP_W(x) ((((x)&0xffU)<<8) | (((x)&0xff00U)>>8)) +#define ORC_SWAP_L(x) ((((x)&0xffU)<<24) | (((x)&0xff00U)<<8) | (((x)&0xff0000U)>>8) | (((x)&0xff000000U)>>24)) +#define ORC_SWAP_Q(x) ((((x)&ORC_UINT64_C(0xff))<<56) | (((x)&ORC_UINT64_C(0xff00))<<40) | (((x)&ORC_UINT64_C(0xff0000))<<24) | (((x)&ORC_UINT64_C(0xff000000))<<8) | (((x)&ORC_UINT64_C(0xff00000000))>>8) | (((x)&ORC_UINT64_C(0xff0000000000))>>24) | (((x)&ORC_UINT64_C(0xff000000000000))>>40) | (((x)&ORC_UINT64_C(0xff00000000000000))>>56)) +#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset))) +#define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff)) +#define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0)) +#define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == 0) ? ORC_UINT64_C(0xfff0000000000000) : ORC_UINT64_C(0xffffffffffffffff))) +#define ORC_ISNAN_DOUBLE(x) ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == ORC_UINT64_C(0x7ff0000000000000)) && (((x)&ORC_UINT64_C(0x000fffffffffffff)) != 0)) +#ifndef ORC_RESTRICT +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define ORC_RESTRICT restrict +#elif defined(__GNUC__) && __GNUC__ >= 4 +#define ORC_RESTRICT __restrict__ +#else +#define ORC_RESTRICT +#endif +#endif +/* end Orc C target preamble */ + + + +/* video_mixer_orc_splat_u32 */ +#ifdef DISABLE_ORC +void +video_mixer_orc_splat_u32 (guint32 * ORC_RESTRICT d1, int p1, int n) +{ + int i; + orc_union32 *ORC_RESTRICT ptr0; + orc_union32 var32; + orc_union32 var33; + + ptr0 = (orc_union32 *) d1; + + /* 0: loadpl */ + var32.i = p1; + + for (i = 0; i < n; i++) { + /* 1: copyl */ + var33.i = var32.i; + /* 2: storel */ + ptr0[i] = var33; + } + +} + +#else +static void +_backup_video_mixer_orc_splat_u32 (OrcExecutor * ORC_RESTRICT ex) +{ + int i; + int n = ex->n; + orc_union32 *ORC_RESTRICT ptr0; + orc_union32 var32; + orc_union32 var33; + + ptr0 = (orc_union32 *) ex->arrays[0]; + + /* 0: loadpl */ + var32.i = ex->params[24]; + + for (i = 0; i < n; i++) { + /* 1: copyl */ + var33.i = var32.i; + /* 2: storel */ + ptr0[i] = var33; + } + +} + +void +video_mixer_orc_splat_u32 (guint32 * ORC_RESTRICT d1, int p1, int n) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 9, 25, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95, 111, + 114, 99, 95, 115, 112, 108, 97, 116, 95, 117, 51, 50, 11, 4, 4, 16, + 4, 112, 0, 24, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, _backup_video_mixer_orc_splat_u32); +#else + p = orc_program_new (); + orc_program_set_name (p, "video_mixer_orc_splat_u32"); + orc_program_set_backup_function (p, _backup_video_mixer_orc_splat_u32); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_parameter (p, 4, "p1"); + + orc_program_append_2 (p, "copyl", 0, ORC_VAR_D1, ORC_VAR_P1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_P1] = p1; + + func = c->exec; + func (ex); +} +#endif + + +/* video_mixer_orc_memcpy_u32 */ +#ifdef DISABLE_ORC +void +video_mixer_orc_memcpy_u32 (guint32 * ORC_RESTRICT d1, + const guint32 * ORC_RESTRICT s1, int n) +{ + int i; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var32; + orc_union32 var33; + + ptr0 = (orc_union32 *) d1; + ptr4 = (orc_union32 *) s1; + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var32 = ptr4[i]; + /* 1: copyl */ + var33.i = var32.i; + /* 2: storel */ + ptr0[i] = var33; + } + +} + +#else +static void +_backup_video_mixer_orc_memcpy_u32 (OrcExecutor * ORC_RESTRICT ex) +{ + int i; + int n = ex->n; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var32; + orc_union32 var33; + + ptr0 = (orc_union32 *) ex->arrays[0]; + ptr4 = (orc_union32 *) ex->arrays[4]; + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var32 = ptr4[i]; + /* 1: copyl */ + var33.i = var32.i; + /* 2: storel */ + ptr0[i] = var33; + } + +} + +void +video_mixer_orc_memcpy_u32 (guint32 * ORC_RESTRICT d1, + const guint32 * ORC_RESTRICT s1, int n) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 9, 26, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95, 111, + 114, 99, 95, 109, 101, 109, 99, 112, 121, 95, 117, 51, 50, 11, 4, 4, + 12, 4, 4, 112, 0, 4, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, _backup_video_mixer_orc_memcpy_u32); +#else + p = orc_program_new (); + orc_program_set_name (p, "video_mixer_orc_memcpy_u32"); + orc_program_set_backup_function (p, _backup_video_mixer_orc_memcpy_u32); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + + orc_program_append_2 (p, "copyl", 0, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->arrays[ORC_VAR_S1] = (void *) s1; + + func = c->exec; + func (ex); +} +#endif + + +/* video_mixer_orc_blend_u8 */ +#ifdef DISABLE_ORC +void +video_mixer_orc_blend_u8 (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m) +{ + int i; + int j; + orc_int8 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + orc_int8 var34; + orc_int8 var35; + orc_union16 var36; + orc_int8 var37; + orc_union16 var38; + orc_union16 var39; + orc_union16 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + orc_union16 var44; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 5: loadpw */ + var36.i = p1; + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var34 = ptr0[i]; + /* 1: convubw */ + var38.i = (orc_uint8) var34; + /* 2: loadb */ + var35 = ptr4[i]; + /* 3: convubw */ + var39.i = (orc_uint8) var35; + /* 4: subw */ + var40.i = var39.i - var38.i; + /* 6: mullw */ + var41.i = (var40.i * var36.i) & 0xffff; + /* 7: shlw */ + var42.i = ((orc_uint16) var38.i) << 8; + /* 8: addw */ + var43.i = var42.i + var41.i; + /* 9: shruw */ + var44.i = ((orc_uint16) var43.i) >> 8; + /* 10: convsuswb */ + var37 = ORC_CLAMP_UB (var44.i); + /* 11: storeb */ + ptr0[i] = var37; + } + } + +} + +#else +static void +_backup_video_mixer_orc_blend_u8 (OrcExecutor * ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_int8 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + orc_int8 var34; + orc_int8 var35; + orc_union16 var36; + orc_int8 var37; + orc_union16 var38; + orc_union16 var39; + orc_union16 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + orc_union16 var44; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 5: loadpw */ + var36.i = ex->params[24]; + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var34 = ptr0[i]; + /* 1: convubw */ + var38.i = (orc_uint8) var34; + /* 2: loadb */ + var35 = ptr4[i]; + /* 3: convubw */ + var39.i = (orc_uint8) var35; + /* 4: subw */ + var40.i = var39.i - var38.i; + /* 6: mullw */ + var41.i = (var40.i * var36.i) & 0xffff; + /* 7: shlw */ + var42.i = ((orc_uint16) var38.i) << 8; + /* 8: addw */ + var43.i = var42.i + var41.i; + /* 9: shruw */ + var44.i = ((orc_uint16) var43.i) >> 8; + /* 10: convsuswb */ + var37 = ORC_CLAMP_UB (var44.i); + /* 11: storeb */ + ptr0[i] = var37; + } + } + +} + +void +video_mixer_orc_blend_u8 (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 24, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95, + 111, 114, 99, 95, 98, 108, 101, 110, 100, 95, 117, 56, 11, 1, 1, 12, + 1, 1, 14, 1, 8, 0, 0, 0, 16, 2, 20, 2, 20, 2, 150, 32, + 0, 150, 33, 4, 98, 33, 33, 32, 89, 33, 33, 24, 93, 32, 32, 16, + 70, 33, 32, 33, 95, 33, 33, 16, 160, 0, 33, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_u8); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, "video_mixer_orc_blend_u8"); + orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_u8); + orc_program_add_destination (p, 1, "d1"); + orc_program_add_source (p, 1, "s1"); + orc_program_add_constant (p, 1, 0x00000008, "c1"); + orc_program_add_parameter (p, 2, "p1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + + orc_program_append_2 (p, "convubw", 0, ORC_VAR_T1, ORC_VAR_D1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 0, ORC_VAR_T2, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "subw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_T1, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "shlw", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "addw", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_T2, + ORC_VAR_D1); + orc_program_append_2 (p, "shruw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "convsuswb", 0, ORC_VAR_D1, ORC_VAR_T2, + ORC_VAR_D1, ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->params[ORC_VAR_P1] = p1; + + func = c->exec; + func (ex); +} +#endif + + +/* video_mixer_orc_blend_argb */ +#ifdef DISABLE_ORC +void +video_mixer_orc_blend_argb (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union64 var39; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var40; +#else + orc_union32 var40; +#endif + orc_union32 var41; + orc_union16 var42; + orc_int8 var43; + orc_union32 var44; + orc_union64 var45; + orc_union64 var46; + orc_union64 var47; + orc_union64 var48; + orc_union32 var49; + orc_union64 var50; + orc_union64 var51; + orc_union64 var52; + orc_union64 var53; + orc_union64 var54; + orc_union32 var55; + orc_union32 var56; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 5: loadpw */ + var39.x4[0] = p1; + var39.x4[1] = p1; + var39.x4[2] = p1; + var39.x4[3] = p1; + /* 16: loadpl */ + var40.i = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var41 = ptr4[i]; + /* 1: convlw */ + var42.i = var41.i; + /* 2: convwb */ + var43 = var42.i; + /* 3: splatbl */ + var44.i = + ((((orc_uint32) var43) & 0xff) << 24) | ((((orc_uint32) var43) & 0xff) + << 16) | ((((orc_uint32) var43) & 0xff) << 8) | (((orc_uint32) var43) + & 0xff); + /* 4: convubw */ + var45.x4[0] = (orc_uint8) var44.x4[0]; + var45.x4[1] = (orc_uint8) var44.x4[1]; + var45.x4[2] = (orc_uint8) var44.x4[2]; + var45.x4[3] = (orc_uint8) var44.x4[3]; + /* 6: mullw */ + var46.x4[0] = (var45.x4[0] * var39.x4[0]) & 0xffff; + var46.x4[1] = (var45.x4[1] * var39.x4[1]) & 0xffff; + var46.x4[2] = (var45.x4[2] * var39.x4[2]) & 0xffff; + var46.x4[3] = (var45.x4[3] * var39.x4[3]) & 0xffff; + /* 7: shruw */ + var47.x4[0] = ((orc_uint16) var46.x4[0]) >> 8; + var47.x4[1] = ((orc_uint16) var46.x4[1]) >> 8; + var47.x4[2] = ((orc_uint16) var46.x4[2]) >> 8; + var47.x4[3] = ((orc_uint16) var46.x4[3]) >> 8; + /* 8: convubw */ + var48.x4[0] = (orc_uint8) var41.x4[0]; + var48.x4[1] = (orc_uint8) var41.x4[1]; + var48.x4[2] = (orc_uint8) var41.x4[2]; + var48.x4[3] = (orc_uint8) var41.x4[3]; + /* 9: loadl */ + var49 = ptr0[i]; + /* 10: convubw */ + var50.x4[0] = (orc_uint8) var49.x4[0]; + var50.x4[1] = (orc_uint8) var49.x4[1]; + var50.x4[2] = (orc_uint8) var49.x4[2]; + var50.x4[3] = (orc_uint8) var49.x4[3]; + /* 11: subw */ + var51.x4[0] = var48.x4[0] - var50.x4[0]; + var51.x4[1] = var48.x4[1] - var50.x4[1]; + var51.x4[2] = var48.x4[2] - var50.x4[2]; + var51.x4[3] = var48.x4[3] - var50.x4[3]; + /* 12: mullw */ + var52.x4[0] = (var51.x4[0] * var47.x4[0]) & 0xffff; + var52.x4[1] = (var51.x4[1] * var47.x4[1]) & 0xffff; + var52.x4[2] = (var51.x4[2] * var47.x4[2]) & 0xffff; + var52.x4[3] = (var51.x4[3] * var47.x4[3]) & 0xffff; + /* 13: div255w */ + var53.x4[0] = + ((orc_uint16) (((orc_uint16) (var52.x4[0] + 128)) + + (((orc_uint16) (var52.x4[0] + 128)) >> 8))) >> 8; + var53.x4[1] = + ((orc_uint16) (((orc_uint16) (var52.x4[1] + 128)) + + (((orc_uint16) (var52.x4[1] + 128)) >> 8))) >> 8; + var53.x4[2] = + ((orc_uint16) (((orc_uint16) (var52.x4[2] + 128)) + + (((orc_uint16) (var52.x4[2] + 128)) >> 8))) >> 8; + var53.x4[3] = + ((orc_uint16) (((orc_uint16) (var52.x4[3] + 128)) + + (((orc_uint16) (var52.x4[3] + 128)) >> 8))) >> 8; + /* 14: addw */ + var54.x4[0] = var50.x4[0] + var53.x4[0]; + var54.x4[1] = var50.x4[1] + var53.x4[1]; + var54.x4[2] = var50.x4[2] + var53.x4[2]; + var54.x4[3] = var50.x4[3] + var53.x4[3]; + /* 15: convwb */ + var55.x4[0] = var54.x4[0]; + var55.x4[1] = var54.x4[1]; + var55.x4[2] = var54.x4[2]; + var55.x4[3] = var54.x4[3]; + /* 17: orl */ + var56.i = var55.i | var40.i; + /* 18: storel */ + ptr0[i] = var56; + } + } + +} + +#else +static void +_backup_video_mixer_orc_blend_argb (OrcExecutor * ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union64 var39; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var40; +#else + orc_union32 var40; +#endif + orc_union32 var41; + orc_union16 var42; + orc_int8 var43; + orc_union32 var44; + orc_union64 var45; + orc_union64 var46; + orc_union64 var47; + orc_union64 var48; + orc_union32 var49; + orc_union64 var50; + orc_union64 var51; + orc_union64 var52; + orc_union64 var53; + orc_union64 var54; + orc_union32 var55; + orc_union32 var56; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 5: loadpw */ + var39.x4[0] = ex->params[24]; + var39.x4[1] = ex->params[24]; + var39.x4[2] = ex->params[24]; + var39.x4[3] = ex->params[24]; + /* 16: loadpl */ + var40.i = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var41 = ptr4[i]; + /* 1: convlw */ + var42.i = var41.i; + /* 2: convwb */ + var43 = var42.i; + /* 3: splatbl */ + var44.i = + ((((orc_uint32) var43) & 0xff) << 24) | ((((orc_uint32) var43) & 0xff) + << 16) | ((((orc_uint32) var43) & 0xff) << 8) | (((orc_uint32) var43) + & 0xff); + /* 4: convubw */ + var45.x4[0] = (orc_uint8) var44.x4[0]; + var45.x4[1] = (orc_uint8) var44.x4[1]; + var45.x4[2] = (orc_uint8) var44.x4[2]; + var45.x4[3] = (orc_uint8) var44.x4[3]; + /* 6: mullw */ + var46.x4[0] = (var45.x4[0] * var39.x4[0]) & 0xffff; + var46.x4[1] = (var45.x4[1] * var39.x4[1]) & 0xffff; + var46.x4[2] = (var45.x4[2] * var39.x4[2]) & 0xffff; + var46.x4[3] = (var45.x4[3] * var39.x4[3]) & 0xffff; + /* 7: shruw */ + var47.x4[0] = ((orc_uint16) var46.x4[0]) >> 8; + var47.x4[1] = ((orc_uint16) var46.x4[1]) >> 8; + var47.x4[2] = ((orc_uint16) var46.x4[2]) >> 8; + var47.x4[3] = ((orc_uint16) var46.x4[3]) >> 8; + /* 8: convubw */ + var48.x4[0] = (orc_uint8) var41.x4[0]; + var48.x4[1] = (orc_uint8) var41.x4[1]; + var48.x4[2] = (orc_uint8) var41.x4[2]; + var48.x4[3] = (orc_uint8) var41.x4[3]; + /* 9: loadl */ + var49 = ptr0[i]; + /* 10: convubw */ + var50.x4[0] = (orc_uint8) var49.x4[0]; + var50.x4[1] = (orc_uint8) var49.x4[1]; + var50.x4[2] = (orc_uint8) var49.x4[2]; + var50.x4[3] = (orc_uint8) var49.x4[3]; + /* 11: subw */ + var51.x4[0] = var48.x4[0] - var50.x4[0]; + var51.x4[1] = var48.x4[1] - var50.x4[1]; + var51.x4[2] = var48.x4[2] - var50.x4[2]; + var51.x4[3] = var48.x4[3] - var50.x4[3]; + /* 12: mullw */ + var52.x4[0] = (var51.x4[0] * var47.x4[0]) & 0xffff; + var52.x4[1] = (var51.x4[1] * var47.x4[1]) & 0xffff; + var52.x4[2] = (var51.x4[2] * var47.x4[2]) & 0xffff; + var52.x4[3] = (var51.x4[3] * var47.x4[3]) & 0xffff; + /* 13: div255w */ + var53.x4[0] = + ((orc_uint16) (((orc_uint16) (var52.x4[0] + 128)) + + (((orc_uint16) (var52.x4[0] + 128)) >> 8))) >> 8; + var53.x4[1] = + ((orc_uint16) (((orc_uint16) (var52.x4[1] + 128)) + + (((orc_uint16) (var52.x4[1] + 128)) >> 8))) >> 8; + var53.x4[2] = + ((orc_uint16) (((orc_uint16) (var52.x4[2] + 128)) + + (((orc_uint16) (var52.x4[2] + 128)) >> 8))) >> 8; + var53.x4[3] = + ((orc_uint16) (((orc_uint16) (var52.x4[3] + 128)) + + (((orc_uint16) (var52.x4[3] + 128)) >> 8))) >> 8; + /* 14: addw */ + var54.x4[0] = var50.x4[0] + var53.x4[0]; + var54.x4[1] = var50.x4[1] + var53.x4[1]; + var54.x4[2] = var50.x4[2] + var53.x4[2]; + var54.x4[3] = var50.x4[3] + var53.x4[3]; + /* 15: convwb */ + var55.x4[0] = var54.x4[0]; + var55.x4[1] = var54.x4[1]; + var55.x4[2] = var54.x4[2]; + var55.x4[3] = var54.x4[3]; + /* 17: orl */ + var56.i = var55.i | var40.i; + /* 18: storel */ + ptr0[i] = var56; + } + } + +} + +void +video_mixer_orc_blend_argb (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 26, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95, + 111, 114, 99, 95, 98, 108, 101, 110, 100, 95, 97, 114, 103, 98, 11, 4, + 4, 12, 4, 4, 14, 4, 255, 0, 0, 0, 14, 2, 8, 0, 0, 0, + 16, 2, 20, 4, 20, 2, 20, 1, 20, 4, 20, 8, 20, 8, 20, 8, + 113, 32, 4, 163, 33, 32, 157, 34, 33, 152, 35, 34, 21, 2, 150, 38, + 35, 21, 2, 89, 38, 38, 24, 21, 2, 95, 38, 38, 17, 21, 2, 150, + 37, 32, 113, 32, 0, 21, 2, 150, 36, 32, 21, 2, 98, 37, 37, 36, + 21, 2, 89, 37, 37, 38, 21, 2, 80, 37, 37, 21, 2, 70, 36, 36, + 37, 21, 2, 157, 32, 36, 123, 32, 32, 16, 128, 0, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_argb); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, "video_mixer_orc_blend_argb"); + orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_argb); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_constant (p, 4, 0x000000ff, "c1"); + orc_program_add_constant (p, 2, 0x00000008, "c2"); + orc_program_add_parameter (p, 2, "p1"); + orc_program_add_temporary (p, 4, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 1, "t3"); + orc_program_add_temporary (p, 4, "t4"); + orc_program_add_temporary (p, 8, "t5"); + orc_program_add_temporary (p, 8, "t6"); + orc_program_add_temporary (p, 8, "t7"); + + orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convlw", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 0, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbl", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T7, ORC_VAR_T4, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "shruw", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_C2, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T6, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_D1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T5, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "subw", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_T7, + ORC_VAR_D1); + orc_program_append_2 (p, "div255w", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "addw", 2, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_T6, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 2, ORC_VAR_T1, ORC_VAR_T5, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "orl", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "storel", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->params[ORC_VAR_P1] = p1; + + func = c->exec; + func (ex); +} +#endif + + +/* video_mixer_orc_blend_bgra */ +#ifdef DISABLE_ORC +void +video_mixer_orc_blend_bgra (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union64 var40; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var41; +#else + orc_union32 var41; +#endif + orc_union32 var42; + orc_union32 var43; + orc_union16 var44; + orc_int8 var45; + orc_union32 var46; + orc_union64 var47; + orc_union64 var48; + orc_union64 var49; + orc_union64 var50; + orc_union32 var51; + orc_union64 var52; + orc_union64 var53; + orc_union64 var54; + orc_union64 var55; + orc_union64 var56; + orc_union32 var57; + orc_union32 var58; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 6: loadpw */ + var40.x4[0] = p1; + var40.x4[1] = p1; + var40.x4[2] = p1; + var40.x4[3] = p1; + /* 17: loadpl */ + var41.i = (int) 0xff000000; /* -16777216 or 2.11371e-314f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var42 = ptr4[i]; + /* 1: shrul */ + var43.i = ((orc_uint32) var42.i) >> 24; + /* 2: convlw */ + var44.i = var43.i; + /* 3: convwb */ + var45 = var44.i; + /* 4: splatbl */ + var46.i = + ((((orc_uint32) var45) & 0xff) << 24) | ((((orc_uint32) var45) & 0xff) + << 16) | ((((orc_uint32) var45) & 0xff) << 8) | (((orc_uint32) var45) + & 0xff); + /* 5: convubw */ + var47.x4[0] = (orc_uint8) var46.x4[0]; + var47.x4[1] = (orc_uint8) var46.x4[1]; + var47.x4[2] = (orc_uint8) var46.x4[2]; + var47.x4[3] = (orc_uint8) var46.x4[3]; + /* 7: mullw */ + var48.x4[0] = (var47.x4[0] * var40.x4[0]) & 0xffff; + var48.x4[1] = (var47.x4[1] * var40.x4[1]) & 0xffff; + var48.x4[2] = (var47.x4[2] * var40.x4[2]) & 0xffff; + var48.x4[3] = (var47.x4[3] * var40.x4[3]) & 0xffff; + /* 8: shruw */ + var49.x4[0] = ((orc_uint16) var48.x4[0]) >> 8; + var49.x4[1] = ((orc_uint16) var48.x4[1]) >> 8; + var49.x4[2] = ((orc_uint16) var48.x4[2]) >> 8; + var49.x4[3] = ((orc_uint16) var48.x4[3]) >> 8; + /* 9: convubw */ + var50.x4[0] = (orc_uint8) var42.x4[0]; + var50.x4[1] = (orc_uint8) var42.x4[1]; + var50.x4[2] = (orc_uint8) var42.x4[2]; + var50.x4[3] = (orc_uint8) var42.x4[3]; + /* 10: loadl */ + var51 = ptr0[i]; + /* 11: convubw */ + var52.x4[0] = (orc_uint8) var51.x4[0]; + var52.x4[1] = (orc_uint8) var51.x4[1]; + var52.x4[2] = (orc_uint8) var51.x4[2]; + var52.x4[3] = (orc_uint8) var51.x4[3]; + /* 12: subw */ + var53.x4[0] = var50.x4[0] - var52.x4[0]; + var53.x4[1] = var50.x4[1] - var52.x4[1]; + var53.x4[2] = var50.x4[2] - var52.x4[2]; + var53.x4[3] = var50.x4[3] - var52.x4[3]; + /* 13: mullw */ + var54.x4[0] = (var53.x4[0] * var49.x4[0]) & 0xffff; + var54.x4[1] = (var53.x4[1] * var49.x4[1]) & 0xffff; + var54.x4[2] = (var53.x4[2] * var49.x4[2]) & 0xffff; + var54.x4[3] = (var53.x4[3] * var49.x4[3]) & 0xffff; + /* 14: div255w */ + var55.x4[0] = + ((orc_uint16) (((orc_uint16) (var54.x4[0] + 128)) + + (((orc_uint16) (var54.x4[0] + 128)) >> 8))) >> 8; + var55.x4[1] = + ((orc_uint16) (((orc_uint16) (var54.x4[1] + 128)) + + (((orc_uint16) (var54.x4[1] + 128)) >> 8))) >> 8; + var55.x4[2] = + ((orc_uint16) (((orc_uint16) (var54.x4[2] + 128)) + + (((orc_uint16) (var54.x4[2] + 128)) >> 8))) >> 8; + var55.x4[3] = + ((orc_uint16) (((orc_uint16) (var54.x4[3] + 128)) + + (((orc_uint16) (var54.x4[3] + 128)) >> 8))) >> 8; + /* 15: addw */ + var56.x4[0] = var52.x4[0] + var55.x4[0]; + var56.x4[1] = var52.x4[1] + var55.x4[1]; + var56.x4[2] = var52.x4[2] + var55.x4[2]; + var56.x4[3] = var52.x4[3] + var55.x4[3]; + /* 16: convwb */ + var57.x4[0] = var56.x4[0]; + var57.x4[1] = var56.x4[1]; + var57.x4[2] = var56.x4[2]; + var57.x4[3] = var56.x4[3]; + /* 18: orl */ + var58.i = var57.i | var41.i; + /* 19: storel */ + ptr0[i] = var58; + } + } + +} + +#else +static void +_backup_video_mixer_orc_blend_bgra (OrcExecutor * ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union64 var40; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var41; +#else + orc_union32 var41; +#endif + orc_union32 var42; + orc_union32 var43; + orc_union16 var44; + orc_int8 var45; + orc_union32 var46; + orc_union64 var47; + orc_union64 var48; + orc_union64 var49; + orc_union64 var50; + orc_union32 var51; + orc_union64 var52; + orc_union64 var53; + orc_union64 var54; + orc_union64 var55; + orc_union64 var56; + orc_union32 var57; + orc_union32 var58; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 6: loadpw */ + var40.x4[0] = ex->params[24]; + var40.x4[1] = ex->params[24]; + var40.x4[2] = ex->params[24]; + var40.x4[3] = ex->params[24]; + /* 17: loadpl */ + var41.i = (int) 0xff000000; /* -16777216 or 2.11371e-314f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var42 = ptr4[i]; + /* 1: shrul */ + var43.i = ((orc_uint32) var42.i) >> 24; + /* 2: convlw */ + var44.i = var43.i; + /* 3: convwb */ + var45 = var44.i; + /* 4: splatbl */ + var46.i = + ((((orc_uint32) var45) & 0xff) << 24) | ((((orc_uint32) var45) & 0xff) + << 16) | ((((orc_uint32) var45) & 0xff) << 8) | (((orc_uint32) var45) + & 0xff); + /* 5: convubw */ + var47.x4[0] = (orc_uint8) var46.x4[0]; + var47.x4[1] = (orc_uint8) var46.x4[1]; + var47.x4[2] = (orc_uint8) var46.x4[2]; + var47.x4[3] = (orc_uint8) var46.x4[3]; + /* 7: mullw */ + var48.x4[0] = (var47.x4[0] * var40.x4[0]) & 0xffff; + var48.x4[1] = (var47.x4[1] * var40.x4[1]) & 0xffff; + var48.x4[2] = (var47.x4[2] * var40.x4[2]) & 0xffff; + var48.x4[3] = (var47.x4[3] * var40.x4[3]) & 0xffff; + /* 8: shruw */ + var49.x4[0] = ((orc_uint16) var48.x4[0]) >> 8; + var49.x4[1] = ((orc_uint16) var48.x4[1]) >> 8; + var49.x4[2] = ((orc_uint16) var48.x4[2]) >> 8; + var49.x4[3] = ((orc_uint16) var48.x4[3]) >> 8; + /* 9: convubw */ + var50.x4[0] = (orc_uint8) var42.x4[0]; + var50.x4[1] = (orc_uint8) var42.x4[1]; + var50.x4[2] = (orc_uint8) var42.x4[2]; + var50.x4[3] = (orc_uint8) var42.x4[3]; + /* 10: loadl */ + var51 = ptr0[i]; + /* 11: convubw */ + var52.x4[0] = (orc_uint8) var51.x4[0]; + var52.x4[1] = (orc_uint8) var51.x4[1]; + var52.x4[2] = (orc_uint8) var51.x4[2]; + var52.x4[3] = (orc_uint8) var51.x4[3]; + /* 12: subw */ + var53.x4[0] = var50.x4[0] - var52.x4[0]; + var53.x4[1] = var50.x4[1] - var52.x4[1]; + var53.x4[2] = var50.x4[2] - var52.x4[2]; + var53.x4[3] = var50.x4[3] - var52.x4[3]; + /* 13: mullw */ + var54.x4[0] = (var53.x4[0] * var49.x4[0]) & 0xffff; + var54.x4[1] = (var53.x4[1] * var49.x4[1]) & 0xffff; + var54.x4[2] = (var53.x4[2] * var49.x4[2]) & 0xffff; + var54.x4[3] = (var53.x4[3] * var49.x4[3]) & 0xffff; + /* 14: div255w */ + var55.x4[0] = + ((orc_uint16) (((orc_uint16) (var54.x4[0] + 128)) + + (((orc_uint16) (var54.x4[0] + 128)) >> 8))) >> 8; + var55.x4[1] = + ((orc_uint16) (((orc_uint16) (var54.x4[1] + 128)) + + (((orc_uint16) (var54.x4[1] + 128)) >> 8))) >> 8; + var55.x4[2] = + ((orc_uint16) (((orc_uint16) (var54.x4[2] + 128)) + + (((orc_uint16) (var54.x4[2] + 128)) >> 8))) >> 8; + var55.x4[3] = + ((orc_uint16) (((orc_uint16) (var54.x4[3] + 128)) + + (((orc_uint16) (var54.x4[3] + 128)) >> 8))) >> 8; + /* 15: addw */ + var56.x4[0] = var52.x4[0] + var55.x4[0]; + var56.x4[1] = var52.x4[1] + var55.x4[1]; + var56.x4[2] = var52.x4[2] + var55.x4[2]; + var56.x4[3] = var52.x4[3] + var55.x4[3]; + /* 16: convwb */ + var57.x4[0] = var56.x4[0]; + var57.x4[1] = var56.x4[1]; + var57.x4[2] = var56.x4[2]; + var57.x4[3] = var56.x4[3]; + /* 18: orl */ + var58.i = var57.i | var41.i; + /* 19: storel */ + ptr0[i] = var58; + } + } + +} + +void +video_mixer_orc_blend_bgra (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 26, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95, + 111, 114, 99, 95, 98, 108, 101, 110, 100, 95, 98, 103, 114, 97, 11, 4, + 4, 12, 4, 4, 14, 4, 0, 0, 0, 255, 14, 4, 24, 0, 0, 0, + 14, 2, 8, 0, 0, 0, 16, 2, 20, 4, 20, 4, 20, 2, 20, 1, + 20, 4, 20, 8, 20, 8, 20, 8, 113, 32, 4, 126, 33, 32, 17, 163, + 34, 33, 157, 35, 34, 152, 36, 35, 21, 2, 150, 39, 36, 21, 2, 89, + 39, 39, 24, 21, 2, 95, 39, 39, 18, 21, 2, 150, 38, 32, 113, 32, + 0, 21, 2, 150, 37, 32, 21, 2, 98, 38, 38, 37, 21, 2, 89, 38, + 38, 39, 21, 2, 80, 38, 38, 21, 2, 70, 37, 37, 38, 21, 2, 157, + 32, 37, 123, 32, 32, 16, 128, 0, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_bgra); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, "video_mixer_orc_blend_bgra"); + orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_bgra); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_constant (p, 4, 0xff000000, "c1"); + orc_program_add_constant (p, 4, 0x00000018, "c2"); + orc_program_add_constant (p, 2, 0x00000008, "c3"); + orc_program_add_parameter (p, 2, "p1"); + orc_program_add_temporary (p, 4, "t1"); + orc_program_add_temporary (p, 4, "t2"); + orc_program_add_temporary (p, 2, "t3"); + orc_program_add_temporary (p, 1, "t4"); + orc_program_add_temporary (p, 4, "t5"); + orc_program_add_temporary (p, 8, "t6"); + orc_program_add_temporary (p, 8, "t7"); + orc_program_add_temporary (p, 8, "t8"); + + orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "shrul", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_C2, + ORC_VAR_D1); + orc_program_append_2 (p, "convlw", 0, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbl", 0, ORC_VAR_T5, ORC_VAR_T4, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T8, ORC_VAR_T5, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T8, ORC_VAR_T8, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "shruw", 2, ORC_VAR_T8, ORC_VAR_T8, ORC_VAR_C3, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T7, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_D1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T6, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "subw", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_T6, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_T8, + ORC_VAR_D1); + orc_program_append_2 (p, "div255w", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "addw", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_T7, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 2, ORC_VAR_T1, ORC_VAR_T6, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "orl", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "storel", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->params[ORC_VAR_P1] = p1; + + func = c->exec; + func (ex); +} +#endif + + +/* video_mixer_orc_overlay_argb */ +#ifdef DISABLE_ORC +void +video_mixer_orc_overlay_argb (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union64 var41; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var42; +#else + orc_union32 var42; +#endif +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var43; +#else + orc_union32 var43; +#endif + orc_union32 var44; + orc_union16 var45; + orc_int8 var46; + orc_union32 var47; + orc_union64 var48; + orc_union64 var49; + orc_union64 var50; + orc_union64 var51; + orc_union64 var52; + orc_union32 var53; + orc_union64 var54; + orc_union64 var55; + orc_union32 var56; + orc_union16 var57; + orc_int8 var58; + orc_union32 var59; + orc_union64 var60; + orc_union64 var61; + orc_union64 var62; + orc_union64 var63; + orc_union64 var64; + orc_union64 var65; + orc_union64 var66; + orc_union64 var67; + orc_union32 var68; + orc_union32 var69; + orc_union32 var70; + orc_union32 var71; + orc_union32 var72; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 5: loadpw */ + var41.x4[0] = p1; + var41.x4[1] = p1; + var41.x4[2] = p1; + var41.x4[3] = p1; + /* 10: loadpl */ + var53.i = (int) 0xffffffff; /* -1 or 2.122e-314f */ + /* 26: loadpl */ + var42.i = (int) 0xffffff00; /* -256 or 2.122e-314f */ + /* 29: loadpl */ + var43.i = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var44 = ptr4[i]; + /* 1: convlw */ + var45.i = var44.i; + /* 2: convwb */ + var46 = var45.i; + /* 3: splatbl */ + var47.i = + ((((orc_uint32) var46) & 0xff) << 24) | ((((orc_uint32) var46) & 0xff) + << 16) | ((((orc_uint32) var46) & 0xff) << 8) | (((orc_uint32) var46) + & 0xff); + /* 4: convubw */ + var48.x4[0] = (orc_uint8) var47.x4[0]; + var48.x4[1] = (orc_uint8) var47.x4[1]; + var48.x4[2] = (orc_uint8) var47.x4[2]; + var48.x4[3] = (orc_uint8) var47.x4[3]; + /* 6: mullw */ + var49.x4[0] = (var48.x4[0] * var41.x4[0]) & 0xffff; + var49.x4[1] = (var48.x4[1] * var41.x4[1]) & 0xffff; + var49.x4[2] = (var48.x4[2] * var41.x4[2]) & 0xffff; + var49.x4[3] = (var48.x4[3] * var41.x4[3]) & 0xffff; + /* 7: shruw */ + var50.x4[0] = ((orc_uint16) var49.x4[0]) >> 8; + var50.x4[1] = ((orc_uint16) var49.x4[1]) >> 8; + var50.x4[2] = ((orc_uint16) var49.x4[2]) >> 8; + var50.x4[3] = ((orc_uint16) var49.x4[3]) >> 8; + /* 8: convubw */ + var51.x4[0] = (orc_uint8) var44.x4[0]; + var51.x4[1] = (orc_uint8) var44.x4[1]; + var51.x4[2] = (orc_uint8) var44.x4[2]; + var51.x4[3] = (orc_uint8) var44.x4[3]; + /* 9: mullw */ + var52.x4[0] = (var51.x4[0] * var50.x4[0]) & 0xffff; + var52.x4[1] = (var51.x4[1] * var50.x4[1]) & 0xffff; + var52.x4[2] = (var51.x4[2] * var50.x4[2]) & 0xffff; + var52.x4[3] = (var51.x4[3] * var50.x4[3]) & 0xffff; + /* 11: convubw */ + var54.x4[0] = (orc_uint8) var53.x4[0]; + var54.x4[1] = (orc_uint8) var53.x4[1]; + var54.x4[2] = (orc_uint8) var53.x4[2]; + var54.x4[3] = (orc_uint8) var53.x4[3]; + /* 12: subw */ + var55.x4[0] = var54.x4[0] - var50.x4[0]; + var55.x4[1] = var54.x4[1] - var50.x4[1]; + var55.x4[2] = var54.x4[2] - var50.x4[2]; + var55.x4[3] = var54.x4[3] - var50.x4[3]; + /* 13: loadl */ + var56 = ptr0[i]; + /* 14: convlw */ + var57.i = var56.i; + /* 15: convwb */ + var58 = var57.i; + /* 16: splatbl */ + var59.i = + ((((orc_uint32) var58) & 0xff) << 24) | ((((orc_uint32) var58) & 0xff) + << 16) | ((((orc_uint32) var58) & 0xff) << 8) | (((orc_uint32) var58) + & 0xff); + /* 17: convubw */ + var60.x4[0] = (orc_uint8) var59.x4[0]; + var60.x4[1] = (orc_uint8) var59.x4[1]; + var60.x4[2] = (orc_uint8) var59.x4[2]; + var60.x4[3] = (orc_uint8) var59.x4[3]; + /* 18: mullw */ + var61.x4[0] = (var60.x4[0] * var55.x4[0]) & 0xffff; + var61.x4[1] = (var60.x4[1] * var55.x4[1]) & 0xffff; + var61.x4[2] = (var60.x4[2] * var55.x4[2]) & 0xffff; + var61.x4[3] = (var60.x4[3] * var55.x4[3]) & 0xffff; + /* 19: div255w */ + var62.x4[0] = + ((orc_uint16) (((orc_uint16) (var61.x4[0] + 128)) + + (((orc_uint16) (var61.x4[0] + 128)) >> 8))) >> 8; + var62.x4[1] = + ((orc_uint16) (((orc_uint16) (var61.x4[1] + 128)) + + (((orc_uint16) (var61.x4[1] + 128)) >> 8))) >> 8; + var62.x4[2] = + ((orc_uint16) (((orc_uint16) (var61.x4[2] + 128)) + + (((orc_uint16) (var61.x4[2] + 128)) >> 8))) >> 8; + var62.x4[3] = + ((orc_uint16) (((orc_uint16) (var61.x4[3] + 128)) + + (((orc_uint16) (var61.x4[3] + 128)) >> 8))) >> 8; + /* 20: convubw */ + var63.x4[0] = (orc_uint8) var56.x4[0]; + var63.x4[1] = (orc_uint8) var56.x4[1]; + var63.x4[2] = (orc_uint8) var56.x4[2]; + var63.x4[3] = (orc_uint8) var56.x4[3]; + /* 21: mullw */ + var64.x4[0] = (var63.x4[0] * var62.x4[0]) & 0xffff; + var64.x4[1] = (var63.x4[1] * var62.x4[1]) & 0xffff; + var64.x4[2] = (var63.x4[2] * var62.x4[2]) & 0xffff; + var64.x4[3] = (var63.x4[3] * var62.x4[3]) & 0xffff; + /* 22: addw */ + var65.x4[0] = var64.x4[0] + var52.x4[0]; + var65.x4[1] = var64.x4[1] + var52.x4[1]; + var65.x4[2] = var64.x4[2] + var52.x4[2]; + var65.x4[3] = var64.x4[3] + var52.x4[3]; + /* 23: addw */ + var66.x4[0] = var62.x4[0] + var50.x4[0]; + var66.x4[1] = var62.x4[1] + var50.x4[1]; + var66.x4[2] = var62.x4[2] + var50.x4[2]; + var66.x4[3] = var62.x4[3] + var50.x4[3]; + /* 24: divluw */ + var67.x4[0] = + ((var66.x4[0] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var65.x4[0]) / + ((orc_uint16) var66.x4[0] & 0xff)); + var67.x4[1] = + ((var66.x4[1] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var65.x4[1]) / + ((orc_uint16) var66.x4[1] & 0xff)); + var67.x4[2] = + ((var66.x4[2] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var65.x4[2]) / + ((orc_uint16) var66.x4[2] & 0xff)); + var67.x4[3] = + ((var66.x4[3] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var65.x4[3]) / + ((orc_uint16) var66.x4[3] & 0xff)); + /* 25: convwb */ + var68.x4[0] = var67.x4[0]; + var68.x4[1] = var67.x4[1]; + var68.x4[2] = var67.x4[2]; + var68.x4[3] = var67.x4[3]; + /* 27: andl */ + var69.i = var68.i & var42.i; + /* 28: convwb */ + var70.x4[0] = var66.x4[0]; + var70.x4[1] = var66.x4[1]; + var70.x4[2] = var66.x4[2]; + var70.x4[3] = var66.x4[3]; + /* 30: andl */ + var71.i = var70.i & var43.i; + /* 31: orl */ + var72.i = var69.i | var71.i; + /* 32: storel */ + ptr0[i] = var72; + } + } + +} + +#else +static void +_backup_video_mixer_orc_overlay_argb (OrcExecutor * ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union64 var41; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var42; +#else + orc_union32 var42; +#endif +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var43; +#else + orc_union32 var43; +#endif + orc_union32 var44; + orc_union16 var45; + orc_int8 var46; + orc_union32 var47; + orc_union64 var48; + orc_union64 var49; + orc_union64 var50; + orc_union64 var51; + orc_union64 var52; + orc_union32 var53; + orc_union64 var54; + orc_union64 var55; + orc_union32 var56; + orc_union16 var57; + orc_int8 var58; + orc_union32 var59; + orc_union64 var60; + orc_union64 var61; + orc_union64 var62; + orc_union64 var63; + orc_union64 var64; + orc_union64 var65; + orc_union64 var66; + orc_union64 var67; + orc_union32 var68; + orc_union32 var69; + orc_union32 var70; + orc_union32 var71; + orc_union32 var72; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 5: loadpw */ + var41.x4[0] = ex->params[24]; + var41.x4[1] = ex->params[24]; + var41.x4[2] = ex->params[24]; + var41.x4[3] = ex->params[24]; + /* 10: loadpl */ + var53.i = (int) 0xffffffff; /* -1 or 2.122e-314f */ + /* 26: loadpl */ + var42.i = (int) 0xffffff00; /* -256 or 2.122e-314f */ + /* 29: loadpl */ + var43.i = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var44 = ptr4[i]; + /* 1: convlw */ + var45.i = var44.i; + /* 2: convwb */ + var46 = var45.i; + /* 3: splatbl */ + var47.i = + ((((orc_uint32) var46) & 0xff) << 24) | ((((orc_uint32) var46) & 0xff) + << 16) | ((((orc_uint32) var46) & 0xff) << 8) | (((orc_uint32) var46) + & 0xff); + /* 4: convubw */ + var48.x4[0] = (orc_uint8) var47.x4[0]; + var48.x4[1] = (orc_uint8) var47.x4[1]; + var48.x4[2] = (orc_uint8) var47.x4[2]; + var48.x4[3] = (orc_uint8) var47.x4[3]; + /* 6: mullw */ + var49.x4[0] = (var48.x4[0] * var41.x4[0]) & 0xffff; + var49.x4[1] = (var48.x4[1] * var41.x4[1]) & 0xffff; + var49.x4[2] = (var48.x4[2] * var41.x4[2]) & 0xffff; + var49.x4[3] = (var48.x4[3] * var41.x4[3]) & 0xffff; + /* 7: shruw */ + var50.x4[0] = ((orc_uint16) var49.x4[0]) >> 8; + var50.x4[1] = ((orc_uint16) var49.x4[1]) >> 8; + var50.x4[2] = ((orc_uint16) var49.x4[2]) >> 8; + var50.x4[3] = ((orc_uint16) var49.x4[3]) >> 8; + /* 8: convubw */ + var51.x4[0] = (orc_uint8) var44.x4[0]; + var51.x4[1] = (orc_uint8) var44.x4[1]; + var51.x4[2] = (orc_uint8) var44.x4[2]; + var51.x4[3] = (orc_uint8) var44.x4[3]; + /* 9: mullw */ + var52.x4[0] = (var51.x4[0] * var50.x4[0]) & 0xffff; + var52.x4[1] = (var51.x4[1] * var50.x4[1]) & 0xffff; + var52.x4[2] = (var51.x4[2] * var50.x4[2]) & 0xffff; + var52.x4[3] = (var51.x4[3] * var50.x4[3]) & 0xffff; + /* 11: convubw */ + var54.x4[0] = (orc_uint8) var53.x4[0]; + var54.x4[1] = (orc_uint8) var53.x4[1]; + var54.x4[2] = (orc_uint8) var53.x4[2]; + var54.x4[3] = (orc_uint8) var53.x4[3]; + /* 12: subw */ + var55.x4[0] = var54.x4[0] - var50.x4[0]; + var55.x4[1] = var54.x4[1] - var50.x4[1]; + var55.x4[2] = var54.x4[2] - var50.x4[2]; + var55.x4[3] = var54.x4[3] - var50.x4[3]; + /* 13: loadl */ + var56 = ptr0[i]; + /* 14: convlw */ + var57.i = var56.i; + /* 15: convwb */ + var58 = var57.i; + /* 16: splatbl */ + var59.i = + ((((orc_uint32) var58) & 0xff) << 24) | ((((orc_uint32) var58) & 0xff) + << 16) | ((((orc_uint32) var58) & 0xff) << 8) | (((orc_uint32) var58) + & 0xff); + /* 17: convubw */ + var60.x4[0] = (orc_uint8) var59.x4[0]; + var60.x4[1] = (orc_uint8) var59.x4[1]; + var60.x4[2] = (orc_uint8) var59.x4[2]; + var60.x4[3] = (orc_uint8) var59.x4[3]; + /* 18: mullw */ + var61.x4[0] = (var60.x4[0] * var55.x4[0]) & 0xffff; + var61.x4[1] = (var60.x4[1] * var55.x4[1]) & 0xffff; + var61.x4[2] = (var60.x4[2] * var55.x4[2]) & 0xffff; + var61.x4[3] = (var60.x4[3] * var55.x4[3]) & 0xffff; + /* 19: div255w */ + var62.x4[0] = + ((orc_uint16) (((orc_uint16) (var61.x4[0] + 128)) + + (((orc_uint16) (var61.x4[0] + 128)) >> 8))) >> 8; + var62.x4[1] = + ((orc_uint16) (((orc_uint16) (var61.x4[1] + 128)) + + (((orc_uint16) (var61.x4[1] + 128)) >> 8))) >> 8; + var62.x4[2] = + ((orc_uint16) (((orc_uint16) (var61.x4[2] + 128)) + + (((orc_uint16) (var61.x4[2] + 128)) >> 8))) >> 8; + var62.x4[3] = + ((orc_uint16) (((orc_uint16) (var61.x4[3] + 128)) + + (((orc_uint16) (var61.x4[3] + 128)) >> 8))) >> 8; + /* 20: convubw */ + var63.x4[0] = (orc_uint8) var56.x4[0]; + var63.x4[1] = (orc_uint8) var56.x4[1]; + var63.x4[2] = (orc_uint8) var56.x4[2]; + var63.x4[3] = (orc_uint8) var56.x4[3]; + /* 21: mullw */ + var64.x4[0] = (var63.x4[0] * var62.x4[0]) & 0xffff; + var64.x4[1] = (var63.x4[1] * var62.x4[1]) & 0xffff; + var64.x4[2] = (var63.x4[2] * var62.x4[2]) & 0xffff; + var64.x4[3] = (var63.x4[3] * var62.x4[3]) & 0xffff; + /* 22: addw */ + var65.x4[0] = var64.x4[0] + var52.x4[0]; + var65.x4[1] = var64.x4[1] + var52.x4[1]; + var65.x4[2] = var64.x4[2] + var52.x4[2]; + var65.x4[3] = var64.x4[3] + var52.x4[3]; + /* 23: addw */ + var66.x4[0] = var62.x4[0] + var50.x4[0]; + var66.x4[1] = var62.x4[1] + var50.x4[1]; + var66.x4[2] = var62.x4[2] + var50.x4[2]; + var66.x4[3] = var62.x4[3] + var50.x4[3]; + /* 24: divluw */ + var67.x4[0] = + ((var66.x4[0] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var65.x4[0]) / + ((orc_uint16) var66.x4[0] & 0xff)); + var67.x4[1] = + ((var66.x4[1] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var65.x4[1]) / + ((orc_uint16) var66.x4[1] & 0xff)); + var67.x4[2] = + ((var66.x4[2] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var65.x4[2]) / + ((orc_uint16) var66.x4[2] & 0xff)); + var67.x4[3] = + ((var66.x4[3] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var65.x4[3]) / + ((orc_uint16) var66.x4[3] & 0xff)); + /* 25: convwb */ + var68.x4[0] = var67.x4[0]; + var68.x4[1] = var67.x4[1]; + var68.x4[2] = var67.x4[2]; + var68.x4[3] = var67.x4[3]; + /* 27: andl */ + var69.i = var68.i & var42.i; + /* 28: convwb */ + var70.x4[0] = var66.x4[0]; + var70.x4[1] = var66.x4[1]; + var70.x4[2] = var66.x4[2]; + var70.x4[3] = var66.x4[3]; + /* 30: andl */ + var71.i = var70.i & var43.i; + /* 31: orl */ + var72.i = var69.i | var71.i; + /* 32: storel */ + ptr0[i] = var72; + } + } + +} + +void +video_mixer_orc_overlay_argb (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 28, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95, + 111, 114, 99, 95, 111, 118, 101, 114, 108, 97, 121, 95, 97, 114, 103, + 98, + 11, 4, 4, 12, 4, 4, 14, 4, 255, 255, 255, 255, 14, 4, 255, 0, + 0, 0, 14, 4, 0, 255, 255, 255, 14, 2, 8, 0, 0, 0, 16, 2, + 20, 4, 20, 2, 20, 1, 20, 8, 20, 8, 20, 8, 20, 4, 20, 8, + 20, 8, 113, 32, 4, 163, 33, 32, 157, 34, 33, 152, 38, 34, 21, 2, + 150, 35, 38, 21, 2, 89, 35, 35, 24, 21, 2, 95, 35, 35, 19, 21, + 2, 150, 40, 32, 21, 2, 89, 40, 40, 35, 115, 38, 16, 21, 2, 150, + 36, 38, 21, 2, 98, 36, 36, 35, 113, 32, 0, 163, 33, 32, 157, 34, + 33, 152, 38, 34, 21, 2, 150, 37, 38, 21, 2, 89, 37, 37, 36, 21, + 2, 80, 37, 37, 21, 2, 150, 39, 32, 21, 2, 89, 39, 39, 37, 21, + 2, 70, 39, 39, 40, 21, 2, 70, 37, 37, 35, 21, 2, 81, 39, 39, + 37, 21, 2, 157, 32, 39, 106, 32, 32, 18, 21, 2, 157, 38, 37, 106, + 38, 38, 17, 123, 32, 32, 38, 128, 0, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, _backup_video_mixer_orc_overlay_argb); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, "video_mixer_orc_overlay_argb"); + orc_program_set_backup_function (p, _backup_video_mixer_orc_overlay_argb); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_constant (p, 4, 0xffffffff, "c1"); + orc_program_add_constant (p, 4, 0x000000ff, "c2"); + orc_program_add_constant (p, 4, 0xffffff00, "c3"); + orc_program_add_constant (p, 2, 0x00000008, "c4"); + orc_program_add_parameter (p, 2, "p1"); + orc_program_add_temporary (p, 4, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 1, "t3"); + orc_program_add_temporary (p, 8, "t4"); + orc_program_add_temporary (p, 8, "t5"); + orc_program_add_temporary (p, 8, "t6"); + orc_program_add_temporary (p, 4, "t7"); + orc_program_add_temporary (p, 8, "t8"); + orc_program_add_temporary (p, 8, "t9"); + + orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convlw", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 0, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbl", 0, ORC_VAR_T7, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T4, ORC_VAR_T7, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T4, ORC_VAR_T4, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "shruw", 2, ORC_VAR_T4, ORC_VAR_T4, ORC_VAR_C4, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T9, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T9, ORC_VAR_T9, ORC_VAR_T4, + ORC_VAR_D1); + orc_program_append_2 (p, "loadpl", 0, ORC_VAR_T7, ORC_VAR_C1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T5, ORC_VAR_T7, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "subw", 2, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_T4, + ORC_VAR_D1); + orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_D1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convlw", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 0, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbl", 0, ORC_VAR_T7, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T6, ORC_VAR_T7, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "div255w", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T8, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T8, ORC_VAR_T8, ORC_VAR_T6, + ORC_VAR_D1); + orc_program_append_2 (p, "addw", 2, ORC_VAR_T8, ORC_VAR_T8, ORC_VAR_T9, + ORC_VAR_D1); + orc_program_append_2 (p, "addw", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_T4, + ORC_VAR_D1); + orc_program_append_2 (p, "divluw", 2, ORC_VAR_T8, ORC_VAR_T8, ORC_VAR_T6, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 2, ORC_VAR_T1, ORC_VAR_T8, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "andl", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C3, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 2, ORC_VAR_T7, ORC_VAR_T6, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "andl", 0, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_C2, + ORC_VAR_D1); + orc_program_append_2 (p, "orl", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_T7, + ORC_VAR_D1); + orc_program_append_2 (p, "storel", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->params[ORC_VAR_P1] = p1; + + func = c->exec; + func (ex); +} +#endif + + +/* video_mixer_orc_overlay_bgra */ +#ifdef DISABLE_ORC +void +video_mixer_orc_overlay_bgra (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union64 var42; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var43; +#else + orc_union32 var43; +#endif +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var44; +#else + orc_union32 var44; +#endif + orc_union32 var45; + orc_union32 var46; + orc_union16 var47; + orc_int8 var48; + orc_union32 var49; + orc_union64 var50; + orc_union64 var51; + orc_union64 var52; + orc_union64 var53; + orc_union64 var54; + orc_union32 var55; + orc_union64 var56; + orc_union64 var57; + orc_union32 var58; + orc_union32 var59; + orc_union16 var60; + orc_int8 var61; + orc_union32 var62; + orc_union64 var63; + orc_union64 var64; + orc_union64 var65; + orc_union64 var66; + orc_union64 var67; + orc_union64 var68; + orc_union64 var69; + orc_union64 var70; + orc_union32 var71; + orc_union32 var72; + orc_union32 var73; + orc_union32 var74; + orc_union32 var75; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 6: loadpw */ + var42.x4[0] = p1; + var42.x4[1] = p1; + var42.x4[2] = p1; + var42.x4[3] = p1; + /* 11: loadpl */ + var55.i = (int) 0xffffffff; /* -1 or 2.122e-314f */ + /* 28: loadpl */ + var43.i = (int) 0x00ffffff; /* 16777215 or 8.28905e-317f */ + /* 31: loadpl */ + var44.i = (int) 0xff000000; /* -16777216 or 2.11371e-314f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var45 = ptr4[i]; + /* 1: shrul */ + var46.i = ((orc_uint32) var45.i) >> 24; + /* 2: convlw */ + var47.i = var46.i; + /* 3: convwb */ + var48 = var47.i; + /* 4: splatbl */ + var49.i = + ((((orc_uint32) var48) & 0xff) << 24) | ((((orc_uint32) var48) & 0xff) + << 16) | ((((orc_uint32) var48) & 0xff) << 8) | (((orc_uint32) var48) + & 0xff); + /* 5: convubw */ + var50.x4[0] = (orc_uint8) var49.x4[0]; + var50.x4[1] = (orc_uint8) var49.x4[1]; + var50.x4[2] = (orc_uint8) var49.x4[2]; + var50.x4[3] = (orc_uint8) var49.x4[3]; + /* 7: mullw */ + var51.x4[0] = (var50.x4[0] * var42.x4[0]) & 0xffff; + var51.x4[1] = (var50.x4[1] * var42.x4[1]) & 0xffff; + var51.x4[2] = (var50.x4[2] * var42.x4[2]) & 0xffff; + var51.x4[3] = (var50.x4[3] * var42.x4[3]) & 0xffff; + /* 8: shruw */ + var52.x4[0] = ((orc_uint16) var51.x4[0]) >> 8; + var52.x4[1] = ((orc_uint16) var51.x4[1]) >> 8; + var52.x4[2] = ((orc_uint16) var51.x4[2]) >> 8; + var52.x4[3] = ((orc_uint16) var51.x4[3]) >> 8; + /* 9: convubw */ + var53.x4[0] = (orc_uint8) var45.x4[0]; + var53.x4[1] = (orc_uint8) var45.x4[1]; + var53.x4[2] = (orc_uint8) var45.x4[2]; + var53.x4[3] = (orc_uint8) var45.x4[3]; + /* 10: mullw */ + var54.x4[0] = (var53.x4[0] * var52.x4[0]) & 0xffff; + var54.x4[1] = (var53.x4[1] * var52.x4[1]) & 0xffff; + var54.x4[2] = (var53.x4[2] * var52.x4[2]) & 0xffff; + var54.x4[3] = (var53.x4[3] * var52.x4[3]) & 0xffff; + /* 12: convubw */ + var56.x4[0] = (orc_uint8) var55.x4[0]; + var56.x4[1] = (orc_uint8) var55.x4[1]; + var56.x4[2] = (orc_uint8) var55.x4[2]; + var56.x4[3] = (orc_uint8) var55.x4[3]; + /* 13: subw */ + var57.x4[0] = var56.x4[0] - var52.x4[0]; + var57.x4[1] = var56.x4[1] - var52.x4[1]; + var57.x4[2] = var56.x4[2] - var52.x4[2]; + var57.x4[3] = var56.x4[3] - var52.x4[3]; + /* 14: loadl */ + var58 = ptr0[i]; + /* 15: shrul */ + var59.i = ((orc_uint32) var58.i) >> 24; + /* 16: convlw */ + var60.i = var59.i; + /* 17: convwb */ + var61 = var60.i; + /* 18: splatbl */ + var62.i = + ((((orc_uint32) var61) & 0xff) << 24) | ((((orc_uint32) var61) & 0xff) + << 16) | ((((orc_uint32) var61) & 0xff) << 8) | (((orc_uint32) var61) + & 0xff); + /* 19: convubw */ + var63.x4[0] = (orc_uint8) var62.x4[0]; + var63.x4[1] = (orc_uint8) var62.x4[1]; + var63.x4[2] = (orc_uint8) var62.x4[2]; + var63.x4[3] = (orc_uint8) var62.x4[3]; + /* 20: mullw */ + var64.x4[0] = (var63.x4[0] * var57.x4[0]) & 0xffff; + var64.x4[1] = (var63.x4[1] * var57.x4[1]) & 0xffff; + var64.x4[2] = (var63.x4[2] * var57.x4[2]) & 0xffff; + var64.x4[3] = (var63.x4[3] * var57.x4[3]) & 0xffff; + /* 21: div255w */ + var65.x4[0] = + ((orc_uint16) (((orc_uint16) (var64.x4[0] + 128)) + + (((orc_uint16) (var64.x4[0] + 128)) >> 8))) >> 8; + var65.x4[1] = + ((orc_uint16) (((orc_uint16) (var64.x4[1] + 128)) + + (((orc_uint16) (var64.x4[1] + 128)) >> 8))) >> 8; + var65.x4[2] = + ((orc_uint16) (((orc_uint16) (var64.x4[2] + 128)) + + (((orc_uint16) (var64.x4[2] + 128)) >> 8))) >> 8; + var65.x4[3] = + ((orc_uint16) (((orc_uint16) (var64.x4[3] + 128)) + + (((orc_uint16) (var64.x4[3] + 128)) >> 8))) >> 8; + /* 22: convubw */ + var66.x4[0] = (orc_uint8) var58.x4[0]; + var66.x4[1] = (orc_uint8) var58.x4[1]; + var66.x4[2] = (orc_uint8) var58.x4[2]; + var66.x4[3] = (orc_uint8) var58.x4[3]; + /* 23: mullw */ + var67.x4[0] = (var66.x4[0] * var65.x4[0]) & 0xffff; + var67.x4[1] = (var66.x4[1] * var65.x4[1]) & 0xffff; + var67.x4[2] = (var66.x4[2] * var65.x4[2]) & 0xffff; + var67.x4[3] = (var66.x4[3] * var65.x4[3]) & 0xffff; + /* 24: addw */ + var68.x4[0] = var67.x4[0] + var54.x4[0]; + var68.x4[1] = var67.x4[1] + var54.x4[1]; + var68.x4[2] = var67.x4[2] + var54.x4[2]; + var68.x4[3] = var67.x4[3] + var54.x4[3]; + /* 25: addw */ + var69.x4[0] = var65.x4[0] + var52.x4[0]; + var69.x4[1] = var65.x4[1] + var52.x4[1]; + var69.x4[2] = var65.x4[2] + var52.x4[2]; + var69.x4[3] = var65.x4[3] + var52.x4[3]; + /* 26: divluw */ + var70.x4[0] = + ((var69.x4[0] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var68.x4[0]) / + ((orc_uint16) var69.x4[0] & 0xff)); + var70.x4[1] = + ((var69.x4[1] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var68.x4[1]) / + ((orc_uint16) var69.x4[1] & 0xff)); + var70.x4[2] = + ((var69.x4[2] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var68.x4[2]) / + ((orc_uint16) var69.x4[2] & 0xff)); + var70.x4[3] = + ((var69.x4[3] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var68.x4[3]) / + ((orc_uint16) var69.x4[3] & 0xff)); + /* 27: convwb */ + var71.x4[0] = var70.x4[0]; + var71.x4[1] = var70.x4[1]; + var71.x4[2] = var70.x4[2]; + var71.x4[3] = var70.x4[3]; + /* 29: andl */ + var72.i = var71.i & var43.i; + /* 30: convwb */ + var73.x4[0] = var69.x4[0]; + var73.x4[1] = var69.x4[1]; + var73.x4[2] = var69.x4[2]; + var73.x4[3] = var69.x4[3]; + /* 32: andl */ + var74.i = var73.i & var44.i; + /* 33: orl */ + var75.i = var72.i | var74.i; + /* 34: storel */ + ptr0[i] = var75; + } + } + +} + +#else +static void +_backup_video_mixer_orc_overlay_bgra (OrcExecutor * ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union64 var42; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var43; +#else + orc_union32 var43; +#endif +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var44; +#else + orc_union32 var44; +#endif + orc_union32 var45; + orc_union32 var46; + orc_union16 var47; + orc_int8 var48; + orc_union32 var49; + orc_union64 var50; + orc_union64 var51; + orc_union64 var52; + orc_union64 var53; + orc_union64 var54; + orc_union32 var55; + orc_union64 var56; + orc_union64 var57; + orc_union32 var58; + orc_union32 var59; + orc_union16 var60; + orc_int8 var61; + orc_union32 var62; + orc_union64 var63; + orc_union64 var64; + orc_union64 var65; + orc_union64 var66; + orc_union64 var67; + orc_union64 var68; + orc_union64 var69; + orc_union64 var70; + orc_union32 var71; + orc_union32 var72; + orc_union32 var73; + orc_union32 var74; + orc_union32 var75; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 6: loadpw */ + var42.x4[0] = ex->params[24]; + var42.x4[1] = ex->params[24]; + var42.x4[2] = ex->params[24]; + var42.x4[3] = ex->params[24]; + /* 11: loadpl */ + var55.i = (int) 0xffffffff; /* -1 or 2.122e-314f */ + /* 28: loadpl */ + var43.i = (int) 0x00ffffff; /* 16777215 or 8.28905e-317f */ + /* 31: loadpl */ + var44.i = (int) 0xff000000; /* -16777216 or 2.11371e-314f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var45 = ptr4[i]; + /* 1: shrul */ + var46.i = ((orc_uint32) var45.i) >> 24; + /* 2: convlw */ + var47.i = var46.i; + /* 3: convwb */ + var48 = var47.i; + /* 4: splatbl */ + var49.i = + ((((orc_uint32) var48) & 0xff) << 24) | ((((orc_uint32) var48) & 0xff) + << 16) | ((((orc_uint32) var48) & 0xff) << 8) | (((orc_uint32) var48) + & 0xff); + /* 5: convubw */ + var50.x4[0] = (orc_uint8) var49.x4[0]; + var50.x4[1] = (orc_uint8) var49.x4[1]; + var50.x4[2] = (orc_uint8) var49.x4[2]; + var50.x4[3] = (orc_uint8) var49.x4[3]; + /* 7: mullw */ + var51.x4[0] = (var50.x4[0] * var42.x4[0]) & 0xffff; + var51.x4[1] = (var50.x4[1] * var42.x4[1]) & 0xffff; + var51.x4[2] = (var50.x4[2] * var42.x4[2]) & 0xffff; + var51.x4[3] = (var50.x4[3] * var42.x4[3]) & 0xffff; + /* 8: shruw */ + var52.x4[0] = ((orc_uint16) var51.x4[0]) >> 8; + var52.x4[1] = ((orc_uint16) var51.x4[1]) >> 8; + var52.x4[2] = ((orc_uint16) var51.x4[2]) >> 8; + var52.x4[3] = ((orc_uint16) var51.x4[3]) >> 8; + /* 9: convubw */ + var53.x4[0] = (orc_uint8) var45.x4[0]; + var53.x4[1] = (orc_uint8) var45.x4[1]; + var53.x4[2] = (orc_uint8) var45.x4[2]; + var53.x4[3] = (orc_uint8) var45.x4[3]; + /* 10: mullw */ + var54.x4[0] = (var53.x4[0] * var52.x4[0]) & 0xffff; + var54.x4[1] = (var53.x4[1] * var52.x4[1]) & 0xffff; + var54.x4[2] = (var53.x4[2] * var52.x4[2]) & 0xffff; + var54.x4[3] = (var53.x4[3] * var52.x4[3]) & 0xffff; + /* 12: convubw */ + var56.x4[0] = (orc_uint8) var55.x4[0]; + var56.x4[1] = (orc_uint8) var55.x4[1]; + var56.x4[2] = (orc_uint8) var55.x4[2]; + var56.x4[3] = (orc_uint8) var55.x4[3]; + /* 13: subw */ + var57.x4[0] = var56.x4[0] - var52.x4[0]; + var57.x4[1] = var56.x4[1] - var52.x4[1]; + var57.x4[2] = var56.x4[2] - var52.x4[2]; + var57.x4[3] = var56.x4[3] - var52.x4[3]; + /* 14: loadl */ + var58 = ptr0[i]; + /* 15: shrul */ + var59.i = ((orc_uint32) var58.i) >> 24; + /* 16: convlw */ + var60.i = var59.i; + /* 17: convwb */ + var61 = var60.i; + /* 18: splatbl */ + var62.i = + ((((orc_uint32) var61) & 0xff) << 24) | ((((orc_uint32) var61) & 0xff) + << 16) | ((((orc_uint32) var61) & 0xff) << 8) | (((orc_uint32) var61) + & 0xff); + /* 19: convubw */ + var63.x4[0] = (orc_uint8) var62.x4[0]; + var63.x4[1] = (orc_uint8) var62.x4[1]; + var63.x4[2] = (orc_uint8) var62.x4[2]; + var63.x4[3] = (orc_uint8) var62.x4[3]; + /* 20: mullw */ + var64.x4[0] = (var63.x4[0] * var57.x4[0]) & 0xffff; + var64.x4[1] = (var63.x4[1] * var57.x4[1]) & 0xffff; + var64.x4[2] = (var63.x4[2] * var57.x4[2]) & 0xffff; + var64.x4[3] = (var63.x4[3] * var57.x4[3]) & 0xffff; + /* 21: div255w */ + var65.x4[0] = + ((orc_uint16) (((orc_uint16) (var64.x4[0] + 128)) + + (((orc_uint16) (var64.x4[0] + 128)) >> 8))) >> 8; + var65.x4[1] = + ((orc_uint16) (((orc_uint16) (var64.x4[1] + 128)) + + (((orc_uint16) (var64.x4[1] + 128)) >> 8))) >> 8; + var65.x4[2] = + ((orc_uint16) (((orc_uint16) (var64.x4[2] + 128)) + + (((orc_uint16) (var64.x4[2] + 128)) >> 8))) >> 8; + var65.x4[3] = + ((orc_uint16) (((orc_uint16) (var64.x4[3] + 128)) + + (((orc_uint16) (var64.x4[3] + 128)) >> 8))) >> 8; + /* 22: convubw */ + var66.x4[0] = (orc_uint8) var58.x4[0]; + var66.x4[1] = (orc_uint8) var58.x4[1]; + var66.x4[2] = (orc_uint8) var58.x4[2]; + var66.x4[3] = (orc_uint8) var58.x4[3]; + /* 23: mullw */ + var67.x4[0] = (var66.x4[0] * var65.x4[0]) & 0xffff; + var67.x4[1] = (var66.x4[1] * var65.x4[1]) & 0xffff; + var67.x4[2] = (var66.x4[2] * var65.x4[2]) & 0xffff; + var67.x4[3] = (var66.x4[3] * var65.x4[3]) & 0xffff; + /* 24: addw */ + var68.x4[0] = var67.x4[0] + var54.x4[0]; + var68.x4[1] = var67.x4[1] + var54.x4[1]; + var68.x4[2] = var67.x4[2] + var54.x4[2]; + var68.x4[3] = var67.x4[3] + var54.x4[3]; + /* 25: addw */ + var69.x4[0] = var65.x4[0] + var52.x4[0]; + var69.x4[1] = var65.x4[1] + var52.x4[1]; + var69.x4[2] = var65.x4[2] + var52.x4[2]; + var69.x4[3] = var65.x4[3] + var52.x4[3]; + /* 26: divluw */ + var70.x4[0] = + ((var69.x4[0] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var68.x4[0]) / + ((orc_uint16) var69.x4[0] & 0xff)); + var70.x4[1] = + ((var69.x4[1] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var68.x4[1]) / + ((orc_uint16) var69.x4[1] & 0xff)); + var70.x4[2] = + ((var69.x4[2] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var68.x4[2]) / + ((orc_uint16) var69.x4[2] & 0xff)); + var70.x4[3] = + ((var69.x4[3] & 0xff) == + 0) ? 255 : ORC_CLAMP_UB (((orc_uint16) var68.x4[3]) / + ((orc_uint16) var69.x4[3] & 0xff)); + /* 27: convwb */ + var71.x4[0] = var70.x4[0]; + var71.x4[1] = var70.x4[1]; + var71.x4[2] = var70.x4[2]; + var71.x4[3] = var70.x4[3]; + /* 29: andl */ + var72.i = var71.i & var43.i; + /* 30: convwb */ + var73.x4[0] = var69.x4[0]; + var73.x4[1] = var69.x4[1]; + var73.x4[2] = var69.x4[2]; + var73.x4[3] = var69.x4[3]; + /* 32: andl */ + var74.i = var73.i & var44.i; + /* 33: orl */ + var75.i = var72.i | var74.i; + /* 34: storel */ + ptr0[i] = var75; + } + } + +} + +void +video_mixer_orc_overlay_bgra (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 28, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95, + 111, 114, 99, 95, 111, 118, 101, 114, 108, 97, 121, 95, 98, 103, 114, + 97, + 11, 4, 4, 12, 4, 4, 14, 4, 255, 255, 255, 255, 14, 4, 0, 0, + 0, 255, 14, 4, 255, 255, 255, 0, 14, 4, 24, 0, 0, 0, 14, 2, + 8, 0, 0, 0, 16, 2, 20, 4, 20, 4, 20, 2, 20, 1, 20, 8, + 20, 8, 20, 8, 20, 4, 20, 8, 20, 8, 113, 32, 4, 126, 33, 32, + 19, 163, 34, 33, 157, 35, 34, 152, 39, 35, 21, 2, 150, 36, 39, 21, + 2, 89, 36, 36, 24, 21, 2, 95, 36, 36, 20, 21, 2, 150, 41, 32, + 21, 2, 89, 41, 41, 36, 115, 39, 16, 21, 2, 150, 37, 39, 21, 2, + 98, 37, 37, 36, 113, 32, 0, 126, 33, 32, 19, 163, 34, 33, 157, 35, + 34, 152, 39, 35, 21, 2, 150, 38, 39, 21, 2, 89, 38, 38, 37, 21, + 2, 80, 38, 38, 21, 2, 150, 40, 32, 21, 2, 89, 40, 40, 38, 21, + 2, 70, 40, 40, 41, 21, 2, 70, 38, 38, 36, 21, 2, 81, 40, 40, + 38, 21, 2, 157, 32, 40, 106, 32, 32, 18, 21, 2, 157, 39, 38, 106, + 39, 39, 17, 123, 32, 32, 39, 128, 0, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, _backup_video_mixer_orc_overlay_bgra); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, "video_mixer_orc_overlay_bgra"); + orc_program_set_backup_function (p, _backup_video_mixer_orc_overlay_bgra); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_constant (p, 4, 0xffffffff, "c1"); + orc_program_add_constant (p, 4, 0xff000000, "c2"); + orc_program_add_constant (p, 4, 0x00ffffff, "c3"); + orc_program_add_constant (p, 4, 0x00000018, "c4"); + orc_program_add_constant (p, 2, 0x00000008, "c5"); + orc_program_add_parameter (p, 2, "p1"); + orc_program_add_temporary (p, 4, "t1"); + orc_program_add_temporary (p, 4, "t2"); + orc_program_add_temporary (p, 2, "t3"); + orc_program_add_temporary (p, 1, "t4"); + orc_program_add_temporary (p, 8, "t5"); + orc_program_add_temporary (p, 8, "t6"); + orc_program_add_temporary (p, 8, "t7"); + orc_program_add_temporary (p, 4, "t8"); + orc_program_add_temporary (p, 8, "t9"); + orc_program_add_temporary (p, 8, "t10"); + + orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "shrul", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_C4, + ORC_VAR_D1); + orc_program_append_2 (p, "convlw", 0, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbl", 0, ORC_VAR_T8, ORC_VAR_T4, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T5, ORC_VAR_T8, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "shruw", 2, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_C5, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T10, ORC_VAR_T1, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T10, ORC_VAR_T10, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "loadpl", 0, ORC_VAR_T8, ORC_VAR_C1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T6, ORC_VAR_T8, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "subw", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_D1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "shrul", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_C4, + ORC_VAR_D1); + orc_program_append_2 (p, "convlw", 0, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbl", 0, ORC_VAR_T8, ORC_VAR_T4, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T7, ORC_VAR_T8, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_T6, + ORC_VAR_D1); + orc_program_append_2 (p, "div255w", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "convubw", 2, ORC_VAR_T9, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mullw", 2, ORC_VAR_T9, ORC_VAR_T9, ORC_VAR_T7, + ORC_VAR_D1); + orc_program_append_2 (p, "addw", 2, ORC_VAR_T9, ORC_VAR_T9, ORC_VAR_T10, + ORC_VAR_D1); + orc_program_append_2 (p, "addw", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "divluw", 2, ORC_VAR_T9, ORC_VAR_T9, ORC_VAR_T7, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 2, ORC_VAR_T1, ORC_VAR_T9, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "andl", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C3, + ORC_VAR_D1); + orc_program_append_2 (p, "convwb", 2, ORC_VAR_T8, ORC_VAR_T7, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "andl", 0, ORC_VAR_T8, ORC_VAR_T8, ORC_VAR_C2, + ORC_VAR_D1); + orc_program_append_2 (p, "orl", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_T8, + ORC_VAR_D1); + orc_program_append_2 (p, "storel", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->params[ORC_VAR_P1] = p1; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_memcpy_2d */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_memcpy_2d (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + int i; + int j; + orc_int8 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + orc_int8 var32; + orc_int8 var33; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var32 = ptr4[i]; + /* 1: copyb */ + var33 = var32; + /* 2: storeb */ + ptr0[i] = var33; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_memcpy_2d (OrcExecutor * ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_int8 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + orc_int8 var32; + orc_int8 var33; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var32 = ptr4[i]; + /* 1: copyb */ + var33 = var32; + /* 2: storeb */ + ptr0[i] = var33; + } + } + +} + +void +videomixer_video_convert_orc_memcpy_2d (guint8 * ORC_RESTRICT d1, int d1_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 38, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 109, 101, 109, 99, 112, 121, 95, 50, 100, 11, 1, 1, 12, 1, 1, + 42, 0, 4, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_memcpy_2d); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, "videomixer_video_convert_orc_memcpy_2d"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_memcpy_2d); + orc_program_add_destination (p, 1, "d1"); + orc_program_add_source (p, 1, "s1"); + + orc_program_append_2 (p, "copyb", 0, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_I420_UYVY */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_I420_UYVY (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, + const guint8 * ORC_RESTRICT s4, int n) +{ + int i; + orc_union32 *ORC_RESTRICT ptr0; + orc_union32 *ORC_RESTRICT ptr1; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_union16 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + const orc_int8 *ORC_RESTRICT ptr7; + orc_int8 var33; + orc_int8 var34; + orc_union16 var35; + orc_union32 var36; + orc_union16 var37; + orc_union32 var38; + orc_union16 var39; + + ptr0 = (orc_union32 *) d1; + ptr1 = (orc_union32 *) d2; + ptr4 = (orc_union16 *) s1; + ptr5 = (orc_union16 *) s2; + ptr6 = (orc_int8 *) s3; + ptr7 = (orc_int8 *) s4; + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr6[i]; + /* 1: loadb */ + var34 = ptr7[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var33; + _dest.x2[1] = var34; + var39.i = _dest.i; + } + /* 3: loadw */ + var35 = ptr4[i]; + /* 4: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var39.x2[0]; + _dest.x2[1] = var35.x2[0]; + var36.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var39.x2[1]; + _dest.x2[1] = var35.x2[1]; + var36.x2[1] = _dest.i; + } + /* 5: storel */ + ptr0[i] = var36; + /* 6: loadw */ + var37 = ptr5[i]; + /* 7: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var39.x2[0]; + _dest.x2[1] = var37.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var39.x2[1]; + _dest.x2[1] = var37.x2[1]; + var38.x2[1] = _dest.i; + } + /* 8: storel */ + ptr1[i] = var38; + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_I420_UYVY (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int n = ex->n; + orc_union32 *ORC_RESTRICT ptr0; + orc_union32 *ORC_RESTRICT ptr1; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_union16 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + const orc_int8 *ORC_RESTRICT ptr7; + orc_int8 var33; + orc_int8 var34; + orc_union16 var35; + orc_union32 var36; + orc_union16 var37; + orc_union32 var38; + orc_union16 var39; + + ptr0 = (orc_union32 *) ex->arrays[0]; + ptr1 = (orc_union32 *) ex->arrays[1]; + ptr4 = (orc_union16 *) ex->arrays[4]; + ptr5 = (orc_union16 *) ex->arrays[5]; + ptr6 = (orc_int8 *) ex->arrays[6]; + ptr7 = (orc_int8 *) ex->arrays[7]; + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr6[i]; + /* 1: loadb */ + var34 = ptr7[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var33; + _dest.x2[1] = var34; + var39.i = _dest.i; + } + /* 3: loadw */ + var35 = ptr4[i]; + /* 4: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var39.x2[0]; + _dest.x2[1] = var35.x2[0]; + var36.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var39.x2[1]; + _dest.x2[1] = var35.x2[1]; + var36.x2[1] = _dest.i; + } + /* 5: storel */ + ptr0[i] = var36; + /* 6: loadw */ + var37 = ptr5[i]; + /* 7: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var39.x2[0]; + _dest.x2[1] = var37.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var39.x2[1]; + _dest.x2[1] = var37.x2[1]; + var38.x2[1] = _dest.i; + } + /* 8: storel */ + ptr1[i] = var38; + } + +} + +void +videomixer_video_convert_orc_convert_I420_UYVY (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, + const guint8 * ORC_RESTRICT s4, int n) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, + 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, 99, + 95, + 99, 111, 110, 118, 101, 114, 116, 95, 73, 52, 50, 48, 95, 85, 89, 86, + 89, 11, 4, 4, 11, 4, 4, 12, 2, 2, 12, 2, 2, 12, 1, 1, + 12, 1, 1, 20, 2, 196, 32, 6, 7, 21, 1, 196, 0, 32, 4, 21, + 1, 196, 1, 32, 5, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_I420_UYVY); +#else + p = orc_program_new (); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_I420_UYVY"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_I420_UYVY); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_destination (p, 4, "d2"); + orc_program_add_source (p, 2, "s1"); + orc_program_add_source (p, 2, "s2"); + orc_program_add_source (p, 1, "s3"); + orc_program_add_source (p, 1, "s4"); + orc_program_add_temporary (p, 2, "t1"); + + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T1, ORC_VAR_S3, ORC_VAR_S4, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D2, ORC_VAR_T1, ORC_VAR_S2, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->arrays[ORC_VAR_D2] = d2; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->arrays[ORC_VAR_S3] = (void *) s3; + ex->arrays[ORC_VAR_S4] = (void *) s4; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_I420_YUY2 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_I420_YUY2 (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, + const guint8 * ORC_RESTRICT s4, int n) +{ + int i; + orc_union32 *ORC_RESTRICT ptr0; + orc_union32 *ORC_RESTRICT ptr1; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_union16 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + const orc_int8 *ORC_RESTRICT ptr7; + orc_int8 var33; + orc_int8 var34; + orc_union16 var35; + orc_union32 var36; + orc_union16 var37; + orc_union32 var38; + orc_union16 var39; + + ptr0 = (orc_union32 *) d1; + ptr1 = (orc_union32 *) d2; + ptr4 = (orc_union16 *) s1; + ptr5 = (orc_union16 *) s2; + ptr6 = (orc_int8 *) s3; + ptr7 = (orc_int8 *) s4; + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr6[i]; + /* 1: loadb */ + var34 = ptr7[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var33; + _dest.x2[1] = var34; + var39.i = _dest.i; + } + /* 3: loadw */ + var35 = ptr4[i]; + /* 4: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var35.x2[0]; + _dest.x2[1] = var39.x2[0]; + var36.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var35.x2[1]; + _dest.x2[1] = var39.x2[1]; + var36.x2[1] = _dest.i; + } + /* 5: storel */ + ptr0[i] = var36; + /* 6: loadw */ + var37 = ptr5[i]; + /* 7: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[0]; + _dest.x2[1] = var39.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[1]; + _dest.x2[1] = var39.x2[1]; + var38.x2[1] = _dest.i; + } + /* 8: storel */ + ptr1[i] = var38; + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_I420_YUY2 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int n = ex->n; + orc_union32 *ORC_RESTRICT ptr0; + orc_union32 *ORC_RESTRICT ptr1; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_union16 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + const orc_int8 *ORC_RESTRICT ptr7; + orc_int8 var33; + orc_int8 var34; + orc_union16 var35; + orc_union32 var36; + orc_union16 var37; + orc_union32 var38; + orc_union16 var39; + + ptr0 = (orc_union32 *) ex->arrays[0]; + ptr1 = (orc_union32 *) ex->arrays[1]; + ptr4 = (orc_union16 *) ex->arrays[4]; + ptr5 = (orc_union16 *) ex->arrays[5]; + ptr6 = (orc_int8 *) ex->arrays[6]; + ptr7 = (orc_int8 *) ex->arrays[7]; + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr6[i]; + /* 1: loadb */ + var34 = ptr7[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var33; + _dest.x2[1] = var34; + var39.i = _dest.i; + } + /* 3: loadw */ + var35 = ptr4[i]; + /* 4: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var35.x2[0]; + _dest.x2[1] = var39.x2[0]; + var36.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var35.x2[1]; + _dest.x2[1] = var39.x2[1]; + var36.x2[1] = _dest.i; + } + /* 5: storel */ + ptr0[i] = var36; + /* 6: loadw */ + var37 = ptr5[i]; + /* 7: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[0]; + _dest.x2[1] = var39.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[1]; + _dest.x2[1] = var39.x2[1]; + var38.x2[1] = _dest.i; + } + /* 8: storel */ + ptr1[i] = var38; + } + +} + +void +videomixer_video_convert_orc_convert_I420_YUY2 (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, + const guint8 * ORC_RESTRICT s4, int n) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, + 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, 99, + 95, + 99, 111, 110, 118, 101, 114, 116, 95, 73, 52, 50, 48, 95, 89, 85, 89, + 50, 11, 4, 4, 11, 4, 4, 12, 2, 2, 12, 2, 2, 12, 1, 1, + 12, 1, 1, 20, 2, 196, 32, 6, 7, 21, 1, 196, 0, 4, 32, 21, + 1, 196, 1, 5, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_I420_YUY2); +#else + p = orc_program_new (); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_I420_YUY2"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_I420_YUY2); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_destination (p, 4, "d2"); + orc_program_add_source (p, 2, "s1"); + orc_program_add_source (p, 2, "s2"); + orc_program_add_source (p, 1, "s3"); + orc_program_add_source (p, 1, "s4"); + orc_program_add_temporary (p, 2, "t1"); + + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T1, ORC_VAR_S3, ORC_VAR_S4, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_T1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D2, ORC_VAR_S2, ORC_VAR_T1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->arrays[ORC_VAR_D2] = d2; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->arrays[ORC_VAR_S3] = (void *) s3; + ex->arrays[ORC_VAR_S4] = (void *) s4; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_I420_AYUV */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_I420_AYUV (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, + const guint8 * ORC_RESTRICT s4, int n) +{ + int i; + orc_union32 *ORC_RESTRICT ptr0; + orc_union32 *ORC_RESTRICT ptr1; + const orc_int8 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + const orc_int8 *ORC_RESTRICT ptr7; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_int8 var36; +#else + orc_int8 var36; +#endif + orc_int8 var37; + orc_union32 var38; + orc_int8 var39; + orc_union32 var40; + orc_int8 var41; + orc_int8 var42; + orc_union16 var43; + orc_union16 var44; + orc_union16 var45; + + ptr0 = (orc_union32 *) d1; + ptr1 = (orc_union32 *) d2; + ptr4 = (orc_int8 *) s1; + ptr5 = (orc_int8 *) s2; + ptr6 = (orc_int8 *) s3; + ptr7 = (orc_int8 *) s4; + + /* 3: loadpb */ + var36 = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadupdb */ + var41 = ptr6[i >> 1]; + /* 1: loadupdb */ + var42 = ptr7[i >> 1]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var41; + _dest.x2[1] = var42; + var43.i = _dest.i; + } + /* 4: loadb */ + var37 = ptr4[i]; + /* 5: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36; + _dest.x2[1] = var37; + var44.i = _dest.i; + } + /* 6: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var44.i; + _dest.x2[1] = var43.i; + var38.i = _dest.i; + } + /* 7: storel */ + ptr0[i] = var38; + /* 8: loadb */ + var39 = ptr5[i]; + /* 9: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36; + _dest.x2[1] = var39; + var45.i = _dest.i; + } + /* 10: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var45.i; + _dest.x2[1] = var43.i; + var40.i = _dest.i; + } + /* 11: storel */ + ptr1[i] = var40; + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_I420_AYUV (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int n = ex->n; + orc_union32 *ORC_RESTRICT ptr0; + orc_union32 *ORC_RESTRICT ptr1; + const orc_int8 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + const orc_int8 *ORC_RESTRICT ptr7; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_int8 var36; +#else + orc_int8 var36; +#endif + orc_int8 var37; + orc_union32 var38; + orc_int8 var39; + orc_union32 var40; + orc_int8 var41; + orc_int8 var42; + orc_union16 var43; + orc_union16 var44; + orc_union16 var45; + + ptr0 = (orc_union32 *) ex->arrays[0]; + ptr1 = (orc_union32 *) ex->arrays[1]; + ptr4 = (orc_int8 *) ex->arrays[4]; + ptr5 = (orc_int8 *) ex->arrays[5]; + ptr6 = (orc_int8 *) ex->arrays[6]; + ptr7 = (orc_int8 *) ex->arrays[7]; + + /* 3: loadpb */ + var36 = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadupdb */ + var41 = ptr6[i >> 1]; + /* 1: loadupdb */ + var42 = ptr7[i >> 1]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var41; + _dest.x2[1] = var42; + var43.i = _dest.i; + } + /* 4: loadb */ + var37 = ptr4[i]; + /* 5: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36; + _dest.x2[1] = var37; + var44.i = _dest.i; + } + /* 6: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var44.i; + _dest.x2[1] = var43.i; + var38.i = _dest.i; + } + /* 7: storel */ + ptr0[i] = var38; + /* 8: loadb */ + var39 = ptr5[i]; + /* 9: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36; + _dest.x2[1] = var39; + var45.i = _dest.i; + } + /* 10: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var45.i; + _dest.x2[1] = var43.i; + var40.i = _dest.i; + } + /* 11: storel */ + ptr1[i] = var40; + } + +} + +void +videomixer_video_convert_orc_convert_I420_AYUV (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, + const guint8 * ORC_RESTRICT s4, int n) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, + 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, 99, + 95, + 99, 111, 110, 118, 101, 114, 116, 95, 73, 52, 50, 48, 95, 65, 89, 85, + 86, 11, 4, 4, 11, 4, 4, 12, 1, 1, 12, 1, 1, 12, 1, 1, + 12, 1, 1, 14, 1, 255, 0, 0, 0, 20, 2, 20, 2, 20, 1, 20, + 1, 45, 34, 6, 45, 35, 7, 196, 32, 34, 35, 196, 33, 16, 4, 195, + 0, 33, 32, 196, 33, 16, 5, 195, 1, 33, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_I420_AYUV); +#else + p = orc_program_new (); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_I420_AYUV"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_I420_AYUV); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_destination (p, 4, "d2"); + orc_program_add_source (p, 1, "s1"); + orc_program_add_source (p, 1, "s2"); + orc_program_add_source (p, 1, "s3"); + orc_program_add_source (p, 1, "s4"); + orc_program_add_constant (p, 1, 0x000000ff, "c1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 1, "t3"); + orc_program_add_temporary (p, 1, "t4"); + + orc_program_append_2 (p, "loadupdb", 0, ORC_VAR_T3, ORC_VAR_S3, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "loadupdb", 0, ORC_VAR_T4, ORC_VAR_S4, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T1, ORC_VAR_T3, ORC_VAR_T4, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T2, ORC_VAR_C1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_D1, ORC_VAR_T2, ORC_VAR_T1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T2, ORC_VAR_C1, ORC_VAR_S2, + ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_D2, ORC_VAR_T2, ORC_VAR_T1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->arrays[ORC_VAR_D2] = d2; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->arrays[ORC_VAR_S3] = (void *) s3; + ex->arrays[ORC_VAR_S4] = (void *) s4; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_YUY2_I420 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_YUY2_I420 (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, guint8 * ORC_RESTRICT d3, + guint8 * ORC_RESTRICT d4, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, int n) +{ + int i; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + orc_int8 *ORC_RESTRICT ptr3; + const orc_union32 *ORC_RESTRICT ptr4; + const orc_union32 *ORC_RESTRICT ptr5; + orc_union32 var35; + orc_union32 var36; + orc_int8 var37; + orc_int8 var38; + orc_union16 var39; + orc_union16 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + + ptr0 = (orc_union16 *) d1; + ptr1 = (orc_union16 *) d2; + ptr2 = (orc_int8 *) d3; + ptr3 = (orc_int8 *) d4; + ptr4 = (orc_union32 *) s1; + ptr5 = (orc_union32 *) s2; + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var35 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var35.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var35.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var40; + /* 3: loadl */ + var36 = ptr5[i]; + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var36.x2[0]; + var41.x2[0] = _src.x2[1]; + var42.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var36.x2[1]; + var41.x2[1] = _src.x2[1]; + var42.x2[1] = _src.x2[0]; + } + /* 5: storew */ + ptr1[i] = var42; + /* 6: avgub */ + var43.x2[0] = ((orc_uint8) var39.x2[0] + (orc_uint8) var41.x2[0] + 1) >> 1; + var43.x2[1] = ((orc_uint8) var39.x2[1] + (orc_uint8) var41.x2[1] + 1) >> 1; + /* 7: splitwb */ + { + orc_union16 _src; + _src.i = var43.i; + var37 = _src.x2[1]; + var38 = _src.x2[0]; + } + /* 8: storeb */ + ptr3[i] = var37; + /* 9: storeb */ + ptr2[i] = var38; + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_YUY2_I420 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int n = ex->n; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + orc_int8 *ORC_RESTRICT ptr3; + const orc_union32 *ORC_RESTRICT ptr4; + const orc_union32 *ORC_RESTRICT ptr5; + orc_union32 var35; + orc_union32 var36; + orc_int8 var37; + orc_int8 var38; + orc_union16 var39; + orc_union16 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + + ptr0 = (orc_union16 *) ex->arrays[0]; + ptr1 = (orc_union16 *) ex->arrays[1]; + ptr2 = (orc_int8 *) ex->arrays[2]; + ptr3 = (orc_int8 *) ex->arrays[3]; + ptr4 = (orc_union32 *) ex->arrays[4]; + ptr5 = (orc_union32 *) ex->arrays[5]; + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var35 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var35.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var35.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var40; + /* 3: loadl */ + var36 = ptr5[i]; + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var36.x2[0]; + var41.x2[0] = _src.x2[1]; + var42.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var36.x2[1]; + var41.x2[1] = _src.x2[1]; + var42.x2[1] = _src.x2[0]; + } + /* 5: storew */ + ptr1[i] = var42; + /* 6: avgub */ + var43.x2[0] = ((orc_uint8) var39.x2[0] + (orc_uint8) var41.x2[0] + 1) >> 1; + var43.x2[1] = ((orc_uint8) var39.x2[1] + (orc_uint8) var41.x2[1] + 1) >> 1; + /* 7: splitwb */ + { + orc_union16 _src; + _src.i = var43.i; + var37 = _src.x2[1]; + var38 = _src.x2[0]; + } + /* 8: storeb */ + ptr3[i] = var37; + /* 9: storeb */ + ptr2[i] = var38; + } + +} + +void +videomixer_video_convert_orc_convert_YUY2_I420 (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, guint8 * ORC_RESTRICT d3, + guint8 * ORC_RESTRICT d4, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, int n) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, + 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, 99, + 95, + 99, 111, 110, 118, 101, 114, 116, 95, 89, 85, 89, 50, 95, 73, 52, 50, + 48, 11, 2, 2, 11, 2, 2, 11, 1, 1, 11, 1, 1, 12, 4, 4, + 12, 4, 4, 20, 2, 20, 2, 20, 2, 21, 1, 199, 32, 34, 4, 97, + 0, 34, 21, 1, 199, 33, 34, 5, 97, 1, 34, 21, 1, 39, 32, 32, + 33, 199, 3, 2, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_YUY2_I420); +#else + p = orc_program_new (); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_YUY2_I420"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_YUY2_I420); + orc_program_add_destination (p, 2, "d1"); + orc_program_add_destination (p, 2, "d2"); + orc_program_add_destination (p, 1, "d3"); + orc_program_add_destination (p, 1, "d4"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_source (p, 4, "s2"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 2, "t3"); + + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T1, ORC_VAR_T3, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "storew", 0, ORC_VAR_D1, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T2, ORC_VAR_T3, ORC_VAR_S2, + ORC_VAR_D1); + orc_program_append_2 (p, "storew", 0, ORC_VAR_D2, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 1, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_T2, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_D4, ORC_VAR_D3, ORC_VAR_T1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->arrays[ORC_VAR_D2] = d2; + ex->arrays[ORC_VAR_D3] = d3; + ex->arrays[ORC_VAR_D4] = d4; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->arrays[ORC_VAR_S2] = (void *) s2; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_UYVY_YUY2 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_UYVY_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var32; + orc_union32 var33; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var32 = ptr4[i]; + /* 1: swapw */ + var33.x2[0] = ORC_SWAP_W (var32.x2[0]); + var33.x2[1] = ORC_SWAP_W (var32.x2[1]); + /* 2: storel */ + ptr0[i] = var33; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_UYVY_YUY2 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var32; + orc_union32 var33; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var32 = ptr4[i]; + /* 1: swapw */ + var33.x2[0] = ORC_SWAP_W (var32.x2[0]); + var33.x2[1] = ORC_SWAP_W (var32.x2[1]); + /* 2: storel */ + ptr0[i] = var33; + } + } + +} + +void +videomixer_video_convert_orc_convert_UYVY_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 85, 89, 86, 89, 95, 89, 85, + 89, 50, 11, 4, 4, 12, 4, 4, 21, 1, 183, 0, 4, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_UYVY_YUY2); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_UYVY_YUY2"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_UYVY_YUY2); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + + orc_program_append_2 (p, "swapw", 1, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_planar_chroma_420_422 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_planar_chroma_420_422 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + int i; + int j; + orc_int8 *ORC_RESTRICT ptr0; + orc_int8 *ORC_RESTRICT ptr1; + const orc_int8 *ORC_RESTRICT ptr4; + orc_int8 var32; + orc_int8 var33; + orc_int8 var34; + orc_int8 var35; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr1 = ORC_PTR_OFFSET (d2, d2_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var32 = ptr4[i]; + /* 1: copyb */ + var33 = var32; + /* 2: storeb */ + ptr0[i] = var33; + /* 3: loadb */ + var34 = ptr4[i]; + /* 4: copyb */ + var35 = var34; + /* 5: storeb */ + ptr1[i] = var35; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_planar_chroma_420_422 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_int8 *ORC_RESTRICT ptr0; + orc_int8 *ORC_RESTRICT ptr1; + const orc_int8 *ORC_RESTRICT ptr4; + orc_int8 var32; + orc_int8 var33; + orc_int8 var34; + orc_int8 var35; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr1 = ORC_PTR_OFFSET (ex->arrays[1], ex->params[1] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var32 = ptr4[i]; + /* 1: copyb */ + var33 = var32; + /* 2: storeb */ + ptr0[i] = var33; + /* 3: loadb */ + var34 = ptr4[i]; + /* 4: copyb */ + var35 = var34; + /* 5: storeb */ + ptr1[i] = var35; + } + } + +} + +void +videomixer_video_convert_orc_planar_chroma_420_422 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 50, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 112, 108, 97, 110, 97, 114, 95, 99, 104, 114, 111, 109, 97, 95, 52, + 50, 48, 95, 52, 50, 50, 11, 1, 1, 11, 1, 1, 12, 1, 1, 42, + 0, 4, 42, 1, 4, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_420_422); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_planar_chroma_420_422"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_420_422); + orc_program_add_destination (p, 1, "d1"); + orc_program_add_destination (p, 1, "d2"); + orc_program_add_source (p, 1, "s1"); + + orc_program_append_2 (p, "copyb", 0, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "copyb", 0, ORC_VAR_D2, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_D2] = d2; + ex->params[ORC_VAR_D2] = d2_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_planar_chroma_420_444 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_planar_chroma_420_444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + int i; + int j; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + const orc_int8 *ORC_RESTRICT ptr4; + orc_int8 var33; + orc_union16 var34; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr1 = ORC_PTR_OFFSET (d2, d2_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr4[i]; + /* 1: splatbw */ + var34.i = ((var33 & 0xff) << 8) | (var33 & 0xff); + /* 2: storew */ + ptr0[i] = var34; + /* 3: storew */ + ptr1[i] = var34; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_planar_chroma_420_444 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + const orc_int8 *ORC_RESTRICT ptr4; + orc_int8 var33; + orc_union16 var34; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr1 = ORC_PTR_OFFSET (ex->arrays[1], ex->params[1] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr4[i]; + /* 1: splatbw */ + var34.i = ((var33 & 0xff) << 8) | (var33 & 0xff); + /* 2: storew */ + ptr0[i] = var34; + /* 3: storew */ + ptr1[i] = var34; + } + } + +} + +void +videomixer_video_convert_orc_planar_chroma_420_444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 50, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 112, 108, 97, 110, 97, 114, 95, 99, 104, 114, 111, 109, 97, 95, 52, + 50, 48, 95, 52, 52, 52, 11, 2, 2, 11, 2, 2, 12, 1, 1, 20, + 2, 151, 32, 4, 97, 0, 32, 97, 1, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_420_444); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_planar_chroma_420_444"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_420_444); + orc_program_add_destination (p, 2, "d1"); + orc_program_add_destination (p, 2, "d2"); + orc_program_add_source (p, 1, "s1"); + orc_program_add_temporary (p, 2, "t1"); + + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "storew", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "storew", 0, ORC_VAR_D2, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_D2] = d2; + ex->params[ORC_VAR_D2] = d2_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_planar_chroma_422_444 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_planar_chroma_422_444 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + int i; + int j; + orc_union16 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + orc_int8 var33; + orc_union16 var34; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr4[i]; + /* 1: splatbw */ + var34.i = ((var33 & 0xff) << 8) | (var33 & 0xff); + /* 2: storew */ + ptr0[i] = var34; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_planar_chroma_422_444 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union16 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + orc_int8 var33; + orc_union16 var34; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr4[i]; + /* 1: splatbw */ + var34.i = ((var33 & 0xff) << 8) | (var33 & 0xff); + /* 2: storew */ + ptr0[i] = var34; + } + } + +} + +void +videomixer_video_convert_orc_planar_chroma_422_444 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 50, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 112, 108, 97, 110, 97, 114, 95, 99, 104, 114, 111, 109, 97, 95, 52, + 50, 50, 95, 52, 52, 52, 11, 2, 2, 12, 1, 1, 20, 2, 151, 32, + 4, 97, 0, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_422_444); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_planar_chroma_422_444"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_422_444); + orc_program_add_destination (p, 2, "d1"); + orc_program_add_source (p, 1, "s1"); + orc_program_add_temporary (p, 2, "t1"); + + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "storew", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_planar_chroma_444_422 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_planar_chroma_444_422 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + int i; + int j; + orc_int8 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + orc_union16 var34; + orc_int8 var35; + orc_int8 var36; + orc_int8 var37; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadw */ + var34 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var34.i; + var36 = _src.x2[1]; + var37 = _src.x2[0]; + } + /* 2: avgub */ + var35 = ((orc_uint8) var36 + (orc_uint8) var37 + 1) >> 1; + /* 3: storeb */ + ptr0[i] = var35; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_planar_chroma_444_422 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_int8 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + orc_union16 var34; + orc_int8 var35; + orc_int8 var36; + orc_int8 var37; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadw */ + var34 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var34.i; + var36 = _src.x2[1]; + var37 = _src.x2[0]; + } + /* 2: avgub */ + var35 = ((orc_uint8) var36 + (orc_uint8) var37 + 1) >> 1; + /* 3: storeb */ + ptr0[i] = var35; + } + } + +} + +void +videomixer_video_convert_orc_planar_chroma_444_422 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 50, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 112, 108, 97, 110, 97, 114, 95, 99, 104, 114, 111, 109, 97, 95, 52, + 52, 52, 95, 52, 50, 50, 11, 1, 1, 12, 2, 2, 20, 1, 20, 1, + 199, 32, 33, 4, 39, 0, 32, 33, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_444_422); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_planar_chroma_444_422"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_444_422); + orc_program_add_destination (p, 1, "d1"); + orc_program_add_source (p, 2, "s1"); + orc_program_add_temporary (p, 1, "t1"); + orc_program_add_temporary (p, 1, "t2"); + + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T1, ORC_VAR_T2, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_T2, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_planar_chroma_444_420 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_planar_chroma_444_420 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m) +{ + int i; + int j; + orc_int8 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_union16 *ORC_RESTRICT ptr5; + orc_union16 var35; + orc_union16 var36; + orc_int8 var37; + orc_union16 var38; + orc_int8 var39; + orc_int8 var40; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + ptr5 = ORC_PTR_OFFSET (s2, s2_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadw */ + var35 = ptr4[i]; + /* 1: loadw */ + var36 = ptr5[i]; + /* 2: avgub */ + var38.x2[0] = + ((orc_uint8) var35.x2[0] + (orc_uint8) var36.x2[0] + 1) >> 1; + var38.x2[1] = + ((orc_uint8) var35.x2[1] + (orc_uint8) var36.x2[1] + 1) >> 1; + /* 3: splitwb */ + { + orc_union16 _src; + _src.i = var38.i; + var39 = _src.x2[1]; + var40 = _src.x2[0]; + } + /* 4: avgub */ + var37 = ((orc_uint8) var39 + (orc_uint8) var40 + 1) >> 1; + /* 5: storeb */ + ptr0[i] = var37; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_planar_chroma_444_420 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_int8 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_union16 *ORC_RESTRICT ptr5; + orc_union16 var35; + orc_union16 var36; + orc_int8 var37; + orc_union16 var38; + orc_int8 var39; + orc_int8 var40; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + ptr5 = ORC_PTR_OFFSET (ex->arrays[5], ex->params[5] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadw */ + var35 = ptr4[i]; + /* 1: loadw */ + var36 = ptr5[i]; + /* 2: avgub */ + var38.x2[0] = + ((orc_uint8) var35.x2[0] + (orc_uint8) var36.x2[0] + 1) >> 1; + var38.x2[1] = + ((orc_uint8) var35.x2[1] + (orc_uint8) var36.x2[1] + 1) >> 1; + /* 3: splitwb */ + { + orc_union16 _src; + _src.i = var38.i; + var39 = _src.x2[1]; + var40 = _src.x2[0]; + } + /* 4: avgub */ + var37 = ((orc_uint8) var39 + (orc_uint8) var40 + 1) >> 1; + /* 5: storeb */ + ptr0[i] = var37; + } + } + +} + +void +videomixer_video_convert_orc_planar_chroma_444_420 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 50, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 112, 108, 97, 110, 97, 114, 95, 99, 104, 114, 111, 109, 97, 95, 52, + 52, 52, 95, 52, 50, 48, 11, 1, 1, 12, 2, 2, 12, 2, 2, 20, + 2, 20, 1, 20, 1, 21, 1, 39, 32, 4, 5, 199, 33, 34, 32, 39, + 0, 33, 34, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_444_420); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_planar_chroma_444_420"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_444_420); + orc_program_add_destination (p, 1, "d1"); + orc_program_add_source (p, 2, "s1"); + orc_program_add_source (p, 2, "s2"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 1, "t2"); + orc_program_add_temporary (p, 1, "t3"); + + orc_program_append_2 (p, "avgub", 1, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_S2, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T2, ORC_VAR_T3, ORC_VAR_T1, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 0, ORC_VAR_D1, ORC_VAR_T2, ORC_VAR_T3, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->params[ORC_VAR_S2] = s2_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_planar_chroma_422_420 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_planar_chroma_422_420 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m) +{ + int i; + int j; + orc_int8 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + orc_int8 var32; + orc_int8 var33; + orc_int8 var34; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + ptr5 = ORC_PTR_OFFSET (s2, s2_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var32 = ptr4[i]; + /* 1: loadb */ + var33 = ptr5[i]; + /* 2: avgub */ + var34 = ((orc_uint8) var32 + (orc_uint8) var33 + 1) >> 1; + /* 3: storeb */ + ptr0[i] = var34; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_planar_chroma_422_420 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_int8 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + orc_int8 var32; + orc_int8 var33; + orc_int8 var34; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + ptr5 = ORC_PTR_OFFSET (ex->arrays[5], ex->params[5] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var32 = ptr4[i]; + /* 1: loadb */ + var33 = ptr5[i]; + /* 2: avgub */ + var34 = ((orc_uint8) var32 + (orc_uint8) var33 + 1) >> 1; + /* 3: storeb */ + ptr0[i] = var34; + } + } + +} + +void +videomixer_video_convert_orc_planar_chroma_422_420 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 50, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 112, 108, 97, 110, 97, 114, 95, 99, 104, 114, 111, 109, 97, 95, 52, + 50, 50, 95, 52, 50, 48, 11, 1, 1, 12, 1, 1, 12, 1, 1, 39, + 0, 4, 5, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_422_420); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_planar_chroma_422_420"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_planar_chroma_422_420); + orc_program_add_destination (p, 1, "d1"); + orc_program_add_source (p, 1, "s1"); + orc_program_add_source (p, 1, "s2"); + + orc_program_append_2 (p, "avgub", 0, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_S2, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->params[ORC_VAR_S2] = s2_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_YUY2_AYUV */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_YUY2_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + int i; + int j; + orc_union64 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var36; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union16 var37; +#else + orc_union16 var37; +#endif + orc_union64 var38; + orc_union16 var39; + orc_union16 var40; + orc_union32 var41; + orc_union32 var42; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 2: loadpb */ + var37.x2[0] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + var37.x2[1] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var36 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var36.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var36.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 3: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[0]; + _dest.x2[1] = var40.x2[0]; + var41.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[1]; + _dest.x2[1] = var40.x2[1]; + var41.x2[1] = _dest.i; + } + /* 4: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var39.i; + _dest.x2[1] = var39.i; + var42.i = _dest.i; + } + /* 5: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var41.x2[0]; + _dest.x2[1] = var42.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union32 _dest; + _dest.x2[0] = var41.x2[1]; + _dest.x2[1] = var42.x2[1]; + var38.x2[1] = _dest.i; + } + /* 6: storeq */ + ptr0[i] = var38; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_YUY2_AYUV (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union64 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var36; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union16 var37; +#else + orc_union16 var37; +#endif + orc_union64 var38; + orc_union16 var39; + orc_union16 var40; + orc_union32 var41; + orc_union32 var42; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 2: loadpb */ + var37.x2[0] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + var37.x2[1] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var36 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var36.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var36.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 3: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[0]; + _dest.x2[1] = var40.x2[0]; + var41.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[1]; + _dest.x2[1] = var40.x2[1]; + var41.x2[1] = _dest.i; + } + /* 4: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var39.i; + _dest.x2[1] = var39.i; + var42.i = _dest.i; + } + /* 5: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var41.x2[0]; + _dest.x2[1] = var42.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union32 _dest; + _dest.x2[0] = var41.x2[1]; + _dest.x2[1] = var42.x2[1]; + var38.x2[1] = _dest.i; + } + /* 6: storeq */ + ptr0[i] = var38; + } + } + +} + +void +videomixer_video_convert_orc_convert_YUY2_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 89, 85, 89, 50, 95, 65, 89, + 85, 86, 11, 8, 8, 12, 4, 4, 14, 2, 255, 0, 0, 0, 20, 2, + 20, 2, 20, 4, 20, 4, 21, 1, 199, 33, 32, 4, 21, 1, 196, 34, + 16, 32, 195, 35, 33, 33, 21, 1, 195, 0, 34, 35, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_YUY2_AYUV); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_YUY2_AYUV"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_YUY2_AYUV); + orc_program_add_destination (p, 8, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_constant (p, 2, 0x000000ff, "c1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 4, "t3"); + orc_program_add_temporary (p, 4, "t4"); + + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_T3, ORC_VAR_C1, ORC_VAR_T1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_T4, ORC_VAR_T2, ORC_VAR_T2, + ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 1, ORC_VAR_D1, ORC_VAR_T3, ORC_VAR_T4, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_UYVY_AYUV */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_UYVY_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + int i; + int j; + orc_union64 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var36; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union16 var37; +#else + orc_union16 var37; +#endif + orc_union64 var38; + orc_union16 var39; + orc_union16 var40; + orc_union32 var41; + orc_union32 var42; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 2: loadpb */ + var37.x2[0] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + var37.x2[1] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var36 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var36.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var36.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 3: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[0]; + _dest.x2[1] = var39.x2[0]; + var41.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[1]; + _dest.x2[1] = var39.x2[1]; + var41.x2[1] = _dest.i; + } + /* 4: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var40.i; + _dest.x2[1] = var40.i; + var42.i = _dest.i; + } + /* 5: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var41.x2[0]; + _dest.x2[1] = var42.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union32 _dest; + _dest.x2[0] = var41.x2[1]; + _dest.x2[1] = var42.x2[1]; + var38.x2[1] = _dest.i; + } + /* 6: storeq */ + ptr0[i] = var38; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_UYVY_AYUV (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union64 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var36; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union16 var37; +#else + orc_union16 var37; +#endif + orc_union64 var38; + orc_union16 var39; + orc_union16 var40; + orc_union32 var41; + orc_union32 var42; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 2: loadpb */ + var37.x2[0] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + var37.x2[1] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var36 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var36.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var36.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 3: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[0]; + _dest.x2[1] = var39.x2[0]; + var41.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[1]; + _dest.x2[1] = var39.x2[1]; + var41.x2[1] = _dest.i; + } + /* 4: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var40.i; + _dest.x2[1] = var40.i; + var42.i = _dest.i; + } + /* 5: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var41.x2[0]; + _dest.x2[1] = var42.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union32 _dest; + _dest.x2[0] = var41.x2[1]; + _dest.x2[1] = var42.x2[1]; + var38.x2[1] = _dest.i; + } + /* 6: storeq */ + ptr0[i] = var38; + } + } + +} + +void +videomixer_video_convert_orc_convert_UYVY_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 85, 89, 86, 89, 95, 65, 89, + 85, 86, 11, 8, 8, 12, 4, 4, 14, 2, 255, 0, 0, 0, 20, 2, + 20, 2, 20, 4, 20, 4, 21, 1, 199, 32, 33, 4, 21, 1, 196, 34, + 16, 32, 195, 35, 33, 33, 21, 1, 195, 0, 34, 35, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_UYVY_AYUV); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_UYVY_AYUV"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_UYVY_AYUV); + orc_program_add_destination (p, 8, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_constant (p, 2, 0x000000ff, "c1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 4, "t3"); + orc_program_add_temporary (p, 4, "t4"); + + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T1, ORC_VAR_T2, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_T3, ORC_VAR_C1, ORC_VAR_T1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_T4, ORC_VAR_T2, ORC_VAR_T2, + ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 1, ORC_VAR_D1, ORC_VAR_T3, ORC_VAR_T4, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_YUY2_Y42B */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_YUY2_Y42B (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + int i; + int j; + orc_union16 *ORC_RESTRICT ptr0; + orc_int8 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var33; + orc_union16 var34; + orc_int8 var35; + orc_int8 var36; + orc_union16 var37; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr1 = ORC_PTR_OFFSET (d2, d2_stride * j); + ptr2 = ORC_PTR_OFFSET (d3, d3_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var33 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var33.x2[0]; + var37.x2[0] = _src.x2[1]; + var34.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var33.x2[1]; + var37.x2[1] = _src.x2[1]; + var34.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var34; + /* 3: splitwb */ + { + orc_union16 _src; + _src.i = var37.i; + var35 = _src.x2[1]; + var36 = _src.x2[0]; + } + /* 4: storeb */ + ptr2[i] = var35; + /* 5: storeb */ + ptr1[i] = var36; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_YUY2_Y42B (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union16 *ORC_RESTRICT ptr0; + orc_int8 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var33; + orc_union16 var34; + orc_int8 var35; + orc_int8 var36; + orc_union16 var37; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr1 = ORC_PTR_OFFSET (ex->arrays[1], ex->params[1] * j); + ptr2 = ORC_PTR_OFFSET (ex->arrays[2], ex->params[2] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var33 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var33.x2[0]; + var37.x2[0] = _src.x2[1]; + var34.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var33.x2[1]; + var37.x2[1] = _src.x2[1]; + var34.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var34; + /* 3: splitwb */ + { + orc_union16 _src; + _src.i = var37.i; + var35 = _src.x2[1]; + var36 = _src.x2[0]; + } + /* 4: storeb */ + ptr2[i] = var35; + /* 5: storeb */ + ptr1[i] = var36; + } + } + +} + +void +videomixer_video_convert_orc_convert_YUY2_Y42B (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 89, 85, 89, 50, 95, 89, 52, + 50, 66, 11, 2, 2, 11, 1, 1, 11, 1, 1, 12, 4, 4, 20, 2, + 21, 1, 199, 32, 0, 4, 199, 2, 1, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_YUY2_Y42B); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_YUY2_Y42B"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_YUY2_Y42B); + orc_program_add_destination (p, 2, "d1"); + orc_program_add_destination (p, 1, "d2"); + orc_program_add_destination (p, 1, "d3"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_temporary (p, 2, "t1"); + + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T1, ORC_VAR_D1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_D3, ORC_VAR_D2, ORC_VAR_T1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_D2] = d2; + ex->params[ORC_VAR_D2] = d2_stride; + ex->arrays[ORC_VAR_D3] = d3; + ex->params[ORC_VAR_D3] = d3_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_UYVY_Y42B */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_UYVY_Y42B (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + int i; + int j; + orc_union16 *ORC_RESTRICT ptr0; + orc_int8 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var33; + orc_union16 var34; + orc_int8 var35; + orc_int8 var36; + orc_union16 var37; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr1 = ORC_PTR_OFFSET (d2, d2_stride * j); + ptr2 = ORC_PTR_OFFSET (d3, d3_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var33 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var33.x2[0]; + var34.x2[0] = _src.x2[1]; + var37.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var33.x2[1]; + var34.x2[1] = _src.x2[1]; + var37.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var34; + /* 3: splitwb */ + { + orc_union16 _src; + _src.i = var37.i; + var35 = _src.x2[1]; + var36 = _src.x2[0]; + } + /* 4: storeb */ + ptr2[i] = var35; + /* 5: storeb */ + ptr1[i] = var36; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_UYVY_Y42B (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union16 *ORC_RESTRICT ptr0; + orc_int8 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var33; + orc_union16 var34; + orc_int8 var35; + orc_int8 var36; + orc_union16 var37; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr1 = ORC_PTR_OFFSET (ex->arrays[1], ex->params[1] * j); + ptr2 = ORC_PTR_OFFSET (ex->arrays[2], ex->params[2] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var33 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var33.x2[0]; + var34.x2[0] = _src.x2[1]; + var37.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var33.x2[1]; + var34.x2[1] = _src.x2[1]; + var37.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var34; + /* 3: splitwb */ + { + orc_union16 _src; + _src.i = var37.i; + var35 = _src.x2[1]; + var36 = _src.x2[0]; + } + /* 4: storeb */ + ptr2[i] = var35; + /* 5: storeb */ + ptr1[i] = var36; + } + } + +} + +void +videomixer_video_convert_orc_convert_UYVY_Y42B (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 85, 89, 86, 89, 95, 89, 52, + 50, 66, 11, 2, 2, 11, 1, 1, 11, 1, 1, 12, 4, 4, 20, 2, + 21, 1, 199, 0, 32, 4, 199, 2, 1, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_UYVY_Y42B); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_UYVY_Y42B"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_UYVY_Y42B); + orc_program_add_destination (p, 2, "d1"); + orc_program_add_destination (p, 1, "d2"); + orc_program_add_destination (p, 1, "d3"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_temporary (p, 2, "t1"); + + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_D3, ORC_VAR_D2, ORC_VAR_T1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_D2] = d2; + ex->params[ORC_VAR_D2] = d2_stride; + ex->arrays[ORC_VAR_D3] = d3; + ex->params[ORC_VAR_D3] = d3_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_YUY2_Y444 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_YUY2_Y444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + int i; + int j; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + orc_union16 *ORC_RESTRICT ptr2; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var35; + orc_union16 var36; + orc_union16 var37; + orc_union16 var38; + orc_union16 var39; + orc_int8 var40; + orc_int8 var41; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr1 = ORC_PTR_OFFSET (d2, d2_stride * j); + ptr2 = ORC_PTR_OFFSET (d3, d3_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var35 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var35.x2[0]; + var39.x2[0] = _src.x2[1]; + var36.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var35.x2[1]; + var39.x2[1] = _src.x2[1]; + var36.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var36; + /* 3: splitwb */ + { + orc_union16 _src; + _src.i = var39.i; + var40 = _src.x2[1]; + var41 = _src.x2[0]; + } + /* 4: splatbw */ + var37.i = ((var41 & 0xff) << 8) | (var41 & 0xff); + /* 5: storew */ + ptr1[i] = var37; + /* 6: splatbw */ + var38.i = ((var40 & 0xff) << 8) | (var40 & 0xff); + /* 7: storew */ + ptr2[i] = var38; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_YUY2_Y444 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + orc_union16 *ORC_RESTRICT ptr2; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var35; + orc_union16 var36; + orc_union16 var37; + orc_union16 var38; + orc_union16 var39; + orc_int8 var40; + orc_int8 var41; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr1 = ORC_PTR_OFFSET (ex->arrays[1], ex->params[1] * j); + ptr2 = ORC_PTR_OFFSET (ex->arrays[2], ex->params[2] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var35 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var35.x2[0]; + var39.x2[0] = _src.x2[1]; + var36.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var35.x2[1]; + var39.x2[1] = _src.x2[1]; + var36.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var36; + /* 3: splitwb */ + { + orc_union16 _src; + _src.i = var39.i; + var40 = _src.x2[1]; + var41 = _src.x2[0]; + } + /* 4: splatbw */ + var37.i = ((var41 & 0xff) << 8) | (var41 & 0xff); + /* 5: storew */ + ptr1[i] = var37; + /* 6: splatbw */ + var38.i = ((var40 & 0xff) << 8) | (var40 & 0xff); + /* 7: storew */ + ptr2[i] = var38; + } + } + +} + +void +videomixer_video_convert_orc_convert_YUY2_Y444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 89, 85, 89, 50, 95, 89, 52, + 52, 52, 11, 2, 2, 11, 2, 2, 11, 2, 2, 12, 4, 4, 20, 2, + 20, 1, 20, 1, 21, 1, 199, 32, 0, 4, 199, 34, 33, 32, 151, 1, + 33, 151, 2, 34, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_YUY2_Y444); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_YUY2_Y444"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_YUY2_Y444); + orc_program_add_destination (p, 2, "d1"); + orc_program_add_destination (p, 2, "d2"); + orc_program_add_destination (p, 2, "d3"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 1, "t2"); + orc_program_add_temporary (p, 1, "t3"); + + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T1, ORC_VAR_D1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_T1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_D2, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_D3, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_D2] = d2; + ex->params[ORC_VAR_D2] = d2_stride; + ex->arrays[ORC_VAR_D3] = d3; + ex->params[ORC_VAR_D3] = d3_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_UYVY_Y444 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_UYVY_Y444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + int i; + int j; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + orc_union16 *ORC_RESTRICT ptr2; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var35; + orc_union16 var36; + orc_union16 var37; + orc_union16 var38; + orc_union16 var39; + orc_int8 var40; + orc_int8 var41; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr1 = ORC_PTR_OFFSET (d2, d2_stride * j); + ptr2 = ORC_PTR_OFFSET (d3, d3_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var35 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var35.x2[0]; + var36.x2[0] = _src.x2[1]; + var39.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var35.x2[1]; + var36.x2[1] = _src.x2[1]; + var39.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var36; + /* 3: splitwb */ + { + orc_union16 _src; + _src.i = var39.i; + var40 = _src.x2[1]; + var41 = _src.x2[0]; + } + /* 4: splatbw */ + var37.i = ((var41 & 0xff) << 8) | (var41 & 0xff); + /* 5: storew */ + ptr1[i] = var37; + /* 6: splatbw */ + var38.i = ((var40 & 0xff) << 8) | (var40 & 0xff); + /* 7: storew */ + ptr2[i] = var38; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_UYVY_Y444 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + orc_union16 *ORC_RESTRICT ptr2; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var35; + orc_union16 var36; + orc_union16 var37; + orc_union16 var38; + orc_union16 var39; + orc_int8 var40; + orc_int8 var41; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr1 = ORC_PTR_OFFSET (ex->arrays[1], ex->params[1] * j); + ptr2 = ORC_PTR_OFFSET (ex->arrays[2], ex->params[2] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var35 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var35.x2[0]; + var36.x2[0] = _src.x2[1]; + var39.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var35.x2[1]; + var36.x2[1] = _src.x2[1]; + var39.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var36; + /* 3: splitwb */ + { + orc_union16 _src; + _src.i = var39.i; + var40 = _src.x2[1]; + var41 = _src.x2[0]; + } + /* 4: splatbw */ + var37.i = ((var41 & 0xff) << 8) | (var41 & 0xff); + /* 5: storew */ + ptr1[i] = var37; + /* 6: splatbw */ + var38.i = ((var40 & 0xff) << 8) | (var40 & 0xff); + /* 7: storew */ + ptr2[i] = var38; + } + } + +} + +void +videomixer_video_convert_orc_convert_UYVY_Y444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 85, 89, 86, 89, 95, 89, 52, + 52, 52, 11, 2, 2, 11, 2, 2, 11, 2, 2, 12, 4, 4, 20, 2, + 20, 1, 20, 1, 21, 1, 199, 0, 32, 4, 199, 34, 33, 32, 151, 1, + 33, 151, 2, 34, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_UYVY_Y444); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_UYVY_Y444"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_UYVY_Y444); + orc_program_add_destination (p, 2, "d1"); + orc_program_add_destination (p, 2, "d2"); + orc_program_add_destination (p, 2, "d3"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 1, "t2"); + orc_program_add_temporary (p, 1, "t3"); + + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_T1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_D2, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_D3, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_D2] = d2; + ex->params[ORC_VAR_D2] = d2_stride; + ex->arrays[ORC_VAR_D3] = d3; + ex->params[ORC_VAR_D3] = d3_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_UYVY_I420 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_UYVY_I420 (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, guint8 * ORC_RESTRICT d3, + guint8 * ORC_RESTRICT d4, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, int n) +{ + int i; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + orc_int8 *ORC_RESTRICT ptr3; + const orc_union32 *ORC_RESTRICT ptr4; + const orc_union32 *ORC_RESTRICT ptr5; + orc_union32 var35; + orc_union32 var36; + orc_int8 var37; + orc_int8 var38; + orc_union16 var39; + orc_union16 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + + ptr0 = (orc_union16 *) d1; + ptr1 = (orc_union16 *) d2; + ptr2 = (orc_int8 *) d3; + ptr3 = (orc_int8 *) d4; + ptr4 = (orc_union32 *) s1; + ptr5 = (orc_union32 *) s2; + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var35 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var35.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var35.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var39; + /* 3: loadl */ + var36 = ptr5[i]; + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var36.x2[0]; + var41.x2[0] = _src.x2[1]; + var42.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var36.x2[1]; + var41.x2[1] = _src.x2[1]; + var42.x2[1] = _src.x2[0]; + } + /* 5: storew */ + ptr1[i] = var41; + /* 6: avgub */ + var43.x2[0] = ((orc_uint8) var40.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1; + var43.x2[1] = ((orc_uint8) var40.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1; + /* 7: splitwb */ + { + orc_union16 _src; + _src.i = var43.i; + var37 = _src.x2[1]; + var38 = _src.x2[0]; + } + /* 8: storeb */ + ptr3[i] = var37; + /* 9: storeb */ + ptr2[i] = var38; + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_UYVY_I420 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int n = ex->n; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + orc_int8 *ORC_RESTRICT ptr3; + const orc_union32 *ORC_RESTRICT ptr4; + const orc_union32 *ORC_RESTRICT ptr5; + orc_union32 var35; + orc_union32 var36; + orc_int8 var37; + orc_int8 var38; + orc_union16 var39; + orc_union16 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + + ptr0 = (orc_union16 *) ex->arrays[0]; + ptr1 = (orc_union16 *) ex->arrays[1]; + ptr2 = (orc_int8 *) ex->arrays[2]; + ptr3 = (orc_int8 *) ex->arrays[3]; + ptr4 = (orc_union32 *) ex->arrays[4]; + ptr5 = (orc_union32 *) ex->arrays[5]; + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var35 = ptr4[i]; + /* 1: splitwb */ + { + orc_union16 _src; + _src.i = var35.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var35.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 2: storew */ + ptr0[i] = var39; + /* 3: loadl */ + var36 = ptr5[i]; + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var36.x2[0]; + var41.x2[0] = _src.x2[1]; + var42.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var36.x2[1]; + var41.x2[1] = _src.x2[1]; + var42.x2[1] = _src.x2[0]; + } + /* 5: storew */ + ptr1[i] = var41; + /* 6: avgub */ + var43.x2[0] = ((orc_uint8) var40.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1; + var43.x2[1] = ((orc_uint8) var40.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1; + /* 7: splitwb */ + { + orc_union16 _src; + _src.i = var43.i; + var37 = _src.x2[1]; + var38 = _src.x2[0]; + } + /* 8: storeb */ + ptr3[i] = var37; + /* 9: storeb */ + ptr2[i] = var38; + } + +} + +void +videomixer_video_convert_orc_convert_UYVY_I420 (guint8 * ORC_RESTRICT d1, + guint8 * ORC_RESTRICT d2, guint8 * ORC_RESTRICT d3, + guint8 * ORC_RESTRICT d4, const guint8 * ORC_RESTRICT s1, + const guint8 * ORC_RESTRICT s2, int n) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, + 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, 99, + 95, + 99, 111, 110, 118, 101, 114, 116, 95, 85, 89, 86, 89, 95, 73, 52, 50, + 48, 11, 2, 2, 11, 2, 2, 11, 1, 1, 11, 1, 1, 12, 4, 4, + 12, 4, 4, 20, 2, 20, 2, 20, 2, 21, 1, 199, 34, 32, 4, 97, + 0, 34, 21, 1, 199, 34, 33, 5, 97, 1, 34, 21, 1, 39, 32, 32, + 33, 199, 3, 2, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_UYVY_I420); +#else + p = orc_program_new (); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_UYVY_I420"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_UYVY_I420); + orc_program_add_destination (p, 2, "d1"); + orc_program_add_destination (p, 2, "d2"); + orc_program_add_destination (p, 1, "d3"); + orc_program_add_destination (p, 1, "d4"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_source (p, 4, "s2"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 2, "t3"); + + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T3, ORC_VAR_T1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "storew", 0, ORC_VAR_D1, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_S2, + ORC_VAR_D1); + orc_program_append_2 (p, "storew", 0, ORC_VAR_D2, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 1, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_T2, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_D4, ORC_VAR_D3, ORC_VAR_T1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->arrays[ORC_VAR_D2] = d2; + ex->arrays[ORC_VAR_D3] = d3; + ex->arrays[ORC_VAR_D4] = d4; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->arrays[ORC_VAR_S2] = (void *) s2; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_AYUV_I420 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_AYUV_I420 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, guint8 * ORC_RESTRICT d4, + int d4_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m) +{ + int i; + int j; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + orc_int8 *ORC_RESTRICT ptr3; + const orc_union64 *ORC_RESTRICT ptr4; + const orc_union64 *ORC_RESTRICT ptr5; + orc_union64 var40; + orc_union16 var41; + orc_union64 var42; + orc_union16 var43; + orc_int8 var44; + orc_int8 var45; + orc_union32 var46; + orc_union32 var47; + orc_union32 var48; + orc_union32 var49; + orc_union32 var50; + orc_union16 var51; + orc_union16 var52; + orc_int8 var53; + orc_int8 var54; + orc_int8 var55; + orc_int8 var56; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr1 = ORC_PTR_OFFSET (d2, d2_stride * j); + ptr2 = ORC_PTR_OFFSET (d3, d3_stride * j); + ptr3 = ORC_PTR_OFFSET (d4, d4_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + ptr5 = ORC_PTR_OFFSET (s2, s2_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var40 = ptr4[i]; + /* 1: splitlw */ + { + orc_union32 _src; + _src.i = var40.x2[0]; + var46.x2[0] = _src.x2[1]; + var47.x2[0] = _src.x2[0]; + } + { + orc_union32 _src; + _src.i = var40.x2[1]; + var46.x2[1] = _src.x2[1]; + var47.x2[1] = _src.x2[0]; + } + /* 2: select1wb */ + { + orc_union16 _src; + _src.i = var47.x2[0]; + var41.x2[0] = _src.x2[1]; + } + { + orc_union16 _src; + _src.i = var47.x2[1]; + var41.x2[1] = _src.x2[1]; + } + /* 3: storew */ + ptr0[i] = var41; + /* 4: loadq */ + var42 = ptr5[i]; + /* 5: splitlw */ + { + orc_union32 _src; + _src.i = var42.x2[0]; + var48.x2[0] = _src.x2[1]; + var49.x2[0] = _src.x2[0]; + } + { + orc_union32 _src; + _src.i = var42.x2[1]; + var48.x2[1] = _src.x2[1]; + var49.x2[1] = _src.x2[0]; + } + /* 6: select1wb */ + { + orc_union16 _src; + _src.i = var49.x2[0]; + var43.x2[0] = _src.x2[1]; + } + { + orc_union16 _src; + _src.i = var49.x2[1]; + var43.x2[1] = _src.x2[1]; + } + /* 7: storew */ + ptr1[i] = var43; + /* 8: avgub */ + var50.x4[0] = + ((orc_uint8) var46.x4[0] + (orc_uint8) var48.x4[0] + 1) >> 1; + var50.x4[1] = + ((orc_uint8) var46.x4[1] + (orc_uint8) var48.x4[1] + 1) >> 1; + var50.x4[2] = + ((orc_uint8) var46.x4[2] + (orc_uint8) var48.x4[2] + 1) >> 1; + var50.x4[3] = + ((orc_uint8) var46.x4[3] + (orc_uint8) var48.x4[3] + 1) >> 1; + /* 9: splitwb */ + { + orc_union16 _src; + _src.i = var50.x2[0]; + var51.x2[0] = _src.x2[1]; + var52.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var50.x2[1]; + var51.x2[1] = _src.x2[1]; + var52.x2[1] = _src.x2[0]; + } + /* 10: splitwb */ + { + orc_union16 _src; + _src.i = var52.i; + var53 = _src.x2[1]; + var54 = _src.x2[0]; + } + /* 11: avgub */ + var44 = ((orc_uint8) var53 + (orc_uint8) var54 + 1) >> 1; + /* 12: storeb */ + ptr2[i] = var44; + /* 13: splitwb */ + { + orc_union16 _src; + _src.i = var51.i; + var55 = _src.x2[1]; + var56 = _src.x2[0]; + } + /* 14: avgub */ + var45 = ((orc_uint8) var55 + (orc_uint8) var56 + 1) >> 1; + /* 15: storeb */ + ptr3[i] = var45; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_AYUV_I420 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union16 *ORC_RESTRICT ptr0; + orc_union16 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + orc_int8 *ORC_RESTRICT ptr3; + const orc_union64 *ORC_RESTRICT ptr4; + const orc_union64 *ORC_RESTRICT ptr5; + orc_union64 var40; + orc_union16 var41; + orc_union64 var42; + orc_union16 var43; + orc_int8 var44; + orc_int8 var45; + orc_union32 var46; + orc_union32 var47; + orc_union32 var48; + orc_union32 var49; + orc_union32 var50; + orc_union16 var51; + orc_union16 var52; + orc_int8 var53; + orc_int8 var54; + orc_int8 var55; + orc_int8 var56; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr1 = ORC_PTR_OFFSET (ex->arrays[1], ex->params[1] * j); + ptr2 = ORC_PTR_OFFSET (ex->arrays[2], ex->params[2] * j); + ptr3 = ORC_PTR_OFFSET (ex->arrays[3], ex->params[3] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + ptr5 = ORC_PTR_OFFSET (ex->arrays[5], ex->params[5] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var40 = ptr4[i]; + /* 1: splitlw */ + { + orc_union32 _src; + _src.i = var40.x2[0]; + var46.x2[0] = _src.x2[1]; + var47.x2[0] = _src.x2[0]; + } + { + orc_union32 _src; + _src.i = var40.x2[1]; + var46.x2[1] = _src.x2[1]; + var47.x2[1] = _src.x2[0]; + } + /* 2: select1wb */ + { + orc_union16 _src; + _src.i = var47.x2[0]; + var41.x2[0] = _src.x2[1]; + } + { + orc_union16 _src; + _src.i = var47.x2[1]; + var41.x2[1] = _src.x2[1]; + } + /* 3: storew */ + ptr0[i] = var41; + /* 4: loadq */ + var42 = ptr5[i]; + /* 5: splitlw */ + { + orc_union32 _src; + _src.i = var42.x2[0]; + var48.x2[0] = _src.x2[1]; + var49.x2[0] = _src.x2[0]; + } + { + orc_union32 _src; + _src.i = var42.x2[1]; + var48.x2[1] = _src.x2[1]; + var49.x2[1] = _src.x2[0]; + } + /* 6: select1wb */ + { + orc_union16 _src; + _src.i = var49.x2[0]; + var43.x2[0] = _src.x2[1]; + } + { + orc_union16 _src; + _src.i = var49.x2[1]; + var43.x2[1] = _src.x2[1]; + } + /* 7: storew */ + ptr1[i] = var43; + /* 8: avgub */ + var50.x4[0] = + ((orc_uint8) var46.x4[0] + (orc_uint8) var48.x4[0] + 1) >> 1; + var50.x4[1] = + ((orc_uint8) var46.x4[1] + (orc_uint8) var48.x4[1] + 1) >> 1; + var50.x4[2] = + ((orc_uint8) var46.x4[2] + (orc_uint8) var48.x4[2] + 1) >> 1; + var50.x4[3] = + ((orc_uint8) var46.x4[3] + (orc_uint8) var48.x4[3] + 1) >> 1; + /* 9: splitwb */ + { + orc_union16 _src; + _src.i = var50.x2[0]; + var51.x2[0] = _src.x2[1]; + var52.x2[0] = _src.x2[0]; + } + { + orc_union16 _src; + _src.i = var50.x2[1]; + var51.x2[1] = _src.x2[1]; + var52.x2[1] = _src.x2[0]; + } + /* 10: splitwb */ + { + orc_union16 _src; + _src.i = var52.i; + var53 = _src.x2[1]; + var54 = _src.x2[0]; + } + /* 11: avgub */ + var44 = ((orc_uint8) var53 + (orc_uint8) var54 + 1) >> 1; + /* 12: storeb */ + ptr2[i] = var44; + /* 13: splitwb */ + { + orc_union16 _src; + _src.i = var51.i; + var55 = _src.x2[1]; + var56 = _src.x2[0]; + } + /* 14: avgub */ + var45 = ((orc_uint8) var55 + (orc_uint8) var56 + 1) >> 1; + /* 15: storeb */ + ptr3[i] = var45; + } + } + +} + +void +videomixer_video_convert_orc_convert_AYUV_I420 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, guint8 * ORC_RESTRICT d4, + int d4_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 65, 89, 85, 86, 95, 73, 52, + 50, 48, 11, 2, 2, 11, 2, 2, 11, 1, 1, 11, 1, 1, 12, 8, + 8, 12, 8, 8, 20, 4, 20, 4, 20, 4, 20, 4, 20, 2, 20, 2, + 20, 1, 20, 1, 21, 1, 198, 33, 32, 4, 21, 1, 189, 0, 32, 21, + 1, 198, 34, 32, 5, 21, 1, 189, 1, 32, 21, 2, 39, 35, 33, 34, + 21, 1, 199, 37, 36, 35, 199, 38, 39, 36, 39, 2, 38, 39, 199, 38, + 39, 37, 39, 3, 38, 39, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_I420); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_AYUV_I420"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_I420); + orc_program_add_destination (p, 2, "d1"); + orc_program_add_destination (p, 2, "d2"); + orc_program_add_destination (p, 1, "d3"); + orc_program_add_destination (p, 1, "d4"); + orc_program_add_source (p, 8, "s1"); + orc_program_add_source (p, 8, "s2"); + orc_program_add_temporary (p, 4, "t1"); + orc_program_add_temporary (p, 4, "t2"); + orc_program_add_temporary (p, 4, "t3"); + orc_program_add_temporary (p, 4, "t4"); + orc_program_add_temporary (p, 2, "t5"); + orc_program_add_temporary (p, 2, "t6"); + orc_program_add_temporary (p, 1, "t7"); + orc_program_add_temporary (p, 1, "t8"); + + orc_program_append_2 (p, "splitlw", 1, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "select1wb", 1, ORC_VAR_D1, ORC_VAR_T1, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "splitlw", 1, ORC_VAR_T3, ORC_VAR_T1, ORC_VAR_S2, + ORC_VAR_D1); + orc_program_append_2 (p, "select1wb", 1, ORC_VAR_D2, ORC_VAR_T1, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 2, ORC_VAR_T4, ORC_VAR_T2, ORC_VAR_T3, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T6, ORC_VAR_T5, ORC_VAR_T4, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T7, ORC_VAR_T8, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 0, ORC_VAR_D3, ORC_VAR_T7, ORC_VAR_T8, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T7, ORC_VAR_T8, ORC_VAR_T6, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 0, ORC_VAR_D4, ORC_VAR_T7, ORC_VAR_T8, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_D2] = d2; + ex->params[ORC_VAR_D2] = d2_stride; + ex->arrays[ORC_VAR_D3] = d3; + ex->params[ORC_VAR_D3] = d3_stride; + ex->arrays[ORC_VAR_D4] = d4; + ex->params[ORC_VAR_D4] = d4_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->params[ORC_VAR_S2] = s2_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_AYUV_YUY2 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_AYUV_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union64 *ORC_RESTRICT ptr4; + orc_union64 var37; + orc_union32 var38; + orc_union32 var39; + orc_union32 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + orc_union16 var44; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var37 = ptr4[i]; + /* 1: splitlw */ + { + orc_union32 _src; + _src.i = var37.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union32 _src; + _src.i = var37.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 2: splitlw */ + { + orc_union32 _src; + _src.i = var39.i; + var41.i = _src.x2[1]; + var42.i = _src.x2[0]; + } + /* 3: avgub */ + var43.x2[0] = + ((orc_uint8) var41.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1; + var43.x2[1] = + ((orc_uint8) var41.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1; + /* 4: select1wb */ + { + orc_union16 _src; + _src.i = var40.x2[0]; + var44.x2[0] = _src.x2[1]; + } + { + orc_union16 _src; + _src.i = var40.x2[1]; + var44.x2[1] = _src.x2[1]; + } + /* 5: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var44.x2[0]; + _dest.x2[1] = var43.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var44.x2[1]; + _dest.x2[1] = var43.x2[1]; + var38.x2[1] = _dest.i; + } + /* 6: storel */ + ptr0[i] = var38; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_AYUV_YUY2 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union64 *ORC_RESTRICT ptr4; + orc_union64 var37; + orc_union32 var38; + orc_union32 var39; + orc_union32 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + orc_union16 var44; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var37 = ptr4[i]; + /* 1: splitlw */ + { + orc_union32 _src; + _src.i = var37.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union32 _src; + _src.i = var37.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 2: splitlw */ + { + orc_union32 _src; + _src.i = var39.i; + var41.i = _src.x2[1]; + var42.i = _src.x2[0]; + } + /* 3: avgub */ + var43.x2[0] = + ((orc_uint8) var41.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1; + var43.x2[1] = + ((orc_uint8) var41.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1; + /* 4: select1wb */ + { + orc_union16 _src; + _src.i = var40.x2[0]; + var44.x2[0] = _src.x2[1]; + } + { + orc_union16 _src; + _src.i = var40.x2[1]; + var44.x2[1] = _src.x2[1]; + } + /* 5: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var44.x2[0]; + _dest.x2[1] = var43.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var44.x2[1]; + _dest.x2[1] = var43.x2[1]; + var38.x2[1] = _dest.i; + } + /* 6: storel */ + ptr0[i] = var38; + } + } + +} + +void +videomixer_video_convert_orc_convert_AYUV_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 65, 89, 85, 86, 95, 89, 85, + 89, 50, 11, 4, 4, 12, 8, 8, 20, 2, 20, 2, 20, 2, 20, 4, + 20, 4, 21, 1, 198, 36, 35, 4, 198, 33, 34, 36, 21, 1, 39, 33, + 33, 34, 21, 1, 189, 32, 35, 21, 1, 196, 0, 32, 33, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_YUY2); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_AYUV_YUY2"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_YUY2); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 8, "s1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 2, "t3"); + orc_program_add_temporary (p, 4, "t4"); + orc_program_add_temporary (p, 4, "t5"); + + orc_program_append_2 (p, "splitlw", 1, ORC_VAR_T5, ORC_VAR_T4, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T2, ORC_VAR_T3, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 1, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_T3, + ORC_VAR_D1); + orc_program_append_2 (p, "select1wb", 1, ORC_VAR_T1, ORC_VAR_T4, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_T2, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_AYUV_UYVY */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_AYUV_UYVY (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union64 *ORC_RESTRICT ptr4; + orc_union64 var37; + orc_union32 var38; + orc_union32 var39; + orc_union32 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + orc_union16 var44; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var37 = ptr4[i]; + /* 1: splitlw */ + { + orc_union32 _src; + _src.i = var37.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union32 _src; + _src.i = var37.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 2: splitlw */ + { + orc_union32 _src; + _src.i = var39.i; + var41.i = _src.x2[1]; + var42.i = _src.x2[0]; + } + /* 3: avgub */ + var43.x2[0] = + ((orc_uint8) var41.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1; + var43.x2[1] = + ((orc_uint8) var41.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1; + /* 4: select1wb */ + { + orc_union16 _src; + _src.i = var40.x2[0]; + var44.x2[0] = _src.x2[1]; + } + { + orc_union16 _src; + _src.i = var40.x2[1]; + var44.x2[1] = _src.x2[1]; + } + /* 5: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var43.x2[0]; + _dest.x2[1] = var44.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var43.x2[1]; + _dest.x2[1] = var44.x2[1]; + var38.x2[1] = _dest.i; + } + /* 6: storel */ + ptr0[i] = var38; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_AYUV_UYVY (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union64 *ORC_RESTRICT ptr4; + orc_union64 var37; + orc_union32 var38; + orc_union32 var39; + orc_union32 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + orc_union16 var44; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var37 = ptr4[i]; + /* 1: splitlw */ + { + orc_union32 _src; + _src.i = var37.x2[0]; + var39.x2[0] = _src.x2[1]; + var40.x2[0] = _src.x2[0]; + } + { + orc_union32 _src; + _src.i = var37.x2[1]; + var39.x2[1] = _src.x2[1]; + var40.x2[1] = _src.x2[0]; + } + /* 2: splitlw */ + { + orc_union32 _src; + _src.i = var39.i; + var41.i = _src.x2[1]; + var42.i = _src.x2[0]; + } + /* 3: avgub */ + var43.x2[0] = + ((orc_uint8) var41.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1; + var43.x2[1] = + ((orc_uint8) var41.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1; + /* 4: select1wb */ + { + orc_union16 _src; + _src.i = var40.x2[0]; + var44.x2[0] = _src.x2[1]; + } + { + orc_union16 _src; + _src.i = var40.x2[1]; + var44.x2[1] = _src.x2[1]; + } + /* 5: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var43.x2[0]; + _dest.x2[1] = var44.x2[0]; + var38.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var43.x2[1]; + _dest.x2[1] = var44.x2[1]; + var38.x2[1] = _dest.i; + } + /* 6: storel */ + ptr0[i] = var38; + } + } + +} + +void +videomixer_video_convert_orc_convert_AYUV_UYVY (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 65, 89, 85, 86, 95, 85, 89, + 86, 89, 11, 4, 4, 12, 8, 8, 20, 2, 20, 2, 20, 2, 20, 4, + 20, 4, 21, 1, 198, 36, 35, 4, 198, 33, 34, 36, 21, 1, 39, 33, + 33, 34, 21, 1, 189, 32, 35, 21, 1, 196, 0, 33, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_UYVY); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_AYUV_UYVY"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_UYVY); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 8, "s1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 2, "t3"); + orc_program_add_temporary (p, 4, "t4"); + orc_program_add_temporary (p, 4, "t5"); + + orc_program_append_2 (p, "splitlw", 1, ORC_VAR_T5, ORC_VAR_T4, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T2, ORC_VAR_T3, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 1, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_T3, + ORC_VAR_D1); + orc_program_append_2 (p, "select1wb", 1, ORC_VAR_T1, ORC_VAR_T4, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D1, ORC_VAR_T2, ORC_VAR_T1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_AYUV_Y42B */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_AYUV_Y42B (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + int i; + int j; + orc_union16 *ORC_RESTRICT ptr0; + orc_int8 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + const orc_union64 *ORC_RESTRICT ptr4; + orc_union64 var36; + orc_int8 var37; + orc_int8 var38; + orc_union16 var39; + orc_union32 var40; + orc_union32 var41; + orc_union16 var42; + orc_union16 var43; + orc_union16 var44; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr1 = ORC_PTR_OFFSET (d2, d2_stride * j); + ptr2 = ORC_PTR_OFFSET (d3, d3_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var36 = ptr4[i]; + /* 1: splitlw */ + { + orc_union32 _src; + _src.i = var36.x2[0]; + var40.x2[0] = _src.x2[1]; + var41.x2[0] = _src.x2[0]; + } + { + orc_union32 _src; + _src.i = var36.x2[1]; + var40.x2[1] = _src.x2[1]; + var41.x2[1] = _src.x2[0]; + } + /* 2: splitlw */ + { + orc_union32 _src; + _src.i = var40.i; + var42.i = _src.x2[1]; + var43.i = _src.x2[0]; + } + /* 3: avgub */ + var44.x2[0] = + ((orc_uint8) var42.x2[0] + (orc_uint8) var43.x2[0] + 1) >> 1; + var44.x2[1] = + ((orc_uint8) var42.x2[1] + (orc_uint8) var43.x2[1] + 1) >> 1; + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var44.i; + var37 = _src.x2[1]; + var38 = _src.x2[0]; + } + /* 5: storeb */ + ptr2[i] = var37; + /* 6: storeb */ + ptr1[i] = var38; + /* 7: select1wb */ + { + orc_union16 _src; + _src.i = var41.x2[0]; + var39.x2[0] = _src.x2[1]; + } + { + orc_union16 _src; + _src.i = var41.x2[1]; + var39.x2[1] = _src.x2[1]; + } + /* 8: storew */ + ptr0[i] = var39; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_AYUV_Y42B (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union16 *ORC_RESTRICT ptr0; + orc_int8 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + const orc_union64 *ORC_RESTRICT ptr4; + orc_union64 var36; + orc_int8 var37; + orc_int8 var38; + orc_union16 var39; + orc_union32 var40; + orc_union32 var41; + orc_union16 var42; + orc_union16 var43; + orc_union16 var44; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr1 = ORC_PTR_OFFSET (ex->arrays[1], ex->params[1] * j); + ptr2 = ORC_PTR_OFFSET (ex->arrays[2], ex->params[2] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadq */ + var36 = ptr4[i]; + /* 1: splitlw */ + { + orc_union32 _src; + _src.i = var36.x2[0]; + var40.x2[0] = _src.x2[1]; + var41.x2[0] = _src.x2[0]; + } + { + orc_union32 _src; + _src.i = var36.x2[1]; + var40.x2[1] = _src.x2[1]; + var41.x2[1] = _src.x2[0]; + } + /* 2: splitlw */ + { + orc_union32 _src; + _src.i = var40.i; + var42.i = _src.x2[1]; + var43.i = _src.x2[0]; + } + /* 3: avgub */ + var44.x2[0] = + ((orc_uint8) var42.x2[0] + (orc_uint8) var43.x2[0] + 1) >> 1; + var44.x2[1] = + ((orc_uint8) var42.x2[1] + (orc_uint8) var43.x2[1] + 1) >> 1; + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var44.i; + var37 = _src.x2[1]; + var38 = _src.x2[0]; + } + /* 5: storeb */ + ptr2[i] = var37; + /* 6: storeb */ + ptr1[i] = var38; + /* 7: select1wb */ + { + orc_union16 _src; + _src.i = var41.x2[0]; + var39.x2[0] = _src.x2[1]; + } + { + orc_union16 _src; + _src.i = var41.x2[1]; + var39.x2[1] = _src.x2[1]; + } + /* 8: storew */ + ptr0[i] = var39; + } + } + +} + +void +videomixer_video_convert_orc_convert_AYUV_Y42B (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 65, 89, 85, 86, 95, 89, 52, + 50, 66, 11, 2, 2, 11, 1, 1, 11, 1, 1, 12, 8, 8, 20, 4, + 20, 4, 20, 2, 20, 2, 21, 1, 198, 33, 32, 4, 198, 34, 35, 33, + 21, 1, 39, 34, 34, 35, 199, 2, 1, 34, 21, 1, 189, 0, 32, 2, + 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_Y42B); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_AYUV_Y42B"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_Y42B); + orc_program_add_destination (p, 2, "d1"); + orc_program_add_destination (p, 1, "d2"); + orc_program_add_destination (p, 1, "d3"); + orc_program_add_source (p, 8, "s1"); + orc_program_add_temporary (p, 4, "t1"); + orc_program_add_temporary (p, 4, "t2"); + orc_program_add_temporary (p, 2, "t3"); + orc_program_add_temporary (p, 2, "t4"); + + orc_program_append_2 (p, "splitlw", 1, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T3, ORC_VAR_T4, ORC_VAR_T2, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 1, ORC_VAR_T3, ORC_VAR_T3, ORC_VAR_T4, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_D3, ORC_VAR_D2, ORC_VAR_T3, + ORC_VAR_D1); + orc_program_append_2 (p, "select1wb", 1, ORC_VAR_D1, ORC_VAR_T1, + ORC_VAR_D1, ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_D2] = d2; + ex->params[ORC_VAR_D2] = d2_stride; + ex->arrays[ORC_VAR_D3] = d3; + ex->params[ORC_VAR_D3] = d3_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_AYUV_Y444 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_AYUV_Y444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + int i; + int j; + orc_int8 *ORC_RESTRICT ptr0; + orc_int8 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var34; + orc_int8 var35; + orc_int8 var36; + orc_int8 var37; + orc_union16 var38; + orc_union16 var39; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr1 = ORC_PTR_OFFSET (d2, d2_stride * j); + ptr2 = ORC_PTR_OFFSET (d3, d3_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var34 = ptr4[i]; + /* 1: splitlw */ + { + orc_union32 _src; + _src.i = var34.i; + var38.i = _src.x2[1]; + var39.i = _src.x2[0]; + } + /* 2: splitwb */ + { + orc_union16 _src; + _src.i = var38.i; + var35 = _src.x2[1]; + var36 = _src.x2[0]; + } + /* 3: storeb */ + ptr2[i] = var35; + /* 4: storeb */ + ptr1[i] = var36; + /* 5: select1wb */ + { + orc_union16 _src; + _src.i = var39.i; + var37 = _src.x2[1]; + } + /* 6: storeb */ + ptr0[i] = var37; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_AYUV_Y444 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_int8 *ORC_RESTRICT ptr0; + orc_int8 *ORC_RESTRICT ptr1; + orc_int8 *ORC_RESTRICT ptr2; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var34; + orc_int8 var35; + orc_int8 var36; + orc_int8 var37; + orc_union16 var38; + orc_union16 var39; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr1 = ORC_PTR_OFFSET (ex->arrays[1], ex->params[1] * j); + ptr2 = ORC_PTR_OFFSET (ex->arrays[2], ex->params[2] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var34 = ptr4[i]; + /* 1: splitlw */ + { + orc_union32 _src; + _src.i = var34.i; + var38.i = _src.x2[1]; + var39.i = _src.x2[0]; + } + /* 2: splitwb */ + { + orc_union16 _src; + _src.i = var38.i; + var35 = _src.x2[1]; + var36 = _src.x2[0]; + } + /* 3: storeb */ + ptr2[i] = var35; + /* 4: storeb */ + ptr1[i] = var36; + /* 5: select1wb */ + { + orc_union16 _src; + _src.i = var39.i; + var37 = _src.x2[1]; + } + /* 6: storeb */ + ptr0[i] = var37; + } + } + +} + +void +videomixer_video_convert_orc_convert_AYUV_Y444 (guint8 * ORC_RESTRICT d1, + int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, + guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, + int s1_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 65, 89, 85, 86, 95, 89, 52, + 52, 52, 11, 1, 1, 11, 1, 1, 11, 1, 1, 12, 4, 4, 20, 2, + 20, 2, 198, 33, 32, 4, 199, 2, 1, 33, 189, 0, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_Y444); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_AYUV_Y444"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_Y444); + orc_program_add_destination (p, 1, "d1"); + orc_program_add_destination (p, 1, "d2"); + orc_program_add_destination (p, 1, "d3"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + + orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_D3, ORC_VAR_D2, ORC_VAR_T2, + ORC_VAR_D1); + orc_program_append_2 (p, "select1wb", 0, ORC_VAR_D1, ORC_VAR_T1, + ORC_VAR_D1, ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_D2] = d2; + ex->params[ORC_VAR_D2] = d2_stride; + ex->arrays[ORC_VAR_D3] = d3; + ex->params[ORC_VAR_D3] = d3_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_Y42B_YUY2 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_Y42B_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + orc_int8 var33; + orc_int8 var34; + orc_union16 var35; + orc_union32 var36; + orc_union16 var37; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + ptr5 = ORC_PTR_OFFSET (s2, s2_stride * j); + ptr6 = ORC_PTR_OFFSET (s3, s3_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr5[i]; + /* 1: loadb */ + var34 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var33; + _dest.x2[1] = var34; + var37.i = _dest.i; + } + /* 3: loadw */ + var35 = ptr4[i]; + /* 4: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var35.x2[0]; + _dest.x2[1] = var37.x2[0]; + var36.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var35.x2[1]; + _dest.x2[1] = var37.x2[1]; + var36.x2[1] = _dest.i; + } + /* 5: storel */ + ptr0[i] = var36; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_Y42B_YUY2 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + orc_int8 var33; + orc_int8 var34; + orc_union16 var35; + orc_union32 var36; + orc_union16 var37; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + ptr5 = ORC_PTR_OFFSET (ex->arrays[5], ex->params[5] * j); + ptr6 = ORC_PTR_OFFSET (ex->arrays[6], ex->params[6] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr5[i]; + /* 1: loadb */ + var34 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var33; + _dest.x2[1] = var34; + var37.i = _dest.i; + } + /* 3: loadw */ + var35 = ptr4[i]; + /* 4: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var35.x2[0]; + _dest.x2[1] = var37.x2[0]; + var36.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var35.x2[1]; + _dest.x2[1] = var37.x2[1]; + var36.x2[1] = _dest.i; + } + /* 5: storel */ + ptr0[i] = var36; + } + } + +} + +void +videomixer_video_convert_orc_convert_Y42B_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 89, 52, 50, 66, 95, 89, 85, + 89, 50, 11, 4, 4, 12, 2, 2, 12, 1, 1, 12, 1, 1, 20, 2, + 196, 32, 5, 6, 21, 1, 196, 0, 4, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y42B_YUY2); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_Y42B_YUY2"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y42B_YUY2); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 2, "s1"); + orc_program_add_source (p, 1, "s2"); + orc_program_add_source (p, 1, "s3"); + orc_program_add_temporary (p, 2, "t1"); + + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T1, ORC_VAR_S2, ORC_VAR_S3, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_T1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->params[ORC_VAR_S2] = s2_stride; + ex->arrays[ORC_VAR_S3] = (void *) s3; + ex->params[ORC_VAR_S3] = s3_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_Y42B_UYVY */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_Y42B_UYVY (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + orc_int8 var33; + orc_int8 var34; + orc_union16 var35; + orc_union32 var36; + orc_union16 var37; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + ptr5 = ORC_PTR_OFFSET (s2, s2_stride * j); + ptr6 = ORC_PTR_OFFSET (s3, s3_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr5[i]; + /* 1: loadb */ + var34 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var33; + _dest.x2[1] = var34; + var37.i = _dest.i; + } + /* 3: loadw */ + var35 = ptr4[i]; + /* 4: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[0]; + _dest.x2[1] = var35.x2[0]; + var36.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[1]; + _dest.x2[1] = var35.x2[1]; + var36.x2[1] = _dest.i; + } + /* 5: storel */ + ptr0[i] = var36; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_Y42B_UYVY (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + orc_int8 var33; + orc_int8 var34; + orc_union16 var35; + orc_union32 var36; + orc_union16 var37; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + ptr5 = ORC_PTR_OFFSET (ex->arrays[5], ex->params[5] * j); + ptr6 = ORC_PTR_OFFSET (ex->arrays[6], ex->params[6] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var33 = ptr5[i]; + /* 1: loadb */ + var34 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var33; + _dest.x2[1] = var34; + var37.i = _dest.i; + } + /* 3: loadw */ + var35 = ptr4[i]; + /* 4: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[0]; + _dest.x2[1] = var35.x2[0]; + var36.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var37.x2[1]; + _dest.x2[1] = var35.x2[1]; + var36.x2[1] = _dest.i; + } + /* 5: storel */ + ptr0[i] = var36; + } + } + +} + +void +videomixer_video_convert_orc_convert_Y42B_UYVY (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 89, 52, 50, 66, 95, 85, 89, + 86, 89, 11, 4, 4, 12, 2, 2, 12, 1, 1, 12, 1, 1, 20, 2, + 196, 32, 5, 6, 21, 1, 196, 0, 32, 4, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y42B_UYVY); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_Y42B_UYVY"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y42B_UYVY); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 2, "s1"); + orc_program_add_source (p, 1, "s2"); + orc_program_add_source (p, 1, "s3"); + orc_program_add_temporary (p, 2, "t1"); + + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T1, ORC_VAR_S2, ORC_VAR_S3, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_S1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->params[ORC_VAR_S2] = s2_stride; + ex->arrays[ORC_VAR_S3] = (void *) s3; + ex->params[ORC_VAR_S3] = s3_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_Y42B_AYUV */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_Y42B_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + int i; + int j; + orc_union64 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + orc_int8 var36; + orc_int8 var37; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union16 var38; +#else + orc_union16 var38; +#endif + orc_union16 var39; + orc_union64 var40; + orc_union16 var41; + orc_union32 var42; + orc_union32 var43; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + ptr5 = ORC_PTR_OFFSET (s2, s2_stride * j); + ptr6 = ORC_PTR_OFFSET (s3, s3_stride * j); + + /* 3: loadpb */ + var38.x2[0] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + var38.x2[1] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var36 = ptr5[i]; + /* 1: loadb */ + var37 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36; + _dest.x2[1] = var37; + var41.i = _dest.i; + } + /* 4: loadw */ + var39 = ptr4[i]; + /* 5: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var38.x2[0]; + _dest.x2[1] = var39.x2[0]; + var42.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var38.x2[1]; + _dest.x2[1] = var39.x2[1]; + var42.x2[1] = _dest.i; + } + /* 6: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var41.i; + _dest.x2[1] = var41.i; + var43.i = _dest.i; + } + /* 7: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var42.x2[0]; + _dest.x2[1] = var43.x2[0]; + var40.x2[0] = _dest.i; + } + { + orc_union32 _dest; + _dest.x2[0] = var42.x2[1]; + _dest.x2[1] = var43.x2[1]; + var40.x2[1] = _dest.i; + } + /* 8: storeq */ + ptr0[i] = var40; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_Y42B_AYUV (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union64 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + orc_int8 var36; + orc_int8 var37; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union16 var38; +#else + orc_union16 var38; +#endif + orc_union16 var39; + orc_union64 var40; + orc_union16 var41; + orc_union32 var42; + orc_union32 var43; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + ptr5 = ORC_PTR_OFFSET (ex->arrays[5], ex->params[5] * j); + ptr6 = ORC_PTR_OFFSET (ex->arrays[6], ex->params[6] * j); + + /* 3: loadpb */ + var38.x2[0] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + var38.x2[1] = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var36 = ptr5[i]; + /* 1: loadb */ + var37 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36; + _dest.x2[1] = var37; + var41.i = _dest.i; + } + /* 4: loadw */ + var39 = ptr4[i]; + /* 5: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var38.x2[0]; + _dest.x2[1] = var39.x2[0]; + var42.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var38.x2[1]; + _dest.x2[1] = var39.x2[1]; + var42.x2[1] = _dest.i; + } + /* 6: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var41.i; + _dest.x2[1] = var41.i; + var43.i = _dest.i; + } + /* 7: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var42.x2[0]; + _dest.x2[1] = var43.x2[0]; + var40.x2[0] = _dest.i; + } + { + orc_union32 _dest; + _dest.x2[0] = var42.x2[1]; + _dest.x2[1] = var43.x2[1]; + var40.x2[1] = _dest.i; + } + /* 8: storeq */ + ptr0[i] = var40; + } + } + +} + +void +videomixer_video_convert_orc_convert_Y42B_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 89, 52, 50, 66, 95, 65, 89, + 85, 86, 11, 8, 8, 12, 2, 2, 12, 1, 1, 12, 1, 1, 14, 1, + 255, 0, 0, 0, 20, 2, 20, 2, 20, 4, 20, 4, 196, 32, 5, 6, + 21, 1, 196, 35, 16, 4, 195, 34, 32, 32, 21, 1, 195, 0, 35, 34, + 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y42B_AYUV); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_Y42B_AYUV"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y42B_AYUV); + orc_program_add_destination (p, 8, "d1"); + orc_program_add_source (p, 2, "s1"); + orc_program_add_source (p, 1, "s2"); + orc_program_add_source (p, 1, "s3"); + orc_program_add_constant (p, 1, 0x000000ff, "c1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 4, "t3"); + orc_program_add_temporary (p, 4, "t4"); + + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T1, ORC_VAR_S2, ORC_VAR_S3, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_T4, ORC_VAR_C1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_T3, ORC_VAR_T1, ORC_VAR_T1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 1, ORC_VAR_D1, ORC_VAR_T4, ORC_VAR_T3, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->params[ORC_VAR_S2] = s2_stride; + ex->arrays[ORC_VAR_S3] = (void *) s3; + ex->params[ORC_VAR_S3] = s3_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_Y444_YUY2 */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_Y444_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_union16 *ORC_RESTRICT ptr5; + const orc_union16 *ORC_RESTRICT ptr6; + orc_union16 var36; + orc_union16 var37; + orc_union16 var38; + orc_union32 var39; + orc_union32 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + ptr5 = ORC_PTR_OFFSET (s2, s2_stride * j); + ptr6 = ORC_PTR_OFFSET (s3, s3_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadw */ + var36 = ptr5[i]; + /* 1: loadw */ + var37 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36.x2[0]; + _dest.x2[1] = var37.x2[0]; + var40.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var36.x2[1]; + _dest.x2[1] = var37.x2[1]; + var40.x2[1] = _dest.i; + } + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var40.i; + var41.i = _src.x2[1]; + var42.i = _src.x2[0]; + } + /* 4: avgub */ + var43.x2[0] = + ((orc_uint8) var41.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1; + var43.x2[1] = + ((orc_uint8) var41.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1; + /* 5: loadw */ + var38 = ptr4[i]; + /* 6: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var38.x2[0]; + _dest.x2[1] = var43.x2[0]; + var39.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var38.x2[1]; + _dest.x2[1] = var43.x2[1]; + var39.x2[1] = _dest.i; + } + /* 7: storel */ + ptr0[i] = var39; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_Y444_YUY2 (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_union16 *ORC_RESTRICT ptr5; + const orc_union16 *ORC_RESTRICT ptr6; + orc_union16 var36; + orc_union16 var37; + orc_union16 var38; + orc_union32 var39; + orc_union32 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + ptr5 = ORC_PTR_OFFSET (ex->arrays[5], ex->params[5] * j); + ptr6 = ORC_PTR_OFFSET (ex->arrays[6], ex->params[6] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadw */ + var36 = ptr5[i]; + /* 1: loadw */ + var37 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36.x2[0]; + _dest.x2[1] = var37.x2[0]; + var40.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var36.x2[1]; + _dest.x2[1] = var37.x2[1]; + var40.x2[1] = _dest.i; + } + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var40.i; + var41.i = _src.x2[1]; + var42.i = _src.x2[0]; + } + /* 4: avgub */ + var43.x2[0] = + ((orc_uint8) var41.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1; + var43.x2[1] = + ((orc_uint8) var41.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1; + /* 5: loadw */ + var38 = ptr4[i]; + /* 6: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var38.x2[0]; + _dest.x2[1] = var43.x2[0]; + var39.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var38.x2[1]; + _dest.x2[1] = var43.x2[1]; + var39.x2[1] = _dest.i; + } + /* 7: storel */ + ptr0[i] = var39; + } + } + +} + +void +videomixer_video_convert_orc_convert_Y444_YUY2 (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 89, 52, 52, 52, 95, 89, 85, + 89, 50, 11, 4, 4, 12, 2, 2, 12, 2, 2, 12, 2, 2, 20, 2, + 20, 4, 20, 2, 20, 2, 21, 1, 196, 33, 5, 6, 198, 34, 35, 33, + 21, 1, 39, 32, 34, 35, 21, 1, 196, 0, 4, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y444_YUY2); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_Y444_YUY2"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y444_YUY2); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 2, "s1"); + orc_program_add_source (p, 2, "s2"); + orc_program_add_source (p, 2, "s3"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 4, "t2"); + orc_program_add_temporary (p, 2, "t3"); + orc_program_add_temporary (p, 2, "t4"); + + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_T2, ORC_VAR_S2, ORC_VAR_S3, + ORC_VAR_D1); + orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T3, ORC_VAR_T4, ORC_VAR_T2, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 1, ORC_VAR_T1, ORC_VAR_T3, ORC_VAR_T4, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_T1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->params[ORC_VAR_S2] = s2_stride; + ex->arrays[ORC_VAR_S3] = (void *) s3; + ex->params[ORC_VAR_S3] = s3_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_Y444_UYVY */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_Y444_UYVY (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_union16 *ORC_RESTRICT ptr5; + const orc_union16 *ORC_RESTRICT ptr6; + orc_union16 var36; + orc_union16 var37; + orc_union16 var38; + orc_union32 var39; + orc_union32 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + ptr5 = ORC_PTR_OFFSET (s2, s2_stride * j); + ptr6 = ORC_PTR_OFFSET (s3, s3_stride * j); + + + for (i = 0; i < n; i++) { + /* 0: loadw */ + var36 = ptr5[i]; + /* 1: loadw */ + var37 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36.x2[0]; + _dest.x2[1] = var37.x2[0]; + var40.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var36.x2[1]; + _dest.x2[1] = var37.x2[1]; + var40.x2[1] = _dest.i; + } + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var40.i; + var41.i = _src.x2[1]; + var42.i = _src.x2[0]; + } + /* 4: avgub */ + var43.x2[0] = + ((orc_uint8) var41.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1; + var43.x2[1] = + ((orc_uint8) var41.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1; + /* 5: loadw */ + var38 = ptr4[i]; + /* 6: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var43.x2[0]; + _dest.x2[1] = var38.x2[0]; + var39.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var43.x2[1]; + _dest.x2[1] = var38.x2[1]; + var39.x2[1] = _dest.i; + } + /* 7: storel */ + ptr0[i] = var39; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_Y444_UYVY (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union16 *ORC_RESTRICT ptr4; + const orc_union16 *ORC_RESTRICT ptr5; + const orc_union16 *ORC_RESTRICT ptr6; + orc_union16 var36; + orc_union16 var37; + orc_union16 var38; + orc_union32 var39; + orc_union32 var40; + orc_union16 var41; + orc_union16 var42; + orc_union16 var43; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + ptr5 = ORC_PTR_OFFSET (ex->arrays[5], ex->params[5] * j); + ptr6 = ORC_PTR_OFFSET (ex->arrays[6], ex->params[6] * j); + + + for (i = 0; i < n; i++) { + /* 0: loadw */ + var36 = ptr5[i]; + /* 1: loadw */ + var37 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36.x2[0]; + _dest.x2[1] = var37.x2[0]; + var40.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var36.x2[1]; + _dest.x2[1] = var37.x2[1]; + var40.x2[1] = _dest.i; + } + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var40.i; + var41.i = _src.x2[1]; + var42.i = _src.x2[0]; + } + /* 4: avgub */ + var43.x2[0] = + ((orc_uint8) var41.x2[0] + (orc_uint8) var42.x2[0] + 1) >> 1; + var43.x2[1] = + ((orc_uint8) var41.x2[1] + (orc_uint8) var42.x2[1] + 1) >> 1; + /* 5: loadw */ + var38 = ptr4[i]; + /* 6: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var43.x2[0]; + _dest.x2[1] = var38.x2[0]; + var39.x2[0] = _dest.i; + } + { + orc_union16 _dest; + _dest.x2[0] = var43.x2[1]; + _dest.x2[1] = var38.x2[1]; + var39.x2[1] = _dest.i; + } + /* 7: storel */ + ptr0[i] = var39; + } + } + +} + +void +videomixer_video_convert_orc_convert_Y444_UYVY (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 89, 52, 52, 52, 95, 85, 89, + 86, 89, 11, 4, 4, 12, 2, 2, 12, 2, 2, 12, 2, 2, 20, 2, + 20, 4, 20, 2, 20, 2, 21, 1, 196, 33, 5, 6, 198, 34, 35, 33, + 21, 1, 39, 32, 34, 35, 21, 1, 196, 0, 32, 4, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y444_UYVY); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_Y444_UYVY"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y444_UYVY); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 2, "s1"); + orc_program_add_source (p, 2, "s2"); + orc_program_add_source (p, 2, "s3"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 4, "t2"); + orc_program_add_temporary (p, 2, "t3"); + orc_program_add_temporary (p, 2, "t4"); + + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_T2, ORC_VAR_S2, ORC_VAR_S3, + ORC_VAR_D1); + orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T3, ORC_VAR_T4, ORC_VAR_T2, + ORC_VAR_D1); + orc_program_append_2 (p, "avgub", 1, ORC_VAR_T1, ORC_VAR_T3, ORC_VAR_T4, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_S1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->params[ORC_VAR_S2] = s2_stride; + ex->arrays[ORC_VAR_S3] = (void *) s3; + ex->params[ORC_VAR_S3] = s3_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_Y444_AYUV */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_Y444_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + orc_int8 var34; + orc_int8 var35; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_int8 var36; +#else + orc_int8 var36; +#endif + orc_int8 var37; + orc_union32 var38; + orc_union16 var39; + orc_union16 var40; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + ptr5 = ORC_PTR_OFFSET (s2, s2_stride * j); + ptr6 = ORC_PTR_OFFSET (s3, s3_stride * j); + + /* 3: loadpb */ + var36 = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var34 = ptr5[i]; + /* 1: loadb */ + var35 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var34; + _dest.x2[1] = var35; + var39.i = _dest.i; + } + /* 4: loadb */ + var37 = ptr4[i]; + /* 5: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36; + _dest.x2[1] = var37; + var40.i = _dest.i; + } + /* 6: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var40.i; + _dest.x2[1] = var39.i; + var38.i = _dest.i; + } + /* 7: storel */ + ptr0[i] = var38; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_Y444_AYUV (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + orc_int8 var34; + orc_int8 var35; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_int8 var36; +#else + orc_int8 var36; +#endif + orc_int8 var37; + orc_union32 var38; + orc_union16 var39; + orc_union16 var40; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + ptr5 = ORC_PTR_OFFSET (ex->arrays[5], ex->params[5] * j); + ptr6 = ORC_PTR_OFFSET (ex->arrays[6], ex->params[6] * j); + + /* 3: loadpb */ + var36 = (int) 0x000000ff; /* 255 or 1.25987e-321f */ + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var34 = ptr5[i]; + /* 1: loadb */ + var35 = ptr6[i]; + /* 2: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var34; + _dest.x2[1] = var35; + var39.i = _dest.i; + } + /* 4: loadb */ + var37 = ptr4[i]; + /* 5: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var36; + _dest.x2[1] = var37; + var40.i = _dest.i; + } + /* 6: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var40.i; + _dest.x2[1] = var39.i; + var38.i = _dest.i; + } + /* 7: storel */ + ptr0[i] = var38; + } + } + +} + +void +videomixer_video_convert_orc_convert_Y444_AYUV (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, + const guint8 * ORC_RESTRICT s2, int s2_stride, + const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 89, 52, 52, 52, 95, 65, 89, + 85, 86, 11, 4, 4, 12, 1, 1, 12, 1, 1, 12, 1, 1, 14, 1, + 255, 0, 0, 0, 20, 2, 20, 2, 196, 32, 5, 6, 196, 33, 16, 4, + 195, 0, 33, 32, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y444_AYUV); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_Y444_AYUV"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_Y444_AYUV); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 1, "s1"); + orc_program_add_source (p, 1, "s2"); + orc_program_add_source (p, 1, "s3"); + orc_program_add_constant (p, 1, 0x000000ff, "c1"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T1, ORC_VAR_S2, ORC_VAR_S3, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T2, ORC_VAR_C1, ORC_VAR_S1, + ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_D1, ORC_VAR_T2, ORC_VAR_T1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->params[ORC_VAR_S2] = s2_stride; + ex->arrays[ORC_VAR_S3] = (void *) s3; + ex->params[ORC_VAR_S3] = s3_stride; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_AYUV_ARGB */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_AYUV_ARGB (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var46; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var47; +#else + orc_union32 var47; +#endif + orc_union16 var48; + orc_union16 var49; + orc_union16 var50; + orc_union16 var51; + orc_union16 var52; + orc_union32 var53; + orc_union32 var54; + orc_union16 var55; + orc_union16 var56; + orc_int8 var57; + orc_int8 var58; + orc_int8 var59; + orc_int8 var60; + orc_union16 var61; + orc_union16 var62; + orc_union16 var63; + orc_union16 var64; + orc_union16 var65; + orc_union16 var66; + orc_union16 var67; + orc_union16 var68; + orc_union16 var69; + orc_union16 var70; + orc_union16 var71; + orc_union16 var72; + orc_int8 var73; + orc_int8 var74; + orc_int8 var75; + orc_union16 var76; + orc_union16 var77; + orc_union32 var78; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 1: loadpb */ + var47.x4[0] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[1] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[2] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[3] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + /* 9: loadpw */ + var48.i = p1; + /* 11: loadpw */ + var49.i = p2; + /* 14: loadpw */ + var50.i = p3; + /* 17: loadpw */ + var51.i = p4; + /* 20: loadpw */ + var52.i = p5; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var46 = ptr4[i]; + /* 2: subb */ + var54.x4[0] = var46.x4[0] - var47.x4[0]; + var54.x4[1] = var46.x4[1] - var47.x4[1]; + var54.x4[2] = var46.x4[2] - var47.x4[2]; + var54.x4[3] = var46.x4[3] - var47.x4[3]; + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var54.i; + var55.i = _src.x2[1]; + var56.i = _src.x2[0]; + } + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var56.i; + var57 = _src.x2[1]; + var58 = _src.x2[0]; + } + /* 5: splitwb */ + { + orc_union16 _src; + _src.i = var55.i; + var59 = _src.x2[1]; + var60 = _src.x2[0]; + } + /* 6: splatbw */ + var61.i = ((var57 & 0xff) << 8) | (var57 & 0xff); + /* 7: splatbw */ + var62.i = ((var60 & 0xff) << 8) | (var60 & 0xff); + /* 8: splatbw */ + var63.i = ((var59 & 0xff) << 8) | (var59 & 0xff); + /* 10: mulhsw */ + var64.i = (var61.i * var48.i) >> 16; + /* 12: mulhsw */ + var65.i = (var63.i * var49.i) >> 16; + /* 13: addssw */ + var66.i = ORC_CLAMP_SW (var64.i + var65.i); + /* 15: mulhsw */ + var67.i = (var62.i * var50.i) >> 16; + /* 16: addssw */ + var68.i = ORC_CLAMP_SW (var64.i + var67.i); + /* 18: mulhsw */ + var69.i = (var62.i * var51.i) >> 16; + /* 19: addssw */ + var70.i = ORC_CLAMP_SW (var64.i + var69.i); + /* 21: mulhsw */ + var71.i = (var63.i * var52.i) >> 16; + /* 22: addssw */ + var72.i = ORC_CLAMP_SW (var70.i + var71.i); + /* 23: convssswb */ + var73 = ORC_CLAMP_SB (var66.i); + /* 24: convssswb */ + var74 = ORC_CLAMP_SB (var72.i); + /* 25: convssswb */ + var75 = ORC_CLAMP_SB (var68.i); + /* 26: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var58; + _dest.x2[1] = var73; + var76.i = _dest.i; + } + /* 27: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var74; + _dest.x2[1] = var75; + var77.i = _dest.i; + } + /* 28: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var76.i; + _dest.x2[1] = var77.i; + var78.i = _dest.i; + } + /* 29: addb */ + var53.x4[0] = var78.x4[0] + var47.x4[0]; + var53.x4[1] = var78.x4[1] + var47.x4[1]; + var53.x4[2] = var78.x4[2] + var47.x4[2]; + var53.x4[3] = var78.x4[3] + var47.x4[3]; + /* 30: storel */ + ptr0[i] = var53; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_AYUV_ARGB (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var46; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var47; +#else + orc_union32 var47; +#endif + orc_union16 var48; + orc_union16 var49; + orc_union16 var50; + orc_union16 var51; + orc_union16 var52; + orc_union32 var53; + orc_union32 var54; + orc_union16 var55; + orc_union16 var56; + orc_int8 var57; + orc_int8 var58; + orc_int8 var59; + orc_int8 var60; + orc_union16 var61; + orc_union16 var62; + orc_union16 var63; + orc_union16 var64; + orc_union16 var65; + orc_union16 var66; + orc_union16 var67; + orc_union16 var68; + orc_union16 var69; + orc_union16 var70; + orc_union16 var71; + orc_union16 var72; + orc_int8 var73; + orc_int8 var74; + orc_int8 var75; + orc_union16 var76; + orc_union16 var77; + orc_union32 var78; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 1: loadpb */ + var47.x4[0] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[1] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[2] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[3] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + /* 9: loadpw */ + var48.i = ex->params[24]; + /* 11: loadpw */ + var49.i = ex->params[25]; + /* 14: loadpw */ + var50.i = ex->params[26]; + /* 17: loadpw */ + var51.i = ex->params[27]; + /* 20: loadpw */ + var52.i = ex->params[28]; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var46 = ptr4[i]; + /* 2: subb */ + var54.x4[0] = var46.x4[0] - var47.x4[0]; + var54.x4[1] = var46.x4[1] - var47.x4[1]; + var54.x4[2] = var46.x4[2] - var47.x4[2]; + var54.x4[3] = var46.x4[3] - var47.x4[3]; + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var54.i; + var55.i = _src.x2[1]; + var56.i = _src.x2[0]; + } + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var56.i; + var57 = _src.x2[1]; + var58 = _src.x2[0]; + } + /* 5: splitwb */ + { + orc_union16 _src; + _src.i = var55.i; + var59 = _src.x2[1]; + var60 = _src.x2[0]; + } + /* 6: splatbw */ + var61.i = ((var57 & 0xff) << 8) | (var57 & 0xff); + /* 7: splatbw */ + var62.i = ((var60 & 0xff) << 8) | (var60 & 0xff); + /* 8: splatbw */ + var63.i = ((var59 & 0xff) << 8) | (var59 & 0xff); + /* 10: mulhsw */ + var64.i = (var61.i * var48.i) >> 16; + /* 12: mulhsw */ + var65.i = (var63.i * var49.i) >> 16; + /* 13: addssw */ + var66.i = ORC_CLAMP_SW (var64.i + var65.i); + /* 15: mulhsw */ + var67.i = (var62.i * var50.i) >> 16; + /* 16: addssw */ + var68.i = ORC_CLAMP_SW (var64.i + var67.i); + /* 18: mulhsw */ + var69.i = (var62.i * var51.i) >> 16; + /* 19: addssw */ + var70.i = ORC_CLAMP_SW (var64.i + var69.i); + /* 21: mulhsw */ + var71.i = (var63.i * var52.i) >> 16; + /* 22: addssw */ + var72.i = ORC_CLAMP_SW (var70.i + var71.i); + /* 23: convssswb */ + var73 = ORC_CLAMP_SB (var66.i); + /* 24: convssswb */ + var74 = ORC_CLAMP_SB (var72.i); + /* 25: convssswb */ + var75 = ORC_CLAMP_SB (var68.i); + /* 26: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var58; + _dest.x2[1] = var73; + var76.i = _dest.i; + } + /* 27: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var74; + _dest.x2[1] = var75; + var77.i = _dest.i; + } + /* 28: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var76.i; + _dest.x2[1] = var77.i; + var78.i = _dest.i; + } + /* 29: addb */ + var53.x4[0] = var78.x4[0] + var47.x4[0]; + var53.x4[1] = var78.x4[1] + var47.x4[1]; + var53.x4[2] = var78.x4[2] + var47.x4[2]; + var53.x4[3] = var78.x4[3] + var47.x4[3]; + /* 30: storel */ + ptr0[i] = var53; + } + } + +} + +void +videomixer_video_convert_orc_convert_AYUV_ARGB (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 65, 89, 85, 86, 95, 65, 82, + 71, 66, 11, 4, 4, 12, 4, 4, 14, 1, 128, 0, 0, 0, 16, 2, + 16, 2, 16, 2, 16, 2, 16, 2, 20, 1, 20, 1, 20, 1, 20, 1, + 20, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, 1, 20, 1, + 20, 1, 20, 4, 21, 2, 65, 45, 4, 16, 198, 38, 36, 45, 199, 33, + 32, 36, 199, 35, 34, 38, 151, 36, 33, 151, 37, 34, 151, 38, 35, 90, + 36, 36, 24, 90, 39, 38, 25, 71, 39, 36, 39, 90, 41, 37, 26, 71, + 41, 36, 41, 90, 40, 37, 27, 71, 40, 36, 40, 90, 36, 38, 28, 71, + 40, 40, 36, 159, 42, 39, 159, 43, 40, 159, 44, 41, 196, 39, 32, 42, + 196, 41, 43, 44, 195, 45, 39, 41, 21, 2, 33, 0, 45, 16, 2, 0, + + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_ARGB); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_AYUV_ARGB"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_ARGB); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_constant (p, 1, 0x00000080, "c1"); + orc_program_add_parameter (p, 2, "p1"); + orc_program_add_parameter (p, 2, "p2"); + orc_program_add_parameter (p, 2, "p3"); + orc_program_add_parameter (p, 2, "p4"); + orc_program_add_parameter (p, 2, "p5"); + orc_program_add_temporary (p, 1, "t1"); + orc_program_add_temporary (p, 1, "t2"); + orc_program_add_temporary (p, 1, "t3"); + orc_program_add_temporary (p, 1, "t4"); + orc_program_add_temporary (p, 2, "t5"); + orc_program_add_temporary (p, 2, "t6"); + orc_program_add_temporary (p, 2, "t7"); + orc_program_add_temporary (p, 2, "t8"); + orc_program_add_temporary (p, 2, "t9"); + orc_program_add_temporary (p, 2, "t10"); + orc_program_add_temporary (p, 1, "t11"); + orc_program_add_temporary (p, 1, "t12"); + orc_program_add_temporary (p, 1, "t13"); + orc_program_add_temporary (p, 4, "t14"); + + orc_program_append_2 (p, "subb", 2, ORC_VAR_T14, ORC_VAR_S1, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T7, ORC_VAR_T5, + ORC_VAR_T14, ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_T7, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T5, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T6, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T7, ORC_VAR_T4, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T8, ORC_VAR_T7, ORC_VAR_P2, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T8, ORC_VAR_T5, ORC_VAR_T8, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T10, ORC_VAR_T6, ORC_VAR_P3, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T10, ORC_VAR_T5, + ORC_VAR_T10, ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T9, ORC_VAR_T6, ORC_VAR_P4, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T9, ORC_VAR_T5, ORC_VAR_T9, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T5, ORC_VAR_T7, ORC_VAR_P5, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T9, ORC_VAR_T9, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T11, ORC_VAR_T8, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T12, ORC_VAR_T9, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T13, ORC_VAR_T10, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T8, ORC_VAR_T1, + ORC_VAR_T11, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T10, ORC_VAR_T12, + ORC_VAR_T13, ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_T14, ORC_VAR_T8, + ORC_VAR_T10, ORC_VAR_D1); + orc_program_append_2 (p, "addb", 2, ORC_VAR_D1, ORC_VAR_T14, ORC_VAR_C1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->params[ORC_VAR_P1] = p1; + ex->params[ORC_VAR_P2] = p2; + ex->params[ORC_VAR_P3] = p3; + ex->params[ORC_VAR_P4] = p4; + ex->params[ORC_VAR_P5] = p5; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_AYUV_BGRA */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_AYUV_BGRA (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var46; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var47; +#else + orc_union32 var47; +#endif + orc_union16 var48; + orc_union16 var49; + orc_union16 var50; + orc_union16 var51; + orc_union16 var52; + orc_union32 var53; + orc_union32 var54; + orc_union16 var55; + orc_union16 var56; + orc_int8 var57; + orc_int8 var58; + orc_int8 var59; + orc_int8 var60; + orc_union16 var61; + orc_union16 var62; + orc_union16 var63; + orc_union16 var64; + orc_union16 var65; + orc_union16 var66; + orc_union16 var67; + orc_union16 var68; + orc_union16 var69; + orc_union16 var70; + orc_union16 var71; + orc_union16 var72; + orc_int8 var73; + orc_int8 var74; + orc_int8 var75; + orc_union16 var76; + orc_union16 var77; + orc_union32 var78; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 1: loadpb */ + var47.x4[0] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[1] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[2] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[3] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + /* 9: loadpw */ + var48.i = p1; + /* 11: loadpw */ + var49.i = p2; + /* 14: loadpw */ + var50.i = p3; + /* 17: loadpw */ + var51.i = p4; + /* 20: loadpw */ + var52.i = p5; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var46 = ptr4[i]; + /* 2: subb */ + var54.x4[0] = var46.x4[0] - var47.x4[0]; + var54.x4[1] = var46.x4[1] - var47.x4[1]; + var54.x4[2] = var46.x4[2] - var47.x4[2]; + var54.x4[3] = var46.x4[3] - var47.x4[3]; + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var54.i; + var55.i = _src.x2[1]; + var56.i = _src.x2[0]; + } + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var56.i; + var57 = _src.x2[1]; + var58 = _src.x2[0]; + } + /* 5: splitwb */ + { + orc_union16 _src; + _src.i = var55.i; + var59 = _src.x2[1]; + var60 = _src.x2[0]; + } + /* 6: splatbw */ + var61.i = ((var57 & 0xff) << 8) | (var57 & 0xff); + /* 7: splatbw */ + var62.i = ((var60 & 0xff) << 8) | (var60 & 0xff); + /* 8: splatbw */ + var63.i = ((var59 & 0xff) << 8) | (var59 & 0xff); + /* 10: mulhsw */ + var64.i = (var61.i * var48.i) >> 16; + /* 12: mulhsw */ + var65.i = (var63.i * var49.i) >> 16; + /* 13: addssw */ + var66.i = ORC_CLAMP_SW (var64.i + var65.i); + /* 15: mulhsw */ + var67.i = (var62.i * var50.i) >> 16; + /* 16: addssw */ + var68.i = ORC_CLAMP_SW (var64.i + var67.i); + /* 18: mulhsw */ + var69.i = (var62.i * var51.i) >> 16; + /* 19: addssw */ + var70.i = ORC_CLAMP_SW (var64.i + var69.i); + /* 21: mulhsw */ + var71.i = (var63.i * var52.i) >> 16; + /* 22: addssw */ + var72.i = ORC_CLAMP_SW (var70.i + var71.i); + /* 23: convssswb */ + var73 = ORC_CLAMP_SB (var66.i); + /* 24: convssswb */ + var74 = ORC_CLAMP_SB (var72.i); + /* 25: convssswb */ + var75 = ORC_CLAMP_SB (var68.i); + /* 26: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var75; + _dest.x2[1] = var74; + var76.i = _dest.i; + } + /* 27: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var73; + _dest.x2[1] = var58; + var77.i = _dest.i; + } + /* 28: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var76.i; + _dest.x2[1] = var77.i; + var78.i = _dest.i; + } + /* 29: addb */ + var53.x4[0] = var78.x4[0] + var47.x4[0]; + var53.x4[1] = var78.x4[1] + var47.x4[1]; + var53.x4[2] = var78.x4[2] + var47.x4[2]; + var53.x4[3] = var78.x4[3] + var47.x4[3]; + /* 30: storel */ + ptr0[i] = var53; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_AYUV_BGRA (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var46; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var47; +#else + orc_union32 var47; +#endif + orc_union16 var48; + orc_union16 var49; + orc_union16 var50; + orc_union16 var51; + orc_union16 var52; + orc_union32 var53; + orc_union32 var54; + orc_union16 var55; + orc_union16 var56; + orc_int8 var57; + orc_int8 var58; + orc_int8 var59; + orc_int8 var60; + orc_union16 var61; + orc_union16 var62; + orc_union16 var63; + orc_union16 var64; + orc_union16 var65; + orc_union16 var66; + orc_union16 var67; + orc_union16 var68; + orc_union16 var69; + orc_union16 var70; + orc_union16 var71; + orc_union16 var72; + orc_int8 var73; + orc_int8 var74; + orc_int8 var75; + orc_union16 var76; + orc_union16 var77; + orc_union32 var78; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 1: loadpb */ + var47.x4[0] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[1] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[2] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[3] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + /* 9: loadpw */ + var48.i = ex->params[24]; + /* 11: loadpw */ + var49.i = ex->params[25]; + /* 14: loadpw */ + var50.i = ex->params[26]; + /* 17: loadpw */ + var51.i = ex->params[27]; + /* 20: loadpw */ + var52.i = ex->params[28]; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var46 = ptr4[i]; + /* 2: subb */ + var54.x4[0] = var46.x4[0] - var47.x4[0]; + var54.x4[1] = var46.x4[1] - var47.x4[1]; + var54.x4[2] = var46.x4[2] - var47.x4[2]; + var54.x4[3] = var46.x4[3] - var47.x4[3]; + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var54.i; + var55.i = _src.x2[1]; + var56.i = _src.x2[0]; + } + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var56.i; + var57 = _src.x2[1]; + var58 = _src.x2[0]; + } + /* 5: splitwb */ + { + orc_union16 _src; + _src.i = var55.i; + var59 = _src.x2[1]; + var60 = _src.x2[0]; + } + /* 6: splatbw */ + var61.i = ((var57 & 0xff) << 8) | (var57 & 0xff); + /* 7: splatbw */ + var62.i = ((var60 & 0xff) << 8) | (var60 & 0xff); + /* 8: splatbw */ + var63.i = ((var59 & 0xff) << 8) | (var59 & 0xff); + /* 10: mulhsw */ + var64.i = (var61.i * var48.i) >> 16; + /* 12: mulhsw */ + var65.i = (var63.i * var49.i) >> 16; + /* 13: addssw */ + var66.i = ORC_CLAMP_SW (var64.i + var65.i); + /* 15: mulhsw */ + var67.i = (var62.i * var50.i) >> 16; + /* 16: addssw */ + var68.i = ORC_CLAMP_SW (var64.i + var67.i); + /* 18: mulhsw */ + var69.i = (var62.i * var51.i) >> 16; + /* 19: addssw */ + var70.i = ORC_CLAMP_SW (var64.i + var69.i); + /* 21: mulhsw */ + var71.i = (var63.i * var52.i) >> 16; + /* 22: addssw */ + var72.i = ORC_CLAMP_SW (var70.i + var71.i); + /* 23: convssswb */ + var73 = ORC_CLAMP_SB (var66.i); + /* 24: convssswb */ + var74 = ORC_CLAMP_SB (var72.i); + /* 25: convssswb */ + var75 = ORC_CLAMP_SB (var68.i); + /* 26: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var75; + _dest.x2[1] = var74; + var76.i = _dest.i; + } + /* 27: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var73; + _dest.x2[1] = var58; + var77.i = _dest.i; + } + /* 28: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var76.i; + _dest.x2[1] = var77.i; + var78.i = _dest.i; + } + /* 29: addb */ + var53.x4[0] = var78.x4[0] + var47.x4[0]; + var53.x4[1] = var78.x4[1] + var47.x4[1]; + var53.x4[2] = var78.x4[2] + var47.x4[2]; + var53.x4[3] = var78.x4[3] + var47.x4[3]; + /* 30: storel */ + ptr0[i] = var53; + } + } + +} + +void +videomixer_video_convert_orc_convert_AYUV_BGRA (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 65, 89, 85, 86, 95, 66, 71, + 82, 65, 11, 4, 4, 12, 4, 4, 14, 1, 128, 0, 0, 0, 16, 2, + 16, 2, 16, 2, 16, 2, 16, 2, 20, 1, 20, 1, 20, 1, 20, 1, + 20, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, 1, 20, 1, + 20, 1, 20, 4, 21, 2, 65, 45, 4, 16, 198, 38, 36, 45, 199, 33, + 32, 36, 199, 35, 34, 38, 151, 36, 33, 151, 37, 34, 151, 38, 35, 90, + 36, 36, 24, 90, 39, 38, 25, 71, 39, 36, 39, 90, 41, 37, 26, 71, + 41, 36, 41, 90, 40, 37, 27, 71, 40, 36, 40, 90, 36, 38, 28, 71, + 40, 40, 36, 159, 42, 39, 159, 43, 40, 159, 44, 41, 196, 41, 44, 43, + 196, 39, 42, 32, 195, 45, 41, 39, 21, 2, 33, 0, 45, 16, 2, 0, + + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_BGRA); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_AYUV_BGRA"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_BGRA); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_constant (p, 1, 0x00000080, "c1"); + orc_program_add_parameter (p, 2, "p1"); + orc_program_add_parameter (p, 2, "p2"); + orc_program_add_parameter (p, 2, "p3"); + orc_program_add_parameter (p, 2, "p4"); + orc_program_add_parameter (p, 2, "p5"); + orc_program_add_temporary (p, 1, "t1"); + orc_program_add_temporary (p, 1, "t2"); + orc_program_add_temporary (p, 1, "t3"); + orc_program_add_temporary (p, 1, "t4"); + orc_program_add_temporary (p, 2, "t5"); + orc_program_add_temporary (p, 2, "t6"); + orc_program_add_temporary (p, 2, "t7"); + orc_program_add_temporary (p, 2, "t8"); + orc_program_add_temporary (p, 2, "t9"); + orc_program_add_temporary (p, 2, "t10"); + orc_program_add_temporary (p, 1, "t11"); + orc_program_add_temporary (p, 1, "t12"); + orc_program_add_temporary (p, 1, "t13"); + orc_program_add_temporary (p, 4, "t14"); + + orc_program_append_2 (p, "subb", 2, ORC_VAR_T14, ORC_VAR_S1, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T7, ORC_VAR_T5, + ORC_VAR_T14, ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_T7, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T5, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T6, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T7, ORC_VAR_T4, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T8, ORC_VAR_T7, ORC_VAR_P2, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T8, ORC_VAR_T5, ORC_VAR_T8, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T10, ORC_VAR_T6, ORC_VAR_P3, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T10, ORC_VAR_T5, + ORC_VAR_T10, ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T9, ORC_VAR_T6, ORC_VAR_P4, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T9, ORC_VAR_T5, ORC_VAR_T9, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T5, ORC_VAR_T7, ORC_VAR_P5, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T9, ORC_VAR_T9, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T11, ORC_VAR_T8, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T12, ORC_VAR_T9, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T13, ORC_VAR_T10, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T10, ORC_VAR_T13, + ORC_VAR_T12, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T8, ORC_VAR_T11, + ORC_VAR_T1, ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_T14, ORC_VAR_T10, + ORC_VAR_T8, ORC_VAR_D1); + orc_program_append_2 (p, "addb", 2, ORC_VAR_D1, ORC_VAR_T14, ORC_VAR_C1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->params[ORC_VAR_P1] = p1; + ex->params[ORC_VAR_P2] = p2; + ex->params[ORC_VAR_P3] = p3; + ex->params[ORC_VAR_P4] = p4; + ex->params[ORC_VAR_P5] = p5; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_AYUV_ABGR */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_AYUV_ABGR (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var46; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var47; +#else + orc_union32 var47; +#endif + orc_union16 var48; + orc_union16 var49; + orc_union16 var50; + orc_union16 var51; + orc_union16 var52; + orc_union32 var53; + orc_union32 var54; + orc_union16 var55; + orc_union16 var56; + orc_int8 var57; + orc_int8 var58; + orc_int8 var59; + orc_int8 var60; + orc_union16 var61; + orc_union16 var62; + orc_union16 var63; + orc_union16 var64; + orc_union16 var65; + orc_union16 var66; + orc_union16 var67; + orc_union16 var68; + orc_union16 var69; + orc_union16 var70; + orc_union16 var71; + orc_union16 var72; + orc_int8 var73; + orc_int8 var74; + orc_int8 var75; + orc_union16 var76; + orc_union16 var77; + orc_union32 var78; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 1: loadpb */ + var47.x4[0] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[1] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[2] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[3] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + /* 9: loadpw */ + var48.i = p1; + /* 11: loadpw */ + var49.i = p2; + /* 14: loadpw */ + var50.i = p3; + /* 17: loadpw */ + var51.i = p4; + /* 20: loadpw */ + var52.i = p5; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var46 = ptr4[i]; + /* 2: subb */ + var54.x4[0] = var46.x4[0] - var47.x4[0]; + var54.x4[1] = var46.x4[1] - var47.x4[1]; + var54.x4[2] = var46.x4[2] - var47.x4[2]; + var54.x4[3] = var46.x4[3] - var47.x4[3]; + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var54.i; + var55.i = _src.x2[1]; + var56.i = _src.x2[0]; + } + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var56.i; + var57 = _src.x2[1]; + var58 = _src.x2[0]; + } + /* 5: splitwb */ + { + orc_union16 _src; + _src.i = var55.i; + var59 = _src.x2[1]; + var60 = _src.x2[0]; + } + /* 6: splatbw */ + var61.i = ((var57 & 0xff) << 8) | (var57 & 0xff); + /* 7: splatbw */ + var62.i = ((var60 & 0xff) << 8) | (var60 & 0xff); + /* 8: splatbw */ + var63.i = ((var59 & 0xff) << 8) | (var59 & 0xff); + /* 10: mulhsw */ + var64.i = (var61.i * var48.i) >> 16; + /* 12: mulhsw */ + var65.i = (var63.i * var49.i) >> 16; + /* 13: addssw */ + var66.i = ORC_CLAMP_SW (var64.i + var65.i); + /* 15: mulhsw */ + var67.i = (var62.i * var50.i) >> 16; + /* 16: addssw */ + var68.i = ORC_CLAMP_SW (var64.i + var67.i); + /* 18: mulhsw */ + var69.i = (var62.i * var51.i) >> 16; + /* 19: addssw */ + var70.i = ORC_CLAMP_SW (var64.i + var69.i); + /* 21: mulhsw */ + var71.i = (var63.i * var52.i) >> 16; + /* 22: addssw */ + var72.i = ORC_CLAMP_SW (var70.i + var71.i); + /* 23: convssswb */ + var73 = ORC_CLAMP_SB (var66.i); + /* 24: convssswb */ + var74 = ORC_CLAMP_SB (var72.i); + /* 25: convssswb */ + var75 = ORC_CLAMP_SB (var68.i); + /* 26: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var58; + _dest.x2[1] = var75; + var76.i = _dest.i; + } + /* 27: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var74; + _dest.x2[1] = var73; + var77.i = _dest.i; + } + /* 28: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var76.i; + _dest.x2[1] = var77.i; + var78.i = _dest.i; + } + /* 29: addb */ + var53.x4[0] = var78.x4[0] + var47.x4[0]; + var53.x4[1] = var78.x4[1] + var47.x4[1]; + var53.x4[2] = var78.x4[2] + var47.x4[2]; + var53.x4[3] = var78.x4[3] + var47.x4[3]; + /* 30: storel */ + ptr0[i] = var53; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_AYUV_ABGR (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var46; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var47; +#else + orc_union32 var47; +#endif + orc_union16 var48; + orc_union16 var49; + orc_union16 var50; + orc_union16 var51; + orc_union16 var52; + orc_union32 var53; + orc_union32 var54; + orc_union16 var55; + orc_union16 var56; + orc_int8 var57; + orc_int8 var58; + orc_int8 var59; + orc_int8 var60; + orc_union16 var61; + orc_union16 var62; + orc_union16 var63; + orc_union16 var64; + orc_union16 var65; + orc_union16 var66; + orc_union16 var67; + orc_union16 var68; + orc_union16 var69; + orc_union16 var70; + orc_union16 var71; + orc_union16 var72; + orc_int8 var73; + orc_int8 var74; + orc_int8 var75; + orc_union16 var76; + orc_union16 var77; + orc_union32 var78; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 1: loadpb */ + var47.x4[0] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[1] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[2] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[3] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + /* 9: loadpw */ + var48.i = ex->params[24]; + /* 11: loadpw */ + var49.i = ex->params[25]; + /* 14: loadpw */ + var50.i = ex->params[26]; + /* 17: loadpw */ + var51.i = ex->params[27]; + /* 20: loadpw */ + var52.i = ex->params[28]; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var46 = ptr4[i]; + /* 2: subb */ + var54.x4[0] = var46.x4[0] - var47.x4[0]; + var54.x4[1] = var46.x4[1] - var47.x4[1]; + var54.x4[2] = var46.x4[2] - var47.x4[2]; + var54.x4[3] = var46.x4[3] - var47.x4[3]; + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var54.i; + var55.i = _src.x2[1]; + var56.i = _src.x2[0]; + } + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var56.i; + var57 = _src.x2[1]; + var58 = _src.x2[0]; + } + /* 5: splitwb */ + { + orc_union16 _src; + _src.i = var55.i; + var59 = _src.x2[1]; + var60 = _src.x2[0]; + } + /* 6: splatbw */ + var61.i = ((var57 & 0xff) << 8) | (var57 & 0xff); + /* 7: splatbw */ + var62.i = ((var60 & 0xff) << 8) | (var60 & 0xff); + /* 8: splatbw */ + var63.i = ((var59 & 0xff) << 8) | (var59 & 0xff); + /* 10: mulhsw */ + var64.i = (var61.i * var48.i) >> 16; + /* 12: mulhsw */ + var65.i = (var63.i * var49.i) >> 16; + /* 13: addssw */ + var66.i = ORC_CLAMP_SW (var64.i + var65.i); + /* 15: mulhsw */ + var67.i = (var62.i * var50.i) >> 16; + /* 16: addssw */ + var68.i = ORC_CLAMP_SW (var64.i + var67.i); + /* 18: mulhsw */ + var69.i = (var62.i * var51.i) >> 16; + /* 19: addssw */ + var70.i = ORC_CLAMP_SW (var64.i + var69.i); + /* 21: mulhsw */ + var71.i = (var63.i * var52.i) >> 16; + /* 22: addssw */ + var72.i = ORC_CLAMP_SW (var70.i + var71.i); + /* 23: convssswb */ + var73 = ORC_CLAMP_SB (var66.i); + /* 24: convssswb */ + var74 = ORC_CLAMP_SB (var72.i); + /* 25: convssswb */ + var75 = ORC_CLAMP_SB (var68.i); + /* 26: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var58; + _dest.x2[1] = var75; + var76.i = _dest.i; + } + /* 27: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var74; + _dest.x2[1] = var73; + var77.i = _dest.i; + } + /* 28: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var76.i; + _dest.x2[1] = var77.i; + var78.i = _dest.i; + } + /* 29: addb */ + var53.x4[0] = var78.x4[0] + var47.x4[0]; + var53.x4[1] = var78.x4[1] + var47.x4[1]; + var53.x4[2] = var78.x4[2] + var47.x4[2]; + var53.x4[3] = var78.x4[3] + var47.x4[3]; + /* 30: storel */ + ptr0[i] = var53; + } + } + +} + +void +videomixer_video_convert_orc_convert_AYUV_ABGR (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 65, 89, 85, 86, 95, 65, 66, + 71, 82, 11, 4, 4, 12, 4, 4, 14, 1, 128, 0, 0, 0, 16, 2, + 16, 2, 16, 2, 16, 2, 16, 2, 20, 1, 20, 1, 20, 1, 20, 1, + 20, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, 1, 20, 1, + 20, 1, 20, 4, 21, 2, 65, 45, 4, 16, 198, 38, 36, 45, 199, 33, + 32, 36, 199, 35, 34, 38, 151, 36, 33, 151, 37, 34, 151, 38, 35, 90, + 36, 36, 24, 90, 39, 38, 25, 71, 39, 36, 39, 90, 41, 37, 26, 71, + 41, 36, 41, 90, 40, 37, 27, 71, 40, 36, 40, 90, 36, 38, 28, 71, + 40, 40, 36, 159, 42, 39, 159, 43, 40, 159, 44, 41, 196, 41, 32, 44, + 196, 39, 43, 42, 195, 45, 41, 39, 21, 2, 33, 0, 45, 16, 2, 0, + + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_ABGR); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_AYUV_ABGR"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_ABGR); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_constant (p, 1, 0x00000080, "c1"); + orc_program_add_parameter (p, 2, "p1"); + orc_program_add_parameter (p, 2, "p2"); + orc_program_add_parameter (p, 2, "p3"); + orc_program_add_parameter (p, 2, "p4"); + orc_program_add_parameter (p, 2, "p5"); + orc_program_add_temporary (p, 1, "t1"); + orc_program_add_temporary (p, 1, "t2"); + orc_program_add_temporary (p, 1, "t3"); + orc_program_add_temporary (p, 1, "t4"); + orc_program_add_temporary (p, 2, "t5"); + orc_program_add_temporary (p, 2, "t6"); + orc_program_add_temporary (p, 2, "t7"); + orc_program_add_temporary (p, 2, "t8"); + orc_program_add_temporary (p, 2, "t9"); + orc_program_add_temporary (p, 2, "t10"); + orc_program_add_temporary (p, 1, "t11"); + orc_program_add_temporary (p, 1, "t12"); + orc_program_add_temporary (p, 1, "t13"); + orc_program_add_temporary (p, 4, "t14"); + + orc_program_append_2 (p, "subb", 2, ORC_VAR_T14, ORC_VAR_S1, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T7, ORC_VAR_T5, + ORC_VAR_T14, ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_T7, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T5, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T6, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T7, ORC_VAR_T4, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T8, ORC_VAR_T7, ORC_VAR_P2, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T8, ORC_VAR_T5, ORC_VAR_T8, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T10, ORC_VAR_T6, ORC_VAR_P3, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T10, ORC_VAR_T5, + ORC_VAR_T10, ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T9, ORC_VAR_T6, ORC_VAR_P4, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T9, ORC_VAR_T5, ORC_VAR_T9, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T5, ORC_VAR_T7, ORC_VAR_P5, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T9, ORC_VAR_T9, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T11, ORC_VAR_T8, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T12, ORC_VAR_T9, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T13, ORC_VAR_T10, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T10, ORC_VAR_T1, + ORC_VAR_T13, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T8, ORC_VAR_T12, + ORC_VAR_T11, ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_T14, ORC_VAR_T10, + ORC_VAR_T8, ORC_VAR_D1); + orc_program_append_2 (p, "addb", 2, ORC_VAR_D1, ORC_VAR_T14, ORC_VAR_C1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->params[ORC_VAR_P1] = p1; + ex->params[ORC_VAR_P2] = p2; + ex->params[ORC_VAR_P3] = p3; + ex->params[ORC_VAR_P4] = p4; + ex->params[ORC_VAR_P5] = p5; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_AYUV_RGBA */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_AYUV_RGBA (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m) +{ + int i; + int j; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var46; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var47; +#else + orc_union32 var47; +#endif + orc_union16 var48; + orc_union16 var49; + orc_union16 var50; + orc_union16 var51; + orc_union16 var52; + orc_union32 var53; + orc_union32 var54; + orc_union16 var55; + orc_union16 var56; + orc_int8 var57; + orc_int8 var58; + orc_int8 var59; + orc_int8 var60; + orc_union16 var61; + orc_union16 var62; + orc_union16 var63; + orc_union16 var64; + orc_union16 var65; + orc_union16 var66; + orc_union16 var67; + orc_union16 var68; + orc_union16 var69; + orc_union16 var70; + orc_union16 var71; + orc_union16 var72; + orc_int8 var73; + orc_int8 var74; + orc_int8 var75; + orc_union16 var76; + orc_union16 var77; + orc_union32 var78; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j); + ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j); + + /* 1: loadpb */ + var47.x4[0] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[1] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[2] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[3] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + /* 9: loadpw */ + var48.i = p1; + /* 11: loadpw */ + var49.i = p2; + /* 14: loadpw */ + var50.i = p3; + /* 17: loadpw */ + var51.i = p4; + /* 20: loadpw */ + var52.i = p5; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var46 = ptr4[i]; + /* 2: subb */ + var54.x4[0] = var46.x4[0] - var47.x4[0]; + var54.x4[1] = var46.x4[1] - var47.x4[1]; + var54.x4[2] = var46.x4[2] - var47.x4[2]; + var54.x4[3] = var46.x4[3] - var47.x4[3]; + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var54.i; + var55.i = _src.x2[1]; + var56.i = _src.x2[0]; + } + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var56.i; + var57 = _src.x2[1]; + var58 = _src.x2[0]; + } + /* 5: splitwb */ + { + orc_union16 _src; + _src.i = var55.i; + var59 = _src.x2[1]; + var60 = _src.x2[0]; + } + /* 6: splatbw */ + var61.i = ((var57 & 0xff) << 8) | (var57 & 0xff); + /* 7: splatbw */ + var62.i = ((var60 & 0xff) << 8) | (var60 & 0xff); + /* 8: splatbw */ + var63.i = ((var59 & 0xff) << 8) | (var59 & 0xff); + /* 10: mulhsw */ + var64.i = (var61.i * var48.i) >> 16; + /* 12: mulhsw */ + var65.i = (var63.i * var49.i) >> 16; + /* 13: addssw */ + var66.i = ORC_CLAMP_SW (var64.i + var65.i); + /* 15: mulhsw */ + var67.i = (var62.i * var50.i) >> 16; + /* 16: addssw */ + var68.i = ORC_CLAMP_SW (var64.i + var67.i); + /* 18: mulhsw */ + var69.i = (var62.i * var51.i) >> 16; + /* 19: addssw */ + var70.i = ORC_CLAMP_SW (var64.i + var69.i); + /* 21: mulhsw */ + var71.i = (var63.i * var52.i) >> 16; + /* 22: addssw */ + var72.i = ORC_CLAMP_SW (var70.i + var71.i); + /* 23: convssswb */ + var73 = ORC_CLAMP_SB (var66.i); + /* 24: convssswb */ + var74 = ORC_CLAMP_SB (var72.i); + /* 25: convssswb */ + var75 = ORC_CLAMP_SB (var68.i); + /* 26: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var73; + _dest.x2[1] = var74; + var76.i = _dest.i; + } + /* 27: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var75; + _dest.x2[1] = var58; + var77.i = _dest.i; + } + /* 28: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var76.i; + _dest.x2[1] = var77.i; + var78.i = _dest.i; + } + /* 29: addb */ + var53.x4[0] = var78.x4[0] + var47.x4[0]; + var53.x4[1] = var78.x4[1] + var47.x4[1]; + var53.x4[2] = var78.x4[2] + var47.x4[2]; + var53.x4[3] = var78.x4[3] + var47.x4[3]; + /* 30: storel */ + ptr0[i] = var53; + } + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_AYUV_RGBA (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int j; + int n = ex->n; + int m = ex->params[ORC_VAR_A1]; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var46; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var47; +#else + orc_union32 var47; +#endif + orc_union16 var48; + orc_union16 var49; + orc_union16 var50; + orc_union16 var51; + orc_union16 var52; + orc_union32 var53; + orc_union32 var54; + orc_union16 var55; + orc_union16 var56; + orc_int8 var57; + orc_int8 var58; + orc_int8 var59; + orc_int8 var60; + orc_union16 var61; + orc_union16 var62; + orc_union16 var63; + orc_union16 var64; + orc_union16 var65; + orc_union16 var66; + orc_union16 var67; + orc_union16 var68; + orc_union16 var69; + orc_union16 var70; + orc_union16 var71; + orc_union16 var72; + orc_int8 var73; + orc_int8 var74; + orc_int8 var75; + orc_union16 var76; + orc_union16 var77; + orc_union32 var78; + + for (j = 0; j < m; j++) { + ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j); + ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j); + + /* 1: loadpb */ + var47.x4[0] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[1] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[2] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var47.x4[3] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + /* 9: loadpw */ + var48.i = ex->params[24]; + /* 11: loadpw */ + var49.i = ex->params[25]; + /* 14: loadpw */ + var50.i = ex->params[26]; + /* 17: loadpw */ + var51.i = ex->params[27]; + /* 20: loadpw */ + var52.i = ex->params[28]; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var46 = ptr4[i]; + /* 2: subb */ + var54.x4[0] = var46.x4[0] - var47.x4[0]; + var54.x4[1] = var46.x4[1] - var47.x4[1]; + var54.x4[2] = var46.x4[2] - var47.x4[2]; + var54.x4[3] = var46.x4[3] - var47.x4[3]; + /* 3: splitlw */ + { + orc_union32 _src; + _src.i = var54.i; + var55.i = _src.x2[1]; + var56.i = _src.x2[0]; + } + /* 4: splitwb */ + { + orc_union16 _src; + _src.i = var56.i; + var57 = _src.x2[1]; + var58 = _src.x2[0]; + } + /* 5: splitwb */ + { + orc_union16 _src; + _src.i = var55.i; + var59 = _src.x2[1]; + var60 = _src.x2[0]; + } + /* 6: splatbw */ + var61.i = ((var57 & 0xff) << 8) | (var57 & 0xff); + /* 7: splatbw */ + var62.i = ((var60 & 0xff) << 8) | (var60 & 0xff); + /* 8: splatbw */ + var63.i = ((var59 & 0xff) << 8) | (var59 & 0xff); + /* 10: mulhsw */ + var64.i = (var61.i * var48.i) >> 16; + /* 12: mulhsw */ + var65.i = (var63.i * var49.i) >> 16; + /* 13: addssw */ + var66.i = ORC_CLAMP_SW (var64.i + var65.i); + /* 15: mulhsw */ + var67.i = (var62.i * var50.i) >> 16; + /* 16: addssw */ + var68.i = ORC_CLAMP_SW (var64.i + var67.i); + /* 18: mulhsw */ + var69.i = (var62.i * var51.i) >> 16; + /* 19: addssw */ + var70.i = ORC_CLAMP_SW (var64.i + var69.i); + /* 21: mulhsw */ + var71.i = (var63.i * var52.i) >> 16; + /* 22: addssw */ + var72.i = ORC_CLAMP_SW (var70.i + var71.i); + /* 23: convssswb */ + var73 = ORC_CLAMP_SB (var66.i); + /* 24: convssswb */ + var74 = ORC_CLAMP_SB (var72.i); + /* 25: convssswb */ + var75 = ORC_CLAMP_SB (var68.i); + /* 26: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var73; + _dest.x2[1] = var74; + var76.i = _dest.i; + } + /* 27: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var75; + _dest.x2[1] = var58; + var77.i = _dest.i; + } + /* 28: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var76.i; + _dest.x2[1] = var77.i; + var78.i = _dest.i; + } + /* 29: addb */ + var53.x4[0] = var78.x4[0] + var47.x4[0]; + var53.x4[1] = var78.x4[1] + var47.x4[1]; + var53.x4[2] = var78.x4[2] + var47.x4[2]; + var53.x4[3] = var78.x4[3] + var47.x4[3]; + /* 30: storel */ + ptr0[i] = var53; + } + } + +} + +void +videomixer_video_convert_orc_convert_AYUV_RGBA (guint8 * ORC_RESTRICT d1, + int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, + int p2, int p3, int p4, int p5, int n, int m) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 7, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, + 99, + 95, 99, 111, 110, 118, 101, 114, 116, 95, 65, 89, 85, 86, 95, 82, 71, + 66, 65, 11, 4, 4, 12, 4, 4, 14, 1, 128, 0, 0, 0, 16, 2, + 16, 2, 16, 2, 16, 2, 16, 2, 20, 1, 20, 1, 20, 1, 20, 1, + 20, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, 1, 20, 1, + 20, 1, 20, 4, 21, 2, 65, 45, 4, 16, 198, 38, 36, 45, 199, 33, + 32, 36, 199, 35, 34, 38, 151, 36, 33, 151, 37, 34, 151, 38, 35, 90, + 36, 36, 24, 90, 39, 38, 25, 71, 39, 36, 39, 90, 41, 37, 26, 71, + 41, 36, 41, 90, 40, 37, 27, 71, 40, 36, 40, 90, 36, 38, 28, 71, + 40, 40, 36, 159, 42, 39, 159, 43, 40, 159, 44, 41, 196, 39, 42, 43, + 196, 41, 44, 32, 195, 45, 39, 41, 21, 2, 33, 0, 45, 16, 2, 0, + + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_RGBA); +#else + p = orc_program_new (); + orc_program_set_2d (p); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_AYUV_RGBA"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_AYUV_RGBA); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_constant (p, 1, 0x00000080, "c1"); + orc_program_add_parameter (p, 2, "p1"); + orc_program_add_parameter (p, 2, "p2"); + orc_program_add_parameter (p, 2, "p3"); + orc_program_add_parameter (p, 2, "p4"); + orc_program_add_parameter (p, 2, "p5"); + orc_program_add_temporary (p, 1, "t1"); + orc_program_add_temporary (p, 1, "t2"); + orc_program_add_temporary (p, 1, "t3"); + orc_program_add_temporary (p, 1, "t4"); + orc_program_add_temporary (p, 2, "t5"); + orc_program_add_temporary (p, 2, "t6"); + orc_program_add_temporary (p, 2, "t7"); + orc_program_add_temporary (p, 2, "t8"); + orc_program_add_temporary (p, 2, "t9"); + orc_program_add_temporary (p, 2, "t10"); + orc_program_add_temporary (p, 1, "t11"); + orc_program_add_temporary (p, 1, "t12"); + orc_program_add_temporary (p, 1, "t13"); + orc_program_add_temporary (p, 4, "t14"); + + orc_program_append_2 (p, "subb", 2, ORC_VAR_T14, ORC_VAR_S1, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T7, ORC_VAR_T5, + ORC_VAR_T14, ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_T7, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T5, ORC_VAR_T2, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T6, ORC_VAR_T3, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T7, ORC_VAR_T4, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T8, ORC_VAR_T7, ORC_VAR_P2, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T8, ORC_VAR_T5, ORC_VAR_T8, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T10, ORC_VAR_T6, ORC_VAR_P3, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T10, ORC_VAR_T5, + ORC_VAR_T10, ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T9, ORC_VAR_T6, ORC_VAR_P4, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T9, ORC_VAR_T5, ORC_VAR_T9, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T5, ORC_VAR_T7, ORC_VAR_P5, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T9, ORC_VAR_T9, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T11, ORC_VAR_T8, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T12, ORC_VAR_T9, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T13, ORC_VAR_T10, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T8, ORC_VAR_T11, + ORC_VAR_T12, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T10, ORC_VAR_T13, + ORC_VAR_T1, ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_T14, ORC_VAR_T8, + ORC_VAR_T10, ORC_VAR_D1); + orc_program_append_2 (p, "addb", 2, ORC_VAR_D1, ORC_VAR_T14, ORC_VAR_C1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ORC_EXECUTOR_M (ex) = m; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_D1] = d1_stride; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_S1] = s1_stride; + ex->params[ORC_VAR_P1] = p1; + ex->params[ORC_VAR_P2] = p2; + ex->params[ORC_VAR_P3] = p3; + ex->params[ORC_VAR_P4] = p4; + ex->params[ORC_VAR_P5] = p5; + + func = c->exec; + func (ex); +} +#endif + + +/* videomixer_video_convert_orc_convert_I420_BGRA */ +#ifdef DISABLE_ORC +void +videomixer_video_convert_orc_convert_I420_BGRA (guint8 * ORC_RESTRICT d1, + const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, + const guint8 * ORC_RESTRICT s3, int p1, int p2, int p3, int p4, int p5, + int n) +{ + int i; + orc_union32 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + orc_int8 var42; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_int8 var43; +#else + orc_int8 var43; +#endif + orc_union16 var44; + orc_union16 var45; + orc_union16 var46; + orc_union16 var47; + orc_union16 var48; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_int8 var49; +#else + orc_int8 var49; +#endif +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var50; +#else + orc_union32 var50; +#endif + orc_union32 var51; + orc_int8 var52; + orc_union16 var53; + orc_int8 var54; + orc_int8 var55; + orc_union16 var56; + orc_int8 var57; + orc_int8 var58; + orc_union16 var59; + orc_union16 var60; + orc_union16 var61; + orc_union16 var62; + orc_union16 var63; + orc_union16 var64; + orc_union16 var65; + orc_union16 var66; + orc_union16 var67; + orc_union16 var68; + orc_int8 var69; + orc_int8 var70; + orc_int8 var71; + orc_union16 var72; + orc_union16 var73; + orc_union32 var74; + + ptr0 = (orc_union32 *) d1; + ptr4 = (orc_int8 *) s1; + ptr5 = (orc_int8 *) s2; + ptr6 = (orc_int8 *) s3; + + /* 1: loadpb */ + var43 = (int) 0x00000080; /* 128 or 6.32404e-322f */ + /* 10: loadpw */ + var44.i = p1; + /* 12: loadpw */ + var45.i = p2; + /* 15: loadpw */ + var46.i = p3; + /* 18: loadpw */ + var47.i = p4; + /* 21: loadpw */ + var48.i = p5; + /* 28: loadpb */ + var49 = (int) 0x0000007f; /* 127 or 6.27463e-322f */ + /* 31: loadpb */ + var50.x4[0] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var50.x4[1] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var50.x4[2] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var50.x4[3] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var42 = ptr4[i]; + /* 2: subb */ + var52 = var42 - var43; + /* 3: splatbw */ + var53.i = ((var52 & 0xff) << 8) | (var52 & 0xff); + /* 4: loadupdb */ + var54 = ptr5[i >> 1]; + /* 5: subb */ + var55 = var54 - var43; + /* 6: splatbw */ + var56.i = ((var55 & 0xff) << 8) | (var55 & 0xff); + /* 7: loadupdb */ + var57 = ptr6[i >> 1]; + /* 8: subb */ + var58 = var57 - var43; + /* 9: splatbw */ + var59.i = ((var58 & 0xff) << 8) | (var58 & 0xff); + /* 11: mulhsw */ + var60.i = (var53.i * var44.i) >> 16; + /* 13: mulhsw */ + var61.i = (var59.i * var45.i) >> 16; + /* 14: addssw */ + var62.i = ORC_CLAMP_SW (var60.i + var61.i); + /* 16: mulhsw */ + var63.i = (var56.i * var46.i) >> 16; + /* 17: addssw */ + var64.i = ORC_CLAMP_SW (var60.i + var63.i); + /* 19: mulhsw */ + var65.i = (var56.i * var47.i) >> 16; + /* 20: addssw */ + var66.i = ORC_CLAMP_SW (var60.i + var65.i); + /* 22: mulhsw */ + var67.i = (var59.i * var48.i) >> 16; + /* 23: addssw */ + var68.i = ORC_CLAMP_SW (var66.i + var67.i); + /* 24: convssswb */ + var69 = ORC_CLAMP_SB (var62.i); + /* 25: convssswb */ + var70 = ORC_CLAMP_SB (var68.i); + /* 26: convssswb */ + var71 = ORC_CLAMP_SB (var64.i); + /* 27: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var71; + _dest.x2[1] = var70; + var72.i = _dest.i; + } + /* 29: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var69; + _dest.x2[1] = var49; + var73.i = _dest.i; + } + /* 30: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var72.i; + _dest.x2[1] = var73.i; + var74.i = _dest.i; + } + /* 32: addb */ + var51.x4[0] = var74.x4[0] + var50.x4[0]; + var51.x4[1] = var74.x4[1] + var50.x4[1]; + var51.x4[2] = var74.x4[2] + var50.x4[2]; + var51.x4[3] = var74.x4[3] + var50.x4[3]; + /* 33: storel */ + ptr0[i] = var51; + } + +} + +#else +static void +_backup_videomixer_video_convert_orc_convert_I420_BGRA (OrcExecutor * + ORC_RESTRICT ex) +{ + int i; + int n = ex->n; + orc_union32 *ORC_RESTRICT ptr0; + const orc_int8 *ORC_RESTRICT ptr4; + const orc_int8 *ORC_RESTRICT ptr5; + const orc_int8 *ORC_RESTRICT ptr6; + orc_int8 var42; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_int8 var43; +#else + orc_int8 var43; +#endif + orc_union16 var44; + orc_union16 var45; + orc_union16 var46; + orc_union16 var47; + orc_union16 var48; +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_int8 var49; +#else + orc_int8 var49; +#endif +#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) + volatile orc_union32 var50; +#else + orc_union32 var50; +#endif + orc_union32 var51; + orc_int8 var52; + orc_union16 var53; + orc_int8 var54; + orc_int8 var55; + orc_union16 var56; + orc_int8 var57; + orc_int8 var58; + orc_union16 var59; + orc_union16 var60; + orc_union16 var61; + orc_union16 var62; + orc_union16 var63; + orc_union16 var64; + orc_union16 var65; + orc_union16 var66; + orc_union16 var67; + orc_union16 var68; + orc_int8 var69; + orc_int8 var70; + orc_int8 var71; + orc_union16 var72; + orc_union16 var73; + orc_union32 var74; + + ptr0 = (orc_union32 *) ex->arrays[0]; + ptr4 = (orc_int8 *) ex->arrays[4]; + ptr5 = (orc_int8 *) ex->arrays[5]; + ptr6 = (orc_int8 *) ex->arrays[6]; + + /* 1: loadpb */ + var43 = (int) 0x00000080; /* 128 or 6.32404e-322f */ + /* 10: loadpw */ + var44.i = ex->params[24]; + /* 12: loadpw */ + var45.i = ex->params[25]; + /* 15: loadpw */ + var46.i = ex->params[26]; + /* 18: loadpw */ + var47.i = ex->params[27]; + /* 21: loadpw */ + var48.i = ex->params[28]; + /* 28: loadpb */ + var49 = (int) 0x0000007f; /* 127 or 6.27463e-322f */ + /* 31: loadpb */ + var50.x4[0] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var50.x4[1] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var50.x4[2] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + var50.x4[3] = (int) 0x00000080; /* 128 or 6.32404e-322f */ + + for (i = 0; i < n; i++) { + /* 0: loadb */ + var42 = ptr4[i]; + /* 2: subb */ + var52 = var42 - var43; + /* 3: splatbw */ + var53.i = ((var52 & 0xff) << 8) | (var52 & 0xff); + /* 4: loadupdb */ + var54 = ptr5[i >> 1]; + /* 5: subb */ + var55 = var54 - var43; + /* 6: splatbw */ + var56.i = ((var55 & 0xff) << 8) | (var55 & 0xff); + /* 7: loadupdb */ + var57 = ptr6[i >> 1]; + /* 8: subb */ + var58 = var57 - var43; + /* 9: splatbw */ + var59.i = ((var58 & 0xff) << 8) | (var58 & 0xff); + /* 11: mulhsw */ + var60.i = (var53.i * var44.i) >> 16; + /* 13: mulhsw */ + var61.i = (var59.i * var45.i) >> 16; + /* 14: addssw */ + var62.i = ORC_CLAMP_SW (var60.i + var61.i); + /* 16: mulhsw */ + var63.i = (var56.i * var46.i) >> 16; + /* 17: addssw */ + var64.i = ORC_CLAMP_SW (var60.i + var63.i); + /* 19: mulhsw */ + var65.i = (var56.i * var47.i) >> 16; + /* 20: addssw */ + var66.i = ORC_CLAMP_SW (var60.i + var65.i); + /* 22: mulhsw */ + var67.i = (var59.i * var48.i) >> 16; + /* 23: addssw */ + var68.i = ORC_CLAMP_SW (var66.i + var67.i); + /* 24: convssswb */ + var69 = ORC_CLAMP_SB (var62.i); + /* 25: convssswb */ + var70 = ORC_CLAMP_SB (var68.i); + /* 26: convssswb */ + var71 = ORC_CLAMP_SB (var64.i); + /* 27: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var71; + _dest.x2[1] = var70; + var72.i = _dest.i; + } + /* 29: mergebw */ + { + orc_union16 _dest; + _dest.x2[0] = var69; + _dest.x2[1] = var49; + var73.i = _dest.i; + } + /* 30: mergewl */ + { + orc_union32 _dest; + _dest.x2[0] = var72.i; + _dest.x2[1] = var73.i; + var74.i = _dest.i; + } + /* 32: addb */ + var51.x4[0] = var74.x4[0] + var50.x4[0]; + var51.x4[1] = var74.x4[1] + var50.x4[1]; + var51.x4[2] = var74.x4[2] + var50.x4[2]; + var51.x4[3] = var74.x4[3] + var50.x4[3]; + /* 33: storel */ + ptr0[i] = var51; + } + +} + +void +videomixer_video_convert_orc_convert_I420_BGRA (guint8 * ORC_RESTRICT d1, + const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, + const guint8 * ORC_RESTRICT s3, int p1, int p2, int p3, int p4, int p5, + int n) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 9, 46, 118, 105, 100, 101, 111, 109, 105, 120, 101, 114, 95, 118, + 105, + 100, 101, 111, 95, 99, 111, 110, 118, 101, 114, 116, 95, 111, 114, 99, + 95, + 99, 111, 110, 118, 101, 114, 116, 95, 73, 52, 50, 48, 95, 66, 71, 82, + 65, 11, 4, 4, 12, 1, 1, 12, 1, 1, 12, 1, 1, 14, 1, 128, + 0, 0, 0, 14, 1, 127, 0, 0, 0, 16, 2, 16, 2, 16, 2, 16, + 2, 16, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, 2, 20, + 1, 20, 1, 20, 1, 20, 4, 65, 38, 4, 16, 151, 32, 38, 45, 38, + 5, 65, 38, 38, 16, 151, 33, 38, 45, 38, 6, 65, 38, 38, 16, 151, + 34, 38, 90, 32, 32, 24, 90, 35, 34, 25, 71, 35, 32, 35, 90, 37, + 33, 26, 71, 37, 32, 37, 90, 36, 33, 27, 71, 36, 32, 36, 90, 32, + 34, 28, 71, 36, 36, 32, 159, 38, 35, 159, 39, 36, 159, 40, 37, 196, + 37, 40, 39, 196, 35, 38, 17, 195, 41, 37, 35, 21, 2, 33, 0, 41, + 16, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_I420_BGRA); +#else + p = orc_program_new (); + orc_program_set_name (p, + "videomixer_video_convert_orc_convert_I420_BGRA"); + orc_program_set_backup_function (p, + _backup_videomixer_video_convert_orc_convert_I420_BGRA); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 1, "s1"); + orc_program_add_source (p, 1, "s2"); + orc_program_add_source (p, 1, "s3"); + orc_program_add_constant (p, 1, 0x00000080, "c1"); + orc_program_add_constant (p, 1, 0x0000007f, "c2"); + orc_program_add_parameter (p, 2, "p1"); + orc_program_add_parameter (p, 2, "p2"); + orc_program_add_parameter (p, 2, "p3"); + orc_program_add_parameter (p, 2, "p4"); + orc_program_add_parameter (p, 2, "p5"); + orc_program_add_temporary (p, 2, "t1"); + orc_program_add_temporary (p, 2, "t2"); + orc_program_add_temporary (p, 2, "t3"); + orc_program_add_temporary (p, 2, "t4"); + orc_program_add_temporary (p, 2, "t5"); + orc_program_add_temporary (p, 2, "t6"); + orc_program_add_temporary (p, 1, "t7"); + orc_program_add_temporary (p, 1, "t8"); + orc_program_add_temporary (p, 1, "t9"); + orc_program_add_temporary (p, 4, "t10"); + + orc_program_append_2 (p, "subb", 0, ORC_VAR_T7, ORC_VAR_S1, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T1, ORC_VAR_T7, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "loadupdb", 0, ORC_VAR_T7, ORC_VAR_S2, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "subb", 0, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T2, ORC_VAR_T7, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "loadupdb", 0, ORC_VAR_T7, ORC_VAR_S3, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "subb", 0, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_C1, + ORC_VAR_D1); + orc_program_append_2 (p, "splatbw", 0, ORC_VAR_T3, ORC_VAR_T7, ORC_VAR_D1, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_P2, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T4, ORC_VAR_T1, ORC_VAR_T4, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T6, ORC_VAR_T2, ORC_VAR_P3, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T6, ORC_VAR_T1, ORC_VAR_T6, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T5, ORC_VAR_T2, ORC_VAR_P4, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T5, ORC_VAR_T1, ORC_VAR_T5, + ORC_VAR_D1); + orc_program_append_2 (p, "mulhsw", 0, ORC_VAR_T1, ORC_VAR_T3, ORC_VAR_P5, + ORC_VAR_D1); + orc_program_append_2 (p, "addssw", 0, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_T1, + ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T7, ORC_VAR_T4, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T8, ORC_VAR_T5, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "convssswb", 0, ORC_VAR_T9, ORC_VAR_T6, + ORC_VAR_D1, ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T6, ORC_VAR_T9, ORC_VAR_T8, + ORC_VAR_D1); + orc_program_append_2 (p, "mergebw", 0, ORC_VAR_T4, ORC_VAR_T7, ORC_VAR_C2, + ORC_VAR_D1); + orc_program_append_2 (p, "mergewl", 0, ORC_VAR_T10, ORC_VAR_T6, + ORC_VAR_T4, ORC_VAR_D1); + orc_program_append_2 (p, "addb", 2, ORC_VAR_D1, ORC_VAR_T10, ORC_VAR_C1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->arrays[ORC_VAR_S3] = (void *) s3; + ex->params[ORC_VAR_P1] = p1; + ex->params[ORC_VAR_P2] = p2; + ex->params[ORC_VAR_P3] = p3; + ex->params[ORC_VAR_P4] = p4; + ex->params[ORC_VAR_P5] = p5; + + func = c->exec; + func (ex); +} +#endif diff --git a/gst/videomixer/videomixerorc-dist.h b/gst/videomixer/videomixerorc-dist.h new file mode 100755 index 0000000..ad35551 --- /dev/null +++ b/gst/videomixer/videomixerorc-dist.h @@ -0,0 +1,131 @@ + +/* autogenerated from videomixerorc.orc */ + +#ifndef _VIDEOMIXERORC_H_ +#define _VIDEOMIXERORC_H_ + +#include <glib.h> + +#ifdef __cplusplus +extern "C" { +#endif + + + +#ifndef _ORC_INTEGER_TYPEDEFS_ +#define _ORC_INTEGER_TYPEDEFS_ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include <stdint.h> +typedef int8_t orc_int8; +typedef int16_t orc_int16; +typedef int32_t orc_int32; +typedef int64_t orc_int64; +typedef uint8_t orc_uint8; +typedef uint16_t orc_uint16; +typedef uint32_t orc_uint32; +typedef uint64_t orc_uint64; +#define ORC_UINT64_C(x) UINT64_C(x) +#elif defined(_MSC_VER) +typedef signed __int8 orc_int8; +typedef signed __int16 orc_int16; +typedef signed __int32 orc_int32; +typedef signed __int64 orc_int64; +typedef unsigned __int8 orc_uint8; +typedef unsigned __int16 orc_uint16; +typedef unsigned __int32 orc_uint32; +typedef unsigned __int64 orc_uint64; +#define ORC_UINT64_C(x) (x##Ui64) +#define inline __inline +#else +#include <limits.h> +typedef signed char orc_int8; +typedef short orc_int16; +typedef int orc_int32; +typedef unsigned char orc_uint8; +typedef unsigned short orc_uint16; +typedef unsigned int orc_uint32; +#if INT_MAX == LONG_MAX +typedef long long orc_int64; +typedef unsigned long long orc_uint64; +#define ORC_UINT64_C(x) (x##ULL) +#else +typedef long orc_int64; +typedef unsigned long orc_uint64; +#define ORC_UINT64_C(x) (x##UL) +#endif +#endif +typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16; +typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32; +typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 x4[4]; } orc_union64; +#endif +#ifndef ORC_RESTRICT +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define ORC_RESTRICT restrict +#elif defined(__GNUC__) && __GNUC__ >= 4 +#define ORC_RESTRICT __restrict__ +#else +#define ORC_RESTRICT +#endif +#endif + +#ifndef ORC_INTERNAL +#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) +#define ORC_INTERNAL __attribute__((visibility("hidden"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) +#define ORC_INTERNAL __hidden +#elif defined (__GNUC__) +#define ORC_INTERNAL __attribute__((visibility("hidden"))) +#else +#define ORC_INTERNAL +#endif +#endif + +void video_mixer_orc_splat_u32 (guint32 * ORC_RESTRICT d1, int p1, int n); +void video_mixer_orc_memcpy_u32 (guint32 * ORC_RESTRICT d1, const guint32 * ORC_RESTRICT s1, int n); +void video_mixer_orc_blend_u8 (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m); +void video_mixer_orc_blend_argb (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m); +void video_mixer_orc_blend_bgra (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m); +void video_mixer_orc_overlay_argb (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m); +void video_mixer_orc_overlay_bgra (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m); +void videomixer_video_convert_orc_memcpy_2d (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_I420_UYVY (guint8 * ORC_RESTRICT d1, guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, const guint8 * ORC_RESTRICT s4, int n); +void videomixer_video_convert_orc_convert_I420_YUY2 (guint8 * ORC_RESTRICT d1, guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, const guint8 * ORC_RESTRICT s4, int n); +void videomixer_video_convert_orc_convert_I420_AYUV (guint8 * ORC_RESTRICT d1, guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, const guint8 * ORC_RESTRICT s4, int n); +void videomixer_video_convert_orc_convert_YUY2_I420 (guint8 * ORC_RESTRICT d1, guint8 * ORC_RESTRICT d2, guint8 * ORC_RESTRICT d3, guint8 * ORC_RESTRICT d4, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, int n); +void videomixer_video_convert_orc_convert_UYVY_YUY2 (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_420_422 (guint8 * ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_420_444 (guint8 * ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_422_444 (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_444_422 (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_444_420 (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m); +void videomixer_video_convert_orc_planar_chroma_422_420 (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m); +void videomixer_video_convert_orc_convert_YUY2_AYUV (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_UYVY_AYUV (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_YUY2_Y42B (guint8 * ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_UYVY_Y42B (guint8 * ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_YUY2_Y444 (guint8 * ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_UYVY_Y444 (guint8 * ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_UYVY_I420 (guint8 * ORC_RESTRICT d1, guint8 * ORC_RESTRICT d2, guint8 * ORC_RESTRICT d3, guint8 * ORC_RESTRICT d4, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, int n); +void videomixer_video_convert_orc_convert_AYUV_I420 (guint8 * ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, guint8 * ORC_RESTRICT d3, int d3_stride, guint8 * ORC_RESTRICT d4, int d4_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_YUY2 (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_UYVY (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_Y42B (guint8 * ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_Y444 (guint8 * ORC_RESTRICT d1, int d1_stride, guint8 * ORC_RESTRICT d2, int d2_stride, guint8 * ORC_RESTRICT d3, int d3_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y42B_YUY2 (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y42B_UYVY (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y42B_AYUV (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y444_YUY2 (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y444_UYVY (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_Y444_AYUV (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, const guint8 * ORC_RESTRICT s3, int s3_stride, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_ARGB (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int p2, int p3, int p4, int p5, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_BGRA (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int p2, int p3, int p4, int p5, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_ABGR (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int p2, int p3, int p4, int p5, int n, int m); +void videomixer_video_convert_orc_convert_AYUV_RGBA (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int p2, int p3, int p4, int p5, int n, int m); +void videomixer_video_convert_orc_convert_I420_BGRA (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, int p1, int p2, int p3, int p4, int p5, int n); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/gst/videomixer/videomixerorc.orc b/gst/videomixer/videomixerorc.orc new file mode 100755 index 0000000..45e0f56 --- /dev/null +++ b/gst/videomixer/videomixerorc.orc @@ -0,0 +1,952 @@ +.function video_mixer_orc_splat_u32 +.dest 4 d1 guint32 +.param 4 p1 guint32 + +copyl d1, p1 + +.function video_mixer_orc_memcpy_u32 +.dest 4 d1 guint32 +.source 4 s1 guint32 + +copyl d1, s1 + +.function video_mixer_orc_blend_u8 +.flags 2d +.dest 1 d1 guint8 +.source 1 s1 guint8 +.param 2 p1 +.temp 2 t1 +.temp 2 t2 +.const 1 c1 8 + +convubw t1, d1 +convubw t2, s1 +subw t2, t2, t1 +mullw t2, t2, p1 +shlw t1, t1, c1 +addw t2, t1, t2 +shruw t2, t2, c1 +convsuswb d1, t2 + + +.function video_mixer_orc_blend_argb +.flags 2d +.dest 4 d guint8 +.source 4 s guint8 +.param 2 alpha +.temp 4 t +.temp 2 tw +.temp 1 tb +.temp 4 a +.temp 8 d_wide +.temp 8 s_wide +.temp 8 a_wide +.const 4 a_alpha 0x000000ff + +loadl t, s +convlw tw, t +convwb tb, tw +splatbl a, tb +x4 convubw a_wide, a +x4 mullw a_wide, a_wide, alpha +x4 shruw a_wide, a_wide, 8 +x4 convubw s_wide, t +loadl t, d +x4 convubw d_wide, t +x4 subw s_wide, s_wide, d_wide +x4 mullw s_wide, s_wide, a_wide +x4 div255w s_wide, s_wide +x4 addw d_wide, d_wide, s_wide +x4 convwb t, d_wide +orl t, t, a_alpha +storel d, t + +.function video_mixer_orc_blend_bgra +.flags 2d +.dest 4 d guint8 +.source 4 s guint8 +.param 2 alpha +.temp 4 t +.temp 4 t2 +.temp 2 tw +.temp 1 tb +.temp 4 a +.temp 8 d_wide +.temp 8 s_wide +.temp 8 a_wide +.const 4 a_alpha 0xff000000 + +loadl t, s +shrul t2, t, 24 +convlw tw, t2 +convwb tb, tw +splatbl a, tb +x4 convubw a_wide, a +x4 mullw a_wide, a_wide, alpha +x4 shruw a_wide, a_wide, 8 +x4 convubw s_wide, t +loadl t, d +x4 convubw d_wide, t +x4 subw s_wide, s_wide, d_wide +x4 mullw s_wide, s_wide, a_wide +x4 div255w s_wide, s_wide +x4 addw d_wide, d_wide, s_wide +x4 convwb t, d_wide +orl t, t, a_alpha +storel d, t + + +.function video_mixer_orc_overlay_argb +.flags 2d +.dest 4 d guint8 +.source 4 s guint8 +.param 2 alpha +.temp 4 t +.temp 2 tw +.temp 1 tb +.temp 8 alpha_s +.temp 8 alpha_s_inv +.temp 8 alpha_d +.temp 4 a +.temp 8 d_wide +.temp 8 s_wide +.const 4 xfs 0xffffffff +.const 4 a_alpha 0x000000ff +.const 4 a_alpha_inv 0xffffff00 + +# calc source alpha as alpha_s = alpha_s * alpha / 256 +loadl t, s +convlw tw, t +convwb tb, tw +splatbl a, tb +x4 convubw alpha_s, a +x4 mullw alpha_s, alpha_s, alpha +x4 shruw alpha_s, alpha_s, 8 +x4 convubw s_wide, t +x4 mullw s_wide, s_wide, alpha_s + +# calc destination alpha as alpha_d = (255-alpha_s) * alpha_d / 255 +loadpl a, xfs +x4 convubw alpha_s_inv, a +x4 subw alpha_s_inv, alpha_s_inv, alpha_s +loadl t, d +convlw tw, t +convwb tb, tw +splatbl a, tb +x4 convubw alpha_d, a +x4 mullw alpha_d, alpha_d, alpha_s_inv +x4 div255w alpha_d, alpha_d +x4 convubw d_wide, t +x4 mullw d_wide, d_wide, alpha_d + +# calc final pixel as pix_d = pix_s*alpha_s + pix_d*alpha_d*(255-alpha_s)/255 +x4 addw d_wide, d_wide, s_wide + +# calc the final destination alpha_d = alpha_s + alpha_d * (255-alpha_s)/255 +x4 addw alpha_d, alpha_d, alpha_s + +# now normalize the pix_d by the final alpha to make it associative +x4 divluw, d_wide, d_wide, alpha_d + +# pack the new alpha into the correct spot +x4 convwb t, d_wide +andl t, t, a_alpha_inv +x4 convwb a, alpha_d +andl a, a, a_alpha +orl t, t, a +storel d, t + +.function video_mixer_orc_overlay_bgra +.flags 2d +.dest 4 d guint8 +.source 4 s guint8 +.param 2 alpha +.temp 4 t +.temp 4 t2 +.temp 2 tw +.temp 1 tb +.temp 8 alpha_s +.temp 8 alpha_s_inv +.temp 8 alpha_d +.temp 4 a +.temp 8 d_wide +.temp 8 s_wide +.const 4 xfs 0xffffffff +.const 4 a_alpha 0xff000000 +.const 4 a_alpha_inv 0x00ffffff + +# calc source alpha as alpha_s = alpha_s * alpha / 256 +loadl t, s +shrul t2, t, 24 +convlw tw, t2 +convwb tb, tw +splatbl a, tb +x4 convubw alpha_s, a +x4 mullw alpha_s, alpha_s, alpha +x4 shruw alpha_s, alpha_s, 8 +x4 convubw s_wide, t +x4 mullw s_wide, s_wide, alpha_s + +# calc destination alpha as alpha_d = (255-alpha_s) * alpha_d / 255 +loadpl a, xfs +x4 convubw alpha_s_inv, a +x4 subw alpha_s_inv, alpha_s_inv, alpha_s +loadl t, d +shrul t2, t, 24 +convlw tw, t2 +convwb tb, tw +splatbl a, tb +x4 convubw alpha_d, a +x4 mullw alpha_d, alpha_d, alpha_s_inv +x4 div255w alpha_d, alpha_d +x4 convubw d_wide, t +x4 mullw d_wide, d_wide, alpha_d + +# calc final pixel as pix_d = pix_s*alpha_s + pix_d*alpha_d*(255-alpha_s)/255 +x4 addw d_wide, d_wide, s_wide + +# calc the final destination alpha_d = alpha_s + alpha_d * (255-alpha_s)/255 +x4 addw alpha_d, alpha_d, alpha_s + +# now normalize the pix_d by the final alpha to make it associative +x4 divluw, d_wide, d_wide, alpha_d + +# pack the new alpha into the correct spot +x4 convwb t, d_wide +andl t, t, a_alpha_inv +x4 convwb a, alpha_d +andl a, a, a_alpha +orl t, t, a +storel d, t + +# Videoconvert logic, copy from videomixer_videoconvert. +# Remove that when videomixer_videoconvert lands in libgstvideo. + +.function videomixer_video_convert_orc_memcpy_2d +.flags 2d +.dest 1 d1 guint8 +.source 1 s1 guint8 + +copyb d1, s1 + +.function videomixer_video_convert_orc_convert_I420_UYVY +.dest 4 d1 guint8 +.dest 4 d2 guint8 +.source 2 y1 guint8 +.source 2 y2 guint8 +.source 1 u guint8 +.source 1 v guint8 +.temp 2 uv + +mergebw uv, u, v +x2 mergebw d1, uv, y1 +x2 mergebw d2, uv, y2 + + +.function videomixer_video_convert_orc_convert_I420_YUY2 +.dest 4 d1 guint8 +.dest 4 d2 guint8 +.source 2 y1 guint8 +.source 2 y2 guint8 +.source 1 u guint8 +.source 1 v guint8 +.temp 2 uv + +mergebw uv, u, v +x2 mergebw d1, y1, uv +x2 mergebw d2, y2, uv + + + +.function videomixer_video_convert_orc_convert_I420_AYUV +.dest 4 d1 guint8 +.dest 4 d2 guint8 +.source 1 y1 guint8 +.source 1 y2 guint8 +.source 1 u guint8 +.source 1 v guint8 +.const 1 c255 255 +.temp 2 uv +.temp 2 ay +.temp 1 tu +.temp 1 tv + +loadupdb tu, u +loadupdb tv, v +mergebw uv, tu, tv +mergebw ay, c255, y1 +mergewl d1, ay, uv +mergebw ay, c255, y2 +mergewl d2, ay, uv + + +.function videomixer_video_convert_orc_convert_YUY2_I420 +.dest 2 y1 guint8 +.dest 2 y2 guint8 +.dest 1 u guint8 +.dest 1 v guint8 +.source 4 yuv1 guint8 +.source 4 yuv2 guint8 +.temp 2 t1 +.temp 2 t2 +.temp 2 ty + +x2 splitwb t1, ty, yuv1 +storew y1, ty +x2 splitwb t2, ty, yuv2 +storew y2, ty +x2 avgub t1, t1, t2 +splitwb v, u, t1 + + +.function videomixer_video_convert_orc_convert_UYVY_YUY2 +.flags 2d +.dest 4 yuy2 guint8 +.source 4 uyvy guint8 + +x2 swapw yuy2, uyvy + + +.function videomixer_video_convert_orc_planar_chroma_420_422 +.flags 2d +.dest 1 d1 guint8 +.dest 1 d2 guint8 +.source 1 s guint8 + +copyb d1, s +copyb d2, s + + +.function videomixer_video_convert_orc_planar_chroma_420_444 +.flags 2d +.dest 2 d1 guint8 +.dest 2 d2 guint8 +.source 1 s guint8 +.temp 2 t + +splatbw t, s +storew d1, t +storew d2, t + + +.function videomixer_video_convert_orc_planar_chroma_422_444 +.flags 2d +.dest 2 d1 guint8 +.source 1 s guint8 +.temp 2 t + +splatbw t, s +storew d1, t + + +.function videomixer_video_convert_orc_planar_chroma_444_422 +.flags 2d +.dest 1 d guint8 +.source 2 s guint8 +.temp 1 t1 +.temp 1 t2 + +splitwb t1, t2, s +avgub d, t1, t2 + + +.function videomixer_video_convert_orc_planar_chroma_444_420 +.flags 2d +.dest 1 d guint8 +.source 2 s1 guint8 +.source 2 s2 guint8 +.temp 2 t +.temp 1 t1 +.temp 1 t2 + +x2 avgub t, s1, s2 +splitwb t1, t2, t +avgub d, t1, t2 + + +.function videomixer_video_convert_orc_planar_chroma_422_420 +.flags 2d +.dest 1 d guint8 +.source 1 s1 guint8 +.source 1 s2 guint8 + +avgub d, s1, s2 + + +.function videomixer_video_convert_orc_convert_YUY2_AYUV +.flags 2d +.dest 8 ayuv guint8 +.source 4 yuy2 guint8 +.const 2 c255 0xff +.temp 2 yy +.temp 2 uv +.temp 4 ayay +.temp 4 uvuv + +x2 splitwb uv, yy, yuy2 +x2 mergebw ayay, c255, yy +mergewl uvuv, uv, uv +x2 mergewl ayuv, ayay, uvuv + + +.function videomixer_video_convert_orc_convert_UYVY_AYUV +.flags 2d +.dest 8 ayuv guint8 +.source 4 uyvy guint8 +.const 2 c255 0xff +.temp 2 yy +.temp 2 uv +.temp 4 ayay +.temp 4 uvuv + +x2 splitwb yy, uv, uyvy +x2 mergebw ayay, c255, yy +mergewl uvuv, uv, uv +x2 mergewl ayuv, ayay, uvuv + + +.function videomixer_video_convert_orc_convert_YUY2_Y42B +.flags 2d +.dest 2 y guint8 +.dest 1 u guint8 +.dest 1 v guint8 +.source 4 yuy2 guint8 +.temp 2 uv + +x2 splitwb uv, y, yuy2 +splitwb v, u, uv + + +.function videomixer_video_convert_orc_convert_UYVY_Y42B +.flags 2d +.dest 2 y guint8 +.dest 1 u guint8 +.dest 1 v guint8 +.source 4 uyvy guint8 +.temp 2 uv + +x2 splitwb y, uv, uyvy +splitwb v, u, uv + + +.function videomixer_video_convert_orc_convert_YUY2_Y444 +.flags 2d +.dest 2 y guint8 +.dest 2 uu guint8 +.dest 2 vv guint8 +.source 4 yuy2 guint8 +.temp 2 uv +.temp 1 u +.temp 1 v + +x2 splitwb uv, y, yuy2 +splitwb v, u, uv +splatbw uu, u +splatbw vv, v + + +.function videomixer_video_convert_orc_convert_UYVY_Y444 +.flags 2d +.dest 2 y guint8 +.dest 2 uu guint8 +.dest 2 vv guint8 +.source 4 uyvy guint8 +.temp 2 uv +.temp 1 u +.temp 1 v + +x2 splitwb y, uv, uyvy +splitwb v, u, uv +splatbw uu, u +splatbw vv, v + + +.function videomixer_video_convert_orc_convert_UYVY_I420 +.dest 2 y1 guint8 +.dest 2 y2 guint8 +.dest 1 u guint8 +.dest 1 v guint8 +.source 4 yuv1 guint8 +.source 4 yuv2 guint8 +.temp 2 t1 +.temp 2 t2 +.temp 2 ty + +x2 splitwb ty, t1, yuv1 +storew y1, ty +x2 splitwb ty, t2, yuv2 +storew y2, ty +x2 avgub t1, t1, t2 +splitwb v, u, t1 + + + +.function videomixer_video_convert_orc_convert_AYUV_I420 +.flags 2d +.dest 2 y1 guint8 +.dest 2 y2 guint8 +.dest 1 u guint8 +.dest 1 v guint8 +.source 8 ayuv1 guint8 +.source 8 ayuv2 guint8 +.temp 4 ay +.temp 4 uv1 +.temp 4 uv2 +.temp 4 uv +.temp 2 uu +.temp 2 vv +.temp 1 t1 +.temp 1 t2 + +x2 splitlw uv1, ay, ayuv1 +x2 select1wb y1, ay +x2 splitlw uv2, ay, ayuv2 +x2 select1wb y2, ay +x4 avgub uv, uv1, uv2 +x2 splitwb vv, uu, uv +splitwb t1, t2, uu +avgub u, t1, t2 +splitwb t1, t2, vv +avgub v, t1, t2 + + + +.function videomixer_video_convert_orc_convert_AYUV_YUY2 +.flags 2d +.dest 4 yuy2 guint8 +.source 8 ayuv guint8 +.temp 2 yy +.temp 2 uv1 +.temp 2 uv2 +.temp 4 ayay +.temp 4 uvuv + +x2 splitlw uvuv, ayay, ayuv +splitlw uv1, uv2, uvuv +x2 avgub uv1, uv1, uv2 +x2 select1wb yy, ayay +x2 mergebw yuy2, yy, uv1 + + +.function videomixer_video_convert_orc_convert_AYUV_UYVY +.flags 2d +.dest 4 yuy2 guint8 +.source 8 ayuv guint8 +.temp 2 yy +.temp 2 uv1 +.temp 2 uv2 +.temp 4 ayay +.temp 4 uvuv + +x2 splitlw uvuv, ayay, ayuv +splitlw uv1, uv2, uvuv +x2 avgub uv1, uv1, uv2 +x2 select1wb yy, ayay +x2 mergebw yuy2, uv1, yy + + + +.function videomixer_video_convert_orc_convert_AYUV_Y42B +.flags 2d +.dest 2 y guint8 +.dest 1 u guint8 +.dest 1 v guint8 +.source 8 ayuv guint8 +.temp 4 ayay +.temp 4 uvuv +.temp 2 uv1 +.temp 2 uv2 + +x2 splitlw uvuv, ayay, ayuv +splitlw uv1, uv2, uvuv +x2 avgub uv1, uv1, uv2 +splitwb v, u, uv1 +x2 select1wb y, ayay + + +.function videomixer_video_convert_orc_convert_AYUV_Y444 +.flags 2d +.dest 1 y guint8 +.dest 1 u guint8 +.dest 1 v guint8 +.source 4 ayuv guint8 +.temp 2 ay +.temp 2 uv + +splitlw uv, ay, ayuv +splitwb v, u, uv +select1wb y, ay + + +.function videomixer_video_convert_orc_convert_Y42B_YUY2 +.flags 2d +.dest 4 yuy2 guint8 +.source 2 y guint8 +.source 1 u guint8 +.source 1 v guint8 +.temp 2 uv + +mergebw uv, u, v +x2 mergebw yuy2, y, uv + + +.function videomixer_video_convert_orc_convert_Y42B_UYVY +.flags 2d +.dest 4 uyvy guint8 +.source 2 y guint8 +.source 1 u guint8 +.source 1 v guint8 +.temp 2 uv + +mergebw uv, u, v +x2 mergebw uyvy, uv, y + + +.function videomixer_video_convert_orc_convert_Y42B_AYUV +.flags 2d +.dest 8 ayuv guint8 +.source 2 yy guint8 +.source 1 u guint8 +.source 1 v guint8 +.const 1 c255 255 +.temp 2 uv +.temp 2 ay +.temp 4 uvuv +.temp 4 ayay + +mergebw uv, u, v +x2 mergebw ayay, c255, yy +mergewl uvuv, uv, uv +x2 mergewl ayuv, ayay, uvuv + + +.function videomixer_video_convert_orc_convert_Y444_YUY2 +.flags 2d +.dest 4 yuy2 guint8 +.source 2 y guint8 +.source 2 u guint8 +.source 2 v guint8 +.temp 2 uv +.temp 4 uvuv +.temp 2 uv1 +.temp 2 uv2 + +x2 mergebw uvuv, u, v +splitlw uv1, uv2, uvuv +x2 avgub uv, uv1, uv2 +x2 mergebw yuy2, y, uv + + +.function videomixer_video_convert_orc_convert_Y444_UYVY +.flags 2d +.dest 4 uyvy guint8 +.source 2 y guint8 +.source 2 u guint8 +.source 2 v guint8 +.temp 2 uv +.temp 4 uvuv +.temp 2 uv1 +.temp 2 uv2 + +x2 mergebw uvuv, u, v +splitlw uv1, uv2, uvuv +x2 avgub uv, uv1, uv2 +x2 mergebw uyvy, uv, y + + +.function videomixer_video_convert_orc_convert_Y444_AYUV +.flags 2d +.dest 4 ayuv guint8 +.source 1 yy guint8 +.source 1 u guint8 +.source 1 v guint8 +.const 1 c255 255 +.temp 2 uv +.temp 2 ay + +mergebw uv, u, v +mergebw ay, c255, yy +mergewl ayuv, ay, uv + + + +.function videomixer_video_convert_orc_convert_AYUV_ARGB +.flags 2d +.dest 4 argb guint8 +.source 4 ayuv guint8 +.param 2 p1 +.param 2 p2 +.param 2 p3 +.param 2 p4 +.param 2 p5 +.temp 1 a +.temp 1 y +.temp 1 u +.temp 1 v +.temp 2 wy +.temp 2 wu +.temp 2 wv +.temp 2 wr +.temp 2 wg +.temp 2 wb +.temp 1 r +.temp 1 g +.temp 1 b +.temp 4 x +.const 1 c128 128 + +x4 subb x, ayuv, c128 +splitlw wv, wy, x +splitwb y, a, wy +splitwb v, u, wv + +splatbw wy, y +splatbw wu, u +splatbw wv, v + +mulhsw wy, wy, p1 + +mulhsw wr, wv, p2 +addssw wr, wy, wr + +mulhsw wb, wu, p3 +addssw wb, wy, wb + +mulhsw wg, wu, p4 +addssw wg, wy, wg +mulhsw wy, wv, p5 +addssw wg, wg, wy + +convssswb r, wr +convssswb g, wg +convssswb b, wb + +mergebw wr, a, r +mergebw wb, g, b +mergewl x, wr, wb +x4 addb argb, x, c128 + +.function videomixer_video_convert_orc_convert_AYUV_BGRA +.flags 2d +.dest 4 bgra guint8 +.source 4 ayuv guint8 +.param 2 p1 +.param 2 p2 +.param 2 p3 +.param 2 p4 +.param 2 p5 +.temp 1 a +.temp 1 y +.temp 1 u +.temp 1 v +.temp 2 wy +.temp 2 wu +.temp 2 wv +.temp 2 wr +.temp 2 wg +.temp 2 wb +.temp 1 r +.temp 1 g +.temp 1 b +.temp 4 x +.const 1 c128 128 + +x4 subb x, ayuv, c128 +splitlw wv, wy, x +splitwb y, a, wy +splitwb v, u, wv + +splatbw wy, y +splatbw wu, u +splatbw wv, v + +mulhsw wy, wy, p1 + +mulhsw wr, wv, p2 +addssw wr, wy, wr + +mulhsw wb, wu, p3 +addssw wb, wy, wb + +mulhsw wg, wu, p4 +addssw wg, wy, wg +mulhsw wy, wv, p5 +addssw wg, wg, wy + +convssswb r, wr +convssswb g, wg +convssswb b, wb + +mergebw wb, b, g +mergebw wr, r, a +mergewl x, wb, wr +x4 addb bgra, x, c128 + + +.function videomixer_video_convert_orc_convert_AYUV_ABGR +.flags 2d +.dest 4 argb guint8 +.source 4 ayuv guint8 +.param 2 p1 +.param 2 p2 +.param 2 p3 +.param 2 p4 +.param 2 p5 +.temp 1 a +.temp 1 y +.temp 1 u +.temp 1 v +.temp 2 wy +.temp 2 wu +.temp 2 wv +.temp 2 wr +.temp 2 wg +.temp 2 wb +.temp 1 r +.temp 1 g +.temp 1 b +.temp 4 x +.const 1 c128 128 + +x4 subb x, ayuv, c128 +splitlw wv, wy, x +splitwb y, a, wy +splitwb v, u, wv + +splatbw wy, y +splatbw wu, u +splatbw wv, v + +mulhsw wy, wy, p1 + +mulhsw wr, wv, p2 +addssw wr, wy, wr + +mulhsw wb, wu, p3 +addssw wb, wy, wb + +mulhsw wg, wu, p4 +addssw wg, wy, wg +mulhsw wy, wv, p5 +addssw wg, wg, wy + +convssswb r, wr +convssswb g, wg +convssswb b, wb + +mergebw wb, a, b +mergebw wr, g, r +mergewl x, wb, wr +x4 addb argb, x, c128 + +.function videomixer_video_convert_orc_convert_AYUV_RGBA +.flags 2d +.dest 4 argb guint8 +.source 4 ayuv guint8 +.param 2 p1 +.param 2 p2 +.param 2 p3 +.param 2 p4 +.param 2 p5 +.temp 1 a +.temp 1 y +.temp 1 u +.temp 1 v +.temp 2 wy +.temp 2 wu +.temp 2 wv +.temp 2 wr +.temp 2 wg +.temp 2 wb +.temp 1 r +.temp 1 g +.temp 1 b +.temp 4 x +.const 1 c128 128 + +x4 subb x, ayuv, c128 +splitlw wv, wy, x +splitwb y, a, wy +splitwb v, u, wv + +splatbw wy, y +splatbw wu, u +splatbw wv, v + +mulhsw wy, wy, p1 + +mulhsw wr, wv, p2 +addssw wr, wy, wr + +mulhsw wb, wu, p3 +addssw wb, wy, wb + +mulhsw wg, wu, p4 +addssw wg, wy, wg +mulhsw wy, wv, p5 +addssw wg, wg, wy + +convssswb r, wr +convssswb g, wg +convssswb b, wb + +mergebw wr, r, g +mergebw wb, b, a +mergewl x, wr, wb +x4 addb argb, x, c128 + + + +.function videomixer_video_convert_orc_convert_I420_BGRA +.dest 4 argb guint8 +.source 1 y guint8 +.source 1 u guint8 +.source 1 v guint8 +.param 2 p1 +.param 2 p2 +.param 2 p3 +.param 2 p4 +.param 2 p5 +.temp 2 wy +.temp 2 wu +.temp 2 wv +.temp 2 wr +.temp 2 wg +.temp 2 wb +.temp 1 r +.temp 1 g +.temp 1 b +.temp 4 x +.const 1 c128 128 + +subb r, y, c128 +splatbw wy, r +loadupdb r, u +subb r, r, c128 +splatbw wu, r +loadupdb r, v +subb r, r, c128 +splatbw wv, r + +mulhsw wy, wy, p1 + +mulhsw wr, wv, p2 +addssw wr, wy, wr + +mulhsw wb, wu, p3 +addssw wb, wy, wb + +mulhsw wg, wu, p4 +addssw wg, wy, wg +mulhsw wy, wv, p5 +addssw wg, wg, wy + +convssswb r, wr +convssswb g, wg +convssswb b, wb + +mergebw wb, b, g +mergebw wr, r, 127 +mergewl x, wb, wr +x4 addb argb, x, c128 + |