summaryrefslogtreecommitdiff
path: root/test/pdiff
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-16 15:59:03 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-16 15:59:03 -0800
commita38f0dced529c3f584fd69c10373893842f4d1d5 (patch)
treefbb5f30fb92852766094c7b1711f33d96a342026 /test/pdiff
downloadcairo-a38f0dced529c3f584fd69c10373893842f4d1d5.tar.gz
cairo-a38f0dced529c3f584fd69c10373893842f4d1d5.tar.bz2
cairo-a38f0dced529c3f584fd69c10373893842f4d1d5.zip
Imported Upstream version 1.12.4upstream/1.12.4
Diffstat (limited to 'test/pdiff')
-rw-r--r--test/pdiff/Makefile.am19
-rw-r--r--test/pdiff/Makefile.in778
-rw-r--r--test/pdiff/args.c119
-rw-r--r--test/pdiff/args.h46
-rw-r--r--test/pdiff/gpl.txt340
-rw-r--r--test/pdiff/lpyramid.c116
-rw-r--r--test/pdiff/lpyramid.h32
-rw-r--r--test/pdiff/pdiff.c420
-rw-r--r--test/pdiff/pdiff.h40
-rw-r--r--test/pdiff/perceptualdiff.c101
10 files changed, 2011 insertions, 0 deletions
diff --git a/test/pdiff/Makefile.am b/test/pdiff/Makefile.am
new file mode 100644
index 0000000..73098da
--- /dev/null
+++ b/test/pdiff/Makefile.am
@@ -0,0 +1,19 @@
+include $(top_srcdir)/build/Makefile.am.common
+
+EXTRA_PROGRAMS += perceptualdiff
+EXTRA_DIST += gpl.txt
+
+noinst_LTLIBRARIES = libpdiff.la
+libpdiff_la_SOURCES = \
+ pdiff.h \
+ lpyramid.c \
+ lpyramid.h \
+ pdiff.c
+
+perceptualdiff_SOURCES = \
+ args.c \
+ args.h \
+ perceptualdiff.c
+
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src $(CAIRO_CFLAGS)
+LDADD = libpdiff.la $(top_builddir)/src/libcairo.la
diff --git a/test/pdiff/Makefile.in b/test/pdiff/Makefile.in
new file mode 100644
index 0000000..0e41f74
--- /dev/null
+++ b/test/pdiff/Makefile.in
@@ -0,0 +1,778 @@
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__make_dryrun = \
+ { \
+ am__dry=no; \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
+ esac; \
+ test $$am__dry = yes; \
+ }
+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@
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+ $(top_srcdir)/build/Makefile.am.common
+EXTRA_PROGRAMS = perceptualdiff$(EXEEXT)
+TESTS =
+check_PROGRAMS =
+subdir = test/pdiff
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/build/aclocal.cairo.m4 \
+ $(top_srcdir)/build/aclocal.compare.m4 \
+ $(top_srcdir)/build/aclocal.enable.m4 \
+ $(top_srcdir)/build/aclocal.float.m4 \
+ $(top_srcdir)/build/aclocal.makefile.m4 \
+ $(top_srcdir)/build/aclocal.pkg.m4 \
+ $(top_srcdir)/build/gtk-doc.m4 $(top_srcdir)/build/libtool.m4 \
+ $(top_srcdir)/build/ltoptions.m4 \
+ $(top_srcdir)/build/ltsugar.m4 \
+ $(top_srcdir)/build/ltversion.m4 \
+ $(top_srcdir)/build/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/cairo-version.h \
+ $(top_srcdir)/build/configure.ac.version \
+ $(top_srcdir)/build/configure.ac.tools \
+ $(top_srcdir)/build/configure.ac.features \
+ $(top_srcdir)/build/configure.ac.warnings \
+ $(top_srcdir)/build/configure.ac.system \
+ $(top_srcdir)/build/configure.ac.analysis \
+ $(top_srcdir)/build/configure.ac.noversion \
+ $(top_srcdir)/build/configure.ac.pthread \
+ $(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 =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libpdiff_la_LIBADD =
+am_libpdiff_la_OBJECTS = lpyramid.lo pdiff.lo
+libpdiff_la_OBJECTS = $(am_libpdiff_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_perceptualdiff_OBJECTS = args.$(OBJEXT) perceptualdiff.$(OBJEXT)
+perceptualdiff_OBJECTS = $(am_perceptualdiff_OBJECTS)
+perceptualdiff_LDADD = $(LDADD)
+perceptualdiff_DEPENDENCIES = libpdiff.la \
+ $(top_builddir)/src/libcairo.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build/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_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+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_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libpdiff_la_SOURCES) $(perceptualdiff_SOURCES)
+DIST_SOURCES = $(libpdiff_la_SOURCES) $(perceptualdiff_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BFD_LIBS = @BFD_LIBS@
+CAIROBOILERPLATE_LIBS = @CAIROBOILERPLATE_LIBS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LDFLAGS = @CAIRO_LDFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CAIRO_LIBTOOL_VERSION_INFO = @CAIRO_LIBTOOL_VERSION_INFO@
+CAIRO_NONPKGCONFIG_CFLAGS = @CAIRO_NONPKGCONFIG_CFLAGS@
+CAIRO_NONPKGCONFIG_LIBS = @CAIRO_NONPKGCONFIG_LIBS@
+CAIRO_RELEASE_STATUS = @CAIRO_RELEASE_STATUS@
+CAIRO_REQUIRES = @CAIRO_REQUIRES@
+CAIRO_TEST_MODE = @CAIRO_TEST_MODE@
+CAIRO_TEST_UNDEFINED_LDFLAGS = @CAIRO_TEST_UNDEFINED_LDFLAGS@
+CAIRO_VERSION_MAJOR = @CAIRO_VERSION_MAJOR@
+CAIRO_VERSION_MICRO = @CAIRO_VERSION_MICRO@
+CAIRO_VERSION_MINOR = @CAIRO_VERSION_MINOR@
+CAIRO_VERSION_SONUM = @CAIRO_VERSION_SONUM@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FIND = @FIND@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GOBJECT_CFLAGS = @GOBJECT_CFLAGS@
+GOBJECT_LIBS = @GOBJECT_LIBS@
+GREP = @GREP@
+GS = @GS@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
+GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
+GTKDOC_MKPDF = @GTKDOC_MKPDF@
+GTKDOC_REBASE = @GTKDOC_REBASE@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBSPECTRE_CFLAGS = @LIBSPECTRE_CFLAGS@
+LIBSPECTRE_LIBS = @LIBSPECTRE_LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LTP = @LTP@
+LTP_GENHTML = @LTP_GENHTML@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+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@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+POPPLER_CFLAGS = @POPPLER_CFLAGS@
+POPPLER_LIBS = @POPPLER_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SHM_LIBS = @SHM_LIBS@
+SHTOOL = @SHTOOL@
+STRIP = @STRIP@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VERSION = @VERSION@
+XARGS = @XARGS@
+XMKMF = @XMKMF@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_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@
+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@
+cogl_CFLAGS = @cogl_CFLAGS@
+cogl_LIBS = @cogl_LIBS@
+datadir = @datadir@
+datarootdir = @datarootdir@
+directfb_CFLAGS = @directfb_CFLAGS@
+directfb_LIBS = @directfb_LIBS@
+docdir = @docdir@
+drm_CFLAGS = @drm_CFLAGS@
+drm_LIBS = @drm_LIBS@
+dvidir = @dvidir@
+egl_CFLAGS = @egl_CFLAGS@
+egl_LIBS = @egl_LIBS@
+exec_prefix = @exec_prefix@
+gallium_DIR = @gallium_DIR@
+gl_CFLAGS = @gl_CFLAGS@
+gl_LIBS = @gl_LIBS@
+glesv2_CFLAGS = @glesv2_CFLAGS@
+glesv2_LIBS = @glesv2_LIBS@
+glib_CFLAGS = @glib_CFLAGS@
+glib_LIBS = @glib_LIBS@
+gtk_CFLAGS = @gtk_CFLAGS@
+gtk_LIBS = @gtk_LIBS@
+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@
+mesa_DIR = @mesa_DIR@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pixman_CFLAGS = @pixman_CFLAGS@
+pixman_LIBS = @pixman_LIBS@
+png_CFLAGS = @png_CFLAGS@
+png_LIBS = @png_LIBS@
+png_REQUIRES = @png_REQUIRES@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pthread_CFLAGS = @pthread_CFLAGS@
+pthread_LIBS = @pthread_LIBS@
+qt_CFLAGS = @qt_CFLAGS@
+qt_LIBS = @qt_LIBS@
+real_pthread_CFLAGS = @real_pthread_CFLAGS@
+real_pthread_LIBS = @real_pthread_LIBS@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+shm_LIBS = @shm_LIBS@
+skia_DIR = @skia_DIR@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xcb_CFLAGS = @xcb_CFLAGS@
+xcb_LIBS = @xcb_LIBS@
+xcb_shm_CFLAGS = @xcb_shm_CFLAGS@
+xcb_shm_LIBS = @xcb_shm_LIBS@
+xlib_CFLAGS = @xlib_CFLAGS@
+xlib_LIBS = @xlib_LIBS@
+xlib_xcb_CFLAGS = @xlib_xcb_CFLAGS@
+xlib_xcb_LIBS = @xlib_xcb_LIBS@
+xlib_xrender_CFLAGS = @xlib_xrender_CFLAGS@
+xlib_xrender_LIBS = @xlib_xrender_LIBS@
+BUILT_SOURCES =
+CLEANFILES = *.i *.s *.gch $(EXTRA_LTLIBRARIES) $(EXTRA_PROGRAMS) \
+ $(check_PROGRAMS)
+DISTCLEANFILES = $(BUILT_SOURCES)
+EXTRA_DIST = gpl.txt
+EXTRA_LTLIBRARIES =
+MAINTAINERCLEANFILES = Makefile.in
+noinst_LTLIBRARIES = libpdiff.la
+libpdiff_la_SOURCES = \
+ pdiff.h \
+ lpyramid.c \
+ lpyramid.h \
+ pdiff.c
+
+perceptualdiff_SOURCES = \
+ args.c \
+ args.h \
+ perceptualdiff.c
+
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src $(CAIRO_CFLAGS)
+LDADD = libpdiff.la $(top_builddir)/src/libcairo.la
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/build/Makefile.am.common $(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) --foreign test/pdiff/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign test/pdiff/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)/build/Makefile.am.common:
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libpdiff.la: $(libpdiff_la_OBJECTS) $(libpdiff_la_DEPENDENCIES) $(EXTRA_libpdiff_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(LINK) $(libpdiff_la_OBJECTS) $(libpdiff_la_LIBADD) $(LIBS)
+
+clean-checkPROGRAMS:
+ @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+perceptualdiff$(EXEEXT): $(perceptualdiff_OBJECTS) $(perceptualdiff_DEPENDENCIES) $(EXTRA_perceptualdiff_DEPENDENCIES)
+ @rm -f perceptualdiff$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(perceptualdiff_OBJECTS) $(perceptualdiff_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/args.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lpyramid.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdiff.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perceptualdiff.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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 $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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 `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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 $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ 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
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ col="$$grn"; \
+ else \
+ col="$$red"; \
+ fi; \
+ echo "$${col}$$dashes$${std}"; \
+ echo "$${col}$$banner$${std}"; \
+ test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
+ test -z "$$report" || echo "$${col}$$report$${std}"; \
+ echo "$${col}$$dashes$${std}"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+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
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+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:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+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)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+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)
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+ clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+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:
+
+.MAKE: all check check-am install install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-checkPROGRAMS clean-generic clean-libtool \
+ clean-noinstLTLIBRARIES ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+
+# 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/test/pdiff/args.c b/test/pdiff/args.c
new file mode 100644
index 0000000..ac3aa83
--- /dev/null
+++ b/test/pdiff/args.c
@@ -0,0 +1,119 @@
+/*
+ Comapre Args
+ Copyright (C) 2006 Yangli Hector Yee
+
+ This program is free software; you can redistribute it and/or modify it under the terms of the
+ GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with this program;
+ if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+*/
+
+#include "args.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static const char* copyright =
+"PerceptualDiff version 1.0, Copyright (C) 2006 Yangli Hector Yee\n\
+PerceptualDiff comes with ABSOLUTELY NO WARRANTY;\n\
+This is free software, and you are welcome\n\
+to redistribute it under certain conditions;\n\
+See the GPL page for details: http://www.gnu.org/copyleft/gpl.html\n\n";
+
+static const char *usage =
+"PeceptualDiff image1.tif image2.tif\n\n\
+ Compares image1.tif and image2.tif using a perceptually based image metric\n\
+ Options:\n\
+\t-verbose : Turns on verbose mode\n\
+\t-fov deg : Field of view in degrees (0.1 to 89.9)\n\
+\t-threshold p : #pixels p below which differences are ignored\n\
+\t-gamma g : Value to convert rgb into linear space (default 2.2)\n\
+\t-luminance l : White luminance (default 100.0 cdm^-2)\n\
+\n\
+\n Note: Input files can also be in the PNG format\
+\n";
+
+void
+args_init (args_t *args)
+{
+ args->surface_a = NULL;
+ args->surface_b = NULL;
+ args->Verbose = false;
+ args->FieldOfView = 45.0f;
+ args->Gamma = 2.2f;
+ args->ThresholdPixels = 100;
+ args->Luminance = 100.0f;
+}
+
+void
+args_fini (args_t *args)
+{
+ cairo_surface_destroy (args->surface_a);
+ cairo_surface_destroy (args->surface_b);
+}
+
+bool
+args_parse (args_t *args, int argc, char **argv)
+{
+ int i;
+ if (argc < 3) {
+ fprintf (stderr, "%s", copyright);
+ fprintf (stderr, "%s", usage);
+ return false;
+ }
+ for (i = 0; i < argc; i++) {
+ if (i == 1) {
+ args->surface_a = cairo_image_surface_create_from_png (argv[1]);
+ if (cairo_surface_status (args->surface_a))
+ {
+ fprintf (stderr, "FAIL: Cannot open %s: %s\n",
+ argv[1], cairo_status_to_string (cairo_surface_status (args->surface_a)));
+ return false;
+ }
+ } else if (i == 2) {
+ args->surface_b = cairo_image_surface_create_from_png (argv[2]);
+ if (cairo_surface_status (args->surface_b))
+ {
+ fprintf (stderr, "FAIL: Cannot open %s: %s\n",
+ argv[2], cairo_status_to_string (cairo_surface_status (args->surface_b)));
+ return false;
+ }
+ } else {
+ if (strstr(argv[i], "-fov")) {
+ if (i + 1 < argc) {
+ args->FieldOfView = (float) atof(argv[i + 1]);
+ }
+ } else if (strstr(argv[i], "-verbose")) {
+ args->Verbose = true;
+ } else if (strstr(argv[i], "-threshold")) {
+ if (i + 1 < argc) {
+ args->ThresholdPixels = atoi(argv[i + 1]);
+ }
+ } else if (strstr(argv[i], "-gamma")) {
+ if (i + 1 < argc) {
+ args->Gamma = (float) atof(argv[i + 1]);
+ }
+ }else if (strstr(argv[i], "-luminance")) {
+ if (i + 1 < argc) {
+ args->Luminance = (float) atof(argv[i + 1]);
+ }
+ }
+ }
+ } /* i */
+ return true;
+}
+
+void
+args_print (args_t *args)
+{
+ printf("Field of view is %f degrees\n", args->FieldOfView);
+ printf("Threshold pixels is %d pixels\n", args->ThresholdPixels);
+ printf("The Gamma is %f\n", args->Gamma);
+ printf("The Display's luminance is %f candela per meter squared\n", args->Luminance);
+}
diff --git a/test/pdiff/args.h b/test/pdiff/args.h
new file mode 100644
index 0000000..5020239
--- /dev/null
+++ b/test/pdiff/args.h
@@ -0,0 +1,46 @@
+/*
+ Comapre Args
+ Copyright (C) 2006 Yangli Hector Yee
+
+ This program is free software; you can redistribute it and/or modify it under the terms of the
+ GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with this program;
+ if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+*/
+
+#ifndef _ARGS_H
+#define _ARGS_H
+
+#include "pdiff.h"
+
+/* Args to pass into the comparison function */
+typedef struct _args
+{
+ cairo_surface_t *surface_a; /* Image A */
+ cairo_surface_t *surface_b; /* Image B */
+ bool Verbose; /* Print lots of text or not */
+ float FieldOfView; /* Field of view in degrees */
+ float Gamma; /* The gamma to convert to linear color space */
+ float Luminance; /* the display's luminance */
+ unsigned int ThresholdPixels; /* How many pixels different to ignore */
+} args_t;
+
+void
+args_init (args_t *args);
+
+void
+args_fini (args_t *args);
+
+bool
+args_parse (args_t *args, int argc, char **argv);
+
+void
+args_print (args_t *args);
+
+#endif
diff --git a/test/pdiff/gpl.txt b/test/pdiff/gpl.txt
new file mode 100644
index 0000000..f90922e
--- /dev/null
+++ b/test/pdiff/gpl.txt
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/test/pdiff/lpyramid.c b/test/pdiff/lpyramid.c
new file mode 100644
index 0000000..aa57ca2
--- /dev/null
+++ b/test/pdiff/lpyramid.c
@@ -0,0 +1,116 @@
+/*
+ Laplacian Pyramid
+ Copyright (C) 2006 Yangli Hector Yee
+
+ This program is free software; you can redistribute it and/or modify it under the terms of the
+ GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with this program;
+ if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+*/
+
+#include "lpyramid.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+struct _lpyramid {
+ /* Successively blurred versions of the original image */
+ float *levels[MAX_PYR_LEVELS];
+
+ int width;
+ int height;
+};
+
+static void
+convolve (lpyramid_t *pyramid, float *a, const float *b)
+/* convolves image b with the filter kernel and stores it in a */
+{
+ int y,x,i,j;
+ const float Kernel[] = {0.05f, 0.25f, 0.4f, 0.25f, 0.05f};
+ int width = pyramid->width;
+ int height = pyramid->height;
+
+ for (y=0; y<height; y++) {
+ for (x=0; x<width; x++) {
+ float sum = 0.f;
+ for (j=-2; j<=2; j++) {
+ float sum_i = 0.f;
+ int ny=y+j;
+ if (ny<0) ny=-ny;
+ if (ny>=height) ny=2*height - ny - 1;
+ ny *= width;
+ for (i=-2; i<=2; i++) {
+ int nx=x+i;
+ if (nx<0) nx=-nx;
+ if (nx>=width) nx=2*width - nx - 1;
+ sum_i += Kernel[i+2] * b[ny + nx];
+ }
+ sum += sum_i * Kernel[j+2];
+ }
+ *a++ = sum;
+ }
+ }
+}
+
+/*
+ * Construction/Destruction
+ */
+
+lpyramid_t *
+lpyramid_create (float *image, int width, int height)
+{
+ lpyramid_t *pyramid;
+ int i;
+
+ pyramid = malloc (sizeof (lpyramid_t));
+ if (pyramid == NULL) {
+ fprintf (stderr, "Out of memory.\n");
+ exit (1);
+ }
+ pyramid->width = width;
+ pyramid->height = height;
+
+ /* Make the Laplacian pyramid by successively
+ * copying the earlier levels and blurring them */
+ for (i=0; i<MAX_PYR_LEVELS; i++) {
+ pyramid->levels[i] = malloc (width * height * sizeof (float));
+ if (pyramid->levels[i] == NULL) {
+ fprintf (stderr, "Out of memory.\n");
+ exit (1);
+ }
+ if (i == 0) {
+ memcpy (pyramid->levels[i], image, width * height * sizeof (float));
+ } else {
+ convolve(pyramid, pyramid->levels[i], pyramid->levels[i - 1]);
+ }
+ }
+
+ return pyramid;
+}
+
+void
+lpyramid_destroy (lpyramid_t *pyramid)
+{
+ int i;
+
+ for (i=0; i<MAX_PYR_LEVELS; i++)
+ free (pyramid->levels[i]);
+
+ free (pyramid);
+}
+
+float
+lpyramid_get_value (lpyramid_t *pyramid, int x, int y, int level)
+{
+ int index = x + y * pyramid->width;
+ int l = level;
+ if (l > MAX_PYR_LEVELS)
+ l = MAX_PYR_LEVELS;
+ return pyramid->levels[level][index];
+}
diff --git a/test/pdiff/lpyramid.h b/test/pdiff/lpyramid.h
new file mode 100644
index 0000000..e47a66e
--- /dev/null
+++ b/test/pdiff/lpyramid.h
@@ -0,0 +1,32 @@
+/*
+ Laplacian Pyramid
+ Copyright (C) 2006 Yangli Hector Yee
+
+ This program is free software; you can redistribute it and/or modify it under the terms of the
+ GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with this program;
+ if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+*/
+#ifndef _LPYRAMID_H
+#define _LPYRAMID_H
+
+#define MAX_PYR_LEVELS 8
+
+typedef struct _lpyramid lpyramid_t;
+
+lpyramid_t *
+lpyramid_create (float *image, int width, int height);
+
+void
+lpyramid_destroy (lpyramid_t *pyramid);
+
+float
+lpyramid_get_value (lpyramid_t *pyramid, int x, int y, int level);
+
+#endif /* _LPYRAMID_H */
diff --git a/test/pdiff/pdiff.c b/test/pdiff/pdiff.c
new file mode 100644
index 0000000..eb5f156
--- /dev/null
+++ b/test/pdiff/pdiff.c
@@ -0,0 +1,420 @@
+/*
+ Metric
+ Copyright (C) 2006 Yangli Hector Yee
+
+ This program is free software; you can redistribute it and/or modify it under the terms of the
+ GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with this program;
+ if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+*/
+
+#define _GNU_SOURCE
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "lpyramid.h"
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#if HAVE_STDINT_H
+# include <stdint.h>
+#elif HAVE_INTTYPES_H
+# include <inttypes.h>
+#elif HAVE_SYS_INT_TYPES_H
+# include <sys/int_types.h>
+#elif defined(_MSC_VER)
+ typedef __int8 int8_t;
+ typedef unsigned __int8 uint8_t;
+ typedef __int16 int16_t;
+ typedef unsigned __int16 uint16_t;
+ typedef __int32 int32_t;
+ typedef unsigned __int32 uint32_t;
+ typedef __int64 int64_t;
+ typedef unsigned __int64 uint64_t;
+# ifndef HAVE_UINT64_T
+# define HAVE_UINT64_T 1
+# endif
+# ifndef INT16_MIN
+# define INT16_MIN (-32767-1)
+# endif
+# ifndef INT16_MAX
+# define INT16_MAX (32767)
+# endif
+# ifndef UINT16_MAX
+# define UINT16_MAX (65535)
+# endif
+#else
+#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.)
+#endif
+
+#include "pdiff.h"
+
+#ifndef M_PI
+#define M_PI 3.14159265f
+#endif
+
+#ifndef __USE_ISOC99
+#define expf exp
+#define powf pow
+#define fabsf fabs
+#define sqrtf sqrt
+#define log10f log10
+#endif
+
+/*
+ * Given the adaptation luminance, this function returns the
+ * threshold of visibility in cd per m^2
+ * TVI means Threshold vs Intensity function
+ * This version comes from Ward Larson Siggraph 1997
+ */
+static float
+tvi (float adaptation_luminance)
+{
+ /* returns the threshold luminance given the adaptation luminance
+ units are candelas per meter squared
+ */
+ float log_a, r, result;
+ log_a = log10f(adaptation_luminance);
+
+ if (log_a < -3.94f) {
+ r = -2.86f;
+ } else if (log_a < -1.44f) {
+ r = powf(0.405f * log_a + 1.6f , 2.18f) - 2.86f;
+ } else if (log_a < -0.0184f) {
+ r = log_a - 0.395f;
+ } else if (log_a < 1.9f) {
+ r = powf(0.249f * log_a + 0.65f, 2.7f) - 0.72f;
+ } else {
+ r = log_a - 1.255f;
+ }
+
+ result = powf(10.0f , r);
+
+ return result;
+}
+
+/* computes the contrast sensitivity function (Barten SPIE 1989)
+ * given the cycles per degree (cpd) and luminance (lum)
+ */
+static float
+csf (float cpd, float lum)
+{
+ float a, b, result;
+
+ a = 440.0f * powf((1.0f + 0.7f / lum), -0.2f);
+ b = 0.3f * powf((1.0f + 100.0f / lum), 0.15f);
+
+ result = a * cpd * expf(-b * cpd) * sqrtf(1.0f + 0.06f * expf(b * cpd));
+
+ return result;
+}
+
+/*
+ * Visual Masking Function
+ * from Daly 1993
+ */
+static float
+mask (float contrast)
+{
+ float a, b, result;
+ a = powf(392.498f * contrast, 0.7f);
+ b = powf(0.0153f * a, 4.0f);
+ result = powf(1.0f + b, 0.25f);
+
+ return result;
+}
+
+/* convert Adobe RGB (1998) with reference white D65 to XYZ */
+static void
+AdobeRGBToXYZ (float r, float g, float b, float *x, float *y, float *z)
+{
+ /* matrix is from http://www.brucelindbloom.com/ */
+ *x = r * 0.576700f + g * 0.185556f + b * 0.188212f;
+ *y = r * 0.297361f + g * 0.627355f + b * 0.0752847f;
+ *z = r * 0.0270328f + g * 0.0706879f + b * 0.991248f;
+}
+
+static void
+XYZToLAB (float x, float y, float z, float *L, float *A, float *B)
+{
+ static float xw = -1;
+ static float yw;
+ static float zw;
+ const float epsilon = 216.0f / 24389.0f;
+ const float kappa = 24389.0f / 27.0f;
+ float f[3];
+ float r[3];
+ int i;
+
+ /* reference white */
+ if (xw < 0) {
+ AdobeRGBToXYZ(1, 1, 1, &xw, &yw, &zw);
+ }
+ r[0] = x / xw;
+ r[1] = y / yw;
+ r[2] = z / zw;
+ for (i = 0; i < 3; i++) {
+ if (r[i] > epsilon) {
+ f[i] = powf(r[i], 1.0f / 3.0f);
+ } else {
+ f[i] = (kappa * r[i] + 16.0f) / 116.0f;
+ }
+ }
+ *L = 116.0f * f[1] - 16.0f;
+ *A = 500.0f * (f[0] - f[1]);
+ *B = 200.0f * (f[1] - f[2]);
+}
+
+static uint32_t
+_get_pixel (const uint32_t *data, int i)
+{
+ return data[i];
+}
+
+static unsigned char
+_get_red (const uint32_t *data, int i)
+{
+ uint32_t pixel;
+ uint8_t alpha;
+
+ pixel = _get_pixel (data, i);
+ alpha = (pixel & 0xff000000) >> 24;
+ if (alpha == 0)
+ return 0;
+ else
+ return (((pixel & 0x00ff0000) >> 16) * 255 + alpha / 2) / alpha;
+}
+
+static unsigned char
+_get_green (const uint32_t *data, int i)
+{
+ uint32_t pixel;
+ uint8_t alpha;
+
+ pixel = _get_pixel (data, i);
+ alpha = (pixel & 0xff000000) >> 24;
+ if (alpha == 0)
+ return 0;
+ else
+ return (((pixel & 0x0000ff00) >> 8) * 255 + alpha / 2) / alpha;
+}
+
+static unsigned char
+_get_blue (const uint32_t *data, int i)
+{
+ uint32_t pixel;
+ uint8_t alpha;
+
+ pixel = _get_pixel (data, i);
+ alpha = (pixel & 0xff000000) >> 24;
+ if (alpha == 0)
+ return 0;
+ else
+ return (((pixel & 0x000000ff) >> 0) * 255 + alpha / 2) / alpha;
+}
+
+static void *
+xmalloc (size_t size)
+{
+ void *buf;
+
+ buf = malloc (size);
+ if (buf == NULL) {
+ fprintf (stderr, "Out of memory.\n");
+ exit (1);
+ }
+
+ return buf;
+}
+
+int
+pdiff_compare (cairo_surface_t *surface_a,
+ cairo_surface_t *surface_b,
+ double gamma,
+ double luminance,
+ double field_of_view)
+{
+ unsigned int dim = (cairo_image_surface_get_width (surface_a)
+ * cairo_image_surface_get_height (surface_a));
+ unsigned int i;
+
+ /* assuming colorspaces are in Adobe RGB (1998) convert to XYZ */
+ float *aX;
+ float *aY;
+ float *aZ;
+ float *bX;
+ float *bY;
+ float *bZ;
+ float *aLum;
+ float *bLum;
+
+ float *aA;
+ float *bA;
+ float *aB;
+ float *bB;
+
+ unsigned int x, y, w, h;
+
+ lpyramid_t *la, *lb;
+
+ float num_one_degree_pixels, pixels_per_degree, num_pixels;
+ unsigned int adaptation_level;
+
+ float cpd[MAX_PYR_LEVELS];
+ float F_freq[MAX_PYR_LEVELS - 2];
+ float csf_max;
+ const uint32_t *data_a, *data_b;
+
+ unsigned int pixels_failed;
+
+ w = cairo_image_surface_get_width (surface_a);
+ h = cairo_image_surface_get_height (surface_a);
+ if (w < 3 || h < 3) /* too small for the Laplacian convolution */
+ return -1;
+
+ aX = xmalloc (dim * sizeof (float));
+ aY = xmalloc (dim * sizeof (float));
+ aZ = xmalloc (dim * sizeof (float));
+ bX = xmalloc (dim * sizeof (float));
+ bY = xmalloc (dim * sizeof (float));
+ bZ = xmalloc (dim * sizeof (float));
+ aLum = xmalloc (dim * sizeof (float));
+ bLum = xmalloc (dim * sizeof (float));
+
+ aA = xmalloc (dim * sizeof (float));
+ bA = xmalloc (dim * sizeof (float));
+ aB = xmalloc (dim * sizeof (float));
+ bB = xmalloc (dim * sizeof (float));
+
+ data_a = (uint32_t *) cairo_image_surface_get_data (surface_a);
+ data_b = (uint32_t *) cairo_image_surface_get_data (surface_b);
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++) {
+ float r, g, b, l;
+ i = x + y * w;
+ r = powf(_get_red (data_a, i) / 255.0f, gamma);
+ g = powf(_get_green (data_a, i) / 255.0f, gamma);
+ b = powf(_get_blue (data_a, i) / 255.0f, gamma);
+
+ AdobeRGBToXYZ(r,g,b,&aX[i],&aY[i],&aZ[i]);
+ XYZToLAB(aX[i], aY[i], aZ[i], &l, &aA[i], &aB[i]);
+ r = powf(_get_red (data_b, i) / 255.0f, gamma);
+ g = powf(_get_green (data_b, i) / 255.0f, gamma);
+ b = powf(_get_blue (data_b, i) / 255.0f, gamma);
+
+ AdobeRGBToXYZ(r,g,b,&bX[i],&bY[i],&bZ[i]);
+ XYZToLAB(bX[i], bY[i], bZ[i], &l, &bA[i], &bB[i]);
+ aLum[i] = aY[i] * luminance;
+ bLum[i] = bY[i] * luminance;
+ }
+ }
+
+ la = lpyramid_create (aLum, w, h);
+ lb = lpyramid_create (bLum, w, h);
+
+ num_one_degree_pixels = (float) (2 * tan(field_of_view * 0.5 * M_PI / 180) * 180 / M_PI);
+ pixels_per_degree = w / num_one_degree_pixels;
+
+ num_pixels = 1;
+ adaptation_level = 0;
+ for (i = 0; i < MAX_PYR_LEVELS; i++) {
+ adaptation_level = i;
+ if (num_pixels > num_one_degree_pixels) break;
+ num_pixels *= 2;
+ }
+
+ cpd[0] = 0.5f * pixels_per_degree;
+ for (i = 1; i < MAX_PYR_LEVELS; i++) cpd[i] = 0.5f * cpd[i - 1];
+ csf_max = csf(3.248f, 100.0f);
+
+ for (i = 0; i < MAX_PYR_LEVELS - 2; i++) F_freq[i] = csf_max / csf( cpd[i], 100.0f);
+
+ pixels_failed = 0;
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++) {
+ int index = x + y * w;
+ float contrast[MAX_PYR_LEVELS - 2];
+ float F_mask[MAX_PYR_LEVELS - 2];
+ float factor;
+ float delta;
+ float adapt;
+ bool pass;
+ float sum_contrast = 0;
+ for (i = 0; i < MAX_PYR_LEVELS - 2; i++) {
+ float n1 = fabsf(lpyramid_get_value (la,x,y,i) - lpyramid_get_value (la,x,y,i + 1));
+ float n2 = fabsf(lpyramid_get_value (lb,x,y,i) - lpyramid_get_value (lb,x,y,i + 1));
+ float numerator = (n1 > n2) ? n1 : n2;
+ float d1 = fabsf(lpyramid_get_value(la,x,y,i+2));
+ float d2 = fabsf(lpyramid_get_value(lb,x,y,i+2));
+ float denominator = (d1 > d2) ? d1 : d2;
+ if (denominator < 1e-5f) denominator = 1e-5f;
+ contrast[i] = numerator / denominator;
+ sum_contrast += contrast[i];
+ }
+ if (sum_contrast < 1e-5) sum_contrast = 1e-5f;
+ adapt = lpyramid_get_value(la,x,y,adaptation_level) + lpyramid_get_value(lb,x,y,adaptation_level);
+ adapt *= 0.5f;
+ if (adapt < 1e-5) adapt = 1e-5f;
+ for (i = 0; i < MAX_PYR_LEVELS - 2; i++) {
+ F_mask[i] = mask(contrast[i] * csf(cpd[i], adapt));
+ }
+ factor = 0;
+ for (i = 0; i < MAX_PYR_LEVELS - 2; i++) {
+ factor += contrast[i] * F_freq[i] * F_mask[i] / sum_contrast;
+ }
+ if (factor < 1) factor = 1;
+ if (factor > 10) factor = 10;
+ delta = fabsf(lpyramid_get_value(la,x,y,0) - lpyramid_get_value(lb,x,y,0));
+ pass = true;
+ /* pure luminance test */
+ if (delta > factor * tvi(adapt)) {
+ pass = false;
+ } else {
+ /* CIE delta E test with modifications */
+ float color_scale = 1.0f;
+ float da = aA[index] - bA[index];
+ float db = aB[index] - bB[index];
+ float delta_e;
+ /* ramp down the color test in scotopic regions */
+ if (adapt < 10.0f) {
+ color_scale = 1.0f - (10.0f - color_scale) / 10.0f;
+ color_scale = color_scale * color_scale;
+ }
+ da = da * da;
+ db = db * db;
+ delta_e = (da + db) * color_scale;
+ if (delta_e > factor) {
+ pass = false;
+ }
+ }
+ if (!pass)
+ pixels_failed++;
+ }
+ }
+
+ free (aX);
+ free (aY);
+ free (aZ);
+ free (bX);
+ free (bY);
+ free (bZ);
+ free (aLum);
+ free (bLum);
+ lpyramid_destroy (la);
+ lpyramid_destroy (lb);
+ free (aA);
+ free (bA);
+ free (aB);
+ free (bB);
+
+ return pixels_failed;
+}
diff --git a/test/pdiff/pdiff.h b/test/pdiff/pdiff.h
new file mode 100644
index 0000000..30fec06
--- /dev/null
+++ b/test/pdiff/pdiff.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2006 Yangli Hector Yee
+ Copyright (C) 2006 Red Hat, Inc.
+
+ This program is free software; you can redistribute it and/or modify it under the terms of the
+ GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with this program;
+ if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+*/
+
+#ifndef _PDIFF_H
+#define _PDIFF_H
+
+#include <cairo.h>
+
+typedef int bool;
+#ifndef true
+#define true 1
+#endif
+#ifndef false
+#define false 0
+#endif
+
+/* Image comparison metric using Yee's method (and a cairo interface)
+ * References: A Perceptual Metric for Production Testing, Hector Yee, Journal of Graphics Tools 2004
+ */
+int
+pdiff_compare (cairo_surface_t *surface_a,
+ cairo_surface_t *surface_b,
+ double gamma,
+ double luminance,
+ double field_of_view);
+
+#endif
diff --git a/test/pdiff/perceptualdiff.c b/test/pdiff/perceptualdiff.c
new file mode 100644
index 0000000..a3a6e80
--- /dev/null
+++ b/test/pdiff/perceptualdiff.c
@@ -0,0 +1,101 @@
+/*
+ PerceptualDiff - a program that compares two images using a perceptual metric
+ based on the paper :
+ A perceptual metric for production testing. Journal of graphics tools, 9(4):33-40, 2004, Hector Yee
+ Copyright (C) 2006 Yangli Hector Yee
+
+ This program is free software; you can redistribute it and/or modify it under the terms of the
+ GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with this program;
+ if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+*/
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <math.h>
+#include "lpyramid.h"
+#include "args.h"
+#include "pdiff.h"
+
+static bool Yee_Compare(args_t *args)
+{
+ int width_a, height_a, stride_a;
+ unsigned char *data_a, *row_a;
+ uint32_t *pixel_a;
+ int width_b, height_b, stride_b;
+ unsigned char *data_b, *row_b;
+ uint32_t *pixel_b;
+ unsigned int x, y, dim, pixels_failed;
+ bool identical = true;
+
+ width_a = cairo_image_surface_get_width (args->surface_a);
+ height_a = cairo_image_surface_get_height (args->surface_a);
+ stride_a = cairo_image_surface_get_stride (args->surface_a);
+ data_a = cairo_image_surface_get_data (args->surface_a);
+
+ width_b = cairo_image_surface_get_width (args->surface_b);
+ height_b = cairo_image_surface_get_height (args->surface_b);
+ stride_b = cairo_image_surface_get_stride (args->surface_b);
+ data_b = cairo_image_surface_get_data (args->surface_b);
+
+ if ((width_a != width_b) || (height_a != height_b)) {
+ printf ("FAIL: Image dimensions do not match\n");
+ return false;
+ }
+
+ identical = true;
+
+ for (y = 0; y < height_a; y++) {
+ row_a = data_a + y * stride_a;
+ row_b = data_b + y * stride_b;
+ pixel_a = (uint32_t *) row_a;
+ pixel_b = (uint32_t *) row_b;
+ for (x = 0; x < width_a; x++) {
+ if (*pixel_a != *pixel_b) {
+ identical = false;
+ }
+ pixel_a++;
+ pixel_b++;
+ }
+ }
+ if (identical) {
+ printf ("PASS: Images are binary identical\n");
+ return true;
+ }
+
+ pixels_failed = pdiff_compare (args->surface_a, args->surface_b,
+ args->Gamma, args->Luminance,
+ args->FieldOfView);
+
+ if (pixels_failed < args->ThresholdPixels) {
+ printf ("PASS: Images are perceptually indistinguishable\n");
+ return true;
+ }
+
+ printf("FAIL: Images are visibly different\n"
+ "%d pixels are different\n", pixels_failed);
+
+ return false;
+}
+
+int main(int argc, char **argv)
+{
+ args_t args;
+
+ args_init (&args);
+
+ if (!args_parse (&args, argc, argv)) {
+ return -1;
+ } else {
+ if (args.Verbose)
+ args_print (&args);
+ }
+ return ! Yee_Compare(&args);
+}