Mozilla Home
Privacy
Cookies
Legal
Bugzilla
Browse
Advanced Search
New Bug
Reports
Documentation
Log In
Log In with GitHub
or
Remember me
Browse
Advanced Search
New Bug
Reports
Documentation
Attachment 463272 Details for
Bug 573948
[patch]
Patch v1 - Patching libjpeg-turbo on top of libjpeg
libjpeg-turbo (text/plain), 1.43 MB, created by
Justin Lebar (not reading bugmail)
(
hide
)
Description:
Patch v1 - Patching libjpeg-turbo on top of libjpeg
Filename:
MIME Type:
Creator:
Justin Lebar (not reading bugmail)
Size:
1.43 MB
patch
obsolete
># HG changeset patch ># User Justin Lebar <justin.lebar@gmail.com> ># Date 1279560881 25200 ># Node ID d22c27829dcc253f141d32cf8ac1579a47f8f5eb ># Parent dd6d85ae97546a0de5aed2db07e25fd2e58ef5de >Bug 573948: Use libjpeg-turbo instead of libjpeg. > >diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in >--- a/config/autoconf.mk.in >+++ b/config/autoconf.mk.in >@@ -158,16 +158,20 @@ MOZ_RAW = @MOZ_RAW@ > MOZ_SYDNEYAUDIO = @MOZ_SYDNEYAUDIO@ > MOZ_WAVE = @MOZ_WAVE@ > MOZ_MEDIA = @MOZ_MEDIA@ > MOZ_VORBIS = @MOZ_VORBIS@ > MOZ_WEBM = @MOZ_WEBM@ > VPX_AS = @VPX_AS@ > VPX_ASFLAGS = @VPX_ASFLAGS@ > VPX_X86_ASM = @VPX_X86_ASM@ >+LIBJPEG_TURBO_AS = @LIBJPEG_TURBO_AS@ >+LIBJPEG_TURBO_ASFLAGS = @LIBJPEG_TURBO_ASFLAGS@ >+LIBJPEG_TURBO_X86_ASM = @LIBJPEG_TURBO_X86_ASM@ >+LIBJPEG_TURBO_X64_ASM = @LIBJPEG_TURBO_X64_ASM@ > NS_PRINTING = @NS_PRINTING@ > MOZ_CRASHREPORTER = @MOZ_CRASHREPORTER@ > MOZ_HELP_VIEWER = @MOZ_HELP_VIEWER@ > MOC= @MOC@ > MOZ_NSS_PATCH = @MOZ_NSS_PATCH@ > MOZ_WEBGL = @MOZ_WEBGL@ > > MOZ_JAVAXPCOM = @MOZ_JAVAXPCOM@ >diff --git a/configure.in b/configure.in >--- a/configure.in >+++ b/configure.in >@@ -1208,17 +1208,17 @@ ASM_SUFFIX=s > IMPORT_LIB_SUFFIX= > TARGET_MD_ARCH=unix > DIRENT_INO=d_ino > CYGWIN_WRAPPER= > WIN_TOP_SRC= > MOZ_USER_DIR=".mozilla" > > MOZ_JPEG_CFLAGS= >-MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/jpeg)' >+MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/modules/libjpeg-turbo)' > MOZ_ZLIB_CFLAGS= > MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/modules/zlib/src)' > MOZ_BZ2_CFLAGS= > MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)' > MOZ_PNG_CFLAGS= > MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/modules/libimg/png)' > > MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -lmozjs' >@@ -2396,17 +2396,17 @@ ia64*-hpux*) > dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul. > dnl Probably also a compiler bug, but what can you do? > PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE" > if test -n "$_USE_DYNAMICBASE"; then > LDFLAGS="$LDFLAGS -DYNAMICBASE" > fi > fi > fi >- MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,jpeg32$(VERSION_NUMBER),$(DEPTH)/jpeg)' >+ MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,jpeg32$(VERSION_NUMBER),$(DEPTH)/modules/libjpeg-turbo)' > MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,png,$(DEPTH)/modules/libimg/png)' > AC_DEFINE(HAVE_SNPRINTF) > AC_DEFINE(_WINDOWS) > AC_DEFINE(WIN32) > AC_DEFINE(XP_WIN) > AC_DEFINE(XP_WIN32) > AC_DEFINE(HW_THREADS) > AC_DEFINE(STDC_HEADERS) >@@ -4883,16 +4883,20 @@ MOZ_RAW=1 > MOZ_SYDNEYAUDIO= > MOZ_VORBIS= > MOZ_WAVE=1 > MOZ_MEDIA= > MOZ_WEBM=1 > VPX_AS= > VPX_ASFLAGS= > VPX_X86_ASM= >+LIBJPEG_TURBO_AS= >+LIBJPEG_TURBO_ASFLAGS= >+LIBJPEG_TURBO_X86_ASM= >+LIBJPEG_TURBO_X64_ASM= > MOZ_PANGO=1 > MOZ_PERMISSIONS=1 > MOZ_PLACES=1 > MOZ_PLAINTEXT_EDITOR_ONLY= > MOZ_PLUGINS=1 > MOZ_PREF_EXTENSIONS=1 > MOZ_PROFILELOCKING=1 > MOZ_PSM=1 >@@ -6160,16 +6164,77 @@ MOZ_ARG_WITH_STRING(crashreporter-enable > MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"]) > > if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then > MOZ_CRASHREPORTER_ENABLE_PERCENT=100 > fi > AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT) > > dnl ======================================================== >+dnl = libjpeg-turbo configuration >+dnl ======================================================== >+ >+dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly >+dnl files. >+AC_MSG_CHECKING([for YASM assembler]) >+AC_CHECK_PROGS(LIBJPEG_TURBO_AS, yasm, "") >+ >+dnl XXX jlebar -- need a yasm version check here. >+ >+if test -n "LIBJPEG_TURBO_AS"; then >+ >+ LIBJPEG_TURBO_AS="yasm" >+ >+ dnl We have YASM; see if we support it on this platform. >+ case "$OS_ARCH:$OS_TEST" in >+ Linux:x86|Linux:i?86) >+ LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF" >+ LIBJPEG_TURBO_X86_ASM=1 >+ ;; >+ Linux:x86_64) >+ LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF" >+ LIBJPEG_TURBO_X64_ASM=1 >+ ;; >+ SunOS:i?86) >+ LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF" >+ LIBJPEG_TURBO_X86_ASM=1 >+ ;; >+ SunOS:x86_64) >+ LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF" >+ LIBJPEG_TURBO_X64_ASM=1 >+ ;; >+ Darwin:i?86) >+ LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO" >+ LIBJPEG_TURBO_X86_ASM=1 >+ ;; >+ Darwin:x86_64) >+ LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO" >+ LIBJPEG_TURBO_X64_ASM=1 >+ ;; >+ WINNT:x86|WINNT:i?86) >+ LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32" >+ LIBJPEG_TURBO_X86_ASM=1 >+ ;; >+ WINNT:x86_64) >+ LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64" >+ LIBJPEG_TURBO_X64_ASM=1 >+ ;; >+ esac >+ >+fi # end have YASM >+ >+if test -n "$LIBJPEG_TURBO_X86_ASM"; then >+ AC_DEFINE(LIBJPEG_TURBO_X86_ASM) >+elif test -n "$LIBJPEG_TURBO_X64_ASM"; then >+ AC_DEFINE(LIBJPEG_TURBO_X64_ASM) >+else >+ AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo. Using unoptimized C routines.]) >+fi >+ >+dnl ======================================================== > dnl = Enable compilation of specific extension modules > dnl ======================================================== > > MOZ_ARG_ENABLE_STRING(extensions, > [ --enable-extensions Enable extensions], > [ for option in `echo $enableval | sed 's/,/ /g'`; do > if test "$option" = "yes" -o "$option" = "all"; then > AC_MSG_ERROR([--enable-extensions=$option is no longer supported.]) >@@ -8872,16 +8937,20 @@ AC_SUBST(MOZ_SYDNEYAUDIO) > AC_SUBST(MOZ_WAVE) > AC_SUBST(MOZ_VORBIS) > AC_SUBST(MOZ_WEBM) > AC_SUBST(MOZ_OGG) > AC_SUBST(MOZ_ALSA_LIBS) > AC_SUBST(VPX_AS) > AC_SUBST(VPX_ASFLAGS) > AC_SUBST(VPX_X86_ASM) >+AC_SUBST(LIBJPEG_TURBO_AS) >+AC_SUBST(LIBJPEG_TURBO_ASFLAGS) >+AC_SUBST(LIBJPEG_TURBO_X86_ASM) >+AC_SUBST(LIBJPEG_TURBO_X64_ASM) > > if test "$USING_HCC"; then > CC='${topsrcdir}/build/hcc' > CC="$CC '$_OLDCC'" > CXX='${topsrcdir}/build/hcpp' > CXX="$CXX '$_OLDCXX'" > AC_SUBST(CC) > AC_SUBST(CXX) >diff --git a/jpeg/ckconfig.c b/jpeg/ckconfig.c >deleted file mode 100644 >--- a/jpeg/ckconfig.c >+++ /dev/null >@@ -1,402 +0,0 @@ >-/* >- * ckconfig.c >- * >- * Copyright (C) 1991-1994, Thomas G. Lane. >- * This file is part of the Independent JPEG Group's software. >- * For conditions of distribution and use, see the accompanying README file. >- */ >- >-/* >- * This program is intended to help you determine how to configure the JPEG >- * software for installation on a particular system. The idea is to try to >- * compile and execute this program. If your compiler fails to compile the >- * program, make changes as indicated in the comments below. Once you can >- * compile the program, run it, and it will produce a "jconfig.h" file for >- * your system. >- * >- * As a general rule, each time you try to compile this program, >- * pay attention only to the *first* error message you get from the compiler. >- * Many C compilers will issue lots of spurious error messages once they >- * have gotten confused. Go to the line indicated in the first error message, >- * and read the comments preceding that line to see what to change. >- * >- * Almost all of the edits you may need to make to this program consist of >- * changing a line that reads "#define SOME_SYMBOL" to "#undef SOME_SYMBOL", >- * or vice versa. This is called defining or undefining that symbol. >- */ >- >- >-/* First we must see if your system has the include files we need. >- * We start out with the assumption that your system has all the ANSI-standard >- * include files. If you get any error trying to include one of these files, >- * undefine the corresponding HAVE_xxx symbol. >- */ >- >-#define HAVE_STDDEF_H /* replace 'define' by 'undef' if error here */ >-#ifdef HAVE_STDDEF_H /* next line will be skipped if you undef... */ >-#include <stddef.h> >-#endif >- >-#define HAVE_STDLIB_H /* same thing for stdlib.h */ >-#ifdef HAVE_STDLIB_H >-#include <stdlib.h> >-#endif >- >-#include <stdio.h> /* If you ain't got this, you ain't got C. */ >- >-/* We have to see if your string functions are defined by >- * strings.h (old BSD convention) or string.h (everybody else). >- * We try the non-BSD convention first; define NEED_BSD_STRINGS >- * if the compiler says it can't find string.h. >- */ >- >-#undef NEED_BSD_STRINGS >- >-#ifdef NEED_BSD_STRINGS >-#include <strings.h> >-#else >-#include <string.h> >-#endif >- >-/* On some systems (especially older Unix machines), type size_t is >- * defined only in the include file <sys/types.h>. If you get a failure >- * on the size_t test below, try defining NEED_SYS_TYPES_H. >- */ >- >-#undef NEED_SYS_TYPES_H /* start by assuming we don't need it */ >-#ifdef NEED_SYS_TYPES_H >-#include <sys/types.h> >-#endif >- >- >-/* Usually type size_t is defined in one of the include files we've included >- * above. If not, you'll get an error on the "typedef size_t my_size_t;" line. >- * In that case, first try defining NEED_SYS_TYPES_H just above. >- * If that doesn't work, you'll have to search through your system library >- * to figure out which include file defines "size_t". Look for a line that >- * says "typedef something-or-other size_t;". Then, change the line below >- * that says "#include <someincludefile.h>" to instead include the file >- * you found size_t in, and define NEED_SPECIAL_INCLUDE. If you can't find >- * type size_t anywhere, try replacing "#include <someincludefile.h>" with >- * "typedef unsigned int size_t;". >- */ >- >-#undef NEED_SPECIAL_INCLUDE /* assume we DON'T need it, for starters */ >- >-#ifdef NEED_SPECIAL_INCLUDE >-#include <someincludefile.h> >-#endif >- >-typedef size_t my_size_t; /* The payoff: do we have size_t now? */ >- >- >-/* The next question is whether your compiler supports ANSI-style function >- * prototypes. You need to know this in order to choose between using >- * makefile.ansi and using makefile.unix. >- * The #define line below is set to assume you have ANSI function prototypes. >- * If you get an error in this group of lines, undefine HAVE_PROTOTYPES. >- */ >- >-#define HAVE_PROTOTYPES >- >-#ifdef HAVE_PROTOTYPES >-int testfunction (int arg1, int * arg2); /* check prototypes */ >- >-struct methods_struct { /* check method-pointer declarations */ >- int (*error_exit) (char *msgtext); >- int (*trace_message) (char *msgtext); >- int (*another_method) (void); >-}; >- >-int testfunction (int arg1, int * arg2) /* check definitions */ >-{ >- return arg2[arg1]; >-} >- >-int test2function (void) /* check void arg list */ >-{ >- return 0; >-} >-#endif >- >- >-/* Now we want to find out if your compiler knows what "unsigned char" means. >- * If you get an error on the "unsigned char un_char;" line, >- * then undefine HAVE_UNSIGNED_CHAR. >- */ >- >-#define HAVE_UNSIGNED_CHAR >- >-#ifdef HAVE_UNSIGNED_CHAR >-unsigned char un_char; >-#endif >- >- >-/* Now we want to find out if your compiler knows what "unsigned short" means. >- * If you get an error on the "unsigned short un_short;" line, >- * then undefine HAVE_UNSIGNED_SHORT. >- */ >- >-#define HAVE_UNSIGNED_SHORT >- >-#ifdef HAVE_UNSIGNED_SHORT >-unsigned short un_short; >-#endif >- >- >-/* Now we want to find out if your compiler understands type "void". >- * If you get an error anywhere in here, undefine HAVE_VOID. >- */ >- >-#define HAVE_VOID >- >-#ifdef HAVE_VOID >-/* Caution: a C++ compiler will insist on complete prototypes */ >-typedef void * void_ptr; /* check void * */ >-#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ >-typedef void (*void_func) (int a, int b); >-#else >-typedef void (*void_func) (); >-#endif >- >-#ifdef HAVE_PROTOTYPES /* check void function result */ >-void test3function (void_ptr arg1, void_func arg2) >-#else >-void test3function (arg1, arg2) >- void_ptr arg1; >- void_func arg2; >-#endif >-{ >- char * locptr = (char *) arg1; /* check casting to and from void * */ >- arg1 = (void *) locptr; >- (*arg2) (1, 2); /* check call of fcn returning void */ >-} >-#endif >- >- >-/* Now we want to find out if your compiler knows what "const" means. >- * If you get an error here, undefine HAVE_CONST. >- */ >- >-#define HAVE_CONST >- >-#ifdef HAVE_CONST >-static const int carray[3] = {1, 2, 3}; >- >-#ifdef HAVE_PROTOTYPES >-int test4function (const int arg1) >-#else >-int test4function (arg1) >- const int arg1; >-#endif >-{ >- return carray[arg1]; >-} >-#endif >- >- >-/* If you get an error or warning about this structure definition, >- * define INCOMPLETE_TYPES_BROKEN. >- */ >- >-#undef INCOMPLETE_TYPES_BROKEN >- >-#ifndef INCOMPLETE_TYPES_BROKEN >-typedef struct undefined_structure * undef_struct_ptr; >-#endif >- >- >-/* If you get an error about duplicate names, >- * define NEED_SHORT_EXTERNAL_NAMES. >- */ >- >-#undef NEED_SHORT_EXTERNAL_NAMES >- >-#ifndef NEED_SHORT_EXTERNAL_NAMES >- >-int possibly_duplicate_function () >-{ >- return 0; >-} >- >-int possibly_dupli_function () >-{ >- return 1; >-} >- >-#endif >- >- >- >-/************************************************************************ >- * OK, that's it. You should not have to change anything beyond this >- * point in order to compile and execute this program. (You might get >- * some warnings, but you can ignore them.) >- * When you run the program, it will make a couple more tests that it >- * can do automatically, and then it will create jconfig.h and print out >- * any additional suggestions it has. >- ************************************************************************ >- */ >- >- >-#ifdef HAVE_PROTOTYPES >-int is_char_signed (int arg) >-#else >-int is_char_signed (arg) >- int arg; >-#endif >-{ >- if (arg == 189) { /* expected result for unsigned char */ >- return 0; /* type char is unsigned */ >- } >- else if (arg != -67) { /* expected result for signed char */ >- printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); >- printf("I fear the JPEG software will not work at all.\n\n"); >- } >- return 1; /* assume char is signed otherwise */ >-} >- >- >-#ifdef HAVE_PROTOTYPES >-int is_shifting_signed (long arg) >-#else >-int is_shifting_signed (arg) >- long arg; >-#endif >-/* See whether right-shift on a long is signed or not. */ >-{ >- long res = arg >> 4; >- >- if (res == -0x7F7E80CL) { /* expected result for signed shift */ >- return 1; /* right shift is signed */ >- } >- /* see if unsigned-shift hack will fix it. */ >- /* we can't just test exact value since it depends on width of long... */ >- res |= (~0L) << (32-4); >- if (res == -0x7F7E80CL) { /* expected result now? */ >- return 0; /* right shift is unsigned */ >- } >- printf("Right shift isn't acting as I expect it to.\n"); >- printf("I fear the JPEG software will not work at all.\n\n"); >- return 0; /* try it with unsigned anyway */ >-} >- >- >-#ifdef HAVE_PROTOTYPES >-int main (int argc, char ** argv) >-#else >-int main (argc, argv) >- int argc; >- char ** argv; >-#endif >-{ >- char signed_char_check = (char) (-67); >- FILE *outfile; >- >- /* Attempt to write jconfig.h */ >- if ((outfile = fopen("jconfig.h", "w")) == NULL) { >- printf("Failed to write jconfig.h\n"); >- return 1; >- } >- >- /* Write out all the info */ >- fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n"); >- fprintf(outfile, "/* see jconfig.doc for explanations */\n\n"); >-#ifdef HAVE_PROTOTYPES >- fprintf(outfile, "#define HAVE_PROTOTYPES\n"); >-#else >- fprintf(outfile, "#undef HAVE_PROTOTYPES\n"); >-#endif >-#ifdef HAVE_UNSIGNED_CHAR >- fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n"); >-#else >- fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n"); >-#endif >-#ifdef HAVE_UNSIGNED_SHORT >- fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n"); >-#else >- fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n"); >-#endif >-#ifdef HAVE_VOID >- fprintf(outfile, "/* #define void char */\n"); >-#else >- fprintf(outfile, "#define void char\n"); >-#endif >-#ifdef HAVE_CONST >- fprintf(outfile, "/* #define const */\n"); >-#else >- fprintf(outfile, "#define const\n"); >-#endif >- if (is_char_signed((int) signed_char_check)) >- fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n"); >- else >- fprintf(outfile, "#define CHAR_IS_UNSIGNED\n"); >-#ifdef HAVE_STDDEF_H >- fprintf(outfile, "#define HAVE_STDDEF_H\n"); >-#else >- fprintf(outfile, "#undef HAVE_STDDEF_H\n"); >-#endif >-#ifdef HAVE_STDLIB_H >- fprintf(outfile, "#define HAVE_STDLIB_H\n"); >-#else >- fprintf(outfile, "#undef HAVE_STDLIB_H\n"); >-#endif >-#ifdef NEED_BSD_STRINGS >- fprintf(outfile, "#define NEED_BSD_STRINGS\n"); >-#else >- fprintf(outfile, "#undef NEED_BSD_STRINGS\n"); >-#endif >-#ifdef NEED_SYS_TYPES_H >- fprintf(outfile, "#define NEED_SYS_TYPES_H\n"); >-#else >- fprintf(outfile, "#undef NEED_SYS_TYPES_H\n"); >-#endif >- fprintf(outfile, "#undef NEED_FAR_POINTERS\n"); >-#ifdef NEED_SHORT_EXTERNAL_NAMES >- fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n"); >-#else >- fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n"); >-#endif >-#ifdef INCOMPLETE_TYPES_BROKEN >- fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n"); >-#else >- fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n"); >-#endif >- fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n"); >- if (is_shifting_signed(-0x7F7E80B1L)) >- fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n"); >- else >- fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n"); >- fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n"); >- fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n"); >- fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n"); >- fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n"); >- fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n"); >- fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n"); >- fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n"); >- fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n"); >- fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n"); >- fprintf(outfile, "#undef DONT_USE_B_MODE\n"); >- fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n"); >- fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n"); >- >- /* Close the jconfig.h file */ >- fclose(outfile); >- >- /* User report */ >- printf("Configuration check for Independent JPEG Group's software done.\n"); >- printf("\nI have written the jconfig.h file for you.\n\n"); >-#ifdef HAVE_PROTOTYPES >- printf("You should use makefile.ansi as the starting point for your Makefile.\n"); >-#else >- printf("You should use makefile.unix as the starting point for your Makefile.\n"); >-#endif >- >-#ifdef NEED_SPECIAL_INCLUDE >- printf("\nYou'll need to change jconfig.h to include the system include file\n"); >- printf("that you found type size_t in, or add a direct definition of type\n"); >- printf("size_t if that's what you used. Just add it to the end.\n"); >-#endif >- >- return 0; >-} >diff --git a/jpeg/jconfig-mac-cw.h b/jpeg/jconfig-mac-cw.h >deleted file mode 100644 >--- a/jpeg/jconfig-mac-cw.h >+++ /dev/null >@@ -1,43 +0,0 @@ >-/* jconfig.h --- generated by ckconfig.c */ >-/* see jconfig.doc for explanations */ >- >-#define ALIGN_TYPE long /* memory alignment */ >-#define NO_GETENV /* we do have the function, but it's dead */ >-#ifdef __cplusplus >-#define INLINE inline /* we have them in C++ */ >-#endif >- >-#define HAVE_PROTOTYPES >-#define HAVE_UNSIGNED_CHAR >-#define HAVE_UNSIGNED_SHORT >-/* #define void char */ >-/* #define const */ >-#undef CHAR_IS_UNSIGNED >-#define HAVE_STDDEF_H >-#define HAVE_STDLIB_H >-#undef NEED_BSD_STRINGS >-#undef NEED_SYS_TYPES_H >-#undef NEED_FAR_POINTERS >-#undef NEED_SHORT_EXTERNAL_NAMES >-#undef INCOMPLETE_TYPES_BROKEN >- >-#ifdef JPEG_INTERNALS >- >-#undef RIGHT_SHIFT_IS_UNSIGNED >- >-#endif /* JPEG_INTERNALS */ >- >-#ifdef JPEG_CJPEG_DJPEG >- >-#define BMP_SUPPORTED /* BMP image file format */ >-#define GIF_SUPPORTED /* GIF image file format */ >-#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ >-#undef RLE_SUPPORTED /* Utah RLE image file format */ >-#define TARGA_SUPPORTED /* Targa image file format */ >- >-#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */ >-#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ >-#undef DONT_USE_B_MODE >-/* #define PROGRESS_REPORT */ /* optional */ >- >-#endif /* JPEG_CJPEG_DJPEG */ >diff --git a/jpeg/jconfig.wat b/jpeg/jconfig.wat >deleted file mode 100644 >--- a/jpeg/jconfig.wat >+++ /dev/null >@@ -1,38 +0,0 @@ >-/* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */ >-/* see jconfig.doc for explanations */ >- >-#define HAVE_PROTOTYPES >-#define HAVE_UNSIGNED_CHAR >-#define HAVE_UNSIGNED_SHORT >-/* #define void char */ >-/* #define const */ >-#define CHAR_IS_UNSIGNED >-#define HAVE_STDDEF_H >-#define HAVE_STDLIB_H >-#undef NEED_BSD_STRINGS >-#undef NEED_SYS_TYPES_H >-#undef NEED_FAR_POINTERS /* Watcom uses flat 32-bit addressing */ >-#undef NEED_SHORT_EXTERNAL_NAMES >-#undef INCOMPLETE_TYPES_BROKEN >- >-#ifdef JPEG_INTERNALS >- >-#undef RIGHT_SHIFT_IS_UNSIGNED >- >-#endif /* JPEG_INTERNALS */ >- >-#ifdef JPEG_CJPEG_DJPEG >- >-#define BMP_SUPPORTED /* BMP image file format */ >-#define GIF_SUPPORTED /* GIF image file format */ >-#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ >-#undef RLE_SUPPORTED /* Utah RLE image file format */ >-#define TARGA_SUPPORTED /* Targa image file format */ >- >-#undef TWO_FILE_COMMANDLINE /* optional */ >-#define USE_SETMODE /* Needed to make one-file style work in Watcom */ >-#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ >-#undef DONT_USE_B_MODE >-#undef PROGRESS_REPORT /* optional */ >- >-#endif /* JPEG_CJPEG_DJPEG */ >diff --git a/jpeg/jmemansi.c b/jpeg/jmemansi.c >deleted file mode 100644 >--- a/jpeg/jmemansi.c >+++ /dev/null >@@ -1,167 +0,0 @@ >-/* >- * jmemansi.c >- * >- * Copyright (C) 1992-1996, Thomas G. Lane. >- * This file is part of the Independent JPEG Group's software. >- * For conditions of distribution and use, see the accompanying README file. >- * >- * This file provides a simple generic implementation of the system- >- * dependent portion of the JPEG memory manager. This implementation >- * assumes that you have the ANSI-standard library routine tmpfile(). >- * Also, the problem of determining the amount of memory available >- * is shoved onto the user. >- */ >- >-#define JPEG_INTERNALS >-#include "jinclude.h" >-#include "jpeglib.h" >-#include "jmemsys.h" /* import the system-dependent declarations */ >- >-#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */ >-extern void * malloc JPP((size_t size)); >-extern void free JPP((void *ptr)); >-#endif >- >-#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ >-#define SEEK_SET 0 /* if not, assume 0 is correct */ >-#endif >- >- >-/* >- * Memory allocation and freeing are controlled by the regular library >- * routines malloc() and free(). >- */ >- >-GLOBAL(void *) >-jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) >-{ >- return (void *) malloc(sizeofobject); >-} >- >-GLOBAL(void) >-jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) >-{ >- free(object); >-} >- >- >-/* >- * "Large" objects are treated the same as "small" ones. >- * NB: although we include FAR keywords in the routine declarations, >- * this file won't actually work in 80x86 small/medium model; at least, >- * you probably won't be able to process useful-size images in only 64KB. >- */ >- >-GLOBAL(void FAR *) >-jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) >-{ >- return (void FAR *) malloc(sizeofobject); >-} >- >-GLOBAL(void) >-jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) >-{ >- free(object); >-} >- >- >-/* >- * This routine computes the total memory space available for allocation. >- * It's impossible to do this in a portable way; our current solution is >- * to make the user tell us (with a default value set at compile time). >- * If you can actually get the available space, it's a good idea to subtract >- * a slop factor of 5% or so. >- */ >- >-#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ >-#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ >-#endif >- >-GLOBAL(long) >-jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, >- long max_bytes_needed, long already_allocated) >-{ >- return cinfo->mem->max_memory_to_use - already_allocated; >-} >- >- >-/* >- * Backing store (temporary file) management. >- * Backing store objects are only used when the value returned by >- * jpeg_mem_available is less than the total space needed. You can dispense >- * with these routines if you have plenty of virtual memory; see jmemnobs.c. >- */ >- >- >-METHODDEF(void) >-read_backing_store (j_common_ptr cinfo, backing_store_ptr info, >- void FAR * buffer_address, >- long file_offset, long byte_count) >-{ >- if (fseek(info->temp_file, file_offset, SEEK_SET)) >- ERREXIT(cinfo, JERR_TFILE_SEEK); >- if (JFREAD(info->temp_file, buffer_address, byte_count) >- != (size_t) byte_count) >- ERREXIT(cinfo, JERR_TFILE_READ); >-} >- >- >-METHODDEF(void) >-write_backing_store (j_common_ptr cinfo, backing_store_ptr info, >- void FAR * buffer_address, >- long file_offset, long byte_count) >-{ >- if (fseek(info->temp_file, file_offset, SEEK_SET)) >- ERREXIT(cinfo, JERR_TFILE_SEEK); >- if (JFWRITE(info->temp_file, buffer_address, byte_count) >- != (size_t) byte_count) >- ERREXIT(cinfo, JERR_TFILE_WRITE); >-} >- >- >-METHODDEF(void) >-close_backing_store (j_common_ptr cinfo, backing_store_ptr info) >-{ >- fclose(info->temp_file); >- /* Since this implementation uses tmpfile() to create the file, >- * no explicit file deletion is needed. >- */ >-} >- >- >-/* >- * Initial opening of a backing-store object. >- * >- * This version uses tmpfile(), which constructs a suitable file name >- * behind the scenes. We don't have to use info->temp_name[] at all; >- * indeed, we can't even find out the actual name of the temp file. >- */ >- >-GLOBAL(void) >-jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, >- long total_bytes_needed) >-{ >- if ((info->temp_file = tmpfile()) == NULL) >- ERREXITS(cinfo, JERR_TFILE_CREATE, ""); >- info->read_backing_store = read_backing_store; >- info->write_backing_store = write_backing_store; >- info->close_backing_store = close_backing_store; >-} >- >- >-/* >- * These routines take care of any system-dependent initialization and >- * cleanup required. >- */ >- >-GLOBAL(long) >-jpeg_mem_init (j_common_ptr cinfo) >-{ >- return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ >-} >- >-GLOBAL(void) >-jpeg_mem_term (j_common_ptr cinfo) >-{ >- /* no work */ >-} >diff --git a/jpeg/jmemdos.c b/jpeg/jmemdos.c >deleted file mode 100644 >--- a/jpeg/jmemdos.c >+++ /dev/null >@@ -1,638 +0,0 @@ >-/* >- * jmemdos.c >- * >- * Copyright (C) 1992-1997, Thomas G. Lane. >- * This file is part of the Independent JPEG Group's software. >- * For conditions of distribution and use, see the accompanying README file. >- * >- * This file provides an MS-DOS-compatible implementation of the system- >- * dependent portion of the JPEG memory manager. Temporary data can be >- * stored in extended or expanded memory as well as in regular DOS files. >- * >- * If you use this file, you must be sure that NEED_FAR_POINTERS is defined >- * if you compile in a small-data memory model; it should NOT be defined if >- * you use a large-data memory model. This file is not recommended if you >- * are using a flat-memory-space 386 environment such as DJGCC or Watcom C. >- * Also, this code will NOT work if struct fields are aligned on greater than >- * 2-byte boundaries. >- * >- * Based on code contributed by Ge' Weijers. >- */ >- >-/* >- * If you have both extended and expanded memory, you may want to change the >- * order in which they are tried in jopen_backing_store. On a 286 machine >- * expanded memory is usually faster, since extended memory access involves >- * an expensive protected-mode-and-back switch. On 386 and better, extended >- * memory is usually faster. As distributed, the code tries extended memory >- * first (what? not everyone has a 386? :-). >- * >- * You can disable use of extended/expanded memory entirely by altering these >- * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0). >- */ >- >-#ifndef XMS_SUPPORTED >-#define XMS_SUPPORTED 1 >-#endif >-#ifndef EMS_SUPPORTED >-#define EMS_SUPPORTED 1 >-#endif >- >- >-#define JPEG_INTERNALS >-#include "jinclude.h" >-#include "jpeglib.h" >-#include "jmemsys.h" /* import the system-dependent declarations */ >- >-#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare these */ >-extern void * malloc JPP((size_t size)); >-extern void free JPP((void *ptr)); >-extern char * getenv JPP((const char * name)); >-#endif >- >-#ifdef NEED_FAR_POINTERS >- >-#ifdef __TURBOC__ >-/* These definitions work for Borland C (Turbo C) */ >-#include <alloc.h> /* need farmalloc(), farfree() */ >-#define far_malloc(x) farmalloc(x) >-#define far_free(x) farfree(x) >-#else >-/* These definitions work for Microsoft C and compatible compilers */ >-#include <malloc.h> /* need _fmalloc(), _ffree() */ >-#define far_malloc(x) _fmalloc(x) >-#define far_free(x) _ffree(x) >-#endif >- >-#else /* not NEED_FAR_POINTERS */ >- >-#define far_malloc(x) malloc(x) >-#define far_free(x) free(x) >- >-#endif /* NEED_FAR_POINTERS */ >- >-#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ >-#define READ_BINARY "r" >-#else >-#define READ_BINARY "rb" >-#endif >- >-#ifndef USE_MSDOS_MEMMGR /* make sure user got configuration right */ >- You forgot to define USE_MSDOS_MEMMGR in jconfig.h. /* deliberate syntax error */ >-#endif >- >-#if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */ >- MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */ >-#endif >- >- >-/* >- * Declarations for assembly-language support routines (see jmemdosa.asm). >- * >- * The functions are declared "far" as are all their pointer arguments; >- * this ensures the assembly source code will work regardless of the >- * compiler memory model. We assume "short" is 16 bits, "long" is 32. >- */ >- >-typedef void far * XMSDRIVER; /* actually a pointer to code */ >-typedef struct { /* registers for calling XMS driver */ >- unsigned short ax, dx, bx; >- void far * ds_si; >- } XMScontext; >-typedef struct { /* registers for calling EMS driver */ >- unsigned short ax, dx, bx; >- void far * ds_si; >- } EMScontext; >- >-extern short far jdos_open JPP((short far * handle, char far * filename)); >-extern short far jdos_close JPP((short handle)); >-extern short far jdos_seek JPP((short handle, long offset)); >-extern short far jdos_read JPP((short handle, void far * buffer, >- unsigned short count)); >-extern short far jdos_write JPP((short handle, void far * buffer, >- unsigned short count)); >-extern void far jxms_getdriver JPP((XMSDRIVER far *)); >-extern void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *)); >-extern short far jems_available JPP((void)); >-extern void far jems_calldriver JPP((EMScontext far *)); >- >- >-/* >- * Selection of a file name for a temporary file. >- * This is highly system-dependent, and you may want to customize it. >- */ >- >-static int next_file_num; /* to distinguish among several temp files */ >- >-LOCAL(void) >-select_file_name (char * fname) >-{ >- const char * env; >- char * ptr; >- FILE * tfile; >- >- /* Keep generating file names till we find one that's not in use */ >- for (;;) { >- /* Get temp directory name from environment TMP or TEMP variable; >- * if none, use "." >- */ >- if ((env = (const char *) getenv("TMP")) == NULL) >- if ((env = (const char *) getenv("TEMP")) == NULL) >- env = "."; >- if (*env == '\0') /* null string means "." */ >- env = "."; >- ptr = fname; /* copy name to fname */ >- while (*env != '\0') >- *ptr++ = *env++; >- if (ptr[-1] != '\\' && ptr[-1] != '/') >- *ptr++ = '\\'; /* append backslash if not in env variable */ >- /* Append a suitable file name */ >- next_file_num++; /* advance counter */ >- sprintf(ptr, "JPG%03d.TMP", next_file_num); >- /* Probe to see if file name is already in use */ >- if ((tfile = fopen(fname, READ_BINARY)) == NULL) >- break; >- fclose(tfile); /* oops, it's there; close tfile & try again */ >- } >-} >- >- >-/* >- * Near-memory allocation and freeing are controlled by the regular library >- * routines malloc() and free(). >- */ >- >-GLOBAL(void *) >-jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) >-{ >- return (void *) malloc(sizeofobject); >-} >- >-GLOBAL(void) >-jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) >-{ >- free(object); >-} >- >- >-/* >- * "Large" objects are allocated in far memory, if possible >- */ >- >-GLOBAL(void FAR *) >-jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) >-{ >- return (void FAR *) far_malloc(sizeofobject); >-} >- >-GLOBAL(void) >-jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) >-{ >- far_free(object); >-} >- >- >-/* >- * This routine computes the total memory space available for allocation. >- * It's impossible to do this in a portable way; our current solution is >- * to make the user tell us (with a default value set at compile time). >- * If you can actually get the available space, it's a good idea to subtract >- * a slop factor of 5% or so. >- */ >- >-#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ >-#define DEFAULT_MAX_MEM 300000L /* for total usage about 450K */ >-#endif >- >-GLOBAL(long) >-jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, >- long max_bytes_needed, long already_allocated) >-{ >- return cinfo->mem->max_memory_to_use - already_allocated; >-} >- >- >-/* >- * Backing store (temporary file) management. >- * Backing store objects are only used when the value returned by >- * jpeg_mem_available is less than the total space needed. You can dispense >- * with these routines if you have plenty of virtual memory; see jmemnobs.c. >- */ >- >-/* >- * For MS-DOS we support three types of backing storage: >- * 1. Conventional DOS files. We access these by direct DOS calls rather >- * than via the stdio package. This provides a bit better performance, >- * but the real reason is that the buffers to be read or written are FAR. >- * The stdio library for small-data memory models can't cope with that. >- * 2. Extended memory, accessed per the XMS V2.0 specification. >- * 3. Expanded memory, accessed per the LIM/EMS 4.0 specification. >- * You'll need copies of those specs to make sense of the related code. >- * The specs are available by Internet FTP from the SIMTEL archives >- * (oak.oakland.edu and its various mirror sites). See files >- * pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip. >- */ >- >- >-/* >- * Access methods for a DOS file. >- */ >- >- >-METHODDEF(void) >-read_file_store (j_common_ptr cinfo, backing_store_ptr info, >- void FAR * buffer_address, >- long file_offset, long byte_count) >-{ >- if (jdos_seek(info->handle.file_handle, file_offset)) >- ERREXIT(cinfo, JERR_TFILE_SEEK); >- /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ >- if (byte_count > 65535L) /* safety check */ >- ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); >- if (jdos_read(info->handle.file_handle, buffer_address, >- (unsigned short) byte_count)) >- ERREXIT(cinfo, JERR_TFILE_READ); >-} >- >- >-METHODDEF(void) >-write_file_store (j_common_ptr cinfo, backing_store_ptr info, >- void FAR * buffer_address, >- long file_offset, long byte_count) >-{ >- if (jdos_seek(info->handle.file_handle, file_offset)) >- ERREXIT(cinfo, JERR_TFILE_SEEK); >- /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ >- if (byte_count > 65535L) /* safety check */ >- ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); >- if (jdos_write(info->handle.file_handle, buffer_address, >- (unsigned short) byte_count)) >- ERREXIT(cinfo, JERR_TFILE_WRITE); >-} >- >- >-METHODDEF(void) >-close_file_store (j_common_ptr cinfo, backing_store_ptr info) >-{ >- jdos_close(info->handle.file_handle); /* close the file */ >- remove(info->temp_name); /* delete the file */ >-/* If your system doesn't have remove(), try unlink() instead. >- * remove() is the ANSI-standard name for this function, but >- * unlink() was more common in pre-ANSI systems. >- */ >- TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); >-} >- >- >-LOCAL(boolean) >-open_file_store (j_common_ptr cinfo, backing_store_ptr info, >- long total_bytes_needed) >-{ >- short handle; >- >- select_file_name(info->temp_name); >- if (jdos_open((short far *) & handle, (char far *) info->temp_name)) { >- /* might as well exit since jpeg_open_backing_store will fail anyway */ >- ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); >- return FALSE; >- } >- info->handle.file_handle = handle; >- info->read_backing_store = read_file_store; >- info->write_backing_store = write_file_store; >- info->close_backing_store = close_file_store; >- TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); >- return TRUE; /* succeeded */ >-} >- >- >-/* >- * Access methods for extended memory. >- */ >- >-#if XMS_SUPPORTED >- >-static XMSDRIVER xms_driver; /* saved address of XMS driver */ >- >-typedef union { /* either long offset or real-mode pointer */ >- long offset; >- void far * ptr; >- } XMSPTR; >- >-typedef struct { /* XMS move specification structure */ >- long length; >- XMSH src_handle; >- XMSPTR src; >- XMSH dst_handle; >- XMSPTR dst; >- } XMSspec; >- >-#define ODD(X) (((X) & 1L) != 0) >- >- >-METHODDEF(void) >-read_xms_store (j_common_ptr cinfo, backing_store_ptr info, >- void FAR * buffer_address, >- long file_offset, long byte_count) >-{ >- XMScontext ctx; >- XMSspec spec; >- char endbuffer[2]; >- >- /* The XMS driver can't cope with an odd length, so handle the last byte >- * specially if byte_count is odd. We don't expect this to be common. >- */ >- >- spec.length = byte_count & (~ 1L); >- spec.src_handle = info->handle.xms_handle; >- spec.src.offset = file_offset; >- spec.dst_handle = 0; >- spec.dst.ptr = buffer_address; >- >- ctx.ds_si = (void far *) & spec; >- ctx.ax = 0x0b00; /* EMB move */ >- jxms_calldriver(xms_driver, (XMScontext far *) & ctx); >- if (ctx.ax != 1) >- ERREXIT(cinfo, JERR_XMS_READ); >- >- if (ODD(byte_count)) { >- read_xms_store(cinfo, info, (void FAR *) endbuffer, >- file_offset + byte_count - 1L, 2L); >- ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0]; >- } >-} >- >- >-METHODDEF(void) >-write_xms_store (j_common_ptr cinfo, backing_store_ptr info, >- void FAR * buffer_address, >- long file_offset, long byte_count) >-{ >- XMScontext ctx; >- XMSspec spec; >- char endbuffer[2]; >- >- /* The XMS driver can't cope with an odd length, so handle the last byte >- * specially if byte_count is odd. We don't expect this to be common. >- */ >- >- spec.length = byte_count & (~ 1L); >- spec.src_handle = 0; >- spec.src.ptr = buffer_address; >- spec.dst_handle = info->handle.xms_handle; >- spec.dst.offset = file_offset; >- >- ctx.ds_si = (void far *) & spec; >- ctx.ax = 0x0b00; /* EMB move */ >- jxms_calldriver(xms_driver, (XMScontext far *) & ctx); >- if (ctx.ax != 1) >- ERREXIT(cinfo, JERR_XMS_WRITE); >- >- if (ODD(byte_count)) { >- read_xms_store(cinfo, info, (void FAR *) endbuffer, >- file_offset + byte_count - 1L, 2L); >- endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L]; >- write_xms_store(cinfo, info, (void FAR *) endbuffer, >- file_offset + byte_count - 1L, 2L); >- } >-} >- >- >-METHODDEF(void) >-close_xms_store (j_common_ptr cinfo, backing_store_ptr info) >-{ >- XMScontext ctx; >- >- ctx.dx = info->handle.xms_handle; >- ctx.ax = 0x0a00; >- jxms_calldriver(xms_driver, (XMScontext far *) & ctx); >- TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle); >- /* we ignore any error return from the driver */ >-} >- >- >-LOCAL(boolean) >-open_xms_store (j_common_ptr cinfo, backing_store_ptr info, >- long total_bytes_needed) >-{ >- XMScontext ctx; >- >- /* Get address of XMS driver */ >- jxms_getdriver((XMSDRIVER far *) & xms_driver); >- if (xms_driver == NULL) >- return FALSE; /* no driver to be had */ >- >- /* Get version number, must be >= 2.00 */ >- ctx.ax = 0x0000; >- jxms_calldriver(xms_driver, (XMScontext far *) & ctx); >- if (ctx.ax < (unsigned short) 0x0200) >- return FALSE; >- >- /* Try to get space (expressed in kilobytes) */ >- ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10); >- ctx.ax = 0x0900; >- jxms_calldriver(xms_driver, (XMScontext far *) & ctx); >- if (ctx.ax != 1) >- return FALSE; >- >- /* Succeeded, save the handle and away we go */ >- info->handle.xms_handle = ctx.dx; >- info->read_backing_store = read_xms_store; >- info->write_backing_store = write_xms_store; >- info->close_backing_store = close_xms_store; >- TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx); >- return TRUE; /* succeeded */ >-} >- >-#endif /* XMS_SUPPORTED */ >- >- >-/* >- * Access methods for expanded memory. >- */ >- >-#if EMS_SUPPORTED >- >-/* The EMS move specification structure requires word and long fields aligned >- * at odd byte boundaries. Some compilers will align struct fields at even >- * byte boundaries. While it's usually possible to force byte alignment, >- * that causes an overall performance penalty and may pose problems in merging >- * JPEG into a larger application. Instead we accept some rather dirty code >- * here. Note this code would fail if the hardware did not allow odd-byte >- * word & long accesses, but all 80x86 CPUs do. >- */ >- >-typedef void far * EMSPTR; >- >-typedef union { /* EMS move specification structure */ >- long length; /* It's easy to access first 4 bytes */ >- char bytes[18]; /* Misaligned fields in here! */ >- } EMSspec; >- >-/* Macros for accessing misaligned fields */ >-#define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset]))) >-#define SRC_TYPE(spec) FIELD_AT(spec,4,char) >-#define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH) >-#define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short) >-#define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short) >-#define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR) >-#define DST_TYPE(spec) FIELD_AT(spec,11,char) >-#define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH) >-#define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short) >-#define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short) >-#define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR) >- >-#define EMSPAGESIZE 16384L /* gospel, see the EMS specs */ >- >-#define HIBYTE(W) (((W) >> 8) & 0xFF) >-#define LOBYTE(W) ((W) & 0xFF) >- >- >-METHODDEF(void) >-read_ems_store (j_common_ptr cinfo, backing_store_ptr info, >- void FAR * buffer_address, >- long file_offset, long byte_count) >-{ >- EMScontext ctx; >- EMSspec spec; >- >- spec.length = byte_count; >- SRC_TYPE(spec) = 1; >- SRC_HANDLE(spec) = info->handle.ems_handle; >- SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); >- SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); >- DST_TYPE(spec) = 0; >- DST_HANDLE(spec) = 0; >- DST_PTR(spec) = buffer_address; >- >- ctx.ds_si = (void far *) & spec; >- ctx.ax = 0x5700; /* move memory region */ >- jems_calldriver((EMScontext far *) & ctx); >- if (HIBYTE(ctx.ax) != 0) >- ERREXIT(cinfo, JERR_EMS_READ); >-} >- >- >-METHODDEF(void) >-write_ems_store (j_common_ptr cinfo, backing_store_ptr info, >- void FAR * buffer_address, >- long file_offset, long byte_count) >-{ >- EMScontext ctx; >- EMSspec spec; >- >- spec.length = byte_count; >- SRC_TYPE(spec) = 0; >- SRC_HANDLE(spec) = 0; >- SRC_PTR(spec) = buffer_address; >- DST_TYPE(spec) = 1; >- DST_HANDLE(spec) = info->handle.ems_handle; >- DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); >- DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); >- >- ctx.ds_si = (void far *) & spec; >- ctx.ax = 0x5700; /* move memory region */ >- jems_calldriver((EMScontext far *) & ctx); >- if (HIBYTE(ctx.ax) != 0) >- ERREXIT(cinfo, JERR_EMS_WRITE); >-} >- >- >-METHODDEF(void) >-close_ems_store (j_common_ptr cinfo, backing_store_ptr info) >-{ >- EMScontext ctx; >- >- ctx.ax = 0x4500; >- ctx.dx = info->handle.ems_handle; >- jems_calldriver((EMScontext far *) & ctx); >- TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle); >- /* we ignore any error return from the driver */ >-} >- >- >-LOCAL(boolean) >-open_ems_store (j_common_ptr cinfo, backing_store_ptr info, >- long total_bytes_needed) >-{ >- EMScontext ctx; >- >- /* Is EMS driver there? */ >- if (! jems_available()) >- return FALSE; >- >- /* Get status, make sure EMS is OK */ >- ctx.ax = 0x4000; >- jems_calldriver((EMScontext far *) & ctx); >- if (HIBYTE(ctx.ax) != 0) >- return FALSE; >- >- /* Get version, must be >= 4.0 */ >- ctx.ax = 0x4600; >- jems_calldriver((EMScontext far *) & ctx); >- if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40) >- return FALSE; >- >- /* Try to allocate requested space */ >- ctx.ax = 0x4300; >- ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE); >- jems_calldriver((EMScontext far *) & ctx); >- if (HIBYTE(ctx.ax) != 0) >- return FALSE; >- >- /* Succeeded, save the handle and away we go */ >- info->handle.ems_handle = ctx.dx; >- info->read_backing_store = read_ems_store; >- info->write_backing_store = write_ems_store; >- info->close_backing_store = close_ems_store; >- TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx); >- return TRUE; /* succeeded */ >-} >- >-#endif /* EMS_SUPPORTED */ >- >- >-/* >- * Initial opening of a backing-store object. >- */ >- >-GLOBAL(void) >-jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, >- long total_bytes_needed) >-{ >- /* Try extended memory, then expanded memory, then regular file. */ >-#if XMS_SUPPORTED >- if (open_xms_store(cinfo, info, total_bytes_needed)) >- return; >-#endif >-#if EMS_SUPPORTED >- if (open_ems_store(cinfo, info, total_bytes_needed)) >- return; >-#endif >- if (open_file_store(cinfo, info, total_bytes_needed)) >- return; >- ERREXITS(cinfo, JERR_TFILE_CREATE, ""); >-} >- >- >-/* >- * These routines take care of any system-dependent initialization and >- * cleanup required. >- */ >- >-GLOBAL(long) >-jpeg_mem_init (j_common_ptr cinfo) >-{ >- next_file_num = 0; /* initialize temp file name generator */ >- return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ >-} >- >-GLOBAL(void) >-jpeg_mem_term (j_common_ptr cinfo) >-{ >- /* Microsoft C, at least in v6.00A, will not successfully reclaim freed >- * blocks of size > 32Kbytes unless we give it a kick in the rear, like so: >- */ >-#ifdef NEED_FHEAPMIN >- _fheapmin(); >-#endif >-} >diff --git a/jpeg/jmemdosa.asm b/jpeg/jmemdosa.asm >deleted file mode 100644 >--- a/jpeg/jmemdosa.asm >+++ /dev/null >@@ -1,379 +0,0 @@ >-; >-; jmemdosa.asm >-; >-; Copyright (C) 1992, Thomas G. Lane. >-; This file is part of the Independent JPEG Group's software. >-; For conditions of distribution and use, see the accompanying README file. >-; >-; This file contains low-level interface routines to support the MS-DOS >-; backing store manager (jmemdos.c). Routines are provided to access disk >-; files through direct DOS calls, and to access XMS and EMS drivers. >-; >-; This file should assemble with Microsoft's MASM or any compatible >-; assembler (including Borland's Turbo Assembler). If you haven't got >-; a compatible assembler, better fall back to jmemansi.c or jmemname.c. >-; >-; To minimize dependence on the C compiler's register usage conventions, >-; we save and restore all 8086 registers, even though most compilers only >-; require SI,DI,DS to be preserved. Also, we use only 16-bit-wide return >-; values, which everybody returns in AX. >-; >-; Based on code contributed by Ge' Weijers. >-; >- >-JMEMDOSA_TXT segment byte public 'CODE' >- >- assume cs:JMEMDOSA_TXT >- >- public _jdos_open >- public _jdos_close >- public _jdos_seek >- public _jdos_read >- public _jdos_write >- public _jxms_getdriver >- public _jxms_calldriver >- public _jems_available >- public _jems_calldriver >- >-; >-; short far jdos_open (short far * handle, char far * filename) >-; >-; Create and open a temporary file >-; >-_jdos_open proc far >- push bp ; linkage >- mov bp,sp >- push si ; save all registers for safety >- push di >- push bx >- push cx >- push dx >- push es >- push ds >- mov cx,0 ; normal file attributes >- lds dx,dword ptr [bp+10] ; get filename pointer >- mov ah,3ch ; create file >- int 21h >- jc open_err ; if failed, return error code >- lds bx,dword ptr [bp+6] ; get handle pointer >- mov word ptr [bx],ax ; save the handle >- xor ax,ax ; return zero for OK >-open_err: pop ds ; restore registers and exit >- pop es >- pop dx >- pop cx >- pop bx >- pop di >- pop si >- pop bp >- ret >-_jdos_open endp >- >- >-; >-; short far jdos_close (short handle) >-; >-; Close the file handle >-; >-_jdos_close proc far >- push bp ; linkage >- mov bp,sp >- push si ; save all registers for safety >- push di >- push bx >- push cx >- push dx >- push es >- push ds >- mov bx,word ptr [bp+6] ; file handle >- mov ah,3eh ; close file >- int 21h >- jc close_err ; if failed, return error code >- xor ax,ax ; return zero for OK >-close_err: pop ds ; restore registers and exit >- pop es >- pop dx >- pop cx >- pop bx >- pop di >- pop si >- pop bp >- ret >-_jdos_close endp >- >- >-; >-; short far jdos_seek (short handle, long offset) >-; >-; Set file position >-; >-_jdos_seek proc far >- push bp ; linkage >- mov bp,sp >- push si ; save all registers for safety >- push di >- push bx >- push cx >- push dx >- push es >- push ds >- mov bx,word ptr [bp+6] ; file handle >- mov dx,word ptr [bp+8] ; LS offset >- mov cx,word ptr [bp+10] ; MS offset >- mov ax,4200h ; absolute seek >- int 21h >- jc seek_err ; if failed, return error code >- xor ax,ax ; return zero for OK >-seek_err: pop ds ; restore registers and exit >- pop es >- pop dx >- pop cx >- pop bx >- pop di >- pop si >- pop bp >- ret >-_jdos_seek endp >- >- >-; >-; short far jdos_read (short handle, void far * buffer, unsigned short count) >-; >-; Read from file >-; >-_jdos_read proc far >- push bp ; linkage >- mov bp,sp >- push si ; save all registers for safety >- push di >- push bx >- push cx >- push dx >- push es >- push ds >- mov bx,word ptr [bp+6] ; file handle >- lds dx,dword ptr [bp+8] ; buffer address >- mov cx,word ptr [bp+12] ; number of bytes >- mov ah,3fh ; read file >- int 21h >- jc read_err ; if failed, return error code >- cmp ax,word ptr [bp+12] ; make sure all bytes were read >- je read_ok >- mov ax,1 ; else return 1 for not OK >- jmp short read_err >-read_ok: xor ax,ax ; return zero for OK >-read_err: pop ds ; restore registers and exit >- pop es >- pop dx >- pop cx >- pop bx >- pop di >- pop si >- pop bp >- ret >-_jdos_read endp >- >- >-; >-; short far jdos_write (short handle, void far * buffer, unsigned short count) >-; >-; Write to file >-; >-_jdos_write proc far >- push bp ; linkage >- mov bp,sp >- push si ; save all registers for safety >- push di >- push bx >- push cx >- push dx >- push es >- push ds >- mov bx,word ptr [bp+6] ; file handle >- lds dx,dword ptr [bp+8] ; buffer address >- mov cx,word ptr [bp+12] ; number of bytes >- mov ah,40h ; write file >- int 21h >- jc write_err ; if failed, return error code >- cmp ax,word ptr [bp+12] ; make sure all bytes written >- je write_ok >- mov ax,1 ; else return 1 for not OK >- jmp short write_err >-write_ok: xor ax,ax ; return zero for OK >-write_err: pop ds ; restore registers and exit >- pop es >- pop dx >- pop cx >- pop bx >- pop di >- pop si >- pop bp >- ret >-_jdos_write endp >- >- >-; >-; void far jxms_getdriver (XMSDRIVER far *) >-; >-; Get the address of the XMS driver, or NULL if not available >-; >-_jxms_getdriver proc far >- push bp ; linkage >- mov bp,sp >- push si ; save all registers for safety >- push di >- push bx >- push cx >- push dx >- push es >- push ds >- mov ax,4300h ; call multiplex interrupt with >- int 2fh ; a magic cookie, hex 4300 >- cmp al,80h ; AL should contain hex 80 >- je xmsavail >- xor dx,dx ; no XMS driver available >- xor ax,ax ; return a nil pointer >- jmp short xmsavail_done >-xmsavail: mov ax,4310h ; fetch driver address with >- int 2fh ; another magic cookie >- mov dx,es ; copy address to dx:ax >- mov ax,bx >-xmsavail_done: les bx,dword ptr [bp+6] ; get pointer to return value >- mov word ptr es:[bx],ax >- mov word ptr es:[bx+2],dx >- pop ds ; restore registers and exit >- pop es >- pop dx >- pop cx >- pop bx >- pop di >- pop si >- pop bp >- ret >-_jxms_getdriver endp >- >- >-; >-; void far jxms_calldriver (XMSDRIVER, XMScontext far *) >-; >-; The XMScontext structure contains values for the AX,DX,BX,SI,DS registers. >-; These are loaded, the XMS call is performed, and the new values of the >-; AX,DX,BX registers are written back to the context structure. >-; >-_jxms_calldriver proc far >- push bp ; linkage >- mov bp,sp >- push si ; save all registers for safety >- push di >- push bx >- push cx >- push dx >- push es >- push ds >- les bx,dword ptr [bp+10] ; get XMScontext pointer >- mov ax,word ptr es:[bx] ; load registers >- mov dx,word ptr es:[bx+2] >- mov si,word ptr es:[bx+6] >- mov ds,word ptr es:[bx+8] >- mov bx,word ptr es:[bx+4] >- call dword ptr [bp+6] ; call the driver >- mov cx,bx ; save returned BX for a sec >- les bx,dword ptr [bp+10] ; get XMScontext pointer >- mov word ptr es:[bx],ax ; put back ax,dx,bx >- mov word ptr es:[bx+2],dx >- mov word ptr es:[bx+4],cx >- pop ds ; restore registers and exit >- pop es >- pop dx >- pop cx >- pop bx >- pop di >- pop si >- pop bp >- ret >-_jxms_calldriver endp >- >- >-; >-; short far jems_available (void) >-; >-; Have we got an EMS driver? (this comes straight from the EMS 4.0 specs) >-; >-_jems_available proc far >- push si ; save all registers for safety >- push di >- push bx >- push cx >- push dx >- push es >- push ds >- mov ax,3567h ; get interrupt vector 67h >- int 21h >- push cs >- pop ds >- mov di,000ah ; check offs 10 in returned seg >- lea si,ASCII_device_name ; against literal string >- mov cx,8 >- cld >- repe cmpsb >- jne no_ems >- mov ax,1 ; match, it's there >- jmp short avail_done >-no_ems: xor ax,ax ; it's not there >-avail_done: pop ds ; restore registers and exit >- pop es >- pop dx >- pop cx >- pop bx >- pop di >- pop si >- ret >- >-ASCII_device_name db "EMMXXXX0" >- >-_jems_available endp >- >- >-; >-; void far jems_calldriver (EMScontext far *) >-; >-; The EMScontext structure contains values for the AX,DX,BX,SI,DS registers. >-; These are loaded, the EMS trap is performed, and the new values of the >-; AX,DX,BX registers are written back to the context structure. >-; >-_jems_calldriver proc far >- push bp ; linkage >- mov bp,sp >- push si ; save all registers for safety >- push di >- push bx >- push cx >- push dx >- push es >- push ds >- les bx,dword ptr [bp+6] ; get EMScontext pointer >- mov ax,word ptr es:[bx] ; load registers >- mov dx,word ptr es:[bx+2] >- mov si,word ptr es:[bx+6] >- mov ds,word ptr es:[bx+8] >- mov bx,word ptr es:[bx+4] >- int 67h ; call the EMS driver >- mov cx,bx ; save returned BX for a sec >- les bx,dword ptr [bp+6] ; get EMScontext pointer >- mov word ptr es:[bx],ax ; put back ax,dx,bx >- mov word ptr es:[bx+2],dx >- mov word ptr es:[bx+4],cx >- pop ds ; restore registers and exit >- pop es >- pop dx >- pop cx >- pop bx >- pop di >- pop si >- pop bp >- ret >-_jems_calldriver endp >- >-JMEMDOSA_TXT ends >- >- end >diff --git a/jpeg/jmemname.c b/jpeg/jmemname.c >deleted file mode 100644 >--- a/jpeg/jmemname.c >+++ /dev/null >@@ -1,276 +0,0 @@ >-/* >- * jmemname.c >- * >- * Copyright (C) 1992-1997, Thomas G. Lane. >- * This file is part of the Independent JPEG Group's software. >- * For conditions of distribution and use, see the accompanying README file. >- * >- * This file provides a generic implementation of the system-dependent >- * portion of the JPEG memory manager. This implementation assumes that >- * you must explicitly construct a name for each temp file. >- * Also, the problem of determining the amount of memory available >- * is shoved onto the user. >- */ >- >-#define JPEG_INTERNALS >-#include "jinclude.h" >-#include "jpeglib.h" >-#include "jmemsys.h" /* import the system-dependent declarations */ >- >-#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */ >-extern void * malloc JPP((size_t size)); >-extern void free JPP((void *ptr)); >-#endif >- >-#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ >-#define SEEK_SET 0 /* if not, assume 0 is correct */ >-#endif >- >-#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ >-#define READ_BINARY "r" >-#define RW_BINARY "w+" >-#else >-#ifdef VMS /* VMS is very nonstandard */ >-#define READ_BINARY "rb", "ctx=stm" >-#define RW_BINARY "w+b", "ctx=stm" >-#else /* standard ANSI-compliant case */ >-#define READ_BINARY "rb" >-#define RW_BINARY "w+b" >-#endif >-#endif >- >- >-/* >- * Selection of a file name for a temporary file. >- * This is system-dependent! >- * >- * The code as given is suitable for most Unix systems, and it is easily >- * modified for most non-Unix systems. Some notes: >- * 1. The temp file is created in the directory named by TEMP_DIRECTORY. >- * The default value is /usr/tmp, which is the conventional place for >- * creating large temp files on Unix. On other systems you'll probably >- * want to change the file location. You can do this by editing the >- * #define, or (preferred) by defining TEMP_DIRECTORY in jconfig.h. >- * >- * 2. If you need to change the file name as well as its location, >- * you can override the TEMP_FILE_NAME macro. (Note that this is >- * actually a printf format string; it must contain %s and %d.) >- * Few people should need to do this. >- * >- * 3. mktemp() is used to ensure that multiple processes running >- * simultaneously won't select the same file names. If your system >- * doesn't have mktemp(), define NO_MKTEMP to do it the hard way. >- * (If you don't have <errno.h>, also define NO_ERRNO_H.) >- * >- * 4. You probably want to define NEED_SIGNAL_CATCHER so that cjpeg.c/djpeg.c >- * will cause the temp files to be removed if you stop the program early. >- */ >- >-#ifndef TEMP_DIRECTORY /* can override from jconfig.h or Makefile */ >-#define TEMP_DIRECTORY "/usr/tmp/" /* recommended setting for Unix */ >-#endif >- >-static int next_file_num; /* to distinguish among several temp files */ >- >-#ifdef NO_MKTEMP >- >-#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ >-#define TEMP_FILE_NAME "%sJPG%03d.TMP" >-#endif >- >-#ifndef NO_ERRNO_H >-#include <errno.h> /* to define ENOENT */ >-#endif >- >-/* ANSI C specifies that errno is a macro, but on older systems it's more >- * likely to be a plain int variable. And not all versions of errno.h >- * bother to declare it, so we have to in order to be most portable. Thus: >- */ >-#ifndef errno >-extern int errno; >-#endif >- >- >-LOCAL(void) >-select_file_name (char * fname) >-{ >- FILE * tfile; >- >- /* Keep generating file names till we find one that's not in use */ >- for (;;) { >- next_file_num++; /* advance counter */ >- sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); >- if ((tfile = fopen(fname, READ_BINARY)) == NULL) { >- /* fopen could have failed for a reason other than the file not >- * being there; for example, file there but unreadable. >- * If <errno.h> isn't available, then we cannot test the cause. >- */ >-#ifdef ENOENT >- if (errno != ENOENT) >- continue; >-#endif >- break; >- } >- fclose(tfile); /* oops, it's there; close tfile & try again */ >- } >-} >- >-#else /* ! NO_MKTEMP */ >- >-/* Note that mktemp() requires the initial filename to end in six X's */ >-#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ >-#define TEMP_FILE_NAME "%sJPG%dXXXXXX" >-#endif >- >-LOCAL(void) >-select_file_name (char * fname) >-{ >- next_file_num++; /* advance counter */ >- sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); >- mktemp(fname); /* make sure file name is unique */ >- /* mktemp replaces the trailing XXXXXX with a unique string of characters */ >-} >- >-#endif /* NO_MKTEMP */ >- >- >-/* >- * Memory allocation and freeing are controlled by the regular library >- * routines malloc() and free(). >- */ >- >-GLOBAL(void *) >-jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) >-{ >- return (void *) malloc(sizeofobject); >-} >- >-GLOBAL(void) >-jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) >-{ >- free(object); >-} >- >- >-/* >- * "Large" objects are treated the same as "small" ones. >- * NB: although we include FAR keywords in the routine declarations, >- * this file won't actually work in 80x86 small/medium model; at least, >- * you probably won't be able to process useful-size images in only 64KB. >- */ >- >-GLOBAL(void FAR *) >-jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) >-{ >- return (void FAR *) malloc(sizeofobject); >-} >- >-GLOBAL(void) >-jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) >-{ >- free(object); >-} >- >- >-/* >- * This routine computes the total memory space available for allocation. >- * It's impossible to do this in a portable way; our current solution is >- * to make the user tell us (with a default value set at compile time). >- * If you can actually get the available space, it's a good idea to subtract >- * a slop factor of 5% or so. >- */ >- >-#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ >-#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ >-#endif >- >-GLOBAL(long) >-jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, >- long max_bytes_needed, long already_allocated) >-{ >- return cinfo->mem->max_memory_to_use - already_allocated; >-} >- >- >-/* >- * Backing store (temporary file) management. >- * Backing store objects are only used when the value returned by >- * jpeg_mem_available is less than the total space needed. You can dispense >- * with these routines if you have plenty of virtual memory; see jmemnobs.c. >- */ >- >- >-METHODDEF(void) >-read_backing_store (j_common_ptr cinfo, backing_store_ptr info, >- void FAR * buffer_address, >- long file_offset, long byte_count) >-{ >- if (fseek(info->temp_file, file_offset, SEEK_SET)) >- ERREXIT(cinfo, JERR_TFILE_SEEK); >- if (JFREAD(info->temp_file, buffer_address, byte_count) >- != (size_t) byte_count) >- ERREXIT(cinfo, JERR_TFILE_READ); >-} >- >- >-METHODDEF(void) >-write_backing_store (j_common_ptr cinfo, backing_store_ptr info, >- void FAR * buffer_address, >- long file_offset, long byte_count) >-{ >- if (fseek(info->temp_file, file_offset, SEEK_SET)) >- ERREXIT(cinfo, JERR_TFILE_SEEK); >- if (JFWRITE(info->temp_file, buffer_address, byte_count) >- != (size_t) byte_count) >- ERREXIT(cinfo, JERR_TFILE_WRITE); >-} >- >- >-METHODDEF(void) >-close_backing_store (j_common_ptr cinfo, backing_store_ptr info) >-{ >- fclose(info->temp_file); /* close the file */ >- unlink(info->temp_name); /* delete the file */ >-/* If your system doesn't have unlink(), use remove() instead. >- * remove() is the ANSI-standard name for this function, but if >- * your system was ANSI you'd be using jmemansi.c, right? >- */ >- TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); >-} >- >- >-/* >- * Initial opening of a backing-store object. >- */ >- >-GLOBAL(void) >-jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, >- long total_bytes_needed) >-{ >- select_file_name(info->temp_name); >- if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL) >- ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); >- info->read_backing_store = read_backing_store; >- info->write_backing_store = write_backing_store; >- info->close_backing_store = close_backing_store; >- TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); >-} >- >- >-/* >- * These routines take care of any system-dependent initialization and >- * cleanup required. >- */ >- >-GLOBAL(long) >-jpeg_mem_init (j_common_ptr cinfo) >-{ >- next_file_num = 0; /* initialize temp file name generator */ >- return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ >-} >- >-GLOBAL(void) >-jpeg_mem_term (j_common_ptr cinfo) >-{ >- /* no work */ >-} >diff --git a/jpeg/jos2fig.h b/jpeg/jos2fig.h >deleted file mode 100644 >--- a/jpeg/jos2fig.h >+++ /dev/null >@@ -1,45 +0,0 @@ >-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ >-/* ***** BEGIN LICENSE BLOCK ***** >- * Version: MPL 1.1/GPL 2.0/LGPL 2.1 >- * >- * The contents of this file are subject to the Mozilla Public License Version >- * 1.1 (the "License"); you may not use this file except in compliance with >- * the License. You may obtain a copy of the License at >- * http://www.mozilla.org/MPL/ >- * >- * Software distributed under the License is distributed on an "AS IS" basis, >- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License >- * for the specific language governing rights and limitations under the >- * License. >- * >- * The Original Code is mozilla.org code. >- * >- * The Initial Developer of the Original Code is >- * Netscape Communications Corporation. >- * Portions created by the Initial Developer are Copyright (C) 1998 >- * the Initial Developer. All Rights Reserved. >- * >- * Contributor(s): >- * >- * Alternatively, the contents of this file may be used under the terms of >- * either the GNU General Public License Version 2 or later (the "GPL"), or >- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), >- * in which case the provisions of the GPL or the LGPL are applicable instead >- * of those above. If you wish to allow use of your version of this file only >- * under the terms of either the GPL or the LGPL, and not to allow others to >- * use your version of this file under the terms of the MPL, indicate your >- * decision by deleting the provisions above and replace them with the notice >- * and other provisions required by the GPL or the LGPL. If you do not delete >- * the provisions above, a recipient may use your version of this file under >- * the terms of any one of the MPL, the GPL or the LGPL. >- * >- * ***** END LICENSE BLOCK ***** */ >- >-#ifndef __jos2fig_h__ >-#define __jos2fig_h__ >- >-/* >-** Place holder for the OS/2 code that might actually make it into the trunk someday. Maybe. >-*/ >- >-#endif /* __jos2fig_h__ */ >diff --git a/jpeg/jwinfig.h b/jpeg/jwinfig.h >deleted file mode 100644 >--- a/jpeg/jwinfig.h >+++ /dev/null >@@ -1,48 +0,0 @@ >-/* jconfig.mc6 --- jconfig.h for Microsoft C on MS-DOS, version 6.00A & up. */ >-/* see jconfig.doc for explanations */ >- >-/* this is a hack */ >-#define HAVE_BOOLEAN >-#ifndef __RPCNDR_H__ >-typedef unsigned char boolean; >-#endif >- >-#define HAVE_PROTOTYPES >-#define HAVE_UNSIGNED_CHAR >-#define HAVE_UNSIGNED_SHORT >-/* #define void char */ >-/* #define const */ >-#undef CHAR_IS_UNSIGNED >-#define HAVE_STDDEF_H >-#define HAVE_STDLIB_H >-#undef NEED_BSD_STRINGS >-#undef NEED_SYS_TYPES_H >-#undef NEED_FAR_POINTERS /* for small or medium memory model */ >-#undef NEED_SHORT_EXTERNAL_NAMES >-#undef INCOMPLETE_TYPES_BROKEN >- >-#ifdef JPEG_INTERNALS >- >-#undef RIGHT_SHIFT_IS_UNSIGNED >- >-#define USE_MSDOS_MEMANSI >- >-#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */ >- >-#endif /* JPEG_INTERNALS */ >- >-#ifdef JPEG_CJPEG_DJPEG >- >-#define BMP_SUPPORTED /* BMP image file format */ >-#define GIF_SUPPORTED /* GIF image file format */ >-#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ >-#undef RLE_SUPPORTED /* Utah RLE image file format */ >-#define TARGA_SUPPORTED /* Targa image file format */ >- >-#define TWO_FILE_COMMANDLINE >-#define USE_SETMODE /* Microsoft has setmode() */ >-#define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */ >-#undef DONT_USE_B_MODE >-#undef PROGRESS_REPORT /* optional */ >- >-#endif /* JPEG_CJPEG_DJPEG */ >diff --git a/jpeg/makefile.gen b/jpeg/makefile.gen >deleted file mode 100644 >--- a/jpeg/makefile.gen >+++ /dev/null >@@ -1,274 +0,0 @@ >-# Generated automatically from makefile.cfg by configure. >-# Makefile for Independent JPEG Group's software >- >-# makefile.cfg is edited by configure to produce a custom Makefile. >- >-# Read installation instructions before saying "make" !! >- >-# For compiling with source and object files in different directories. >-srcdir = $(VPATH) >- >-# Where to install the programs and man pages. >-prefix = /usr/local >-exec_prefix = ${prefix} >-bindir = $(exec_prefix)/bin >-libdir = $(exec_prefix)/lib >-includedir = $(prefix)/include >-binprefix = >-manprefix = >-manext = 1 >-mandir = $(prefix)/man/man$(manext) >- >-# The name of your C compiler: >-CC= cc >- >-# You may need to adjust these cc options: >-CFLAGS= -O3 -I$(srcdir) >-# Generally, we recommend defining any configuration symbols in jconfig.h, >-# NOT via -D switches here. >-# However, any special defines for ansi2knr.c may be included here: >-ANSI2KNRFLAGS= >- >-# Link-time cc options: >-LDFLAGS= >- >-# To link any special libraries, add the necessary -l commands here. >-LDLIBS= >- >-# Put here the object file name for the correct system-dependent memory >-# manager file. For Unix this is usually jmemnobs.o, but you may want >-# to use jmemansi.o or jmemname.o if you have limited swap space. >-SYSDEPMEM= jmemnobs.o >- >-# miscellaneous OS-dependent stuff >-SHELL= /bin/sh >-# linker >-LN= $(CC) >-# file deletion command >-RM= rm -f >-# file rename command >-MV= mv >-# library (.a) file creation command >-AR= ar rc >-# second step in .a creation (use "touch" if not needed) >-AR2= ranlib >-# installation program >-INSTALL= cp >-INSTALL_PROGRAM= ${INSTALL} >-INSTALL_DATA= ${INSTALL} >- >-# End of configurable options. >- >- >-# source files: JPEG library proper >-LIBSOURCES= jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ >- jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ >- jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ >- jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ >- jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ >- jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ >- jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ >- jquant2.c jutils.c jmemmgr.c jmemansi.c jmemname.c jmemnobs.c \ >- jmemdos.c >-# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom >-APPSOURCES= cjpeg.c djpeg.c jpegtran.c cdjpeg.c rdcolmap.c rdswitch.c \ >- rdjpgcom.c wrjpgcom.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \ >- wrtarga.c rdbmp.c wrbmp.c rdrle.c wrrle.c >-SOURCES= $(LIBSOURCES) $(APPSOURCES) >-# files included by source files >-INCLUDES= jchuff.h jdhuff.h jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ >- jpegint.h jpeglib.h jversion.h cdjpeg.h cderror.h >-# documentation, test, and support files >-DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 \ >- wrjpgcom.1 wizard.doc example.c libjpeg.doc structure.doc \ >- coderules.doc filelist.doc change.log >-MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \ >- makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \ >- makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \ >- makefile.vms makvms.opt >-CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \ >- jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms >-OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm >-TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg testprog.jpg \ >- testimgp.jpg >-DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \ >- $(OTHERFILES) $(TESTFILES) >-# library object files common to compression and decompression >-COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) >-# compression library object files >-CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ >- jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ >- jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ >- jfdctint.o >-# decompression library object files >-DLIBOBJECTS= jdapimin.o jdapistd.o jdatasrc.o jdmaster.o \ >- jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ >- jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ >- jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o >-# These objectfiles are included in libjpeg.a >-LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) >-# object files for sample applications (excluding library files) >-COBJECTS= cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o \ >- cdjpeg.o >-DOBJECTS= djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o \ >- cdjpeg.o >-TROBJECTS= jpegtran.o rdswitch.o cdjpeg.o >- >-all: libjpeg.a >- >-realall: libjpeg.a cjpeg djpeg jpegtran rdjpgcom wrjpgcom >- >-# This rule causes ansi2knr to be invoked. >-# .c.o: >-# ./ansi2knr $(srcdir)/$*.c T$*.c >-# $(CC) $(CFLAGS) -c T$*.c >-# $(RM) T$*.c $*.o >-# $(MV) T$*.o $*.o >- >-ansi2knr: ansi2knr.c >- $(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c >- >-# Decompression-only library >-libjpeg.a: $(DLIBOBJECTS) $(COMOBJECTS) >- $(RM) libjpeg.a >- $(AR) libjpeg.a $(DLIBOBJECTS) $(COMOBJECTS) >- $(AR2) libjpeg.a >- >-cjpeg: $(COBJECTS) libjpeg.a >- $(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) libjpeg.a $(LDLIBS) >- >-djpeg: $(DOBJECTS) libjpeg.a >- $(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) libjpeg.a $(LDLIBS) >- >-jpegtran: $(TROBJECTS) libjpeg.a >- $(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) libjpeg.a $(LDLIBS) >- >-rdjpgcom: rdjpgcom.o >- $(LN) $(LDFLAGS) -o rdjpgcom rdjpgcom.o $(LDLIBS) >- >-wrjpgcom: wrjpgcom.o >- $(LN) $(LDFLAGS) -o wrjpgcom wrjpgcom.o $(LDLIBS) >- >-jconfig.h: jconfig.doc >- echo You must prepare a system-dependent jconfig.h file. >- echo Please read the installation directions in install.doc. >- exit 1 >- >-install: cjpeg djpeg jpegtran rdjpgcom wrjpgcom >- $(INSTALL_PROGRAM) cjpeg $(bindir)/$(binprefix)cjpeg >- $(INSTALL_PROGRAM) djpeg $(bindir)/$(binprefix)djpeg >- $(INSTALL_PROGRAM) jpegtran $(bindir)/$(binprefix)jpegtran >- $(INSTALL_PROGRAM) rdjpgcom $(bindir)/$(binprefix)rdjpgcom >- $(INSTALL_PROGRAM) wrjpgcom $(bindir)/$(binprefix)wrjpgcom >- $(INSTALL_DATA) $(srcdir)/cjpeg.1 $(mandir)/$(manprefix)cjpeg.$(manext) >- $(INSTALL_DATA) $(srcdir)/djpeg.1 $(mandir)/$(manprefix)djpeg.$(manext) >- $(INSTALL_DATA) $(srcdir)/jpegtran.1 $(mandir)/$(manprefix)jpegtran.$(manext) >- $(INSTALL_DATA) $(srcdir)/rdjpgcom.1 $(mandir)/$(manprefix)rdjpgcom.$(manext) >- $(INSTALL_DATA) $(srcdir)/wrjpgcom.1 $(mandir)/$(manprefix)wrjpgcom.$(manext) >- >-install-lib: libjpeg.a install-headers >- $(INSTALL_DATA) libjpeg.a $(libdir)/$(binprefix)libjpeg.a >- >-install-headers: jconfig.h >- $(INSTALL_DATA) jconfig.h $(includedir)/jconfig.h >- $(INSTALL_DATA) $(srcdir)/jpeglib.h $(includedir)/jpeglib.h >- $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(includedir)/jmorecfg.h >- $(INSTALL_DATA) $(srcdir)/jerror.h $(includedir)/jerror.h >- >-clean: >- $(RM) *.o cjpeg djpeg jpegtran libjpeg.a rdjpgcom wrjpgcom >- $(RM) ansi2knr core testout* config.log config.status >- >-distribute: >- $(RM) jpegsrc.tar* >- tar cvf jpegsrc.tar $(DISTFILES) >- compress -v jpegsrc.tar >- >-test: cjpeg djpeg jpegtran >- $(RM) testout* >- ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg >- ./djpeg -dct int -gif -outfile testout.gif $(srcdir)/testorig.jpg >- ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm >- ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg >- ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm >- ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg >- cmp $(srcdir)/testimg.ppm testout.ppm >- cmp $(srcdir)/testimg.gif testout.gif >- cmp $(srcdir)/testimg.jpg testout.jpg >- cmp $(srcdir)/testimg.ppm testoutp.ppm >- cmp $(srcdir)/testimgp.jpg testoutp.jpg >- cmp $(srcdir)/testorig.jpg testoutt.jpg >- >-check: test >- >-# GNU Make likes to know which target names are not really files to be made: >-.PHONY: all install install-lib install-headers clean distribute test check >- >- >-jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h >-jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h >-jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h >-jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h >-jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h >-jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h >-jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h >-jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h >-jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h >-jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h >-jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h >-jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h >-jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h >-jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h >-jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h >-jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h >-jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h >-jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h >-jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h >-jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h >-jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h >-jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h >-cjpeg.o: cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h >-djpeg.o: djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h >-jpegtran.o: jpegtran.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h >-cdjpeg.o: cdjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-rdcolmap.o: rdcolmap.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-rdswitch.o: rdswitch.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-rdjpgcom.o: rdjpgcom.c jinclude.h jconfig.h >-wrjpgcom.o: wrjpgcom.c jinclude.h jconfig.h >-rdppm.o: rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-wrppm.o: wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-rdgif.o: rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-wrgif.o: wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-rdtarga.o: rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-wrtarga.o: wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-rdbmp.o: rdbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-wrbmp.o: wrbmp.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-rdrle.o: rdrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >-wrrle.o: wrrle.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h >diff --git a/jpeg/netscape_mods.doc b/jpeg/netscape_mods.doc >deleted file mode 100644 >--- a/jpeg/netscape_mods.doc >+++ /dev/null >@@ -1,52 +0,0 @@ >-***** BEGIN LICENSE BLOCK ***** >-Version: MPL 1.1/GPL 2.0/LGPL 2.1 >- >-The contents of this file are subject to the Mozilla Public License Version >-1.1 (the "License"); you may not use this file except in compliance with >-the License. You may obtain a copy of the License at >-http://www.mozilla.org/MPL/ >- >-Software distributed under the License is distributed on an "AS IS" basis, >-WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License >-for the specific language governing rights and limitations under the >-License. >- >-The Original Code is mozilla.org code. >- >-The Initial Developer of the Original Code is >-Netscape Communications Corporation >-Portions created by the Initial Developer are Copyright (C) 1998 >-the Initial Developer. All Rights Reserved. >- >-Contributor(s): >- >-Alternatively, the contents of this file may be used under the terms of >-either the GNU General Public License Version 2 or later (the "GPL"), or >-the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), >-in which case the provisions of the GPL or the LGPL are applicable instead >-of those above. If you wish to allow use of your version of this file only >-under the terms of either the GPL or the LGPL, and not to allow others to >-use your version of this file under the terms of the MPL, indicate your >-decision by deleting the provisions above and replace them with the notice >-and other provisions required by the GPL or the LGPL. If you do not delete >-the provisions above, a recipient may use your version of this file under >-the terms of any one of the MPL, the GPL or the LGPL. >- >-***** END LICENSE BLOCK ***** >- >-This directory contains a subset of the IJG JPEG library. Among other >-omissions, most of the original IJG documentation has been deleted. >-You can find the full IJG distribution at the archive sites mentioned in >-the README file. Please note that the IJG code does not fall under the >-Netscape NPL, but is freely distributable under its own copyright terms >-(see README). >- >-Several files have been modified to allow incorporation of the IJG code >-into the Netscape environment. As of this writing, jconfig.h, jmorecfg.h, >-and jerror.c contain Netscape-specific changes. In addition, we have created >-our own makefiles following Netscape conventions, rather than using any of >-those provided by IJG. >- >-There are some other changes herein, such as MMX-specific optimizations, >-which should eventually make their way back into the standard IJG >-distribution. >diff --git a/modules/libjpeg-turbo/BUILDING.txt b/modules/libjpeg-turbo/BUILDING.txt >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/BUILDING.txt >@@ -0,0 +1,328 @@ >+******************************************************************************* >+** Building on Unix Platforms, Cygwin, and MinGW >+******************************************************************************* >+ >+================== >+Build Requirements >+================== >+ >+-- autoconf 2.56 or later >+-- automake 1.7 or later >+-- libtool 1.4 or later >+ * If using MinGW, these can be obtained by installing the MSYS DTK >+ >+-- NASM >+ * 0.98 or later is required for a 32-bit build >+ * NASM 2.05 or later is required for a 64-bit build >+ * NASM 2.07 or later is required for a 64-bit build on OS/X. This can be >+ obtained from MacPorts (http://www.macports.org/). >+ >+ The NASM 2.05 RPMs do not work on older Linux systems, such as Enterprise >+ Linux 4. On such systems, you can easily build and install NASM 2.05 >+ from the source RPM by executing the following as root: >+ >+ ARCH=`uname -m` >+ wget http://www.nasm.us/pub/nasm/releasebuilds/2.05.01/nasm-2.05.01-1.src.rpm >+ rpmbuild --rebuild nasm-2.05.01-1.src.rpm >+ rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-2.05.01-1.$ARCH.rpm >+ >+ NOTE: NASM build will fail if texinfo is not installed. >+ >+-- GCC v4.1 or later recommended for best performance >+ >+====================== >+Building libjpeg-turbo >+====================== >+ >+The following procedure will build libjpeg-turbo on Linux, FreeBSD, 32-bit >+OS X, and Solaris/x86 systems (on Solaris, this generates a 32-bit library. >+See below for 64-bit build instructions.) >+ >+ cd libjpeg-turbo >+ autoreconf -fiv >+ sh ./configure >+ make >+ >+NOTE: Running autoreconf is only necessary if building libjpeg-turbo from the >+SVN repository. >+ >+This will generate the following files under .libs/ >+ >+ libjpeg.a >+ Static link library for libjpeg-turbo >+ >+ libjpeg.so.62.0.0 (Linux, Solaris) >+ libjpeg.62.dylib (OS X) >+ libjpeg-62.dll (MinGW) >+ cygjpeg-62.dll (Cygwin) >+ Shared library for libjpeg-turbo >+ >+ libjpeg.so (Linux, Solaris) >+ libjpeg.dylib (OS X) >+ libjpeg.dll.a (Cygwin, MinGW) >+ Development stub for libjpeg-turbo shared library >+ >+ libturbojpeg.a >+ Static link library for TurboJPEG/OSS >+ >+ libturbojpeg.so (Linux, Solaris) >+ libturbojpeg.dylib (OS X) >+ Shared library and development stub for TurboJPEG/OSS >+ >+ libturbojpeg.dll (MinGW) >+ cygturbojpeg.dll (Cygwin) >+ Shared library for TurboJPEG/OSS >+ >+ libturbojpeg.dll.a (Cygwin, MinGW) >+ Development stub for TurboJPEG/OSS shared library >+ >+======================== >+Installing libjpeg-turbo >+======================== >+ >+If you intend to install these libraries and the associated header files, then >+replace 'make' in the instructions above with >+ >+ make install prefix={base dir} libdir={library directory} >+ >+For example, >+ >+ make install prefix=/usr/local libdir=/usr/local/lib64 >+ >+will install the header files in /usr/local/include and the library files in >+/usr/local/lib64. If 'prefix' and 'libdir' are not specified, then the default >+is to install the header files in /opt/libjpeg-turbo/include and the library >+files in /opt/libjpeg-turbo/lib. >+ >+NOTE: You can specify a prefix of /usr and a libdir of, for instance, >+/usr/lib64 to overwrite the system's version of libjpeg. If you do this, >+however, then be sure to BACK UP YOUR SYSTEM'S INSTALLATION OF LIBJPEG before >+overwriting it. It is recommended that you instead install libjpeg-turbo into >+a non-system directory and manipulate the LD_LIBRARY_PATH or create sym links >+to force applications to use libjpeg-turbo instead of libjpeg. See >+README-turbo.txt for more information. >+ >+============= >+Build Recipes >+============= >+ >+32-bit Library Build on 64-bit Linux >+------------------------------------ >+ >+Add >+ >+ --host i686-pc-linux-gnu CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS=-m32 >+ >+to the configure command line. >+ >+ >+64-bit Library Build on 64-bit OS/X >+----------------------------------- >+ >+Add >+ >+ --host x86_64-apple-darwin NASM=/opt/local/bin/nasm >+ >+to the configure command line. NASM 2.07 or later from MacPorts must be >+installed. >+ >+ >+32-bit Library Build on 64-bit OS/X >+----------------------------------- >+ >+Add >+ >+ CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS=-m32 >+ >+to the configure command line. >+ >+ >+64-bit Backward-Compatible Library Build on 64-bit OS/X >+------------------------------------------------------- >+ >+Add >+ >+ --host x86_64-apple-darwin NASM=/opt/local/bin/nasm \ >+ CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ >+ -mmacosx-version-min=10.4 -O3' \ >+ CXXFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ >+ -mmacosx-version-min=10.4 -O3' \ >+ LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ >+ -mmacosx-version-min=10.4' >+ >+to the configure command line. The OS X 10.4 SDK, and NASM 2.07 or later from >+MacPorts, must be installed. >+ >+ >+32-bit Backward-Compatible Library Build on OS/X >+------------------------------------------------ >+ >+Add >+ >+ CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ >+ -mmacosx-version-min=10.4 -O3 -m32' \ >+ CXXFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ >+ -mmacosx-version-min=10.4 -O3 -m32' \ >+ LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ >+ -mmacosx-version-min=10.4 -m32' >+ >+to the configure command line. The OS X 10.4 SDK must be installed. >+ >+ >+64-bit Library Build on 64-bit Solaris >+-------------------------------------- >+ >+Add >+ >+ --host x86_64-pc-solaris CFLAGS='-O3 -m64' CXXFLAGS='-O3 -m64' LDFLAGS=-m64 >+ >+to the configure command line. >+ >+ >+32-bit Library Build on 64-bit FreeBSD >+-------------------------------------- >+ >+Add >+ >+ --host i386-unknown-freebsd CC='gcc -B /usr/lib32' CXX='g++ -B/usr/lib32' \ >+ CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS='-B/usr/lib32' >+ >+to the configure command line. NASM 2.07 or later from FreeBSD ports must be >+installed. >+ >+ >+MinGW Build on Cygwin >+--------------------- >+ >+Add >+ >+ --host mingw32 >+ >+to the configure command line. This will produce libraries which do not >+depend on cygwin1.dll or other Cygwin DLL's. >+ >+ >+Sun Studio >+---------- >+ >+Add >+ >+ CC=cc CXX=CC >+ >+to the configure command line. libjpeg-turbo will automatically be built with >+the maximum optimization level (-xO5) unless you override CFLAGS and CXXFLAGS. >+ >+To build a 64-bit version of libjpeg-turbo using Sun Studio, add >+ >+ --host x86_64-pc-solaris CC=cc CXX=CC CFLAGS='-xO5 -m64' \ >+ CXXFLAGS='-xO5 -m64' LDFLAGS=-m64 >+ >+to the configure command line. >+ >+ >+******************************************************************************* >+** Building on Windows (Visual C++) >+******************************************************************************* >+ >+================== >+Build Requirements >+================== >+ >+-- GNU Make v3.7 or later >+ * Can be found in MSYS (http://www.mingw.org/download.shtml) or >+ Cygwin (http://www.cygwin.com/) >+ >+-- Windows SDK for Windows Server 2008 and .NET Framework 3.5 (or a later >+ version) >+ >+ http://msdn.microsoft.com/en-us/windows/dd146047.aspx >+ >+ * The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and >+ everything necessary to build libjpeg-turbo. If you do not already have >+ Visual C++ installed, then this is the recommended solution. Also tested >+ with Microsoft Visual C++ 2008 Express Edition (both are free downloads.) >+ * Add the compiler and SDK binary directories (for instance, >+ c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN; >+ c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE; >+ c:\Program Files\Microsoft SDKs\Windows\v6.1\bin) >+ to the system or user PATH environment variable prior to building >+ libjpeg-turbo. >+ * Add the compiler and SDK include directories (for instance, >+ c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE; >+ c:\Program Files\Microsoft SDKs\Windows\v6.1\include) >+ to the system or user INCLUDE environment variable prior to building >+ libjpeg-turbo. >+ * Add the compiler library directory (for instance, >+ c:\Program Files\Microsoft Visual Studio 9.0\VC\LIB; >+ c:\Program Files\Microsoft SDKs\Windows\v6.1\lib) >+ to the system or user LIB environment variable prior to building >+ libjpeg-turbo. >+ >+-- NASM (http://www.nasm.us/) 0.98 or later (NASM 2.05 or later is required for >+ a 64-bit build) >+ >+====================== >+Building libjpeg-turbo >+====================== >+ >+ cd libjpeg-turbo >+ make -f win/Makefile >+ >+This will generate the following files under libjpeg-turbo\windows\: >+ >+ jpeg-static.lib Static link library for libjpeg-turbo >+ jpeg62.dll Shared library for libjpeg-turbo >+ jpeg.lib Development stub for libjpeg-turbo shared library >+ turbojpeg-static.lib Static link library for TurboJPEG/OSS >+ turbojpeg.dll Shared library for TurboJPEG/OSS >+ turbojpeg.lib Development stub for TurboJPEG/OSS shared library >+ >+If a 64-bit Windows platform is detected, then the build system will attempt >+to build a 64-bit version of libjpeg-turbo. You can override this by running >+ >+ make -f win/Makefile WIN64=no >+ >+ >+******************************************************************************* >+** Creating Release Packages >+******************************************************************************* >+ >+The following commands can be used to create various types of release packages: >+ >+make rpm >+ >+ Create RedHat-style binary RPM package. Requires RPM v4 or later. >+ >+make srpm >+ >+ This runs 'make dist' to create a pristine source tarball, then creates a >+ RedHat-style source RPM package from the tarball. Requires RPM v4 or later. >+ >+make deb >+ >+ Create Debian-style binary package. Requires dpkg. >+ >+make dmg >+ >+ Create Macintosh package/disk image. This requires the PackageMaker >+ application, which must be installed in /Developer/Applications/Utilities. >+ >+make udmg >+ >+ On 64-bit OS X systems, this creates a version of the Macintosh package and >+ disk image which contains universal i386/x86-64 binaries. The 32-bit fork of >+ these binaries is backward compatible with OS X 10.4 and later. The 64-bit >+ fork can be made backward compatible as well by using the instructions in >+ the "Build Recipes" section. OS X 10.4 compatibility SDK required. >+ >+make nsi >+ >+ When using MinGW, this creates a Win32 installer for the GCC version of the >+ libjpeg-turbo SDK. This requires the Nullsoft Install System >+ (http://nsis.sourceforge.net/.) makensis.exe should be in your PATH. >+ >+make -f win/Makefile nsi >+ >+ This creates a Win32 installer for the Visual C++ version of the >+ libjpeg-turbo SDK. This requires the Nullsoft Install System >+ (http://nsis.sourceforge.net/.) makensis.exe should be in your PATH. >diff --git a/modules/libjpeg-turbo/ChangeLog.txt b/modules/libjpeg-turbo/ChangeLog.txt >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/ChangeLog.txt >@@ -0,0 +1,48 @@ >+Significant changes since 1.0.0 >+=============================== >+ >+[1] The Huffman decoder will now handle erroneous Huffman codes (for instance, >+from a corrupt JPEG image.) Previously, these would cause libjpeg-turbo to >+crash under certain circumstances. >+ >+ >+Significant changes since 0.0.93 >+================================ >+ >+[1] 2983700: Further FreeBSD build tweaks (no longer necessary to specify >+--host when configuring on a 64-bit system) >+ >+[2] Created sym. links in the Unix/Linux packages so that the TurboJPEG >+include file can always be found in /opt/libjpeg-turbo/include, the 32-bit >+static libraries can always be found in /opt/libjpeg-turbo/lib32, and the >+64-bit static libraries can always be found in /opt/libjpeg-turbo/lib64. >+ >+[3] The Unix/Linux distribution packages now include the libjpeg run-time >+programs (cjpeg, etc.) and man pages. >+ >+[4] Created a 32-bit supplementary package for amd64 Debian systems which >+contains just the 32-bit libjpeg-turbo libraries. >+ >+[5] Moved the libraries from */lib32 to */lib in the i386 Debian package. >+ >+[6] Include distribution package for Cygwin >+ >+[7] No longer necessary to specify --without-simd on non-x86 architectures, and >+unit tests now work on those architectures. >+ >+ >+Significant changes since 0.0.91 >+================================ >+ >+[1] 2982659, Fixed x86-64 build on FreeBSD systems >+ >+[2] 2988188: Added support for Windows 64-bit systems >+ >+ >+Significant changes since 0.0.90 >+================================ >+ >+[1] Added documentation to .deb packages >+ >+[2] 2968313: Fixed data corruption issues when decompressing large JPEG images >+and/or using buffered I/O with the libjpeg-turbo decompressor >diff --git a/modules/libjpeg-turbo/LGPL.txt b/modules/libjpeg-turbo/LGPL.txt >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/LGPL.txt >@@ -0,0 +1,504 @@ >+ GNU LESSER GENERAL PUBLIC LICENSE >+ Version 2.1, February 1999 >+ >+ Copyright (C) 1991, 1999 Free Software Foundation, Inc. >+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+ Everyone is permitted to copy and distribute verbatim copies >+ of this license document, but changing it is not allowed. >+ >+[This is the first released version of the Lesser GPL. It also counts >+ as the successor of the GNU Library Public License, version 2, hence >+ the version number 2.1.] >+ >+ Preamble >+ >+ The licenses for most software are designed to take away your >+freedom to share and change it. By contrast, the GNU General Public >+Licenses are intended to guarantee your freedom to share and change >+free software--to make sure the software is free for all its users. >+ >+ This license, the Lesser General Public License, applies to some >+specially designated software packages--typically libraries--of the >+Free Software Foundation and other authors who decide to use it. You >+can use it too, but we suggest you first think carefully about whether >+this license or the ordinary General Public License is the better >+strategy to use in any particular case, based on the explanations below. >+ >+ When we speak of free software, we are referring to freedom of use, >+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 and use pieces of >+it in new free programs; and that you are informed that you can do >+these things. >+ >+ To protect your rights, we need to make restrictions that forbid >+distributors to deny you these rights or to ask you to surrender these >+rights. These restrictions translate to certain responsibilities for >+you if you distribute copies of the library or if you modify it. >+ >+ For example, if you distribute copies of the library, whether gratis >+or for a fee, you must give the recipients all the rights that we gave >+you. You must make sure that they, too, receive or can get the source >+code. If you link other code with the library, you must provide >+complete object files to the recipients, so that they can relink them >+with the library after making changes to the library and recompiling >+it. And you must show them these terms so they know their rights. >+ >+ We protect your rights with a two-step method: (1) we copyright the >+library, and (2) we offer you this license, which gives you legal >+permission to copy, distribute and/or modify the library. >+ >+ To protect each distributor, we want to make it very clear that >+there is no warranty for the free library. Also, if the library is >+modified by someone else and passed on, the recipients should know >+that what they have is not the original version, so that the original >+author's reputation will not be affected by problems that might be >+introduced by others. >+ >+ Finally, software patents pose a constant threat to the existence of >+any free program. We wish to make sure that a company cannot >+effectively restrict the users of a free program by obtaining a >+restrictive license from a patent holder. Therefore, we insist that >+any patent license obtained for a version of the library must be >+consistent with the full freedom of use specified in this license. >+ >+ Most GNU software, including some libraries, is covered by the >+ordinary GNU General Public License. This license, the GNU Lesser >+General Public License, applies to certain designated libraries, and >+is quite different from the ordinary General Public License. We use >+this license for certain libraries in order to permit linking those >+libraries into non-free programs. >+ >+ When a program is linked with a library, whether statically or using >+a shared library, the combination of the two is legally speaking a >+combined work, a derivative of the original library. The ordinary >+General Public License therefore permits such linking only if the >+entire combination fits its criteria of freedom. The Lesser General >+Public License permits more lax criteria for linking other code with >+the library. >+ >+ We call this license the "Lesser" General Public License because it >+does Less to protect the user's freedom than the ordinary General >+Public License. It also provides other free software developers Less >+of an advantage over competing non-free programs. These disadvantages >+are the reason we use the ordinary General Public License for many >+libraries. However, the Lesser license provides advantages in certain >+special circumstances. >+ >+ For example, on rare occasions, there may be a special need to >+encourage the widest possible use of a certain library, so that it becomes >+a de-facto standard. To achieve this, non-free programs must be >+allowed to use the library. A more frequent case is that a free >+library does the same job as widely used non-free libraries. In this >+case, there is little to gain by limiting the free library to free >+software only, so we use the Lesser General Public License. >+ >+ In other cases, permission to use a particular library in non-free >+programs enables a greater number of people to use a large body of >+free software. For example, permission to use the GNU C Library in >+non-free programs enables many more people to use the whole GNU >+operating system, as well as its variant, the GNU/Linux operating >+system. >+ >+ Although the Lesser General Public License is Less protective of the >+users' freedom, it does ensure that the user of a program that is >+linked with the Library has the freedom and the wherewithal to run >+that program using a modified version of the Library. >+ >+ The precise terms and conditions for copying, distribution and >+modification follow. Pay close attention to the difference between a >+"work based on the library" and a "work that uses the library". The >+former contains code derived from the library, whereas the latter must >+be combined with the library in order to run. >+ >+ GNU LESSER GENERAL PUBLIC LICENSE >+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION >+ >+ 0. This License Agreement applies to any software library or other >+program which contains a notice placed by the copyright holder or >+other authorized party saying it may be distributed under the terms of >+this Lesser General Public License (also called "this License"). >+Each licensee is addressed as "you". >+ >+ A "library" means a collection of software functions and/or data >+prepared so as to be conveniently linked with application programs >+(which use some of those functions and data) to form executables. >+ >+ The "Library", below, refers to any such software library or work >+which has been distributed under these terms. A "work based on the >+Library" means either the Library or any derivative work under >+copyright law: that is to say, a work containing the Library or a >+portion of it, either verbatim or with modifications and/or translated >+straightforwardly into another language. (Hereinafter, translation is >+included without limitation in the term "modification".) >+ >+ "Source code" for a work means the preferred form of the work for >+making modifications to it. For a library, 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 library. >+ >+ Activities other than copying, distribution and modification are not >+covered by this License; they are outside its scope. The act of >+running a program using the Library is not restricted, and output from >+such a program is covered only if its contents constitute a work based >+on the Library (independent of the use of the Library in a tool for >+writing it). Whether that is true depends on what the Library does >+and what the program that uses the Library does. >+ >+ 1. You may copy and distribute verbatim copies of the Library's >+complete 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 distribute a copy of this License along with the >+Library. >+ >+ 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 Library or any portion >+of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. >+ >+ b) You must cause the files modified to carry prominent notices >+ stating that you changed the files and the date of any change. >+ >+ c) You must cause the whole of the work to be licensed at no >+ charge to all third parties under the terms of this License. >+ >+ d) If a facility in the modified Library refers to a function or a >+ table of data to be supplied by an application program that uses >+ the facility, other than as an argument passed when the facility >+ is invoked, then you must make a good faith effort to ensure that, >+ in the event an application does not supply such function or >+ table, the facility still operates, and performs whatever part of >+ its purpose remains meaningful. >+ >+ (For example, a function in a library to compute square roots has >+ a purpose that is entirely well-defined independent of the >+ application. Therefore, Subsection 2d requires that any >+ application-supplied function or table used by this function must >+ be optional: if the application does not supply it, the square >+ root function must still compute square roots.) >+ >+These requirements apply to the modified work as a whole. If >+identifiable sections of that work are not derived from the Library, >+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 Library, 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 Library. >+ >+In addition, mere aggregation of another work not based on the Library >+with the Library (or with a work based on the Library) on a volume of >+a storage or distribution medium does not bring the other work under >+the scope of this License. >+ >+ 3. You may opt to apply the terms of the ordinary GNU General Public >+License instead of this License to a given copy of the Library. To do >+this, you must alter all the notices that refer to this License, so >+that they refer to the ordinary GNU General Public License, version 2, >+instead of to this License. (If a newer version than version 2 of the >+ordinary GNU General Public License has appeared, then you can specify >+that version instead if you wish.) Do not make any other change in >+these notices. >+ >+ Once this change is made in a given copy, it is irreversible for >+that copy, so the ordinary GNU General Public License applies to all >+subsequent copies and derivative works made from that copy. >+ >+ This option is useful when you wish to copy part of the code of >+the Library into a program that is not a library. >+ >+ 4. You may copy and distribute the Library (or a portion or >+derivative of it, under Section 2) in object code or executable form >+under the terms of Sections 1 and 2 above provided that you 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. >+ >+ If distribution of 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 satisfies the requirement to >+distribute the source code, even though third parties are not >+compelled to copy the source along with the object code. >+ >+ 5. A program that contains no derivative of any portion of the >+Library, but is designed to work with the Library by being compiled or >+linked with it, is called a "work that uses the Library". Such a >+work, in isolation, is not a derivative work of the Library, and >+therefore falls outside the scope of this License. >+ >+ However, linking a "work that uses the Library" with the Library >+creates an executable that is a derivative of the Library (because it >+contains portions of the Library), rather than a "work that uses the >+library". The executable is therefore covered by this License. >+Section 6 states terms for distribution of such executables. >+ >+ When a "work that uses the Library" uses material from a header file >+that is part of the Library, the object code for the work may be a >+derivative work of the Library even though the source code is not. >+Whether this is true is especially significant if the work can be >+linked without the Library, or if the work is itself a library. The >+threshold for this to be true is not precisely defined by law. >+ >+ If such an object file uses only numerical parameters, data >+structure layouts and accessors, and small macros and small inline >+functions (ten lines or less in length), then the use of the object >+file is unrestricted, regardless of whether it is legally a derivative >+work. (Executables containing this object code plus portions of the >+Library will still fall under Section 6.) >+ >+ Otherwise, if the work is a derivative of the Library, you may >+distribute the object code for the work under the terms of Section 6. >+Any executables containing that work also fall under Section 6, >+whether or not they are linked directly with the Library itself. >+ >+ 6. As an exception to the Sections above, you may also combine or >+link a "work that uses the Library" with the Library to produce a >+work containing portions of the Library, and distribute that work >+under terms of your choice, provided that the terms permit >+modification of the work for the customer's own use and reverse >+engineering for debugging such modifications. >+ >+ You must give prominent notice with each copy of the work that the >+Library is used in it and that the Library and its use are covered by >+this License. You must supply a copy of this License. If the work >+during execution displays copyright notices, you must include the >+copyright notice for the Library among them, as well as a reference >+directing the user to the copy of this License. Also, you must do one >+of these things: >+ >+ a) Accompany the work with the complete corresponding >+ machine-readable source code for the Library including whatever >+ changes were used in the work (which must be distributed under >+ Sections 1 and 2 above); and, if the work is an executable linked >+ with the Library, with the complete machine-readable "work that >+ uses the Library", as object code and/or source code, so that the >+ user can modify the Library and then relink to produce a modified >+ executable containing the modified Library. (It is understood >+ that the user who changes the contents of definitions files in the >+ Library will not necessarily be able to recompile the application >+ to use the modified definitions.) >+ >+ b) Use a suitable shared library mechanism for linking with the >+ Library. A suitable mechanism is one that (1) uses at run time a >+ copy of the library already present on the user's computer system, >+ rather than copying library functions into the executable, and (2) >+ will operate properly with a modified version of the library, if >+ the user installs one, as long as the modified version is >+ interface-compatible with the version that the work was made with. >+ >+ c) Accompany the work with a written offer, valid for at >+ least three years, to give the same user the materials >+ specified in Subsection 6a, above, for a charge no more >+ than the cost of performing this distribution. >+ >+ d) If distribution of the work is made by offering access to copy >+ from a designated place, offer equivalent access to copy the above >+ specified materials from the same place. >+ >+ e) Verify that the user has already received a copy of these >+ materials or that you have already sent this user a copy. >+ >+ For an executable, the required form of the "work that uses the >+Library" must include any data and utility programs needed for >+reproducing the executable from it. However, as a special exception, >+the materials to be 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. >+ >+ It may happen that this requirement contradicts the license >+restrictions of other proprietary libraries that do not normally >+accompany the operating system. Such a contradiction means you cannot >+use both them and the Library together in an executable that you >+distribute. >+ >+ 7. You may place library facilities that are a work based on the >+Library side-by-side in a single library together with other library >+facilities not covered by this License, and distribute such a combined >+library, provided that the separate distribution of the work based on >+the Library and of the other library facilities is otherwise >+permitted, and provided that you do these two things: >+ >+ a) Accompany the combined library with a copy of the same work >+ based on the Library, uncombined with any other library >+ facilities. This must be distributed under the terms of the >+ Sections above. >+ >+ b) Give prominent notice with the combined library of the fact >+ that part of it is a work based on the Library, and explaining >+ where to find the accompanying uncombined form of the same work. >+ >+ 8. You may not copy, modify, sublicense, link with, or distribute >+the Library except as expressly provided under this License. Any >+attempt otherwise to copy, modify, sublicense, link with, or >+distribute the Library 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. >+ >+ 9. 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 Library or its derivative works. These actions are >+prohibited by law if you do not accept this License. Therefore, by >+modifying or distributing the Library (or any work based on the >+Library), you indicate your acceptance of this License to do so, and >+all its terms and conditions for copying, distributing or modifying >+the Library or works based on it. >+ >+ 10. Each time you redistribute the Library (or any work based on the >+Library), the recipient automatically receives a license from the >+original licensor to copy, distribute, link with or modify the Library >+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 with >+this License. >+ >+ 11. 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 Library at all. For example, if a patent >+license would not permit royalty-free redistribution of the Library 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 Library. >+ >+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. >+ >+ 12. If the distribution and/or use of the Library is restricted in >+certain countries either by patents or by copyrighted interfaces, the >+original copyright holder who places the Library 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. >+ >+ 13. The Free Software Foundation may publish revised and/or new >+versions of the Lesser 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 Library >+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 Library does not specify a >+license version number, you may choose any version ever published by >+the Free Software Foundation. >+ >+ 14. If you wish to incorporate parts of the Library into other free >+programs whose distribution conditions are incompatible with these, >+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 >+ >+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO >+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. >+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR >+OTHER PARTIES PROVIDE THE LIBRARY "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 >+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME >+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. >+ >+ 16. 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 LIBRARY 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 >+LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries >+ >+ If you develop a new library, and you want it to be of the greatest >+possible use to the public, we recommend making it free software that >+everyone can redistribute and change. You can do so by permitting >+redistribution under these terms (or, alternatively, under the terms of the >+ordinary General Public License). >+ >+ To apply these terms, attach the following notices to the library. 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 library's name and a brief idea of what it does.> >+ Copyright (C) <year> <name of author> >+ >+ This library is free software; you can redistribute it and/or >+ modify it under the terms of the GNU Lesser General Public >+ License as published by the Free Software Foundation; either >+ version 2.1 of the License, or (at your option) any later version. >+ >+ This library is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ Lesser General Public License for more details. >+ >+ You should have received a copy of the GNU Lesser General Public >+ License along with this library; if not, write to the Free Software >+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+ >+Also add information on how to contact you by electronic and paper mail. >+ >+You should also get your employer (if you work as a programmer) or your >+school, if any, to sign a "copyright disclaimer" for the library, if >+necessary. Here is a sample; alter the names: >+ >+ Yoyodyne, Inc., hereby disclaims all copyright interest in the >+ library `Frob' (a library for tweaking knobs) written by James Random Hacker. >+ >+ <signature of Ty Coon>, 1 April 1990 >+ Ty Coon, President of Vice >+ >+That's all there is to it! >+ >+ >diff --git a/modules/libjpeg-turbo/LICENSE.txt b/modules/libjpeg-turbo/LICENSE.txt >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/LICENSE.txt >@@ -0,0 +1,53 @@ >+ wxWindows Library Licence, Version 3.1 >+ ====================================== >+ >+ Copyright (C) 1998-2005 Julian Smart, Robert Roebling et al >+ >+ Everyone is permitted to copy and distribute verbatim copies >+ of this licence document, but changing it is not allowed. >+ >+ WXWINDOWS LIBRARY LICENCE >+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION >+ >+ This library is free software; you can redistribute it and/or modify it >+ under the terms of the GNU Library General Public Licence as published by >+ the Free Software Foundation; either version 2 of the Licence, 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 Licence for more details. >+ >+ You should have received a copy of the GNU Library General Public Licence >+ along with this software, usually in a file named COPYING.LIB. If not, >+ write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, >+ Boston, MA 02111-1307 USA. >+ >+ EXCEPTION NOTICE >+ >+ 1. As a special exception, the copyright holders of this library give >+ permission for additional uses of the text contained in this release of >+ the library as licenced under the wxWindows Library Licence, applying >+ either version 3.1 of the Licence, or (at your option) any later version of >+ the Licence as published by the copyright holders of version >+ 3.1 of the Licence document. >+ >+ 2. The exception is that you may use, copy, link, modify and distribute >+ under your own terms, binary object code versions of works based >+ on the Library. >+ >+ 3. If you copy code from files distributed under the terms of the GNU >+ General Public Licence or the GNU Library General Public Licence into a >+ copy of this library, as this licence permits, the exception does not >+ apply to the code that you add in this way. To avoid misleading anyone as >+ to the status of such modified files, you must delete this exception >+ notice from such code and/or adjust the licensing conditions notice >+ accordingly. >+ >+ 4. If you write modifications of your own for this library, it is your >+ choice whether to permit this exception to apply to your modifications. >+ If you do not wish that, you must delete the exception notice from such >+ code and/or adjust the licensing conditions notice accordingly. >+ >+ >diff --git a/jpeg/MOZCHANGES b/modules/libjpeg-turbo/MOZCHANGES >rename from jpeg/MOZCHANGES >rename to modules/libjpeg-turbo/MOZCHANGES >--- a/jpeg/MOZCHANGES >+++ b/modules/libjpeg-turbo/MOZCHANGES >@@ -1,10 +1,41 @@ >+To upgrade to a new revision of libjpeg-turbo, do the following: > >-Changes made to pristine jpeg source by mozilla.org developers. >+* Check out libjpeg-turbo from SVN: > >-2003/08/18 -- change default mapping for METHODDEF, LOCAL, GLOBAL, EXTERN to better match NSPR >+ $ svn co https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo/trunk libjpeg-turbo > >-2003/03/14 -- mingw bustage fix. w32api uses different header guard define >- for <basestd.h> than msvc. >+* In a clean clone of mozilla-central, run the following commands > >-????/??/?? -- Lots of undocumented changes. :( >+ rm -rf modules/libjpeg-turbo >+ svn export --ignore-externals /path/to/libjpeg-turbo modules/libjpeg-turbo >+ cd modules/libjpeg-turbo > >+ # Remove packaging files, Windows-specific config, test images, and wxWindows-licensed files. >+ rm -rf release win >+ rm *.jpg *.ppm *.bmp bmp.c bmp.h jpegut.c jpgtest.cxx rrtimer.h rrutil.h turbojpeg.h turbojpegl.c >+ >+ # Restore files >+ hg revert --no-backup Makefile.in jconfig.h jmorecfg.h simd/Makefile.in simd/jsimdcfg.inc jchuff.c jdhuff.c jdhuff.h MOZCHANGES >+ >+ # Add or remove other files to sync us with the SVN repository. >+ hg addremove >+ >+ >+== 8/4/2010 (initial commit, SVN r222 2010-08-03) == >+ >+* Modified jmorecfg.h to define UINT8, UINT16, INT16, and INT32 in terms of >+ prtypes to fix a build error on Windows. >+ >+* Removed the following files which are licensed under the wxWindows license: >+ >+ bmp.c, bmp.h, jpegut.c, jpgtest.cxx, rrtimer.h, rrutil.h, turbojpeg.h, >+ turbojpegl.c >+ >+* Reverted the following files to what was previously in Mozilla's tree >+ (nominally libjpeg 6.2): >+ >+ jchuff.c, jdhuff.c, jdhuff.h >+ >+ since the versions of these files in libjpeg-turbo are also under the >+ wxWindows license. (It would have been nicer to revert them to the new >+ libjepg-8b code, but that doesn't easily integrate with libjepg-turbo.) >diff --git a/modules/libjpeg-turbo/Makefile.am b/modules/libjpeg-turbo/Makefile.am >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/Makefile.am >@@ -0,0 +1,211 @@ >+lib_LTLIBRARIES = libjpeg.la libturbojpeg.la >+libjpeg_la_LDFLAGS = -version-number 62:0:0 -no-undefined >+libturbojpeg_la_LDFLAGS = -avoid-version -no-undefined >+include_HEADERS = jerror.h jmorecfg.h jpeglib.h turbojpeg.h >+nodist_include_HEADERS = jconfig.h >+ >+HDRS = jchuff.h jdct.h jdhuff.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ >+ jpegint.h jpeglib.h jversion.h jsimd.h jsimddct.h >+ >+libjpeg_la_SOURCES = $(HDRS) jcapimin.c jcapistd.c jccoefct.c jccolor.c \ >+ jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ >+ jcomapi.c jcparam.c jcphuff.c jcprepct.c jcsample.c jctrans.c \ >+ jdapimin.c jdapistd.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \ >+ jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \ >+ jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c \ >+ jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c \ >+ jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c >+ >+libturbojpeg_la_SOURCES = $(libjpeg_la_SOURCES) turbojpegl.c turbojpeg.h \ >+ turbojpeg-mapfile >+ >+if VERSION_SCRIPT >+ >+libturbojpeg_la_LDFLAGS += $(VERSION_SCRIPT_FLAG)$(srcdir)/turbojpeg-mapfile >+ >+endif >+ >+if WITH_SIMD >+ >+SUBDIRS = simd >+libjpeg_la_LIBADD = simd/libsimd.la >+libturbojpeg_la_LIBADD = simd/libsimd.la >+ >+else >+ >+libjpeg_la_SOURCES += jsimd_none.c >+ >+endif >+ >+TSTHDRS = rrutil.h rrtimer.h >+ >+bin_PROGRAMS = cjpeg djpeg jpegtran rdjpgcom wrjpgcom >+noinst_PROGRAMS = jpgtest jpegut >+ >+jpgtest_SOURCES = $(TSTHDRS) jpgtest.cxx bmp.h bmp.c >+ >+jpgtest_LDADD = libturbojpeg.la >+ >+jpegut_SOURCES = $(TSTHDRS) jpegut.c bmp.h bmp.c >+ >+jpegut_LDADD = libturbojpeg.la >+ >+cjpeg_SOURCES = cdjpeg.h cderror.h cdjpeg.c cjpeg.c rdbmp.c rdgif.c \ >+ rdppm.c rdswitch.c rdtarga.c >+ >+cjpeg_LDADD = libjpeg.la >+ >+cjpeg_CFLAGS = -DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED \ >+ -DTARGA_SUPPORTED >+ >+djpeg_SOURCES = cdjpeg.h cderror.h cdjpeg.c djpeg.c rdcolmap.c rdswitch.c \ >+ wrbmp.c wrgif.c wrppm.c wrtarga.c >+ >+djpeg_LDADD = libjpeg.la >+ >+djpeg_CFLAGS = -DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED \ >+ -DTARGA_SUPPORTED >+ >+jpegtran_SOURCES = jpegtran.c rdswitch.c cdjpeg.c transupp.c transupp.h >+ >+jpegtran_LDADD = libjpeg.la >+ >+rdjpgcom_SOURCES = rdjpgcom.c >+ >+rdjpgcom_LDADD = libjpeg.la >+ >+wrjpgcom_SOURCES = wrjpgcom.c >+ >+wrjpgcom_LDADD = libjpeg.la >+ >+ >+dist_man1_MANS = cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1 >+ >+DOCS= README install.doc usage.doc wizard.doc example.c libjpeg.doc \ >+ structure.doc coderules.doc filelist.doc jconfig.doc change.log \ >+ README-turbo.txt rdrle.c wrrle.c LICENSE.txt LGPL.txt BUILDING.txt \ >+ ChangeLog.txt >+ >+TESTFILES= testorig.jpg testorig.ppm testimg.bmp testimgflt.jpg \ >+ testimgfst.jpg testimgint.jpg testimgp.jpg testimgfst.ppm testimgint.ppm \ >+ testimg-nosimd.bmp testimgfst-nosimd.ppm testorig-nosimd.ppm \ >+ testimgflt-nosimd.jpg testimgint-nosimd.jpg testimgfst-nosimd.jpg \ >+ testimgp-nosimd.jpg >+ >+EXTRA_DIST = win release $(DOCS) $(TESTFILES) >+ >+dist-hook: >+ rm -rf `find $(distdir) -name .svn` >+ >+ >+if WITH_SIMD >+ >+test: testclean cjpeg djpeg jpegtran jpegut >+ ./jpegut >+ ./cjpeg -dct int -outfile testoutint.jpg $(srcdir)/testorig.ppm >+ ./cjpeg -dct fast -opt -outfile testoutfst.jpg $(srcdir)/testorig.ppm >+ ./cjpeg -dct float -outfile testoutflt.jpg $(srcdir)/testorig.ppm >+ cmp $(srcdir)/testimgint.jpg testoutint.jpg >+ cmp $(srcdir)/testimgfst.jpg testoutfst.jpg >+ cmp $(srcdir)/testimgflt.jpg testoutflt.jpg >+ ./djpeg -dct int -fast -ppm -outfile testoutint.ppm $(srcdir)/testorig.jpg >+ ./djpeg -dct fast -ppm -outfile testoutfst.ppm $(srcdir)/testorig.jpg >+ ./djpeg -dct float -ppm -outfile testoutflt.ppm $(srcdir)/testorig.jpg >+ cmp $(srcdir)/testimgint.ppm testoutint.ppm >+ cmp $(srcdir)/testimgfst.ppm testoutfst.ppm >+ cmp $(srcdir)/testorig.ppm testoutflt.ppm >+ ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg >+ cmp $(srcdir)/testimg.bmp testout.bmp >+ ./cjpeg -dct int -progressive -outfile testoutp.jpg $(srcdir)/testorig.ppm >+ cmp $(srcdir)/testimgp.jpg testoutp.jpg >+ ./jpegtran -outfile testoutt.jpg testoutp.jpg >+ cmp $(srcdir)/testimgint.jpg testoutt.jpg >+ >+else >+ >+test: testclean cjpeg djpeg jpegtran jpegut >+ ./jpegut >+ ./cjpeg -dct int -outfile testoutint.jpg $(srcdir)/testorig-nosimd.ppm >+ ./cjpeg -dct fast -opt -outfile testoutfst.jpg $(srcdir)/testorig-nosimd.ppm >+ ./cjpeg -dct float -outfile testoutflt.jpg $(srcdir)/testorig-nosimd.ppm >+ cmp $(srcdir)/testimgint-nosimd.jpg testoutint.jpg >+ cmp $(srcdir)/testimgfst-nosimd.jpg testoutfst.jpg >+ cmp $(srcdir)/testimgflt-nosimd.jpg testoutflt.jpg >+ ./djpeg -dct int -fast -ppm -outfile testoutint.ppm $(srcdir)/testorig.jpg >+ ./djpeg -dct fast -ppm -outfile testoutfst.ppm $(srcdir)/testorig.jpg >+ ./djpeg -dct float -ppm -outfile testoutflt.ppm $(srcdir)/testorig.jpg >+ cmp $(srcdir)/testimgint.ppm testoutint.ppm >+ cmp $(srcdir)/testimgfst-nosimd.ppm testoutfst.ppm >+ cmp $(srcdir)/testorig-nosimd.ppm testoutflt.ppm >+ ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg >+ cmp $(srcdir)/testimg-nosimd.bmp testout.bmp >+ ./cjpeg -dct int -progressive -outfile testoutp.jpg $(srcdir)/testorig-nosimd.ppm >+ cmp $(srcdir)/testimgp-nosimd.jpg testoutp.jpg >+ ./jpegtran -outfile testoutt.jpg testoutp.jpg >+ cmp $(srcdir)/testimgint-nosimd.jpg testoutt.jpg >+ >+endif >+ >+testclean: >+ rm -f testout* >+ rm -f *_GRAYQ[0-9]*.bmp >+ rm -f *_GRAYQ[0-9]*.ppm >+ rm -f *_GRAYQ[0-9]*.jpg >+ rm -f *_420Q[0-9]*.bmp >+ rm -f *_420Q[0-9]*.ppm >+ rm -f *_420Q[0-9]*.jpg >+ rm -f *_422Q[0-9]*.bmp >+ rm -f *_422Q[0-9]*.ppm >+ rm -f *_422Q[0-9]*.jpg >+ rm -f *_444Q[0-9]*.bmp >+ rm -f *_444Q[0-9]*.ppm >+ rm -f *_444Q[0-9]*.jpg >+ >+rpm: all >+ sh $(srcdir)/release/makerpm ${PACKAGE_NAME} ${VERSION} ${BUILD} \ >+ ${RPMARCH} ${srcdir} >+ >+srpm: dist-gzip >+ sh $(srcdir)/release/makesrpm ${PACKAGE_NAME} ${VERSION} ${BUILD} ${srcdir} >+ >+deb: all >+ sh $(srcdir)/release/makedpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \ >+ ${DEBARCH} ${srcdir} >+ >+if X86_64 >+ >+udmg: all >+ sh $(srcdir)/release/makemacpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \ >+ ${srcdir} universal >+ >+endif >+ >+dmg: all >+ sh $(srcdir)/release/makemacpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} ${srcdir} >+ >+if X86_64 >+ >+sunpkg: all >+ sh $(srcdir)/release/makesunpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \ >+ ${DEBARCH} ${srcdir} $(CC) $(CXX) combined >+ >+nsi: all >+ makensis -nocd -DVERSION=$(VERSION) -DAPPNAME=libjpeg-turbo-gcc64 \ >+ -DWLIBDIR=.libs -DWSRCDIR=$(srcdir) -DWBLDDIR=. -DWHDRDIR=. -DWIN64 \ >+ -DPLATFORM="GCC 64-bit" -DGCC $(srcdir)/release/libjpeg-turbo.nsi >+ >+else >+ >+sunpkg: all >+ sh $(srcdir)/release/makesunpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \ >+ ${DEBARCH} ${srcdir} $(CC) $(CXX) >+ >+nsi: all >+ makensis -nocd -DVERSION=$(VERSION) -DAPPNAME=libjpeg-turbo-gcc \ >+ -DWLIBDIR=.libs -DWSRCDIR=$(srcdir) -DWBLDDIR=. -DWHDRDIR=. \ >+ -DPLATFORM="GCC" -DGCC $(srcdir)/release/libjpeg-turbo.nsi >+ >+endif >+ >+cygwinpkg: all >+ sh $(srcdir)/release/makecygwinpkg ${PACKAGE_NAME} ${VERSION} ${srcdir} >diff --git a/jpeg/Makefile.in b/modules/libjpeg-turbo/Makefile.in >rename from jpeg/Makefile.in >rename to modules/libjpeg-turbo/Makefile.in >--- a/jpeg/Makefile.in >+++ b/modules/libjpeg-turbo/Makefile.in >@@ -10,117 +10,193 @@ > # Software distributed under the License is distributed on an "AS IS" basis, > # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License > # for the specific language governing rights and limitations under the > # License. > # > # The Original Code is mozilla.org code. > # > # The Initial Developer of the Original Code is >-# Netscape Communications Corporation. >-# Portions created by the Initial Developer are Copyright (C) 1998 >+# Mozilla Corporation >+# Portions created by the Initial Developer are Copyright (C) 2010 > # the Initial Developer. All Rights Reserved. > # > # Contributor(s): >+# Justin Lebar <justin.lebar@gmail.com> > # > # Alternatively, the contents of this file may be used under the terms of > # either the GNU General Public License Version 2 or later (the "GPL"), or > # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), > # in which case the provisions of the GPL or the LGPL are applicable instead > # of those above. If you wish to allow use of your version of this file only > # under the terms of either the GPL or the LGPL, and not to allow others to > # use your version of this file under the terms of the MPL, indicate your > # decision by deleting the provisions above and replace them with the notice > # and other provisions required by the GPL or the LGPL. If you do not delete > # the provisions above, a recipient may use your version of this file under > # the terms of any one of the MPL, the GPL or the LGPL. > # > # ***** END LICENSE BLOCK ***** > >-DEPTH = .. >+DEPTH = ../.. > topsrcdir = @top_srcdir@ > srcdir = @srcdir@ > VPATH = @srcdir@ > > include $(DEPTH)/config/autoconf.mk > >+DIRS = simd > MODULE = jpeg > LIBRARY_NAME = mozjpeg > > ifeq ($(OS_ARCH),WINNT) > LIBRARY_NAME = jpeg32$(VERSION_NUMBER) > # FIXME: bug 413019 > ifndef GNU_CC > OS_COMPILE_CFLAGS += -GL- > endif > endif > > GRE_MODULE = 1 > > CSRCS = \ >+ jcomapi.c \ > jdapimin.c \ > jdapistd.c \ >+ jdatadst.c \ > jdatasrc.c \ >- jdatadst.c \ >+ jdcoefct.c \ >+ jdcolor.c \ >+ jddctmgr.c \ >+ jdhuff.c \ >+ jdinput.c \ >+ jdmainct.c \ >+ jdmarker.c \ > jdmaster.c \ >- jdinput.c \ >- jdmarker.c \ >- jdhuff.c \ >+ jdmerge.c \ > jdphuff.c \ >- jdmainct.c \ >- jdcoefct.c \ > jdpostct.c \ >- jddctmgr.c \ >- jidctfst.c \ >- jidctflt.c \ >- jidctint.c \ > jdsample.c \ >- jdcolor.c \ >- jquant1.c \ >- jquant2.c \ >- jdmerge.c \ >- jcomapi.c \ >- jutils.c \ >+ jdtrans.c \ > jerror.c \ >- jmemmgr.c \ >- jmemnobs.c \ > jfdctflt.c \ > jfdctfst.c \ > jfdctint.c \ >- $(NULL) >- >-EXPORTS = \ >- jconfig.h \ >- jerror.h \ >- jinclude.h \ >- jmorecfg.h \ >- jpeglib.h \ >- jpegint.h \ >- jwinfig.h \ >- jos2fig.h \ >+ jidctflt.c \ >+ jidctfst.c \ >+ jidctint.c \ >+ jidctred.c \ >+ jmemmgr.c \ >+ jmemnobs.c \ >+ jpegtran.c \ >+ jquant1.c \ >+ jquant2.c \ >+ jutils.c \ > $(NULL) > > # These files enable support for writing JPEGs > # (on certain platforms, or if JPEG image encoder support is required) > ifneq (,$(filter os2 windows,$(MOZ_WIDGET_TOOLKIT))$(filter jpeg,$(MOZ_IMG_ENCODERS))) > CSRCS += \ > jcapimin.c \ >- jcparam.c \ > jcapistd.c \ >- jcmarker.c \ >+ jccoefct.c \ >+ jccolor.c \ >+ jcdctmgr.c \ >+ jchuff.c \ > jcinit.c \ > jcmainct.c \ >- jchuff.c \ >+ jcmarker.c \ >+ jcmaster.c \ >+ jcparam.c \ >+ jcphuff.c \ >+ jcprepct.c \ > jcsample.c \ >- jcmaster.c \ >- jccoefct.c \ >- jccolor.c \ >- jcphuff.c \ >- jcdctmgr.c \ >- jcprepct.c \ > $(NULL) > > endif > >+AS=$(LIBJPEG_TURBO_AS) >+ASM_SUFFIX=asm >+ASFLAGS=$(LIBJPEG_TURBO_ASFLAGS) -I$(topsrcdir)/modules/libjpeg-turbo/simd/ >+ >+ifeq ($(AS),yasm) >+ # yasm doesn't like -c >+ AS_DASH_C_FLAG= >+endif >+ >+# No SIMD support? >+ifeq (,$(LIBJPEG_TURBO_X86_ASM)$(LIBJPEG_TURBO_X64_ASM)) >+ CSRCS += jsimd_none.c >+endif >+ >+ifeq (1,$(LIBJPEG_TURBO_X64_ASM)) >+ CSRCS += simd/jsimd_x86_64.c >+ ASFILES += \ >+ simd/jccolss2-64.asm \ >+ simd/jcqnts2f-64.asm \ >+ simd/jcqnts2i-64.asm \ >+ simd/jcsamss2-64.asm \ >+ simd/jdcolss2-64.asm \ >+ simd/jdmerss2-64.asm \ >+ simd/jdsamss2-64.asm \ >+ simd/jfss2fst-64.asm \ >+ simd/jfss2int-64.asm \ >+ simd/jfsseflt-64.asm \ >+ simd/jiss2flt-64.asm \ >+ simd/jiss2fst-64.asm \ >+ simd/jiss2int-64.asm \ >+ simd/jiss2red-64.asm \ >+ $(NULL) >+endif >+ >+ifeq (1,$(LIBJPEG_TURBO_X86_ASM)) >+ CSRCS +=simd/jsimd_i386.c >+ ASFILES += \ >+ simd/jccolmmx.asm \ >+ simd/jccolss2.asm \ >+ simd/jcqnt3dn.asm \ >+ simd/jcqntmmx.asm \ >+ simd/jcqnts2f.asm \ >+ simd/jcqnts2i.asm \ >+ simd/jcqntsse.asm \ >+ simd/jcsammmx.asm \ >+ simd/jcsamss2.asm \ >+ simd/jdcolmmx.asm \ >+ simd/jdcolss2.asm \ >+ simd/jdmermmx.asm \ >+ simd/jdmerss2.asm \ >+ simd/jdsammmx.asm \ >+ simd/jdsamss2.asm \ >+ simd/jf3dnflt.asm \ >+ simd/jfmmxfst.asm \ >+ simd/jfmmxint.asm \ >+ simd/jfss2fst.asm \ >+ simd/jfss2int.asm \ >+ simd/jfsseflt.asm \ >+ simd/ji3dnflt.asm \ >+ simd/jimmxfst.asm \ >+ simd/jimmxint.asm \ >+ simd/jimmxred.asm \ >+ simd/jiss2flt.asm \ >+ simd/jiss2fst.asm \ >+ simd/jiss2int.asm \ >+ simd/jiss2red.asm \ >+ simd/jisseflt.asm \ >+ simd/jsimdcpu.asm \ >+ $(NULL) >+endif >+ >+ >+# jwinfig.h, jos2fig.h ? XXX >+EXPORTS = \ >+ jconfig.h \ >+ jerror.h \ >+ jinclude.h \ >+ jmorecfg.h \ >+ jpegint.h \ >+ jpeglib.h \ >+ $(NULL) >+ > # need static lib for some of the libimg componentry to link properly > FORCE_STATIC_LIB = 1 > > include $(topsrcdir)/config/rules.mk >diff --git a/jpeg/README b/modules/libjpeg-turbo/README >rename from jpeg/README >rename to modules/libjpeg-turbo/README >--- a/jpeg/README >+++ b/modules/libjpeg-turbo/README >@@ -1,8 +1,15 @@ >+libjpeg-turbo note: This is the legacy document from the original libjpeg v6b >+release, which is included for reference. The Internet addresses given below >+are likely non-functional. For more information about the libjpeg project, >+please see http://www.ijg.org. For more information about libjpeg-turbo, >+please see http://libjpeg-turbo.virtualgl.org. >+ >+ > The Independent JPEG Group's JPEG software > ========================================== > > README for release 6b of 27-Mar-1998 > ==================================== > > This distribution contains the sixth public release of the Independent JPEG > Group's free JPEG software. You are welcome to redistribute this software and >diff --git a/modules/libjpeg-turbo/README-turbo.txt b/modules/libjpeg-turbo/README-turbo.txt >new file mode 100755 >--- /dev/null >+++ b/modules/libjpeg-turbo/README-turbo.txt >@@ -0,0 +1,202 @@ >+******************************************************************************* >+** Background >+******************************************************************************* >+ >+libjpeg-turbo is a high-speed version of libjpeg for x86 and x86-64 processors >+which uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG >+compression and decompression. libjpeg-turbo is generally 2-4x as fast >+as the unmodified version of libjpeg, all else being equal. >+ >+libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but >+the TigerVNC and VirtualGL projects made numerous enhancements to the codec, >+including improved support for Mac OS X, 64-bit support, support for 32-bit >+and big endian pixel formats, accelerated Huffman encoding/decoding, and >+various bug fixes. The goal was to produce a fully open source codec that >+could replace the partially closed source TurboJPEG/IPP codec used by VirtualGL >+and TurboVNC. libjpeg-turbo generally performs in the range of 80-120% of >+TurboJPEG/IPP. It is faster in some areas but slower in others. >+ >+It was decided to split libjpeg-turbo into a separate SDK so that other >+projects could take advantage of this technology. The libjpeg-turbo shared >+libraries can be used as drop-in replacements for libjpeg on most systems. >+ >+ >+******************************************************************************* >+** License >+******************************************************************************* >+ >+Some of the optimizations to the Huffman encoder/decoder were borrowed from >+VirtualGL, and thus the libjpeg-turbo distribution, as a whole, falls under the >+wxWindows Library Licence, Version 3.1. A copy of this license can be found in >+this directory under LICENSE.txt. The wxWindows Library License is based on >+the LGPL but includes provisions which allow the Library to be statically >+linked into proprietary libraries and applications without requiring the >+resulting binaries to be distributed under the terms of the LGPL. >+ >+The rest of the source code, apart from these modifications, falls under a less >+restrictive, BSD-style license (see README.) >+ >+ >+******************************************************************************* >+** Using libjpeg-turbo >+******************************************************************************* >+ >+============================= >+Replacing libjpeg at Run Time >+============================= >+ >+If a Unix application is dynamically linked with libjpeg, then you can replace >+libjpeg with libjpeg-turbo at run time by manipulating the LD_LIBRARY_PATH. >+For instance: >+ >+ [Using libjpeg] >+ > time cjpeg <vgl_5674_0098.ppm >vgl_5674_0098.jpg >+ real 0m0.392s >+ user 0m0.074s >+ sys 0m0.020s >+ >+ [Using libjpeg-turbo] >+ > export LD_LIBRARY_PATH=/opt/libjpeg-turbo/{lib}:$LD_LIBRARY_PATH >+ > time cjpeg <vgl_5674_0098.ppm >vgl_5674_0098.jpg >+ real 0m0.109s >+ user 0m0.029s >+ sys 0m0.010s >+ >+NOTE: {lib} can be lib, lib32, lib64, or lib/64, depending on the O/S and >+architecture. >+ >+System administrators can also replace the libjpeg sym links in /usr/{lib} with >+links to the libjpeg dynamic library located in /opt/libjpeg-turbo/{lib}. This >+will effectively accelerate every dynamically linked libjpeg application on the >+system. >+ >+The Windows distribution of the libjpeg-turbo SDK installs jpeg62.dll into >+c:\libjpeg-turbo\bin, and the PATH environment variable can be modified such >+that this directory is searched before any others that might contain >+jpeg62.dll. However, if jpeg62.dll also exists in an application's install >+directory, then Windows will load the application's version of it first. Thus, >+if an application ships with jpeg62.dll, then back up the application's version >+of jpeg62.dll and copy c:\libjpeg-turbo\bin\jpeg62.dll into the application's >+install directory to accelerate it. >+ >+The version of jpeg62.dll distributed in the libjpeg-turbo SDK requires the >+Visual C++ 2008 C run time DLL (msvcr90.dll). This library ships with more >+recent versions of Windows, but users of older versions can obtain it from the >+Visual C++ 2008 Redistributable Package, which is available as a free download >+from Microsoft's web site. >+ >+NOTE: Features of libjpeg which require passing a C run time structure, such >+as a file handle, from an application to libjpeg will probably not work with >+the distributed version of jpeg62.dll unless the application is also built to >+use the Visual C++ 2008 C run time DLL. In particular, this affects >+jpeg_stdio_dest() and jpeg_stdio_src(). >+ >+Mac applications typically embed their own copies of libjpeg.62.dylib inside >+the (hidden) application bundle, so it is not possible to globally replace >+libjpeg on OS X systems. If an application uses a shared library version of >+libjpeg, then it may be possible to replace the application's version of it. >+This would generally involve copying libjpeg.62.dylib into the appropriate >+place in the application bundle and using install_name_tool to repoint the >+dylib to the new directory. This requires an advanced knowledge of OS X and >+would not survive an upgrade or a re-install of the application. Thus, it is >+not recommended for most users. >+ >+======================= >+Replacing TurboJPEG/IPP >+======================= >+ >+libjpeg-turbo is a drop-in replacement for the TurboJPEG/IPP SDK used by >+VirtualGL 2.1.x and TurboVNC 0.6 (and prior.) libjpeg-turbo contains a wrapper >+library (TurboJPEG/OSS) that emulates the TurboJPEG API using libjpeg-turbo >+instead of the closed source Intel Performance Primitives. You can replace the >+TurboJPEG/IPP package on Linux systems with the libjpeg-turbo package in order >+to make existing releases of VirtualGL 2.1.x and TurboVNC use the new codec at >+run time. Note that the 64-bit libjpeg-turbo packages contain only 64-bit >+binaries, whereas the TurboJPEG/IPP 64-bit packages contained both 64-bit and >+32-bit binaries. Thus, to replace a TurboJPEG/IPP 64-bit package, install >+both the 64-bit and 32-bit versions of libjpeg-turbo. >+ >+You can also build the VirtualGL 2.1.x and TurboVNC 0.6 source code with >+the libjpeg-turbo SDK instead of TurboJPEG/IPP. It should work identically. >+libjpeg-turbo also includes static library versions of TurboJPEG/OSS, which >+are used to build TurboVNC 1.0 and later. >+ >+======================================== >+Using libjpeg-turbo in Your Own Programs >+======================================== >+ >+For the most part, libjpeg-turbo should work identically to libjpeg, so in >+most cases, an application can be built against libjpeg and then run against >+libjpeg-turbo. On Unix systems, you can build against libjpeg-turbo instead >+of libjpeg by setting >+ >+ CPATH=/opt/libjpeg-turbo/include >+ and >+ LIBRARY_PATH=/opt/libjpeg-turbo/{lib} >+ >+({lib} = lib32 or lib64, depending on whether you are building a 32-bit or a >+64-bit application.) >+ >+If using Cygwin, then set >+ >+ CPATH=/cygdrive/c/libjpeg-turbo-gcc[64]/include >+ and >+ LIBRARY_PATH=/cygdrive/c/libjpeg-turbo-gcc[64]/lib >+ >+If using MinGW, then set >+ >+ CPATH=/c/libjpeg-turbo-gcc[64]/include >+ and >+ LIBRARY_PATH=/c/libjpeg-turbo-gcc[64]/lib >+ >+Building against libjpeg-turbo is useful, for instance, if you want to build an >+application that leverages the libjpeg-turbo colorspace extensions (see below.) >+On Linux and Solaris systems, you would still need to manipulate the >+LD_LIBRARY_PATH or sym links appropriately to use libjpeg-turbo at run time. >+On such systems, you can pass -R /opt/libjpeg-turbo/{lib} to the linker to >+force the use of libjpeg-turbo at run time rather than libjpeg (also useful if >+you want to leverage the colorspace extensions), or you can link against the >+libjpeg-turbo static library. >+ >+To force a Linux, Solaris, or MinGW application to link against the static >+version of libjpeg-turbo, you can use the following linker options: >+ >+ -Wl,-Bstatic -ljpeg -Wl,-Bdynamic >+ >+On OS X, simply add /opt/libjpeg-turbo/lib/libjpeg.a to the linker command >+line (this also works on Linux and Solaris.) >+ >+To build Visual C++ applications using libjpeg-turbo, add >+c:\libjpeg-turbo[64]\include to your system or user INCLUDE environment >+variable and c:\libjpeg-turbo[64]\lib to your system or user LIB environment >+variable, and then link against either jpeg.lib (to use jpeg62.dll) or >+jpeg-static.lib (to use the static version of libjpeg-turbo.) >+ >+===================== >+Colorspace Extensions >+===================== >+ >+libjpeg-turbo includes extensions which allow JPEG images to be compressed >+directly from (and decompressed directly to) buffers which use BGR, BGRA, >+RGBA, ABGR, and ARGB pixel ordering. This is implemented with six new >+colorspace constants: >+ >+ JCS_EXT_RGB /* red/green/blue */ >+ JCS_EXT_RGBX /* red/green/blue/x */ >+ JCS_EXT_BGR /* blue/green/red */ >+ JCS_EXT_BGRX /* blue/green/red/x */ >+ JCS_EXT_XBGR /* x/blue/green/red */ >+ JCS_EXT_XRGB /* x/red/green/blue */ >+ >+Setting cinfo.in_color_space (compression) or cinfo.out_color_space >+(decompression) to one of these values will cause libjpeg-turbo to read the >+red, green, and blue values from (or write them to) the appropriate position in >+the pixel when YUV conversion is performed. >+ >+Your application can check for the existence of these extensions at compile >+time with: >+ >+ #ifdef JCS_EXTENSIONS >+ >+At run time, attempting to use these extensions with a version of libjpeg >+that doesn't support them will result in a "Bogus input colorspace" error. >diff --git a/modules/libjpeg-turbo/acinclude.m4 b/modules/libjpeg-turbo/acinclude.m4 >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/acinclude.m4 >@@ -0,0 +1,136 @@ >+# AC_PROG_NASM >+# -------------------------- >+# Check that NASM exists and determine flags >+AC_DEFUN([AC_PROG_NASM],[ >+ >+AC_CHECK_PROGS(NASM, [nasm nasmw]) >+test -z "$NASM" && AC_MSG_ERROR([no nasm (Netwide Assembler) found]) >+ >+AC_MSG_CHECKING([for object file format of host system]) >+case "$host_os" in >+ cygwin* | mingw* | pw32* | interix*) >+ case "$host_cpu" in >+ x86_64) >+ objfmt='Win64-COFF' >+ ;; >+ *) >+ objfmt='Win32-COFF' >+ ;; >+ esac >+ ;; >+ msdosdjgpp* | go32*) >+ objfmt='COFF' >+ ;; >+ os2-emx*) # not tested >+ objfmt='MSOMF' # obj >+ ;; >+ linux*coff* | linux*oldld*) >+ objfmt='COFF' # ??? >+ ;; >+ linux*aout*) >+ objfmt='a.out' >+ ;; >+ linux*) >+ case "$host_cpu" in >+ x86_64) >+ objfmt='ELF64' >+ ;; >+ *) >+ objfmt='ELF' >+ ;; >+ esac >+ ;; >+ freebsd* | netbsd* | openbsd*) >+ if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then >+ objfmt='BSD-a.out' >+ else >+ case "$host_cpu" in >+ x86_64 | amd64) >+ objfmt='ELF64' >+ ;; >+ *) >+ objfmt='ELF' >+ ;; >+ esac >+ fi >+ ;; >+ solaris* | sunos* | sysv* | sco*) >+ case "$host_cpu" in >+ x86_64) >+ objfmt='ELF64' >+ ;; >+ *) >+ objfmt='ELF' >+ ;; >+ esac >+ ;; >+ darwin* | rhapsody* | nextstep* | openstep* | macos*) >+ case "$host_cpu" in >+ x86_64) >+ objfmt='Mach-O64' >+ ;; >+ *) >+ objfmt='Mach-O' >+ ;; >+ esac >+ ;; >+ *) >+ objfmt='ELF ?' >+ ;; >+esac >+ >+AC_MSG_RESULT([$objfmt]) >+if test "$objfmt" = 'ELF ?'; then >+ objfmt='ELF' >+ AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.]) >+fi >+ >+AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ]) >+case "$objfmt" in >+ MSOMF) NAFLAGS='-fobj -DOBJ32';; >+ Win32-COFF) NAFLAGS='-fwin32 -DWIN32';; >+ Win64-COFF) NAFLAGS='-fwin64 -DWIN64 -D__x86_64__';; >+ COFF) NAFLAGS='-fcoff -DCOFF';; >+ a.out) NAFLAGS='-faout -DAOUT';; >+ BSD-a.out) NAFLAGS='-faoutb -DAOUT';; >+ ELF) NAFLAGS='-felf -DELF';; >+ ELF64) NAFLAGS='-felf64 -DELF -D__x86_64__';; >+ RDF) NAFLAGS='-frdf -DRDF';; >+ Mach-O) NAFLAGS='-fmacho -DMACHO';; >+ Mach-O64) NAFLAGS='-fmacho64 -DMACHO -D__x86_64__';; >+esac >+AC_MSG_RESULT([$NAFLAGS]) >+AC_SUBST([NAFLAGS]) >+ >+AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works]) >+cat > conftest.asm <<EOF >+[%line __oline__ "configure" >+ section .text >+ global _main,main >+_main: >+main: xor eax,eax >+ ret >+]EOF >+try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm' >+if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then >+ AC_MSG_RESULT(yes) >+else >+ echo "configure: failed program was:" >&AC_FD_CC >+ cat conftest.asm >&AC_FD_CC >+ rm -rf conftest* >+ AC_MSG_RESULT(no) >+ AC_MSG_ERROR([installation or configuration problem: assembler cannot create object files.]) >+fi >+ >+AC_MSG_CHECKING([whether the linker accepts assembler output]) >+try_nasm='${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.o $LIBS 1>&AC_FD_CC' >+if AC_TRY_EVAL(try_nasm) && test -s conftest${ac_exeext}; then >+ rm -rf conftest* >+ AC_MSG_RESULT(yes) >+else >+ rm -rf conftest* >+ AC_MSG_RESULT(no) >+ AC_MSG_ERROR([configuration problem: maybe object file format mismatch.]) >+fi >+ >+]) >diff --git a/jpeg/cderror.h b/modules/libjpeg-turbo/cderror.h >rename from jpeg/cderror.h >rename to modules/libjpeg-turbo/cderror.h >diff --git a/jpeg/cdjpeg.c b/modules/libjpeg-turbo/cdjpeg.c >rename from jpeg/cdjpeg.c >rename to modules/libjpeg-turbo/cdjpeg.c >diff --git a/jpeg/cdjpeg.h b/modules/libjpeg-turbo/cdjpeg.h >rename from jpeg/cdjpeg.h >rename to modules/libjpeg-turbo/cdjpeg.h >diff --git a/jpeg/change.log b/modules/libjpeg-turbo/change.log >rename from jpeg/change.log >rename to modules/libjpeg-turbo/change.log >diff --git a/modules/libjpeg-turbo/cjpeg.1 b/modules/libjpeg-turbo/cjpeg.1 >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/cjpeg.1 >@@ -0,0 +1,292 @@ >+.TH CJPEG 1 "20 March 1998" >+.SH NAME >+cjpeg \- compress an image file to a JPEG file >+.SH SYNOPSIS >+.B cjpeg >+[ >+.I options >+] >+[ >+.I filename >+] >+.LP >+.SH DESCRIPTION >+.LP >+.B cjpeg >+compresses the named image file, or the standard input if no file is >+named, and produces a JPEG/JFIF file on the standard output. >+The currently supported input file formats are: PPM (PBMPLUS color >+format), PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster >+Toolkit format). (RLE is supported only if the URT library is available.) >+.SH OPTIONS >+All switch names may be abbreviated; for example, >+.B \-grayscale >+may be written >+.B \-gray >+or >+.BR \-gr . >+Most of the "basic" switches can be abbreviated to as little as one letter. >+Upper and lower case are equivalent (thus >+.B \-BMP >+is the same as >+.BR \-bmp ). >+British spellings are also accepted (e.g., >+.BR \-greyscale ), >+though for brevity these are not mentioned below. >+.PP >+The basic switches are: >+.TP >+.BI \-quality " N" >+Scale quantization tables to adjust image quality. Quality is 0 (worst) to >+100 (best); default is 75. (See below for more info.) >+.TP >+.B \-grayscale >+Create monochrome JPEG file from color input. Be sure to use this switch when >+compressing a grayscale BMP file, because >+.B cjpeg >+isn't bright enough to notice whether a BMP file uses only shades of gray. >+By saying >+.BR \-grayscale , >+you'll get a smaller JPEG file that takes less time to process. >+.TP >+.B \-optimize >+Perform optimization of entropy encoding parameters. Without this, default >+encoding parameters are used. >+.B \-optimize >+usually makes the JPEG file a little smaller, but >+.B cjpeg >+runs somewhat slower and needs much more memory. Image quality and speed of >+decompression are unaffected by >+.BR \-optimize . >+.TP >+.B \-progressive >+Create progressive JPEG file (see below). >+.TP >+.B \-targa >+Input file is Targa format. Targa files that contain an "identification" >+field will not be automatically recognized by >+.BR cjpeg ; >+for such files you must specify >+.B \-targa >+to make >+.B cjpeg >+treat the input as Targa format. >+For most Targa files, you won't need this switch. >+.PP >+The >+.B \-quality >+switch lets you trade off compressed file size against quality of the >+reconstructed image: the higher the quality setting, the larger the JPEG file, >+and the closer the output image will be to the original input. Normally you >+want to use the lowest quality setting (smallest file) that decompresses into >+something visually indistinguishable from the original image. For this >+purpose the quality setting should be between 50 and 95; the default of 75 is >+often about right. If you see defects at >+.B \-quality >+75, then go up 5 or 10 counts at a time until you are happy with the output >+image. (The optimal setting will vary from one image to another.) >+.PP >+.B \-quality >+100 will generate a quantization table of all 1's, minimizing loss in the >+quantization step (but there is still information loss in subsampling, as well >+as roundoff error). This setting is mainly of interest for experimental >+purposes. Quality values above about 95 are >+.B not >+recommended for normal use; the compressed file size goes up dramatically for >+hardly any gain in output image quality. >+.PP >+In the other direction, quality values below 50 will produce very small files >+of low image quality. Settings around 5 to 10 might be useful in preparing an >+index of a large image library, for example. Try >+.B \-quality >+2 (or so) for some amusing Cubist effects. (Note: quality >+values below about 25 generate 2-byte quantization tables, which are >+considered optional in the JPEG standard. >+.B cjpeg >+emits a warning message when you give such a quality value, because some >+other JPEG programs may be unable to decode the resulting file. Use >+.B \-baseline >+if you need to ensure compatibility at low quality values.) >+.PP >+The >+.B \-progressive >+switch creates a "progressive JPEG" file. In this type of JPEG file, the data >+is stored in multiple scans of increasing quality. If the file is being >+transmitted over a slow communications link, the decoder can use the first >+scan to display a low-quality image very quickly, and can then improve the >+display with each subsequent scan. The final image is exactly equivalent to a >+standard JPEG file of the same quality setting, and the total file size is >+about the same --- often a little smaller. >+.B Caution: >+progressive JPEG is not yet widely implemented, so many decoders will be >+unable to view a progressive JPEG file at all. >+.PP >+Switches for advanced users: >+.TP >+.B \-dct int >+Use integer DCT method (default). >+.TP >+.B \-dct fast >+Use fast integer DCT (less accurate). >+.TP >+.B \-dct float >+Use floating-point DCT method. >+The float method is very slightly more accurate than the int method, but is >+much slower unless your machine has very fast floating-point hardware. Also >+note that results of the floating-point method may vary slightly across >+machines, while the integer methods should give the same results everywhere. >+The fast integer method is much less accurate than the other two. >+.TP >+.BI \-restart " N" >+Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is >+attached to the number. >+.B \-restart 0 >+(the default) means no restart markers. >+.TP >+.BI \-smooth " N" >+Smooth the input image to eliminate dithering noise. N, ranging from 1 to >+100, indicates the strength of smoothing. 0 (the default) means no smoothing. >+.TP >+.BI \-maxmemory " N" >+Set limit for amount of memory to use in processing large images. Value is >+in thousands of bytes, or millions of bytes if "M" is attached to the >+number. For example, >+.B \-max 4m >+selects 4000000 bytes. If more space is needed, temporary files will be used. >+.TP >+.BI \-outfile " name" >+Send output image to the named file, not to standard output. >+.TP >+.B \-verbose >+Enable debug printout. More >+.BR \-v 's >+give more output. Also, version information is printed at startup. >+.TP >+.B \-debug >+Same as >+.BR \-verbose . >+.PP >+The >+.B \-restart >+option inserts extra markers that allow a JPEG decoder to resynchronize after >+a transmission error. Without restart markers, any damage to a compressed >+file will usually ruin the image from the point of the error to the end of the >+image; with restart markers, the damage is usually confined to the portion of >+the image up to the next restart marker. Of course, the restart markers >+occupy extra space. We recommend >+.B \-restart 1 >+for images that will be transmitted across unreliable networks such as Usenet. >+.PP >+The >+.B \-smooth >+option filters the input to eliminate fine-scale noise. This is often useful >+when converting dithered images to JPEG: a moderate smoothing factor of 10 to >+50 gets rid of dithering patterns in the input file, resulting in a smaller >+JPEG file and a better-looking image. Too large a smoothing factor will >+visibly blur the image, however. >+.PP >+Switches for wizards: >+.TP >+.B \-baseline >+Force baseline-compatible quantization tables to be generated. This clamps >+quantization values to 8 bits even at low quality settings. (This switch is >+poorly named, since it does not ensure that the output is actually baseline >+JPEG. For example, you can use >+.B \-baseline >+and >+.B \-progressive >+together.) >+.TP >+.BI \-qtables " file" >+Use the quantization tables given in the specified text file. >+.TP >+.BI \-qslots " N[,...]" >+Select which quantization table to use for each color component. >+.TP >+.BI \-sample " HxV[,...]" >+Set JPEG sampling factors for each color component. >+.TP >+.BI \-scans " file" >+Use the scan script given in the specified text file. >+.PP >+The "wizard" switches are intended for experimentation with JPEG. If you >+don't know what you are doing, \fBdon't use them\fR. These switches are >+documented further in the file wizard.doc. >+.SH EXAMPLES >+.LP >+This example compresses the PPM file foo.ppm with a quality factor of >+60 and saves the output as foo.jpg: >+.IP >+.B cjpeg \-quality >+.I 60 foo.ppm >+.B > >+.I foo.jpg >+.SH HINTS >+Color GIF files are not the ideal input for JPEG; JPEG is really intended for >+compressing full-color (24-bit) images. In particular, don't try to convert >+cartoons, line drawings, and other images that have only a few distinct >+colors. GIF works great on these, JPEG does not. If you want to convert a >+GIF to JPEG, you should experiment with >+.BR cjpeg 's >+.B \-quality >+and >+.B \-smooth >+options to get a satisfactory conversion. >+.B \-smooth 10 >+or so is often helpful. >+.PP >+Avoid running an image through a series of JPEG compression/decompression >+cycles. Image quality loss will accumulate; after ten or so cycles the image >+may be noticeably worse than it was after one cycle. It's best to use a >+lossless format while manipulating an image, then convert to JPEG format when >+you are ready to file the image away. >+.PP >+The >+.B \-optimize >+option to >+.B cjpeg >+is worth using when you are making a "final" version for posting or archiving. >+It's also a win when you are using low quality settings to make very small >+JPEG files; the percentage improvement is often a lot more than it is on >+larger files. (At present, >+.B \-optimize >+mode is always selected when generating progressive JPEG files.) >+.SH ENVIRONMENT >+.TP >+.B JPEGMEM >+If this environment variable is set, its value is the default memory limit. >+The value is specified as described for the >+.B \-maxmemory >+switch. >+.B JPEGMEM >+overrides the default value specified when the program was compiled, and >+itself is overridden by an explicit >+.BR \-maxmemory . >+.SH SEE ALSO >+.BR djpeg (1), >+.BR jpegtran (1), >+.BR rdjpgcom (1), >+.BR wrjpgcom (1) >+.br >+.BR ppm (5), >+.BR pgm (5) >+.br >+Wallace, Gregory K. "The JPEG Still Picture Compression Standard", >+Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. >+.SH AUTHOR >+Independent JPEG Group >+.SH BUGS >+Arithmetic coding is not supported for legal reasons. >+.PP >+GIF input files are no longer supported, to avoid the Unisys LZW patent. >+Use a Unisys-licensed program if you need to read a GIF file. (Conversion >+of GIF files to JPEG is usually a bad idea anyway.) >+.PP >+Not all variants of BMP and Targa file formats are supported. >+.PP >+The >+.B \-targa >+switch is not a bug, it's a feature. (It would be a bug if the Targa format >+designers had not been clueless.) >+.PP >+Still not as fast as we'd like. >diff --git a/jpeg/cjpeg.c b/modules/libjpeg-turbo/cjpeg.c >rename from jpeg/cjpeg.c >rename to modules/libjpeg-turbo/cjpeg.c >diff --git a/jpeg/coderules.doc b/modules/libjpeg-turbo/coderules.doc >rename from jpeg/coderules.doc >rename to modules/libjpeg-turbo/coderules.doc >diff --git a/modules/libjpeg-turbo/configure.ac b/modules/libjpeg-turbo/configure.ac >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/configure.ac >@@ -0,0 +1,185 @@ >+# -*- Autoconf -*- >+# Process this file with autoconf to produce a configure script. >+ >+AC_PREREQ([2.56]) >+AC_INIT([libjpeg-turbo], [1.0.1]) >+BUILD=`date +%Y%m%d` >+ >+AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2]) >+AC_PREFIX_DEFAULT(/opt/libjpeg-turbo) >+ >+# Always build with prototypes >+AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes]) >+# Don't use undefined types >+AC_DEFINE([INCOMPLETE_TYPES_BROKEN], 1, [Define if you want use complete types]) >+ >+# Checks for programs. >+SAVED_CFLAGS=${CFLAGS} >+SAVED_CXXFLAGS=${CXXFLAGS} >+AC_PROG_CPP >+AC_PROG_CC >+AC_PROG_CXX >+AC_PROG_INSTALL >+AC_PROG_LIBTOOL >+AC_PROG_LN_S >+ >+AC_MSG_CHECKING([whether the linker supports version scripts]) >+VERSION_SCRIPT=no >+LDVER=`$LD --help </dev/null 2>&1 | grep "\-\-version-script"` >+if test "$LDVER"; then >+ VERSION_SCRIPT=yes >+ VERSION_SCRIPT_FLAG=-Wl,--version-script, >+ AC_MSG_RESULT(yes) >+else >+ LDVER=`$LD --help </dev/null 2>&1 | grep "\-M"` >+ if test "$LDVER"; then >+ VERSION_SCRIPT=yes >+ VERSION_SCRIPT_FLAG=-Wl,-M, >+ AC_MSG_RESULT(yes) >+ else >+ AC_MSG_RESULT(no) >+ fi >+fi >+ >+AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes") >+AC_SUBST(VERSION_SCRIPT_FLAG) >+ >+if test "x${GCC}" = "xyes"; then >+ if test "x${SAVED_CFLAGS}" = "x"; then >+ CFLAGS=-O3 >+ fi >+ if test "x${SAVED_CXXFLAGS}" = "x"; then >+ CXXFLAGS=-O3 >+ fi >+fi >+ >+AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) >+if test "x${SUNCC}" = "xyes"; then >+ if test "x${SAVED_CFLAGS}" = "x"; then >+ CFLAGS=-xO5 >+ fi >+ if test "x${SAVED_CXXFLAGS}" = "x"; then >+ CXXFLAGS=-xO5 >+ fi >+fi >+ >+# Checks for libraries. >+ >+# Checks for header files. >+AC_HEADER_STDC >+AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) >+AC_CHECK_HEADER([sys/types.h], AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h])) >+ >+# Checks for typedefs, structures, and compiler characteristics. >+AC_C_CONST >+AC_C_CHAR_UNSIGNED >+AC_C_INLINE >+AC_TYPE_SIZE_T >+AC_CHECK_TYPES([unsigned char, unsigned short]) >+ >+AC_MSG_CHECKING([if right shift is signed]) >+AC_TRY_RUN( >+ [#include <stdio.h> >+ int is_shifting_signed (long arg) { >+ long res = arg >> 4; >+ >+ if (res == -0x7F7E80CL) >+ return 1; /* right shift is signed */ >+ >+ /* see if unsigned-shift hack will fix it. */ >+ /* we can't just test exact value since it depends on width of long... */ >+ res |= (~0L) << (32-4); >+ if (res == -0x7F7E80CL) >+ return 0; /* right shift is unsigned */ >+ >+ printf("Right shift isn't acting as I expect it to.\n"); >+ printf("I fear the JPEG software will not work at all.\n\n"); >+ return 0; /* try it with unsigned anyway */ >+ } >+ int main (void) { >+ exit(is_shifting_signed(-0x7F7E80B1L)); >+ }], >+ [AC_MSG_RESULT(no) >+ AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])], >+ [AC_MSG_RESULT(yes)], >+ [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)]) >+ >+# test whether global names are unique to at least 15 chars >+AC_MSG_CHECKING([for short external names]) >+AC_TRY_LINK( >+ [int possibly_duplicate_function () { return 0; } >+ int possibly_dupli_function () { return 1; }], [ ], >+ [AC_MSG_RESULT(ok)], >+ [AC_MSG_RESULT(short) >+ AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], 1, [Define if you need short function names])]) >+ >+# Checks for library functions. >+AC_CHECK_FUNCS([memset memcpy], [], >+ [AC_DEFINE([NEED_BSD_STRINGS], 1, >+ [Define if you have BSD-like bzero and bcopy])]) >+ >+# Set flags to indicate platform >+case "$host_os" in >+ cygwin* | mingw* | pw32* | interix*) >+ is_win32=1 >+ ;; >+esac >+AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"]) >+ >+# SIMD is optional >+AC_ARG_WITH([simd], >+ AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.])) >+if test "x${with_simd}" != "xno"; then >+ # Check if we're on a supported CPU >+ AC_MSG_CHECKING([if we have SIMD optimisations for cpu type]) >+ case "$host_cpu" in >+ x86_64 | amd64) >+ AC_MSG_RESULT([yes (x86_64)]) >+ AC_PROG_NASM >+ simd_arch=x86_64 >+ ;; >+ i*86 | x86 | ia32) >+ AC_MSG_RESULT([yes (i386)]) >+ AC_PROG_NASM >+ simd_arch=i386 >+ ;; >+ *) >+ AC_MSG_RESULT([no ("$host_cpu")]) >+ AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.]) >+ with_simd=no; >+ ;; >+ esac >+ >+ if test "x${with_simd}" != "xno"; then >+ AC_DEFINE([WITH_SIMD], [1], [Use accelerated SIMD routines.]) >+ fi >+fi >+ >+AM_CONDITIONAL([WITH_SIMD], [test "x$with_simd" != "xno"]) >+AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"]) >+AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"]) >+AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"]) >+ >+case "$host_cpu" in >+ x86_64) >+ RPMARCH=x86_64 >+ DEBARCH=amd64 >+ ;; >+ i*86 | x86 | ia32) >+ RPMARCH=i386 >+ DEBARCH=i386 >+ ;; >+esac >+ >+AC_SUBST(RPMARCH) >+AC_SUBST(DEBARCH) >+AC_SUBST(BUILD) >+ >+# jconfig.h is the file we use, but we have another before that to >+# fool autoheader. the reason is that we include this header in our >+# API headers, which can screw things up for users of the lib. >+# jconfig.h is a minimal version that allows this package to be built >+AC_CONFIG_HEADERS([config.h]) >+AC_CONFIG_HEADERS([jconfig.h]) >+AC_CONFIG_FILES([Makefile simd/Makefile]) >+AC_OUTPUT >diff --git a/modules/libjpeg-turbo/djpeg.1 b/modules/libjpeg-turbo/djpeg.1 >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/djpeg.1 >@@ -0,0 +1,253 @@ >+.TH DJPEG 1 "22 August 1997" >+.SH NAME >+djpeg \- decompress a JPEG file to an image file >+.SH SYNOPSIS >+.B djpeg >+[ >+.I options >+] >+[ >+.I filename >+] >+.LP >+.SH DESCRIPTION >+.LP >+.B djpeg >+decompresses the named JPEG file, or the standard input if no file is named, >+and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP, >+GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected. >+(RLE is supported only if the URT library is available.) >+.SH OPTIONS >+All switch names may be abbreviated; for example, >+.B \-grayscale >+may be written >+.B \-gray >+or >+.BR \-gr . >+Most of the "basic" switches can be abbreviated to as little as one letter. >+Upper and lower case are equivalent (thus >+.B \-BMP >+is the same as >+.BR \-bmp ). >+British spellings are also accepted (e.g., >+.BR \-greyscale ), >+though for brevity these are not mentioned below. >+.PP >+The basic switches are: >+.TP >+.BI \-colors " N" >+Reduce image to at most N colors. This reduces the number of colors used in >+the output image, so that it can be displayed on a colormapped display or >+stored in a colormapped file format. For example, if you have an 8-bit >+display, you'd need to reduce to 256 or fewer colors. >+.TP >+.BI \-quantize " N" >+Same as >+.BR \-colors . >+.B \-colors >+is the recommended name, >+.B \-quantize >+is provided only for backwards compatibility. >+.TP >+.B \-fast >+Select recommended processing options for fast, low quality output. (The >+default options are chosen for highest quality output.) Currently, this is >+equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR. >+.TP >+.B \-grayscale >+Force gray-scale output even if JPEG file is color. Useful for viewing on >+monochrome displays; also, >+.B djpeg >+runs noticeably faster in this mode. >+.TP >+.BI \-scale " M/N" >+Scale the output image by a factor M/N. Currently the scale factor must be >+1/1, 1/2, 1/4, or 1/8. Scaling is handy if the image is larger than your >+screen; also, >+.B djpeg >+runs much faster when scaling down the output. >+.TP >+.B \-bmp >+Select BMP output format (Windows flavor). 8-bit colormapped format is >+emitted if >+.B \-colors >+or >+.B \-grayscale >+is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color >+format is emitted. >+.TP >+.B \-gif >+Select GIF output format. Since GIF does not support more than 256 colors, >+.B \-colors 256 >+is assumed (unless you specify a smaller number of colors). >+.TP >+.B \-os2 >+Select BMP output format (OS/2 1.x flavor). 8-bit colormapped format is >+emitted if >+.B \-colors >+or >+.B \-grayscale >+is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color >+format is emitted. >+.TP >+.B \-pnm >+Select PBMPLUS (PPM/PGM) output format (this is the default format). >+PGM is emitted if the JPEG file is gray-scale or if >+.B \-grayscale >+is specified; otherwise PPM is emitted. >+.TP >+.B \-rle >+Select RLE output format. (Requires URT library.) >+.TP >+.B \-targa >+Select Targa output format. Gray-scale format is emitted if the JPEG file is >+gray-scale or if >+.B \-grayscale >+is specified; otherwise, colormapped format is emitted if >+.B \-colors >+is specified; otherwise, 24-bit full-color format is emitted. >+.PP >+Switches for advanced users: >+.TP >+.B \-dct int >+Use integer DCT method (default). >+.TP >+.B \-dct fast >+Use fast integer DCT (less accurate). >+.TP >+.B \-dct float >+Use floating-point DCT method. >+The float method is very slightly more accurate than the int method, but is >+much slower unless your machine has very fast floating-point hardware. Also >+note that results of the floating-point method may vary slightly across >+machines, while the integer methods should give the same results everywhere. >+The fast integer method is much less accurate than the other two. >+.TP >+.B \-dither fs >+Use Floyd-Steinberg dithering in color quantization. >+.TP >+.B \-dither ordered >+Use ordered dithering in color quantization. >+.TP >+.B \-dither none >+Do not use dithering in color quantization. >+By default, Floyd-Steinberg dithering is applied when quantizing colors; this >+is slow but usually produces the best results. Ordered dither is a compromise >+between speed and quality; no dithering is fast but usually looks awful. Note >+that these switches have no effect unless color quantization is being done. >+Ordered dither is only available in >+.B \-onepass >+mode. >+.TP >+.BI \-map " file" >+Quantize to the colors used in the specified image file. This is useful for >+producing multiple files with identical color maps, or for forcing a >+predefined set of colors to be used. The >+.I file >+must be a GIF or PPM file. This option overrides >+.B \-colors >+and >+.BR \-onepass . >+.TP >+.B \-nosmooth >+Use a faster, lower-quality upsampling routine. >+.TP >+.B \-onepass >+Use one-pass instead of two-pass color quantization. The one-pass method is >+faster and needs less memory, but it produces a lower-quality image. >+.B \-onepass >+is ignored unless you also say >+.B \-colors >+.IR N . >+Also, the one-pass method is always used for gray-scale output (the two-pass >+method is no improvement then). >+.TP >+.BI \-maxmemory " N" >+Set limit for amount of memory to use in processing large images. Value is >+in thousands of bytes, or millions of bytes if "M" is attached to the >+number. For example, >+.B \-max 4m >+selects 4000000 bytes. If more space is needed, temporary files will be used. >+.TP >+.BI \-outfile " name" >+Send output image to the named file, not to standard output. >+.TP >+.B \-verbose >+Enable debug printout. More >+.BR \-v 's >+give more output. Also, version information is printed at startup. >+.TP >+.B \-debug >+Same as >+.BR \-verbose . >+.SH EXAMPLES >+.LP >+This example decompresses the JPEG file foo.jpg, quantizes it to >+256 colors, and saves the output in 8-bit BMP format in foo.bmp: >+.IP >+.B djpeg \-colors 256 \-bmp >+.I foo.jpg >+.B > >+.I foo.bmp >+.SH HINTS >+To get a quick preview of an image, use the >+.B \-grayscale >+and/or >+.B \-scale >+switches. >+.B \-grayscale \-scale 1/8 >+is the fastest case. >+.PP >+Several options are available that trade off image quality to gain speed. >+.B \-fast >+turns on the recommended settings. >+.PP >+.B \-dct fast >+and/or >+.B \-nosmooth >+gain speed at a small sacrifice in quality. >+When producing a color-quantized image, >+.B \-onepass \-dither ordered >+is fast but much lower quality than the default behavior. >+.B \-dither none >+may give acceptable results in two-pass mode, but is seldom tolerable in >+one-pass mode. >+.PP >+If you are fortunate enough to have very fast floating point hardware, >+\fB\-dct float\fR may be even faster than \fB\-dct fast\fR. But on most >+machines \fB\-dct float\fR is slower than \fB\-dct int\fR; in this case it is >+not worth using, because its theoretical accuracy advantage is too small to be >+significant in practice. >+.SH ENVIRONMENT >+.TP >+.B JPEGMEM >+If this environment variable is set, its value is the default memory limit. >+The value is specified as described for the >+.B \-maxmemory >+switch. >+.B JPEGMEM >+overrides the default value specified when the program was compiled, and >+itself is overridden by an explicit >+.BR \-maxmemory . >+.SH SEE ALSO >+.BR cjpeg (1), >+.BR jpegtran (1), >+.BR rdjpgcom (1), >+.BR wrjpgcom (1) >+.br >+.BR ppm (5), >+.BR pgm (5) >+.br >+Wallace, Gregory K. "The JPEG Still Picture Compression Standard", >+Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. >+.SH AUTHOR >+Independent JPEG Group >+.SH BUGS >+Arithmetic coding is not supported for legal reasons. >+.PP >+To avoid the Unisys LZW patent, >+.B djpeg >+produces uncompressed GIF files. These are larger than they should be, but >+are readable by standard GIF decoders. >+.PP >+Still not as fast as we'd like. >diff --git a/jpeg/djpeg.c b/modules/libjpeg-turbo/djpeg.c >rename from jpeg/djpeg.c >rename to modules/libjpeg-turbo/djpeg.c >diff --git a/jpeg/example.c b/modules/libjpeg-turbo/example.c >rename from jpeg/example.c >rename to modules/libjpeg-turbo/example.c >diff --git a/jpeg/filelist.doc b/modules/libjpeg-turbo/filelist.doc >rename from jpeg/filelist.doc >rename to modules/libjpeg-turbo/filelist.doc >diff --git a/jpeg/install.doc b/modules/libjpeg-turbo/install.doc >rename from jpeg/install.doc >rename to modules/libjpeg-turbo/install.doc >diff --git a/jpeg/jcapimin.c b/modules/libjpeg-turbo/jcapimin.c >rename from jpeg/jcapimin.c >rename to modules/libjpeg-turbo/jcapimin.c >diff --git a/jpeg/jcapistd.c b/modules/libjpeg-turbo/jcapistd.c >rename from jpeg/jcapistd.c >rename to modules/libjpeg-turbo/jcapistd.c >diff --git a/jpeg/jccoefct.c b/modules/libjpeg-turbo/jccoefct.c >rename from jpeg/jccoefct.c >rename to modules/libjpeg-turbo/jccoefct.c >diff --git a/jpeg/jccolor.c b/modules/libjpeg-turbo/jccolor.c >rename from jpeg/jccolor.c >rename to modules/libjpeg-turbo/jccolor.c >--- a/jpeg/jccolor.c >+++ b/modules/libjpeg-turbo/jccolor.c >@@ -1,21 +1,24 @@ > /* > * jccolor.c > * > * Copyright (C) 1991-1996, Thomas G. Lane. >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+ * Copyright 2009 D. R. Commander > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains input colorspace conversion routines. > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" >+#include "jsimd.h" > > > /* Private subobject */ > > typedef struct { > struct jpeg_color_converter pub; /* public fields */ > > /* Private state for RGB->YCC conversion */ >@@ -73,16 +76,84 @@ typedef my_color_converter * my_cconvert > #define G_CB_OFF (4*(MAXJSAMPLE+1)) > #define B_CB_OFF (5*(MAXJSAMPLE+1)) > #define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */ > #define G_CR_OFF (6*(MAXJSAMPLE+1)) > #define B_CR_OFF (7*(MAXJSAMPLE+1)) > #define TABLE_SIZE (8*(MAXJSAMPLE+1)) > > >+#if BITS_IN_JSAMPLE == 8 >+ >+const unsigned char red_lut[256] = { >+ 0 , 0 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 4 , 4 , 4 , 4 , >+ 5 , 5 , 5 , 6 , 6 , 6 , 7 , 7 , 7 , 7 , 8 , 8 , 8 , 9 , 9 , 9 , >+ 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, >+ 14, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, >+ 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 24, >+ 24, 24, 25, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 28, >+ 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, >+ 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 36, 37, 37, 37, 38, 38, >+ 38, 39, 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42, 42, 42, 43, >+ 43, 43, 44, 44, 44, 45, 45, 45, 45, 46, 46, 46, 47, 47, 47, 48, >+ 48, 48, 48, 49, 49, 49, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, >+ 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 56, 56, 56, 57, 57, 57, >+ 57, 58, 58, 58, 59, 59, 59, 60, 60, 60, 60, 61, 61, 61, 62, 62, >+ 62, 62, 63, 63, 63, 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, >+ 67, 67, 68, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71, 71, >+ 72, 72, 72, 73, 73, 73, 74, 74, 74, 74, 75, 75, 75, 76, 76, 76 >+}; >+ >+const unsigned char green_lut[256] = { >+ 0 , 1 , 1 , 2 , 2 , 3 , 4 , 4 , 5 , 5 , 6 , 6 , >+ 7 , 8 , 8 , 9 , 9 , 10 , 11 , 11 , 12 , 12 , 13 , 14 , >+ 14 , 15 , 15 , 16 , 16 , 17 , 18 , 18 , 19 , 19 , 20 , 21 , >+ 21 , 22 , 22 , 23 , 23 , 24 , 25 , 25 , 26 , 26 , 27 , 28 , >+ 28 , 29 , 29 , 30 , 31 , 31 , 32 , 32 , 33 , 33 , 34 , 35 , >+ 35 , 36 , 36 , 37 , 38 , 38 , 39 , 39 , 40 , 41 , 41 , 42 , >+ 42 , 43 , 43 , 44 , 45 , 45 , 46 , 46 , 47 , 48 , 48 , 49 , >+ 49 , 50 , 50 , 51 , 52 , 52 , 53 , 53 , 54 , 55 , 55 , 56 , >+ 56 , 57 , 58 , 58 , 59 , 59 , 60 , 60 , 61 , 62 , 62 , 63 , >+ 63 , 64 , 65 , 65 , 66 , 66 , 67 , 68 , 68 , 69 , 69 , 70 , >+ 70 , 71 , 72 , 72 , 73 , 73 , 74 , 75 , 75 , 76 , 76 , 77 , >+ 77 , 78 , 79 , 79 , 80 , 80 , 81 , 82 , 82 , 83 , 83 , 84 , >+ 85 , 85 , 86 , 86 , 87 , 87 , 88 , 89 , 89 , 90 , 90 , 91 , >+ 92 , 92 , 93 , 93 , 94 , 95 , 95 , 96 , 96 , 97 , 97 , 98 , >+ 99 , 99 , 100, 100, 101, 102, 102, 103, 103, 104, 104, 105, >+ 106, 106, 107, 107, 108, 109, 109, 110, 110, 111, 112, 112, >+ 113, 113, 114, 114, 115, 116, 116, 117, 117, 118, 119, 119, >+ 120, 120, 121, 122, 122, 123, 123, 124, 124, 125, 126, 126, >+ 127, 127, 128, 129, 129, 130, 130, 131, 131, 132, 133, 133, >+ 34, 134, 135, 136, 136, 137, 137, 138, 139, 139, 140, 140, >+ 141, 141, 142, 143, 143, 144, 144, 145, 146, 146, 147, 147, >+ 148, 149, 149, 150 >+}; >+ >+const unsigned char blue_lut[256] = { >+ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 2 , >+ 2 , 2 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 4 , >+ 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , >+ 5 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 7 , 7 , 7 , 7 , 7 , 7 , >+ 7 , 7 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 9 , 9 , 9 , 9 , 9 , >+ 9 , 9 , 9 , 9 , 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, >+ 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, >+ 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, >+ 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, >+ 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, >+ 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, >+ 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, >+ 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, >+ 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, >+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, >+ 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29 >+}; >+ >+#endif >+ >+ > /* > * Initialize for RGB->YCC colorspace conversion. > */ > > METHODDEF(void) > rgb_ycc_start (j_compress_ptr cinfo) > { > my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; >@@ -141,20 +212,20 @@ rgb_ycc_convert (j_compress_ptr cinfo, > > while (--num_rows >= 0) { > inptr = *input_buf++; > outptr0 = output_buf[0][output_row]; > outptr1 = output_buf[1][output_row]; > outptr2 = output_buf[2][output_row]; > output_row++; > for (col = 0; col < num_cols; col++) { >- r = GETJSAMPLE(inptr[RGB_RED]); >- g = GETJSAMPLE(inptr[RGB_GREEN]); >- b = GETJSAMPLE(inptr[RGB_BLUE]); >- inptr += RGB_PIXELSIZE; >+ r = GETJSAMPLE(inptr[rgb_red[cinfo->in_color_space]]); >+ g = GETJSAMPLE(inptr[rgb_green[cinfo->in_color_space]]); >+ b = GETJSAMPLE(inptr[rgb_blue[cinfo->in_color_space]]); >+ inptr += rgb_pixelsize[cinfo->in_color_space]; > /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations > * must be too; we do not need an explicit range-limiting operation. > * Hence the value being shifted is never negative, and we don't > * need the general RIGHT_SHIFT macro. > */ > /* Y */ > outptr0[col] = (JSAMPLE) > ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) >@@ -183,36 +254,46 @@ rgb_ycc_convert (j_compress_ptr cinfo, > */ > > METHODDEF(void) > rgb_gray_convert (j_compress_ptr cinfo, > JSAMPARRAY input_buf, JSAMPIMAGE output_buf, > JDIMENSION output_row, int num_rows) > { > my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; >- register int r, g, b; >+ #if BITS_IN_JSAMPLE != 8 > register INT32 * ctab = cconvert->rgb_ycc_tab; >+ #endif > register JSAMPROW inptr; > register JSAMPROW outptr; >+ JSAMPLE *maxoutptr; > register JDIMENSION col; > JDIMENSION num_cols = cinfo->image_width; >+ int rindex = rgb_red[cinfo->in_color_space]; >+ int gindex = rgb_green[cinfo->in_color_space]; >+ int bindex = rgb_blue[cinfo->in_color_space]; >+ int rgbstride = rgb_pixelsize[cinfo->in_color_space]; > > while (--num_rows >= 0) { > inptr = *input_buf++; > outptr = output_buf[0][output_row]; >+ maxoutptr = &outptr[num_cols]; > output_row++; >- for (col = 0; col < num_cols; col++) { >- r = GETJSAMPLE(inptr[RGB_RED]); >- g = GETJSAMPLE(inptr[RGB_GREEN]); >- b = GETJSAMPLE(inptr[RGB_BLUE]); >- inptr += RGB_PIXELSIZE; >+ for (; outptr < maxoutptr; outptr++, inptr += rgbstride) { > /* Y */ >- outptr[col] = (JSAMPLE) >- ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) >- >> SCALEBITS); >+ #if BITS_IN_JSAMPLE == 8 >+ *outptr = red_lut[inptr[rindex]] + green_lut[inptr[gindex]] >+ + blue_lut[inptr[bindex]]; >+ #else >+ *outptr = (JSAMPLE) >+ ((ctab[GETJSAMPLE(inptr[rindex])+R_Y_OFF] >+ + ctab[GETJSAMPLE(inptr[gindex])+G_Y_OFF] >+ + ctab[GETJSAMPLE(inptr[bindex])+B_Y_OFF]) >+ >> SCALEBITS); >+ #endif > } > } > } > > > /* > * Convert some rows of samples to the JPEG colorspace. > * This version handles Adobe-style CMYK->YCCK conversion, >@@ -363,21 +444,25 @@ jinit_color_converter (j_compress_ptr ci > /* Make sure input_components agrees with in_color_space */ > switch (cinfo->in_color_space) { > case JCS_GRAYSCALE: > if (cinfo->input_components != 1) > ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); > break; > > case JCS_RGB: >-#if RGB_PIXELSIZE != 3 >- if (cinfo->input_components != RGB_PIXELSIZE) >+ case JCS_EXT_RGB: >+ case JCS_EXT_RGBX: >+ case JCS_EXT_BGR: >+ case JCS_EXT_BGRX: >+ case JCS_EXT_XBGR: >+ case JCS_EXT_XRGB: >+ if (cinfo->input_components != rgb_pixelsize[cinfo->in_color_space]) > ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); > break; >-#endif /* else share code with YCbCr */ > > case JCS_YCbCr: > if (cinfo->input_components != 3) > ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); > break; > > case JCS_CMYK: > case JCS_YCCK: >@@ -393,40 +478,63 @@ jinit_color_converter (j_compress_ptr ci > > /* Check num_components, set conversion method based on requested space */ > switch (cinfo->jpeg_color_space) { > case JCS_GRAYSCALE: > if (cinfo->num_components != 1) > ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); > if (cinfo->in_color_space == JCS_GRAYSCALE) > cconvert->pub.color_convert = grayscale_convert; >- else if (cinfo->in_color_space == JCS_RGB) { >+ else if (cinfo->in_color_space == JCS_RGB || >+ cinfo->in_color_space == JCS_EXT_RGB || >+ cinfo->in_color_space == JCS_EXT_RGBX || >+ cinfo->in_color_space == JCS_EXT_BGR || >+ cinfo->in_color_space == JCS_EXT_BGRX || >+ cinfo->in_color_space == JCS_EXT_XBGR || >+ cinfo->in_color_space == JCS_EXT_XRGB) { > cconvert->pub.start_pass = rgb_ycc_start; > cconvert->pub.color_convert = rgb_gray_convert; > } else if (cinfo->in_color_space == JCS_YCbCr) > cconvert->pub.color_convert = grayscale_convert; > else > ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); > break; > > case JCS_RGB: >+ case JCS_EXT_RGB: >+ case JCS_EXT_RGBX: >+ case JCS_EXT_BGR: >+ case JCS_EXT_BGRX: >+ case JCS_EXT_XBGR: >+ case JCS_EXT_XRGB: > if (cinfo->num_components != 3) > ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); >- if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) >+ if (cinfo->in_color_space == cinfo->jpeg_color_space && >+ rgb_pixelsize[cinfo->in_color_space] == 3) > cconvert->pub.color_convert = null_convert; > else > ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); > break; > > case JCS_YCbCr: > if (cinfo->num_components != 3) > ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); >- if (cinfo->in_color_space == JCS_RGB) { >- cconvert->pub.start_pass = rgb_ycc_start; >- cconvert->pub.color_convert = rgb_ycc_convert; >+ if (cinfo->in_color_space == JCS_RGB || >+ cinfo->in_color_space == JCS_EXT_RGB || >+ cinfo->in_color_space == JCS_EXT_RGBX || >+ cinfo->in_color_space == JCS_EXT_BGR || >+ cinfo->in_color_space == JCS_EXT_BGRX || >+ cinfo->in_color_space == JCS_EXT_XBGR || >+ cinfo->in_color_space == JCS_EXT_XRGB) { >+ if (jsimd_can_rgb_ycc()) >+ cconvert->pub.color_convert = jsimd_rgb_ycc_convert; >+ else { >+ cconvert->pub.start_pass = rgb_ycc_start; >+ cconvert->pub.color_convert = rgb_ycc_convert; >+ } > } else if (cinfo->in_color_space == JCS_YCbCr) > cconvert->pub.color_convert = null_convert; > else > ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); > break; > > case JCS_CMYK: > if (cinfo->num_components != 4) >diff --git a/jpeg/jcdctmgr.c b/modules/libjpeg-turbo/jcdctmgr.c >rename from jpeg/jcdctmgr.c >rename to modules/libjpeg-turbo/jcdctmgr.c >--- a/jpeg/jcdctmgr.c >+++ b/modules/libjpeg-turbo/jcdctmgr.c >@@ -1,52 +1,202 @@ > /* > * jcdctmgr.c > * > * Copyright (C) 1994-1996, Thomas G. Lane. >+ * Copyright (C) 1999-2006, MIYASAKA Masaru. >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains the forward-DCT management logic. > * This code selects a particular DCT implementation to be used, > * and it performs related housekeeping chores including coefficient > * quantization. > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" > #include "jdct.h" /* Private declarations for DCT subsystem */ >+#include "jsimddct.h" > > > /* Private subobject for this module */ > >+typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); >+typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); >+ >+typedef JMETHOD(void, convsamp_method_ptr, >+ (JSAMPARRAY sample_data, JDIMENSION start_col, >+ DCTELEM * workspace)); >+typedef JMETHOD(void, float_convsamp_method_ptr, >+ (JSAMPARRAY sample_data, JDIMENSION start_col, >+ FAST_FLOAT *workspace)); >+ >+typedef JMETHOD(void, quantize_method_ptr, >+ (JCOEFPTR coef_block, DCTELEM * divisors, >+ DCTELEM * workspace)); >+typedef JMETHOD(void, float_quantize_method_ptr, >+ (JCOEFPTR coef_block, FAST_FLOAT * divisors, >+ FAST_FLOAT * workspace)); >+ > typedef struct { > struct jpeg_forward_dct pub; /* public fields */ > > /* Pointer to the DCT routine actually in use */ >- forward_DCT_method_ptr do_dct; >+ forward_DCT_method_ptr dct; >+ convsamp_method_ptr convsamp; >+ quantize_method_ptr quantize; > > /* The actual post-DCT divisors --- not identical to the quant table > * entries, because of scaling (especially for an unnormalized DCT). > * Each table is given in normal array order. > */ > DCTELEM * divisors[NUM_QUANT_TBLS]; > >+ /* work area for FDCT subroutine */ >+ DCTELEM * workspace; >+ > #ifdef DCT_FLOAT_SUPPORTED > /* Same as above for the floating-point case. */ >- float_DCT_method_ptr do_float_dct; >+ float_DCT_method_ptr float_dct; >+ float_convsamp_method_ptr float_convsamp; >+ float_quantize_method_ptr float_quantize; > FAST_FLOAT * float_divisors[NUM_QUANT_TBLS]; >+ FAST_FLOAT * float_workspace; > #endif > } my_fdct_controller; > > typedef my_fdct_controller * my_fdct_ptr; > > > /* >+ * Find the highest bit in an integer through binary search. >+ */ >+LOCAL(int) >+flss (UINT16 val) >+{ >+ int bit; >+ >+ bit = 16; >+ >+ if (!val) >+ return 0; >+ >+ if (!(val & 0xff00)) { >+ bit -= 8; >+ val <<= 8; >+ } >+ if (!(val & 0xf000)) { >+ bit -= 4; >+ val <<= 4; >+ } >+ if (!(val & 0xc000)) { >+ bit -= 2; >+ val <<= 2; >+ } >+ if (!(val & 0x8000)) { >+ bit -= 1; >+ val <<= 1; >+ } >+ >+ return bit; >+} >+ >+/* >+ * Compute values to do a division using reciprocal. >+ * >+ * This implementation is based on an algorithm described in >+ * "How to optimize for the Pentium family of microprocessors" >+ * (http://www.agner.org/assem/). >+ * More information about the basic algorithm can be found in >+ * the paper "Integer Division Using Reciprocals" by Robert Alverson. >+ * >+ * The basic idea is to replace x/d by x * d^-1. In order to store >+ * d^-1 with enough precision we shift it left a few places. It turns >+ * out that this algoright gives just enough precision, and also fits >+ * into DCTELEM: >+ * >+ * b = (the number of significant bits in divisor) - 1 >+ * r = (word size) + b >+ * f = 2^r / divisor >+ * >+ * f will not be an integer for most cases, so we need to compensate >+ * for the rounding error introduced: >+ * >+ * no fractional part: >+ * >+ * result = input >> r >+ * >+ * fractional part of f < 0.5: >+ * >+ * round f down to nearest integer >+ * result = ((input + 1) * f) >> r >+ * >+ * fractional part of f > 0.5: >+ * >+ * round f up to nearest integer >+ * result = (input * f) >> r >+ * >+ * This is the original algorithm that gives truncated results. But we >+ * want properly rounded results, so we replace "input" with >+ * "input + divisor/2". >+ * >+ * In order to allow SIMD implementations we also tweak the values to >+ * allow the same calculation to be made at all times: >+ * >+ * dctbl[0] = f rounded to nearest integer >+ * dctbl[1] = divisor / 2 (+ 1 if fractional part of f < 0.5) >+ * dctbl[2] = 1 << ((word size) * 2 - r) >+ * dctbl[3] = r - (word size) >+ * >+ * dctbl[2] is for stupid instruction sets where the shift operation >+ * isn't member wise (e.g. MMX). >+ * >+ * The reason dctbl[2] and dctbl[3] reduce the shift with (word size) >+ * is that most SIMD implementations have a "multiply and store top >+ * half" operation. >+ * >+ * Lastly, we store each of the values in their own table instead >+ * of in a consecutive manner, yet again in order to allow SIMD >+ * routines. >+ */ >+LOCAL(void) >+compute_reciprocal (UINT16 divisor, DCTELEM * dtbl) >+{ >+ UDCTELEM2 fq, fr; >+ UDCTELEM c; >+ int b, r; >+ >+ b = flss(divisor) - 1; >+ r = sizeof(DCTELEM) * 8 + b; >+ >+ fq = ((UDCTELEM2)1 << r) / divisor; >+ fr = ((UDCTELEM2)1 << r) % divisor; >+ >+ c = divisor / 2; /* for rounding */ >+ >+ if (fr == 0) { /* divisor is power of two */ >+ /* fq will be one bit too large to fit in DCTELEM, so adjust */ >+ fq >>= 1; >+ r--; >+ } else if (fr <= (divisor / 2)) { /* fractional part is < 0.5 */ >+ c++; >+ } else { /* fractional part is > 0.5 */ >+ fq++; >+ } >+ >+ dtbl[DCTSIZE2 * 0] = (DCTELEM) fq; /* reciprocal */ >+ dtbl[DCTSIZE2 * 1] = (DCTELEM) c; /* correction + roundfactor */ >+ dtbl[DCTSIZE2 * 2] = (DCTELEM) (1 << (sizeof(DCTELEM)*8*2 - r)); /* scale */ >+ dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */ >+} >+ >+/* > * Initialize for a processing pass. > * Verify that all referenced Q-tables are present, and set up > * the divisor table for each one. > * In the current implementation, DCT of all components is done during > * the first pass, even if only some components will be output in the > * first scan. Hence all components should be examined here. > */ > >@@ -73,21 +223,21 @@ start_pass_fdctmgr (j_compress_ptr cinfo > #ifdef DCT_ISLOW_SUPPORTED > case JDCT_ISLOW: > /* For LL&M IDCT method, divisors are equal to raw quantization > * coefficients multiplied by 8 (to counteract scaling). > */ > if (fdct->divisors[qtblno] == NULL) { > fdct->divisors[qtblno] = (DCTELEM *) > (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >- DCTSIZE2 * SIZEOF(DCTELEM)); >+ (DCTSIZE2 * 4) * SIZEOF(DCTELEM)); > } > dtbl = fdct->divisors[qtblno]; > for (i = 0; i < DCTSIZE2; i++) { >- dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3; >+ compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]); > } > break; > #endif > #ifdef DCT_IFAST_SUPPORTED > case JDCT_IFAST: > { > /* For AA&N IDCT method, divisors are equal to quantization > * coefficients scaled by scalefactor[row]*scalefactor[col], where >@@ -107,24 +257,24 @@ start_pass_fdctmgr (j_compress_ptr cinfo > 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, > 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 > }; > SHIFT_TEMPS > > if (fdct->divisors[qtblno] == NULL) { > fdct->divisors[qtblno] = (DCTELEM *) > (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >- DCTSIZE2 * SIZEOF(DCTELEM)); >+ (DCTSIZE2 * 4) * SIZEOF(DCTELEM)); > } > dtbl = fdct->divisors[qtblno]; > for (i = 0; i < DCTSIZE2; i++) { >- dtbl[i] = (DCTELEM) >+ compute_reciprocal( > DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], > (INT32) aanscales[i]), >- CONST_BITS-3); >+ CONST_BITS-3), &dtbl[i]); > } > } > break; > #endif > #ifdef DCT_FLOAT_SUPPORTED > case JDCT_FLOAT: > { > /* For float AA&N IDCT method, divisors are equal to quantization >@@ -164,178 +314,215 @@ start_pass_fdctmgr (j_compress_ptr cinfo > ERREXIT(cinfo, JERR_NOT_COMPILED); > break; > } > } > } > > > /* >+ * Load data into workspace, applying unsigned->signed conversion. >+ */ >+ >+METHODDEF(void) >+convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM * workspace) >+{ >+ register DCTELEM *workspaceptr; >+ register JSAMPROW elemptr; >+ register int elemr; >+ >+ workspaceptr = workspace; >+ for (elemr = 0; elemr < DCTSIZE; elemr++) { >+ elemptr = sample_data[elemr] + start_col; >+ >+#if DCTSIZE == 8 /* unroll the inner loop */ >+ *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >+ *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >+ *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >+ *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >+ *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >+ *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >+ *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >+ *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >+#else >+ { >+ register int elemc; >+ for (elemc = DCTSIZE; elemc > 0; elemc--) >+ *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >+ } >+#endif >+ } >+} >+ >+ >+/* >+ * Quantize/descale the coefficients, and store into coef_blocks[]. >+ */ >+ >+METHODDEF(void) >+quantize (JCOEFPTR coef_block, DCTELEM * divisors, DCTELEM * workspace) >+{ >+ int i; >+ DCTELEM temp; >+ UDCTELEM recip, corr, shift; >+ UDCTELEM2 product; >+ JCOEFPTR output_ptr = coef_block; >+ >+ for (i = 0; i < DCTSIZE2; i++) { >+ temp = workspace[i]; >+ recip = divisors[i + DCTSIZE2 * 0]; >+ corr = divisors[i + DCTSIZE2 * 1]; >+ shift = divisors[i + DCTSIZE2 * 3]; >+ >+ if (temp < 0) { >+ temp = -temp; >+ product = (UDCTELEM2)(temp + corr) * recip; >+ product >>= shift + sizeof(DCTELEM)*8; >+ temp = product; >+ temp = -temp; >+ } else { >+ product = (UDCTELEM2)(temp + corr) * recip; >+ product >>= shift + sizeof(DCTELEM)*8; >+ temp = product; >+ } >+ >+ output_ptr[i] = (JCOEF) temp; >+ } >+} >+ >+ >+/* > * Perform forward DCT on one or more blocks of a component. > * > * The input samples are taken from the sample_data[] array starting at > * position start_row/start_col, and moving to the right for any additional > * blocks. The quantized coefficients are returned in coef_blocks[]. > */ > > METHODDEF(void) > forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, > JSAMPARRAY sample_data, JBLOCKROW coef_blocks, > JDIMENSION start_row, JDIMENSION start_col, > JDIMENSION num_blocks) > /* This version is used for integer DCT implementations. */ > { > /* This routine is heavily used, so it's worth coding it tightly. */ > my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; >- forward_DCT_method_ptr do_dct = fdct->do_dct; > DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no]; >- DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ >+ DCTELEM * workspace; > JDIMENSION bi; > >+ /* Make sure the compiler doesn't look up these every pass */ >+ forward_DCT_method_ptr do_dct = fdct->dct; >+ convsamp_method_ptr do_convsamp = fdct->convsamp; >+ quantize_method_ptr do_quantize = fdct->quantize; >+ workspace = fdct->workspace; >+ > sample_data += start_row; /* fold in the vertical offset once */ > > for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { > /* Load data into workspace, applying unsigned->signed conversion */ >- { register DCTELEM *workspaceptr; >- register JSAMPROW elemptr; >- register int elemr; >- >- workspaceptr = workspace; >- for (elemr = 0; elemr < DCTSIZE; elemr++) { >- elemptr = sample_data[elemr] + start_col; >-#if DCTSIZE == 8 /* unroll the inner loop */ >- *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >- *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >- *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >- *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >- *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >- *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >- *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >- *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >-#else >- { register int elemc; >- for (elemc = DCTSIZE; elemc > 0; elemc--) { >- *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; >- } >- } >-#endif >- } >- } >+ (*do_convsamp) (sample_data, start_col, workspace); > > /* Perform the DCT */ > (*do_dct) (workspace); > > /* Quantize/descale the coefficients, and store into coef_blocks[] */ >- { register DCTELEM temp, qval; >- register int i; >- register JCOEFPTR output_ptr = coef_blocks[bi]; >- >- for (i = 0; i < DCTSIZE2; i++) { >- qval = divisors[i]; >- temp = workspace[i]; >- /* Divide the coefficient value by qval, ensuring proper rounding. >- * Since C does not specify the direction of rounding for negative >- * quotients, we have to force the dividend positive for portability. >- * >- * In most files, at least half of the output values will be zero >- * (at default quantization settings, more like three-quarters...) >- * so we should ensure that this case is fast. On many machines, >- * a comparison is enough cheaper than a divide to make a special test >- * a win. Since both inputs will be nonnegative, we need only test >- * for a < b to discover whether a/b is 0. >- * If your machine's division is fast enough, define FAST_DIVIDE. >- */ >-#ifdef FAST_DIVIDE >-#define DIVIDE_BY(a,b) a /= b >-#else >-#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 >-#endif >- if (temp < 0) { >- temp = -temp; >- temp += qval>>1; /* for rounding */ >- DIVIDE_BY(temp, qval); >- temp = -temp; >- } else { >- temp += qval>>1; /* for rounding */ >- DIVIDE_BY(temp, qval); >- } >- output_ptr[i] = (JCOEF) temp; >- } >- } >+ (*do_quantize) (coef_blocks[bi], divisors, workspace); > } > } > > > #ifdef DCT_FLOAT_SUPPORTED > >+ >+METHODDEF(void) >+convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, FAST_FLOAT * workspace) >+{ >+ register FAST_FLOAT *workspaceptr; >+ register JSAMPROW elemptr; >+ register int elemr; >+ >+ workspaceptr = workspace; >+ for (elemr = 0; elemr < DCTSIZE; elemr++) { >+ elemptr = sample_data[elemr] + start_col; >+#if DCTSIZE == 8 /* unroll the inner loop */ >+ *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >+ *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >+ *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >+ *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >+ *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >+ *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >+ *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >+ *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >+#else >+ { >+ register int elemc; >+ for (elemc = DCTSIZE; elemc > 0; elemc--) >+ *workspaceptr++ = (FAST_FLOAT) >+ (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >+ } >+#endif >+ } >+} >+ >+ >+METHODDEF(void) >+quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, FAST_FLOAT * workspace) >+{ >+ register FAST_FLOAT temp; >+ register int i; >+ register JCOEFPTR output_ptr = coef_block; >+ >+ for (i = 0; i < DCTSIZE2; i++) { >+ /* Apply the quantization and scaling factor */ >+ temp = workspace[i] * divisors[i]; >+ >+ /* Round to nearest integer. >+ * Since C does not specify the direction of rounding for negative >+ * quotients, we have to force the dividend positive for portability. >+ * The maximum coefficient size is +-16K (for 12-bit data), so this >+ * code should work for either 16-bit or 32-bit ints. >+ */ >+ output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); >+ } >+} >+ >+ > METHODDEF(void) > forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, > JSAMPARRAY sample_data, JBLOCKROW coef_blocks, > JDIMENSION start_row, JDIMENSION start_col, > JDIMENSION num_blocks) > /* This version is used for floating-point DCT implementations. */ > { > /* This routine is heavily used, so it's worth coding it tightly. */ > my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; >- float_DCT_method_ptr do_dct = fdct->do_float_dct; > FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no]; >- FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ >+ FAST_FLOAT * workspace; > JDIMENSION bi; > >+ >+ /* Make sure the compiler doesn't look up these every pass */ >+ float_DCT_method_ptr do_dct = fdct->float_dct; >+ float_convsamp_method_ptr do_convsamp = fdct->float_convsamp; >+ float_quantize_method_ptr do_quantize = fdct->float_quantize; >+ workspace = fdct->float_workspace; >+ > sample_data += start_row; /* fold in the vertical offset once */ > > for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { > /* Load data into workspace, applying unsigned->signed conversion */ >- { register FAST_FLOAT *workspaceptr; >- register JSAMPROW elemptr; >- register int elemr; >- >- workspaceptr = workspace; >- for (elemr = 0; elemr < DCTSIZE; elemr++) { >- elemptr = sample_data[elemr] + start_col; >-#if DCTSIZE == 8 /* unroll the inner loop */ >- *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >- *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >- *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >- *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >- *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >- *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >- *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >- *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >-#else >- { register int elemc; >- for (elemc = DCTSIZE; elemc > 0; elemc--) { >- *workspaceptr++ = (FAST_FLOAT) >- (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); >- } >- } >-#endif >- } >- } >+ (*do_convsamp) (sample_data, start_col, workspace); > > /* Perform the DCT */ > (*do_dct) (workspace); > > /* Quantize/descale the coefficients, and store into coef_blocks[] */ >- { register FAST_FLOAT temp; >- register int i; >- register JCOEFPTR output_ptr = coef_blocks[bi]; >- >- for (i = 0; i < DCTSIZE2; i++) { >- /* Apply the quantization and scaling factor */ >- temp = workspace[i] * divisors[i]; >- /* Round to nearest integer. >- * Since C does not specify the direction of rounding for negative >- * quotients, we have to force the dividend positive for portability. >- * The maximum coefficient size is +-16K (for 12-bit data), so this >- * code should work for either 16-bit or 32-bit ints. >- */ >- output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); >- } >- } >+ (*do_quantize) (coef_blocks[bi], divisors, workspace); > } > } > > #endif /* DCT_FLOAT_SUPPORTED */ > > > /* > * Initialize FDCT manager. >@@ -348,40 +535,98 @@ jinit_forward_dct (j_compress_ptr cinfo) > int i; > > fdct = (my_fdct_ptr) > (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, > SIZEOF(my_fdct_controller)); > cinfo->fdct = (struct jpeg_forward_dct *) fdct; > fdct->pub.start_pass = start_pass_fdctmgr; > >+ /* First determine the DCT... */ > switch (cinfo->dct_method) { > #ifdef DCT_ISLOW_SUPPORTED > case JDCT_ISLOW: > fdct->pub.forward_DCT = forward_DCT; >- fdct->do_dct = jpeg_fdct_islow; >+ if (jsimd_can_fdct_islow()) >+ fdct->dct = jsimd_fdct_islow; >+ else >+ fdct->dct = jpeg_fdct_islow; > break; > #endif > #ifdef DCT_IFAST_SUPPORTED > case JDCT_IFAST: > fdct->pub.forward_DCT = forward_DCT; >- fdct->do_dct = jpeg_fdct_ifast; >+ if (jsimd_can_fdct_ifast()) >+ fdct->dct = jsimd_fdct_ifast; >+ else >+ fdct->dct = jpeg_fdct_ifast; > break; > #endif > #ifdef DCT_FLOAT_SUPPORTED > case JDCT_FLOAT: > fdct->pub.forward_DCT = forward_DCT_float; >- fdct->do_float_dct = jpeg_fdct_float; >+ if (jsimd_can_fdct_float()) >+ fdct->float_dct = jsimd_fdct_float; >+ else >+ fdct->float_dct = jpeg_fdct_float; > break; > #endif > default: > ERREXIT(cinfo, JERR_NOT_COMPILED); > break; > } > >+ /* ...then the supporting stages. */ >+ switch (cinfo->dct_method) { >+#ifdef DCT_ISLOW_SUPPORTED >+ case JDCT_ISLOW: >+#endif >+#ifdef DCT_IFAST_SUPPORTED >+ case JDCT_IFAST: >+#endif >+#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED) >+ if (jsimd_can_convsamp()) >+ fdct->convsamp = jsimd_convsamp; >+ else >+ fdct->convsamp = convsamp; >+ if (jsimd_can_quantize()) >+ fdct->quantize = jsimd_quantize; >+ else >+ fdct->quantize = quantize; >+ break; >+#endif >+#ifdef DCT_FLOAT_SUPPORTED >+ case JDCT_FLOAT: >+ if (jsimd_can_convsamp_float()) >+ fdct->float_convsamp = jsimd_convsamp_float; >+ else >+ fdct->float_convsamp = convsamp_float; >+ if (jsimd_can_quantize_float()) >+ fdct->float_quantize = jsimd_quantize_float; >+ else >+ fdct->float_quantize = quantize_float; >+ break; >+#endif >+ default: >+ ERREXIT(cinfo, JERR_NOT_COMPILED); >+ break; >+ } >+ >+ /* Allocate workspace memory */ >+#ifdef DCT_FLOAT_SUPPORTED >+ if (cinfo->dct_method == JDCT_FLOAT) >+ fdct->float_workspace = (FAST_FLOAT *) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(FAST_FLOAT) * DCTSIZE2); >+ else >+#endif >+ fdct->workspace = (DCTELEM *) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(DCTELEM) * DCTSIZE2); >+ > /* Mark divisor tables unallocated */ > for (i = 0; i < NUM_QUANT_TBLS; i++) { > fdct->divisors[i] = NULL; > #ifdef DCT_FLOAT_SUPPORTED > fdct->float_divisors[i] = NULL; > #endif > } > } >diff --git a/jpeg/jchuff.c b/modules/libjpeg-turbo/jchuff.c >rename from jpeg/jchuff.c >rename to modules/libjpeg-turbo/jchuff.c >--- a/jpeg/jchuff.c >+++ b/modules/libjpeg-turbo/jchuff.c >@@ -14,16 +14,19 @@ > * permanent JPEG objects only upon successful completion of an MCU. > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" > #include "jchuff.h" /* Declarations shared with jcphuff.c */ > >+/* MOZILLA CHANGE: libjpeg-turbo doesn't define INLINE in its config file, so >+ * we define it here. */ >+#define INLINE > > /* Expanded entropy encoder object for Huffman encoding. > * > * The savable_state subrecord contains fields that change within an MCU, > * but must not be updated permanently until we complete the MCU. > */ > > typedef struct { >diff --git a/jpeg/jchuff.h b/modules/libjpeg-turbo/jchuff.h >rename from jpeg/jchuff.h >rename to modules/libjpeg-turbo/jchuff.h >diff --git a/jpeg/jcinit.c b/modules/libjpeg-turbo/jcinit.c >rename from jpeg/jcinit.c >rename to modules/libjpeg-turbo/jcinit.c >diff --git a/jpeg/jcmainct.c b/modules/libjpeg-turbo/jcmainct.c >rename from jpeg/jcmainct.c >rename to modules/libjpeg-turbo/jcmainct.c >diff --git a/jpeg/jcmarker.c b/modules/libjpeg-turbo/jcmarker.c >rename from jpeg/jcmarker.c >rename to modules/libjpeg-turbo/jcmarker.c >--- a/jpeg/jcmarker.c >+++ b/modules/libjpeg-turbo/jcmarker.c >@@ -70,17 +70,19 @@ typedef enum { /* JPEG marker codes */ > M_APP13 = 0xed, > M_APP14 = 0xee, > M_APP15 = 0xef, > > M_JPG0 = 0xf0, > M_JPG13 = 0xfd, > M_COM = 0xfe, > >- M_TEM = 0x01 >+ M_TEM = 0x01, >+ >+ M_ERROR = 0x100 > } JPEG_MARKER; > > > /* Private state */ > > typedef struct { > struct jpeg_marker_writer pub; /* public fields */ > >@@ -98,17 +100,17 @@ typedef my_marker_writer * my_marker_ptr > * enough buffer space for the initial markers (typ. 600-700 bytes) before > * calling jpeg_start_compress, and enough space to write the trailing EOI > * (a few bytes) before calling jpeg_finish_compress. Multipass compression > * modes are not supported at all with suspension, so those two are the only > * points where markers will be written. > */ > > LOCAL(void) >-emit_byte (j_compress_ptr cinfo, int16 val) >+emit_byte (j_compress_ptr cinfo, int val) > /* Emit a byte */ > { > struct jpeg_destination_mgr * dest = cinfo->dest; > > *(dest->next_output_byte)++ = (JOCTET) val; > if (--dest->free_in_buffer == 0) { > if (! (*dest->empty_output_buffer) (cinfo)) > ERREXIT(cinfo, JERR_CANT_SUSPEND); >@@ -116,41 +118,41 @@ emit_byte (j_compress_ptr cinfo, int16 v > } > > > LOCAL(void) > emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) > /* Emit a marker code */ > { > emit_byte(cinfo, 0xFF); >- emit_byte(cinfo, (int16) mark); >+ emit_byte(cinfo, (int) mark); > } > > > LOCAL(void) >-emit_2bytes (j_compress_ptr cinfo, int16 value) >+emit_2bytes (j_compress_ptr cinfo, int value) > /* Emit a 2-byte integer; these are always MSB first in JPEG files */ > { > emit_byte(cinfo, (value >> 8) & 0xFF); > emit_byte(cinfo, value & 0xFF); > } > > > /* > * Routines to write specific marker types. > */ > >-LOCAL(int16) >-emit_dqt (j_compress_ptr cinfo, int16 index) >+LOCAL(int) >+emit_dqt (j_compress_ptr cinfo, int index) > /* Emit a DQT marker */ > /* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ > { > JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; >- int16 prec; >- int16 i; >+ int prec; >+ int i; > > if (qtbl == NULL) > ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); > > prec = 0; > for (i = 0; i < DCTSIZE2; i++) { > if (qtbl->quantval[i] > 255) > prec = 1; >@@ -162,33 +164,33 @@ emit_dqt (j_compress_ptr cinfo, int16 in > emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); > > emit_byte(cinfo, index + (prec<<4)); > > for (i = 0; i < DCTSIZE2; i++) { > /* The table entries must be emitted in zigzag order. */ > unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; > if (prec) >- emit_byte(cinfo, (int16) (qval >> 8)); >- emit_byte(cinfo, (int16) (qval & 0xFF)); >+ emit_byte(cinfo, (int) (qval >> 8)); >+ emit_byte(cinfo, (int) (qval & 0xFF)); > } > > qtbl->sent_table = TRUE; > } > > return prec; > } > > > LOCAL(void) >-emit_dht (j_compress_ptr cinfo, int16 index, boolean is_ac) >+emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) > /* Emit a DHT marker */ > { > JHUFF_TBL * htbl; >- int16 length, i; >+ int length, i; > > if (is_ac) { > htbl = cinfo->ac_huff_tbl_ptrs[index]; > index += 0x10; /* output index has AC bit set */ > } else { > htbl = cinfo->dc_huff_tbl_ptrs[index]; > } > >@@ -220,17 +222,17 @@ LOCAL(void) > emit_dac (j_compress_ptr cinfo) > /* Emit a DAC marker */ > /* Since the useful info is so small, we want to emit all the tables in */ > /* one DAC marker. Therefore this routine does its own scan of the table. */ > { > #ifdef C_ARITH_CODING_SUPPORTED > char dc_in_use[NUM_ARITH_TBLS]; > char ac_in_use[NUM_ARITH_TBLS]; >- int16 length, i; >+ int length, i; > jpeg_component_info *compptr; > > for (i = 0; i < NUM_ARITH_TBLS; i++) > dc_in_use[i] = ac_in_use[i] = 0; > > for (i = 0; i < cinfo->comps_in_scan; i++) { > compptr = cinfo->cur_comp_info[i]; > dc_in_use[compptr->dc_tbl_no] = 1; >@@ -262,56 +264,56 @@ emit_dac (j_compress_ptr cinfo) > LOCAL(void) > emit_dri (j_compress_ptr cinfo) > /* Emit a DRI marker */ > { > emit_marker(cinfo, M_DRI); > > emit_2bytes(cinfo, 4); /* fixed length */ > >- emit_2bytes(cinfo, (int16) cinfo->restart_interval); >+ emit_2bytes(cinfo, (int) cinfo->restart_interval); > } > > > LOCAL(void) > emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) > /* Emit a SOF marker */ > { >- int16 ci; >+ int ci; > jpeg_component_info *compptr; > > emit_marker(cinfo, code); > > emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ > > /* Make sure image isn't bigger than SOF field can handle */ > if ((long) cinfo->image_height > 65535L || > (long) cinfo->image_width > 65535L) > ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); > > emit_byte(cinfo, cinfo->data_precision); >- emit_2bytes(cinfo, (int16) cinfo->image_height); >- emit_2bytes(cinfo, (int16) cinfo->image_width); >+ emit_2bytes(cinfo, (int) cinfo->image_height); >+ emit_2bytes(cinfo, (int) cinfo->image_width); > > emit_byte(cinfo, cinfo->num_components); > > for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; > ci++, compptr++) { > emit_byte(cinfo, compptr->component_id); > emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); > emit_byte(cinfo, compptr->quant_tbl_no); > } > } > > > LOCAL(void) > emit_sos (j_compress_ptr cinfo) > /* Emit a SOS marker */ > { >- int16 i, td, ta; >+ int i, td, ta; > jpeg_component_info *compptr; > > emit_marker(cinfo, M_SOS); > > emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ > > emit_byte(cinfo, cinfo->comps_in_scan); > >@@ -366,18 +368,18 @@ emit_jfif_app0 (j_compress_ptr cinfo) > emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ > emit_byte(cinfo, 0x46); > emit_byte(cinfo, 0x49); > emit_byte(cinfo, 0x46); > emit_byte(cinfo, 0); > emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ > emit_byte(cinfo, cinfo->JFIF_minor_version); > emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ >- emit_2bytes(cinfo, (int16) cinfo->X_density); >- emit_2bytes(cinfo, (int16) cinfo->Y_density); >+ emit_2bytes(cinfo, (int) cinfo->X_density); >+ emit_2bytes(cinfo, (int) cinfo->Y_density); > emit_byte(cinfo, 0); /* No thumbnail image */ > emit_byte(cinfo, 0); > } > > > LOCAL(void) > emit_adobe_app14 (j_compress_ptr cinfo) > /* Emit an Adobe APP14 marker */ >@@ -436,24 +438,24 @@ METHODDEF(void) > write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) > /* Emit an arbitrary marker header */ > { > if (datalen > (unsigned int) 65533) /* safety check */ > ERREXIT(cinfo, JERR_BAD_LENGTH); > > emit_marker(cinfo, (JPEG_MARKER) marker); > >- emit_2bytes(cinfo, (int16) (datalen + 2)); /* total length */ >+ emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ > } > > METHODDEF(void) > write_marker_byte (j_compress_ptr cinfo, int val) > /* Emit one byte of marker parameters following write_marker_header */ > { >- emit_byte(cinfo, (int16) val); >+ emit_byte(cinfo, val); > } > > > /* > * Write datastream header. > * This consists of an SOI and optional APPn markers. > * We recommend use of the JFIF marker, but not the Adobe marker, > * when using YCbCr or grayscale data. The JFIF marker should NOT >@@ -486,17 +488,17 @@ write_file_header (j_compress_ptr cinfo) > * Note that we do not emit the SOF until we have emitted the DQT(s). > * This avoids compatibility problems with incorrect implementations that > * try to error-check the quant table numbers as soon as they see the SOF. > */ > > METHODDEF(void) > write_frame_header (j_compress_ptr cinfo) > { >- int16 ci, prec; >+ int ci, prec; > boolean is_baseline; > jpeg_component_info *compptr; > > /* Emit DQT for each quantization table. > * Note that emit_dqt() suppresses any duplicate tables. > */ > prec = 0; > for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; >@@ -544,17 +546,17 @@ write_frame_header (j_compress_ptr cinfo > * This consists of DHT or DAC markers, optional DRI, and SOS. > * Compressed data will be written following the SOS. > */ > > METHODDEF(void) > write_scan_header (j_compress_ptr cinfo) > { > my_marker_ptr marker = (my_marker_ptr) cinfo->marker; >- int16 i; >+ int i; > jpeg_component_info *compptr; > > if (cinfo->arith_code) { > /* Emit arith conditioning info. We may have some duplication > * if the file has multiple scans, but it's so small it's hardly > * worth worrying about. > */ > emit_dac(cinfo); >@@ -608,17 +610,17 @@ write_file_trailer (j_compress_ptr cinfo > * This consists of SOI, DQT and DHT tables, and EOI. > * Any table that is defined and not marked sent_table = TRUE will be > * emitted. Note that all tables will be marked sent_table = TRUE at exit. > */ > > METHODDEF(void) > write_tables_only (j_compress_ptr cinfo) > { >- int16 i; >+ int i; > > emit_marker(cinfo, M_SOI); > > for (i = 0; i < NUM_QUANT_TBLS; i++) { > if (cinfo->quant_tbl_ptrs[i] != NULL) > (void) emit_dqt(cinfo, i); > } > >diff --git a/jpeg/jcmaster.c b/modules/libjpeg-turbo/jcmaster.c >rename from jpeg/jcmaster.c >rename to modules/libjpeg-turbo/jcmaster.c >diff --git a/jpeg/jcomapi.c b/modules/libjpeg-turbo/jcomapi.c >rename from jpeg/jcomapi.c >rename to modules/libjpeg-turbo/jcomapi.c >diff --git a/jpeg/jconfig.doc b/modules/libjpeg-turbo/jconfig.doc >rename from jpeg/jconfig.doc >rename to modules/libjpeg-turbo/jconfig.doc >diff --git a/jpeg/jconfig.h b/modules/libjpeg-turbo/jconfig.h >rename from jpeg/jconfig.h >rename to modules/libjpeg-turbo/jconfig.h >--- a/jpeg/jconfig.h >+++ b/modules/libjpeg-turbo/jconfig.h >@@ -1,107 +1,50 @@ >-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ >-/* ***** BEGIN LICENSE BLOCK ***** >- * Version: MPL 1.1/GPL 2.0/LGPL 2.1 >- * >- * The contents of this file are subject to the Mozilla Public License Version >- * 1.1 (the "License"); you may not use this file except in compliance with >- * the License. You may obtain a copy of the License at >- * http://www.mozilla.org/MPL/ >- * >- * Software distributed under the License is distributed on an "AS IS" basis, >- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License >- * for the specific language governing rights and limitations under the >- * License. >- * >- * The Original Code is mozilla.org code. >- * >- * The Initial Developer of the Original Code is >- * Netscape Communications Corporation. >- * Portions created by the Initial Developer are Copyright (C) 1998 >- * the Initial Developer. All Rights Reserved. >- * >- * Contributor(s): >- * >- * Alternatively, the contents of this file may be used under the terms of >- * either the GNU General Public License Version 2 or later (the "GPL"), or >- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), >- * in which case the provisions of the GPL or the LGPL are applicable instead >- * of those above. If you wish to allow use of your version of this file only >- * under the terms of either the GPL or the LGPL, and not to allow others to >- * use your version of this file under the terms of the MPL, indicate your >- * decision by deleting the provisions above and replace them with the notice >- * and other provisions required by the GPL or the LGPL. If you do not delete >- * the provisions above, a recipient may use your version of this file under >- * the terms of any one of the MPL, the GPL or the LGPL. >- * >- * ***** END LICENSE BLOCK ***** */ >+/* jconfig.h. Generated from jconfig.h.in by configure. */ >+/* Define if your compiler supports prototypes */ >+#define HAVE_PROTOTYPES 1 > >-/* >- * jconfig.h to configure the IJG JPEG library for the Mozilla/Netscape >- * environment. Note that there are also Mozilla mods in jmorecfg.h. >- */ >+/* Define to 1 if you have the <stddef.h> header file. */ >+#define HAVE_STDDEF_H 1 > >-/* We assume an ANSI C or C++ compilation environment */ >-#define HAVE_PROTOTYPES >-#define HAVE_UNSIGNED_CHAR >-#define HAVE_UNSIGNED_SHORT >-/* #define void char */ >-/* #define const */ >-#ifndef HAVE_STDDEF_H >-#define HAVE_STDDEF_H >-#endif /* HAVE_STDDEF_H */ >-#ifndef HAVE_STDLIB_H >-#define HAVE_STDLIB_H >-#endif /* HAVE_STDLIB_H */ >-#undef NEED_BSD_STRINGS >-#undef NEED_SYS_TYPES_H >-#undef NEED_FAR_POINTERS >-#undef NEED_SHORT_EXTERNAL_NAMES >-/* Define this if you get warnings about undefined structures. */ >-#undef INCOMPLETE_TYPES_BROKEN >+/* Define to 1 if you have the <stdlib.h> header file. */ >+#define HAVE_STDLIB_H 1 > >-/* With this setting, the IJG code will work regardless of whether >- * type "char" is signed or unsigned. >- */ >-#undef CHAR_IS_UNSIGNED >+/* Define to 1 if the system has the type `unsigned char'. */ >+#define HAVE_UNSIGNED_CHAR 1 > >+/* Define to 1 if the system has the type `unsigned short'. */ >+#define HAVE_UNSIGNED_SHORT 1 > >-/* defines that need not be visible to callers of the IJG library */ >+/* Define if you want use complete types */ >+/* #define INCOMPLETE_TYPES_BROKEN 1 */ > >-#ifdef JPEG_INTERNALS >+/* Define if you have BSD-like bzero and bcopy */ >+/* #undef NEED_BSD_STRINGS */ > >-/* If right shift of "long" quantities is unsigned on your machine, >- * you'll have to define this. Fortunately few people should need it. >- */ >-#undef RIGHT_SHIFT_IS_UNSIGNED >+/* Define if you need short function names */ >+/* #undef NEED_SHORT_EXTERNAL_NAMES */ > >-#endif /* JPEG_INTERNALS */ >+/* Define if you have sys/types.h */ >+#define NEED_SYS_TYPES_H 1 > >+/* Define if shift is unsigned */ >+/* #undef RIGHT_SHIFT_IS_UNSIGNED */ > >-/* these defines are not interesting for building just the IJG library, >- * but we leave 'em here anyway. >- */ >-#ifdef JPEG_CJPEG_DJPEG >+/* Use accelerated SIMD routines. */ >+#define WITH_SIMD 1 > >-#define BMP_SUPPORTED /* BMP image file format */ >-#define GIF_SUPPORTED /* GIF image file format */ >-#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ >-#undef RLE_SUPPORTED /* Utah RLE image file format */ >-#define TARGA_SUPPORTED /* Targa image file format */ >+/* Define to 1 if type `char' is unsigned and you are not using gcc. */ >+#ifndef __CHAR_UNSIGNED__ >+/* # undef __CHAR_UNSIGNED__ */ >+#endif > >-#undef TWO_FILE_COMMANDLINE >-#undef NEED_SIGNAL_CATCHER >-#undef DONT_USE_B_MODE >-#undef PROGRESS_REPORT >+/* Define to empty if `const' does not conform to ANSI C. */ >+/* #undef const */ > >-#endif /* JPEG_CJPEG_DJPEG */ >+/* Define to `__inline__' or `__inline' if that's what the C compiler >+ calls it, or to nothing if 'inline' is not supported under any name. */ >+#ifndef __cplusplus >+/* #undef inline */ >+#endif > >-/* SSE* alignment support - only use on platforms that support declspec and __attribute__ */ >- >-#if defined(XP_WIN32) && defined(_M_IX86) && !defined(__GNUC__) >-#define ALIGN16_const_vector_short(name) __declspec(align(16)) const short name[8] >-#define ALIGN16_const_vector_uchar(name) __declspec(align(16)) const unsigned char name[16] >-#else >-#define ALIGN16_const_vector_short(name) const short name[8] __attribute__ ((aligned (16))) >-#define ALIGN16_const_vector_uchar(name) const unsigned char name[16] __attribute__ ((aligned (16))) >-#endif /* ! XP_WIN32 && _M_IX86 && !__GNUC */ >- >+/* Define to `unsigned int' if <sys/types.h> does not define. */ >+/* #undef size_t */ >diff --git a/modules/libjpeg-turbo/jconfig.h.in b/modules/libjpeg-turbo/jconfig.h.in >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/jconfig.h.in >@@ -0,0 +1,49 @@ >+/* Define if your compiler supports prototypes */ >+#undef HAVE_PROTOTYPES >+ >+/* Define to 1 if you have the <stddef.h> header file. */ >+#undef HAVE_STDDEF_H >+ >+/* Define to 1 if you have the <stdlib.h> header file. */ >+#undef HAVE_STDLIB_H >+ >+/* Define to 1 if the system has the type `unsigned char'. */ >+#undef HAVE_UNSIGNED_CHAR >+ >+/* Define to 1 if the system has the type `unsigned short'. */ >+#undef HAVE_UNSIGNED_SHORT >+ >+/* Define if you want use complete types */ >+#undef INCOMPLETE_TYPES_BROKEN >+ >+/* Define if you have BSD-like bzero and bcopy */ >+#undef NEED_BSD_STRINGS >+ >+/* Define if you need short function names */ >+#undef NEED_SHORT_EXTERNAL_NAMES >+ >+/* Define if you have sys/types.h */ >+#undef NEED_SYS_TYPES_H >+ >+/* Define if shift is unsigned */ >+#undef RIGHT_SHIFT_IS_UNSIGNED >+ >+/* Use accelerated SIMD routines. */ >+#undef WITH_SIMD >+ >+/* Define to 1 if type `char' is unsigned and you are not using gcc. */ >+#ifndef __CHAR_UNSIGNED__ >+# undef __CHAR_UNSIGNED__ >+#endif >+ >+/* Define to empty if `const' does not conform to ANSI C. */ >+#undef const >+ >+/* Define to `__inline__' or `__inline' if that's what the C compiler >+ calls it, or to nothing if 'inline' is not supported under any name. */ >+#ifndef __cplusplus >+#undef inline >+#endif >+ >+/* Define to `unsigned int' if <sys/types.h> does not define. */ >+#undef size_t >diff --git a/jpeg/jcparam.c b/modules/libjpeg-turbo/jcparam.c >rename from jpeg/jcparam.c >rename to modules/libjpeg-turbo/jcparam.c >--- a/jpeg/jcparam.c >+++ b/modules/libjpeg-turbo/jcparam.c >@@ -1,12 +1,13 @@ > /* > * jcparam.c > * > * Copyright (C) 1991-1998, Thomas G. Lane. >+ * Copyright (C) 2009, D. R. Commander. > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains optional default-setting code for the JPEG compressor. > * Applications do not have to use this file, but those that don't use it > * must know a lot more about the innards of the JPEG code. > */ > >@@ -90,19 +91,19 @@ jpeg_set_linear_quality (j_compress_ptr > 47, 66, 99, 99, 99, 99, 99, 99, > 99, 99, 99, 99, 99, 99, 99, 99, > 99, 99, 99, 99, 99, 99, 99, 99, > 99, 99, 99, 99, 99, 99, 99, 99, > 99, 99, 99, 99, 99, 99, 99, 99 > }; > > /* Set up two quantization tables using the specified scaling */ >- jpeg_add_quant_table(cinfo, 0, (const unsigned int *)std_luminance_quant_tbl, >+ jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, > scale_factor, force_baseline); >- jpeg_add_quant_table(cinfo, 1, (const unsigned int *)std_chrominance_quant_tbl, >+ jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, > scale_factor, force_baseline); > } > > > GLOBAL(int) > jpeg_quality_scaling (int quality) > /* Convert a user-specified quality rating to a percentage scaling factor > * for an underlying quantization table, using our recommended scaling curve. >@@ -358,16 +359,22 @@ jpeg_set_defaults (j_compress_ptr cinfo) > GLOBAL(void) > jpeg_default_colorspace (j_compress_ptr cinfo) > { > switch (cinfo->in_color_space) { > case JCS_GRAYSCALE: > jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); > break; > case JCS_RGB: >+ case JCS_EXT_RGB: >+ case JCS_EXT_RGBX: >+ case JCS_EXT_BGR: >+ case JCS_EXT_BGRX: >+ case JCS_EXT_XBGR: >+ case JCS_EXT_XRGB: > jpeg_set_colorspace(cinfo, JCS_YCbCr); > break; > case JCS_YCbCr: > jpeg_set_colorspace(cinfo, JCS_YCbCr); > break; > case JCS_CMYK: > jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */ > break; >diff --git a/jpeg/jcphuff.c b/modules/libjpeg-turbo/jcphuff.c >rename from jpeg/jcphuff.c >rename to modules/libjpeg-turbo/jcphuff.c >--- a/jpeg/jcphuff.c >+++ b/modules/libjpeg-turbo/jcphuff.c >@@ -218,17 +218,16 @@ dump_buffer (phuff_entropy_ptr entropy) > /* Outputting bits to the file */ > > /* Only the right 24 bits of put_buffer are used; the valid bits are > * left-justified in this part. At most 16 bits can be passed to emit_bits > * in one call, and we never retain more than 7 bits in put_buffer > * between calls, so 24 bits are sufficient. > */ > >-INLINE > LOCAL(void) > emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size) > /* Emit some bits, unless we are in gather mode */ > { > /* This routine is heavily used, so it's worth coding tightly. */ > register INT32 put_buffer = (INT32) code; > register int put_bits = entropy->put_bits; > >@@ -271,17 +270,16 @@ flush_bits (phuff_entropy_ptr entropy) > entropy->put_bits = 0; > } > > > /* > * Emit (or just count) a Huffman symbol. > */ > >-INLINE > LOCAL(void) > emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol) > { > if (entropy->gather_statistics) > entropy->count_ptrs[tbl_no][symbol]++; > else { > c_derived_tbl * tbl = entropy->derived_tbls[tbl_no]; > emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); >diff --git a/jpeg/jcprepct.c b/modules/libjpeg-turbo/jcprepct.c >rename from jpeg/jcprepct.c >rename to modules/libjpeg-turbo/jcprepct.c >diff --git a/jpeg/jcsample.c b/modules/libjpeg-turbo/jcsample.c >rename from jpeg/jcsample.c >rename to modules/libjpeg-turbo/jcsample.c >--- a/jpeg/jcsample.c >+++ b/modules/libjpeg-turbo/jcsample.c >@@ -1,12 +1,13 @@ > /* > * jcsample.c > * > * Copyright (C) 1991-1996, Thomas G. Lane. >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains downsampling routines. > * > * Downsampling input data is counted in "row groups". A row group > * is defined to be max_v_samp_factor pixel rows of each component, > * from which the downsampler produces v_samp_factor sample rows. >@@ -43,16 +44,17 @@ > * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, > * where SF = (smoothing_factor / 1024). > * Currently, smoothing is only supported for 2h2v sampling factors. > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" >+#include "jsimd.h" > > > /* Pointer to routine to downsample a single component */ > typedef JMETHOD(void, downsample1_ptr, > (j_compress_ptr cinfo, jpeg_component_info * compptr, > JSAMPARRAY input_data, JSAMPARRAY output_data)); > > /* Private subobject */ >@@ -489,26 +491,32 @@ jinit_downsampler (j_compress_ptr cinfo) > downsample->methods[ci] = fullsize_smooth_downsample; > downsample->pub.need_context_rows = TRUE; > } else > #endif > downsample->methods[ci] = fullsize_downsample; > } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && > compptr->v_samp_factor == cinfo->max_v_samp_factor) { > smoothok = FALSE; >- downsample->methods[ci] = h2v1_downsample; >+ if (jsimd_can_h2v1_downsample()) >+ downsample->methods[ci] = jsimd_h2v1_downsample; >+ else >+ downsample->methods[ci] = h2v1_downsample; > } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && > compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) { > #ifdef INPUT_SMOOTHING_SUPPORTED > if (cinfo->smoothing_factor) { > downsample->methods[ci] = h2v2_smooth_downsample; > downsample->pub.need_context_rows = TRUE; > } else > #endif >- downsample->methods[ci] = h2v2_downsample; >+ if (jsimd_can_h2v2_downsample()) >+ downsample->methods[ci] = jsimd_h2v2_downsample; >+ else >+ downsample->methods[ci] = h2v2_downsample; > } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && > (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { > smoothok = FALSE; > downsample->methods[ci] = int_downsample; > } else > ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); > } > >diff --git a/modules/libjpeg-turbo/jctrans.c b/modules/libjpeg-turbo/jctrans.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/jctrans.c >@@ -0,0 +1,388 @@ >+/* >+ * jctrans.c >+ * >+ * Copyright (C) 1995-1998, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains library routines for transcoding compression, >+ * that is, writing raw DCT coefficient arrays to an output JPEG file. >+ * The routines in jcapimin.c will also be needed by a transcoder. >+ */ >+ >+#define JPEG_INTERNALS >+#include "jinclude.h" >+#include "jpeglib.h" >+ >+ >+/* Forward declarations */ >+LOCAL(void) transencode_master_selection >+ JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); >+LOCAL(void) transencode_coef_controller >+ JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); >+ >+ >+/* >+ * Compression initialization for writing raw-coefficient data. >+ * Before calling this, all parameters and a data destination must be set up. >+ * Call jpeg_finish_compress() to actually write the data. >+ * >+ * The number of passed virtual arrays must match cinfo->num_components. >+ * Note that the virtual arrays need not be filled or even realized at >+ * the time write_coefficients is called; indeed, if the virtual arrays >+ * were requested from this compression object's memory manager, they >+ * typically will be realized during this routine and filled afterwards. >+ */ >+ >+GLOBAL(void) >+jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) >+{ >+ if (cinfo->global_state != CSTATE_START) >+ ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); >+ /* Mark all tables to be written */ >+ jpeg_suppress_tables(cinfo, FALSE); >+ /* (Re)initialize error mgr and destination modules */ >+ (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); >+ (*cinfo->dest->init_destination) (cinfo); >+ /* Perform master selection of active modules */ >+ transencode_master_selection(cinfo, coef_arrays); >+ /* Wait for jpeg_finish_compress() call */ >+ cinfo->next_scanline = 0; /* so jpeg_write_marker works */ >+ cinfo->global_state = CSTATE_WRCOEFS; >+} >+ >+ >+/* >+ * Initialize the compression object with default parameters, >+ * then copy from the source object all parameters needed for lossless >+ * transcoding. Parameters that can be varied without loss (such as >+ * scan script and Huffman optimization) are left in their default states. >+ */ >+ >+GLOBAL(void) >+jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, >+ j_compress_ptr dstinfo) >+{ >+ JQUANT_TBL ** qtblptr; >+ jpeg_component_info *incomp, *outcomp; >+ JQUANT_TBL *c_quant, *slot_quant; >+ int tblno, ci, coefi; >+ >+ /* Safety check to ensure start_compress not called yet. */ >+ if (dstinfo->global_state != CSTATE_START) >+ ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); >+ /* Copy fundamental image dimensions */ >+ dstinfo->image_width = srcinfo->image_width; >+ dstinfo->image_height = srcinfo->image_height; >+ dstinfo->input_components = srcinfo->num_components; >+ dstinfo->in_color_space = srcinfo->jpeg_color_space; >+ /* Initialize all parameters to default values */ >+ jpeg_set_defaults(dstinfo); >+ /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. >+ * Fix it to get the right header markers for the image colorspace. >+ */ >+ jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); >+ dstinfo->data_precision = srcinfo->data_precision; >+ dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; >+ /* Copy the source's quantization tables. */ >+ for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { >+ if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { >+ qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; >+ if (*qtblptr == NULL) >+ *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); >+ MEMCOPY((*qtblptr)->quantval, >+ srcinfo->quant_tbl_ptrs[tblno]->quantval, >+ SIZEOF((*qtblptr)->quantval)); >+ (*qtblptr)->sent_table = FALSE; >+ } >+ } >+ /* Copy the source's per-component info. >+ * Note we assume jpeg_set_defaults has allocated the dest comp_info array. >+ */ >+ dstinfo->num_components = srcinfo->num_components; >+ if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) >+ ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, >+ MAX_COMPONENTS); >+ for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; >+ ci < dstinfo->num_components; ci++, incomp++, outcomp++) { >+ outcomp->component_id = incomp->component_id; >+ outcomp->h_samp_factor = incomp->h_samp_factor; >+ outcomp->v_samp_factor = incomp->v_samp_factor; >+ outcomp->quant_tbl_no = incomp->quant_tbl_no; >+ /* Make sure saved quantization table for component matches the qtable >+ * slot. If not, the input file re-used this qtable slot. >+ * IJG encoder currently cannot duplicate this. >+ */ >+ tblno = outcomp->quant_tbl_no; >+ if (tblno < 0 || tblno >= NUM_QUANT_TBLS || >+ srcinfo->quant_tbl_ptrs[tblno] == NULL) >+ ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno); >+ slot_quant = srcinfo->quant_tbl_ptrs[tblno]; >+ c_quant = incomp->quant_table; >+ if (c_quant != NULL) { >+ for (coefi = 0; coefi < DCTSIZE2; coefi++) { >+ if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) >+ ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); >+ } >+ } >+ /* Note: we do not copy the source's Huffman table assignments; >+ * instead we rely on jpeg_set_colorspace to have made a suitable choice. >+ */ >+ } >+ /* Also copy JFIF version and resolution information, if available. >+ * Strictly speaking this isn't "critical" info, but it's nearly >+ * always appropriate to copy it if available. In particular, >+ * if the application chooses to copy JFIF 1.02 extension markers from >+ * the source file, we need to copy the version to make sure we don't >+ * emit a file that has 1.02 extensions but a claimed version of 1.01. >+ * We will *not*, however, copy version info from mislabeled "2.01" files. >+ */ >+ if (srcinfo->saw_JFIF_marker) { >+ if (srcinfo->JFIF_major_version == 1) { >+ dstinfo->JFIF_major_version = srcinfo->JFIF_major_version; >+ dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version; >+ } >+ dstinfo->density_unit = srcinfo->density_unit; >+ dstinfo->X_density = srcinfo->X_density; >+ dstinfo->Y_density = srcinfo->Y_density; >+ } >+} >+ >+ >+/* >+ * Master selection of compression modules for transcoding. >+ * This substitutes for jcinit.c's initialization of the full compressor. >+ */ >+ >+LOCAL(void) >+transencode_master_selection (j_compress_ptr cinfo, >+ jvirt_barray_ptr * coef_arrays) >+{ >+ /* Although we don't actually use input_components for transcoding, >+ * jcmaster.c's initial_setup will complain if input_components is 0. >+ */ >+ cinfo->input_components = 1; >+ /* Initialize master control (includes parameter checking/processing) */ >+ jinit_c_master_control(cinfo, TRUE /* transcode only */); >+ >+ /* Entropy encoding: either Huffman or arithmetic coding. */ >+ if (cinfo->arith_code) { >+ ERREXIT(cinfo, JERR_ARITH_NOTIMPL); >+ } else { >+ if (cinfo->progressive_mode) { >+#ifdef C_PROGRESSIVE_SUPPORTED >+ jinit_phuff_encoder(cinfo); >+#else >+ ERREXIT(cinfo, JERR_NOT_COMPILED); >+#endif >+ } else >+ jinit_huff_encoder(cinfo); >+ } >+ >+ /* We need a special coefficient buffer controller. */ >+ transencode_coef_controller(cinfo, coef_arrays); >+ >+ jinit_marker_writer(cinfo); >+ >+ /* We can now tell the memory manager to allocate virtual arrays. */ >+ (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); >+ >+ /* Write the datastream header (SOI, JFIF) immediately. >+ * Frame and scan headers are postponed till later. >+ * This lets application insert special markers after the SOI. >+ */ >+ (*cinfo->marker->write_file_header) (cinfo); >+} >+ >+ >+/* >+ * The rest of this file is a special implementation of the coefficient >+ * buffer controller. This is similar to jccoefct.c, but it handles only >+ * output from presupplied virtual arrays. Furthermore, we generate any >+ * dummy padding blocks on-the-fly rather than expecting them to be present >+ * in the arrays. >+ */ >+ >+/* Private buffer controller object */ >+ >+typedef struct { >+ struct jpeg_c_coef_controller pub; /* public fields */ >+ >+ JDIMENSION iMCU_row_num; /* iMCU row # within image */ >+ JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ >+ int MCU_vert_offset; /* counts MCU rows within iMCU row */ >+ int MCU_rows_per_iMCU_row; /* number of such rows needed */ >+ >+ /* Virtual block array for each component. */ >+ jvirt_barray_ptr * whole_image; >+ >+ /* Workspace for constructing dummy blocks at right/bottom edges. */ >+ JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; >+} my_coef_controller; >+ >+typedef my_coef_controller * my_coef_ptr; >+ >+ >+LOCAL(void) >+start_iMCU_row (j_compress_ptr cinfo) >+/* Reset within-iMCU-row counters for a new row */ >+{ >+ my_coef_ptr coef = (my_coef_ptr) cinfo->coef; >+ >+ /* In an interleaved scan, an MCU row is the same as an iMCU row. >+ * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. >+ * But at the bottom of the image, process only what's left. >+ */ >+ if (cinfo->comps_in_scan > 1) { >+ coef->MCU_rows_per_iMCU_row = 1; >+ } else { >+ if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) >+ coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; >+ else >+ coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; >+ } >+ >+ coef->mcu_ctr = 0; >+ coef->MCU_vert_offset = 0; >+} >+ >+ >+/* >+ * Initialize for a processing pass. >+ */ >+ >+METHODDEF(void) >+start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) >+{ >+ my_coef_ptr coef = (my_coef_ptr) cinfo->coef; >+ >+ if (pass_mode != JBUF_CRANK_DEST) >+ ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); >+ >+ coef->iMCU_row_num = 0; >+ start_iMCU_row(cinfo); >+} >+ >+ >+/* >+ * Process some data. >+ * We process the equivalent of one fully interleaved MCU row ("iMCU" row) >+ * per call, ie, v_samp_factor block rows for each component in the scan. >+ * The data is obtained from the virtual arrays and fed to the entropy coder. >+ * Returns TRUE if the iMCU row is completed, FALSE if suspended. >+ * >+ * NB: input_buf is ignored; it is likely to be a NULL pointer. >+ */ >+ >+METHODDEF(boolean) >+compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) >+{ >+ my_coef_ptr coef = (my_coef_ptr) cinfo->coef; >+ JDIMENSION MCU_col_num; /* index of current MCU within row */ >+ JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; >+ JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; >+ int blkn, ci, xindex, yindex, yoffset, blockcnt; >+ JDIMENSION start_col; >+ JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; >+ JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; >+ JBLOCKROW buffer_ptr; >+ jpeg_component_info *compptr; >+ >+ /* Align the virtual buffers for the components used in this scan. */ >+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) { >+ compptr = cinfo->cur_comp_info[ci]; >+ buffer[ci] = (*cinfo->mem->access_virt_barray) >+ ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], >+ coef->iMCU_row_num * compptr->v_samp_factor, >+ (JDIMENSION) compptr->v_samp_factor, FALSE); >+ } >+ >+ /* Loop to process one whole iMCU row */ >+ for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; >+ yoffset++) { >+ for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; >+ MCU_col_num++) { >+ /* Construct list of pointers to DCT blocks belonging to this MCU */ >+ blkn = 0; /* index of current DCT block within MCU */ >+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) { >+ compptr = cinfo->cur_comp_info[ci]; >+ start_col = MCU_col_num * compptr->MCU_width; >+ blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width >+ : compptr->last_col_width; >+ for (yindex = 0; yindex < compptr->MCU_height; yindex++) { >+ if (coef->iMCU_row_num < last_iMCU_row || >+ yindex+yoffset < compptr->last_row_height) { >+ /* Fill in pointers to real blocks in this row */ >+ buffer_ptr = buffer[ci][yindex+yoffset] + start_col; >+ for (xindex = 0; xindex < blockcnt; xindex++) >+ MCU_buffer[blkn++] = buffer_ptr++; >+ } else { >+ /* At bottom of image, need a whole row of dummy blocks */ >+ xindex = 0; >+ } >+ /* Fill in any dummy blocks needed in this row. >+ * Dummy blocks are filled in the same way as in jccoefct.c: >+ * all zeroes in the AC entries, DC entries equal to previous >+ * block's DC value. The init routine has already zeroed the >+ * AC entries, so we need only set the DC entries correctly. >+ */ >+ for (; xindex < compptr->MCU_width; xindex++) { >+ MCU_buffer[blkn] = coef->dummy_buffer[blkn]; >+ MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; >+ blkn++; >+ } >+ } >+ } >+ /* Try to write the MCU. */ >+ if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { >+ /* Suspension forced; update state counters and exit */ >+ coef->MCU_vert_offset = yoffset; >+ coef->mcu_ctr = MCU_col_num; >+ return FALSE; >+ } >+ } >+ /* Completed an MCU row, but perhaps not an iMCU row */ >+ coef->mcu_ctr = 0; >+ } >+ /* Completed the iMCU row, advance counters for next one */ >+ coef->iMCU_row_num++; >+ start_iMCU_row(cinfo); >+ return TRUE; >+} >+ >+ >+/* >+ * Initialize coefficient buffer controller. >+ * >+ * Each passed coefficient array must be the right size for that >+ * coefficient: width_in_blocks wide and height_in_blocks high, >+ * with unitheight at least v_samp_factor. >+ */ >+ >+LOCAL(void) >+transencode_coef_controller (j_compress_ptr cinfo, >+ jvirt_barray_ptr * coef_arrays) >+{ >+ my_coef_ptr coef; >+ JBLOCKROW buffer; >+ int i; >+ >+ coef = (my_coef_ptr) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(my_coef_controller)); >+ cinfo->coef = (struct jpeg_c_coef_controller *) coef; >+ coef->pub.start_pass = start_pass_coef; >+ coef->pub.compress_data = compress_output; >+ >+ /* Save pointer to virtual arrays */ >+ coef->whole_image = coef_arrays; >+ >+ /* Allocate and pre-zero space for dummy DCT blocks. */ >+ buffer = (JBLOCKROW) >+ (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); >+ jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); >+ for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { >+ coef->dummy_buffer[i] = buffer + i; >+ } >+} >diff --git a/jpeg/jdapimin.c b/modules/libjpeg-turbo/jdapimin.c >rename from jpeg/jdapimin.c >rename to modules/libjpeg-turbo/jdapimin.c >--- a/jpeg/jdapimin.c >+++ b/modules/libjpeg-turbo/jdapimin.c >@@ -15,115 +15,27 @@ > * shared by compression and decompression, and jdtrans.c for the transcoding > * case. > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" > >-#ifdef HAVE_MMX_INTEL_MNEMONICS >-#if _MSC_VER >= 1400 >-#include "intrin.h" >-#else >-/* no __cpuid intrinsic, use a manually rewritten replacement */ >-void __stdcall __cpuid( int CPUInfo[4], int InfoType ) >-{ >- int my_eax = 0, my_ebx = 0, my_ecx = 0, my_edx = 0; >- __asm { >- /* check eflags bit 21 to see if cpuid is supported */ >- pushfd /* save eflags to stack */ >- pop eax /* and put it in eax */ >- mov ecx, eax /* save a copy in ecx to compare against */ >- xor eax, 0x200000 /* toggle ID bit (bit 21) in eflags */ >- push eax /* save modified eflags to stack */ >- popfd /* set eflags register with modified value */ >- pushfd /* read eflags back out */ >- pop eax >- xor eax, ecx /* check for modified eflags */ >- jz NOT_SUPPORTED /* cpuid not supported */ >- >- /* check to see if the requested cpuid type is supported */ >- xor eax, eax /* set eax to zero */ >- cpuid >- cmp eax, InfoType >- jl NOT_SUPPORTED /* the requested cpuid type is not supported */ >- >- /* actually make the cpuid call */ >- mov eax, InfoType >- cpuid >- mov my_eax, eax >- mov my_ebx, ebx >- mov my_ecx, ecx >- mov my_edx, edx >-NOT_SUPPORTED: >- } >- CPUInfo[0] = my_eax; >- CPUInfo[1] = my_ebx; >- CPUInfo[2] = my_ecx; >- CPUInfo[3] = my_edx; >-} >-#endif /* _MSC_VER >= 1400 */ >- >-int MMXAvailable; >-static int mmxsupport(); >-#endif >- >-#ifdef HAVE_SSE2_INTRINSICS >-int SSE2Available = 0; >-#ifdef HAVE_SSE2_INTEL_MNEMONICS >-static int sse2support(); >-#else >-static int sse2supportGCC(); >-#endif /* HAVE_SSE2_INTEL_MNEMONICS */ >-#endif /* HAVE_SSE2_INTRINSICS */ >- > > /* > * Initialization of a JPEG decompression object. > * The error manager must already be set up (in case memory manager fails). > */ > > GLOBAL(void) > jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize) > { > int i; > >-#ifdef HAVE_MMX_INTEL_MNEMONICS >- static int cpuidDetected = 0; >- >- if(!cpuidDetected) >- { >- MMXAvailable = mmxsupport(); >- >-#ifdef HAVE_SSE2_INTEL_MNEMONICS >- /* only do the sse2 support check if mmx is supported (so >- we know the processor supports cpuid) */ >- if (MMXAvailable) >- SSE2Available = sse2support(); >-#endif >- >- cpuidDetected = 1; >- } >-#else >-#ifdef HAVE_SSE2_INTRINSICS >- static int cpuidDetected = 0; >- >- if(!cpuidDetected) { >- SSE2Available = sse2supportGCC(); >- cpuidDetected = 1; >- } >- >-#endif /* HAVE_SSE2_INTRINSICS */ >-#endif /* HAVE_MMX_INTEL_MNEMONICS */ >- >- /* For debugging purposes, zero the whole master structure. >- * But error manager pointer is already there, so save and restore it. >- */ >- > /* Guard against version mismatches between library and caller. */ > cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ > if (version != JPEG_LIB_VERSION) > ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); > if (structsize != SIZEOF(struct jpeg_decompress_struct)) > ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, > (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); > >@@ -188,16 +100,17 @@ jpeg_destroy_decompress (j_decompress_pt > */ > > GLOBAL(void) > jpeg_abort_decompress (j_decompress_ptr cinfo) > { > jpeg_abort((j_common_ptr) cinfo); /* use common routine */ > } > >+ > /* > * Set default decompression parameters. > */ > > LOCAL(void) > default_decompress_parms (j_decompress_ptr cinfo) > { > /* Guess the input colorspace, and set output colorspace accordingly. */ >@@ -475,56 +388,8 @@ jpeg_finish_decompress (j_decompress_ptr > return FALSE; /* Suspend, come back later */ > } > /* Do final cleanup */ > (*cinfo->src->term_source) (cinfo); > /* We can use jpeg_abort to release memory and reset global_state */ > jpeg_abort((j_common_ptr) cinfo); > return TRUE; > } >- >- >-#ifdef HAVE_MMX_INTEL_MNEMONICS >-static int mmxsupport() >-{ >- int CPUInfo[4]; >- >- __cpuid(CPUInfo, 1); >- if (CPUInfo[3] & (0x1 << 23)) >- return 1; >- else >- return 0; >-} >-#endif >- >-#ifdef HAVE_SSE2_INTEL_MNEMONICS >-static int sse2support() >-{ >- int CPUInfo[4]; >- >- __cpuid(CPUInfo, 1); >- if (CPUInfo[3] & (0x1 << 26)) >- return 1; >- else >- return 2; >-} >-#else >-#ifdef HAVE_SSE2_INTRINSICS >-static int sse2supportGCC() >-{ >- >- /* Mac Intel started with Core Duo chips which have SSE2 Support */ >- >-#if defined(__GNUC__) && defined(__i386__) >-#if defined(XP_MACOSX) >- return 1; >-#endif /* XP_MACOSX */ >-#endif /* GNUC && i386 */ >- >- /* Add checking for SSE2 support for other platforms here */ >- >- /* We don't have SSE2 intrinsics support */ >- >- return 2; >-} >-#endif /* HAVE_SSE2_INTRINSICS */ >-#endif /* HAVE_SSE2_INTEL_MNEMONICS */ >- >diff --git a/jpeg/jdapistd.c b/modules/libjpeg-turbo/jdapistd.c >rename from jpeg/jdapistd.c >rename to modules/libjpeg-turbo/jdapistd.c >diff --git a/jpeg/jdatadst.c b/modules/libjpeg-turbo/jdatadst.c >rename from jpeg/jdatadst.c >rename to modules/libjpeg-turbo/jdatadst.c >--- a/jpeg/jdatadst.c >+++ b/modules/libjpeg-turbo/jdatadst.c >@@ -144,71 +144,8 @@ jpeg_stdio_dest (j_compress_ptr cinfo, F > } > > dest = (my_dest_ptr) cinfo->dest; > dest->pub.init_destination = init_destination; > dest->pub.empty_output_buffer = empty_output_buffer; > dest->pub.term_destination = term_destination; > dest->outfile = outfile; > } >- >-/* >- * term_destination_file_close --- called by jpeg_finish_compress >- * after all data has been written. Usually needs to flush buffer. >- * also will need to close file >- * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding >- * application must deal with any cleanup that should happen even >- * for error exit. >- */ >- >-METHODDEF(void) >-term_destination_file_close(j_compress_ptr cinfo) >-{ >- my_dest_ptr dest = (my_dest_ptr) cinfo->dest; >- size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; >- >- /* Write any data remaining in the buffer */ >- if (datacount > 0) { >- if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount) >- ERREXIT(cinfo, JERR_FILE_WRITE); >- } >- fflush(dest->outfile); >- >- /* Make sure we wrote the output file OK */ >- if (ferror(dest->outfile)) >- ERREXIT(cinfo, JERR_FILE_WRITE); >- else >- fclose(dest->outfile); >-} >- >- >- >- >- >-/* >- * Prepare for output to a file from a char * >- * The caller is responsible >- * for closing it after finishing compression. >- */ >- >-GLOBAL(void) >-jpeg_file_dest (j_compress_ptr cinfo, char * outfile) >-{ >- my_dest_ptr dest; >- >- /* The destination object is made permanent so that multiple JPEG images >- * can be written to the same file without re-executing jpeg_stdio_dest. >- * This makes it dangerous to use this manager and a different destination >- * manager serially with the same JPEG object, because their private object >- * sizes may be different. Caveat programmer. >- */ >- if (cinfo->dest == NULL) { /* first time for this JPEG object? */ >- cinfo->dest = (struct jpeg_destination_mgr *) >- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, >- SIZEOF(my_destination_mgr)); >- } >- >- dest = (my_dest_ptr) cinfo->dest; >- dest->pub.init_destination = init_destination; >- dest->pub.empty_output_buffer = empty_output_buffer; >- dest->pub.term_destination = term_destination_file_close; >- dest->outfile = fopen(outfile,"wb"); >-} >diff --git a/jpeg/jdatasrc.c b/modules/libjpeg-turbo/jdatasrc.c >rename from jpeg/jdatasrc.c >rename to modules/libjpeg-turbo/jdatasrc.c >diff --git a/jpeg/jdcoefct.c b/modules/libjpeg-turbo/jdcoefct.c >rename from jpeg/jdcoefct.c >rename to modules/libjpeg-turbo/jdcoefct.c >--- a/jpeg/jdcoefct.c >+++ b/modules/libjpeg-turbo/jdcoefct.c >@@ -42,16 +42,19 @@ typedef struct { > * (On 80x86, the workspace is FAR even though it's not really very big; > * this is to keep the module interfaces unchanged when a large coefficient > * buffer is necessary.) > * In multi-pass modes, this array points to the current MCU's blocks > * within the virtual arrays; it is used only by the input side. > */ > JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; > >+ /* Temporary workspace for one MCU */ >+ JCOEF * workspace; >+ > #ifdef D_MULTISCAN_FILES_SUPPORTED > /* In multi-pass modes, we need a virtual block array for each component. */ > jvirt_barray_ptr whole_image[MAX_COMPONENTS]; > #endif > > #ifdef BLOCK_SMOOTHING_SUPPORTED > /* When doing block smoothing, we latch coefficient Al values here */ > int * coef_bits_latch; >@@ -466,23 +469,26 @@ decompress_smooth_data (j_decompress_ptr > int ci, block_row, block_rows, access_rows; > JBLOCKARRAY buffer; > JBLOCKROW buffer_ptr, prev_block_row, next_block_row; > JSAMPARRAY output_ptr; > JDIMENSION output_col; > jpeg_component_info *compptr; > inverse_DCT_method_ptr inverse_DCT; > boolean first_row, last_row; >- JBLOCK workspace; >+ JCOEF * workspace; > int *coef_bits; > JQUANT_TBL *quanttbl; > INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; > int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; > int Al, pred; > >+ /* Keep a local variable to avoid looking it up more than once */ >+ workspace = coef->workspace; >+ > /* Force some input to be done if we are getting ahead of the input. */ > while (cinfo->input_scan_number <= cinfo->output_scan_number && > ! cinfo->inputctl->eoi_reached) { > if (cinfo->input_scan_number == cinfo->output_scan_number) { > /* If input is working on current scan, we ordinarily want it to > * have completed the current row. But if input scan is DC, > * we want it to keep one row ahead so that next block row's DC > * values are up to date. >@@ -728,9 +734,14 @@ jinit_d_coef_controller (j_decompress_pt > D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); > for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { > coef->MCU_buffer[i] = buffer + i; > } > coef->pub.consume_data = dummy_consume_data; > coef->pub.decompress_data = decompress_onepass; > coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ > } >+ >+ /* Allocate the workspace buffer */ >+ coef->workspace = (JCOEF *) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(JCOEF) * DCTSIZE2); > } >diff --git a/jpeg/jdcolor.c b/modules/libjpeg-turbo/jdcolor.c >rename from jpeg/jdcolor.c >rename to modules/libjpeg-turbo/jdcolor.c >--- a/jpeg/jdcolor.c >+++ b/modules/libjpeg-turbo/jdcolor.c >@@ -1,38 +1,36 @@ > /* > * jdcolor.c > * > * Copyright (C) 1991-1997, Thomas G. Lane. >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+ * Copyright (C) 2009, D. R. Commander. > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains output colorspace conversion routines. > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" >-#include "jconfig.h" >+#include "jsimd.h" > > > /* Private subobject */ > > typedef struct { > struct jpeg_color_deconverter pub; /* public fields */ > >- /* These fields are not needed anymore as these are now static tables */ >- >-#if 0 > /* Private state for YCC->RGB conversion */ > int * Cr_r_tab; /* => table for Cr to R conversion */ > int * Cb_b_tab; /* => table for Cb to B conversion */ > INT32 * Cr_g_tab; /* => table for Cr to G conversion */ > INT32 * Cb_g_tab; /* => table for Cb to G conversion */ >-#endif > } my_color_deconverter; > > typedef my_color_deconverter * my_cconvert_ptr; > > > /**************** YCbCr -> RGB conversion: most common case **************/ > > /* >@@ -61,213 +59,24 @@ typedef my_color_deconverter * my_cconve > * values for the G calculation are left scaled up, since we must add them > * together before rounding. > */ > > #define SCALEBITS 16 /* speediest right-shift on some machines */ > #define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) > #define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5)) > >-/* Use static tables for color processing. */ >- >-const int Cr_r_tab[(MAXJSAMPLE+1) * SIZEOF(int)] ={ >- 0xffffff4dUL, 0xffffff4eUL, 0xffffff4fUL, 0xffffff51UL, 0xffffff52UL, 0xffffff54UL, >- 0xffffff55UL, 0xffffff56UL, 0xffffff58UL, 0xffffff59UL, 0xffffff5bUL, 0xffffff5cUL, >- 0xffffff5dUL, 0xffffff5fUL, 0xffffff60UL, 0xffffff62UL, 0xffffff63UL, 0xffffff64UL, >- 0xffffff66UL, 0xffffff67UL, 0xffffff69UL, 0xffffff6aUL, 0xffffff6bUL, 0xffffff6dUL, >- 0xffffff6eUL, 0xffffff70UL, 0xffffff71UL, 0xffffff72UL, 0xffffff74UL, 0xffffff75UL, >- 0xffffff77UL, 0xffffff78UL, 0xffffff79UL, 0xffffff7bUL, 0xffffff7cUL, 0xffffff7eUL, >- 0xffffff7fUL, 0xffffff80UL, 0xffffff82UL, 0xffffff83UL, 0xffffff85UL, 0xffffff86UL, >- 0xffffff87UL, 0xffffff89UL, 0xffffff8aUL, 0xffffff8cUL, 0xffffff8dUL, 0xffffff8eUL, >- 0xffffff90UL, 0xffffff91UL, 0xffffff93UL, 0xffffff94UL, 0xffffff95UL, 0xffffff97UL, >- 0xffffff98UL, 0xffffff9aUL, 0xffffff9bUL, 0xffffff9cUL, 0xffffff9eUL, 0xffffff9fUL, >- 0xffffffa1UL, 0xffffffa2UL, 0xffffffa3UL, 0xffffffa5UL, 0xffffffa6UL, 0xffffffa8UL, >- 0xffffffa9UL, 0xffffffaaUL, 0xffffffacUL, 0xffffffadUL, 0xffffffafUL, 0xffffffb0UL, >- 0xffffffb1UL, 0xffffffb3UL, 0xffffffb4UL, 0xffffffb6UL, 0xffffffb7UL, 0xffffffb8UL, >- 0xffffffbaUL, 0xffffffbbUL, 0xffffffbdUL, 0xffffffbeUL, 0xffffffc0UL, 0xffffffc1UL, >- 0xffffffc2UL, 0xffffffc4UL, 0xffffffc5UL, 0xffffffc7UL, 0xffffffc8UL, 0xffffffc9UL, >- 0xffffffcbUL, 0xffffffccUL, 0xffffffceUL, 0xffffffcfUL, 0xffffffd0UL, 0xffffffd2UL, >- 0xffffffd3UL, 0xffffffd5UL, 0xffffffd6UL, 0xffffffd7UL, 0xffffffd9UL, 0xffffffdaUL, >- 0xffffffdcUL, 0xffffffddUL, 0xffffffdeUL, 0xffffffe0UL, 0xffffffe1UL, 0xffffffe3UL, >- 0xffffffe4UL, 0xffffffe5UL, 0xffffffe7UL, 0xffffffe8UL, 0xffffffeaUL, 0xffffffebUL, >- 0xffffffecUL, 0xffffffeeUL, 0xffffffefUL, 0xfffffff1UL, 0xfffffff2UL, 0xfffffff3UL, >- 0xfffffff5UL, 0xfffffff6UL, 0xfffffff8UL, 0xfffffff9UL, 0xfffffffaUL, 0xfffffffcUL, >- 0xfffffffdUL, 0xffffffffUL, 0x00UL, 0x01UL, 0x03UL, 0x04UL, >- 0x06UL, 0x07UL, 0x08UL, 0x0aUL, 0x0bUL, 0x0dUL, >- 0x0eUL, 0x0fUL, 0x11UL, 0x12UL, 0x14UL, 0x15UL, >- 0x16UL, 0x18UL, 0x19UL, 0x1bUL, 0x1cUL, 0x1dUL, >- 0x1fUL, 0x20UL, 0x22UL, 0x23UL, 0x24UL, 0x26UL, >- 0x27UL, 0x29UL, 0x2aUL, 0x2bUL, 0x2dUL, 0x2eUL, >- 0x30UL, 0x31UL, 0x32UL, 0x34UL, 0x35UL, 0x37UL, >- 0x38UL, 0x39UL, 0x3bUL, 0x3cUL, 0x3eUL, 0x3fUL, >- 0x40UL, 0x42UL, 0x43UL, 0x45UL, 0x46UL, 0x48UL, >- 0x49UL, 0x4aUL, 0x4cUL, 0x4dUL, 0x4fUL, 0x50UL, >- 0x51UL, 0x53UL, 0x54UL, 0x56UL, 0x57UL, 0x58UL, >- 0x5aUL, 0x5bUL, 0x5dUL, 0x5eUL, 0x5fUL, 0x61UL, >- 0x62UL, 0x64UL, 0x65UL, 0x66UL, 0x68UL, 0x69UL, >- 0x6bUL, 0x6cUL, 0x6dUL, 0x6fUL, 0x70UL, 0x72UL, >- 0x73UL, 0x74UL, 0x76UL, 0x77UL, 0x79UL, 0x7aUL, >- 0x7bUL, 0x7dUL, 0x7eUL, 0x80UL, 0x81UL, 0x82UL, >- 0x84UL, 0x85UL, 0x87UL, 0x88UL, 0x89UL, 0x8bUL, >- 0x8cUL, 0x8eUL, 0x8fUL, 0x90UL, 0x92UL, 0x93UL, >- 0x95UL, 0x96UL, 0x97UL, 0x99UL, 0x9aUL, 0x9cUL, >- 0x9dUL, 0x9eUL, 0xa0UL, 0xa1UL, 0xa3UL, 0xa4UL, >- 0xa5UL, 0xa7UL, 0xa8UL, 0xaaUL, 0xabUL, 0xacUL, >- 0xaeUL, 0xafUL, 0xb1UL, 0xb2UL >- }; >- >-const int Cb_b_tab[(MAXJSAMPLE+1) * SIZEOF(int)] ={ >- 0xffffff1dUL, 0xffffff1fUL, 0xffffff21UL, 0xffffff22UL, 0xffffff24UL, 0xffffff26UL, >- 0xffffff28UL, 0xffffff2aUL, 0xffffff2bUL, 0xffffff2dUL, 0xffffff2fUL, 0xffffff31UL, >- 0xffffff32UL, 0xffffff34UL, 0xffffff36UL, 0xffffff38UL, 0xffffff3aUL, 0xffffff3bUL, >- 0xffffff3dUL, 0xffffff3fUL, 0xffffff41UL, 0xffffff42UL, 0xffffff44UL, 0xffffff46UL, >- 0xffffff48UL, 0xffffff49UL, 0xffffff4bUL, 0xffffff4dUL, 0xffffff4fUL, 0xffffff51UL, >- 0xffffff52UL, 0xffffff54UL, 0xffffff56UL, 0xffffff58UL, 0xffffff59UL, 0xffffff5bUL, >- 0xffffff5dUL, 0xffffff5fUL, 0xffffff61UL, 0xffffff62UL, 0xffffff64UL, 0xffffff66UL, >- 0xffffff68UL, 0xffffff69UL, 0xffffff6bUL, 0xffffff6dUL, 0xffffff6fUL, 0xffffff70UL, >- 0xffffff72UL, 0xffffff74UL, 0xffffff76UL, 0xffffff78UL, 0xffffff79UL, 0xffffff7bUL, >- 0xffffff7dUL, 0xffffff7fUL, 0xffffff80UL, 0xffffff82UL, 0xffffff84UL, 0xffffff86UL, >- 0xffffff88UL, 0xffffff89UL, 0xffffff8bUL, 0xffffff8dUL, 0xffffff8fUL, 0xffffff90UL, >- 0xffffff92UL, 0xffffff94UL, 0xffffff96UL, 0xffffff97UL, 0xffffff99UL, 0xffffff9bUL, >- 0xffffff9dUL, 0xffffff9fUL, 0xffffffa0UL, 0xffffffa2UL, 0xffffffa4UL, 0xffffffa6UL, >- 0xffffffa7UL, 0xffffffa9UL, 0xffffffabUL, 0xffffffadUL, 0xffffffaeUL, 0xffffffb0UL, >- 0xffffffb2UL, 0xffffffb4UL, 0xffffffb6UL, 0xffffffb7UL, 0xffffffb9UL, 0xffffffbbUL, >- 0xffffffbdUL, 0xffffffbeUL, 0xffffffc0UL, 0xffffffc2UL, 0xffffffc4UL, 0xffffffc6UL, >- 0xffffffc7UL, 0xffffffc9UL, 0xffffffcbUL, 0xffffffcdUL, 0xffffffceUL, 0xffffffd0UL, >- 0xffffffd2UL, 0xffffffd4UL, 0xffffffd5UL, 0xffffffd7UL, 0xffffffd9UL, 0xffffffdbUL, >- 0xffffffddUL, 0xffffffdeUL, 0xffffffe0UL, 0xffffffe2UL, 0xffffffe4UL, 0xffffffe5UL, >- 0xffffffe7UL, 0xffffffe9UL, 0xffffffebUL, 0xffffffedUL, 0xffffffeeUL, 0xfffffff0UL, >- 0xfffffff2UL, 0xfffffff4UL, 0xfffffff5UL, 0xfffffff7UL, 0xfffffff9UL, 0xfffffffbUL, >- 0xfffffffcUL, 0xfffffffeUL, 0x00UL, 0x02UL, 0x04UL, 0x05UL, >- 0x07UL, 0x09UL, 0x0bUL, 0x0cUL, 0x0eUL, 0x10UL, >- 0x12UL, 0x13UL, 0x15UL, 0x17UL, 0x19UL, 0x1bUL, >- 0x1cUL, 0x1eUL, 0x20UL, 0x22UL, 0x23UL, 0x25UL, >- 0x27UL, 0x29UL, 0x2bUL, 0x2cUL, 0x2eUL, 0x30UL, >- 0x32UL, 0x33UL, 0x35UL, 0x37UL, 0x39UL, 0x3aUL, >- 0x3cUL, 0x3eUL, 0x40UL, 0x42UL, 0x43UL, 0x45UL, >- 0x47UL, 0x49UL, 0x4aUL, 0x4cUL, 0x4eUL, 0x50UL, >- 0x52UL, 0x53UL, 0x55UL, 0x57UL, 0x59UL, 0x5aUL, >- 0x5cUL, 0x5eUL, 0x60UL, 0x61UL, 0x63UL, 0x65UL, >- 0x67UL, 0x69UL, 0x6aUL, 0x6cUL, 0x6eUL, 0x70UL, >- 0x71UL, 0x73UL, 0x75UL, 0x77UL, 0x78UL, 0x7aUL, >- 0x7cUL, 0x7eUL, 0x80UL, 0x81UL, 0x83UL, 0x85UL, >- 0x87UL, 0x88UL, 0x8aUL, 0x8cUL, 0x8eUL, 0x90UL, >- 0x91UL, 0x93UL, 0x95UL, 0x97UL, 0x98UL, 0x9aUL, >- 0x9cUL, 0x9eUL, 0x9fUL, 0xa1UL, 0xa3UL, 0xa5UL, >- 0xa7UL, 0xa8UL, 0xaaUL, 0xacUL, 0xaeUL, 0xafUL, >- 0xb1UL, 0xb3UL, 0xb5UL, 0xb7UL, 0xb8UL, 0xbaUL, >- 0xbcUL, 0xbeUL, 0xbfUL, 0xc1UL, 0xc3UL, 0xc5UL, >- 0xc6UL, 0xc8UL, 0xcaUL, 0xccUL, 0xceUL, 0xcfUL, >- 0xd1UL, 0xd3UL, 0xd5UL, 0xd6UL, 0xd8UL, 0xdaUL, >- 0xdcUL, 0xdeUL, 0xdfUL, 0xe1UL >- }; >- >-const int Cr_g_tab[(MAXJSAMPLE+1) * SIZEOF(int)] ={ >- 0x5b6900UL, 0x5ab22eUL, 0x59fb5cUL, 0x59448aUL, 0x588db8UL, 0x57d6e6UL, >- 0x572014UL, 0x566942UL, 0x55b270UL, 0x54fb9eUL, 0x5444ccUL, 0x538dfaUL, >- 0x52d728UL, 0x522056UL, 0x516984UL, 0x50b2b2UL, 0x4ffbe0UL, 0x4f450eUL, >- 0x4e8e3cUL, 0x4dd76aUL, 0x4d2098UL, 0x4c69c6UL, 0x4bb2f4UL, 0x4afc22UL, >- 0x4a4550UL, 0x498e7eUL, 0x48d7acUL, 0x4820daUL, 0x476a08UL, 0x46b336UL, >- 0x45fc64UL, 0x454592UL, 0x448ec0UL, 0x43d7eeUL, 0x43211cUL, 0x426a4aUL, >- 0x41b378UL, 0x40fca6UL, 0x4045d4UL, 0x3f8f02UL, 0x3ed830UL, 0x3e215eUL, >- 0x3d6a8cUL, 0x3cb3baUL, 0x3bfce8UL, 0x3b4616UL, 0x3a8f44UL, 0x39d872UL, >- 0x3921a0UL, 0x386aceUL, 0x37b3fcUL, 0x36fd2aUL, 0x364658UL, 0x358f86UL, >- 0x34d8b4UL, 0x3421e2UL, 0x336b10UL, 0x32b43eUL, 0x31fd6cUL, 0x31469aUL, >- 0x308fc8UL, 0x2fd8f6UL, 0x2f2224UL, 0x2e6b52UL, 0x2db480UL, 0x2cfdaeUL, >- 0x2c46dcUL, 0x2b900aUL, 0x2ad938UL, 0x2a2266UL, 0x296b94UL, 0x28b4c2UL, >- 0x27fdf0UL, 0x27471eUL, 0x26904cUL, 0x25d97aUL, 0x2522a8UL, 0x246bd6UL, >- 0x23b504UL, 0x22fe32UL, 0x224760UL, 0x21908eUL, 0x20d9bcUL, 0x2022eaUL, >- 0x1f6c18UL, 0x1eb546UL, 0x1dfe74UL, 0x1d47a2UL, 0x1c90d0UL, 0x1bd9feUL, >- 0x1b232cUL, 0x1a6c5aUL, 0x19b588UL, 0x18feb6UL, 0x1847e4UL, 0x179112UL, >- 0x16da40UL, 0x16236eUL, 0x156c9cUL, 0x14b5caUL, 0x13fef8UL, 0x134826UL, >- 0x129154UL, 0x11da82UL, 0x1123b0UL, 0x106cdeUL, 0xfb60cUL, 0xeff3aUL, >- 0xe4868UL, 0xd9196UL, 0xcdac4UL, 0xc23f2UL, 0xb6d20UL, 0xab64eUL, >- 0x9ff7cUL, 0x948aaUL, 0x891d8UL, 0x7db06UL, 0x72434UL, 0x66d62UL, >- 0x5b690UL, 0x4ffbeUL, 0x448ecUL, 0x3921aUL, 0x2db48UL, 0x22476UL, >- 0x16da4UL, 0xb6d2UL, 0x0UL, 0xffff492eUL, 0xfffe925cUL, 0xfffddb8aUL, >- 0xfffd24b8UL, 0xfffc6de6UL, 0xfffbb714UL, 0xfffb0042UL, 0xfffa4970UL, 0xfff9929eUL, >- 0xfff8dbccUL, 0xfff824faUL, 0xfff76e28UL, 0xfff6b756UL, 0xfff60084UL, 0xfff549b2UL, >- 0xfff492e0UL, 0xfff3dc0eUL, 0xfff3253cUL, 0xfff26e6aUL, 0xfff1b798UL, 0xfff100c6UL, >- 0xfff049f4UL, 0xffef9322UL, 0xffeedc50UL, 0xffee257eUL, 0xffed6eacUL, 0xffecb7daUL, >- 0xffec0108UL, 0xffeb4a36UL, 0xffea9364UL, 0xffe9dc92UL, 0xffe925c0UL, 0xffe86eeeUL, >- 0xffe7b81cUL, 0xffe7014aUL, 0xffe64a78UL, 0xffe593a6UL, 0xffe4dcd4UL, 0xffe42602UL, >- 0xffe36f30UL, 0xffe2b85eUL, 0xffe2018cUL, 0xffe14abaUL, 0xffe093e8UL, 0xffdfdd16UL, >- 0xffdf2644UL, 0xffde6f72UL, 0xffddb8a0UL, 0xffdd01ceUL, 0xffdc4afcUL, 0xffdb942aUL, >- 0xffdadd58UL, 0xffda2686UL, 0xffd96fb4UL, 0xffd8b8e2UL, 0xffd80210UL, 0xffd74b3eUL, >- 0xffd6946cUL, 0xffd5dd9aUL, 0xffd526c8UL, 0xffd46ff6UL, 0xffd3b924UL, 0xffd30252UL, >- 0xffd24b80UL, 0xffd194aeUL, 0xffd0dddcUL, 0xffd0270aUL, 0xffcf7038UL, 0xffceb966UL, >- 0xffce0294UL, 0xffcd4bc2UL, 0xffcc94f0UL, 0xffcbde1eUL, 0xffcb274cUL, 0xffca707aUL, >- 0xffc9b9a8UL, 0xffc902d6UL, 0xffc84c04UL, 0xffc79532UL, 0xffc6de60UL, 0xffc6278eUL, >- 0xffc570bcUL, 0xffc4b9eaUL, 0xffc40318UL, 0xffc34c46UL, 0xffc29574UL, 0xffc1dea2UL, >- 0xffc127d0UL, 0xffc070feUL, 0xffbfba2cUL, 0xffbf035aUL, 0xffbe4c88UL, 0xffbd95b6UL, >- 0xffbcdee4UL, 0xffbc2812UL, 0xffbb7140UL, 0xffbaba6eUL, 0xffba039cUL, 0xffb94ccaUL, >- 0xffb895f8UL, 0xffb7df26UL, 0xffb72854UL, 0xffb67182UL, 0xffb5bab0UL, 0xffb503deUL, >- 0xffb44d0cUL, 0xffb3963aUL, 0xffb2df68UL, 0xffb22896UL, 0xffb171c4UL, 0xffb0baf2UL, >- 0xffb00420UL, 0xffaf4d4eUL, 0xffae967cUL, 0xffaddfaaUL, 0xffad28d8UL, 0xffac7206UL, >- 0xffabbb34UL, 0xffab0462UL, 0xffaa4d90UL, 0xffa996beUL, 0xffa8dfecUL, 0xffa8291aUL, >- 0xffa77248UL, 0xffa6bb76UL, 0xffa604a4UL, 0xffa54dd2UL >- }; >- >-const int Cb_g_tab[(MAXJSAMPLE+1) * SIZEOF(int)] ={ >- 0x2c8d00UL, 0x2c34e6UL, 0x2bdcccUL, 0x2b84b2UL, 0x2b2c98UL, 0x2ad47eUL, >- 0x2a7c64UL, 0x2a244aUL, 0x29cc30UL, 0x297416UL, 0x291bfcUL, 0x28c3e2UL, >- 0x286bc8UL, 0x2813aeUL, 0x27bb94UL, 0x27637aUL, 0x270b60UL, 0x26b346UL, >- 0x265b2cUL, 0x260312UL, 0x25aaf8UL, 0x2552deUL, 0x24fac4UL, 0x24a2aaUL, >- 0x244a90UL, 0x23f276UL, 0x239a5cUL, 0x234242UL, 0x22ea28UL, 0x22920eUL, >- 0x2239f4UL, 0x21e1daUL, 0x2189c0UL, 0x2131a6UL, 0x20d98cUL, 0x208172UL, >- 0x202958UL, 0x1fd13eUL, 0x1f7924UL, 0x1f210aUL, 0x1ec8f0UL, 0x1e70d6UL, >- 0x1e18bcUL, 0x1dc0a2UL, 0x1d6888UL, 0x1d106eUL, 0x1cb854UL, 0x1c603aUL, >- 0x1c0820UL, 0x1bb006UL, 0x1b57ecUL, 0x1affd2UL, 0x1aa7b8UL, 0x1a4f9eUL, >- 0x19f784UL, 0x199f6aUL, 0x194750UL, 0x18ef36UL, 0x18971cUL, 0x183f02UL, >- 0x17e6e8UL, 0x178eceUL, 0x1736b4UL, 0x16de9aUL, 0x168680UL, 0x162e66UL, >- 0x15d64cUL, 0x157e32UL, 0x152618UL, 0x14cdfeUL, 0x1475e4UL, 0x141dcaUL, >- 0x13c5b0UL, 0x136d96UL, 0x13157cUL, 0x12bd62UL, 0x126548UL, 0x120d2eUL, >- 0x11b514UL, 0x115cfaUL, 0x1104e0UL, 0x10acc6UL, 0x1054acUL, 0xffc92UL, >- 0xfa478UL, 0xf4c5eUL, 0xef444UL, 0xe9c2aUL, 0xe4410UL, 0xdebf6UL, >- 0xd93dcUL, 0xd3bc2UL, 0xce3a8UL, 0xc8b8eUL, 0xc3374UL, 0xbdb5aUL, >- 0xb8340UL, 0xb2b26UL, 0xad30cUL, 0xa7af2UL, 0xa22d8UL, 0x9cabeUL, >- 0x972a4UL, 0x91a8aUL, 0x8c270UL, 0x86a56UL, 0x8123cUL, 0x7ba22UL, >- 0x76208UL, 0x709eeUL, 0x6b1d4UL, 0x659baUL, 0x601a0UL, 0x5a986UL, >- 0x5516cUL, 0x4f952UL, 0x4a138UL, 0x4491eUL, 0x3f104UL, 0x398eaUL, >- 0x340d0UL, 0x2e8b6UL, 0x2909cUL, 0x23882UL, 0x1e068UL, 0x1884eUL, >- 0x13034UL, 0xd81aUL, 0x8000UL, 0x27e6UL, 0xffffcfccUL, 0xffff77b2UL, >- 0xffff1f98UL, 0xfffec77eUL, 0xfffe6f64UL, 0xfffe174aUL, 0xfffdbf30UL, 0xfffd6716UL, >- 0xfffd0efcUL, 0xfffcb6e2UL, 0xfffc5ec8UL, 0xfffc06aeUL, 0xfffbae94UL, 0xfffb567aUL, >- 0xfffafe60UL, 0xfffaa646UL, 0xfffa4e2cUL, 0xfff9f612UL, 0xfff99df8UL, 0xfff945deUL, >- 0xfff8edc4UL, 0xfff895aaUL, 0xfff83d90UL, 0xfff7e576UL, 0xfff78d5cUL, 0xfff73542UL, >- 0xfff6dd28UL, 0xfff6850eUL, 0xfff62cf4UL, 0xfff5d4daUL, 0xfff57cc0UL, 0xfff524a6UL, >- 0xfff4cc8cUL, 0xfff47472UL, 0xfff41c58UL, 0xfff3c43eUL, 0xfff36c24UL, 0xfff3140aUL, >- 0xfff2bbf0UL, 0xfff263d6UL, 0xfff20bbcUL, 0xfff1b3a2UL, 0xfff15b88UL, 0xfff1036eUL, >- 0xfff0ab54UL, 0xfff0533aUL, 0xffeffb20UL, 0xffefa306UL, 0xffef4aecUL, 0xffeef2d2UL, >- 0xffee9ab8UL, 0xffee429eUL, 0xffedea84UL, 0xffed926aUL, 0xffed3a50UL, 0xffece236UL, >- 0xffec8a1cUL, 0xffec3202UL, 0xffebd9e8UL, 0xffeb81ceUL, 0xffeb29b4UL, 0xffead19aUL, >- 0xffea7980UL, 0xffea2166UL, 0xffe9c94cUL, 0xffe97132UL, 0xffe91918UL, 0xffe8c0feUL, >- 0xffe868e4UL, 0xffe810caUL, 0xffe7b8b0UL, 0xffe76096UL, 0xffe7087cUL, 0xffe6b062UL, >- 0xffe65848UL, 0xffe6002eUL, 0xffe5a814UL, 0xffe54ffaUL, 0xffe4f7e0UL, 0xffe49fc6UL, >- 0xffe447acUL, 0xffe3ef92UL, 0xffe39778UL, 0xffe33f5eUL, 0xffe2e744UL, 0xffe28f2aUL, >- 0xffe23710UL, 0xffe1def6UL, 0xffe186dcUL, 0xffe12ec2UL, 0xffe0d6a8UL, 0xffe07e8eUL, >- 0xffe02674UL, 0xffdfce5aUL, 0xffdf7640UL, 0xffdf1e26UL, 0xffdec60cUL, 0xffde6df2UL, >- 0xffde15d8UL, 0xffddbdbeUL, 0xffdd65a4UL, 0xffdd0d8aUL, 0xffdcb570UL, 0xffdc5d56UL, >- 0xffdc053cUL, 0xffdbad22UL, 0xffdb5508UL, 0xffdafceeUL, 0xffdaa4d4UL, 0xffda4cbaUL, >- 0xffd9f4a0UL, 0xffd99c86UL, 0xffd9446cUL, 0xffd8ec52UL, 0xffd89438UL, 0xffd83c1eUL, >- 0xffd7e404UL, 0xffd78beaUL, 0xffd733d0UL, 0xffd6dbb6UL, 0xffd6839cUL, 0xffd62b82UL, >- 0xffd5d368UL, 0xffd57b4eUL, 0xffd52334UL, 0xffd4cb1aUL >- }; > > /* > * Initialize tables for YCC->RGB colorspace conversion. > */ > > LOCAL(void) > build_ycc_rgb_table (j_decompress_ptr cinfo) > { >- >- /* The code below was used to generate the static tables above */ >- >-#if 0 > my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; > int i; > INT32 x; > SHIFT_TEMPS > > cconvert->Cr_r_tab = (int *) > (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, > (MAXJSAMPLE+1) * SIZEOF(int)); >@@ -291,17 +100,16 @@ build_ycc_rgb_table (j_decompress_ptr ci > cconvert->Cb_b_tab[i] = (int) > RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); > /* Cr=>G value is scaled-up -0.71414 * x */ > cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; > /* Cb=>G value is scaled-up -0.34414 * x */ > /* We also add in ONE_HALF so that need not do it in inner loop */ > cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; > } >-#endif /* 0 */ > } > > > /* > * Convert some rows of samples to the output colorspace. > * > * Note that we change from noninterleaved, one-plane-per-component format > * to interleaved-pixel format. The output buffer is therefore three times >@@ -313,42 +121,45 @@ build_ycc_rgb_table (j_decompress_ptr ci > > METHODDEF(void) > ycc_rgb_convert (j_decompress_ptr cinfo, > JSAMPIMAGE input_buf, JDIMENSION input_row, > JSAMPARRAY output_buf, int num_rows) > { > my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; > register int y, cb, cr; >- JSAMPLE * range_limit_y; >- JSAMPROW outptr; >- JSAMPROW inptr0, inptr1, inptr2; >- JDIMENSION col; >+ register JSAMPROW outptr; >+ register JSAMPROW inptr0, inptr1, inptr2; >+ register JDIMENSION col; > JDIMENSION num_cols = cinfo->output_width; >- JSAMPLE * range_limit = cinfo->sample_range_limit; >+ /* copy these pointers into registers if possible */ >+ register JSAMPLE * range_limit = cinfo->sample_range_limit; >+ register int * Crrtab = cconvert->Cr_r_tab; >+ register int * Cbbtab = cconvert->Cb_b_tab; >+ register INT32 * Crgtab = cconvert->Cr_g_tab; >+ register INT32 * Cbgtab = cconvert->Cb_g_tab; > SHIFT_TEMPS > > while (--num_rows >= 0) { > inptr0 = input_buf[0][input_row]; > inptr1 = input_buf[1][input_row]; > inptr2 = input_buf[2][input_row]; > input_row++; > outptr = *output_buf++; > for (col = 0; col < num_cols; col++) { > y = GETJSAMPLE(inptr0[col]); > cb = GETJSAMPLE(inptr1[col]); > cr = GETJSAMPLE(inptr2[col]); >- range_limit_y = range_limit + y; > /* Range-limiting is essential due to noise introduced by DCT losses. */ >- outptr[RGB_RED] = range_limit_y[Cr_r_tab[cr]]; >- outptr[RGB_GREEN] = range_limit_y[ >- ((int) RIGHT_SHIFT(Cb_g_tab[cb] + Cr_g_tab[cr], >+ outptr[rgb_red[cinfo->out_color_space]] = range_limit[y + Crrtab[cr]]; >+ outptr[rgb_green[cinfo->out_color_space]] = range_limit[y + >+ ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], > SCALEBITS))]; >- outptr[RGB_BLUE] = range_limit_y[Cb_b_tab[cb]]; >- outptr += RGB_PIXELSIZE; >+ outptr[rgb_blue[cinfo->out_color_space]] = range_limit[y + Cbbtab[cb]]; >+ outptr += rgb_pixelsize[cinfo->out_color_space]; > } > } > } > > > /**************** Cases other than YCbCr -> RGB **************/ > > >@@ -406,69 +217,79 @@ grayscale_convert (j_decompress_ptr cinf > */ > > METHODDEF(void) > gray_rgb_convert (j_decompress_ptr cinfo, > JSAMPIMAGE input_buf, JDIMENSION input_row, > JSAMPARRAY output_buf, int num_rows) > { > register JSAMPROW inptr, outptr; >+ JSAMPLE *maxinptr; > register JDIMENSION col; > JDIMENSION num_cols = cinfo->output_width; >+ int rindex = rgb_red[cinfo->out_color_space]; >+ int gindex = rgb_green[cinfo->out_color_space]; >+ int bindex = rgb_blue[cinfo->out_color_space]; >+ int rgbstride = rgb_pixelsize[cinfo->out_color_space]; > > while (--num_rows >= 0) { > inptr = input_buf[0][input_row++]; >+ maxinptr = &inptr[num_cols]; > outptr = *output_buf++; >- for (col = 0; col < num_cols; col++) { >+ for (; inptr < maxinptr; inptr++, outptr += rgbstride) { > /* We can dispense with GETJSAMPLE() here */ >- outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; >- outptr += RGB_PIXELSIZE; >+ outptr[rindex] = outptr[gindex] = outptr[bindex] = *inptr; > } > } > } > > > /* > * Adobe-style YCCK->CMYK conversion. > * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same > * conversion as above, while passing K (black) unchanged. >+ * We assume build_ycc_rgb_table has been called. > */ > > METHODDEF(void) > ycck_cmyk_convert (j_decompress_ptr cinfo, > JSAMPIMAGE input_buf, JDIMENSION input_row, > JSAMPARRAY output_buf, int num_rows) > { > my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; > register int y, cb, cr; > register JSAMPROW outptr; > register JSAMPROW inptr0, inptr1, inptr2, inptr3; > register JDIMENSION col; > JDIMENSION num_cols = cinfo->output_width; > /* copy these pointers into registers if possible */ > register JSAMPLE * range_limit = cinfo->sample_range_limit; >+ register int * Crrtab = cconvert->Cr_r_tab; >+ register int * Cbbtab = cconvert->Cb_b_tab; >+ register INT32 * Crgtab = cconvert->Cr_g_tab; >+ register INT32 * Cbgtab = cconvert->Cb_g_tab; > SHIFT_TEMPS > > while (--num_rows >= 0) { > inptr0 = input_buf[0][input_row]; > inptr1 = input_buf[1][input_row]; > inptr2 = input_buf[2][input_row]; > inptr3 = input_buf[3][input_row]; > input_row++; > outptr = *output_buf++; > for (col = 0; col < num_cols; col++) { > y = GETJSAMPLE(inptr0[col]); > cb = GETJSAMPLE(inptr1[col]); > cr = GETJSAMPLE(inptr2[col]); > /* Range-limiting is essential due to noise introduced by DCT losses. */ >- outptr[0] = range_limit[MAXJSAMPLE - (y + Cr_r_tab[cr])]; /* red */ >- outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ >- ((int) RIGHT_SHIFT(Cb_g_tab[cb] + Cr_g_tab[cr], >- SCALEBITS)))]; >- outptr[2] = range_limit[MAXJSAMPLE - (y + Cb_b_tab[cb])]; /* blue */ >+ outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ >+ outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ >+ ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], >+ SCALEBITS)))]; >+ outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ > /* K passes through unchanged */ > outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ > outptr += 4; > } > } > } > > >@@ -538,23 +359,34 @@ jinit_color_deconverter (j_decompress_pt > /* For color->grayscale conversion, only the Y (0) component is needed */ > for (ci = 1; ci < cinfo->num_components; ci++) > cinfo->comp_info[ci].component_needed = FALSE; > } else > ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); > break; > > case JCS_RGB: >- cinfo->out_color_components = RGB_PIXELSIZE; >+ case JCS_EXT_RGB: >+ case JCS_EXT_RGBX: >+ case JCS_EXT_BGR: >+ case JCS_EXT_BGRX: >+ case JCS_EXT_XBGR: >+ case JCS_EXT_XRGB: >+ cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space]; > if (cinfo->jpeg_color_space == JCS_YCbCr) { >- cconvert->pub.color_convert = ycc_rgb_convert; >- build_ycc_rgb_table(cinfo); >+ if (jsimd_can_ycc_rgb()) >+ cconvert->pub.color_convert = jsimd_ycc_rgb_convert; >+ else { >+ cconvert->pub.color_convert = ycc_rgb_convert; >+ build_ycc_rgb_table(cinfo); >+ } > } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { > cconvert->pub.color_convert = gray_rgb_convert; >- } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { >+ } else if (cinfo->jpeg_color_space == cinfo->out_color_space && >+ rgb_pixelsize[cinfo->out_color_space] == 3) { > cconvert->pub.color_convert = null_convert; > } else > ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); > break; > > case JCS_CMYK: > cinfo->out_color_components = 4; > if (cinfo->jpeg_color_space == JCS_YCCK) { >diff --git a/jpeg/jdct.h b/modules/libjpeg-turbo/jdct.h >rename from jpeg/jdct.h >rename to modules/libjpeg-turbo/jdct.h >--- a/jpeg/jdct.h >+++ b/modules/libjpeg-turbo/jdct.h >@@ -18,28 +18,36 @@ > * the DCT is to be performed in-place in that buffer. Type DCTELEM is int > * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT > * implementations use an array of type FAST_FLOAT, instead.) > * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). > * The DCT outputs are returned scaled up by a factor of 8; they therefore > * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This > * convention improves accuracy in integer implementations and saves some > * work in floating-point ones. >- * Quantization of the output coefficients is done by jcdctmgr.c. >+ * Quantization of the output coefficients is done by jcdctmgr.c. This >+ * step requires an unsigned type and also one with twice the bits. > */ > > #if BITS_IN_JSAMPLE == 8 >+#ifndef WITH_SIMD > typedef int DCTELEM; /* 16 or 32 bits is fine */ >+typedef unsigned int UDCTELEM; >+typedef unsigned long long UDCTELEM2; >+#else >+typedef short DCTELEM; /* prefer 16 bit with SIMD for parellelism */ >+typedef unsigned short UDCTELEM; >+typedef unsigned int UDCTELEM2; >+#endif > #else > typedef INT32 DCTELEM; /* must have 32 bits */ >+typedef UINT32 UDCTELEM; >+typedef unsigned long long UDCTELEM2; > #endif > >-typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); >-typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); >- > > /* > * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer > * to an output sample array. The routine must dequantize the input data as > * well as perform the IDCT; for dequantization, it uses the multiplier table > * pointed to by compptr->dct_table. The output data is to be placed into the > * sample array starting at a specified column. (Any row offset needed will > * be applied to the array pointer before it is passed to the IDCT code.) >diff --git a/jpeg/jddctmgr.c b/modules/libjpeg-turbo/jddctmgr.c >rename from jpeg/jddctmgr.c >rename to modules/libjpeg-turbo/jddctmgr.c >--- a/jpeg/jddctmgr.c >+++ b/modules/libjpeg-turbo/jddctmgr.c >@@ -1,12 +1,13 @@ > /* > * jddctmgr.c > * > * Copyright (C) 1994-1996, Thomas G. Lane. >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains the inverse-DCT management logic. > * This code selects a particular IDCT implementation to be used, > * and it performs related housekeeping chores. No code in this file > * is executed per IDCT step, only during output pass setup. > * >@@ -14,19 +15,18 @@ > * dequantization as well as the IDCT proper. This module sets up the > * dequantization multiplier table needed by the IDCT routine. > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" > #include "jdct.h" /* Private declarations for DCT subsystem */ >-#ifdef HAVE_SSE2_INTRINSICS >-extern int SSE2Available; >-#endif >+#include "jsimddct.h" >+ > > /* > * The decompressor input side (jdinput.c) saves away the appropriate > * quantization table for each component at the start of the first scan > * involving that component. (This is necessary in order to correctly > * decode files that reuse Q-table slots.) > * When we are ready to make an output pass, the saved Q-table is converted > * to a multiplier table that will actually be used by the IDCT routine. >@@ -75,24 +75,16 @@ typedef union { > #ifdef DCT_ISLOW_SUPPORTED > #define PROVIDE_ISLOW_TABLES > #else > #ifdef IDCT_SCALING_SUPPORTED > #define PROVIDE_ISLOW_TABLES > #endif > #endif > >-GLOBAL(void) >-jpeg_idct_islow_sse2 ( >- j_decompress_ptr cinfo, >- jpeg_component_info * compptr, >- JCOEFPTR coef_block, >- JSAMPARRAY output_buf, >- JDIMENSION output_col); >- > > /* > * Prepare for an output pass. > * Here we select the proper IDCT routine for each component and build > * a matching multiplier table. > */ > > METHODDEF(void) >@@ -110,69 +102,56 @@ start_pass (j_decompress_ptr cinfo) > /* Select the proper IDCT routine for this component's scaling */ > switch (compptr->DCT_scaled_size) { > #ifdef IDCT_SCALING_SUPPORTED > case 1: > method_ptr = jpeg_idct_1x1; > method = JDCT_ISLOW; /* jidctred uses islow-style table */ > break; > case 2: >- method_ptr = jpeg_idct_2x2; >+ if (jsimd_can_idct_2x2()) >+ method_ptr = jsimd_idct_2x2; >+ else >+ method_ptr = jpeg_idct_2x2; > method = JDCT_ISLOW; /* jidctred uses islow-style table */ > break; > case 4: >- method_ptr = jpeg_idct_4x4; >+ if (jsimd_can_idct_4x4()) >+ method_ptr = jsimd_idct_4x4; >+ else >+ method_ptr = jpeg_idct_4x4; > method = JDCT_ISLOW; /* jidctred uses islow-style table */ > break; > #endif > case DCTSIZE: > switch (cinfo->dct_method) { > #ifdef DCT_ISLOW_SUPPORTED > case JDCT_ISLOW: >-#ifdef HAVE_SSE2_INTEL_MNEMONICS >- if(SSE2Available == 1) >- { >- method_ptr = jpeg_idct_islow_sse2; >- method = JDCT_ISLOW; >- } >- else >- { >- method_ptr = jpeg_idct_islow; >- method = JDCT_ISLOW; >- } >-#else >- method_ptr = jpeg_idct_islow; >- method = JDCT_ISLOW; >- >-#endif /* HAVE_SSE2_INTEL_MNEMONICS */ >+ if (jsimd_can_idct_islow()) >+ method_ptr = jsimd_idct_islow; >+ else >+ method_ptr = jpeg_idct_islow; >+ method = JDCT_ISLOW; > break; > #endif > #ifdef DCT_IFAST_SUPPORTED > case JDCT_IFAST: >-#ifdef HAVE_SSE2_INTEL_MNEMONICS >- if (SSE2Available==1) >- { >- method_ptr = jpeg_idct_islow_sse2; >- method = JDCT_ISLOW; >- } >- else >- { >- method_ptr = jpeg_idct_ifast; >- method = JDCT_IFAST; >- } >-#else >- method_ptr = jpeg_idct_ifast; >- method = JDCT_IFAST; >-#endif /* HAVE_SSE2_INTEL_MNEMONICS */ >+ if (jsimd_can_idct_ifast()) >+ method_ptr = jsimd_idct_ifast; >+ else >+ method_ptr = jpeg_idct_ifast; >+ method = JDCT_IFAST; > break; >- > #endif > #ifdef DCT_FLOAT_SUPPORTED > case JDCT_FLOAT: >- method_ptr = jpeg_idct_float; >+ if (jsimd_can_idct_float()) >+ method_ptr = jsimd_idct_float; >+ else >+ method_ptr = jpeg_idct_float; > method = JDCT_FLOAT; > break; > #endif > default: > ERREXIT(cinfo, JERR_NOT_COMPILED); > break; > } > break; >diff --git a/jpeg/jdhuff.c b/modules/libjpeg-turbo/jdhuff.c >rename from jpeg/jdhuff.c >rename to modules/libjpeg-turbo/jdhuff.c >diff --git a/jpeg/jdhuff.h b/modules/libjpeg-turbo/jdhuff.h >rename from jpeg/jdhuff.h >rename to modules/libjpeg-turbo/jdhuff.h >diff --git a/jpeg/jdinput.c b/modules/libjpeg-turbo/jdinput.c >rename from jpeg/jdinput.c >rename to modules/libjpeg-turbo/jdinput.c >diff --git a/jpeg/jdmainct.c b/modules/libjpeg-turbo/jdmainct.c >rename from jpeg/jdmainct.c >rename to modules/libjpeg-turbo/jdmainct.c >diff --git a/jpeg/jdmarker.c b/modules/libjpeg-turbo/jdmarker.c >rename from jpeg/jdmarker.c >rename to modules/libjpeg-turbo/jdmarker.c >--- a/jpeg/jdmarker.c >+++ b/modules/libjpeg-turbo/jdmarker.c >@@ -74,17 +74,19 @@ typedef enum { /* JPEG marker codes */ > M_APP13 = 0xed, > M_APP14 = 0xee, > M_APP15 = 0xef, > > M_JPG0 = 0xf0, > M_JPG13 = 0xfd, > M_COM = 0xfe, > >- M_TEM = 0x01 >+ M_TEM = 0x01, >+ >+ M_ERROR = 0x100 > } JPEG_MARKER; > > > /* Private state */ > > typedef struct { > struct jpeg_marker_reader pub; /* public fields */ > >diff --git a/jpeg/jdmaster.c b/modules/libjpeg-turbo/jdmaster.c >rename from jpeg/jdmaster.c >rename to modules/libjpeg-turbo/jdmaster.c >--- a/jpeg/jdmaster.c >+++ b/modules/libjpeg-turbo/jdmaster.c >@@ -1,123 +1,26 @@ > /* > * jdmaster.c > * > * Copyright (C) 1991-1997, Thomas G. Lane. >+ * Copyright (C) 2009, D. R. Commander. > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains master control logic for the JPEG decompressor. > * These routines are concerned with selecting the modules to be executed > * and with determining the number of passes and the work to be done in each > * pass. > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" > >-/* Use static array */ >- >-const JSAMPLE static_range_table[ (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE) ]={ >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, >- 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, >- 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, >- 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, >- 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, >- 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, >- 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, >- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, >- 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, >- 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, >- 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, >- 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, >- 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, >- 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, >- 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, >- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, >- 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, >- 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, >- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, >- 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, >- 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, >- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, >- 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, >- 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, >- 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, >- 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, >- 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f >-}; > > /* Private state */ > > typedef struct { > struct jpeg_decomp_master pub; /* public fields */ > > int pass_number; /* # of passes completed */ > >@@ -142,18 +45,24 @@ LOCAL(boolean) > use_merged_upsample (j_decompress_ptr cinfo) > { > #ifdef UPSAMPLE_MERGING_SUPPORTED > /* Merging is the equivalent of plain box-filter upsampling */ > if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) > return FALSE; > /* jdmerge.c only supports YCC=>RGB color conversion */ > if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || >- cinfo->out_color_space != JCS_RGB || >- cinfo->out_color_components != RGB_PIXELSIZE) >+ (cinfo->out_color_space != JCS_RGB && >+ cinfo->out_color_space != JCS_EXT_RGB && >+ cinfo->out_color_space != JCS_EXT_RGBX && >+ cinfo->out_color_space != JCS_EXT_BGR && >+ cinfo->out_color_space != JCS_EXT_BGRX && >+ cinfo->out_color_space != JCS_EXT_XBGR && >+ cinfo->out_color_space != JCS_EXT_XRGB) || >+ cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space]) > return FALSE; > /* and it only handles 2h1v or 2h2v sampling ratios */ > if (cinfo->comp_info[0].h_samp_factor != 2 || > cinfo->comp_info[1].h_samp_factor != 1 || > cinfo->comp_info[2].h_samp_factor != 1 || > cinfo->comp_info[0].v_samp_factor > 2 || > cinfo->comp_info[1].v_samp_factor != 1 || > cinfo->comp_info[2].v_samp_factor != 1) >@@ -268,20 +177,24 @@ jpeg_calc_output_dimensions (j_decompres > > /* Report number of components in selected colorspace. */ > /* Probably this should be in the color conversion module... */ > switch (cinfo->out_color_space) { > case JCS_GRAYSCALE: > cinfo->out_color_components = 1; > break; > case JCS_RGB: >-#if RGB_PIXELSIZE != 3 >- cinfo->out_color_components = RGB_PIXELSIZE; >+ case JCS_EXT_RGB: >+ case JCS_EXT_RGBX: >+ case JCS_EXT_BGR: >+ case JCS_EXT_BGRX: >+ case JCS_EXT_XBGR: >+ case JCS_EXT_XRGB: >+ cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space]; > break; >-#endif /* else share code with YCbCr */ > case JCS_YCbCr: > cinfo->out_color_components = 3; > break; > case JCS_CMYK: > case JCS_YCCK: > cinfo->out_color_components = 4; > break; > default: /* else must be same colorspace as in file */ >@@ -341,24 +254,16 @@ jpeg_calc_output_dimensions (j_decompres > * Note that the table is allocated in near data space on PCs; it's small > * enough and used often enough to justify this. > */ > > LOCAL(void) > prepare_range_limit_table (j_decompress_ptr cinfo) > /* Allocate and fill in the sample_range_limit table */ > { >- /* Use a static table and allow negative subscripts of simple table */ >- >- cinfo->sample_range_limit = (JSAMPLE *) static_range_table + (MAXJSAMPLE+1); >- >- /* This code is used to create the values for the static table used above */ >- >-#if 0 >- > JSAMPLE * table; > int i; > > table = (JSAMPLE *) > (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, > (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); > table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ > cinfo->sample_range_limit = table; >@@ -371,18 +276,16 @@ prepare_range_limit_table (j_decompress_ > /* End of simple table, rest of first half of post-IDCT table */ > for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) > table[i] = MAXJSAMPLE; > /* Second half of post-IDCT table */ > MEMZERO(table + (2 * (MAXJSAMPLE+1)), > (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); > MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), > cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); >- >-#endif /* 0 */ > } > > > /* > * Master selection of decompression modules. > * This is done once at jpeg_start_decompress time. We determine > * which modules will be used and give them appropriate initialization calls. > * We also initialize the decompressor input side to begin consuming data. >diff --git a/jpeg/jdmerge.c b/modules/libjpeg-turbo/jdmerge.c >rename from jpeg/jdmerge.c >rename to modules/libjpeg-turbo/jdmerge.c >--- a/jpeg/jdmerge.c >+++ b/modules/libjpeg-turbo/jdmerge.c >@@ -1,12 +1,14 @@ > /* > * jdmerge.c > * > * Copyright (C) 1994-1996, Thomas G. Lane. >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+ * Copyright (C) 2009, D. R. Commander. > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains code for merged upsampling/color conversion. > * > * This file combines functions from jdsample.c and jdcolor.c; > * read those files first to understand what's going on. > * >@@ -30,32 +32,20 @@ > * Other special cases could be added, but in most applications these are > * the only common cases. (For uncommon cases we fall back on the more > * general code in jdsample.c and jdcolor.c.) > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" >+#include "jsimd.h" > > #ifdef UPSAMPLE_MERGING_SUPPORTED > >-#ifdef HAVE_MMX_INTEL_MNEMONICS >- __int64 const1 = 0x59BA0000D24B59BA; // Cr_r Cr_b Cr_g Cr_r >- __int64 const2 = 0x00007168E9FA0000; // Cb-r Cb_b Cb_g Cb_r >- __int64 const5 = 0x0000D24B59BA0000; // Cr_b Cr_g Cr_r Cr_b >- __int64 const6 = 0x7168E9FA00007168; // Cb_b Cb_g Cb_r Cb_b >- >- // constants for factors (One_Half/fix(x)) << 2 >- >- __int64 const05 = 0x0001000000000001; // Cr_r Cr_b Cr_g Cr_r >- __int64 const15 = 0x00000001FFFA0000; // Cb-r Cb_b Cb_g Cb_r >- __int64 const45 = 0x0000000000010000; // Cr_b Cr_g Cr_r Cr_b >- __int64 const55 = 0x0001FFFA00000001; // Cb_b Cb_g Cb_r Cb_b >-#endif > > /* Private subobject */ > > typedef struct { > struct jpeg_upsampler pub; /* public fields */ > > /* Pointer to routine to do actual upsampling/conversion of one row group */ > JMETHOD(void, upmethod, (j_decompress_ptr cinfo, >@@ -235,19 +225,17 @@ merged_1v_upsample (j_decompress_ptr cin > * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. > */ > > METHODDEF(void) > h2v1_merged_upsample (j_decompress_ptr cinfo, > JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, > JSAMPARRAY output_buf) > { >- >- >- my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; >+ my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; > register int y, cred, cgreen, cblue; > int cb, cr; > register JSAMPROW outptr; > JSAMPROW inptr0, inptr1, inptr2; > JDIMENSION col; > /* copy these pointers into registers if possible */ > register JSAMPLE * range_limit = cinfo->sample_range_limit; > int * Crrtab = upsample->Cr_r_tab; >@@ -265,653 +253,45 @@ h2v1_merged_upsample (j_decompress_ptr c > /* Do the chroma part of the calculation */ > cb = GETJSAMPLE(*inptr1++); > cr = GETJSAMPLE(*inptr2++); > cred = Crrtab[cr]; > cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); > cblue = Cbbtab[cb]; > /* Fetch 2 Y values and emit 2 pixels */ > y = GETJSAMPLE(*inptr0++); >- outptr[RGB_RED] = range_limit[y + cred]; >- outptr[RGB_GREEN] = range_limit[y + cgreen]; >- outptr[RGB_BLUE] = range_limit[y + cblue]; >- outptr += RGB_PIXELSIZE; >+ outptr[rgb_red[cinfo->out_color_space]] = range_limit[y + cred]; >+ outptr[rgb_green[cinfo->out_color_space]] = range_limit[y + cgreen]; >+ outptr[rgb_blue[cinfo->out_color_space]] = range_limit[y + cblue]; >+ outptr += rgb_pixelsize[cinfo->out_color_space]; > y = GETJSAMPLE(*inptr0++); >- outptr[RGB_RED] = range_limit[y + cred]; >- outptr[RGB_GREEN] = range_limit[y + cgreen]; >- outptr[RGB_BLUE] = range_limit[y + cblue]; >- outptr += RGB_PIXELSIZE; >+ outptr[rgb_red[cinfo->out_color_space]] = range_limit[y + cred]; >+ outptr[rgb_green[cinfo->out_color_space]] = range_limit[y + cgreen]; >+ outptr[rgb_blue[cinfo->out_color_space]] = range_limit[y + cblue]; >+ outptr += rgb_pixelsize[cinfo->out_color_space]; > } > /* If image width is odd, do the last output column separately */ > if (cinfo->output_width & 1) { > cb = GETJSAMPLE(*inptr1); > cr = GETJSAMPLE(*inptr2); > cred = Crrtab[cr]; > cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); > cblue = Cbbtab[cb]; > y = GETJSAMPLE(*inptr0); >- outptr[RGB_RED] = range_limit[y + cred]; >- outptr[RGB_GREEN] = range_limit[y + cgreen]; >- outptr[RGB_BLUE] = range_limit[y + cblue]; >+ outptr[rgb_red[cinfo->out_color_space]] = range_limit[y + cred]; >+ outptr[rgb_green[cinfo->out_color_space]] = range_limit[y + cgreen]; >+ outptr[rgb_blue[cinfo->out_color_space]] = range_limit[y + cblue]; > } > } > > > /* > * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. > */ > >-#ifdef HAVE_MMX_INTEL_MNEMONICS >-__inline METHODDEF(void) >-h2v2_merged_upsample_orig (j_decompress_ptr cinfo, >- JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, >- JSAMPARRAY output_buf); >-__inline METHODDEF(void) >-h2v2_merged_upsample_mmx (j_decompress_ptr cinfo, >- JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, >- JSAMPARRAY output_buf); >-#endif >- >-METHODDEF(void) >-h2v2_merged_upsample (j_decompress_ptr cinfo, >- JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, >- JSAMPARRAY output_buf); >- >-#ifdef HAVE_MMX_INTEL_MNEMONICS >-METHODDEF(void) >-h2v2_merged_upsample (j_decompress_ptr cinfo, >- JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, >- JSAMPARRAY output_buf) >-{ >-if (MMXAvailable && (cinfo->image_width >= 8)) >- h2v2_merged_upsample_mmx (cinfo, input_buf, in_row_group_ctr, output_buf); >-else >- h2v2_merged_upsample_orig (cinfo, input_buf, in_row_group_ctr, output_buf); >- >-} >- >-__inline METHODDEF(void) >-h2v2_merged_upsample_orig (j_decompress_ptr cinfo, >- JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, >- JSAMPARRAY output_buf) >-{ >- >- my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; >- register int y, cred, cgreen, cblue; >- int cb, cr; >- register JSAMPROW outptr0, outptr1; >- JSAMPROW inptr00, inptr01, inptr1, inptr2; >- JDIMENSION col; >- /* copy these pointers into registers if possible */ >- register JSAMPLE * range_limit = cinfo->sample_range_limit; >- int * Crrtab = upsample->Cr_r_tab; >- int * Cbbtab = upsample->Cb_b_tab; >- INT32 * Crgtab = upsample->Cr_g_tab; >- INT32 * Cbgtab = upsample->Cb_g_tab; >- SHIFT_TEMPS >- >- inptr00 = input_buf[0][in_row_group_ctr*2]; >- inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; >- inptr1 = input_buf[1][in_row_group_ctr]; >- inptr2 = input_buf[2][in_row_group_ctr]; >- outptr0 = output_buf[0]; >- outptr1 = output_buf[1]; >- /* Loop for each group of output pixels */ >- for (col = cinfo->output_width >> 1; col > 0; col--) { >- /* Do the chroma part of the calculation */ >- cb = GETJSAMPLE(*inptr1++); >- cr = GETJSAMPLE(*inptr2++); >- cred = Crrtab[cr]; >- cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); >- cblue = Cbbtab[cb]; >- /* Fetch 4 Y values and emit 4 pixels */ >- y = GETJSAMPLE(*inptr00++); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >- outptr0 += RGB_PIXELSIZE; >- y = GETJSAMPLE(*inptr00++); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >- outptr0 += RGB_PIXELSIZE; >- y = GETJSAMPLE(*inptr01++); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >- outptr1 += RGB_PIXELSIZE; >- y = GETJSAMPLE(*inptr01++); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >- outptr1 += RGB_PIXELSIZE; >- } >- /* If image width is odd, do the last output column separately */ >- if (cinfo->output_width & 1) { >- cb = GETJSAMPLE(*inptr1); >- cr = GETJSAMPLE(*inptr2); >- cred = Crrtab[cr]; >- cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); >- cblue = Cbbtab[cb]; >- y = GETJSAMPLE(*inptr00); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >- y = GETJSAMPLE(*inptr01); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >- } >-} >- >-/* >- * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. >- */ >-__inline METHODDEF(void) >-h2v2_merged_upsample_mmx (j_decompress_ptr cinfo, >- JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, >- JSAMPARRAY output_buf) >-{ >- // added for MMX >- __int64 const128 = 0x0080008000800080; >- __int64 empty = 0x0000000000000000; >- __int64 davemask = 0x0000FFFFFFFF0000; >- //////////////////////////////// >- >- my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; >- register int y, cred, cgreen, cblue; >- int cb, cr; >- register JSAMPROW outptr0, outptr1; >- JSAMPROW inptr00, inptr01, inptr1, inptr2; >- JDIMENSION col; >- /* copy these pointers into registers if possible */ >- register JSAMPLE * range_limit = cinfo->sample_range_limit; >- int * Crrtab = upsample->Cr_r_tab; >- int * Cbbtab = upsample->Cb_b_tab; >- INT32 * Crgtab = upsample->Cr_g_tab; >- INT32 * Cbgtab = upsample->Cb_g_tab; >- SHIFT_TEMPS >- >- >- // Added for MMX >- register int width = cinfo->image_width; >- int cols = cinfo->output_width; >- int cols_asm = (cols >> 3); >- int diff = cols - (cols_asm<<3); >- int cols_asm_copy = cols_asm; >- >- /////////////////////////////////////// >- >- inptr00 = input_buf[0][in_row_group_ctr*2]; >- inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; >- inptr1 = input_buf[1][in_row_group_ctr]; >- inptr2 = input_buf[2][in_row_group_ctr]; >- outptr0 = output_buf[0]; >- outptr1 = output_buf[1]; >- /* Loop for each group of output pixels */ >- >- >- _asm >- { >- mov esi, inptr00 >- >- mov eax, inptr01 >- >- mov ebx, inptr2 >- >- mov ecx, inptr1 >- >- mov edi, outptr0 >- >- mov edx, outptr1 >- >-do_next16: >- >- movd mm0, [ebx] ; Cr7 Cr6.....Cr1 Cr0 >- >- pxor mm6, mm6 >- >- punpcklbw mm0, mm0 ; Cr3 Cr3 Cr2 Cr2 Cr1 Cr1 Cr0 Cr0 >- >- movq mm7, const128 >- >- punpcklwd mm0, mm0 ; Cr1 Cr1 Cr1 Cr1 Cr0 Cr0 Cr0 Cr0 >- >- movq mm4, mm0 >- >- punpcklbw mm0, mm6 ; Cr0 Cr0 Cr0 Cr0 >- >- psubsw mm0, mm7 ; Cr0 - 128:Cr0-128:Cr0-128:Cr0 -128 >- >- movd mm1, [ecx] ; Cb7 Cb6...... Cb1 Cb0 >- >- psllw mm0, 2 ; left shift by 2 bits >- >- punpcklbw mm1, mm1 ; Cb3 Cb3 Cb2 Cb2 Cb1 Cb1 Cb0 Cb0 >- >- paddsw mm0, const05 ; add (one_half/fix(x)) << 2 >- >- punpcklwd mm1, mm1 ; Cb1 Cb1 Cb1 Cb1 Cb0 Cb0 Cb0 Cb0 >- >- movq mm5, mm1 >- >- pmulhw mm0, const1 ; multiply by (fix(x) >> 1) >- >- punpcklbw mm1, mm6 ; Cb0 Cb0 Cb0 Cb0 >- >- punpckhbw mm4, mm6 ; Cr1 Cr1 Cr1 Cr1 >- >- psubsw mm1, mm7 ; Cb0 - 128:Cb0-128:Cb0-128:Cb0 -128 >- >- punpckhbw mm5, mm6 ; Cb1 Cb1 Cb1 Cb1 >- >- psllw mm1, 2 ; left shift by 2 bits >- >- paddsw mm1, const15 ; add (one_half/fix(x)) << 2 >- >- psubsw mm4, mm7 ; Cr1 - 128:Cr1-128:Cr1-128:Cr1 -128 >- >- psubsw mm5, mm7 ; Cb1 - 128:Cb1-128:Cb1-128:Cb1 -128 >- >- pmulhw mm1, const2 ; multiply by (fix(x) >> 1) >- >- psllw mm4, 2 ; left shift by 2 bits >- >- psllw mm5, 2 ; left shift by 2 bits >- >- paddsw mm4, const45 ; add (one_half/fix(x)) << 2 >- >- movd mm7, [esi] ; Y13 Y12 Y9 Y8 Y5 Y4 Y1 Y0 >- >- pmulhw mm4, const5 ; multiply by (fix(x) >> 1) >- >- movq mm6, mm7 >- >- punpcklbw mm7, mm7 ; Y5 Y5 Y4 Y4 Y1 Y1 Y0 Y0 >- >- paddsw mm5, const55 ; add (one_half/fix(x)) << 2 >- >- paddsw mm0, mm1 ; cred0 cbl0 cgr0 cred0 >- >- movq mm1, mm7 >- >- pmulhw mm5, const6 ; multiply by (fix(x) >> 1) >- >- movq mm2, mm0 ; cred0 cbl0 cgr0 cred0 >- >- punpcklwd mm7, mm6 ; Y5 Y4 Y1 Y1 Y1 Y0 Y0 Y0 >- >- pand mm2, davemask ; 0 cbl0 cgr0 0 >- >- psrlq mm1, 16 ; 0 0 Y5 Y5 Y4 Y4 Y1 Y1 >- >- psrlq mm2, 16 ; 0 0 cbl0 cgr0 >- >- punpcklbw mm7, empty ; Y1 Y0 Y0 Y0 >- >- paddsw mm4, mm5 ; cbl1 cgr1 cred1 cbl1 >- >- movq mm3, mm4 ; cbl1 cgr1 cred1 cbl1 >- >- pand mm3, davemask ; 0 cgr1 cred1 0 >- >- paddsw mm7, mm0 ; r1 b0 g0 r0 >- >- psllq mm3, 16 ; cgr1 cred1 0 0 >- >- movq mm6, mm1 ; 0 0 Y5 Y5 Y4 Y4 Y1 Y1 >- >- por mm2, mm3 ; cgr1 cred1 cbl0 cgr0 >- >- punpcklbw mm6, empty ; Y4 Y4 Y1 Y1 >- >- movd mm3, [eax] ; Y15 Y14 Y11 Y10 Y7 Y6 Y3 Y2 >- >- paddsw mm6, mm2 ; g4 r4 b1 g1 >- >- packuswb mm7, mm6 ; g4 r4 b1 g1 r1 b0 g0 r0 >- >- movq mm6, mm3 ; Y15 Y14 Y11 Y10 Y7 Y6 Y3 Y2 >- >- punpcklbw mm3, mm3 ; Y7 Y7 Y6 Y6 Y3 Y3 Y2 Y2 >- >- movq [edi], mm7 ; move to memory g4 r4 b1 g1 r1 b0 g0 r0 >- >- movq mm5, mm3 ; Y7 Y7 Y6 Y6 Y3 Y3 Y2 Y2 >- >- punpcklwd mm3, mm6 ; X X X X Y3 Y2 Y2 Y2 >- >- punpcklbw mm3, empty ; Y3 Y2 Y2 Y2 >- >- psrlq mm5, 16 ; 0 0 Y7 Y7 Y6 Y6 Y3 Y3 >- >- paddsw mm3, mm0 ; r3 b2 g2 r2 >- >- movq mm6, mm5 ; 0 0 Y7 Y7 Y6 Y6 Y3 Y3 >- >- movq mm0, mm1 ; 0 0 Y5 Y5 Y4 Y4 Y1 Y1 >- >- punpckldq mm6, mm6 ; X X X X Y6 Y6 Y3 Y3 >- >- punpcklbw mm6, empty ; Y6 Y6 Y3 Y3 >- >- psrlq mm1, 24 ; 0 0 0 0 0 Y5 Y5 Y4 >- >- paddsw mm6, mm2 ; g6 r6 b3 g3 >- >- packuswb mm3, mm6 ; g6 r6 b3 g3 r3 b2 g2 r2 >- >- movq mm2, mm5 ; 0 0 Y7 Y7 Y6 Y6 Y3 Y3 >- >- psrlq mm0, 32 ; 0 0 0 0 0 0 Y5 Y5 >- >- movq [edx], mm3 ; move to memory g6 r6 b3 g3 r3 b2 g2 r2 >- >- punpcklwd mm1, mm0 ; X X X X Y5 Y5 Y5 Y4 >- >- psrlq mm5, 24 ; 0 0 0 0 0 Y7 Y7 Y6 >- >- movd mm0, [ebx] ; Cr9 Cr8.....Cr3 Cr2 >- >- psrlq mm2, 32 ; 0 0 0 0 0 0 Y7 Y7 >- >- psrlq mm0, 16 >- >- punpcklbw mm1, empty ; Y5 Y5 Y5 Y4 >- >- punpcklwd mm5, mm2 ; X X X X Y7 Y7 Y7 Y6 >- >- paddsw mm1, mm4 ; b5 g5 r5 b4 >- >- punpcklbw mm5, empty ; Y7 Y7 Y7 Y6 >- >- pxor mm6, mm6 ; clear mm6 registr >- >- punpcklbw mm0, mm0 ; X X X X Cr3 Cr3 Cr2 Cr2 >- >- paddsw mm5, mm4 ; b7 g7 r7 b6 >- >- punpcklwd mm0, mm0 ; Cr3 Cr3 Cr3 Cr3 Cr2 Cr2 Cr2 Cr2 >- >- movq mm4, mm0 >- >- movd mm3, [ecx] ; Cb9 Cb8...... Cb3 Cb2 >- >- punpcklbw mm0, mm6 ; Cr2 Cr2 Cr2 Cr2 >- >- psrlq mm3, 16 >- >- psubsw mm0, const128 ; Cr2 - 128:Cr2-128:Cr2-128:Cr2 -128 >- >- punpcklbw mm3, mm3 ; X X X X Cb3 Cb3 Cb2 Cb2 >- >- psllw mm0, 2 ; left shift by 2 bits >- >- paddsw mm0, const05 ; add (one_half/fix(x)) << 2 >- >- punpcklwd mm3, mm3 ; Cb3 Cb3 Cb3 Cb3 Cb2 Cb2 Cb2 Cb2 >- >- movq mm7, mm3 >- >- pmulhw mm0, const1 ; multiply by (fix(x) >> 1) >- >- punpcklbw mm3, mm6 ; Cb2 Cb2 Cb2 Cb2 >- >- psubsw mm3, const128 ; Cb0 - 128:Cb0-128:Cb0-128:Cb0 -128 >- >- punpckhbw mm4, mm6 ; Cr3 Cr3 Cr3 Cr3 >- >- psllw mm3, 2 ; left shift by 2 bits >- >- paddsw mm3, const15 ; add (one_half/fix(x)) << 2 >- >- punpckhbw mm7, mm6 ; Cb3 Cb3 Cb3 Cb3 >- >- pmulhw mm3, const2 ; multiply by (fix(x) >> 1) >- >- psubsw mm7, const128 ; Cb3 - 128:Cb3-128:Cb3-128:Cb3 -128 >- >- paddsw mm0, mm3 ; cred2 cbl2 cgr2 cred2 >- >- psllw mm7, 2 ; left shift by 2 bits >- >- psubsw mm4, const128 ; Cr3 - 128:Cr3-128:Cr3-128:Cr3 -128 >- >- movd mm3, [esi+4] ; Y21 Y20 Y17 Y16 Y13 Y12 Y9 Y8 >- >- psllw mm4, 2 ; left shift by 2 bits >- >- paddsw mm7, const55 ; add (one_half/fix(x)) << 2 >- >- movq mm6, mm3 ; Y21 Y20 Y17 Y16 Y13 Y12 Y9 Y8 >- >- movq mm2, mm0 >- >- pand mm2, davemask >- >- punpcklbw mm3, mm3 ; Y13 Y13 Y12 Y12 Y9 Y9 Y8 Y8 >- >- psrlq mm2, 16 >- >- paddsw mm4, const45 ; add (one_half/fix(x)) << 2 >- >- punpcklwd mm3, mm6 ; X X X X Y9 Y8 Y8 Y8 >- >- pmulhw mm4, const5 ; multiply by (fix(x) >> 1) >- >- pmulhw mm7, const6 ; multiply by (fix(x) >> 1) >- >- punpcklbw mm3, empty ; Y9 Y8 Y8 Y8 >- >- paddsw mm4, mm7 ; cbl3 cgr3 cred3 cbl3 >- >- paddsw mm3, mm0 ; r9 b8 g8 r8 >- >- movq mm7, mm4 >- >- packuswb mm1, mm3 ; r9 b8 g8 r8 b5 g5 r5 b4 >- >- movd mm3, [eax+4] ; Y23 Y22 Y19 Y18 Y15 Y14 Y11 Y10 >- >- pand mm7, davemask >- >- psrlq mm6, 8 ; 0 Y21 Y20 Y17 Y16 Y13 Y12 Y9 >- >- psllq mm7, 16 >- >- movq [edi+8], mm1 ; move to memory r9 b8 g8 r8 b5 g5 r5 b4 >- >- por mm2, mm7 >- >- movq mm7, mm3 ; Y23 Y22 Y19 Y18 Y15 Y14 Y11 Y10 >- >- punpcklbw mm3, mm3 ; X X X X Y11 Y11 Y10 Y10 >- >- pxor mm1, mm1 >- >- punpcklwd mm3, mm7 ; X X X X Y11 Y10 Y10 Y10 >- >- punpcklbw mm3, mm1 ; Y11 Y10 Y10 Y10 >- >- psrlq mm7, 8 ; 0 Y23 Y22 Y19 Y18 Y15 Y14 Y11 >- >- paddsw mm3, mm0 ; r11 b10 g10 r10 >- >- movq mm0, mm7 ; 0 Y23 Y22 Y19 Y18 Y15 Y14 Y11 >- >- packuswb mm5, mm3 ; r11 b10 g10 r10 b7 g7 r7 b6 >- >- punpcklbw mm7, mm7 ; X X X X Y14 Y14 Y11 Y11 >- >- movq [edx+8], mm5 ; move to memory r11 b10 g10 r10 b7 g7 r7 b6 >- >- movq mm3, mm6 ; 0 Y21 Y20 Y17 Y16 Y13 Y12 Y9 >- >- punpcklbw mm6, mm6 ; X X X X Y12 Y12 Y9 Y9 >- >- punpcklbw mm7, mm1 ; Y14 Y14 Y11 Y11 >- >- punpcklbw mm6, mm1 ; Y12 Y12 Y9 Y9 >- >- paddsw mm7, mm2 ; g14 r14 b11 g11 >- >- paddsw mm6, mm2 ; g12 r12 b9 g9 >- >- psrlq mm3, 8 ; 0 0 Y21 Y20 Y17 Y16 Y13 Y12 >- >- movq mm1, mm3 ; 0 0 Y21 Y20 Y17 Y16 Y13 Y12 >- >- punpcklbw mm3, mm3 ; X X X X Y13 Y13 Y12 Y12 >- >- add esi, 8 >- >- psrlq mm3, 16 ; X X X X X X Y13 Y13 modified on 09/24 >- >- punpcklwd mm1, mm3 ; X X X X Y13 Y13 Y13 Y12 >- >- add eax, 8 >- >- psrlq mm0, 8 ; 0 0 Y23 Y22 Y19 Y18 Y15 Y14 >- >- punpcklbw mm1, empty ; Y13 Y13 Y13 Y12 >- >- movq mm5, mm0 ; 0 0 Y23 Y22 Y19 Y18 Y15 Y14 >- >- punpcklbw mm0, mm0 ; X X X X Y15 Y15 Y14 Y14 >- >- paddsw mm1, mm4 ; b13 g13 r13 b12 >- >- psrlq mm0, 16 ; X X X X X X Y15 Y15 >- >- add edi, 24 >- >- punpcklwd mm5, mm0 ; X X X X Y15 Y15 Y15 Y14 >- >- packuswb mm6, mm1 ; b13 g13 r13 b12 g12 r12 b9 g9 >- >- add edx, 24 >- >- punpcklbw mm5, empty ; Y15 Y15 Y15 Y14 >- >- add ebx, 4 >- >- paddsw mm5, mm4 ; b15 g15 r15 b14 >- >- movq [edi-8], mm6 ; move to memory b13 g13 r13 b12 g12 r12 b9 g9 >- >- packuswb mm7, mm5 ; b15 g15 r15 b14 g14 r14 b11 g11 >- >- add ecx, 4 >- >- movq [edx-8], mm7 ; move to memory b15 g15 r15 b14 g14 r14 b11 g11 >- >- dec cols_asm >- >- jnz do_next16 >- >- EMMS >- >- } >- >- >- inptr1 += (cols_asm_copy<<2); >- >- inptr2 += (cols_asm_copy<<2); >- >- inptr00 += (cols_asm_copy<<3); >- >- inptr01 += (cols_asm_copy<<3); >- >- outptr0 += cols_asm_copy*24; >- >- outptr1 += cols_asm_copy*24; >- >- //for (col = cinfo->output_width >> 1; col > 0; col--) { >- /* Do the chroma part of the calculation */ >- /*cb = GETJSAMPLE(*inptr1++); >- cr = GETJSAMPLE(*inptr2++); >- cred = Crrtab[cr]; >- cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); >- cblue = Cbbtab[cb];*/ >- /* Fetch 4 Y values and emit 4 pixels */ >- /*y = GETJSAMPLE(*inptr00++); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >- outptr0 += RGB_PIXELSIZE; >- y = GETJSAMPLE(*inptr00++); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >- outptr0 += RGB_PIXELSIZE; >- y = GETJSAMPLE(*inptr01++); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >- outptr1 += RGB_PIXELSIZE; >- y = GETJSAMPLE(*inptr01++); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >- outptr1 += RGB_PIXELSIZE; >- } */ >- >- >- for (col = diff >> 1; col > 0; col--) { >- /* Do the chroma part of the calculation */ >- cb = GETJSAMPLE(*inptr1++); >- cr = GETJSAMPLE(*inptr2++); >- cred = Crrtab[cr]; >- cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); >- cblue = Cbbtab[cb]; >- /* Fetch 4 Y values and emit 4 pixels */ >- y = GETJSAMPLE(*inptr00++); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >- outptr0 += RGB_PIXELSIZE; >- y = GETJSAMPLE(*inptr00++); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >- outptr0 += RGB_PIXELSIZE; >- y = GETJSAMPLE(*inptr01++); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >- outptr1 += RGB_PIXELSIZE; >- y = GETJSAMPLE(*inptr01++); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >- outptr1 += RGB_PIXELSIZE; >- } >- >- >- /* If image width is odd, do the last output column separately */ >- //if (cinfo->output_width & 1) { >- if (diff & 1) { >- cb = GETJSAMPLE(*inptr1); >- cr = GETJSAMPLE(*inptr2); >- cred = Crrtab[cr]; >- cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); >- cblue = Cbbtab[cb]; >- y = GETJSAMPLE(*inptr00); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >- y = GETJSAMPLE(*inptr01); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >- } >-} >-#else >- >- > METHODDEF(void) > h2v2_merged_upsample (j_decompress_ptr cinfo, > JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, > JSAMPARRAY output_buf) > { > my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; > register int y, cred, cgreen, cblue; > int cb, cr; >@@ -937,54 +317,53 @@ h2v2_merged_upsample (j_decompress_ptr c > /* Do the chroma part of the calculation */ > cb = GETJSAMPLE(*inptr1++); > cr = GETJSAMPLE(*inptr2++); > cred = Crrtab[cr]; > cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); > cblue = Cbbtab[cb]; > /* Fetch 4 Y values and emit 4 pixels */ > y = GETJSAMPLE(*inptr00++); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >+ outptr0[rgb_red[cinfo->out_color_space]] = range_limit[y + cred]; >+ outptr0[rgb_green[cinfo->out_color_space]] = range_limit[y + cgreen]; >+ outptr0[rgb_blue[cinfo->out_color_space]] = range_limit[y + cblue]; > outptr0 += RGB_PIXELSIZE; > y = GETJSAMPLE(*inptr00++); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >+ outptr0[rgb_red[cinfo->out_color_space]] = range_limit[y + cred]; >+ outptr0[rgb_green[cinfo->out_color_space]] = range_limit[y + cgreen]; >+ outptr0[rgb_blue[cinfo->out_color_space]] = range_limit[y + cblue]; > outptr0 += RGB_PIXELSIZE; > y = GETJSAMPLE(*inptr01++); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >+ outptr1[rgb_red[cinfo->out_color_space]] = range_limit[y + cred]; >+ outptr1[rgb_green[cinfo->out_color_space]] = range_limit[y + cgreen]; >+ outptr1[rgb_blue[cinfo->out_color_space]] = range_limit[y + cblue]; > outptr1 += RGB_PIXELSIZE; > y = GETJSAMPLE(*inptr01++); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >+ outptr1[rgb_red[cinfo->out_color_space]] = range_limit[y + cred]; >+ outptr1[rgb_green[cinfo->out_color_space]] = range_limit[y + cgreen]; >+ outptr1[rgb_blue[cinfo->out_color_space]] = range_limit[y + cblue]; > outptr1 += RGB_PIXELSIZE; > } > /* If image width is odd, do the last output column separately */ > if (cinfo->output_width & 1) { > cb = GETJSAMPLE(*inptr1); > cr = GETJSAMPLE(*inptr2); > cred = Crrtab[cr]; > cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); > cblue = Cbbtab[cb]; > y = GETJSAMPLE(*inptr00); >- outptr0[RGB_RED] = range_limit[y + cred]; >- outptr0[RGB_GREEN] = range_limit[y + cgreen]; >- outptr0[RGB_BLUE] = range_limit[y + cblue]; >+ outptr0[rgb_red[cinfo->out_color_space]] = range_limit[y + cred]; >+ outptr0[rgb_green[cinfo->out_color_space]] = range_limit[y + cgreen]; >+ outptr0[rgb_blue[cinfo->out_color_space]] = range_limit[y + cblue]; > y = GETJSAMPLE(*inptr01); >- outptr1[RGB_RED] = range_limit[y + cred]; >- outptr1[RGB_GREEN] = range_limit[y + cgreen]; >- outptr1[RGB_BLUE] = range_limit[y + cblue]; >+ outptr1[rgb_red[cinfo->out_color_space]] = range_limit[y + cred]; >+ outptr1[rgb_green[cinfo->out_color_space]] = range_limit[y + cgreen]; >+ outptr1[rgb_blue[cinfo->out_color_space]] = range_limit[y + cblue]; > } > } >-#endif > > > /* > * Module initialization routine for merged upsampling/color conversion. > * > * NB: this is called under the conditions determined by use_merged_upsample() > * in jdmaster.c. That routine MUST correspond to the actual capabilities > * of this module; no safety checks are made here. >@@ -1001,24 +380,30 @@ jinit_merged_upsampler (j_decompress_ptr > cinfo->upsample = (struct jpeg_upsampler *) upsample; > upsample->pub.start_pass = start_pass_merged_upsample; > upsample->pub.need_context_rows = FALSE; > > upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; > > if (cinfo->max_v_samp_factor == 2) { > upsample->pub.upsample = merged_2v_upsample; >- upsample->upmethod = h2v2_merged_upsample; >+ if (jsimd_can_h2v2_merged_upsample()) >+ upsample->upmethod = jsimd_h2v2_merged_upsample; >+ else >+ upsample->upmethod = h2v2_merged_upsample; > /* Allocate a spare row buffer */ > upsample->spare_row = (JSAMPROW) > (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, > (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); > } else { > upsample->pub.upsample = merged_1v_upsample; >- upsample->upmethod = h2v1_merged_upsample; >+ if (jsimd_can_h2v1_merged_upsample()) >+ upsample->upmethod = jsimd_h2v1_merged_upsample; >+ else >+ upsample->upmethod = h2v1_merged_upsample; > /* No spare row needed */ > upsample->spare_row = NULL; > } > > build_ycc_rgb_table(cinfo); > } > > #endif /* UPSAMPLE_MERGING_SUPPORTED */ >diff --git a/jpeg/jdphuff.c b/modules/libjpeg-turbo/jdphuff.c >rename from jpeg/jdphuff.c >rename to modules/libjpeg-turbo/jdphuff.c >diff --git a/jpeg/jdpostct.c b/modules/libjpeg-turbo/jdpostct.c >rename from jpeg/jdpostct.c >rename to modules/libjpeg-turbo/jdpostct.c >diff --git a/jpeg/jdsample.c b/modules/libjpeg-turbo/jdsample.c >rename from jpeg/jdsample.c >rename to modules/libjpeg-turbo/jdsample.c >--- a/jpeg/jdsample.c >+++ b/modules/libjpeg-turbo/jdsample.c >@@ -1,12 +1,13 @@ > /* > * jdsample.c > * > * Copyright (C) 1991-1996, Thomas G. Lane. >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains upsampling routines. > * > * Upsampling input data is counted in "row groups". A row group > * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) > * sample rows of each component. Upsampling will normally produce >@@ -16,16 +17,17 @@ > * An excellent reference for image resampling is > * Digital Image Warping, George Wolberg, 1990. > * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" >+#include "jsimd.h" > > > /* Pointer to routine to upsample a single component */ > typedef JMETHOD(void, upsample1_ptr, > (j_decompress_ptr cinfo, jpeg_component_info * compptr, > JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); > > /* Private subobject */ >@@ -442,28 +444,42 @@ jinit_upsampler (j_decompress_ptr cinfo) > need_buffer = FALSE; > } else if (h_in_group == h_out_group && v_in_group == v_out_group) { > /* Fullsize components can be processed without any work. */ > upsample->methods[ci] = fullsize_upsample; > need_buffer = FALSE; > } else if (h_in_group * 2 == h_out_group && > v_in_group == v_out_group) { > /* Special cases for 2h1v upsampling */ >- if (do_fancy && compptr->downsampled_width > 2) >- upsample->methods[ci] = h2v1_fancy_upsample; >- else >- upsample->methods[ci] = h2v1_upsample; >+ if (do_fancy && compptr->downsampled_width > 2) { >+ if (jsimd_can_h2v1_fancy_upsample()) >+ upsample->methods[ci] = jsimd_h2v1_fancy_upsample; >+ else >+ upsample->methods[ci] = h2v1_fancy_upsample; >+ } else { >+ if (jsimd_can_h2v1_upsample()) >+ upsample->methods[ci] = jsimd_h2v1_upsample; >+ else >+ upsample->methods[ci] = h2v1_upsample; >+ } > } else if (h_in_group * 2 == h_out_group && > v_in_group * 2 == v_out_group) { > /* Special cases for 2h2v upsampling */ > if (do_fancy && compptr->downsampled_width > 2) { >- upsample->methods[ci] = h2v2_fancy_upsample; >+ if (jsimd_can_h2v2_fancy_upsample()) >+ upsample->methods[ci] = jsimd_h2v2_fancy_upsample; >+ else >+ upsample->methods[ci] = h2v2_fancy_upsample; > upsample->pub.need_context_rows = TRUE; >- } else >- upsample->methods[ci] = h2v2_upsample; >+ } else { >+ if (jsimd_can_h2v2_upsample()) >+ upsample->methods[ci] = jsimd_h2v2_upsample; >+ else >+ upsample->methods[ci] = h2v2_upsample; >+ } > } else if ((h_out_group % h_in_group) == 0 && > (v_out_group % v_in_group) == 0) { > /* Generic integral-factors upsampling method */ > upsample->methods[ci] = int_upsample; > upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group); > upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); > } else > ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); >diff --git a/modules/libjpeg-turbo/jdtrans.c b/modules/libjpeg-turbo/jdtrans.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/jdtrans.c >@@ -0,0 +1,143 @@ >+/* >+ * jdtrans.c >+ * >+ * Copyright (C) 1995-1997, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains library routines for transcoding decompression, >+ * that is, reading raw DCT coefficient arrays from an input JPEG file. >+ * The routines in jdapimin.c will also be needed by a transcoder. >+ */ >+ >+#define JPEG_INTERNALS >+#include "jinclude.h" >+#include "jpeglib.h" >+ >+ >+/* Forward declarations */ >+LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); >+ >+ >+/* >+ * Read the coefficient arrays from a JPEG file. >+ * jpeg_read_header must be completed before calling this. >+ * >+ * The entire image is read into a set of virtual coefficient-block arrays, >+ * one per component. The return value is a pointer to the array of >+ * virtual-array descriptors. These can be manipulated directly via the >+ * JPEG memory manager, or handed off to jpeg_write_coefficients(). >+ * To release the memory occupied by the virtual arrays, call >+ * jpeg_finish_decompress() when done with the data. >+ * >+ * An alternative usage is to simply obtain access to the coefficient arrays >+ * during a buffered-image-mode decompression operation. This is allowed >+ * after any jpeg_finish_output() call. The arrays can be accessed until >+ * jpeg_finish_decompress() is called. (Note that any call to the library >+ * may reposition the arrays, so don't rely on access_virt_barray() results >+ * to stay valid across library calls.) >+ * >+ * Returns NULL if suspended. This case need be checked only if >+ * a suspending data source is used. >+ */ >+ >+GLOBAL(jvirt_barray_ptr *) >+jpeg_read_coefficients (j_decompress_ptr cinfo) >+{ >+ if (cinfo->global_state == DSTATE_READY) { >+ /* First call: initialize active modules */ >+ transdecode_master_selection(cinfo); >+ cinfo->global_state = DSTATE_RDCOEFS; >+ } >+ if (cinfo->global_state == DSTATE_RDCOEFS) { >+ /* Absorb whole file into the coef buffer */ >+ for (;;) { >+ int retcode; >+ /* Call progress monitor hook if present */ >+ if (cinfo->progress != NULL) >+ (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); >+ /* Absorb some more input */ >+ retcode = (*cinfo->inputctl->consume_input) (cinfo); >+ if (retcode == JPEG_SUSPENDED) >+ return NULL; >+ if (retcode == JPEG_REACHED_EOI) >+ break; >+ /* Advance progress counter if appropriate */ >+ if (cinfo->progress != NULL && >+ (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { >+ if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { >+ /* startup underestimated number of scans; ratchet up one scan */ >+ cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; >+ } >+ } >+ } >+ /* Set state so that jpeg_finish_decompress does the right thing */ >+ cinfo->global_state = DSTATE_STOPPING; >+ } >+ /* At this point we should be in state DSTATE_STOPPING if being used >+ * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access >+ * to the coefficients during a full buffered-image-mode decompression. >+ */ >+ if ((cinfo->global_state == DSTATE_STOPPING || >+ cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { >+ return cinfo->coef->coef_arrays; >+ } >+ /* Oops, improper usage */ >+ ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); >+ return NULL; /* keep compiler happy */ >+} >+ >+ >+/* >+ * Master selection of decompression modules for transcoding. >+ * This substitutes for jdmaster.c's initialization of the full decompressor. >+ */ >+ >+LOCAL(void) >+transdecode_master_selection (j_decompress_ptr cinfo) >+{ >+ /* This is effectively a buffered-image operation. */ >+ cinfo->buffered_image = TRUE; >+ >+ /* Entropy decoding: either Huffman or arithmetic coding. */ >+ if (cinfo->arith_code) { >+ ERREXIT(cinfo, JERR_ARITH_NOTIMPL); >+ } else { >+ if (cinfo->progressive_mode) { >+#ifdef D_PROGRESSIVE_SUPPORTED >+ jinit_phuff_decoder(cinfo); >+#else >+ ERREXIT(cinfo, JERR_NOT_COMPILED); >+#endif >+ } else >+ jinit_huff_decoder(cinfo); >+ } >+ >+ /* Always get a full-image coefficient buffer. */ >+ jinit_d_coef_controller(cinfo, TRUE); >+ >+ /* We can now tell the memory manager to allocate virtual arrays. */ >+ (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); >+ >+ /* Initialize input side of decompressor to consume first scan. */ >+ (*cinfo->inputctl->start_input_pass) (cinfo); >+ >+ /* Initialize progress monitoring. */ >+ if (cinfo->progress != NULL) { >+ int nscans; >+ /* Estimate number of scans to set pass_limit. */ >+ if (cinfo->progressive_mode) { >+ /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ >+ nscans = 2 + 3 * cinfo->num_components; >+ } else if (cinfo->inputctl->has_multiple_scans) { >+ /* For a nonprogressive multiscan file, estimate 1 scan per component. */ >+ nscans = cinfo->num_components; >+ } else { >+ nscans = 1; >+ } >+ cinfo->progress->pass_counter = 0L; >+ cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; >+ cinfo->progress->completed_passes = 0; >+ cinfo->progress->total_passes = 1; >+ } >+} >diff --git a/jpeg/jerror.c b/modules/libjpeg-turbo/jerror.c >rename from jpeg/jerror.c >rename to modules/libjpeg-turbo/jerror.c >--- a/jpeg/jerror.c >+++ b/modules/libjpeg-turbo/jerror.c >@@ -13,23 +13,16 @@ > * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile, > * you get a Windows-specific hack to display error messages in a dialog box. > * It ain't much, but it beats dropping error messages into the bit bucket, > * which is what happens to output to stderr under most Windows C compilers. > * > * These routines are used by both the compression and decompression code. > */ > >-/* >- * This file has been modified for the Mozilla/Netscape environment. >- * Modifications are distributed under the mozilla.org tri-license and are >- * Copyright (C) 1998 Netscape Communications Corporation. All Rights >- * Reserved. See http://www.mozilla.org/MPL/ >- */ >- > /* this is not a core library module, so it doesn't define JPEG_INTERNALS */ > #include "jinclude.h" > #include "jpeglib.h" > #include "jversion.h" > #include "jerror.h" > > #ifdef USE_WINDOWS_MESSAGEBOX > #include <windows.h> >@@ -77,25 +70,17 @@ METHODDEF(void) > error_exit (j_common_ptr cinfo) > { > /* Always display the message */ > (*cinfo->err->output_message) (cinfo); > > /* Let the memory manager delete any temp files before we die */ > jpeg_destroy(cinfo); > >-/* Mozilla mod: in some Windows environments, the exit() function doesn't >- * even exist, so don't compile a reference to it. Heaven help you if >- * you fail to provide a replacement error_exit function, because the >- * IJG library will NOT handle control returning from error_exit! >- */ >- >-#ifndef XP_WIN > exit(EXIT_FAILURE); >-#endif > } > > > /* > * Actual output of an error or trace message. > * Applications may override this method to send JPEG messages somewhere > * other than stderr. > * >@@ -111,16 +96,25 @@ error_exit (j_common_ptr cinfo) > > METHODDEF(void) > output_message (j_common_ptr cinfo) > { > char buffer[JMSG_LENGTH_MAX]; > > /* Create the message */ > (*cinfo->err->format_message) (cinfo, buffer); >+ >+#ifdef USE_WINDOWS_MESSAGEBOX >+ /* Display it in a message dialog box */ >+ MessageBox(GetActiveWindow(), buffer, "JPEG Library Error", >+ MB_OK | MB_ICONERROR); >+#else >+ /* Send it to stderr, adding a newline */ >+ fprintf(stderr, "%s\n", buffer); >+#endif > } > > > /* > * Decide whether to emit a trace or warning message. > * msg_level is one of: > * -1: recoverable corrupt-data warning, may want to abort. > * 0: important advisory messages (always display to user). >diff --git a/jpeg/jerror.h b/modules/libjpeg-turbo/jerror.h >rename from jpeg/jerror.h >rename to modules/libjpeg-turbo/jerror.h >diff --git a/jpeg/jfdctflt.c b/modules/libjpeg-turbo/jfdctflt.c >rename from jpeg/jfdctflt.c >rename to modules/libjpeg-turbo/jfdctflt.c >diff --git a/jpeg/jfdctfst.c b/modules/libjpeg-turbo/jfdctfst.c >rename from jpeg/jfdctfst.c >rename to modules/libjpeg-turbo/jfdctfst.c >diff --git a/jpeg/jfdctint.c b/modules/libjpeg-turbo/jfdctint.c >rename from jpeg/jfdctint.c >rename to modules/libjpeg-turbo/jfdctint.c >diff --git a/jpeg/jidctflt.c b/modules/libjpeg-turbo/jidctflt.c >rename from jpeg/jidctflt.c >rename to modules/libjpeg-turbo/jidctflt.c >diff --git a/jpeg/jidctfst.c b/modules/libjpeg-turbo/jidctfst.c >rename from jpeg/jidctfst.c >rename to modules/libjpeg-turbo/jidctfst.c >--- a/jpeg/jidctfst.c >+++ b/modules/libjpeg-turbo/jidctfst.c >@@ -32,17 +32,16 @@ > * quality-setting files than with low-quality ones. > */ > > #define JPEG_INTERNALS > #include "jinclude.h" > #include "jpeglib.h" > #include "jdct.h" /* Private declarations for DCT subsystem */ > >- > #ifdef DCT_IFAST_SUPPORTED > > > /* > * This module is specialized to the case DCTSIZE = 8. > */ > > #if DCTSIZE != 8 >@@ -155,51 +154,22 @@ > #endif > > #ifdef USE_ACCURATE_ROUNDING > #define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n)) > #else > #define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n)) > #endif > >-#ifdef HAVE_MMX_INTEL_MNEMONICS >-__inline GLOBAL(void) >-jpeg_idct_ifast_mmx (j_decompress_ptr cinfo, jpeg_component_info * compptr, >- JCOEFPTR coef_block, >- JSAMPARRAY output_buf, JDIMENSION output_col); >-__inline GLOBAL(void) >-jpeg_idct_ifast_orig (j_decompress_ptr cinfo, jpeg_component_info * compptr, >- JCOEFPTR coef_block, >- JSAMPARRAY output_buf, JDIMENSION output_col); >-#endif >- >-GLOBAL(void) >-jpeg_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info * compptr, >- JCOEFPTR coef_block, >- JSAMPARRAY output_buf, JDIMENSION output_col); >- >- >-#ifdef HAVE_MMX_INTEL_MNEMONICS >-GLOBAL(void) >-jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, >- JCOEFPTR coef_block, >- JSAMPARRAY output_buf, JDIMENSION output_col) >-{ >-if (MMXAvailable) >- jpeg_idct_ifast_mmx(cinfo, compptr, coef_block, output_buf, output_col); >-else >- jpeg_idct_ifast_orig(cinfo, compptr, coef_block, output_buf, output_col); >-} >-#else > > /* > * Perform dequantization and inverse DCT on one block of coefficients. > */ > >-GLOBAL (void) >+GLOBAL(void) > jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, > JCOEFPTR coef_block, > JSAMPARRAY output_buf, JDIMENSION output_col) > { > DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; > DCTELEM tmp10, tmp11, tmp12, tmp13; > DCTELEM z5, z10, z11, z12, z13; > JCOEFPTR inptr; >@@ -390,1261 +360,9 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, > & RANGE_MASK]; > outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) > & RANGE_MASK]; > > wsptr += DCTSIZE; /* advance pointer to next row */ > } > } > >-#endif >- >-#ifdef HAVE_MMX_INTEL_MNEMONICS >- >- >-_inline GLOBAL(void) >-jpeg_idct_ifast_orig (j_decompress_ptr cinfo, jpeg_component_info * compptr, >- JCOEFPTR coef_block, >- JSAMPARRAY output_buf, JDIMENSION output_col) >-{ >- DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; >- DCTELEM tmp10, tmp11, tmp12, tmp13; >- DCTELEM z5, z10, z11, z12, z13; >- JCOEFPTR inptr; >- IFAST_MULT_TYPE * quantptr; >- int * wsptr; >- JSAMPROW outptr; >- JSAMPLE *range_limit = IDCT_range_limit(cinfo); >- int ctr; >- int workspace[DCTSIZE2]; /* buffers data between passes */ >- SHIFT_TEMPS /* for DESCALE */ >- ISHIFT_TEMPS /* for IDESCALE */ >- >- /* Pass 1: process columns from input, store into work array. */ >- >- inptr = coef_block; >- quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; >- wsptr = workspace; >- for (ctr = DCTSIZE; ctr > 0; ctr--) { >- /* Due to quantization, we will usually find that many of the input >- * coefficients are zero, especially the AC terms. We can exploit this >- * by short-circuiting the IDCT calculation for any column in which all >- * the AC terms are zero. In that case each output is equal to the >- * DC coefficient (with scale factor as needed). >- * With typical images and quantization tables, half or more of the >- * column DCT calculations can be simplified this way. >- */ >- >- if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*2] | inptr[DCTSIZE*3] | >- inptr[DCTSIZE*4] | inptr[DCTSIZE*5] | inptr[DCTSIZE*6] | >- inptr[DCTSIZE*7]) == 0) { >- /* AC terms all zero */ >- int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); >- >- wsptr[DCTSIZE*0] = dcval; >- wsptr[DCTSIZE*1] = dcval; >- wsptr[DCTSIZE*2] = dcval; >- wsptr[DCTSIZE*3] = dcval; >- wsptr[DCTSIZE*4] = dcval; >- wsptr[DCTSIZE*5] = dcval; >- wsptr[DCTSIZE*6] = dcval; >- wsptr[DCTSIZE*7] = dcval; >- >- inptr++; /* advance pointers to next column */ >- quantptr++; >- wsptr++; >- continue; >- } >- >- /* Even part */ >- >- tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); >- tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); >- tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); >- tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); >- >- tmp10 = tmp0 + tmp2; /* phase 3 */ >- tmp11 = tmp0 - tmp2; >- >- tmp13 = tmp1 + tmp3; /* phases 5-3 */ >- tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ >- >- tmp0 = tmp10 + tmp13; /* phase 2 */ >- tmp3 = tmp10 - tmp13; >- tmp1 = tmp11 + tmp12; >- tmp2 = tmp11 - tmp12; >- >- /* Odd part */ >- >- tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); >- tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); >- tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); >- tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); >- >- z13 = tmp6 + tmp5; /* phase 6 */ >- z10 = tmp6 - tmp5; >- z11 = tmp4 + tmp7; >- z12 = tmp4 - tmp7; >- >- tmp7 = z11 + z13; /* phase 5 */ >- tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ >- >- z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ >- tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ >- tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ >- >- tmp6 = tmp12 - tmp7; /* phase 2 */ >- tmp5 = tmp11 - tmp6; >- tmp4 = tmp10 + tmp5; >- >- wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); >- wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); >- wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); >- wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); >- wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); >- wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); >- wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); >- wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); >- >- inptr++; /* advance pointers to next column */ >- quantptr++; >- wsptr++; >- } >- >- /* Pass 2: process rows from work array, store into output array. */ >- /* Note that we must descale the results by a factor of 8 == 2**3, */ >- /* and also undo the PASS1_BITS scaling. */ >- >- wsptr = workspace; >- for (ctr = 0; ctr < DCTSIZE; ctr++) { >- outptr = output_buf[ctr] + output_col; >- /* Rows of zeroes can be exploited in the same way as we did with columns. >- * However, the column calculation has created many nonzero AC terms, so >- * the simplification applies less often (typically 5% to 10% of the time). >- * On machines with very fast multiplication, it's possible that the >- * test takes more time than it's worth. In that case this section >- * may be commented out. >- */ >- >-#ifndef NO_ZERO_ROW_TEST >- if ((wsptr[1] | wsptr[2] | wsptr[3] | wsptr[4] | wsptr[5] | wsptr[6] | >- wsptr[7]) == 0) { >- /* AC terms all zero */ >- JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) >- & RANGE_MASK]; >- >- outptr[0] = dcval; >- outptr[1] = dcval; >- outptr[2] = dcval; >- outptr[3] = dcval; >- outptr[4] = dcval; >- outptr[5] = dcval; >- outptr[6] = dcval; >- outptr[7] = dcval; >- >- wsptr += DCTSIZE; /* advance pointer to next row */ >- continue; >- } >-#endif >- >- /* Even part */ >- >- tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); >- tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); >- >- tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); >- tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) >- - tmp13; >- >- tmp0 = tmp10 + tmp13; >- tmp3 = tmp10 - tmp13; >- tmp1 = tmp11 + tmp12; >- tmp2 = tmp11 - tmp12; >- >- /* Odd part */ >- >- z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; >- z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; >- z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; >- z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; >- >- tmp7 = z11 + z13; /* phase 5 */ >- tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ >- >- z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ >- tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ >- tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ >- >- tmp6 = tmp12 - tmp7; /* phase 2 */ >- tmp5 = tmp11 - tmp6; >- tmp4 = tmp10 + tmp5; >- >- /* Final output stage: scale down by a factor of 8 and range-limit */ >- >- outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) >- & RANGE_MASK]; >- outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) >- & RANGE_MASK]; >- outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) >- & RANGE_MASK]; >- outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) >- & RANGE_MASK]; >- outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) >- & RANGE_MASK]; >- outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) >- & RANGE_MASK]; >- outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) >- & RANGE_MASK]; >- outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) >- & RANGE_MASK]; >- >- wsptr += DCTSIZE; /* advance pointer to next row */ >- } >-} >- >- >- static __int64 fix_141 = 0x5a825a825a825a82; >- static __int64 fix_184n261 = 0xcf04cf04cf04cf04; >- static __int64 fix_184 = 0x7641764176417641; >- static __int64 fix_n184 = 0x896f896f896f896f; >- static __int64 fix_108n184 = 0xcf04cf04cf04cf04; >- static __int64 const_0x0080 = 0x0080008000800080; >- >- >-__inline GLOBAL(void) >-jpeg_idct_ifast_mmx (j_decompress_ptr cinfo, jpeg_component_info * compptr, >- JCOEFPTR inptr, >- JSAMPARRAY outptr, JDIMENSION output_col) >-{ >- >- int16 workspace[DCTSIZE2 + 4]; /* buffers data between passes */ >- int16 *wsptr=workspace; >- int16 *quantptr=compptr->dct_table; >- >- __asm{ >- >- mov edi, quantptr >- mov ebx, inptr >- mov esi, wsptr >- add esi, 0x07 ;align wsptr to qword >- and esi, 0xfffffff8 ;align wsptr to qword >- >- mov eax, esi >- >- /* Odd part */ >- >- >- movq mm1, [ebx + 8*10] ;load inptr[DCTSIZE*5] >- >- pmullw mm1, [edi + 8*10] ;tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); >- >- movq mm0, [ebx + 8*6] ;load inptr[DCTSIZE*3] >- >- pmullw mm0, [edi + 8*6] ;tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); >- >- movq mm3, [ebx + 8*2] ;load inptr[DCTSIZE*1] >- movq mm2, mm1 ;copy tmp6 /* phase 6 */ >- >- pmullw mm3, [edi + 8*2] ;tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); >- >- movq mm4, [ebx + 8*14] ;load inptr[DCTSIZE*1] >- paddw mm1, mm0 ;z13 = tmp6 + tmp5; >- >- pmullw mm4, [edi + 8*14] ;tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); >- psubw mm2, mm0 ;z10 = tmp6 - tmp5 >- >- psllw mm2, 2 ;shift z10 >- movq mm0, mm2 ;copy z10 >- >- pmulhw mm2, fix_184n261 ;MULTIPLY( z12, FIX_1_847759065); /* 2*c2 */ >- movq mm5, mm3 ;copy tmp4 >- >- pmulhw mm0, fix_n184 ;MULTIPLY(z10, -FIX_1_847759065); /* 2*c2 */ >- paddw mm3, mm4 ;z11 = tmp4 + tmp7; >- >- movq mm6, mm3 ;copy z11 /* phase 5 */ >- psubw mm5, mm4 ;z12 = tmp4 - tmp7; >- >- psubw mm6, mm1 ;z11-z13 >- psllw mm5, 2 ;shift z12 >- >- movq mm4, [ebx + 8*12] ;load inptr[DCTSIZE*6], even part >- movq mm7, mm5 ;copy z12 >- >- pmulhw mm5, fix_108n184 ;MULT(z12, (FIX_1_08-FIX_1_84)) //- z5; /* 2*(c2-c6) */ even part >- paddw mm3, mm1 ;tmp7 = z11 + z13; >- >- >- /* Even part */ >- pmulhw mm7, fix_184 ;MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) //+ z5; /* -2*(c2+c6) */ >- psllw mm6, 2 >- >- movq mm1, [ebx + 8*4] ;load inptr[DCTSIZE*2] >- >- pmullw mm1, [edi + 8*4] ;tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); >- paddw mm0, mm5 ;tmp10 >- >- pmullw mm4, [edi + 8*12] ;tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); >- paddw mm2, mm7 ;tmp12 >- >- pmulhw mm6, fix_141 ;tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ >- psubw mm2, mm3 ;tmp6 = tmp12 - tmp7 >- >- movq mm5, mm1 ;copy tmp1 >- paddw mm1, mm4 ;tmp13= tmp1 + tmp3; /* phases 5-3 */ >- >- psubw mm5, mm4 ;tmp1-tmp3 >- psubw mm6, mm2 ;tmp5 = tmp11 - tmp6; >- >- movq [esi+8*0], mm1 ;save tmp13 in workspace >- psllw mm5, 2 ;shift tmp1-tmp3 >- >- movq mm7, [ebx + 8*0] ;load inptr[DCTSIZE*0] >- >- pmulhw mm5, fix_141 ;MULTIPLY(tmp1 - tmp3, FIX_1_414213562) >- paddw mm0, mm6 ;tmp4 = tmp10 + tmp5; >- >- pmullw mm7, [edi + 8*0] ;tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); >- >- movq mm4, [ebx + 8*8] ;load inptr[DCTSIZE*4] >- >- pmullw mm4, [edi + 8*8] ;tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); >- psubw mm5, mm1 ;tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ >- >- movq [esi+8*4], mm0 ;save tmp4 in workspace >- movq mm1, mm7 ;copy tmp0 /* phase 3 */ >- >- movq [esi+8*2], mm5 ;save tmp12 in workspace >- psubw mm1, mm4 ;tmp11 = tmp0 - tmp2; >- >- paddw mm7, mm4 ;tmp10 = tmp0 + tmp2; >- movq mm5, mm1 ;copy tmp11 >- >- paddw mm1, [esi+8*2] ;tmp1 = tmp11 + tmp12; >- movq mm4, mm7 ;copy tmp10 /* phase 2 */ >- >- paddw mm7, [esi+8*0] ;tmp0 = tmp10 + tmp13; >- >- psubw mm4, [esi+8*0] ;tmp3 = tmp10 - tmp13; >- movq mm0, mm7 ;copy tmp0 >- >- psubw mm5, [esi+8*2] ;tmp2 = tmp11 - tmp12; >- paddw mm7, mm3 ;wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); >- >- psubw mm0, mm3 ;wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); >- >- movq [esi + 8*0], mm7 ;wsptr[DCTSIZE*0] >- movq mm3, mm1 ;copy tmp1 >- >- movq [esi + 8*14], mm0 ;wsptr[DCTSIZE*7] >- paddw mm1, mm2 ;wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); >- >- psubw mm3, mm2 ;wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); >- >- movq [esi + 8*2], mm1 ;wsptr[DCTSIZE*1] >- movq mm1, mm4 ;copy tmp3 >- >- movq [esi + 8*12], mm3 ;wsptr[DCTSIZE*6] >- >- paddw mm4, [esi+8*4] ;wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); >- >- psubw mm1, [esi+8*4] ;wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); >- >- movq [esi + 8*8], mm4 >- movq mm7, mm5 ;copy tmp2 >- >- paddw mm5, mm6 ;wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5) >- >- movq [esi+8*6], mm1 ; >- psubw mm7, mm6 ;wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); >- >- movq [esi + 8*4], mm5 >- >- movq [esi + 8*10], mm7 >- >- >- >-/*****************************************************************/ >- add edi, 8 >- add ebx, 8 >- add esi, 8 >- >-/*****************************************************************/ >- >- >- >- >- movq mm1, [ebx + 8*10] ;load inptr[DCTSIZE*5] >- >- pmullw mm1, [edi + 8*10] ;tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); >- >- movq mm0, [ebx + 8*6] ;load inptr[DCTSIZE*3] >- >- pmullw mm0, [edi + 8*6] ;tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); >- >- movq mm3, [ebx + 8*2] ;load inptr[DCTSIZE*1] >- movq mm2, mm1 ;copy tmp6 /* phase 6 */ >- >- pmullw mm3, [edi + 8*2] ;tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); >- >- movq mm4, [ebx + 8*14] ;load inptr[DCTSIZE*1] >- paddw mm1, mm0 ;z13 = tmp6 + tmp5; >- >- pmullw mm4, [edi + 8*14] ;tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); >- psubw mm2, mm0 ;z10 = tmp6 - tmp5 >- >- psllw mm2, 2 ;shift z10 >- movq mm0, mm2 ;copy z10 >- >- pmulhw mm2, fix_184n261 ;MULTIPLY( z12, FIX_1_847759065); /* 2*c2 */ >- movq mm5, mm3 ;copy tmp4 >- >- pmulhw mm0, fix_n184 ;MULTIPLY(z10, -FIX_1_847759065); /* 2*c2 */ >- paddw mm3, mm4 ;z11 = tmp4 + tmp7; >- >- movq mm6, mm3 ;copy z11 /* phase 5 */ >- psubw mm5, mm4 ;z12 = tmp4 - tmp7; >- >- psubw mm6, mm1 ;z11-z13 >- psllw mm5, 2 ;shift z12 >- >- movq mm4, [ebx + 8*12] ;load inptr[DCTSIZE*6], even part >- movq mm7, mm5 ;copy z12 >- >- pmulhw mm5, fix_108n184 ;MULT(z12, (FIX_1_08-FIX_1_84)) //- z5; /* 2*(c2-c6) */ even part >- paddw mm3, mm1 ;tmp7 = z11 + z13; >- >- >- /* Even part */ >- pmulhw mm7, fix_184 ;MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) //+ z5; /* -2*(c2+c6) */ >- psllw mm6, 2 >- >- movq mm1, [ebx + 8*4] ;load inptr[DCTSIZE*2] >- >- pmullw mm1, [edi + 8*4] ;tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); >- paddw mm0, mm5 ;tmp10 >- >- pmullw mm4, [edi + 8*12] ;tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); >- paddw mm2, mm7 ;tmp12 >- >- pmulhw mm6, fix_141 ;tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ >- psubw mm2, mm3 ;tmp6 = tmp12 - tmp7 >- >- movq mm5, mm1 ;copy tmp1 >- paddw mm1, mm4 ;tmp13= tmp1 + tmp3; /* phases 5-3 */ >- >- psubw mm5, mm4 ;tmp1-tmp3 >- psubw mm6, mm2 ;tmp5 = tmp11 - tmp6; >- >- movq [esi+8*0], mm1 ;save tmp13 in workspace >- psllw mm5, 2 ;shift tmp1-tmp3 >- >- movq mm7, [ebx + 8*0] ;load inptr[DCTSIZE*0] >- paddw mm0, mm6 ;tmp4 = tmp10 + tmp5; >- >- pmulhw mm5, fix_141 ;MULTIPLY(tmp1 - tmp3, FIX_1_414213562) >- >- pmullw mm7, [edi + 8*0] ;tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); >- >- movq mm4, [ebx + 8*8] ;load inptr[DCTSIZE*4] >- >- pmullw mm4, [edi + 8*8] ;tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); >- psubw mm5, mm1 ;tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ >- >- movq [esi+8*4], mm0 ;save tmp4 in workspace >- movq mm1, mm7 ;copy tmp0 /* phase 3 */ >- >- movq [esi+8*2], mm5 ;save tmp12 in workspace >- psubw mm1, mm4 ;tmp11 = tmp0 - tmp2; >- >- paddw mm7, mm4 ;tmp10 = tmp0 + tmp2; >- movq mm5, mm1 ;copy tmp11 >- >- paddw mm1, [esi+8*2] ;tmp1 = tmp11 + tmp12; >- movq mm4, mm7 ;copy tmp10 /* phase 2 */ >- >- paddw mm7, [esi+8*0] ;tmp0 = tmp10 + tmp13; >- >- psubw mm4, [esi+8*0] ;tmp3 = tmp10 - tmp13; >- movq mm0, mm7 ;copy tmp0 >- >- psubw mm5, [esi+8*2] ;tmp2 = tmp11 - tmp12; >- paddw mm7, mm3 ;wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); >- >- psubw mm0, mm3 ;wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); >- >- movq [esi + 8*0], mm7 ;wsptr[DCTSIZE*0] >- movq mm3, mm1 ;copy tmp1 >- >- movq [esi + 8*14], mm0 ;wsptr[DCTSIZE*7] >- paddw mm1, mm2 ;wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); >- >- psubw mm3, mm2 ;wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); >- >- movq [esi + 8*2], mm1 ;wsptr[DCTSIZE*1] >- movq mm1, mm4 ;copy tmp3 >- >- movq [esi + 8*12], mm3 ;wsptr[DCTSIZE*6] >- >- paddw mm4, [esi+8*4] ;wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); >- >- psubw mm1, [esi+8*4] ;wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); >- >- movq [esi + 8*8], mm4 >- movq mm7, mm5 ;copy tmp2 >- >- paddw mm5, mm6 ;wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5) >- >- movq [esi+8*6], mm1 ; >- psubw mm7, mm6 ;wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); >- >- movq [esi + 8*4], mm5 >- >- movq [esi + 8*10], mm7 >- >- >- >- >-/*****************************************************************/ >- >- /* Pass 2: process rows from work array, store into output array. */ >- /* Note that we must descale the results by a factor of 8 == 2**3, */ >- /* and also undo the PASS1_BITS scaling. */ >- >-/*****************************************************************/ >- /* Even part */ >- >- mov esi, eax >- mov eax, outptr >- >-// tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); >-// tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); >-// tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); >-// tmp14 = ((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6]); >- movq mm0, [esi+8*0] ;wsptr[0,0],[0,1],[0,2],[0,3] >- >- movq mm1, [esi+8*1] ;wsptr[0,4],[0,5],[0,6],[0,7] >- movq mm2, mm0 >- >- movq mm3, [esi+8*2] ;wsptr[1,0],[1,1],[1,2],[1,3] >- paddw mm0, mm1 ;wsptr[0,tmp10],[xxx],[0,tmp13],[xxx] >- >- movq mm4, [esi+8*3] ;wsptr[1,4],[1,5],[1,6],[1,7] >- psubw mm2, mm1 ;wsptr[0,tmp11],[xxx],[0,tmp14],[xxx] >- >- movq mm6, mm0 >- movq mm5, mm3 >- >- paddw mm3, mm4 ;wsptr[1,tmp10],[xxx],[1,tmp13],[xxx] >- movq mm1, mm2 >- >- psubw mm5, mm4 ;wsptr[1,tmp11],[xxx],[1,tmp14],[xxx] >- punpcklwd mm0, mm3 ;wsptr[0,tmp10],[1,tmp10],[xxx],[xxx] >- >- movq mm7, [esi+8*7] ;wsptr[3,4],[3,5],[3,6],[3,7] >- punpckhwd mm6, mm3 ;wsptr[0,tmp13],[1,tmp13],[xxx],[xxx] >- >- movq mm3, [esi+8*4] ;wsptr[2,0],[2,1],[2,2],[2,3] >- punpckldq mm0, mm6 ;wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] >- >- punpcklwd mm1, mm5 ;wsptr[0,tmp11],[1,tmp11],[xxx],[xxx] >- movq mm4, mm3 >- >- movq mm6, [esi+8*6] ;wsptr[3,0],[3,1],[3,2],[3,3] >- punpckhwd mm2, mm5 ;wsptr[0,tmp14],[1,tmp14],[xxx],[xxx] >- >- movq mm5, [esi+8*5] ;wsptr[2,4],[2,5],[2,6],[2,7] >- punpckldq mm1, mm2 ;wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] >- >- >- paddw mm3, mm5 ;wsptr[2,tmp10],[xxx],[2,tmp13],[xxx] >- movq mm2, mm6 >- >- psubw mm4, mm5 ;wsptr[2,tmp11],[xxx],[2,tmp14],[xxx] >- paddw mm6, mm7 ;wsptr[3,tmp10],[xxx],[3,tmp13],[xxx] >- >- movq mm5, mm3 >- punpcklwd mm3, mm6 ;wsptr[2,tmp10],[3,tmp10],[xxx],[xxx] >- >- psubw mm2, mm7 ;wsptr[3,tmp11],[xxx],[3,tmp14],[xxx] >- punpckhwd mm5, mm6 ;wsptr[2,tmp13],[3,tmp13],[xxx],[xxx] >- >- movq mm7, mm4 >- punpckldq mm3, mm5 ;wsptr[2,tmp10],[3,tmp10],[2,tmp13],[3,tmp13] >- >- punpcklwd mm4, mm2 ;wsptr[2,tmp11],[3,tmp11],[xxx],[xxx] >- >- punpckhwd mm7, mm2 ;wsptr[2,tmp14],[3,tmp14],[xxx],[xxx] >- >- punpckldq mm4, mm7 ;wsptr[2,tmp11],[3,tmp11],[2,tmp14],[3,tmp14] >- movq mm6, mm1 >- >-// mm0 = ;wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] >-// mm1 = ;wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] >- >- >- movq mm2, mm0 >- punpckhdq mm6, mm4 ;wsptr[0,tmp14],[1,tmp14],[2,tmp14],[3,tmp14] >- >- punpckldq mm1, mm4 ;wsptr[0,tmp11],[1,tmp11],[2,tmp11],[3,tmp11] >- psllw mm6, 2 >- >- pmulhw mm6, fix_141 >- punpckldq mm0, mm3 ;wsptr[0,tmp10],[1,tmp10],[2,tmp10],[3,tmp10] >- >- punpckhdq mm2, mm3 ;wsptr[0,tmp13],[1,tmp13],[2,tmp13],[3,tmp13] >- movq mm7, mm0 >- >-// tmp0 = tmp10 + tmp13; >-// tmp3 = tmp10 - tmp13; >- paddw mm0, mm2 ;[0,tmp0],[1,tmp0],[2,tmp0],[3,tmp0] >- psubw mm7, mm2 ;[0,tmp3],[1,tmp3],[2,tmp3],[3,tmp3] >- >-// tmp12 = MULTIPLY(tmp14, FIX_1_414213562) - tmp13; >- psubw mm6, mm2 ;wsptr[0,tmp12],[1,tmp12],[2,tmp12],[3,tmp12] >-// tmp1 = tmp11 + tmp12; >-// tmp2 = tmp11 - tmp12; >- movq mm5, mm1 >- >- >- >- /* Odd part */ >- >-// z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; >-// z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; >-// z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; >-// z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; >- movq mm3, [esi+8*0] ;wsptr[0,0],[0,1],[0,2],[0,3] >- paddw mm1, mm6 ;[0,tmp1],[1,tmp1],[2,tmp1],[3,tmp1] >- >- movq mm4, [esi+8*1] ;wsptr[0,4],[0,5],[0,6],[0,7] >- psubw mm5, mm6 ;[0,tmp2],[1,tmp2],[2,tmp2],[3,tmp2] >- >- movq mm6, mm3 >- punpckldq mm3, mm4 ;wsptr[0,0],[0,1],[0,4],[0,5] >- >- punpckhdq mm4, mm6 ;wsptr[0,6],[0,7],[0,2],[0,3] >- movq mm2, mm3 >- >-//Save tmp0 and tmp1 in wsptr >- movq [esi+8*0], mm0 ;save tmp0 >- paddw mm2, mm4 ;wsptr[xxx],[0,z11],[xxx],[0,z13] >- >- >-//Continue with z10 --- z13 >- movq mm6, [esi+8*2] ;wsptr[1,0],[1,1],[1,2],[1,3] >- psubw mm3, mm4 ;wsptr[xxx],[0,z12],[xxx],[0,z10] >- >- movq mm0, [esi+8*3] ;wsptr[1,4],[1,5],[1,6],[1,7] >- movq mm4, mm6 >- >- movq [esi+8*1], mm1 ;save tmp1 >- punpckldq mm6, mm0 ;wsptr[1,0],[1,1],[1,4],[1,5] >- >- punpckhdq mm0, mm4 ;wsptr[1,6],[1,7],[1,2],[1,3] >- movq mm1, mm6 >- >-//Save tmp2 and tmp3 in wsptr >- paddw mm6, mm0 ;wsptr[xxx],[1,z11],[xxx],[1,z13] >- movq mm4, mm2 >- >-//Continue with z10 --- z13 >- movq [esi+8*2], mm5 ;save tmp2 >- punpcklwd mm2, mm6 ;wsptr[xxx],[xxx],[0,z11],[1,z11] >- >- psubw mm1, mm0 ;wsptr[xxx],[1,z12],[xxx],[1,z10] >- punpckhwd mm4, mm6 ;wsptr[xxx],[xxx],[0,z13],[1,z13] >- >- movq mm0, mm3 >- punpcklwd mm3, mm1 ;wsptr[xxx],[xxx],[0,z12],[1,z12] >- >- movq [esi+8*3], mm7 ;save tmp3 >- punpckhwd mm0, mm1 ;wsptr[xxx],[xxx],[0,z10],[1,z10] >- >- movq mm6, [esi+8*4] ;wsptr[2,0],[2,1],[2,2],[2,3] >- punpckhdq mm0, mm2 ;wsptr[0,z10],[1,z10],[0,z11],[1,z11] >- >- movq mm7, [esi+8*5] ;wsptr[2,4],[2,5],[2,6],[2,7] >- punpckhdq mm3, mm4 ;wsptr[0,z12],[1,z12],[0,z13],[1,z13] >- >- movq mm1, [esi+8*6] ;wsptr[3,0],[3,1],[3,2],[3,3] >- movq mm4, mm6 >- >- punpckldq mm6, mm7 ;wsptr[2,0],[2,1],[2,4],[2,5] >- movq mm5, mm1 >- >- punpckhdq mm7, mm4 ;wsptr[2,6],[2,7],[2,2],[2,3] >- movq mm2, mm6 >- >- movq mm4, [esi+8*7] ;wsptr[3,4],[3,5],[3,6],[3,7] >- paddw mm6, mm7 ;wsptr[xxx],[2,z11],[xxx],[2,z13] >- >- psubw mm2, mm7 ;wsptr[xxx],[2,z12],[xxx],[2,z10] >- punpckldq mm1, mm4 ;wsptr[3,0],[3,1],[3,4],[3,5] >- >- punpckhdq mm4, mm5 ;wsptr[3,6],[3,7],[3,2],[3,3] >- movq mm7, mm1 >- >- paddw mm1, mm4 ;wsptr[xxx],[3,z11],[xxx],[3,z13] >- psubw mm7, mm4 ;wsptr[xxx],[3,z12],[xxx],[3,z10] >- >- movq mm5, mm6 >- punpcklwd mm6, mm1 ;wsptr[xxx],[xxx],[2,z11],[3,z11] >- >- punpckhwd mm5, mm1 ;wsptr[xxx],[xxx],[2,z13],[3,z13] >- movq mm4, mm2 >- >- punpcklwd mm2, mm7 ;wsptr[xxx],[xxx],[2,z12],[3,z12] >- >- punpckhwd mm4, mm7 ;wsptr[xxx],[xxx],[2,z10],[3,z10] >- >- punpckhdq mm4, mm6 ;wsptr[2,z10],[3,z10],[2,z11],[3,z11] >- >- punpckhdq mm2, mm5 ;wsptr[2,z12],[3,z12],[2,z13],[3,z13] >- movq mm5, mm0 >- >- punpckldq mm0, mm4 ;wsptr[0,z10],[1,z10],[2,z10],[3,z10] >- >- punpckhdq mm5, mm4 ;wsptr[0,z11],[1,z11],[2,z11],[3,z11] >- movq mm4, mm3 >- >- punpckhdq mm4, mm2 ;wsptr[0,z13],[1,z13],[2,z13],[3,z13] >- movq mm1, mm5 >- >- punpckldq mm3, mm2 ;wsptr[0,z12],[1,z12],[2,z12],[3,z12] >-// tmp7 = z11 + z13; /* phase 5 */ >-// tmp8 = z11 - z13; /* phase 5 */ >- psubw mm1, mm4 ;tmp8 >- >- paddw mm5, mm4 ;tmp7 >-// tmp21 = MULTIPLY(tmp8, FIX_1_414213562); /* 2*c4 */ >- psllw mm1, 2 >- >- psllw mm0, 2 >- >- pmulhw mm1, fix_141 ;tmp21 >-// tmp20 = MULTIPLY(z12, (FIX_1_082392200- FIX_1_847759065)) /* 2*(c2-c6) */ >-// + MULTIPLY(z10, - FIX_1_847759065); /* 2*c2 */ >- psllw mm3, 2 >- movq mm7, mm0 >- >- pmulhw mm7, fix_n184 >- movq mm6, mm3 >- >- movq mm2, [esi+8*0] ;tmp0,final1 >- >- pmulhw mm6, fix_108n184 >-// tmp22 = MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) /* -2*(c2+c6) */ >-// + MULTIPLY(z12, FIX_1_847759065); /* 2*c2 */ >- movq mm4, mm2 ;final1 >- >- pmulhw mm0, fix_184n261 >- paddw mm2, mm5 ;tmp0+tmp7,final1 >- >- pmulhw mm3, fix_184 >- psubw mm4, mm5 ;tmp0-tmp7,final1 >- >-// tmp6 = tmp22 - tmp7; /* phase 2 */ >- psraw mm2, 5 ;outptr[0,0],[1,0],[2,0],[3,0],final1 >- >- paddsw mm2, const_0x0080 ;final1 >- paddw mm7, mm6 ;tmp20 >- psraw mm4, 5 ;outptr[0,7],[1,7],[2,7],[3,7],final1 >- >- paddsw mm4, const_0x0080 ;final1 >- paddw mm3, mm0 ;tmp22 >- >-// tmp5 = tmp21 - tmp6; >- psubw mm3, mm5 ;tmp6 >- >-// tmp4 = tmp20 + tmp5; >- movq mm0, [esi+8*1] ;tmp1,final2 >- psubw mm1, mm3 ;tmp5 >- >- movq mm6, mm0 ;final2 >- paddw mm0, mm3 ;tmp1+tmp6,final2 >- >- /* Final output stage: scale down by a factor of 8 and range-limit */ >- >- >-// outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) >-// & RANGE_MASK]; >-// outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) >-// & RANGE_MASK]; final1 >- >- >-// outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) >-// & RANGE_MASK]; >-// outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) >-// & RANGE_MASK]; final2 >- psubw mm6, mm3 ;tmp1-tmp6,final2 >- psraw mm0, 5 ;outptr[0,1],[1,1],[2,1],[3,1] >- >- paddsw mm0, const_0x0080 >- psraw mm6, 5 ;outptr[0,6],[1,6],[2,6],[3,6] >- >- paddsw mm6, const_0x0080 ;need to check this value >- packuswb mm0, mm4 ;out[0,1],[1,1],[2,1],[3,1],[0,7],[1,7],[2,7],[3,7] >- >- movq mm5, [esi+8*2] ;tmp2,final3 >- packuswb mm2, mm6 ;out[0,0],[1,0],[2,0],[3,0],[0,6],[1,6],[2,6],[3,6] >- >-// outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) >-// & RANGE_MASK]; >-// outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) >-// & RANGE_MASK]; final3 >- paddw mm7, mm1 ;tmp4 >- movq mm3, mm5 >- >- paddw mm5, mm1 ;tmp2+tmp5 >- psubw mm3, mm1 ;tmp2-tmp5 >- >- psraw mm5, 5 ;outptr[0,2],[1,2],[2,2],[3,2] >- >- paddsw mm5, const_0x0080 >- movq mm4, [esi+8*3] ;tmp3,final4 >- psraw mm3, 5 ;outptr[0,5],[1,5],[2,5],[3,5] >- >- paddsw mm3, const_0x0080 >- >- >-// outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) >-// & RANGE_MASK]; >-// outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) >-// & RANGE_MASK]; final4 >- movq mm6, mm4 >- paddw mm4, mm7 ;tmp3+tmp4 >- >- psubw mm6, mm7 ;tmp3-tmp4 >- psraw mm4, 5 ;outptr[0,4],[1,4],[2,4],[3,4] >- mov ecx, [eax] >- >- paddsw mm4, const_0x0080 >- psraw mm6, 5 ;outptr[0,3],[1,3],[2,3],[3,3] >- >- paddsw mm6, const_0x0080 >- packuswb mm5, mm4 ;out[0,2],[1,2],[2,2],[3,2],[0,4],[1,4],[2,4],[3,4] >- >- packuswb mm6, mm3 ;out[0,3],[1,3],[2,3],[3,3],[0,5],[1,5],[2,5],[3,5] >- movq mm4, mm2 >- >- movq mm7, mm5 >- punpcklbw mm2, mm0 ;out[0,0],[0,1],[1,0],[1,1],[2,0],[2,1],[3,0],[3,1] >- >- punpckhbw mm4, mm0 ;out[0,6],[0,7],[1,6],[1,7],[2,6],[2,7],[3,6],[3,7] >- movq mm1, mm2 >- >- punpcklbw mm5, mm6 ;out[0,2],[0,3],[1,2],[1,3],[2,2],[2,3],[3,2],[3,3] >- add eax, 4 >- >- punpckhbw mm7, mm6 ;out[0,4],[0,5],[1,4],[1,5],[2,4],[2,5],[3,4],[3,5] >- >- punpcklwd mm2, mm5 ;out[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3] >- add ecx, output_col >- >- movq mm6, mm7 >- punpckhwd mm1, mm5 ;out[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3] >- >- movq mm0, mm2 >- punpcklwd mm6, mm4 ;out[0,4],[0,5],[0,6],[0,7],[1,4],[1,5],[1,6],[1,7] >- >- mov ebx, [eax] >- punpckldq mm2, mm6 ;out[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7] >- >- add eax, 4 >- movq mm3, mm1 >- >- add ebx, output_col >- punpckhwd mm7, mm4 ;out[2,4],[2,5],[2,6],[2,7],[3,4],[3,5],[3,6],[3,7] >- >- movq [ecx], mm2 >- punpckhdq mm0, mm6 ;out[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7] >- >- mov ecx, [eax] >- add eax, 4 >- add ecx, output_col >- >- movq [ebx], mm0 >- punpckldq mm1, mm7 ;out[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7] >- >- mov ebx, [eax] >- >- add ebx, output_col >- punpckhdq mm3, mm7 ;out[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7] >- movq [ecx], mm1 >- >- >- movq [ebx], mm3 >- >- >- >-/*******************************************************************/ >- >- >- add esi, 64 >- add eax, 4 >- >-/*******************************************************************/ >- >-// tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); >-// tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); >-// tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); >-// tmp14 = ((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6]); >- movq mm0, [esi+8*0] ;wsptr[0,0],[0,1],[0,2],[0,3] >- >- movq mm1, [esi+8*1] ;wsptr[0,4],[0,5],[0,6],[0,7] >- movq mm2, mm0 >- >- movq mm3, [esi+8*2] ;wsptr[1,0],[1,1],[1,2],[1,3] >- paddw mm0, mm1 ;wsptr[0,tmp10],[xxx],[0,tmp13],[xxx] >- >- movq mm4, [esi+8*3] ;wsptr[1,4],[1,5],[1,6],[1,7] >- psubw mm2, mm1 ;wsptr[0,tmp11],[xxx],[0,tmp14],[xxx] >- >- movq mm6, mm0 >- movq mm5, mm3 >- >- paddw mm3, mm4 ;wsptr[1,tmp10],[xxx],[1,tmp13],[xxx] >- movq mm1, mm2 >- >- psubw mm5, mm4 ;wsptr[1,tmp11],[xxx],[1,tmp14],[xxx] >- punpcklwd mm0, mm3 ;wsptr[0,tmp10],[1,tmp10],[xxx],[xxx] >- >- movq mm7, [esi+8*7] ;wsptr[3,4],[3,5],[3,6],[3,7] >- punpckhwd mm6, mm3 ;wsptr[0,tmp13],[1,tmp13],[xxx],[xxx] >- >- movq mm3, [esi+8*4] ;wsptr[2,0],[2,1],[2,2],[2,3] >- punpckldq mm0, mm6 ;wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] >- >- punpcklwd mm1, mm5 ;wsptr[0,tmp11],[1,tmp11],[xxx],[xxx] >- movq mm4, mm3 >- >- movq mm6, [esi+8*6] ;wsptr[3,0],[3,1],[3,2],[3,3] >- punpckhwd mm2, mm5 ;wsptr[0,tmp14],[1,tmp14],[xxx],[xxx] >- >- movq mm5, [esi+8*5] ;wsptr[2,4],[2,5],[2,6],[2,7] >- punpckldq mm1, mm2 ;wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] >- >- >- paddw mm3, mm5 ;wsptr[2,tmp10],[xxx],[2,tmp13],[xxx] >- movq mm2, mm6 >- >- psubw mm4, mm5 ;wsptr[2,tmp11],[xxx],[2,tmp14],[xxx] >- paddw mm6, mm7 ;wsptr[3,tmp10],[xxx],[3,tmp13],[xxx] >- >- movq mm5, mm3 >- punpcklwd mm3, mm6 ;wsptr[2,tmp10],[3,tmp10],[xxx],[xxx] >- >- psubw mm2, mm7 ;wsptr[3,tmp11],[xxx],[3,tmp14],[xxx] >- punpckhwd mm5, mm6 ;wsptr[2,tmp13],[3,tmp13],[xxx],[xxx] >- >- movq mm7, mm4 >- punpckldq mm3, mm5 ;wsptr[2,tmp10],[3,tmp10],[2,tmp13],[3,tmp13] >- >- punpcklwd mm4, mm2 ;wsptr[2,tmp11],[3,tmp11],[xxx],[xxx] >- >- punpckhwd mm7, mm2 ;wsptr[2,tmp14],[3,tmp14],[xxx],[xxx] >- >- punpckldq mm4, mm7 ;wsptr[2,tmp11],[3,tmp11],[2,tmp14],[3,tmp14] >- movq mm6, mm1 >- >-// mm0 = ;wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] >-// mm1 = ;wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] >- >- >- movq mm2, mm0 >- punpckhdq mm6, mm4 ;wsptr[0,tmp14],[1,tmp14],[2,tmp14],[3,tmp14] >- >- punpckldq mm1, mm4 ;wsptr[0,tmp11],[1,tmp11],[2,tmp11],[3,tmp11] >- psllw mm6, 2 >- >- pmulhw mm6, fix_141 >- punpckldq mm0, mm3 ;wsptr[0,tmp10],[1,tmp10],[2,tmp10],[3,tmp10] >- >- punpckhdq mm2, mm3 ;wsptr[0,tmp13],[1,tmp13],[2,tmp13],[3,tmp13] >- movq mm7, mm0 >- >-// tmp0 = tmp10 + tmp13; >-// tmp3 = tmp10 - tmp13; >- paddw mm0, mm2 ;[0,tmp0],[1,tmp0],[2,tmp0],[3,tmp0] >- psubw mm7, mm2 ;[0,tmp3],[1,tmp3],[2,tmp3],[3,tmp3] >- >-// tmp12 = MULTIPLY(tmp14, FIX_1_414213562) - tmp13; >- psubw mm6, mm2 ;wsptr[0,tmp12],[1,tmp12],[2,tmp12],[3,tmp12] >-// tmp1 = tmp11 + tmp12; >-// tmp2 = tmp11 - tmp12; >- movq mm5, mm1 >- >- >- >- /* Odd part */ >- >-// z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; >-// z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; >-// z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; >-// z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; >- movq mm3, [esi+8*0] ;wsptr[0,0],[0,1],[0,2],[0,3] >- paddw mm1, mm6 ;[0,tmp1],[1,tmp1],[2,tmp1],[3,tmp1] >- >- movq mm4, [esi+8*1] ;wsptr[0,4],[0,5],[0,6],[0,7] >- psubw mm5, mm6 ;[0,tmp2],[1,tmp2],[2,tmp2],[3,tmp2] >- >- movq mm6, mm3 >- punpckldq mm3, mm4 ;wsptr[0,0],[0,1],[0,4],[0,5] >- >- punpckhdq mm4, mm6 ;wsptr[0,6],[0,7],[0,2],[0,3] >- movq mm2, mm3 >- >-//Save tmp0 and tmp1 in wsptr >- movq [esi+8*0], mm0 ;save tmp0 >- paddw mm2, mm4 ;wsptr[xxx],[0,z11],[xxx],[0,z13] >- >- >-//Continue with z10 --- z13 >- movq mm6, [esi+8*2] ;wsptr[1,0],[1,1],[1,2],[1,3] >- psubw mm3, mm4 ;wsptr[xxx],[0,z12],[xxx],[0,z10] >- >- movq mm0, [esi+8*3] ;wsptr[1,4],[1,5],[1,6],[1,7] >- movq mm4, mm6 >- >- movq [esi+8*1], mm1 ;save tmp1 >- punpckldq mm6, mm0 ;wsptr[1,0],[1,1],[1,4],[1,5] >- >- punpckhdq mm0, mm4 ;wsptr[1,6],[1,7],[1,2],[1,3] >- movq mm1, mm6 >- >-//Save tmp2 and tmp3 in wsptr >- paddw mm6, mm0 ;wsptr[xxx],[1,z11],[xxx],[1,z13] >- movq mm4, mm2 >- >-//Continue with z10 --- z13 >- movq [esi+8*2], mm5 ;save tmp2 >- punpcklwd mm2, mm6 ;wsptr[xxx],[xxx],[0,z11],[1,z11] >- >- psubw mm1, mm0 ;wsptr[xxx],[1,z12],[xxx],[1,z10] >- punpckhwd mm4, mm6 ;wsptr[xxx],[xxx],[0,z13],[1,z13] >- >- movq mm0, mm3 >- punpcklwd mm3, mm1 ;wsptr[xxx],[xxx],[0,z12],[1,z12] >- >- movq [esi+8*3], mm7 ;save tmp3 >- punpckhwd mm0, mm1 ;wsptr[xxx],[xxx],[0,z10],[1,z10] >- >- movq mm6, [esi+8*4] ;wsptr[2,0],[2,1],[2,2],[2,3] >- punpckhdq mm0, mm2 ;wsptr[0,z10],[1,z10],[0,z11],[1,z11] >- >- movq mm7, [esi+8*5] ;wsptr[2,4],[2,5],[2,6],[2,7] >- punpckhdq mm3, mm4 ;wsptr[0,z12],[1,z12],[0,z13],[1,z13] >- >- movq mm1, [esi+8*6] ;wsptr[3,0],[3,1],[3,2],[3,3] >- movq mm4, mm6 >- >- punpckldq mm6, mm7 ;wsptr[2,0],[2,1],[2,4],[2,5] >- movq mm5, mm1 >- >- punpckhdq mm7, mm4 ;wsptr[2,6],[2,7],[2,2],[2,3] >- movq mm2, mm6 >- >- movq mm4, [esi+8*7] ;wsptr[3,4],[3,5],[3,6],[3,7] >- paddw mm6, mm7 ;wsptr[xxx],[2,z11],[xxx],[2,z13] >- >- psubw mm2, mm7 ;wsptr[xxx],[2,z12],[xxx],[2,z10] >- punpckldq mm1, mm4 ;wsptr[3,0],[3,1],[3,4],[3,5] >- >- punpckhdq mm4, mm5 ;wsptr[3,6],[3,7],[3,2],[3,3] >- movq mm7, mm1 >- >- paddw mm1, mm4 ;wsptr[xxx],[3,z11],[xxx],[3,z13] >- psubw mm7, mm4 ;wsptr[xxx],[3,z12],[xxx],[3,z10] >- >- movq mm5, mm6 >- punpcklwd mm6, mm1 ;wsptr[xxx],[xxx],[2,z11],[3,z11] >- >- punpckhwd mm5, mm1 ;wsptr[xxx],[xxx],[2,z13],[3,z13] >- movq mm4, mm2 >- >- punpcklwd mm2, mm7 ;wsptr[xxx],[xxx],[2,z12],[3,z12] >- >- punpckhwd mm4, mm7 ;wsptr[xxx],[xxx],[2,z10],[3,z10] >- >- punpckhdq mm4, mm6 ;wsptr[2,z10],[3,z10],[2,z11],[3,z11] >- >- punpckhdq mm2, mm5 ;wsptr[2,z12],[3,z12],[2,z13],[3,z13] >- movq mm5, mm0 >- >- punpckldq mm0, mm4 ;wsptr[0,z10],[1,z10],[2,z10],[3,z10] >- >- punpckhdq mm5, mm4 ;wsptr[0,z11],[1,z11],[2,z11],[3,z11] >- movq mm4, mm3 >- >- punpckhdq mm4, mm2 ;wsptr[0,z13],[1,z13],[2,z13],[3,z13] >- movq mm1, mm5 >- >- punpckldq mm3, mm2 ;wsptr[0,z12],[1,z12],[2,z12],[3,z12] >-// tmp7 = z11 + z13; /* phase 5 */ >-// tmp8 = z11 - z13; /* phase 5 */ >- psubw mm1, mm4 ;tmp8 >- >- paddw mm5, mm4 ;tmp7 >-// tmp21 = MULTIPLY(tmp8, FIX_1_414213562); /* 2*c4 */ >- psllw mm1, 2 >- >- psllw mm0, 2 >- >- pmulhw mm1, fix_141 ;tmp21 >-// tmp20 = MULTIPLY(z12, (FIX_1_082392200- FIX_1_847759065)) /* 2*(c2-c6) */ >-// + MULTIPLY(z10, - FIX_1_847759065); /* 2*c2 */ >- psllw mm3, 2 >- movq mm7, mm0 >- >- pmulhw mm7, fix_n184 >- movq mm6, mm3 >- >- movq mm2, [esi+8*0] ;tmp0,final1 >- >- pmulhw mm6, fix_108n184 >-// tmp22 = MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) /* -2*(c2+c6) */ >-// + MULTIPLY(z12, FIX_1_847759065); /* 2*c2 */ >- movq mm4, mm2 ;final1 >- >- pmulhw mm0, fix_184n261 >- paddw mm2, mm5 ;tmp0+tmp7,final1 >- >- pmulhw mm3, fix_184 >- psubw mm4, mm5 ;tmp0-tmp7,final1 >- >-// tmp6 = tmp22 - tmp7; /* phase 2 */ >- psraw mm2, 5 ;outptr[0,0],[1,0],[2,0],[3,0],final1 >- >- paddsw mm2, const_0x0080 ;final1 >- paddw mm7, mm6 ;tmp20 >- psraw mm4, 5 ;outptr[0,7],[1,7],[2,7],[3,7],final1 >- >- paddsw mm4, const_0x0080 ;final1 >- paddw mm3, mm0 ;tmp22 >- >-// tmp5 = tmp21 - tmp6; >- psubw mm3, mm5 ;tmp6 >- >-// tmp4 = tmp20 + tmp5; >- movq mm0, [esi+8*1] ;tmp1,final2 >- psubw mm1, mm3 ;tmp5 >- >- movq mm6, mm0 ;final2 >- paddw mm0, mm3 ;tmp1+tmp6,final2 >- >- /* Final output stage: scale down by a factor of 8 and range-limit */ >- >- >-// outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) >-// & RANGE_MASK]; >-// outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) >-// & RANGE_MASK]; final1 >- >- >-// outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) >-// & RANGE_MASK]; >-// outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) >-// & RANGE_MASK]; final2 >- psubw mm6, mm3 ;tmp1-tmp6,final2 >- psraw mm0, 5 ;outptr[0,1],[1,1],[2,1],[3,1] >- >- paddsw mm0, const_0x0080 >- psraw mm6, 5 ;outptr[0,6],[1,6],[2,6],[3,6] >- >- paddsw mm6, const_0x0080 ;need to check this value >- packuswb mm0, mm4 ;out[0,1],[1,1],[2,1],[3,1],[0,7],[1,7],[2,7],[3,7] >- >- movq mm5, [esi+8*2] ;tmp2,final3 >- packuswb mm2, mm6 ;out[0,0],[1,0],[2,0],[3,0],[0,6],[1,6],[2,6],[3,6] >- >-// outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) >-// & RANGE_MASK]; >-// outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) >-// & RANGE_MASK]; final3 >- paddw mm7, mm1 ;tmp4 >- movq mm3, mm5 >- >- paddw mm5, mm1 ;tmp2+tmp5 >- psubw mm3, mm1 ;tmp2-tmp5 >- >- psraw mm5, 5 ;outptr[0,2],[1,2],[2,2],[3,2] >- >- paddsw mm5, const_0x0080 >- movq mm4, [esi+8*3] ;tmp3,final4 >- psraw mm3, 5 ;outptr[0,5],[1,5],[2,5],[3,5] >- >- paddsw mm3, const_0x0080 >- >- >-// outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) >-// & RANGE_MASK]; >-// outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) >-// & RANGE_MASK]; final4 >- movq mm6, mm4 >- paddw mm4, mm7 ;tmp3+tmp4 >- >- psubw mm6, mm7 ;tmp3-tmp4 >- psraw mm4, 5 ;outptr[0,4],[1,4],[2,4],[3,4] >- mov ecx, [eax] >- >- paddsw mm4, const_0x0080 >- psraw mm6, 5 ;outptr[0,3],[1,3],[2,3],[3,3] >- >- paddsw mm6, const_0x0080 >- packuswb mm5, mm4 ;out[0,2],[1,2],[2,2],[3,2],[0,4],[1,4],[2,4],[3,4] >- >- packuswb mm6, mm3 ;out[0,3],[1,3],[2,3],[3,3],[0,5],[1,5],[2,5],[3,5] >- movq mm4, mm2 >- >- movq mm7, mm5 >- punpcklbw mm2, mm0 ;out[0,0],[0,1],[1,0],[1,1],[2,0],[2,1],[3,0],[3,1] >- >- punpckhbw mm4, mm0 ;out[0,6],[0,7],[1,6],[1,7],[2,6],[2,7],[3,6],[3,7] >- movq mm1, mm2 >- >- punpcklbw mm5, mm6 ;out[0,2],[0,3],[1,2],[1,3],[2,2],[2,3],[3,2],[3,3] >- add eax, 4 >- >- punpckhbw mm7, mm6 ;out[0,4],[0,5],[1,4],[1,5],[2,4],[2,5],[3,4],[3,5] >- >- punpcklwd mm2, mm5 ;out[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3] >- add ecx, output_col >- >- movq mm6, mm7 >- punpckhwd mm1, mm5 ;out[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3] >- >- movq mm0, mm2 >- punpcklwd mm6, mm4 ;out[0,4],[0,5],[0,6],[0,7],[1,4],[1,5],[1,6],[1,7] >- >- mov ebx, [eax] >- punpckldq mm2, mm6 ;out[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7] >- >- add eax, 4 >- movq mm3, mm1 >- >- add ebx, output_col >- punpckhwd mm7, mm4 ;out[2,4],[2,5],[2,6],[2,7],[3,4],[3,5],[3,6],[3,7] >- >- movq [ecx], mm2 >- punpckhdq mm0, mm6 ;out[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7] >- >- mov ecx, [eax] >- add eax, 4 >- add ecx, output_col >- >- movq [ebx], mm0 >- punpckldq mm1, mm7 ;out[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7] >- >- mov ebx, [eax] >- >- add ebx, output_col >- punpckhdq mm3, mm7 ;out[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7] >- movq [ecx], mm1 >- >- movq [ebx], mm3 >- >- emms >- } >-} >-#endif >- > #endif /* DCT_IFAST_SUPPORTED */ >diff --git a/jpeg/jidctint.c b/modules/libjpeg-turbo/jidctint.c >rename from jpeg/jidctint.c >rename to modules/libjpeg-turbo/jidctint.c >--- a/jpeg/jidctint.c >+++ b/modules/libjpeg-turbo/jidctint.c >@@ -381,583 +381,9 @@ jpeg_idct_islow (j_decompress_ptr cinfo, > outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0, > CONST_BITS+PASS1_BITS+3) > & RANGE_MASK]; > > wsptr += DCTSIZE; /* advance pointer to next row */ > } > } > >- >-#ifdef HAVE_SSE2_INTEL_MNEMONICS >- >-/* >-* Intel SSE2 optimized Inverse Discrete Cosine Transform >-* >-* >-* Copyright (c) 2001-2002 Intel Corporation >-* All Rights Reserved >-* >-* >-* Authors: >-* Danilov G. >-* >-* >-*----------------------------------------------------------------------------- >-* >-* References: >-* K.R. Rao and P. Yip >-* Discrete Cosine Transform. >-* Algorithms, Advantages, Applications. >-* Academic Press, Inc, London, 1990. >-* JPEG Group's software. >-* This implementation is based on Appendix A.2 of the book (R&Y) ... >-* >-*----------------------------------------------------------------------------- >-*/ >- >-typedef unsigned char Ipp8u; >-typedef unsigned short Ipp16u; >-typedef unsigned int Ipp32u; >- >-typedef signed char Ipp8s; >-typedef signed short Ipp16s; >-typedef signed int Ipp32s; >- >-#define BITS_INV_ACC 4 >-#define SHIFT_INV_ROW 16 - BITS_INV_ACC >-#define SHIFT_INV_COL 1 + BITS_INV_ACC >- >-#define RND_INV_ROW 1024 * (6 - BITS_INV_ACC) /* 1 << (SHIFT_INV_ROW-1) */ >-#define RND_INV_COL = 16 * (BITS_INV_ACC - 3) /* 1 << (SHIFT_INV_COL-1) */ >-#define RND_INV_CORR = RND_INV_COL - 1 /* correction -1.0 and round */ >- >-#define c_inv_corr_0 -1024 * (6 - BITS_INV_ACC) + 65536 /* -0.5 + (16.0 or 32.0) */ >-#define c_inv_corr_1 1877 * (6 - BITS_INV_ACC) /* 0.9167 */ >-#define c_inv_corr_2 1236 * (6 - BITS_INV_ACC) /* 0.6035 */ >-#define c_inv_corr_3 680 * (6 - BITS_INV_ACC) /* 0.3322 */ >-#define c_inv_corr_4 0 * (6 - BITS_INV_ACC) /* 0.0 */ >-#define c_inv_corr_5 -569 * (6 - BITS_INV_ACC) /* -0.278 */ >-#define c_inv_corr_6 -512 * (6 - BITS_INV_ACC) /* -0.25 */ >-#define c_inv_corr_7 -651 * (6 - BITS_INV_ACC) /* -0.3176 */ >- >-#define RND_INV_ROW_0 RND_INV_ROW + c_inv_corr_0 >-#define RND_INV_ROW_1 RND_INV_ROW + c_inv_corr_1 >-#define RND_INV_ROW_2 RND_INV_ROW + c_inv_corr_2 >-#define RND_INV_ROW_3 RND_INV_ROW + c_inv_corr_3 >-#define RND_INV_ROW_4 RND_INV_ROW + c_inv_corr_4 >-#define RND_INV_ROW_5 RND_INV_ROW + c_inv_corr_5 >-#define RND_INV_ROW_6 RND_INV_ROW + c_inv_corr_6 >-#define RND_INV_ROW_7 RND_INV_ROW + c_inv_corr_7 >- >-/* Table for rows 0,4 - constants are multiplied on cos_4_16 */ >- >-__declspec(align(16)) short tab_i_04[] = { >- 16384, 21407, 16384, 8867, >- -16384, 21407, 16384, -8867, >- 16384, -8867, 16384, -21407, >- 16384, 8867, -16384, -21407, >- 22725, 19266, 19266, -4520, >- 4520, 19266, 19266, -22725, >- 12873, -22725, 4520, -12873, >- 12873, 4520, -22725, -12873}; >- >-/* Table for rows 1,7 - constants are multiplied on cos_1_16 */ >- >-__declspec(align(16)) short tab_i_17[] = { >- 22725, 29692, 22725, 12299, >- -22725, 29692, 22725, -12299, >- 22725, -12299, 22725, -29692, >- 22725, 12299, -22725, -29692, >- 31521, 26722, 26722, -6270, >- 6270, 26722, 26722, -31521, >- 17855, -31521, 6270, -17855, >- 17855, 6270, -31521, -17855}; >- >-/* Table for rows 2,6 - constants are multiplied on cos_2_16 */ >- >-__declspec(align(16)) short tab_i_26[] = { >- 21407, 27969, 21407, 11585, >- -21407, 27969, 21407, -11585, >- 21407, -11585, 21407, -27969, >- 21407, 11585, -21407, -27969, >- 29692, 25172, 25172, -5906, >- 5906, 25172, 25172, -29692, >- 16819, -29692, 5906, -16819, >- 16819, 5906, -29692, -16819}; >- >-/* Table for rows 3,5 - constants are multiplied on cos_3_16 */ >- >-__declspec(align(16)) short tab_i_35[] = { >- 19266, 25172, 19266, 10426, >- -19266, 25172, 19266, -10426, >- 19266, -10426, 19266, -25172, >- 19266, 10426, -19266, -25172, >- 26722, 22654, 22654, -5315, >- 5315, 22654, 22654, -26722, >- 15137, -26722, 5315, -15137, >- 15137, 5315, -26722, -15137}; >- >-__declspec(align(16)) long round_i_0[] = {RND_INV_ROW_0,RND_INV_ROW_0, >- RND_INV_ROW_0,RND_INV_ROW_0}; >-__declspec(align(16)) long round_i_1[] = {RND_INV_ROW_1,RND_INV_ROW_1, >- RND_INV_ROW_1,RND_INV_ROW_1}; >-__declspec(align(16)) long round_i_2[] = {RND_INV_ROW_2,RND_INV_ROW_2, >- RND_INV_ROW_2,RND_INV_ROW_2}; >-__declspec(align(16)) long round_i_3[] = {RND_INV_ROW_3,RND_INV_ROW_3, >- RND_INV_ROW_3,RND_INV_ROW_3}; >-__declspec(align(16)) long round_i_4[] = {RND_INV_ROW_4,RND_INV_ROW_4, >- RND_INV_ROW_4,RND_INV_ROW_4}; >-__declspec(align(16)) long round_i_5[] = {RND_INV_ROW_5,RND_INV_ROW_5, >- RND_INV_ROW_5,RND_INV_ROW_5}; >-__declspec(align(16)) long round_i_6[] = {RND_INV_ROW_6,RND_INV_ROW_6, >- RND_INV_ROW_6,RND_INV_ROW_6}; >-__declspec(align(16)) long round_i_7[] = {RND_INV_ROW_7,RND_INV_ROW_7, >- RND_INV_ROW_7,RND_INV_ROW_7}; >- >-__declspec(align(16)) short tg_1_16[] = { >- 13036, 13036, 13036, 13036, /* tg * (2<<16) + 0.5 */ >- 13036, 13036, 13036, 13036}; >-__declspec(align(16)) short tg_2_16[] = { >- 27146, 27146, 27146, 27146, /* tg * (2<<16) + 0.5 */ >- 27146, 27146, 27146, 27146}; >-__declspec(align(16)) short tg_3_16[] = { >- -21746, -21746, -21746, -21746, /* tg * (2<<16) + 0.5 */ >- -21746, -21746, -21746, -21746}; >-__declspec(align(16)) short cos_4_16[] = { >- -19195, -19195, -19195, -19195, /* cos * (2<<16) + 0.5 */ >- -19195, -19195, -19195, -19195}; >- >-/* >-* In this implementation the outputs of the iDCT-1D are multiplied >-* for rows 0,4 - on cos_4_16, >-* for rows 1,7 - on cos_1_16, >-* for rows 2,6 - on cos_2_16, >-* for rows 3,5 - on cos_3_16 >-* and are shifted to the left for rise of accuracy >-* >-* For used constants >-* FIX(float_const) = (short) (float_const * (1<<15) + 0.5) >-* >-*----------------------------------------------------------------------------- >-* >-* On the first stage the calculation is executed at once for two rows. >-* The permutation for each output row is done on second stage >-* t7 t6 t5 t4 t3 t2 t1 t0 -> t4 t5 t6 t7 t3 t2 t1 t0 >-* >-*----------------------------------------------------------------------------- >-*/ >- >-#define DCT_8_INV_ROW_2R(TABLE, ROUND1, ROUND2) __asm { \ >- __asm pshuflw xmm1, xmm0, 10001000b \ >- __asm pshuflw xmm0, xmm0, 11011101b \ >- __asm pshufhw xmm1, xmm1, 10001000b \ >- __asm pshufhw xmm0, xmm0, 11011101b \ >- __asm movdqa xmm2, XMMWORD PTR [TABLE] \ >- __asm pmaddwd xmm2, xmm1 \ >- __asm movdqa xmm3, XMMWORD PTR [TABLE + 32] \ >- __asm pmaddwd xmm3, xmm0 \ >- __asm pmaddwd xmm1, XMMWORD PTR [TABLE + 16] \ >- __asm pmaddwd xmm0, XMMWORD PTR [TABLE + 48] \ >- __asm pshuflw xmm5, xmm4, 10001000b \ >- __asm pshuflw xmm4, xmm4, 11011101b \ >- __asm pshufhw xmm5, xmm5, 10001000b \ >- __asm pshufhw xmm4, xmm4, 11011101b \ >- __asm movdqa xmm6, XMMWORD PTR [TABLE] \ >- __asm pmaddwd xmm6, xmm5 \ >- __asm movdqa xmm7, XMMWORD PTR [TABLE + 32] \ >- __asm pmaddwd xmm7, xmm4 \ >- __asm pmaddwd xmm5, XMMWORD PTR [TABLE + 16] \ >- __asm pmaddwd xmm4, XMMWORD PTR [TABLE + 48] \ >- __asm pshufd xmm1, xmm1, 01001110b \ >- __asm pshufd xmm0, xmm0, 01001110b \ >- __asm paddd xmm2, XMMWORD PTR [ROUND1] \ >- __asm paddd xmm3, xmm0 \ >- __asm paddd xmm1, xmm2 \ >- __asm pshufd xmm5, xmm5, 01001110b \ >- __asm pshufd xmm4, xmm4, 01001110b \ >- __asm movdqa xmm2, xmm1 \ >- __asm psubd xmm2, xmm3 \ >- __asm psrad xmm2, SHIFT_INV_ROW \ >- __asm paddd xmm1, xmm3 \ >- __asm psrad xmm1, SHIFT_INV_ROW \ >- __asm packssdw xmm1, xmm2 \ >- __asm paddd xmm6, XMMWORD PTR [ROUND2] \ >- __asm paddd xmm7, xmm4 \ >- __asm paddd xmm5, xmm6 \ >- __asm movdqa xmm6, xmm5 \ >- __asm psubd xmm6, xmm7 \ >- __asm psrad xmm6, SHIFT_INV_ROW \ >- __asm paddd xmm5, xmm7 \ >- __asm psrad xmm5, SHIFT_INV_ROW \ >- __asm packssdw xmm5, xmm6 \ >- } >- >-/* >-* >-* The second stage - inverse DCTs of columns >-* >-* The inputs are multiplied >-* for rows 0,4 - on cos_4_16, >-* for rows 1,7 - on cos_1_16, >-* for rows 2,6 - on cos_2_16, >-* for rows 3,5 - on cos_3_16 >-* and are shifted to the left for rise of accuracy >-*/ >- >-#define DCT_8_INV_COL_8R(INP, OUTP) __asm { \ >- __asm movdqa xmm0, [INP + 5*16] \ >- __asm movdqa xmm1, XMMWORD PTR tg_3_16 \ >- __asm movdqa xmm2, xmm0 \ >- __asm movdqa xmm3, [INP + 3*16] \ >- __asm pmulhw xmm0, xmm1 \ >- __asm movdqa xmm4, [INP + 7*16] \ >- __asm pmulhw xmm1, xmm3 \ >- __asm movdqa xmm5, XMMWORD PTR tg_1_16 \ >- __asm movdqa xmm6, xmm4 \ >- __asm pmulhw xmm4, xmm5 \ >- __asm paddsw xmm0, xmm2 \ >- __asm pmulhw xmm5, [INP + 1*16] \ >- __asm paddsw xmm1, xmm3 \ >- __asm movdqa xmm7, [INP + 6*16] \ >- __asm paddsw xmm0, xmm3 \ >- __asm movdqa xmm3, XMMWORD PTR tg_2_16 \ >- __asm psubsw xmm2, xmm1 \ >- __asm pmulhw xmm7, xmm3 \ >- __asm movdqa xmm1, xmm0 \ >- __asm pmulhw xmm3, [INP + 2*16] \ >- __asm psubsw xmm5, xmm6 \ >- __asm paddsw xmm4, [INP + 1*16] \ >- __asm paddsw xmm0, xmm4 \ >- __asm psubsw xmm4, xmm1 \ >- __asm pshufhw xmm0, xmm0, 00011011b \ >- __asm paddsw xmm7, [INP + 2*16] \ >- __asm movdqa xmm6, xmm5 \ >- __asm psubsw xmm3, [INP + 6*16] \ >- __asm psubsw xmm5, xmm2 \ >- __asm paddsw xmm6, xmm2 \ >- __asm movdqa [OUTP + 7*16], xmm0 \ >- __asm movdqa xmm1, xmm4 \ >- __asm movdqa xmm2, XMMWORD PTR cos_4_16 \ >- __asm paddsw xmm4, xmm5 \ >- __asm movdqa xmm0, XMMWORD PTR cos_4_16 \ >- __asm pmulhw xmm2, xmm4 \ >- __asm pshufhw xmm6, xmm6, 00011011b \ >- __asm movdqa [OUTP + 3*16], xmm6 \ >- __asm psubsw xmm1, xmm5 \ >- __asm movdqa xmm6, [INP + 0*16] \ >- __asm pmulhw xmm0, xmm1 \ >- __asm movdqa xmm5, [INP + 4*16] \ >- __asm paddsw xmm4, xmm2 \ >- __asm paddsw xmm5, xmm6 \ >- __asm psubsw xmm6, [INP + 4*16] \ >- __asm paddsw xmm0, xmm1 \ >- __asm pshufhw xmm4, xmm4, 00011011b \ >- __asm movdqa xmm2, xmm5 \ >- __asm paddsw xmm5, xmm7 \ >- __asm movdqa xmm1, xmm6 \ >- __asm psubsw xmm2, xmm7 \ >- __asm movdqa xmm7, [OUTP + 7*16] \ >- __asm paddsw xmm6, xmm3 \ >- __asm pshufhw xmm5, xmm5, 00011011b \ >- __asm paddsw xmm7, xmm5 \ >- __asm psubsw xmm1, xmm3 \ >- __asm pshufhw xmm6, xmm6, 00011011b \ >- __asm movdqa xmm3, xmm6 \ >- __asm paddsw xmm6, xmm4 \ >- __asm pshufhw xmm2, xmm2, 00011011b \ >- __asm psraw xmm7, SHIFT_INV_COL \ >- __asm movdqa [OUTP + 0*16], xmm7 \ >- __asm movdqa xmm7, xmm1 \ >- __asm paddsw xmm1, xmm0 \ >- __asm psraw xmm6, SHIFT_INV_COL \ >- __asm movdqa [OUTP + 1*16], xmm6 \ >- __asm pshufhw xmm1, xmm1, 00011011b \ >- __asm movdqa xmm6, [OUTP + 3*16] \ >- __asm psubsw xmm7, xmm0 \ >- __asm psraw xmm1, SHIFT_INV_COL \ >- __asm movdqa [OUTP + 2*16], xmm1 \ >- __asm psubsw xmm5, [OUTP + 7*16] \ >- __asm paddsw xmm6, xmm2 \ >- __asm psubsw xmm2, [OUTP + 3*16] \ >- __asm psubsw xmm3, xmm4 \ >- __asm psraw xmm7, SHIFT_INV_COL \ >- __asm pshufhw xmm7, xmm7, 00011011b \ >- __asm movdqa [OUTP + 5*16], xmm7 \ >- __asm psraw xmm5, SHIFT_INV_COL \ >- __asm movdqa [OUTP + 7*16], xmm5 \ >- __asm psraw xmm6, SHIFT_INV_COL \ >- __asm movdqa [OUTP + 3*16], xmm6 \ >- __asm psraw xmm2, SHIFT_INV_COL \ >- __asm movdqa [OUTP + 4*16], xmm2 \ >- __asm psraw xmm3, SHIFT_INV_COL \ >- __asm movdqa [OUTP + 6*16], xmm3 \ >- } >- >-/* >-* >-* Name: dct_8x8_inv_16s >-* Purpose: Inverse Discrete Cosine Transform 8x8 with >-* 2D buffer of short int data >-* Context: >-* void dct_8x8_inv_16s ( short *src, short *dst ) >-* Parameters: >-* src - Pointer to the source buffer >-* dst - Pointer to the destination buffer >-* >-*/ >- >-GLOBAL(void) >-dct_8x8_inv_16s ( short *src, short *dst ) { >- >- __asm { >- >- mov ecx, src >- mov edx, dst >- >- movdqa xmm0, [ecx+0*16] >- movdqa xmm4, [ecx+4*16] >- DCT_8_INV_ROW_2R(tab_i_04, round_i_0, round_i_4) >- movdqa [edx+0*16], xmm1 >- movdqa [edx+4*16], xmm5 >- >- movdqa xmm0, [ecx+1*16] >- movdqa xmm4, [ecx+7*16] >- DCT_8_INV_ROW_2R(tab_i_17, round_i_1, round_i_7) >- movdqa [edx+1*16], xmm1 >- movdqa [edx+7*16], xmm5 >- >- movdqa xmm0, [ecx+3*16] >- movdqa xmm4, [ecx+5*16] >- DCT_8_INV_ROW_2R(tab_i_35, round_i_3, round_i_5); >- movdqa [edx+3*16], xmm1 >- movdqa [edx+5*16], xmm5 >- >- movdqa xmm0, [ecx+2*16] >- movdqa xmm4, [ecx+6*16] >- DCT_8_INV_ROW_2R(tab_i_26, round_i_2, round_i_6); >- movdqa [edx+2*16], xmm1 >- movdqa [edx+6*16], xmm5 >- >- DCT_8_INV_COL_8R(edx+0, edx+0); >- } >-} >- >- >-/* >-* Name: >-* ownpj_QuantInv_8x8_16s >-* >-* Purpose: >-* Dequantize 8x8 block of DCT coefficients >-* >-* Context: >-* void ownpj_QuantInv_8x8_16s >-* Ipp16s* pSrc, >-* Ipp16s* pDst, >-* const Ipp16u* pQTbl)* >-* >-*/ >- >-GLOBAL(void) >-ownpj_QuantInv_8x8_16s(short * pSrc, short * pDst, const unsigned short * pQTbl) >-{ >- __asm { >- >- push ebx >- push ecx >- push edx >- push esi >- push edi >- >- mov esi, pSrc >- mov edi, pDst >- mov edx, pQTbl >- mov ecx, 4 >- mov ebx, 32 >- >- again: >- >- movq mm0, QWORD PTR [esi+0] >- movq mm1, QWORD PTR [esi+8] >- movq mm2, QWORD PTR [esi+16] >- movq mm3, QWORD PTR [esi+24] >- >- prefetcht0 [esi+ebx] ; fetch next cache line >- >- pmullw mm0, QWORD PTR [edx+0] >- pmullw mm1, QWORD PTR [edx+8] >- pmullw mm2, QWORD PTR [edx+16] >- pmullw mm3, QWORD PTR [edx+24] >- >- movq QWORD PTR [edi+0], mm0 >- movq QWORD PTR [edi+8], mm1 >- movq QWORD PTR [edi+16], mm2 >- movq QWORD PTR [edi+24], mm3 >- >- add esi, ebx >- add edi, ebx >- add edx, ebx >- dec ecx >- jnz again >- >- emms >- >- pop edi >- pop esi >- pop edx >- pop ecx >- pop ebx >- } >-} >- >- >-/* >-* Name: >-* ownpj_Add128_8x8_16s8u >-* >-* Purpose: >-* signed to unsigned conversion (level shift) >-* for 8x8 block of DCT coefficients >-* >-* Context: >-* void ownpj_Add128_8x8_16s8u >-* const Ipp16s* pSrc, >-* Ipp8u* pDst, >-* int DstStep); >-* >-*/ >- >-__declspec(align(16)) long const_128[]= {0x00800080, 0x00800080, 0x00800080, 0x00800080}; >- >-GLOBAL(void) >-ownpj_Add128_8x8_16s8u(const short * pSrc, unsigned char * pDst, int DstStep) >-{ >- __asm { >- push eax >- push ebx >- push ecx >- push edx >- push esi >- push edi >- >- mov esi, pSrc >- mov edi, pDst >- mov edx, DstStep >- mov ecx, 2 >- mov ebx, edx >- mov eax, edx >- sal ebx, 1 >- add eax, ebx >- movdqa xmm7, XMMWORD PTR const_128 >- >- again: >- >- movdqa xmm0, XMMWORD PTR [esi+0] ; line 0 >- movdqa xmm1, XMMWORD PTR [esi+16] ; line 1 >- movdqa xmm2, XMMWORD PTR [esi+32] ; line 2 >- movdqa xmm3, XMMWORD PTR [esi+48] ; line 3 >- >- paddw xmm0, xmm7 >- paddw xmm1, xmm7 >- paddw xmm2, xmm7 >- paddw xmm3, xmm7 >- >- packuswb xmm0, xmm1 >- packuswb xmm2, xmm3 >- >- movq QWORD PTR [edi], xmm0 ;0*DstStep >- movq QWORD PTR [edi+ebx], xmm2 ;2*DstStep >- >- psrldq xmm0, 8 >- psrldq xmm2, 8 >- >- movq QWORD PTR [edi+edx], xmm0 ;1*DstStep >- movq QWORD PTR [edi+eax], xmm2 ;3*DstStep >- >- add edi, ebx >- add esi, 64 >- add edi, ebx >- dec ecx >- jnz again >- >- pop edi >- pop esi >- pop edx >- pop ecx >- pop ebx >- pop eax >- } >-} >- >- >-/* >-* Name: >-* ippiDCTQuantInv8x8LS_JPEG_16s8u_C1R >-* >-* Purpose: >-* Inverse DCT transform, de-quantization and level shift >-* >-* Parameters: >-* pSrc - pointer to source >-* pDst - pointer to output array >-* DstStep - line offset for output data >-* pEncoderQuantTable - pointer to Quantization table >-* >-*/ >- >-GLOBAL(void) >-ippiDCTQuantInv8x8LS_JPEG_16s8u_C1R( >- short * pSrc, >- unsigned char * pDst, >- int DstStep, >- const unsigned short * pQuantInvTable) >-{ >- >- __declspec(align(16)) Ipp8u buf[DCTSIZE2*sizeof(Ipp16s)]; >- Ipp16s * workbuf = (Ipp16s *)buf; >- >- ownpj_QuantInv_8x8_16s(pSrc,workbuf,pQuantInvTable); >- dct_8x8_inv_16s(workbuf,workbuf); >- ownpj_Add128_8x8_16s8u(workbuf,pDst,DstStep); >- >-} >- >-GLOBAL(void) >-jpeg_idct_islow_sse2 ( >- j_decompress_ptr cinfo, >- jpeg_component_info * compptr, >- JCOEFPTR coef_block, >- JSAMPARRAY output_buf, >- JDIMENSION output_col) >-{ >- int ctr; >- JCOEFPTR inptr; >- Ipp16u* quantptr; >- Ipp8u* wsptr; >- __declspec(align(16)) Ipp8u workspace[DCTSIZE2]; >- JSAMPROW outptr; >- >- inptr = coef_block; >- quantptr = (Ipp16u*)compptr->dct_table; >- wsptr = workspace; >- >- ippiDCTQuantInv8x8LS_JPEG_16s8u_C1R(inptr, workspace, 8, quantptr); >- >- for(ctr = 0; ctr < DCTSIZE; ctr++) >- { >- outptr = output_buf[ctr] + output_col; >- >- outptr[0] = wsptr[0]; >- outptr[1] = wsptr[1]; >- outptr[2] = wsptr[2]; >- outptr[3] = wsptr[3]; >- outptr[4] = wsptr[4]; >- outptr[5] = wsptr[5]; >- outptr[6] = wsptr[6]; >- outptr[7] = wsptr[7]; >- >- wsptr += DCTSIZE; >- } >-} >-#endif /* HAVE_SSE2_INTEL_MNEMONICS */ >- > #endif /* DCT_ISLOW_SUPPORTED */ >diff --git a/jpeg/jidctred.c b/modules/libjpeg-turbo/jidctred.c >rename from jpeg/jidctred.c >rename to modules/libjpeg-turbo/jidctred.c >diff --git a/jpeg/jinclude.h b/modules/libjpeg-turbo/jinclude.h >rename from jpeg/jinclude.h >rename to modules/libjpeg-turbo/jinclude.h >diff --git a/jpeg/jmemmgr.c b/modules/libjpeg-turbo/jmemmgr.c >rename from jpeg/jmemmgr.c >rename to modules/libjpeg-turbo/jmemmgr.c >--- a/jpeg/jmemmgr.c >+++ b/modules/libjpeg-turbo/jmemmgr.c >@@ -52,68 +52,61 @@ extern char * getenv JPP((const char * n > > /* > * Many machines require storage alignment: longs must start on 4-byte > * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc() > * always returns pointers that are multiples of the worst-case alignment > * requirement, and we had better do so too. > * There isn't any really portable way to determine the worst-case alignment > * requirement. This module assumes that the alignment requirement is >- * multiples of sizeof(ALIGN_TYPE). >- * By default, we define ALIGN_TYPE as double. This is necessary on some >+ * multiples of ALIGN_SIZE. >+ * By default, we define ALIGN_SIZE as sizeof(double). This is necessary on some > * workstations (where doubles really do need 8-byte alignment) and will work > * fine on nearly everything. If your machine has lesser alignment needs, >- * you can save a few bytes by making ALIGN_TYPE smaller. >+ * you can save a few bytes by making ALIGN_SIZE smaller. > * The only place I know of where this will NOT work is certain Macintosh > * 680x0 compilers that define double as a 10-byte IEEE extended float. > * Doing 10-byte alignment is counterproductive because longwords won't be >- * aligned well. Put "#define ALIGN_TYPE long" in jconfig.h if you have >+ * aligned well. Put "#define ALIGN_SIZE 4" in jconfig.h if you have > * such a compiler. > */ > >-#ifndef ALIGN_TYPE /* so can override from jconfig.h */ >-#define ALIGN_TYPE double >+#ifndef ALIGN_SIZE /* so can override from jconfig.h */ >+#ifndef WITH_SIMD >+#define ALIGN_SIZE SIZEOF(double) >+#else >+#define ALIGN_SIZE 16 /* Most SIMD implementations require this */ > #endif >- >+#endif > > /* > * We allocate objects from "pools", where each pool is gotten with a single > * request to jpeg_get_small() or jpeg_get_large(). There is no per-object > * overhead within a pool, except for alignment padding. Each pool has a > * header with a link to the next pool of the same class. > * Small and large pool headers are identical except that the latter's > * link pointer must be FAR on 80x86 machines. >- * Notice that the "real" header fields are union'ed with a dummy ALIGN_TYPE >- * field. This forces the compiler to make SIZEOF(small_pool_hdr) a multiple >- * of the alignment requirement of ALIGN_TYPE. > */ > >-typedef union small_pool_struct * small_pool_ptr; >+typedef struct small_pool_struct * small_pool_ptr; > >-typedef union small_pool_struct { >- struct { >- small_pool_ptr next; /* next in list of pools */ >- size_t bytes_used; /* how many bytes already used within pool */ >- size_t bytes_left; /* bytes still available in this pool */ >- } hdr; >- ALIGN_TYPE dummy; /* included in union to ensure alignment */ >+typedef struct small_pool_struct { >+ small_pool_ptr next; /* next in list of pools */ >+ size_t bytes_used; /* how many bytes already used within pool */ >+ size_t bytes_left; /* bytes still available in this pool */ > } small_pool_hdr; > >-typedef union large_pool_struct FAR * large_pool_ptr; >+typedef struct large_pool_struct FAR * large_pool_ptr; > >-typedef union large_pool_struct { >- struct { >- large_pool_ptr next; /* next in list of pools */ >- size_t bytes_used; /* how many bytes already used within pool */ >- size_t bytes_left; /* bytes still available in this pool */ >- } hdr; >- ALIGN_TYPE dummy; /* included in union to ensure alignment */ >+typedef struct large_pool_struct { >+ large_pool_ptr next; /* next in list of pools */ >+ size_t bytes_used; /* how many bytes already used within pool */ >+ size_t bytes_left; /* bytes still available in this pool */ > } large_pool_hdr; > >- > /* > * Here is the full definition of a memory manager object. > */ > > typedef struct { > struct jpeg_memory_mgr pub; /* public fields */ > > /* Each pool identifier (lifetime class) names a linked list of pools. */ >@@ -124,17 +117,17 @@ typedef struct { > * linked list is necessary (for each datatype). Note that the virtual > * array control blocks being linked together are actually stored somewhere > * in the small-pool list. > */ > jvirt_sarray_ptr virt_sarray_list; > jvirt_barray_ptr virt_barray_list; > > /* This counts total space obtained from jpeg_get_small/large */ >- long total_space_allocated; >+ size_t total_space_allocated; > > /* alloc_sarray and alloc_barray set this value for use by virtual > * array routines. > */ > JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */ > } my_memory_mgr; > > typedef my_memory_mgr * my_mem_ptr; >@@ -192,26 +185,26 @@ print_mem_stats (j_common_ptr cinfo, int > /* Since this is only a debugging stub, we can cheat a little by using > * fprintf directly rather than going through the trace message code. > * This is helpful because message parm array can't handle longs. > */ > fprintf(stderr, "Freeing pool %d, total space = %ld\n", > pool_id, mem->total_space_allocated); > > for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; >- lhdr_ptr = lhdr_ptr->hdr.next) { >+ lhdr_ptr = lhdr_ptr->next) { > fprintf(stderr, " Large chunk used %ld\n", >- (long) lhdr_ptr->hdr.bytes_used); >+ (long) lhdr_ptr->bytes_used); > } > > for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; >- shdr_ptr = shdr_ptr->hdr.next) { >+ shdr_ptr = shdr_ptr->next) { > fprintf(stderr, " Small chunk used %ld free %ld\n", >- (long) shdr_ptr->hdr.bytes_used, >- (long) shdr_ptr->hdr.bytes_left); >+ (long) shdr_ptr->bytes_used, >+ (long) shdr_ptr->bytes_left); > } > } > > #endif /* MEM_STATS */ > > > LOCAL(void) > out_of_memory (j_common_ptr cinfo, int which) >@@ -231,16 +224,20 @@ out_of_memory (j_common_ptr cinfo, int w > * For these, we use pooled storage. When a new pool must be created, > * we try to get enough space for the current request plus a "slop" factor, > * where the slop will be the amount of leftover space in the new pool. > * The speed vs. space tradeoff is largely determined by the slop values. > * A different slop value is provided for each pool class (lifetime), > * and we also distinguish the first pool of a class from later ones. > * NOTE: the values given work fairly well on both 16- and 32-bit-int > * machines, but may be too small if longs are 64 bits or more. >+ * >+ * Since we do not know what alignment malloc() gives us, we have to >+ * allocate ALIGN_SIZE-1 extra space per pool to have room for alignment >+ * adjustment. > */ > > static const size_t first_pool_slop[JPOOL_NUMPOOLS] = > { > 1600, /* first PERMANENT pool */ > 16000 /* first IMAGE pool */ > }; > >@@ -255,43 +252,46 @@ static const size_t extra_pool_slop[JPOO > > METHODDEF(void *) > alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) > /* Allocate a "small" object */ > { > my_mem_ptr mem = (my_mem_ptr) cinfo->mem; > small_pool_ptr hdr_ptr, prev_hdr_ptr; > char * data_ptr; >- size_t odd_bytes, min_request, slop; >+ size_t min_request, slop; >+ >+ /* >+ * Round up the requested size to a multiple of ALIGN_SIZE in order >+ * to assure alignment for the next object allocated in the same pool >+ * and so that algorithms can straddle outside the proper area up >+ * to the next alignment. >+ */ >+ sizeofobject = jround_up(sizeofobject, ALIGN_SIZE); > > /* Check for unsatisfiable request (do now to ensure no overflow below) */ >- if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr))) >+ if ((SIZEOF(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK) > out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ > >- /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ >- odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); >- if (odd_bytes > 0) >- sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; >- > /* See if space is available in any existing pool */ > if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) > ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ > prev_hdr_ptr = NULL; > hdr_ptr = mem->small_list[pool_id]; > while (hdr_ptr != NULL) { >- if (hdr_ptr->hdr.bytes_left >= sizeofobject) >+ if (hdr_ptr->bytes_left >= sizeofobject) > break; /* found pool with enough space */ > prev_hdr_ptr = hdr_ptr; >- hdr_ptr = hdr_ptr->hdr.next; >+ hdr_ptr = hdr_ptr->next; > } > > /* Time to make a new pool? */ > if (hdr_ptr == NULL) { > /* min_request is what we need now, slop is what will be leftover */ >- min_request = sizeofobject + SIZEOF(small_pool_hdr); >+ min_request = SIZEOF(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1; > if (prev_hdr_ptr == NULL) /* first pool in class? */ > slop = first_pool_slop[pool_id]; > else > slop = extra_pool_slop[pool_id]; > /* Don't ask for more than MAX_ALLOC_CHUNK */ > if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request)) > slop = (size_t) (MAX_ALLOC_CHUNK-min_request); > /* Try to get space, if fail reduce slop and try again */ >@@ -300,30 +300,33 @@ alloc_small (j_common_ptr cinfo, int poo > if (hdr_ptr != NULL) > break; > slop /= 2; > if (slop < MIN_SLOP) /* give up when it gets real small */ > out_of_memory(cinfo, 2); /* jpeg_get_small failed */ > } > mem->total_space_allocated += min_request + slop; > /* Success, initialize the new pool header and add to end of list */ >- hdr_ptr->hdr.next = NULL; >- hdr_ptr->hdr.bytes_used = 0; >- hdr_ptr->hdr.bytes_left = sizeofobject + slop; >+ hdr_ptr->next = NULL; >+ hdr_ptr->bytes_used = 0; >+ hdr_ptr->bytes_left = sizeofobject + slop; > if (prev_hdr_ptr == NULL) /* first pool in class? */ > mem->small_list[pool_id] = hdr_ptr; > else >- prev_hdr_ptr->hdr.next = hdr_ptr; >+ prev_hdr_ptr->next = hdr_ptr; > } > > /* OK, allocate the object from the current pool */ >- data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */ >- data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */ >- hdr_ptr->hdr.bytes_used += sizeofobject; >- hdr_ptr->hdr.bytes_left -= sizeofobject; >+ data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */ >+ data_ptr += SIZEOF(small_pool_hdr); /* ...by skipping the header... */ >+ if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */ >+ data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE; >+ data_ptr += hdr_ptr->bytes_used; /* point to place for object */ >+ hdr_ptr->bytes_used += sizeofobject; >+ hdr_ptr->bytes_left -= sizeofobject; > > return (void *) data_ptr; > } > > > /* > * Allocation of "large" objects. > * >@@ -339,74 +342,91 @@ alloc_small (j_common_ptr cinfo, int poo > */ > > METHODDEF(void FAR *) > alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) > /* Allocate a "large" object */ > { > my_mem_ptr mem = (my_mem_ptr) cinfo->mem; > large_pool_ptr hdr_ptr; >- size_t odd_bytes; >+ char FAR * data_ptr; >+ >+ /* >+ * Round up the requested size to a multiple of ALIGN_SIZE so that >+ * algorithms can straddle outside the proper area up to the next >+ * alignment. >+ */ >+ sizeofobject = jround_up(sizeofobject, ALIGN_SIZE); > > /* Check for unsatisfiable request (do now to ensure no overflow below) */ >- if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr))) >+ if ((SIZEOF(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK) > out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ > >- /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ >- odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); >- if (odd_bytes > 0) >- sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; >- > /* Always make a new pool */ > if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) > ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ > > hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + >- SIZEOF(large_pool_hdr)); >+ SIZEOF(large_pool_hdr) + >+ ALIGN_SIZE - 1); > if (hdr_ptr == NULL) > out_of_memory(cinfo, 4); /* jpeg_get_large failed */ >- mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); >+ mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr) + ALIGN_SIZE - 1; > > /* Success, initialize the new pool header and add to list */ >- hdr_ptr->hdr.next = mem->large_list[pool_id]; >+ hdr_ptr->next = mem->large_list[pool_id]; > /* We maintain space counts in each pool header for statistical purposes, > * even though they are not needed for allocation. > */ >- hdr_ptr->hdr.bytes_used = sizeofobject; >- hdr_ptr->hdr.bytes_left = 0; >+ hdr_ptr->bytes_used = sizeofobject; >+ hdr_ptr->bytes_left = 0; > mem->large_list[pool_id] = hdr_ptr; > >- return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */ >+ data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */ >+ data_ptr += SIZEOF(small_pool_hdr); /* ...by skipping the header... */ >+ if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */ >+ data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE; >+ >+ return (void FAR *) data_ptr; > } > > > /* > * Creation of 2-D sample arrays. > * The pointers are in near heap, the samples themselves in FAR heap. > * > * To minimize allocation overhead and to allow I/O of large contiguous > * blocks, we allocate the sample rows in groups of as many rows as possible > * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request. > * NB: the virtual array control routines, later in this file, know about > * this chunking of rows. The rowsperchunk value is left in the mem manager > * object so that it can be saved away if this sarray is the workspace for > * a virtual array. >+ * >+ * Since we are often upsampling with a factor 2, we align the size (not >+ * the start) to 2 * ALIGN_SIZE so that the upsampling routines don't have >+ * to be as careful about size. > */ > > METHODDEF(JSAMPARRAY) > alloc_sarray (j_common_ptr cinfo, int pool_id, > JDIMENSION samplesperrow, JDIMENSION numrows) > /* Allocate a 2-D sample array */ > { > my_mem_ptr mem = (my_mem_ptr) cinfo->mem; > JSAMPARRAY result; > JSAMPROW workspace; > JDIMENSION rowsperchunk, currow, i; > long ltemp; > >+ /* Make sure each row is properly aligned */ >+ if ((ALIGN_SIZE % SIZEOF(JSAMPLE)) != 0) >+ out_of_memory(cinfo, 5); /* safety check */ >+ samplesperrow = (JDIMENSION)jround_up(samplesperrow, (2 * ALIGN_SIZE) / SIZEOF(JSAMPLE)); >+ > /* Calculate max # of rows allowed in one allocation chunk */ > ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / > ((long) samplesperrow * SIZEOF(JSAMPLE)); > if (ltemp <= 0) > ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); > if (ltemp < (long) numrows) > rowsperchunk = (JDIMENSION) ltemp; > else >@@ -445,16 +465,20 @@ alloc_barray (j_common_ptr cinfo, int po > /* Allocate a 2-D coefficient-block array */ > { > my_mem_ptr mem = (my_mem_ptr) cinfo->mem; > JBLOCKARRAY result; > JBLOCKROW workspace; > JDIMENSION rowsperchunk, currow, i; > long ltemp; > >+ /* Make sure each row is properly aligned */ >+ if ((SIZEOF(JBLOCK) % ALIGN_SIZE) != 0) >+ out_of_memory(cinfo, 6); /* safety check */ >+ > /* Calculate max # of rows allowed in one allocation chunk */ > ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / > ((long) blocksperrow * SIZEOF(JBLOCK)); > if (ltemp <= 0) > ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); > if (ltemp < (long) numrows) > rowsperchunk = (JDIMENSION) ltemp; > else >@@ -579,18 +603,18 @@ request_virt_barray (j_common_ptr cinfo, > } > > > METHODDEF(void) > realize_virt_arrays (j_common_ptr cinfo) > /* Allocate the in-memory buffers for any unrealized virtual arrays */ > { > my_mem_ptr mem = (my_mem_ptr) cinfo->mem; >- long space_per_minheight, maximum_space, avail_mem; >- long minheights, max_minheights; >+ size_t space_per_minheight, maximum_space, avail_mem; >+ size_t minheights, max_minheights; > jvirt_sarray_ptr sptr; > jvirt_barray_ptr bptr; > > /* Compute the minimum space needed (maxaccess rows in each buffer) > * and the maximum space needed (full image height in each buffer). > * These may be of use to the system-dependent jpeg_mem_available routine. > */ > space_per_minheight = 0; >@@ -963,33 +987,33 @@ free_pool (j_common_ptr cinfo, int pool_ > mem->virt_barray_list = NULL; > } > > /* Release large objects */ > lhdr_ptr = mem->large_list[pool_id]; > mem->large_list[pool_id] = NULL; > > while (lhdr_ptr != NULL) { >- large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next; >- space_freed = lhdr_ptr->hdr.bytes_used + >- lhdr_ptr->hdr.bytes_left + >+ large_pool_ptr next_lhdr_ptr = lhdr_ptr->next; >+ space_freed = lhdr_ptr->bytes_used + >+ lhdr_ptr->bytes_left + > SIZEOF(large_pool_hdr); > jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); > mem->total_space_allocated -= space_freed; > lhdr_ptr = next_lhdr_ptr; > } > > /* Release small objects */ > shdr_ptr = mem->small_list[pool_id]; > mem->small_list[pool_id] = NULL; > > while (shdr_ptr != NULL) { >- small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next; >- space_freed = shdr_ptr->hdr.bytes_used + >- shdr_ptr->hdr.bytes_left + >+ small_pool_ptr next_shdr_ptr = shdr_ptr->next; >+ space_freed = shdr_ptr->bytes_used + >+ shdr_ptr->bytes_left + > SIZEOF(small_pool_hdr); > jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); > mem->total_space_allocated -= space_freed; > shdr_ptr = next_shdr_ptr; > } > } > > >@@ -1036,26 +1060,26 @@ jinit_memory_mgr (j_common_ptr cinfo) > > /* Check for configuration errors. > * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably > * doesn't reflect any real hardware alignment requirement. > * The test is a little tricky: for X>0, X and X-1 have no one-bits > * in common if and only if X is a power of 2, ie has only one one-bit. > * Some compilers may give an "unreachable code" warning here; ignore it. > */ >- if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0) >+ if ((ALIGN_SIZE & (ALIGN_SIZE-1)) != 0) > ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE); > /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be >- * a multiple of SIZEOF(ALIGN_TYPE). >+ * a multiple of ALIGN_SIZE. > * Again, an "unreachable code" warning may be ignored here. > * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. > */ > test_mac = (size_t) MAX_ALLOC_CHUNK; > if ((long) test_mac != MAX_ALLOC_CHUNK || >- (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) >+ (MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0) > ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); > > max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ > > /* Attempt to allocate memory manager's control block */ > mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); > > if (mem == NULL) { >diff --git a/jpeg/jmemnobs.c b/modules/libjpeg-turbo/jmemnobs.c >rename from jpeg/jmemnobs.c >rename to modules/libjpeg-turbo/jmemnobs.c >--- a/jpeg/jmemnobs.c >+++ b/modules/libjpeg-turbo/jmemnobs.c >@@ -64,19 +64,19 @@ jpeg_free_large (j_common_ptr cinfo, voi > } > > > /* > * This routine computes the total memory space available for allocation. > * Here we always say, "we got all you want bud!" > */ > >-GLOBAL(long) >-jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, >- long max_bytes_needed, long already_allocated) >+GLOBAL(size_t) >+jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed, >+ size_t max_bytes_needed, size_t already_allocated) > { > return max_bytes_needed; > } > > > /* > * Backing store (temporary file) management. > * Since jpeg_mem_available always promised the moon, >diff --git a/jpeg/jmemsys.h b/modules/libjpeg-turbo/jmemsys.h >rename from jpeg/jmemsys.h >rename to modules/libjpeg-turbo/jmemsys.h >--- a/jpeg/jmemsys.h >+++ b/modules/libjpeg-turbo/jmemsys.h >@@ -95,20 +95,20 @@ EXTERN(void) jpeg_free_large JPP((j_comm > * (that'll just lead to more backing-store access than is really necessary). > * However, an overestimate will lead to failure. Hence it's wise to subtract > * a slop factor from the true available space. 5% should be enough. > * > * On machines with lots of virtual memory, any large constant may be returned. > * Conversely, zero may be returned to always use the minimum amount of memory. > */ > >-EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, >- long min_bytes_needed, >- long max_bytes_needed, >- long already_allocated)); >+EXTERN(size_t) jpeg_mem_available JPP((j_common_ptr cinfo, >+ size_t min_bytes_needed, >+ size_t max_bytes_needed, >+ size_t already_allocated)); > > > /* > * This structure holds whatever state is needed to access a single > * backing-store object. The read/write/close method pointers are called > * by jmemmgr.c to manipulate the backing-store object; all other fields > * are private to the system-dependent backing store routines. > */ >diff --git a/jpeg/jmorecfg.h b/modules/libjpeg-turbo/jmorecfg.h >rename from jpeg/jmorecfg.h >rename to modules/libjpeg-turbo/jmorecfg.h >--- a/jpeg/jmorecfg.h >+++ b/modules/libjpeg-turbo/jmorecfg.h >@@ -1,27 +1,22 @@ > /* > * jmorecfg.h > * > * Copyright (C) 1991-1997, Thomas G. Lane. >+ * Copyright (C) 2009, D. R. Commander. > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains additional configuration options that customize the > * JPEG software for special applications or support machine-dependent > * optimizations. Most users will not need to touch this file. > */ > >-/* >- * This file has been modified for the Mozilla/Netscape environment. >- * Modifications are distributed under the mozilla.org tri-license and are >- * Copyright (C) 1998 Netscape Communications Corporation. All Rights >- * Reserved. See http://www.mozilla.org/MPL/ >- */ >- >+#include "prtypes.h" > > /* > * Define BITS_IN_JSAMPLE as either > * 8 for 8-bit sample values (the usual setting) > * 12 for 12-bit sample values > * Only 8 and 12 are legal data precisions for lossy JPEG according to the > * JPEG standard, and the IJG code does not support anything else! > * We do not support run-time selection of data precision, sorry. >@@ -64,21 +59,21 @@ > #ifdef HAVE_UNSIGNED_CHAR > > typedef unsigned char JSAMPLE; > #define GETJSAMPLE(value) ((int) (value)) > > #else /* not HAVE_UNSIGNED_CHAR */ > > typedef char JSAMPLE; >-#ifdef CHAR_IS_UNSIGNED >+#ifdef __CHAR_UNSIGNED__ > #define GETJSAMPLE(value) ((int) (value)) > #else > #define GETJSAMPLE(value) ((int) (value) & 0xFF) >-#endif /* CHAR_IS_UNSIGNED */ >+#endif /* __CHAR_UNSIGNED__ */ > > #endif /* HAVE_UNSIGNED_CHAR */ > > #define MAXJSAMPLE 255 > #define CENTERJSAMPLE 128 > > #endif /* BITS_IN_JSAMPLE == 8 */ > >@@ -100,100 +95,62 @@ typedef short JSAMPLE; > /* Representation of a DCT frequency coefficient. > * This should be a signed value of at least 16 bits; "short" is usually OK. > * Again, we allocate large arrays of these, but you can change to int > * if you have memory to burn and "short" is really slow. > */ > > typedef short JCOEF; > >-/* Defines for MMX/SSE2 support. */ >- >-#if defined(XP_WIN32) && defined(_M_IX86) && !defined(__GNUC__) >-#define HAVE_MMX_INTEL_MNEMONICS >- >-/* SSE2 code appears broken for some cpus (bug 247437) */ >-#define HAVE_SSE2_INTEL_MNEMONICS >-#define HAVE_SSE2_INTRINSICS >-#endif >- >-#if defined(__GNUC__) && defined(__i386__) >-#if defined(XP_MACOSX) >-#define HAVE_SSE2_INTRINSICS >-#endif /* ! XP_MACOSX */ >-#endif /* ! GNUC && i386 */ >- >-/* Add support for other platforms here */ >- > > /* Compressed datastreams are represented as arrays of JOCTET. > * These must be EXACTLY 8 bits wide, at least once they are written to > * external storage. Note that when using the stdio data source/destination > * managers, this is also the data type passed to fread/fwrite. > */ > > #ifdef HAVE_UNSIGNED_CHAR > > typedef unsigned char JOCTET; > #define GETJOCTET(value) (value) > > #else /* not HAVE_UNSIGNED_CHAR */ > > typedef char JOCTET; >-#ifdef CHAR_IS_UNSIGNED >+#ifdef __CHAR_UNSIGNED__ > #define GETJOCTET(value) (value) > #else > #define GETJOCTET(value) ((value) & 0xFF) >-#endif /* CHAR_IS_UNSIGNED */ >+#endif /* __CHAR_UNSIGNED__ */ > > #endif /* HAVE_UNSIGNED_CHAR */ > > > /* These typedefs are used for various table entries and so forth. > * They must be at least as wide as specified; but making them too big > * won't cost a huge amount of memory, so we don't provide special > * extraction code like we did for JSAMPLE. (In other words, these > * typedefs live at a different point on the speed/space tradeoff curve.) > */ > > /* UINT8 must hold at least the values 0..255. */ > >-#ifdef HAVE_UNSIGNED_CHAR >-typedef unsigned char UINT8; >-#else /* not HAVE_UNSIGNED_CHAR */ >-#ifdef CHAR_IS_UNSIGNED >-typedef char UINT8; >-#else /* not CHAR_IS_UNSIGNED */ >-typedef short UINT8; >-#endif /* CHAR_IS_UNSIGNED */ >-#endif /* HAVE_UNSIGNED_CHAR */ >+typedef PRUint8 UINT8; > > /* UINT16 must hold at least the values 0..65535. */ > >-#ifdef HAVE_UNSIGNED_SHORT >-typedef unsigned short UINT16; >-#else /* not HAVE_UNSIGNED_SHORT */ >-typedef unsigned int UINT16; >-#endif /* HAVE_UNSIGNED_SHORT */ >+typedef PRUint16 UINT16; > > /* INT16 must hold at least the values -32768..32767. */ > >-#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ >-typedef short INT16; >-#endif >+typedef PRInt16 INT16; > > /* INT32 must hold at least signed 32-bit values. */ > >-#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ >-#ifndef _BASETSD_H_ /* basetsd.h correctly defines INT32 */ >-#ifndef _BASETSD_H >-typedef long INT32; >-#endif >-#endif >-#endif >+typedef PRInt32 INT32; > > /* Datatype used for image dimensions. The JPEG standard only supports > * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore > * "unsigned int" is sufficient on all machines. However, if you need to > * handle larger images and you don't mind deviating from the spec, you > * can change this datatype. > */ > >@@ -204,31 +161,24 @@ typedef unsigned int JDIMENSION; > > /* These macros are used in all function definitions and extern declarations. > * You could modify them if you need to change function linkage conventions; > * in particular, you'll need to do that to make the library a Windows DLL. > * Another application is to make all functions global for use with debuggers > * or code profilers that require it. > */ > >-/* Mozilla mod: make external functions be DLL-able via JRI_PUBLIC_API(), >- * and supply extern "C" for C++ users of the C-compiled IJG library. >- * (Well, not anymore, but there's still a modification here.) >- */ >-#include "prtypes.h" >- > /* a function called through method pointers: */ > #define METHODDEF(type) static type > /* a function used only in its module: */ > #define LOCAL(type) static type >- >-PR_BEGIN_EXTERN_C >-#define GLOBAL(type) type >-#define EXTERN(type) extern type >-PR_END_EXTERN_C >+/* a function referenced thru EXTERNs: */ >+#define GLOBAL(type) type >+/* a reference to a GLOBAL function: */ >+#define EXTERN(type) extern type > > > /* This macro is used to declare a "method", that is, a function pointer. > * We want to supply prototype parameters if the compiler can cope. > * Note that the arglist parameter must be parenthesized! > * Again, you can customize this if you need special linkage keywords. > */ > >@@ -240,46 +190,32 @@ PR_END_EXTERN_C > > > /* Here is the pseudo-keyword for declaring pointers that must be "far" > * on 80x86 machines. Most of the specialized coding for 80x86 is handled > * by just saying "FAR *" where such a pointer is needed. In a few places > * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. > */ > >-#ifndef FAR > #ifdef NEED_FAR_POINTERS > #define FAR far > #else > #define FAR > #endif >-#endif > > > /* > * On a few systems, type boolean and/or its values FALSE, TRUE may appear > * in standard header files. Or you may have conflicts with application- > * specific header files that you want to include together with these files. > * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. > */ > >-/* Mozilla mod: IJG distribution makes boolean = int, but on Windows >- * it's far safer to define boolean = unsigned char. Easier to switch >- * than fight. >- */ >- >-/* For some reason, on SunOS 5.3 HAVE_BOOLEAN gets defined when using >- * gcc, but boolean doesn't. Even if you use -UHAVE_BOOLEAN, it still >- * gets reset somewhere. >- */ >-#if defined(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES) && defined(HAVE_BOOLEAN) >-#undef HAVE_BOOLEAN >-#endif > #ifndef HAVE_BOOLEAN >-typedef unsigned char boolean; >+typedef int boolean; > #endif > #ifndef FALSE /* in case these macros already exist */ > #define FALSE 0 /* values of boolean */ > #endif > #ifndef TRUE > #define TRUE 1 > #endif > >@@ -301,61 +237,52 @@ typedef unsigned char boolean; > /* > * These defines indicate whether to include various optional functions. > * Undefining some of these symbols will produce a smaller but less capable > * library. Note that you can leave certain source files out of the > * compilation/linking process if you've #undef'd the corresponding symbols. > * (You may HAVE to do that if your compiler doesn't like null source files.) > */ > >-/* >- * Mozilla mods here: undef some features not actually used by the browser. >- * This reduces object code size and more importantly allows us to compile >- * even with broken compilers that crash when fed certain modules of the >- * IJG sources. Currently we undef: >- * DCT_FLOAT_SUPPORTED INPUT_SMOOTHING_SUPPORTED IDCT_SCALING_SUPPORTED >- * QUANT_1PASS_SUPPORTED QUANT_2PASS_SUPPORTED >- */ >- > /* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ > > /* Capability options common to encoder and decoder: */ > > #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ >-#undef DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ >-#undef DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ >+#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ >+#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ > > /* Encoder capability options: */ > > #undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ > #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ > #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ > #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ > /* Note: if you selected 12-bit data precision, it is dangerous to turn off > * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit > * precision, so jchuff.c normally uses entropy optimization to compute > * usable tables for higher precision. If you don't want to do optimization, > * you'll have to supply different default Huffman tables. > * The exact same statements apply for progressive JPEG: the default tables > * don't work for progressive mode. (This may get fixed, however.) > */ >-#undef INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ >+#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ > > /* Decoder capability options: */ > > #undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ > #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ > #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ > #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ > #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ >-#undef IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ >+#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ > #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ > #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ >-#undef QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ >-#undef QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ >+#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ >+#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ > > /* more capability options later, no doubt */ > > > /* > * Ordering of RGB data in scanlines passed to or from the application. > * If your application wants to deal with data in the order B,G,R, just > * change these macros. You can also deal with formats such as R,G,B,X >@@ -370,50 +297,47 @@ typedef unsigned char boolean; > * can't use color quantization if you change that value. > */ > > #define RGB_RED 0 /* Offset of Red in an RGB scanline element */ > #define RGB_GREEN 1 /* Offset of Green */ > #define RGB_BLUE 2 /* Offset of Blue */ > #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ > >+#define JPEG_NUMCS 12 >+ >+static const int rgb_red[JPEG_NUMCS] = { >+ -1, -1, RGB_RED, -1, -1, -1, 0, 0, 2, 2, 3, 1 >+}; >+ >+static const int rgb_green[JPEG_NUMCS] = { >+ -1, -1, RGB_GREEN, -1, -1, -1, 1, 1, 1, 1, 2, 2 >+}; >+ >+static const int rgb_blue[JPEG_NUMCS] = { >+ -1, -1, RGB_BLUE, -1, -1, -1, 2, 2, 0, 0, 1, 3 >+}; >+ >+static const int rgb_pixelsize[JPEG_NUMCS] = { >+ -1, -1, RGB_PIXELSIZE, -1, -1, -1, 3, 4, 3, 4, 4, 4 >+}; > > /* Definitions for speed-related optimizations. */ > >- >-/* If your compiler supports inline functions, define INLINE >- * as the inline keyword; otherwise define it as empty. >- */ >- >-/* Mozilla mods here: add more ways of defining INLINE */ >- >-#ifndef INLINE >-#ifdef __GNUC__ /* for instance, GNU C knows about inline */ >-#define INLINE __inline__ >-#endif >-#if defined( __IBMC__ ) || defined (__IBMCPP__) >-#define INLINE _Inline >-#endif >-#ifndef INLINE >-#ifdef __cplusplus >-#define INLINE inline /* a C++ compiler should have it too */ >-#else >-#define INLINE /* default is to define it as empty */ >-#endif >-#endif >-#endif >- >- > /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying > * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER > * as short on such a machine. MULTIPLIER must be at least 16 bits wide. > */ > > #ifndef MULTIPLIER >-#define MULTIPLIER int16 /* type for fastest integer multiply */ >+#ifndef WITH_SIMD >+#define MULTIPLIER int /* type for fastest integer multiply */ >+#else >+#define MULTIPLIER short /* prefer 16-bit with SIMD for parellelism */ >+#endif > #endif > > > /* FAST_FLOAT should be either float or double, whichever is done faster > * by your compiler. (Note that this type is only used in the floating point > * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) > * Typically, float is faster in ANSI C compilers, while double is faster in > * pre-ANSI compilers (because they insist on converting to double anyway). >diff --git a/jpeg/jpegint.h b/modules/libjpeg-turbo/jpegint.h >rename from jpeg/jpegint.h >rename to modules/libjpeg-turbo/jpegint.h >--- a/jpeg/jpegint.h >+++ b/modules/libjpeg-turbo/jpegint.h >@@ -364,17 +364,17 @@ EXTERN(void) jinit_color_deconverter JPP > EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); > EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); > EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); > /* Memory manager initialization */ > EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); > > /* Utility routines in jutils.c */ > EXTERN(long) jdiv_round_up JPP((long a, long b)); >-EXTERN(long) jround_up JPP((long a, long b)); >+EXTERN(size_t) jround_up JPP((size_t a, size_t b)); > EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, > JSAMPARRAY output_array, int dest_row, > int num_rows, JDIMENSION num_cols)); > EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, > JDIMENSION num_blocks)); > EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); > /* Constant tables in jutils.c */ > #if 0 /* This table is not actually needed in v6a */ >diff --git a/jpeg/jpeglib.h b/modules/libjpeg-turbo/jpeglib.h >rename from jpeg/jpeglib.h >rename to modules/libjpeg-turbo/jpeglib.h >--- a/jpeg/jpeglib.h >+++ b/modules/libjpeg-turbo/jpeglib.h >@@ -1,58 +1,41 @@ > /* > * jpeglib.h > * > * Copyright (C) 1991-1998, Thomas G. Lane. >+ * Copyright (C) 2009, D. R. Commander. > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file defines the application interface for the JPEG library. > * Most applications using the library need only include this file, > * and perhaps jerror.h if they want to know the exact error codes. > */ > > #ifndef JPEGLIB_H > #define JPEGLIB_H > >-#ifdef XP_OS2 >-/* >- * On OS/2, the system will have defined RGB_* so we #undef 'em to avoid warnings >- * from jmorecfg.h. >- */ >-#ifdef RGB_RED >- #undef RGB_RED >-#endif >-#ifdef RGB_GREEN >- #undef RGB_GREEN >-#endif >-#ifdef RGB_BLUE >- #undef RGB_BLUE >-#endif >- >+#ifdef __cplusplus >+extern "C" { > #endif > > /* > * First we include the configuration files that record how this > * installation of the JPEG library is set up. jconfig.h can be > * generated automatically for many systems. jmorecfg.h contains > * manual configuration options that most people need not worry about. > */ > > #ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ > #include "jconfig.h" /* widely used configuration options */ > #endif > #include "jmorecfg.h" /* seldom changed options */ > > >-#ifdef HAVE_MMX_INTEL_MNEMONICS >- extern int MMXAvailable; >-#endif >- >- > /* Version ID for the JPEG library. > * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". > */ > > #define JPEG_LIB_VERSION 62 /* Version 6b */ > > > /* Various constants determining the sizes of things. >@@ -220,23 +203,32 @@ struct jpeg_marker_struct { > unsigned int original_length; /* # bytes of data in the file */ > unsigned int data_length; /* # bytes of data saved at data[] */ > JOCTET FAR * data; /* the data contained in the marker */ > /* the marker length word is not counted in data_length or original_length */ > }; > > /* Known color spaces. */ > >+#define JCS_EXTENSIONS 1 >+ > typedef enum { > JCS_UNKNOWN, /* error/unspecified */ > JCS_GRAYSCALE, /* monochrome */ >- JCS_RGB, /* red/green/blue */ >+ JCS_RGB, /* red/green/blue as specified by the RGB_RED, RGB_GREEN, >+ RGB_BLUE, and RGB_PIXELSIZE macros */ > JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ > JCS_CMYK, /* C/M/Y/K */ >- JCS_YCCK /* Y/Cb/Cr/K */ >+ JCS_YCCK, /* Y/Cb/Cr/K */ >+ JCS_EXT_RGB, /* red/green/blue */ >+ JCS_EXT_RGBX, /* red/green/blue/x */ >+ JCS_EXT_BGR, /* blue/green/red */ >+ JCS_EXT_BGRX, /* blue/green/red/x */ >+ JCS_EXT_XBGR, /* x/blue/green/red */ >+ JCS_EXT_XRGB /* x/red/green/blue */ > } J_COLOR_SPACE; > > /* DCT/IDCT algorithm options. */ > > typedef enum { > JDCT_ISLOW, /* slow but accurate integer algorithm */ > JDCT_IFAST, /* faster, less accurate integer method */ > JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ >@@ -896,19 +888,16 @@ typedef JMETHOD(boolean, jpeg_marker_par > #define jpeg_copy_critical_parameters jCopyCrit > #define jpeg_abort_compress jAbrtCompress > #define jpeg_abort_decompress jAbrtDecompress > #define jpeg_abort jAbort > #define jpeg_destroy jDestroy > #define jpeg_resync_to_restart jResyncRestart > #endif /* NEED_SHORT_EXTERNAL_NAMES */ > >-#ifdef __cplusplus >-extern "C" { >-#endif > > /* Default error-management setup */ > EXTERN(struct jpeg_error_mgr *) jpeg_std_error > JPP((struct jpeg_error_mgr * err)); > > /* Initialization of JPEG compression objects. > * jpeg_create_compress() and jpeg_create_decompress() are the exported > * names that applications should call. These expand to calls on >@@ -1057,19 +1046,16 @@ EXTERN(void) jpeg_abort_decompress JPP(( > */ > EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); > EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); > > /* Default restart-marker-resync procedure for use by data source modules */ > EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, > int desired)); > >-#ifdef __cplusplus >-} /* extern "C" */ >-#endif /* __cplusplus */ > > /* These marker codes are exported since applications and data source modules > * are likely to want to use them. > */ > > #define JPEG_RST0 0xD0 /* RST0 marker code */ > #define JPEG_EOI 0xD9 /* EOI marker code */ > #define JPEG_APP0 0xE0 /* APP0 marker code */ >@@ -1116,9 +1102,13 @@ struct jpeg_color_quantizer { long dummy > * to include jerror.h. > */ > > #ifdef JPEG_INTERNALS > #include "jpegint.h" /* fetch private declarations */ > #include "jerror.h" /* fetch error codes too */ > #endif > >+#ifdef __cplusplus >+} >+#endif >+ > #endif /* JPEGLIB_H */ >diff --git a/modules/libjpeg-turbo/jpegtran.1 b/modules/libjpeg-turbo/jpegtran.1 >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/jpegtran.1 >@@ -0,0 +1,238 @@ >+.TH JPEGTRAN 1 "3 August 1997" >+.SH NAME >+jpegtran \- lossless transformation of JPEG files >+.SH SYNOPSIS >+.B jpegtran >+[ >+.I options >+] >+[ >+.I filename >+] >+.LP >+.SH DESCRIPTION >+.LP >+.B jpegtran >+performs various useful transformations of JPEG files. >+It can translate the coded representation from one variant of JPEG to another, >+for example from baseline JPEG to progressive JPEG or vice versa. It can also >+perform some rearrangements of the image data, for example turning an image >+from landscape to portrait format by rotation. >+.PP >+.B jpegtran >+works by rearranging the compressed data (DCT coefficients), without >+ever fully decoding the image. Therefore, its transformations are lossless: >+there is no image degradation at all, which would not be true if you used >+.B djpeg >+followed by >+.B cjpeg >+to accomplish the same conversion. But by the same token, >+.B jpegtran >+cannot perform lossy operations such as changing the image quality. >+.PP >+.B jpegtran >+reads the named JPEG/JFIF file, or the standard input if no file is >+named, and produces a JPEG/JFIF file on the standard output. >+.SH OPTIONS >+All switch names may be abbreviated; for example, >+.B \-optimize >+may be written >+.B \-opt >+or >+.BR \-o . >+Upper and lower case are equivalent. >+British spellings are also accepted (e.g., >+.BR \-optimise ), >+though for brevity these are not mentioned below. >+.PP >+To specify the coded JPEG representation used in the output file, >+.B jpegtran >+accepts a subset of the switches recognized by >+.BR cjpeg : >+.TP >+.B \-optimize >+Perform optimization of entropy encoding parameters. >+.TP >+.B \-progressive >+Create progressive JPEG file. >+.TP >+.BI \-restart " N" >+Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is >+attached to the number. >+.TP >+.BI \-scans " file" >+Use the scan script given in the specified text file. >+.PP >+See >+.BR cjpeg (1) >+for more details about these switches. >+If you specify none of these switches, you get a plain baseline-JPEG output >+file. The quality setting and so forth are determined by the input file. >+.PP >+The image can be losslessly transformed by giving one of these switches: >+.TP >+.B \-flip horizontal >+Mirror image horizontally (left-right). >+.TP >+.B \-flip vertical >+Mirror image vertically (top-bottom). >+.TP >+.B \-rotate 90 >+Rotate image 90 degrees clockwise. >+.TP >+.B \-rotate 180 >+Rotate image 180 degrees. >+.TP >+.B \-rotate 270 >+Rotate image 270 degrees clockwise (or 90 ccw). >+.TP >+.B \-transpose >+Transpose image (across UL-to-LR axis). >+.TP >+.B \-transverse >+Transverse transpose (across UR-to-LL axis). >+.PP >+The transpose transformation has no restrictions regarding image dimensions. >+The other transformations operate rather oddly if the image dimensions are not >+a multiple of the iMCU size (usually 8 or 16 pixels), because they can only >+transform complete blocks of DCT coefficient data in the desired way. >+.PP >+.BR jpegtran 's >+default behavior when transforming an odd-size image is designed >+to preserve exact reversibility and mathematical consistency of the >+transformation set. As stated, transpose is able to flip the entire image >+area. Horizontal mirroring leaves any partial iMCU column at the right edge >+untouched, but is able to flip all rows of the image. Similarly, vertical >+mirroring leaves any partial iMCU row at the bottom edge untouched, but is >+able to flip all columns. The other transforms can be built up as sequences >+of transpose and flip operations; for consistency, their actions on edge >+pixels are defined to be the same as the end result of the corresponding >+transpose-and-flip sequence. >+.PP >+For practical use, you may prefer to discard any untransformable edge pixels >+rather than having a strange-looking strip along the right and/or bottom edges >+of a transformed image. To do this, add the >+.B \-trim >+switch: >+.TP >+.B \-trim >+Drop non-transformable edge blocks. >+.PP >+Obviously, a transformation with >+.B \-trim >+is not reversible, so strictly speaking >+.B jpegtran >+with this switch is not lossless. Also, the expected mathematical >+equivalences between the transformations no longer hold. For example, >+.B \-rot 270 -trim >+trims only the bottom edge, but >+.B \-rot 90 -trim >+followed by >+.B \-rot 180 -trim >+trims both edges. >+.PP >+Another not-strictly-lossless transformation switch is: >+.TP >+.B \-grayscale >+Force grayscale output. >+.PP >+This option discards the chrominance channels if the input image is YCbCr >+(ie, a standard color JPEG), resulting in a grayscale JPEG file. The >+luminance channel is preserved exactly, so this is a better method of reducing >+to grayscale than decompression, conversion, and recompression. This switch >+is particularly handy for fixing a monochrome picture that was mistakenly >+encoded as a color JPEG. (In such a case, the space savings from getting rid >+of the near-empty chroma channels won't be large; but the decoding time for >+a grayscale JPEG is substantially less than that for a color JPEG.) >+.PP >+.B jpegtran >+also recognizes these switches that control what to do with "extra" markers, >+such as comment blocks: >+.TP >+.B \-copy none >+Copy no extra markers from source file. This setting suppresses all >+comments and other excess baggage present in the source file. >+.TP >+.B \-copy comments >+Copy only comment markers. This setting copies comments from the source file, >+but discards any other inessential data. >+.TP >+.B \-copy all >+Copy all extra markers. This setting preserves miscellaneous markers >+found in the source file, such as JFIF thumbnails and Photoshop settings. >+In some files these extra markers can be sizable. >+.PP >+The default behavior is >+.BR "\-copy comments" . >+(Note: in IJG releases v6 and v6a, >+.B jpegtran >+always did the equivalent of >+.BR "\-copy none" .) >+.PP >+Additional switches recognized by jpegtran are: >+.TP >+.BI \-maxmemory " N" >+Set limit for amount of memory to use in processing large images. Value is >+in thousands of bytes, or millions of bytes if "M" is attached to the >+number. For example, >+.B \-max 4m >+selects 4000000 bytes. If more space is needed, temporary files will be used. >+.TP >+.BI \-outfile " name" >+Send output image to the named file, not to standard output. >+.TP >+.B \-verbose >+Enable debug printout. More >+.BR \-v 's >+give more output. Also, version information is printed at startup. >+.TP >+.B \-debug >+Same as >+.BR \-verbose . >+.SH EXAMPLES >+.LP >+This example converts a baseline JPEG file to progressive form: >+.IP >+.B jpegtran \-progressive >+.I foo.jpg >+.B > >+.I fooprog.jpg >+.PP >+This example rotates an image 90 degrees clockwise, discarding any >+unrotatable edge pixels: >+.IP >+.B jpegtran \-rot 90 -trim >+.I foo.jpg >+.B > >+.I foo90.jpg >+.SH ENVIRONMENT >+.TP >+.B JPEGMEM >+If this environment variable is set, its value is the default memory limit. >+The value is specified as described for the >+.B \-maxmemory >+switch. >+.B JPEGMEM >+overrides the default value specified when the program was compiled, and >+itself is overridden by an explicit >+.BR \-maxmemory . >+.SH SEE ALSO >+.BR cjpeg (1), >+.BR djpeg (1), >+.BR rdjpgcom (1), >+.BR wrjpgcom (1) >+.br >+Wallace, Gregory K. "The JPEG Still Picture Compression Standard", >+Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. >+.SH AUTHOR >+Independent JPEG Group >+.SH BUGS >+Arithmetic coding is not supported for legal reasons. >+.PP >+The transform options can't transform odd-size images perfectly. Use >+.B \-trim >+if you don't like the results without it. >+.PP >+The entire image is read into memory and then written out again, even in >+cases where this isn't really necessary. Expect swapping on large images, >+especially when using the more complex transform options. >diff --git a/modules/libjpeg-turbo/jpegtran.c b/modules/libjpeg-turbo/jpegtran.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/jpegtran.c >@@ -0,0 +1,504 @@ >+/* >+ * jpegtran.c >+ * >+ * Copyright (C) 1995-1997, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains a command-line user interface for JPEG transcoding. >+ * It is very similar to cjpeg.c, but provides lossless transcoding between >+ * different JPEG file formats. It also provides some lossless and sort-of- >+ * lossless transformations of JPEG data. >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+#include "transupp.h" /* Support routines for jpegtran */ >+#include "jversion.h" /* for version message */ >+ >+#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ >+#ifdef __MWERKS__ >+#include <SIOUX.h> /* Metrowerks needs this */ >+#include <console.h> /* ... and this */ >+#endif >+#ifdef THINK_C >+#include <console.h> /* Think declares it here */ >+#endif >+#endif >+ >+ >+/* >+ * Argument-parsing code. >+ * The switch parser is designed to be useful with DOS-style command line >+ * syntax, ie, intermixed switches and file names, where only the switches >+ * to the left of a given file name affect processing of that file. >+ * The main program in this file doesn't actually use this capability... >+ */ >+ >+ >+static const char * progname; /* program name for error messages */ >+static char * outfilename; /* for -outfile switch */ >+static JCOPY_OPTION copyoption; /* -copy switch */ >+static jpeg_transform_info transformoption; /* image transformation options */ >+ >+ >+LOCAL(void) >+usage (void) >+/* complain about bad command line */ >+{ >+ fprintf(stderr, "usage: %s [switches] ", progname); >+#ifdef TWO_FILE_COMMANDLINE >+ fprintf(stderr, "inputfile outputfile\n"); >+#else >+ fprintf(stderr, "[inputfile]\n"); >+#endif >+ >+ fprintf(stderr, "Switches (names may be abbreviated):\n"); >+ fprintf(stderr, " -copy none Copy no extra markers from source file\n"); >+ fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); >+ fprintf(stderr, " -copy all Copy all extra markers\n"); >+#ifdef ENTROPY_OPT_SUPPORTED >+ fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); >+#endif >+#ifdef C_PROGRESSIVE_SUPPORTED >+ fprintf(stderr, " -progressive Create progressive JPEG file\n"); >+#endif >+#if TRANSFORMS_SUPPORTED >+ fprintf(stderr, "Switches for modifying the image:\n"); >+ fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); >+ fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); >+ fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); >+ fprintf(stderr, " -transpose Transpose image\n"); >+ fprintf(stderr, " -transverse Transverse transpose image\n"); >+ fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); >+#endif /* TRANSFORMS_SUPPORTED */ >+ fprintf(stderr, "Switches for advanced users:\n"); >+ fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); >+ fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); >+ fprintf(stderr, " -outfile name Specify name for output file\n"); >+ fprintf(stderr, " -verbose or -debug Emit debug output\n"); >+ fprintf(stderr, "Switches for wizards:\n"); >+#ifdef C_ARITH_CODING_SUPPORTED >+ fprintf(stderr, " -arithmetic Use arithmetic coding\n"); >+#endif >+#ifdef C_MULTISCAN_FILES_SUPPORTED >+ fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); >+#endif >+ exit(EXIT_FAILURE); >+} >+ >+ >+LOCAL(void) >+select_transform (JXFORM_CODE transform) >+/* Silly little routine to detect multiple transform options, >+ * which we can't handle. >+ */ >+{ >+#if TRANSFORMS_SUPPORTED >+ if (transformoption.transform == JXFORM_NONE || >+ transformoption.transform == transform) { >+ transformoption.transform = transform; >+ } else { >+ fprintf(stderr, "%s: can only do one image transformation at a time\n", >+ progname); >+ usage(); >+ } >+#else >+ fprintf(stderr, "%s: sorry, image transformation was not compiled\n", >+ progname); >+ exit(EXIT_FAILURE); >+#endif >+} >+ >+ >+LOCAL(int) >+parse_switches (j_compress_ptr cinfo, int argc, char **argv, >+ int last_file_arg_seen, boolean for_real) >+/* Parse optional switches. >+ * Returns argv[] index of first file-name argument (== argc if none). >+ * Any file names with indexes <= last_file_arg_seen are ignored; >+ * they have presumably been processed in a previous iteration. >+ * (Pass 0 for last_file_arg_seen on the first or only iteration.) >+ * for_real is FALSE on the first (dummy) pass; we may skip any expensive >+ * processing. >+ */ >+{ >+ int argn; >+ char * arg; >+ boolean simple_progressive; >+ char * scansarg = NULL; /* saves -scans parm if any */ >+ >+ /* Set up default JPEG parameters. */ >+ simple_progressive = FALSE; >+ outfilename = NULL; >+ copyoption = JCOPYOPT_DEFAULT; >+ transformoption.transform = JXFORM_NONE; >+ transformoption.trim = FALSE; >+ transformoption.force_grayscale = FALSE; >+ cinfo->err->trace_level = 0; >+ >+ /* Scan command line options, adjust parameters */ >+ >+ for (argn = 1; argn < argc; argn++) { >+ arg = argv[argn]; >+ if (*arg != '-') { >+ /* Not a switch, must be a file name argument */ >+ if (argn <= last_file_arg_seen) { >+ outfilename = NULL; /* -outfile applies to just one input file */ >+ continue; /* ignore this name if previously processed */ >+ } >+ break; /* else done parsing switches */ >+ } >+ arg++; /* advance past switch marker character */ >+ >+ if (keymatch(arg, "arithmetic", 1)) { >+ /* Use arithmetic coding. */ >+#ifdef C_ARITH_CODING_SUPPORTED >+ cinfo->arith_code = TRUE; >+#else >+ fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", >+ progname); >+ exit(EXIT_FAILURE); >+#endif >+ >+ } else if (keymatch(arg, "copy", 1)) { >+ /* Select which extra markers to copy. */ >+ if (++argn >= argc) /* advance to next argument */ >+ usage(); >+ if (keymatch(argv[argn], "none", 1)) { >+ copyoption = JCOPYOPT_NONE; >+ } else if (keymatch(argv[argn], "comments", 1)) { >+ copyoption = JCOPYOPT_COMMENTS; >+ } else if (keymatch(argv[argn], "all", 1)) { >+ copyoption = JCOPYOPT_ALL; >+ } else >+ usage(); >+ >+ } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { >+ /* Enable debug printouts. */ >+ /* On first -d, print version identification */ >+ static boolean printed_version = FALSE; >+ >+ if (! printed_version) { >+ fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", >+ JVERSION, JCOPYRIGHT); >+ printed_version = TRUE; >+ } >+ cinfo->err->trace_level++; >+ >+ } else if (keymatch(arg, "flip", 1)) { >+ /* Mirror left-right or top-bottom. */ >+ if (++argn >= argc) /* advance to next argument */ >+ usage(); >+ if (keymatch(argv[argn], "horizontal", 1)) >+ select_transform(JXFORM_FLIP_H); >+ else if (keymatch(argv[argn], "vertical", 1)) >+ select_transform(JXFORM_FLIP_V); >+ else >+ usage(); >+ >+ } else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) { >+ /* Force to grayscale. */ >+#if TRANSFORMS_SUPPORTED >+ transformoption.force_grayscale = TRUE; >+#else >+ select_transform(JXFORM_NONE); /* force an error */ >+#endif >+ >+ } else if (keymatch(arg, "maxmemory", 3)) { >+ /* Maximum memory in Kb (or Mb with 'm'). */ >+ long lval; >+ char ch = 'x'; >+ >+ if (++argn >= argc) /* advance to next argument */ >+ usage(); >+ if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) >+ usage(); >+ if (ch == 'm' || ch == 'M') >+ lval *= 1000L; >+ cinfo->mem->max_memory_to_use = lval * 1000L; >+ >+ } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { >+ /* Enable entropy parm optimization. */ >+#ifdef ENTROPY_OPT_SUPPORTED >+ cinfo->optimize_coding = TRUE; >+#else >+ fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", >+ progname); >+ exit(EXIT_FAILURE); >+#endif >+ >+ } else if (keymatch(arg, "outfile", 4)) { >+ /* Set output file name. */ >+ if (++argn >= argc) /* advance to next argument */ >+ usage(); >+ outfilename = argv[argn]; /* save it away for later use */ >+ >+ } else if (keymatch(arg, "progressive", 1)) { >+ /* Select simple progressive mode. */ >+#ifdef C_PROGRESSIVE_SUPPORTED >+ simple_progressive = TRUE; >+ /* We must postpone execution until num_components is known. */ >+#else >+ fprintf(stderr, "%s: sorry, progressive output was not compiled\n", >+ progname); >+ exit(EXIT_FAILURE); >+#endif >+ >+ } else if (keymatch(arg, "restart", 1)) { >+ /* Restart interval in MCU rows (or in MCUs with 'b'). */ >+ long lval; >+ char ch = 'x'; >+ >+ if (++argn >= argc) /* advance to next argument */ >+ usage(); >+ if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) >+ usage(); >+ if (lval < 0 || lval > 65535L) >+ usage(); >+ if (ch == 'b' || ch == 'B') { >+ cinfo->restart_interval = (unsigned int) lval; >+ cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ >+ } else { >+ cinfo->restart_in_rows = (int) lval; >+ /* restart_interval will be computed during startup */ >+ } >+ >+ } else if (keymatch(arg, "rotate", 2)) { >+ /* Rotate 90, 180, or 270 degrees (measured clockwise). */ >+ if (++argn >= argc) /* advance to next argument */ >+ usage(); >+ if (keymatch(argv[argn], "90", 2)) >+ select_transform(JXFORM_ROT_90); >+ else if (keymatch(argv[argn], "180", 3)) >+ select_transform(JXFORM_ROT_180); >+ else if (keymatch(argv[argn], "270", 3)) >+ select_transform(JXFORM_ROT_270); >+ else >+ usage(); >+ >+ } else if (keymatch(arg, "scans", 1)) { >+ /* Set scan script. */ >+#ifdef C_MULTISCAN_FILES_SUPPORTED >+ if (++argn >= argc) /* advance to next argument */ >+ usage(); >+ scansarg = argv[argn]; >+ /* We must postpone reading the file in case -progressive appears. */ >+#else >+ fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", >+ progname); >+ exit(EXIT_FAILURE); >+#endif >+ >+ } else if (keymatch(arg, "transpose", 1)) { >+ /* Transpose (across UL-to-LR axis). */ >+ select_transform(JXFORM_TRANSPOSE); >+ >+ } else if (keymatch(arg, "transverse", 6)) { >+ /* Transverse transpose (across UR-to-LL axis). */ >+ select_transform(JXFORM_TRANSVERSE); >+ >+ } else if (keymatch(arg, "trim", 3)) { >+ /* Trim off any partial edge MCUs that the transform can't handle. */ >+ transformoption.trim = TRUE; >+ >+ } else { >+ usage(); /* bogus switch */ >+ } >+ } >+ >+ /* Post-switch-scanning cleanup */ >+ >+ if (for_real) { >+ >+#ifdef C_PROGRESSIVE_SUPPORTED >+ if (simple_progressive) /* process -progressive; -scans can override */ >+ jpeg_simple_progression(cinfo); >+#endif >+ >+#ifdef C_MULTISCAN_FILES_SUPPORTED >+ if (scansarg != NULL) /* process -scans if it was present */ >+ if (! read_scan_script(cinfo, scansarg)) >+ usage(); >+#endif >+ } >+ >+ return argn; /* return index of next arg (file name) */ >+} >+ >+ >+/* >+ * The main program. >+ */ >+ >+int >+main (int argc, char **argv) >+{ >+ struct jpeg_decompress_struct srcinfo; >+ struct jpeg_compress_struct dstinfo; >+ struct jpeg_error_mgr jsrcerr, jdsterr; >+#ifdef PROGRESS_REPORT >+ struct cdjpeg_progress_mgr progress; >+#endif >+ jvirt_barray_ptr * src_coef_arrays; >+ jvirt_barray_ptr * dst_coef_arrays; >+ int file_index; >+ FILE * input_file; >+ FILE * output_file; >+ >+ /* On Mac, fetch a command line. */ >+#ifdef USE_CCOMMAND >+ argc = ccommand(&argv); >+#endif >+ >+ progname = argv[0]; >+ if (progname == NULL || progname[0] == 0) >+ progname = "jpegtran"; /* in case C library doesn't provide it */ >+ >+ /* Initialize the JPEG decompression object with default error handling. */ >+ srcinfo.err = jpeg_std_error(&jsrcerr); >+ jpeg_create_decompress(&srcinfo); >+ /* Initialize the JPEG compression object with default error handling. */ >+ dstinfo.err = jpeg_std_error(&jdsterr); >+ jpeg_create_compress(&dstinfo); >+ >+ /* Now safe to enable signal catcher. >+ * Note: we assume only the decompression object will have virtual arrays. >+ */ >+#ifdef NEED_SIGNAL_CATCHER >+ enable_signal_catcher((j_common_ptr) &srcinfo); >+#endif >+ >+ /* Scan command line to find file names. >+ * It is convenient to use just one switch-parsing routine, but the switch >+ * values read here are mostly ignored; we will rescan the switches after >+ * opening the input file. Also note that most of the switches affect the >+ * destination JPEG object, so we parse into that and then copy over what >+ * needs to affects the source too. >+ */ >+ >+ file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE); >+ jsrcerr.trace_level = jdsterr.trace_level; >+ srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; >+ >+#ifdef TWO_FILE_COMMANDLINE >+ /* Must have either -outfile switch or explicit output file name */ >+ if (outfilename == NULL) { >+ if (file_index != argc-2) { >+ fprintf(stderr, "%s: must name one input and one output file\n", >+ progname); >+ usage(); >+ } >+ outfilename = argv[file_index+1]; >+ } else { >+ if (file_index != argc-1) { >+ fprintf(stderr, "%s: must name one input and one output file\n", >+ progname); >+ usage(); >+ } >+ } >+#else >+ /* Unix style: expect zero or one file name */ >+ if (file_index < argc-1) { >+ fprintf(stderr, "%s: only one input file\n", progname); >+ usage(); >+ } >+#endif /* TWO_FILE_COMMANDLINE */ >+ >+ /* Open the input file. */ >+ if (file_index < argc) { >+ if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { >+ fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); >+ exit(EXIT_FAILURE); >+ } >+ } else { >+ /* default input file is stdin */ >+ input_file = read_stdin(); >+ } >+ >+ /* Open the output file. */ >+ if (outfilename != NULL) { >+ if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { >+ fprintf(stderr, "%s: can't open %s\n", progname, outfilename); >+ exit(EXIT_FAILURE); >+ } >+ } else { >+ /* default output file is stdout */ >+ output_file = write_stdout(); >+ } >+ >+#ifdef PROGRESS_REPORT >+ start_progress_monitor((j_common_ptr) &dstinfo, &progress); >+#endif >+ >+ /* Specify data source for decompression */ >+ jpeg_stdio_src(&srcinfo, input_file); >+ >+ /* Enable saving of extra markers that we want to copy */ >+ jcopy_markers_setup(&srcinfo, copyoption); >+ >+ /* Read file header */ >+ (void) jpeg_read_header(&srcinfo, TRUE); >+ >+ /* Any space needed by a transform option must be requested before >+ * jpeg_read_coefficients so that memory allocation will be done right. >+ */ >+#if TRANSFORMS_SUPPORTED >+ jtransform_request_workspace(&srcinfo, &transformoption); >+#endif >+ >+ /* Read source file as DCT coefficients */ >+ src_coef_arrays = jpeg_read_coefficients(&srcinfo); >+ >+ /* Initialize destination compression parameters from source values */ >+ jpeg_copy_critical_parameters(&srcinfo, &dstinfo); >+ >+ /* Adjust destination parameters if required by transform options; >+ * also find out which set of coefficient arrays will hold the output. >+ */ >+#if TRANSFORMS_SUPPORTED >+ dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, >+ src_coef_arrays, >+ &transformoption); >+#else >+ dst_coef_arrays = src_coef_arrays; >+#endif >+ >+ /* Adjust default compression parameters by re-parsing the options */ >+ file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); >+ >+ /* Specify data destination for compression */ >+ jpeg_stdio_dest(&dstinfo, output_file); >+ >+ /* Start compressor (note no image data is actually written here) */ >+ jpeg_write_coefficients(&dstinfo, dst_coef_arrays); >+ >+ /* Copy to the output file any extra markers that we want to preserve */ >+ jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); >+ >+ /* Execute image transformation, if any */ >+#if TRANSFORMS_SUPPORTED >+ jtransform_execute_transformation(&srcinfo, &dstinfo, >+ src_coef_arrays, >+ &transformoption); >+#endif >+ >+ /* Finish compression and release memory */ >+ jpeg_finish_compress(&dstinfo); >+ jpeg_destroy_compress(&dstinfo); >+ (void) jpeg_finish_decompress(&srcinfo); >+ jpeg_destroy_decompress(&srcinfo); >+ >+ /* Close files, if we opened them */ >+ if (input_file != stdin) >+ fclose(input_file); >+ if (output_file != stdout) >+ fclose(output_file); >+ >+#ifdef PROGRESS_REPORT >+ end_progress_monitor((j_common_ptr) &dstinfo); >+#endif >+ >+ /* All done. */ >+ exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS); >+ return 0; /* suppress no-return-value warnings */ >+} >diff --git a/jpeg/jquant1.c b/modules/libjpeg-turbo/jquant1.c >rename from jpeg/jquant1.c >rename to modules/libjpeg-turbo/jquant1.c >--- a/jpeg/jquant1.c >+++ b/modules/libjpeg-turbo/jquant1.c >@@ -1,12 +1,13 @@ > /* > * jquant1.c > * > * Copyright (C) 1991-1996, Thomas G. Lane. >+ * Copyright (C) 2009, D. R. Commander > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains 1-pass color quantization (color mapping) routines. > * These routines provide mapping to a fixed color map using equally spaced > * color values. Optional Floyd-Steinberg or ordered dithering is available. > */ > >@@ -188,17 +189,20 @@ select_ncolors (j_decompress_ptr cinfo, > /* and fill in Ncolors[] array to indicate choice. */ > /* Return value is total number of colors (product of Ncolors[] values). */ > { > int nc = cinfo->out_color_components; /* number of color components */ > int max_colors = cinfo->desired_number_of_colors; > int total_colors, iroot, i, j; > boolean changed; > long temp; >- static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; >+ int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; >+ RGB_order[0] = rgb_green[cinfo->out_color_space]; >+ RGB_order[1] = rgb_red[cinfo->out_color_space]; >+ RGB_order[2] = rgb_blue[cinfo->out_color_space]; > > /* We can allocate at least the nc'th root of max_colors per component. */ > /* Compute floor(nc'th root of max_colors). */ > iroot = 1; > do { > iroot++; > temp = iroot; /* set temp = iroot ** nc */ > for (i = 1; i < nc; i++) >diff --git a/jpeg/jquant2.c b/modules/libjpeg-turbo/jquant2.c >rename from jpeg/jquant2.c >rename to modules/libjpeg-turbo/jquant2.c >--- a/jpeg/jquant2.c >+++ b/modules/libjpeg-turbo/jquant2.c >@@ -1,12 +1,13 @@ > /* > * jquant2.c > * > * Copyright (C) 1991-1996, Thomas G. Lane. >+ * Copyright (C) 2009, D. R. Commander. > * This file is part of the Independent JPEG Group's software. > * For conditions of distribution and use, see the accompanying README file. > * > * This file contains 2-pass color quantization (color mapping) routines. > * These routines provide selection of a custom color map for an image, > * followed by mapping of the image to that color map, with optional > * Floyd-Steinberg dithering. > * It is also possible to use just the second pass to map to an arbitrary >@@ -69,39 +70,20 @@ > * If you want to use this code to quantize a non-RGB color space, you'll > * probably need to change these scale factors. > */ > > #define R_SCALE 2 /* scale R distances by this much */ > #define G_SCALE 3 /* scale G distances by this much */ > #define B_SCALE 1 /* and B by this much */ > >-/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined >- * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B >- * and B,G,R orders. If you define some other weird order in jmorecfg.h, >- * you'll get compile errors until you extend this logic. In that case >- * you'll probably want to tweak the histogram sizes too. >- */ >- >-#if RGB_RED == 0 >-#define C0_SCALE R_SCALE >-#endif >-#if RGB_BLUE == 0 >-#define C0_SCALE B_SCALE >-#endif >-#if RGB_GREEN == 1 >-#define C1_SCALE G_SCALE >-#endif >-#if RGB_RED == 2 >-#define C2_SCALE R_SCALE >-#endif >-#if RGB_BLUE == 2 >-#define C2_SCALE B_SCALE >-#endif >- >+static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE}; >+#define C0_SCALE c_scales[rgb_red[cinfo->out_color_space]] >+#define C1_SCALE c_scales[rgb_green[cinfo->out_color_space]] >+#define C2_SCALE c_scales[rgb_blue[cinfo->out_color_space]] > > /* > * First we have the histogram data structure and routines for creating it. > * > * The number of bits of precision can be adjusted by changing these symbols. > * We recommend keeping 6 bits for G and 5 each for R and B. > * If you have plenty of memory and cycles, 6 bits all around gives marginally > * better results; if you are short of memory, 5 bits all around will save >@@ -449,25 +431,26 @@ median_cut (j_decompress_ptr cinfo, boxp > * See notes in update_box about scaling distances. > */ > c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; > c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; > c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; > /* We want to break any ties in favor of green, then red, blue last. > * This code does the right thing for R,G,B or B,G,R color orders only. > */ >-#if RGB_RED == 0 >- cmax = c1; n = 1; >- if (c0 > cmax) { cmax = c0; n = 0; } >- if (c2 > cmax) { n = 2; } >-#else >- cmax = c1; n = 1; >- if (c2 > cmax) { cmax = c2; n = 2; } >- if (c0 > cmax) { n = 0; } >-#endif >+ if (rgb_red[cinfo->out_color_space] == 0) { >+ cmax = c1; n = 1; >+ if (c0 > cmax) { cmax = c0; n = 0; } >+ if (c2 > cmax) { n = 2; } >+ } >+ else { >+ cmax = c1; n = 1; >+ if (c2 > cmax) { cmax = c2; n = 2; } >+ if (c0 > cmax) { n = 0; } >+ } > /* Choose split point along selected axis, and update box bounds. > * Current algorithm: split at halfway point. > * (Since the box has been shrunk to minimum volume, > * any split will produce two nonempty subboxes.) > * Note that lb value is max for lower box, so must be < old max. > */ > switch (n) { > case 0: >diff --git a/modules/libjpeg-turbo/jsimd.h b/modules/libjpeg-turbo/jsimd.h >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/jsimd.h >@@ -0,0 +1,89 @@ >+/* >+ * jsimd.h >+ * >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+ * >+ * Based on the x86 SIMD extension for IJG JPEG library, >+ * Copyright (C) 1999-2006, MIYASAKA Masaru. >+ * >+ */ >+ >+/* Short forms of external names for systems with brain-damaged linkers. */ >+ >+#ifdef NEED_SHORT_EXTERNAL_NAMES >+#define jsimd_can_rgb_ycc jSCanRgbYcc >+#define jsimd_can_ycc_rgb jSCanYccRgb >+#define jsimd_rgb_ycc_convert jSRgbYccConv >+#define jsimd_ycc_rgb_convert jSYccRgbConv >+#define jsimd_can_h2v2_downsample jSCanH2V2Down >+#define jsimd_can_h2v1_downsample jSCanH2V1Down >+#define jsimd_h2v2_downsample jSH2V2Down >+#define jsimd_h2v1_downsample jSH2V1Down >+#define jsimd_can_h2v2_upsample jSCanH2V2Up >+#define jsimd_can_h2v1_upsample jSCanH2V1Up >+#define jsimd_h2v2_upsample jSH2V2Up >+#define jsimd_h2v1_upsample jSH2V1Up >+#define jsimd_can_h2v2_fancy_upsample jSCanH2V2FUp >+#define jsimd_can_h2v1_fancy_upsample jSCanH2V1FUp >+#define jsimd_h2v2_fancy_upsample jSH2V2FUp >+#define jsimd_h2v1_fancy_upsample jSH2V1FUp >+#define jsimd_can_h2v2_merged_upsample jSCanH2V2MUp >+#define jsimd_can_h2v1_merged_upsample jSCanH2V1MUp >+#define jsimd_h2v2_merged_upsample jSH2V2MUp >+#define jsimd_h2v1_merged_upsample jSH2V1MUp >+#endif /* NEED_SHORT_EXTERNAL_NAMES */ >+ >+EXTERN(int) jsimd_can_rgb_ycc JPP((void)); >+EXTERN(int) jsimd_can_ycc_rgb JPP((void)); >+ >+EXTERN(void) jsimd_rgb_ycc_convert >+ JPP((j_compress_ptr cinfo, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_ycc_rgb_convert >+ JPP((j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+ >+EXTERN(int) jsimd_can_h2v2_downsample JPP((void)); >+EXTERN(int) jsimd_can_h2v1_downsample JPP((void)); >+ >+EXTERN(void) jsimd_h2v2_downsample >+ JPP((j_compress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY output_data)); >+EXTERN(void) jsimd_h2v1_downsample >+ JPP((j_compress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY output_data)); >+ >+EXTERN(int) jsimd_can_h2v2_upsample JPP((void)); >+EXTERN(int) jsimd_can_h2v1_upsample JPP((void)); >+ >+EXTERN(void) jsimd_h2v2_upsample >+ JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+EXTERN(void) jsimd_h2v1_upsample >+ JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+ >+EXTERN(int) jsimd_can_h2v2_fancy_upsample JPP((void)); >+EXTERN(int) jsimd_can_h2v1_fancy_upsample JPP((void)); >+ >+EXTERN(void) jsimd_h2v2_fancy_upsample >+ JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+EXTERN(void) jsimd_h2v1_fancy_upsample >+ JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+ >+EXTERN(int) jsimd_can_h2v2_merged_upsample JPP((void)); >+EXTERN(int) jsimd_can_h2v1_merged_upsample JPP((void)); >+ >+EXTERN(void) jsimd_h2v2_merged_upsample >+ JPP((j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, >+ JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_merged_upsample >+ JPP((j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, >+ JSAMPARRAY output_buf)); >+ >diff --git a/modules/libjpeg-turbo/jsimd_none.c b/modules/libjpeg-turbo/jsimd_none.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/jsimd_none.c >@@ -0,0 +1,299 @@ >+/* >+ * jsimd_none.c >+ * >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+ * Copyright 2009 D. R. Commander >+ * >+ * Based on the x86 SIMD extension for IJG JPEG library, >+ * Copyright (C) 1999-2006, MIYASAKA Masaru. >+ * >+ * This file contains stubs for when there is no SIMD support available. >+ */ >+ >+#define JPEG_INTERNALS >+#include "jinclude.h" >+#include "jpeglib.h" >+#include "jsimd.h" >+#include "jdct.h" >+#include "jsimddct.h" >+ >+GLOBAL(int) >+jsimd_can_rgb_ycc (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_ycc_rgb (void) >+{ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_rgb_ycc_convert (j_compress_ptr cinfo, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows) >+{ >+} >+ >+GLOBAL(void) >+jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows) >+{ >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_downsample (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_downsample (void) >+{ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY output_data) >+{ >+} >+ >+GLOBAL(void) >+jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY output_data) >+{ >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_upsample (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_upsample (void) >+{ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+} >+ >+GLOBAL(void) >+jsimd_h2v1_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_fancy_upsample (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_fancy_upsample (void) >+{ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+} >+ >+GLOBAL(void) >+jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_merged_upsample (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_merged_upsample (void) >+{ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, >+ JSAMPARRAY output_buf) >+{ >+} >+ >+GLOBAL(void) >+jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, >+ JSAMPARRAY output_buf) >+{ >+} >+ >+GLOBAL(int) >+jsimd_can_convsamp (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_convsamp_float (void) >+{ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, >+ DCTELEM * workspace) >+{ >+} >+ >+GLOBAL(void) >+jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, >+ FAST_FLOAT * workspace) >+{ >+} >+ >+GLOBAL(int) >+jsimd_can_fdct_islow (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_fdct_ifast (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_fdct_float (void) >+{ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_fdct_islow (DCTELEM * data) >+{ >+} >+ >+GLOBAL(void) >+jsimd_fdct_ifast (DCTELEM * data) >+{ >+} >+ >+GLOBAL(void) >+jsimd_fdct_float (FAST_FLOAT * data) >+{ >+} >+ >+GLOBAL(int) >+jsimd_can_quantize (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_quantize_float (void) >+{ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, >+ DCTELEM * workspace) >+{ >+} >+ >+GLOBAL(void) >+jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, >+ FAST_FLOAT * workspace) >+{ >+} >+ >+GLOBAL(int) >+jsimd_can_idct_2x2 (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_idct_4x4 (void) >+{ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+} >+ >+GLOBAL(void) >+jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+} >+ >+GLOBAL(int) >+jsimd_can_idct_islow (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_idct_ifast (void) >+{ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_idct_float (void) >+{ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+} >+ >+GLOBAL(void) >+jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+} >+ >+GLOBAL(void) >+jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+} >+ >diff --git a/modules/libjpeg-turbo/jsimddct.h b/modules/libjpeg-turbo/jsimddct.h >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/jsimddct.h >@@ -0,0 +1,101 @@ >+/* >+ * jsimddct.h >+ * >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+ * >+ * Based on the x86 SIMD extension for IJG JPEG library, >+ * Copyright (C) 1999-2006, MIYASAKA Masaru. >+ * >+ */ >+ >+/* Short forms of external names for systems with brain-damaged linkers. */ >+ >+#ifdef NEED_SHORT_EXTERNAL_NAMES >+#define jsimd_can_convsamp jSCanConv >+#define jsimd_can_convsamp_float jSCanConvF >+#define jsimd_convsamp jSConv >+#define jsimd_convsamp_float jSConvF >+#define jsimd_can_fdct_islow jSCanFDCTIS >+#define jsimd_can_fdct_ifast jSCanFDCTIF >+#define jsimd_can_fdct_float jSCanFDCTFl >+#define jsimd_fdct_islow jSFDCTIS >+#define jsimd_fdct_ifast jSFDCTIF >+#define jsimd_fdct_float jSFDCTFl >+#define jsimd_can_quantize jSCanQuant >+#define jsimd_can_quantize_float jSCanQuantF >+#define jsimd_quantize jSQuant >+#define jsimd_quantize_float jSQuantF >+#define jsimd_can_idct_2x2 jSCanIDCT22 >+#define jsimd_can_idct_4x4 jSCanIDCT44 >+#define jsimd_idct_2x2 jSIDCT22 >+#define jsimd_idct_4x4 jSIDCT44 >+#define jsimd_can_idct_islow jSCanIDCTIS >+#define jsimd_can_idct_ifast jSCanIDCTIF >+#define jsimd_can_idct_float jSCanIDCTFl >+#define jsimd_idct_islow jSIDCTIS >+#define jsimd_idct_ifast jSIDCTIF >+#define jsimd_idct_float jSIDCTFl >+#endif /* NEED_SHORT_EXTERNAL_NAMES */ >+ >+EXTERN(int) jsimd_can_convsamp JPP((void)); >+EXTERN(int) jsimd_can_convsamp_float JPP((void)); >+ >+EXTERN(void) jsimd_convsamp JPP((JSAMPARRAY sample_data, >+ JDIMENSION start_col, >+ DCTELEM * workspace)); >+EXTERN(void) jsimd_convsamp_float JPP((JSAMPARRAY sample_data, >+ JDIMENSION start_col, >+ FAST_FLOAT * workspace)); >+ >+EXTERN(int) jsimd_can_fdct_islow JPP((void)); >+EXTERN(int) jsimd_can_fdct_ifast JPP((void)); >+EXTERN(int) jsimd_can_fdct_float JPP((void)); >+ >+EXTERN(void) jsimd_fdct_islow JPP((DCTELEM * data)); >+EXTERN(void) jsimd_fdct_ifast JPP((DCTELEM * data)); >+EXTERN(void) jsimd_fdct_float JPP((FAST_FLOAT * data)); >+ >+EXTERN(int) jsimd_can_quantize JPP((void)); >+EXTERN(int) jsimd_can_quantize_float JPP((void)); >+ >+EXTERN(void) jsimd_quantize JPP((JCOEFPTR coef_block, >+ DCTELEM * divisors, >+ DCTELEM * workspace)); >+EXTERN(void) jsimd_quantize_float JPP((JCOEFPTR coef_block, >+ FAST_FLOAT * divisors, >+ FAST_FLOAT * workspace)); >+ >+EXTERN(int) jsimd_can_idct_2x2 JPP((void)); >+EXTERN(int) jsimd_can_idct_4x4 JPP((void)); >+ >+EXTERN(void) jsimd_idct_2x2 JPP((j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+EXTERN(void) jsimd_idct_4x4 JPP((j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+ >+EXTERN(int) jsimd_can_idct_islow JPP((void)); >+EXTERN(int) jsimd_can_idct_ifast JPP((void)); >+EXTERN(int) jsimd_can_idct_float JPP((void)); >+ >+EXTERN(void) jsimd_idct_islow JPP((j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+EXTERN(void) jsimd_idct_ifast JPP((j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+EXTERN(void) jsimd_idct_float JPP((j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+ >diff --git a/jpeg/jutils.c b/modules/libjpeg-turbo/jutils.c >rename from jpeg/jutils.c >rename to modules/libjpeg-turbo/jutils.c >--- a/jpeg/jutils.c >+++ b/modules/libjpeg-turbo/jutils.c >@@ -72,18 +72,18 @@ GLOBAL(long) > jdiv_round_up (long a, long b) > /* Compute a/b rounded up to next integer, ie, ceil(a/b) */ > /* Assumes a >= 0, b > 0 */ > { > return (a + b - 1L) / b; > } > > >-GLOBAL(long) >-jround_up (long a, long b) >+GLOBAL(size_t) >+jround_up (size_t a, size_t b) > /* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ > /* Assumes a >= 0, b > 0 */ > { > a += b - 1L; > return a - (a % b); > } > > >diff --git a/jpeg/jversion.h b/modules/libjpeg-turbo/jversion.h >rename from jpeg/jversion.h >rename to modules/libjpeg-turbo/jversion.h >diff --git a/jpeg/libjpeg.doc b/modules/libjpeg-turbo/libjpeg.doc >rename from jpeg/libjpeg.doc >rename to modules/libjpeg-turbo/libjpeg.doc >diff --git a/modules/libjpeg-turbo/rdbmp.c b/modules/libjpeg-turbo/rdbmp.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/rdbmp.c >@@ -0,0 +1,439 @@ >+/* >+ * rdbmp.c >+ * >+ * Copyright (C) 1994-1996, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to read input images in Microsoft "BMP" >+ * format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors). >+ * Currently, only 8-bit and 24-bit images are supported, not 1-bit or >+ * 4-bit (feeding such low-depth images into JPEG would be silly anyway). >+ * Also, we don't support RLE-compressed files. >+ * >+ * These routines may need modification for non-Unix environments or >+ * specialized applications. As they stand, they assume input from >+ * an ordinary stdio stream. They further assume that reading begins >+ * at the start of the file; start_input may need work if the >+ * user interface has already read some data (e.g., to determine that >+ * the file is indeed BMP format). >+ * >+ * This code contributed by James Arthur Boucher. >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef BMP_SUPPORTED >+ >+ >+/* Macros to deal with unsigned chars as efficiently as compiler allows */ >+ >+#ifdef HAVE_UNSIGNED_CHAR >+typedef unsigned char U_CHAR; >+#define UCH(x) ((int) (x)) >+#else /* !HAVE_UNSIGNED_CHAR */ >+#ifdef CHAR_IS_UNSIGNED >+typedef char U_CHAR; >+#define UCH(x) ((int) (x)) >+#else >+typedef char U_CHAR; >+#define UCH(x) ((int) (x) & 0xFF) >+#endif >+#endif /* HAVE_UNSIGNED_CHAR */ >+ >+ >+#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) >+ >+ >+/* Private version of data source object */ >+ >+typedef struct _bmp_source_struct * bmp_source_ptr; >+ >+typedef struct _bmp_source_struct { >+ struct cjpeg_source_struct pub; /* public fields */ >+ >+ j_compress_ptr cinfo; /* back link saves passing separate parm */ >+ >+ JSAMPARRAY colormap; /* BMP colormap (converted to my format) */ >+ >+ jvirt_sarray_ptr whole_image; /* Needed to reverse row order */ >+ JDIMENSION source_row; /* Current source row number */ >+ JDIMENSION row_width; /* Physical width of scanlines in file */ >+ >+ int bits_per_pixel; /* remembers 8- or 24-bit format */ >+} bmp_source_struct; >+ >+ >+LOCAL(int) >+read_byte (bmp_source_ptr sinfo) >+/* Read next byte from BMP file */ >+{ >+ register FILE *infile = sinfo->pub.input_file; >+ register int c; >+ >+ if ((c = getc(infile)) == EOF) >+ ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); >+ return c; >+} >+ >+ >+LOCAL(void) >+read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize) >+/* Read the colormap from a BMP file */ >+{ >+ int i; >+ >+ switch (mapentrysize) { >+ case 3: >+ /* BGR format (occurs in OS/2 files) */ >+ for (i = 0; i < cmaplen; i++) { >+ sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); >+ sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); >+ sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); >+ } >+ break; >+ case 4: >+ /* BGR0 format (occurs in MS Windows files) */ >+ for (i = 0; i < cmaplen; i++) { >+ sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); >+ sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); >+ sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); >+ (void) read_byte(sinfo); >+ } >+ break; >+ default: >+ ERREXIT(sinfo->cinfo, JERR_BMP_BADCMAP); >+ break; >+ } >+} >+ >+ >+/* >+ * Read one row of pixels. >+ * The image has been read into the whole_image array, but is otherwise >+ * unprocessed. We must read it out in top-to-bottom row order, and if >+ * it is an 8-bit image, we must expand colormapped pixels to 24bit format. >+ */ >+ >+METHODDEF(JDIMENSION) >+get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading 8-bit colormap indexes */ >+{ >+ bmp_source_ptr source = (bmp_source_ptr) sinfo; >+ register JSAMPARRAY colormap = source->colormap; >+ JSAMPARRAY image_ptr; >+ register int t; >+ register JSAMPROW inptr, outptr; >+ register JDIMENSION col; >+ >+ /* Fetch next row from virtual array */ >+ source->source_row--; >+ image_ptr = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, source->whole_image, >+ source->source_row, (JDIMENSION) 1, FALSE); >+ >+ /* Expand the colormap indexes to real data */ >+ inptr = image_ptr[0]; >+ outptr = source->pub.buffer[0]; >+ for (col = cinfo->image_width; col > 0; col--) { >+ t = GETJSAMPLE(*inptr++); >+ *outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */ >+ *outptr++ = colormap[1][t]; >+ *outptr++ = colormap[2][t]; >+ } >+ >+ return 1; >+} >+ >+ >+METHODDEF(JDIMENSION) >+get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading 24-bit pixels */ >+{ >+ bmp_source_ptr source = (bmp_source_ptr) sinfo; >+ JSAMPARRAY image_ptr; >+ register JSAMPROW inptr, outptr; >+ register JDIMENSION col; >+ >+ /* Fetch next row from virtual array */ >+ source->source_row--; >+ image_ptr = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, source->whole_image, >+ source->source_row, (JDIMENSION) 1, FALSE); >+ >+ /* Transfer data. Note source values are in BGR order >+ * (even though Microsoft's own documents say the opposite). >+ */ >+ inptr = image_ptr[0]; >+ outptr = source->pub.buffer[0]; >+ for (col = cinfo->image_width; col > 0; col--) { >+ outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ >+ outptr[1] = *inptr++; >+ outptr[0] = *inptr++; >+ outptr += 3; >+ } >+ >+ return 1; >+} >+ >+ >+/* >+ * This method loads the image into whole_image during the first call on >+ * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call >+ * get_8bit_row or get_24bit_row on subsequent calls. >+ */ >+ >+METHODDEF(JDIMENSION) >+preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ bmp_source_ptr source = (bmp_source_ptr) sinfo; >+ register FILE *infile = source->pub.input_file; >+ register int c; >+ register JSAMPROW out_ptr; >+ JSAMPARRAY image_ptr; >+ JDIMENSION row, col; >+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; >+ >+ /* Read the data into a virtual array in input-file row order. */ >+ for (row = 0; row < cinfo->image_height; row++) { >+ if (progress != NULL) { >+ progress->pub.pass_counter = (long) row; >+ progress->pub.pass_limit = (long) cinfo->image_height; >+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); >+ } >+ image_ptr = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, source->whole_image, >+ row, (JDIMENSION) 1, TRUE); >+ out_ptr = image_ptr[0]; >+ for (col = source->row_width; col > 0; col--) { >+ /* inline copy of read_byte() for speed */ >+ if ((c = getc(infile)) == EOF) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ *out_ptr++ = (JSAMPLE) c; >+ } >+ } >+ if (progress != NULL) >+ progress->completed_extra_passes++; >+ >+ /* Set up to read from the virtual array in top-to-bottom order */ >+ switch (source->bits_per_pixel) { >+ case 8: >+ source->pub.get_pixel_rows = get_8bit_row; >+ break; >+ case 24: >+ source->pub.get_pixel_rows = get_24bit_row; >+ break; >+ default: >+ ERREXIT(cinfo, JERR_BMP_BADDEPTH); >+ } >+ source->source_row = cinfo->image_height; >+ >+ /* And read the first row */ >+ return (*source->pub.get_pixel_rows) (cinfo, sinfo); >+} >+ >+ >+/* >+ * Read the file header; return image size and component count. >+ */ >+ >+METHODDEF(void) >+start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ bmp_source_ptr source = (bmp_source_ptr) sinfo; >+ U_CHAR bmpfileheader[14]; >+ U_CHAR bmpinfoheader[64]; >+#define GET_2B(array,offset) ((unsigned int) UCH(array[offset]) + \ >+ (((unsigned int) UCH(array[offset+1])) << 8)) >+#define GET_4B(array,offset) ((INT32) UCH(array[offset]) + \ >+ (((INT32) UCH(array[offset+1])) << 8) + \ >+ (((INT32) UCH(array[offset+2])) << 16) + \ >+ (((INT32) UCH(array[offset+3])) << 24)) >+ INT32 bfOffBits; >+ INT32 headerSize; >+ INT32 biWidth = 0; /* initialize to avoid compiler warning */ >+ INT32 biHeight = 0; >+ unsigned int biPlanes; >+ INT32 biCompression; >+ INT32 biXPelsPerMeter,biYPelsPerMeter; >+ INT32 biClrUsed = 0; >+ int mapentrysize = 0; /* 0 indicates no colormap */ >+ INT32 bPad; >+ JDIMENSION row_width; >+ >+ /* Read and verify the bitmap file header */ >+ if (! ReadOK(source->pub.input_file, bmpfileheader, 14)) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ if (GET_2B(bmpfileheader,0) != 0x4D42) /* 'BM' */ >+ ERREXIT(cinfo, JERR_BMP_NOT); >+ bfOffBits = (INT32) GET_4B(bmpfileheader,10); >+ /* We ignore the remaining fileheader fields */ >+ >+ /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows), >+ * or 64 bytes (OS/2 2.x). Check the first 4 bytes to find out which. >+ */ >+ if (! ReadOK(source->pub.input_file, bmpinfoheader, 4)) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ headerSize = (INT32) GET_4B(bmpinfoheader,0); >+ if (headerSize < 12 || headerSize > 64) >+ ERREXIT(cinfo, JERR_BMP_BADHEADER); >+ if (! ReadOK(source->pub.input_file, bmpinfoheader+4, headerSize-4)) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ >+ switch ((int) headerSize) { >+ case 12: >+ /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */ >+ biWidth = (INT32) GET_2B(bmpinfoheader,4); >+ biHeight = (INT32) GET_2B(bmpinfoheader,6); >+ biPlanes = GET_2B(bmpinfoheader,8); >+ source->bits_per_pixel = (int) GET_2B(bmpinfoheader,10); >+ >+ switch (source->bits_per_pixel) { >+ case 8: /* colormapped image */ >+ mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */ >+ TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight); >+ break; >+ case 24: /* RGB image */ >+ TRACEMS2(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight); >+ break; >+ default: >+ ERREXIT(cinfo, JERR_BMP_BADDEPTH); >+ break; >+ } >+ if (biPlanes != 1) >+ ERREXIT(cinfo, JERR_BMP_BADPLANES); >+ break; >+ case 40: >+ case 64: >+ /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */ >+ /* or OS/2 2.x header, which has additional fields that we ignore */ >+ biWidth = GET_4B(bmpinfoheader,4); >+ biHeight = GET_4B(bmpinfoheader,8); >+ biPlanes = GET_2B(bmpinfoheader,12); >+ source->bits_per_pixel = (int) GET_2B(bmpinfoheader,14); >+ biCompression = GET_4B(bmpinfoheader,16); >+ biXPelsPerMeter = GET_4B(bmpinfoheader,24); >+ biYPelsPerMeter = GET_4B(bmpinfoheader,28); >+ biClrUsed = GET_4B(bmpinfoheader,32); >+ /* biSizeImage, biClrImportant fields are ignored */ >+ >+ switch (source->bits_per_pixel) { >+ case 8: /* colormapped image */ >+ mapentrysize = 4; /* Windows uses RGBQUAD colormap */ >+ TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (int) biWidth, (int) biHeight); >+ break; >+ case 24: /* RGB image */ >+ TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight); >+ break; >+ default: >+ ERREXIT(cinfo, JERR_BMP_BADDEPTH); >+ break; >+ } >+ if (biPlanes != 1) >+ ERREXIT(cinfo, JERR_BMP_BADPLANES); >+ if (biCompression != 0) >+ ERREXIT(cinfo, JERR_BMP_COMPRESSED); >+ >+ if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) { >+ /* Set JFIF density parameters from the BMP data */ >+ cinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */ >+ cinfo->Y_density = (UINT16) (biYPelsPerMeter/100); >+ cinfo->density_unit = 2; /* dots/cm */ >+ } >+ break; >+ default: >+ ERREXIT(cinfo, JERR_BMP_BADHEADER); >+ break; >+ } >+ >+ /* Compute distance to bitmap data --- will adjust for colormap below */ >+ bPad = bfOffBits - (headerSize + 14); >+ >+ /* Read the colormap, if any */ >+ if (mapentrysize > 0) { >+ if (biClrUsed <= 0) >+ biClrUsed = 256; /* assume it's 256 */ >+ else if (biClrUsed > 256) >+ ERREXIT(cinfo, JERR_BMP_BADCMAP); >+ /* Allocate space to store the colormap */ >+ source->colormap = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ (JDIMENSION) biClrUsed, (JDIMENSION) 3); >+ /* and read it from the file */ >+ read_colormap(source, (int) biClrUsed, mapentrysize); >+ /* account for size of colormap */ >+ bPad -= biClrUsed * mapentrysize; >+ } >+ >+ /* Skip any remaining pad bytes */ >+ if (bPad < 0) /* incorrect bfOffBits value? */ >+ ERREXIT(cinfo, JERR_BMP_BADHEADER); >+ while (--bPad >= 0) { >+ (void) read_byte(source); >+ } >+ >+ /* Compute row width in file, including padding to 4-byte boundary */ >+ if (source->bits_per_pixel == 24) >+ row_width = (JDIMENSION) (biWidth * 3); >+ else >+ row_width = (JDIMENSION) biWidth; >+ while ((row_width & 3) != 0) row_width++; >+ source->row_width = row_width; >+ >+ /* Allocate space for inversion array, prepare for preload pass */ >+ source->whole_image = (*cinfo->mem->request_virt_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, >+ row_width, (JDIMENSION) biHeight, (JDIMENSION) 1); >+ source->pub.get_pixel_rows = preload_image; >+ if (cinfo->progress != NULL) { >+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; >+ progress->total_extra_passes++; /* count file input as separate pass */ >+ } >+ >+ /* Allocate one-row buffer for returned data */ >+ source->pub.buffer = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ (JDIMENSION) (biWidth * 3), (JDIMENSION) 1); >+ source->pub.buffer_height = 1; >+ >+ cinfo->in_color_space = JCS_RGB; >+ cinfo->input_components = 3; >+ cinfo->data_precision = 8; >+ cinfo->image_width = (JDIMENSION) biWidth; >+ cinfo->image_height = (JDIMENSION) biHeight; >+} >+ >+ >+/* >+ * Finish up at the end of the file. >+ */ >+ >+METHODDEF(void) >+finish_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ /* no work */ >+} >+ >+ >+/* >+ * The module selection routine for BMP format input. >+ */ >+ >+GLOBAL(cjpeg_source_ptr) >+jinit_read_bmp (j_compress_ptr cinfo) >+{ >+ bmp_source_ptr source; >+ >+ /* Create module interface object */ >+ source = (bmp_source_ptr) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(bmp_source_struct)); >+ source->cinfo = cinfo; /* make back link for subroutines */ >+ /* Fill in method ptrs, except get_pixel_rows which start_input sets */ >+ source->pub.start_input = start_input_bmp; >+ source->pub.finish_input = finish_input_bmp; >+ >+ return (cjpeg_source_ptr) source; >+} >+ >+#endif /* BMP_SUPPORTED */ >diff --git a/modules/libjpeg-turbo/rdcolmap.c b/modules/libjpeg-turbo/rdcolmap.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/rdcolmap.c >@@ -0,0 +1,253 @@ >+/* >+ * rdcolmap.c >+ * >+ * Copyright (C) 1994-1996, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file implements djpeg's "-map file" switch. It reads a source image >+ * and constructs a colormap to be supplied to the JPEG decompressor. >+ * >+ * Currently, these file formats are supported for the map file: >+ * GIF: the contents of the GIF's global colormap are used. >+ * PPM (either text or raw flavor): the entire file is read and >+ * each unique pixel value is entered in the map. >+ * Note that reading a large PPM file will be horrendously slow. >+ * Typically, a PPM-format map file should contain just one pixel >+ * of each desired color. Such a file can be extracted from an >+ * ordinary image PPM file with ppmtomap(1). >+ * >+ * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not >+ * currently implemented. >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ >+ >+/* Portions of this code are based on the PBMPLUS library, which is: >+** >+** Copyright (C) 1988 by Jef Poskanzer. >+** >+** Permission to use, copy, modify, and distribute this software and its >+** documentation for any purpose and without fee is hereby granted, provided >+** that the above copyright notice appear in all copies and that both that >+** copyright notice and this permission notice appear in supporting >+** documentation. This software is provided "as is" without express or >+** implied warranty. >+*/ >+ >+ >+/* >+ * Add a (potentially) new color to the color map. >+ */ >+ >+LOCAL(void) >+add_map_entry (j_decompress_ptr cinfo, int R, int G, int B) >+{ >+ JSAMPROW colormap0 = cinfo->colormap[0]; >+ JSAMPROW colormap1 = cinfo->colormap[1]; >+ JSAMPROW colormap2 = cinfo->colormap[2]; >+ int ncolors = cinfo->actual_number_of_colors; >+ int index; >+ >+ /* Check for duplicate color. */ >+ for (index = 0; index < ncolors; index++) { >+ if (GETJSAMPLE(colormap0[index]) == R && >+ GETJSAMPLE(colormap1[index]) == G && >+ GETJSAMPLE(colormap2[index]) == B) >+ return; /* color is already in map */ >+ } >+ >+ /* Check for map overflow. */ >+ if (ncolors >= (MAXJSAMPLE+1)) >+ ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE+1)); >+ >+ /* OK, add color to map. */ >+ colormap0[ncolors] = (JSAMPLE) R; >+ colormap1[ncolors] = (JSAMPLE) G; >+ colormap2[ncolors] = (JSAMPLE) B; >+ cinfo->actual_number_of_colors++; >+} >+ >+ >+/* >+ * Extract color map from a GIF file. >+ */ >+ >+LOCAL(void) >+read_gif_map (j_decompress_ptr cinfo, FILE * infile) >+{ >+ int header[13]; >+ int i, colormaplen; >+ int R, G, B; >+ >+ /* Initial 'G' has already been read by read_color_map */ >+ /* Read the rest of the GIF header and logical screen descriptor */ >+ for (i = 1; i < 13; i++) { >+ if ((header[i] = getc(infile)) == EOF) >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ } >+ >+ /* Verify GIF Header */ >+ if (header[1] != 'I' || header[2] != 'F') >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ >+ /* There must be a global color map. */ >+ if ((header[10] & 0x80) == 0) >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ >+ /* OK, fetch it. */ >+ colormaplen = 2 << (header[10] & 0x07); >+ >+ for (i = 0; i < colormaplen; i++) { >+ R = getc(infile); >+ G = getc(infile); >+ B = getc(infile); >+ if (R == EOF || G == EOF || B == EOF) >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ add_map_entry(cinfo, >+ R << (BITS_IN_JSAMPLE-8), >+ G << (BITS_IN_JSAMPLE-8), >+ B << (BITS_IN_JSAMPLE-8)); >+ } >+} >+ >+ >+/* Support routines for reading PPM */ >+ >+ >+LOCAL(int) >+pbm_getc (FILE * infile) >+/* Read next char, skipping over any comments */ >+/* A comment/newline sequence is returned as a newline */ >+{ >+ register int ch; >+ >+ ch = getc(infile); >+ if (ch == '#') { >+ do { >+ ch = getc(infile); >+ } while (ch != '\n' && ch != EOF); >+ } >+ return ch; >+} >+ >+ >+LOCAL(unsigned int) >+read_pbm_integer (j_decompress_ptr cinfo, FILE * infile) >+/* Read an unsigned decimal integer from the PPM file */ >+/* Swallows one trailing character after the integer */ >+/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ >+/* This should not be a problem in practice. */ >+{ >+ register int ch; >+ register unsigned int val; >+ >+ /* Skip any leading whitespace */ >+ do { >+ ch = pbm_getc(infile); >+ if (ch == EOF) >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); >+ >+ if (ch < '0' || ch > '9') >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ >+ val = ch - '0'; >+ while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { >+ val *= 10; >+ val += ch - '0'; >+ } >+ return val; >+} >+ >+ >+/* >+ * Extract color map from a PPM file. >+ */ >+ >+LOCAL(void) >+read_ppm_map (j_decompress_ptr cinfo, FILE * infile) >+{ >+ int c; >+ unsigned int w, h, maxval, row, col; >+ int R, G, B; >+ >+ /* Initial 'P' has already been read by read_color_map */ >+ c = getc(infile); /* save format discriminator for a sec */ >+ >+ /* while we fetch the remaining header info */ >+ w = read_pbm_integer(cinfo, infile); >+ h = read_pbm_integer(cinfo, infile); >+ maxval = read_pbm_integer(cinfo, infile); >+ >+ if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ >+ /* For now, we don't support rescaling from an unusual maxval. */ >+ if (maxval != (unsigned int) MAXJSAMPLE) >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ >+ switch (c) { >+ case '3': /* it's a text-format PPM file */ >+ for (row = 0; row < h; row++) { >+ for (col = 0; col < w; col++) { >+ R = read_pbm_integer(cinfo, infile); >+ G = read_pbm_integer(cinfo, infile); >+ B = read_pbm_integer(cinfo, infile); >+ add_map_entry(cinfo, R, G, B); >+ } >+ } >+ break; >+ >+ case '6': /* it's a raw-format PPM file */ >+ for (row = 0; row < h; row++) { >+ for (col = 0; col < w; col++) { >+ R = getc(infile); >+ G = getc(infile); >+ B = getc(infile); >+ if (R == EOF || G == EOF || B == EOF) >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ add_map_entry(cinfo, R, G, B); >+ } >+ } >+ break; >+ >+ default: >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ break; >+ } >+} >+ >+ >+/* >+ * Main entry point from djpeg.c. >+ * Input: opened input file (from file name argument on command line). >+ * Output: colormap and actual_number_of_colors fields are set in cinfo. >+ */ >+ >+GLOBAL(void) >+read_color_map (j_decompress_ptr cinfo, FILE * infile) >+{ >+ /* Allocate space for a color map of maximum supported size. */ >+ cinfo->colormap = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ (JDIMENSION) (MAXJSAMPLE+1), (JDIMENSION) 3); >+ cinfo->actual_number_of_colors = 0; /* initialize map to empty */ >+ >+ /* Read first byte to determine file format */ >+ switch (getc(infile)) { >+ case 'G': >+ read_gif_map(cinfo, infile); >+ break; >+ case 'P': >+ read_ppm_map(cinfo, infile); >+ break; >+ default: >+ ERREXIT(cinfo, JERR_BAD_CMAP_FILE); >+ break; >+ } >+} >+ >+#endif /* QUANT_2PASS_SUPPORTED */ >diff --git a/modules/libjpeg-turbo/rdgif.c b/modules/libjpeg-turbo/rdgif.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/rdgif.c >@@ -0,0 +1,38 @@ >+/* >+ * rdgif.c >+ * >+ * Copyright (C) 1991-1997, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to read input images in GIF format. >+ * >+ ***************************************************************************** >+ * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * >+ * the ability to read GIF files has been removed from the IJG distribution. * >+ * Sorry about that. * >+ ***************************************************************************** >+ * >+ * We are required to state that >+ * "The Graphics Interchange Format(c) is the Copyright property of >+ * CompuServe Incorporated. GIF(sm) is a Service Mark property of >+ * CompuServe Incorporated." >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef GIF_SUPPORTED >+ >+/* >+ * The module selection routine for GIF format input. >+ */ >+ >+GLOBAL(cjpeg_source_ptr) >+jinit_read_gif (j_compress_ptr cinfo) >+{ >+ fprintf(stderr, "GIF input is unsupported for legal reasons. Sorry.\n"); >+ exit(EXIT_FAILURE); >+ return NULL; /* keep compiler happy */ >+} >+ >+#endif /* GIF_SUPPORTED */ >diff --git a/modules/libjpeg-turbo/rdjpgcom.1 b/modules/libjpeg-turbo/rdjpgcom.1 >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/rdjpgcom.1 >@@ -0,0 +1,54 @@ >+.TH RDJPGCOM 1 "11 October 1997" >+.SH NAME >+rdjpgcom \- display text comments from a JPEG file >+.SH SYNOPSIS >+.B rdjpgcom >+[ >+.B \-verbose >+] >+[ >+.I filename >+] >+.LP >+.SH DESCRIPTION >+.LP >+.B rdjpgcom >+reads the named JPEG/JFIF file, or the standard input if no file is named, >+and prints any text comments found in the file on the standard output. >+.PP >+The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. >+Although the standard doesn't actually define what COM blocks are for, they >+are widely used to hold user-supplied text strings. This lets you add >+annotations, titles, index terms, etc to your JPEG files, and later retrieve >+them as text. COM blocks do not interfere with the image stored in the JPEG >+file. The maximum size of a COM block is 64K, but you can have as many of >+them as you like in one JPEG file. >+.SH OPTIONS >+.TP >+.B \-verbose >+Causes >+.B rdjpgcom >+to also display the JPEG image dimensions. >+.PP >+Switch names may be abbreviated, and are not case sensitive. >+.SH HINTS >+.B rdjpgcom >+does not depend on the IJG JPEG library. Its source code is intended as an >+illustration of the minimum amount of code required to parse a JPEG file >+header correctly. >+.PP >+In >+.B \-verbose >+mode, >+.B rdjpgcom >+will also attempt to print the contents of any "APP12" markers as text. >+Some digital cameras produce APP12 markers containing useful textual >+information. If you like, you can modify the source code to print >+other APPn marker types as well. >+.SH SEE ALSO >+.BR cjpeg (1), >+.BR djpeg (1), >+.BR jpegtran (1), >+.BR wrjpgcom (1) >+.SH AUTHOR >+Independent JPEG Group >diff --git a/modules/libjpeg-turbo/rdjpgcom.c b/modules/libjpeg-turbo/rdjpgcom.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/rdjpgcom.c >@@ -0,0 +1,496 @@ >+/* >+ * rdjpgcom.c >+ * >+ * Copyright (C) 1994-1997, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains a very simple stand-alone application that displays >+ * the text in COM (comment) markers in a JFIF file. >+ * This may be useful as an example of the minimum logic needed to parse >+ * JPEG markers. >+ */ >+ >+#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ >+#include "jinclude.h" /* get auto-config symbols, <stdio.h> */ >+ >+#include <ctype.h> /* to declare isupper(), tolower() */ >+#ifdef USE_SETMODE >+#include <fcntl.h> /* to declare setmode()'s parameter macros */ >+/* If you have setmode() but not <io.h>, just delete this line: */ >+#include <io.h> /* to declare setmode() */ >+#endif >+ >+#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ >+#ifdef __MWERKS__ >+#include <SIOUX.h> /* Metrowerks needs this */ >+#include <console.h> /* ... and this */ >+#endif >+#ifdef THINK_C >+#include <console.h> /* Think declares it here */ >+#endif >+#endif >+ >+#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ >+#define READ_BINARY "r" >+#else >+#ifdef VMS /* VMS is very nonstandard */ >+#define READ_BINARY "rb", "ctx=stm" >+#else /* standard ANSI-compliant case */ >+#define READ_BINARY "rb" >+#endif >+#endif >+ >+#ifndef EXIT_FAILURE /* define exit() codes if not provided */ >+#define EXIT_FAILURE 1 >+#endif >+#ifndef EXIT_SUCCESS >+#ifdef VMS >+#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ >+#else >+#define EXIT_SUCCESS 0 >+#endif >+#endif >+ >+ >+/* >+ * These macros are used to read the input file. >+ * To reuse this code in another application, you might need to change these. >+ */ >+ >+static FILE * infile; /* input JPEG file */ >+ >+/* Return next input byte, or EOF if no more */ >+#define NEXTBYTE() getc(infile) >+ >+ >+/* Error exit handler */ >+#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) >+ >+ >+/* Read one byte, testing for EOF */ >+static int >+read_1_byte (void) >+{ >+ int c; >+ >+ c = NEXTBYTE(); >+ if (c == EOF) >+ ERREXIT("Premature EOF in JPEG file"); >+ return c; >+} >+ >+/* Read 2 bytes, convert to unsigned int */ >+/* All 2-byte quantities in JPEG markers are MSB first */ >+static unsigned int >+read_2_bytes (void) >+{ >+ int c1, c2; >+ >+ c1 = NEXTBYTE(); >+ if (c1 == EOF) >+ ERREXIT("Premature EOF in JPEG file"); >+ c2 = NEXTBYTE(); >+ if (c2 == EOF) >+ ERREXIT("Premature EOF in JPEG file"); >+ return (((unsigned int) c1) << 8) + ((unsigned int) c2); >+} >+ >+ >+/* >+ * JPEG markers consist of one or more 0xFF bytes, followed by a marker >+ * code byte (which is not an FF). Here are the marker codes of interest >+ * in this program. (See jdmarker.c for a more complete list.) >+ */ >+ >+#define M_SOF0 0xC0 /* Start Of Frame N */ >+#define M_SOF1 0xC1 /* N indicates which compression process */ >+#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ >+#define M_SOF3 0xC3 >+#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ >+#define M_SOF6 0xC6 >+#define M_SOF7 0xC7 >+#define M_SOF9 0xC9 >+#define M_SOF10 0xCA >+#define M_SOF11 0xCB >+#define M_SOF13 0xCD >+#define M_SOF14 0xCE >+#define M_SOF15 0xCF >+#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ >+#define M_EOI 0xD9 /* End Of Image (end of datastream) */ >+#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ >+#define M_APP0 0xE0 /* Application-specific marker, type N */ >+#define M_APP12 0xEC /* (we don't bother to list all 16 APPn's) */ >+#define M_COM 0xFE /* COMment */ >+ >+ >+/* >+ * Find the next JPEG marker and return its marker code. >+ * We expect at least one FF byte, possibly more if the compressor used FFs >+ * to pad the file. >+ * There could also be non-FF garbage between markers. The treatment of such >+ * garbage is unspecified; we choose to skip over it but emit a warning msg. >+ * NB: this routine must not be used after seeing SOS marker, since it will >+ * not deal correctly with FF/00 sequences in the compressed image data... >+ */ >+ >+static int >+next_marker (void) >+{ >+ int c; >+ int discarded_bytes = 0; >+ >+ /* Find 0xFF byte; count and skip any non-FFs. */ >+ c = read_1_byte(); >+ while (c != 0xFF) { >+ discarded_bytes++; >+ c = read_1_byte(); >+ } >+ /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs >+ * are legal as pad bytes, so don't count them in discarded_bytes. >+ */ >+ do { >+ c = read_1_byte(); >+ } while (c == 0xFF); >+ >+ if (discarded_bytes != 0) { >+ fprintf(stderr, "Warning: garbage data found in JPEG file\n"); >+ } >+ >+ return c; >+} >+ >+ >+/* >+ * Read the initial marker, which should be SOI. >+ * For a JFIF file, the first two bytes of the file should be literally >+ * 0xFF M_SOI. To be more general, we could use next_marker, but if the >+ * input file weren't actually JPEG at all, next_marker might read the whole >+ * file and then return a misleading error message... >+ */ >+ >+static int >+first_marker (void) >+{ >+ int c1, c2; >+ >+ c1 = NEXTBYTE(); >+ c2 = NEXTBYTE(); >+ if (c1 != 0xFF || c2 != M_SOI) >+ ERREXIT("Not a JPEG file"); >+ return c2; >+} >+ >+ >+/* >+ * Most types of marker are followed by a variable-length parameter segment. >+ * This routine skips over the parameters for any marker we don't otherwise >+ * want to process. >+ * Note that we MUST skip the parameter segment explicitly in order not to >+ * be fooled by 0xFF bytes that might appear within the parameter segment; >+ * such bytes do NOT introduce new markers. >+ */ >+ >+static void >+skip_variable (void) >+/* Skip over an unknown or uninteresting variable-length marker */ >+{ >+ unsigned int length; >+ >+ /* Get the marker parameter length count */ >+ length = read_2_bytes(); >+ /* Length includes itself, so must be at least 2 */ >+ if (length < 2) >+ ERREXIT("Erroneous JPEG marker length"); >+ length -= 2; >+ /* Skip over the remaining bytes */ >+ while (length > 0) { >+ (void) read_1_byte(); >+ length--; >+ } >+} >+ >+ >+/* >+ * Process a COM marker. >+ * We want to print out the marker contents as legible text; >+ * we must guard against non-text junk and varying newline representations. >+ */ >+ >+static void >+process_COM (void) >+{ >+ unsigned int length; >+ int ch; >+ int lastch = 0; >+ >+ /* Get the marker parameter length count */ >+ length = read_2_bytes(); >+ /* Length includes itself, so must be at least 2 */ >+ if (length < 2) >+ ERREXIT("Erroneous JPEG marker length"); >+ length -= 2; >+ >+ while (length > 0) { >+ ch = read_1_byte(); >+ /* Emit the character in a readable form. >+ * Nonprintables are converted to \nnn form, >+ * while \ is converted to \\. >+ * Newlines in CR, CR/LF, or LF form will be printed as one newline. >+ */ >+ if (ch == '\r') { >+ printf("\n"); >+ } else if (ch == '\n') { >+ if (lastch != '\r') >+ printf("\n"); >+ } else if (ch == '\\') { >+ printf("\\\\"); >+ } else if (isprint(ch)) { >+ putc(ch, stdout); >+ } else { >+ printf("\\%03o", ch); >+ } >+ lastch = ch; >+ length--; >+ } >+ printf("\n"); >+} >+ >+ >+/* >+ * Process a SOFn marker. >+ * This code is only needed if you want to know the image dimensions... >+ */ >+ >+static void >+process_SOFn (int marker) >+{ >+ unsigned int length; >+ unsigned int image_height, image_width; >+ int data_precision, num_components; >+ const char * process; >+ int ci; >+ >+ length = read_2_bytes(); /* usual parameter length count */ >+ >+ data_precision = read_1_byte(); >+ image_height = read_2_bytes(); >+ image_width = read_2_bytes(); >+ num_components = read_1_byte(); >+ >+ switch (marker) { >+ case M_SOF0: process = "Baseline"; break; >+ case M_SOF1: process = "Extended sequential"; break; >+ case M_SOF2: process = "Progressive"; break; >+ case M_SOF3: process = "Lossless"; break; >+ case M_SOF5: process = "Differential sequential"; break; >+ case M_SOF6: process = "Differential progressive"; break; >+ case M_SOF7: process = "Differential lossless"; break; >+ case M_SOF9: process = "Extended sequential, arithmetic coding"; break; >+ case M_SOF10: process = "Progressive, arithmetic coding"; break; >+ case M_SOF11: process = "Lossless, arithmetic coding"; break; >+ case M_SOF13: process = "Differential sequential, arithmetic coding"; break; >+ case M_SOF14: process = "Differential progressive, arithmetic coding"; break; >+ case M_SOF15: process = "Differential lossless, arithmetic coding"; break; >+ default: process = "Unknown"; break; >+ } >+ >+ printf("JPEG image is %uw * %uh, %d color components, %d bits per sample\n", >+ image_width, image_height, num_components, data_precision); >+ printf("JPEG process: %s\n", process); >+ >+ if (length != (unsigned int) (8 + num_components * 3)) >+ ERREXIT("Bogus SOF marker length"); >+ >+ for (ci = 0; ci < num_components; ci++) { >+ (void) read_1_byte(); /* Component ID code */ >+ (void) read_1_byte(); /* H, V sampling factors */ >+ (void) read_1_byte(); /* Quantization table number */ >+ } >+} >+ >+ >+/* >+ * Parse the marker stream until SOS or EOI is seen; >+ * display any COM markers. >+ * While the companion program wrjpgcom will always insert COM markers before >+ * SOFn, other implementations might not, so we scan to SOS before stopping. >+ * If we were only interested in the image dimensions, we would stop at SOFn. >+ * (Conversely, if we only cared about COM markers, there would be no need >+ * for special code to handle SOFn; we could treat it like other markers.) >+ */ >+ >+static int >+scan_JPEG_header (int verbose) >+{ >+ int marker; >+ >+ /* Expect SOI at start of file */ >+ if (first_marker() != M_SOI) >+ ERREXIT("Expected SOI marker first"); >+ >+ /* Scan miscellaneous markers until we reach SOS. */ >+ for (;;) { >+ marker = next_marker(); >+ switch (marker) { >+ /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, >+ * treated as SOFn. C4 in particular is actually DHT. >+ */ >+ case M_SOF0: /* Baseline */ >+ case M_SOF1: /* Extended sequential, Huffman */ >+ case M_SOF2: /* Progressive, Huffman */ >+ case M_SOF3: /* Lossless, Huffman */ >+ case M_SOF5: /* Differential sequential, Huffman */ >+ case M_SOF6: /* Differential progressive, Huffman */ >+ case M_SOF7: /* Differential lossless, Huffman */ >+ case M_SOF9: /* Extended sequential, arithmetic */ >+ case M_SOF10: /* Progressive, arithmetic */ >+ case M_SOF11: /* Lossless, arithmetic */ >+ case M_SOF13: /* Differential sequential, arithmetic */ >+ case M_SOF14: /* Differential progressive, arithmetic */ >+ case M_SOF15: /* Differential lossless, arithmetic */ >+ if (verbose) >+ process_SOFn(marker); >+ else >+ skip_variable(); >+ break; >+ >+ case M_SOS: /* stop before hitting compressed data */ >+ return marker; >+ >+ case M_EOI: /* in case it's a tables-only JPEG stream */ >+ return marker; >+ >+ case M_COM: >+ process_COM(); >+ break; >+ >+ case M_APP12: >+ /* Some digital camera makers put useful textual information into >+ * APP12 markers, so we print those out too when in -verbose mode. >+ */ >+ if (verbose) { >+ printf("APP12 contains:\n"); >+ process_COM(); >+ } else >+ skip_variable(); >+ break; >+ >+ default: /* Anything else just gets skipped */ >+ skip_variable(); /* we assume it has a parameter count... */ >+ break; >+ } >+ } /* end loop */ >+} >+ >+ >+/* Command line parsing code */ >+ >+static const char * progname; /* program name for error messages */ >+ >+ >+static void >+usage (void) >+/* complain about bad command line */ >+{ >+ fprintf(stderr, "rdjpgcom displays any textual comments in a JPEG file.\n"); >+ >+ fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname); >+ >+ fprintf(stderr, "Switches (names may be abbreviated):\n"); >+ fprintf(stderr, " -verbose Also display dimensions of JPEG image\n"); >+ >+ exit(EXIT_FAILURE); >+} >+ >+ >+static int >+keymatch (char * arg, const char * keyword, int minchars) >+/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ >+/* keyword is the constant keyword (must be lower case already), */ >+/* minchars is length of minimum legal abbreviation. */ >+{ >+ register int ca, ck; >+ register int nmatched = 0; >+ >+ while ((ca = *arg++) != '\0') { >+ if ((ck = *keyword++) == '\0') >+ return 0; /* arg longer than keyword, no good */ >+ if (isupper(ca)) /* force arg to lcase (assume ck is already) */ >+ ca = tolower(ca); >+ if (ca != ck) >+ return 0; /* no good */ >+ nmatched++; /* count matched characters */ >+ } >+ /* reached end of argument; fail if it's too short for unique abbrev */ >+ if (nmatched < minchars) >+ return 0; >+ return 1; /* A-OK */ >+} >+ >+ >+/* >+ * The main program. >+ */ >+ >+int >+main (int argc, char **argv) >+{ >+ int argn; >+ char * arg; >+ int verbose = 0; >+ >+ /* On Mac, fetch a command line. */ >+#ifdef USE_CCOMMAND >+ argc = ccommand(&argv); >+#endif >+ >+ progname = argv[0]; >+ if (progname == NULL || progname[0] == 0) >+ progname = "rdjpgcom"; /* in case C library doesn't provide it */ >+ >+ /* Parse switches, if any */ >+ for (argn = 1; argn < argc; argn++) { >+ arg = argv[argn]; >+ if (arg[0] != '-') >+ break; /* not switch, must be file name */ >+ arg++; /* advance over '-' */ >+ if (keymatch(arg, "verbose", 1)) { >+ verbose++; >+ } else >+ usage(); >+ } >+ >+ /* Open the input file. */ >+ /* Unix style: expect zero or one file name */ >+ if (argn < argc-1) { >+ fprintf(stderr, "%s: only one input file\n", progname); >+ usage(); >+ } >+ if (argn < argc) { >+ if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { >+ fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); >+ exit(EXIT_FAILURE); >+ } >+ } else { >+ /* default input file is stdin */ >+#ifdef USE_SETMODE /* need to hack file mode? */ >+ setmode(fileno(stdin), O_BINARY); >+#endif >+#ifdef USE_FDOPEN /* need to re-open in binary mode? */ >+ if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { >+ fprintf(stderr, "%s: can't open stdin\n", progname); >+ exit(EXIT_FAILURE); >+ } >+#else >+ infile = stdin; >+#endif >+ } >+ >+ /* Scan the JPEG headers. */ >+ (void) scan_JPEG_header(verbose); >+ >+ /* All done. */ >+ exit(EXIT_SUCCESS); >+ return 0; /* suppress no-return-value warnings */ >+} >diff --git a/modules/libjpeg-turbo/rdppm.c b/modules/libjpeg-turbo/rdppm.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/rdppm.c >@@ -0,0 +1,458 @@ >+/* >+ * rdppm.c >+ * >+ * Copyright (C) 1991-1997, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to read input images in PPM/PGM format. >+ * The extended 2-byte-per-sample raw PPM/PGM formats are supported. >+ * The PBMPLUS library is NOT required to compile this software >+ * (but it is highly useful as a set of PPM image manipulation programs). >+ * >+ * These routines may need modification for non-Unix environments or >+ * specialized applications. As they stand, they assume input from >+ * an ordinary stdio stream. They further assume that reading begins >+ * at the start of the file; start_input may need work if the >+ * user interface has already read some data (e.g., to determine that >+ * the file is indeed PPM format). >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef PPM_SUPPORTED >+ >+ >+/* Portions of this code are based on the PBMPLUS library, which is: >+** >+** Copyright (C) 1988 by Jef Poskanzer. >+** >+** Permission to use, copy, modify, and distribute this software and its >+** documentation for any purpose and without fee is hereby granted, provided >+** that the above copyright notice appear in all copies and that both that >+** copyright notice and this permission notice appear in supporting >+** documentation. This software is provided "as is" without express or >+** implied warranty. >+*/ >+ >+ >+/* Macros to deal with unsigned chars as efficiently as compiler allows */ >+ >+#ifdef HAVE_UNSIGNED_CHAR >+typedef unsigned char U_CHAR; >+#define UCH(x) ((int) (x)) >+#else /* !HAVE_UNSIGNED_CHAR */ >+#ifdef CHAR_IS_UNSIGNED >+typedef char U_CHAR; >+#define UCH(x) ((int) (x)) >+#else >+typedef char U_CHAR; >+#define UCH(x) ((int) (x) & 0xFF) >+#endif >+#endif /* HAVE_UNSIGNED_CHAR */ >+ >+ >+#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) >+ >+ >+/* >+ * On most systems, reading individual bytes with getc() is drastically less >+ * efficient than buffering a row at a time with fread(). On PCs, we must >+ * allocate the buffer in near data space, because we are assuming small-data >+ * memory model, wherein fread() can't reach far memory. If you need to >+ * process very wide images on a PC, you might have to compile in large-memory >+ * model, or else replace fread() with a getc() loop --- which will be much >+ * slower. >+ */ >+ >+ >+/* Private version of data source object */ >+ >+typedef struct { >+ struct cjpeg_source_struct pub; /* public fields */ >+ >+ U_CHAR *iobuffer; /* non-FAR pointer to I/O buffer */ >+ JSAMPROW pixrow; /* FAR pointer to same */ >+ size_t buffer_width; /* width of I/O buffer */ >+ JSAMPLE *rescale; /* => maxval-remapping array, or NULL */ >+} ppm_source_struct; >+ >+typedef ppm_source_struct * ppm_source_ptr; >+ >+ >+LOCAL(int) >+pbm_getc (FILE * infile) >+/* Read next char, skipping over any comments */ >+/* A comment/newline sequence is returned as a newline */ >+{ >+ register int ch; >+ >+ ch = getc(infile); >+ if (ch == '#') { >+ do { >+ ch = getc(infile); >+ } while (ch != '\n' && ch != EOF); >+ } >+ return ch; >+} >+ >+ >+LOCAL(unsigned int) >+read_pbm_integer (j_compress_ptr cinfo, FILE * infile) >+/* Read an unsigned decimal integer from the PPM file */ >+/* Swallows one trailing character after the integer */ >+/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ >+/* This should not be a problem in practice. */ >+{ >+ register int ch; >+ register unsigned int val; >+ >+ /* Skip any leading whitespace */ >+ do { >+ ch = pbm_getc(infile); >+ if (ch == EOF) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); >+ >+ if (ch < '0' || ch > '9') >+ ERREXIT(cinfo, JERR_PPM_NONNUMERIC); >+ >+ val = ch - '0'; >+ while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { >+ val *= 10; >+ val += ch - '0'; >+ } >+ return val; >+} >+ >+ >+/* >+ * Read one row of pixels. >+ * >+ * We provide several different versions depending on input file format. >+ * In all cases, input is scaled to the size of JSAMPLE. >+ * >+ * A really fast path is provided for reading byte/sample raw files with >+ * maxval = MAXJSAMPLE, which is the normal case for 8-bit data. >+ */ >+ >+ >+METHODDEF(JDIMENSION) >+get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading text-format PGM files with any maxval */ >+{ >+ ppm_source_ptr source = (ppm_source_ptr) sinfo; >+ FILE * infile = source->pub.input_file; >+ register JSAMPROW ptr; >+ register JSAMPLE *rescale = source->rescale; >+ JDIMENSION col; >+ >+ ptr = source->pub.buffer[0]; >+ for (col = cinfo->image_width; col > 0; col--) { >+ *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; >+ } >+ return 1; >+} >+ >+ >+METHODDEF(JDIMENSION) >+get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading text-format PPM files with any maxval */ >+{ >+ ppm_source_ptr source = (ppm_source_ptr) sinfo; >+ FILE * infile = source->pub.input_file; >+ register JSAMPROW ptr; >+ register JSAMPLE *rescale = source->rescale; >+ JDIMENSION col; >+ >+ ptr = source->pub.buffer[0]; >+ for (col = cinfo->image_width; col > 0; col--) { >+ *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; >+ *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; >+ *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; >+ } >+ return 1; >+} >+ >+ >+METHODDEF(JDIMENSION) >+get_scaled_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading raw-byte-format PGM files with any maxval */ >+{ >+ ppm_source_ptr source = (ppm_source_ptr) sinfo; >+ register JSAMPROW ptr; >+ register U_CHAR * bufferptr; >+ register JSAMPLE *rescale = source->rescale; >+ JDIMENSION col; >+ >+ if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ ptr = source->pub.buffer[0]; >+ bufferptr = source->iobuffer; >+ for (col = cinfo->image_width; col > 0; col--) { >+ *ptr++ = rescale[UCH(*bufferptr++)]; >+ } >+ return 1; >+} >+ >+ >+METHODDEF(JDIMENSION) >+get_scaled_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading raw-byte-format PPM files with any maxval */ >+{ >+ ppm_source_ptr source = (ppm_source_ptr) sinfo; >+ register JSAMPROW ptr; >+ register U_CHAR * bufferptr; >+ register JSAMPLE *rescale = source->rescale; >+ JDIMENSION col; >+ >+ if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ ptr = source->pub.buffer[0]; >+ bufferptr = source->iobuffer; >+ for (col = cinfo->image_width; col > 0; col--) { >+ *ptr++ = rescale[UCH(*bufferptr++)]; >+ *ptr++ = rescale[UCH(*bufferptr++)]; >+ *ptr++ = rescale[UCH(*bufferptr++)]; >+ } >+ return 1; >+} >+ >+ >+METHODDEF(JDIMENSION) >+get_raw_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE. >+ * In this case we just read right into the JSAMPLE buffer! >+ * Note that same code works for PPM and PGM files. >+ */ >+{ >+ ppm_source_ptr source = (ppm_source_ptr) sinfo; >+ >+ if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ return 1; >+} >+ >+ >+METHODDEF(JDIMENSION) >+get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading raw-word-format PGM files with any maxval */ >+{ >+ ppm_source_ptr source = (ppm_source_ptr) sinfo; >+ register JSAMPROW ptr; >+ register U_CHAR * bufferptr; >+ register JSAMPLE *rescale = source->rescale; >+ JDIMENSION col; >+ >+ if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ ptr = source->pub.buffer[0]; >+ bufferptr = source->iobuffer; >+ for (col = cinfo->image_width; col > 0; col--) { >+ register int temp; >+ temp = UCH(*bufferptr++); >+ temp |= UCH(*bufferptr++) << 8; >+ *ptr++ = rescale[temp]; >+ } >+ return 1; >+} >+ >+ >+METHODDEF(JDIMENSION) >+get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading raw-word-format PPM files with any maxval */ >+{ >+ ppm_source_ptr source = (ppm_source_ptr) sinfo; >+ register JSAMPROW ptr; >+ register U_CHAR * bufferptr; >+ register JSAMPLE *rescale = source->rescale; >+ JDIMENSION col; >+ >+ if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ ptr = source->pub.buffer[0]; >+ bufferptr = source->iobuffer; >+ for (col = cinfo->image_width; col > 0; col--) { >+ register int temp; >+ temp = UCH(*bufferptr++); >+ temp |= UCH(*bufferptr++) << 8; >+ *ptr++ = rescale[temp]; >+ temp = UCH(*bufferptr++); >+ temp |= UCH(*bufferptr++) << 8; >+ *ptr++ = rescale[temp]; >+ temp = UCH(*bufferptr++); >+ temp |= UCH(*bufferptr++) << 8; >+ *ptr++ = rescale[temp]; >+ } >+ return 1; >+} >+ >+ >+/* >+ * Read the file header; return image size and component count. >+ */ >+ >+METHODDEF(void) >+start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ ppm_source_ptr source = (ppm_source_ptr) sinfo; >+ int c; >+ unsigned int w, h, maxval; >+ boolean need_iobuffer, use_raw_buffer, need_rescale; >+ >+ if (getc(source->pub.input_file) != 'P') >+ ERREXIT(cinfo, JERR_PPM_NOT); >+ >+ c = getc(source->pub.input_file); /* subformat discriminator character */ >+ >+ /* detect unsupported variants (ie, PBM) before trying to read header */ >+ switch (c) { >+ case '2': /* it's a text-format PGM file */ >+ case '3': /* it's a text-format PPM file */ >+ case '5': /* it's a raw-format PGM file */ >+ case '6': /* it's a raw-format PPM file */ >+ break; >+ default: >+ ERREXIT(cinfo, JERR_PPM_NOT); >+ break; >+ } >+ >+ /* fetch the remaining header info */ >+ w = read_pbm_integer(cinfo, source->pub.input_file); >+ h = read_pbm_integer(cinfo, source->pub.input_file); >+ maxval = read_pbm_integer(cinfo, source->pub.input_file); >+ >+ if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ >+ ERREXIT(cinfo, JERR_PPM_NOT); >+ >+ cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ >+ cinfo->image_width = (JDIMENSION) w; >+ cinfo->image_height = (JDIMENSION) h; >+ >+ /* initialize flags to most common settings */ >+ need_iobuffer = TRUE; /* do we need an I/O buffer? */ >+ use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */ >+ need_rescale = TRUE; /* do we need a rescale array? */ >+ >+ switch (c) { >+ case '2': /* it's a text-format PGM file */ >+ cinfo->input_components = 1; >+ cinfo->in_color_space = JCS_GRAYSCALE; >+ TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h); >+ source->pub.get_pixel_rows = get_text_gray_row; >+ need_iobuffer = FALSE; >+ break; >+ >+ case '3': /* it's a text-format PPM file */ >+ cinfo->input_components = 3; >+ cinfo->in_color_space = JCS_RGB; >+ TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h); >+ source->pub.get_pixel_rows = get_text_rgb_row; >+ need_iobuffer = FALSE; >+ break; >+ >+ case '5': /* it's a raw-format PGM file */ >+ cinfo->input_components = 1; >+ cinfo->in_color_space = JCS_GRAYSCALE; >+ TRACEMS2(cinfo, 1, JTRC_PGM, w, h); >+ if (maxval > 255) { >+ source->pub.get_pixel_rows = get_word_gray_row; >+ } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { >+ source->pub.get_pixel_rows = get_raw_row; >+ use_raw_buffer = TRUE; >+ need_rescale = FALSE; >+ } else { >+ source->pub.get_pixel_rows = get_scaled_gray_row; >+ } >+ break; >+ >+ case '6': /* it's a raw-format PPM file */ >+ cinfo->input_components = 3; >+ cinfo->in_color_space = JCS_RGB; >+ TRACEMS2(cinfo, 1, JTRC_PPM, w, h); >+ if (maxval > 255) { >+ source->pub.get_pixel_rows = get_word_rgb_row; >+ } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { >+ source->pub.get_pixel_rows = get_raw_row; >+ use_raw_buffer = TRUE; >+ need_rescale = FALSE; >+ } else { >+ source->pub.get_pixel_rows = get_scaled_rgb_row; >+ } >+ break; >+ } >+ >+ /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */ >+ if (need_iobuffer) { >+ source->buffer_width = (size_t) w * cinfo->input_components * >+ ((maxval<=255) ? SIZEOF(U_CHAR) : (2*SIZEOF(U_CHAR))); >+ source->iobuffer = (U_CHAR *) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ source->buffer_width); >+ } >+ >+ /* Create compressor input buffer. */ >+ if (use_raw_buffer) { >+ /* For unscaled raw-input case, we can just map it onto the I/O buffer. */ >+ /* Synthesize a JSAMPARRAY pointer structure */ >+ /* Cast here implies near->far pointer conversion on PCs */ >+ source->pixrow = (JSAMPROW) source->iobuffer; >+ source->pub.buffer = & source->pixrow; >+ source->pub.buffer_height = 1; >+ } else { >+ /* Need to translate anyway, so make a separate sample buffer. */ >+ source->pub.buffer = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ (JDIMENSION) w * cinfo->input_components, (JDIMENSION) 1); >+ source->pub.buffer_height = 1; >+ } >+ >+ /* Compute the rescaling array if required. */ >+ if (need_rescale) { >+ INT32 val, half_maxval; >+ >+ /* On 16-bit-int machines we have to be careful of maxval = 65535 */ >+ source->rescale = (JSAMPLE *) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ (size_t) (((long) maxval + 1L) * SIZEOF(JSAMPLE))); >+ half_maxval = maxval / 2; >+ for (val = 0; val <= (INT32) maxval; val++) { >+ /* The multiplication here must be done in 32 bits to avoid overflow */ >+ source->rescale[val] = (JSAMPLE) ((val*MAXJSAMPLE + half_maxval)/maxval); >+ } >+ } >+} >+ >+ >+/* >+ * Finish up at the end of the file. >+ */ >+ >+METHODDEF(void) >+finish_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ /* no work */ >+} >+ >+ >+/* >+ * The module selection routine for PPM format input. >+ */ >+ >+GLOBAL(cjpeg_source_ptr) >+jinit_read_ppm (j_compress_ptr cinfo) >+{ >+ ppm_source_ptr source; >+ >+ /* Create module interface object */ >+ source = (ppm_source_ptr) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(ppm_source_struct)); >+ /* Fill in method ptrs, except get_pixel_rows which start_input sets */ >+ source->pub.start_input = start_input_ppm; >+ source->pub.finish_input = finish_input_ppm; >+ >+ return (cjpeg_source_ptr) source; >+} >+ >+#endif /* PPM_SUPPORTED */ >diff --git a/modules/libjpeg-turbo/rdrle.c b/modules/libjpeg-turbo/rdrle.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/rdrle.c >@@ -0,0 +1,387 @@ >+/* >+ * rdrle.c >+ * >+ * Copyright (C) 1991-1996, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to read input images in Utah RLE format. >+ * The Utah Raster Toolkit library is required (version 3.1 or later). >+ * >+ * These routines may need modification for non-Unix environments or >+ * specialized applications. As they stand, they assume input from >+ * an ordinary stdio stream. They further assume that reading begins >+ * at the start of the file; start_input may need work if the >+ * user interface has already read some data (e.g., to determine that >+ * the file is indeed RLE format). >+ * >+ * Based on code contributed by Mike Lijewski, >+ * with updates from Robert Hutchinson. >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef RLE_SUPPORTED >+ >+/* rle.h is provided by the Utah Raster Toolkit. */ >+ >+#include <rle.h> >+ >+/* >+ * We assume that JSAMPLE has the same representation as rle_pixel, >+ * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. >+ */ >+ >+#if BITS_IN_JSAMPLE != 8 >+ Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ >+#endif >+ >+/* >+ * We support the following types of RLE files: >+ * >+ * GRAYSCALE - 8 bits, no colormap >+ * MAPPEDGRAY - 8 bits, 1 channel colomap >+ * PSEUDOCOLOR - 8 bits, 3 channel colormap >+ * TRUECOLOR - 24 bits, 3 channel colormap >+ * DIRECTCOLOR - 24 bits, no colormap >+ * >+ * For now, we ignore any alpha channel in the image. >+ */ >+ >+typedef enum >+ { GRAYSCALE, MAPPEDGRAY, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind; >+ >+ >+/* >+ * Since RLE stores scanlines bottom-to-top, we have to invert the image >+ * to conform to JPEG's top-to-bottom order. To do this, we read the >+ * incoming image into a virtual array on the first get_pixel_rows call, >+ * then fetch the required row from the virtual array on subsequent calls. >+ */ >+ >+typedef struct _rle_source_struct * rle_source_ptr; >+ >+typedef struct _rle_source_struct { >+ struct cjpeg_source_struct pub; /* public fields */ >+ >+ rle_kind visual; /* actual type of input file */ >+ jvirt_sarray_ptr image; /* virtual array to hold the image */ >+ JDIMENSION row; /* current row # in the virtual array */ >+ rle_hdr header; /* Input file information */ >+ rle_pixel** rle_row; /* holds a row returned by rle_getrow() */ >+ >+} rle_source_struct; >+ >+ >+/* >+ * Read the file header; return image size and component count. >+ */ >+ >+METHODDEF(void) >+start_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ rle_source_ptr source = (rle_source_ptr) sinfo; >+ JDIMENSION width, height; >+#ifdef PROGRESS_REPORT >+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; >+#endif >+ >+ /* Use RLE library routine to get the header info */ >+ source->header = *rle_hdr_init(NULL); >+ source->header.rle_file = source->pub.input_file; >+ switch (rle_get_setup(&(source->header))) { >+ case RLE_SUCCESS: >+ /* A-OK */ >+ break; >+ case RLE_NOT_RLE: >+ ERREXIT(cinfo, JERR_RLE_NOT); >+ break; >+ case RLE_NO_SPACE: >+ ERREXIT(cinfo, JERR_RLE_MEM); >+ break; >+ case RLE_EMPTY: >+ ERREXIT(cinfo, JERR_RLE_EMPTY); >+ break; >+ case RLE_EOF: >+ ERREXIT(cinfo, JERR_RLE_EOF); >+ break; >+ default: >+ ERREXIT(cinfo, JERR_RLE_BADERROR); >+ break; >+ } >+ >+ /* Figure out what we have, set private vars and return values accordingly */ >+ >+ width = source->header.xmax - source->header.xmin + 1; >+ height = source->header.ymax - source->header.ymin + 1; >+ source->header.xmin = 0; /* realign horizontally */ >+ source->header.xmax = width-1; >+ >+ cinfo->image_width = width; >+ cinfo->image_height = height; >+ cinfo->data_precision = 8; /* we can only handle 8 bit data */ >+ >+ if (source->header.ncolors == 1 && source->header.ncmap == 0) { >+ source->visual = GRAYSCALE; >+ TRACEMS2(cinfo, 1, JTRC_RLE_GRAY, width, height); >+ } else if (source->header.ncolors == 1 && source->header.ncmap == 1) { >+ source->visual = MAPPEDGRAY; >+ TRACEMS3(cinfo, 1, JTRC_RLE_MAPGRAY, width, height, >+ 1 << source->header.cmaplen); >+ } else if (source->header.ncolors == 1 && source->header.ncmap == 3) { >+ source->visual = PSEUDOCOLOR; >+ TRACEMS3(cinfo, 1, JTRC_RLE_MAPPED, width, height, >+ 1 << source->header.cmaplen); >+ } else if (source->header.ncolors == 3 && source->header.ncmap == 3) { >+ source->visual = TRUECOLOR; >+ TRACEMS3(cinfo, 1, JTRC_RLE_FULLMAP, width, height, >+ 1 << source->header.cmaplen); >+ } else if (source->header.ncolors == 3 && source->header.ncmap == 0) { >+ source->visual = DIRECTCOLOR; >+ TRACEMS2(cinfo, 1, JTRC_RLE, width, height); >+ } else >+ ERREXIT(cinfo, JERR_RLE_UNSUPPORTED); >+ >+ if (source->visual == GRAYSCALE || source->visual == MAPPEDGRAY) { >+ cinfo->in_color_space = JCS_GRAYSCALE; >+ cinfo->input_components = 1; >+ } else { >+ cinfo->in_color_space = JCS_RGB; >+ cinfo->input_components = 3; >+ } >+ >+ /* >+ * A place to hold each scanline while it's converted. >+ * (GRAYSCALE scanlines don't need converting) >+ */ >+ if (source->visual != GRAYSCALE) { >+ source->rle_row = (rle_pixel**) (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ (JDIMENSION) width, (JDIMENSION) cinfo->input_components); >+ } >+ >+ /* request a virtual array to hold the image */ >+ source->image = (*cinfo->mem->request_virt_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, >+ (JDIMENSION) (width * source->header.ncolors), >+ (JDIMENSION) height, (JDIMENSION) 1); >+ >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) { >+ /* count file input as separate pass */ >+ progress->total_extra_passes++; >+ } >+#endif >+ >+ source->pub.buffer_height = 1; >+} >+ >+ >+/* >+ * Read one row of pixels. >+ * Called only after load_image has read the image into the virtual array. >+ * Used for GRAYSCALE, MAPPEDGRAY, TRUECOLOR, and DIRECTCOLOR images. >+ */ >+ >+METHODDEF(JDIMENSION) >+get_rle_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ rle_source_ptr source = (rle_source_ptr) sinfo; >+ >+ source->row--; >+ source->pub.buffer = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); >+ >+ return 1; >+} >+ >+/* >+ * Read one row of pixels. >+ * Called only after load_image has read the image into the virtual array. >+ * Used for PSEUDOCOLOR images. >+ */ >+ >+METHODDEF(JDIMENSION) >+get_pseudocolor_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ rle_source_ptr source = (rle_source_ptr) sinfo; >+ JSAMPROW src_row, dest_row; >+ JDIMENSION col; >+ rle_map *colormap; >+ int val; >+ >+ colormap = source->header.cmap; >+ dest_row = source->pub.buffer[0]; >+ source->row--; >+ src_row = * (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); >+ >+ for (col = cinfo->image_width; col > 0; col--) { >+ val = GETJSAMPLE(*src_row++); >+ *dest_row++ = (JSAMPLE) (colormap[val ] >> 8); >+ *dest_row++ = (JSAMPLE) (colormap[val + 256] >> 8); >+ *dest_row++ = (JSAMPLE) (colormap[val + 512] >> 8); >+ } >+ >+ return 1; >+} >+ >+ >+/* >+ * Load the image into a virtual array. We have to do this because RLE >+ * files start at the lower left while the JPEG standard has them starting >+ * in the upper left. This is called the first time we want to get a row >+ * of input. What we do is load the RLE data into the array and then call >+ * the appropriate routine to read one row from the array. Before returning, >+ * we set source->pub.get_pixel_rows so that subsequent calls go straight to >+ * the appropriate row-reading routine. >+ */ >+ >+METHODDEF(JDIMENSION) >+load_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ rle_source_ptr source = (rle_source_ptr) sinfo; >+ JDIMENSION row, col; >+ JSAMPROW scanline, red_ptr, green_ptr, blue_ptr; >+ rle_pixel **rle_row; >+ rle_map *colormap; >+ char channel; >+#ifdef PROGRESS_REPORT >+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; >+#endif >+ >+ colormap = source->header.cmap; >+ rle_row = source->rle_row; >+ >+ /* Read the RLE data into our virtual array. >+ * We assume here that (a) rle_pixel is represented the same as JSAMPLE, >+ * and (b) we are not on a machine where FAR pointers differ from regular. >+ */ >+ RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */ >+ >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) { >+ progress->pub.pass_limit = cinfo->image_height; >+ progress->pub.pass_counter = 0; >+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); >+ } >+#endif >+ >+ switch (source->visual) { >+ >+ case GRAYSCALE: >+ case PSEUDOCOLOR: >+ for (row = 0; row < cinfo->image_height; row++) { >+ rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); >+ rle_getrow(&source->header, rle_row); >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) { >+ progress->pub.pass_counter++; >+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); >+ } >+#endif >+ } >+ break; >+ >+ case MAPPEDGRAY: >+ case TRUECOLOR: >+ for (row = 0; row < cinfo->image_height; row++) { >+ scanline = * (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); >+ rle_row = source->rle_row; >+ rle_getrow(&source->header, rle_row); >+ >+ for (col = 0; col < cinfo->image_width; col++) { >+ for (channel = 0; channel < source->header.ncolors; channel++) { >+ *scanline++ = (JSAMPLE) >+ (colormap[GETJSAMPLE(rle_row[channel][col]) + 256 * channel] >> 8); >+ } >+ } >+ >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) { >+ progress->pub.pass_counter++; >+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); >+ } >+#endif >+ } >+ break; >+ >+ case DIRECTCOLOR: >+ for (row = 0; row < cinfo->image_height; row++) { >+ scanline = * (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); >+ rle_getrow(&source->header, rle_row); >+ >+ red_ptr = rle_row[0]; >+ green_ptr = rle_row[1]; >+ blue_ptr = rle_row[2]; >+ >+ for (col = cinfo->image_width; col > 0; col--) { >+ *scanline++ = *red_ptr++; >+ *scanline++ = *green_ptr++; >+ *scanline++ = *blue_ptr++; >+ } >+ >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) { >+ progress->pub.pass_counter++; >+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); >+ } >+#endif >+ } >+ } >+ >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) >+ progress->completed_extra_passes++; >+#endif >+ >+ /* Set up to call proper row-extraction routine in future */ >+ if (source->visual == PSEUDOCOLOR) { >+ source->pub.buffer = source->rle_row; >+ source->pub.get_pixel_rows = get_pseudocolor_row; >+ } else { >+ source->pub.get_pixel_rows = get_rle_row; >+ } >+ source->row = cinfo->image_height; >+ >+ /* And fetch the topmost (bottommost) row */ >+ return (*source->pub.get_pixel_rows) (cinfo, sinfo); >+} >+ >+ >+/* >+ * Finish up at the end of the file. >+ */ >+ >+METHODDEF(void) >+finish_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ /* no work */ >+} >+ >+ >+/* >+ * The module selection routine for RLE format input. >+ */ >+ >+GLOBAL(cjpeg_source_ptr) >+jinit_read_rle (j_compress_ptr cinfo) >+{ >+ rle_source_ptr source; >+ >+ /* Create module interface object */ >+ source = (rle_source_ptr) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(rle_source_struct)); >+ /* Fill in method ptrs */ >+ source->pub.start_input = start_input_rle; >+ source->pub.finish_input = finish_input_rle; >+ source->pub.get_pixel_rows = load_image; >+ >+ return (cjpeg_source_ptr) source; >+} >+ >+#endif /* RLE_SUPPORTED */ >diff --git a/modules/libjpeg-turbo/rdswitch.c b/modules/libjpeg-turbo/rdswitch.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/rdswitch.c >@@ -0,0 +1,332 @@ >+/* >+ * rdswitch.c >+ * >+ * Copyright (C) 1991-1996, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to process some of cjpeg's more complicated >+ * command-line switches. Switches processed here are: >+ * -qtables file Read quantization tables from text file >+ * -scans file Read scan script from text file >+ * -qslots N[,N,...] Set component quantization table selectors >+ * -sample HxV[,HxV,...] Set component sampling factors >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+#include <ctype.h> /* to declare isdigit(), isspace() */ >+ >+ >+LOCAL(int) >+text_getc (FILE * file) >+/* Read next char, skipping over any comments (# to end of line) */ >+/* A comment/newline sequence is returned as a newline */ >+{ >+ register int ch; >+ >+ ch = getc(file); >+ if (ch == '#') { >+ do { >+ ch = getc(file); >+ } while (ch != '\n' && ch != EOF); >+ } >+ return ch; >+} >+ >+ >+LOCAL(boolean) >+read_text_integer (FILE * file, long * result, int * termchar) >+/* Read an unsigned decimal integer from a file, store it in result */ >+/* Reads one trailing character after the integer; returns it in termchar */ >+{ >+ register int ch; >+ register long val; >+ >+ /* Skip any leading whitespace, detect EOF */ >+ do { >+ ch = text_getc(file); >+ if (ch == EOF) { >+ *termchar = ch; >+ return FALSE; >+ } >+ } while (isspace(ch)); >+ >+ if (! isdigit(ch)) { >+ *termchar = ch; >+ return FALSE; >+ } >+ >+ val = ch - '0'; >+ while ((ch = text_getc(file)) != EOF) { >+ if (! isdigit(ch)) >+ break; >+ val *= 10; >+ val += ch - '0'; >+ } >+ *result = val; >+ *termchar = ch; >+ return TRUE; >+} >+ >+ >+GLOBAL(boolean) >+read_quant_tables (j_compress_ptr cinfo, char * filename, >+ int scale_factor, boolean force_baseline) >+/* Read a set of quantization tables from the specified file. >+ * The file is plain ASCII text: decimal numbers with whitespace between. >+ * Comments preceded by '#' may be included in the file. >+ * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values. >+ * The tables are implicitly numbered 0,1,etc. >+ * NOTE: does not affect the qslots mapping, which will default to selecting >+ * table 0 for luminance (or primary) components, 1 for chrominance components. >+ * You must use -qslots if you want a different component->table mapping. >+ */ >+{ >+ FILE * fp; >+ int tblno, i, termchar; >+ long val; >+ unsigned int table[DCTSIZE2]; >+ >+ if ((fp = fopen(filename, "r")) == NULL) { >+ fprintf(stderr, "Can't open table file %s\n", filename); >+ return FALSE; >+ } >+ tblno = 0; >+ >+ while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */ >+ if (tblno >= NUM_QUANT_TBLS) { >+ fprintf(stderr, "Too many tables in file %s\n", filename); >+ fclose(fp); >+ return FALSE; >+ } >+ table[0] = (unsigned int) val; >+ for (i = 1; i < DCTSIZE2; i++) { >+ if (! read_text_integer(fp, &val, &termchar)) { >+ fprintf(stderr, "Invalid table data in file %s\n", filename); >+ fclose(fp); >+ return FALSE; >+ } >+ table[i] = (unsigned int) val; >+ } >+ jpeg_add_quant_table(cinfo, tblno, table, scale_factor, force_baseline); >+ tblno++; >+ } >+ >+ if (termchar != EOF) { >+ fprintf(stderr, "Non-numeric data in file %s\n", filename); >+ fclose(fp); >+ return FALSE; >+ } >+ >+ fclose(fp); >+ return TRUE; >+} >+ >+ >+#ifdef C_MULTISCAN_FILES_SUPPORTED >+ >+LOCAL(boolean) >+read_scan_integer (FILE * file, long * result, int * termchar) >+/* Variant of read_text_integer that always looks for a non-space termchar; >+ * this simplifies parsing of punctuation in scan scripts. >+ */ >+{ >+ register int ch; >+ >+ if (! read_text_integer(file, result, termchar)) >+ return FALSE; >+ ch = *termchar; >+ while (ch != EOF && isspace(ch)) >+ ch = text_getc(file); >+ if (isdigit(ch)) { /* oops, put it back */ >+ if (ungetc(ch, file) == EOF) >+ return FALSE; >+ ch = ' '; >+ } else { >+ /* Any separators other than ';' and ':' are ignored; >+ * this allows user to insert commas, etc, if desired. >+ */ >+ if (ch != EOF && ch != ';' && ch != ':') >+ ch = ' '; >+ } >+ *termchar = ch; >+ return TRUE; >+} >+ >+ >+GLOBAL(boolean) >+read_scan_script (j_compress_ptr cinfo, char * filename) >+/* Read a scan script from the specified text file. >+ * Each entry in the file defines one scan to be emitted. >+ * Entries are separated by semicolons ';'. >+ * An entry contains one to four component indexes, >+ * optionally followed by a colon ':' and four progressive-JPEG parameters. >+ * The component indexes denote which component(s) are to be transmitted >+ * in the current scan. The first component has index 0. >+ * Sequential JPEG is used if the progressive-JPEG parameters are omitted. >+ * The file is free format text: any whitespace may appear between numbers >+ * and the ':' and ';' punctuation marks. Also, other punctuation (such >+ * as commas or dashes) can be placed between numbers if desired. >+ * Comments preceded by '#' may be included in the file. >+ * Note: we do very little validity checking here; >+ * jcmaster.c will validate the script parameters. >+ */ >+{ >+ FILE * fp; >+ int scanno, ncomps, termchar; >+ long val; >+ jpeg_scan_info * scanptr; >+#define MAX_SCANS 100 /* quite arbitrary limit */ >+ jpeg_scan_info scans[MAX_SCANS]; >+ >+ if ((fp = fopen(filename, "r")) == NULL) { >+ fprintf(stderr, "Can't open scan definition file %s\n", filename); >+ return FALSE; >+ } >+ scanptr = scans; >+ scanno = 0; >+ >+ while (read_scan_integer(fp, &val, &termchar)) { >+ if (scanno >= MAX_SCANS) { >+ fprintf(stderr, "Too many scans defined in file %s\n", filename); >+ fclose(fp); >+ return FALSE; >+ } >+ scanptr->component_index[0] = (int) val; >+ ncomps = 1; >+ while (termchar == ' ') { >+ if (ncomps >= MAX_COMPS_IN_SCAN) { >+ fprintf(stderr, "Too many components in one scan in file %s\n", >+ filename); >+ fclose(fp); >+ return FALSE; >+ } >+ if (! read_scan_integer(fp, &val, &termchar)) >+ goto bogus; >+ scanptr->component_index[ncomps] = (int) val; >+ ncomps++; >+ } >+ scanptr->comps_in_scan = ncomps; >+ if (termchar == ':') { >+ if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') >+ goto bogus; >+ scanptr->Ss = (int) val; >+ if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') >+ goto bogus; >+ scanptr->Se = (int) val; >+ if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') >+ goto bogus; >+ scanptr->Ah = (int) val; >+ if (! read_scan_integer(fp, &val, &termchar)) >+ goto bogus; >+ scanptr->Al = (int) val; >+ } else { >+ /* set non-progressive parameters */ >+ scanptr->Ss = 0; >+ scanptr->Se = DCTSIZE2-1; >+ scanptr->Ah = 0; >+ scanptr->Al = 0; >+ } >+ if (termchar != ';' && termchar != EOF) { >+bogus: >+ fprintf(stderr, "Invalid scan entry format in file %s\n", filename); >+ fclose(fp); >+ return FALSE; >+ } >+ scanptr++, scanno++; >+ } >+ >+ if (termchar != EOF) { >+ fprintf(stderr, "Non-numeric data in file %s\n", filename); >+ fclose(fp); >+ return FALSE; >+ } >+ >+ if (scanno > 0) { >+ /* Stash completed scan list in cinfo structure. >+ * NOTE: for cjpeg's use, JPOOL_IMAGE is the right lifetime for this data, >+ * but if you want to compress multiple images you'd want JPOOL_PERMANENT. >+ */ >+ scanptr = (jpeg_scan_info *) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ scanno * SIZEOF(jpeg_scan_info)); >+ MEMCOPY(scanptr, scans, scanno * SIZEOF(jpeg_scan_info)); >+ cinfo->scan_info = scanptr; >+ cinfo->num_scans = scanno; >+ } >+ >+ fclose(fp); >+ return TRUE; >+} >+ >+#endif /* C_MULTISCAN_FILES_SUPPORTED */ >+ >+ >+GLOBAL(boolean) >+set_quant_slots (j_compress_ptr cinfo, char *arg) >+/* Process a quantization-table-selectors parameter string, of the form >+ * N[,N,...] >+ * If there are more components than parameters, the last value is replicated. >+ */ >+{ >+ int val = 0; /* default table # */ >+ int ci; >+ char ch; >+ >+ for (ci = 0; ci < MAX_COMPONENTS; ci++) { >+ if (*arg) { >+ ch = ','; /* if not set by sscanf, will be ',' */ >+ if (sscanf(arg, "%d%c", &val, &ch) < 1) >+ return FALSE; >+ if (ch != ',') /* syntax check */ >+ return FALSE; >+ if (val < 0 || val >= NUM_QUANT_TBLS) { >+ fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n", >+ NUM_QUANT_TBLS-1); >+ return FALSE; >+ } >+ cinfo->comp_info[ci].quant_tbl_no = val; >+ while (*arg && *arg++ != ',') /* advance to next segment of arg string */ >+ ; >+ } else { >+ /* reached end of parameter, set remaining components to last table */ >+ cinfo->comp_info[ci].quant_tbl_no = val; >+ } >+ } >+ return TRUE; >+} >+ >+ >+GLOBAL(boolean) >+set_sample_factors (j_compress_ptr cinfo, char *arg) >+/* Process a sample-factors parameter string, of the form >+ * HxV[,HxV,...] >+ * If there are more components than parameters, "1x1" is assumed for the rest. >+ */ >+{ >+ int ci, val1, val2; >+ char ch1, ch2; >+ >+ for (ci = 0; ci < MAX_COMPONENTS; ci++) { >+ if (*arg) { >+ ch2 = ','; /* if not set by sscanf, will be ',' */ >+ if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3) >+ return FALSE; >+ if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */ >+ return FALSE; >+ if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) { >+ fprintf(stderr, "JPEG sampling factors must be 1..4\n"); >+ return FALSE; >+ } >+ cinfo->comp_info[ci].h_samp_factor = val1; >+ cinfo->comp_info[ci].v_samp_factor = val2; >+ while (*arg && *arg++ != ',') /* advance to next segment of arg string */ >+ ; >+ } else { >+ /* reached end of parameter, set remaining components to 1x1 sampling */ >+ cinfo->comp_info[ci].h_samp_factor = 1; >+ cinfo->comp_info[ci].v_samp_factor = 1; >+ } >+ } >+ return TRUE; >+} >diff --git a/modules/libjpeg-turbo/rdtarga.c b/modules/libjpeg-turbo/rdtarga.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/rdtarga.c >@@ -0,0 +1,500 @@ >+/* >+ * rdtarga.c >+ * >+ * Copyright (C) 1991-1996, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to read input images in Targa format. >+ * >+ * These routines may need modification for non-Unix environments or >+ * specialized applications. As they stand, they assume input from >+ * an ordinary stdio stream. They further assume that reading begins >+ * at the start of the file; start_input may need work if the >+ * user interface has already read some data (e.g., to determine that >+ * the file is indeed Targa format). >+ * >+ * Based on code contributed by Lee Daniel Crocker. >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef TARGA_SUPPORTED >+ >+ >+/* Macros to deal with unsigned chars as efficiently as compiler allows */ >+ >+#ifdef HAVE_UNSIGNED_CHAR >+typedef unsigned char U_CHAR; >+#define UCH(x) ((int) (x)) >+#else /* !HAVE_UNSIGNED_CHAR */ >+#ifdef CHAR_IS_UNSIGNED >+typedef char U_CHAR; >+#define UCH(x) ((int) (x)) >+#else >+typedef char U_CHAR; >+#define UCH(x) ((int) (x) & 0xFF) >+#endif >+#endif /* HAVE_UNSIGNED_CHAR */ >+ >+ >+#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) >+ >+ >+/* Private version of data source object */ >+ >+typedef struct _tga_source_struct * tga_source_ptr; >+ >+typedef struct _tga_source_struct { >+ struct cjpeg_source_struct pub; /* public fields */ >+ >+ j_compress_ptr cinfo; /* back link saves passing separate parm */ >+ >+ JSAMPARRAY colormap; /* Targa colormap (converted to my format) */ >+ >+ jvirt_sarray_ptr whole_image; /* Needed if funny input row order */ >+ JDIMENSION current_row; /* Current logical row number to read */ >+ >+ /* Pointer to routine to extract next Targa pixel from input file */ >+ JMETHOD(void, read_pixel, (tga_source_ptr sinfo)); >+ >+ /* Result of read_pixel is delivered here: */ >+ U_CHAR tga_pixel[4]; >+ >+ int pixel_size; /* Bytes per Targa pixel (1 to 4) */ >+ >+ /* State info for reading RLE-coded pixels; both counts must be init to 0 */ >+ int block_count; /* # of pixels remaining in RLE block */ >+ int dup_pixel_count; /* # of times to duplicate previous pixel */ >+ >+ /* This saves the correct pixel-row-expansion method for preload_image */ >+ JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, >+ cjpeg_source_ptr sinfo)); >+} tga_source_struct; >+ >+ >+/* For expanding 5-bit pixel values to 8-bit with best rounding */ >+ >+static const UINT8 c5to8bits[32] = { >+ 0, 8, 16, 25, 33, 41, 49, 58, >+ 66, 74, 82, 90, 99, 107, 115, 123, >+ 132, 140, 148, 156, 165, 173, 181, 189, >+ 197, 206, 214, 222, 230, 239, 247, 255 >+}; >+ >+ >+ >+LOCAL(int) >+read_byte (tga_source_ptr sinfo) >+/* Read next byte from Targa file */ >+{ >+ register FILE *infile = sinfo->pub.input_file; >+ register int c; >+ >+ if ((c = getc(infile)) == EOF) >+ ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); >+ return c; >+} >+ >+ >+LOCAL(void) >+read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize) >+/* Read the colormap from a Targa file */ >+{ >+ int i; >+ >+ /* Presently only handles 24-bit BGR format */ >+ if (mapentrysize != 24) >+ ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP); >+ >+ for (i = 0; i < cmaplen; i++) { >+ sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); >+ sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); >+ sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); >+ } >+} >+ >+ >+/* >+ * read_pixel methods: get a single pixel from Targa file into tga_pixel[] >+ */ >+ >+METHODDEF(void) >+read_non_rle_pixel (tga_source_ptr sinfo) >+/* Read one Targa pixel from the input file; no RLE expansion */ >+{ >+ register FILE *infile = sinfo->pub.input_file; >+ register int i; >+ >+ for (i = 0; i < sinfo->pixel_size; i++) { >+ sinfo->tga_pixel[i] = (U_CHAR) getc(infile); >+ } >+} >+ >+ >+METHODDEF(void) >+read_rle_pixel (tga_source_ptr sinfo) >+/* Read one Targa pixel from the input file, expanding RLE data as needed */ >+{ >+ register FILE *infile = sinfo->pub.input_file; >+ register int i; >+ >+ /* Duplicate previously read pixel? */ >+ if (sinfo->dup_pixel_count > 0) { >+ sinfo->dup_pixel_count--; >+ return; >+ } >+ >+ /* Time to read RLE block header? */ >+ if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */ >+ i = read_byte(sinfo); >+ if (i & 0x80) { /* Start of duplicate-pixel block? */ >+ sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */ >+ sinfo->block_count = 0; /* then read new block header */ >+ } else { >+ sinfo->block_count = i & 0x7F; /* number of pixels after this one */ >+ } >+ } >+ >+ /* Read next pixel */ >+ for (i = 0; i < sinfo->pixel_size; i++) { >+ sinfo->tga_pixel[i] = (U_CHAR) getc(infile); >+ } >+} >+ >+ >+/* >+ * Read one row of pixels. >+ * >+ * We provide several different versions depending on input file format. >+ */ >+ >+ >+METHODDEF(JDIMENSION) >+get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading 8-bit grayscale pixels */ >+{ >+ tga_source_ptr source = (tga_source_ptr) sinfo; >+ register JSAMPROW ptr; >+ register JDIMENSION col; >+ >+ ptr = source->pub.buffer[0]; >+ for (col = cinfo->image_width; col > 0; col--) { >+ (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ >+ *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); >+ } >+ return 1; >+} >+ >+METHODDEF(JDIMENSION) >+get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading 8-bit colormap indexes */ >+{ >+ tga_source_ptr source = (tga_source_ptr) sinfo; >+ register int t; >+ register JSAMPROW ptr; >+ register JDIMENSION col; >+ register JSAMPARRAY colormap = source->colormap; >+ >+ ptr = source->pub.buffer[0]; >+ for (col = cinfo->image_width; col > 0; col--) { >+ (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ >+ t = UCH(source->tga_pixel[0]); >+ *ptr++ = colormap[0][t]; >+ *ptr++ = colormap[1][t]; >+ *ptr++ = colormap[2][t]; >+ } >+ return 1; >+} >+ >+METHODDEF(JDIMENSION) >+get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading 16-bit pixels */ >+{ >+ tga_source_ptr source = (tga_source_ptr) sinfo; >+ register int t; >+ register JSAMPROW ptr; >+ register JDIMENSION col; >+ >+ ptr = source->pub.buffer[0]; >+ for (col = cinfo->image_width; col > 0; col--) { >+ (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ >+ t = UCH(source->tga_pixel[0]); >+ t += UCH(source->tga_pixel[1]) << 8; >+ /* We expand 5 bit data to 8 bit sample width. >+ * The format of the 16-bit (LSB first) input word is >+ * xRRRRRGGGGGBBBBB >+ */ >+ ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F]; >+ t >>= 5; >+ ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F]; >+ t >>= 5; >+ ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F]; >+ ptr += 3; >+ } >+ return 1; >+} >+ >+METHODDEF(JDIMENSION) >+get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+/* This version is for reading 24-bit pixels */ >+{ >+ tga_source_ptr source = (tga_source_ptr) sinfo; >+ register JSAMPROW ptr; >+ register JDIMENSION col; >+ >+ ptr = source->pub.buffer[0]; >+ for (col = cinfo->image_width; col > 0; col--) { >+ (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ >+ *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */ >+ *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]); >+ *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); >+ } >+ return 1; >+} >+ >+/* >+ * Targa also defines a 32-bit pixel format with order B,G,R,A. >+ * We presently ignore the attribute byte, so the code for reading >+ * these pixels is identical to the 24-bit routine above. >+ * This works because the actual pixel length is only known to read_pixel. >+ */ >+ >+#define get_32bit_row get_24bit_row >+ >+ >+/* >+ * This method is for re-reading the input data in standard top-down >+ * row order. The entire image has already been read into whole_image >+ * with proper conversion of pixel format, but it's in a funny row order. >+ */ >+ >+METHODDEF(JDIMENSION) >+get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ tga_source_ptr source = (tga_source_ptr) sinfo; >+ JDIMENSION source_row; >+ >+ /* Compute row of source that maps to current_row of normal order */ >+ /* For now, assume image is bottom-up and not interlaced. */ >+ /* NEEDS WORK to support interlaced images! */ >+ source_row = cinfo->image_height - source->current_row - 1; >+ >+ /* Fetch that row from virtual array */ >+ source->pub.buffer = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, source->whole_image, >+ source_row, (JDIMENSION) 1, FALSE); >+ >+ source->current_row++; >+ return 1; >+} >+ >+ >+/* >+ * This method loads the image into whole_image during the first call on >+ * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call >+ * get_memory_row on subsequent calls. >+ */ >+ >+METHODDEF(JDIMENSION) >+preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ tga_source_ptr source = (tga_source_ptr) sinfo; >+ JDIMENSION row; >+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; >+ >+ /* Read the data into a virtual array in input-file row order. */ >+ for (row = 0; row < cinfo->image_height; row++) { >+ if (progress != NULL) { >+ progress->pub.pass_counter = (long) row; >+ progress->pub.pass_limit = (long) cinfo->image_height; >+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); >+ } >+ source->pub.buffer = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE); >+ (*source->get_pixel_rows) (cinfo, sinfo); >+ } >+ if (progress != NULL) >+ progress->completed_extra_passes++; >+ >+ /* Set up to read from the virtual array in unscrambled order */ >+ source->pub.get_pixel_rows = get_memory_row; >+ source->current_row = 0; >+ /* And read the first row */ >+ return get_memory_row(cinfo, sinfo); >+} >+ >+ >+/* >+ * Read the file header; return image size and component count. >+ */ >+ >+METHODDEF(void) >+start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ tga_source_ptr source = (tga_source_ptr) sinfo; >+ U_CHAR targaheader[18]; >+ int idlen, cmaptype, subtype, flags, interlace_type, components; >+ unsigned int width, height, maplen; >+ boolean is_bottom_up; >+ >+#define GET_2B(offset) ((unsigned int) UCH(targaheader[offset]) + \ >+ (((unsigned int) UCH(targaheader[offset+1])) << 8)) >+ >+ if (! ReadOK(source->pub.input_file, targaheader, 18)) >+ ERREXIT(cinfo, JERR_INPUT_EOF); >+ >+ /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */ >+ if (targaheader[16] == 15) >+ targaheader[16] = 16; >+ >+ idlen = UCH(targaheader[0]); >+ cmaptype = UCH(targaheader[1]); >+ subtype = UCH(targaheader[2]); >+ maplen = GET_2B(5); >+ width = GET_2B(12); >+ height = GET_2B(14); >+ source->pixel_size = UCH(targaheader[16]) >> 3; >+ flags = UCH(targaheader[17]); /* Image Descriptor byte */ >+ >+ is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */ >+ interlace_type = flags >> 6; /* bits 6/7 are interlace code */ >+ >+ if (cmaptype > 1 || /* cmaptype must be 0 or 1 */ >+ source->pixel_size < 1 || source->pixel_size > 4 || >+ (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */ >+ interlace_type != 0) /* currently don't allow interlaced image */ >+ ERREXIT(cinfo, JERR_TGA_BADPARMS); >+ >+ if (subtype > 8) { >+ /* It's an RLE-coded file */ >+ source->read_pixel = read_rle_pixel; >+ source->block_count = source->dup_pixel_count = 0; >+ subtype -= 8; >+ } else { >+ /* Non-RLE file */ >+ source->read_pixel = read_non_rle_pixel; >+ } >+ >+ /* Now should have subtype 1, 2, or 3 */ >+ components = 3; /* until proven different */ >+ cinfo->in_color_space = JCS_RGB; >+ >+ switch (subtype) { >+ case 1: /* Colormapped image */ >+ if (source->pixel_size == 1 && cmaptype == 1) >+ source->get_pixel_rows = get_8bit_row; >+ else >+ ERREXIT(cinfo, JERR_TGA_BADPARMS); >+ TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height); >+ break; >+ case 2: /* RGB image */ >+ switch (source->pixel_size) { >+ case 2: >+ source->get_pixel_rows = get_16bit_row; >+ break; >+ case 3: >+ source->get_pixel_rows = get_24bit_row; >+ break; >+ case 4: >+ source->get_pixel_rows = get_32bit_row; >+ break; >+ default: >+ ERREXIT(cinfo, JERR_TGA_BADPARMS); >+ break; >+ } >+ TRACEMS2(cinfo, 1, JTRC_TGA, width, height); >+ break; >+ case 3: /* Grayscale image */ >+ components = 1; >+ cinfo->in_color_space = JCS_GRAYSCALE; >+ if (source->pixel_size == 1) >+ source->get_pixel_rows = get_8bit_gray_row; >+ else >+ ERREXIT(cinfo, JERR_TGA_BADPARMS); >+ TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height); >+ break; >+ default: >+ ERREXIT(cinfo, JERR_TGA_BADPARMS); >+ break; >+ } >+ >+ if (is_bottom_up) { >+ /* Create a virtual array to buffer the upside-down image. */ >+ source->whole_image = (*cinfo->mem->request_virt_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, >+ (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1); >+ if (cinfo->progress != NULL) { >+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; >+ progress->total_extra_passes++; /* count file input as separate pass */ >+ } >+ /* source->pub.buffer will point to the virtual array. */ >+ source->pub.buffer_height = 1; /* in case anyone looks at it */ >+ source->pub.get_pixel_rows = preload_image; >+ } else { >+ /* Don't need a virtual array, but do need a one-row input buffer. */ >+ source->whole_image = NULL; >+ source->pub.buffer = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ (JDIMENSION) width * components, (JDIMENSION) 1); >+ source->pub.buffer_height = 1; >+ source->pub.get_pixel_rows = source->get_pixel_rows; >+ } >+ >+ while (idlen--) /* Throw away ID field */ >+ (void) read_byte(source); >+ >+ if (maplen > 0) { >+ if (maplen > 256 || GET_2B(3) != 0) >+ ERREXIT(cinfo, JERR_TGA_BADCMAP); >+ /* Allocate space to store the colormap */ >+ source->colormap = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3); >+ /* and read it from the file */ >+ read_colormap(source, (int) maplen, UCH(targaheader[7])); >+ } else { >+ if (cmaptype) /* but you promised a cmap! */ >+ ERREXIT(cinfo, JERR_TGA_BADPARMS); >+ source->colormap = NULL; >+ } >+ >+ cinfo->input_components = components; >+ cinfo->data_precision = 8; >+ cinfo->image_width = width; >+ cinfo->image_height = height; >+} >+ >+ >+/* >+ * Finish up at the end of the file. >+ */ >+ >+METHODDEF(void) >+finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) >+{ >+ /* no work */ >+} >+ >+ >+/* >+ * The module selection routine for Targa format input. >+ */ >+ >+GLOBAL(cjpeg_source_ptr) >+jinit_read_targa (j_compress_ptr cinfo) >+{ >+ tga_source_ptr source; >+ >+ /* Create module interface object */ >+ source = (tga_source_ptr) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(tga_source_struct)); >+ source->cinfo = cinfo; /* make back link for subroutines */ >+ /* Fill in method ptrs, except get_pixel_rows which start_input sets */ >+ source->pub.start_input = start_input_tga; >+ source->pub.finish_input = finish_input_tga; >+ >+ return (cjpeg_source_ptr) source; >+} >+ >+#endif /* TARGA_SUPPORTED */ >diff --git a/modules/libjpeg-turbo/simd/Makefile.am b/modules/libjpeg-turbo/simd/Makefile.am >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/Makefile.am >@@ -0,0 +1,58 @@ >+noinst_LTLIBRARIES = libsimd.la >+ >+BUILT_SOURCES = jsimdcfg.inc >+ >+EXTRA_DIST = nasm_lt.sh jcclrmmx.asm jcclrss2.asm jdclrmmx.asm jdclrss2.asm \ >+ jdmrgmmx.asm jdmrgss2.asm jcclrss2-64.asm jdclrss2-64.asm \ >+ jdmrgss2-64.asm >+ >+if SIMD_X86_64 >+ >+libsimd_la_SOURCES = jsimd_x86_64.c \ >+ jsimd.h jsimdcfg.inc.h \ >+ jsimdext.inc jcolsamp.inc jdct.inc \ >+ jfsseflt-64.asm \ >+ jccolss2-64.asm jdcolss2-64.asm \ >+ jcsamss2-64.asm jdsamss2-64.asm jdmerss2-64.asm \ >+ jcqnts2i-64.asm jfss2fst-64.asm jfss2int-64.asm \ >+ jiss2red-64.asm jiss2int-64.asm jiss2fst-64.asm \ >+ jcqnts2f-64.asm jiss2flt-64.asm >+ >+jccolss2-64.lo: jcclrss2-64.asm >+jdcolss2-64.lo: jdclrss2-64.asm >+jdmerss2-64.lo: jdmrgss2-64.asm >+endif >+ >+if SIMD_I386 >+ >+libsimd_la_SOURCES = jsimd_i386.c \ >+ jsimd.h jsimdcfg.inc.h \ >+ jsimdext.inc jcolsamp.inc jdct.inc \ >+ jsimdcpu.asm \ >+ jccolmmx.asm jdcolmmx.asm \ >+ jcsammmx.asm jdsammmx.asm jdmermmx.asm \ >+ jcqntmmx.asm jfmmxfst.asm jfmmxint.asm \ >+ jimmxred.asm jimmxint.asm jimmxfst.asm \ >+ jcqnt3dn.asm jf3dnflt.asm ji3dnflt.asm \ >+ jcqntsse.asm jfsseflt.asm jisseflt.asm \ >+ jccolss2.asm jdcolss2.asm \ >+ jcsamss2.asm jdsamss2.asm jdmerss2.asm \ >+ jcqnts2i.asm jfss2fst.asm jfss2int.asm \ >+ jiss2red.asm jiss2int.asm jiss2fst.asm \ >+ jcqnts2f.asm jiss2flt.asm >+ >+jccolmmx.lo: jcclrmmx.asm >+jccolss2.lo: jcclrss2.asm >+jdcolmmx.lo: jdclrmmx.asm >+jdcolss2.lo: jdclrss2.asm >+jdmermmx.lo: jdmrgmmx.asm >+jdmerss2.lo: jdmrgss2.asm >+endif >+ >+AM_CPPFLAGS = -I$(top_srcdir) >+ >+.asm.lo: >+ $(LIBTOOL) --mode=compile --tag NASM $(srcdir)/nasm_lt.sh $(NASM) $(NAFLAGS) -I$(srcdir) $< -o $@ >+ >+jsimdcfg.inc: $(srcdir)/jsimdcfg.inc.h ../jpeglib.h ../jconfig.h ../jmorecfg.h >+ $(CPP) -I$(top_builddir) -I$(top_builddir)/simd $(srcdir)/jsimdcfg.inc.h | $(EGREP) "^[\;%]|^\ %" | sed 's%_cpp_protection_%%' | sed 's@% define@%define@g' > $@ >diff --git a/modules/libjpeg-turbo/simd/Makefile.in b/modules/libjpeg-turbo/simd/Makefile.in >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/Makefile.in >@@ -0,0 +1,48 @@ >+# >+# ***** BEGIN LICENSE BLOCK ***** >+# Version: MPL 1.1/GPL 2.0/LGPL 2.1 >+# >+# The contents of this file are subject to the Mozilla Public License Version >+# 1.1 (the "License"); you may not use this file except in compliance with >+# the License. You may obtain a copy of the License at >+# http://www.mozilla.org/MPL/ >+# >+# Software distributed under the License is distributed on an "AS IS" basis, >+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License >+# for the specific language governing rights and limitations under the >+# License. >+# >+# The Original Code is mozilla.org code. >+# >+# The Initial Developer of the Original Code is >+# Mozilla Corporation >+# Portions created by the Initial Developer are Copyright (C) 2010 >+# the Initial Developer. All Rights Reserved. >+# >+# Contributor(s): >+# Justin Lebar <justin.lebar@gmail.com> >+# >+# Alternatively, the contents of this file may be used under the terms of >+# either the GNU General Public License Version 2 or later (the "GPL"), or >+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), >+# in which case the provisions of the GPL or the LGPL are applicable instead >+# of those above. If you wish to allow use of your version of this file only >+# under the terms of either the GPL or the LGPL, and not to allow others to >+# use your version of this file under the terms of the MPL, indicate your >+# decision by deleting the provisions above and replace them with the notice >+# and other provisions required by the GPL or the LGPL. If you do not delete >+# the provisions above, a recipient may use your version of this file under >+# the terms of any one of the MPL, the GPL or the LGPL. >+# >+# ***** END LICENSE BLOCK ***** >+ >+DEPTH = ../../.. >+topsrcdir = @top_srcdir@ >+srcdir = @srcdir@ >+VPATH = @srcdir@ >+ >+include $(DEPTH)/config/autoconf.mk >+ >+# empty makefile so this directory gets created in the objdir. >+ >+include $(topsrcdir)/config/rules.mk >diff --git a/modules/libjpeg-turbo/simd/jcclrmmx.asm b/modules/libjpeg-turbo/simd/jcclrmmx.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcclrmmx.asm >@@ -0,0 +1,479 @@ >+; >+; jcclrmmx.asm - colorspace conversion (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jcolsamp.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Convert some rows of samples to the output colorspace. >+; >+; GLOBAL(void) >+; jsimd_rgb_ycc_convert_mmx (JDIMENSION img_width, >+; JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+; JDIMENSION output_row, int num_rows); >+; >+ >+%define img_width(b) (b)+8 ; JDIMENSION img_width >+%define input_buf(b) (b)+12 ; JSAMPARRAY input_buf >+%define output_buf(b) (b)+16 ; JSAMPIMAGE output_buf >+%define output_row(b) (b)+20 ; JDIMENSION output_row >+%define num_rows(b) (b)+24 ; int num_rows >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 8 >+%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr >+ >+ align 16 >+ global EXTN(jsimd_rgb_ycc_convert_mmx) >+ >+EXTN(jsimd_rgb_ycc_convert_mmx): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic eax ; make a room for GOT address >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ movpic POINTER [gotptr], ebx ; save GOT address >+ >+ mov ecx, JDIMENSION [img_width(eax)] ; num_cols >+ test ecx,ecx >+ jz near .return >+ >+ push ecx >+ >+ mov esi, JSAMPIMAGE [output_buf(eax)] >+ mov ecx, JDIMENSION [output_row(eax)] >+ mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY] >+ mov ebx, JSAMPARRAY [esi+1*SIZEOF_JSAMPARRAY] >+ mov edx, JSAMPARRAY [esi+2*SIZEOF_JSAMPARRAY] >+ lea edi, [edi+ecx*SIZEOF_JSAMPROW] >+ lea ebx, [ebx+ecx*SIZEOF_JSAMPROW] >+ lea edx, [edx+ecx*SIZEOF_JSAMPROW] >+ >+ pop ecx >+ >+ mov esi, JSAMPARRAY [input_buf(eax)] >+ mov eax, INT [num_rows(eax)] >+ test eax,eax >+ jle near .return >+ alignx 16,7 >+.rowloop: >+ pushpic eax >+ push edx >+ push ebx >+ push edi >+ push esi >+ push ecx ; col >+ >+ mov esi, JSAMPROW [esi] ; inptr >+ mov edi, JSAMPROW [edi] ; outptr0 >+ mov ebx, JSAMPROW [ebx] ; outptr1 >+ mov edx, JSAMPROW [edx] ; outptr2 >+ movpic eax, POINTER [gotptr] ; load GOT address (eax) >+ >+ cmp ecx, byte SIZEOF_MMWORD >+ jae short .columnloop >+ alignx 16,7 >+ >+%if RGB_PIXELSIZE == 3 ; --------------- >+ >+.column_ld1: >+ push eax >+ push edx >+ lea ecx,[ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE >+ test cl, SIZEOF_BYTE >+ jz short .column_ld2 >+ sub ecx, byte SIZEOF_BYTE >+ xor eax,eax >+ mov al, BYTE [esi+ecx] >+.column_ld2: >+ test cl, SIZEOF_WORD >+ jz short .column_ld4 >+ sub ecx, byte SIZEOF_WORD >+ xor edx,edx >+ mov dx, WORD [esi+ecx] >+ shl eax, WORD_BIT >+ or eax,edx >+.column_ld4: >+ movd mmA,eax >+ pop edx >+ pop eax >+ test cl, SIZEOF_DWORD >+ jz short .column_ld8 >+ sub ecx, byte SIZEOF_DWORD >+ movd mmG, DWORD [esi+ecx] >+ psllq mmA, DWORD_BIT >+ por mmA,mmG >+.column_ld8: >+ test cl, SIZEOF_MMWORD >+ jz short .column_ld16 >+ movq mmG,mmA >+ movq mmA, MMWORD [esi+0*SIZEOF_MMWORD] >+ mov ecx, SIZEOF_MMWORD >+ jmp short .rgb_ycc_cnv >+.column_ld16: >+ test cl, 2*SIZEOF_MMWORD >+ mov ecx, SIZEOF_MMWORD >+ jz short .rgb_ycc_cnv >+ movq mmF,mmA >+ movq mmA, MMWORD [esi+0*SIZEOF_MMWORD] >+ movq mmG, MMWORD [esi+1*SIZEOF_MMWORD] >+ jmp short .rgb_ycc_cnv >+ alignx 16,7 >+ >+.columnloop: >+ movq mmA, MMWORD [esi+0*SIZEOF_MMWORD] >+ movq mmG, MMWORD [esi+1*SIZEOF_MMWORD] >+ movq mmF, MMWORD [esi+2*SIZEOF_MMWORD] >+ >+.rgb_ycc_cnv: >+ ; mmA=(00 10 20 01 11 21 02 12) >+ ; mmG=(22 03 13 23 04 14 24 05) >+ ; mmF=(15 25 06 16 26 07 17 27) >+ >+ movq mmD,mmA >+ psllq mmA,4*BYTE_BIT ; mmA=(-- -- -- -- 00 10 20 01) >+ psrlq mmD,4*BYTE_BIT ; mmD=(11 21 02 12 -- -- -- --) >+ >+ punpckhbw mmA,mmG ; mmA=(00 04 10 14 20 24 01 05) >+ psllq mmG,4*BYTE_BIT ; mmG=(-- -- -- -- 22 03 13 23) >+ >+ punpcklbw mmD,mmF ; mmD=(11 15 21 25 02 06 12 16) >+ punpckhbw mmG,mmF ; mmG=(22 26 03 07 13 17 23 27) >+ >+ movq mmE,mmA >+ psllq mmA,4*BYTE_BIT ; mmA=(-- -- -- -- 00 04 10 14) >+ psrlq mmE,4*BYTE_BIT ; mmE=(20 24 01 05 -- -- -- --) >+ >+ punpckhbw mmA,mmD ; mmA=(00 02 04 06 10 12 14 16) >+ psllq mmD,4*BYTE_BIT ; mmD=(-- -- -- -- 11 15 21 25) >+ >+ punpcklbw mmE,mmG ; mmE=(20 22 24 26 01 03 05 07) >+ punpckhbw mmD,mmG ; mmD=(11 13 15 17 21 23 25 27) >+ >+ pxor mmH,mmH >+ >+ movq mmC,mmA >+ punpcklbw mmA,mmH ; mmA=(00 02 04 06) >+ punpckhbw mmC,mmH ; mmC=(10 12 14 16) >+ >+ movq mmB,mmE >+ punpcklbw mmE,mmH ; mmE=(20 22 24 26) >+ punpckhbw mmB,mmH ; mmB=(01 03 05 07) >+ >+ movq mmF,mmD >+ punpcklbw mmD,mmH ; mmD=(11 13 15 17) >+ punpckhbw mmF,mmH ; mmF=(21 23 25 27) >+ >+%else ; RGB_PIXELSIZE == 4 ; ----------- >+ >+.column_ld1: >+ test cl, SIZEOF_MMWORD/8 >+ jz short .column_ld2 >+ sub ecx, byte SIZEOF_MMWORD/8 >+ movd mmA, DWORD [esi+ecx*RGB_PIXELSIZE] >+.column_ld2: >+ test cl, SIZEOF_MMWORD/4 >+ jz short .column_ld4 >+ sub ecx, byte SIZEOF_MMWORD/4 >+ movq mmF,mmA >+ movq mmA, MMWORD [esi+ecx*RGB_PIXELSIZE] >+.column_ld4: >+ test cl, SIZEOF_MMWORD/2 >+ mov ecx, SIZEOF_MMWORD >+ jz short .rgb_ycc_cnv >+ movq mmD,mmA >+ movq mmC,mmF >+ movq mmA, MMWORD [esi+0*SIZEOF_MMWORD] >+ movq mmF, MMWORD [esi+1*SIZEOF_MMWORD] >+ jmp short .rgb_ycc_cnv >+ alignx 16,7 >+ >+.columnloop: >+ movq mmA, MMWORD [esi+0*SIZEOF_MMWORD] >+ movq mmF, MMWORD [esi+1*SIZEOF_MMWORD] >+ movq mmD, MMWORD [esi+2*SIZEOF_MMWORD] >+ movq mmC, MMWORD [esi+3*SIZEOF_MMWORD] >+ >+.rgb_ycc_cnv: >+ ; mmA=(00 10 20 30 01 11 21 31) >+ ; mmF=(02 12 22 32 03 13 23 33) >+ ; mmD=(04 14 24 34 05 15 25 35) >+ ; mmC=(06 16 26 36 07 17 27 37) >+ >+ movq mmB,mmA >+ punpcklbw mmA,mmF ; mmA=(00 02 10 12 20 22 30 32) >+ punpckhbw mmB,mmF ; mmB=(01 03 11 13 21 23 31 33) >+ >+ movq mmG,mmD >+ punpcklbw mmD,mmC ; mmD=(04 06 14 16 24 26 34 36) >+ punpckhbw mmG,mmC ; mmG=(05 07 15 17 25 27 35 37) >+ >+ movq mmE,mmA >+ punpcklwd mmA,mmD ; mmA=(00 02 04 06 10 12 14 16) >+ punpckhwd mmE,mmD ; mmE=(20 22 24 26 30 32 34 36) >+ >+ movq mmH,mmB >+ punpcklwd mmB,mmG ; mmB=(01 03 05 07 11 13 15 17) >+ punpckhwd mmH,mmG ; mmH=(21 23 25 27 31 33 35 37) >+ >+ pxor mmF,mmF >+ >+ movq mmC,mmA >+ punpcklbw mmA,mmF ; mmA=(00 02 04 06) >+ punpckhbw mmC,mmF ; mmC=(10 12 14 16) >+ >+ movq mmD,mmB >+ punpcklbw mmB,mmF ; mmB=(01 03 05 07) >+ punpckhbw mmD,mmF ; mmD=(11 13 15 17) >+ >+ movq mmG,mmE >+ punpcklbw mmE,mmF ; mmE=(20 22 24 26) >+ punpckhbw mmG,mmF ; mmG=(30 32 34 36) >+ >+ punpcklbw mmF,mmH >+ punpckhbw mmH,mmH >+ psrlw mmF,BYTE_BIT ; mmF=(21 23 25 27) >+ psrlw mmH,BYTE_BIT ; mmH=(31 33 35 37) >+ >+%endif ; RGB_PIXELSIZE ; --------------- >+ >+ ; mm0=(R0 R2 R4 R6)=RE, mm2=(G0 G2 G4 G6)=GE, mm4=(B0 B2 B4 B6)=BE >+ ; mm1=(R1 R3 R5 R7)=RO, mm3=(G1 G3 G5 G7)=GO, mm5=(B1 B3 B5 B7)=BO >+ >+ ; (Original) >+ ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B >+ ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE >+ ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE >+ ; >+ ; (This implementation) >+ ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G >+ ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE >+ ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE >+ >+ movq MMWORD [wk(0)], mm0 ; wk(0)=RE >+ movq MMWORD [wk(1)], mm1 ; wk(1)=RO >+ movq MMWORD [wk(2)], mm4 ; wk(2)=BE >+ movq MMWORD [wk(3)], mm5 ; wk(3)=BO >+ >+ movq mm6,mm1 >+ punpcklwd mm1,mm3 >+ punpckhwd mm6,mm3 >+ movq mm7,mm1 >+ movq mm4,mm6 >+ pmaddwd mm1,[GOTOFF(eax,PW_F0299_F0337)] ; mm1=ROL*FIX(0.299)+GOL*FIX(0.337) >+ pmaddwd mm6,[GOTOFF(eax,PW_F0299_F0337)] ; mm6=ROH*FIX(0.299)+GOH*FIX(0.337) >+ pmaddwd mm7,[GOTOFF(eax,PW_MF016_MF033)] ; mm7=ROL*-FIX(0.168)+GOL*-FIX(0.331) >+ pmaddwd mm4,[GOTOFF(eax,PW_MF016_MF033)] ; mm4=ROH*-FIX(0.168)+GOH*-FIX(0.331) >+ >+ movq MMWORD [wk(4)], mm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337) >+ movq MMWORD [wk(5)], mm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337) >+ >+ pxor mm1,mm1 >+ pxor mm6,mm6 >+ punpcklwd mm1,mm5 ; mm1=BOL >+ punpckhwd mm6,mm5 ; mm6=BOH >+ psrld mm1,1 ; mm1=BOL*FIX(0.500) >+ psrld mm6,1 ; mm6=BOH*FIX(0.500) >+ >+ movq mm5,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm5=[PD_ONEHALFM1_CJ] >+ >+ paddd mm7,mm1 >+ paddd mm4,mm6 >+ paddd mm7,mm5 >+ paddd mm4,mm5 >+ psrld mm7,SCALEBITS ; mm7=CbOL >+ psrld mm4,SCALEBITS ; mm4=CbOH >+ packssdw mm7,mm4 ; mm7=CbO >+ >+ movq mm1, MMWORD [wk(2)] ; mm1=BE >+ >+ movq mm6,mm0 >+ punpcklwd mm0,mm2 >+ punpckhwd mm6,mm2 >+ movq mm5,mm0 >+ movq mm4,mm6 >+ pmaddwd mm0,[GOTOFF(eax,PW_F0299_F0337)] ; mm0=REL*FIX(0.299)+GEL*FIX(0.337) >+ pmaddwd mm6,[GOTOFF(eax,PW_F0299_F0337)] ; mm6=REH*FIX(0.299)+GEH*FIX(0.337) >+ pmaddwd mm5,[GOTOFF(eax,PW_MF016_MF033)] ; mm5=REL*-FIX(0.168)+GEL*-FIX(0.331) >+ pmaddwd mm4,[GOTOFF(eax,PW_MF016_MF033)] ; mm4=REH*-FIX(0.168)+GEH*-FIX(0.331) >+ >+ movq MMWORD [wk(6)], mm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337) >+ movq MMWORD [wk(7)], mm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337) >+ >+ pxor mm0,mm0 >+ pxor mm6,mm6 >+ punpcklwd mm0,mm1 ; mm0=BEL >+ punpckhwd mm6,mm1 ; mm6=BEH >+ psrld mm0,1 ; mm0=BEL*FIX(0.500) >+ psrld mm6,1 ; mm6=BEH*FIX(0.500) >+ >+ movq mm1,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm1=[PD_ONEHALFM1_CJ] >+ >+ paddd mm5,mm0 >+ paddd mm4,mm6 >+ paddd mm5,mm1 >+ paddd mm4,mm1 >+ psrld mm5,SCALEBITS ; mm5=CbEL >+ psrld mm4,SCALEBITS ; mm4=CbEH >+ packssdw mm5,mm4 ; mm5=CbE >+ >+ psllw mm7,BYTE_BIT >+ por mm5,mm7 ; mm5=Cb >+ movq MMWORD [ebx], mm5 ; Save Cb >+ >+ movq mm0, MMWORD [wk(3)] ; mm0=BO >+ movq mm6, MMWORD [wk(2)] ; mm6=BE >+ movq mm1, MMWORD [wk(1)] ; mm1=RO >+ >+ movq mm4,mm0 >+ punpcklwd mm0,mm3 >+ punpckhwd mm4,mm3 >+ movq mm7,mm0 >+ movq mm5,mm4 >+ pmaddwd mm0,[GOTOFF(eax,PW_F0114_F0250)] ; mm0=BOL*FIX(0.114)+GOL*FIX(0.250) >+ pmaddwd mm4,[GOTOFF(eax,PW_F0114_F0250)] ; mm4=BOH*FIX(0.114)+GOH*FIX(0.250) >+ pmaddwd mm7,[GOTOFF(eax,PW_MF008_MF041)] ; mm7=BOL*-FIX(0.081)+GOL*-FIX(0.418) >+ pmaddwd mm5,[GOTOFF(eax,PW_MF008_MF041)] ; mm5=BOH*-FIX(0.081)+GOH*-FIX(0.418) >+ >+ movq mm3,[GOTOFF(eax,PD_ONEHALF)] ; mm3=[PD_ONEHALF] >+ >+ paddd mm0, MMWORD [wk(4)] >+ paddd mm4, MMWORD [wk(5)] >+ paddd mm0,mm3 >+ paddd mm4,mm3 >+ psrld mm0,SCALEBITS ; mm0=YOL >+ psrld mm4,SCALEBITS ; mm4=YOH >+ packssdw mm0,mm4 ; mm0=YO >+ >+ pxor mm3,mm3 >+ pxor mm4,mm4 >+ punpcklwd mm3,mm1 ; mm3=ROL >+ punpckhwd mm4,mm1 ; mm4=ROH >+ psrld mm3,1 ; mm3=ROL*FIX(0.500) >+ psrld mm4,1 ; mm4=ROH*FIX(0.500) >+ >+ movq mm1,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm1=[PD_ONEHALFM1_CJ] >+ >+ paddd mm7,mm3 >+ paddd mm5,mm4 >+ paddd mm7,mm1 >+ paddd mm5,mm1 >+ psrld mm7,SCALEBITS ; mm7=CrOL >+ psrld mm5,SCALEBITS ; mm5=CrOH >+ packssdw mm7,mm5 ; mm7=CrO >+ >+ movq mm3, MMWORD [wk(0)] ; mm3=RE >+ >+ movq mm4,mm6 >+ punpcklwd mm6,mm2 >+ punpckhwd mm4,mm2 >+ movq mm1,mm6 >+ movq mm5,mm4 >+ pmaddwd mm6,[GOTOFF(eax,PW_F0114_F0250)] ; mm6=BEL*FIX(0.114)+GEL*FIX(0.250) >+ pmaddwd mm4,[GOTOFF(eax,PW_F0114_F0250)] ; mm4=BEH*FIX(0.114)+GEH*FIX(0.250) >+ pmaddwd mm1,[GOTOFF(eax,PW_MF008_MF041)] ; mm1=BEL*-FIX(0.081)+GEL*-FIX(0.418) >+ pmaddwd mm5,[GOTOFF(eax,PW_MF008_MF041)] ; mm5=BEH*-FIX(0.081)+GEH*-FIX(0.418) >+ >+ movq mm2,[GOTOFF(eax,PD_ONEHALF)] ; mm2=[PD_ONEHALF] >+ >+ paddd mm6, MMWORD [wk(6)] >+ paddd mm4, MMWORD [wk(7)] >+ paddd mm6,mm2 >+ paddd mm4,mm2 >+ psrld mm6,SCALEBITS ; mm6=YEL >+ psrld mm4,SCALEBITS ; mm4=YEH >+ packssdw mm6,mm4 ; mm6=YE >+ >+ psllw mm0,BYTE_BIT >+ por mm6,mm0 ; mm6=Y >+ movq MMWORD [edi], mm6 ; Save Y >+ >+ pxor mm2,mm2 >+ pxor mm4,mm4 >+ punpcklwd mm2,mm3 ; mm2=REL >+ punpckhwd mm4,mm3 ; mm4=REH >+ psrld mm2,1 ; mm2=REL*FIX(0.500) >+ psrld mm4,1 ; mm4=REH*FIX(0.500) >+ >+ movq mm0,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; mm0=[PD_ONEHALFM1_CJ] >+ >+ paddd mm1,mm2 >+ paddd mm5,mm4 >+ paddd mm1,mm0 >+ paddd mm5,mm0 >+ psrld mm1,SCALEBITS ; mm1=CrEL >+ psrld mm5,SCALEBITS ; mm5=CrEH >+ packssdw mm1,mm5 ; mm1=CrE >+ >+ psllw mm7,BYTE_BIT >+ por mm1,mm7 ; mm1=Cr >+ movq MMWORD [edx], mm1 ; Save Cr >+ >+ sub ecx, byte SIZEOF_MMWORD >+ add esi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; inptr >+ add edi, byte SIZEOF_MMWORD ; outptr0 >+ add ebx, byte SIZEOF_MMWORD ; outptr1 >+ add edx, byte SIZEOF_MMWORD ; outptr2 >+ cmp ecx, byte SIZEOF_MMWORD >+ jae near .columnloop >+ test ecx,ecx >+ jnz near .column_ld1 >+ >+ pop ecx ; col >+ pop esi >+ pop edi >+ pop ebx >+ pop edx >+ poppic eax >+ >+ add esi, byte SIZEOF_JSAMPROW ; input_buf >+ add edi, byte SIZEOF_JSAMPROW >+ add ebx, byte SIZEOF_JSAMPROW >+ add edx, byte SIZEOF_JSAMPROW >+ dec eax ; num_rows >+ jg near .rowloop >+ >+ emms ; empty MMX state >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcclrss2-64.asm b/modules/libjpeg-turbo/simd/jcclrss2-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcclrss2-64.asm >@@ -0,0 +1,487 @@ >+; >+; jcclrss2-64.asm - colorspace conversion (64-bit SSE2) >+; >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; Copyright (C) 2009, D. R. Commander. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jcolsamp.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Convert some rows of samples to the output colorspace. >+; >+; GLOBAL(void) >+; jsimd_rgb_ycc_convert_sse2 (JDIMENSION img_width, >+; JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+; JDIMENSION output_row, int num_rows); >+; >+ >+; r10 = JDIMENSION img_width >+; r11 = JSAMPARRAY input_buf >+; r12 = JSAMPIMAGE output_buf >+; r13 = JDIMENSION output_row >+; r14 = int num_rows >+ >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 8 >+ >+ align 16 >+ >+ global EXTN(jsimd_rgb_ycc_convert_sse2) >+ >+EXTN(jsimd_rgb_ycc_convert_sse2): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [wk(0)] >+ collect_args >+ push rbx >+ >+ mov rcx, r10 >+ test rcx,rcx >+ jz near .return >+ >+ push rcx >+ >+ mov rsi, r12 >+ mov rcx, r13 >+ mov rdi, JSAMPARRAY [rsi+0*SIZEOF_JSAMPARRAY] >+ mov rbx, JSAMPARRAY [rsi+1*SIZEOF_JSAMPARRAY] >+ mov rdx, JSAMPARRAY [rsi+2*SIZEOF_JSAMPARRAY] >+ lea rdi, [rdi+rcx*SIZEOF_JSAMPROW] >+ lea rbx, [rbx+rcx*SIZEOF_JSAMPROW] >+ lea rdx, [rdx+rcx*SIZEOF_JSAMPROW] >+ >+ pop rcx >+ >+ mov rsi, r11 >+ mov eax, r14d >+ test rax,rax >+ jle near .return >+.rowloop: >+ push rdx >+ push rbx >+ push rdi >+ push rsi >+ push rcx ; col >+ >+ mov rsi, JSAMPROW [rsi] ; inptr >+ mov rdi, JSAMPROW [rdi] ; outptr0 >+ mov rbx, JSAMPROW [rbx] ; outptr1 >+ mov rdx, JSAMPROW [rdx] ; outptr2 >+ >+ cmp rcx, byte SIZEOF_XMMWORD >+ jae near .columnloop >+ >+%if RGB_PIXELSIZE == 3 ; --------------- >+ >+.column_ld1: >+ push rax >+ push rdx >+ lea rcx,[rcx+rcx*2] ; imul ecx,RGB_PIXELSIZE >+ test cl, SIZEOF_BYTE >+ jz short .column_ld2 >+ sub rcx, byte SIZEOF_BYTE >+ movzx rax, BYTE [rsi+rcx] >+.column_ld2: >+ test cl, SIZEOF_WORD >+ jz short .column_ld4 >+ sub rcx, byte SIZEOF_WORD >+ movzx rdx, WORD [rsi+rcx] >+ shl rax, WORD_BIT >+ or rax,rdx >+.column_ld4: >+ movd xmmA,eax >+ pop rdx >+ pop rax >+ test cl, SIZEOF_DWORD >+ jz short .column_ld8 >+ sub rcx, byte SIZEOF_DWORD >+ movd xmmF, XMM_DWORD [rsi+rcx] >+ pslldq xmmA, SIZEOF_DWORD >+ por xmmA,xmmF >+.column_ld8: >+ test cl, SIZEOF_MMWORD >+ jz short .column_ld16 >+ sub rcx, byte SIZEOF_MMWORD >+ movq xmmB, XMM_MMWORD [rsi+rcx] >+ pslldq xmmA, SIZEOF_MMWORD >+ por xmmA,xmmB >+.column_ld16: >+ test cl, SIZEOF_XMMWORD >+ jz short .column_ld32 >+ movdqa xmmF,xmmA >+ movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ mov rcx, SIZEOF_XMMWORD >+ jmp short .rgb_ycc_cnv >+.column_ld32: >+ test cl, 2*SIZEOF_XMMWORD >+ mov rcx, SIZEOF_XMMWORD >+ jz short .rgb_ycc_cnv >+ movdqa xmmB,xmmA >+ movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ movdqu xmmF, XMMWORD [rsi+1*SIZEOF_XMMWORD] >+ jmp short .rgb_ycc_cnv >+ >+.columnloop: >+ movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ movdqu xmmF, XMMWORD [rsi+1*SIZEOF_XMMWORD] >+ movdqu xmmB, XMMWORD [rsi+2*SIZEOF_XMMWORD] >+ >+.rgb_ycc_cnv: >+ ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05) >+ ; xmmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) >+ ; xmmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F) >+ >+ movdqa xmmG,xmmA >+ pslldq xmmA,8 ; xmmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12) >+ psrldq xmmG,8 ; xmmG=(22 03 13 23 04 14 24 05 -- -- -- -- -- -- -- --) >+ >+ punpckhbw xmmA,xmmF ; xmmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A) >+ pslldq xmmF,8 ; xmmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27) >+ >+ punpcklbw xmmG,xmmB ; xmmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D) >+ punpckhbw xmmF,xmmB ; xmmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F) >+ >+ movdqa xmmD,xmmA >+ pslldq xmmA,8 ; xmmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09) >+ psrldq xmmD,8 ; xmmD=(11 19 21 29 02 0A 12 1A -- -- -- -- -- -- -- --) >+ >+ punpckhbw xmmA,xmmG ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D) >+ pslldq xmmG,8 ; xmmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B) >+ >+ punpcklbw xmmD,xmmF ; xmmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E) >+ punpckhbw xmmG,xmmF ; xmmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F) >+ >+ movdqa xmmE,xmmA >+ pslldq xmmA,8 ; xmmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C) >+ psrldq xmmE,8 ; xmmE=(20 24 28 2C 01 05 09 0D -- -- -- -- -- -- -- --) >+ >+ punpckhbw xmmA,xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E) >+ pslldq xmmD,8 ; xmmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D) >+ >+ punpcklbw xmmE,xmmG ; xmmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F) >+ punpckhbw xmmD,xmmG ; xmmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F) >+ >+ pxor xmmH,xmmH >+ >+ movdqa xmmC,xmmA >+ punpcklbw xmmA,xmmH ; xmmA=(00 02 04 06 08 0A 0C 0E) >+ punpckhbw xmmC,xmmH ; xmmC=(10 12 14 16 18 1A 1C 1E) >+ >+ movdqa xmmB,xmmE >+ punpcklbw xmmE,xmmH ; xmmE=(20 22 24 26 28 2A 2C 2E) >+ punpckhbw xmmB,xmmH ; xmmB=(01 03 05 07 09 0B 0D 0F) >+ >+ movdqa xmmF,xmmD >+ punpcklbw xmmD,xmmH ; xmmD=(11 13 15 17 19 1B 1D 1F) >+ punpckhbw xmmF,xmmH ; xmmF=(21 23 25 27 29 2B 2D 2F) >+ >+%else ; RGB_PIXELSIZE == 4 ; ----------- >+ >+.column_ld1: >+ test cl, SIZEOF_XMMWORD/16 >+ jz short .column_ld2 >+ sub rcx, byte SIZEOF_XMMWORD/16 >+ movd xmmA, XMM_DWORD [rsi+rcx*RGB_PIXELSIZE] >+.column_ld2: >+ test cl, SIZEOF_XMMWORD/8 >+ jz short .column_ld4 >+ sub rcx, byte SIZEOF_XMMWORD/8 >+ movq xmmE, XMM_MMWORD [rsi+rcx*RGB_PIXELSIZE] >+ pslldq xmmA, SIZEOF_MMWORD >+ por xmmA,xmmE >+.column_ld4: >+ test cl, SIZEOF_XMMWORD/4 >+ jz short .column_ld8 >+ sub rcx, byte SIZEOF_XMMWORD/4 >+ movdqa xmmE,xmmA >+ movdqu xmmA, XMMWORD [rsi+rcx*RGB_PIXELSIZE] >+.column_ld8: >+ test cl, SIZEOF_XMMWORD/2 >+ mov rcx, SIZEOF_XMMWORD >+ jz short .rgb_ycc_cnv >+ movdqa xmmF,xmmA >+ movdqa xmmH,xmmE >+ movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ movdqu xmmE, XMMWORD [rsi+1*SIZEOF_XMMWORD] >+ jmp short .rgb_ycc_cnv >+ >+.columnloop: >+ movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ movdqu xmmE, XMMWORD [rsi+1*SIZEOF_XMMWORD] >+ movdqu xmmF, XMMWORD [rsi+2*SIZEOF_XMMWORD] >+ movdqu xmmH, XMMWORD [rsi+3*SIZEOF_XMMWORD] >+ >+.rgb_ycc_cnv: >+ ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33) >+ ; xmmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37) >+ ; xmmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B) >+ ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F) >+ >+ movdqa xmmD,xmmA >+ punpcklbw xmmA,xmmE ; xmmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35) >+ punpckhbw xmmD,xmmE ; xmmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37) >+ >+ movdqa xmmC,xmmF >+ punpcklbw xmmF,xmmH ; xmmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D) >+ punpckhbw xmmC,xmmH ; xmmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F) >+ >+ movdqa xmmB,xmmA >+ punpcklwd xmmA,xmmF ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C) >+ punpckhwd xmmB,xmmF ; xmmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D) >+ >+ movdqa xmmG,xmmD >+ punpcklwd xmmD,xmmC ; xmmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E) >+ punpckhwd xmmG,xmmC ; xmmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F) >+ >+ movdqa xmmE,xmmA >+ punpcklbw xmmA,xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E) >+ punpckhbw xmmE,xmmD ; xmmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E) >+ >+ movdqa xmmH,xmmB >+ punpcklbw xmmB,xmmG ; xmmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F) >+ punpckhbw xmmH,xmmG ; xmmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F) >+ >+ pxor xmmF,xmmF >+ >+ movdqa xmmC,xmmA >+ punpcklbw xmmA,xmmF ; xmmA=(00 02 04 06 08 0A 0C 0E) >+ punpckhbw xmmC,xmmF ; xmmC=(10 12 14 16 18 1A 1C 1E) >+ >+ movdqa xmmD,xmmB >+ punpcklbw xmmB,xmmF ; xmmB=(01 03 05 07 09 0B 0D 0F) >+ punpckhbw xmmD,xmmF ; xmmD=(11 13 15 17 19 1B 1D 1F) >+ >+ movdqa xmmG,xmmE >+ punpcklbw xmmE,xmmF ; xmmE=(20 22 24 26 28 2A 2C 2E) >+ punpckhbw xmmG,xmmF ; xmmG=(30 32 34 36 38 3A 3C 3E) >+ >+ punpcklbw xmmF,xmmH >+ punpckhbw xmmH,xmmH >+ psrlw xmmF,BYTE_BIT ; xmmF=(21 23 25 27 29 2B 2D 2F) >+ psrlw xmmH,BYTE_BIT ; xmmH=(31 33 35 37 39 3B 3D 3F) >+ >+%endif ; RGB_PIXELSIZE ; --------------- >+ >+ ; xmm0=R(02468ACE)=RE, xmm2=G(02468ACE)=GE, xmm4=B(02468ACE)=BE >+ ; xmm1=R(13579BDF)=RO, xmm3=G(13579BDF)=GO, xmm5=B(13579BDF)=BO >+ >+ ; (Original) >+ ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B >+ ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE >+ ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE >+ ; >+ ; (This implementation) >+ ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G >+ ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE >+ ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE >+ >+ movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=RE >+ movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=RO >+ movdqa XMMWORD [wk(2)], xmm4 ; wk(2)=BE >+ movdqa XMMWORD [wk(3)], xmm5 ; wk(3)=BO >+ >+ movdqa xmm6,xmm1 >+ punpcklwd xmm1,xmm3 >+ punpckhwd xmm6,xmm3 >+ movdqa xmm7,xmm1 >+ movdqa xmm4,xmm6 >+ pmaddwd xmm1,[rel PW_F0299_F0337] ; xmm1=ROL*FIX(0.299)+GOL*FIX(0.337) >+ pmaddwd xmm6,[rel PW_F0299_F0337] ; xmm6=ROH*FIX(0.299)+GOH*FIX(0.337) >+ pmaddwd xmm7,[rel PW_MF016_MF033] ; xmm7=ROL*-FIX(0.168)+GOL*-FIX(0.331) >+ pmaddwd xmm4,[rel PW_MF016_MF033] ; xmm4=ROH*-FIX(0.168)+GOH*-FIX(0.331) >+ >+ movdqa XMMWORD [wk(4)], xmm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337) >+ movdqa XMMWORD [wk(5)], xmm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337) >+ >+ pxor xmm1,xmm1 >+ pxor xmm6,xmm6 >+ punpcklwd xmm1,xmm5 ; xmm1=BOL >+ punpckhwd xmm6,xmm5 ; xmm6=BOH >+ psrld xmm1,1 ; xmm1=BOL*FIX(0.500) >+ psrld xmm6,1 ; xmm6=BOH*FIX(0.500) >+ >+ movdqa xmm5,[rel PD_ONEHALFM1_CJ] ; xmm5=[PD_ONEHALFM1_CJ] >+ >+ paddd xmm7,xmm1 >+ paddd xmm4,xmm6 >+ paddd xmm7,xmm5 >+ paddd xmm4,xmm5 >+ psrld xmm7,SCALEBITS ; xmm7=CbOL >+ psrld xmm4,SCALEBITS ; xmm4=CbOH >+ packssdw xmm7,xmm4 ; xmm7=CbO >+ >+ movdqa xmm1, XMMWORD [wk(2)] ; xmm1=BE >+ >+ movdqa xmm6,xmm0 >+ punpcklwd xmm0,xmm2 >+ punpckhwd xmm6,xmm2 >+ movdqa xmm5,xmm0 >+ movdqa xmm4,xmm6 >+ pmaddwd xmm0,[rel PW_F0299_F0337] ; xmm0=REL*FIX(0.299)+GEL*FIX(0.337) >+ pmaddwd xmm6,[rel PW_F0299_F0337] ; xmm6=REH*FIX(0.299)+GEH*FIX(0.337) >+ pmaddwd xmm5,[rel PW_MF016_MF033] ; xmm5=REL*-FIX(0.168)+GEL*-FIX(0.331) >+ pmaddwd xmm4,[rel PW_MF016_MF033] ; xmm4=REH*-FIX(0.168)+GEH*-FIX(0.331) >+ >+ movdqa XMMWORD [wk(6)], xmm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337) >+ movdqa XMMWORD [wk(7)], xmm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337) >+ >+ pxor xmm0,xmm0 >+ pxor xmm6,xmm6 >+ punpcklwd xmm0,xmm1 ; xmm0=BEL >+ punpckhwd xmm6,xmm1 ; xmm6=BEH >+ psrld xmm0,1 ; xmm0=BEL*FIX(0.500) >+ psrld xmm6,1 ; xmm6=BEH*FIX(0.500) >+ >+ movdqa xmm1,[rel PD_ONEHALFM1_CJ] ; xmm1=[PD_ONEHALFM1_CJ] >+ >+ paddd xmm5,xmm0 >+ paddd xmm4,xmm6 >+ paddd xmm5,xmm1 >+ paddd xmm4,xmm1 >+ psrld xmm5,SCALEBITS ; xmm5=CbEL >+ psrld xmm4,SCALEBITS ; xmm4=CbEH >+ packssdw xmm5,xmm4 ; xmm5=CbE >+ >+ psllw xmm7,BYTE_BIT >+ por xmm5,xmm7 ; xmm5=Cb >+ movdqa XMMWORD [rbx], xmm5 ; Save Cb >+ >+ movdqa xmm0, XMMWORD [wk(3)] ; xmm0=BO >+ movdqa xmm6, XMMWORD [wk(2)] ; xmm6=BE >+ movdqa xmm1, XMMWORD [wk(1)] ; xmm1=RO >+ >+ movdqa xmm4,xmm0 >+ punpcklwd xmm0,xmm3 >+ punpckhwd xmm4,xmm3 >+ movdqa xmm7,xmm0 >+ movdqa xmm5,xmm4 >+ pmaddwd xmm0,[rel PW_F0114_F0250] ; xmm0=BOL*FIX(0.114)+GOL*FIX(0.250) >+ pmaddwd xmm4,[rel PW_F0114_F0250] ; xmm4=BOH*FIX(0.114)+GOH*FIX(0.250) >+ pmaddwd xmm7,[rel PW_MF008_MF041] ; xmm7=BOL*-FIX(0.081)+GOL*-FIX(0.418) >+ pmaddwd xmm5,[rel PW_MF008_MF041] ; xmm5=BOH*-FIX(0.081)+GOH*-FIX(0.418) >+ >+ movdqa xmm3,[rel PD_ONEHALF] ; xmm3=[PD_ONEHALF] >+ >+ paddd xmm0, XMMWORD [wk(4)] >+ paddd xmm4, XMMWORD [wk(5)] >+ paddd xmm0,xmm3 >+ paddd xmm4,xmm3 >+ psrld xmm0,SCALEBITS ; xmm0=YOL >+ psrld xmm4,SCALEBITS ; xmm4=YOH >+ packssdw xmm0,xmm4 ; xmm0=YO >+ >+ pxor xmm3,xmm3 >+ pxor xmm4,xmm4 >+ punpcklwd xmm3,xmm1 ; xmm3=ROL >+ punpckhwd xmm4,xmm1 ; xmm4=ROH >+ psrld xmm3,1 ; xmm3=ROL*FIX(0.500) >+ psrld xmm4,1 ; xmm4=ROH*FIX(0.500) >+ >+ movdqa xmm1,[rel PD_ONEHALFM1_CJ] ; xmm1=[PD_ONEHALFM1_CJ] >+ >+ paddd xmm7,xmm3 >+ paddd xmm5,xmm4 >+ paddd xmm7,xmm1 >+ paddd xmm5,xmm1 >+ psrld xmm7,SCALEBITS ; xmm7=CrOL >+ psrld xmm5,SCALEBITS ; xmm5=CrOH >+ packssdw xmm7,xmm5 ; xmm7=CrO >+ >+ movdqa xmm3, XMMWORD [wk(0)] ; xmm3=RE >+ >+ movdqa xmm4,xmm6 >+ punpcklwd xmm6,xmm2 >+ punpckhwd xmm4,xmm2 >+ movdqa xmm1,xmm6 >+ movdqa xmm5,xmm4 >+ pmaddwd xmm6,[rel PW_F0114_F0250] ; xmm6=BEL*FIX(0.114)+GEL*FIX(0.250) >+ pmaddwd xmm4,[rel PW_F0114_F0250] ; xmm4=BEH*FIX(0.114)+GEH*FIX(0.250) >+ pmaddwd xmm1,[rel PW_MF008_MF041] ; xmm1=BEL*-FIX(0.081)+GEL*-FIX(0.418) >+ pmaddwd xmm5,[rel PW_MF008_MF041] ; xmm5=BEH*-FIX(0.081)+GEH*-FIX(0.418) >+ >+ movdqa xmm2,[rel PD_ONEHALF] ; xmm2=[PD_ONEHALF] >+ >+ paddd xmm6, XMMWORD [wk(6)] >+ paddd xmm4, XMMWORD [wk(7)] >+ paddd xmm6,xmm2 >+ paddd xmm4,xmm2 >+ psrld xmm6,SCALEBITS ; xmm6=YEL >+ psrld xmm4,SCALEBITS ; xmm4=YEH >+ packssdw xmm6,xmm4 ; xmm6=YE >+ >+ psllw xmm0,BYTE_BIT >+ por xmm6,xmm0 ; xmm6=Y >+ movdqa XMMWORD [rdi], xmm6 ; Save Y >+ >+ pxor xmm2,xmm2 >+ pxor xmm4,xmm4 >+ punpcklwd xmm2,xmm3 ; xmm2=REL >+ punpckhwd xmm4,xmm3 ; xmm4=REH >+ psrld xmm2,1 ; xmm2=REL*FIX(0.500) >+ psrld xmm4,1 ; xmm4=REH*FIX(0.500) >+ >+ movdqa xmm0,[rel PD_ONEHALFM1_CJ] ; xmm0=[PD_ONEHALFM1_CJ] >+ >+ paddd xmm1,xmm2 >+ paddd xmm5,xmm4 >+ paddd xmm1,xmm0 >+ paddd xmm5,xmm0 >+ psrld xmm1,SCALEBITS ; xmm1=CrEL >+ psrld xmm5,SCALEBITS ; xmm5=CrEH >+ packssdw xmm1,xmm5 ; xmm1=CrE >+ >+ psllw xmm7,BYTE_BIT >+ por xmm1,xmm7 ; xmm1=Cr >+ movdqa XMMWORD [rdx], xmm1 ; Save Cr >+ >+ sub rcx, byte SIZEOF_XMMWORD >+ add rsi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; inptr >+ add rdi, byte SIZEOF_XMMWORD ; outptr0 >+ add rbx, byte SIZEOF_XMMWORD ; outptr1 >+ add rdx, byte SIZEOF_XMMWORD ; outptr2 >+ cmp rcx, byte SIZEOF_XMMWORD >+ jae near .columnloop >+ test rcx,rcx >+ jnz near .column_ld1 >+ >+ pop rcx ; col >+ pop rsi >+ pop rdi >+ pop rbx >+ pop rdx >+ >+ add rsi, byte SIZEOF_JSAMPROW ; input_buf >+ add rdi, byte SIZEOF_JSAMPROW >+ add rbx, byte SIZEOF_JSAMPROW >+ add rdx, byte SIZEOF_JSAMPROW >+ dec rax ; num_rows >+ jg near .rowloop >+ >+.return: >+ pop rbx >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcclrss2.asm b/modules/libjpeg-turbo/simd/jcclrss2.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcclrss2.asm >@@ -0,0 +1,505 @@ >+; >+; jcclrss2.asm - colorspace conversion (SSE2) >+; >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jcolsamp.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Convert some rows of samples to the output colorspace. >+; >+; GLOBAL(void) >+; jsimd_rgb_ycc_convert_sse2 (JDIMENSION img_width, >+; JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+; JDIMENSION output_row, int num_rows); >+; >+ >+%define img_width(b) (b)+8 ; JDIMENSION img_width >+%define input_buf(b) (b)+12 ; JSAMPARRAY input_buf >+%define output_buf(b) (b)+16 ; JSAMPIMAGE output_buf >+%define output_row(b) (b)+20 ; JDIMENSION output_row >+%define num_rows(b) (b)+24 ; int num_rows >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 8 >+%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr >+ >+ align 16 >+ >+ global EXTN(jsimd_rgb_ycc_convert_sse2) >+ >+EXTN(jsimd_rgb_ycc_convert_sse2): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic eax ; make a room for GOT address >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ movpic POINTER [gotptr], ebx ; save GOT address >+ >+ mov ecx, JDIMENSION [img_width(eax)] >+ test ecx,ecx >+ jz near .return >+ >+ push ecx >+ >+ mov esi, JSAMPIMAGE [output_buf(eax)] >+ mov ecx, JDIMENSION [output_row(eax)] >+ mov edi, JSAMPARRAY [esi+0*SIZEOF_JSAMPARRAY] >+ mov ebx, JSAMPARRAY [esi+1*SIZEOF_JSAMPARRAY] >+ mov edx, JSAMPARRAY [esi+2*SIZEOF_JSAMPARRAY] >+ lea edi, [edi+ecx*SIZEOF_JSAMPROW] >+ lea ebx, [ebx+ecx*SIZEOF_JSAMPROW] >+ lea edx, [edx+ecx*SIZEOF_JSAMPROW] >+ >+ pop ecx >+ >+ mov esi, JSAMPARRAY [input_buf(eax)] >+ mov eax, INT [num_rows(eax)] >+ test eax,eax >+ jle near .return >+ alignx 16,7 >+.rowloop: >+ pushpic eax >+ push edx >+ push ebx >+ push edi >+ push esi >+ push ecx ; col >+ >+ mov esi, JSAMPROW [esi] ; inptr >+ mov edi, JSAMPROW [edi] ; outptr0 >+ mov ebx, JSAMPROW [ebx] ; outptr1 >+ mov edx, JSAMPROW [edx] ; outptr2 >+ movpic eax, POINTER [gotptr] ; load GOT address (eax) >+ >+ cmp ecx, byte SIZEOF_XMMWORD >+ jae near .columnloop >+ alignx 16,7 >+ >+%if RGB_PIXELSIZE == 3 ; --------------- >+ >+.column_ld1: >+ push eax >+ push edx >+ lea ecx,[ecx+ecx*2] ; imul ecx,RGB_PIXELSIZE >+ test cl, SIZEOF_BYTE >+ jz short .column_ld2 >+ sub ecx, byte SIZEOF_BYTE >+ movzx eax, BYTE [esi+ecx] >+.column_ld2: >+ test cl, SIZEOF_WORD >+ jz short .column_ld4 >+ sub ecx, byte SIZEOF_WORD >+ movzx edx, WORD [esi+ecx] >+ shl eax, WORD_BIT >+ or eax,edx >+.column_ld4: >+ movd xmmA,eax >+ pop edx >+ pop eax >+ test cl, SIZEOF_DWORD >+ jz short .column_ld8 >+ sub ecx, byte SIZEOF_DWORD >+ movd xmmF, XMM_DWORD [esi+ecx] >+ pslldq xmmA, SIZEOF_DWORD >+ por xmmA,xmmF >+.column_ld8: >+ test cl, SIZEOF_MMWORD >+ jz short .column_ld16 >+ sub ecx, byte SIZEOF_MMWORD >+ movq xmmB, XMM_MMWORD [esi+ecx] >+ pslldq xmmA, SIZEOF_MMWORD >+ por xmmA,xmmB >+.column_ld16: >+ test cl, SIZEOF_XMMWORD >+ jz short .column_ld32 >+ movdqa xmmF,xmmA >+ movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ mov ecx, SIZEOF_XMMWORD >+ jmp short .rgb_ycc_cnv >+.column_ld32: >+ test cl, 2*SIZEOF_XMMWORD >+ mov ecx, SIZEOF_XMMWORD >+ jz short .rgb_ycc_cnv >+ movdqa xmmB,xmmA >+ movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD] >+ jmp short .rgb_ycc_cnv >+ alignx 16,7 >+ >+.columnloop: >+ movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD] >+ movdqu xmmB, XMMWORD [esi+2*SIZEOF_XMMWORD] >+ >+.rgb_ycc_cnv: >+ ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05) >+ ; xmmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) >+ ; xmmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F) >+ >+ movdqa xmmG,xmmA >+ pslldq xmmA,8 ; xmmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12) >+ psrldq xmmG,8 ; xmmG=(22 03 13 23 04 14 24 05 -- -- -- -- -- -- -- --) >+ >+ punpckhbw xmmA,xmmF ; xmmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A) >+ pslldq xmmF,8 ; xmmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27) >+ >+ punpcklbw xmmG,xmmB ; xmmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D) >+ punpckhbw xmmF,xmmB ; xmmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F) >+ >+ movdqa xmmD,xmmA >+ pslldq xmmA,8 ; xmmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09) >+ psrldq xmmD,8 ; xmmD=(11 19 21 29 02 0A 12 1A -- -- -- -- -- -- -- --) >+ >+ punpckhbw xmmA,xmmG ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D) >+ pslldq xmmG,8 ; xmmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B) >+ >+ punpcklbw xmmD,xmmF ; xmmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E) >+ punpckhbw xmmG,xmmF ; xmmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F) >+ >+ movdqa xmmE,xmmA >+ pslldq xmmA,8 ; xmmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C) >+ psrldq xmmE,8 ; xmmE=(20 24 28 2C 01 05 09 0D -- -- -- -- -- -- -- --) >+ >+ punpckhbw xmmA,xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E) >+ pslldq xmmD,8 ; xmmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D) >+ >+ punpcklbw xmmE,xmmG ; xmmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F) >+ punpckhbw xmmD,xmmG ; xmmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F) >+ >+ pxor xmmH,xmmH >+ >+ movdqa xmmC,xmmA >+ punpcklbw xmmA,xmmH ; xmmA=(00 02 04 06 08 0A 0C 0E) >+ punpckhbw xmmC,xmmH ; xmmC=(10 12 14 16 18 1A 1C 1E) >+ >+ movdqa xmmB,xmmE >+ punpcklbw xmmE,xmmH ; xmmE=(20 22 24 26 28 2A 2C 2E) >+ punpckhbw xmmB,xmmH ; xmmB=(01 03 05 07 09 0B 0D 0F) >+ >+ movdqa xmmF,xmmD >+ punpcklbw xmmD,xmmH ; xmmD=(11 13 15 17 19 1B 1D 1F) >+ punpckhbw xmmF,xmmH ; xmmF=(21 23 25 27 29 2B 2D 2F) >+ >+%else ; RGB_PIXELSIZE == 4 ; ----------- >+ >+.column_ld1: >+ test cl, SIZEOF_XMMWORD/16 >+ jz short .column_ld2 >+ sub ecx, byte SIZEOF_XMMWORD/16 >+ movd xmmA, XMM_DWORD [esi+ecx*RGB_PIXELSIZE] >+.column_ld2: >+ test cl, SIZEOF_XMMWORD/8 >+ jz short .column_ld4 >+ sub ecx, byte SIZEOF_XMMWORD/8 >+ movq xmmE, XMM_MMWORD [esi+ecx*RGB_PIXELSIZE] >+ pslldq xmmA, SIZEOF_MMWORD >+ por xmmA,xmmE >+.column_ld4: >+ test cl, SIZEOF_XMMWORD/4 >+ jz short .column_ld8 >+ sub ecx, byte SIZEOF_XMMWORD/4 >+ movdqa xmmE,xmmA >+ movdqu xmmA, XMMWORD [esi+ecx*RGB_PIXELSIZE] >+.column_ld8: >+ test cl, SIZEOF_XMMWORD/2 >+ mov ecx, SIZEOF_XMMWORD >+ jz short .rgb_ycc_cnv >+ movdqa xmmF,xmmA >+ movdqa xmmH,xmmE >+ movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD] >+ jmp short .rgb_ycc_cnv >+ alignx 16,7 >+ >+.columnloop: >+ movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD] >+ movdqu xmmF, XMMWORD [esi+2*SIZEOF_XMMWORD] >+ movdqu xmmH, XMMWORD [esi+3*SIZEOF_XMMWORD] >+ >+.rgb_ycc_cnv: >+ ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33) >+ ; xmmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37) >+ ; xmmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B) >+ ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F) >+ >+ movdqa xmmD,xmmA >+ punpcklbw xmmA,xmmE ; xmmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35) >+ punpckhbw xmmD,xmmE ; xmmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37) >+ >+ movdqa xmmC,xmmF >+ punpcklbw xmmF,xmmH ; xmmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D) >+ punpckhbw xmmC,xmmH ; xmmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F) >+ >+ movdqa xmmB,xmmA >+ punpcklwd xmmA,xmmF ; xmmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C) >+ punpckhwd xmmB,xmmF ; xmmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D) >+ >+ movdqa xmmG,xmmD >+ punpcklwd xmmD,xmmC ; xmmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E) >+ punpckhwd xmmG,xmmC ; xmmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F) >+ >+ movdqa xmmE,xmmA >+ punpcklbw xmmA,xmmD ; xmmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E) >+ punpckhbw xmmE,xmmD ; xmmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E) >+ >+ movdqa xmmH,xmmB >+ punpcklbw xmmB,xmmG ; xmmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F) >+ punpckhbw xmmH,xmmG ; xmmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F) >+ >+ pxor xmmF,xmmF >+ >+ movdqa xmmC,xmmA >+ punpcklbw xmmA,xmmF ; xmmA=(00 02 04 06 08 0A 0C 0E) >+ punpckhbw xmmC,xmmF ; xmmC=(10 12 14 16 18 1A 1C 1E) >+ >+ movdqa xmmD,xmmB >+ punpcklbw xmmB,xmmF ; xmmB=(01 03 05 07 09 0B 0D 0F) >+ punpckhbw xmmD,xmmF ; xmmD=(11 13 15 17 19 1B 1D 1F) >+ >+ movdqa xmmG,xmmE >+ punpcklbw xmmE,xmmF ; xmmE=(20 22 24 26 28 2A 2C 2E) >+ punpckhbw xmmG,xmmF ; xmmG=(30 32 34 36 38 3A 3C 3E) >+ >+ punpcklbw xmmF,xmmH >+ punpckhbw xmmH,xmmH >+ psrlw xmmF,BYTE_BIT ; xmmF=(21 23 25 27 29 2B 2D 2F) >+ psrlw xmmH,BYTE_BIT ; xmmH=(31 33 35 37 39 3B 3D 3F) >+ >+%endif ; RGB_PIXELSIZE ; --------------- >+ >+ ; xmm0=R(02468ACE)=RE, xmm2=G(02468ACE)=GE, xmm4=B(02468ACE)=BE >+ ; xmm1=R(13579BDF)=RO, xmm3=G(13579BDF)=GO, xmm5=B(13579BDF)=BO >+ >+ ; (Original) >+ ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B >+ ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE >+ ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE >+ ; >+ ; (This implementation) >+ ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G >+ ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE >+ ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE >+ >+ movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=RE >+ movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=RO >+ movdqa XMMWORD [wk(2)], xmm4 ; wk(2)=BE >+ movdqa XMMWORD [wk(3)], xmm5 ; wk(3)=BO >+ >+ movdqa xmm6,xmm1 >+ punpcklwd xmm1,xmm3 >+ punpckhwd xmm6,xmm3 >+ movdqa xmm7,xmm1 >+ movdqa xmm4,xmm6 >+ pmaddwd xmm1,[GOTOFF(eax,PW_F0299_F0337)] ; xmm1=ROL*FIX(0.299)+GOL*FIX(0.337) >+ pmaddwd xmm6,[GOTOFF(eax,PW_F0299_F0337)] ; xmm6=ROH*FIX(0.299)+GOH*FIX(0.337) >+ pmaddwd xmm7,[GOTOFF(eax,PW_MF016_MF033)] ; xmm7=ROL*-FIX(0.168)+GOL*-FIX(0.331) >+ pmaddwd xmm4,[GOTOFF(eax,PW_MF016_MF033)] ; xmm4=ROH*-FIX(0.168)+GOH*-FIX(0.331) >+ >+ movdqa XMMWORD [wk(4)], xmm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337) >+ movdqa XMMWORD [wk(5)], xmm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337) >+ >+ pxor xmm1,xmm1 >+ pxor xmm6,xmm6 >+ punpcklwd xmm1,xmm5 ; xmm1=BOL >+ punpckhwd xmm6,xmm5 ; xmm6=BOH >+ psrld xmm1,1 ; xmm1=BOL*FIX(0.500) >+ psrld xmm6,1 ; xmm6=BOH*FIX(0.500) >+ >+ movdqa xmm5,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; xmm5=[PD_ONEHALFM1_CJ] >+ >+ paddd xmm7,xmm1 >+ paddd xmm4,xmm6 >+ paddd xmm7,xmm5 >+ paddd xmm4,xmm5 >+ psrld xmm7,SCALEBITS ; xmm7=CbOL >+ psrld xmm4,SCALEBITS ; xmm4=CbOH >+ packssdw xmm7,xmm4 ; xmm7=CbO >+ >+ movdqa xmm1, XMMWORD [wk(2)] ; xmm1=BE >+ >+ movdqa xmm6,xmm0 >+ punpcklwd xmm0,xmm2 >+ punpckhwd xmm6,xmm2 >+ movdqa xmm5,xmm0 >+ movdqa xmm4,xmm6 >+ pmaddwd xmm0,[GOTOFF(eax,PW_F0299_F0337)] ; xmm0=REL*FIX(0.299)+GEL*FIX(0.337) >+ pmaddwd xmm6,[GOTOFF(eax,PW_F0299_F0337)] ; xmm6=REH*FIX(0.299)+GEH*FIX(0.337) >+ pmaddwd xmm5,[GOTOFF(eax,PW_MF016_MF033)] ; xmm5=REL*-FIX(0.168)+GEL*-FIX(0.331) >+ pmaddwd xmm4,[GOTOFF(eax,PW_MF016_MF033)] ; xmm4=REH*-FIX(0.168)+GEH*-FIX(0.331) >+ >+ movdqa XMMWORD [wk(6)], xmm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337) >+ movdqa XMMWORD [wk(7)], xmm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337) >+ >+ pxor xmm0,xmm0 >+ pxor xmm6,xmm6 >+ punpcklwd xmm0,xmm1 ; xmm0=BEL >+ punpckhwd xmm6,xmm1 ; xmm6=BEH >+ psrld xmm0,1 ; xmm0=BEL*FIX(0.500) >+ psrld xmm6,1 ; xmm6=BEH*FIX(0.500) >+ >+ movdqa xmm1,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; xmm1=[PD_ONEHALFM1_CJ] >+ >+ paddd xmm5,xmm0 >+ paddd xmm4,xmm6 >+ paddd xmm5,xmm1 >+ paddd xmm4,xmm1 >+ psrld xmm5,SCALEBITS ; xmm5=CbEL >+ psrld xmm4,SCALEBITS ; xmm4=CbEH >+ packssdw xmm5,xmm4 ; xmm5=CbE >+ >+ psllw xmm7,BYTE_BIT >+ por xmm5,xmm7 ; xmm5=Cb >+ movdqa XMMWORD [ebx], xmm5 ; Save Cb >+ >+ movdqa xmm0, XMMWORD [wk(3)] ; xmm0=BO >+ movdqa xmm6, XMMWORD [wk(2)] ; xmm6=BE >+ movdqa xmm1, XMMWORD [wk(1)] ; xmm1=RO >+ >+ movdqa xmm4,xmm0 >+ punpcklwd xmm0,xmm3 >+ punpckhwd xmm4,xmm3 >+ movdqa xmm7,xmm0 >+ movdqa xmm5,xmm4 >+ pmaddwd xmm0,[GOTOFF(eax,PW_F0114_F0250)] ; xmm0=BOL*FIX(0.114)+GOL*FIX(0.250) >+ pmaddwd xmm4,[GOTOFF(eax,PW_F0114_F0250)] ; xmm4=BOH*FIX(0.114)+GOH*FIX(0.250) >+ pmaddwd xmm7,[GOTOFF(eax,PW_MF008_MF041)] ; xmm7=BOL*-FIX(0.081)+GOL*-FIX(0.418) >+ pmaddwd xmm5,[GOTOFF(eax,PW_MF008_MF041)] ; xmm5=BOH*-FIX(0.081)+GOH*-FIX(0.418) >+ >+ movdqa xmm3,[GOTOFF(eax,PD_ONEHALF)] ; xmm3=[PD_ONEHALF] >+ >+ paddd xmm0, XMMWORD [wk(4)] >+ paddd xmm4, XMMWORD [wk(5)] >+ paddd xmm0,xmm3 >+ paddd xmm4,xmm3 >+ psrld xmm0,SCALEBITS ; xmm0=YOL >+ psrld xmm4,SCALEBITS ; xmm4=YOH >+ packssdw xmm0,xmm4 ; xmm0=YO >+ >+ pxor xmm3,xmm3 >+ pxor xmm4,xmm4 >+ punpcklwd xmm3,xmm1 ; xmm3=ROL >+ punpckhwd xmm4,xmm1 ; xmm4=ROH >+ psrld xmm3,1 ; xmm3=ROL*FIX(0.500) >+ psrld xmm4,1 ; xmm4=ROH*FIX(0.500) >+ >+ movdqa xmm1,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; xmm1=[PD_ONEHALFM1_CJ] >+ >+ paddd xmm7,xmm3 >+ paddd xmm5,xmm4 >+ paddd xmm7,xmm1 >+ paddd xmm5,xmm1 >+ psrld xmm7,SCALEBITS ; xmm7=CrOL >+ psrld xmm5,SCALEBITS ; xmm5=CrOH >+ packssdw xmm7,xmm5 ; xmm7=CrO >+ >+ movdqa xmm3, XMMWORD [wk(0)] ; xmm3=RE >+ >+ movdqa xmm4,xmm6 >+ punpcklwd xmm6,xmm2 >+ punpckhwd xmm4,xmm2 >+ movdqa xmm1,xmm6 >+ movdqa xmm5,xmm4 >+ pmaddwd xmm6,[GOTOFF(eax,PW_F0114_F0250)] ; xmm6=BEL*FIX(0.114)+GEL*FIX(0.250) >+ pmaddwd xmm4,[GOTOFF(eax,PW_F0114_F0250)] ; xmm4=BEH*FIX(0.114)+GEH*FIX(0.250) >+ pmaddwd xmm1,[GOTOFF(eax,PW_MF008_MF041)] ; xmm1=BEL*-FIX(0.081)+GEL*-FIX(0.418) >+ pmaddwd xmm5,[GOTOFF(eax,PW_MF008_MF041)] ; xmm5=BEH*-FIX(0.081)+GEH*-FIX(0.418) >+ >+ movdqa xmm2,[GOTOFF(eax,PD_ONEHALF)] ; xmm2=[PD_ONEHALF] >+ >+ paddd xmm6, XMMWORD [wk(6)] >+ paddd xmm4, XMMWORD [wk(7)] >+ paddd xmm6,xmm2 >+ paddd xmm4,xmm2 >+ psrld xmm6,SCALEBITS ; xmm6=YEL >+ psrld xmm4,SCALEBITS ; xmm4=YEH >+ packssdw xmm6,xmm4 ; xmm6=YE >+ >+ psllw xmm0,BYTE_BIT >+ por xmm6,xmm0 ; xmm6=Y >+ movdqa XMMWORD [edi], xmm6 ; Save Y >+ >+ pxor xmm2,xmm2 >+ pxor xmm4,xmm4 >+ punpcklwd xmm2,xmm3 ; xmm2=REL >+ punpckhwd xmm4,xmm3 ; xmm4=REH >+ psrld xmm2,1 ; xmm2=REL*FIX(0.500) >+ psrld xmm4,1 ; xmm4=REH*FIX(0.500) >+ >+ movdqa xmm0,[GOTOFF(eax,PD_ONEHALFM1_CJ)] ; xmm0=[PD_ONEHALFM1_CJ] >+ >+ paddd xmm1,xmm2 >+ paddd xmm5,xmm4 >+ paddd xmm1,xmm0 >+ paddd xmm5,xmm0 >+ psrld xmm1,SCALEBITS ; xmm1=CrEL >+ psrld xmm5,SCALEBITS ; xmm5=CrEH >+ packssdw xmm1,xmm5 ; xmm1=CrE >+ >+ psllw xmm7,BYTE_BIT >+ por xmm1,xmm7 ; xmm1=Cr >+ movdqa XMMWORD [edx], xmm1 ; Save Cr >+ >+ sub ecx, byte SIZEOF_XMMWORD >+ add esi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; inptr >+ add edi, byte SIZEOF_XMMWORD ; outptr0 >+ add ebx, byte SIZEOF_XMMWORD ; outptr1 >+ add edx, byte SIZEOF_XMMWORD ; outptr2 >+ cmp ecx, byte SIZEOF_XMMWORD >+ jae near .columnloop >+ test ecx,ecx >+ jnz near .column_ld1 >+ >+ pop ecx ; col >+ pop esi >+ pop edi >+ pop ebx >+ pop edx >+ poppic eax >+ >+ add esi, byte SIZEOF_JSAMPROW ; input_buf >+ add edi, byte SIZEOF_JSAMPROW >+ add ebx, byte SIZEOF_JSAMPROW >+ add edx, byte SIZEOF_JSAMPROW >+ dec eax ; num_rows >+ jg near .rowloop >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jccolmmx.asm b/modules/libjpeg-turbo/simd/jccolmmx.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jccolmmx.asm >@@ -0,0 +1,120 @@ >+; >+; jccolmmx.asm - colorspace conversion (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define SCALEBITS 16 >+ >+F_0_081 equ 5329 ; FIX(0.08131) >+F_0_114 equ 7471 ; FIX(0.11400) >+F_0_168 equ 11059 ; FIX(0.16874) >+F_0_250 equ 16384 ; FIX(0.25000) >+F_0_299 equ 19595 ; FIX(0.29900) >+F_0_331 equ 21709 ; FIX(0.33126) >+F_0_418 equ 27439 ; FIX(0.41869) >+F_0_587 equ 38470 ; FIX(0.58700) >+F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000) >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_rgb_ycc_convert_mmx) >+ >+EXTN(jconst_rgb_ycc_convert_mmx): >+ >+PW_F0299_F0337 times 2 dw F_0_299, F_0_337 >+PW_F0114_F0250 times 2 dw F_0_114, F_0_250 >+PW_MF016_MF033 times 2 dw -F_0_168,-F_0_331 >+PW_MF008_MF041 times 2 dw -F_0_081,-F_0_418 >+PD_ONEHALFM1_CJ times 2 dd (1 << (SCALEBITS-1)) - 1 + (CENTERJSAMPLE << SCALEBITS) >+PD_ONEHALF times 2 dd (1 << (SCALEBITS-1)) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+%include "jcclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 3 >+%define jsimd_rgb_ycc_convert_mmx jsimd_extrgb_ycc_convert_mmx >+%include "jcclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_mmx jsimd_extrgbx_ycc_convert_mmx >+%include "jcclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 3 >+%define jsimd_rgb_ycc_convert_mmx jsimd_extbgr_ycc_convert_mmx >+%include "jcclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_mmx jsimd_extbgrx_ycc_convert_mmx >+%include "jcclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 3 >+%define RGB_GREEN 2 >+%define RGB_BLUE 1 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_mmx jsimd_extxbgr_ycc_convert_mmx >+%include "jcclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 1 >+%define RGB_GREEN 2 >+%define RGB_BLUE 3 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_mmx jsimd_extxrgb_ycc_convert_mmx >+%include "jcclrmmx.asm" >diff --git a/modules/libjpeg-turbo/simd/jccolss2-64.asm b/modules/libjpeg-turbo/simd/jccolss2-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jccolss2-64.asm >@@ -0,0 +1,117 @@ >+; >+; jccolss2-64.asm - colorspace conversion (64-bit SSE2) >+; >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; Copyright (C) 2009, D. R. Commander. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define SCALEBITS 16 >+ >+F_0_081 equ 5329 ; FIX(0.08131) >+F_0_114 equ 7471 ; FIX(0.11400) >+F_0_168 equ 11059 ; FIX(0.16874) >+F_0_250 equ 16384 ; FIX(0.25000) >+F_0_299 equ 19595 ; FIX(0.29900) >+F_0_331 equ 21709 ; FIX(0.33126) >+F_0_418 equ 27439 ; FIX(0.41869) >+F_0_587 equ 38470 ; FIX(0.58700) >+F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000) >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_rgb_ycc_convert_sse2) >+ >+EXTN(jconst_rgb_ycc_convert_sse2): >+ >+PW_F0299_F0337 times 4 dw F_0_299, F_0_337 >+PW_F0114_F0250 times 4 dw F_0_114, F_0_250 >+PW_MF016_MF033 times 4 dw -F_0_168,-F_0_331 >+PW_MF008_MF041 times 4 dw -F_0_081,-F_0_418 >+PD_ONEHALFM1_CJ times 4 dd (1 << (SCALEBITS-1)) - 1 + (CENTERJSAMPLE << SCALEBITS) >+PD_ONEHALF times 4 dd (1 << (SCALEBITS-1)) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+%include "jcclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 3 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgb_ycc_convert_sse2 >+%include "jcclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgbx_ycc_convert_sse2 >+%include "jcclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 3 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgr_ycc_convert_sse2 >+%include "jcclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgrx_ycc_convert_sse2 >+%include "jcclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 3 >+%define RGB_GREEN 2 >+%define RGB_BLUE 1 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extxbgr_ycc_convert_sse2 >+%include "jcclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 1 >+%define RGB_GREEN 2 >+%define RGB_BLUE 3 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extxrgb_ycc_convert_sse2 >+%include "jcclrss2-64.asm" >diff --git a/modules/libjpeg-turbo/simd/jccolss2.asm b/modules/libjpeg-turbo/simd/jccolss2.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jccolss2.asm >@@ -0,0 +1,117 @@ >+; >+; jccolss2.asm - colorspace conversion (SSE2) >+; >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; Copyright (C) 2009, D. R. Commander. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define SCALEBITS 16 >+ >+F_0_081 equ 5329 ; FIX(0.08131) >+F_0_114 equ 7471 ; FIX(0.11400) >+F_0_168 equ 11059 ; FIX(0.16874) >+F_0_250 equ 16384 ; FIX(0.25000) >+F_0_299 equ 19595 ; FIX(0.29900) >+F_0_331 equ 21709 ; FIX(0.33126) >+F_0_418 equ 27439 ; FIX(0.41869) >+F_0_587 equ 38470 ; FIX(0.58700) >+F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000) >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_rgb_ycc_convert_sse2) >+ >+EXTN(jconst_rgb_ycc_convert_sse2): >+ >+PW_F0299_F0337 times 4 dw F_0_299, F_0_337 >+PW_F0114_F0250 times 4 dw F_0_114, F_0_250 >+PW_MF016_MF033 times 4 dw -F_0_168,-F_0_331 >+PW_MF008_MF041 times 4 dw -F_0_081,-F_0_418 >+PD_ONEHALFM1_CJ times 4 dd (1 << (SCALEBITS-1)) - 1 + (CENTERJSAMPLE << SCALEBITS) >+PD_ONEHALF times 4 dd (1 << (SCALEBITS-1)) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+%include "jcclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 3 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgb_ycc_convert_sse2 >+%include "jcclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgbx_ycc_convert_sse2 >+%include "jcclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 3 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgr_ycc_convert_sse2 >+%include "jcclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgrx_ycc_convert_sse2 >+%include "jcclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 3 >+%define RGB_GREEN 2 >+%define RGB_BLUE 1 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extxbgr_ycc_convert_sse2 >+%include "jcclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 1 >+%define RGB_GREEN 2 >+%define RGB_BLUE 3 >+%define RGB_PIXELSIZE 4 >+%define jsimd_rgb_ycc_convert_sse2 jsimd_extxrgb_ycc_convert_sse2 >+%include "jcclrss2.asm" >diff --git a/modules/libjpeg-turbo/simd/jcolsamp.inc b/modules/libjpeg-turbo/simd/jcolsamp.inc >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcolsamp.inc >@@ -0,0 +1,105 @@ >+; >+; jcolsamp.inc - private declarations for color conversion & up/downsampling >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; [TAB8] >+ >+; -------------------------------------------------------------------------- >+ >+; pseudo-resisters to make ordering of RGB configurable >+; >+%if RGB_RED == 0 >+%define mmA mm0 >+%define mmB mm1 >+%define xmmA xmm0 >+%define xmmB xmm1 >+%elif RGB_GREEN == 0 >+%define mmA mm2 >+%define mmB mm3 >+%define xmmA xmm2 >+%define xmmB xmm3 >+%elif RGB_BLUE == 0 >+%define mmA mm4 >+%define mmB mm5 >+%define xmmA xmm4 >+%define xmmB xmm5 >+%else >+%define mmA mm6 >+%define mmB mm7 >+%define xmmA xmm6 >+%define xmmB xmm7 >+%endif >+ >+%if RGB_RED == 1 >+%define mmC mm0 >+%define mmD mm1 >+%define xmmC xmm0 >+%define xmmD xmm1 >+%elif RGB_GREEN == 1 >+%define mmC mm2 >+%define mmD mm3 >+%define xmmC xmm2 >+%define xmmD xmm3 >+%elif RGB_BLUE == 1 >+%define mmC mm4 >+%define mmD mm5 >+%define xmmC xmm4 >+%define xmmD xmm5 >+%else >+%define mmC mm6 >+%define mmD mm7 >+%define xmmC xmm6 >+%define xmmD xmm7 >+%endif >+ >+%if RGB_RED == 2 >+%define mmE mm0 >+%define mmF mm1 >+%define xmmE xmm0 >+%define xmmF xmm1 >+%elif RGB_GREEN == 2 >+%define mmE mm2 >+%define mmF mm3 >+%define xmmE xmm2 >+%define xmmF xmm3 >+%elif RGB_BLUE == 2 >+%define mmE mm4 >+%define mmF mm5 >+%define xmmE xmm4 >+%define xmmF xmm5 >+%else >+%define mmE mm6 >+%define mmF mm7 >+%define xmmE xmm6 >+%define xmmF xmm7 >+%endif >+ >+%if RGB_RED == 3 >+%define mmG mm0 >+%define mmH mm1 >+%define xmmG xmm0 >+%define xmmH xmm1 >+%elif RGB_GREEN == 3 >+%define mmG mm2 >+%define mmH mm3 >+%define xmmG xmm2 >+%define xmmH xmm3 >+%elif RGB_BLUE == 3 >+%define mmG mm4 >+%define mmH mm5 >+%define xmmG xmm4 >+%define xmmH xmm5 >+%else >+%define mmG mm6 >+%define mmH mm7 >+%define xmmG xmm6 >+%define xmmH xmm7 >+%endif >+ >+; -------------------------------------------------------------------------- >diff --git a/modules/libjpeg-turbo/simd/jcqnt3dn.asm b/modules/libjpeg-turbo/simd/jcqnt3dn.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcqnt3dn.asm >@@ -0,0 +1,233 @@ >+; >+; jcqnt3dn.asm - sample data conversion and quantization (3DNow! & MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Load data into workspace, applying unsigned->signed conversion >+; >+; GLOBAL(void) >+; jsimd_convsamp_float_3dnow (JSAMPARRAY sample_data, JDIMENSION start_col, >+; FAST_FLOAT * workspace); >+; >+ >+%define sample_data ebp+8 ; JSAMPARRAY sample_data >+%define start_col ebp+12 ; JDIMENSION start_col >+%define workspace ebp+16 ; FAST_FLOAT * workspace >+ >+ align 16 >+ global EXTN(jsimd_convsamp_float_3dnow) >+ >+EXTN(jsimd_convsamp_float_3dnow): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ pcmpeqw mm7,mm7 >+ psllw mm7,7 >+ packsswb mm7,mm7 ; mm7 = PB_CENTERJSAMPLE (0x808080..) >+ >+ mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *) >+ mov eax, JDIMENSION [start_col] >+ mov edi, POINTER [workspace] ; (DCTELEM *) >+ mov ecx, DCTSIZE/2 >+ alignx 16,7 >+.convloop: >+ mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ >+ movq mm0, MMWORD [ebx+eax*SIZEOF_JSAMPLE] >+ movq mm1, MMWORD [edx+eax*SIZEOF_JSAMPLE] >+ >+ psubb mm0,mm7 ; mm0=(01234567) >+ psubb mm1,mm7 ; mm1=(89ABCDEF) >+ >+ punpcklbw mm2,mm0 ; mm2=(*0*1*2*3) >+ punpckhbw mm0,mm0 ; mm0=(*4*5*6*7) >+ punpcklbw mm3,mm1 ; mm3=(*8*9*A*B) >+ punpckhbw mm1,mm1 ; mm1=(*C*D*E*F) >+ >+ punpcklwd mm4,mm2 ; mm4=(***0***1) >+ punpckhwd mm2,mm2 ; mm2=(***2***3) >+ punpcklwd mm5,mm0 ; mm5=(***4***5) >+ punpckhwd mm0,mm0 ; mm0=(***6***7) >+ >+ psrad mm4,(DWORD_BIT-BYTE_BIT) ; mm4=(01) >+ psrad mm2,(DWORD_BIT-BYTE_BIT) ; mm2=(23) >+ pi2fd mm4,mm4 >+ pi2fd mm2,mm2 >+ psrad mm5,(DWORD_BIT-BYTE_BIT) ; mm5=(45) >+ psrad mm0,(DWORD_BIT-BYTE_BIT) ; mm0=(67) >+ pi2fd mm5,mm5 >+ pi2fd mm0,mm0 >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], mm4 >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], mm2 >+ movq MMWORD [MMBLOCK(0,2,edi,SIZEOF_FAST_FLOAT)], mm5 >+ movq MMWORD [MMBLOCK(0,3,edi,SIZEOF_FAST_FLOAT)], mm0 >+ >+ punpcklwd mm6,mm3 ; mm6=(***8***9) >+ punpckhwd mm3,mm3 ; mm3=(***A***B) >+ punpcklwd mm4,mm1 ; mm4=(***C***D) >+ punpckhwd mm1,mm1 ; mm1=(***E***F) >+ >+ psrad mm6,(DWORD_BIT-BYTE_BIT) ; mm6=(89) >+ psrad mm3,(DWORD_BIT-BYTE_BIT) ; mm3=(AB) >+ pi2fd mm6,mm6 >+ pi2fd mm3,mm3 >+ psrad mm4,(DWORD_BIT-BYTE_BIT) ; mm4=(CD) >+ psrad mm1,(DWORD_BIT-BYTE_BIT) ; mm1=(EF) >+ pi2fd mm4,mm4 >+ pi2fd mm1,mm1 >+ >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], mm6 >+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], mm3 >+ movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm4 >+ movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm1 >+ >+ add esi, byte 2*SIZEOF_JSAMPROW >+ add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT >+ dec ecx >+ jnz near .convloop >+ >+ femms ; empty MMX/3DNow! state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+ >+; -------------------------------------------------------------------------- >+; >+; Quantize/descale the coefficients, and store into coef_block >+; >+; GLOBAL(void) >+; jsimd_quantize_float_3dnow (JCOEFPTR coef_block, FAST_FLOAT * divisors, >+; FAST_FLOAT * workspace); >+; >+ >+%define coef_block ebp+8 ; JCOEFPTR coef_block >+%define divisors ebp+12 ; FAST_FLOAT * divisors >+%define workspace ebp+16 ; FAST_FLOAT * workspace >+ >+ align 16 >+ global EXTN(jsimd_quantize_float_3dnow) >+ >+EXTN(jsimd_quantize_float_3dnow): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; unused >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov eax, 0x4B400000 ; (float)0x00C00000 (rndint_magic) >+ movd mm7,eax >+ punpckldq mm7,mm7 ; mm7={12582912.0F 12582912.0F} >+ >+ mov esi, POINTER [workspace] >+ mov edx, POINTER [divisors] >+ mov edi, JCOEFPTR [coef_block] >+ mov eax, DCTSIZE2/16 >+ alignx 16,7 >+.quantloop: >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)] >+ movq mm1, MMWORD [MMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)] >+ pfmul mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)] >+ pfmul mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)] >+ movq mm2, MMWORD [MMBLOCK(0,2,esi,SIZEOF_FAST_FLOAT)] >+ movq mm3, MMWORD [MMBLOCK(0,3,esi,SIZEOF_FAST_FLOAT)] >+ pfmul mm2, MMWORD [MMBLOCK(0,2,edx,SIZEOF_FAST_FLOAT)] >+ pfmul mm3, MMWORD [MMBLOCK(0,3,edx,SIZEOF_FAST_FLOAT)] >+ >+ pfadd mm0,mm7 ; mm0=(00 ** 01 **) >+ pfadd mm1,mm7 ; mm1=(02 ** 03 **) >+ pfadd mm2,mm7 ; mm0=(04 ** 05 **) >+ pfadd mm3,mm7 ; mm1=(06 ** 07 **) >+ >+ movq mm4,mm0 >+ punpcklwd mm0,mm1 ; mm0=(00 02 ** **) >+ punpckhwd mm4,mm1 ; mm4=(01 03 ** **) >+ movq mm5,mm2 >+ punpcklwd mm2,mm3 ; mm2=(04 06 ** **) >+ punpckhwd mm5,mm3 ; mm5=(05 07 ** **) >+ >+ punpcklwd mm0,mm4 ; mm0=(00 01 02 03) >+ punpcklwd mm2,mm5 ; mm2=(04 05 06 07) >+ >+ movq mm6, MMWORD [MMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)] >+ movq mm1, MMWORD [MMBLOCK(1,1,esi,SIZEOF_FAST_FLOAT)] >+ pfmul mm6, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)] >+ pfmul mm1, MMWORD [MMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)] >+ movq mm3, MMWORD [MMBLOCK(1,2,esi,SIZEOF_FAST_FLOAT)] >+ movq mm4, MMWORD [MMBLOCK(1,3,esi,SIZEOF_FAST_FLOAT)] >+ pfmul mm3, MMWORD [MMBLOCK(1,2,edx,SIZEOF_FAST_FLOAT)] >+ pfmul mm4, MMWORD [MMBLOCK(1,3,edx,SIZEOF_FAST_FLOAT)] >+ >+ pfadd mm6,mm7 ; mm0=(10 ** 11 **) >+ pfadd mm1,mm7 ; mm4=(12 ** 13 **) >+ pfadd mm3,mm7 ; mm0=(14 ** 15 **) >+ pfadd mm4,mm7 ; mm4=(16 ** 17 **) >+ >+ movq mm5,mm6 >+ punpcklwd mm6,mm1 ; mm6=(10 12 ** **) >+ punpckhwd mm5,mm1 ; mm5=(11 13 ** **) >+ movq mm1,mm3 >+ punpcklwd mm3,mm4 ; mm3=(14 16 ** **) >+ punpckhwd mm1,mm4 ; mm1=(15 17 ** **) >+ >+ punpcklwd mm6,mm5 ; mm6=(10 11 12 13) >+ punpcklwd mm3,mm1 ; mm3=(14 15 16 17) >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0 >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm2 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm6 >+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm3 >+ >+ add esi, byte 16*SIZEOF_FAST_FLOAT >+ add edx, byte 16*SIZEOF_FAST_FLOAT >+ add edi, byte 16*SIZEOF_JCOEF >+ dec eax >+ jnz near .quantloop >+ >+ femms ; empty MMX/3DNow! state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; unused >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcqntmmx.asm b/modules/libjpeg-turbo/simd/jcqntmmx.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcqntmmx.asm >@@ -0,0 +1,274 @@ >+; >+; jcqntmmx.asm - sample data conversion and quantization (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Load data into workspace, applying unsigned->signed conversion >+; >+; GLOBAL(void) >+; jsimd_convsamp_mmx (JSAMPARRAY sample_data, JDIMENSION start_col, >+; DCTELEM * workspace); >+; >+ >+%define sample_data ebp+8 ; JSAMPARRAY sample_data >+%define start_col ebp+12 ; JDIMENSION start_col >+%define workspace ebp+16 ; DCTELEM * workspace >+ >+ align 16 >+ global EXTN(jsimd_convsamp_mmx) >+ >+EXTN(jsimd_convsamp_mmx): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ pxor mm6,mm6 ; mm6=(all 0's) >+ pcmpeqw mm7,mm7 >+ psllw mm7,7 ; mm7={0xFF80 0xFF80 0xFF80 0xFF80} >+ >+ mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *) >+ mov eax, JDIMENSION [start_col] >+ mov edi, POINTER [workspace] ; (DCTELEM *) >+ mov ecx, DCTSIZE/4 >+ alignx 16,7 >+.convloop: >+ mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ >+ movq mm0, MMWORD [ebx+eax*SIZEOF_JSAMPLE] ; mm0=(01234567) >+ movq mm1, MMWORD [edx+eax*SIZEOF_JSAMPLE] ; mm1=(89ABCDEF) >+ >+ mov ebx, JSAMPROW [esi+2*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ mov edx, JSAMPROW [esi+3*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ >+ movq mm2, MMWORD [ebx+eax*SIZEOF_JSAMPLE] ; mm2=(GHIJKLMN) >+ movq mm3, MMWORD [edx+eax*SIZEOF_JSAMPLE] ; mm3=(OPQRSTUV) >+ >+ movq mm4,mm0 >+ punpcklbw mm0,mm6 ; mm0=(0123) >+ punpckhbw mm4,mm6 ; mm4=(4567) >+ movq mm5,mm1 >+ punpcklbw mm1,mm6 ; mm1=(89AB) >+ punpckhbw mm5,mm6 ; mm5=(CDEF) >+ >+ paddw mm0,mm7 >+ paddw mm4,mm7 >+ paddw mm1,mm7 >+ paddw mm5,mm7 >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_DCTELEM)], mm0 >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_DCTELEM)], mm4 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_DCTELEM)], mm1 >+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_DCTELEM)], mm5 >+ >+ movq mm0,mm2 >+ punpcklbw mm2,mm6 ; mm2=(GHIJ) >+ punpckhbw mm0,mm6 ; mm0=(KLMN) >+ movq mm4,mm3 >+ punpcklbw mm3,mm6 ; mm3=(OPQR) >+ punpckhbw mm4,mm6 ; mm4=(STUV) >+ >+ paddw mm2,mm7 >+ paddw mm0,mm7 >+ paddw mm3,mm7 >+ paddw mm4,mm7 >+ >+ movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_DCTELEM)], mm2 >+ movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_DCTELEM)], mm0 >+ movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_DCTELEM)], mm3 >+ movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_DCTELEM)], mm4 >+ >+ add esi, byte 4*SIZEOF_JSAMPROW >+ add edi, byte 4*DCTSIZE*SIZEOF_DCTELEM >+ dec ecx >+ jnz short .convloop >+ >+ emms ; empty MMX state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Quantize/descale the coefficients, and store into coef_block >+; >+; This implementation is based on an algorithm described in >+; "How to optimize for the Pentium family of microprocessors" >+; (http://www.agner.org/assem/). >+; >+; GLOBAL(void) >+; jsimd_quantize_mmx (JCOEFPTR coef_block, DCTELEM * divisors, >+; DCTELEM * workspace); >+; >+ >+%define RECIPROCAL(m,n,b) MMBLOCK(DCTSIZE*0+(m),(n),(b),SIZEOF_DCTELEM) >+%define CORRECTION(m,n,b) MMBLOCK(DCTSIZE*1+(m),(n),(b),SIZEOF_DCTELEM) >+%define SCALE(m,n,b) MMBLOCK(DCTSIZE*2+(m),(n),(b),SIZEOF_DCTELEM) >+%define SHIFT(m,n,b) MMBLOCK(DCTSIZE*3+(m),(n),(b),SIZEOF_DCTELEM) >+ >+%define coef_block ebp+8 ; JCOEFPTR coef_block >+%define divisors ebp+12 ; DCTELEM * divisors >+%define workspace ebp+16 ; DCTELEM * workspace >+ >+ align 16 >+ global EXTN(jsimd_quantize_mmx) >+ >+EXTN(jsimd_quantize_mmx): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; unused >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov esi, POINTER [workspace] >+ mov edx, POINTER [divisors] >+ mov edi, JCOEFPTR [coef_block] >+ mov ah, 2 >+ alignx 16,7 >+.quantloop1: >+ mov al, DCTSIZE2/8/2 >+ alignx 16,7 >+.quantloop2: >+ movq mm2, MMWORD [MMBLOCK(0,0,esi,SIZEOF_DCTELEM)] >+ movq mm3, MMWORD [MMBLOCK(0,1,esi,SIZEOF_DCTELEM)] >+ >+ movq mm0,mm2 >+ movq mm1,mm3 >+ >+ psraw mm2,(WORD_BIT-1) ; -1 if value < 0, 0 otherwise >+ psraw mm3,(WORD_BIT-1) >+ >+ pxor mm0,mm2 ; val = -val >+ pxor mm1,mm3 >+ psubw mm0,mm2 >+ psubw mm1,mm3 >+ >+ ; >+ ; MMX is an annoyingly crappy instruction set. It has two >+ ; misfeatures that are causing problems here: >+ ; >+ ; - All multiplications are signed. >+ ; >+ ; - The second operand for the shifts is not treated as packed. >+ ; >+ ; >+ ; We work around the first problem by implementing this algorithm: >+ ; >+ ; unsigned long unsigned_multiply(unsigned short x, unsigned short y) >+ ; { >+ ; enum { SHORT_BIT = 16 }; >+ ; signed short sx = (signed short) x; >+ ; signed short sy = (signed short) y; >+ ; signed long sz; >+ ; >+ ; sz = (long) sx * (long) sy; /* signed multiply */ >+ ; >+ ; if (sx < 0) sz += (long) sy << SHORT_BIT; >+ ; if (sy < 0) sz += (long) sx << SHORT_BIT; >+ ; >+ ; return (unsigned long) sz; >+ ; } >+ ; >+ ; (note that a negative sx adds _sy_ and vice versa) >+ ; >+ ; For the second problem, we replace the shift by a multiplication. >+ ; Unfortunately that means we have to deal with the signed issue again. >+ ; >+ >+ paddw mm0, MMWORD [CORRECTION(0,0,edx)] ; correction + roundfactor >+ paddw mm1, MMWORD [CORRECTION(0,1,edx)] >+ >+ movq mm4,mm0 ; store current value for later >+ movq mm5,mm1 >+ pmulhw mm0, MMWORD [RECIPROCAL(0,0,edx)] ; reciprocal >+ pmulhw mm1, MMWORD [RECIPROCAL(0,1,edx)] >+ paddw mm0,mm4 ; reciprocal is always negative (MSB=1), >+ paddw mm1,mm5 ; so we always need to add the initial value >+ ; (input value is never negative as we >+ ; inverted it at the start of this routine) >+ >+ ; here it gets a bit tricky as both scale >+ ; and mm0/mm1 can be negative >+ movq mm6, MMWORD [SCALE(0,0,edx)] ; scale >+ movq mm7, MMWORD [SCALE(0,1,edx)] >+ movq mm4,mm0 >+ movq mm5,mm1 >+ pmulhw mm0,mm6 >+ pmulhw mm1,mm7 >+ >+ psraw mm6,(WORD_BIT-1) ; determine if scale is negative >+ psraw mm7,(WORD_BIT-1) >+ >+ pand mm6,mm4 ; and add input if it is >+ pand mm7,mm5 >+ paddw mm0,mm6 >+ paddw mm1,mm7 >+ >+ psraw mm4,(WORD_BIT-1) ; then check if negative input >+ psraw mm5,(WORD_BIT-1) >+ >+ pand mm4, MMWORD [SCALE(0,0,edx)] ; and add scale if it is >+ pand mm5, MMWORD [SCALE(0,1,edx)] >+ paddw mm0,mm4 >+ paddw mm1,mm5 >+ >+ pxor mm0,mm2 ; val = -val >+ pxor mm1,mm3 >+ psubw mm0,mm2 >+ psubw mm1,mm3 >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_DCTELEM)], mm0 >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_DCTELEM)], mm1 >+ >+ add esi, byte 8*SIZEOF_DCTELEM >+ add edx, byte 8*SIZEOF_DCTELEM >+ add edi, byte 8*SIZEOF_JCOEF >+ dec al >+ jnz near .quantloop2 >+ dec ah >+ jnz near .quantloop1 ; to avoid branch misprediction >+ >+ emms ; empty MMX state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; unused >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcqnts2f-64.asm b/modules/libjpeg-turbo/simd/jcqnts2f-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcqnts2f-64.asm >@@ -0,0 +1,158 @@ >+; >+; jcqnts2f-64.asm - sample data conversion and quantization (64-bit SSE & SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Load data into workspace, applying unsigned->signed conversion >+; >+; GLOBAL(void) >+; jsimd_convsamp_float_sse2 (JSAMPARRAY sample_data, JDIMENSION start_col, >+; FAST_FLOAT * workspace); >+; >+ >+; r10 = JSAMPARRAY sample_data >+; r11 = JDIMENSION start_col >+; r12 = FAST_FLOAT * workspace >+ >+ align 16 >+ global EXTN(jsimd_convsamp_float_sse2) >+ >+EXTN(jsimd_convsamp_float_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ push rbx >+ >+ pcmpeqw xmm7,xmm7 >+ psllw xmm7,7 >+ packsswb xmm7,xmm7 ; xmm7 = PB_CENTERJSAMPLE (0x808080..) >+ >+ mov rsi, r10 >+ mov rax, r11 >+ mov rdi, r12 >+ mov rcx, DCTSIZE/2 >+.convloop: >+ mov rbx, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ mov rdx, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ >+ movq xmm0, XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE] >+ movq xmm1, XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE] >+ >+ psubb xmm0,xmm7 ; xmm0=(01234567) >+ psubb xmm1,xmm7 ; xmm1=(89ABCDEF) >+ >+ punpcklbw xmm0,xmm0 ; xmm0=(*0*1*2*3*4*5*6*7) >+ punpcklbw xmm1,xmm1 ; xmm1=(*8*9*A*B*C*D*E*F) >+ >+ punpcklwd xmm2,xmm0 ; xmm2=(***0***1***2***3) >+ punpckhwd xmm0,xmm0 ; xmm0=(***4***5***6***7) >+ punpcklwd xmm3,xmm1 ; xmm3=(***8***9***A***B) >+ punpckhwd xmm1,xmm1 ; xmm1=(***C***D***E***F) >+ >+ psrad xmm2,(DWORD_BIT-BYTE_BIT) ; xmm2=(0123) >+ psrad xmm0,(DWORD_BIT-BYTE_BIT) ; xmm0=(4567) >+ cvtdq2ps xmm2,xmm2 ; xmm2=(0123) >+ cvtdq2ps xmm0,xmm0 ; xmm0=(4567) >+ psrad xmm3,(DWORD_BIT-BYTE_BIT) ; xmm3=(89AB) >+ psrad xmm1,(DWORD_BIT-BYTE_BIT) ; xmm1=(CDEF) >+ cvtdq2ps xmm3,xmm3 ; xmm3=(89AB) >+ cvtdq2ps xmm1,xmm1 ; xmm1=(CDEF) >+ >+ movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm2 >+ movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm3 >+ movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm1 >+ >+ add rsi, byte 2*SIZEOF_JSAMPROW >+ add rdi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT >+ dec rcx >+ jnz short .convloop >+ >+ pop rbx >+ uncollect_args >+ pop rbp >+ ret >+ >+ >+; -------------------------------------------------------------------------- >+; >+; Quantize/descale the coefficients, and store into coef_block >+; >+; GLOBAL(void) >+; jsimd_quantize_float_sse2 (JCOEFPTR coef_block, FAST_FLOAT * divisors, >+; FAST_FLOAT * workspace); >+; >+ >+; r10 = JCOEFPTR coef_block >+; r11 = FAST_FLOAT * divisors >+; r12 = FAST_FLOAT * workspace >+ >+ align 16 >+ global EXTN(jsimd_quantize_float_sse2) >+ >+EXTN(jsimd_quantize_float_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ >+ mov rsi, r12 >+ mov rdx, r11 >+ mov rdi, r10 >+ mov rax, DCTSIZE2/16 >+.quantloop: >+ movaps xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(0,1,rsi,SIZEOF_FAST_FLOAT)] >+ mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)] >+ mulps xmm1, XMMWORD [XMMBLOCK(0,1,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(1,1,rsi,SIZEOF_FAST_FLOAT)] >+ mulps xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)] >+ mulps xmm3, XMMWORD [XMMBLOCK(1,1,rdx,SIZEOF_FAST_FLOAT)] >+ >+ cvtps2dq xmm0,xmm0 >+ cvtps2dq xmm1,xmm1 >+ cvtps2dq xmm2,xmm2 >+ cvtps2dq xmm3,xmm3 >+ >+ packssdw xmm0,xmm1 >+ packssdw xmm2,xmm3 >+ >+ movdqa XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_JCOEF)], xmm0 >+ movdqa XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_JCOEF)], xmm2 >+ >+ add rsi, byte 16*SIZEOF_FAST_FLOAT >+ add rdx, byte 16*SIZEOF_FAST_FLOAT >+ add rdi, byte 16*SIZEOF_JCOEF >+ dec rax >+ jnz short .quantloop >+ >+ uncollect_args >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcqnts2f.asm b/modules/libjpeg-turbo/simd/jcqnts2f.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcqnts2f.asm >@@ -0,0 +1,171 @@ >+; >+; jcqnts2f.asm - sample data conversion and quantization (SSE & SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Load data into workspace, applying unsigned->signed conversion >+; >+; GLOBAL(void) >+; jsimd_convsamp_float_sse2 (JSAMPARRAY sample_data, JDIMENSION start_col, >+; FAST_FLOAT * workspace); >+; >+ >+%define sample_data ebp+8 ; JSAMPARRAY sample_data >+%define start_col ebp+12 ; JDIMENSION start_col >+%define workspace ebp+16 ; FAST_FLOAT * workspace >+ >+ align 16 >+ global EXTN(jsimd_convsamp_float_sse2) >+ >+EXTN(jsimd_convsamp_float_sse2): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ pcmpeqw xmm7,xmm7 >+ psllw xmm7,7 >+ packsswb xmm7,xmm7 ; xmm7 = PB_CENTERJSAMPLE (0x808080..) >+ >+ mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *) >+ mov eax, JDIMENSION [start_col] >+ mov edi, POINTER [workspace] ; (DCTELEM *) >+ mov ecx, DCTSIZE/2 >+ alignx 16,7 >+.convloop: >+ mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ >+ movq xmm0, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE] >+ movq xmm1, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE] >+ >+ psubb xmm0,xmm7 ; xmm0=(01234567) >+ psubb xmm1,xmm7 ; xmm1=(89ABCDEF) >+ >+ punpcklbw xmm0,xmm0 ; xmm0=(*0*1*2*3*4*5*6*7) >+ punpcklbw xmm1,xmm1 ; xmm1=(*8*9*A*B*C*D*E*F) >+ >+ punpcklwd xmm2,xmm0 ; xmm2=(***0***1***2***3) >+ punpckhwd xmm0,xmm0 ; xmm0=(***4***5***6***7) >+ punpcklwd xmm3,xmm1 ; xmm3=(***8***9***A***B) >+ punpckhwd xmm1,xmm1 ; xmm1=(***C***D***E***F) >+ >+ psrad xmm2,(DWORD_BIT-BYTE_BIT) ; xmm2=(0123) >+ psrad xmm0,(DWORD_BIT-BYTE_BIT) ; xmm0=(4567) >+ cvtdq2ps xmm2,xmm2 ; xmm2=(0123) >+ cvtdq2ps xmm0,xmm0 ; xmm0=(4567) >+ psrad xmm3,(DWORD_BIT-BYTE_BIT) ; xmm3=(89AB) >+ psrad xmm1,(DWORD_BIT-BYTE_BIT) ; xmm1=(CDEF) >+ cvtdq2ps xmm3,xmm3 ; xmm3=(89AB) >+ cvtdq2ps xmm1,xmm1 ; xmm1=(CDEF) >+ >+ movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm2 >+ movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm3 >+ movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm1 >+ >+ add esi, byte 2*SIZEOF_JSAMPROW >+ add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT >+ dec ecx >+ jnz short .convloop >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+ >+; -------------------------------------------------------------------------- >+; >+; Quantize/descale the coefficients, and store into coef_block >+; >+; GLOBAL(void) >+; jsimd_quantize_float_sse2 (JCOEFPTR coef_block, FAST_FLOAT * divisors, >+; FAST_FLOAT * workspace); >+; >+ >+%define coef_block ebp+8 ; JCOEFPTR coef_block >+%define divisors ebp+12 ; FAST_FLOAT * divisors >+%define workspace ebp+16 ; FAST_FLOAT * workspace >+ >+ align 16 >+ global EXTN(jsimd_quantize_float_sse2) >+ >+EXTN(jsimd_quantize_float_sse2): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; unused >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov esi, POINTER [workspace] >+ mov edx, POINTER [divisors] >+ mov edi, JCOEFPTR [coef_block] >+ mov eax, DCTSIZE2/16 >+ alignx 16,7 >+.quantloop: >+ movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)] >+ mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)] >+ mulps xmm1, XMMWORD [XMMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(1,1,esi,SIZEOF_FAST_FLOAT)] >+ mulps xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)] >+ mulps xmm3, XMMWORD [XMMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)] >+ >+ cvtps2dq xmm0,xmm0 >+ cvtps2dq xmm1,xmm1 >+ cvtps2dq xmm2,xmm2 >+ cvtps2dq xmm3,xmm3 >+ >+ packssdw xmm0,xmm1 >+ packssdw xmm2,xmm3 >+ >+ movdqa XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_JCOEF)], xmm0 >+ movdqa XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_JCOEF)], xmm2 >+ >+ add esi, byte 16*SIZEOF_FAST_FLOAT >+ add edx, byte 16*SIZEOF_FAST_FLOAT >+ add edi, byte 16*SIZEOF_JCOEF >+ dec eax >+ jnz short .quantloop >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; unused >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcqnts2i-64.asm b/modules/libjpeg-turbo/simd/jcqnts2i-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcqnts2i-64.asm >@@ -0,0 +1,187 @@ >+; >+; jcqnts2i-64.asm - sample data conversion and quantization (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Load data into workspace, applying unsigned->signed conversion >+; >+; GLOBAL(void) >+; jsimd_convsamp_sse2 (JSAMPARRAY sample_data, JDIMENSION start_col, >+; DCTELEM * workspace); >+; >+ >+; r10 = JSAMPARRAY sample_data >+; r11 = JDIMENSION start_col >+; r12 = DCTELEM * workspace >+ >+ align 16 >+ global EXTN(jsimd_convsamp_sse2) >+ >+EXTN(jsimd_convsamp_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ push rbx >+ >+ pxor xmm6,xmm6 ; xmm6=(all 0's) >+ pcmpeqw xmm7,xmm7 >+ psllw xmm7,7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..} >+ >+ mov rsi, r10 >+ mov rax, r11 >+ mov rdi, r12 >+ mov rcx, DCTSIZE/4 >+.convloop: >+ mov rbx, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ mov rdx, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ >+ movq xmm0, XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE] ; xmm0=(01234567) >+ movq xmm1, XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE] ; xmm1=(89ABCDEF) >+ >+ mov rbx, JSAMPROW [rsi+2*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ mov rdx, JSAMPROW [rsi+3*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ >+ movq xmm2, XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE] ; xmm2=(GHIJKLMN) >+ movq xmm3, XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE] ; xmm3=(OPQRSTUV) >+ >+ punpcklbw xmm0,xmm6 ; xmm0=(01234567) >+ punpcklbw xmm1,xmm6 ; xmm1=(89ABCDEF) >+ paddw xmm0,xmm7 >+ paddw xmm1,xmm7 >+ punpcklbw xmm2,xmm6 ; xmm2=(GHIJKLMN) >+ punpcklbw xmm3,xmm6 ; xmm3=(OPQRSTUV) >+ paddw xmm2,xmm7 >+ paddw xmm3,xmm7 >+ >+ movdqa XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_DCTELEM)], xmm0 >+ movdqa XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_DCTELEM)], xmm1 >+ movdqa XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_DCTELEM)], xmm2 >+ movdqa XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_DCTELEM)], xmm3 >+ >+ add rsi, byte 4*SIZEOF_JSAMPROW >+ add rdi, byte 4*DCTSIZE*SIZEOF_DCTELEM >+ dec rcx >+ jnz short .convloop >+ >+ pop rbx >+ uncollect_args >+ pop rbp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Quantize/descale the coefficients, and store into coef_block >+; >+; This implementation is based on an algorithm described in >+; "How to optimize for the Pentium family of microprocessors" >+; (http://www.agner.org/assem/). >+; >+; GLOBAL(void) >+; jsimd_quantize_sse2 (JCOEFPTR coef_block, DCTELEM * divisors, >+; DCTELEM * workspace); >+; >+ >+%define RECIPROCAL(m,n,b) XMMBLOCK(DCTSIZE*0+(m),(n),(b),SIZEOF_DCTELEM) >+%define CORRECTION(m,n,b) XMMBLOCK(DCTSIZE*1+(m),(n),(b),SIZEOF_DCTELEM) >+%define SCALE(m,n,b) XMMBLOCK(DCTSIZE*2+(m),(n),(b),SIZEOF_DCTELEM) >+ >+; r10 = JCOEFPTR coef_block >+; r11 = DCTELEM * divisors >+; r12 = DCTELEM * workspace >+ >+ align 16 >+ global EXTN(jsimd_quantize_sse2) >+ >+EXTN(jsimd_quantize_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ >+ mov rsi, r12 >+ mov rdx, r11 >+ mov rdi, r10 >+ mov rax, DCTSIZE2/32 >+.quantloop: >+ movdqa xmm4, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_DCTELEM)] >+ movdqa xmm5, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_DCTELEM)] >+ movdqa xmm6, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_DCTELEM)] >+ movdqa xmm7, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_DCTELEM)] >+ movdqa xmm0,xmm4 >+ movdqa xmm1,xmm5 >+ movdqa xmm2,xmm6 >+ movdqa xmm3,xmm7 >+ psraw xmm4,(WORD_BIT-1) >+ psraw xmm5,(WORD_BIT-1) >+ psraw xmm6,(WORD_BIT-1) >+ psraw xmm7,(WORD_BIT-1) >+ pxor xmm0,xmm4 >+ pxor xmm1,xmm5 >+ pxor xmm2,xmm6 >+ pxor xmm3,xmm7 >+ psubw xmm0,xmm4 ; if (xmm0 < 0) xmm0 = -xmm0; >+ psubw xmm1,xmm5 ; if (xmm1 < 0) xmm1 = -xmm1; >+ psubw xmm2,xmm6 ; if (xmm2 < 0) xmm2 = -xmm2; >+ psubw xmm3,xmm7 ; if (xmm3 < 0) xmm3 = -xmm3; >+ >+ paddw xmm0, XMMWORD [CORRECTION(0,0,rdx)] ; correction + roundfactor >+ paddw xmm1, XMMWORD [CORRECTION(1,0,rdx)] >+ paddw xmm2, XMMWORD [CORRECTION(2,0,rdx)] >+ paddw xmm3, XMMWORD [CORRECTION(3,0,rdx)] >+ pmulhuw xmm0, XMMWORD [RECIPROCAL(0,0,rdx)] ; reciprocal >+ pmulhuw xmm1, XMMWORD [RECIPROCAL(1,0,rdx)] >+ pmulhuw xmm2, XMMWORD [RECIPROCAL(2,0,rdx)] >+ pmulhuw xmm3, XMMWORD [RECIPROCAL(3,0,rdx)] >+ pmulhuw xmm0, XMMWORD [SCALE(0,0,rdx)] ; scale >+ pmulhuw xmm1, XMMWORD [SCALE(1,0,rdx)] >+ pmulhuw xmm2, XMMWORD [SCALE(2,0,rdx)] >+ pmulhuw xmm3, XMMWORD [SCALE(3,0,rdx)] >+ >+ pxor xmm0,xmm4 >+ pxor xmm1,xmm5 >+ pxor xmm2,xmm6 >+ pxor xmm3,xmm7 >+ psubw xmm0,xmm4 >+ psubw xmm1,xmm5 >+ psubw xmm2,xmm6 >+ psubw xmm3,xmm7 >+ movdqa XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_DCTELEM)], xmm0 >+ movdqa XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_DCTELEM)], xmm1 >+ movdqa XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_DCTELEM)], xmm2 >+ movdqa XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_DCTELEM)], xmm3 >+ >+ add rsi, byte 32*SIZEOF_DCTELEM >+ add rdx, byte 32*SIZEOF_DCTELEM >+ add rdi, byte 32*SIZEOF_JCOEF >+ dec rax >+ jnz near .quantloop >+ >+ uncollect_args >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcqnts2i.asm b/modules/libjpeg-turbo/simd/jcqnts2i.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcqnts2i.asm >@@ -0,0 +1,200 @@ >+; >+; jcqnts2i.asm - sample data conversion and quantization (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Load data into workspace, applying unsigned->signed conversion >+; >+; GLOBAL(void) >+; jsimd_convsamp_sse2 (JSAMPARRAY sample_data, JDIMENSION start_col, >+; DCTELEM * workspace); >+; >+ >+%define sample_data ebp+8 ; JSAMPARRAY sample_data >+%define start_col ebp+12 ; JDIMENSION start_col >+%define workspace ebp+16 ; DCTELEM * workspace >+ >+ align 16 >+ global EXTN(jsimd_convsamp_sse2) >+ >+EXTN(jsimd_convsamp_sse2): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ pxor xmm6,xmm6 ; xmm6=(all 0's) >+ pcmpeqw xmm7,xmm7 >+ psllw xmm7,7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..} >+ >+ mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *) >+ mov eax, JDIMENSION [start_col] >+ mov edi, POINTER [workspace] ; (DCTELEM *) >+ mov ecx, DCTSIZE/4 >+ alignx 16,7 >+.convloop: >+ mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ >+ movq xmm0, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE] ; xmm0=(01234567) >+ movq xmm1, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE] ; xmm1=(89ABCDEF) >+ >+ mov ebx, JSAMPROW [esi+2*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ mov edx, JSAMPROW [esi+3*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ >+ movq xmm2, XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE] ; xmm2=(GHIJKLMN) >+ movq xmm3, XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE] ; xmm3=(OPQRSTUV) >+ >+ punpcklbw xmm0,xmm6 ; xmm0=(01234567) >+ punpcklbw xmm1,xmm6 ; xmm1=(89ABCDEF) >+ paddw xmm0,xmm7 >+ paddw xmm1,xmm7 >+ punpcklbw xmm2,xmm6 ; xmm2=(GHIJKLMN) >+ punpcklbw xmm3,xmm6 ; xmm3=(OPQRSTUV) >+ paddw xmm2,xmm7 >+ paddw xmm3,xmm7 >+ >+ movdqa XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_DCTELEM)], xmm0 >+ movdqa XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_DCTELEM)], xmm1 >+ movdqa XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_DCTELEM)], xmm2 >+ movdqa XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_DCTELEM)], xmm3 >+ >+ add esi, byte 4*SIZEOF_JSAMPROW >+ add edi, byte 4*DCTSIZE*SIZEOF_DCTELEM >+ dec ecx >+ jnz short .convloop >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Quantize/descale the coefficients, and store into coef_block >+; >+; This implementation is based on an algorithm described in >+; "How to optimize for the Pentium family of microprocessors" >+; (http://www.agner.org/assem/). >+; >+; GLOBAL(void) >+; jsimd_quantize_sse2 (JCOEFPTR coef_block, DCTELEM * divisors, >+; DCTELEM * workspace); >+; >+ >+%define RECIPROCAL(m,n,b) XMMBLOCK(DCTSIZE*0+(m),(n),(b),SIZEOF_DCTELEM) >+%define CORRECTION(m,n,b) XMMBLOCK(DCTSIZE*1+(m),(n),(b),SIZEOF_DCTELEM) >+%define SCALE(m,n,b) XMMBLOCK(DCTSIZE*2+(m),(n),(b),SIZEOF_DCTELEM) >+ >+%define coef_block ebp+8 ; JCOEFPTR coef_block >+%define divisors ebp+12 ; DCTELEM * divisors >+%define workspace ebp+16 ; DCTELEM * workspace >+ >+ align 16 >+ global EXTN(jsimd_quantize_sse2) >+ >+EXTN(jsimd_quantize_sse2): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; unused >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov esi, POINTER [workspace] >+ mov edx, POINTER [divisors] >+ mov edi, JCOEFPTR [coef_block] >+ mov eax, DCTSIZE2/32 >+ alignx 16,7 >+.quantloop: >+ movdqa xmm4, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_DCTELEM)] >+ movdqa xmm5, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_DCTELEM)] >+ movdqa xmm6, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_DCTELEM)] >+ movdqa xmm7, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_DCTELEM)] >+ movdqa xmm0,xmm4 >+ movdqa xmm1,xmm5 >+ movdqa xmm2,xmm6 >+ movdqa xmm3,xmm7 >+ psraw xmm4,(WORD_BIT-1) >+ psraw xmm5,(WORD_BIT-1) >+ psraw xmm6,(WORD_BIT-1) >+ psraw xmm7,(WORD_BIT-1) >+ pxor xmm0,xmm4 >+ pxor xmm1,xmm5 >+ pxor xmm2,xmm6 >+ pxor xmm3,xmm7 >+ psubw xmm0,xmm4 ; if (xmm0 < 0) xmm0 = -xmm0; >+ psubw xmm1,xmm5 ; if (xmm1 < 0) xmm1 = -xmm1; >+ psubw xmm2,xmm6 ; if (xmm2 < 0) xmm2 = -xmm2; >+ psubw xmm3,xmm7 ; if (xmm3 < 0) xmm3 = -xmm3; >+ >+ paddw xmm0, XMMWORD [CORRECTION(0,0,edx)] ; correction + roundfactor >+ paddw xmm1, XMMWORD [CORRECTION(1,0,edx)] >+ paddw xmm2, XMMWORD [CORRECTION(2,0,edx)] >+ paddw xmm3, XMMWORD [CORRECTION(3,0,edx)] >+ pmulhuw xmm0, XMMWORD [RECIPROCAL(0,0,edx)] ; reciprocal >+ pmulhuw xmm1, XMMWORD [RECIPROCAL(1,0,edx)] >+ pmulhuw xmm2, XMMWORD [RECIPROCAL(2,0,edx)] >+ pmulhuw xmm3, XMMWORD [RECIPROCAL(3,0,edx)] >+ pmulhuw xmm0, XMMWORD [SCALE(0,0,edx)] ; scale >+ pmulhuw xmm1, XMMWORD [SCALE(1,0,edx)] >+ pmulhuw xmm2, XMMWORD [SCALE(2,0,edx)] >+ pmulhuw xmm3, XMMWORD [SCALE(3,0,edx)] >+ >+ pxor xmm0,xmm4 >+ pxor xmm1,xmm5 >+ pxor xmm2,xmm6 >+ pxor xmm3,xmm7 >+ psubw xmm0,xmm4 >+ psubw xmm1,xmm5 >+ psubw xmm2,xmm6 >+ psubw xmm3,xmm7 >+ movdqa XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_DCTELEM)], xmm0 >+ movdqa XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_DCTELEM)], xmm1 >+ movdqa XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_DCTELEM)], xmm2 >+ movdqa XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_DCTELEM)], xmm3 >+ >+ add esi, byte 32*SIZEOF_DCTELEM >+ add edx, byte 32*SIZEOF_DCTELEM >+ add edi, byte 32*SIZEOF_JCOEF >+ dec eax >+ jnz near .quantloop >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; unused >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcqntsse.asm b/modules/libjpeg-turbo/simd/jcqntsse.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcqntsse.asm >@@ -0,0 +1,211 @@ >+; >+; jcqntsse.asm - sample data conversion and quantization (SSE & MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Load data into workspace, applying unsigned->signed conversion >+; >+; GLOBAL(void) >+; jsimd_convsamp_float_sse (JSAMPARRAY sample_data, JDIMENSION start_col, >+; FAST_FLOAT * workspace); >+; >+ >+%define sample_data ebp+8 ; JSAMPARRAY sample_data >+%define start_col ebp+12 ; JDIMENSION start_col >+%define workspace ebp+16 ; FAST_FLOAT * workspace >+ >+ align 16 >+ global EXTN(jsimd_convsamp_float_sse) >+ >+EXTN(jsimd_convsamp_float_sse): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ pcmpeqw mm7,mm7 >+ psllw mm7,7 >+ packsswb mm7,mm7 ; mm7 = PB_CENTERJSAMPLE (0x808080..) >+ >+ mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *) >+ mov eax, JDIMENSION [start_col] >+ mov edi, POINTER [workspace] ; (DCTELEM *) >+ mov ecx, DCTSIZE/2 >+ alignx 16,7 >+.convloop: >+ mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *) >+ >+ movq mm0, MMWORD [ebx+eax*SIZEOF_JSAMPLE] >+ movq mm1, MMWORD [edx+eax*SIZEOF_JSAMPLE] >+ >+ psubb mm0,mm7 ; mm0=(01234567) >+ psubb mm1,mm7 ; mm1=(89ABCDEF) >+ >+ punpcklbw mm2,mm0 ; mm2=(*0*1*2*3) >+ punpckhbw mm0,mm0 ; mm0=(*4*5*6*7) >+ punpcklbw mm3,mm1 ; mm3=(*8*9*A*B) >+ punpckhbw mm1,mm1 ; mm1=(*C*D*E*F) >+ >+ punpcklwd mm4,mm2 ; mm4=(***0***1) >+ punpckhwd mm2,mm2 ; mm2=(***2***3) >+ punpcklwd mm5,mm0 ; mm5=(***4***5) >+ punpckhwd mm0,mm0 ; mm0=(***6***7) >+ >+ psrad mm4,(DWORD_BIT-BYTE_BIT) ; mm4=(01) >+ psrad mm2,(DWORD_BIT-BYTE_BIT) ; mm2=(23) >+ cvtpi2ps xmm0,mm4 ; xmm0=(01**) >+ cvtpi2ps xmm1,mm2 ; xmm1=(23**) >+ psrad mm5,(DWORD_BIT-BYTE_BIT) ; mm5=(45) >+ psrad mm0,(DWORD_BIT-BYTE_BIT) ; mm0=(67) >+ cvtpi2ps xmm2,mm5 ; xmm2=(45**) >+ cvtpi2ps xmm3,mm0 ; xmm3=(67**) >+ >+ punpcklwd mm6,mm3 ; mm6=(***8***9) >+ punpckhwd mm3,mm3 ; mm3=(***A***B) >+ punpcklwd mm4,mm1 ; mm4=(***C***D) >+ punpckhwd mm1,mm1 ; mm1=(***E***F) >+ >+ psrad mm6,(DWORD_BIT-BYTE_BIT) ; mm6=(89) >+ psrad mm3,(DWORD_BIT-BYTE_BIT) ; mm3=(AB) >+ cvtpi2ps xmm4,mm6 ; xmm4=(89**) >+ cvtpi2ps xmm5,mm3 ; xmm5=(AB**) >+ psrad mm4,(DWORD_BIT-BYTE_BIT) ; mm4=(CD) >+ psrad mm1,(DWORD_BIT-BYTE_BIT) ; mm1=(EF) >+ cvtpi2ps xmm6,mm4 ; xmm6=(CD**) >+ cvtpi2ps xmm7,mm1 ; xmm7=(EF**) >+ >+ movlhps xmm0,xmm1 ; xmm0=(0123) >+ movlhps xmm2,xmm3 ; xmm2=(4567) >+ movlhps xmm4,xmm5 ; xmm4=(89AB) >+ movlhps xmm6,xmm7 ; xmm6=(CDEF) >+ >+ movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm2 >+ movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm4 >+ movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6 >+ >+ add esi, byte 2*SIZEOF_JSAMPROW >+ add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT >+ dec ecx >+ jnz near .convloop >+ >+ emms ; empty MMX state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+ >+; -------------------------------------------------------------------------- >+; >+; Quantize/descale the coefficients, and store into coef_block >+; >+; GLOBAL(void) >+; jsimd_quantize_float_sse (JCOEFPTR coef_block, FAST_FLOAT * divisors, >+; FAST_FLOAT * workspace); >+; >+ >+%define coef_block ebp+8 ; JCOEFPTR coef_block >+%define divisors ebp+12 ; FAST_FLOAT * divisors >+%define workspace ebp+16 ; FAST_FLOAT * workspace >+ >+ align 16 >+ global EXTN(jsimd_quantize_float_sse) >+ >+EXTN(jsimd_quantize_float_sse): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; unused >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov esi, POINTER [workspace] >+ mov edx, POINTER [divisors] >+ mov edi, JCOEFPTR [coef_block] >+ mov eax, DCTSIZE2/16 >+ alignx 16,7 >+.quantloop: >+ movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)] >+ mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)] >+ mulps xmm1, XMMWORD [XMMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(1,1,esi,SIZEOF_FAST_FLOAT)] >+ mulps xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)] >+ mulps xmm3, XMMWORD [XMMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)] >+ >+ movhlps xmm4,xmm0 >+ movhlps xmm5,xmm1 >+ >+ cvtps2pi mm0,xmm0 >+ cvtps2pi mm1,xmm1 >+ cvtps2pi mm4,xmm4 >+ cvtps2pi mm5,xmm5 >+ >+ movhlps xmm6,xmm2 >+ movhlps xmm7,xmm3 >+ >+ cvtps2pi mm2,xmm2 >+ cvtps2pi mm3,xmm3 >+ cvtps2pi mm6,xmm6 >+ cvtps2pi mm7,xmm7 >+ >+ packssdw mm0,mm4 >+ packssdw mm1,mm5 >+ packssdw mm2,mm6 >+ packssdw mm3,mm7 >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0 >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm1 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm2 >+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm3 >+ >+ add esi, byte 16*SIZEOF_FAST_FLOAT >+ add edx, byte 16*SIZEOF_FAST_FLOAT >+ add edi, byte 16*SIZEOF_JCOEF >+ dec eax >+ jnz short .quantloop >+ >+ emms ; empty MMX state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; unused >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcsammmx.asm b/modules/libjpeg-turbo/simd/jcsammmx.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcsammmx.asm >@@ -0,0 +1,324 @@ >+; >+; jcsammmx.asm - downsampling (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Downsample pixel values of a single component. >+; This version handles the common case of 2:1 horizontal and 1:1 vertical, >+; without smoothing. >+; >+; GLOBAL(void) >+; jsimd_h2v1_downsample_mmx (JDIMENSION image_width, int max_v_samp_factor, >+; JDIMENSION v_samp_factor, JDIMENSION width_blocks, >+; JSAMPARRAY input_data, JSAMPARRAY output_data); >+; >+ >+%define img_width(b) (b)+8 ; JDIMENSION image_width >+%define max_v_samp(b) (b)+12 ; int max_v_samp_factor >+%define v_samp(b) (b)+16 ; JDIMENSION v_samp_factor >+%define width_blks(b) (b)+20 ; JDIMENSION width_blocks >+%define input_data(b) (b)+24 ; JSAMPARRAY input_data >+%define output_data(b) (b)+28 ; JSAMPARRAY output_data >+ >+ align 16 >+ global EXTN(jsimd_h2v1_downsample_mmx) >+ >+EXTN(jsimd_h2v1_downsample_mmx): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov ecx, JDIMENSION [width_blks(ebp)] >+ shl ecx,3 ; imul ecx,DCTSIZE (ecx = output_cols) >+ jz near .return >+ >+ mov edx, JDIMENSION [img_width(ebp)] >+ >+ ; -- expand_right_edge >+ >+ push ecx >+ shl ecx,1 ; output_cols * 2 >+ sub ecx,edx >+ jle short .expand_end >+ >+ mov eax, INT [max_v_samp(ebp)] >+ test eax,eax >+ jle short .expand_end >+ >+ cld >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ alignx 16,7 >+.expandloop: >+ push eax >+ push ecx >+ >+ mov edi, JSAMPROW [esi] >+ add edi,edx >+ mov al, JSAMPLE [edi-1] >+ >+ rep stosb >+ >+ pop ecx >+ pop eax >+ >+ add esi, byte SIZEOF_JSAMPROW >+ dec eax >+ jg short .expandloop >+ >+.expand_end: >+ pop ecx ; output_cols >+ >+ ; -- h2v1_downsample >+ >+ mov eax, JDIMENSION [v_samp(ebp)] ; rowctr >+ test eax,eax >+ jle near .return >+ >+ mov edx, 0x00010000 ; bias pattern >+ movd mm7,edx >+ pcmpeqw mm6,mm6 >+ punpckldq mm7,mm7 ; mm7={0, 1, 0, 1} >+ psrlw mm6,BYTE_BIT ; mm6={0xFF 0x00 0xFF 0x00 ..} >+ >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ mov edi, JSAMPARRAY [output_data(ebp)] ; output_data >+ alignx 16,7 >+.rowloop: >+ push ecx >+ push edi >+ push esi >+ >+ mov esi, JSAMPROW [esi] ; inptr >+ mov edi, JSAMPROW [edi] ; outptr >+ alignx 16,7 >+.columnloop: >+ >+ movq mm0, MMWORD [esi+0*SIZEOF_MMWORD] >+ movq mm1, MMWORD [esi+1*SIZEOF_MMWORD] >+ movq mm2,mm0 >+ movq mm3,mm1 >+ >+ pand mm0,mm6 >+ psrlw mm2,BYTE_BIT >+ pand mm1,mm6 >+ psrlw mm3,BYTE_BIT >+ >+ paddw mm0,mm2 >+ paddw mm1,mm3 >+ paddw mm0,mm7 >+ paddw mm1,mm7 >+ psrlw mm0,1 >+ psrlw mm1,1 >+ >+ packuswb mm0,mm1 >+ >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mm0 >+ >+ add esi, byte 2*SIZEOF_MMWORD ; inptr >+ add edi, byte 1*SIZEOF_MMWORD ; outptr >+ sub ecx, byte SIZEOF_MMWORD ; outcol >+ jnz short .columnloop >+ >+ pop esi >+ pop edi >+ pop ecx >+ >+ add esi, byte SIZEOF_JSAMPROW ; input_data >+ add edi, byte SIZEOF_JSAMPROW ; output_data >+ dec eax ; rowctr >+ jg short .rowloop >+ >+ emms ; empty MMX state >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Downsample pixel values of a single component. >+; This version handles the standard case of 2:1 horizontal and 2:1 vertical, >+; without smoothing. >+; >+; GLOBAL(void) >+; jsimd_h2v2_downsample_mmx (JDIMENSION image_width, int max_v_samp_factor, >+; JDIMENSION v_samp_factor, JDIMENSION width_blocks, >+; JSAMPARRAY input_data, JSAMPARRAY output_data); >+; >+ >+%define img_width(b) (b)+8 ; JDIMENSION image_width >+%define max_v_samp(b) (b)+12 ; int max_v_samp_factor >+%define v_samp(b) (b)+16 ; JDIMENSION v_samp_factor >+%define width_blks(b) (b)+20 ; JDIMENSION width_blocks >+%define input_data(b) (b)+24 ; JSAMPARRAY input_data >+%define output_data(b) (b)+28 ; JSAMPARRAY output_data >+ >+ align 16 >+ global EXTN(jsimd_h2v2_downsample_mmx) >+ >+EXTN(jsimd_h2v2_downsample_mmx): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov ecx, JDIMENSION [width_blks(ebp)] >+ shl ecx,3 ; imul ecx,DCTSIZE (ecx = output_cols) >+ jz near .return >+ >+ mov edx, JDIMENSION [img_width(ebp)] >+ >+ ; -- expand_right_edge >+ >+ push ecx >+ shl ecx,1 ; output_cols * 2 >+ sub ecx,edx >+ jle short .expand_end >+ >+ mov eax, INT [max_v_samp(ebp)] >+ test eax,eax >+ jle short .expand_end >+ >+ cld >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ alignx 16,7 >+.expandloop: >+ push eax >+ push ecx >+ >+ mov edi, JSAMPROW [esi] >+ add edi,edx >+ mov al, JSAMPLE [edi-1] >+ >+ rep stosb >+ >+ pop ecx >+ pop eax >+ >+ add esi, byte SIZEOF_JSAMPROW >+ dec eax >+ jg short .expandloop >+ >+.expand_end: >+ pop ecx ; output_cols >+ >+ ; -- h2v2_downsample >+ >+ mov eax, JDIMENSION [v_samp(ebp)] ; rowctr >+ test eax,eax >+ jle near .return >+ >+ mov edx, 0x00020001 ; bias pattern >+ movd mm7,edx >+ pcmpeqw mm6,mm6 >+ punpckldq mm7,mm7 ; mm7={1, 2, 1, 2} >+ psrlw mm6,BYTE_BIT ; mm6={0xFF 0x00 0xFF 0x00 ..} >+ >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ mov edi, JSAMPARRAY [output_data(ebp)] ; output_data >+ alignx 16,7 >+.rowloop: >+ push ecx >+ push edi >+ push esi >+ >+ mov edx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0 >+ mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1 >+ mov edi, JSAMPROW [edi] ; outptr >+ alignx 16,7 >+.columnloop: >+ >+ movq mm0, MMWORD [edx+0*SIZEOF_MMWORD] >+ movq mm1, MMWORD [esi+0*SIZEOF_MMWORD] >+ movq mm2, MMWORD [edx+1*SIZEOF_MMWORD] >+ movq mm3, MMWORD [esi+1*SIZEOF_MMWORD] >+ >+ movq mm4,mm0 >+ movq mm5,mm1 >+ pand mm0,mm6 >+ psrlw mm4,BYTE_BIT >+ pand mm1,mm6 >+ psrlw mm5,BYTE_BIT >+ paddw mm0,mm4 >+ paddw mm1,mm5 >+ >+ movq mm4,mm2 >+ movq mm5,mm3 >+ pand mm2,mm6 >+ psrlw mm4,BYTE_BIT >+ pand mm3,mm6 >+ psrlw mm5,BYTE_BIT >+ paddw mm2,mm4 >+ paddw mm3,mm5 >+ >+ paddw mm0,mm1 >+ paddw mm2,mm3 >+ paddw mm0,mm7 >+ paddw mm2,mm7 >+ psrlw mm0,2 >+ psrlw mm2,2 >+ >+ packuswb mm0,mm2 >+ >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mm0 >+ >+ add edx, byte 2*SIZEOF_MMWORD ; inptr0 >+ add esi, byte 2*SIZEOF_MMWORD ; inptr1 >+ add edi, byte 1*SIZEOF_MMWORD ; outptr >+ sub ecx, byte SIZEOF_MMWORD ; outcol >+ jnz near .columnloop >+ >+ pop esi >+ pop edi >+ pop ecx >+ >+ add esi, byte 2*SIZEOF_JSAMPROW ; input_data >+ add edi, byte 1*SIZEOF_JSAMPROW ; output_data >+ dec eax ; rowctr >+ jg near .rowloop >+ >+ emms ; empty MMX state >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcsamss2-64.asm b/modules/libjpeg-turbo/simd/jcsamss2-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcsamss2-64.asm >@@ -0,0 +1,330 @@ >+; >+; jcsamss2-64.asm - downsampling (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Downsample pixel values of a single component. >+; This version handles the common case of 2:1 horizontal and 1:1 vertical, >+; without smoothing. >+; >+; GLOBAL(void) >+; jsimd_h2v1_downsample_sse2 (JDIMENSION image_width, int max_v_samp_factor, >+; JDIMENSION v_samp_factor, JDIMENSION width_blocks, >+; JSAMPARRAY input_data, JSAMPARRAY output_data); >+; >+ >+; r10 = JDIMENSION image_width >+; r11 = int max_v_samp_factor >+; r12 = JDIMENSION v_samp_factor >+; r13 = JDIMENSION width_blocks >+; r14 = JSAMPARRAY input_data >+; r15 = JSAMPARRAY output_data >+ >+ align 16 >+ global EXTN(jsimd_h2v1_downsample_sse2) >+ >+EXTN(jsimd_h2v1_downsample_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ >+ mov rcx, r13 >+ shl rcx,3 ; imul rcx,DCTSIZE (rcx = output_cols) >+ jz near .return >+ >+ mov rdx, r10 >+ >+ ; -- expand_right_edge >+ >+ push rcx >+ shl rcx,1 ; output_cols * 2 >+ sub rcx,rdx >+ jle short .expand_end >+ >+ mov rax, r11 >+ test rax,rax >+ jle short .expand_end >+ >+ cld >+ mov rsi, r14 ; input_data >+.expandloop: >+ push rax >+ push rcx >+ >+ mov rdi, JSAMPROW [rsi] >+ add rdi,rdx >+ mov al, JSAMPLE [rdi-1] >+ >+ rep stosb >+ >+ pop rcx >+ pop rax >+ >+ add rsi, byte SIZEOF_JSAMPROW >+ dec rax >+ jg short .expandloop >+ >+.expand_end: >+ pop rcx ; output_cols >+ >+ ; -- h2v1_downsample >+ >+ mov rax, r12 ; rowctr >+ test eax,eax >+ jle near .return >+ >+ mov rdx, 0x00010000 ; bias pattern >+ movd xmm7,edx >+ pcmpeqw xmm6,xmm6 >+ pshufd xmm7,xmm7,0x00 ; xmm7={0, 1, 0, 1, 0, 1, 0, 1} >+ psrlw xmm6,BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..} >+ >+ mov rsi, r14 ; input_data >+ mov rdi, r15 ; output_data >+.rowloop: >+ push rcx >+ push rdi >+ push rsi >+ >+ mov rsi, JSAMPROW [rsi] ; inptr >+ mov rdi, JSAMPROW [rdi] ; outptr >+ >+ cmp rcx, byte SIZEOF_XMMWORD >+ jae short .columnloop >+ >+.columnloop_r8: >+ movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ pxor xmm1,xmm1 >+ mov rcx, SIZEOF_XMMWORD >+ jmp short .downsample >+ >+.columnloop: >+ movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ movdqa xmm1, XMMWORD [rsi+1*SIZEOF_XMMWORD] >+ >+.downsample: >+ movdqa xmm2,xmm0 >+ movdqa xmm3,xmm1 >+ >+ pand xmm0,xmm6 >+ psrlw xmm2,BYTE_BIT >+ pand xmm1,xmm6 >+ psrlw xmm3,BYTE_BIT >+ >+ paddw xmm0,xmm2 >+ paddw xmm1,xmm3 >+ paddw xmm0,xmm7 >+ paddw xmm1,xmm7 >+ psrlw xmm0,1 >+ psrlw xmm1,1 >+ >+ packuswb xmm0,xmm1 >+ >+ movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0 >+ >+ sub rcx, byte SIZEOF_XMMWORD ; outcol >+ add rsi, byte 2*SIZEOF_XMMWORD ; inptr >+ add rdi, byte 1*SIZEOF_XMMWORD ; outptr >+ cmp rcx, byte SIZEOF_XMMWORD >+ jae short .columnloop >+ test rcx,rcx >+ jnz short .columnloop_r8 >+ >+ pop rsi >+ pop rdi >+ pop rcx >+ >+ add rsi, byte SIZEOF_JSAMPROW ; input_data >+ add rdi, byte SIZEOF_JSAMPROW ; output_data >+ dec rax ; rowctr >+ jg near .rowloop >+ >+.return: >+ uncollect_args >+ pop rbp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Downsample pixel values of a single component. >+; This version handles the standard case of 2:1 horizontal and 2:1 vertical, >+; without smoothing. >+; >+; GLOBAL(void) >+; jsimd_h2v2_downsample_sse2 (JDIMENSION image_width, int max_v_samp_factor, >+; JDIMENSION v_samp_factor, JDIMENSION width_blocks, >+; JSAMPARRAY input_data, JSAMPARRAY output_data); >+; >+ >+; r10 = JDIMENSION image_width >+; r11 = int max_v_samp_factor >+; r12 = JDIMENSION v_samp_factor >+; r13 = JDIMENSION width_blocks >+; r14 = JSAMPARRAY input_data >+; r15 = JSAMPARRAY output_data >+ >+ align 16 >+ global EXTN(jsimd_h2v2_downsample_sse2) >+ >+EXTN(jsimd_h2v2_downsample_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ >+ mov rcx, r13 >+ shl rcx,3 ; imul rcx,DCTSIZE (rcx = output_cols) >+ jz near .return >+ >+ mov rdx, r10 >+ >+ ; -- expand_right_edge >+ >+ push rcx >+ shl rcx,1 ; output_cols * 2 >+ sub rcx,rdx >+ jle short .expand_end >+ >+ mov rax, r11 >+ test rax,rax >+ jle short .expand_end >+ >+ cld >+ mov rsi, r14 ; input_data >+.expandloop: >+ push rax >+ push rcx >+ >+ mov rdi, JSAMPROW [rsi] >+ add rdi,rdx >+ mov al, JSAMPLE [rdi-1] >+ >+ rep stosb >+ >+ pop rcx >+ pop rax >+ >+ add rsi, byte SIZEOF_JSAMPROW >+ dec rax >+ jg short .expandloop >+ >+.expand_end: >+ pop rcx ; output_cols >+ >+ ; -- h2v2_downsample >+ >+ mov rax, r12 ; rowctr >+ test rax,rax >+ jle near .return >+ >+ mov rdx, 0x00020001 ; bias pattern >+ movd xmm7,edx >+ pcmpeqw xmm6,xmm6 >+ pshufd xmm7,xmm7,0x00 ; xmm7={1, 2, 1, 2, 1, 2, 1, 2} >+ psrlw xmm6,BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..} >+ >+ mov rsi, r14 ; input_data >+ mov rdi, r15 ; output_data >+.rowloop: >+ push rcx >+ push rdi >+ push rsi >+ >+ mov rdx, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; inptr0 >+ mov rsi, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; inptr1 >+ mov rdi, JSAMPROW [rdi] ; outptr >+ >+ cmp rcx, byte SIZEOF_XMMWORD >+ jae short .columnloop >+ >+.columnloop_r8: >+ movdqa xmm0, XMMWORD [rdx+0*SIZEOF_XMMWORD] >+ movdqa xmm1, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ pxor xmm2,xmm2 >+ pxor xmm3,xmm3 >+ mov rcx, SIZEOF_XMMWORD >+ jmp short .downsample >+ >+.columnloop: >+ movdqa xmm0, XMMWORD [rdx+0*SIZEOF_XMMWORD] >+ movdqa xmm1, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ movdqa xmm2, XMMWORD [rdx+1*SIZEOF_XMMWORD] >+ movdqa xmm3, XMMWORD [rsi+1*SIZEOF_XMMWORD] >+ >+.downsample: >+ movdqa xmm4,xmm0 >+ movdqa xmm5,xmm1 >+ pand xmm0,xmm6 >+ psrlw xmm4,BYTE_BIT >+ pand xmm1,xmm6 >+ psrlw xmm5,BYTE_BIT >+ paddw xmm0,xmm4 >+ paddw xmm1,xmm5 >+ >+ movdqa xmm4,xmm2 >+ movdqa xmm5,xmm3 >+ pand xmm2,xmm6 >+ psrlw xmm4,BYTE_BIT >+ pand xmm3,xmm6 >+ psrlw xmm5,BYTE_BIT >+ paddw xmm2,xmm4 >+ paddw xmm3,xmm5 >+ >+ paddw xmm0,xmm1 >+ paddw xmm2,xmm3 >+ paddw xmm0,xmm7 >+ paddw xmm2,xmm7 >+ psrlw xmm0,2 >+ psrlw xmm2,2 >+ >+ packuswb xmm0,xmm2 >+ >+ movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0 >+ >+ sub rcx, byte SIZEOF_XMMWORD ; outcol >+ add rdx, byte 2*SIZEOF_XMMWORD ; inptr0 >+ add rsi, byte 2*SIZEOF_XMMWORD ; inptr1 >+ add rdi, byte 1*SIZEOF_XMMWORD ; outptr >+ cmp rcx, byte SIZEOF_XMMWORD >+ jae near .columnloop >+ test rcx,rcx >+ jnz near .columnloop_r8 >+ >+ pop rsi >+ pop rdi >+ pop rcx >+ >+ add rsi, byte 2*SIZEOF_JSAMPROW ; input_data >+ add rdi, byte 1*SIZEOF_JSAMPROW ; output_data >+ dec rax ; rowctr >+ jg near .rowloop >+ >+.return: >+ uncollect_args >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jcsamss2.asm b/modules/libjpeg-turbo/simd/jcsamss2.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jcsamss2.asm >@@ -0,0 +1,351 @@ >+; >+; jcsamss2.asm - downsampling (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Downsample pixel values of a single component. >+; This version handles the common case of 2:1 horizontal and 1:1 vertical, >+; without smoothing. >+; >+; GLOBAL(void) >+; jsimd_h2v1_downsample_sse2 (JDIMENSION image_width, int max_v_samp_factor, >+; JDIMENSION v_samp_factor, JDIMENSION width_blocks, >+; JSAMPARRAY input_data, JSAMPARRAY output_data); >+; >+ >+%define img_width(b) (b)+8 ; JDIMENSION image_width >+%define max_v_samp(b) (b)+12 ; int max_v_samp_factor >+%define v_samp(b) (b)+16 ; JDIMENSION v_samp_factor >+%define width_blks(b) (b)+20 ; JDIMENSION width_blocks >+%define input_data(b) (b)+24 ; JSAMPARRAY input_data >+%define output_data(b) (b)+28 ; JSAMPARRAY output_data >+ >+ align 16 >+ global EXTN(jsimd_h2v1_downsample_sse2) >+ >+EXTN(jsimd_h2v1_downsample_sse2): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov ecx, JDIMENSION [width_blks(ebp)] >+ shl ecx,3 ; imul ecx,DCTSIZE (ecx = output_cols) >+ jz near .return >+ >+ mov edx, JDIMENSION [img_width(ebp)] >+ >+ ; -- expand_right_edge >+ >+ push ecx >+ shl ecx,1 ; output_cols * 2 >+ sub ecx,edx >+ jle short .expand_end >+ >+ mov eax, INT [max_v_samp(ebp)] >+ test eax,eax >+ jle short .expand_end >+ >+ cld >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ alignx 16,7 >+.expandloop: >+ push eax >+ push ecx >+ >+ mov edi, JSAMPROW [esi] >+ add edi,edx >+ mov al, JSAMPLE [edi-1] >+ >+ rep stosb >+ >+ pop ecx >+ pop eax >+ >+ add esi, byte SIZEOF_JSAMPROW >+ dec eax >+ jg short .expandloop >+ >+.expand_end: >+ pop ecx ; output_cols >+ >+ ; -- h2v1_downsample >+ >+ mov eax, JDIMENSION [v_samp(ebp)] ; rowctr >+ test eax,eax >+ jle near .return >+ >+ mov edx, 0x00010000 ; bias pattern >+ movd xmm7,edx >+ pcmpeqw xmm6,xmm6 >+ pshufd xmm7,xmm7,0x00 ; xmm7={0, 1, 0, 1, 0, 1, 0, 1} >+ psrlw xmm6,BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..} >+ >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ mov edi, JSAMPARRAY [output_data(ebp)] ; output_data >+ alignx 16,7 >+.rowloop: >+ push ecx >+ push edi >+ push esi >+ >+ mov esi, JSAMPROW [esi] ; inptr >+ mov edi, JSAMPROW [edi] ; outptr >+ >+ cmp ecx, byte SIZEOF_XMMWORD >+ jae short .columnloop >+ alignx 16,7 >+ >+.columnloop_r8: >+ movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ pxor xmm1,xmm1 >+ mov ecx, SIZEOF_XMMWORD >+ jmp short .downsample >+ alignx 16,7 >+ >+.columnloop: >+ movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ movdqa xmm1, XMMWORD [esi+1*SIZEOF_XMMWORD] >+ >+.downsample: >+ movdqa xmm2,xmm0 >+ movdqa xmm3,xmm1 >+ >+ pand xmm0,xmm6 >+ psrlw xmm2,BYTE_BIT >+ pand xmm1,xmm6 >+ psrlw xmm3,BYTE_BIT >+ >+ paddw xmm0,xmm2 >+ paddw xmm1,xmm3 >+ paddw xmm0,xmm7 >+ paddw xmm1,xmm7 >+ psrlw xmm0,1 >+ psrlw xmm1,1 >+ >+ packuswb xmm0,xmm1 >+ >+ movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0 >+ >+ sub ecx, byte SIZEOF_XMMWORD ; outcol >+ add esi, byte 2*SIZEOF_XMMWORD ; inptr >+ add edi, byte 1*SIZEOF_XMMWORD ; outptr >+ cmp ecx, byte SIZEOF_XMMWORD >+ jae short .columnloop >+ test ecx,ecx >+ jnz short .columnloop_r8 >+ >+ pop esi >+ pop edi >+ pop ecx >+ >+ add esi, byte SIZEOF_JSAMPROW ; input_data >+ add edi, byte SIZEOF_JSAMPROW ; output_data >+ dec eax ; rowctr >+ jg near .rowloop >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Downsample pixel values of a single component. >+; This version handles the standard case of 2:1 horizontal and 2:1 vertical, >+; without smoothing. >+; >+; GLOBAL(void) >+; jsimd_h2v2_downsample_sse2 (JDIMENSION image_width, int max_v_samp_factor, >+; JDIMENSION v_samp_factor, JDIMENSION width_blocks, >+; JSAMPARRAY input_data, JSAMPARRAY output_data); >+; >+ >+%define img_width(b) (b)+8 ; JDIMENSION image_width >+%define max_v_samp(b) (b)+12 ; int max_v_samp_factor >+%define v_samp(b) (b)+16 ; JDIMENSION v_samp_factor >+%define width_blks(b) (b)+20 ; JDIMENSION width_blocks >+%define input_data(b) (b)+24 ; JSAMPARRAY input_data >+%define output_data(b) (b)+28 ; JSAMPARRAY output_data >+ >+ align 16 >+ global EXTN(jsimd_h2v2_downsample_sse2) >+ >+EXTN(jsimd_h2v2_downsample_sse2): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov ecx, JDIMENSION [width_blks(ebp)] >+ shl ecx,3 ; imul ecx,DCTSIZE (ecx = output_cols) >+ jz near .return >+ >+ mov edx, JDIMENSION [img_width(ebp)] >+ >+ ; -- expand_right_edge >+ >+ push ecx >+ shl ecx,1 ; output_cols * 2 >+ sub ecx,edx >+ jle short .expand_end >+ >+ mov eax, INT [max_v_samp(ebp)] >+ test eax,eax >+ jle short .expand_end >+ >+ cld >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ alignx 16,7 >+.expandloop: >+ push eax >+ push ecx >+ >+ mov edi, JSAMPROW [esi] >+ add edi,edx >+ mov al, JSAMPLE [edi-1] >+ >+ rep stosb >+ >+ pop ecx >+ pop eax >+ >+ add esi, byte SIZEOF_JSAMPROW >+ dec eax >+ jg short .expandloop >+ >+.expand_end: >+ pop ecx ; output_cols >+ >+ ; -- h2v2_downsample >+ >+ mov eax, JDIMENSION [v_samp(ebp)] ; rowctr >+ test eax,eax >+ jle near .return >+ >+ mov edx, 0x00020001 ; bias pattern >+ movd xmm7,edx >+ pcmpeqw xmm6,xmm6 >+ pshufd xmm7,xmm7,0x00 ; xmm7={1, 2, 1, 2, 1, 2, 1, 2} >+ psrlw xmm6,BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..} >+ >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ mov edi, JSAMPARRAY [output_data(ebp)] ; output_data >+ alignx 16,7 >+.rowloop: >+ push ecx >+ push edi >+ push esi >+ >+ mov edx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0 >+ mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1 >+ mov edi, JSAMPROW [edi] ; outptr >+ >+ cmp ecx, byte SIZEOF_XMMWORD >+ jae short .columnloop >+ alignx 16,7 >+ >+.columnloop_r8: >+ movdqa xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD] >+ movdqa xmm1, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ pxor xmm2,xmm2 >+ pxor xmm3,xmm3 >+ mov ecx, SIZEOF_XMMWORD >+ jmp short .downsample >+ alignx 16,7 >+ >+.columnloop: >+ movdqa xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD] >+ movdqa xmm1, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ movdqa xmm2, XMMWORD [edx+1*SIZEOF_XMMWORD] >+ movdqa xmm3, XMMWORD [esi+1*SIZEOF_XMMWORD] >+ >+.downsample: >+ movdqa xmm4,xmm0 >+ movdqa xmm5,xmm1 >+ pand xmm0,xmm6 >+ psrlw xmm4,BYTE_BIT >+ pand xmm1,xmm6 >+ psrlw xmm5,BYTE_BIT >+ paddw xmm0,xmm4 >+ paddw xmm1,xmm5 >+ >+ movdqa xmm4,xmm2 >+ movdqa xmm5,xmm3 >+ pand xmm2,xmm6 >+ psrlw xmm4,BYTE_BIT >+ pand xmm3,xmm6 >+ psrlw xmm5,BYTE_BIT >+ paddw xmm2,xmm4 >+ paddw xmm3,xmm5 >+ >+ paddw xmm0,xmm1 >+ paddw xmm2,xmm3 >+ paddw xmm0,xmm7 >+ paddw xmm2,xmm7 >+ psrlw xmm0,2 >+ psrlw xmm2,2 >+ >+ packuswb xmm0,xmm2 >+ >+ movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0 >+ >+ sub ecx, byte SIZEOF_XMMWORD ; outcol >+ add edx, byte 2*SIZEOF_XMMWORD ; inptr0 >+ add esi, byte 2*SIZEOF_XMMWORD ; inptr1 >+ add edi, byte 1*SIZEOF_XMMWORD ; outptr >+ cmp ecx, byte SIZEOF_XMMWORD >+ jae near .columnloop >+ test ecx,ecx >+ jnz near .columnloop_r8 >+ >+ pop esi >+ pop edi >+ pop ecx >+ >+ add esi, byte 2*SIZEOF_JSAMPROW ; input_data >+ add edi, byte 1*SIZEOF_JSAMPROW ; output_data >+ dec eax ; rowctr >+ jg near .rowloop >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jdclrmmx.asm b/modules/libjpeg-turbo/simd/jdclrmmx.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdclrmmx.asm >@@ -0,0 +1,407 @@ >+; >+; jdclrmmx.asm - colorspace conversion (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jcolsamp.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Convert some rows of samples to the output colorspace. >+; >+; GLOBAL(void) >+; jsimd_ycc_rgb_convert_mmx (JDIMENSION out_width, >+; JSAMPIMAGE input_buf, JDIMENSION input_row, >+; JSAMPARRAY output_buf, int num_rows) >+; >+ >+%define out_width(b) (b)+8 ; JDIMENSION out_width >+%define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf >+%define input_row(b) (b)+16 ; JDIMENSION input_row >+%define output_buf(b) (b)+20 ; JSAMPARRAY output_buf >+%define num_rows(b) (b)+24 ; int num_rows >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 2 >+%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr >+ >+ align 16 >+ global EXTN(jsimd_ycc_rgb_convert_mmx) >+ >+EXTN(jsimd_ycc_rgb_convert_mmx): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic eax ; make a room for GOT address >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ movpic POINTER [gotptr], ebx ; save GOT address >+ >+ mov ecx, JDIMENSION [out_width(eax)] ; num_cols >+ test ecx,ecx >+ jz near .return >+ >+ push ecx >+ >+ mov edi, JSAMPIMAGE [input_buf(eax)] >+ mov ecx, JDIMENSION [input_row(eax)] >+ mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY] >+ mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY] >+ mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY] >+ lea esi, [esi+ecx*SIZEOF_JSAMPROW] >+ lea ebx, [ebx+ecx*SIZEOF_JSAMPROW] >+ lea edx, [edx+ecx*SIZEOF_JSAMPROW] >+ >+ pop ecx >+ >+ mov edi, JSAMPARRAY [output_buf(eax)] >+ mov eax, INT [num_rows(eax)] >+ test eax,eax >+ jle near .return >+ alignx 16,7 >+.rowloop: >+ push eax >+ push edi >+ push edx >+ push ebx >+ push esi >+ push ecx ; col >+ >+ mov esi, JSAMPROW [esi] ; inptr0 >+ mov ebx, JSAMPROW [ebx] ; inptr1 >+ mov edx, JSAMPROW [edx] ; inptr2 >+ mov edi, JSAMPROW [edi] ; outptr >+ movpic eax, POINTER [gotptr] ; load GOT address (eax) >+ alignx 16,7 >+.columnloop: >+ >+ movq mm5, MMWORD [ebx] ; mm5=Cb(01234567) >+ movq mm1, MMWORD [edx] ; mm1=Cr(01234567) >+ >+ pcmpeqw mm4,mm4 >+ pcmpeqw mm7,mm7 >+ psrlw mm4,BYTE_BIT >+ psllw mm7,7 ; mm7={0xFF80 0xFF80 0xFF80 0xFF80} >+ movq mm0,mm4 ; mm0=mm4={0xFF 0x00 0xFF 0x00 ..} >+ >+ pand mm4,mm5 ; mm4=Cb(0246)=CbE >+ psrlw mm5,BYTE_BIT ; mm5=Cb(1357)=CbO >+ pand mm0,mm1 ; mm0=Cr(0246)=CrE >+ psrlw mm1,BYTE_BIT ; mm1=Cr(1357)=CrO >+ >+ paddw mm4,mm7 >+ paddw mm5,mm7 >+ paddw mm0,mm7 >+ paddw mm1,mm7 >+ >+ ; (Original) >+ ; R = Y + 1.40200 * Cr >+ ; G = Y - 0.34414 * Cb - 0.71414 * Cr >+ ; B = Y + 1.77200 * Cb >+ ; >+ ; (This implementation) >+ ; R = Y + 0.40200 * Cr + Cr >+ ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr >+ ; B = Y - 0.22800 * Cb + Cb + Cb >+ >+ movq mm2,mm4 ; mm2=CbE >+ movq mm3,mm5 ; mm3=CbO >+ paddw mm4,mm4 ; mm4=2*CbE >+ paddw mm5,mm5 ; mm5=2*CbO >+ movq mm6,mm0 ; mm6=CrE >+ movq mm7,mm1 ; mm7=CrO >+ paddw mm0,mm0 ; mm0=2*CrE >+ paddw mm1,mm1 ; mm1=2*CrO >+ >+ pmulhw mm4,[GOTOFF(eax,PW_MF0228)] ; mm4=(2*CbE * -FIX(0.22800)) >+ pmulhw mm5,[GOTOFF(eax,PW_MF0228)] ; mm5=(2*CbO * -FIX(0.22800)) >+ pmulhw mm0,[GOTOFF(eax,PW_F0402)] ; mm0=(2*CrE * FIX(0.40200)) >+ pmulhw mm1,[GOTOFF(eax,PW_F0402)] ; mm1=(2*CrO * FIX(0.40200)) >+ >+ paddw mm4,[GOTOFF(eax,PW_ONE)] >+ paddw mm5,[GOTOFF(eax,PW_ONE)] >+ psraw mm4,1 ; mm4=(CbE * -FIX(0.22800)) >+ psraw mm5,1 ; mm5=(CbO * -FIX(0.22800)) >+ paddw mm0,[GOTOFF(eax,PW_ONE)] >+ paddw mm1,[GOTOFF(eax,PW_ONE)] >+ psraw mm0,1 ; mm0=(CrE * FIX(0.40200)) >+ psraw mm1,1 ; mm1=(CrO * FIX(0.40200)) >+ >+ paddw mm4,mm2 >+ paddw mm5,mm3 >+ paddw mm4,mm2 ; mm4=(CbE * FIX(1.77200))=(B-Y)E >+ paddw mm5,mm3 ; mm5=(CbO * FIX(1.77200))=(B-Y)O >+ paddw mm0,mm6 ; mm0=(CrE * FIX(1.40200))=(R-Y)E >+ paddw mm1,mm7 ; mm1=(CrO * FIX(1.40200))=(R-Y)O >+ >+ movq MMWORD [wk(0)], mm4 ; wk(0)=(B-Y)E >+ movq MMWORD [wk(1)], mm5 ; wk(1)=(B-Y)O >+ >+ movq mm4,mm2 >+ movq mm5,mm3 >+ punpcklwd mm2,mm6 >+ punpckhwd mm4,mm6 >+ pmaddwd mm2,[GOTOFF(eax,PW_MF0344_F0285)] >+ pmaddwd mm4,[GOTOFF(eax,PW_MF0344_F0285)] >+ punpcklwd mm3,mm7 >+ punpckhwd mm5,mm7 >+ pmaddwd mm3,[GOTOFF(eax,PW_MF0344_F0285)] >+ pmaddwd mm5,[GOTOFF(eax,PW_MF0344_F0285)] >+ >+ paddd mm2,[GOTOFF(eax,PD_ONEHALF)] >+ paddd mm4,[GOTOFF(eax,PD_ONEHALF)] >+ psrad mm2,SCALEBITS >+ psrad mm4,SCALEBITS >+ paddd mm3,[GOTOFF(eax,PD_ONEHALF)] >+ paddd mm5,[GOTOFF(eax,PD_ONEHALF)] >+ psrad mm3,SCALEBITS >+ psrad mm5,SCALEBITS >+ >+ packssdw mm2,mm4 ; mm2=CbE*-FIX(0.344)+CrE*FIX(0.285) >+ packssdw mm3,mm5 ; mm3=CbO*-FIX(0.344)+CrO*FIX(0.285) >+ psubw mm2,mm6 ; mm2=CbE*-FIX(0.344)+CrE*-FIX(0.714)=(G-Y)E >+ psubw mm3,mm7 ; mm3=CbO*-FIX(0.344)+CrO*-FIX(0.714)=(G-Y)O >+ >+ movq mm5, MMWORD [esi] ; mm5=Y(01234567) >+ >+ pcmpeqw mm4,mm4 >+ psrlw mm4,BYTE_BIT ; mm4={0xFF 0x00 0xFF 0x00 ..} >+ pand mm4,mm5 ; mm4=Y(0246)=YE >+ psrlw mm5,BYTE_BIT ; mm5=Y(1357)=YO >+ >+ paddw mm0,mm4 ; mm0=((R-Y)E+YE)=RE=(R0 R2 R4 R6) >+ paddw mm1,mm5 ; mm1=((R-Y)O+YO)=RO=(R1 R3 R5 R7) >+ packuswb mm0,mm0 ; mm0=(R0 R2 R4 R6 ** ** ** **) >+ packuswb mm1,mm1 ; mm1=(R1 R3 R5 R7 ** ** ** **) >+ >+ paddw mm2,mm4 ; mm2=((G-Y)E+YE)=GE=(G0 G2 G4 G6) >+ paddw mm3,mm5 ; mm3=((G-Y)O+YO)=GO=(G1 G3 G5 G7) >+ packuswb mm2,mm2 ; mm2=(G0 G2 G4 G6 ** ** ** **) >+ packuswb mm3,mm3 ; mm3=(G1 G3 G5 G7 ** ** ** **) >+ >+ paddw mm4, MMWORD [wk(0)] ; mm4=(YE+(B-Y)E)=BE=(B0 B2 B4 B6) >+ paddw mm5, MMWORD [wk(1)] ; mm5=(YO+(B-Y)O)=BO=(B1 B3 B5 B7) >+ packuswb mm4,mm4 ; mm4=(B0 B2 B4 B6 ** ** ** **) >+ packuswb mm5,mm5 ; mm5=(B1 B3 B5 B7 ** ** ** **) >+ >+%if RGB_PIXELSIZE == 3 ; --------------- >+ >+ ; mmA=(00 02 04 06 ** ** ** **), mmB=(01 03 05 07 ** ** ** **) >+ ; mmC=(10 12 14 16 ** ** ** **), mmD=(11 13 15 17 ** ** ** **) >+ ; mmE=(20 22 24 26 ** ** ** **), mmF=(21 23 25 27 ** ** ** **) >+ ; mmG=(** ** ** ** ** ** ** **), mmH=(** ** ** ** ** ** ** **) >+ >+ punpcklbw mmA,mmC ; mmA=(00 10 02 12 04 14 06 16) >+ punpcklbw mmE,mmB ; mmE=(20 01 22 03 24 05 26 07) >+ punpcklbw mmD,mmF ; mmD=(11 21 13 23 15 25 17 27) >+ >+ movq mmG,mmA >+ movq mmH,mmA >+ punpcklwd mmA,mmE ; mmA=(00 10 20 01 02 12 22 03) >+ punpckhwd mmG,mmE ; mmG=(04 14 24 05 06 16 26 07) >+ >+ psrlq mmH,2*BYTE_BIT ; mmH=(02 12 04 14 06 16 -- --) >+ psrlq mmE,2*BYTE_BIT ; mmE=(22 03 24 05 26 07 -- --) >+ >+ movq mmC,mmD >+ movq mmB,mmD >+ punpcklwd mmD,mmH ; mmD=(11 21 02 12 13 23 04 14) >+ punpckhwd mmC,mmH ; mmC=(15 25 06 16 17 27 -- --) >+ >+ psrlq mmB,2*BYTE_BIT ; mmB=(13 23 15 25 17 27 -- --) >+ >+ movq mmF,mmE >+ punpcklwd mmE,mmB ; mmE=(22 03 13 23 24 05 15 25) >+ punpckhwd mmF,mmB ; mmF=(26 07 17 27 -- -- -- --) >+ >+ punpckldq mmA,mmD ; mmA=(00 10 20 01 11 21 02 12) >+ punpckldq mmE,mmG ; mmE=(22 03 13 23 04 14 24 05) >+ punpckldq mmC,mmF ; mmC=(15 25 06 16 26 07 17 27) >+ >+ cmp ecx, byte SIZEOF_MMWORD >+ jb short .column_st16 >+ >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mmE >+ movq MMWORD [edi+2*SIZEOF_MMWORD], mmC >+ >+ sub ecx, byte SIZEOF_MMWORD >+ jz short .nextrow >+ >+ add esi, byte SIZEOF_MMWORD ; inptr0 >+ add ebx, byte SIZEOF_MMWORD ; inptr1 >+ add edx, byte SIZEOF_MMWORD ; inptr2 >+ add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr >+ jmp near .columnloop >+ alignx 16,7 >+ >+.column_st16: >+ lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE >+ cmp ecx, byte 2*SIZEOF_MMWORD >+ jb short .column_st8 >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mmE >+ movq mmA,mmC >+ sub ecx, byte 2*SIZEOF_MMWORD >+ add edi, byte 2*SIZEOF_MMWORD >+ jmp short .column_st4 >+.column_st8: >+ cmp ecx, byte SIZEOF_MMWORD >+ jb short .column_st4 >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq mmA,mmE >+ sub ecx, byte SIZEOF_MMWORD >+ add edi, byte SIZEOF_MMWORD >+.column_st4: >+ movd eax,mmA >+ cmp ecx, byte SIZEOF_DWORD >+ jb short .column_st2 >+ mov DWORD [edi+0*SIZEOF_DWORD], eax >+ psrlq mmA,DWORD_BIT >+ movd eax,mmA >+ sub ecx, byte SIZEOF_DWORD >+ add edi, byte SIZEOF_DWORD >+.column_st2: >+ cmp ecx, byte SIZEOF_WORD >+ jb short .column_st1 >+ mov WORD [edi+0*SIZEOF_WORD], ax >+ shr eax,WORD_BIT >+ sub ecx, byte SIZEOF_WORD >+ add edi, byte SIZEOF_WORD >+.column_st1: >+ cmp ecx, byte SIZEOF_BYTE >+ jb short .nextrow >+ mov BYTE [edi+0*SIZEOF_BYTE], al >+ >+%else ; RGB_PIXELSIZE == 4 ; ----------- >+ >+%ifdef RGBX_FILLER_0XFF >+ pcmpeqb mm6,mm6 ; mm6=(X0 X2 X4 X6 ** ** ** **) >+ pcmpeqb mm7,mm7 ; mm7=(X1 X3 X5 X7 ** ** ** **) >+%else >+ pxor mm6,mm6 ; mm6=(X0 X2 X4 X6 ** ** ** **) >+ pxor mm7,mm7 ; mm7=(X1 X3 X5 X7 ** ** ** **) >+%endif >+ ; mmA=(00 02 04 06 ** ** ** **), mmB=(01 03 05 07 ** ** ** **) >+ ; mmC=(10 12 14 16 ** ** ** **), mmD=(11 13 15 17 ** ** ** **) >+ ; mmE=(20 22 24 26 ** ** ** **), mmF=(21 23 25 27 ** ** ** **) >+ ; mmG=(30 32 34 36 ** ** ** **), mmH=(31 33 35 37 ** ** ** **) >+ >+ punpcklbw mmA,mmC ; mmA=(00 10 02 12 04 14 06 16) >+ punpcklbw mmE,mmG ; mmE=(20 30 22 32 24 34 26 36) >+ punpcklbw mmB,mmD ; mmB=(01 11 03 13 05 15 07 17) >+ punpcklbw mmF,mmH ; mmF=(21 31 23 33 25 35 27 37) >+ >+ movq mmC,mmA >+ punpcklwd mmA,mmE ; mmA=(00 10 20 30 02 12 22 32) >+ punpckhwd mmC,mmE ; mmC=(04 14 24 34 06 16 26 36) >+ movq mmG,mmB >+ punpcklwd mmB,mmF ; mmB=(01 11 21 31 03 13 23 33) >+ punpckhwd mmG,mmF ; mmG=(05 15 25 35 07 17 27 37) >+ >+ movq mmD,mmA >+ punpckldq mmA,mmB ; mmA=(00 10 20 30 01 11 21 31) >+ punpckhdq mmD,mmB ; mmD=(02 12 22 32 03 13 23 33) >+ movq mmH,mmC >+ punpckldq mmC,mmG ; mmC=(04 14 24 34 05 15 25 35) >+ punpckhdq mmH,mmG ; mmH=(06 16 26 36 07 17 27 37) >+ >+ cmp ecx, byte SIZEOF_MMWORD >+ jb short .column_st16 >+ >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mmD >+ movq MMWORD [edi+2*SIZEOF_MMWORD], mmC >+ movq MMWORD [edi+3*SIZEOF_MMWORD], mmH >+ >+ sub ecx, byte SIZEOF_MMWORD >+ jz short .nextrow >+ >+ add esi, byte SIZEOF_MMWORD ; inptr0 >+ add ebx, byte SIZEOF_MMWORD ; inptr1 >+ add edx, byte SIZEOF_MMWORD ; inptr2 >+ add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr >+ jmp near .columnloop >+ alignx 16,7 >+ >+.column_st16: >+ cmp ecx, byte SIZEOF_MMWORD/2 >+ jb short .column_st8 >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mmD >+ movq mmA,mmC >+ movq mmD,mmH >+ sub ecx, byte SIZEOF_MMWORD/2 >+ add edi, byte 2*SIZEOF_MMWORD >+.column_st8: >+ cmp ecx, byte SIZEOF_MMWORD/4 >+ jb short .column_st4 >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq mmA,mmD >+ sub ecx, byte SIZEOF_MMWORD/4 >+ add edi, byte 1*SIZEOF_MMWORD >+.column_st4: >+ cmp ecx, byte SIZEOF_MMWORD/8 >+ jb short .nextrow >+ movd DWORD [edi+0*SIZEOF_DWORD], mmA >+ >+%endif ; RGB_PIXELSIZE ; --------------- >+ >+ alignx 16,7 >+ >+.nextrow: >+ pop ecx >+ pop esi >+ pop ebx >+ pop edx >+ pop edi >+ pop eax >+ >+ add esi, byte SIZEOF_JSAMPROW >+ add ebx, byte SIZEOF_JSAMPROW >+ add edx, byte SIZEOF_JSAMPROW >+ add edi, byte SIZEOF_JSAMPROW ; output_buf >+ dec eax ; num_rows >+ jg near .rowloop >+ >+ emms ; empty MMX state >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jdclrss2-64.asm b/modules/libjpeg-turbo/simd/jdclrss2-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdclrss2-64.asm >@@ -0,0 +1,487 @@ >+; >+; jdclrss2-64.asm - colorspace conversion (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jcolsamp.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Convert some rows of samples to the output colorspace. >+; >+; GLOBAL(void) >+; jsimd_ycc_rgb_convert_sse2 (JDIMENSION out_width, >+; JSAMPIMAGE input_buf, JDIMENSION input_row, >+; JSAMPARRAY output_buf, int num_rows) >+; >+ >+; r10 = JDIMENSION out_width >+; r11 = JSAMPIMAGE input_buf >+; r12 = JDIMENSION input_row >+; r13 = JSAMPARRAY output_buf >+; r14 = int num_rows >+ >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_ycc_rgb_convert_sse2) >+ >+EXTN(jsimd_ycc_rgb_convert_sse2): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [wk(0)] >+ collect_args >+ push rbx >+ >+ mov rcx, r10 ; num_cols >+ test rcx,rcx >+ jz near .return >+ >+ push rcx >+ >+ mov rdi, r11 >+ mov rcx, r12 >+ mov rsi, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY] >+ mov rbx, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY] >+ mov rdx, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY] >+ lea rsi, [rsi+rcx*SIZEOF_JSAMPROW] >+ lea rbx, [rbx+rcx*SIZEOF_JSAMPROW] >+ lea rdx, [rdx+rcx*SIZEOF_JSAMPROW] >+ >+ pop rcx >+ >+ mov rdi, r13 >+ mov eax, r14d >+ test rax,rax >+ jle near .return >+.rowloop: >+ push rax >+ push rdi >+ push rdx >+ push rbx >+ push rsi >+ push rcx ; col >+ >+ mov rsi, JSAMPROW [rsi] ; inptr0 >+ mov rbx, JSAMPROW [rbx] ; inptr1 >+ mov rdx, JSAMPROW [rdx] ; inptr2 >+ mov rdi, JSAMPROW [rdi] ; outptr >+.columnloop: >+ >+ movdqa xmm5, XMMWORD [rbx] ; xmm5=Cb(0123456789ABCDEF) >+ movdqa xmm1, XMMWORD [rdx] ; xmm1=Cr(0123456789ABCDEF) >+ >+ pcmpeqw xmm4,xmm4 >+ pcmpeqw xmm7,xmm7 >+ psrlw xmm4,BYTE_BIT >+ psllw xmm7,7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..} >+ movdqa xmm0,xmm4 ; xmm0=xmm4={0xFF 0x00 0xFF 0x00 ..} >+ >+ pand xmm4,xmm5 ; xmm4=Cb(02468ACE)=CbE >+ psrlw xmm5,BYTE_BIT ; xmm5=Cb(13579BDF)=CbO >+ pand xmm0,xmm1 ; xmm0=Cr(02468ACE)=CrE >+ psrlw xmm1,BYTE_BIT ; xmm1=Cr(13579BDF)=CrO >+ >+ paddw xmm4,xmm7 >+ paddw xmm5,xmm7 >+ paddw xmm0,xmm7 >+ paddw xmm1,xmm7 >+ >+ ; (Original) >+ ; R = Y + 1.40200 * Cr >+ ; G = Y - 0.34414 * Cb - 0.71414 * Cr >+ ; B = Y + 1.77200 * Cb >+ ; >+ ; (This implementation) >+ ; R = Y + 0.40200 * Cr + Cr >+ ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr >+ ; B = Y - 0.22800 * Cb + Cb + Cb >+ >+ movdqa xmm2,xmm4 ; xmm2=CbE >+ movdqa xmm3,xmm5 ; xmm3=CbO >+ paddw xmm4,xmm4 ; xmm4=2*CbE >+ paddw xmm5,xmm5 ; xmm5=2*CbO >+ movdqa xmm6,xmm0 ; xmm6=CrE >+ movdqa xmm7,xmm1 ; xmm7=CrO >+ paddw xmm0,xmm0 ; xmm0=2*CrE >+ paddw xmm1,xmm1 ; xmm1=2*CrO >+ >+ pmulhw xmm4,[rel PW_MF0228] ; xmm4=(2*CbE * -FIX(0.22800)) >+ pmulhw xmm5,[rel PW_MF0228] ; xmm5=(2*CbO * -FIX(0.22800)) >+ pmulhw xmm0,[rel PW_F0402] ; xmm0=(2*CrE * FIX(0.40200)) >+ pmulhw xmm1,[rel PW_F0402] ; xmm1=(2*CrO * FIX(0.40200)) >+ >+ paddw xmm4,[rel PW_ONE] >+ paddw xmm5,[rel PW_ONE] >+ psraw xmm4,1 ; xmm4=(CbE * -FIX(0.22800)) >+ psraw xmm5,1 ; xmm5=(CbO * -FIX(0.22800)) >+ paddw xmm0,[rel PW_ONE] >+ paddw xmm1,[rel PW_ONE] >+ psraw xmm0,1 ; xmm0=(CrE * FIX(0.40200)) >+ psraw xmm1,1 ; xmm1=(CrO * FIX(0.40200)) >+ >+ paddw xmm4,xmm2 >+ paddw xmm5,xmm3 >+ paddw xmm4,xmm2 ; xmm4=(CbE * FIX(1.77200))=(B-Y)E >+ paddw xmm5,xmm3 ; xmm5=(CbO * FIX(1.77200))=(B-Y)O >+ paddw xmm0,xmm6 ; xmm0=(CrE * FIX(1.40200))=(R-Y)E >+ paddw xmm1,xmm7 ; xmm1=(CrO * FIX(1.40200))=(R-Y)O >+ >+ movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=(B-Y)E >+ movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(B-Y)O >+ >+ movdqa xmm4,xmm2 >+ movdqa xmm5,xmm3 >+ punpcklwd xmm2,xmm6 >+ punpckhwd xmm4,xmm6 >+ pmaddwd xmm2,[rel PW_MF0344_F0285] >+ pmaddwd xmm4,[rel PW_MF0344_F0285] >+ punpcklwd xmm3,xmm7 >+ punpckhwd xmm5,xmm7 >+ pmaddwd xmm3,[rel PW_MF0344_F0285] >+ pmaddwd xmm5,[rel PW_MF0344_F0285] >+ >+ paddd xmm2,[rel PD_ONEHALF] >+ paddd xmm4,[rel PD_ONEHALF] >+ psrad xmm2,SCALEBITS >+ psrad xmm4,SCALEBITS >+ paddd xmm3,[rel PD_ONEHALF] >+ paddd xmm5,[rel PD_ONEHALF] >+ psrad xmm3,SCALEBITS >+ psrad xmm5,SCALEBITS >+ >+ packssdw xmm2,xmm4 ; xmm2=CbE*-FIX(0.344)+CrE*FIX(0.285) >+ packssdw xmm3,xmm5 ; xmm3=CbO*-FIX(0.344)+CrO*FIX(0.285) >+ psubw xmm2,xmm6 ; xmm2=CbE*-FIX(0.344)+CrE*-FIX(0.714)=(G-Y)E >+ psubw xmm3,xmm7 ; xmm3=CbO*-FIX(0.344)+CrO*-FIX(0.714)=(G-Y)O >+ >+ movdqa xmm5, XMMWORD [rsi] ; xmm5=Y(0123456789ABCDEF) >+ >+ pcmpeqw xmm4,xmm4 >+ psrlw xmm4,BYTE_BIT ; xmm4={0xFF 0x00 0xFF 0x00 ..} >+ pand xmm4,xmm5 ; xmm4=Y(02468ACE)=YE >+ psrlw xmm5,BYTE_BIT ; xmm5=Y(13579BDF)=YO >+ >+ paddw xmm0,xmm4 ; xmm0=((R-Y)E+YE)=RE=R(02468ACE) >+ paddw xmm1,xmm5 ; xmm1=((R-Y)O+YO)=RO=R(13579BDF) >+ packuswb xmm0,xmm0 ; xmm0=R(02468ACE********) >+ packuswb xmm1,xmm1 ; xmm1=R(13579BDF********) >+ >+ paddw xmm2,xmm4 ; xmm2=((G-Y)E+YE)=GE=G(02468ACE) >+ paddw xmm3,xmm5 ; xmm3=((G-Y)O+YO)=GO=G(13579BDF) >+ packuswb xmm2,xmm2 ; xmm2=G(02468ACE********) >+ packuswb xmm3,xmm3 ; xmm3=G(13579BDF********) >+ >+ paddw xmm4, XMMWORD [wk(0)] ; xmm4=(YE+(B-Y)E)=BE=B(02468ACE) >+ paddw xmm5, XMMWORD [wk(1)] ; xmm5=(YO+(B-Y)O)=BO=B(13579BDF) >+ packuswb xmm4,xmm4 ; xmm4=B(02468ACE********) >+ packuswb xmm5,xmm5 ; xmm5=B(13579BDF********) >+ >+%if RGB_PIXELSIZE == 3 ; --------------- >+ >+ ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **) >+ ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **) >+ ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **) >+ ; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **) >+ >+ punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E) >+ punpcklbw xmmE,xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F) >+ punpcklbw xmmD,xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F) >+ >+ movdqa xmmG,xmmA >+ movdqa xmmH,xmmA >+ punpcklwd xmmA,xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07) >+ punpckhwd xmmG,xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F) >+ >+ psrldq xmmH,2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --) >+ psrldq xmmE,2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --) >+ >+ movdqa xmmC,xmmD >+ movdqa xmmB,xmmD >+ punpcklwd xmmD,xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18) >+ punpckhwd xmmC,xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --) >+ >+ psrldq xmmB,2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --) >+ >+ movdqa xmmF,xmmE >+ punpcklwd xmmE,xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29) >+ punpckhwd xmmF,xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --) >+ >+ pshufd xmmH,xmmA,0x4E; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03) >+ movdqa xmmB,xmmE >+ punpckldq xmmA,xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14) >+ punpckldq xmmE,xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07) >+ punpckhdq xmmD,xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29) >+ >+ pshufd xmmH,xmmG,0x4E; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B) >+ movdqa xmmB,xmmF >+ punpckldq xmmG,xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C) >+ punpckldq xmmF,xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F) >+ punpckhdq xmmC,xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --) >+ >+ punpcklqdq xmmA,xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05) >+ punpcklqdq xmmD,xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) >+ punpcklqdq xmmF,xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F) >+ >+ cmp rcx, byte SIZEOF_XMMWORD >+ jb short .column_st32 >+ >+ test rdi, SIZEOF_XMMWORD-1 >+ jnz short .out1 >+ ; --(aligned)------------------- >+ movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA >+ movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD >+ movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmF >+ add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr >+ jmp short .out0 >+.out1: ; --(unaligned)----------------- >+ pcmpeqb xmmH,xmmH ; xmmH=(all 1's) >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [rdi], xmmD >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmF,xmmH ; movntdqu XMMWORD [rdi], xmmF >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+.out0: >+ sub rcx, byte SIZEOF_XMMWORD >+ jz near .nextrow >+ >+ add rsi, byte SIZEOF_XMMWORD ; inptr0 >+ add rbx, byte SIZEOF_XMMWORD ; inptr1 >+ add rdx, byte SIZEOF_XMMWORD ; inptr2 >+ jmp near .columnloop >+ >+.column_st32: >+ pcmpeqb xmmH,xmmH ; xmmH=(all 1's) >+ lea rcx, [rcx+rcx*2] ; imul ecx, RGB_PIXELSIZE >+ cmp rcx, byte 2*SIZEOF_XMMWORD >+ jb short .column_st16 >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [rdi], xmmD >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmF >+ sub rcx, byte 2*SIZEOF_XMMWORD >+ jmp short .column_st15 >+.column_st16: >+ cmp rcx, byte SIZEOF_XMMWORD >+ jb short .column_st15 >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmD >+ sub rcx, byte SIZEOF_XMMWORD >+.column_st15: >+ mov rax,rcx >+ xor rcx, byte 0x0F >+ shl rcx, 2 >+ movd xmmB,ecx >+ psrlq xmmH,4 >+ pcmpeqb xmmE,xmmE >+ psrlq xmmH,xmmB >+ psrlq xmmE,xmmB >+ punpcklbw xmmE,xmmH >+ ; ---------------- >+ mov rcx,rdi >+ and rcx, byte SIZEOF_XMMWORD-1 >+ jz short .adj0 >+ add rax,rcx >+ cmp rax, byte SIZEOF_XMMWORD >+ ja short .adj0 >+ and rdi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary >+ shl rcx, 3 ; pslldq xmmA,ecx & pslldq xmmE,rcx >+ movdqa xmmG,xmmA >+ movdqa xmmC,xmmE >+ pslldq xmmA, SIZEOF_XMMWORD/2 >+ pslldq xmmE, SIZEOF_XMMWORD/2 >+ movd xmmD,ecx >+ sub rcx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT >+ jb short .adj1 >+ movd xmmF,ecx >+ psllq xmmA,xmmF >+ psllq xmmE,xmmF >+ jmp short .adj0 >+.adj1: neg ecx >+ movd xmmF,ecx >+ psrlq xmmA,xmmF >+ psrlq xmmE,xmmF >+ psllq xmmG,xmmD >+ psllq xmmC,xmmD >+ por xmmA,xmmG >+ por xmmE,xmmC >+.adj0: ; ---------------- >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [rdi], xmmA >+ >+%else ; RGB_PIXELSIZE == 4 ; ----------- >+ >+%ifdef RGBX_FILLER_0XFF >+ pcmpeqb xmm6,xmm6 ; xmm6=XE=X(02468ACE********) >+ pcmpeqb xmm7,xmm7 ; xmm7=XO=X(13579BDF********) >+%else >+ pxor xmm6,xmm6 ; xmm6=XE=X(02468ACE********) >+ pxor xmm7,xmm7 ; xmm7=XO=X(13579BDF********) >+%endif >+ ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **) >+ ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **) >+ ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **) >+ ; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **) >+ >+ punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E) >+ punpcklbw xmmE,xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E) >+ punpcklbw xmmB,xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F) >+ punpcklbw xmmF,xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F) >+ >+ movdqa xmmC,xmmA >+ punpcklwd xmmA,xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36) >+ punpckhwd xmmC,xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E) >+ movdqa xmmG,xmmB >+ punpcklwd xmmB,xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37) >+ punpckhwd xmmG,xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F) >+ >+ movdqa xmmD,xmmA >+ punpckldq xmmA,xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33) >+ punpckhdq xmmD,xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37) >+ movdqa xmmH,xmmC >+ punpckldq xmmC,xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B) >+ punpckhdq xmmH,xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F) >+ >+ cmp rcx, byte SIZEOF_XMMWORD >+ jb short .column_st32 >+ >+ test rdi, SIZEOF_XMMWORD-1 >+ jnz short .out1 >+ ; --(aligned)------------------- >+ movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA >+ movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD >+ movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmC >+ movntdq XMMWORD [rdi+3*SIZEOF_XMMWORD], xmmH >+ add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr >+ jmp short .out0 >+.out1: ; --(unaligned)----------------- >+ pcmpeqb xmmE,xmmE ; xmmE=(all 1's) >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [rdi], xmmD >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmC,xmmE ; movntdqu XMMWORD [rdi], xmmC >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmH,xmmE ; movntdqu XMMWORD [rdi], xmmH >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+.out0: >+ sub rcx, byte SIZEOF_XMMWORD >+ jz near .nextrow >+ >+ add rsi, byte SIZEOF_XMMWORD ; inptr0 >+ add rbx, byte SIZEOF_XMMWORD ; inptr1 >+ add rdx, byte SIZEOF_XMMWORD ; inptr2 >+ jmp near .columnloop >+ >+.column_st32: >+ pcmpeqb xmmE,xmmE ; xmmE=(all 1's) >+ cmp rcx, byte SIZEOF_XMMWORD/2 >+ jb short .column_st16 >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [rdi], xmmD >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmC >+ movdqa xmmD,xmmH >+ sub rcx, byte SIZEOF_XMMWORD/2 >+.column_st16: >+ cmp rcx, byte SIZEOF_XMMWORD/4 >+ jb short .column_st15 >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmD >+ sub rcx, byte SIZEOF_XMMWORD/4 >+.column_st15: >+ cmp rcx, byte SIZEOF_XMMWORD/16 >+ jb near .nextrow >+ mov rax,rcx >+ xor rcx, byte 0x03 >+ inc rcx >+ shl rcx, 4 >+ movd xmmF,ecx >+ psrlq xmmE,xmmF >+ punpcklbw xmmE,xmmE >+ ; ---------------- >+ mov rcx,rdi >+ and rcx, byte SIZEOF_XMMWORD-1 >+ jz short .adj0 >+ lea rax, [rcx+rax*4] ; RGB_PIXELSIZE >+ cmp rax, byte SIZEOF_XMMWORD >+ ja short .adj0 >+ and rdi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary >+ shl rcx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx >+ movdqa xmmB,xmmA >+ movdqa xmmG,xmmE >+ pslldq xmmA, SIZEOF_XMMWORD/2 >+ pslldq xmmE, SIZEOF_XMMWORD/2 >+ movd xmmC,ecx >+ sub rcx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT >+ jb short .adj1 >+ movd xmmH,ecx >+ psllq xmmA,xmmH >+ psllq xmmE,xmmH >+ jmp short .adj0 >+.adj1: neg rcx >+ movd xmmH,ecx >+ psrlq xmmA,xmmH >+ psrlq xmmE,xmmH >+ psllq xmmB,xmmC >+ psllq xmmG,xmmC >+ por xmmA,xmmB >+ por xmmE,xmmG >+.adj0: ; ---------------- >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [rdi], xmmA >+ >+%endif ; RGB_PIXELSIZE ; --------------- >+ >+.nextrow: >+ pop rcx >+ pop rsi >+ pop rbx >+ pop rdx >+ pop rdi >+ pop rax >+ >+ add rsi, byte SIZEOF_JSAMPROW >+ add rbx, byte SIZEOF_JSAMPROW >+ add rdx, byte SIZEOF_JSAMPROW >+ add rdi, byte SIZEOF_JSAMPROW ; output_buf >+ dec rax ; num_rows >+ jg near .rowloop >+ >+ sfence ; flush the write buffer >+ >+.return: >+ pop rbx >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jdclrss2.asm b/modules/libjpeg-turbo/simd/jdclrss2.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdclrss2.asm >@@ -0,0 +1,505 @@ >+; >+; jdclrss2.asm - colorspace conversion (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jcolsamp.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Convert some rows of samples to the output colorspace. >+; >+; GLOBAL(void) >+; jsimd_ycc_rgb_convert_sse2 (JDIMENSION out_width, >+; JSAMPIMAGE input_buf, JDIMENSION input_row, >+; JSAMPARRAY output_buf, int num_rows) >+; >+ >+%define out_width(b) (b)+8 ; JDIMENSION out_width >+%define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf >+%define input_row(b) (b)+16 ; JDIMENSION input_row >+%define output_buf(b) (b)+20 ; JSAMPARRAY output_buf >+%define num_rows(b) (b)+24 ; int num_rows >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr >+ >+ align 16 >+ global EXTN(jsimd_ycc_rgb_convert_sse2) >+ >+EXTN(jsimd_ycc_rgb_convert_sse2): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic eax ; make a room for GOT address >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ movpic POINTER [gotptr], ebx ; save GOT address >+ >+ mov ecx, JDIMENSION [out_width(eax)] ; num_cols >+ test ecx,ecx >+ jz near .return >+ >+ push ecx >+ >+ mov edi, JSAMPIMAGE [input_buf(eax)] >+ mov ecx, JDIMENSION [input_row(eax)] >+ mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY] >+ mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY] >+ mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY] >+ lea esi, [esi+ecx*SIZEOF_JSAMPROW] >+ lea ebx, [ebx+ecx*SIZEOF_JSAMPROW] >+ lea edx, [edx+ecx*SIZEOF_JSAMPROW] >+ >+ pop ecx >+ >+ mov edi, JSAMPARRAY [output_buf(eax)] >+ mov eax, INT [num_rows(eax)] >+ test eax,eax >+ jle near .return >+ alignx 16,7 >+.rowloop: >+ push eax >+ push edi >+ push edx >+ push ebx >+ push esi >+ push ecx ; col >+ >+ mov esi, JSAMPROW [esi] ; inptr0 >+ mov ebx, JSAMPROW [ebx] ; inptr1 >+ mov edx, JSAMPROW [edx] ; inptr2 >+ mov edi, JSAMPROW [edi] ; outptr >+ movpic eax, POINTER [gotptr] ; load GOT address (eax) >+ alignx 16,7 >+.columnloop: >+ >+ movdqa xmm5, XMMWORD [ebx] ; xmm5=Cb(0123456789ABCDEF) >+ movdqa xmm1, XMMWORD [edx] ; xmm1=Cr(0123456789ABCDEF) >+ >+ pcmpeqw xmm4,xmm4 >+ pcmpeqw xmm7,xmm7 >+ psrlw xmm4,BYTE_BIT >+ psllw xmm7,7 ; xmm7={0xFF80 0xFF80 0xFF80 0xFF80 ..} >+ movdqa xmm0,xmm4 ; xmm0=xmm4={0xFF 0x00 0xFF 0x00 ..} >+ >+ pand xmm4,xmm5 ; xmm4=Cb(02468ACE)=CbE >+ psrlw xmm5,BYTE_BIT ; xmm5=Cb(13579BDF)=CbO >+ pand xmm0,xmm1 ; xmm0=Cr(02468ACE)=CrE >+ psrlw xmm1,BYTE_BIT ; xmm1=Cr(13579BDF)=CrO >+ >+ paddw xmm4,xmm7 >+ paddw xmm5,xmm7 >+ paddw xmm0,xmm7 >+ paddw xmm1,xmm7 >+ >+ ; (Original) >+ ; R = Y + 1.40200 * Cr >+ ; G = Y - 0.34414 * Cb - 0.71414 * Cr >+ ; B = Y + 1.77200 * Cb >+ ; >+ ; (This implementation) >+ ; R = Y + 0.40200 * Cr + Cr >+ ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr >+ ; B = Y - 0.22800 * Cb + Cb + Cb >+ >+ movdqa xmm2,xmm4 ; xmm2=CbE >+ movdqa xmm3,xmm5 ; xmm3=CbO >+ paddw xmm4,xmm4 ; xmm4=2*CbE >+ paddw xmm5,xmm5 ; xmm5=2*CbO >+ movdqa xmm6,xmm0 ; xmm6=CrE >+ movdqa xmm7,xmm1 ; xmm7=CrO >+ paddw xmm0,xmm0 ; xmm0=2*CrE >+ paddw xmm1,xmm1 ; xmm1=2*CrO >+ >+ pmulhw xmm4,[GOTOFF(eax,PW_MF0228)] ; xmm4=(2*CbE * -FIX(0.22800)) >+ pmulhw xmm5,[GOTOFF(eax,PW_MF0228)] ; xmm5=(2*CbO * -FIX(0.22800)) >+ pmulhw xmm0,[GOTOFF(eax,PW_F0402)] ; xmm0=(2*CrE * FIX(0.40200)) >+ pmulhw xmm1,[GOTOFF(eax,PW_F0402)] ; xmm1=(2*CrO * FIX(0.40200)) >+ >+ paddw xmm4,[GOTOFF(eax,PW_ONE)] >+ paddw xmm5,[GOTOFF(eax,PW_ONE)] >+ psraw xmm4,1 ; xmm4=(CbE * -FIX(0.22800)) >+ psraw xmm5,1 ; xmm5=(CbO * -FIX(0.22800)) >+ paddw xmm0,[GOTOFF(eax,PW_ONE)] >+ paddw xmm1,[GOTOFF(eax,PW_ONE)] >+ psraw xmm0,1 ; xmm0=(CrE * FIX(0.40200)) >+ psraw xmm1,1 ; xmm1=(CrO * FIX(0.40200)) >+ >+ paddw xmm4,xmm2 >+ paddw xmm5,xmm3 >+ paddw xmm4,xmm2 ; xmm4=(CbE * FIX(1.77200))=(B-Y)E >+ paddw xmm5,xmm3 ; xmm5=(CbO * FIX(1.77200))=(B-Y)O >+ paddw xmm0,xmm6 ; xmm0=(CrE * FIX(1.40200))=(R-Y)E >+ paddw xmm1,xmm7 ; xmm1=(CrO * FIX(1.40200))=(R-Y)O >+ >+ movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=(B-Y)E >+ movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(B-Y)O >+ >+ movdqa xmm4,xmm2 >+ movdqa xmm5,xmm3 >+ punpcklwd xmm2,xmm6 >+ punpckhwd xmm4,xmm6 >+ pmaddwd xmm2,[GOTOFF(eax,PW_MF0344_F0285)] >+ pmaddwd xmm4,[GOTOFF(eax,PW_MF0344_F0285)] >+ punpcklwd xmm3,xmm7 >+ punpckhwd xmm5,xmm7 >+ pmaddwd xmm3,[GOTOFF(eax,PW_MF0344_F0285)] >+ pmaddwd xmm5,[GOTOFF(eax,PW_MF0344_F0285)] >+ >+ paddd xmm2,[GOTOFF(eax,PD_ONEHALF)] >+ paddd xmm4,[GOTOFF(eax,PD_ONEHALF)] >+ psrad xmm2,SCALEBITS >+ psrad xmm4,SCALEBITS >+ paddd xmm3,[GOTOFF(eax,PD_ONEHALF)] >+ paddd xmm5,[GOTOFF(eax,PD_ONEHALF)] >+ psrad xmm3,SCALEBITS >+ psrad xmm5,SCALEBITS >+ >+ packssdw xmm2,xmm4 ; xmm2=CbE*-FIX(0.344)+CrE*FIX(0.285) >+ packssdw xmm3,xmm5 ; xmm3=CbO*-FIX(0.344)+CrO*FIX(0.285) >+ psubw xmm2,xmm6 ; xmm2=CbE*-FIX(0.344)+CrE*-FIX(0.714)=(G-Y)E >+ psubw xmm3,xmm7 ; xmm3=CbO*-FIX(0.344)+CrO*-FIX(0.714)=(G-Y)O >+ >+ movdqa xmm5, XMMWORD [esi] ; xmm5=Y(0123456789ABCDEF) >+ >+ pcmpeqw xmm4,xmm4 >+ psrlw xmm4,BYTE_BIT ; xmm4={0xFF 0x00 0xFF 0x00 ..} >+ pand xmm4,xmm5 ; xmm4=Y(02468ACE)=YE >+ psrlw xmm5,BYTE_BIT ; xmm5=Y(13579BDF)=YO >+ >+ paddw xmm0,xmm4 ; xmm0=((R-Y)E+YE)=RE=R(02468ACE) >+ paddw xmm1,xmm5 ; xmm1=((R-Y)O+YO)=RO=R(13579BDF) >+ packuswb xmm0,xmm0 ; xmm0=R(02468ACE********) >+ packuswb xmm1,xmm1 ; xmm1=R(13579BDF********) >+ >+ paddw xmm2,xmm4 ; xmm2=((G-Y)E+YE)=GE=G(02468ACE) >+ paddw xmm3,xmm5 ; xmm3=((G-Y)O+YO)=GO=G(13579BDF) >+ packuswb xmm2,xmm2 ; xmm2=G(02468ACE********) >+ packuswb xmm3,xmm3 ; xmm3=G(13579BDF********) >+ >+ paddw xmm4, XMMWORD [wk(0)] ; xmm4=(YE+(B-Y)E)=BE=B(02468ACE) >+ paddw xmm5, XMMWORD [wk(1)] ; xmm5=(YO+(B-Y)O)=BO=B(13579BDF) >+ packuswb xmm4,xmm4 ; xmm4=B(02468ACE********) >+ packuswb xmm5,xmm5 ; xmm5=B(13579BDF********) >+ >+%if RGB_PIXELSIZE == 3 ; --------------- >+ >+ ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **) >+ ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **) >+ ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **) >+ ; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **) >+ >+ punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E) >+ punpcklbw xmmE,xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F) >+ punpcklbw xmmD,xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F) >+ >+ movdqa xmmG,xmmA >+ movdqa xmmH,xmmA >+ punpcklwd xmmA,xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07) >+ punpckhwd xmmG,xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F) >+ >+ psrldq xmmH,2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --) >+ psrldq xmmE,2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --) >+ >+ movdqa xmmC,xmmD >+ movdqa xmmB,xmmD >+ punpcklwd xmmD,xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18) >+ punpckhwd xmmC,xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --) >+ >+ psrldq xmmB,2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --) >+ >+ movdqa xmmF,xmmE >+ punpcklwd xmmE,xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29) >+ punpckhwd xmmF,xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --) >+ >+ pshufd xmmH,xmmA,0x4E; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03) >+ movdqa xmmB,xmmE >+ punpckldq xmmA,xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14) >+ punpckldq xmmE,xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07) >+ punpckhdq xmmD,xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29) >+ >+ pshufd xmmH,xmmG,0x4E; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B) >+ movdqa xmmB,xmmF >+ punpckldq xmmG,xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C) >+ punpckldq xmmF,xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F) >+ punpckhdq xmmC,xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --) >+ >+ punpcklqdq xmmA,xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05) >+ punpcklqdq xmmD,xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) >+ punpcklqdq xmmF,xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F) >+ >+ cmp ecx, byte SIZEOF_XMMWORD >+ jb short .column_st32 >+ >+ test edi, SIZEOF_XMMWORD-1 >+ jnz short .out1 >+ ; --(aligned)------------------- >+ movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA >+ movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD >+ movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmF >+ add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr >+ jmp short .out0 >+.out1: ; --(unaligned)----------------- >+ pcmpeqb xmmH,xmmH ; xmmH=(all 1's) >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [edi], xmmD >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmF,xmmH ; movntdqu XMMWORD [edi], xmmF >+ add edi, byte SIZEOF_XMMWORD ; outptr >+.out0: >+ sub ecx, byte SIZEOF_XMMWORD >+ jz near .nextrow >+ >+ add esi, byte SIZEOF_XMMWORD ; inptr0 >+ add ebx, byte SIZEOF_XMMWORD ; inptr1 >+ add edx, byte SIZEOF_XMMWORD ; inptr2 >+ jmp near .columnloop >+ alignx 16,7 >+ >+.column_st32: >+ pcmpeqb xmmH,xmmH ; xmmH=(all 1's) >+ lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE >+ cmp ecx, byte 2*SIZEOF_XMMWORD >+ jb short .column_st16 >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [edi], xmmD >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmF >+ sub ecx, byte 2*SIZEOF_XMMWORD >+ jmp short .column_st15 >+.column_st16: >+ cmp ecx, byte SIZEOF_XMMWORD >+ jb short .column_st15 >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmD >+ sub ecx, byte SIZEOF_XMMWORD >+.column_st15: >+ mov eax,ecx >+ xor ecx, byte 0x0F >+ shl ecx, 2 >+ movd xmmB,ecx >+ psrlq xmmH,4 >+ pcmpeqb xmmE,xmmE >+ psrlq xmmH,xmmB >+ psrlq xmmE,xmmB >+ punpcklbw xmmE,xmmH >+ ; ---------------- >+ mov ecx,edi >+ and ecx, byte SIZEOF_XMMWORD-1 >+ jz short .adj0 >+ add eax,ecx >+ cmp eax, byte SIZEOF_XMMWORD >+ ja short .adj0 >+ and edi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary >+ shl ecx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx >+ movdqa xmmG,xmmA >+ movdqa xmmC,xmmE >+ pslldq xmmA, SIZEOF_XMMWORD/2 >+ pslldq xmmE, SIZEOF_XMMWORD/2 >+ movd xmmD,ecx >+ sub ecx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT >+ jb short .adj1 >+ movd xmmF,ecx >+ psllq xmmA,xmmF >+ psllq xmmE,xmmF >+ jmp short .adj0 >+.adj1: neg ecx >+ movd xmmF,ecx >+ psrlq xmmA,xmmF >+ psrlq xmmE,xmmF >+ psllq xmmG,xmmD >+ psllq xmmC,xmmD >+ por xmmA,xmmG >+ por xmmE,xmmC >+.adj0: ; ---------------- >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ >+%else ; RGB_PIXELSIZE == 4 ; ----------- >+ >+%ifdef RGBX_FILLER_0XFF >+ pcmpeqb xmm6,xmm6 ; xmm6=XE=X(02468ACE********) >+ pcmpeqb xmm7,xmm7 ; xmm7=XO=X(13579BDF********) >+%else >+ pxor xmm6,xmm6 ; xmm6=XE=X(02468ACE********) >+ pxor xmm7,xmm7 ; xmm7=XO=X(13579BDF********) >+%endif >+ ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **) >+ ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **) >+ ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **) >+ ; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **) >+ >+ punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E) >+ punpcklbw xmmE,xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E) >+ punpcklbw xmmB,xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F) >+ punpcklbw xmmF,xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F) >+ >+ movdqa xmmC,xmmA >+ punpcklwd xmmA,xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36) >+ punpckhwd xmmC,xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E) >+ movdqa xmmG,xmmB >+ punpcklwd xmmB,xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37) >+ punpckhwd xmmG,xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F) >+ >+ movdqa xmmD,xmmA >+ punpckldq xmmA,xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33) >+ punpckhdq xmmD,xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37) >+ movdqa xmmH,xmmC >+ punpckldq xmmC,xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B) >+ punpckhdq xmmH,xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F) >+ >+ cmp ecx, byte SIZEOF_XMMWORD >+ jb short .column_st32 >+ >+ test edi, SIZEOF_XMMWORD-1 >+ jnz short .out1 >+ ; --(aligned)------------------- >+ movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA >+ movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD >+ movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmC >+ movntdq XMMWORD [edi+3*SIZEOF_XMMWORD], xmmH >+ add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr >+ jmp short .out0 >+.out1: ; --(unaligned)----------------- >+ pcmpeqb xmmE,xmmE ; xmmE=(all 1's) >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [edi], xmmD >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmC,xmmE ; movntdqu XMMWORD [edi], xmmC >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmH,xmmE ; movntdqu XMMWORD [edi], xmmH >+ add edi, byte SIZEOF_XMMWORD ; outptr >+.out0: >+ sub ecx, byte SIZEOF_XMMWORD >+ jz near .nextrow >+ >+ add esi, byte SIZEOF_XMMWORD ; inptr0 >+ add ebx, byte SIZEOF_XMMWORD ; inptr1 >+ add edx, byte SIZEOF_XMMWORD ; inptr2 >+ jmp near .columnloop >+ alignx 16,7 >+ >+.column_st32: >+ pcmpeqb xmmE,xmmE ; xmmE=(all 1's) >+ cmp ecx, byte SIZEOF_XMMWORD/2 >+ jb short .column_st16 >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [edi], xmmD >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmC >+ movdqa xmmD,xmmH >+ sub ecx, byte SIZEOF_XMMWORD/2 >+.column_st16: >+ cmp ecx, byte SIZEOF_XMMWORD/4 >+ jb short .column_st15 >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmD >+ sub ecx, byte SIZEOF_XMMWORD/4 >+.column_st15: >+ cmp ecx, byte SIZEOF_XMMWORD/16 >+ jb short .nextrow >+ mov eax,ecx >+ xor ecx, byte 0x03 >+ inc ecx >+ shl ecx, 4 >+ movd xmmF,ecx >+ psrlq xmmE,xmmF >+ punpcklbw xmmE,xmmE >+ ; ---------------- >+ mov ecx,edi >+ and ecx, byte SIZEOF_XMMWORD-1 >+ jz short .adj0 >+ lea eax, [ecx+eax*4] ; RGB_PIXELSIZE >+ cmp eax, byte SIZEOF_XMMWORD >+ ja short .adj0 >+ and edi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary >+ shl ecx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx >+ movdqa xmmB,xmmA >+ movdqa xmmG,xmmE >+ pslldq xmmA, SIZEOF_XMMWORD/2 >+ pslldq xmmE, SIZEOF_XMMWORD/2 >+ movd xmmC,ecx >+ sub ecx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT >+ jb short .adj1 >+ movd xmmH,ecx >+ psllq xmmA,xmmH >+ psllq xmmE,xmmH >+ jmp short .adj0 >+.adj1: neg ecx >+ movd xmmH,ecx >+ psrlq xmmA,xmmH >+ psrlq xmmE,xmmH >+ psllq xmmB,xmmC >+ psllq xmmG,xmmC >+ por xmmA,xmmB >+ por xmmE,xmmG >+.adj0: ; ---------------- >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ >+%endif ; RGB_PIXELSIZE ; --------------- >+ >+ alignx 16,7 >+ >+.nextrow: >+ pop ecx >+ pop esi >+ pop ebx >+ pop edx >+ pop edi >+ pop eax >+ >+ add esi, byte SIZEOF_JSAMPROW >+ add ebx, byte SIZEOF_JSAMPROW >+ add edx, byte SIZEOF_JSAMPROW >+ add edi, byte SIZEOF_JSAMPROW ; output_buf >+ dec eax ; num_rows >+ jg near .rowloop >+ >+ sfence ; flush the write buffer >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jdcolmmx.asm b/modules/libjpeg-turbo/simd/jdcolmmx.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdcolmmx.asm >@@ -0,0 +1,117 @@ >+; >+; jdcolmmx.asm - colorspace conversion (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define SCALEBITS 16 >+ >+F_0_344 equ 22554 ; FIX(0.34414) >+F_0_714 equ 46802 ; FIX(0.71414) >+F_1_402 equ 91881 ; FIX(1.40200) >+F_1_772 equ 116130 ; FIX(1.77200) >+F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1) >+F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414) >+F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200) >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_ycc_rgb_convert_mmx) >+ >+EXTN(jconst_ycc_rgb_convert_mmx): >+ >+PW_F0402 times 4 dw F_0_402 >+PW_MF0228 times 4 dw -F_0_228 >+PW_MF0344_F0285 times 2 dw -F_0_344, F_0_285 >+PW_ONE times 4 dw 1 >+PD_ONEHALF times 2 dd 1 << (SCALEBITS-1) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+%include "jdclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 3 >+%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extrgb_convert_mmx >+%include "jdclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extrgbx_convert_mmx >+%include "jdclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 3 >+%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extbgr_convert_mmx >+%include "jdclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extbgrx_convert_mmx >+%include "jdclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 3 >+%define RGB_GREEN 2 >+%define RGB_BLUE 1 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extxbgr_convert_mmx >+%include "jdclrmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 1 >+%define RGB_GREEN 2 >+%define RGB_BLUE 3 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_mmx jsimd_ycc_extxrgb_convert_mmx >+%include "jdclrmmx.asm" >diff --git a/modules/libjpeg-turbo/simd/jdcolss2-64.asm b/modules/libjpeg-turbo/simd/jdcolss2-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdcolss2-64.asm >@@ -0,0 +1,117 @@ >+; >+; jdcolss2-64.asm - colorspace conversion (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define SCALEBITS 16 >+ >+F_0_344 equ 22554 ; FIX(0.34414) >+F_0_714 equ 46802 ; FIX(0.71414) >+F_1_402 equ 91881 ; FIX(1.40200) >+F_1_772 equ 116130 ; FIX(1.77200) >+F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1) >+F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414) >+F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200) >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_ycc_rgb_convert_sse2) >+ >+EXTN(jconst_ycc_rgb_convert_sse2): >+ >+PW_F0402 times 8 dw F_0_402 >+PW_MF0228 times 8 dw -F_0_228 >+PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285 >+PW_ONE times 8 dw 1 >+PD_ONEHALF times 4 dd 1 << (SCALEBITS-1) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+%include "jdclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 3 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extrgb_convert_sse2 >+%include "jdclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extrgbx_convert_sse2 >+%include "jdclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 3 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extbgr_convert_sse2 >+%include "jdclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extbgrx_convert_sse2 >+%include "jdclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 3 >+%define RGB_GREEN 2 >+%define RGB_BLUE 1 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extxbgr_convert_sse2 >+%include "jdclrss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 1 >+%define RGB_GREEN 2 >+%define RGB_BLUE 3 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extxrgb_convert_sse2 >+%include "jdclrss2-64.asm" >diff --git a/modules/libjpeg-turbo/simd/jdcolss2.asm b/modules/libjpeg-turbo/simd/jdcolss2.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdcolss2.asm >@@ -0,0 +1,117 @@ >+; >+; jdcolss2.asm - colorspace conversion (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define SCALEBITS 16 >+ >+F_0_344 equ 22554 ; FIX(0.34414) >+F_0_714 equ 46802 ; FIX(0.71414) >+F_1_402 equ 91881 ; FIX(1.40200) >+F_1_772 equ 116130 ; FIX(1.77200) >+F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1) >+F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414) >+F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200) >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_ycc_rgb_convert_sse2) >+ >+EXTN(jconst_ycc_rgb_convert_sse2): >+ >+PW_F0402 times 8 dw F_0_402 >+PW_MF0228 times 8 dw -F_0_228 >+PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285 >+PW_ONE times 8 dw 1 >+PD_ONEHALF times 4 dd 1 << (SCALEBITS-1) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+%include "jdclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 3 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extrgb_convert_sse2 >+%include "jdclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extrgbx_convert_sse2 >+%include "jdclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 3 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extbgr_convert_sse2 >+%include "jdclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extbgrx_convert_sse2 >+%include "jdclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 3 >+%define RGB_GREEN 2 >+%define RGB_BLUE 1 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extxbgr_convert_sse2 >+%include "jdclrss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 1 >+%define RGB_GREEN 2 >+%define RGB_BLUE 3 >+%define RGB_PIXELSIZE 4 >+%define jsimd_ycc_rgb_convert_sse2 jsimd_ycc_extxrgb_convert_sse2 >+%include "jdclrss2.asm" >diff --git a/modules/libjpeg-turbo/simd/jdct.inc b/modules/libjpeg-turbo/simd/jdct.inc >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdct.inc >@@ -0,0 +1,28 @@ >+; >+; jdct.inc - private declarations for forward & reverse DCT subsystems >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; [TAB8] >+ >+; Each IDCT routine is responsible for range-limiting its results and >+; converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could >+; be quite far out of range if the input data is corrupt, so a bulletproof >+; range-limiting step is required. We use a mask-and-table-lookup method >+; to do the combined operations quickly. >+; >+%define RANGE_MASK (MAXJSAMPLE * 4 + 3) ; 2 bits wider than legal samples >+ >+%define ROW(n,b,s) ((b)+(n)*(s)) >+%define COL(n,b,s) ((b)+(n)*(s)*DCTSIZE) >+ >+%define DWBLOCK(m,n,b,s) ((b)+(m)*DCTSIZE*(s)+(n)*SIZEOF_DWORD) >+%define MMBLOCK(m,n,b,s) ((b)+(m)*DCTSIZE*(s)+(n)*SIZEOF_MMWORD) >+%define XMMBLOCK(m,n,b,s) ((b)+(m)*DCTSIZE*(s)+(n)*SIZEOF_XMMWORD) >+ >+; -------------------------------------------------------------------------- >diff --git a/modules/libjpeg-turbo/simd/jdmermmx.asm b/modules/libjpeg-turbo/simd/jdmermmx.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdmermmx.asm >@@ -0,0 +1,123 @@ >+; >+; jdmermmx.asm - merged upsampling/color conversion (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define SCALEBITS 16 >+ >+F_0_344 equ 22554 ; FIX(0.34414) >+F_0_714 equ 46802 ; FIX(0.71414) >+F_1_402 equ 91881 ; FIX(1.40200) >+F_1_772 equ 116130 ; FIX(1.77200) >+F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1) >+F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414) >+F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200) >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_merged_upsample_mmx) >+ >+EXTN(jconst_merged_upsample_mmx): >+ >+PW_F0402 times 4 dw F_0_402 >+PW_MF0228 times 4 dw -F_0_228 >+PW_MF0344_F0285 times 2 dw -F_0_344, F_0_285 >+PW_ONE times 4 dw 1 >+PD_ONEHALF times 2 dd 1 << (SCALEBITS-1) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+%include "jdmrgmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 3 >+%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extrgb_merged_upsample_mmx >+%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extrgb_merged_upsample_mmx >+%include "jdmrgmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extrgbx_merged_upsample_mmx >+%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extrgbx_merged_upsample_mmx >+%include "jdmrgmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 3 >+%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extbgr_merged_upsample_mmx >+%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extbgr_merged_upsample_mmx >+%include "jdmrgmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extbgrx_merged_upsample_mmx >+%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extbgrx_merged_upsample_mmx >+%include "jdmrgmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 3 >+%define RGB_GREEN 2 >+%define RGB_BLUE 1 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extxbgr_merged_upsample_mmx >+%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extxbgr_merged_upsample_mmx >+%include "jdmrgmmx.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 1 >+%define RGB_GREEN 2 >+%define RGB_BLUE 3 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_mmx jsimd_h2v1_extxrgb_merged_upsample_mmx >+%define jsimd_h2v2_merged_upsample_mmx jsimd_h2v2_extxrgb_merged_upsample_mmx >+%include "jdmrgmmx.asm" >diff --git a/modules/libjpeg-turbo/simd/jdmerss2-64.asm b/modules/libjpeg-turbo/simd/jdmerss2-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdmerss2-64.asm >@@ -0,0 +1,123 @@ >+; >+; jdmerss2-64.asm - merged upsampling/color conversion (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define SCALEBITS 16 >+ >+F_0_344 equ 22554 ; FIX(0.34414) >+F_0_714 equ 46802 ; FIX(0.71414) >+F_1_402 equ 91881 ; FIX(1.40200) >+F_1_772 equ 116130 ; FIX(1.77200) >+F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1) >+F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414) >+F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200) >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_merged_upsample_sse2) >+ >+EXTN(jconst_merged_upsample_sse2): >+ >+PW_F0402 times 8 dw F_0_402 >+PW_MF0228 times 8 dw -F_0_228 >+PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285 >+PW_ONE times 8 dw 1 >+PD_ONEHALF times 4 dd 1 << (SCALEBITS-1) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+%include "jdmrgss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 3 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extrgb_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extrgb_merged_upsample_sse2 >+%include "jdmrgss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extrgbx_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extrgbx_merged_upsample_sse2 >+%include "jdmrgss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 3 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extbgr_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extbgr_merged_upsample_sse2 >+%include "jdmrgss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extbgrx_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extbgrx_merged_upsample_sse2 >+%include "jdmrgss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 3 >+%define RGB_GREEN 2 >+%define RGB_BLUE 1 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extxbgr_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extxbgr_merged_upsample_sse2 >+%include "jdmrgss2-64.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 1 >+%define RGB_GREEN 2 >+%define RGB_BLUE 3 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extxrgb_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extxrgb_merged_upsample_sse2 >+%include "jdmrgss2-64.asm" >diff --git a/modules/libjpeg-turbo/simd/jdmerss2.asm b/modules/libjpeg-turbo/simd/jdmerss2.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdmerss2.asm >@@ -0,0 +1,123 @@ >+; >+; jdmerss2.asm - merged upsampling/color conversion (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define SCALEBITS 16 >+ >+F_0_344 equ 22554 ; FIX(0.34414) >+F_0_714 equ 46802 ; FIX(0.71414) >+F_1_402 equ 91881 ; FIX(1.40200) >+F_1_772 equ 116130 ; FIX(1.77200) >+F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1) >+F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414) >+F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200) >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_merged_upsample_sse2) >+ >+EXTN(jconst_merged_upsample_sse2): >+ >+PW_F0402 times 8 dw F_0_402 >+PW_MF0228 times 8 dw -F_0_228 >+PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285 >+PW_ONE times 8 dw 1 >+PD_ONEHALF times 4 dd 1 << (SCALEBITS-1) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+%include "jdmrgss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 3 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extrgb_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extrgb_merged_upsample_sse2 >+%include "jdmrgss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extrgbx_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extrgbx_merged_upsample_sse2 >+%include "jdmrgss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 3 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extbgr_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extbgr_merged_upsample_sse2 >+%include "jdmrgss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 2 >+%define RGB_GREEN 1 >+%define RGB_BLUE 0 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extbgrx_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extbgrx_merged_upsample_sse2 >+%include "jdmrgss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 3 >+%define RGB_GREEN 2 >+%define RGB_BLUE 1 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extxbgr_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extxbgr_merged_upsample_sse2 >+%include "jdmrgss2.asm" >+ >+%undef RGB_RED >+%undef RGB_GREEN >+%undef RGB_BLUE >+%undef RGB_PIXELSIZE >+%define RGB_RED 1 >+%define RGB_GREEN 2 >+%define RGB_BLUE 3 >+%define RGB_PIXELSIZE 4 >+%define jsimd_h2v1_merged_upsample_sse2 jsimd_h2v1_extxrgb_merged_upsample_sse2 >+%define jsimd_h2v2_merged_upsample_sse2 jsimd_h2v2_extxrgb_merged_upsample_sse2 >+%include "jdmrgss2.asm" >diff --git a/modules/libjpeg-turbo/simd/jdmrgmmx.asm b/modules/libjpeg-turbo/simd/jdmrgmmx.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdmrgmmx.asm >@@ -0,0 +1,466 @@ >+; >+; jdmrgmmx.asm - merged upsampling/color conversion (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jcolsamp.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. >+; >+; GLOBAL(void) >+; jsimd_h2v1_merged_upsample_mmx (JDIMENSION output_width, >+; JSAMPIMAGE input_buf, >+; JDIMENSION in_row_group_ctr, >+; JSAMPARRAY output_buf); >+; >+ >+%define output_width(b) (b)+8 ; JDIMENSION output_width >+%define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf >+%define in_row_group_ctr(b) (b)+16 ; JDIMENSION in_row_group_ctr >+%define output_buf(b) (b)+20 ; JSAMPARRAY output_buf >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 3 >+%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr >+ >+ align 16 >+ global EXTN(jsimd_h2v1_merged_upsample_mmx) >+ >+EXTN(jsimd_h2v1_merged_upsample_mmx): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic eax ; make a room for GOT address >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ movpic POINTER [gotptr], ebx ; save GOT address >+ >+ mov ecx, JDIMENSION [output_width(eax)] ; col >+ test ecx,ecx >+ jz near .return >+ >+ push ecx >+ >+ mov edi, JSAMPIMAGE [input_buf(eax)] >+ mov ecx, JDIMENSION [in_row_group_ctr(eax)] >+ mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY] >+ mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY] >+ mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY] >+ mov edi, JSAMPARRAY [output_buf(eax)] >+ mov esi, JSAMPROW [esi+ecx*SIZEOF_JSAMPROW] ; inptr0 >+ mov ebx, JSAMPROW [ebx+ecx*SIZEOF_JSAMPROW] ; inptr1 >+ mov edx, JSAMPROW [edx+ecx*SIZEOF_JSAMPROW] ; inptr2 >+ mov edi, JSAMPROW [edi] ; outptr >+ >+ pop ecx ; col >+ >+ alignx 16,7 >+.columnloop: >+ movpic eax, POINTER [gotptr] ; load GOT address (eax) >+ >+ movq mm6, MMWORD [ebx] ; mm6=Cb(01234567) >+ movq mm7, MMWORD [edx] ; mm7=Cr(01234567) >+ >+ pxor mm1,mm1 ; mm1=(all 0's) >+ pcmpeqw mm3,mm3 >+ psllw mm3,7 ; mm3={0xFF80 0xFF80 0xFF80 0xFF80} >+ >+ movq mm4,mm6 >+ punpckhbw mm6,mm1 ; mm6=Cb(4567)=CbH >+ punpcklbw mm4,mm1 ; mm4=Cb(0123)=CbL >+ movq mm0,mm7 >+ punpckhbw mm7,mm1 ; mm7=Cr(4567)=CrH >+ punpcklbw mm0,mm1 ; mm0=Cr(0123)=CrL >+ >+ paddw mm6,mm3 >+ paddw mm4,mm3 >+ paddw mm7,mm3 >+ paddw mm0,mm3 >+ >+ ; (Original) >+ ; R = Y + 1.40200 * Cr >+ ; G = Y - 0.34414 * Cb - 0.71414 * Cr >+ ; B = Y + 1.77200 * Cb >+ ; >+ ; (This implementation) >+ ; R = Y + 0.40200 * Cr + Cr >+ ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr >+ ; B = Y - 0.22800 * Cb + Cb + Cb >+ >+ movq mm5,mm6 ; mm5=CbH >+ movq mm2,mm4 ; mm2=CbL >+ paddw mm6,mm6 ; mm6=2*CbH >+ paddw mm4,mm4 ; mm4=2*CbL >+ movq mm1,mm7 ; mm1=CrH >+ movq mm3,mm0 ; mm3=CrL >+ paddw mm7,mm7 ; mm7=2*CrH >+ paddw mm0,mm0 ; mm0=2*CrL >+ >+ pmulhw mm6,[GOTOFF(eax,PW_MF0228)] ; mm6=(2*CbH * -FIX(0.22800)) >+ pmulhw mm4,[GOTOFF(eax,PW_MF0228)] ; mm4=(2*CbL * -FIX(0.22800)) >+ pmulhw mm7,[GOTOFF(eax,PW_F0402)] ; mm7=(2*CrH * FIX(0.40200)) >+ pmulhw mm0,[GOTOFF(eax,PW_F0402)] ; mm0=(2*CrL * FIX(0.40200)) >+ >+ paddw mm6,[GOTOFF(eax,PW_ONE)] >+ paddw mm4,[GOTOFF(eax,PW_ONE)] >+ psraw mm6,1 ; mm6=(CbH * -FIX(0.22800)) >+ psraw mm4,1 ; mm4=(CbL * -FIX(0.22800)) >+ paddw mm7,[GOTOFF(eax,PW_ONE)] >+ paddw mm0,[GOTOFF(eax,PW_ONE)] >+ psraw mm7,1 ; mm7=(CrH * FIX(0.40200)) >+ psraw mm0,1 ; mm0=(CrL * FIX(0.40200)) >+ >+ paddw mm6,mm5 >+ paddw mm4,mm2 >+ paddw mm6,mm5 ; mm6=(CbH * FIX(1.77200))=(B-Y)H >+ paddw mm4,mm2 ; mm4=(CbL * FIX(1.77200))=(B-Y)L >+ paddw mm7,mm1 ; mm7=(CrH * FIX(1.40200))=(R-Y)H >+ paddw mm0,mm3 ; mm0=(CrL * FIX(1.40200))=(R-Y)L >+ >+ movq MMWORD [wk(0)], mm6 ; wk(0)=(B-Y)H >+ movq MMWORD [wk(1)], mm7 ; wk(1)=(R-Y)H >+ >+ movq mm6,mm5 >+ movq mm7,mm2 >+ punpcklwd mm5,mm1 >+ punpckhwd mm6,mm1 >+ pmaddwd mm5,[GOTOFF(eax,PW_MF0344_F0285)] >+ pmaddwd mm6,[GOTOFF(eax,PW_MF0344_F0285)] >+ punpcklwd mm2,mm3 >+ punpckhwd mm7,mm3 >+ pmaddwd mm2,[GOTOFF(eax,PW_MF0344_F0285)] >+ pmaddwd mm7,[GOTOFF(eax,PW_MF0344_F0285)] >+ >+ paddd mm5,[GOTOFF(eax,PD_ONEHALF)] >+ paddd mm6,[GOTOFF(eax,PD_ONEHALF)] >+ psrad mm5,SCALEBITS >+ psrad mm6,SCALEBITS >+ paddd mm2,[GOTOFF(eax,PD_ONEHALF)] >+ paddd mm7,[GOTOFF(eax,PD_ONEHALF)] >+ psrad mm2,SCALEBITS >+ psrad mm7,SCALEBITS >+ >+ packssdw mm5,mm6 ; mm5=CbH*-FIX(0.344)+CrH*FIX(0.285) >+ packssdw mm2,mm7 ; mm2=CbL*-FIX(0.344)+CrL*FIX(0.285) >+ psubw mm5,mm1 ; mm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H >+ psubw mm2,mm3 ; mm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L >+ >+ movq MMWORD [wk(2)], mm5 ; wk(2)=(G-Y)H >+ >+ mov al,2 ; Yctr >+ jmp short .Yloop_1st >+ alignx 16,7 >+ >+.Yloop_2nd: >+ movq mm0, MMWORD [wk(1)] ; mm0=(R-Y)H >+ movq mm2, MMWORD [wk(2)] ; mm2=(G-Y)H >+ movq mm4, MMWORD [wk(0)] ; mm4=(B-Y)H >+ alignx 16,7 >+ >+.Yloop_1st: >+ movq mm7, MMWORD [esi] ; mm7=Y(01234567) >+ >+ pcmpeqw mm6,mm6 >+ psrlw mm6,BYTE_BIT ; mm6={0xFF 0x00 0xFF 0x00 ..} >+ pand mm6,mm7 ; mm6=Y(0246)=YE >+ psrlw mm7,BYTE_BIT ; mm7=Y(1357)=YO >+ >+ movq mm1,mm0 ; mm1=mm0=(R-Y)(L/H) >+ movq mm3,mm2 ; mm3=mm2=(G-Y)(L/H) >+ movq mm5,mm4 ; mm5=mm4=(B-Y)(L/H) >+ >+ paddw mm0,mm6 ; mm0=((R-Y)+YE)=RE=(R0 R2 R4 R6) >+ paddw mm1,mm7 ; mm1=((R-Y)+YO)=RO=(R1 R3 R5 R7) >+ packuswb mm0,mm0 ; mm0=(R0 R2 R4 R6 ** ** ** **) >+ packuswb mm1,mm1 ; mm1=(R1 R3 R5 R7 ** ** ** **) >+ >+ paddw mm2,mm6 ; mm2=((G-Y)+YE)=GE=(G0 G2 G4 G6) >+ paddw mm3,mm7 ; mm3=((G-Y)+YO)=GO=(G1 G3 G5 G7) >+ packuswb mm2,mm2 ; mm2=(G0 G2 G4 G6 ** ** ** **) >+ packuswb mm3,mm3 ; mm3=(G1 G3 G5 G7 ** ** ** **) >+ >+ paddw mm4,mm6 ; mm4=((B-Y)+YE)=BE=(B0 B2 B4 B6) >+ paddw mm5,mm7 ; mm5=((B-Y)+YO)=BO=(B1 B3 B5 B7) >+ packuswb mm4,mm4 ; mm4=(B0 B2 B4 B6 ** ** ** **) >+ packuswb mm5,mm5 ; mm5=(B1 B3 B5 B7 ** ** ** **) >+ >+%if RGB_PIXELSIZE == 3 ; --------------- >+ >+ ; mmA=(00 02 04 06 ** ** ** **), mmB=(01 03 05 07 ** ** ** **) >+ ; mmC=(10 12 14 16 ** ** ** **), mmD=(11 13 15 17 ** ** ** **) >+ ; mmE=(20 22 24 26 ** ** ** **), mmF=(21 23 25 27 ** ** ** **) >+ ; mmG=(** ** ** ** ** ** ** **), mmH=(** ** ** ** ** ** ** **) >+ >+ punpcklbw mmA,mmC ; mmA=(00 10 02 12 04 14 06 16) >+ punpcklbw mmE,mmB ; mmE=(20 01 22 03 24 05 26 07) >+ punpcklbw mmD,mmF ; mmD=(11 21 13 23 15 25 17 27) >+ >+ movq mmG,mmA >+ movq mmH,mmA >+ punpcklwd mmA,mmE ; mmA=(00 10 20 01 02 12 22 03) >+ punpckhwd mmG,mmE ; mmG=(04 14 24 05 06 16 26 07) >+ >+ psrlq mmH,2*BYTE_BIT ; mmH=(02 12 04 14 06 16 -- --) >+ psrlq mmE,2*BYTE_BIT ; mmE=(22 03 24 05 26 07 -- --) >+ >+ movq mmC,mmD >+ movq mmB,mmD >+ punpcklwd mmD,mmH ; mmD=(11 21 02 12 13 23 04 14) >+ punpckhwd mmC,mmH ; mmC=(15 25 06 16 17 27 -- --) >+ >+ psrlq mmB,2*BYTE_BIT ; mmB=(13 23 15 25 17 27 -- --) >+ >+ movq mmF,mmE >+ punpcklwd mmE,mmB ; mmE=(22 03 13 23 24 05 15 25) >+ punpckhwd mmF,mmB ; mmF=(26 07 17 27 -- -- -- --) >+ >+ punpckldq mmA,mmD ; mmA=(00 10 20 01 11 21 02 12) >+ punpckldq mmE,mmG ; mmE=(22 03 13 23 04 14 24 05) >+ punpckldq mmC,mmF ; mmC=(15 25 06 16 26 07 17 27) >+ >+ cmp ecx, byte SIZEOF_MMWORD >+ jb short .column_st16 >+ >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mmE >+ movq MMWORD [edi+2*SIZEOF_MMWORD], mmC >+ >+ sub ecx, byte SIZEOF_MMWORD >+ jz near .endcolumn >+ >+ add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr >+ add esi, byte SIZEOF_MMWORD ; inptr0 >+ dec al ; Yctr >+ jnz near .Yloop_2nd >+ >+ add ebx, byte SIZEOF_MMWORD ; inptr1 >+ add edx, byte SIZEOF_MMWORD ; inptr2 >+ jmp near .columnloop >+ alignx 16,7 >+ >+.column_st16: >+ lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE >+ cmp ecx, byte 2*SIZEOF_MMWORD >+ jb short .column_st8 >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mmE >+ movq mmA,mmC >+ sub ecx, byte 2*SIZEOF_MMWORD >+ add edi, byte 2*SIZEOF_MMWORD >+ jmp short .column_st4 >+.column_st8: >+ cmp ecx, byte SIZEOF_MMWORD >+ jb short .column_st4 >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq mmA,mmE >+ sub ecx, byte SIZEOF_MMWORD >+ add edi, byte SIZEOF_MMWORD >+.column_st4: >+ movd eax,mmA >+ cmp ecx, byte SIZEOF_DWORD >+ jb short .column_st2 >+ mov DWORD [edi+0*SIZEOF_DWORD], eax >+ psrlq mmA,DWORD_BIT >+ movd eax,mmA >+ sub ecx, byte SIZEOF_DWORD >+ add edi, byte SIZEOF_DWORD >+.column_st2: >+ cmp ecx, byte SIZEOF_WORD >+ jb short .column_st1 >+ mov WORD [edi+0*SIZEOF_WORD], ax >+ shr eax,WORD_BIT >+ sub ecx, byte SIZEOF_WORD >+ add edi, byte SIZEOF_WORD >+.column_st1: >+ cmp ecx, byte SIZEOF_BYTE >+ jb short .endcolumn >+ mov BYTE [edi+0*SIZEOF_BYTE], al >+ >+%else ; RGB_PIXELSIZE == 4 ; ----------- >+ >+%ifdef RGBX_FILLER_0XFF >+ pcmpeqb mm6,mm6 ; mm6=(X0 X2 X4 X6 ** ** ** **) >+ pcmpeqb mm7,mm7 ; mm7=(X1 X3 X5 X7 ** ** ** **) >+%else >+ pxor mm6,mm6 ; mm6=(X0 X2 X4 X6 ** ** ** **) >+ pxor mm7,mm7 ; mm7=(X1 X3 X5 X7 ** ** ** **) >+%endif >+ ; mmA=(00 02 04 06 ** ** ** **), mmB=(01 03 05 07 ** ** ** **) >+ ; mmC=(10 12 14 16 ** ** ** **), mmD=(11 13 15 17 ** ** ** **) >+ ; mmE=(20 22 24 26 ** ** ** **), mmF=(21 23 25 27 ** ** ** **) >+ ; mmG=(30 32 34 36 ** ** ** **), mmH=(31 33 35 37 ** ** ** **) >+ >+ punpcklbw mmA,mmC ; mmA=(00 10 02 12 04 14 06 16) >+ punpcklbw mmE,mmG ; mmE=(20 30 22 32 24 34 26 36) >+ punpcklbw mmB,mmD ; mmB=(01 11 03 13 05 15 07 17) >+ punpcklbw mmF,mmH ; mmF=(21 31 23 33 25 35 27 37) >+ >+ movq mmC,mmA >+ punpcklwd mmA,mmE ; mmA=(00 10 20 30 02 12 22 32) >+ punpckhwd mmC,mmE ; mmC=(04 14 24 34 06 16 26 36) >+ movq mmG,mmB >+ punpcklwd mmB,mmF ; mmB=(01 11 21 31 03 13 23 33) >+ punpckhwd mmG,mmF ; mmG=(05 15 25 35 07 17 27 37) >+ >+ movq mmD,mmA >+ punpckldq mmA,mmB ; mmA=(00 10 20 30 01 11 21 31) >+ punpckhdq mmD,mmB ; mmD=(02 12 22 32 03 13 23 33) >+ movq mmH,mmC >+ punpckldq mmC,mmG ; mmC=(04 14 24 34 05 15 25 35) >+ punpckhdq mmH,mmG ; mmH=(06 16 26 36 07 17 27 37) >+ >+ cmp ecx, byte SIZEOF_MMWORD >+ jb short .column_st16 >+ >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mmD >+ movq MMWORD [edi+2*SIZEOF_MMWORD], mmC >+ movq MMWORD [edi+3*SIZEOF_MMWORD], mmH >+ >+ sub ecx, byte SIZEOF_MMWORD >+ jz short .endcolumn >+ >+ add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr >+ add esi, byte SIZEOF_MMWORD ; inptr0 >+ dec al ; Yctr >+ jnz near .Yloop_2nd >+ >+ add ebx, byte SIZEOF_MMWORD ; inptr1 >+ add edx, byte SIZEOF_MMWORD ; inptr2 >+ jmp near .columnloop >+ alignx 16,7 >+ >+.column_st16: >+ cmp ecx, byte SIZEOF_MMWORD/2 >+ jb short .column_st8 >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mmD >+ movq mmA,mmC >+ movq mmD,mmH >+ sub ecx, byte SIZEOF_MMWORD/2 >+ add edi, byte 2*SIZEOF_MMWORD >+.column_st8: >+ cmp ecx, byte SIZEOF_MMWORD/4 >+ jb short .column_st4 >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mmA >+ movq mmA,mmD >+ sub ecx, byte SIZEOF_MMWORD/4 >+ add edi, byte 1*SIZEOF_MMWORD >+.column_st4: >+ cmp ecx, byte SIZEOF_MMWORD/8 >+ jb short .endcolumn >+ movd DWORD [edi+0*SIZEOF_DWORD], mmA >+ >+%endif ; RGB_PIXELSIZE ; --------------- >+ >+.endcolumn: >+ emms ; empty MMX state >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. >+; >+; GLOBAL(void) >+; jsimd_h2v2_merged_upsample_mmx (JDIMENSION output_width, >+; JSAMPIMAGE input_buf, >+; JDIMENSION in_row_group_ctr, >+; JSAMPARRAY output_buf); >+; >+ >+%define output_width(b) (b)+8 ; JDIMENSION output_width >+%define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf >+%define in_row_group_ctr(b) (b)+16 ; JDIMENSION in_row_group_ctr >+%define output_buf(b) (b)+20 ; JSAMPARRAY output_buf >+ >+ align 16 >+ global EXTN(jsimd_h2v2_merged_upsample_mmx) >+ >+EXTN(jsimd_h2v2_merged_upsample_mmx): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov eax, JDIMENSION [output_width(ebp)] >+ >+ mov edi, JSAMPIMAGE [input_buf(ebp)] >+ mov ecx, JDIMENSION [in_row_group_ctr(ebp)] >+ mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY] >+ mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY] >+ mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY] >+ mov edi, JSAMPARRAY [output_buf(ebp)] >+ lea esi, [esi+ecx*SIZEOF_JSAMPROW] >+ >+ push edx ; inptr2 >+ push ebx ; inptr1 >+ push esi ; inptr00 >+ mov ebx,esp >+ >+ push edi ; output_buf (outptr0) >+ push ecx ; in_row_group_ctr >+ push ebx ; input_buf >+ push eax ; output_width >+ >+ call near EXTN(jsimd_h2v1_merged_upsample_mmx) >+ >+ add esi, byte SIZEOF_JSAMPROW ; inptr01 >+ add edi, byte SIZEOF_JSAMPROW ; outptr1 >+ mov POINTER [ebx+0*SIZEOF_POINTER], esi >+ mov POINTER [ebx-1*SIZEOF_POINTER], edi >+ >+ call near EXTN(jsimd_h2v1_merged_upsample_mmx) >+ >+ add esp, byte 7*SIZEOF_DWORD >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jdmrgss2-64.asm b/modules/libjpeg-turbo/simd/jdmrgss2-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdmrgss2-64.asm >@@ -0,0 +1,584 @@ >+; >+; jdmrgss2-64.asm - merged upsampling/color conversion (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ for >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jcolsamp.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. >+; >+; GLOBAL(void) >+; jsimd_h2v1_merged_upsample_sse2 (JDIMENSION output_width, >+; JSAMPIMAGE input_buf, >+; JDIMENSION in_row_group_ctr, >+; JSAMPARRAY output_buf); >+; >+ >+; r10 = JDIMENSION output_width >+; r11 = JSAMPIMAGE input_buf >+; r12 = JDIMENSION in_row_group_ctr >+; r13 = JSAMPARRAY output_buf >+ >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 3 >+ >+ align 16 >+ global EXTN(jsimd_h2v1_merged_upsample_sse2) >+ >+EXTN(jsimd_h2v1_merged_upsample_sse2): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [wk(0)] >+ collect_args >+ push rbx >+ >+ mov rcx, r10 ; col >+ test rcx,rcx >+ jz near .return >+ >+ push rcx >+ >+ mov rdi, r11 >+ mov rcx, r12 >+ mov rsi, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY] >+ mov rbx, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY] >+ mov rdx, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY] >+ mov rdi, r13 >+ mov rsi, JSAMPROW [rsi+rcx*SIZEOF_JSAMPROW] ; inptr0 >+ mov rbx, JSAMPROW [rbx+rcx*SIZEOF_JSAMPROW] ; inptr1 >+ mov rdx, JSAMPROW [rdx+rcx*SIZEOF_JSAMPROW] ; inptr2 >+ mov rdi, JSAMPROW [rdi] ; outptr >+ >+ pop rcx ; col >+ >+.columnloop: >+ >+ movdqa xmm6, XMMWORD [rbx] ; xmm6=Cb(0123456789ABCDEF) >+ movdqa xmm7, XMMWORD [rdx] ; xmm7=Cr(0123456789ABCDEF) >+ >+ pxor xmm1,xmm1 ; xmm1=(all 0's) >+ pcmpeqw xmm3,xmm3 >+ psllw xmm3,7 ; xmm3={0xFF80 0xFF80 0xFF80 0xFF80 ..} >+ >+ movdqa xmm4,xmm6 >+ punpckhbw xmm6,xmm1 ; xmm6=Cb(89ABCDEF)=CbH >+ punpcklbw xmm4,xmm1 ; xmm4=Cb(01234567)=CbL >+ movdqa xmm0,xmm7 >+ punpckhbw xmm7,xmm1 ; xmm7=Cr(89ABCDEF)=CrH >+ punpcklbw xmm0,xmm1 ; xmm0=Cr(01234567)=CrL >+ >+ paddw xmm6,xmm3 >+ paddw xmm4,xmm3 >+ paddw xmm7,xmm3 >+ paddw xmm0,xmm3 >+ >+ ; (Original) >+ ; R = Y + 1.40200 * Cr >+ ; G = Y - 0.34414 * Cb - 0.71414 * Cr >+ ; B = Y + 1.77200 * Cb >+ ; >+ ; (This implementation) >+ ; R = Y + 0.40200 * Cr + Cr >+ ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr >+ ; B = Y - 0.22800 * Cb + Cb + Cb >+ >+ movdqa xmm5,xmm6 ; xmm5=CbH >+ movdqa xmm2,xmm4 ; xmm2=CbL >+ paddw xmm6,xmm6 ; xmm6=2*CbH >+ paddw xmm4,xmm4 ; xmm4=2*CbL >+ movdqa xmm1,xmm7 ; xmm1=CrH >+ movdqa xmm3,xmm0 ; xmm3=CrL >+ paddw xmm7,xmm7 ; xmm7=2*CrH >+ paddw xmm0,xmm0 ; xmm0=2*CrL >+ >+ pmulhw xmm6,[rel PW_MF0228] ; xmm6=(2*CbH * -FIX(0.22800)) >+ pmulhw xmm4,[rel PW_MF0228] ; xmm4=(2*CbL * -FIX(0.22800)) >+ pmulhw xmm7,[rel PW_F0402] ; xmm7=(2*CrH * FIX(0.40200)) >+ pmulhw xmm0,[rel PW_F0402] ; xmm0=(2*CrL * FIX(0.40200)) >+ >+ paddw xmm6,[rel PW_ONE] >+ paddw xmm4,[rel PW_ONE] >+ psraw xmm6,1 ; xmm6=(CbH * -FIX(0.22800)) >+ psraw xmm4,1 ; xmm4=(CbL * -FIX(0.22800)) >+ paddw xmm7,[rel PW_ONE] >+ paddw xmm0,[rel PW_ONE] >+ psraw xmm7,1 ; xmm7=(CrH * FIX(0.40200)) >+ psraw xmm0,1 ; xmm0=(CrL * FIX(0.40200)) >+ >+ paddw xmm6,xmm5 >+ paddw xmm4,xmm2 >+ paddw xmm6,xmm5 ; xmm6=(CbH * FIX(1.77200))=(B-Y)H >+ paddw xmm4,xmm2 ; xmm4=(CbL * FIX(1.77200))=(B-Y)L >+ paddw xmm7,xmm1 ; xmm7=(CrH * FIX(1.40200))=(R-Y)H >+ paddw xmm0,xmm3 ; xmm0=(CrL * FIX(1.40200))=(R-Y)L >+ >+ movdqa XMMWORD [wk(0)], xmm6 ; wk(0)=(B-Y)H >+ movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=(R-Y)H >+ >+ movdqa xmm6,xmm5 >+ movdqa xmm7,xmm2 >+ punpcklwd xmm5,xmm1 >+ punpckhwd xmm6,xmm1 >+ pmaddwd xmm5,[rel PW_MF0344_F0285] >+ pmaddwd xmm6,[rel PW_MF0344_F0285] >+ punpcklwd xmm2,xmm3 >+ punpckhwd xmm7,xmm3 >+ pmaddwd xmm2,[rel PW_MF0344_F0285] >+ pmaddwd xmm7,[rel PW_MF0344_F0285] >+ >+ paddd xmm5,[rel PD_ONEHALF] >+ paddd xmm6,[rel PD_ONEHALF] >+ psrad xmm5,SCALEBITS >+ psrad xmm6,SCALEBITS >+ paddd xmm2,[rel PD_ONEHALF] >+ paddd xmm7,[rel PD_ONEHALF] >+ psrad xmm2,SCALEBITS >+ psrad xmm7,SCALEBITS >+ >+ packssdw xmm5,xmm6 ; xmm5=CbH*-FIX(0.344)+CrH*FIX(0.285) >+ packssdw xmm2,xmm7 ; xmm2=CbL*-FIX(0.344)+CrL*FIX(0.285) >+ psubw xmm5,xmm1 ; xmm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H >+ psubw xmm2,xmm3 ; xmm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L >+ >+ movdqa XMMWORD [wk(2)], xmm5 ; wk(2)=(G-Y)H >+ >+ mov al,2 ; Yctr >+ jmp short .Yloop_1st >+ >+.Yloop_2nd: >+ movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(R-Y)H >+ movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(G-Y)H >+ movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(B-Y)H >+ >+.Yloop_1st: >+ movdqa xmm7, XMMWORD [rsi] ; xmm7=Y(0123456789ABCDEF) >+ >+ pcmpeqw xmm6,xmm6 >+ psrlw xmm6,BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..} >+ pand xmm6,xmm7 ; xmm6=Y(02468ACE)=YE >+ psrlw xmm7,BYTE_BIT ; xmm7=Y(13579BDF)=YO >+ >+ movdqa xmm1,xmm0 ; xmm1=xmm0=(R-Y)(L/H) >+ movdqa xmm3,xmm2 ; xmm3=xmm2=(G-Y)(L/H) >+ movdqa xmm5,xmm4 ; xmm5=xmm4=(B-Y)(L/H) >+ >+ paddw xmm0,xmm6 ; xmm0=((R-Y)+YE)=RE=R(02468ACE) >+ paddw xmm1,xmm7 ; xmm1=((R-Y)+YO)=RO=R(13579BDF) >+ packuswb xmm0,xmm0 ; xmm0=R(02468ACE********) >+ packuswb xmm1,xmm1 ; xmm1=R(13579BDF********) >+ >+ paddw xmm2,xmm6 ; xmm2=((G-Y)+YE)=GE=G(02468ACE) >+ paddw xmm3,xmm7 ; xmm3=((G-Y)+YO)=GO=G(13579BDF) >+ packuswb xmm2,xmm2 ; xmm2=G(02468ACE********) >+ packuswb xmm3,xmm3 ; xmm3=G(13579BDF********) >+ >+ paddw xmm4,xmm6 ; xmm4=((B-Y)+YE)=BE=B(02468ACE) >+ paddw xmm5,xmm7 ; xmm5=((B-Y)+YO)=BO=B(13579BDF) >+ packuswb xmm4,xmm4 ; xmm4=B(02468ACE********) >+ packuswb xmm5,xmm5 ; xmm5=B(13579BDF********) >+ >+%if RGB_PIXELSIZE == 3 ; --------------- >+ >+ ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **) >+ ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **) >+ ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **) >+ ; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **) >+ >+ punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E) >+ punpcklbw xmmE,xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F) >+ punpcklbw xmmD,xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F) >+ >+ movdqa xmmG,xmmA >+ movdqa xmmH,xmmA >+ punpcklwd xmmA,xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07) >+ punpckhwd xmmG,xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F) >+ >+ psrldq xmmH,2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --) >+ psrldq xmmE,2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --) >+ >+ movdqa xmmC,xmmD >+ movdqa xmmB,xmmD >+ punpcklwd xmmD,xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18) >+ punpckhwd xmmC,xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --) >+ >+ psrldq xmmB,2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --) >+ >+ movdqa xmmF,xmmE >+ punpcklwd xmmE,xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29) >+ punpckhwd xmmF,xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --) >+ >+ pshufd xmmH,xmmA,0x4E; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03) >+ movdqa xmmB,xmmE >+ punpckldq xmmA,xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14) >+ punpckldq xmmE,xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07) >+ punpckhdq xmmD,xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29) >+ >+ pshufd xmmH,xmmG,0x4E; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B) >+ movdqa xmmB,xmmF >+ punpckldq xmmG,xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C) >+ punpckldq xmmF,xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F) >+ punpckhdq xmmC,xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --) >+ >+ punpcklqdq xmmA,xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05) >+ punpcklqdq xmmD,xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) >+ punpcklqdq xmmF,xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F) >+ >+ cmp rcx, byte SIZEOF_XMMWORD >+ jb short .column_st32 >+ >+ test rdi, SIZEOF_XMMWORD-1 >+ jnz short .out1 >+ ; --(aligned)------------------- >+ movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA >+ movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD >+ movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmF >+ add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr >+ jmp short .out0 >+.out1: ; --(unaligned)----------------- >+ pcmpeqb xmmH,xmmH ; xmmH=(all 1's) >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [rdi], xmmD >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmF,xmmH ; movntdqu XMMWORD [rdi], xmmF >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+.out0: >+ sub rcx, byte SIZEOF_XMMWORD >+ jz near .endcolumn >+ >+ add rsi, byte SIZEOF_XMMWORD ; inptr0 >+ dec al ; Yctr >+ jnz near .Yloop_2nd >+ >+ add rbx, byte SIZEOF_XMMWORD ; inptr1 >+ add rdx, byte SIZEOF_XMMWORD ; inptr2 >+ jmp near .columnloop >+ >+.column_st32: >+ pcmpeqb xmmH,xmmH ; xmmH=(all 1's) >+ lea rcx, [rcx+rcx*2] ; imul ecx, RGB_PIXELSIZE >+ cmp rcx, byte 2*SIZEOF_XMMWORD >+ jb short .column_st16 >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [rdi], xmmD >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmF >+ sub rcx, byte 2*SIZEOF_XMMWORD >+ jmp short .column_st15 >+.column_st16: >+ cmp rcx, byte SIZEOF_XMMWORD >+ jb short .column_st15 >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmD >+ sub rcx, byte SIZEOF_XMMWORD >+.column_st15: >+ mov rax,rcx >+ xor rcx, byte 0x0F >+ shl rcx, 2 >+ movd xmmB,ecx >+ psrlq xmmH,4 >+ pcmpeqb xmmE,xmmE >+ psrlq xmmH,xmmB >+ psrlq xmmE,xmmB >+ punpcklbw xmmE,xmmH >+ ; ---------------- >+ mov rcx,rdi >+ and rcx, byte SIZEOF_XMMWORD-1 >+ jz short .adj0 >+ add rax,rcx >+ cmp rax, byte SIZEOF_XMMWORD >+ ja short .adj0 >+ and rdi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary >+ shl rcx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx >+ movdqa xmmG,xmmA >+ movdqa xmmC,xmmE >+ pslldq xmmA, SIZEOF_XMMWORD/2 >+ pslldq xmmE, SIZEOF_XMMWORD/2 >+ movd xmmD,ecx >+ sub rcx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT >+ jb short .adj1 >+ movd xmmF,ecx >+ psllq xmmA,xmmF >+ psllq xmmE,xmmF >+ jmp short .adj0 >+.adj1: neg rcx >+ movd xmmF,ecx >+ psrlq xmmA,xmmF >+ psrlq xmmE,xmmF >+ psllq xmmG,xmmD >+ psllq xmmC,xmmD >+ por xmmA,xmmG >+ por xmmE,xmmC >+.adj0: ; ---------------- >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ >+%else ; RGB_PIXELSIZE == 4 ; ----------- >+ >+%ifdef RGBX_FILLER_0XFF >+ pcmpeqb xmm6,xmm6 ; xmm6=XE=X(02468ACE********) >+ pcmpeqb xmm7,xmm7 ; xmm7=XO=X(13579BDF********) >+%else >+ pxor xmm6,xmm6 ; xmm6=XE=X(02468ACE********) >+ pxor xmm7,xmm7 ; xmm7=XO=X(13579BDF********) >+%endif >+ ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **) >+ ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **) >+ ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **) >+ ; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **) >+ >+ punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E) >+ punpcklbw xmmE,xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E) >+ punpcklbw xmmB,xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F) >+ punpcklbw xmmF,xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F) >+ >+ movdqa xmmC,xmmA >+ punpcklwd xmmA,xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36) >+ punpckhwd xmmC,xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E) >+ movdqa xmmG,xmmB >+ punpcklwd xmmB,xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37) >+ punpckhwd xmmG,xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F) >+ >+ movdqa xmmD,xmmA >+ punpckldq xmmA,xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33) >+ punpckhdq xmmD,xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37) >+ movdqa xmmH,xmmC >+ punpckldq xmmC,xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B) >+ punpckhdq xmmH,xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F) >+ >+ cmp rcx, byte SIZEOF_XMMWORD >+ jb short .column_st32 >+ >+ test rdi, SIZEOF_XMMWORD-1 >+ jnz short .out1 >+ ; --(aligned)------------------- >+ movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA >+ movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD >+ movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmC >+ movntdq XMMWORD [rdi+3*SIZEOF_XMMWORD], xmmH >+ add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr >+ jmp short .out0 >+.out1: ; --(unaligned)----------------- >+ pcmpeqb xmmE,xmmE ; xmmE=(all 1's) >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [rdi], xmmD >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmC,xmmE ; movntdqu XMMWORD [rdi], xmmC >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmH,xmmE ; movntdqu XMMWORD [rdi], xmmH >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+.out0: >+ sub rcx, byte SIZEOF_XMMWORD >+ jz near .endcolumn >+ >+ add rsi, byte SIZEOF_XMMWORD ; inptr0 >+ dec al ; Yctr >+ jnz near .Yloop_2nd >+ >+ add rbx, byte SIZEOF_XMMWORD ; inptr1 >+ add rdx, byte SIZEOF_XMMWORD ; inptr2 >+ jmp near .columnloop >+ >+.column_st32: >+ pcmpeqb xmmE,xmmE ; xmmE=(all 1's) >+ cmp rcx, byte SIZEOF_XMMWORD/2 >+ jb short .column_st16 >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [rdi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [rdi], xmmD >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmC >+ movdqa xmmD,xmmH >+ sub rcx, byte SIZEOF_XMMWORD/2 >+.column_st16: >+ cmp rcx, byte SIZEOF_XMMWORD/4 >+ jb short .column_st15 >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ add rdi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmD >+ sub rcx, byte SIZEOF_XMMWORD/4 >+.column_st15: >+ cmp rcx, byte SIZEOF_XMMWORD/16 >+ jb near .endcolumn >+ mov rax,rcx >+ xor rcx, byte 0x03 >+ inc rcx >+ shl rcx, 4 >+ movd xmmF,ecx >+ psrlq xmmE,xmmF >+ punpcklbw xmmE,xmmE >+ ; ---------------- >+ mov rcx,rdi >+ and rcx, byte SIZEOF_XMMWORD-1 >+ jz short .adj0 >+ lea rax, [rcx+rax*4] ; RGB_PIXELSIZE >+ cmp rax, byte SIZEOF_XMMWORD >+ ja short .adj0 >+ and rdi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary >+ shl rcx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx >+ movdqa xmmB,xmmA >+ movdqa xmmG,xmmE >+ pslldq xmmA, SIZEOF_XMMWORD/2 >+ pslldq xmmE, SIZEOF_XMMWORD/2 >+ movd xmmC,ecx >+ sub rcx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT >+ jb short .adj1 >+ movd xmmH,ecx >+ psllq xmmA,xmmH >+ psllq xmmE,xmmH >+ jmp short .adj0 >+.adj1: neg rcx >+ movd xmmH,ecx >+ psrlq xmmA,xmmH >+ psrlq xmmE,xmmH >+ psllq xmmB,xmmC >+ psllq xmmG,xmmC >+ por xmmA,xmmB >+ por xmmE,xmmG >+.adj0: ; ---------------- >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ >+%endif ; RGB_PIXELSIZE ; --------------- >+ >+.endcolumn: >+ sfence ; flush the write buffer >+ >+.return: >+ pop rbx >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. >+; >+; GLOBAL(void) >+; jsimd_h2v2_merged_upsample_sse2 (JDIMENSION output_width, >+; JSAMPIMAGE input_buf, >+; JDIMENSION in_row_group_ctr, >+; JSAMPARRAY output_buf); >+; >+ >+; r10 = JDIMENSION output_width >+; r11 = JSAMPIMAGE input_buf >+; r12 = JDIMENSION in_row_group_ctr >+; r13 = JSAMPARRAY output_buf >+ >+ align 16 >+ global EXTN(jsimd_h2v2_merged_upsample_sse2) >+ >+EXTN(jsimd_h2v2_merged_upsample_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ push rbx >+ >+ mov rax, r10 >+ >+ mov rdi, r11 >+ mov rcx, r12 >+ mov rsi, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY] >+ mov rbx, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY] >+ mov rdx, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY] >+ mov rdi, r13 >+ lea rsi, [rsi+rcx*SIZEOF_JSAMPROW] >+ >+ push rdx ; inptr2 >+ push rbx ; inptr1 >+ push rsi ; inptr00 >+ mov rbx,rsp >+ >+ push rdi >+ push rcx >+ push rax >+ >+ %ifdef WIN64 >+ mov r8, rcx >+ mov r9, rdi >+ mov rcx, rax >+ mov rdx, rbx >+ %else >+ mov rdx, rcx >+ mov rcx, rdi >+ mov rdi, rax >+ mov rsi, rbx >+ %endif >+ >+ call EXTN(jsimd_h2v1_merged_upsample_sse2) >+ >+ pop rax >+ pop rcx >+ pop rdi >+ pop rsi >+ pop rbx >+ pop rdx >+ >+ add rdi, byte SIZEOF_JSAMPROW ; outptr1 >+ add rsi, byte SIZEOF_JSAMPROW ; inptr01 >+ >+ push rdx ; inptr2 >+ push rbx ; inptr1 >+ push rsi ; inptr00 >+ mov rbx,rsp >+ >+ push rdi >+ push rcx >+ push rax >+ >+ %ifdef WIN64 >+ mov r8, rcx >+ mov r9, rdi >+ mov rcx, rax >+ mov rdx, rbx >+ %else >+ mov rdx, rcx >+ mov rcx, rdi >+ mov rdi, rax >+ mov rsi, rbx >+ %endif >+ >+ call EXTN(jsimd_h2v1_merged_upsample_sse2) >+ >+ pop rax >+ pop rcx >+ pop rdi >+ pop rsi >+ pop rbx >+ pop rdx >+ >+ pop rbx >+ uncollect_args >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jdmrgss2.asm b/modules/libjpeg-turbo/simd/jdmrgss2.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdmrgss2.asm >@@ -0,0 +1,564 @@ >+; >+; jdmrgss2.asm - merged upsampling/color conversion (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jcolsamp.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. >+; >+; GLOBAL(void) >+; jsimd_h2v1_merged_upsample_sse2 (JDIMENSION output_width, >+; JSAMPIMAGE input_buf, >+; JDIMENSION in_row_group_ctr, >+; JSAMPARRAY output_buf); >+; >+ >+%define output_width(b) (b)+8 ; JDIMENSION output_width >+%define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf >+%define in_row_group_ctr(b) (b)+16 ; JDIMENSION in_row_group_ctr >+%define output_buf(b) (b)+20 ; JSAMPARRAY output_buf >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 3 >+%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr >+ >+ align 16 >+ global EXTN(jsimd_h2v1_merged_upsample_sse2) >+ >+EXTN(jsimd_h2v1_merged_upsample_sse2): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic eax ; make a room for GOT address >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ movpic POINTER [gotptr], ebx ; save GOT address >+ >+ mov ecx, JDIMENSION [output_width(eax)] ; col >+ test ecx,ecx >+ jz near .return >+ >+ push ecx >+ >+ mov edi, JSAMPIMAGE [input_buf(eax)] >+ mov ecx, JDIMENSION [in_row_group_ctr(eax)] >+ mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY] >+ mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY] >+ mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY] >+ mov edi, JSAMPARRAY [output_buf(eax)] >+ mov esi, JSAMPROW [esi+ecx*SIZEOF_JSAMPROW] ; inptr0 >+ mov ebx, JSAMPROW [ebx+ecx*SIZEOF_JSAMPROW] ; inptr1 >+ mov edx, JSAMPROW [edx+ecx*SIZEOF_JSAMPROW] ; inptr2 >+ mov edi, JSAMPROW [edi] ; outptr >+ >+ pop ecx ; col >+ >+ alignx 16,7 >+.columnloop: >+ movpic eax, POINTER [gotptr] ; load GOT address (eax) >+ >+ movdqa xmm6, XMMWORD [ebx] ; xmm6=Cb(0123456789ABCDEF) >+ movdqa xmm7, XMMWORD [edx] ; xmm7=Cr(0123456789ABCDEF) >+ >+ pxor xmm1,xmm1 ; xmm1=(all 0's) >+ pcmpeqw xmm3,xmm3 >+ psllw xmm3,7 ; xmm3={0xFF80 0xFF80 0xFF80 0xFF80 ..} >+ >+ movdqa xmm4,xmm6 >+ punpckhbw xmm6,xmm1 ; xmm6=Cb(89ABCDEF)=CbH >+ punpcklbw xmm4,xmm1 ; xmm4=Cb(01234567)=CbL >+ movdqa xmm0,xmm7 >+ punpckhbw xmm7,xmm1 ; xmm7=Cr(89ABCDEF)=CrH >+ punpcklbw xmm0,xmm1 ; xmm0=Cr(01234567)=CrL >+ >+ paddw xmm6,xmm3 >+ paddw xmm4,xmm3 >+ paddw xmm7,xmm3 >+ paddw xmm0,xmm3 >+ >+ ; (Original) >+ ; R = Y + 1.40200 * Cr >+ ; G = Y - 0.34414 * Cb - 0.71414 * Cr >+ ; B = Y + 1.77200 * Cb >+ ; >+ ; (This implementation) >+ ; R = Y + 0.40200 * Cr + Cr >+ ; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr >+ ; B = Y - 0.22800 * Cb + Cb + Cb >+ >+ movdqa xmm5,xmm6 ; xmm5=CbH >+ movdqa xmm2,xmm4 ; xmm2=CbL >+ paddw xmm6,xmm6 ; xmm6=2*CbH >+ paddw xmm4,xmm4 ; xmm4=2*CbL >+ movdqa xmm1,xmm7 ; xmm1=CrH >+ movdqa xmm3,xmm0 ; xmm3=CrL >+ paddw xmm7,xmm7 ; xmm7=2*CrH >+ paddw xmm0,xmm0 ; xmm0=2*CrL >+ >+ pmulhw xmm6,[GOTOFF(eax,PW_MF0228)] ; xmm6=(2*CbH * -FIX(0.22800)) >+ pmulhw xmm4,[GOTOFF(eax,PW_MF0228)] ; xmm4=(2*CbL * -FIX(0.22800)) >+ pmulhw xmm7,[GOTOFF(eax,PW_F0402)] ; xmm7=(2*CrH * FIX(0.40200)) >+ pmulhw xmm0,[GOTOFF(eax,PW_F0402)] ; xmm0=(2*CrL * FIX(0.40200)) >+ >+ paddw xmm6,[GOTOFF(eax,PW_ONE)] >+ paddw xmm4,[GOTOFF(eax,PW_ONE)] >+ psraw xmm6,1 ; xmm6=(CbH * -FIX(0.22800)) >+ psraw xmm4,1 ; xmm4=(CbL * -FIX(0.22800)) >+ paddw xmm7,[GOTOFF(eax,PW_ONE)] >+ paddw xmm0,[GOTOFF(eax,PW_ONE)] >+ psraw xmm7,1 ; xmm7=(CrH * FIX(0.40200)) >+ psraw xmm0,1 ; xmm0=(CrL * FIX(0.40200)) >+ >+ paddw xmm6,xmm5 >+ paddw xmm4,xmm2 >+ paddw xmm6,xmm5 ; xmm6=(CbH * FIX(1.77200))=(B-Y)H >+ paddw xmm4,xmm2 ; xmm4=(CbL * FIX(1.77200))=(B-Y)L >+ paddw xmm7,xmm1 ; xmm7=(CrH * FIX(1.40200))=(R-Y)H >+ paddw xmm0,xmm3 ; xmm0=(CrL * FIX(1.40200))=(R-Y)L >+ >+ movdqa XMMWORD [wk(0)], xmm6 ; wk(0)=(B-Y)H >+ movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=(R-Y)H >+ >+ movdqa xmm6,xmm5 >+ movdqa xmm7,xmm2 >+ punpcklwd xmm5,xmm1 >+ punpckhwd xmm6,xmm1 >+ pmaddwd xmm5,[GOTOFF(eax,PW_MF0344_F0285)] >+ pmaddwd xmm6,[GOTOFF(eax,PW_MF0344_F0285)] >+ punpcklwd xmm2,xmm3 >+ punpckhwd xmm7,xmm3 >+ pmaddwd xmm2,[GOTOFF(eax,PW_MF0344_F0285)] >+ pmaddwd xmm7,[GOTOFF(eax,PW_MF0344_F0285)] >+ >+ paddd xmm5,[GOTOFF(eax,PD_ONEHALF)] >+ paddd xmm6,[GOTOFF(eax,PD_ONEHALF)] >+ psrad xmm5,SCALEBITS >+ psrad xmm6,SCALEBITS >+ paddd xmm2,[GOTOFF(eax,PD_ONEHALF)] >+ paddd xmm7,[GOTOFF(eax,PD_ONEHALF)] >+ psrad xmm2,SCALEBITS >+ psrad xmm7,SCALEBITS >+ >+ packssdw xmm5,xmm6 ; xmm5=CbH*-FIX(0.344)+CrH*FIX(0.285) >+ packssdw xmm2,xmm7 ; xmm2=CbL*-FIX(0.344)+CrL*FIX(0.285) >+ psubw xmm5,xmm1 ; xmm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H >+ psubw xmm2,xmm3 ; xmm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L >+ >+ movdqa XMMWORD [wk(2)], xmm5 ; wk(2)=(G-Y)H >+ >+ mov al,2 ; Yctr >+ jmp short .Yloop_1st >+ alignx 16,7 >+ >+.Yloop_2nd: >+ movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(R-Y)H >+ movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(G-Y)H >+ movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(B-Y)H >+ alignx 16,7 >+ >+.Yloop_1st: >+ movdqa xmm7, XMMWORD [esi] ; xmm7=Y(0123456789ABCDEF) >+ >+ pcmpeqw xmm6,xmm6 >+ psrlw xmm6,BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..} >+ pand xmm6,xmm7 ; xmm6=Y(02468ACE)=YE >+ psrlw xmm7,BYTE_BIT ; xmm7=Y(13579BDF)=YO >+ >+ movdqa xmm1,xmm0 ; xmm1=xmm0=(R-Y)(L/H) >+ movdqa xmm3,xmm2 ; xmm3=xmm2=(G-Y)(L/H) >+ movdqa xmm5,xmm4 ; xmm5=xmm4=(B-Y)(L/H) >+ >+ paddw xmm0,xmm6 ; xmm0=((R-Y)+YE)=RE=R(02468ACE) >+ paddw xmm1,xmm7 ; xmm1=((R-Y)+YO)=RO=R(13579BDF) >+ packuswb xmm0,xmm0 ; xmm0=R(02468ACE********) >+ packuswb xmm1,xmm1 ; xmm1=R(13579BDF********) >+ >+ paddw xmm2,xmm6 ; xmm2=((G-Y)+YE)=GE=G(02468ACE) >+ paddw xmm3,xmm7 ; xmm3=((G-Y)+YO)=GO=G(13579BDF) >+ packuswb xmm2,xmm2 ; xmm2=G(02468ACE********) >+ packuswb xmm3,xmm3 ; xmm3=G(13579BDF********) >+ >+ paddw xmm4,xmm6 ; xmm4=((B-Y)+YE)=BE=B(02468ACE) >+ paddw xmm5,xmm7 ; xmm5=((B-Y)+YO)=BO=B(13579BDF) >+ packuswb xmm4,xmm4 ; xmm4=B(02468ACE********) >+ packuswb xmm5,xmm5 ; xmm5=B(13579BDF********) >+ >+%if RGB_PIXELSIZE == 3 ; --------------- >+ >+ ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **) >+ ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **) >+ ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **) >+ ; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **) >+ >+ punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E) >+ punpcklbw xmmE,xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F) >+ punpcklbw xmmD,xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F) >+ >+ movdqa xmmG,xmmA >+ movdqa xmmH,xmmA >+ punpcklwd xmmA,xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07) >+ punpckhwd xmmG,xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F) >+ >+ psrldq xmmH,2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --) >+ psrldq xmmE,2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --) >+ >+ movdqa xmmC,xmmD >+ movdqa xmmB,xmmD >+ punpcklwd xmmD,xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18) >+ punpckhwd xmmC,xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --) >+ >+ psrldq xmmB,2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --) >+ >+ movdqa xmmF,xmmE >+ punpcklwd xmmE,xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29) >+ punpckhwd xmmF,xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --) >+ >+ pshufd xmmH,xmmA,0x4E; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03) >+ movdqa xmmB,xmmE >+ punpckldq xmmA,xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14) >+ punpckldq xmmE,xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07) >+ punpckhdq xmmD,xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29) >+ >+ pshufd xmmH,xmmG,0x4E; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B) >+ movdqa xmmB,xmmF >+ punpckldq xmmG,xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C) >+ punpckldq xmmF,xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F) >+ punpckhdq xmmC,xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --) >+ >+ punpcklqdq xmmA,xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05) >+ punpcklqdq xmmD,xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) >+ punpcklqdq xmmF,xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F) >+ >+ cmp ecx, byte SIZEOF_XMMWORD >+ jb short .column_st32 >+ >+ test edi, SIZEOF_XMMWORD-1 >+ jnz short .out1 >+ ; --(aligned)------------------- >+ movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA >+ movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD >+ movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmF >+ add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr >+ jmp short .out0 >+.out1: ; --(unaligned)----------------- >+ pcmpeqb xmmH,xmmH ; xmmH=(all 1's) >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [edi], xmmD >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmF,xmmH ; movntdqu XMMWORD [edi], xmmF >+ add edi, byte SIZEOF_XMMWORD ; outptr >+.out0: >+ sub ecx, byte SIZEOF_XMMWORD >+ jz near .endcolumn >+ >+ add esi, byte SIZEOF_XMMWORD ; inptr0 >+ dec al ; Yctr >+ jnz near .Yloop_2nd >+ >+ add ebx, byte SIZEOF_XMMWORD ; inptr1 >+ add edx, byte SIZEOF_XMMWORD ; inptr2 >+ jmp near .columnloop >+ alignx 16,7 >+ >+.column_st32: >+ pcmpeqb xmmH,xmmH ; xmmH=(all 1's) >+ lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE >+ cmp ecx, byte 2*SIZEOF_XMMWORD >+ jb short .column_st16 >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [edi], xmmD >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmF >+ sub ecx, byte 2*SIZEOF_XMMWORD >+ jmp short .column_st15 >+.column_st16: >+ cmp ecx, byte SIZEOF_XMMWORD >+ jb short .column_st15 >+ maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmD >+ sub ecx, byte SIZEOF_XMMWORD >+.column_st15: >+ mov eax,ecx >+ xor ecx, byte 0x0F >+ shl ecx, 2 >+ movd xmmB,ecx >+ psrlq xmmH,4 >+ pcmpeqb xmmE,xmmE >+ psrlq xmmH,xmmB >+ psrlq xmmE,xmmB >+ punpcklbw xmmE,xmmH >+ ; ---------------- >+ mov ecx,edi >+ and ecx, byte SIZEOF_XMMWORD-1 >+ jz short .adj0 >+ add eax,ecx >+ cmp eax, byte SIZEOF_XMMWORD >+ ja short .adj0 >+ and edi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary >+ shl ecx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx >+ movdqa xmmG,xmmA >+ movdqa xmmC,xmmE >+ pslldq xmmA, SIZEOF_XMMWORD/2 >+ pslldq xmmE, SIZEOF_XMMWORD/2 >+ movd xmmD,ecx >+ sub ecx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT >+ jb short .adj1 >+ movd xmmF,ecx >+ psllq xmmA,xmmF >+ psllq xmmE,xmmF >+ jmp short .adj0 >+.adj1: neg ecx >+ movd xmmF,ecx >+ psrlq xmmA,xmmF >+ psrlq xmmE,xmmF >+ psllq xmmG,xmmD >+ psllq xmmC,xmmD >+ por xmmA,xmmG >+ por xmmE,xmmC >+.adj0: ; ---------------- >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ >+%else ; RGB_PIXELSIZE == 4 ; ----------- >+ >+%ifdef RGBX_FILLER_0XFF >+ pcmpeqb xmm6,xmm6 ; xmm6=XE=X(02468ACE********) >+ pcmpeqb xmm7,xmm7 ; xmm7=XO=X(13579BDF********) >+%else >+ pxor xmm6,xmm6 ; xmm6=XE=X(02468ACE********) >+ pxor xmm7,xmm7 ; xmm7=XO=X(13579BDF********) >+%endif >+ ; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **) >+ ; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **) >+ ; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **) >+ ; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **) >+ >+ punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E) >+ punpcklbw xmmE,xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E) >+ punpcklbw xmmB,xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F) >+ punpcklbw xmmF,xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F) >+ >+ movdqa xmmC,xmmA >+ punpcklwd xmmA,xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36) >+ punpckhwd xmmC,xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E) >+ movdqa xmmG,xmmB >+ punpcklwd xmmB,xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37) >+ punpckhwd xmmG,xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F) >+ >+ movdqa xmmD,xmmA >+ punpckldq xmmA,xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33) >+ punpckhdq xmmD,xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37) >+ movdqa xmmH,xmmC >+ punpckldq xmmC,xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B) >+ punpckhdq xmmH,xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F) >+ >+ cmp ecx, byte SIZEOF_XMMWORD >+ jb short .column_st32 >+ >+ test edi, SIZEOF_XMMWORD-1 >+ jnz short .out1 >+ ; --(aligned)------------------- >+ movntdq XMMWORD [edi+0*SIZEOF_XMMWORD], xmmA >+ movntdq XMMWORD [edi+1*SIZEOF_XMMWORD], xmmD >+ movntdq XMMWORD [edi+2*SIZEOF_XMMWORD], xmmC >+ movntdq XMMWORD [edi+3*SIZEOF_XMMWORD], xmmH >+ add edi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr >+ jmp short .out0 >+.out1: ; --(unaligned)----------------- >+ pcmpeqb xmmE,xmmE ; xmmE=(all 1's) >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [edi], xmmD >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmC,xmmE ; movntdqu XMMWORD [edi], xmmC >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmH,xmmE ; movntdqu XMMWORD [edi], xmmH >+ add edi, byte SIZEOF_XMMWORD ; outptr >+.out0: >+ sub ecx, byte SIZEOF_XMMWORD >+ jz near .endcolumn >+ >+ add esi, byte SIZEOF_XMMWORD ; inptr0 >+ dec al ; Yctr >+ jnz near .Yloop_2nd >+ >+ add ebx, byte SIZEOF_XMMWORD ; inptr1 >+ add edx, byte SIZEOF_XMMWORD ; inptr2 >+ jmp near .columnloop >+ alignx 16,7 >+ >+.column_st32: >+ pcmpeqb xmmE,xmmE ; xmmE=(all 1's) >+ cmp ecx, byte SIZEOF_XMMWORD/2 >+ jb short .column_st16 >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [edi], xmmD >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmC >+ movdqa xmmD,xmmH >+ sub ecx, byte SIZEOF_XMMWORD/2 >+.column_st16: >+ cmp ecx, byte SIZEOF_XMMWORD/4 >+ jb short .column_st15 >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ add edi, byte SIZEOF_XMMWORD ; outptr >+ movdqa xmmA,xmmD >+ sub ecx, byte SIZEOF_XMMWORD/4 >+.column_st15: >+ cmp ecx, byte SIZEOF_XMMWORD/16 >+ jb short .endcolumn >+ mov eax,ecx >+ xor ecx, byte 0x03 >+ inc ecx >+ shl ecx, 4 >+ movd xmmF,ecx >+ psrlq xmmE,xmmF >+ punpcklbw xmmE,xmmE >+ ; ---------------- >+ mov ecx,edi >+ and ecx, byte SIZEOF_XMMWORD-1 >+ jz short .adj0 >+ lea eax, [ecx+eax*4] ; RGB_PIXELSIZE >+ cmp eax, byte SIZEOF_XMMWORD >+ ja short .adj0 >+ and edi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary >+ shl ecx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx >+ movdqa xmmB,xmmA >+ movdqa xmmG,xmmE >+ pslldq xmmA, SIZEOF_XMMWORD/2 >+ pslldq xmmE, SIZEOF_XMMWORD/2 >+ movd xmmC,ecx >+ sub ecx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT >+ jb short .adj1 >+ movd xmmH,ecx >+ psllq xmmA,xmmH >+ psllq xmmE,xmmH >+ jmp short .adj0 >+.adj1: neg ecx >+ movd xmmH,ecx >+ psrlq xmmA,xmmH >+ psrlq xmmE,xmmH >+ psllq xmmB,xmmC >+ psllq xmmG,xmmC >+ por xmmA,xmmB >+ por xmmE,xmmG >+.adj0: ; ---------------- >+ maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA >+ >+%endif ; RGB_PIXELSIZE ; --------------- >+ >+.endcolumn: >+ sfence ; flush the write buffer >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. >+; >+; GLOBAL(void) >+; jsimd_h2v2_merged_upsample_sse2 (JDIMENSION output_width, >+; JSAMPIMAGE input_buf, >+; JDIMENSION in_row_group_ctr, >+; JSAMPARRAY output_buf); >+; >+ >+%define output_width(b) (b)+8 ; JDIMENSION output_width >+%define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf >+%define in_row_group_ctr(b) (b)+16 ; JDIMENSION in_row_group_ctr >+%define output_buf(b) (b)+20 ; JSAMPARRAY output_buf >+ >+ align 16 >+ global EXTN(jsimd_h2v2_merged_upsample_sse2) >+ >+EXTN(jsimd_h2v2_merged_upsample_sse2): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov eax, POINTER [output_width(ebp)] >+ >+ mov edi, JSAMPIMAGE [input_buf(ebp)] >+ mov ecx, JDIMENSION [in_row_group_ctr(ebp)] >+ mov esi, JSAMPARRAY [edi+0*SIZEOF_JSAMPARRAY] >+ mov ebx, JSAMPARRAY [edi+1*SIZEOF_JSAMPARRAY] >+ mov edx, JSAMPARRAY [edi+2*SIZEOF_JSAMPARRAY] >+ mov edi, JSAMPARRAY [output_buf(ebp)] >+ lea esi, [esi+ecx*SIZEOF_JSAMPROW] >+ >+ push edx ; inptr2 >+ push ebx ; inptr1 >+ push esi ; inptr00 >+ mov ebx,esp >+ >+ push edi ; output_buf (outptr0) >+ push ecx ; in_row_group_ctr >+ push ebx ; input_buf >+ push eax ; output_width >+ >+ call near EXTN(jsimd_h2v1_merged_upsample_sse2) >+ >+ add esi, byte SIZEOF_JSAMPROW ; inptr01 >+ add edi, byte SIZEOF_JSAMPROW ; outptr1 >+ mov POINTER [ebx+0*SIZEOF_POINTER], esi >+ mov POINTER [ebx-1*SIZEOF_POINTER], edi >+ >+ call near EXTN(jsimd_h2v1_merged_upsample_sse2) >+ >+ add esp, byte 7*SIZEOF_DWORD >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jdsammmx.asm b/modules/libjpeg-turbo/simd/jdsammmx.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdsammmx.asm >@@ -0,0 +1,737 @@ >+; >+; jdsammmx.asm - upsampling (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_fancy_upsample_mmx) >+ >+EXTN(jconst_fancy_upsample_mmx): >+ >+PW_ONE times 4 dw 1 >+PW_TWO times 4 dw 2 >+PW_THREE times 4 dw 3 >+PW_SEVEN times 4 dw 7 >+PW_EIGHT times 4 dw 8 >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. >+; >+; The upsampling algorithm is linear interpolation between pixel centers, >+; also known as a "triangle filter". This is a good compromise between >+; speed and visual quality. The centers of the output pixels are 1/4 and 3/4 >+; of the way between input pixel centers. >+; >+; GLOBAL(void) >+; jsimd_h2v1_fancy_upsample_mmx (int max_v_samp_factor, >+; JDIMENSION downsampled_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+%define max_v_samp(b) (b)+8 ; int max_v_samp_factor >+%define downsamp_width(b) (b)+12 ; JDIMENSION downsampled_width >+%define input_data(b) (b)+16 ; JSAMPARRAY input_data >+%define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr >+ >+ align 16 >+ global EXTN(jsimd_h2v1_fancy_upsample_mmx) >+ >+EXTN(jsimd_h2v1_fancy_upsample_mmx): >+ push ebp >+ mov ebp,esp >+ pushpic ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr >+ test eax,eax >+ jz near .return >+ >+ mov ecx, INT [max_v_samp(ebp)] ; rowctr >+ test ecx,ecx >+ jz near .return >+ >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ mov edi, POINTER [output_data_ptr(ebp)] >+ mov edi, JSAMPARRAY [edi] ; output_data >+ alignx 16,7 >+.rowloop: >+ push eax ; colctr >+ push edi >+ push esi >+ >+ mov esi, JSAMPROW [esi] ; inptr >+ mov edi, JSAMPROW [edi] ; outptr >+ >+ test eax, SIZEOF_MMWORD-1 >+ jz short .skip >+ mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample >+.skip: >+ pxor mm0,mm0 ; mm0=(all 0's) >+ pcmpeqb mm7,mm7 >+ psrlq mm7,(SIZEOF_MMWORD-1)*BYTE_BIT >+ pand mm7, MMWORD [esi+0*SIZEOF_MMWORD] >+ >+ add eax, byte SIZEOF_MMWORD-1 >+ and eax, byte -SIZEOF_MMWORD >+ cmp eax, byte SIZEOF_MMWORD >+ ja short .columnloop >+ alignx 16,7 >+ >+.columnloop_last: >+ pcmpeqb mm6,mm6 >+ psllq mm6,(SIZEOF_MMWORD-1)*BYTE_BIT >+ pand mm6, MMWORD [esi+0*SIZEOF_MMWORD] >+ jmp short .upsample >+ alignx 16,7 >+ >+.columnloop: >+ movq mm6, MMWORD [esi+1*SIZEOF_MMWORD] >+ psllq mm6,(SIZEOF_MMWORD-1)*BYTE_BIT >+ >+.upsample: >+ movq mm1, MMWORD [esi+0*SIZEOF_MMWORD] >+ movq mm2,mm1 >+ movq mm3,mm1 ; mm1=( 0 1 2 3 4 5 6 7) >+ psllq mm2,BYTE_BIT ; mm2=( - 0 1 2 3 4 5 6) >+ psrlq mm3,BYTE_BIT ; mm3=( 1 2 3 4 5 6 7 -) >+ >+ por mm2,mm7 ; mm2=(-1 0 1 2 3 4 5 6) >+ por mm3,mm6 ; mm3=( 1 2 3 4 5 6 7 8) >+ >+ movq mm7,mm1 >+ psrlq mm7,(SIZEOF_MMWORD-1)*BYTE_BIT ; mm7=( 7 - - - - - - -) >+ >+ movq mm4,mm1 >+ punpcklbw mm1,mm0 ; mm1=( 0 1 2 3) >+ punpckhbw mm4,mm0 ; mm4=( 4 5 6 7) >+ movq mm5,mm2 >+ punpcklbw mm2,mm0 ; mm2=(-1 0 1 2) >+ punpckhbw mm5,mm0 ; mm5=( 3 4 5 6) >+ movq mm6,mm3 >+ punpcklbw mm3,mm0 ; mm3=( 1 2 3 4) >+ punpckhbw mm6,mm0 ; mm6=( 5 6 7 8) >+ >+ pmullw mm1,[GOTOFF(ebx,PW_THREE)] >+ pmullw mm4,[GOTOFF(ebx,PW_THREE)] >+ paddw mm2,[GOTOFF(ebx,PW_ONE)] >+ paddw mm5,[GOTOFF(ebx,PW_ONE)] >+ paddw mm3,[GOTOFF(ebx,PW_TWO)] >+ paddw mm6,[GOTOFF(ebx,PW_TWO)] >+ >+ paddw mm2,mm1 >+ paddw mm5,mm4 >+ psrlw mm2,2 ; mm2=OutLE=( 0 2 4 6) >+ psrlw mm5,2 ; mm5=OutHE=( 8 10 12 14) >+ paddw mm3,mm1 >+ paddw mm6,mm4 >+ psrlw mm3,2 ; mm3=OutLO=( 1 3 5 7) >+ psrlw mm6,2 ; mm6=OutHO=( 9 11 13 15) >+ >+ psllw mm3,BYTE_BIT >+ psllw mm6,BYTE_BIT >+ por mm2,mm3 ; mm2=OutL=( 0 1 2 3 4 5 6 7) >+ por mm5,mm6 ; mm5=OutH=( 8 9 10 11 12 13 14 15) >+ >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mm2 >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mm5 >+ >+ sub eax, byte SIZEOF_MMWORD >+ add esi, byte 1*SIZEOF_MMWORD ; inptr >+ add edi, byte 2*SIZEOF_MMWORD ; outptr >+ cmp eax, byte SIZEOF_MMWORD >+ ja near .columnloop >+ test eax,eax >+ jnz near .columnloop_last >+ >+ pop esi >+ pop edi >+ pop eax >+ >+ add esi, byte SIZEOF_JSAMPROW ; input_data >+ add edi, byte SIZEOF_JSAMPROW ; output_data >+ dec ecx ; rowctr >+ jg near .rowloop >+ >+ emms ; empty MMX state >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ poppic ebx >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. >+; Again a triangle filter; see comments for h2v1 case, above. >+; >+; GLOBAL(void) >+; jsimd_h2v2_fancy_upsample_mmx (int max_v_samp_factor, >+; JDIMENSION downsampled_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+%define max_v_samp(b) (b)+8 ; int max_v_samp_factor >+%define downsamp_width(b) (b)+12 ; JDIMENSION downsampled_width >+%define input_data(b) (b)+16 ; JSAMPARRAY input_data >+%define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 4 >+%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr >+ >+ align 16 >+ global EXTN(jsimd_h2v2_fancy_upsample_mmx) >+ >+EXTN(jsimd_h2v2_fancy_upsample_mmx): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic eax ; make a room for GOT address >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ movpic POINTER [gotptr], ebx ; save GOT address >+ >+ mov edx,eax ; edx = original ebp >+ mov eax, JDIMENSION [downsamp_width(edx)] ; colctr >+ test eax,eax >+ jz near .return >+ >+ mov ecx, INT [max_v_samp(edx)] ; rowctr >+ test ecx,ecx >+ jz near .return >+ >+ mov esi, JSAMPARRAY [input_data(edx)] ; input_data >+ mov edi, POINTER [output_data_ptr(edx)] >+ mov edi, JSAMPARRAY [edi] ; output_data >+ alignx 16,7 >+.rowloop: >+ push eax ; colctr >+ push ecx >+ push edi >+ push esi >+ >+ mov ecx, JSAMPROW [esi-1*SIZEOF_JSAMPROW] ; inptr1(above) >+ mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0 >+ mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1(below) >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0 >+ mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1 >+ >+ test eax, SIZEOF_MMWORD-1 >+ jz short .skip >+ push edx >+ mov dl, JSAMPLE [ecx+(eax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [ecx+eax*SIZEOF_JSAMPLE], dl >+ mov dl, JSAMPLE [ebx+(eax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [ebx+eax*SIZEOF_JSAMPLE], dl >+ mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample >+ pop edx >+.skip: >+ ; -- process the first column block >+ >+ movq mm0, MMWORD [ebx+0*SIZEOF_MMWORD] ; mm0=row[ 0][0] >+ movq mm1, MMWORD [ecx+0*SIZEOF_MMWORD] ; mm1=row[-1][0] >+ movq mm2, MMWORD [esi+0*SIZEOF_MMWORD] ; mm2=row[+1][0] >+ >+ pushpic ebx >+ movpic ebx, POINTER [gotptr] ; load GOT address >+ >+ pxor mm3,mm3 ; mm3=(all 0's) >+ movq mm4,mm0 >+ punpcklbw mm0,mm3 ; mm0=row[ 0][0]( 0 1 2 3) >+ punpckhbw mm4,mm3 ; mm4=row[ 0][0]( 4 5 6 7) >+ movq mm5,mm1 >+ punpcklbw mm1,mm3 ; mm1=row[-1][0]( 0 1 2 3) >+ punpckhbw mm5,mm3 ; mm5=row[-1][0]( 4 5 6 7) >+ movq mm6,mm2 >+ punpcklbw mm2,mm3 ; mm2=row[+1][0]( 0 1 2 3) >+ punpckhbw mm6,mm3 ; mm6=row[+1][0]( 4 5 6 7) >+ >+ pmullw mm0,[GOTOFF(ebx,PW_THREE)] >+ pmullw mm4,[GOTOFF(ebx,PW_THREE)] >+ >+ pcmpeqb mm7,mm7 >+ psrlq mm7,(SIZEOF_MMWORD-2)*BYTE_BIT >+ >+ paddw mm1,mm0 ; mm1=Int0L=( 0 1 2 3) >+ paddw mm5,mm4 ; mm5=Int0H=( 4 5 6 7) >+ paddw mm2,mm0 ; mm2=Int1L=( 0 1 2 3) >+ paddw mm6,mm4 ; mm6=Int1H=( 4 5 6 7) >+ >+ movq MMWORD [edx+0*SIZEOF_MMWORD], mm1 ; temporarily save >+ movq MMWORD [edx+1*SIZEOF_MMWORD], mm5 ; the intermediate data >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mm2 >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mm6 >+ >+ pand mm1,mm7 ; mm1=( 0 - - -) >+ pand mm2,mm7 ; mm2=( 0 - - -) >+ >+ movq MMWORD [wk(0)], mm1 >+ movq MMWORD [wk(1)], mm2 >+ >+ poppic ebx >+ >+ add eax, byte SIZEOF_MMWORD-1 >+ and eax, byte -SIZEOF_MMWORD >+ cmp eax, byte SIZEOF_MMWORD >+ ja short .columnloop >+ alignx 16,7 >+ >+.columnloop_last: >+ ; -- process the last column block >+ >+ pushpic ebx >+ movpic ebx, POINTER [gotptr] ; load GOT address >+ >+ pcmpeqb mm1,mm1 >+ psllq mm1,(SIZEOF_MMWORD-2)*BYTE_BIT >+ movq mm2,mm1 >+ >+ pand mm1, MMWORD [edx+1*SIZEOF_MMWORD] ; mm1=( - - - 7) >+ pand mm2, MMWORD [edi+1*SIZEOF_MMWORD] ; mm2=( - - - 7) >+ >+ movq MMWORD [wk(2)], mm1 >+ movq MMWORD [wk(3)], mm2 >+ >+ jmp short .upsample >+ alignx 16,7 >+ >+.columnloop: >+ ; -- process the next column block >+ >+ movq mm0, MMWORD [ebx+1*SIZEOF_MMWORD] ; mm0=row[ 0][1] >+ movq mm1, MMWORD [ecx+1*SIZEOF_MMWORD] ; mm1=row[-1][1] >+ movq mm2, MMWORD [esi+1*SIZEOF_MMWORD] ; mm2=row[+1][1] >+ >+ pushpic ebx >+ movpic ebx, POINTER [gotptr] ; load GOT address >+ >+ pxor mm3,mm3 ; mm3=(all 0's) >+ movq mm4,mm0 >+ punpcklbw mm0,mm3 ; mm0=row[ 0][1]( 0 1 2 3) >+ punpckhbw mm4,mm3 ; mm4=row[ 0][1]( 4 5 6 7) >+ movq mm5,mm1 >+ punpcklbw mm1,mm3 ; mm1=row[-1][1]( 0 1 2 3) >+ punpckhbw mm5,mm3 ; mm5=row[-1][1]( 4 5 6 7) >+ movq mm6,mm2 >+ punpcklbw mm2,mm3 ; mm2=row[+1][1]( 0 1 2 3) >+ punpckhbw mm6,mm3 ; mm6=row[+1][1]( 4 5 6 7) >+ >+ pmullw mm0,[GOTOFF(ebx,PW_THREE)] >+ pmullw mm4,[GOTOFF(ebx,PW_THREE)] >+ >+ paddw mm1,mm0 ; mm1=Int0L=( 0 1 2 3) >+ paddw mm5,mm4 ; mm5=Int0H=( 4 5 6 7) >+ paddw mm2,mm0 ; mm2=Int1L=( 0 1 2 3) >+ paddw mm6,mm4 ; mm6=Int1H=( 4 5 6 7) >+ >+ movq MMWORD [edx+2*SIZEOF_MMWORD], mm1 ; temporarily save >+ movq MMWORD [edx+3*SIZEOF_MMWORD], mm5 ; the intermediate data >+ movq MMWORD [edi+2*SIZEOF_MMWORD], mm2 >+ movq MMWORD [edi+3*SIZEOF_MMWORD], mm6 >+ >+ psllq mm1,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm1=( - - - 0) >+ psllq mm2,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm2=( - - - 0) >+ >+ movq MMWORD [wk(2)], mm1 >+ movq MMWORD [wk(3)], mm2 >+ >+.upsample: >+ ; -- process the upper row >+ >+ movq mm7, MMWORD [edx+0*SIZEOF_MMWORD] ; mm7=Int0L=( 0 1 2 3) >+ movq mm3, MMWORD [edx+1*SIZEOF_MMWORD] ; mm3=Int0H=( 4 5 6 7) >+ >+ movq mm0,mm7 >+ movq mm4,mm3 >+ psrlq mm0,2*BYTE_BIT ; mm0=( 1 2 3 -) >+ psllq mm4,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm4=( - - - 4) >+ movq mm5,mm7 >+ movq mm6,mm3 >+ psrlq mm5,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm5=( 3 - - -) >+ psllq mm6,2*BYTE_BIT ; mm6=( - 4 5 6) >+ >+ por mm0,mm4 ; mm0=( 1 2 3 4) >+ por mm5,mm6 ; mm5=( 3 4 5 6) >+ >+ movq mm1,mm7 >+ movq mm2,mm3 >+ psllq mm1,2*BYTE_BIT ; mm1=( - 0 1 2) >+ psrlq mm2,2*BYTE_BIT ; mm2=( 5 6 7 -) >+ movq mm4,mm3 >+ psrlq mm4,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm4=( 7 - - -) >+ >+ por mm1, MMWORD [wk(0)] ; mm1=(-1 0 1 2) >+ por mm2, MMWORD [wk(2)] ; mm2=( 5 6 7 8) >+ >+ movq MMWORD [wk(0)], mm4 >+ >+ pmullw mm7,[GOTOFF(ebx,PW_THREE)] >+ pmullw mm3,[GOTOFF(ebx,PW_THREE)] >+ paddw mm1,[GOTOFF(ebx,PW_EIGHT)] >+ paddw mm5,[GOTOFF(ebx,PW_EIGHT)] >+ paddw mm0,[GOTOFF(ebx,PW_SEVEN)] >+ paddw mm2,[GOTOFF(ebx,PW_SEVEN)] >+ >+ paddw mm1,mm7 >+ paddw mm5,mm3 >+ psrlw mm1,4 ; mm1=Out0LE=( 0 2 4 6) >+ psrlw mm5,4 ; mm5=Out0HE=( 8 10 12 14) >+ paddw mm0,mm7 >+ paddw mm2,mm3 >+ psrlw mm0,4 ; mm0=Out0LO=( 1 3 5 7) >+ psrlw mm2,4 ; mm2=Out0HO=( 9 11 13 15) >+ >+ psllw mm0,BYTE_BIT >+ psllw mm2,BYTE_BIT >+ por mm1,mm0 ; mm1=Out0L=( 0 1 2 3 4 5 6 7) >+ por mm5,mm2 ; mm5=Out0H=( 8 9 10 11 12 13 14 15) >+ >+ movq MMWORD [edx+0*SIZEOF_MMWORD], mm1 >+ movq MMWORD [edx+1*SIZEOF_MMWORD], mm5 >+ >+ ; -- process the lower row >+ >+ movq mm6, MMWORD [edi+0*SIZEOF_MMWORD] ; mm6=Int1L=( 0 1 2 3) >+ movq mm4, MMWORD [edi+1*SIZEOF_MMWORD] ; mm4=Int1H=( 4 5 6 7) >+ >+ movq mm7,mm6 >+ movq mm3,mm4 >+ psrlq mm7,2*BYTE_BIT ; mm7=( 1 2 3 -) >+ psllq mm3,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm3=( - - - 4) >+ movq mm0,mm6 >+ movq mm2,mm4 >+ psrlq mm0,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm0=( 3 - - -) >+ psllq mm2,2*BYTE_BIT ; mm2=( - 4 5 6) >+ >+ por mm7,mm3 ; mm7=( 1 2 3 4) >+ por mm0,mm2 ; mm0=( 3 4 5 6) >+ >+ movq mm1,mm6 >+ movq mm5,mm4 >+ psllq mm1,2*BYTE_BIT ; mm1=( - 0 1 2) >+ psrlq mm5,2*BYTE_BIT ; mm5=( 5 6 7 -) >+ movq mm3,mm4 >+ psrlq mm3,(SIZEOF_MMWORD-2)*BYTE_BIT ; mm3=( 7 - - -) >+ >+ por mm1, MMWORD [wk(1)] ; mm1=(-1 0 1 2) >+ por mm5, MMWORD [wk(3)] ; mm5=( 5 6 7 8) >+ >+ movq MMWORD [wk(1)], mm3 >+ >+ pmullw mm6,[GOTOFF(ebx,PW_THREE)] >+ pmullw mm4,[GOTOFF(ebx,PW_THREE)] >+ paddw mm1,[GOTOFF(ebx,PW_EIGHT)] >+ paddw mm0,[GOTOFF(ebx,PW_EIGHT)] >+ paddw mm7,[GOTOFF(ebx,PW_SEVEN)] >+ paddw mm5,[GOTOFF(ebx,PW_SEVEN)] >+ >+ paddw mm1,mm6 >+ paddw mm0,mm4 >+ psrlw mm1,4 ; mm1=Out1LE=( 0 2 4 6) >+ psrlw mm0,4 ; mm0=Out1HE=( 8 10 12 14) >+ paddw mm7,mm6 >+ paddw mm5,mm4 >+ psrlw mm7,4 ; mm7=Out1LO=( 1 3 5 7) >+ psrlw mm5,4 ; mm5=Out1HO=( 9 11 13 15) >+ >+ psllw mm7,BYTE_BIT >+ psllw mm5,BYTE_BIT >+ por mm1,mm7 ; mm1=Out1L=( 0 1 2 3 4 5 6 7) >+ por mm0,mm5 ; mm0=Out1H=( 8 9 10 11 12 13 14 15) >+ >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mm1 >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mm0 >+ >+ poppic ebx >+ >+ sub eax, byte SIZEOF_MMWORD >+ add ecx, byte 1*SIZEOF_MMWORD ; inptr1(above) >+ add ebx, byte 1*SIZEOF_MMWORD ; inptr0 >+ add esi, byte 1*SIZEOF_MMWORD ; inptr1(below) >+ add edx, byte 2*SIZEOF_MMWORD ; outptr0 >+ add edi, byte 2*SIZEOF_MMWORD ; outptr1 >+ cmp eax, byte SIZEOF_MMWORD >+ ja near .columnloop >+ test eax,eax >+ jnz near .columnloop_last >+ >+ pop esi >+ pop edi >+ pop ecx >+ pop eax >+ >+ add esi, byte 1*SIZEOF_JSAMPROW ; input_data >+ add edi, byte 2*SIZEOF_JSAMPROW ; output_data >+ sub ecx, byte 2 ; rowctr >+ jg near .rowloop >+ >+ emms ; empty MMX state >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Fast processing for the common case of 2:1 horizontal and 1:1 vertical. >+; It's still a box filter. >+; >+; GLOBAL(void) >+; jsimd_h2v1_upsample_mmx (int max_v_samp_factor, >+; JDIMENSION output_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+%define max_v_samp(b) (b)+8 ; int max_v_samp_factor >+%define output_width(b) (b)+12 ; JDIMENSION output_width >+%define input_data(b) (b)+16 ; JSAMPARRAY input_data >+%define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr >+ >+ align 16 >+ global EXTN(jsimd_h2v1_upsample_mmx) >+ >+EXTN(jsimd_h2v1_upsample_mmx): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov edx, JDIMENSION [output_width(ebp)] >+ add edx, byte (2*SIZEOF_MMWORD)-1 >+ and edx, byte -(2*SIZEOF_MMWORD) >+ jz short .return >+ >+ mov ecx, INT [max_v_samp(ebp)] ; rowctr >+ test ecx,ecx >+ jz short .return >+ >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ mov edi, POINTER [output_data_ptr(ebp)] >+ mov edi, JSAMPARRAY [edi] ; output_data >+ alignx 16,7 >+.rowloop: >+ push edi >+ push esi >+ >+ mov esi, JSAMPROW [esi] ; inptr >+ mov edi, JSAMPROW [edi] ; outptr >+ mov eax,edx ; colctr >+ alignx 16,7 >+.columnloop: >+ >+ movq mm0, MMWORD [esi+0*SIZEOF_MMWORD] >+ >+ movq mm1,mm0 >+ punpcklbw mm0,mm0 >+ punpckhbw mm1,mm1 >+ >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mm0 >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mm1 >+ >+ sub eax, byte 2*SIZEOF_MMWORD >+ jz short .nextrow >+ >+ movq mm2, MMWORD [esi+1*SIZEOF_MMWORD] >+ >+ movq mm3,mm2 >+ punpcklbw mm2,mm2 >+ punpckhbw mm3,mm3 >+ >+ movq MMWORD [edi+2*SIZEOF_MMWORD], mm2 >+ movq MMWORD [edi+3*SIZEOF_MMWORD], mm3 >+ >+ sub eax, byte 2*SIZEOF_MMWORD >+ jz short .nextrow >+ >+ add esi, byte 2*SIZEOF_MMWORD ; inptr >+ add edi, byte 4*SIZEOF_MMWORD ; outptr >+ jmp short .columnloop >+ alignx 16,7 >+ >+.nextrow: >+ pop esi >+ pop edi >+ >+ add esi, byte SIZEOF_JSAMPROW ; input_data >+ add edi, byte SIZEOF_JSAMPROW ; output_data >+ dec ecx ; rowctr >+ jg short .rowloop >+ >+ emms ; empty MMX state >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Fast processing for the common case of 2:1 horizontal and 2:1 vertical. >+; It's still a box filter. >+; >+; GLOBAL(void) >+; jsimd_h2v2_upsample_mmx (int max_v_samp_factor, >+; JDIMENSION output_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+%define max_v_samp(b) (b)+8 ; int max_v_samp_factor >+%define output_width(b) (b)+12 ; JDIMENSION output_width >+%define input_data(b) (b)+16 ; JSAMPARRAY input_data >+%define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr >+ >+ align 16 >+ global EXTN(jsimd_h2v2_upsample_mmx) >+ >+EXTN(jsimd_h2v2_upsample_mmx): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov edx, JDIMENSION [output_width(ebp)] >+ add edx, byte (2*SIZEOF_MMWORD)-1 >+ and edx, byte -(2*SIZEOF_MMWORD) >+ jz near .return >+ >+ mov ecx, INT [max_v_samp(ebp)] ; rowctr >+ test ecx,ecx >+ jz short .return >+ >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ mov edi, POINTER [output_data_ptr(ebp)] >+ mov edi, JSAMPARRAY [edi] ; output_data >+ alignx 16,7 >+.rowloop: >+ push edi >+ push esi >+ >+ mov esi, JSAMPROW [esi] ; inptr >+ mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0 >+ mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1 >+ mov eax,edx ; colctr >+ alignx 16,7 >+.columnloop: >+ >+ movq mm0, MMWORD [esi+0*SIZEOF_MMWORD] >+ >+ movq mm1,mm0 >+ punpcklbw mm0,mm0 >+ punpckhbw mm1,mm1 >+ >+ movq MMWORD [ebx+0*SIZEOF_MMWORD], mm0 >+ movq MMWORD [ebx+1*SIZEOF_MMWORD], mm1 >+ movq MMWORD [edi+0*SIZEOF_MMWORD], mm0 >+ movq MMWORD [edi+1*SIZEOF_MMWORD], mm1 >+ >+ sub eax, byte 2*SIZEOF_MMWORD >+ jz short .nextrow >+ >+ movq mm2, MMWORD [esi+1*SIZEOF_MMWORD] >+ >+ movq mm3,mm2 >+ punpcklbw mm2,mm2 >+ punpckhbw mm3,mm3 >+ >+ movq MMWORD [ebx+2*SIZEOF_MMWORD], mm2 >+ movq MMWORD [ebx+3*SIZEOF_MMWORD], mm3 >+ movq MMWORD [edi+2*SIZEOF_MMWORD], mm2 >+ movq MMWORD [edi+3*SIZEOF_MMWORD], mm3 >+ >+ sub eax, byte 2*SIZEOF_MMWORD >+ jz short .nextrow >+ >+ add esi, byte 2*SIZEOF_MMWORD ; inptr >+ add ebx, byte 4*SIZEOF_MMWORD ; outptr0 >+ add edi, byte 4*SIZEOF_MMWORD ; outptr1 >+ jmp short .columnloop >+ alignx 16,7 >+ >+.nextrow: >+ pop esi >+ pop edi >+ >+ add esi, byte 1*SIZEOF_JSAMPROW ; input_data >+ add edi, byte 2*SIZEOF_JSAMPROW ; output_data >+ sub ecx, byte 2 ; rowctr >+ jg short .rowloop >+ >+ emms ; empty MMX state >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jdsamss2-64.asm b/modules/libjpeg-turbo/simd/jdsamss2-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdsamss2-64.asm >@@ -0,0 +1,671 @@ >+; >+; jdsamss2-64.asm - upsampling (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_fancy_upsample_sse2) >+ >+EXTN(jconst_fancy_upsample_sse2): >+ >+PW_ONE times 8 dw 1 >+PW_TWO times 8 dw 2 >+PW_THREE times 8 dw 3 >+PW_SEVEN times 8 dw 7 >+PW_EIGHT times 8 dw 8 >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. >+; >+; The upsampling algorithm is linear interpolation between pixel centers, >+; also known as a "triangle filter". This is a good compromise between >+; speed and visual quality. The centers of the output pixels are 1/4 and 3/4 >+; of the way between input pixel centers. >+; >+; GLOBAL(void) >+; jsimd_h2v1_fancy_upsample_sse2 (int max_v_samp_factor, >+; JDIMENSION downsampled_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+; r10 = int max_v_samp_factor >+; r11 = JDIMENSION downsampled_width >+; r12 = JSAMPARRAY input_data >+; r13 = JSAMPARRAY * output_data_ptr >+ >+ align 16 >+ global EXTN(jsimd_h2v1_fancy_upsample_sse2) >+ >+EXTN(jsimd_h2v1_fancy_upsample_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ >+ mov rax, r11 ; colctr >+ test rax,rax >+ jz near .return >+ >+ mov rcx, r10 ; rowctr >+ test rcx,rcx >+ jz near .return >+ >+ mov rsi, r12 ; input_data >+ mov rdi, r13 >+ mov rdi, JSAMPARRAY [rdi] ; output_data >+.rowloop: >+ push rax ; colctr >+ push rdi >+ push rsi >+ >+ mov rsi, JSAMPROW [rsi] ; inptr >+ mov rdi, JSAMPROW [rdi] ; outptr >+ >+ test rax, SIZEOF_XMMWORD-1 >+ jz short .skip >+ mov dl, JSAMPLE [rsi+(rax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [rsi+rax*SIZEOF_JSAMPLE], dl ; insert a dummy sample >+.skip: >+ pxor xmm0,xmm0 ; xmm0=(all 0's) >+ pcmpeqb xmm7,xmm7 >+ psrldq xmm7,(SIZEOF_XMMWORD-1) >+ pand xmm7, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ >+ add rax, byte SIZEOF_XMMWORD-1 >+ and rax, byte -SIZEOF_XMMWORD >+ cmp rax, byte SIZEOF_XMMWORD >+ ja short .columnloop >+ >+.columnloop_last: >+ pcmpeqb xmm6,xmm6 >+ pslldq xmm6,(SIZEOF_XMMWORD-1) >+ pand xmm6, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ jmp short .upsample >+ >+.columnloop: >+ movdqa xmm6, XMMWORD [rsi+1*SIZEOF_XMMWORD] >+ pslldq xmm6,(SIZEOF_XMMWORD-1) >+ >+.upsample: >+ movdqa xmm1, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ movdqa xmm2,xmm1 >+ movdqa xmm3,xmm1 ; xmm1=( 0 1 2 ... 13 14 15) >+ pslldq xmm2,1 ; xmm2=(-- 0 1 ... 12 13 14) >+ psrldq xmm3,1 ; xmm3=( 1 2 3 ... 14 15 --) >+ >+ por xmm2,xmm7 ; xmm2=(-1 0 1 ... 12 13 14) >+ por xmm3,xmm6 ; xmm3=( 1 2 3 ... 14 15 16) >+ >+ movdqa xmm7,xmm1 >+ psrldq xmm7,(SIZEOF_XMMWORD-1) ; xmm7=(15 -- -- ... -- -- --) >+ >+ movdqa xmm4,xmm1 >+ punpcklbw xmm1,xmm0 ; xmm1=( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm4,xmm0 ; xmm4=( 8 9 10 11 12 13 14 15) >+ movdqa xmm5,xmm2 >+ punpcklbw xmm2,xmm0 ; xmm2=(-1 0 1 2 3 4 5 6) >+ punpckhbw xmm5,xmm0 ; xmm5=( 7 8 9 10 11 12 13 14) >+ movdqa xmm6,xmm3 >+ punpcklbw xmm3,xmm0 ; xmm3=( 1 2 3 4 5 6 7 8) >+ punpckhbw xmm6,xmm0 ; xmm6=( 9 10 11 12 13 14 15 16) >+ >+ pmullw xmm1,[rel PW_THREE] >+ pmullw xmm4,[rel PW_THREE] >+ paddw xmm2,[rel PW_ONE] >+ paddw xmm5,[rel PW_ONE] >+ paddw xmm3,[rel PW_TWO] >+ paddw xmm6,[rel PW_TWO] >+ >+ paddw xmm2,xmm1 >+ paddw xmm5,xmm4 >+ psrlw xmm2,2 ; xmm2=OutLE=( 0 2 4 6 8 10 12 14) >+ psrlw xmm5,2 ; xmm5=OutHE=(16 18 20 22 24 26 28 30) >+ paddw xmm3,xmm1 >+ paddw xmm6,xmm4 >+ psrlw xmm3,2 ; xmm3=OutLO=( 1 3 5 7 9 11 13 15) >+ psrlw xmm6,2 ; xmm6=OutHO=(17 19 21 23 25 27 29 31) >+ >+ psllw xmm3,BYTE_BIT >+ psllw xmm6,BYTE_BIT >+ por xmm2,xmm3 ; xmm2=OutL=( 0 1 2 ... 13 14 15) >+ por xmm5,xmm6 ; xmm5=OutH=(16 17 18 ... 29 30 31) >+ >+ movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm5 >+ >+ sub rax, byte SIZEOF_XMMWORD >+ add rsi, byte 1*SIZEOF_XMMWORD ; inptr >+ add rdi, byte 2*SIZEOF_XMMWORD ; outptr >+ cmp rax, byte SIZEOF_XMMWORD >+ ja near .columnloop >+ test eax,eax >+ jnz near .columnloop_last >+ >+ pop rsi >+ pop rdi >+ pop rax >+ >+ add rsi, byte SIZEOF_JSAMPROW ; input_data >+ add rdi, byte SIZEOF_JSAMPROW ; output_data >+ dec rcx ; rowctr >+ jg near .rowloop >+ >+.return: >+ uncollect_args >+ pop rbp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. >+; Again a triangle filter; see comments for h2v1 case, above. >+; >+; GLOBAL(void) >+; jsimd_h2v2_fancy_upsample_sse2 (int max_v_samp_factor, >+; JDIMENSION downsampled_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+; r10 = int max_v_samp_factor >+; r11 = JDIMENSION downsampled_width >+; r12 = JSAMPARRAY input_data >+; r13 = JSAMPARRAY * output_data_ptr >+ >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 4 >+ >+ align 16 >+ global EXTN(jsimd_h2v2_fancy_upsample_sse2) >+ >+EXTN(jsimd_h2v2_fancy_upsample_sse2): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [wk(0)] >+ collect_args >+ push rbx >+ >+ mov rax, r11 ; colctr >+ test rax,rax >+ jz near .return >+ >+ mov rcx, r10 ; rowctr >+ test rcx,rcx >+ jz near .return >+ >+ mov rsi, r12 ; input_data >+ mov rdi, r13 >+ mov rdi, JSAMPARRAY [rdi] ; output_data >+.rowloop: >+ push rax ; colctr >+ push rcx >+ push rdi >+ push rsi >+ >+ mov rcx, JSAMPROW [rsi-1*SIZEOF_JSAMPROW] ; inptr1(above) >+ mov rbx, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; inptr0 >+ mov rsi, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; inptr1(below) >+ mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] ; outptr0 >+ mov rdi, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] ; outptr1 >+ >+ test rax, SIZEOF_XMMWORD-1 >+ jz short .skip >+ push rdx >+ mov dl, JSAMPLE [rcx+(rax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [rcx+rax*SIZEOF_JSAMPLE], dl >+ mov dl, JSAMPLE [rbx+(rax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [rbx+rax*SIZEOF_JSAMPLE], dl >+ mov dl, JSAMPLE [rsi+(rax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [rsi+rax*SIZEOF_JSAMPLE], dl ; insert a dummy sample >+ pop rdx >+.skip: >+ ; -- process the first column block >+ >+ movdqa xmm0, XMMWORD [rbx+0*SIZEOF_XMMWORD] ; xmm0=row[ 0][0] >+ movdqa xmm1, XMMWORD [rcx+0*SIZEOF_XMMWORD] ; xmm1=row[-1][0] >+ movdqa xmm2, XMMWORD [rsi+0*SIZEOF_XMMWORD] ; xmm2=row[+1][0] >+ >+ pxor xmm3,xmm3 ; xmm3=(all 0's) >+ movdqa xmm4,xmm0 >+ punpcklbw xmm0,xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm4,xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15) >+ movdqa xmm5,xmm1 >+ punpcklbw xmm1,xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm5,xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15) >+ movdqa xmm6,xmm2 >+ punpcklbw xmm2,xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm6,xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15) >+ >+ pmullw xmm0,[rel PW_THREE] >+ pmullw xmm4,[rel PW_THREE] >+ >+ pcmpeqb xmm7,xmm7 >+ psrldq xmm7,(SIZEOF_XMMWORD-2) >+ >+ paddw xmm1,xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7) >+ paddw xmm5,xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15) >+ paddw xmm2,xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7) >+ paddw xmm6,xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15) >+ >+ movdqa XMMWORD [rdx+0*SIZEOF_XMMWORD], xmm1 ; temporarily save >+ movdqa XMMWORD [rdx+1*SIZEOF_XMMWORD], xmm5 ; the intermediate data >+ movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm6 >+ >+ pand xmm1,xmm7 ; xmm1=( 0 -- -- -- -- -- -- --) >+ pand xmm2,xmm7 ; xmm2=( 0 -- -- -- -- -- -- --) >+ >+ movdqa XMMWORD [wk(0)], xmm1 >+ movdqa XMMWORD [wk(1)], xmm2 >+ >+ add rax, byte SIZEOF_XMMWORD-1 >+ and rax, byte -SIZEOF_XMMWORD >+ cmp rax, byte SIZEOF_XMMWORD >+ ja short .columnloop >+ >+.columnloop_last: >+ ; -- process the last column block >+ >+ pcmpeqb xmm1,xmm1 >+ pslldq xmm1,(SIZEOF_XMMWORD-2) >+ movdqa xmm2,xmm1 >+ >+ pand xmm1, XMMWORD [rdx+1*SIZEOF_XMMWORD] >+ pand xmm2, XMMWORD [rdi+1*SIZEOF_XMMWORD] >+ >+ movdqa XMMWORD [wk(2)], xmm1 ; xmm1=(-- -- -- -- -- -- -- 15) >+ movdqa XMMWORD [wk(3)], xmm2 ; xmm2=(-- -- -- -- -- -- -- 15) >+ >+ jmp near .upsample >+ >+.columnloop: >+ ; -- process the next column block >+ >+ movdqa xmm0, XMMWORD [rbx+1*SIZEOF_XMMWORD] ; xmm0=row[ 0][1] >+ movdqa xmm1, XMMWORD [rcx+1*SIZEOF_XMMWORD] ; xmm1=row[-1][1] >+ movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD] ; xmm2=row[+1][1] >+ >+ pxor xmm3,xmm3 ; xmm3=(all 0's) >+ movdqa xmm4,xmm0 >+ punpcklbw xmm0,xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm4,xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15) >+ movdqa xmm5,xmm1 >+ punpcklbw xmm1,xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm5,xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15) >+ movdqa xmm6,xmm2 >+ punpcklbw xmm2,xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm6,xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15) >+ >+ pmullw xmm0,[rel PW_THREE] >+ pmullw xmm4,[rel PW_THREE] >+ >+ paddw xmm1,xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7) >+ paddw xmm5,xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15) >+ paddw xmm2,xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7) >+ paddw xmm6,xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15) >+ >+ movdqa XMMWORD [rdx+2*SIZEOF_XMMWORD], xmm1 ; temporarily save >+ movdqa XMMWORD [rdx+3*SIZEOF_XMMWORD], xmm5 ; the intermediate data >+ movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm6 >+ >+ pslldq xmm1,(SIZEOF_XMMWORD-2) ; xmm1=(-- -- -- -- -- -- -- 0) >+ pslldq xmm2,(SIZEOF_XMMWORD-2) ; xmm2=(-- -- -- -- -- -- -- 0) >+ >+ movdqa XMMWORD [wk(2)], xmm1 >+ movdqa XMMWORD [wk(3)], xmm2 >+ >+.upsample: >+ ; -- process the upper row >+ >+ movdqa xmm7, XMMWORD [rdx+0*SIZEOF_XMMWORD] >+ movdqa xmm3, XMMWORD [rdx+1*SIZEOF_XMMWORD] >+ >+ movdqa xmm0,xmm7 ; xmm7=Int0L=( 0 1 2 3 4 5 6 7) >+ movdqa xmm4,xmm3 ; xmm3=Int0H=( 8 9 10 11 12 13 14 15) >+ psrldq xmm0,2 ; xmm0=( 1 2 3 4 5 6 7 --) >+ pslldq xmm4,(SIZEOF_XMMWORD-2) ; xmm4=(-- -- -- -- -- -- -- 8) >+ movdqa xmm5,xmm7 >+ movdqa xmm6,xmm3 >+ psrldq xmm5,(SIZEOF_XMMWORD-2) ; xmm5=( 7 -- -- -- -- -- -- --) >+ pslldq xmm6,2 ; xmm6=(-- 8 9 10 11 12 13 14) >+ >+ por xmm0,xmm4 ; xmm0=( 1 2 3 4 5 6 7 8) >+ por xmm5,xmm6 ; xmm5=( 7 8 9 10 11 12 13 14) >+ >+ movdqa xmm1,xmm7 >+ movdqa xmm2,xmm3 >+ pslldq xmm1,2 ; xmm1=(-- 0 1 2 3 4 5 6) >+ psrldq xmm2,2 ; xmm2=( 9 10 11 12 13 14 15 --) >+ movdqa xmm4,xmm3 >+ psrldq xmm4,(SIZEOF_XMMWORD-2) ; xmm4=(15 -- -- -- -- -- -- --) >+ >+ por xmm1, XMMWORD [wk(0)] ; xmm1=(-1 0 1 2 3 4 5 6) >+ por xmm2, XMMWORD [wk(2)] ; xmm2=( 9 10 11 12 13 14 15 16) >+ >+ movdqa XMMWORD [wk(0)], xmm4 >+ >+ pmullw xmm7,[rel PW_THREE] >+ pmullw xmm3,[rel PW_THREE] >+ paddw xmm1,[rel PW_EIGHT] >+ paddw xmm5,[rel PW_EIGHT] >+ paddw xmm0,[rel PW_SEVEN] >+ paddw xmm2,[rel PW_SEVEN] >+ >+ paddw xmm1,xmm7 >+ paddw xmm5,xmm3 >+ psrlw xmm1,4 ; xmm1=Out0LE=( 0 2 4 6 8 10 12 14) >+ psrlw xmm5,4 ; xmm5=Out0HE=(16 18 20 22 24 26 28 30) >+ paddw xmm0,xmm7 >+ paddw xmm2,xmm3 >+ psrlw xmm0,4 ; xmm0=Out0LO=( 1 3 5 7 9 11 13 15) >+ psrlw xmm2,4 ; xmm2=Out0HO=(17 19 21 23 25 27 29 31) >+ >+ psllw xmm0,BYTE_BIT >+ psllw xmm2,BYTE_BIT >+ por xmm1,xmm0 ; xmm1=Out0L=( 0 1 2 ... 13 14 15) >+ por xmm5,xmm2 ; xmm5=Out0H=(16 17 18 ... 29 30 31) >+ >+ movdqa XMMWORD [rdx+0*SIZEOF_XMMWORD], xmm1 >+ movdqa XMMWORD [rdx+1*SIZEOF_XMMWORD], xmm5 >+ >+ ; -- process the lower row >+ >+ movdqa xmm6, XMMWORD [rdi+0*SIZEOF_XMMWORD] >+ movdqa xmm4, XMMWORD [rdi+1*SIZEOF_XMMWORD] >+ >+ movdqa xmm7,xmm6 ; xmm6=Int1L=( 0 1 2 3 4 5 6 7) >+ movdqa xmm3,xmm4 ; xmm4=Int1H=( 8 9 10 11 12 13 14 15) >+ psrldq xmm7,2 ; xmm7=( 1 2 3 4 5 6 7 --) >+ pslldq xmm3,(SIZEOF_XMMWORD-2) ; xmm3=(-- -- -- -- -- -- -- 8) >+ movdqa xmm0,xmm6 >+ movdqa xmm2,xmm4 >+ psrldq xmm0,(SIZEOF_XMMWORD-2) ; xmm0=( 7 -- -- -- -- -- -- --) >+ pslldq xmm2,2 ; xmm2=(-- 8 9 10 11 12 13 14) >+ >+ por xmm7,xmm3 ; xmm7=( 1 2 3 4 5 6 7 8) >+ por xmm0,xmm2 ; xmm0=( 7 8 9 10 11 12 13 14) >+ >+ movdqa xmm1,xmm6 >+ movdqa xmm5,xmm4 >+ pslldq xmm1,2 ; xmm1=(-- 0 1 2 3 4 5 6) >+ psrldq xmm5,2 ; xmm5=( 9 10 11 12 13 14 15 --) >+ movdqa xmm3,xmm4 >+ psrldq xmm3,(SIZEOF_XMMWORD-2) ; xmm3=(15 -- -- -- -- -- -- --) >+ >+ por xmm1, XMMWORD [wk(1)] ; xmm1=(-1 0 1 2 3 4 5 6) >+ por xmm5, XMMWORD [wk(3)] ; xmm5=( 9 10 11 12 13 14 15 16) >+ >+ movdqa XMMWORD [wk(1)], xmm3 >+ >+ pmullw xmm6,[rel PW_THREE] >+ pmullw xmm4,[rel PW_THREE] >+ paddw xmm1,[rel PW_EIGHT] >+ paddw xmm0,[rel PW_EIGHT] >+ paddw xmm7,[rel PW_SEVEN] >+ paddw xmm5,[rel PW_SEVEN] >+ >+ paddw xmm1,xmm6 >+ paddw xmm0,xmm4 >+ psrlw xmm1,4 ; xmm1=Out1LE=( 0 2 4 6 8 10 12 14) >+ psrlw xmm0,4 ; xmm0=Out1HE=(16 18 20 22 24 26 28 30) >+ paddw xmm7,xmm6 >+ paddw xmm5,xmm4 >+ psrlw xmm7,4 ; xmm7=Out1LO=( 1 3 5 7 9 11 13 15) >+ psrlw xmm5,4 ; xmm5=Out1HO=(17 19 21 23 25 27 29 31) >+ >+ psllw xmm7,BYTE_BIT >+ psllw xmm5,BYTE_BIT >+ por xmm1,xmm7 ; xmm1=Out1L=( 0 1 2 ... 13 14 15) >+ por xmm0,xmm5 ; xmm0=Out1H=(16 17 18 ... 29 30 31) >+ >+ movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm1 >+ movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm0 >+ >+ sub rax, byte SIZEOF_XMMWORD >+ add rcx, byte 1*SIZEOF_XMMWORD ; inptr1(above) >+ add rbx, byte 1*SIZEOF_XMMWORD ; inptr0 >+ add rsi, byte 1*SIZEOF_XMMWORD ; inptr1(below) >+ add rdx, byte 2*SIZEOF_XMMWORD ; outptr0 >+ add rdi, byte 2*SIZEOF_XMMWORD ; outptr1 >+ cmp rax, byte SIZEOF_XMMWORD >+ ja near .columnloop >+ test rax,rax >+ jnz near .columnloop_last >+ >+ pop rsi >+ pop rdi >+ pop rcx >+ pop rax >+ >+ add rsi, byte 1*SIZEOF_JSAMPROW ; input_data >+ add rdi, byte 2*SIZEOF_JSAMPROW ; output_data >+ sub rcx, byte 2 ; rowctr >+ jg near .rowloop >+ >+.return: >+ pop rbx >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Fast processing for the common case of 2:1 horizontal and 1:1 vertical. >+; It's still a box filter. >+; >+; GLOBAL(void) >+; jsimd_h2v1_upsample_sse2 (int max_v_samp_factor, >+; JDIMENSION output_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+; r10 = int max_v_samp_factor >+; r11 = JDIMENSION output_width >+; r12 = JSAMPARRAY input_data >+; r13 = JSAMPARRAY * output_data_ptr >+ >+ align 16 >+ global EXTN(jsimd_h2v1_upsample_sse2) >+ >+EXTN(jsimd_h2v1_upsample_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ >+ mov rdx, r11 >+ add rdx, byte (2*SIZEOF_XMMWORD)-1 >+ and rdx, byte -(2*SIZEOF_XMMWORD) >+ jz near .return >+ >+ mov rcx, r10 ; rowctr >+ test rcx,rcx >+ jz short .return >+ >+ mov rsi, r12 ; input_data >+ mov rdi, r13 >+ mov rdi, JSAMPARRAY [rdi] ; output_data >+.rowloop: >+ push rdi >+ push rsi >+ >+ mov rsi, JSAMPROW [rsi] ; inptr >+ mov rdi, JSAMPROW [rdi] ; outptr >+ mov rax,rdx ; colctr >+.columnloop: >+ >+ movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ >+ movdqa xmm1,xmm0 >+ punpcklbw xmm0,xmm0 >+ punpckhbw xmm1,xmm1 >+ >+ movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0 >+ movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm1 >+ >+ sub rax, byte 2*SIZEOF_XMMWORD >+ jz short .nextrow >+ >+ movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD] >+ >+ movdqa xmm3,xmm2 >+ punpcklbw xmm2,xmm2 >+ punpckhbw xmm3,xmm3 >+ >+ movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm3 >+ >+ sub rax, byte 2*SIZEOF_XMMWORD >+ jz short .nextrow >+ >+ add rsi, byte 2*SIZEOF_XMMWORD ; inptr >+ add rdi, byte 4*SIZEOF_XMMWORD ; outptr >+ jmp short .columnloop >+ >+.nextrow: >+ pop rsi >+ pop rdi >+ >+ add rsi, byte SIZEOF_JSAMPROW ; input_data >+ add rdi, byte SIZEOF_JSAMPROW ; output_data >+ dec rcx ; rowctr >+ jg short .rowloop >+ >+.return: >+ uncollect_args >+ pop rbp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Fast processing for the common case of 2:1 horizontal and 2:1 vertical. >+; It's still a box filter. >+; >+; GLOBAL(void) >+; jsimd_h2v2_upsample_sse2 (nt max_v_samp_factor, >+; JDIMENSION output_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+; r10 = int max_v_samp_factor >+; r11 = JDIMENSION output_width >+; r12 = JSAMPARRAY input_data >+; r13 = JSAMPARRAY * output_data_ptr >+ >+ align 16 >+ global EXTN(jsimd_h2v2_upsample_sse2) >+ >+EXTN(jsimd_h2v2_upsample_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ push rbx >+ >+ mov rdx, r11 >+ add rdx, byte (2*SIZEOF_XMMWORD)-1 >+ and rdx, byte -(2*SIZEOF_XMMWORD) >+ jz near .return >+ >+ mov rcx, r10 ; rowctr >+ test rcx,rcx >+ jz near .return >+ >+ mov rsi, r12 ; input_data >+ mov rdi, r13 >+ mov rdi, JSAMPARRAY [rdi] ; output_data >+.rowloop: >+ push rdi >+ push rsi >+ >+ mov rsi, JSAMPROW [rsi] ; inptr >+ mov rbx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] ; outptr0 >+ mov rdi, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] ; outptr1 >+ mov rax,rdx ; colctr >+.columnloop: >+ >+ movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD] >+ >+ movdqa xmm1,xmm0 >+ punpcklbw xmm0,xmm0 >+ punpckhbw xmm1,xmm1 >+ >+ movdqa XMMWORD [rbx+0*SIZEOF_XMMWORD], xmm0 >+ movdqa XMMWORD [rbx+1*SIZEOF_XMMWORD], xmm1 >+ movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0 >+ movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm1 >+ >+ sub rax, byte 2*SIZEOF_XMMWORD >+ jz short .nextrow >+ >+ movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD] >+ >+ movdqa xmm3,xmm2 >+ punpcklbw xmm2,xmm2 >+ punpckhbw xmm3,xmm3 >+ >+ movdqa XMMWORD [rbx+2*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [rbx+3*SIZEOF_XMMWORD], xmm3 >+ movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm3 >+ >+ sub rax, byte 2*SIZEOF_XMMWORD >+ jz short .nextrow >+ >+ add rsi, byte 2*SIZEOF_XMMWORD ; inptr >+ add rbx, byte 4*SIZEOF_XMMWORD ; outptr0 >+ add rdi, byte 4*SIZEOF_XMMWORD ; outptr1 >+ jmp short .columnloop >+ >+.nextrow: >+ pop rsi >+ pop rdi >+ >+ add rsi, byte 1*SIZEOF_JSAMPROW ; input_data >+ add rdi, byte 2*SIZEOF_JSAMPROW ; output_data >+ sub rcx, byte 2 ; rowctr >+ jg near .rowloop >+ >+.return: >+ pop rbx >+ uncollect_args >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jdsamss2.asm b/modules/libjpeg-turbo/simd/jdsamss2.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jdsamss2.asm >@@ -0,0 +1,729 @@ >+; >+; jdsamss2.asm - upsampling (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_fancy_upsample_sse2) >+ >+EXTN(jconst_fancy_upsample_sse2): >+ >+PW_ONE times 8 dw 1 >+PW_TWO times 8 dw 2 >+PW_THREE times 8 dw 3 >+PW_SEVEN times 8 dw 7 >+PW_EIGHT times 8 dw 8 >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. >+; >+; The upsampling algorithm is linear interpolation between pixel centers, >+; also known as a "triangle filter". This is a good compromise between >+; speed and visual quality. The centers of the output pixels are 1/4 and 3/4 >+; of the way between input pixel centers. >+; >+; GLOBAL(void) >+; jsimd_h2v1_fancy_upsample_sse2 (int max_v_samp_factor, >+; JDIMENSION downsampled_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+%define max_v_samp(b) (b)+8 ; int max_v_samp_factor >+%define downsamp_width(b) (b)+12 ; JDIMENSION downsampled_width >+%define input_data(b) (b)+16 ; JSAMPARRAY input_data >+%define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr >+ >+ align 16 >+ global EXTN(jsimd_h2v1_fancy_upsample_sse2) >+ >+EXTN(jsimd_h2v1_fancy_upsample_sse2): >+ push ebp >+ mov ebp,esp >+ pushpic ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr >+ test eax,eax >+ jz near .return >+ >+ mov ecx, INT [max_v_samp(ebp)] ; rowctr >+ test ecx,ecx >+ jz near .return >+ >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ mov edi, POINTER [output_data_ptr(ebp)] >+ mov edi, JSAMPARRAY [edi] ; output_data >+ alignx 16,7 >+.rowloop: >+ push eax ; colctr >+ push edi >+ push esi >+ >+ mov esi, JSAMPROW [esi] ; inptr >+ mov edi, JSAMPROW [edi] ; outptr >+ >+ test eax, SIZEOF_XMMWORD-1 >+ jz short .skip >+ mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample >+.skip: >+ pxor xmm0,xmm0 ; xmm0=(all 0's) >+ pcmpeqb xmm7,xmm7 >+ psrldq xmm7,(SIZEOF_XMMWORD-1) >+ pand xmm7, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ >+ add eax, byte SIZEOF_XMMWORD-1 >+ and eax, byte -SIZEOF_XMMWORD >+ cmp eax, byte SIZEOF_XMMWORD >+ ja short .columnloop >+ alignx 16,7 >+ >+.columnloop_last: >+ pcmpeqb xmm6,xmm6 >+ pslldq xmm6,(SIZEOF_XMMWORD-1) >+ pand xmm6, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ jmp short .upsample >+ alignx 16,7 >+ >+.columnloop: >+ movdqa xmm6, XMMWORD [esi+1*SIZEOF_XMMWORD] >+ pslldq xmm6,(SIZEOF_XMMWORD-1) >+ >+.upsample: >+ movdqa xmm1, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ movdqa xmm2,xmm1 >+ movdqa xmm3,xmm1 ; xmm1=( 0 1 2 ... 13 14 15) >+ pslldq xmm2,1 ; xmm2=(-- 0 1 ... 12 13 14) >+ psrldq xmm3,1 ; xmm3=( 1 2 3 ... 14 15 --) >+ >+ por xmm2,xmm7 ; xmm2=(-1 0 1 ... 12 13 14) >+ por xmm3,xmm6 ; xmm3=( 1 2 3 ... 14 15 16) >+ >+ movdqa xmm7,xmm1 >+ psrldq xmm7,(SIZEOF_XMMWORD-1) ; xmm7=(15 -- -- ... -- -- --) >+ >+ movdqa xmm4,xmm1 >+ punpcklbw xmm1,xmm0 ; xmm1=( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm4,xmm0 ; xmm4=( 8 9 10 11 12 13 14 15) >+ movdqa xmm5,xmm2 >+ punpcklbw xmm2,xmm0 ; xmm2=(-1 0 1 2 3 4 5 6) >+ punpckhbw xmm5,xmm0 ; xmm5=( 7 8 9 10 11 12 13 14) >+ movdqa xmm6,xmm3 >+ punpcklbw xmm3,xmm0 ; xmm3=( 1 2 3 4 5 6 7 8) >+ punpckhbw xmm6,xmm0 ; xmm6=( 9 10 11 12 13 14 15 16) >+ >+ pmullw xmm1,[GOTOFF(ebx,PW_THREE)] >+ pmullw xmm4,[GOTOFF(ebx,PW_THREE)] >+ paddw xmm2,[GOTOFF(ebx,PW_ONE)] >+ paddw xmm5,[GOTOFF(ebx,PW_ONE)] >+ paddw xmm3,[GOTOFF(ebx,PW_TWO)] >+ paddw xmm6,[GOTOFF(ebx,PW_TWO)] >+ >+ paddw xmm2,xmm1 >+ paddw xmm5,xmm4 >+ psrlw xmm2,2 ; xmm2=OutLE=( 0 2 4 6 8 10 12 14) >+ psrlw xmm5,2 ; xmm5=OutHE=(16 18 20 22 24 26 28 30) >+ paddw xmm3,xmm1 >+ paddw xmm6,xmm4 >+ psrlw xmm3,2 ; xmm3=OutLO=( 1 3 5 7 9 11 13 15) >+ psrlw xmm6,2 ; xmm6=OutHO=(17 19 21 23 25 27 29 31) >+ >+ psllw xmm3,BYTE_BIT >+ psllw xmm6,BYTE_BIT >+ por xmm2,xmm3 ; xmm2=OutL=( 0 1 2 ... 13 14 15) >+ por xmm5,xmm6 ; xmm5=OutH=(16 17 18 ... 29 30 31) >+ >+ movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm5 >+ >+ sub eax, byte SIZEOF_XMMWORD >+ add esi, byte 1*SIZEOF_XMMWORD ; inptr >+ add edi, byte 2*SIZEOF_XMMWORD ; outptr >+ cmp eax, byte SIZEOF_XMMWORD >+ ja near .columnloop >+ test eax,eax >+ jnz near .columnloop_last >+ >+ pop esi >+ pop edi >+ pop eax >+ >+ add esi, byte SIZEOF_JSAMPROW ; input_data >+ add edi, byte SIZEOF_JSAMPROW ; output_data >+ dec ecx ; rowctr >+ jg near .rowloop >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ poppic ebx >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. >+; Again a triangle filter; see comments for h2v1 case, above. >+; >+; GLOBAL(void) >+; jsimd_h2v2_fancy_upsample_sse2 (int max_v_samp_factor, >+; JDIMENSION downsampled_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+%define max_v_samp(b) (b)+8 ; int max_v_samp_factor >+%define downsamp_width(b) (b)+12 ; JDIMENSION downsampled_width >+%define input_data(b) (b)+16 ; JSAMPARRAY input_data >+%define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 4 >+%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr >+ >+ align 16 >+ global EXTN(jsimd_h2v2_fancy_upsample_sse2) >+ >+EXTN(jsimd_h2v2_fancy_upsample_sse2): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic eax ; make a room for GOT address >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ movpic POINTER [gotptr], ebx ; save GOT address >+ >+ mov edx,eax ; edx = original ebp >+ mov eax, JDIMENSION [downsamp_width(edx)] ; colctr >+ test eax,eax >+ jz near .return >+ >+ mov ecx, INT [max_v_samp(edx)] ; rowctr >+ test ecx,ecx >+ jz near .return >+ >+ mov esi, JSAMPARRAY [input_data(edx)] ; input_data >+ mov edi, POINTER [output_data_ptr(edx)] >+ mov edi, JSAMPARRAY [edi] ; output_data >+ alignx 16,7 >+.rowloop: >+ push eax ; colctr >+ push ecx >+ push edi >+ push esi >+ >+ mov ecx, JSAMPROW [esi-1*SIZEOF_JSAMPROW] ; inptr1(above) >+ mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0 >+ mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1(below) >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0 >+ mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1 >+ >+ test eax, SIZEOF_XMMWORD-1 >+ jz short .skip >+ push edx >+ mov dl, JSAMPLE [ecx+(eax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [ecx+eax*SIZEOF_JSAMPLE], dl >+ mov dl, JSAMPLE [ebx+(eax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [ebx+eax*SIZEOF_JSAMPLE], dl >+ mov dl, JSAMPLE [esi+(eax-1)*SIZEOF_JSAMPLE] >+ mov JSAMPLE [esi+eax*SIZEOF_JSAMPLE], dl ; insert a dummy sample >+ pop edx >+.skip: >+ ; -- process the first column block >+ >+ movdqa xmm0, XMMWORD [ebx+0*SIZEOF_XMMWORD] ; xmm0=row[ 0][0] >+ movdqa xmm1, XMMWORD [ecx+0*SIZEOF_XMMWORD] ; xmm1=row[-1][0] >+ movdqa xmm2, XMMWORD [esi+0*SIZEOF_XMMWORD] ; xmm2=row[+1][0] >+ >+ pushpic ebx >+ movpic ebx, POINTER [gotptr] ; load GOT address >+ >+ pxor xmm3,xmm3 ; xmm3=(all 0's) >+ movdqa xmm4,xmm0 >+ punpcklbw xmm0,xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm4,xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15) >+ movdqa xmm5,xmm1 >+ punpcklbw xmm1,xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm5,xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15) >+ movdqa xmm6,xmm2 >+ punpcklbw xmm2,xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm6,xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15) >+ >+ pmullw xmm0,[GOTOFF(ebx,PW_THREE)] >+ pmullw xmm4,[GOTOFF(ebx,PW_THREE)] >+ >+ pcmpeqb xmm7,xmm7 >+ psrldq xmm7,(SIZEOF_XMMWORD-2) >+ >+ paddw xmm1,xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7) >+ paddw xmm5,xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15) >+ paddw xmm2,xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7) >+ paddw xmm6,xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15) >+ >+ movdqa XMMWORD [edx+0*SIZEOF_XMMWORD], xmm1 ; temporarily save >+ movdqa XMMWORD [edx+1*SIZEOF_XMMWORD], xmm5 ; the intermediate data >+ movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm6 >+ >+ pand xmm1,xmm7 ; xmm1=( 0 -- -- -- -- -- -- --) >+ pand xmm2,xmm7 ; xmm2=( 0 -- -- -- -- -- -- --) >+ >+ movdqa XMMWORD [wk(0)], xmm1 >+ movdqa XMMWORD [wk(1)], xmm2 >+ >+ poppic ebx >+ >+ add eax, byte SIZEOF_XMMWORD-1 >+ and eax, byte -SIZEOF_XMMWORD >+ cmp eax, byte SIZEOF_XMMWORD >+ ja short .columnloop >+ alignx 16,7 >+ >+.columnloop_last: >+ ; -- process the last column block >+ >+ pushpic ebx >+ movpic ebx, POINTER [gotptr] ; load GOT address >+ >+ pcmpeqb xmm1,xmm1 >+ pslldq xmm1,(SIZEOF_XMMWORD-2) >+ movdqa xmm2,xmm1 >+ >+ pand xmm1, XMMWORD [edx+1*SIZEOF_XMMWORD] >+ pand xmm2, XMMWORD [edi+1*SIZEOF_XMMWORD] >+ >+ movdqa XMMWORD [wk(2)], xmm1 ; xmm1=(-- -- -- -- -- -- -- 15) >+ movdqa XMMWORD [wk(3)], xmm2 ; xmm2=(-- -- -- -- -- -- -- 15) >+ >+ jmp near .upsample >+ alignx 16,7 >+ >+.columnloop: >+ ; -- process the next column block >+ >+ movdqa xmm0, XMMWORD [ebx+1*SIZEOF_XMMWORD] ; xmm0=row[ 0][1] >+ movdqa xmm1, XMMWORD [ecx+1*SIZEOF_XMMWORD] ; xmm1=row[-1][1] >+ movdqa xmm2, XMMWORD [esi+1*SIZEOF_XMMWORD] ; xmm2=row[+1][1] >+ >+ pushpic ebx >+ movpic ebx, POINTER [gotptr] ; load GOT address >+ >+ pxor xmm3,xmm3 ; xmm3=(all 0's) >+ movdqa xmm4,xmm0 >+ punpcklbw xmm0,xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm4,xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15) >+ movdqa xmm5,xmm1 >+ punpcklbw xmm1,xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm5,xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15) >+ movdqa xmm6,xmm2 >+ punpcklbw xmm2,xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7) >+ punpckhbw xmm6,xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15) >+ >+ pmullw xmm0,[GOTOFF(ebx,PW_THREE)] >+ pmullw xmm4,[GOTOFF(ebx,PW_THREE)] >+ >+ paddw xmm1,xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7) >+ paddw xmm5,xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15) >+ paddw xmm2,xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7) >+ paddw xmm6,xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15) >+ >+ movdqa XMMWORD [edx+2*SIZEOF_XMMWORD], xmm1 ; temporarily save >+ movdqa XMMWORD [edx+3*SIZEOF_XMMWORD], xmm5 ; the intermediate data >+ movdqa XMMWORD [edi+2*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [edi+3*SIZEOF_XMMWORD], xmm6 >+ >+ pslldq xmm1,(SIZEOF_XMMWORD-2) ; xmm1=(-- -- -- -- -- -- -- 0) >+ pslldq xmm2,(SIZEOF_XMMWORD-2) ; xmm2=(-- -- -- -- -- -- -- 0) >+ >+ movdqa XMMWORD [wk(2)], xmm1 >+ movdqa XMMWORD [wk(3)], xmm2 >+ >+.upsample: >+ ; -- process the upper row >+ >+ movdqa xmm7, XMMWORD [edx+0*SIZEOF_XMMWORD] >+ movdqa xmm3, XMMWORD [edx+1*SIZEOF_XMMWORD] >+ >+ movdqa xmm0,xmm7 ; xmm7=Int0L=( 0 1 2 3 4 5 6 7) >+ movdqa xmm4,xmm3 ; xmm3=Int0H=( 8 9 10 11 12 13 14 15) >+ psrldq xmm0,2 ; xmm0=( 1 2 3 4 5 6 7 --) >+ pslldq xmm4,(SIZEOF_XMMWORD-2) ; xmm4=(-- -- -- -- -- -- -- 8) >+ movdqa xmm5,xmm7 >+ movdqa xmm6,xmm3 >+ psrldq xmm5,(SIZEOF_XMMWORD-2) ; xmm5=( 7 -- -- -- -- -- -- --) >+ pslldq xmm6,2 ; xmm6=(-- 8 9 10 11 12 13 14) >+ >+ por xmm0,xmm4 ; xmm0=( 1 2 3 4 5 6 7 8) >+ por xmm5,xmm6 ; xmm5=( 7 8 9 10 11 12 13 14) >+ >+ movdqa xmm1,xmm7 >+ movdqa xmm2,xmm3 >+ pslldq xmm1,2 ; xmm1=(-- 0 1 2 3 4 5 6) >+ psrldq xmm2,2 ; xmm2=( 9 10 11 12 13 14 15 --) >+ movdqa xmm4,xmm3 >+ psrldq xmm4,(SIZEOF_XMMWORD-2) ; xmm4=(15 -- -- -- -- -- -- --) >+ >+ por xmm1, XMMWORD [wk(0)] ; xmm1=(-1 0 1 2 3 4 5 6) >+ por xmm2, XMMWORD [wk(2)] ; xmm2=( 9 10 11 12 13 14 15 16) >+ >+ movdqa XMMWORD [wk(0)], xmm4 >+ >+ pmullw xmm7,[GOTOFF(ebx,PW_THREE)] >+ pmullw xmm3,[GOTOFF(ebx,PW_THREE)] >+ paddw xmm1,[GOTOFF(ebx,PW_EIGHT)] >+ paddw xmm5,[GOTOFF(ebx,PW_EIGHT)] >+ paddw xmm0,[GOTOFF(ebx,PW_SEVEN)] >+ paddw xmm2,[GOTOFF(ebx,PW_SEVEN)] >+ >+ paddw xmm1,xmm7 >+ paddw xmm5,xmm3 >+ psrlw xmm1,4 ; xmm1=Out0LE=( 0 2 4 6 8 10 12 14) >+ psrlw xmm5,4 ; xmm5=Out0HE=(16 18 20 22 24 26 28 30) >+ paddw xmm0,xmm7 >+ paddw xmm2,xmm3 >+ psrlw xmm0,4 ; xmm0=Out0LO=( 1 3 5 7 9 11 13 15) >+ psrlw xmm2,4 ; xmm2=Out0HO=(17 19 21 23 25 27 29 31) >+ >+ psllw xmm0,BYTE_BIT >+ psllw xmm2,BYTE_BIT >+ por xmm1,xmm0 ; xmm1=Out0L=( 0 1 2 ... 13 14 15) >+ por xmm5,xmm2 ; xmm5=Out0H=(16 17 18 ... 29 30 31) >+ >+ movdqa XMMWORD [edx+0*SIZEOF_XMMWORD], xmm1 >+ movdqa XMMWORD [edx+1*SIZEOF_XMMWORD], xmm5 >+ >+ ; -- process the lower row >+ >+ movdqa xmm6, XMMWORD [edi+0*SIZEOF_XMMWORD] >+ movdqa xmm4, XMMWORD [edi+1*SIZEOF_XMMWORD] >+ >+ movdqa xmm7,xmm6 ; xmm6=Int1L=( 0 1 2 3 4 5 6 7) >+ movdqa xmm3,xmm4 ; xmm4=Int1H=( 8 9 10 11 12 13 14 15) >+ psrldq xmm7,2 ; xmm7=( 1 2 3 4 5 6 7 --) >+ pslldq xmm3,(SIZEOF_XMMWORD-2) ; xmm3=(-- -- -- -- -- -- -- 8) >+ movdqa xmm0,xmm6 >+ movdqa xmm2,xmm4 >+ psrldq xmm0,(SIZEOF_XMMWORD-2) ; xmm0=( 7 -- -- -- -- -- -- --) >+ pslldq xmm2,2 ; xmm2=(-- 8 9 10 11 12 13 14) >+ >+ por xmm7,xmm3 ; xmm7=( 1 2 3 4 5 6 7 8) >+ por xmm0,xmm2 ; xmm0=( 7 8 9 10 11 12 13 14) >+ >+ movdqa xmm1,xmm6 >+ movdqa xmm5,xmm4 >+ pslldq xmm1,2 ; xmm1=(-- 0 1 2 3 4 5 6) >+ psrldq xmm5,2 ; xmm5=( 9 10 11 12 13 14 15 --) >+ movdqa xmm3,xmm4 >+ psrldq xmm3,(SIZEOF_XMMWORD-2) ; xmm3=(15 -- -- -- -- -- -- --) >+ >+ por xmm1, XMMWORD [wk(1)] ; xmm1=(-1 0 1 2 3 4 5 6) >+ por xmm5, XMMWORD [wk(3)] ; xmm5=( 9 10 11 12 13 14 15 16) >+ >+ movdqa XMMWORD [wk(1)], xmm3 >+ >+ pmullw xmm6,[GOTOFF(ebx,PW_THREE)] >+ pmullw xmm4,[GOTOFF(ebx,PW_THREE)] >+ paddw xmm1,[GOTOFF(ebx,PW_EIGHT)] >+ paddw xmm0,[GOTOFF(ebx,PW_EIGHT)] >+ paddw xmm7,[GOTOFF(ebx,PW_SEVEN)] >+ paddw xmm5,[GOTOFF(ebx,PW_SEVEN)] >+ >+ paddw xmm1,xmm6 >+ paddw xmm0,xmm4 >+ psrlw xmm1,4 ; xmm1=Out1LE=( 0 2 4 6 8 10 12 14) >+ psrlw xmm0,4 ; xmm0=Out1HE=(16 18 20 22 24 26 28 30) >+ paddw xmm7,xmm6 >+ paddw xmm5,xmm4 >+ psrlw xmm7,4 ; xmm7=Out1LO=( 1 3 5 7 9 11 13 15) >+ psrlw xmm5,4 ; xmm5=Out1HO=(17 19 21 23 25 27 29 31) >+ >+ psllw xmm7,BYTE_BIT >+ psllw xmm5,BYTE_BIT >+ por xmm1,xmm7 ; xmm1=Out1L=( 0 1 2 ... 13 14 15) >+ por xmm0,xmm5 ; xmm0=Out1H=(16 17 18 ... 29 30 31) >+ >+ movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm1 >+ movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm0 >+ >+ poppic ebx >+ >+ sub eax, byte SIZEOF_XMMWORD >+ add ecx, byte 1*SIZEOF_XMMWORD ; inptr1(above) >+ add ebx, byte 1*SIZEOF_XMMWORD ; inptr0 >+ add esi, byte 1*SIZEOF_XMMWORD ; inptr1(below) >+ add edx, byte 2*SIZEOF_XMMWORD ; outptr0 >+ add edi, byte 2*SIZEOF_XMMWORD ; outptr1 >+ cmp eax, byte SIZEOF_XMMWORD >+ ja near .columnloop >+ test eax,eax >+ jnz near .columnloop_last >+ >+ pop esi >+ pop edi >+ pop ecx >+ pop eax >+ >+ add esi, byte 1*SIZEOF_JSAMPROW ; input_data >+ add edi, byte 2*SIZEOF_JSAMPROW ; output_data >+ sub ecx, byte 2 ; rowctr >+ jg near .rowloop >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Fast processing for the common case of 2:1 horizontal and 1:1 vertical. >+; It's still a box filter. >+; >+; GLOBAL(void) >+; jsimd_h2v1_upsample_sse2 (int max_v_samp_factor, >+; JDIMENSION output_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+%define max_v_samp(b) (b)+8 ; int max_v_samp_factor >+%define output_width(b) (b)+12 ; JDIMENSION output_width >+%define input_data(b) (b)+16 ; JSAMPARRAY input_data >+%define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr >+ >+ align 16 >+ global EXTN(jsimd_h2v1_upsample_sse2) >+ >+EXTN(jsimd_h2v1_upsample_sse2): >+ push ebp >+ mov ebp,esp >+; push ebx ; unused >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov edx, JDIMENSION [output_width(ebp)] >+ add edx, byte (2*SIZEOF_XMMWORD)-1 >+ and edx, byte -(2*SIZEOF_XMMWORD) >+ jz short .return >+ >+ mov ecx, INT [max_v_samp(ebp)] ; rowctr >+ test ecx,ecx >+ jz short .return >+ >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ mov edi, POINTER [output_data_ptr(ebp)] >+ mov edi, JSAMPARRAY [edi] ; output_data >+ alignx 16,7 >+.rowloop: >+ push edi >+ push esi >+ >+ mov esi, JSAMPROW [esi] ; inptr >+ mov edi, JSAMPROW [edi] ; outptr >+ mov eax,edx ; colctr >+ alignx 16,7 >+.columnloop: >+ >+ movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ >+ movdqa xmm1,xmm0 >+ punpcklbw xmm0,xmm0 >+ punpckhbw xmm1,xmm1 >+ >+ movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0 >+ movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm1 >+ >+ sub eax, byte 2*SIZEOF_XMMWORD >+ jz short .nextrow >+ >+ movdqa xmm2, XMMWORD [esi+1*SIZEOF_XMMWORD] >+ >+ movdqa xmm3,xmm2 >+ punpcklbw xmm2,xmm2 >+ punpckhbw xmm3,xmm3 >+ >+ movdqa XMMWORD [edi+2*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [edi+3*SIZEOF_XMMWORD], xmm3 >+ >+ sub eax, byte 2*SIZEOF_XMMWORD >+ jz short .nextrow >+ >+ add esi, byte 2*SIZEOF_XMMWORD ; inptr >+ add edi, byte 4*SIZEOF_XMMWORD ; outptr >+ jmp short .columnloop >+ alignx 16,7 >+ >+.nextrow: >+ pop esi >+ pop edi >+ >+ add esi, byte SIZEOF_JSAMPROW ; input_data >+ add edi, byte SIZEOF_JSAMPROW ; output_data >+ dec ecx ; rowctr >+ jg short .rowloop >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+; pop ebx ; unused >+ pop ebp >+ ret >+ >+; -------------------------------------------------------------------------- >+; >+; Fast processing for the common case of 2:1 horizontal and 2:1 vertical. >+; It's still a box filter. >+; >+; GLOBAL(void) >+; jsimd_h2v2_upsample_sse2 (nt max_v_samp_factor, >+; JDIMENSION output_width, >+; JSAMPARRAY input_data, >+; JSAMPARRAY * output_data_ptr); >+; >+ >+%define max_v_samp(b) (b)+8 ; int max_v_samp_factor >+%define output_width(b) (b)+12 ; JDIMENSION output_width >+%define input_data(b) (b)+16 ; JSAMPARRAY input_data >+%define output_data_ptr(b) (b)+20 ; JSAMPARRAY * output_data_ptr >+ >+ align 16 >+ global EXTN(jsimd_h2v2_upsample_sse2) >+ >+EXTN(jsimd_h2v2_upsample_sse2): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ mov edx, JDIMENSION [output_width(ebp)] >+ add edx, byte (2*SIZEOF_XMMWORD)-1 >+ and edx, byte -(2*SIZEOF_XMMWORD) >+ jz near .return >+ >+ mov ecx, INT [max_v_samp(ebp)] ; rowctr >+ test ecx,ecx >+ jz near .return >+ >+ mov esi, JSAMPARRAY [input_data(ebp)] ; input_data >+ mov edi, POINTER [output_data_ptr(ebp)] >+ mov edi, JSAMPARRAY [edi] ; output_data >+ alignx 16,7 >+.rowloop: >+ push edi >+ push esi >+ >+ mov esi, JSAMPROW [esi] ; inptr >+ mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0 >+ mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1 >+ mov eax,edx ; colctr >+ alignx 16,7 >+.columnloop: >+ >+ movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD] >+ >+ movdqa xmm1,xmm0 >+ punpcklbw xmm0,xmm0 >+ punpckhbw xmm1,xmm1 >+ >+ movdqa XMMWORD [ebx+0*SIZEOF_XMMWORD], xmm0 >+ movdqa XMMWORD [ebx+1*SIZEOF_XMMWORD], xmm1 >+ movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0 >+ movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm1 >+ >+ sub eax, byte 2*SIZEOF_XMMWORD >+ jz short .nextrow >+ >+ movdqa xmm2, XMMWORD [esi+1*SIZEOF_XMMWORD] >+ >+ movdqa xmm3,xmm2 >+ punpcklbw xmm2,xmm2 >+ punpckhbw xmm3,xmm3 >+ >+ movdqa XMMWORD [ebx+2*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [ebx+3*SIZEOF_XMMWORD], xmm3 >+ movdqa XMMWORD [edi+2*SIZEOF_XMMWORD], xmm2 >+ movdqa XMMWORD [edi+3*SIZEOF_XMMWORD], xmm3 >+ >+ sub eax, byte 2*SIZEOF_XMMWORD >+ jz short .nextrow >+ >+ add esi, byte 2*SIZEOF_XMMWORD ; inptr >+ add ebx, byte 4*SIZEOF_XMMWORD ; outptr0 >+ add edi, byte 4*SIZEOF_XMMWORD ; outptr1 >+ jmp short .columnloop >+ alignx 16,7 >+ >+.nextrow: >+ pop esi >+ pop edi >+ >+ add esi, byte 1*SIZEOF_JSAMPROW ; input_data >+ add edi, byte 2*SIZEOF_JSAMPROW ; output_data >+ sub ecx, byte 2 ; rowctr >+ jg short .rowloop >+ >+.return: >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jf3dnflt.asm b/modules/libjpeg-turbo/simd/jf3dnflt.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jf3dnflt.asm >@@ -0,0 +1,320 @@ >+; >+; jf3dnflt.asm - floating-point FDCT (3DNow!) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a floating-point implementation of the forward DCT >+; (Discrete Cosine Transform). The following code is based directly on >+; the IJG's original jfdctflt.c; see the jfdctflt.c for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_fdct_float_3dnow) >+ >+EXTN(jconst_fdct_float_3dnow): >+ >+PD_0_382 times 2 dd 0.382683432365089771728460 >+PD_0_707 times 2 dd 0.707106781186547524400844 >+PD_0_541 times 2 dd 0.541196100146196984399723 >+PD_1_306 times 2 dd 1.306562964876376527856643 >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform the forward DCT on one block of samples. >+; >+; GLOBAL(void) >+; jsimd_fdct_float_3dnow (FAST_FLOAT * data) >+; >+ >+%define data(b) (b)+8 ; FAST_FLOAT * data >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_fdct_float_3dnow) >+ >+EXTN(jsimd_fdct_float_3dnow): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+; push esi ; unused >+; push edi ; unused >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process rows. >+ >+ mov edx, POINTER [data(eax)] ; (FAST_FLOAT *) >+ mov ecx, DCTSIZE/2 >+ alignx 16,7 >+.rowloop: >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)] >+ movq mm1, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)] >+ movq mm2, MMWORD [MMBLOCK(0,3,edx,SIZEOF_FAST_FLOAT)] >+ movq mm3, MMWORD [MMBLOCK(1,3,edx,SIZEOF_FAST_FLOAT)] >+ >+ ; mm0=(00 01), mm1=(10 11), mm2=(06 07), mm3=(16 17) >+ >+ movq mm4,mm0 ; transpose coefficients >+ punpckldq mm0,mm1 ; mm0=(00 10)=data0 >+ punpckhdq mm4,mm1 ; mm4=(01 11)=data1 >+ movq mm5,mm2 ; transpose coefficients >+ punpckldq mm2,mm3 ; mm2=(06 16)=data6 >+ punpckhdq mm5,mm3 ; mm5=(07 17)=data7 >+ >+ movq mm6,mm4 >+ movq mm7,mm0 >+ pfsub mm4,mm2 ; mm4=data1-data6=tmp6 >+ pfsub mm0,mm5 ; mm0=data0-data7=tmp7 >+ pfadd mm6,mm2 ; mm6=data1+data6=tmp1 >+ pfadd mm7,mm5 ; mm7=data0+data7=tmp0 >+ >+ movq mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)] >+ movq mm3, MMWORD [MMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)] >+ movq mm2, MMWORD [MMBLOCK(0,2,edx,SIZEOF_FAST_FLOAT)] >+ movq mm5, MMWORD [MMBLOCK(1,2,edx,SIZEOF_FAST_FLOAT)] >+ >+ ; mm1=(02 03), mm3=(12 13), mm2=(04 05), mm5=(14 15) >+ >+ movq MMWORD [wk(0)], mm4 ; wk(0)=tmp6 >+ movq MMWORD [wk(1)], mm0 ; wk(1)=tmp7 >+ >+ movq mm4,mm1 ; transpose coefficients >+ punpckldq mm1,mm3 ; mm1=(02 12)=data2 >+ punpckhdq mm4,mm3 ; mm4=(03 13)=data3 >+ movq mm0,mm2 ; transpose coefficients >+ punpckldq mm2,mm5 ; mm2=(04 14)=data4 >+ punpckhdq mm0,mm5 ; mm0=(05 15)=data5 >+ >+ movq mm3,mm4 >+ movq mm5,mm1 >+ pfadd mm4,mm2 ; mm4=data3+data4=tmp3 >+ pfadd mm1,mm0 ; mm1=data2+data5=tmp2 >+ pfsub mm3,mm2 ; mm3=data3-data4=tmp4 >+ pfsub mm5,mm0 ; mm5=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movq mm2,mm7 >+ movq mm0,mm6 >+ pfsub mm7,mm4 ; mm7=tmp13 >+ pfsub mm6,mm1 ; mm6=tmp12 >+ pfadd mm2,mm4 ; mm2=tmp10 >+ pfadd mm0,mm1 ; mm0=tmp11 >+ >+ pfadd mm6,mm7 >+ pfmul mm6,[GOTOFF(ebx,PD_0_707)] ; mm6=z1 >+ >+ movq mm4,mm2 >+ movq mm1,mm7 >+ pfsub mm2,mm0 ; mm2=data4 >+ pfsub mm7,mm6 ; mm7=data6 >+ pfadd mm4,mm0 ; mm4=data0 >+ pfadd mm1,mm6 ; mm1=data2 >+ >+ movq MMWORD [MMBLOCK(0,2,edx,SIZEOF_FAST_FLOAT)], mm2 >+ movq MMWORD [MMBLOCK(0,3,edx,SIZEOF_FAST_FLOAT)], mm7 >+ movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)], mm4 >+ movq MMWORD [MMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)], mm1 >+ >+ ; -- Odd part >+ >+ movq mm0, MMWORD [wk(0)] ; mm0=tmp6 >+ movq mm6, MMWORD [wk(1)] ; mm6=tmp7 >+ >+ pfadd mm3,mm5 ; mm3=tmp10 >+ pfadd mm5,mm0 ; mm5=tmp11 >+ pfadd mm0,mm6 ; mm0=tmp12, mm6=tmp7 >+ >+ pfmul mm5,[GOTOFF(ebx,PD_0_707)] ; mm5=z3 >+ >+ movq mm2,mm3 ; mm2=tmp10 >+ pfsub mm3,mm0 >+ pfmul mm3,[GOTOFF(ebx,PD_0_382)] ; mm3=z5 >+ pfmul mm2,[GOTOFF(ebx,PD_0_541)] ; mm2=MULTIPLY(tmp10,FIX_0_54119610) >+ pfmul mm0,[GOTOFF(ebx,PD_1_306)] ; mm0=MULTIPLY(tmp12,FIX_1_30656296) >+ pfadd mm2,mm3 ; mm2=z2 >+ pfadd mm0,mm3 ; mm0=z4 >+ >+ movq mm7,mm6 >+ pfsub mm6,mm5 ; mm6=z13 >+ pfadd mm7,mm5 ; mm7=z11 >+ >+ movq mm4,mm6 >+ movq mm1,mm7 >+ pfsub mm6,mm2 ; mm6=data3 >+ pfsub mm7,mm0 ; mm7=data7 >+ pfadd mm4,mm2 ; mm4=data5 >+ pfadd mm1,mm0 ; mm1=data1 >+ >+ movq MMWORD [MMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)], mm6 >+ movq MMWORD [MMBLOCK(1,3,edx,SIZEOF_FAST_FLOAT)], mm7 >+ movq MMWORD [MMBLOCK(1,2,edx,SIZEOF_FAST_FLOAT)], mm4 >+ movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)], mm1 >+ >+ add edx, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT >+ dec ecx >+ jnz near .rowloop >+ >+ ; ---- Pass 2: process columns. >+ >+ mov edx, POINTER [data(eax)] ; (FAST_FLOAT *) >+ mov ecx, DCTSIZE/2 >+ alignx 16,7 >+.columnloop: >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)] >+ movq mm1, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)] >+ movq mm2, MMWORD [MMBLOCK(6,0,edx,SIZEOF_FAST_FLOAT)] >+ movq mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_FAST_FLOAT)] >+ >+ ; mm0=(00 10), mm1=(01 11), mm2=(60 70), mm3=(61 71) >+ >+ movq mm4,mm0 ; transpose coefficients >+ punpckldq mm0,mm1 ; mm0=(00 01)=data0 >+ punpckhdq mm4,mm1 ; mm4=(10 11)=data1 >+ movq mm5,mm2 ; transpose coefficients >+ punpckldq mm2,mm3 ; mm2=(60 61)=data6 >+ punpckhdq mm5,mm3 ; mm5=(70 71)=data7 >+ >+ movq mm6,mm4 >+ movq mm7,mm0 >+ pfsub mm4,mm2 ; mm4=data1-data6=tmp6 >+ pfsub mm0,mm5 ; mm0=data0-data7=tmp7 >+ pfadd mm6,mm2 ; mm6=data1+data6=tmp1 >+ pfadd mm7,mm5 ; mm7=data0+data7=tmp0 >+ >+ movq mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)] >+ movq mm3, MMWORD [MMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)] >+ movq mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_FAST_FLOAT)] >+ movq mm5, MMWORD [MMBLOCK(5,0,edx,SIZEOF_FAST_FLOAT)] >+ >+ ; mm1=(20 30), mm3=(21 31), mm2=(40 50), mm5=(41 51) >+ >+ movq MMWORD [wk(0)], mm4 ; wk(0)=tmp6 >+ movq MMWORD [wk(1)], mm0 ; wk(1)=tmp7 >+ >+ movq mm4,mm1 ; transpose coefficients >+ punpckldq mm1,mm3 ; mm1=(20 21)=data2 >+ punpckhdq mm4,mm3 ; mm4=(30 31)=data3 >+ movq mm0,mm2 ; transpose coefficients >+ punpckldq mm2,mm5 ; mm2=(40 41)=data4 >+ punpckhdq mm0,mm5 ; mm0=(50 51)=data5 >+ >+ movq mm3,mm4 >+ movq mm5,mm1 >+ pfadd mm4,mm2 ; mm4=data3+data4=tmp3 >+ pfadd mm1,mm0 ; mm1=data2+data5=tmp2 >+ pfsub mm3,mm2 ; mm3=data3-data4=tmp4 >+ pfsub mm5,mm0 ; mm5=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movq mm2,mm7 >+ movq mm0,mm6 >+ pfsub mm7,mm4 ; mm7=tmp13 >+ pfsub mm6,mm1 ; mm6=tmp12 >+ pfadd mm2,mm4 ; mm2=tmp10 >+ pfadd mm0,mm1 ; mm0=tmp11 >+ >+ pfadd mm6,mm7 >+ pfmul mm6,[GOTOFF(ebx,PD_0_707)] ; mm6=z1 >+ >+ movq mm4,mm2 >+ movq mm1,mm7 >+ pfsub mm2,mm0 ; mm2=data4 >+ pfsub mm7,mm6 ; mm7=data6 >+ pfadd mm4,mm0 ; mm4=data0 >+ pfadd mm1,mm6 ; mm1=data2 >+ >+ movq MMWORD [MMBLOCK(4,0,edx,SIZEOF_FAST_FLOAT)], mm2 >+ movq MMWORD [MMBLOCK(6,0,edx,SIZEOF_FAST_FLOAT)], mm7 >+ movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)], mm4 >+ movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)], mm1 >+ >+ ; -- Odd part >+ >+ movq mm0, MMWORD [wk(0)] ; mm0=tmp6 >+ movq mm6, MMWORD [wk(1)] ; mm6=tmp7 >+ >+ pfadd mm3,mm5 ; mm3=tmp10 >+ pfadd mm5,mm0 ; mm5=tmp11 >+ pfadd mm0,mm6 ; mm0=tmp12, mm6=tmp7 >+ >+ pfmul mm5,[GOTOFF(ebx,PD_0_707)] ; mm5=z3 >+ >+ movq mm2,mm3 ; mm2=tmp10 >+ pfsub mm3,mm0 >+ pfmul mm3,[GOTOFF(ebx,PD_0_382)] ; mm3=z5 >+ pfmul mm2,[GOTOFF(ebx,PD_0_541)] ; mm2=MULTIPLY(tmp10,FIX_0_54119610) >+ pfmul mm0,[GOTOFF(ebx,PD_1_306)] ; mm0=MULTIPLY(tmp12,FIX_1_30656296) >+ pfadd mm2,mm3 ; mm2=z2 >+ pfadd mm0,mm3 ; mm0=z4 >+ >+ movq mm7,mm6 >+ pfsub mm6,mm5 ; mm6=z13 >+ pfadd mm7,mm5 ; mm7=z11 >+ >+ movq mm4,mm6 >+ movq mm1,mm7 >+ pfsub mm6,mm2 ; mm6=data3 >+ pfsub mm7,mm0 ; mm7=data7 >+ pfadd mm4,mm2 ; mm4=data5 >+ pfadd mm1,mm0 ; mm1=data1 >+ >+ movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)], mm6 >+ movq MMWORD [MMBLOCK(7,0,edx,SIZEOF_FAST_FLOAT)], mm7 >+ movq MMWORD [MMBLOCK(5,0,edx,SIZEOF_FAST_FLOAT)], mm4 >+ movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)], mm1 >+ >+ add edx, byte 2*SIZEOF_FAST_FLOAT >+ dec ecx >+ jnz near .columnloop >+ >+ femms ; empty MMX/3DNow! state >+ >+; pop edi ; unused >+; pop esi ; unused >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ poppic ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jfmmxfst.asm b/modules/libjpeg-turbo/simd/jfmmxfst.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jfmmxfst.asm >@@ -0,0 +1,397 @@ >+; >+; jfmmxfst.asm - fast integer FDCT (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a fast, not so accurate integer implementation of >+; the forward DCT (Discrete Cosine Transform). The following code is >+; based directly on the IJG's original jfdctfst.c; see the jfdctfst.c >+; for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 8 ; 14 is also OK. >+ >+%if CONST_BITS == 8 >+F_0_382 equ 98 ; FIX(0.382683433) >+F_0_541 equ 139 ; FIX(0.541196100) >+F_0_707 equ 181 ; FIX(0.707106781) >+F_1_306 equ 334 ; FIX(1.306562965) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_382 equ DESCALE( 410903207,30-CONST_BITS) ; FIX(0.382683433) >+F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100) >+F_0_707 equ DESCALE( 759250124,30-CONST_BITS) ; FIX(0.707106781) >+F_1_306 equ DESCALE(1402911301,30-CONST_BITS) ; FIX(1.306562965) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow) >+; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw) >+ >+%define PRE_MULTIPLY_SCALE_BITS 2 >+%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS) >+ >+ alignz 16 >+ global EXTN(jconst_fdct_ifast_mmx) >+ >+EXTN(jconst_fdct_ifast_mmx): >+ >+PW_F0707 times 4 dw F_0_707 << CONST_SHIFT >+PW_F0382 times 4 dw F_0_382 << CONST_SHIFT >+PW_F0541 times 4 dw F_0_541 << CONST_SHIFT >+PW_F1306 times 4 dw F_1_306 << CONST_SHIFT >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform the forward DCT on one block of samples. >+; >+; GLOBAL(void) >+; jsimd_fdct_ifast_mmx (DCTELEM * data) >+; >+ >+%define data(b) (b)+8 ; DCTELEM * data >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_fdct_ifast_mmx) >+ >+EXTN(jsimd_fdct_ifast_mmx): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+; push esi ; unused >+; push edi ; unused >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process rows. >+ >+ mov edx, POINTER [data(eax)] ; (DCTELEM *) >+ mov ecx, DCTSIZE/4 >+ alignx 16,7 >+.rowloop: >+ >+ movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)] >+ movq mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)] >+ movq mm2, MMWORD [MMBLOCK(2,1,edx,SIZEOF_DCTELEM)] >+ movq mm3, MMWORD [MMBLOCK(3,1,edx,SIZEOF_DCTELEM)] >+ >+ ; mm0=(20 21 22 23), mm2=(24 25 26 27) >+ ; mm1=(30 31 32 33), mm3=(34 35 36 37) >+ >+ movq mm4,mm0 ; transpose coefficients(phase 1) >+ punpcklwd mm0,mm1 ; mm0=(20 30 21 31) >+ punpckhwd mm4,mm1 ; mm4=(22 32 23 33) >+ movq mm5,mm2 ; transpose coefficients(phase 1) >+ punpcklwd mm2,mm3 ; mm2=(24 34 25 35) >+ punpckhwd mm5,mm3 ; mm5=(26 36 27 37) >+ >+ movq mm6, MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)] >+ movq mm7, MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)] >+ movq mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_DCTELEM)] >+ movq mm3, MMWORD [MMBLOCK(1,1,edx,SIZEOF_DCTELEM)] >+ >+ ; mm6=(00 01 02 03), mm1=(04 05 06 07) >+ ; mm7=(10 11 12 13), mm3=(14 15 16 17) >+ >+ movq MMWORD [wk(0)], mm4 ; wk(0)=(22 32 23 33) >+ movq MMWORD [wk(1)], mm2 ; wk(1)=(24 34 25 35) >+ >+ movq mm4,mm6 ; transpose coefficients(phase 1) >+ punpcklwd mm6,mm7 ; mm6=(00 10 01 11) >+ punpckhwd mm4,mm7 ; mm4=(02 12 03 13) >+ movq mm2,mm1 ; transpose coefficients(phase 1) >+ punpcklwd mm1,mm3 ; mm1=(04 14 05 15) >+ punpckhwd mm2,mm3 ; mm2=(06 16 07 17) >+ >+ movq mm7,mm6 ; transpose coefficients(phase 2) >+ punpckldq mm6,mm0 ; mm6=(00 10 20 30)=data0 >+ punpckhdq mm7,mm0 ; mm7=(01 11 21 31)=data1 >+ movq mm3,mm2 ; transpose coefficients(phase 2) >+ punpckldq mm2,mm5 ; mm2=(06 16 26 36)=data6 >+ punpckhdq mm3,mm5 ; mm3=(07 17 27 37)=data7 >+ >+ movq mm0,mm7 >+ movq mm5,mm6 >+ psubw mm7,mm2 ; mm7=data1-data6=tmp6 >+ psubw mm6,mm3 ; mm6=data0-data7=tmp7 >+ paddw mm0,mm2 ; mm0=data1+data6=tmp1 >+ paddw mm5,mm3 ; mm5=data0+data7=tmp0 >+ >+ movq mm2, MMWORD [wk(0)] ; mm2=(22 32 23 33) >+ movq mm3, MMWORD [wk(1)] ; mm3=(24 34 25 35) >+ movq MMWORD [wk(0)], mm7 ; wk(0)=tmp6 >+ movq MMWORD [wk(1)], mm6 ; wk(1)=tmp7 >+ >+ movq mm7,mm4 ; transpose coefficients(phase 2) >+ punpckldq mm4,mm2 ; mm4=(02 12 22 32)=data2 >+ punpckhdq mm7,mm2 ; mm7=(03 13 23 33)=data3 >+ movq mm6,mm1 ; transpose coefficients(phase 2) >+ punpckldq mm1,mm3 ; mm1=(04 14 24 34)=data4 >+ punpckhdq mm6,mm3 ; mm6=(05 15 25 35)=data5 >+ >+ movq mm2,mm7 >+ movq mm3,mm4 >+ paddw mm7,mm1 ; mm7=data3+data4=tmp3 >+ paddw mm4,mm6 ; mm4=data2+data5=tmp2 >+ psubw mm2,mm1 ; mm2=data3-data4=tmp4 >+ psubw mm3,mm6 ; mm3=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movq mm1,mm5 >+ movq mm6,mm0 >+ psubw mm5,mm7 ; mm5=tmp13 >+ psubw mm0,mm4 ; mm0=tmp12 >+ paddw mm1,mm7 ; mm1=tmp10 >+ paddw mm6,mm4 ; mm6=tmp11 >+ >+ paddw mm0,mm5 >+ psllw mm0,PRE_MULTIPLY_SCALE_BITS >+ pmulhw mm0,[GOTOFF(ebx,PW_F0707)] ; mm0=z1 >+ >+ movq mm7,mm1 >+ movq mm4,mm5 >+ psubw mm1,mm6 ; mm1=data4 >+ psubw mm5,mm0 ; mm5=data6 >+ paddw mm7,mm6 ; mm7=data0 >+ paddw mm4,mm0 ; mm4=data2 >+ >+ movq MMWORD [MMBLOCK(0,1,edx,SIZEOF_DCTELEM)], mm1 >+ movq MMWORD [MMBLOCK(2,1,edx,SIZEOF_DCTELEM)], mm5 >+ movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)], mm7 >+ movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)], mm4 >+ >+ ; -- Odd part >+ >+ movq mm6, MMWORD [wk(0)] ; mm6=tmp6 >+ movq mm0, MMWORD [wk(1)] ; mm0=tmp7 >+ >+ paddw mm2,mm3 ; mm2=tmp10 >+ paddw mm3,mm6 ; mm3=tmp11 >+ paddw mm6,mm0 ; mm6=tmp12, mm0=tmp7 >+ >+ psllw mm2,PRE_MULTIPLY_SCALE_BITS >+ psllw mm6,PRE_MULTIPLY_SCALE_BITS >+ >+ psllw mm3,PRE_MULTIPLY_SCALE_BITS >+ pmulhw mm3,[GOTOFF(ebx,PW_F0707)] ; mm3=z3 >+ >+ movq mm1,mm2 ; mm1=tmp10 >+ psubw mm2,mm6 >+ pmulhw mm2,[GOTOFF(ebx,PW_F0382)] ; mm2=z5 >+ pmulhw mm1,[GOTOFF(ebx,PW_F0541)] ; mm1=MULTIPLY(tmp10,FIX_0_54119610) >+ pmulhw mm6,[GOTOFF(ebx,PW_F1306)] ; mm6=MULTIPLY(tmp12,FIX_1_30656296) >+ paddw mm1,mm2 ; mm1=z2 >+ paddw mm6,mm2 ; mm6=z4 >+ >+ movq mm5,mm0 >+ psubw mm0,mm3 ; mm0=z13 >+ paddw mm5,mm3 ; mm5=z11 >+ >+ movq mm7,mm0 >+ movq mm4,mm5 >+ psubw mm0,mm1 ; mm0=data3 >+ psubw mm5,mm6 ; mm5=data7 >+ paddw mm7,mm1 ; mm7=data5 >+ paddw mm4,mm6 ; mm4=data1 >+ >+ movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)], mm0 >+ movq MMWORD [MMBLOCK(3,1,edx,SIZEOF_DCTELEM)], mm5 >+ movq MMWORD [MMBLOCK(1,1,edx,SIZEOF_DCTELEM)], mm7 >+ movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)], mm4 >+ >+ add edx, byte 4*DCTSIZE*SIZEOF_DCTELEM >+ dec ecx >+ jnz near .rowloop >+ >+ ; ---- Pass 2: process columns. >+ >+ mov edx, POINTER [data(eax)] ; (DCTELEM *) >+ mov ecx, DCTSIZE/4 >+ alignx 16,7 >+.columnloop: >+ >+ movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)] >+ movq mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)] >+ movq mm2, MMWORD [MMBLOCK(6,0,edx,SIZEOF_DCTELEM)] >+ movq mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_DCTELEM)] >+ >+ ; mm0=(02 12 22 32), mm2=(42 52 62 72) >+ ; mm1=(03 13 23 33), mm3=(43 53 63 73) >+ >+ movq mm4,mm0 ; transpose coefficients(phase 1) >+ punpcklwd mm0,mm1 ; mm0=(02 03 12 13) >+ punpckhwd mm4,mm1 ; mm4=(22 23 32 33) >+ movq mm5,mm2 ; transpose coefficients(phase 1) >+ punpcklwd mm2,mm3 ; mm2=(42 43 52 53) >+ punpckhwd mm5,mm3 ; mm5=(62 63 72 73) >+ >+ movq mm6, MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)] >+ movq mm7, MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)] >+ movq mm1, MMWORD [MMBLOCK(4,0,edx,SIZEOF_DCTELEM)] >+ movq mm3, MMWORD [MMBLOCK(5,0,edx,SIZEOF_DCTELEM)] >+ >+ ; mm6=(00 10 20 30), mm1=(40 50 60 70) >+ ; mm7=(01 11 21 31), mm3=(41 51 61 71) >+ >+ movq MMWORD [wk(0)], mm4 ; wk(0)=(22 23 32 33) >+ movq MMWORD [wk(1)], mm2 ; wk(1)=(42 43 52 53) >+ >+ movq mm4,mm6 ; transpose coefficients(phase 1) >+ punpcklwd mm6,mm7 ; mm6=(00 01 10 11) >+ punpckhwd mm4,mm7 ; mm4=(20 21 30 31) >+ movq mm2,mm1 ; transpose coefficients(phase 1) >+ punpcklwd mm1,mm3 ; mm1=(40 41 50 51) >+ punpckhwd mm2,mm3 ; mm2=(60 61 70 71) >+ >+ movq mm7,mm6 ; transpose coefficients(phase 2) >+ punpckldq mm6,mm0 ; mm6=(00 01 02 03)=data0 >+ punpckhdq mm7,mm0 ; mm7=(10 11 12 13)=data1 >+ movq mm3,mm2 ; transpose coefficients(phase 2) >+ punpckldq mm2,mm5 ; mm2=(60 61 62 63)=data6 >+ punpckhdq mm3,mm5 ; mm3=(70 71 72 73)=data7 >+ >+ movq mm0,mm7 >+ movq mm5,mm6 >+ psubw mm7,mm2 ; mm7=data1-data6=tmp6 >+ psubw mm6,mm3 ; mm6=data0-data7=tmp7 >+ paddw mm0,mm2 ; mm0=data1+data6=tmp1 >+ paddw mm5,mm3 ; mm5=data0+data7=tmp0 >+ >+ movq mm2, MMWORD [wk(0)] ; mm2=(22 23 32 33) >+ movq mm3, MMWORD [wk(1)] ; mm3=(42 43 52 53) >+ movq MMWORD [wk(0)], mm7 ; wk(0)=tmp6 >+ movq MMWORD [wk(1)], mm6 ; wk(1)=tmp7 >+ >+ movq mm7,mm4 ; transpose coefficients(phase 2) >+ punpckldq mm4,mm2 ; mm4=(20 21 22 23)=data2 >+ punpckhdq mm7,mm2 ; mm7=(30 31 32 33)=data3 >+ movq mm6,mm1 ; transpose coefficients(phase 2) >+ punpckldq mm1,mm3 ; mm1=(40 41 42 43)=data4 >+ punpckhdq mm6,mm3 ; mm6=(50 51 52 53)=data5 >+ >+ movq mm2,mm7 >+ movq mm3,mm4 >+ paddw mm7,mm1 ; mm7=data3+data4=tmp3 >+ paddw mm4,mm6 ; mm4=data2+data5=tmp2 >+ psubw mm2,mm1 ; mm2=data3-data4=tmp4 >+ psubw mm3,mm6 ; mm3=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movq mm1,mm5 >+ movq mm6,mm0 >+ psubw mm5,mm7 ; mm5=tmp13 >+ psubw mm0,mm4 ; mm0=tmp12 >+ paddw mm1,mm7 ; mm1=tmp10 >+ paddw mm6,mm4 ; mm6=tmp11 >+ >+ paddw mm0,mm5 >+ psllw mm0,PRE_MULTIPLY_SCALE_BITS >+ pmulhw mm0,[GOTOFF(ebx,PW_F0707)] ; mm0=z1 >+ >+ movq mm7,mm1 >+ movq mm4,mm5 >+ psubw mm1,mm6 ; mm1=data4 >+ psubw mm5,mm0 ; mm5=data6 >+ paddw mm7,mm6 ; mm7=data0 >+ paddw mm4,mm0 ; mm4=data2 >+ >+ movq MMWORD [MMBLOCK(4,0,edx,SIZEOF_DCTELEM)], mm1 >+ movq MMWORD [MMBLOCK(6,0,edx,SIZEOF_DCTELEM)], mm5 >+ movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)], mm7 >+ movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)], mm4 >+ >+ ; -- Odd part >+ >+ movq mm6, MMWORD [wk(0)] ; mm6=tmp6 >+ movq mm0, MMWORD [wk(1)] ; mm0=tmp7 >+ >+ paddw mm2,mm3 ; mm2=tmp10 >+ paddw mm3,mm6 ; mm3=tmp11 >+ paddw mm6,mm0 ; mm6=tmp12, mm0=tmp7 >+ >+ psllw mm2,PRE_MULTIPLY_SCALE_BITS >+ psllw mm6,PRE_MULTIPLY_SCALE_BITS >+ >+ psllw mm3,PRE_MULTIPLY_SCALE_BITS >+ pmulhw mm3,[GOTOFF(ebx,PW_F0707)] ; mm3=z3 >+ >+ movq mm1,mm2 ; mm1=tmp10 >+ psubw mm2,mm6 >+ pmulhw mm2,[GOTOFF(ebx,PW_F0382)] ; mm2=z5 >+ pmulhw mm1,[GOTOFF(ebx,PW_F0541)] ; mm1=MULTIPLY(tmp10,FIX_0_54119610) >+ pmulhw mm6,[GOTOFF(ebx,PW_F1306)] ; mm6=MULTIPLY(tmp12,FIX_1_30656296) >+ paddw mm1,mm2 ; mm1=z2 >+ paddw mm6,mm2 ; mm6=z4 >+ >+ movq mm5,mm0 >+ psubw mm0,mm3 ; mm0=z13 >+ paddw mm5,mm3 ; mm5=z11 >+ >+ movq mm7,mm0 >+ movq mm4,mm5 >+ psubw mm0,mm1 ; mm0=data3 >+ psubw mm5,mm6 ; mm5=data7 >+ paddw mm7,mm1 ; mm7=data5 >+ paddw mm4,mm6 ; mm4=data1 >+ >+ movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)], mm0 >+ movq MMWORD [MMBLOCK(7,0,edx,SIZEOF_DCTELEM)], mm5 >+ movq MMWORD [MMBLOCK(5,0,edx,SIZEOF_DCTELEM)], mm7 >+ movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)], mm4 >+ >+ add edx, byte 4*SIZEOF_DCTELEM >+ dec ecx >+ jnz near .columnloop >+ >+ emms ; empty MMX state >+ >+; pop edi ; unused >+; pop esi ; unused >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ poppic ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jfmmxint.asm b/modules/libjpeg-turbo/simd/jfmmxint.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jfmmxint.asm >@@ -0,0 +1,622 @@ >+; >+; jfmmxint.asm - accurate integer FDCT (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a slow-but-accurate integer implementation of the >+; forward DCT (Discrete Cosine Transform). The following code is based >+; directly on the IJG's original jfdctint.c; see the jfdctint.c for >+; more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 13 >+%define PASS1_BITS 2 >+ >+%define DESCALE_P1 (CONST_BITS-PASS1_BITS) >+%define DESCALE_P2 (CONST_BITS+PASS1_BITS) >+ >+%if CONST_BITS == 13 >+F_0_298 equ 2446 ; FIX(0.298631336) >+F_0_390 equ 3196 ; FIX(0.390180644) >+F_0_541 equ 4433 ; FIX(0.541196100) >+F_0_765 equ 6270 ; FIX(0.765366865) >+F_0_899 equ 7373 ; FIX(0.899976223) >+F_1_175 equ 9633 ; FIX(1.175875602) >+F_1_501 equ 12299 ; FIX(1.501321110) >+F_1_847 equ 15137 ; FIX(1.847759065) >+F_1_961 equ 16069 ; FIX(1.961570560) >+F_2_053 equ 16819 ; FIX(2.053119869) >+F_2_562 equ 20995 ; FIX(2.562915447) >+F_3_072 equ 25172 ; FIX(3.072711026) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_298 equ DESCALE( 320652955,30-CONST_BITS) ; FIX(0.298631336) >+F_0_390 equ DESCALE( 418953276,30-CONST_BITS) ; FIX(0.390180644) >+F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100) >+F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865) >+F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223) >+F_1_175 equ DESCALE(1262586813,30-CONST_BITS) ; FIX(1.175875602) >+F_1_501 equ DESCALE(1612031267,30-CONST_BITS) ; FIX(1.501321110) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_1_961 equ DESCALE(2106220350,30-CONST_BITS) ; FIX(1.961570560) >+F_2_053 equ DESCALE(2204520673,30-CONST_BITS) ; FIX(2.053119869) >+F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447) >+F_3_072 equ DESCALE(3299298341,30-CONST_BITS) ; FIX(3.072711026) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_fdct_islow_mmx) >+ >+EXTN(jconst_fdct_islow_mmx): >+ >+PW_F130_F054 times 2 dw (F_0_541+F_0_765), F_0_541 >+PW_F054_MF130 times 2 dw F_0_541, (F_0_541-F_1_847) >+PW_MF078_F117 times 2 dw (F_1_175-F_1_961), F_1_175 >+PW_F117_F078 times 2 dw F_1_175, (F_1_175-F_0_390) >+PW_MF060_MF089 times 2 dw (F_0_298-F_0_899),-F_0_899 >+PW_MF089_F060 times 2 dw -F_0_899, (F_1_501-F_0_899) >+PW_MF050_MF256 times 2 dw (F_2_053-F_2_562),-F_2_562 >+PW_MF256_F050 times 2 dw -F_2_562, (F_3_072-F_2_562) >+PD_DESCALE_P1 times 2 dd 1 << (DESCALE_P1-1) >+PD_DESCALE_P2 times 2 dd 1 << (DESCALE_P2-1) >+PW_DESCALE_P2X times 4 dw 1 << (PASS1_BITS-1) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform the forward DCT on one block of samples. >+; >+; GLOBAL(void) >+; jsimd_fdct_islow_mmx (DCTELEM * data) >+; >+ >+%define data(b) (b)+8 ; DCTELEM * data >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_fdct_islow_mmx) >+ >+EXTN(jsimd_fdct_islow_mmx): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+; push esi ; unused >+; push edi ; unused >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process rows. >+ >+ mov edx, POINTER [data(eax)] ; (DCTELEM *) >+ mov ecx, DCTSIZE/4 >+ alignx 16,7 >+.rowloop: >+ >+ movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)] >+ movq mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)] >+ movq mm2, MMWORD [MMBLOCK(2,1,edx,SIZEOF_DCTELEM)] >+ movq mm3, MMWORD [MMBLOCK(3,1,edx,SIZEOF_DCTELEM)] >+ >+ ; mm0=(20 21 22 23), mm2=(24 25 26 27) >+ ; mm1=(30 31 32 33), mm3=(34 35 36 37) >+ >+ movq mm4,mm0 ; transpose coefficients(phase 1) >+ punpcklwd mm0,mm1 ; mm0=(20 30 21 31) >+ punpckhwd mm4,mm1 ; mm4=(22 32 23 33) >+ movq mm5,mm2 ; transpose coefficients(phase 1) >+ punpcklwd mm2,mm3 ; mm2=(24 34 25 35) >+ punpckhwd mm5,mm3 ; mm5=(26 36 27 37) >+ >+ movq mm6, MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)] >+ movq mm7, MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)] >+ movq mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_DCTELEM)] >+ movq mm3, MMWORD [MMBLOCK(1,1,edx,SIZEOF_DCTELEM)] >+ >+ ; mm6=(00 01 02 03), mm1=(04 05 06 07) >+ ; mm7=(10 11 12 13), mm3=(14 15 16 17) >+ >+ movq MMWORD [wk(0)], mm4 ; wk(0)=(22 32 23 33) >+ movq MMWORD [wk(1)], mm2 ; wk(1)=(24 34 25 35) >+ >+ movq mm4,mm6 ; transpose coefficients(phase 1) >+ punpcklwd mm6,mm7 ; mm6=(00 10 01 11) >+ punpckhwd mm4,mm7 ; mm4=(02 12 03 13) >+ movq mm2,mm1 ; transpose coefficients(phase 1) >+ punpcklwd mm1,mm3 ; mm1=(04 14 05 15) >+ punpckhwd mm2,mm3 ; mm2=(06 16 07 17) >+ >+ movq mm7,mm6 ; transpose coefficients(phase 2) >+ punpckldq mm6,mm0 ; mm6=(00 10 20 30)=data0 >+ punpckhdq mm7,mm0 ; mm7=(01 11 21 31)=data1 >+ movq mm3,mm2 ; transpose coefficients(phase 2) >+ punpckldq mm2,mm5 ; mm2=(06 16 26 36)=data6 >+ punpckhdq mm3,mm5 ; mm3=(07 17 27 37)=data7 >+ >+ movq mm0,mm7 >+ movq mm5,mm6 >+ psubw mm7,mm2 ; mm7=data1-data6=tmp6 >+ psubw mm6,mm3 ; mm6=data0-data7=tmp7 >+ paddw mm0,mm2 ; mm0=data1+data6=tmp1 >+ paddw mm5,mm3 ; mm5=data0+data7=tmp0 >+ >+ movq mm2, MMWORD [wk(0)] ; mm2=(22 32 23 33) >+ movq mm3, MMWORD [wk(1)] ; mm3=(24 34 25 35) >+ movq MMWORD [wk(0)], mm7 ; wk(0)=tmp6 >+ movq MMWORD [wk(1)], mm6 ; wk(1)=tmp7 >+ >+ movq mm7,mm4 ; transpose coefficients(phase 2) >+ punpckldq mm4,mm2 ; mm4=(02 12 22 32)=data2 >+ punpckhdq mm7,mm2 ; mm7=(03 13 23 33)=data3 >+ movq mm6,mm1 ; transpose coefficients(phase 2) >+ punpckldq mm1,mm3 ; mm1=(04 14 24 34)=data4 >+ punpckhdq mm6,mm3 ; mm6=(05 15 25 35)=data5 >+ >+ movq mm2,mm7 >+ movq mm3,mm4 >+ paddw mm7,mm1 ; mm7=data3+data4=tmp3 >+ paddw mm4,mm6 ; mm4=data2+data5=tmp2 >+ psubw mm2,mm1 ; mm2=data3-data4=tmp4 >+ psubw mm3,mm6 ; mm3=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movq mm1,mm5 >+ movq mm6,mm0 >+ paddw mm5,mm7 ; mm5=tmp10 >+ paddw mm0,mm4 ; mm0=tmp11 >+ psubw mm1,mm7 ; mm1=tmp13 >+ psubw mm6,mm4 ; mm6=tmp12 >+ >+ movq mm7,mm5 >+ paddw mm5,mm0 ; mm5=tmp10+tmp11 >+ psubw mm7,mm0 ; mm7=tmp10-tmp11 >+ >+ psllw mm5,PASS1_BITS ; mm5=data0 >+ psllw mm7,PASS1_BITS ; mm7=data4 >+ >+ movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)], mm5 >+ movq MMWORD [MMBLOCK(0,1,edx,SIZEOF_DCTELEM)], mm7 >+ >+ ; (Original) >+ ; z1 = (tmp12 + tmp13) * 0.541196100; >+ ; data2 = z1 + tmp13 * 0.765366865; >+ ; data6 = z1 + tmp12 * -1.847759065; >+ ; >+ ; (This implementation) >+ ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100; >+ ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065); >+ >+ movq mm4,mm1 ; mm1=tmp13 >+ movq mm0,mm1 >+ punpcklwd mm4,mm6 ; mm6=tmp12 >+ punpckhwd mm0,mm6 >+ movq mm1,mm4 >+ movq mm6,mm0 >+ pmaddwd mm4,[GOTOFF(ebx,PW_F130_F054)] ; mm4=data2L >+ pmaddwd mm0,[GOTOFF(ebx,PW_F130_F054)] ; mm0=data2H >+ pmaddwd mm1,[GOTOFF(ebx,PW_F054_MF130)] ; mm1=data6L >+ pmaddwd mm6,[GOTOFF(ebx,PW_F054_MF130)] ; mm6=data6H >+ >+ paddd mm4,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd mm0,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad mm4,DESCALE_P1 >+ psrad mm0,DESCALE_P1 >+ paddd mm1,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd mm6,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad mm1,DESCALE_P1 >+ psrad mm6,DESCALE_P1 >+ >+ packssdw mm4,mm0 ; mm4=data2 >+ packssdw mm1,mm6 ; mm1=data6 >+ >+ movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)], mm4 >+ movq MMWORD [MMBLOCK(2,1,edx,SIZEOF_DCTELEM)], mm1 >+ >+ ; -- Odd part >+ >+ movq mm5, MMWORD [wk(0)] ; mm5=tmp6 >+ movq mm7, MMWORD [wk(1)] ; mm7=tmp7 >+ >+ movq mm0,mm2 ; mm2=tmp4 >+ movq mm6,mm3 ; mm3=tmp5 >+ paddw mm0,mm5 ; mm0=z3 >+ paddw mm6,mm7 ; mm6=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movq mm4,mm0 >+ movq mm1,mm0 >+ punpcklwd mm4,mm6 >+ punpckhwd mm1,mm6 >+ movq mm0,mm4 >+ movq mm6,mm1 >+ pmaddwd mm4,[GOTOFF(ebx,PW_MF078_F117)] ; mm4=z3L >+ pmaddwd mm1,[GOTOFF(ebx,PW_MF078_F117)] ; mm1=z3H >+ pmaddwd mm0,[GOTOFF(ebx,PW_F117_F078)] ; mm0=z4L >+ pmaddwd mm6,[GOTOFF(ebx,PW_F117_F078)] ; mm6=z4H >+ >+ movq MMWORD [wk(0)], mm4 ; wk(0)=z3L >+ movq MMWORD [wk(1)], mm1 ; wk(1)=z3H >+ >+ ; (Original) >+ ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6; >+ ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869; >+ ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4; >+ ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223; >+ ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447; >+ ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447); >+ ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223); >+ ; data7 = tmp4 + z3; data5 = tmp5 + z4; >+ ; data3 = tmp6 + z3; data1 = tmp7 + z4; >+ >+ movq mm4,mm2 >+ movq mm1,mm2 >+ punpcklwd mm4,mm7 >+ punpckhwd mm1,mm7 >+ movq mm2,mm4 >+ movq mm7,mm1 >+ pmaddwd mm4,[GOTOFF(ebx,PW_MF060_MF089)] ; mm4=tmp4L >+ pmaddwd mm1,[GOTOFF(ebx,PW_MF060_MF089)] ; mm1=tmp4H >+ pmaddwd mm2,[GOTOFF(ebx,PW_MF089_F060)] ; mm2=tmp7L >+ pmaddwd mm7,[GOTOFF(ebx,PW_MF089_F060)] ; mm7=tmp7H >+ >+ paddd mm4, MMWORD [wk(0)] ; mm4=data7L >+ paddd mm1, MMWORD [wk(1)] ; mm1=data7H >+ paddd mm2,mm0 ; mm2=data1L >+ paddd mm7,mm6 ; mm7=data1H >+ >+ paddd mm4,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd mm1,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad mm4,DESCALE_P1 >+ psrad mm1,DESCALE_P1 >+ paddd mm2,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd mm7,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad mm2,DESCALE_P1 >+ psrad mm7,DESCALE_P1 >+ >+ packssdw mm4,mm1 ; mm4=data7 >+ packssdw mm2,mm7 ; mm2=data1 >+ >+ movq MMWORD [MMBLOCK(3,1,edx,SIZEOF_DCTELEM)], mm4 >+ movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)], mm2 >+ >+ movq mm1,mm3 >+ movq mm7,mm3 >+ punpcklwd mm1,mm5 >+ punpckhwd mm7,mm5 >+ movq mm3,mm1 >+ movq mm5,mm7 >+ pmaddwd mm1,[GOTOFF(ebx,PW_MF050_MF256)] ; mm1=tmp5L >+ pmaddwd mm7,[GOTOFF(ebx,PW_MF050_MF256)] ; mm7=tmp5H >+ pmaddwd mm3,[GOTOFF(ebx,PW_MF256_F050)] ; mm3=tmp6L >+ pmaddwd mm5,[GOTOFF(ebx,PW_MF256_F050)] ; mm5=tmp6H >+ >+ paddd mm1,mm0 ; mm1=data5L >+ paddd mm7,mm6 ; mm7=data5H >+ paddd mm3, MMWORD [wk(0)] ; mm3=data3L >+ paddd mm5, MMWORD [wk(1)] ; mm5=data3H >+ >+ paddd mm1,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd mm7,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad mm1,DESCALE_P1 >+ psrad mm7,DESCALE_P1 >+ paddd mm3,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd mm5,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad mm3,DESCALE_P1 >+ psrad mm5,DESCALE_P1 >+ >+ packssdw mm1,mm7 ; mm1=data5 >+ packssdw mm3,mm5 ; mm3=data3 >+ >+ movq MMWORD [MMBLOCK(1,1,edx,SIZEOF_DCTELEM)], mm1 >+ movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)], mm3 >+ >+ add edx, byte 4*DCTSIZE*SIZEOF_DCTELEM >+ dec ecx >+ jnz near .rowloop >+ >+ ; ---- Pass 2: process columns. >+ >+ mov edx, POINTER [data(eax)] ; (DCTELEM *) >+ mov ecx, DCTSIZE/4 >+ alignx 16,7 >+.columnloop: >+ >+ movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)] >+ movq mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)] >+ movq mm2, MMWORD [MMBLOCK(6,0,edx,SIZEOF_DCTELEM)] >+ movq mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_DCTELEM)] >+ >+ ; mm0=(02 12 22 32), mm2=(42 52 62 72) >+ ; mm1=(03 13 23 33), mm3=(43 53 63 73) >+ >+ movq mm4,mm0 ; transpose coefficients(phase 1) >+ punpcklwd mm0,mm1 ; mm0=(02 03 12 13) >+ punpckhwd mm4,mm1 ; mm4=(22 23 32 33) >+ movq mm5,mm2 ; transpose coefficients(phase 1) >+ punpcklwd mm2,mm3 ; mm2=(42 43 52 53) >+ punpckhwd mm5,mm3 ; mm5=(62 63 72 73) >+ >+ movq mm6, MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)] >+ movq mm7, MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)] >+ movq mm1, MMWORD [MMBLOCK(4,0,edx,SIZEOF_DCTELEM)] >+ movq mm3, MMWORD [MMBLOCK(5,0,edx,SIZEOF_DCTELEM)] >+ >+ ; mm6=(00 10 20 30), mm1=(40 50 60 70) >+ ; mm7=(01 11 21 31), mm3=(41 51 61 71) >+ >+ movq MMWORD [wk(0)], mm4 ; wk(0)=(22 23 32 33) >+ movq MMWORD [wk(1)], mm2 ; wk(1)=(42 43 52 53) >+ >+ movq mm4,mm6 ; transpose coefficients(phase 1) >+ punpcklwd mm6,mm7 ; mm6=(00 01 10 11) >+ punpckhwd mm4,mm7 ; mm4=(20 21 30 31) >+ movq mm2,mm1 ; transpose coefficients(phase 1) >+ punpcklwd mm1,mm3 ; mm1=(40 41 50 51) >+ punpckhwd mm2,mm3 ; mm2=(60 61 70 71) >+ >+ movq mm7,mm6 ; transpose coefficients(phase 2) >+ punpckldq mm6,mm0 ; mm6=(00 01 02 03)=data0 >+ punpckhdq mm7,mm0 ; mm7=(10 11 12 13)=data1 >+ movq mm3,mm2 ; transpose coefficients(phase 2) >+ punpckldq mm2,mm5 ; mm2=(60 61 62 63)=data6 >+ punpckhdq mm3,mm5 ; mm3=(70 71 72 73)=data7 >+ >+ movq mm0,mm7 >+ movq mm5,mm6 >+ psubw mm7,mm2 ; mm7=data1-data6=tmp6 >+ psubw mm6,mm3 ; mm6=data0-data7=tmp7 >+ paddw mm0,mm2 ; mm0=data1+data6=tmp1 >+ paddw mm5,mm3 ; mm5=data0+data7=tmp0 >+ >+ movq mm2, MMWORD [wk(0)] ; mm2=(22 23 32 33) >+ movq mm3, MMWORD [wk(1)] ; mm3=(42 43 52 53) >+ movq MMWORD [wk(0)], mm7 ; wk(0)=tmp6 >+ movq MMWORD [wk(1)], mm6 ; wk(1)=tmp7 >+ >+ movq mm7,mm4 ; transpose coefficients(phase 2) >+ punpckldq mm4,mm2 ; mm4=(20 21 22 23)=data2 >+ punpckhdq mm7,mm2 ; mm7=(30 31 32 33)=data3 >+ movq mm6,mm1 ; transpose coefficients(phase 2) >+ punpckldq mm1,mm3 ; mm1=(40 41 42 43)=data4 >+ punpckhdq mm6,mm3 ; mm6=(50 51 52 53)=data5 >+ >+ movq mm2,mm7 >+ movq mm3,mm4 >+ paddw mm7,mm1 ; mm7=data3+data4=tmp3 >+ paddw mm4,mm6 ; mm4=data2+data5=tmp2 >+ psubw mm2,mm1 ; mm2=data3-data4=tmp4 >+ psubw mm3,mm6 ; mm3=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movq mm1,mm5 >+ movq mm6,mm0 >+ paddw mm5,mm7 ; mm5=tmp10 >+ paddw mm0,mm4 ; mm0=tmp11 >+ psubw mm1,mm7 ; mm1=tmp13 >+ psubw mm6,mm4 ; mm6=tmp12 >+ >+ movq mm7,mm5 >+ paddw mm5,mm0 ; mm5=tmp10+tmp11 >+ psubw mm7,mm0 ; mm7=tmp10-tmp11 >+ >+ paddw mm5,[GOTOFF(ebx,PW_DESCALE_P2X)] >+ paddw mm7,[GOTOFF(ebx,PW_DESCALE_P2X)] >+ psraw mm5,PASS1_BITS ; mm5=data0 >+ psraw mm7,PASS1_BITS ; mm7=data4 >+ >+ movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_DCTELEM)], mm5 >+ movq MMWORD [MMBLOCK(4,0,edx,SIZEOF_DCTELEM)], mm7 >+ >+ ; (Original) >+ ; z1 = (tmp12 + tmp13) * 0.541196100; >+ ; data2 = z1 + tmp13 * 0.765366865; >+ ; data6 = z1 + tmp12 * -1.847759065; >+ ; >+ ; (This implementation) >+ ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100; >+ ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065); >+ >+ movq mm4,mm1 ; mm1=tmp13 >+ movq mm0,mm1 >+ punpcklwd mm4,mm6 ; mm6=tmp12 >+ punpckhwd mm0,mm6 >+ movq mm1,mm4 >+ movq mm6,mm0 >+ pmaddwd mm4,[GOTOFF(ebx,PW_F130_F054)] ; mm4=data2L >+ pmaddwd mm0,[GOTOFF(ebx,PW_F130_F054)] ; mm0=data2H >+ pmaddwd mm1,[GOTOFF(ebx,PW_F054_MF130)] ; mm1=data6L >+ pmaddwd mm6,[GOTOFF(ebx,PW_F054_MF130)] ; mm6=data6H >+ >+ paddd mm4,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd mm0,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad mm4,DESCALE_P2 >+ psrad mm0,DESCALE_P2 >+ paddd mm1,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd mm6,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad mm1,DESCALE_P2 >+ psrad mm6,DESCALE_P2 >+ >+ packssdw mm4,mm0 ; mm4=data2 >+ packssdw mm1,mm6 ; mm1=data6 >+ >+ movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)], mm4 >+ movq MMWORD [MMBLOCK(6,0,edx,SIZEOF_DCTELEM)], mm1 >+ >+ ; -- Odd part >+ >+ movq mm5, MMWORD [wk(0)] ; mm5=tmp6 >+ movq mm7, MMWORD [wk(1)] ; mm7=tmp7 >+ >+ movq mm0,mm2 ; mm2=tmp4 >+ movq mm6,mm3 ; mm3=tmp5 >+ paddw mm0,mm5 ; mm0=z3 >+ paddw mm6,mm7 ; mm6=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movq mm4,mm0 >+ movq mm1,mm0 >+ punpcklwd mm4,mm6 >+ punpckhwd mm1,mm6 >+ movq mm0,mm4 >+ movq mm6,mm1 >+ pmaddwd mm4,[GOTOFF(ebx,PW_MF078_F117)] ; mm4=z3L >+ pmaddwd mm1,[GOTOFF(ebx,PW_MF078_F117)] ; mm1=z3H >+ pmaddwd mm0,[GOTOFF(ebx,PW_F117_F078)] ; mm0=z4L >+ pmaddwd mm6,[GOTOFF(ebx,PW_F117_F078)] ; mm6=z4H >+ >+ movq MMWORD [wk(0)], mm4 ; wk(0)=z3L >+ movq MMWORD [wk(1)], mm1 ; wk(1)=z3H >+ >+ ; (Original) >+ ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6; >+ ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869; >+ ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4; >+ ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223; >+ ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447; >+ ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447); >+ ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223); >+ ; data7 = tmp4 + z3; data5 = tmp5 + z4; >+ ; data3 = tmp6 + z3; data1 = tmp7 + z4; >+ >+ movq mm4,mm2 >+ movq mm1,mm2 >+ punpcklwd mm4,mm7 >+ punpckhwd mm1,mm7 >+ movq mm2,mm4 >+ movq mm7,mm1 >+ pmaddwd mm4,[GOTOFF(ebx,PW_MF060_MF089)] ; mm4=tmp4L >+ pmaddwd mm1,[GOTOFF(ebx,PW_MF060_MF089)] ; mm1=tmp4H >+ pmaddwd mm2,[GOTOFF(ebx,PW_MF089_F060)] ; mm2=tmp7L >+ pmaddwd mm7,[GOTOFF(ebx,PW_MF089_F060)] ; mm7=tmp7H >+ >+ paddd mm4, MMWORD [wk(0)] ; mm4=data7L >+ paddd mm1, MMWORD [wk(1)] ; mm1=data7H >+ paddd mm2,mm0 ; mm2=data1L >+ paddd mm7,mm6 ; mm7=data1H >+ >+ paddd mm4,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd mm1,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad mm4,DESCALE_P2 >+ psrad mm1,DESCALE_P2 >+ paddd mm2,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd mm7,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad mm2,DESCALE_P2 >+ psrad mm7,DESCALE_P2 >+ >+ packssdw mm4,mm1 ; mm4=data7 >+ packssdw mm2,mm7 ; mm2=data1 >+ >+ movq MMWORD [MMBLOCK(7,0,edx,SIZEOF_DCTELEM)], mm4 >+ movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_DCTELEM)], mm2 >+ >+ movq mm1,mm3 >+ movq mm7,mm3 >+ punpcklwd mm1,mm5 >+ punpckhwd mm7,mm5 >+ movq mm3,mm1 >+ movq mm5,mm7 >+ pmaddwd mm1,[GOTOFF(ebx,PW_MF050_MF256)] ; mm1=tmp5L >+ pmaddwd mm7,[GOTOFF(ebx,PW_MF050_MF256)] ; mm7=tmp5H >+ pmaddwd mm3,[GOTOFF(ebx,PW_MF256_F050)] ; mm3=tmp6L >+ pmaddwd mm5,[GOTOFF(ebx,PW_MF256_F050)] ; mm5=tmp6H >+ >+ paddd mm1,mm0 ; mm1=data5L >+ paddd mm7,mm6 ; mm7=data5H >+ paddd mm3, MMWORD [wk(0)] ; mm3=data3L >+ paddd mm5, MMWORD [wk(1)] ; mm5=data3H >+ >+ paddd mm1,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd mm7,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad mm1,DESCALE_P2 >+ psrad mm7,DESCALE_P2 >+ paddd mm3,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd mm5,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad mm3,DESCALE_P2 >+ psrad mm5,DESCALE_P2 >+ >+ packssdw mm1,mm7 ; mm1=data5 >+ packssdw mm3,mm5 ; mm3=data3 >+ >+ movq MMWORD [MMBLOCK(5,0,edx,SIZEOF_DCTELEM)], mm1 >+ movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_DCTELEM)], mm3 >+ >+ add edx, byte 4*SIZEOF_DCTELEM >+ dec ecx >+ jnz near .columnloop >+ >+ emms ; empty MMX state >+ >+; pop edi ; unused >+; pop esi ; unused >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ poppic ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jfss2fst-64.asm b/modules/libjpeg-turbo/simd/jfss2fst-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jfss2fst-64.asm >@@ -0,0 +1,392 @@ >+; >+; jfss2fst-64.asm - fast integer FDCT (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a fast, not so accurate integer implementation of >+; the forward DCT (Discrete Cosine Transform). The following code is >+; based directly on the IJG's original jfdctfst.c; see the jfdctfst.c >+; for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 8 ; 14 is also OK. >+ >+%if CONST_BITS == 8 >+F_0_382 equ 98 ; FIX(0.382683433) >+F_0_541 equ 139 ; FIX(0.541196100) >+F_0_707 equ 181 ; FIX(0.707106781) >+F_1_306 equ 334 ; FIX(1.306562965) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_382 equ DESCALE( 410903207,30-CONST_BITS) ; FIX(0.382683433) >+F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100) >+F_0_707 equ DESCALE( 759250124,30-CONST_BITS) ; FIX(0.707106781) >+F_1_306 equ DESCALE(1402911301,30-CONST_BITS) ; FIX(1.306562965) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow) >+; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw) >+ >+%define PRE_MULTIPLY_SCALE_BITS 2 >+%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS) >+ >+ alignz 16 >+ global EXTN(jconst_fdct_ifast_sse2) >+ >+EXTN(jconst_fdct_ifast_sse2): >+ >+PW_F0707 times 8 dw F_0_707 << CONST_SHIFT >+PW_F0382 times 8 dw F_0_382 << CONST_SHIFT >+PW_F0541 times 8 dw F_0_541 << CONST_SHIFT >+PW_F1306 times 8 dw F_1_306 << CONST_SHIFT >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Perform the forward DCT on one block of samples. >+; >+; GLOBAL(void) >+; jsimd_fdct_ifast_sse2 (DCTELEM * data) >+; >+ >+; r10 = DCTELEM * data >+ >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_fdct_ifast_sse2) >+ >+EXTN(jsimd_fdct_ifast_sse2): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [wk(0)] >+ collect_args >+ >+ ; ---- Pass 1: process rows. >+ >+ mov rdx, r10 ; (DCTELEM *) >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)] >+ >+ ; xmm0=(00 01 02 03 04 05 06 07), xmm2=(20 21 22 23 24 25 26 27) >+ ; xmm1=(10 11 12 13 14 15 16 17), xmm3=(30 31 32 33 34 35 36 37) >+ >+ movdqa xmm4,xmm0 ; transpose coefficients(phase 1) >+ punpcklwd xmm0,xmm1 ; xmm0=(00 10 01 11 02 12 03 13) >+ punpckhwd xmm4,xmm1 ; xmm4=(04 14 05 15 06 16 07 17) >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 1) >+ punpcklwd xmm2,xmm3 ; xmm2=(20 30 21 31 22 32 23 33) >+ punpckhwd xmm5,xmm3 ; xmm5=(24 34 25 35 26 36 27 37) >+ >+ movdqa xmm6, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm7, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_DCTELEM)] >+ >+ ; xmm6=( 4 12 20 28 36 44 52 60), xmm1=( 6 14 22 30 38 46 54 62) >+ ; xmm7=( 5 13 21 29 37 45 53 61), xmm3=( 7 15 23 31 39 47 55 63) >+ >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(20 30 21 31 22 32 23 33) >+ movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(24 34 25 35 26 36 27 37) >+ >+ movdqa xmm2,xmm6 ; transpose coefficients(phase 1) >+ punpcklwd xmm6,xmm7 ; xmm6=(40 50 41 51 42 52 43 53) >+ punpckhwd xmm2,xmm7 ; xmm2=(44 54 45 55 46 56 47 57) >+ movdqa xmm5,xmm1 ; transpose coefficients(phase 1) >+ punpcklwd xmm1,xmm3 ; xmm1=(60 70 61 71 62 72 63 73) >+ punpckhwd xmm5,xmm3 ; xmm5=(64 74 65 75 66 76 67 77) >+ >+ movdqa xmm7,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm1 ; xmm6=(40 50 60 70 41 51 61 71) >+ punpckhdq xmm7,xmm1 ; xmm7=(42 52 62 72 43 53 63 73) >+ movdqa xmm3,xmm2 ; transpose coefficients(phase 2) >+ punpckldq xmm2,xmm5 ; xmm2=(44 54 64 74 45 55 65 75) >+ punpckhdq xmm3,xmm5 ; xmm3=(46 56 66 76 47 57 67 77) >+ >+ movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(20 30 21 31 22 32 23 33) >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(24 34 25 35 26 36 27 37) >+ movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=(42 52 62 72 43 53 63 73) >+ movdqa XMMWORD [wk(1)], xmm2 ; wk(1)=(44 54 64 74 45 55 65 75) >+ >+ movdqa xmm7,xmm0 ; transpose coefficients(phase 2) >+ punpckldq xmm0,xmm1 ; xmm0=(00 10 20 30 01 11 21 31) >+ punpckhdq xmm7,xmm1 ; xmm7=(02 12 22 32 03 13 23 33) >+ movdqa xmm2,xmm4 ; transpose coefficients(phase 2) >+ punpckldq xmm4,xmm5 ; xmm4=(04 14 24 34 05 15 25 35) >+ punpckhdq xmm2,xmm5 ; xmm2=(06 16 26 36 07 17 27 37) >+ >+ movdqa xmm1,xmm0 ; transpose coefficients(phase 3) >+ punpcklqdq xmm0,xmm6 ; xmm0=(00 10 20 30 40 50 60 70)=data0 >+ punpckhqdq xmm1,xmm6 ; xmm1=(01 11 21 31 41 51 61 71)=data1 >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 3) >+ punpcklqdq xmm2,xmm3 ; xmm2=(06 16 26 36 46 56 66 76)=data6 >+ punpckhqdq xmm5,xmm3 ; xmm5=(07 17 27 37 47 57 67 77)=data7 >+ >+ movdqa xmm6,xmm1 >+ movdqa xmm3,xmm0 >+ psubw xmm1,xmm2 ; xmm1=data1-data6=tmp6 >+ psubw xmm0,xmm5 ; xmm0=data0-data7=tmp7 >+ paddw xmm6,xmm2 ; xmm6=data1+data6=tmp1 >+ paddw xmm3,xmm5 ; xmm3=data0+data7=tmp0 >+ >+ movdqa xmm2, XMMWORD [wk(0)] ; xmm2=(42 52 62 72 43 53 63 73) >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(44 54 64 74 45 55 65 75) >+ movdqa XMMWORD [wk(0)], xmm1 ; wk(0)=tmp6 >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp7 >+ >+ movdqa xmm1,xmm7 ; transpose coefficients(phase 3) >+ punpcklqdq xmm7,xmm2 ; xmm7=(02 12 22 32 42 52 62 72)=data2 >+ punpckhqdq xmm1,xmm2 ; xmm1=(03 13 23 33 43 53 63 73)=data3 >+ movdqa xmm0,xmm4 ; transpose coefficients(phase 3) >+ punpcklqdq xmm4,xmm5 ; xmm4=(04 14 24 34 44 54 64 74)=data4 >+ punpckhqdq xmm0,xmm5 ; xmm0=(05 15 25 35 45 55 65 75)=data5 >+ >+ movdqa xmm2,xmm1 >+ movdqa xmm5,xmm7 >+ paddw xmm1,xmm4 ; xmm1=data3+data4=tmp3 >+ paddw xmm7,xmm0 ; xmm7=data2+data5=tmp2 >+ psubw xmm2,xmm4 ; xmm2=data3-data4=tmp4 >+ psubw xmm5,xmm0 ; xmm5=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movdqa xmm4,xmm3 >+ movdqa xmm0,xmm6 >+ psubw xmm3,xmm1 ; xmm3=tmp13 >+ psubw xmm6,xmm7 ; xmm6=tmp12 >+ paddw xmm4,xmm1 ; xmm4=tmp10 >+ paddw xmm0,xmm7 ; xmm0=tmp11 >+ >+ paddw xmm6,xmm3 >+ psllw xmm6,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm6,[rel PW_F0707] ; xmm6=z1 >+ >+ movdqa xmm1,xmm4 >+ movdqa xmm7,xmm3 >+ psubw xmm4,xmm0 ; xmm4=data4 >+ psubw xmm3,xmm6 ; xmm3=data6 >+ paddw xmm1,xmm0 ; xmm1=data0 >+ paddw xmm7,xmm6 ; xmm7=data2 >+ >+ movdqa xmm0, XMMWORD [wk(0)] ; xmm0=tmp6 >+ movdqa xmm6, XMMWORD [wk(1)] ; xmm6=tmp7 >+ movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=data4 >+ movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=data6 >+ >+ ; -- Odd part >+ >+ paddw xmm2,xmm5 ; xmm2=tmp10 >+ paddw xmm5,xmm0 ; xmm5=tmp11 >+ paddw xmm0,xmm6 ; xmm0=tmp12, xmm6=tmp7 >+ >+ psllw xmm2,PRE_MULTIPLY_SCALE_BITS >+ psllw xmm0,PRE_MULTIPLY_SCALE_BITS >+ >+ psllw xmm5,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm5,[rel PW_F0707] ; xmm5=z3 >+ >+ movdqa xmm4,xmm2 ; xmm4=tmp10 >+ psubw xmm2,xmm0 >+ pmulhw xmm2,[rel PW_F0382] ; xmm2=z5 >+ pmulhw xmm4,[rel PW_F0541] ; xmm4=MULTIPLY(tmp10,FIX_0_541196) >+ pmulhw xmm0,[rel PW_F1306] ; xmm0=MULTIPLY(tmp12,FIX_1_306562) >+ paddw xmm4,xmm2 ; xmm4=z2 >+ paddw xmm0,xmm2 ; xmm0=z4 >+ >+ movdqa xmm3,xmm6 >+ psubw xmm6,xmm5 ; xmm6=z13 >+ paddw xmm3,xmm5 ; xmm3=z11 >+ >+ movdqa xmm2,xmm6 >+ movdqa xmm5,xmm3 >+ psubw xmm6,xmm4 ; xmm6=data3 >+ psubw xmm3,xmm0 ; xmm3=data7 >+ paddw xmm2,xmm4 ; xmm2=data5 >+ paddw xmm5,xmm0 ; xmm5=data1 >+ >+ ; ---- Pass 2: process columns. >+ >+ ; xmm1=(00 10 20 30 40 50 60 70), xmm7=(02 12 22 32 42 52 62 72) >+ ; xmm5=(01 11 21 31 41 51 61 71), xmm6=(03 13 23 33 43 53 63 73) >+ >+ movdqa xmm4,xmm1 ; transpose coefficients(phase 1) >+ punpcklwd xmm1,xmm5 ; xmm1=(00 01 10 11 20 21 30 31) >+ punpckhwd xmm4,xmm5 ; xmm4=(40 41 50 51 60 61 70 71) >+ movdqa xmm0,xmm7 ; transpose coefficients(phase 1) >+ punpcklwd xmm7,xmm6 ; xmm7=(02 03 12 13 22 23 32 33) >+ punpckhwd xmm0,xmm6 ; xmm0=(42 43 52 53 62 63 72 73) >+ >+ movdqa xmm5, XMMWORD [wk(0)] ; xmm5=col4 >+ movdqa xmm6, XMMWORD [wk(1)] ; xmm6=col6 >+ >+ ; xmm5=(04 14 24 34 44 54 64 74), xmm6=(06 16 26 36 46 56 66 76) >+ ; xmm2=(05 15 25 35 45 55 65 75), xmm3=(07 17 27 37 47 57 67 77) >+ >+ movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=(02 03 12 13 22 23 32 33) >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(42 43 52 53 62 63 72 73) >+ >+ movdqa xmm7,xmm5 ; transpose coefficients(phase 1) >+ punpcklwd xmm5,xmm2 ; xmm5=(04 05 14 15 24 25 34 35) >+ punpckhwd xmm7,xmm2 ; xmm7=(44 45 54 55 64 65 74 75) >+ movdqa xmm0,xmm6 ; transpose coefficients(phase 1) >+ punpcklwd xmm6,xmm3 ; xmm6=(06 07 16 17 26 27 36 37) >+ punpckhwd xmm0,xmm3 ; xmm0=(46 47 56 57 66 67 76 77) >+ >+ movdqa xmm2,xmm5 ; transpose coefficients(phase 2) >+ punpckldq xmm5,xmm6 ; xmm5=(04 05 06 07 14 15 16 17) >+ punpckhdq xmm2,xmm6 ; xmm2=(24 25 26 27 34 35 36 37) >+ movdqa xmm3,xmm7 ; transpose coefficients(phase 2) >+ punpckldq xmm7,xmm0 ; xmm7=(44 45 46 47 54 55 56 57) >+ punpckhdq xmm3,xmm0 ; xmm3=(64 65 66 67 74 75 76 77) >+ >+ movdqa xmm6, XMMWORD [wk(0)] ; xmm6=(02 03 12 13 22 23 32 33) >+ movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(42 43 52 53 62 63 72 73) >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(24 25 26 27 34 35 36 37) >+ movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=(44 45 46 47 54 55 56 57) >+ >+ movdqa xmm2,xmm1 ; transpose coefficients(phase 2) >+ punpckldq xmm1,xmm6 ; xmm1=(00 01 02 03 10 11 12 13) >+ punpckhdq xmm2,xmm6 ; xmm2=(20 21 22 23 30 31 32 33) >+ movdqa xmm7,xmm4 ; transpose coefficients(phase 2) >+ punpckldq xmm4,xmm0 ; xmm4=(40 41 42 43 50 51 52 53) >+ punpckhdq xmm7,xmm0 ; xmm7=(60 61 62 63 70 71 72 73) >+ >+ movdqa xmm6,xmm1 ; transpose coefficients(phase 3) >+ punpcklqdq xmm1,xmm5 ; xmm1=(00 01 02 03 04 05 06 07)=data0 >+ punpckhqdq xmm6,xmm5 ; xmm6=(10 11 12 13 14 15 16 17)=data1 >+ movdqa xmm0,xmm7 ; transpose coefficients(phase 3) >+ punpcklqdq xmm7,xmm3 ; xmm7=(60 61 62 63 64 65 66 67)=data6 >+ punpckhqdq xmm0,xmm3 ; xmm0=(70 71 72 73 74 75 76 77)=data7 >+ >+ movdqa xmm5,xmm6 >+ movdqa xmm3,xmm1 >+ psubw xmm6,xmm7 ; xmm6=data1-data6=tmp6 >+ psubw xmm1,xmm0 ; xmm1=data0-data7=tmp7 >+ paddw xmm5,xmm7 ; xmm5=data1+data6=tmp1 >+ paddw xmm3,xmm0 ; xmm3=data0+data7=tmp0 >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(24 25 26 27 34 35 36 37) >+ movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(44 45 46 47 54 55 56 57) >+ movdqa XMMWORD [wk(0)], xmm6 ; wk(0)=tmp6 >+ movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=tmp7 >+ >+ movdqa xmm6,xmm2 ; transpose coefficients(phase 3) >+ punpcklqdq xmm2,xmm7 ; xmm2=(20 21 22 23 24 25 26 27)=data2 >+ punpckhqdq xmm6,xmm7 ; xmm6=(30 31 32 33 34 35 36 37)=data3 >+ movdqa xmm1,xmm4 ; transpose coefficients(phase 3) >+ punpcklqdq xmm4,xmm0 ; xmm4=(40 41 42 43 44 45 46 47)=data4 >+ punpckhqdq xmm1,xmm0 ; xmm1=(50 51 52 53 54 55 56 57)=data5 >+ >+ movdqa xmm7,xmm6 >+ movdqa xmm0,xmm2 >+ paddw xmm6,xmm4 ; xmm6=data3+data4=tmp3 >+ paddw xmm2,xmm1 ; xmm2=data2+data5=tmp2 >+ psubw xmm7,xmm4 ; xmm7=data3-data4=tmp4 >+ psubw xmm0,xmm1 ; xmm0=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movdqa xmm4,xmm3 >+ movdqa xmm1,xmm5 >+ psubw xmm3,xmm6 ; xmm3=tmp13 >+ psubw xmm5,xmm2 ; xmm5=tmp12 >+ paddw xmm4,xmm6 ; xmm4=tmp10 >+ paddw xmm1,xmm2 ; xmm1=tmp11 >+ >+ paddw xmm5,xmm3 >+ psllw xmm5,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm5,[rel PW_F0707] ; xmm5=z1 >+ >+ movdqa xmm6,xmm4 >+ movdqa xmm2,xmm3 >+ psubw xmm4,xmm1 ; xmm4=data4 >+ psubw xmm3,xmm5 ; xmm3=data6 >+ paddw xmm6,xmm1 ; xmm6=data0 >+ paddw xmm2,xmm5 ; xmm2=data2 >+ >+ movdqa XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_DCTELEM)], xmm4 >+ movdqa XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_DCTELEM)], xmm3 >+ movdqa XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_DCTELEM)], xmm6 >+ movdqa XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_DCTELEM)], xmm2 >+ >+ ; -- Odd part >+ >+ movdqa xmm1, XMMWORD [wk(0)] ; xmm1=tmp6 >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp7 >+ >+ paddw xmm7,xmm0 ; xmm7=tmp10 >+ paddw xmm0,xmm1 ; xmm0=tmp11 >+ paddw xmm1,xmm5 ; xmm1=tmp12, xmm5=tmp7 >+ >+ psllw xmm7,PRE_MULTIPLY_SCALE_BITS >+ psllw xmm1,PRE_MULTIPLY_SCALE_BITS >+ >+ psllw xmm0,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm0,[rel PW_F0707] ; xmm0=z3 >+ >+ movdqa xmm4,xmm7 ; xmm4=tmp10 >+ psubw xmm7,xmm1 >+ pmulhw xmm7,[rel PW_F0382] ; xmm7=z5 >+ pmulhw xmm4,[rel PW_F0541] ; xmm4=MULTIPLY(tmp10,FIX_0_541196) >+ pmulhw xmm1,[rel PW_F1306] ; xmm1=MULTIPLY(tmp12,FIX_1_306562) >+ paddw xmm4,xmm7 ; xmm4=z2 >+ paddw xmm1,xmm7 ; xmm1=z4 >+ >+ movdqa xmm3,xmm5 >+ psubw xmm5,xmm0 ; xmm5=z13 >+ paddw xmm3,xmm0 ; xmm3=z11 >+ >+ movdqa xmm6,xmm5 >+ movdqa xmm2,xmm3 >+ psubw xmm5,xmm4 ; xmm5=data3 >+ psubw xmm3,xmm1 ; xmm3=data7 >+ paddw xmm6,xmm4 ; xmm6=data5 >+ paddw xmm2,xmm1 ; xmm2=data1 >+ >+ movdqa XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)], xmm5 >+ movdqa XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_DCTELEM)], xmm3 >+ movdqa XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)], xmm6 >+ movdqa XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)], xmm2 >+ >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jfss2fst.asm b/modules/libjpeg-turbo/simd/jfss2fst.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jfss2fst.asm >@@ -0,0 +1,404 @@ >+; >+; jfss2fst.asm - fast integer FDCT (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a fast, not so accurate integer implementation of >+; the forward DCT (Discrete Cosine Transform). The following code is >+; based directly on the IJG's original jfdctfst.c; see the jfdctfst.c >+; for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 8 ; 14 is also OK. >+ >+%if CONST_BITS == 8 >+F_0_382 equ 98 ; FIX(0.382683433) >+F_0_541 equ 139 ; FIX(0.541196100) >+F_0_707 equ 181 ; FIX(0.707106781) >+F_1_306 equ 334 ; FIX(1.306562965) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_382 equ DESCALE( 410903207,30-CONST_BITS) ; FIX(0.382683433) >+F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100) >+F_0_707 equ DESCALE( 759250124,30-CONST_BITS) ; FIX(0.707106781) >+F_1_306 equ DESCALE(1402911301,30-CONST_BITS) ; FIX(1.306562965) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow) >+; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw) >+ >+%define PRE_MULTIPLY_SCALE_BITS 2 >+%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS) >+ >+ alignz 16 >+ global EXTN(jconst_fdct_ifast_sse2) >+ >+EXTN(jconst_fdct_ifast_sse2): >+ >+PW_F0707 times 8 dw F_0_707 << CONST_SHIFT >+PW_F0382 times 8 dw F_0_382 << CONST_SHIFT >+PW_F0541 times 8 dw F_0_541 << CONST_SHIFT >+PW_F1306 times 8 dw F_1_306 << CONST_SHIFT >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform the forward DCT on one block of samples. >+; >+; GLOBAL(void) >+; jsimd_fdct_ifast_sse2 (DCTELEM * data) >+; >+ >+%define data(b) (b)+8 ; DCTELEM * data >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_fdct_ifast_sse2) >+ >+EXTN(jsimd_fdct_ifast_sse2): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic ebx >+; push ecx ; unused >+; push edx ; need not be preserved >+; push esi ; unused >+; push edi ; unused >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process rows. >+ >+ mov edx, POINTER [data(eax)] ; (DCTELEM *) >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_DCTELEM)] >+ >+ ; xmm0=(00 01 02 03 04 05 06 07), xmm2=(20 21 22 23 24 25 26 27) >+ ; xmm1=(10 11 12 13 14 15 16 17), xmm3=(30 31 32 33 34 35 36 37) >+ >+ movdqa xmm4,xmm0 ; transpose coefficients(phase 1) >+ punpcklwd xmm0,xmm1 ; xmm0=(00 10 01 11 02 12 03 13) >+ punpckhwd xmm4,xmm1 ; xmm4=(04 14 05 15 06 16 07 17) >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 1) >+ punpcklwd xmm2,xmm3 ; xmm2=(20 30 21 31 22 32 23 33) >+ punpckhwd xmm5,xmm3 ; xmm5=(24 34 25 35 26 36 27 37) >+ >+ movdqa xmm6, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm7, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_DCTELEM)] >+ >+ ; xmm6=( 4 12 20 28 36 44 52 60), xmm1=( 6 14 22 30 38 46 54 62) >+ ; xmm7=( 5 13 21 29 37 45 53 61), xmm3=( 7 15 23 31 39 47 55 63) >+ >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(20 30 21 31 22 32 23 33) >+ movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(24 34 25 35 26 36 27 37) >+ >+ movdqa xmm2,xmm6 ; transpose coefficients(phase 1) >+ punpcklwd xmm6,xmm7 ; xmm6=(40 50 41 51 42 52 43 53) >+ punpckhwd xmm2,xmm7 ; xmm2=(44 54 45 55 46 56 47 57) >+ movdqa xmm5,xmm1 ; transpose coefficients(phase 1) >+ punpcklwd xmm1,xmm3 ; xmm1=(60 70 61 71 62 72 63 73) >+ punpckhwd xmm5,xmm3 ; xmm5=(64 74 65 75 66 76 67 77) >+ >+ movdqa xmm7,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm1 ; xmm6=(40 50 60 70 41 51 61 71) >+ punpckhdq xmm7,xmm1 ; xmm7=(42 52 62 72 43 53 63 73) >+ movdqa xmm3,xmm2 ; transpose coefficients(phase 2) >+ punpckldq xmm2,xmm5 ; xmm2=(44 54 64 74 45 55 65 75) >+ punpckhdq xmm3,xmm5 ; xmm3=(46 56 66 76 47 57 67 77) >+ >+ movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(20 30 21 31 22 32 23 33) >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(24 34 25 35 26 36 27 37) >+ movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=(42 52 62 72 43 53 63 73) >+ movdqa XMMWORD [wk(1)], xmm2 ; wk(1)=(44 54 64 74 45 55 65 75) >+ >+ movdqa xmm7,xmm0 ; transpose coefficients(phase 2) >+ punpckldq xmm0,xmm1 ; xmm0=(00 10 20 30 01 11 21 31) >+ punpckhdq xmm7,xmm1 ; xmm7=(02 12 22 32 03 13 23 33) >+ movdqa xmm2,xmm4 ; transpose coefficients(phase 2) >+ punpckldq xmm4,xmm5 ; xmm4=(04 14 24 34 05 15 25 35) >+ punpckhdq xmm2,xmm5 ; xmm2=(06 16 26 36 07 17 27 37) >+ >+ movdqa xmm1,xmm0 ; transpose coefficients(phase 3) >+ punpcklqdq xmm0,xmm6 ; xmm0=(00 10 20 30 40 50 60 70)=data0 >+ punpckhqdq xmm1,xmm6 ; xmm1=(01 11 21 31 41 51 61 71)=data1 >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 3) >+ punpcklqdq xmm2,xmm3 ; xmm2=(06 16 26 36 46 56 66 76)=data6 >+ punpckhqdq xmm5,xmm3 ; xmm5=(07 17 27 37 47 57 67 77)=data7 >+ >+ movdqa xmm6,xmm1 >+ movdqa xmm3,xmm0 >+ psubw xmm1,xmm2 ; xmm1=data1-data6=tmp6 >+ psubw xmm0,xmm5 ; xmm0=data0-data7=tmp7 >+ paddw xmm6,xmm2 ; xmm6=data1+data6=tmp1 >+ paddw xmm3,xmm5 ; xmm3=data0+data7=tmp0 >+ >+ movdqa xmm2, XMMWORD [wk(0)] ; xmm2=(42 52 62 72 43 53 63 73) >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(44 54 64 74 45 55 65 75) >+ movdqa XMMWORD [wk(0)], xmm1 ; wk(0)=tmp6 >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp7 >+ >+ movdqa xmm1,xmm7 ; transpose coefficients(phase 3) >+ punpcklqdq xmm7,xmm2 ; xmm7=(02 12 22 32 42 52 62 72)=data2 >+ punpckhqdq xmm1,xmm2 ; xmm1=(03 13 23 33 43 53 63 73)=data3 >+ movdqa xmm0,xmm4 ; transpose coefficients(phase 3) >+ punpcklqdq xmm4,xmm5 ; xmm4=(04 14 24 34 44 54 64 74)=data4 >+ punpckhqdq xmm0,xmm5 ; xmm0=(05 15 25 35 45 55 65 75)=data5 >+ >+ movdqa xmm2,xmm1 >+ movdqa xmm5,xmm7 >+ paddw xmm1,xmm4 ; xmm1=data3+data4=tmp3 >+ paddw xmm7,xmm0 ; xmm7=data2+data5=tmp2 >+ psubw xmm2,xmm4 ; xmm2=data3-data4=tmp4 >+ psubw xmm5,xmm0 ; xmm5=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movdqa xmm4,xmm3 >+ movdqa xmm0,xmm6 >+ psubw xmm3,xmm1 ; xmm3=tmp13 >+ psubw xmm6,xmm7 ; xmm6=tmp12 >+ paddw xmm4,xmm1 ; xmm4=tmp10 >+ paddw xmm0,xmm7 ; xmm0=tmp11 >+ >+ paddw xmm6,xmm3 >+ psllw xmm6,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm6,[GOTOFF(ebx,PW_F0707)] ; xmm6=z1 >+ >+ movdqa xmm1,xmm4 >+ movdqa xmm7,xmm3 >+ psubw xmm4,xmm0 ; xmm4=data4 >+ psubw xmm3,xmm6 ; xmm3=data6 >+ paddw xmm1,xmm0 ; xmm1=data0 >+ paddw xmm7,xmm6 ; xmm7=data2 >+ >+ movdqa xmm0, XMMWORD [wk(0)] ; xmm0=tmp6 >+ movdqa xmm6, XMMWORD [wk(1)] ; xmm6=tmp7 >+ movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=data4 >+ movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=data6 >+ >+ ; -- Odd part >+ >+ paddw xmm2,xmm5 ; xmm2=tmp10 >+ paddw xmm5,xmm0 ; xmm5=tmp11 >+ paddw xmm0,xmm6 ; xmm0=tmp12, xmm6=tmp7 >+ >+ psllw xmm2,PRE_MULTIPLY_SCALE_BITS >+ psllw xmm0,PRE_MULTIPLY_SCALE_BITS >+ >+ psllw xmm5,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm5,[GOTOFF(ebx,PW_F0707)] ; xmm5=z3 >+ >+ movdqa xmm4,xmm2 ; xmm4=tmp10 >+ psubw xmm2,xmm0 >+ pmulhw xmm2,[GOTOFF(ebx,PW_F0382)] ; xmm2=z5 >+ pmulhw xmm4,[GOTOFF(ebx,PW_F0541)] ; xmm4=MULTIPLY(tmp10,FIX_0_541196) >+ pmulhw xmm0,[GOTOFF(ebx,PW_F1306)] ; xmm0=MULTIPLY(tmp12,FIX_1_306562) >+ paddw xmm4,xmm2 ; xmm4=z2 >+ paddw xmm0,xmm2 ; xmm0=z4 >+ >+ movdqa xmm3,xmm6 >+ psubw xmm6,xmm5 ; xmm6=z13 >+ paddw xmm3,xmm5 ; xmm3=z11 >+ >+ movdqa xmm2,xmm6 >+ movdqa xmm5,xmm3 >+ psubw xmm6,xmm4 ; xmm6=data3 >+ psubw xmm3,xmm0 ; xmm3=data7 >+ paddw xmm2,xmm4 ; xmm2=data5 >+ paddw xmm5,xmm0 ; xmm5=data1 >+ >+ ; ---- Pass 2: process columns. >+ >+; mov edx, POINTER [data(eax)] ; (DCTELEM *) >+ >+ ; xmm1=(00 10 20 30 40 50 60 70), xmm7=(02 12 22 32 42 52 62 72) >+ ; xmm5=(01 11 21 31 41 51 61 71), xmm6=(03 13 23 33 43 53 63 73) >+ >+ movdqa xmm4,xmm1 ; transpose coefficients(phase 1) >+ punpcklwd xmm1,xmm5 ; xmm1=(00 01 10 11 20 21 30 31) >+ punpckhwd xmm4,xmm5 ; xmm4=(40 41 50 51 60 61 70 71) >+ movdqa xmm0,xmm7 ; transpose coefficients(phase 1) >+ punpcklwd xmm7,xmm6 ; xmm7=(02 03 12 13 22 23 32 33) >+ punpckhwd xmm0,xmm6 ; xmm0=(42 43 52 53 62 63 72 73) >+ >+ movdqa xmm5, XMMWORD [wk(0)] ; xmm5=col4 >+ movdqa xmm6, XMMWORD [wk(1)] ; xmm6=col6 >+ >+ ; xmm5=(04 14 24 34 44 54 64 74), xmm6=(06 16 26 36 46 56 66 76) >+ ; xmm2=(05 15 25 35 45 55 65 75), xmm3=(07 17 27 37 47 57 67 77) >+ >+ movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=(02 03 12 13 22 23 32 33) >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(42 43 52 53 62 63 72 73) >+ >+ movdqa xmm7,xmm5 ; transpose coefficients(phase 1) >+ punpcklwd xmm5,xmm2 ; xmm5=(04 05 14 15 24 25 34 35) >+ punpckhwd xmm7,xmm2 ; xmm7=(44 45 54 55 64 65 74 75) >+ movdqa xmm0,xmm6 ; transpose coefficients(phase 1) >+ punpcklwd xmm6,xmm3 ; xmm6=(06 07 16 17 26 27 36 37) >+ punpckhwd xmm0,xmm3 ; xmm0=(46 47 56 57 66 67 76 77) >+ >+ movdqa xmm2,xmm5 ; transpose coefficients(phase 2) >+ punpckldq xmm5,xmm6 ; xmm5=(04 05 06 07 14 15 16 17) >+ punpckhdq xmm2,xmm6 ; xmm2=(24 25 26 27 34 35 36 37) >+ movdqa xmm3,xmm7 ; transpose coefficients(phase 2) >+ punpckldq xmm7,xmm0 ; xmm7=(44 45 46 47 54 55 56 57) >+ punpckhdq xmm3,xmm0 ; xmm3=(64 65 66 67 74 75 76 77) >+ >+ movdqa xmm6, XMMWORD [wk(0)] ; xmm6=(02 03 12 13 22 23 32 33) >+ movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(42 43 52 53 62 63 72 73) >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(24 25 26 27 34 35 36 37) >+ movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=(44 45 46 47 54 55 56 57) >+ >+ movdqa xmm2,xmm1 ; transpose coefficients(phase 2) >+ punpckldq xmm1,xmm6 ; xmm1=(00 01 02 03 10 11 12 13) >+ punpckhdq xmm2,xmm6 ; xmm2=(20 21 22 23 30 31 32 33) >+ movdqa xmm7,xmm4 ; transpose coefficients(phase 2) >+ punpckldq xmm4,xmm0 ; xmm4=(40 41 42 43 50 51 52 53) >+ punpckhdq xmm7,xmm0 ; xmm7=(60 61 62 63 70 71 72 73) >+ >+ movdqa xmm6,xmm1 ; transpose coefficients(phase 3) >+ punpcklqdq xmm1,xmm5 ; xmm1=(00 01 02 03 04 05 06 07)=data0 >+ punpckhqdq xmm6,xmm5 ; xmm6=(10 11 12 13 14 15 16 17)=data1 >+ movdqa xmm0,xmm7 ; transpose coefficients(phase 3) >+ punpcklqdq xmm7,xmm3 ; xmm7=(60 61 62 63 64 65 66 67)=data6 >+ punpckhqdq xmm0,xmm3 ; xmm0=(70 71 72 73 74 75 76 77)=data7 >+ >+ movdqa xmm5,xmm6 >+ movdqa xmm3,xmm1 >+ psubw xmm6,xmm7 ; xmm6=data1-data6=tmp6 >+ psubw xmm1,xmm0 ; xmm1=data0-data7=tmp7 >+ paddw xmm5,xmm7 ; xmm5=data1+data6=tmp1 >+ paddw xmm3,xmm0 ; xmm3=data0+data7=tmp0 >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(24 25 26 27 34 35 36 37) >+ movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(44 45 46 47 54 55 56 57) >+ movdqa XMMWORD [wk(0)], xmm6 ; wk(0)=tmp6 >+ movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=tmp7 >+ >+ movdqa xmm6,xmm2 ; transpose coefficients(phase 3) >+ punpcklqdq xmm2,xmm7 ; xmm2=(20 21 22 23 24 25 26 27)=data2 >+ punpckhqdq xmm6,xmm7 ; xmm6=(30 31 32 33 34 35 36 37)=data3 >+ movdqa xmm1,xmm4 ; transpose coefficients(phase 3) >+ punpcklqdq xmm4,xmm0 ; xmm4=(40 41 42 43 44 45 46 47)=data4 >+ punpckhqdq xmm1,xmm0 ; xmm1=(50 51 52 53 54 55 56 57)=data5 >+ >+ movdqa xmm7,xmm6 >+ movdqa xmm0,xmm2 >+ paddw xmm6,xmm4 ; xmm6=data3+data4=tmp3 >+ paddw xmm2,xmm1 ; xmm2=data2+data5=tmp2 >+ psubw xmm7,xmm4 ; xmm7=data3-data4=tmp4 >+ psubw xmm0,xmm1 ; xmm0=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movdqa xmm4,xmm3 >+ movdqa xmm1,xmm5 >+ psubw xmm3,xmm6 ; xmm3=tmp13 >+ psubw xmm5,xmm2 ; xmm5=tmp12 >+ paddw xmm4,xmm6 ; xmm4=tmp10 >+ paddw xmm1,xmm2 ; xmm1=tmp11 >+ >+ paddw xmm5,xmm3 >+ psllw xmm5,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm5,[GOTOFF(ebx,PW_F0707)] ; xmm5=z1 >+ >+ movdqa xmm6,xmm4 >+ movdqa xmm2,xmm3 >+ psubw xmm4,xmm1 ; xmm4=data4 >+ psubw xmm3,xmm5 ; xmm3=data6 >+ paddw xmm6,xmm1 ; xmm6=data0 >+ paddw xmm2,xmm5 ; xmm2=data2 >+ >+ movdqa XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_DCTELEM)], xmm4 >+ movdqa XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_DCTELEM)], xmm3 >+ movdqa XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_DCTELEM)], xmm6 >+ movdqa XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_DCTELEM)], xmm2 >+ >+ ; -- Odd part >+ >+ movdqa xmm1, XMMWORD [wk(0)] ; xmm1=tmp6 >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp7 >+ >+ paddw xmm7,xmm0 ; xmm7=tmp10 >+ paddw xmm0,xmm1 ; xmm0=tmp11 >+ paddw xmm1,xmm5 ; xmm1=tmp12, xmm5=tmp7 >+ >+ psllw xmm7,PRE_MULTIPLY_SCALE_BITS >+ psllw xmm1,PRE_MULTIPLY_SCALE_BITS >+ >+ psllw xmm0,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm0,[GOTOFF(ebx,PW_F0707)] ; xmm0=z3 >+ >+ movdqa xmm4,xmm7 ; xmm4=tmp10 >+ psubw xmm7,xmm1 >+ pmulhw xmm7,[GOTOFF(ebx,PW_F0382)] ; xmm7=z5 >+ pmulhw xmm4,[GOTOFF(ebx,PW_F0541)] ; xmm4=MULTIPLY(tmp10,FIX_0_541196) >+ pmulhw xmm1,[GOTOFF(ebx,PW_F1306)] ; xmm1=MULTIPLY(tmp12,FIX_1_306562) >+ paddw xmm4,xmm7 ; xmm4=z2 >+ paddw xmm1,xmm7 ; xmm1=z4 >+ >+ movdqa xmm3,xmm5 >+ psubw xmm5,xmm0 ; xmm5=z13 >+ paddw xmm3,xmm0 ; xmm3=z11 >+ >+ movdqa xmm6,xmm5 >+ movdqa xmm2,xmm3 >+ psubw xmm5,xmm4 ; xmm5=data3 >+ psubw xmm3,xmm1 ; xmm3=data7 >+ paddw xmm6,xmm4 ; xmm6=data5 >+ paddw xmm2,xmm1 ; xmm2=data1 >+ >+ movdqa XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_DCTELEM)], xmm5 >+ movdqa XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_DCTELEM)], xmm3 >+ movdqa XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_DCTELEM)], xmm6 >+ movdqa XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_DCTELEM)], xmm2 >+ >+; pop edi ; unused >+; pop esi ; unused >+; pop edx ; need not be preserved >+; pop ecx ; unused >+ poppic ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jfss2int-64.asm b/modules/libjpeg-turbo/simd/jfss2int-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jfss2int-64.asm >@@ -0,0 +1,622 @@ >+; >+; jfss2int-64.asm - accurate integer FDCT (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a slow-but-accurate integer implementation of the >+; forward DCT (Discrete Cosine Transform). The following code is based >+; directly on the IJG's original jfdctint.c; see the jfdctint.c for >+; more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 13 >+%define PASS1_BITS 2 >+ >+%define DESCALE_P1 (CONST_BITS-PASS1_BITS) >+%define DESCALE_P2 (CONST_BITS+PASS1_BITS) >+ >+%if CONST_BITS == 13 >+F_0_298 equ 2446 ; FIX(0.298631336) >+F_0_390 equ 3196 ; FIX(0.390180644) >+F_0_541 equ 4433 ; FIX(0.541196100) >+F_0_765 equ 6270 ; FIX(0.765366865) >+F_0_899 equ 7373 ; FIX(0.899976223) >+F_1_175 equ 9633 ; FIX(1.175875602) >+F_1_501 equ 12299 ; FIX(1.501321110) >+F_1_847 equ 15137 ; FIX(1.847759065) >+F_1_961 equ 16069 ; FIX(1.961570560) >+F_2_053 equ 16819 ; FIX(2.053119869) >+F_2_562 equ 20995 ; FIX(2.562915447) >+F_3_072 equ 25172 ; FIX(3.072711026) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_298 equ DESCALE( 320652955,30-CONST_BITS) ; FIX(0.298631336) >+F_0_390 equ DESCALE( 418953276,30-CONST_BITS) ; FIX(0.390180644) >+F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100) >+F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865) >+F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223) >+F_1_175 equ DESCALE(1262586813,30-CONST_BITS) ; FIX(1.175875602) >+F_1_501 equ DESCALE(1612031267,30-CONST_BITS) ; FIX(1.501321110) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_1_961 equ DESCALE(2106220350,30-CONST_BITS) ; FIX(1.961570560) >+F_2_053 equ DESCALE(2204520673,30-CONST_BITS) ; FIX(2.053119869) >+F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447) >+F_3_072 equ DESCALE(3299298341,30-CONST_BITS) ; FIX(3.072711026) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_fdct_islow_sse2) >+ >+EXTN(jconst_fdct_islow_sse2): >+ >+PW_F130_F054 times 4 dw (F_0_541+F_0_765), F_0_541 >+PW_F054_MF130 times 4 dw F_0_541, (F_0_541-F_1_847) >+PW_MF078_F117 times 4 dw (F_1_175-F_1_961), F_1_175 >+PW_F117_F078 times 4 dw F_1_175, (F_1_175-F_0_390) >+PW_MF060_MF089 times 4 dw (F_0_298-F_0_899),-F_0_899 >+PW_MF089_F060 times 4 dw -F_0_899, (F_1_501-F_0_899) >+PW_MF050_MF256 times 4 dw (F_2_053-F_2_562),-F_2_562 >+PW_MF256_F050 times 4 dw -F_2_562, (F_3_072-F_2_562) >+PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1-1) >+PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2-1) >+PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS-1) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Perform the forward DCT on one block of samples. >+; >+; GLOBAL(void) >+; jsimd_fdct_islow_sse2 (DCTELEM * data) >+; >+ >+; r10 = DCTELEM * data >+ >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 6 >+ >+ align 16 >+ global EXTN(jsimd_fdct_islow_sse2) >+ >+EXTN(jsimd_fdct_islow_sse2): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [wk(0)] >+ collect_args >+ >+ ; ---- Pass 1: process rows. >+ >+ mov rdx, r10 ; (DCTELEM *) >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)] >+ >+ ; xmm0=(00 01 02 03 04 05 06 07), xmm2=(20 21 22 23 24 25 26 27) >+ ; xmm1=(10 11 12 13 14 15 16 17), xmm3=(30 31 32 33 34 35 36 37) >+ >+ movdqa xmm4,xmm0 ; transpose coefficients(phase 1) >+ punpcklwd xmm0,xmm1 ; xmm0=(00 10 01 11 02 12 03 13) >+ punpckhwd xmm4,xmm1 ; xmm4=(04 14 05 15 06 16 07 17) >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 1) >+ punpcklwd xmm2,xmm3 ; xmm2=(20 30 21 31 22 32 23 33) >+ punpckhwd xmm5,xmm3 ; xmm5=(24 34 25 35 26 36 27 37) >+ >+ movdqa xmm6, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm7, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_DCTELEM)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_DCTELEM)] >+ >+ ; xmm6=( 4 12 20 28 36 44 52 60), xmm1=( 6 14 22 30 38 46 54 62) >+ ; xmm7=( 5 13 21 29 37 45 53 61), xmm3=( 7 15 23 31 39 47 55 63) >+ >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(20 30 21 31 22 32 23 33) >+ movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(24 34 25 35 26 36 27 37) >+ >+ movdqa xmm2,xmm6 ; transpose coefficients(phase 1) >+ punpcklwd xmm6,xmm7 ; xmm6=(40 50 41 51 42 52 43 53) >+ punpckhwd xmm2,xmm7 ; xmm2=(44 54 45 55 46 56 47 57) >+ movdqa xmm5,xmm1 ; transpose coefficients(phase 1) >+ punpcklwd xmm1,xmm3 ; xmm1=(60 70 61 71 62 72 63 73) >+ punpckhwd xmm5,xmm3 ; xmm5=(64 74 65 75 66 76 67 77) >+ >+ movdqa xmm7,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm1 ; xmm6=(40 50 60 70 41 51 61 71) >+ punpckhdq xmm7,xmm1 ; xmm7=(42 52 62 72 43 53 63 73) >+ movdqa xmm3,xmm2 ; transpose coefficients(phase 2) >+ punpckldq xmm2,xmm5 ; xmm2=(44 54 64 74 45 55 65 75) >+ punpckhdq xmm3,xmm5 ; xmm3=(46 56 66 76 47 57 67 77) >+ >+ movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(20 30 21 31 22 32 23 33) >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(24 34 25 35 26 36 27 37) >+ movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=(42 52 62 72 43 53 63 73) >+ movdqa XMMWORD [wk(3)], xmm2 ; wk(3)=(44 54 64 74 45 55 65 75) >+ >+ movdqa xmm7,xmm0 ; transpose coefficients(phase 2) >+ punpckldq xmm0,xmm1 ; xmm0=(00 10 20 30 01 11 21 31) >+ punpckhdq xmm7,xmm1 ; xmm7=(02 12 22 32 03 13 23 33) >+ movdqa xmm2,xmm4 ; transpose coefficients(phase 2) >+ punpckldq xmm4,xmm5 ; xmm4=(04 14 24 34 05 15 25 35) >+ punpckhdq xmm2,xmm5 ; xmm2=(06 16 26 36 07 17 27 37) >+ >+ movdqa xmm1,xmm0 ; transpose coefficients(phase 3) >+ punpcklqdq xmm0,xmm6 ; xmm0=(00 10 20 30 40 50 60 70)=data0 >+ punpckhqdq xmm1,xmm6 ; xmm1=(01 11 21 31 41 51 61 71)=data1 >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 3) >+ punpcklqdq xmm2,xmm3 ; xmm2=(06 16 26 36 46 56 66 76)=data6 >+ punpckhqdq xmm5,xmm3 ; xmm5=(07 17 27 37 47 57 67 77)=data7 >+ >+ movdqa xmm6,xmm1 >+ movdqa xmm3,xmm0 >+ psubw xmm1,xmm2 ; xmm1=data1-data6=tmp6 >+ psubw xmm0,xmm5 ; xmm0=data0-data7=tmp7 >+ paddw xmm6,xmm2 ; xmm6=data1+data6=tmp1 >+ paddw xmm3,xmm5 ; xmm3=data0+data7=tmp0 >+ >+ movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(42 52 62 72 43 53 63 73) >+ movdqa xmm5, XMMWORD [wk(3)] ; xmm5=(44 54 64 74 45 55 65 75) >+ movdqa XMMWORD [wk(0)], xmm1 ; wk(0)=tmp6 >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp7 >+ >+ movdqa xmm1,xmm7 ; transpose coefficients(phase 3) >+ punpcklqdq xmm7,xmm2 ; xmm7=(02 12 22 32 42 52 62 72)=data2 >+ punpckhqdq xmm1,xmm2 ; xmm1=(03 13 23 33 43 53 63 73)=data3 >+ movdqa xmm0,xmm4 ; transpose coefficients(phase 3) >+ punpcklqdq xmm4,xmm5 ; xmm4=(04 14 24 34 44 54 64 74)=data4 >+ punpckhqdq xmm0,xmm5 ; xmm0=(05 15 25 35 45 55 65 75)=data5 >+ >+ movdqa xmm2,xmm1 >+ movdqa xmm5,xmm7 >+ paddw xmm1,xmm4 ; xmm1=data3+data4=tmp3 >+ paddw xmm7,xmm0 ; xmm7=data2+data5=tmp2 >+ psubw xmm2,xmm4 ; xmm2=data3-data4=tmp4 >+ psubw xmm5,xmm0 ; xmm5=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movdqa xmm4,xmm3 >+ movdqa xmm0,xmm6 >+ paddw xmm3,xmm1 ; xmm3=tmp10 >+ paddw xmm6,xmm7 ; xmm6=tmp11 >+ psubw xmm4,xmm1 ; xmm4=tmp13 >+ psubw xmm0,xmm7 ; xmm0=tmp12 >+ >+ movdqa xmm1,xmm3 >+ paddw xmm3,xmm6 ; xmm3=tmp10+tmp11 >+ psubw xmm1,xmm6 ; xmm1=tmp10-tmp11 >+ >+ psllw xmm3,PASS1_BITS ; xmm3=data0 >+ psllw xmm1,PASS1_BITS ; xmm1=data4 >+ >+ movdqa XMMWORD [wk(2)], xmm3 ; wk(2)=data0 >+ movdqa XMMWORD [wk(3)], xmm1 ; wk(3)=data4 >+ >+ ; (Original) >+ ; z1 = (tmp12 + tmp13) * 0.541196100; >+ ; data2 = z1 + tmp13 * 0.765366865; >+ ; data6 = z1 + tmp12 * -1.847759065; >+ ; >+ ; (This implementation) >+ ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100; >+ ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065); >+ >+ movdqa xmm7,xmm4 ; xmm4=tmp13 >+ movdqa xmm6,xmm4 >+ punpcklwd xmm7,xmm0 ; xmm0=tmp12 >+ punpckhwd xmm6,xmm0 >+ movdqa xmm4,xmm7 >+ movdqa xmm0,xmm6 >+ pmaddwd xmm7,[rel PW_F130_F054] ; xmm7=data2L >+ pmaddwd xmm6,[rel PW_F130_F054] ; xmm6=data2H >+ pmaddwd xmm4,[rel PW_F054_MF130] ; xmm4=data6L >+ pmaddwd xmm0,[rel PW_F054_MF130] ; xmm0=data6H >+ >+ paddd xmm7,[rel PD_DESCALE_P1] >+ paddd xmm6,[rel PD_DESCALE_P1] >+ psrad xmm7,DESCALE_P1 >+ psrad xmm6,DESCALE_P1 >+ paddd xmm4,[rel PD_DESCALE_P1] >+ paddd xmm0,[rel PD_DESCALE_P1] >+ psrad xmm4,DESCALE_P1 >+ psrad xmm0,DESCALE_P1 >+ >+ packssdw xmm7,xmm6 ; xmm7=data2 >+ packssdw xmm4,xmm0 ; xmm4=data6 >+ >+ movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=data2 >+ movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=data6 >+ >+ ; -- Odd part >+ >+ movdqa xmm3, XMMWORD [wk(0)] ; xmm3=tmp6 >+ movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp7 >+ >+ movdqa xmm6,xmm2 ; xmm2=tmp4 >+ movdqa xmm0,xmm5 ; xmm5=tmp5 >+ paddw xmm6,xmm3 ; xmm6=z3 >+ paddw xmm0,xmm1 ; xmm0=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movdqa xmm7,xmm6 >+ movdqa xmm4,xmm6 >+ punpcklwd xmm7,xmm0 >+ punpckhwd xmm4,xmm0 >+ movdqa xmm6,xmm7 >+ movdqa xmm0,xmm4 >+ pmaddwd xmm7,[rel PW_MF078_F117] ; xmm7=z3L >+ pmaddwd xmm4,[rel PW_MF078_F117] ; xmm4=z3H >+ pmaddwd xmm6,[rel PW_F117_F078] ; xmm6=z4L >+ pmaddwd xmm0,[rel PW_F117_F078] ; xmm0=z4H >+ >+ movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=z3L >+ movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=z3H >+ >+ ; (Original) >+ ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6; >+ ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869; >+ ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4; >+ ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223; >+ ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447; >+ ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447); >+ ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223); >+ ; data7 = tmp4 + z3; data5 = tmp5 + z4; >+ ; data3 = tmp6 + z3; data1 = tmp7 + z4; >+ >+ movdqa xmm7,xmm2 >+ movdqa xmm4,xmm2 >+ punpcklwd xmm7,xmm1 >+ punpckhwd xmm4,xmm1 >+ movdqa xmm2,xmm7 >+ movdqa xmm1,xmm4 >+ pmaddwd xmm7,[rel PW_MF060_MF089] ; xmm7=tmp4L >+ pmaddwd xmm4,[rel PW_MF060_MF089] ; xmm4=tmp4H >+ pmaddwd xmm2,[rel PW_MF089_F060] ; xmm2=tmp7L >+ pmaddwd xmm1,[rel PW_MF089_F060] ; xmm1=tmp7H >+ >+ paddd xmm7, XMMWORD [wk(0)] ; xmm7=data7L >+ paddd xmm4, XMMWORD [wk(1)] ; xmm4=data7H >+ paddd xmm2,xmm6 ; xmm2=data1L >+ paddd xmm1,xmm0 ; xmm1=data1H >+ >+ paddd xmm7,[rel PD_DESCALE_P1] >+ paddd xmm4,[rel PD_DESCALE_P1] >+ psrad xmm7,DESCALE_P1 >+ psrad xmm4,DESCALE_P1 >+ paddd xmm2,[rel PD_DESCALE_P1] >+ paddd xmm1,[rel PD_DESCALE_P1] >+ psrad xmm2,DESCALE_P1 >+ psrad xmm1,DESCALE_P1 >+ >+ packssdw xmm7,xmm4 ; xmm7=data7 >+ packssdw xmm2,xmm1 ; xmm2=data1 >+ >+ movdqa xmm4,xmm5 >+ movdqa xmm1,xmm5 >+ punpcklwd xmm4,xmm3 >+ punpckhwd xmm1,xmm3 >+ movdqa xmm5,xmm4 >+ movdqa xmm3,xmm1 >+ pmaddwd xmm4,[rel PW_MF050_MF256] ; xmm4=tmp5L >+ pmaddwd xmm1,[rel PW_MF050_MF256] ; xmm1=tmp5H >+ pmaddwd xmm5,[rel PW_MF256_F050] ; xmm5=tmp6L >+ pmaddwd xmm3,[rel PW_MF256_F050] ; xmm3=tmp6H >+ >+ paddd xmm4,xmm6 ; xmm4=data5L >+ paddd xmm1,xmm0 ; xmm1=data5H >+ paddd xmm5, XMMWORD [wk(0)] ; xmm5=data3L >+ paddd xmm3, XMMWORD [wk(1)] ; xmm3=data3H >+ >+ paddd xmm4,[rel PD_DESCALE_P1] >+ paddd xmm1,[rel PD_DESCALE_P1] >+ psrad xmm4,DESCALE_P1 >+ psrad xmm1,DESCALE_P1 >+ paddd xmm5,[rel PD_DESCALE_P1] >+ paddd xmm3,[rel PD_DESCALE_P1] >+ psrad xmm5,DESCALE_P1 >+ psrad xmm3,DESCALE_P1 >+ >+ packssdw xmm4,xmm1 ; xmm4=data5 >+ packssdw xmm5,xmm3 ; xmm5=data3 >+ >+ ; ---- Pass 2: process columns. >+ >+ movdqa xmm6, XMMWORD [wk(2)] ; xmm6=col0 >+ movdqa xmm0, XMMWORD [wk(4)] ; xmm0=col2 >+ >+ ; xmm6=(00 10 20 30 40 50 60 70), xmm0=(02 12 22 32 42 52 62 72) >+ ; xmm2=(01 11 21 31 41 51 61 71), xmm5=(03 13 23 33 43 53 63 73) >+ >+ movdqa xmm1,xmm6 ; transpose coefficients(phase 1) >+ punpcklwd xmm6,xmm2 ; xmm6=(00 01 10 11 20 21 30 31) >+ punpckhwd xmm1,xmm2 ; xmm1=(40 41 50 51 60 61 70 71) >+ movdqa xmm3,xmm0 ; transpose coefficients(phase 1) >+ punpcklwd xmm0,xmm5 ; xmm0=(02 03 12 13 22 23 32 33) >+ punpckhwd xmm3,xmm5 ; xmm3=(42 43 52 53 62 63 72 73) >+ >+ movdqa xmm2, XMMWORD [wk(3)] ; xmm2=col4 >+ movdqa xmm5, XMMWORD [wk(5)] ; xmm5=col6 >+ >+ ; xmm2=(04 14 24 34 44 54 64 74), xmm5=(06 16 26 36 46 56 66 76) >+ ; xmm4=(05 15 25 35 45 55 65 75), xmm7=(07 17 27 37 47 57 67 77) >+ >+ movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=(02 03 12 13 22 23 32 33) >+ movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(42 43 52 53 62 63 72 73) >+ >+ movdqa xmm0,xmm2 ; transpose coefficients(phase 1) >+ punpcklwd xmm2,xmm4 ; xmm2=(04 05 14 15 24 25 34 35) >+ punpckhwd xmm0,xmm4 ; xmm0=(44 45 54 55 64 65 74 75) >+ movdqa xmm3,xmm5 ; transpose coefficients(phase 1) >+ punpcklwd xmm5,xmm7 ; xmm5=(06 07 16 17 26 27 36 37) >+ punpckhwd xmm3,xmm7 ; xmm3=(46 47 56 57 66 67 76 77) >+ >+ movdqa xmm4,xmm2 ; transpose coefficients(phase 2) >+ punpckldq xmm2,xmm5 ; xmm2=(04 05 06 07 14 15 16 17) >+ punpckhdq xmm4,xmm5 ; xmm4=(24 25 26 27 34 35 36 37) >+ movdqa xmm7,xmm0 ; transpose coefficients(phase 2) >+ punpckldq xmm0,xmm3 ; xmm0=(44 45 46 47 54 55 56 57) >+ punpckhdq xmm7,xmm3 ; xmm7=(64 65 66 67 74 75 76 77) >+ >+ movdqa xmm5, XMMWORD [wk(0)] ; xmm5=(02 03 12 13 22 23 32 33) >+ movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(42 43 52 53 62 63 72 73) >+ movdqa XMMWORD [wk(2)], xmm4 ; wk(2)=(24 25 26 27 34 35 36 37) >+ movdqa XMMWORD [wk(3)], xmm0 ; wk(3)=(44 45 46 47 54 55 56 57) >+ >+ movdqa xmm4,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm5 ; xmm6=(00 01 02 03 10 11 12 13) >+ punpckhdq xmm4,xmm5 ; xmm4=(20 21 22 23 30 31 32 33) >+ movdqa xmm0,xmm1 ; transpose coefficients(phase 2) >+ punpckldq xmm1,xmm3 ; xmm1=(40 41 42 43 50 51 52 53) >+ punpckhdq xmm0,xmm3 ; xmm0=(60 61 62 63 70 71 72 73) >+ >+ movdqa xmm5,xmm6 ; transpose coefficients(phase 3) >+ punpcklqdq xmm6,xmm2 ; xmm6=(00 01 02 03 04 05 06 07)=data0 >+ punpckhqdq xmm5,xmm2 ; xmm5=(10 11 12 13 14 15 16 17)=data1 >+ movdqa xmm3,xmm0 ; transpose coefficients(phase 3) >+ punpcklqdq xmm0,xmm7 ; xmm0=(60 61 62 63 64 65 66 67)=data6 >+ punpckhqdq xmm3,xmm7 ; xmm3=(70 71 72 73 74 75 76 77)=data7 >+ >+ movdqa xmm2,xmm5 >+ movdqa xmm7,xmm6 >+ psubw xmm5,xmm0 ; xmm5=data1-data6=tmp6 >+ psubw xmm6,xmm3 ; xmm6=data0-data7=tmp7 >+ paddw xmm2,xmm0 ; xmm2=data1+data6=tmp1 >+ paddw xmm7,xmm3 ; xmm7=data0+data7=tmp0 >+ >+ movdqa xmm0, XMMWORD [wk(2)] ; xmm0=(24 25 26 27 34 35 36 37) >+ movdqa xmm3, XMMWORD [wk(3)] ; xmm3=(44 45 46 47 54 55 56 57) >+ movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=tmp6 >+ movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7 >+ >+ movdqa xmm5,xmm4 ; transpose coefficients(phase 3) >+ punpcklqdq xmm4,xmm0 ; xmm4=(20 21 22 23 24 25 26 27)=data2 >+ punpckhqdq xmm5,xmm0 ; xmm5=(30 31 32 33 34 35 36 37)=data3 >+ movdqa xmm6,xmm1 ; transpose coefficients(phase 3) >+ punpcklqdq xmm1,xmm3 ; xmm1=(40 41 42 43 44 45 46 47)=data4 >+ punpckhqdq xmm6,xmm3 ; xmm6=(50 51 52 53 54 55 56 57)=data5 >+ >+ movdqa xmm0,xmm5 >+ movdqa xmm3,xmm4 >+ paddw xmm5,xmm1 ; xmm5=data3+data4=tmp3 >+ paddw xmm4,xmm6 ; xmm4=data2+data5=tmp2 >+ psubw xmm0,xmm1 ; xmm0=data3-data4=tmp4 >+ psubw xmm3,xmm6 ; xmm3=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movdqa xmm1,xmm7 >+ movdqa xmm6,xmm2 >+ paddw xmm7,xmm5 ; xmm7=tmp10 >+ paddw xmm2,xmm4 ; xmm2=tmp11 >+ psubw xmm1,xmm5 ; xmm1=tmp13 >+ psubw xmm6,xmm4 ; xmm6=tmp12 >+ >+ movdqa xmm5,xmm7 >+ paddw xmm7,xmm2 ; xmm7=tmp10+tmp11 >+ psubw xmm5,xmm2 ; xmm5=tmp10-tmp11 >+ >+ paddw xmm7,[rel PW_DESCALE_P2X] >+ paddw xmm5,[rel PW_DESCALE_P2X] >+ psraw xmm7,PASS1_BITS ; xmm7=data0 >+ psraw xmm5,PASS1_BITS ; xmm5=data4 >+ >+ movdqa XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_DCTELEM)], xmm7 >+ movdqa XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_DCTELEM)], xmm5 >+ >+ ; (Original) >+ ; z1 = (tmp12 + tmp13) * 0.541196100; >+ ; data2 = z1 + tmp13 * 0.765366865; >+ ; data6 = z1 + tmp12 * -1.847759065; >+ ; >+ ; (This implementation) >+ ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100; >+ ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065); >+ >+ movdqa xmm4,xmm1 ; xmm1=tmp13 >+ movdqa xmm2,xmm1 >+ punpcklwd xmm4,xmm6 ; xmm6=tmp12 >+ punpckhwd xmm2,xmm6 >+ movdqa xmm1,xmm4 >+ movdqa xmm6,xmm2 >+ pmaddwd xmm4,[rel PW_F130_F054] ; xmm4=data2L >+ pmaddwd xmm2,[rel PW_F130_F054] ; xmm2=data2H >+ pmaddwd xmm1,[rel PW_F054_MF130] ; xmm1=data6L >+ pmaddwd xmm6,[rel PW_F054_MF130] ; xmm6=data6H >+ >+ paddd xmm4,[rel PD_DESCALE_P2] >+ paddd xmm2,[rel PD_DESCALE_P2] >+ psrad xmm4,DESCALE_P2 >+ psrad xmm2,DESCALE_P2 >+ paddd xmm1,[rel PD_DESCALE_P2] >+ paddd xmm6,[rel PD_DESCALE_P2] >+ psrad xmm1,DESCALE_P2 >+ psrad xmm6,DESCALE_P2 >+ >+ packssdw xmm4,xmm2 ; xmm4=data2 >+ packssdw xmm1,xmm6 ; xmm1=data6 >+ >+ movdqa XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_DCTELEM)], xmm4 >+ movdqa XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_DCTELEM)], xmm1 >+ >+ ; -- Odd part >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp6 >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp7 >+ >+ movdqa xmm2,xmm0 ; xmm0=tmp4 >+ movdqa xmm6,xmm3 ; xmm3=tmp5 >+ paddw xmm2,xmm7 ; xmm2=z3 >+ paddw xmm6,xmm5 ; xmm6=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movdqa xmm4,xmm2 >+ movdqa xmm1,xmm2 >+ punpcklwd xmm4,xmm6 >+ punpckhwd xmm1,xmm6 >+ movdqa xmm2,xmm4 >+ movdqa xmm6,xmm1 >+ pmaddwd xmm4,[rel PW_MF078_F117] ; xmm4=z3L >+ pmaddwd xmm1,[rel PW_MF078_F117] ; xmm1=z3H >+ pmaddwd xmm2,[rel PW_F117_F078] ; xmm2=z4L >+ pmaddwd xmm6,[rel PW_F117_F078] ; xmm6=z4H >+ >+ movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=z3L >+ movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=z3H >+ >+ ; (Original) >+ ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6; >+ ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869; >+ ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4; >+ ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223; >+ ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447; >+ ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447); >+ ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223); >+ ; data7 = tmp4 + z3; data5 = tmp5 + z4; >+ ; data3 = tmp6 + z3; data1 = tmp7 + z4; >+ >+ movdqa xmm4,xmm0 >+ movdqa xmm1,xmm0 >+ punpcklwd xmm4,xmm5 >+ punpckhwd xmm1,xmm5 >+ movdqa xmm0,xmm4 >+ movdqa xmm5,xmm1 >+ pmaddwd xmm4,[rel PW_MF060_MF089] ; xmm4=tmp4L >+ pmaddwd xmm1,[rel PW_MF060_MF089] ; xmm1=tmp4H >+ pmaddwd xmm0,[rel PW_MF089_F060] ; xmm0=tmp7L >+ pmaddwd xmm5,[rel PW_MF089_F060] ; xmm5=tmp7H >+ >+ paddd xmm4, XMMWORD [wk(0)] ; xmm4=data7L >+ paddd xmm1, XMMWORD [wk(1)] ; xmm1=data7H >+ paddd xmm0,xmm2 ; xmm0=data1L >+ paddd xmm5,xmm6 ; xmm5=data1H >+ >+ paddd xmm4,[rel PD_DESCALE_P2] >+ paddd xmm1,[rel PD_DESCALE_P2] >+ psrad xmm4,DESCALE_P2 >+ psrad xmm1,DESCALE_P2 >+ paddd xmm0,[rel PD_DESCALE_P2] >+ paddd xmm5,[rel PD_DESCALE_P2] >+ psrad xmm0,DESCALE_P2 >+ psrad xmm5,DESCALE_P2 >+ >+ packssdw xmm4,xmm1 ; xmm4=data7 >+ packssdw xmm0,xmm5 ; xmm0=data1 >+ >+ movdqa XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_DCTELEM)], xmm4 >+ movdqa XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)], xmm0 >+ >+ movdqa xmm1,xmm3 >+ movdqa xmm5,xmm3 >+ punpcklwd xmm1,xmm7 >+ punpckhwd xmm5,xmm7 >+ movdqa xmm3,xmm1 >+ movdqa xmm7,xmm5 >+ pmaddwd xmm1,[rel PW_MF050_MF256] ; xmm1=tmp5L >+ pmaddwd xmm5,[rel PW_MF050_MF256] ; xmm5=tmp5H >+ pmaddwd xmm3,[rel PW_MF256_F050] ; xmm3=tmp6L >+ pmaddwd xmm7,[rel PW_MF256_F050] ; xmm7=tmp6H >+ >+ paddd xmm1,xmm2 ; xmm1=data5L >+ paddd xmm5,xmm6 ; xmm5=data5H >+ paddd xmm3, XMMWORD [wk(0)] ; xmm3=data3L >+ paddd xmm7, XMMWORD [wk(1)] ; xmm7=data3H >+ >+ paddd xmm1,[rel PD_DESCALE_P2] >+ paddd xmm5,[rel PD_DESCALE_P2] >+ psrad xmm1,DESCALE_P2 >+ psrad xmm5,DESCALE_P2 >+ paddd xmm3,[rel PD_DESCALE_P2] >+ paddd xmm7,[rel PD_DESCALE_P2] >+ psrad xmm3,DESCALE_P2 >+ psrad xmm7,DESCALE_P2 >+ >+ packssdw xmm1,xmm5 ; xmm1=data5 >+ packssdw xmm3,xmm7 ; xmm3=data3 >+ >+ movdqa XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)], xmm1 >+ movdqa XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)], xmm3 >+ >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jfss2int.asm b/modules/libjpeg-turbo/simd/jfss2int.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jfss2int.asm >@@ -0,0 +1,634 @@ >+; >+; jfss2int.asm - accurate integer FDCT (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a slow-but-accurate integer implementation of the >+; forward DCT (Discrete Cosine Transform). The following code is based >+; directly on the IJG's original jfdctint.c; see the jfdctint.c for >+; more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 13 >+%define PASS1_BITS 2 >+ >+%define DESCALE_P1 (CONST_BITS-PASS1_BITS) >+%define DESCALE_P2 (CONST_BITS+PASS1_BITS) >+ >+%if CONST_BITS == 13 >+F_0_298 equ 2446 ; FIX(0.298631336) >+F_0_390 equ 3196 ; FIX(0.390180644) >+F_0_541 equ 4433 ; FIX(0.541196100) >+F_0_765 equ 6270 ; FIX(0.765366865) >+F_0_899 equ 7373 ; FIX(0.899976223) >+F_1_175 equ 9633 ; FIX(1.175875602) >+F_1_501 equ 12299 ; FIX(1.501321110) >+F_1_847 equ 15137 ; FIX(1.847759065) >+F_1_961 equ 16069 ; FIX(1.961570560) >+F_2_053 equ 16819 ; FIX(2.053119869) >+F_2_562 equ 20995 ; FIX(2.562915447) >+F_3_072 equ 25172 ; FIX(3.072711026) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_298 equ DESCALE( 320652955,30-CONST_BITS) ; FIX(0.298631336) >+F_0_390 equ DESCALE( 418953276,30-CONST_BITS) ; FIX(0.390180644) >+F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100) >+F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865) >+F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223) >+F_1_175 equ DESCALE(1262586813,30-CONST_BITS) ; FIX(1.175875602) >+F_1_501 equ DESCALE(1612031267,30-CONST_BITS) ; FIX(1.501321110) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_1_961 equ DESCALE(2106220350,30-CONST_BITS) ; FIX(1.961570560) >+F_2_053 equ DESCALE(2204520673,30-CONST_BITS) ; FIX(2.053119869) >+F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447) >+F_3_072 equ DESCALE(3299298341,30-CONST_BITS) ; FIX(3.072711026) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_fdct_islow_sse2) >+ >+EXTN(jconst_fdct_islow_sse2): >+ >+PW_F130_F054 times 4 dw (F_0_541+F_0_765), F_0_541 >+PW_F054_MF130 times 4 dw F_0_541, (F_0_541-F_1_847) >+PW_MF078_F117 times 4 dw (F_1_175-F_1_961), F_1_175 >+PW_F117_F078 times 4 dw F_1_175, (F_1_175-F_0_390) >+PW_MF060_MF089 times 4 dw (F_0_298-F_0_899),-F_0_899 >+PW_MF089_F060 times 4 dw -F_0_899, (F_1_501-F_0_899) >+PW_MF050_MF256 times 4 dw (F_2_053-F_2_562),-F_2_562 >+PW_MF256_F050 times 4 dw -F_2_562, (F_3_072-F_2_562) >+PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1-1) >+PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2-1) >+PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS-1) >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform the forward DCT on one block of samples. >+; >+; GLOBAL(void) >+; jsimd_fdct_islow_sse2 (DCTELEM * data) >+; >+ >+%define data(b) (b)+8 ; DCTELEM * data >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 6 >+ >+ align 16 >+ global EXTN(jsimd_fdct_islow_sse2) >+ >+EXTN(jsimd_fdct_islow_sse2): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic ebx >+; push ecx ; unused >+; push edx ; need not be preserved >+; push esi ; unused >+; push edi ; unused >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process rows. >+ >+ mov edx, POINTER [data(eax)] ; (DCTELEM *) >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_DCTELEM)] >+ >+ ; xmm0=(00 01 02 03 04 05 06 07), xmm2=(20 21 22 23 24 25 26 27) >+ ; xmm1=(10 11 12 13 14 15 16 17), xmm3=(30 31 32 33 34 35 36 37) >+ >+ movdqa xmm4,xmm0 ; transpose coefficients(phase 1) >+ punpcklwd xmm0,xmm1 ; xmm0=(00 10 01 11 02 12 03 13) >+ punpckhwd xmm4,xmm1 ; xmm4=(04 14 05 15 06 16 07 17) >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 1) >+ punpcklwd xmm2,xmm3 ; xmm2=(20 30 21 31 22 32 23 33) >+ punpckhwd xmm5,xmm3 ; xmm5=(24 34 25 35 26 36 27 37) >+ >+ movdqa xmm6, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm7, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_DCTELEM)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_DCTELEM)] >+ >+ ; xmm6=( 4 12 20 28 36 44 52 60), xmm1=( 6 14 22 30 38 46 54 62) >+ ; xmm7=( 5 13 21 29 37 45 53 61), xmm3=( 7 15 23 31 39 47 55 63) >+ >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(20 30 21 31 22 32 23 33) >+ movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(24 34 25 35 26 36 27 37) >+ >+ movdqa xmm2,xmm6 ; transpose coefficients(phase 1) >+ punpcklwd xmm6,xmm7 ; xmm6=(40 50 41 51 42 52 43 53) >+ punpckhwd xmm2,xmm7 ; xmm2=(44 54 45 55 46 56 47 57) >+ movdqa xmm5,xmm1 ; transpose coefficients(phase 1) >+ punpcklwd xmm1,xmm3 ; xmm1=(60 70 61 71 62 72 63 73) >+ punpckhwd xmm5,xmm3 ; xmm5=(64 74 65 75 66 76 67 77) >+ >+ movdqa xmm7,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm1 ; xmm6=(40 50 60 70 41 51 61 71) >+ punpckhdq xmm7,xmm1 ; xmm7=(42 52 62 72 43 53 63 73) >+ movdqa xmm3,xmm2 ; transpose coefficients(phase 2) >+ punpckldq xmm2,xmm5 ; xmm2=(44 54 64 74 45 55 65 75) >+ punpckhdq xmm3,xmm5 ; xmm3=(46 56 66 76 47 57 67 77) >+ >+ movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(20 30 21 31 22 32 23 33) >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(24 34 25 35 26 36 27 37) >+ movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=(42 52 62 72 43 53 63 73) >+ movdqa XMMWORD [wk(3)], xmm2 ; wk(3)=(44 54 64 74 45 55 65 75) >+ >+ movdqa xmm7,xmm0 ; transpose coefficients(phase 2) >+ punpckldq xmm0,xmm1 ; xmm0=(00 10 20 30 01 11 21 31) >+ punpckhdq xmm7,xmm1 ; xmm7=(02 12 22 32 03 13 23 33) >+ movdqa xmm2,xmm4 ; transpose coefficients(phase 2) >+ punpckldq xmm4,xmm5 ; xmm4=(04 14 24 34 05 15 25 35) >+ punpckhdq xmm2,xmm5 ; xmm2=(06 16 26 36 07 17 27 37) >+ >+ movdqa xmm1,xmm0 ; transpose coefficients(phase 3) >+ punpcklqdq xmm0,xmm6 ; xmm0=(00 10 20 30 40 50 60 70)=data0 >+ punpckhqdq xmm1,xmm6 ; xmm1=(01 11 21 31 41 51 61 71)=data1 >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 3) >+ punpcklqdq xmm2,xmm3 ; xmm2=(06 16 26 36 46 56 66 76)=data6 >+ punpckhqdq xmm5,xmm3 ; xmm5=(07 17 27 37 47 57 67 77)=data7 >+ >+ movdqa xmm6,xmm1 >+ movdqa xmm3,xmm0 >+ psubw xmm1,xmm2 ; xmm1=data1-data6=tmp6 >+ psubw xmm0,xmm5 ; xmm0=data0-data7=tmp7 >+ paddw xmm6,xmm2 ; xmm6=data1+data6=tmp1 >+ paddw xmm3,xmm5 ; xmm3=data0+data7=tmp0 >+ >+ movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(42 52 62 72 43 53 63 73) >+ movdqa xmm5, XMMWORD [wk(3)] ; xmm5=(44 54 64 74 45 55 65 75) >+ movdqa XMMWORD [wk(0)], xmm1 ; wk(0)=tmp6 >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp7 >+ >+ movdqa xmm1,xmm7 ; transpose coefficients(phase 3) >+ punpcklqdq xmm7,xmm2 ; xmm7=(02 12 22 32 42 52 62 72)=data2 >+ punpckhqdq xmm1,xmm2 ; xmm1=(03 13 23 33 43 53 63 73)=data3 >+ movdqa xmm0,xmm4 ; transpose coefficients(phase 3) >+ punpcklqdq xmm4,xmm5 ; xmm4=(04 14 24 34 44 54 64 74)=data4 >+ punpckhqdq xmm0,xmm5 ; xmm0=(05 15 25 35 45 55 65 75)=data5 >+ >+ movdqa xmm2,xmm1 >+ movdqa xmm5,xmm7 >+ paddw xmm1,xmm4 ; xmm1=data3+data4=tmp3 >+ paddw xmm7,xmm0 ; xmm7=data2+data5=tmp2 >+ psubw xmm2,xmm4 ; xmm2=data3-data4=tmp4 >+ psubw xmm5,xmm0 ; xmm5=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movdqa xmm4,xmm3 >+ movdqa xmm0,xmm6 >+ paddw xmm3,xmm1 ; xmm3=tmp10 >+ paddw xmm6,xmm7 ; xmm6=tmp11 >+ psubw xmm4,xmm1 ; xmm4=tmp13 >+ psubw xmm0,xmm7 ; xmm0=tmp12 >+ >+ movdqa xmm1,xmm3 >+ paddw xmm3,xmm6 ; xmm3=tmp10+tmp11 >+ psubw xmm1,xmm6 ; xmm1=tmp10-tmp11 >+ >+ psllw xmm3,PASS1_BITS ; xmm3=data0 >+ psllw xmm1,PASS1_BITS ; xmm1=data4 >+ >+ movdqa XMMWORD [wk(2)], xmm3 ; wk(2)=data0 >+ movdqa XMMWORD [wk(3)], xmm1 ; wk(3)=data4 >+ >+ ; (Original) >+ ; z1 = (tmp12 + tmp13) * 0.541196100; >+ ; data2 = z1 + tmp13 * 0.765366865; >+ ; data6 = z1 + tmp12 * -1.847759065; >+ ; >+ ; (This implementation) >+ ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100; >+ ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065); >+ >+ movdqa xmm7,xmm4 ; xmm4=tmp13 >+ movdqa xmm6,xmm4 >+ punpcklwd xmm7,xmm0 ; xmm0=tmp12 >+ punpckhwd xmm6,xmm0 >+ movdqa xmm4,xmm7 >+ movdqa xmm0,xmm6 >+ pmaddwd xmm7,[GOTOFF(ebx,PW_F130_F054)] ; xmm7=data2L >+ pmaddwd xmm6,[GOTOFF(ebx,PW_F130_F054)] ; xmm6=data2H >+ pmaddwd xmm4,[GOTOFF(ebx,PW_F054_MF130)] ; xmm4=data6L >+ pmaddwd xmm0,[GOTOFF(ebx,PW_F054_MF130)] ; xmm0=data6H >+ >+ paddd xmm7,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd xmm6,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad xmm7,DESCALE_P1 >+ psrad xmm6,DESCALE_P1 >+ paddd xmm4,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd xmm0,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad xmm4,DESCALE_P1 >+ psrad xmm0,DESCALE_P1 >+ >+ packssdw xmm7,xmm6 ; xmm7=data2 >+ packssdw xmm4,xmm0 ; xmm4=data6 >+ >+ movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=data2 >+ movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=data6 >+ >+ ; -- Odd part >+ >+ movdqa xmm3, XMMWORD [wk(0)] ; xmm3=tmp6 >+ movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp7 >+ >+ movdqa xmm6,xmm2 ; xmm2=tmp4 >+ movdqa xmm0,xmm5 ; xmm5=tmp5 >+ paddw xmm6,xmm3 ; xmm6=z3 >+ paddw xmm0,xmm1 ; xmm0=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movdqa xmm7,xmm6 >+ movdqa xmm4,xmm6 >+ punpcklwd xmm7,xmm0 >+ punpckhwd xmm4,xmm0 >+ movdqa xmm6,xmm7 >+ movdqa xmm0,xmm4 >+ pmaddwd xmm7,[GOTOFF(ebx,PW_MF078_F117)] ; xmm7=z3L >+ pmaddwd xmm4,[GOTOFF(ebx,PW_MF078_F117)] ; xmm4=z3H >+ pmaddwd xmm6,[GOTOFF(ebx,PW_F117_F078)] ; xmm6=z4L >+ pmaddwd xmm0,[GOTOFF(ebx,PW_F117_F078)] ; xmm0=z4H >+ >+ movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=z3L >+ movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=z3H >+ >+ ; (Original) >+ ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6; >+ ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869; >+ ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4; >+ ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223; >+ ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447; >+ ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447); >+ ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223); >+ ; data7 = tmp4 + z3; data5 = tmp5 + z4; >+ ; data3 = tmp6 + z3; data1 = tmp7 + z4; >+ >+ movdqa xmm7,xmm2 >+ movdqa xmm4,xmm2 >+ punpcklwd xmm7,xmm1 >+ punpckhwd xmm4,xmm1 >+ movdqa xmm2,xmm7 >+ movdqa xmm1,xmm4 >+ pmaddwd xmm7,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm7=tmp4L >+ pmaddwd xmm4,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm4=tmp4H >+ pmaddwd xmm2,[GOTOFF(ebx,PW_MF089_F060)] ; xmm2=tmp7L >+ pmaddwd xmm1,[GOTOFF(ebx,PW_MF089_F060)] ; xmm1=tmp7H >+ >+ paddd xmm7, XMMWORD [wk(0)] ; xmm7=data7L >+ paddd xmm4, XMMWORD [wk(1)] ; xmm4=data7H >+ paddd xmm2,xmm6 ; xmm2=data1L >+ paddd xmm1,xmm0 ; xmm1=data1H >+ >+ paddd xmm7,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd xmm4,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad xmm7,DESCALE_P1 >+ psrad xmm4,DESCALE_P1 >+ paddd xmm2,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd xmm1,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad xmm2,DESCALE_P1 >+ psrad xmm1,DESCALE_P1 >+ >+ packssdw xmm7,xmm4 ; xmm7=data7 >+ packssdw xmm2,xmm1 ; xmm2=data1 >+ >+ movdqa xmm4,xmm5 >+ movdqa xmm1,xmm5 >+ punpcklwd xmm4,xmm3 >+ punpckhwd xmm1,xmm3 >+ movdqa xmm5,xmm4 >+ movdqa xmm3,xmm1 >+ pmaddwd xmm4,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm4=tmp5L >+ pmaddwd xmm1,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm1=tmp5H >+ pmaddwd xmm5,[GOTOFF(ebx,PW_MF256_F050)] ; xmm5=tmp6L >+ pmaddwd xmm3,[GOTOFF(ebx,PW_MF256_F050)] ; xmm3=tmp6H >+ >+ paddd xmm4,xmm6 ; xmm4=data5L >+ paddd xmm1,xmm0 ; xmm1=data5H >+ paddd xmm5, XMMWORD [wk(0)] ; xmm5=data3L >+ paddd xmm3, XMMWORD [wk(1)] ; xmm3=data3H >+ >+ paddd xmm4,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd xmm1,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad xmm4,DESCALE_P1 >+ psrad xmm1,DESCALE_P1 >+ paddd xmm5,[GOTOFF(ebx,PD_DESCALE_P1)] >+ paddd xmm3,[GOTOFF(ebx,PD_DESCALE_P1)] >+ psrad xmm5,DESCALE_P1 >+ psrad xmm3,DESCALE_P1 >+ >+ packssdw xmm4,xmm1 ; xmm4=data5 >+ packssdw xmm5,xmm3 ; xmm5=data3 >+ >+ ; ---- Pass 2: process columns. >+ >+; mov edx, POINTER [data(eax)] ; (DCTELEM *) >+ >+ movdqa xmm6, XMMWORD [wk(2)] ; xmm6=col0 >+ movdqa xmm0, XMMWORD [wk(4)] ; xmm0=col2 >+ >+ ; xmm6=(00 10 20 30 40 50 60 70), xmm0=(02 12 22 32 42 52 62 72) >+ ; xmm2=(01 11 21 31 41 51 61 71), xmm5=(03 13 23 33 43 53 63 73) >+ >+ movdqa xmm1,xmm6 ; transpose coefficients(phase 1) >+ punpcklwd xmm6,xmm2 ; xmm6=(00 01 10 11 20 21 30 31) >+ punpckhwd xmm1,xmm2 ; xmm1=(40 41 50 51 60 61 70 71) >+ movdqa xmm3,xmm0 ; transpose coefficients(phase 1) >+ punpcklwd xmm0,xmm5 ; xmm0=(02 03 12 13 22 23 32 33) >+ punpckhwd xmm3,xmm5 ; xmm3=(42 43 52 53 62 63 72 73) >+ >+ movdqa xmm2, XMMWORD [wk(3)] ; xmm2=col4 >+ movdqa xmm5, XMMWORD [wk(5)] ; xmm5=col6 >+ >+ ; xmm2=(04 14 24 34 44 54 64 74), xmm5=(06 16 26 36 46 56 66 76) >+ ; xmm4=(05 15 25 35 45 55 65 75), xmm7=(07 17 27 37 47 57 67 77) >+ >+ movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=(02 03 12 13 22 23 32 33) >+ movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(42 43 52 53 62 63 72 73) >+ >+ movdqa xmm0,xmm2 ; transpose coefficients(phase 1) >+ punpcklwd xmm2,xmm4 ; xmm2=(04 05 14 15 24 25 34 35) >+ punpckhwd xmm0,xmm4 ; xmm0=(44 45 54 55 64 65 74 75) >+ movdqa xmm3,xmm5 ; transpose coefficients(phase 1) >+ punpcklwd xmm5,xmm7 ; xmm5=(06 07 16 17 26 27 36 37) >+ punpckhwd xmm3,xmm7 ; xmm3=(46 47 56 57 66 67 76 77) >+ >+ movdqa xmm4,xmm2 ; transpose coefficients(phase 2) >+ punpckldq xmm2,xmm5 ; xmm2=(04 05 06 07 14 15 16 17) >+ punpckhdq xmm4,xmm5 ; xmm4=(24 25 26 27 34 35 36 37) >+ movdqa xmm7,xmm0 ; transpose coefficients(phase 2) >+ punpckldq xmm0,xmm3 ; xmm0=(44 45 46 47 54 55 56 57) >+ punpckhdq xmm7,xmm3 ; xmm7=(64 65 66 67 74 75 76 77) >+ >+ movdqa xmm5, XMMWORD [wk(0)] ; xmm5=(02 03 12 13 22 23 32 33) >+ movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(42 43 52 53 62 63 72 73) >+ movdqa XMMWORD [wk(2)], xmm4 ; wk(2)=(24 25 26 27 34 35 36 37) >+ movdqa XMMWORD [wk(3)], xmm0 ; wk(3)=(44 45 46 47 54 55 56 57) >+ >+ movdqa xmm4,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm5 ; xmm6=(00 01 02 03 10 11 12 13) >+ punpckhdq xmm4,xmm5 ; xmm4=(20 21 22 23 30 31 32 33) >+ movdqa xmm0,xmm1 ; transpose coefficients(phase 2) >+ punpckldq xmm1,xmm3 ; xmm1=(40 41 42 43 50 51 52 53) >+ punpckhdq xmm0,xmm3 ; xmm0=(60 61 62 63 70 71 72 73) >+ >+ movdqa xmm5,xmm6 ; transpose coefficients(phase 3) >+ punpcklqdq xmm6,xmm2 ; xmm6=(00 01 02 03 04 05 06 07)=data0 >+ punpckhqdq xmm5,xmm2 ; xmm5=(10 11 12 13 14 15 16 17)=data1 >+ movdqa xmm3,xmm0 ; transpose coefficients(phase 3) >+ punpcklqdq xmm0,xmm7 ; xmm0=(60 61 62 63 64 65 66 67)=data6 >+ punpckhqdq xmm3,xmm7 ; xmm3=(70 71 72 73 74 75 76 77)=data7 >+ >+ movdqa xmm2,xmm5 >+ movdqa xmm7,xmm6 >+ psubw xmm5,xmm0 ; xmm5=data1-data6=tmp6 >+ psubw xmm6,xmm3 ; xmm6=data0-data7=tmp7 >+ paddw xmm2,xmm0 ; xmm2=data1+data6=tmp1 >+ paddw xmm7,xmm3 ; xmm7=data0+data7=tmp0 >+ >+ movdqa xmm0, XMMWORD [wk(2)] ; xmm0=(24 25 26 27 34 35 36 37) >+ movdqa xmm3, XMMWORD [wk(3)] ; xmm3=(44 45 46 47 54 55 56 57) >+ movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=tmp6 >+ movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7 >+ >+ movdqa xmm5,xmm4 ; transpose coefficients(phase 3) >+ punpcklqdq xmm4,xmm0 ; xmm4=(20 21 22 23 24 25 26 27)=data2 >+ punpckhqdq xmm5,xmm0 ; xmm5=(30 31 32 33 34 35 36 37)=data3 >+ movdqa xmm6,xmm1 ; transpose coefficients(phase 3) >+ punpcklqdq xmm1,xmm3 ; xmm1=(40 41 42 43 44 45 46 47)=data4 >+ punpckhqdq xmm6,xmm3 ; xmm6=(50 51 52 53 54 55 56 57)=data5 >+ >+ movdqa xmm0,xmm5 >+ movdqa xmm3,xmm4 >+ paddw xmm5,xmm1 ; xmm5=data3+data4=tmp3 >+ paddw xmm4,xmm6 ; xmm4=data2+data5=tmp2 >+ psubw xmm0,xmm1 ; xmm0=data3-data4=tmp4 >+ psubw xmm3,xmm6 ; xmm3=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movdqa xmm1,xmm7 >+ movdqa xmm6,xmm2 >+ paddw xmm7,xmm5 ; xmm7=tmp10 >+ paddw xmm2,xmm4 ; xmm2=tmp11 >+ psubw xmm1,xmm5 ; xmm1=tmp13 >+ psubw xmm6,xmm4 ; xmm6=tmp12 >+ >+ movdqa xmm5,xmm7 >+ paddw xmm7,xmm2 ; xmm7=tmp10+tmp11 >+ psubw xmm5,xmm2 ; xmm5=tmp10-tmp11 >+ >+ paddw xmm7,[GOTOFF(ebx,PW_DESCALE_P2X)] >+ paddw xmm5,[GOTOFF(ebx,PW_DESCALE_P2X)] >+ psraw xmm7,PASS1_BITS ; xmm7=data0 >+ psraw xmm5,PASS1_BITS ; xmm5=data4 >+ >+ movdqa XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_DCTELEM)], xmm7 >+ movdqa XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_DCTELEM)], xmm5 >+ >+ ; (Original) >+ ; z1 = (tmp12 + tmp13) * 0.541196100; >+ ; data2 = z1 + tmp13 * 0.765366865; >+ ; data6 = z1 + tmp12 * -1.847759065; >+ ; >+ ; (This implementation) >+ ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100; >+ ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065); >+ >+ movdqa xmm4,xmm1 ; xmm1=tmp13 >+ movdqa xmm2,xmm1 >+ punpcklwd xmm4,xmm6 ; xmm6=tmp12 >+ punpckhwd xmm2,xmm6 >+ movdqa xmm1,xmm4 >+ movdqa xmm6,xmm2 >+ pmaddwd xmm4,[GOTOFF(ebx,PW_F130_F054)] ; xmm4=data2L >+ pmaddwd xmm2,[GOTOFF(ebx,PW_F130_F054)] ; xmm2=data2H >+ pmaddwd xmm1,[GOTOFF(ebx,PW_F054_MF130)] ; xmm1=data6L >+ pmaddwd xmm6,[GOTOFF(ebx,PW_F054_MF130)] ; xmm6=data6H >+ >+ paddd xmm4,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd xmm2,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad xmm4,DESCALE_P2 >+ psrad xmm2,DESCALE_P2 >+ paddd xmm1,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd xmm6,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad xmm1,DESCALE_P2 >+ psrad xmm6,DESCALE_P2 >+ >+ packssdw xmm4,xmm2 ; xmm4=data2 >+ packssdw xmm1,xmm6 ; xmm1=data6 >+ >+ movdqa XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_DCTELEM)], xmm4 >+ movdqa XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_DCTELEM)], xmm1 >+ >+ ; -- Odd part >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp6 >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp7 >+ >+ movdqa xmm2,xmm0 ; xmm0=tmp4 >+ movdqa xmm6,xmm3 ; xmm3=tmp5 >+ paddw xmm2,xmm7 ; xmm2=z3 >+ paddw xmm6,xmm5 ; xmm6=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movdqa xmm4,xmm2 >+ movdqa xmm1,xmm2 >+ punpcklwd xmm4,xmm6 >+ punpckhwd xmm1,xmm6 >+ movdqa xmm2,xmm4 >+ movdqa xmm6,xmm1 >+ pmaddwd xmm4,[GOTOFF(ebx,PW_MF078_F117)] ; xmm4=z3L >+ pmaddwd xmm1,[GOTOFF(ebx,PW_MF078_F117)] ; xmm1=z3H >+ pmaddwd xmm2,[GOTOFF(ebx,PW_F117_F078)] ; xmm2=z4L >+ pmaddwd xmm6,[GOTOFF(ebx,PW_F117_F078)] ; xmm6=z4H >+ >+ movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=z3L >+ movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=z3H >+ >+ ; (Original) >+ ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6; >+ ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869; >+ ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4; >+ ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223; >+ ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447; >+ ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447); >+ ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223); >+ ; data7 = tmp4 + z3; data5 = tmp5 + z4; >+ ; data3 = tmp6 + z3; data1 = tmp7 + z4; >+ >+ movdqa xmm4,xmm0 >+ movdqa xmm1,xmm0 >+ punpcklwd xmm4,xmm5 >+ punpckhwd xmm1,xmm5 >+ movdqa xmm0,xmm4 >+ movdqa xmm5,xmm1 >+ pmaddwd xmm4,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm4=tmp4L >+ pmaddwd xmm1,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm1=tmp4H >+ pmaddwd xmm0,[GOTOFF(ebx,PW_MF089_F060)] ; xmm0=tmp7L >+ pmaddwd xmm5,[GOTOFF(ebx,PW_MF089_F060)] ; xmm5=tmp7H >+ >+ paddd xmm4, XMMWORD [wk(0)] ; xmm4=data7L >+ paddd xmm1, XMMWORD [wk(1)] ; xmm1=data7H >+ paddd xmm0,xmm2 ; xmm0=data1L >+ paddd xmm5,xmm6 ; xmm5=data1H >+ >+ paddd xmm4,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd xmm1,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad xmm4,DESCALE_P2 >+ psrad xmm1,DESCALE_P2 >+ paddd xmm0,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd xmm5,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad xmm0,DESCALE_P2 >+ psrad xmm5,DESCALE_P2 >+ >+ packssdw xmm4,xmm1 ; xmm4=data7 >+ packssdw xmm0,xmm5 ; xmm0=data1 >+ >+ movdqa XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_DCTELEM)], xmm4 >+ movdqa XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_DCTELEM)], xmm0 >+ >+ movdqa xmm1,xmm3 >+ movdqa xmm5,xmm3 >+ punpcklwd xmm1,xmm7 >+ punpckhwd xmm5,xmm7 >+ movdqa xmm3,xmm1 >+ movdqa xmm7,xmm5 >+ pmaddwd xmm1,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm1=tmp5L >+ pmaddwd xmm5,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm5=tmp5H >+ pmaddwd xmm3,[GOTOFF(ebx,PW_MF256_F050)] ; xmm3=tmp6L >+ pmaddwd xmm7,[GOTOFF(ebx,PW_MF256_F050)] ; xmm7=tmp6H >+ >+ paddd xmm1,xmm2 ; xmm1=data5L >+ paddd xmm5,xmm6 ; xmm5=data5H >+ paddd xmm3, XMMWORD [wk(0)] ; xmm3=data3L >+ paddd xmm7, XMMWORD [wk(1)] ; xmm7=data3H >+ >+ paddd xmm1,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd xmm5,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad xmm1,DESCALE_P2 >+ psrad xmm5,DESCALE_P2 >+ paddd xmm3,[GOTOFF(ebx,PD_DESCALE_P2)] >+ paddd xmm7,[GOTOFF(ebx,PD_DESCALE_P2)] >+ psrad xmm3,DESCALE_P2 >+ psrad xmm7,DESCALE_P2 >+ >+ packssdw xmm1,xmm5 ; xmm1=data5 >+ packssdw xmm3,xmm7 ; xmm3=data3 >+ >+ movdqa XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_DCTELEM)], xmm1 >+ movdqa XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_DCTELEM)], xmm3 >+ >+; pop edi ; unused >+; pop esi ; unused >+; pop edx ; need not be preserved >+; pop ecx ; unused >+ poppic ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jfsseflt-64.asm b/modules/libjpeg-turbo/simd/jfsseflt-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jfsseflt-64.asm >@@ -0,0 +1,358 @@ >+; >+; jfsseflt-64.asm - floating-point FDCT (64-bit SSE) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a floating-point implementation of the forward DCT >+; (Discrete Cosine Transform). The following code is based directly on >+; the IJG's original jfdctflt.c; see the jfdctflt.c for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5) >+ shufps %1,%2,0x44 >+%endmacro >+ >+%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7) >+ shufps %1,%2,0xEE >+%endmacro >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_fdct_float_sse) >+ >+EXTN(jconst_fdct_float_sse): >+ >+PD_0_382 times 4 dd 0.382683432365089771728460 >+PD_0_707 times 4 dd 0.707106781186547524400844 >+PD_0_541 times 4 dd 0.541196100146196984399723 >+PD_1_306 times 4 dd 1.306562964876376527856643 >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Perform the forward DCT on one block of samples. >+; >+; GLOBAL(void) >+; jsimd_fdct_float_sse (FAST_FLOAT * data) >+; >+ >+; r10 = FAST_FLOAT * data >+ >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_fdct_float_sse) >+ >+EXTN(jsimd_fdct_float_sse): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [wk(0)] >+ collect_args >+ >+ ; ---- Pass 1: process rows. >+ >+ mov rdx, r10 ; (FAST_FLOAT *) >+ mov rcx, DCTSIZE/4 >+.rowloop: >+ >+ movaps xmm0, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm2, XMMWORD [XMMBLOCK(2,1,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(3,1,rdx,SIZEOF_FAST_FLOAT)] >+ >+ ; xmm0=(20 21 22 23), xmm2=(24 25 26 27) >+ ; xmm1=(30 31 32 33), xmm3=(34 35 36 37) >+ >+ movaps xmm4,xmm0 ; transpose coefficients(phase 1) >+ unpcklps xmm0,xmm1 ; xmm0=(20 30 21 31) >+ unpckhps xmm4,xmm1 ; xmm4=(22 32 23 33) >+ movaps xmm5,xmm2 ; transpose coefficients(phase 1) >+ unpcklps xmm2,xmm3 ; xmm2=(24 34 25 35) >+ unpckhps xmm5,xmm3 ; xmm5=(26 36 27 37) >+ >+ movaps xmm6, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm7, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(0,1,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(1,1,rdx,SIZEOF_FAST_FLOAT)] >+ >+ ; xmm6=(00 01 02 03), xmm1=(04 05 06 07) >+ ; xmm7=(10 11 12 13), xmm3=(14 15 16 17) >+ >+ movaps XMMWORD [wk(0)], xmm4 ; wk(0)=(22 32 23 33) >+ movaps XMMWORD [wk(1)], xmm2 ; wk(1)=(24 34 25 35) >+ >+ movaps xmm4,xmm6 ; transpose coefficients(phase 1) >+ unpcklps xmm6,xmm7 ; xmm6=(00 10 01 11) >+ unpckhps xmm4,xmm7 ; xmm4=(02 12 03 13) >+ movaps xmm2,xmm1 ; transpose coefficients(phase 1) >+ unpcklps xmm1,xmm3 ; xmm1=(04 14 05 15) >+ unpckhps xmm2,xmm3 ; xmm2=(06 16 07 17) >+ >+ movaps xmm7,xmm6 ; transpose coefficients(phase 2) >+ unpcklps2 xmm6,xmm0 ; xmm6=(00 10 20 30)=data0 >+ unpckhps2 xmm7,xmm0 ; xmm7=(01 11 21 31)=data1 >+ movaps xmm3,xmm2 ; transpose coefficients(phase 2) >+ unpcklps2 xmm2,xmm5 ; xmm2=(06 16 26 36)=data6 >+ unpckhps2 xmm3,xmm5 ; xmm3=(07 17 27 37)=data7 >+ >+ movaps xmm0,xmm7 >+ movaps xmm5,xmm6 >+ subps xmm7,xmm2 ; xmm7=data1-data6=tmp6 >+ subps xmm6,xmm3 ; xmm6=data0-data7=tmp7 >+ addps xmm0,xmm2 ; xmm0=data1+data6=tmp1 >+ addps xmm5,xmm3 ; xmm5=data0+data7=tmp0 >+ >+ movaps xmm2, XMMWORD [wk(0)] ; xmm2=(22 32 23 33) >+ movaps xmm3, XMMWORD [wk(1)] ; xmm3=(24 34 25 35) >+ movaps XMMWORD [wk(0)], xmm7 ; wk(0)=tmp6 >+ movaps XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7 >+ >+ movaps xmm7,xmm4 ; transpose coefficients(phase 2) >+ unpcklps2 xmm4,xmm2 ; xmm4=(02 12 22 32)=data2 >+ unpckhps2 xmm7,xmm2 ; xmm7=(03 13 23 33)=data3 >+ movaps xmm6,xmm1 ; transpose coefficients(phase 2) >+ unpcklps2 xmm1,xmm3 ; xmm1=(04 14 24 34)=data4 >+ unpckhps2 xmm6,xmm3 ; xmm6=(05 15 25 35)=data5 >+ >+ movaps xmm2,xmm7 >+ movaps xmm3,xmm4 >+ addps xmm7,xmm1 ; xmm7=data3+data4=tmp3 >+ addps xmm4,xmm6 ; xmm4=data2+data5=tmp2 >+ subps xmm2,xmm1 ; xmm2=data3-data4=tmp4 >+ subps xmm3,xmm6 ; xmm3=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movaps xmm1,xmm5 >+ movaps xmm6,xmm0 >+ subps xmm5,xmm7 ; xmm5=tmp13 >+ subps xmm0,xmm4 ; xmm0=tmp12 >+ addps xmm1,xmm7 ; xmm1=tmp10 >+ addps xmm6,xmm4 ; xmm6=tmp11 >+ >+ addps xmm0,xmm5 >+ mulps xmm0,[rel PD_0_707] ; xmm0=z1 >+ >+ movaps xmm7,xmm1 >+ movaps xmm4,xmm5 >+ subps xmm1,xmm6 ; xmm1=data4 >+ subps xmm5,xmm0 ; xmm5=data6 >+ addps xmm7,xmm6 ; xmm7=data0 >+ addps xmm4,xmm0 ; xmm4=data2 >+ >+ movaps XMMWORD [XMMBLOCK(0,1,rdx,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(2,1,rdx,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)], xmm7 >+ movaps XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FAST_FLOAT)], xmm4 >+ >+ ; -- Odd part >+ >+ movaps xmm6, XMMWORD [wk(0)] ; xmm6=tmp6 >+ movaps xmm0, XMMWORD [wk(1)] ; xmm0=tmp7 >+ >+ addps xmm2,xmm3 ; xmm2=tmp10 >+ addps xmm3,xmm6 ; xmm3=tmp11 >+ addps xmm6,xmm0 ; xmm6=tmp12, xmm0=tmp7 >+ >+ mulps xmm3,[rel PD_0_707] ; xmm3=z3 >+ >+ movaps xmm1,xmm2 ; xmm1=tmp10 >+ subps xmm2,xmm6 >+ mulps xmm2,[rel PD_0_382] ; xmm2=z5 >+ mulps xmm1,[rel PD_0_541] ; xmm1=MULTIPLY(tmp10,FIX_0_541196) >+ mulps xmm6,[rel PD_1_306] ; xmm6=MULTIPLY(tmp12,FIX_1_306562) >+ addps xmm1,xmm2 ; xmm1=z2 >+ addps xmm6,xmm2 ; xmm6=z4 >+ >+ movaps xmm5,xmm0 >+ subps xmm0,xmm3 ; xmm0=z13 >+ addps xmm5,xmm3 ; xmm5=z11 >+ >+ movaps xmm7,xmm0 >+ movaps xmm4,xmm5 >+ subps xmm0,xmm1 ; xmm0=data3 >+ subps xmm5,xmm6 ; xmm5=data7 >+ addps xmm7,xmm1 ; xmm7=data5 >+ addps xmm4,xmm6 ; xmm4=data1 >+ >+ movaps XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(3,1,rdx,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(1,1,rdx,SIZEOF_FAST_FLOAT)], xmm7 >+ movaps XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)], xmm4 >+ >+ add rdx, 4*DCTSIZE*SIZEOF_FAST_FLOAT >+ dec rcx >+ jnz near .rowloop >+ >+ ; ---- Pass 2: process columns. >+ >+ mov rdx, r10 ; (FAST_FLOAT *) >+ mov rcx, DCTSIZE/4 >+.columnloop: >+ >+ movaps xmm0, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm2, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_FAST_FLOAT)] >+ >+ ; xmm0=(02 12 22 32), xmm2=(42 52 62 72) >+ ; xmm1=(03 13 23 33), xmm3=(43 53 63 73) >+ >+ movaps xmm4,xmm0 ; transpose coefficients(phase 1) >+ unpcklps xmm0,xmm1 ; xmm0=(02 03 12 13) >+ unpckhps xmm4,xmm1 ; xmm4=(22 23 32 33) >+ movaps xmm5,xmm2 ; transpose coefficients(phase 1) >+ unpcklps xmm2,xmm3 ; xmm2=(42 43 52 53) >+ unpckhps xmm5,xmm3 ; xmm5=(62 63 72 73) >+ >+ movaps xmm6, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm7, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_FAST_FLOAT)] >+ >+ ; xmm6=(00 10 20 30), xmm1=(40 50 60 70) >+ ; xmm7=(01 11 21 31), xmm3=(41 51 61 71) >+ >+ movaps XMMWORD [wk(0)], xmm4 ; wk(0)=(22 23 32 33) >+ movaps XMMWORD [wk(1)], xmm2 ; wk(1)=(42 43 52 53) >+ >+ movaps xmm4,xmm6 ; transpose coefficients(phase 1) >+ unpcklps xmm6,xmm7 ; xmm6=(00 01 10 11) >+ unpckhps xmm4,xmm7 ; xmm4=(20 21 30 31) >+ movaps xmm2,xmm1 ; transpose coefficients(phase 1) >+ unpcklps xmm1,xmm3 ; xmm1=(40 41 50 51) >+ unpckhps xmm2,xmm3 ; xmm2=(60 61 70 71) >+ >+ movaps xmm7,xmm6 ; transpose coefficients(phase 2) >+ unpcklps2 xmm6,xmm0 ; xmm6=(00 01 02 03)=data0 >+ unpckhps2 xmm7,xmm0 ; xmm7=(10 11 12 13)=data1 >+ movaps xmm3,xmm2 ; transpose coefficients(phase 2) >+ unpcklps2 xmm2,xmm5 ; xmm2=(60 61 62 63)=data6 >+ unpckhps2 xmm3,xmm5 ; xmm3=(70 71 72 73)=data7 >+ >+ movaps xmm0,xmm7 >+ movaps xmm5,xmm6 >+ subps xmm7,xmm2 ; xmm7=data1-data6=tmp6 >+ subps xmm6,xmm3 ; xmm6=data0-data7=tmp7 >+ addps xmm0,xmm2 ; xmm0=data1+data6=tmp1 >+ addps xmm5,xmm3 ; xmm5=data0+data7=tmp0 >+ >+ movaps xmm2, XMMWORD [wk(0)] ; xmm2=(22 23 32 33) >+ movaps xmm3, XMMWORD [wk(1)] ; xmm3=(42 43 52 53) >+ movaps XMMWORD [wk(0)], xmm7 ; wk(0)=tmp6 >+ movaps XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7 >+ >+ movaps xmm7,xmm4 ; transpose coefficients(phase 2) >+ unpcklps2 xmm4,xmm2 ; xmm4=(20 21 22 23)=data2 >+ unpckhps2 xmm7,xmm2 ; xmm7=(30 31 32 33)=data3 >+ movaps xmm6,xmm1 ; transpose coefficients(phase 2) >+ unpcklps2 xmm1,xmm3 ; xmm1=(40 41 42 43)=data4 >+ unpckhps2 xmm6,xmm3 ; xmm6=(50 51 52 53)=data5 >+ >+ movaps xmm2,xmm7 >+ movaps xmm3,xmm4 >+ addps xmm7,xmm1 ; xmm7=data3+data4=tmp3 >+ addps xmm4,xmm6 ; xmm4=data2+data5=tmp2 >+ subps xmm2,xmm1 ; xmm2=data3-data4=tmp4 >+ subps xmm3,xmm6 ; xmm3=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movaps xmm1,xmm5 >+ movaps xmm6,xmm0 >+ subps xmm5,xmm7 ; xmm5=tmp13 >+ subps xmm0,xmm4 ; xmm0=tmp12 >+ addps xmm1,xmm7 ; xmm1=tmp10 >+ addps xmm6,xmm4 ; xmm6=tmp11 >+ >+ addps xmm0,xmm5 >+ mulps xmm0,[rel PD_0_707] ; xmm0=z1 >+ >+ movaps xmm7,xmm1 >+ movaps xmm4,xmm5 >+ subps xmm1,xmm6 ; xmm1=data4 >+ subps xmm5,xmm0 ; xmm5=data6 >+ addps xmm7,xmm6 ; xmm7=data0 >+ addps xmm4,xmm0 ; xmm4=data2 >+ >+ movaps XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FAST_FLOAT)], xmm7 >+ movaps XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FAST_FLOAT)], xmm4 >+ >+ ; -- Odd part >+ >+ movaps xmm6, XMMWORD [wk(0)] ; xmm6=tmp6 >+ movaps xmm0, XMMWORD [wk(1)] ; xmm0=tmp7 >+ >+ addps xmm2,xmm3 ; xmm2=tmp10 >+ addps xmm3,xmm6 ; xmm3=tmp11 >+ addps xmm6,xmm0 ; xmm6=tmp12, xmm0=tmp7 >+ >+ mulps xmm3,[rel PD_0_707] ; xmm3=z3 >+ >+ movaps xmm1,xmm2 ; xmm1=tmp10 >+ subps xmm2,xmm6 >+ mulps xmm2,[rel PD_0_382] ; xmm2=z5 >+ mulps xmm1,[rel PD_0_541] ; xmm1=MULTIPLY(tmp10,FIX_0_541196) >+ mulps xmm6,[rel PD_1_306] ; xmm6=MULTIPLY(tmp12,FIX_1_306562) >+ addps xmm1,xmm2 ; xmm1=z2 >+ addps xmm6,xmm2 ; xmm6=z4 >+ >+ movaps xmm5,xmm0 >+ subps xmm0,xmm3 ; xmm0=z13 >+ addps xmm5,xmm3 ; xmm5=z11 >+ >+ movaps xmm7,xmm0 >+ movaps xmm4,xmm5 >+ subps xmm0,xmm1 ; xmm0=data3 >+ subps xmm5,xmm6 ; xmm5=data7 >+ addps xmm7,xmm1 ; xmm7=data5 >+ addps xmm4,xmm6 ; xmm4=data1 >+ >+ movaps XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_FAST_FLOAT)], xmm7 >+ movaps XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FAST_FLOAT)], xmm4 >+ >+ add rdx, byte 4*SIZEOF_FAST_FLOAT >+ dec rcx >+ jnz near .columnloop >+ >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jfsseflt.asm b/modules/libjpeg-turbo/simd/jfsseflt.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jfsseflt.asm >@@ -0,0 +1,370 @@ >+; >+; jfsseflt.asm - floating-point FDCT (SSE) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a floating-point implementation of the forward DCT >+; (Discrete Cosine Transform). The following code is based directly on >+; the IJG's original jfdctflt.c; see the jfdctflt.c for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5) >+ shufps %1,%2,0x44 >+%endmacro >+ >+%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7) >+ shufps %1,%2,0xEE >+%endmacro >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_fdct_float_sse) >+ >+EXTN(jconst_fdct_float_sse): >+ >+PD_0_382 times 4 dd 0.382683432365089771728460 >+PD_0_707 times 4 dd 0.707106781186547524400844 >+PD_0_541 times 4 dd 0.541196100146196984399723 >+PD_1_306 times 4 dd 1.306562964876376527856643 >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform the forward DCT on one block of samples. >+; >+; GLOBAL(void) >+; jsimd_fdct_float_sse (FAST_FLOAT * data) >+; >+ >+%define data(b) (b)+8 ; FAST_FLOAT * data >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_fdct_float_sse) >+ >+EXTN(jsimd_fdct_float_sse): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+; push esi ; unused >+; push edi ; unused >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process rows. >+ >+ mov edx, POINTER [data(eax)] ; (FAST_FLOAT *) >+ mov ecx, DCTSIZE/4 >+ alignx 16,7 >+.rowloop: >+ >+ movaps xmm0, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm2, XMMWORD [XMMBLOCK(2,1,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(3,1,edx,SIZEOF_FAST_FLOAT)] >+ >+ ; xmm0=(20 21 22 23), xmm2=(24 25 26 27) >+ ; xmm1=(30 31 32 33), xmm3=(34 35 36 37) >+ >+ movaps xmm4,xmm0 ; transpose coefficients(phase 1) >+ unpcklps xmm0,xmm1 ; xmm0=(20 30 21 31) >+ unpckhps xmm4,xmm1 ; xmm4=(22 32 23 33) >+ movaps xmm5,xmm2 ; transpose coefficients(phase 1) >+ unpcklps xmm2,xmm3 ; xmm2=(24 34 25 35) >+ unpckhps xmm5,xmm3 ; xmm5=(26 36 27 37) >+ >+ movaps xmm6, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm7, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)] >+ >+ ; xmm6=(00 01 02 03), xmm1=(04 05 06 07) >+ ; xmm7=(10 11 12 13), xmm3=(14 15 16 17) >+ >+ movaps XMMWORD [wk(0)], xmm4 ; wk(0)=(22 32 23 33) >+ movaps XMMWORD [wk(1)], xmm2 ; wk(1)=(24 34 25 35) >+ >+ movaps xmm4,xmm6 ; transpose coefficients(phase 1) >+ unpcklps xmm6,xmm7 ; xmm6=(00 10 01 11) >+ unpckhps xmm4,xmm7 ; xmm4=(02 12 03 13) >+ movaps xmm2,xmm1 ; transpose coefficients(phase 1) >+ unpcklps xmm1,xmm3 ; xmm1=(04 14 05 15) >+ unpckhps xmm2,xmm3 ; xmm2=(06 16 07 17) >+ >+ movaps xmm7,xmm6 ; transpose coefficients(phase 2) >+ unpcklps2 xmm6,xmm0 ; xmm6=(00 10 20 30)=data0 >+ unpckhps2 xmm7,xmm0 ; xmm7=(01 11 21 31)=data1 >+ movaps xmm3,xmm2 ; transpose coefficients(phase 2) >+ unpcklps2 xmm2,xmm5 ; xmm2=(06 16 26 36)=data6 >+ unpckhps2 xmm3,xmm5 ; xmm3=(07 17 27 37)=data7 >+ >+ movaps xmm0,xmm7 >+ movaps xmm5,xmm6 >+ subps xmm7,xmm2 ; xmm7=data1-data6=tmp6 >+ subps xmm6,xmm3 ; xmm6=data0-data7=tmp7 >+ addps xmm0,xmm2 ; xmm0=data1+data6=tmp1 >+ addps xmm5,xmm3 ; xmm5=data0+data7=tmp0 >+ >+ movaps xmm2, XMMWORD [wk(0)] ; xmm2=(22 32 23 33) >+ movaps xmm3, XMMWORD [wk(1)] ; xmm3=(24 34 25 35) >+ movaps XMMWORD [wk(0)], xmm7 ; wk(0)=tmp6 >+ movaps XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7 >+ >+ movaps xmm7,xmm4 ; transpose coefficients(phase 2) >+ unpcklps2 xmm4,xmm2 ; xmm4=(02 12 22 32)=data2 >+ unpckhps2 xmm7,xmm2 ; xmm7=(03 13 23 33)=data3 >+ movaps xmm6,xmm1 ; transpose coefficients(phase 2) >+ unpcklps2 xmm1,xmm3 ; xmm1=(04 14 24 34)=data4 >+ unpckhps2 xmm6,xmm3 ; xmm6=(05 15 25 35)=data5 >+ >+ movaps xmm2,xmm7 >+ movaps xmm3,xmm4 >+ addps xmm7,xmm1 ; xmm7=data3+data4=tmp3 >+ addps xmm4,xmm6 ; xmm4=data2+data5=tmp2 >+ subps xmm2,xmm1 ; xmm2=data3-data4=tmp4 >+ subps xmm3,xmm6 ; xmm3=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movaps xmm1,xmm5 >+ movaps xmm6,xmm0 >+ subps xmm5,xmm7 ; xmm5=tmp13 >+ subps xmm0,xmm4 ; xmm0=tmp12 >+ addps xmm1,xmm7 ; xmm1=tmp10 >+ addps xmm6,xmm4 ; xmm6=tmp11 >+ >+ addps xmm0,xmm5 >+ mulps xmm0,[GOTOFF(ebx,PD_0_707)] ; xmm0=z1 >+ >+ movaps xmm7,xmm1 >+ movaps xmm4,xmm5 >+ subps xmm1,xmm6 ; xmm1=data4 >+ subps xmm5,xmm0 ; xmm5=data6 >+ addps xmm7,xmm6 ; xmm7=data0 >+ addps xmm4,xmm0 ; xmm4=data2 >+ >+ movaps XMMWORD [XMMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(2,1,edx,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)], xmm7 >+ movaps XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)], xmm4 >+ >+ ; -- Odd part >+ >+ movaps xmm6, XMMWORD [wk(0)] ; xmm6=tmp6 >+ movaps xmm0, XMMWORD [wk(1)] ; xmm0=tmp7 >+ >+ addps xmm2,xmm3 ; xmm2=tmp10 >+ addps xmm3,xmm6 ; xmm3=tmp11 >+ addps xmm6,xmm0 ; xmm6=tmp12, xmm0=tmp7 >+ >+ mulps xmm3,[GOTOFF(ebx,PD_0_707)] ; xmm3=z3 >+ >+ movaps xmm1,xmm2 ; xmm1=tmp10 >+ subps xmm2,xmm6 >+ mulps xmm2,[GOTOFF(ebx,PD_0_382)] ; xmm2=z5 >+ mulps xmm1,[GOTOFF(ebx,PD_0_541)] ; xmm1=MULTIPLY(tmp10,FIX_0_541196) >+ mulps xmm6,[GOTOFF(ebx,PD_1_306)] ; xmm6=MULTIPLY(tmp12,FIX_1_306562) >+ addps xmm1,xmm2 ; xmm1=z2 >+ addps xmm6,xmm2 ; xmm6=z4 >+ >+ movaps xmm5,xmm0 >+ subps xmm0,xmm3 ; xmm0=z13 >+ addps xmm5,xmm3 ; xmm5=z11 >+ >+ movaps xmm7,xmm0 >+ movaps xmm4,xmm5 >+ subps xmm0,xmm1 ; xmm0=data3 >+ subps xmm5,xmm6 ; xmm5=data7 >+ addps xmm7,xmm1 ; xmm7=data5 >+ addps xmm4,xmm6 ; xmm4=data1 >+ >+ movaps XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(3,1,edx,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)], xmm7 >+ movaps XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)], xmm4 >+ >+ add edx, 4*DCTSIZE*SIZEOF_FAST_FLOAT >+ dec ecx >+ jnz near .rowloop >+ >+ ; ---- Pass 2: process columns. >+ >+ mov edx, POINTER [data(eax)] ; (FAST_FLOAT *) >+ mov ecx, DCTSIZE/4 >+ alignx 16,7 >+.columnloop: >+ >+ movaps xmm0, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm2, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_FAST_FLOAT)] >+ >+ ; xmm0=(02 12 22 32), xmm2=(42 52 62 72) >+ ; xmm1=(03 13 23 33), xmm3=(43 53 63 73) >+ >+ movaps xmm4,xmm0 ; transpose coefficients(phase 1) >+ unpcklps xmm0,xmm1 ; xmm0=(02 03 12 13) >+ unpckhps xmm4,xmm1 ; xmm4=(22 23 32 33) >+ movaps xmm5,xmm2 ; transpose coefficients(phase 1) >+ unpcklps xmm2,xmm3 ; xmm2=(42 43 52 53) >+ unpckhps xmm5,xmm3 ; xmm5=(62 63 72 73) >+ >+ movaps xmm6, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm7, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_FAST_FLOAT)] >+ >+ ; xmm6=(00 10 20 30), xmm1=(40 50 60 70) >+ ; xmm7=(01 11 21 31), xmm3=(41 51 61 71) >+ >+ movaps XMMWORD [wk(0)], xmm4 ; wk(0)=(22 23 32 33) >+ movaps XMMWORD [wk(1)], xmm2 ; wk(1)=(42 43 52 53) >+ >+ movaps xmm4,xmm6 ; transpose coefficients(phase 1) >+ unpcklps xmm6,xmm7 ; xmm6=(00 01 10 11) >+ unpckhps xmm4,xmm7 ; xmm4=(20 21 30 31) >+ movaps xmm2,xmm1 ; transpose coefficients(phase 1) >+ unpcklps xmm1,xmm3 ; xmm1=(40 41 50 51) >+ unpckhps xmm2,xmm3 ; xmm2=(60 61 70 71) >+ >+ movaps xmm7,xmm6 ; transpose coefficients(phase 2) >+ unpcklps2 xmm6,xmm0 ; xmm6=(00 01 02 03)=data0 >+ unpckhps2 xmm7,xmm0 ; xmm7=(10 11 12 13)=data1 >+ movaps xmm3,xmm2 ; transpose coefficients(phase 2) >+ unpcklps2 xmm2,xmm5 ; xmm2=(60 61 62 63)=data6 >+ unpckhps2 xmm3,xmm5 ; xmm3=(70 71 72 73)=data7 >+ >+ movaps xmm0,xmm7 >+ movaps xmm5,xmm6 >+ subps xmm7,xmm2 ; xmm7=data1-data6=tmp6 >+ subps xmm6,xmm3 ; xmm6=data0-data7=tmp7 >+ addps xmm0,xmm2 ; xmm0=data1+data6=tmp1 >+ addps xmm5,xmm3 ; xmm5=data0+data7=tmp0 >+ >+ movaps xmm2, XMMWORD [wk(0)] ; xmm2=(22 23 32 33) >+ movaps xmm3, XMMWORD [wk(1)] ; xmm3=(42 43 52 53) >+ movaps XMMWORD [wk(0)], xmm7 ; wk(0)=tmp6 >+ movaps XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7 >+ >+ movaps xmm7,xmm4 ; transpose coefficients(phase 2) >+ unpcklps2 xmm4,xmm2 ; xmm4=(20 21 22 23)=data2 >+ unpckhps2 xmm7,xmm2 ; xmm7=(30 31 32 33)=data3 >+ movaps xmm6,xmm1 ; transpose coefficients(phase 2) >+ unpcklps2 xmm1,xmm3 ; xmm1=(40 41 42 43)=data4 >+ unpckhps2 xmm6,xmm3 ; xmm6=(50 51 52 53)=data5 >+ >+ movaps xmm2,xmm7 >+ movaps xmm3,xmm4 >+ addps xmm7,xmm1 ; xmm7=data3+data4=tmp3 >+ addps xmm4,xmm6 ; xmm4=data2+data5=tmp2 >+ subps xmm2,xmm1 ; xmm2=data3-data4=tmp4 >+ subps xmm3,xmm6 ; xmm3=data2-data5=tmp5 >+ >+ ; -- Even part >+ >+ movaps xmm1,xmm5 >+ movaps xmm6,xmm0 >+ subps xmm5,xmm7 ; xmm5=tmp13 >+ subps xmm0,xmm4 ; xmm0=tmp12 >+ addps xmm1,xmm7 ; xmm1=tmp10 >+ addps xmm6,xmm4 ; xmm6=tmp11 >+ >+ addps xmm0,xmm5 >+ mulps xmm0,[GOTOFF(ebx,PD_0_707)] ; xmm0=z1 >+ >+ movaps xmm7,xmm1 >+ movaps xmm4,xmm5 >+ subps xmm1,xmm6 ; xmm1=data4 >+ subps xmm5,xmm0 ; xmm5=data6 >+ addps xmm7,xmm6 ; xmm7=data0 >+ addps xmm4,xmm0 ; xmm4=data2 >+ >+ movaps XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)], xmm7 >+ movaps XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)], xmm4 >+ >+ ; -- Odd part >+ >+ movaps xmm6, XMMWORD [wk(0)] ; xmm6=tmp6 >+ movaps xmm0, XMMWORD [wk(1)] ; xmm0=tmp7 >+ >+ addps xmm2,xmm3 ; xmm2=tmp10 >+ addps xmm3,xmm6 ; xmm3=tmp11 >+ addps xmm6,xmm0 ; xmm6=tmp12, xmm0=tmp7 >+ >+ mulps xmm3,[GOTOFF(ebx,PD_0_707)] ; xmm3=z3 >+ >+ movaps xmm1,xmm2 ; xmm1=tmp10 >+ subps xmm2,xmm6 >+ mulps xmm2,[GOTOFF(ebx,PD_0_382)] ; xmm2=z5 >+ mulps xmm1,[GOTOFF(ebx,PD_0_541)] ; xmm1=MULTIPLY(tmp10,FIX_0_541196) >+ mulps xmm6,[GOTOFF(ebx,PD_1_306)] ; xmm6=MULTIPLY(tmp12,FIX_1_306562) >+ addps xmm1,xmm2 ; xmm1=z2 >+ addps xmm6,xmm2 ; xmm6=z4 >+ >+ movaps xmm5,xmm0 >+ subps xmm0,xmm3 ; xmm0=z13 >+ addps xmm5,xmm3 ; xmm5=z11 >+ >+ movaps xmm7,xmm0 >+ movaps xmm4,xmm5 >+ subps xmm0,xmm1 ; xmm0=data3 >+ subps xmm5,xmm6 ; xmm5=data7 >+ addps xmm7,xmm1 ; xmm7=data5 >+ addps xmm4,xmm6 ; xmm4=data1 >+ >+ movaps XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_FAST_FLOAT)], xmm7 >+ movaps XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)], xmm4 >+ >+ add edx, byte 4*SIZEOF_FAST_FLOAT >+ dec ecx >+ jnz near .columnloop >+ >+; pop edi ; unused >+; pop esi ; unused >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ poppic ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/ji3dnflt.asm b/modules/libjpeg-turbo/simd/ji3dnflt.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/ji3dnflt.asm >@@ -0,0 +1,452 @@ >+; >+; ji3dnflt.asm - floating-point IDCT (3DNow! & MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a floating-point implementation of the inverse DCT >+; (Discrete Cosine Transform). The following code is based directly on >+; the IJG's original jidctflt.c; see the jidctflt.c for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_idct_float_3dnow) >+ >+EXTN(jconst_idct_float_3dnow): >+ >+PD_1_414 times 2 dd 1.414213562373095048801689 >+PD_1_847 times 2 dd 1.847759065022573512256366 >+PD_1_082 times 2 dd 1.082392200292393968799446 >+PD_2_613 times 2 dd 2.613125929752753055713286 >+PD_RNDINT_MAGIC times 2 dd 100663296.0 ; (float)(0x00C00000 << 3) >+PB_CENTERJSAMP times 8 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform dequantization and inverse DCT on one block of coefficients. >+; >+; GLOBAL(void) >+; jsimd_idct_float_3dnow (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; void * dct_table >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 2 >+%define workspace wk(0)-DCTSIZE2*SIZEOF_FAST_FLOAT >+ ; FAST_FLOAT workspace[DCTSIZE2] >+ >+ align 16 >+ global EXTN(jsimd_idct_float_3dnow) >+ >+EXTN(jsimd_idct_float_3dnow): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [workspace] >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input, store into work array. >+ >+; mov eax, [original_ebp] >+ mov edx, POINTER [dct_table(eax)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(eax)] ; inptr >+ lea edi, [workspace] ; FAST_FLOAT * wsptr >+ mov ecx, DCTSIZE/2 ; ctr >+ alignx 16,7 >+.columnloop: >+%ifndef NO_ZERO_COLUMN_TEST_FLOAT_3DNOW >+ mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ jnz short .columnDCT >+ >+ pushpic ebx ; save GOT address >+ mov ebx, DWORD [DWBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ mov eax, DWORD [DWBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ or ebx, DWORD [DWBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ or ebx, DWORD [DWBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ or eax,ebx >+ poppic ebx ; restore GOT address >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movd mm0, DWORD [DWBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ >+ punpcklwd mm0,mm0 >+ psrad mm0,(DWORD_BIT-WORD_BIT) >+ pi2fd mm0,mm0 >+ >+ pfmul mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movq mm1,mm0 >+ punpckldq mm0,mm0 >+ punpckhdq mm1,mm1 >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], mm0 >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], mm0 >+ movq MMWORD [MMBLOCK(0,2,edi,SIZEOF_FAST_FLOAT)], mm0 >+ movq MMWORD [MMBLOCK(0,3,edi,SIZEOF_FAST_FLOAT)], mm0 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], mm1 >+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], mm1 >+ movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm1 >+ movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm1 >+ jmp near .nextcolumn >+ alignx 16,7 >+%endif >+.columnDCT: >+ >+ ; -- Even part >+ >+ movd mm0, DWORD [DWBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movd mm1, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ movd mm2, DWORD [DWBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ movd mm3, DWORD [DWBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ >+ punpcklwd mm0,mm0 >+ punpcklwd mm1,mm1 >+ psrad mm0,(DWORD_BIT-WORD_BIT) >+ psrad mm1,(DWORD_BIT-WORD_BIT) >+ pi2fd mm0,mm0 >+ pi2fd mm1,mm1 >+ >+ pfmul mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ pfmul mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ punpcklwd mm2,mm2 >+ punpcklwd mm3,mm3 >+ psrad mm2,(DWORD_BIT-WORD_BIT) >+ psrad mm3,(DWORD_BIT-WORD_BIT) >+ pi2fd mm2,mm2 >+ pi2fd mm3,mm3 >+ >+ pfmul mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ pfmul mm3, MMWORD [MMBLOCK(6,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movq mm4,mm0 >+ movq mm5,mm1 >+ pfsub mm0,mm2 ; mm0=tmp11 >+ pfsub mm1,mm3 >+ pfadd mm4,mm2 ; mm4=tmp10 >+ pfadd mm5,mm3 ; mm5=tmp13 >+ >+ pfmul mm1,[GOTOFF(ebx,PD_1_414)] >+ pfsub mm1,mm5 ; mm1=tmp12 >+ >+ movq mm6,mm4 >+ movq mm7,mm0 >+ pfsub mm4,mm5 ; mm4=tmp3 >+ pfsub mm0,mm1 ; mm0=tmp2 >+ pfadd mm6,mm5 ; mm6=tmp0 >+ pfadd mm7,mm1 ; mm7=tmp1 >+ >+ movq MMWORD [wk(1)], mm4 ; tmp3 >+ movq MMWORD [wk(0)], mm0 ; tmp2 >+ >+ ; -- Odd part >+ >+ movd mm2, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movd mm3, DWORD [DWBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ movd mm5, DWORD [DWBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movd mm1, DWORD [DWBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ >+ punpcklwd mm2,mm2 >+ punpcklwd mm3,mm3 >+ psrad mm2,(DWORD_BIT-WORD_BIT) >+ psrad mm3,(DWORD_BIT-WORD_BIT) >+ pi2fd mm2,mm2 >+ pi2fd mm3,mm3 >+ >+ pfmul mm2, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ pfmul mm3, MMWORD [MMBLOCK(3,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ punpcklwd mm5,mm5 >+ punpcklwd mm1,mm1 >+ psrad mm5,(DWORD_BIT-WORD_BIT) >+ psrad mm1,(DWORD_BIT-WORD_BIT) >+ pi2fd mm5,mm5 >+ pi2fd mm1,mm1 >+ >+ pfmul mm5, MMWORD [MMBLOCK(5,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ pfmul mm1, MMWORD [MMBLOCK(7,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movq mm4,mm2 >+ movq mm0,mm5 >+ pfadd mm2,mm1 ; mm2=z11 >+ pfadd mm5,mm3 ; mm5=z13 >+ pfsub mm4,mm1 ; mm4=z12 >+ pfsub mm0,mm3 ; mm0=z10 >+ >+ movq mm1,mm2 >+ pfsub mm2,mm5 >+ pfadd mm1,mm5 ; mm1=tmp7 >+ >+ pfmul mm2,[GOTOFF(ebx,PD_1_414)] ; mm2=tmp11 >+ >+ movq mm3,mm0 >+ pfadd mm0,mm4 >+ pfmul mm0,[GOTOFF(ebx,PD_1_847)] ; mm0=z5 >+ pfmul mm3,[GOTOFF(ebx,PD_2_613)] ; mm3=(z10 * 2.613125930) >+ pfmul mm4,[GOTOFF(ebx,PD_1_082)] ; mm4=(z12 * 1.082392200) >+ pfsubr mm3,mm0 ; mm3=tmp12 >+ pfsub mm4,mm0 ; mm4=tmp10 >+ >+ ; -- Final output stage >+ >+ pfsub mm3,mm1 ; mm3=tmp6 >+ movq mm5,mm6 >+ movq mm0,mm7 >+ pfadd mm6,mm1 ; mm6=data0=(00 01) >+ pfadd mm7,mm3 ; mm7=data1=(10 11) >+ pfsub mm5,mm1 ; mm5=data7=(70 71) >+ pfsub mm0,mm3 ; mm0=data6=(60 61) >+ pfsub mm2,mm3 ; mm2=tmp5 >+ >+ movq mm1,mm6 ; transpose coefficients >+ punpckldq mm6,mm7 ; mm6=(00 10) >+ punpckhdq mm1,mm7 ; mm1=(01 11) >+ movq mm3,mm0 ; transpose coefficients >+ punpckldq mm0,mm5 ; mm0=(60 70) >+ punpckhdq mm3,mm5 ; mm3=(61 71) >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], mm6 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], mm1 >+ movq MMWORD [MMBLOCK(0,3,edi,SIZEOF_FAST_FLOAT)], mm0 >+ movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm3 >+ >+ movq mm7, MMWORD [wk(0)] ; mm7=tmp2 >+ movq mm5, MMWORD [wk(1)] ; mm5=tmp3 >+ >+ pfadd mm4,mm2 ; mm4=tmp4 >+ movq mm6,mm7 >+ movq mm1,mm5 >+ pfadd mm7,mm2 ; mm7=data2=(20 21) >+ pfadd mm5,mm4 ; mm5=data4=(40 41) >+ pfsub mm6,mm2 ; mm6=data5=(50 51) >+ pfsub mm1,mm4 ; mm1=data3=(30 31) >+ >+ movq mm0,mm7 ; transpose coefficients >+ punpckldq mm7,mm1 ; mm7=(20 30) >+ punpckhdq mm0,mm1 ; mm0=(21 31) >+ movq mm3,mm5 ; transpose coefficients >+ punpckldq mm5,mm6 ; mm5=(40 50) >+ punpckhdq mm3,mm6 ; mm3=(41 51) >+ >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], mm7 >+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], mm0 >+ movq MMWORD [MMBLOCK(0,2,edi,SIZEOF_FAST_FLOAT)], mm5 >+ movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm3 >+ >+.nextcolumn: >+ add esi, byte 2*SIZEOF_JCOEF ; coef_block >+ add edx, byte 2*SIZEOF_FLOAT_MULT_TYPE ; quantptr >+ add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr >+ dec ecx ; ctr >+ jnz near .columnloop >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32] >+ prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32] >+ prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32] >+ prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov eax, [original_ebp] >+ lea esi, [workspace] ; FAST_FLOAT * wsptr >+ mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(eax)] >+ mov ecx, DCTSIZE/2 ; ctr >+ alignx 16,7 >+.rowloop: >+ >+ ; -- Even part >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)] >+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_FAST_FLOAT)] >+ movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_FAST_FLOAT)] >+ movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_FAST_FLOAT)] >+ >+ movq mm4,mm0 >+ movq mm5,mm1 >+ pfsub mm0,mm2 ; mm0=tmp11 >+ pfsub mm1,mm3 >+ pfadd mm4,mm2 ; mm4=tmp10 >+ pfadd mm5,mm3 ; mm5=tmp13 >+ >+ pfmul mm1,[GOTOFF(ebx,PD_1_414)] >+ pfsub mm1,mm5 ; mm1=tmp12 >+ >+ movq mm6,mm4 >+ movq mm7,mm0 >+ pfsub mm4,mm5 ; mm4=tmp3 >+ pfsub mm0,mm1 ; mm0=tmp2 >+ pfadd mm6,mm5 ; mm6=tmp0 >+ pfadd mm7,mm1 ; mm7=tmp1 >+ >+ movq MMWORD [wk(1)], mm4 ; tmp3 >+ movq MMWORD [wk(0)], mm0 ; tmp2 >+ >+ ; -- Odd part >+ >+ movq mm2, MMWORD [MMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)] >+ movq mm3, MMWORD [MMBLOCK(3,0,esi,SIZEOF_FAST_FLOAT)] >+ movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_FAST_FLOAT)] >+ movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_FAST_FLOAT)] >+ >+ movq mm4,mm2 >+ movq mm0,mm5 >+ pfadd mm2,mm1 ; mm2=z11 >+ pfadd mm5,mm3 ; mm5=z13 >+ pfsub mm4,mm1 ; mm4=z12 >+ pfsub mm0,mm3 ; mm0=z10 >+ >+ movq mm1,mm2 >+ pfsub mm2,mm5 >+ pfadd mm1,mm5 ; mm1=tmp7 >+ >+ pfmul mm2,[GOTOFF(ebx,PD_1_414)] ; mm2=tmp11 >+ >+ movq mm3,mm0 >+ pfadd mm0,mm4 >+ pfmul mm0,[GOTOFF(ebx,PD_1_847)] ; mm0=z5 >+ pfmul mm3,[GOTOFF(ebx,PD_2_613)] ; mm3=(z10 * 2.613125930) >+ pfmul mm4,[GOTOFF(ebx,PD_1_082)] ; mm4=(z12 * 1.082392200) >+ pfsubr mm3,mm0 ; mm3=tmp12 >+ pfsub mm4,mm0 ; mm4=tmp10 >+ >+ ; -- Final output stage >+ >+ pfsub mm3,mm1 ; mm3=tmp6 >+ movq mm5,mm6 >+ movq mm0,mm7 >+ pfadd mm6,mm1 ; mm6=data0=(00 10) >+ pfadd mm7,mm3 ; mm7=data1=(01 11) >+ pfsub mm5,mm1 ; mm5=data7=(07 17) >+ pfsub mm0,mm3 ; mm0=data6=(06 16) >+ pfsub mm2,mm3 ; mm2=tmp5 >+ >+ movq mm1,[GOTOFF(ebx,PD_RNDINT_MAGIC)] ; mm1=[PD_RNDINT_MAGIC] >+ pcmpeqd mm3,mm3 >+ psrld mm3,WORD_BIT ; mm3={0xFFFF 0x0000 0xFFFF 0x0000} >+ >+ pfadd mm6,mm1 ; mm6=roundint(data0/8)=(00 ** 10 **) >+ pfadd mm7,mm1 ; mm7=roundint(data1/8)=(01 ** 11 **) >+ pfadd mm0,mm1 ; mm0=roundint(data6/8)=(06 ** 16 **) >+ pfadd mm5,mm1 ; mm5=roundint(data7/8)=(07 ** 17 **) >+ >+ pand mm6,mm3 ; mm6=(00 -- 10 --) >+ pslld mm7,WORD_BIT ; mm7=(-- 01 -- 11) >+ pand mm0,mm3 ; mm0=(06 -- 16 --) >+ pslld mm5,WORD_BIT ; mm5=(-- 07 -- 17) >+ por mm6,mm7 ; mm6=(00 01 10 11) >+ por mm0,mm5 ; mm0=(06 07 16 17) >+ >+ movq mm1, MMWORD [wk(0)] ; mm1=tmp2 >+ movq mm3, MMWORD [wk(1)] ; mm3=tmp3 >+ >+ pfadd mm4,mm2 ; mm4=tmp4 >+ movq mm7,mm1 >+ movq mm5,mm3 >+ pfadd mm1,mm2 ; mm1=data2=(02 12) >+ pfadd mm3,mm4 ; mm3=data4=(04 14) >+ pfsub mm7,mm2 ; mm7=data5=(05 15) >+ pfsub mm5,mm4 ; mm5=data3=(03 13) >+ >+ movq mm2,[GOTOFF(ebx,PD_RNDINT_MAGIC)] ; mm2=[PD_RNDINT_MAGIC] >+ pcmpeqd mm4,mm4 >+ psrld mm4,WORD_BIT ; mm4={0xFFFF 0x0000 0xFFFF 0x0000} >+ >+ pfadd mm3,mm2 ; mm3=roundint(data4/8)=(04 ** 14 **) >+ pfadd mm7,mm2 ; mm7=roundint(data5/8)=(05 ** 15 **) >+ pfadd mm1,mm2 ; mm1=roundint(data2/8)=(02 ** 12 **) >+ pfadd mm5,mm2 ; mm5=roundint(data3/8)=(03 ** 13 **) >+ >+ pand mm3,mm4 ; mm3=(04 -- 14 --) >+ pslld mm7,WORD_BIT ; mm7=(-- 05 -- 15) >+ pand mm1,mm4 ; mm1=(02 -- 12 --) >+ pslld mm5,WORD_BIT ; mm5=(-- 03 -- 13) >+ por mm3,mm7 ; mm3=(04 05 14 15) >+ por mm1,mm5 ; mm1=(02 03 12 13) >+ >+ movq mm2,[GOTOFF(ebx,PB_CENTERJSAMP)] ; mm2=[PB_CENTERJSAMP] >+ >+ packsswb mm6,mm3 ; mm6=(00 01 10 11 04 05 14 15) >+ packsswb mm1,mm0 ; mm1=(02 03 12 13 06 07 16 17) >+ paddb mm6,mm2 >+ paddb mm1,mm2 >+ >+ movq mm4,mm6 ; transpose coefficients(phase 2) >+ punpcklwd mm6,mm1 ; mm6=(00 01 02 03 10 11 12 13) >+ punpckhwd mm4,mm1 ; mm4=(04 05 06 07 14 15 16 17) >+ >+ movq mm7,mm6 ; transpose coefficients(phase 3) >+ punpckldq mm6,mm4 ; mm6=(00 01 02 03 04 05 06 07) >+ punpckhdq mm7,mm4 ; mm7=(10 11 12 13 14 15 16 17) >+ >+ pushpic ebx ; save GOT address >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm6 >+ movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm7 >+ >+ poppic ebx ; restore GOT address >+ >+ add esi, byte 2*SIZEOF_FAST_FLOAT ; wsptr >+ add edi, byte 2*SIZEOF_JSAMPROW >+ dec ecx ; ctr >+ jnz near .rowloop >+ >+ femms ; empty MMX/3DNow! state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jimmxfst.asm b/modules/libjpeg-turbo/simd/jimmxfst.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jimmxfst.asm >@@ -0,0 +1,500 @@ >+; >+; jimmxfst.asm - fast integer IDCT (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a fast, not so accurate integer implementation of >+; the inverse DCT (Discrete Cosine Transform). The following code is >+; based directly on the IJG's original jidctfst.c; see the jidctfst.c >+; for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 8 ; 14 is also OK. >+%define PASS1_BITS 2 >+ >+%if IFAST_SCALE_BITS != PASS1_BITS >+%error "'IFAST_SCALE_BITS' must be equal to 'PASS1_BITS'." >+%endif >+ >+%if CONST_BITS == 8 >+F_1_082 equ 277 ; FIX(1.082392200) >+F_1_414 equ 362 ; FIX(1.414213562) >+F_1_847 equ 473 ; FIX(1.847759065) >+F_2_613 equ 669 ; FIX(2.613125930) >+F_1_613 equ (F_2_613 - 256) ; FIX(2.613125930) - FIX(1) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_1_082 equ DESCALE(1162209775,30-CONST_BITS) ; FIX(1.082392200) >+F_1_414 equ DESCALE(1518500249,30-CONST_BITS) ; FIX(1.414213562) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_2_613 equ DESCALE(2805822602,30-CONST_BITS) ; FIX(2.613125930) >+F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow) >+; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw) >+ >+%define PRE_MULTIPLY_SCALE_BITS 2 >+%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS) >+ >+ alignz 16 >+ global EXTN(jconst_idct_ifast_mmx) >+ >+EXTN(jconst_idct_ifast_mmx): >+ >+PW_F1414 times 4 dw F_1_414 << CONST_SHIFT >+PW_F1847 times 4 dw F_1_847 << CONST_SHIFT >+PW_MF1613 times 4 dw -F_1_613 << CONST_SHIFT >+PW_F1082 times 4 dw F_1_082 << CONST_SHIFT >+PB_CENTERJSAMP times 8 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform dequantization and inverse DCT on one block of coefficients. >+; >+; GLOBAL(void) >+; jsimd_idct_ifast_mmx (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; jpeg_component_info * compptr >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 2 >+%define workspace wk(0)-DCTSIZE2*SIZEOF_JCOEF >+ ; JCOEF workspace[DCTSIZE2] >+ >+ align 16 >+ global EXTN(jsimd_idct_ifast_mmx) >+ >+EXTN(jsimd_idct_ifast_mmx): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [workspace] >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input, store into work array. >+ >+; mov eax, [original_ebp] >+ mov edx, POINTER [dct_table(eax)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(eax)] ; inptr >+ lea edi, [workspace] ; JCOEF * wsptr >+ mov ecx, DCTSIZE/4 ; ctr >+ alignx 16,7 >+.columnloop: >+%ifndef NO_ZERO_COLUMN_TEST_IFAST_MMX >+ mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ jnz short .columnDCT >+ >+ movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ por mm1, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ por mm1, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ por mm1,mm0 >+ packsswb mm1,mm1 >+ movd eax,mm1 >+ test eax,eax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ >+ movq mm2,mm0 ; mm0=in0=(00 01 02 03) >+ punpcklwd mm0,mm0 ; mm0=(00 00 01 01) >+ punpckhwd mm2,mm2 ; mm2=(02 02 03 03) >+ >+ movq mm1,mm0 >+ punpckldq mm0,mm0 ; mm0=(00 00 00 00) >+ punpckhdq mm1,mm1 ; mm1=(01 01 01 01) >+ movq mm3,mm2 >+ punpckldq mm2,mm2 ; mm2=(02 02 02 02) >+ punpckhdq mm3,mm3 ; mm3=(03 03 03 03) >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0 >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm0 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1 >+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm1 >+ movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2 >+ movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm2 >+ movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3 >+ movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm3 >+ jmp near .nextcolumn >+ alignx 16,7 >+%endif >+.columnDCT: >+ >+ ; -- Even part >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ pmullw mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw mm3, MMWORD [MMBLOCK(6,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ >+ movq mm4,mm0 >+ movq mm5,mm1 >+ psubw mm0,mm2 ; mm0=tmp11 >+ psubw mm1,mm3 >+ paddw mm4,mm2 ; mm4=tmp10 >+ paddw mm5,mm3 ; mm5=tmp13 >+ >+ psllw mm1,PRE_MULTIPLY_SCALE_BITS >+ pmulhw mm1,[GOTOFF(ebx,PW_F1414)] >+ psubw mm1,mm5 ; mm1=tmp12 >+ >+ movq mm6,mm4 >+ movq mm7,mm0 >+ psubw mm4,mm5 ; mm4=tmp3 >+ psubw mm0,mm1 ; mm0=tmp2 >+ paddw mm6,mm5 ; mm6=tmp0 >+ paddw mm7,mm1 ; mm7=tmp1 >+ >+ movq MMWORD [wk(1)], mm4 ; wk(1)=tmp3 >+ movq MMWORD [wk(0)], mm0 ; wk(0)=tmp2 >+ >+ ; -- Odd part >+ >+ movq mm2, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ pmullw mm2, MMWORD [MMBLOCK(1,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw mm3, MMWORD [MMBLOCK(3,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ pmullw mm5, MMWORD [MMBLOCK(5,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw mm1, MMWORD [MMBLOCK(7,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ >+ movq mm4,mm2 >+ movq mm0,mm5 >+ psubw mm2,mm1 ; mm2=z12 >+ psubw mm5,mm3 ; mm5=z10 >+ paddw mm4,mm1 ; mm4=z11 >+ paddw mm0,mm3 ; mm0=z13 >+ >+ movq mm1,mm5 ; mm1=z10(unscaled) >+ psllw mm2,PRE_MULTIPLY_SCALE_BITS >+ psllw mm5,PRE_MULTIPLY_SCALE_BITS >+ >+ movq mm3,mm4 >+ psubw mm4,mm0 >+ paddw mm3,mm0 ; mm3=tmp7 >+ >+ psllw mm4,PRE_MULTIPLY_SCALE_BITS >+ pmulhw mm4,[GOTOFF(ebx,PW_F1414)] ; mm4=tmp11 >+ >+ ; To avoid overflow... >+ ; >+ ; (Original) >+ ; tmp12 = -2.613125930 * z10 + z5; >+ ; >+ ; (This implementation) >+ ; tmp12 = (-1.613125930 - 1) * z10 + z5; >+ ; = -1.613125930 * z10 - z10 + z5; >+ >+ movq mm0,mm5 >+ paddw mm5,mm2 >+ pmulhw mm5,[GOTOFF(ebx,PW_F1847)] ; mm5=z5 >+ pmulhw mm0,[GOTOFF(ebx,PW_MF1613)] >+ pmulhw mm2,[GOTOFF(ebx,PW_F1082)] >+ psubw mm0,mm1 >+ psubw mm2,mm5 ; mm2=tmp10 >+ paddw mm0,mm5 ; mm0=tmp12 >+ >+ ; -- Final output stage >+ >+ psubw mm0,mm3 ; mm0=tmp6 >+ movq mm1,mm6 >+ movq mm5,mm7 >+ paddw mm6,mm3 ; mm6=data0=(00 01 02 03) >+ paddw mm7,mm0 ; mm7=data1=(10 11 12 13) >+ psubw mm1,mm3 ; mm1=data7=(70 71 72 73) >+ psubw mm5,mm0 ; mm5=data6=(60 61 62 63) >+ psubw mm4,mm0 ; mm4=tmp5 >+ >+ movq mm3,mm6 ; transpose coefficients(phase 1) >+ punpcklwd mm6,mm7 ; mm6=(00 10 01 11) >+ punpckhwd mm3,mm7 ; mm3=(02 12 03 13) >+ movq mm0,mm5 ; transpose coefficients(phase 1) >+ punpcklwd mm5,mm1 ; mm5=(60 70 61 71) >+ punpckhwd mm0,mm1 ; mm0=(62 72 63 73) >+ >+ movq mm7, MMWORD [wk(0)] ; mm7=tmp2 >+ movq mm1, MMWORD [wk(1)] ; mm1=tmp3 >+ >+ movq MMWORD [wk(0)], mm5 ; wk(0)=(60 70 61 71) >+ movq MMWORD [wk(1)], mm0 ; wk(1)=(62 72 63 73) >+ >+ paddw mm2,mm4 ; mm2=tmp4 >+ movq mm5,mm7 >+ movq mm0,mm1 >+ paddw mm7,mm4 ; mm7=data2=(20 21 22 23) >+ paddw mm1,mm2 ; mm1=data4=(40 41 42 43) >+ psubw mm5,mm4 ; mm5=data5=(50 51 52 53) >+ psubw mm0,mm2 ; mm0=data3=(30 31 32 33) >+ >+ movq mm4,mm7 ; transpose coefficients(phase 1) >+ punpcklwd mm7,mm0 ; mm7=(20 30 21 31) >+ punpckhwd mm4,mm0 ; mm4=(22 32 23 33) >+ movq mm2,mm1 ; transpose coefficients(phase 1) >+ punpcklwd mm1,mm5 ; mm1=(40 50 41 51) >+ punpckhwd mm2,mm5 ; mm2=(42 52 43 53) >+ >+ movq mm0,mm6 ; transpose coefficients(phase 2) >+ punpckldq mm6,mm7 ; mm6=(00 10 20 30) >+ punpckhdq mm0,mm7 ; mm0=(01 11 21 31) >+ movq mm5,mm3 ; transpose coefficients(phase 2) >+ punpckldq mm3,mm4 ; mm3=(02 12 22 32) >+ punpckhdq mm5,mm4 ; mm5=(03 13 23 33) >+ >+ movq mm7, MMWORD [wk(0)] ; mm7=(60 70 61 71) >+ movq mm4, MMWORD [wk(1)] ; mm4=(62 72 63 73) >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm6 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm0 >+ movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm3 >+ movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm5 >+ >+ movq mm6,mm1 ; transpose coefficients(phase 2) >+ punpckldq mm1,mm7 ; mm1=(40 50 60 70) >+ punpckhdq mm6,mm7 ; mm6=(41 51 61 71) >+ movq mm0,mm2 ; transpose coefficients(phase 2) >+ punpckldq mm2,mm4 ; mm2=(42 52 62 72) >+ punpckhdq mm0,mm4 ; mm0=(43 53 63 73) >+ >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm1 >+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm6 >+ movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm2 >+ movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm0 >+ >+.nextcolumn: >+ add esi, byte 4*SIZEOF_JCOEF ; coef_block >+ add edx, byte 4*SIZEOF_IFAST_MULT_TYPE ; quantptr >+ add edi, byte 4*DCTSIZE*SIZEOF_JCOEF ; wsptr >+ dec ecx ; ctr >+ jnz near .columnloop >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov eax, [original_ebp] >+ lea esi, [workspace] ; JCOEF * wsptr >+ mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(eax)] >+ mov ecx, DCTSIZE/4 ; ctr >+ alignx 16,7 >+.rowloop: >+ >+ ; -- Even part >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ >+ movq mm4,mm0 >+ movq mm5,mm1 >+ psubw mm0,mm2 ; mm0=tmp11 >+ psubw mm1,mm3 >+ paddw mm4,mm2 ; mm4=tmp10 >+ paddw mm5,mm3 ; mm5=tmp13 >+ >+ psllw mm1,PRE_MULTIPLY_SCALE_BITS >+ pmulhw mm1,[GOTOFF(ebx,PW_F1414)] >+ psubw mm1,mm5 ; mm1=tmp12 >+ >+ movq mm6,mm4 >+ movq mm7,mm0 >+ psubw mm4,mm5 ; mm4=tmp3 >+ psubw mm0,mm1 ; mm0=tmp2 >+ paddw mm6,mm5 ; mm6=tmp0 >+ paddw mm7,mm1 ; mm7=tmp1 >+ >+ movq MMWORD [wk(1)], mm4 ; wk(1)=tmp3 >+ movq MMWORD [wk(0)], mm0 ; wk(0)=tmp2 >+ >+ ; -- Odd part >+ >+ movq mm2, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ >+ movq mm4,mm2 >+ movq mm0,mm5 >+ psubw mm2,mm1 ; mm2=z12 >+ psubw mm5,mm3 ; mm5=z10 >+ paddw mm4,mm1 ; mm4=z11 >+ paddw mm0,mm3 ; mm0=z13 >+ >+ movq mm1,mm5 ; mm1=z10(unscaled) >+ psllw mm2,PRE_MULTIPLY_SCALE_BITS >+ psllw mm5,PRE_MULTIPLY_SCALE_BITS >+ >+ movq mm3,mm4 >+ psubw mm4,mm0 >+ paddw mm3,mm0 ; mm3=tmp7 >+ >+ psllw mm4,PRE_MULTIPLY_SCALE_BITS >+ pmulhw mm4,[GOTOFF(ebx,PW_F1414)] ; mm4=tmp11 >+ >+ ; To avoid overflow... >+ ; >+ ; (Original) >+ ; tmp12 = -2.613125930 * z10 + z5; >+ ; >+ ; (This implementation) >+ ; tmp12 = (-1.613125930 - 1) * z10 + z5; >+ ; = -1.613125930 * z10 - z10 + z5; >+ >+ movq mm0,mm5 >+ paddw mm5,mm2 >+ pmulhw mm5,[GOTOFF(ebx,PW_F1847)] ; mm5=z5 >+ pmulhw mm0,[GOTOFF(ebx,PW_MF1613)] >+ pmulhw mm2,[GOTOFF(ebx,PW_F1082)] >+ psubw mm0,mm1 >+ psubw mm2,mm5 ; mm2=tmp10 >+ paddw mm0,mm5 ; mm0=tmp12 >+ >+ ; -- Final output stage >+ >+ psubw mm0,mm3 ; mm0=tmp6 >+ movq mm1,mm6 >+ movq mm5,mm7 >+ paddw mm6,mm3 ; mm6=data0=(00 10 20 30) >+ paddw mm7,mm0 ; mm7=data1=(01 11 21 31) >+ psraw mm6,(PASS1_BITS+3) ; descale >+ psraw mm7,(PASS1_BITS+3) ; descale >+ psubw mm1,mm3 ; mm1=data7=(07 17 27 37) >+ psubw mm5,mm0 ; mm5=data6=(06 16 26 36) >+ psraw mm1,(PASS1_BITS+3) ; descale >+ psraw mm5,(PASS1_BITS+3) ; descale >+ psubw mm4,mm0 ; mm4=tmp5 >+ >+ packsswb mm6,mm5 ; mm6=(00 10 20 30 06 16 26 36) >+ packsswb mm7,mm1 ; mm7=(01 11 21 31 07 17 27 37) >+ >+ movq mm3, MMWORD [wk(0)] ; mm3=tmp2 >+ movq mm0, MMWORD [wk(1)] ; mm0=tmp3 >+ >+ paddw mm2,mm4 ; mm2=tmp4 >+ movq mm5,mm3 >+ movq mm1,mm0 >+ paddw mm3,mm4 ; mm3=data2=(02 12 22 32) >+ paddw mm0,mm2 ; mm0=data4=(04 14 24 34) >+ psraw mm3,(PASS1_BITS+3) ; descale >+ psraw mm0,(PASS1_BITS+3) ; descale >+ psubw mm5,mm4 ; mm5=data5=(05 15 25 35) >+ psubw mm1,mm2 ; mm1=data3=(03 13 23 33) >+ psraw mm5,(PASS1_BITS+3) ; descale >+ psraw mm1,(PASS1_BITS+3) ; descale >+ >+ movq mm4,[GOTOFF(ebx,PB_CENTERJSAMP)] ; mm4=[PB_CENTERJSAMP] >+ >+ packsswb mm3,mm0 ; mm3=(02 12 22 32 04 14 24 34) >+ packsswb mm1,mm5 ; mm1=(03 13 23 33 05 15 25 35) >+ >+ paddb mm6,mm4 >+ paddb mm7,mm4 >+ paddb mm3,mm4 >+ paddb mm1,mm4 >+ >+ movq mm2,mm6 ; transpose coefficients(phase 1) >+ punpcklbw mm6,mm7 ; mm6=(00 01 10 11 20 21 30 31) >+ punpckhbw mm2,mm7 ; mm2=(06 07 16 17 26 27 36 37) >+ movq mm0,mm3 ; transpose coefficients(phase 1) >+ punpcklbw mm3,mm1 ; mm3=(02 03 12 13 22 23 32 33) >+ punpckhbw mm0,mm1 ; mm0=(04 05 14 15 24 25 34 35) >+ >+ movq mm5,mm6 ; transpose coefficients(phase 2) >+ punpcklwd mm6,mm3 ; mm6=(00 01 02 03 10 11 12 13) >+ punpckhwd mm5,mm3 ; mm5=(20 21 22 23 30 31 32 33) >+ movq mm4,mm0 ; transpose coefficients(phase 2) >+ punpcklwd mm0,mm2 ; mm0=(04 05 06 07 14 15 16 17) >+ punpckhwd mm4,mm2 ; mm4=(24 25 26 27 34 35 36 37) >+ >+ movq mm7,mm6 ; transpose coefficients(phase 3) >+ punpckldq mm6,mm0 ; mm6=(00 01 02 03 04 05 06 07) >+ punpckhdq mm7,mm0 ; mm7=(10 11 12 13 14 15 16 17) >+ movq mm1,mm5 ; transpose coefficients(phase 3) >+ punpckldq mm5,mm4 ; mm5=(20 21 22 23 24 25 26 27) >+ punpckhdq mm1,mm4 ; mm1=(30 31 32 33 34 35 36 37) >+ >+ pushpic ebx ; save GOT address >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm6 >+ movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm7 >+ mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW] >+ mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW] >+ movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm5 >+ movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm1 >+ >+ poppic ebx ; restore GOT address >+ >+ add esi, byte 4*SIZEOF_JCOEF ; wsptr >+ add edi, byte 4*SIZEOF_JSAMPROW >+ dec ecx ; ctr >+ jnz near .rowloop >+ >+ emms ; empty MMX state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jimmxint.asm b/modules/libjpeg-turbo/simd/jimmxint.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jimmxint.asm >@@ -0,0 +1,852 @@ >+; >+; jimmxint.asm - accurate integer IDCT (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a slow-but-accurate integer implementation of the >+; inverse DCT (Discrete Cosine Transform). The following code is based >+; directly on the IJG's original jidctint.c; see the jidctint.c for >+; more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 13 >+%define PASS1_BITS 2 >+ >+%define DESCALE_P1 (CONST_BITS-PASS1_BITS) >+%define DESCALE_P2 (CONST_BITS+PASS1_BITS+3) >+ >+%if CONST_BITS == 13 >+F_0_298 equ 2446 ; FIX(0.298631336) >+F_0_390 equ 3196 ; FIX(0.390180644) >+F_0_541 equ 4433 ; FIX(0.541196100) >+F_0_765 equ 6270 ; FIX(0.765366865) >+F_0_899 equ 7373 ; FIX(0.899976223) >+F_1_175 equ 9633 ; FIX(1.175875602) >+F_1_501 equ 12299 ; FIX(1.501321110) >+F_1_847 equ 15137 ; FIX(1.847759065) >+F_1_961 equ 16069 ; FIX(1.961570560) >+F_2_053 equ 16819 ; FIX(2.053119869) >+F_2_562 equ 20995 ; FIX(2.562915447) >+F_3_072 equ 25172 ; FIX(3.072711026) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_298 equ DESCALE( 320652955,30-CONST_BITS) ; FIX(0.298631336) >+F_0_390 equ DESCALE( 418953276,30-CONST_BITS) ; FIX(0.390180644) >+F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100) >+F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865) >+F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223) >+F_1_175 equ DESCALE(1262586813,30-CONST_BITS) ; FIX(1.175875602) >+F_1_501 equ DESCALE(1612031267,30-CONST_BITS) ; FIX(1.501321110) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_1_961 equ DESCALE(2106220350,30-CONST_BITS) ; FIX(1.961570560) >+F_2_053 equ DESCALE(2204520673,30-CONST_BITS) ; FIX(2.053119869) >+F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447) >+F_3_072 equ DESCALE(3299298341,30-CONST_BITS) ; FIX(3.072711026) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_idct_islow_mmx) >+ >+EXTN(jconst_idct_islow_mmx): >+ >+PW_F130_F054 times 2 dw (F_0_541+F_0_765), F_0_541 >+PW_F054_MF130 times 2 dw F_0_541, (F_0_541-F_1_847) >+PW_MF078_F117 times 2 dw (F_1_175-F_1_961), F_1_175 >+PW_F117_F078 times 2 dw F_1_175, (F_1_175-F_0_390) >+PW_MF060_MF089 times 2 dw (F_0_298-F_0_899),-F_0_899 >+PW_MF089_F060 times 2 dw -F_0_899, (F_1_501-F_0_899) >+PW_MF050_MF256 times 2 dw (F_2_053-F_2_562),-F_2_562 >+PW_MF256_F050 times 2 dw -F_2_562, (F_3_072-F_2_562) >+PD_DESCALE_P1 times 2 dd 1 << (DESCALE_P1-1) >+PD_DESCALE_P2 times 2 dd 1 << (DESCALE_P2-1) >+PB_CENTERJSAMP times 8 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform dequantization and inverse DCT on one block of coefficients. >+; >+; GLOBAL(void) >+; jsimd_idct_islow_mmx (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; jpeg_component_info * compptr >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 12 >+%define workspace wk(0)-DCTSIZE2*SIZEOF_JCOEF >+ ; JCOEF workspace[DCTSIZE2] >+ >+ align 16 >+ global EXTN(jsimd_idct_islow_mmx) >+ >+EXTN(jsimd_idct_islow_mmx): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [workspace] >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input, store into work array. >+ >+; mov eax, [original_ebp] >+ mov edx, POINTER [dct_table(eax)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(eax)] ; inptr >+ lea edi, [workspace] ; JCOEF * wsptr >+ mov ecx, DCTSIZE/4 ; ctr >+ alignx 16,7 >+.columnloop: >+%ifndef NO_ZERO_COLUMN_TEST_ISLOW_MMX >+ mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ jnz short .columnDCT >+ >+ movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ por mm1, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ por mm1, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ por mm1,mm0 >+ packsswb mm1,mm1 >+ movd eax,mm1 >+ test eax,eax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ psllw mm0,PASS1_BITS >+ >+ movq mm2,mm0 ; mm0=in0=(00 01 02 03) >+ punpcklwd mm0,mm0 ; mm0=(00 00 01 01) >+ punpckhwd mm2,mm2 ; mm2=(02 02 03 03) >+ >+ movq mm1,mm0 >+ punpckldq mm0,mm0 ; mm0=(00 00 00 00) >+ punpckhdq mm1,mm1 ; mm1=(01 01 01 01) >+ movq mm3,mm2 >+ punpckldq mm2,mm2 ; mm2=(02 02 02 02) >+ punpckhdq mm3,mm3 ; mm3=(03 03 03 03) >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0 >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm0 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1 >+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm1 >+ movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2 >+ movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm2 >+ movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3 >+ movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm3 >+ jmp near .nextcolumn >+ alignx 16,7 >+%endif >+.columnDCT: >+ >+ ; -- Even part >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ pmullw mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm3, MMWORD [MMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ ; (Original) >+ ; z1 = (z2 + z3) * 0.541196100; >+ ; tmp2 = z1 + z3 * -1.847759065; >+ ; tmp3 = z1 + z2 * 0.765366865; >+ ; >+ ; (This implementation) >+ ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065); >+ ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100; >+ >+ movq mm4,mm1 ; mm1=in2=z2 >+ movq mm5,mm1 >+ punpcklwd mm4,mm3 ; mm3=in6=z3 >+ punpckhwd mm5,mm3 >+ movq mm1,mm4 >+ movq mm3,mm5 >+ pmaddwd mm4,[GOTOFF(ebx,PW_F130_F054)] ; mm4=tmp3L >+ pmaddwd mm5,[GOTOFF(ebx,PW_F130_F054)] ; mm5=tmp3H >+ pmaddwd mm1,[GOTOFF(ebx,PW_F054_MF130)] ; mm1=tmp2L >+ pmaddwd mm3,[GOTOFF(ebx,PW_F054_MF130)] ; mm3=tmp2H >+ >+ movq mm6,mm0 >+ paddw mm0,mm2 ; mm0=in0+in4 >+ psubw mm6,mm2 ; mm6=in0-in4 >+ >+ pxor mm7,mm7 >+ pxor mm2,mm2 >+ punpcklwd mm7,mm0 ; mm7=tmp0L >+ punpckhwd mm2,mm0 ; mm2=tmp0H >+ psrad mm7,(16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS >+ psrad mm2,(16-CONST_BITS) ; psrad mm2,16 & pslld mm2,CONST_BITS >+ >+ movq mm0,mm7 >+ paddd mm7,mm4 ; mm7=tmp10L >+ psubd mm0,mm4 ; mm0=tmp13L >+ movq mm4,mm2 >+ paddd mm2,mm5 ; mm2=tmp10H >+ psubd mm4,mm5 ; mm4=tmp13H >+ >+ movq MMWORD [wk(0)], mm7 ; wk(0)=tmp10L >+ movq MMWORD [wk(1)], mm2 ; wk(1)=tmp10H >+ movq MMWORD [wk(2)], mm0 ; wk(2)=tmp13L >+ movq MMWORD [wk(3)], mm4 ; wk(3)=tmp13H >+ >+ pxor mm5,mm5 >+ pxor mm7,mm7 >+ punpcklwd mm5,mm6 ; mm5=tmp1L >+ punpckhwd mm7,mm6 ; mm7=tmp1H >+ psrad mm5,(16-CONST_BITS) ; psrad mm5,16 & pslld mm5,CONST_BITS >+ psrad mm7,(16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS >+ >+ movq mm2,mm5 >+ paddd mm5,mm1 ; mm5=tmp11L >+ psubd mm2,mm1 ; mm2=tmp12L >+ movq mm0,mm7 >+ paddd mm7,mm3 ; mm7=tmp11H >+ psubd mm0,mm3 ; mm0=tmp12H >+ >+ movq MMWORD [wk(4)], mm5 ; wk(4)=tmp11L >+ movq MMWORD [wk(5)], mm7 ; wk(5)=tmp11H >+ movq MMWORD [wk(6)], mm2 ; wk(6)=tmp12L >+ movq MMWORD [wk(7)], mm0 ; wk(7)=tmp12H >+ >+ ; -- Odd part >+ >+ movq mm4, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm6, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ pmullw mm4, MMWORD [MMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm6, MMWORD [MMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ movq mm1, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ pmullw mm1, MMWORD [MMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ movq mm5,mm6 >+ movq mm7,mm4 >+ paddw mm5,mm3 ; mm5=z3 >+ paddw mm7,mm1 ; mm7=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movq mm2,mm5 >+ movq mm0,mm5 >+ punpcklwd mm2,mm7 >+ punpckhwd mm0,mm7 >+ movq mm5,mm2 >+ movq mm7,mm0 >+ pmaddwd mm2,[GOTOFF(ebx,PW_MF078_F117)] ; mm2=z3L >+ pmaddwd mm0,[GOTOFF(ebx,PW_MF078_F117)] ; mm0=z3H >+ pmaddwd mm5,[GOTOFF(ebx,PW_F117_F078)] ; mm5=z4L >+ pmaddwd mm7,[GOTOFF(ebx,PW_F117_F078)] ; mm7=z4H >+ >+ movq MMWORD [wk(10)], mm2 ; wk(10)=z3L >+ movq MMWORD [wk(11)], mm0 ; wk(11)=z3H >+ >+ ; (Original) >+ ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2; >+ ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869; >+ ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; tmp0 += z1 + z3; tmp1 += z2 + z4; >+ ; tmp2 += z2 + z3; tmp3 += z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223; >+ ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447; >+ ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447); >+ ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223); >+ ; tmp0 += z3; tmp1 += z4; >+ ; tmp2 += z3; tmp3 += z4; >+ >+ movq mm2,mm3 >+ movq mm0,mm3 >+ punpcklwd mm2,mm4 >+ punpckhwd mm0,mm4 >+ movq mm3,mm2 >+ movq mm4,mm0 >+ pmaddwd mm2,[GOTOFF(ebx,PW_MF060_MF089)] ; mm2=tmp0L >+ pmaddwd mm0,[GOTOFF(ebx,PW_MF060_MF089)] ; mm0=tmp0H >+ pmaddwd mm3,[GOTOFF(ebx,PW_MF089_F060)] ; mm3=tmp3L >+ pmaddwd mm4,[GOTOFF(ebx,PW_MF089_F060)] ; mm4=tmp3H >+ >+ paddd mm2, MMWORD [wk(10)] ; mm2=tmp0L >+ paddd mm0, MMWORD [wk(11)] ; mm0=tmp0H >+ paddd mm3,mm5 ; mm3=tmp3L >+ paddd mm4,mm7 ; mm4=tmp3H >+ >+ movq MMWORD [wk(8)], mm2 ; wk(8)=tmp0L >+ movq MMWORD [wk(9)], mm0 ; wk(9)=tmp0H >+ >+ movq mm2,mm1 >+ movq mm0,mm1 >+ punpcklwd mm2,mm6 >+ punpckhwd mm0,mm6 >+ movq mm1,mm2 >+ movq mm6,mm0 >+ pmaddwd mm2,[GOTOFF(ebx,PW_MF050_MF256)] ; mm2=tmp1L >+ pmaddwd mm0,[GOTOFF(ebx,PW_MF050_MF256)] ; mm0=tmp1H >+ pmaddwd mm1,[GOTOFF(ebx,PW_MF256_F050)] ; mm1=tmp2L >+ pmaddwd mm6,[GOTOFF(ebx,PW_MF256_F050)] ; mm6=tmp2H >+ >+ paddd mm2,mm5 ; mm2=tmp1L >+ paddd mm0,mm7 ; mm0=tmp1H >+ paddd mm1, MMWORD [wk(10)] ; mm1=tmp2L >+ paddd mm6, MMWORD [wk(11)] ; mm6=tmp2H >+ >+ movq MMWORD [wk(10)], mm2 ; wk(10)=tmp1L >+ movq MMWORD [wk(11)], mm0 ; wk(11)=tmp1H >+ >+ ; -- Final output stage >+ >+ movq mm5, MMWORD [wk(0)] ; mm5=tmp10L >+ movq mm7, MMWORD [wk(1)] ; mm7=tmp10H >+ >+ movq mm2,mm5 >+ movq mm0,mm7 >+ paddd mm5,mm3 ; mm5=data0L >+ paddd mm7,mm4 ; mm7=data0H >+ psubd mm2,mm3 ; mm2=data7L >+ psubd mm0,mm4 ; mm0=data7H >+ >+ movq mm3,[GOTOFF(ebx,PD_DESCALE_P1)] ; mm3=[PD_DESCALE_P1] >+ >+ paddd mm5,mm3 >+ paddd mm7,mm3 >+ psrad mm5,DESCALE_P1 >+ psrad mm7,DESCALE_P1 >+ paddd mm2,mm3 >+ paddd mm0,mm3 >+ psrad mm2,DESCALE_P1 >+ psrad mm0,DESCALE_P1 >+ >+ packssdw mm5,mm7 ; mm5=data0=(00 01 02 03) >+ packssdw mm2,mm0 ; mm2=data7=(70 71 72 73) >+ >+ movq mm4, MMWORD [wk(4)] ; mm4=tmp11L >+ movq mm3, MMWORD [wk(5)] ; mm3=tmp11H >+ >+ movq mm7,mm4 >+ movq mm0,mm3 >+ paddd mm4,mm1 ; mm4=data1L >+ paddd mm3,mm6 ; mm3=data1H >+ psubd mm7,mm1 ; mm7=data6L >+ psubd mm0,mm6 ; mm0=data6H >+ >+ movq mm1,[GOTOFF(ebx,PD_DESCALE_P1)] ; mm1=[PD_DESCALE_P1] >+ >+ paddd mm4,mm1 >+ paddd mm3,mm1 >+ psrad mm4,DESCALE_P1 >+ psrad mm3,DESCALE_P1 >+ paddd mm7,mm1 >+ paddd mm0,mm1 >+ psrad mm7,DESCALE_P1 >+ psrad mm0,DESCALE_P1 >+ >+ packssdw mm4,mm3 ; mm4=data1=(10 11 12 13) >+ packssdw mm7,mm0 ; mm7=data6=(60 61 62 63) >+ >+ movq mm6,mm5 ; transpose coefficients(phase 1) >+ punpcklwd mm5,mm4 ; mm5=(00 10 01 11) >+ punpckhwd mm6,mm4 ; mm6=(02 12 03 13) >+ movq mm1,mm7 ; transpose coefficients(phase 1) >+ punpcklwd mm7,mm2 ; mm7=(60 70 61 71) >+ punpckhwd mm1,mm2 ; mm1=(62 72 63 73) >+ >+ movq mm3, MMWORD [wk(6)] ; mm3=tmp12L >+ movq mm0, MMWORD [wk(7)] ; mm0=tmp12H >+ movq mm4, MMWORD [wk(10)] ; mm4=tmp1L >+ movq mm2, MMWORD [wk(11)] ; mm2=tmp1H >+ >+ movq MMWORD [wk(0)], mm5 ; wk(0)=(00 10 01 11) >+ movq MMWORD [wk(1)], mm6 ; wk(1)=(02 12 03 13) >+ movq MMWORD [wk(4)], mm7 ; wk(4)=(60 70 61 71) >+ movq MMWORD [wk(5)], mm1 ; wk(5)=(62 72 63 73) >+ >+ movq mm5,mm3 >+ movq mm6,mm0 >+ paddd mm3,mm4 ; mm3=data2L >+ paddd mm0,mm2 ; mm0=data2H >+ psubd mm5,mm4 ; mm5=data5L >+ psubd mm6,mm2 ; mm6=data5H >+ >+ movq mm7,[GOTOFF(ebx,PD_DESCALE_P1)] ; mm7=[PD_DESCALE_P1] >+ >+ paddd mm3,mm7 >+ paddd mm0,mm7 >+ psrad mm3,DESCALE_P1 >+ psrad mm0,DESCALE_P1 >+ paddd mm5,mm7 >+ paddd mm6,mm7 >+ psrad mm5,DESCALE_P1 >+ psrad mm6,DESCALE_P1 >+ >+ packssdw mm3,mm0 ; mm3=data2=(20 21 22 23) >+ packssdw mm5,mm6 ; mm5=data5=(50 51 52 53) >+ >+ movq mm1, MMWORD [wk(2)] ; mm1=tmp13L >+ movq mm4, MMWORD [wk(3)] ; mm4=tmp13H >+ movq mm2, MMWORD [wk(8)] ; mm2=tmp0L >+ movq mm7, MMWORD [wk(9)] ; mm7=tmp0H >+ >+ movq mm0,mm1 >+ movq mm6,mm4 >+ paddd mm1,mm2 ; mm1=data3L >+ paddd mm4,mm7 ; mm4=data3H >+ psubd mm0,mm2 ; mm0=data4L >+ psubd mm6,mm7 ; mm6=data4H >+ >+ movq mm2,[GOTOFF(ebx,PD_DESCALE_P1)] ; mm2=[PD_DESCALE_P1] >+ >+ paddd mm1,mm2 >+ paddd mm4,mm2 >+ psrad mm1,DESCALE_P1 >+ psrad mm4,DESCALE_P1 >+ paddd mm0,mm2 >+ paddd mm6,mm2 >+ psrad mm0,DESCALE_P1 >+ psrad mm6,DESCALE_P1 >+ >+ packssdw mm1,mm4 ; mm1=data3=(30 31 32 33) >+ packssdw mm0,mm6 ; mm0=data4=(40 41 42 43) >+ >+ movq mm7, MMWORD [wk(0)] ; mm7=(00 10 01 11) >+ movq mm2, MMWORD [wk(1)] ; mm2=(02 12 03 13) >+ >+ movq mm4,mm3 ; transpose coefficients(phase 1) >+ punpcklwd mm3,mm1 ; mm3=(20 30 21 31) >+ punpckhwd mm4,mm1 ; mm4=(22 32 23 33) >+ movq mm6,mm0 ; transpose coefficients(phase 1) >+ punpcklwd mm0,mm5 ; mm0=(40 50 41 51) >+ punpckhwd mm6,mm5 ; mm6=(42 52 43 53) >+ >+ movq mm1,mm7 ; transpose coefficients(phase 2) >+ punpckldq mm7,mm3 ; mm7=(00 10 20 30) >+ punpckhdq mm1,mm3 ; mm1=(01 11 21 31) >+ movq mm5,mm2 ; transpose coefficients(phase 2) >+ punpckldq mm2,mm4 ; mm2=(02 12 22 32) >+ punpckhdq mm5,mm4 ; mm5=(03 13 23 33) >+ >+ movq mm3, MMWORD [wk(4)] ; mm3=(60 70 61 71) >+ movq mm4, MMWORD [wk(5)] ; mm4=(62 72 63 73) >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm7 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1 >+ movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2 >+ movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm5 >+ >+ movq mm7,mm0 ; transpose coefficients(phase 2) >+ punpckldq mm0,mm3 ; mm0=(40 50 60 70) >+ punpckhdq mm7,mm3 ; mm7=(41 51 61 71) >+ movq mm1,mm6 ; transpose coefficients(phase 2) >+ punpckldq mm6,mm4 ; mm6=(42 52 62 72) >+ punpckhdq mm1,mm4 ; mm1=(43 53 63 73) >+ >+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm0 >+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm7 >+ movq MMWORD [MMBLOCK(2,1,edi,SIZEOF_JCOEF)], mm6 >+ movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm1 >+ >+.nextcolumn: >+ add esi, byte 4*SIZEOF_JCOEF ; coef_block >+ add edx, byte 4*SIZEOF_ISLOW_MULT_TYPE ; quantptr >+ add edi, byte 4*DCTSIZE*SIZEOF_JCOEF ; wsptr >+ dec ecx ; ctr >+ jnz near .columnloop >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov eax, [original_ebp] >+ lea esi, [workspace] ; JCOEF * wsptr >+ mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(eax)] >+ mov ecx, DCTSIZE/4 ; ctr >+ alignx 16,7 >+.rowloop: >+ >+ ; -- Even part >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ >+ ; (Original) >+ ; z1 = (z2 + z3) * 0.541196100; >+ ; tmp2 = z1 + z3 * -1.847759065; >+ ; tmp3 = z1 + z2 * 0.765366865; >+ ; >+ ; (This implementation) >+ ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065); >+ ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100; >+ >+ movq mm4,mm1 ; mm1=in2=z2 >+ movq mm5,mm1 >+ punpcklwd mm4,mm3 ; mm3=in6=z3 >+ punpckhwd mm5,mm3 >+ movq mm1,mm4 >+ movq mm3,mm5 >+ pmaddwd mm4,[GOTOFF(ebx,PW_F130_F054)] ; mm4=tmp3L >+ pmaddwd mm5,[GOTOFF(ebx,PW_F130_F054)] ; mm5=tmp3H >+ pmaddwd mm1,[GOTOFF(ebx,PW_F054_MF130)] ; mm1=tmp2L >+ pmaddwd mm3,[GOTOFF(ebx,PW_F054_MF130)] ; mm3=tmp2H >+ >+ movq mm6,mm0 >+ paddw mm0,mm2 ; mm0=in0+in4 >+ psubw mm6,mm2 ; mm6=in0-in4 >+ >+ pxor mm7,mm7 >+ pxor mm2,mm2 >+ punpcklwd mm7,mm0 ; mm7=tmp0L >+ punpckhwd mm2,mm0 ; mm2=tmp0H >+ psrad mm7,(16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS >+ psrad mm2,(16-CONST_BITS) ; psrad mm2,16 & pslld mm2,CONST_BITS >+ >+ movq mm0,mm7 >+ paddd mm7,mm4 ; mm7=tmp10L >+ psubd mm0,mm4 ; mm0=tmp13L >+ movq mm4,mm2 >+ paddd mm2,mm5 ; mm2=tmp10H >+ psubd mm4,mm5 ; mm4=tmp13H >+ >+ movq MMWORD [wk(0)], mm7 ; wk(0)=tmp10L >+ movq MMWORD [wk(1)], mm2 ; wk(1)=tmp10H >+ movq MMWORD [wk(2)], mm0 ; wk(2)=tmp13L >+ movq MMWORD [wk(3)], mm4 ; wk(3)=tmp13H >+ >+ pxor mm5,mm5 >+ pxor mm7,mm7 >+ punpcklwd mm5,mm6 ; mm5=tmp1L >+ punpckhwd mm7,mm6 ; mm7=tmp1H >+ psrad mm5,(16-CONST_BITS) ; psrad mm5,16 & pslld mm5,CONST_BITS >+ psrad mm7,(16-CONST_BITS) ; psrad mm7,16 & pslld mm7,CONST_BITS >+ >+ movq mm2,mm5 >+ paddd mm5,mm1 ; mm5=tmp11L >+ psubd mm2,mm1 ; mm2=tmp12L >+ movq mm0,mm7 >+ paddd mm7,mm3 ; mm7=tmp11H >+ psubd mm0,mm3 ; mm0=tmp12H >+ >+ movq MMWORD [wk(4)], mm5 ; wk(4)=tmp11L >+ movq MMWORD [wk(5)], mm7 ; wk(5)=tmp11H >+ movq MMWORD [wk(6)], mm2 ; wk(6)=tmp12L >+ movq MMWORD [wk(7)], mm0 ; wk(7)=tmp12H >+ >+ ; -- Odd part >+ >+ movq mm4, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm6, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ >+ movq mm5,mm6 >+ movq mm7,mm4 >+ paddw mm5,mm3 ; mm5=z3 >+ paddw mm7,mm1 ; mm7=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movq mm2,mm5 >+ movq mm0,mm5 >+ punpcklwd mm2,mm7 >+ punpckhwd mm0,mm7 >+ movq mm5,mm2 >+ movq mm7,mm0 >+ pmaddwd mm2,[GOTOFF(ebx,PW_MF078_F117)] ; mm2=z3L >+ pmaddwd mm0,[GOTOFF(ebx,PW_MF078_F117)] ; mm0=z3H >+ pmaddwd mm5,[GOTOFF(ebx,PW_F117_F078)] ; mm5=z4L >+ pmaddwd mm7,[GOTOFF(ebx,PW_F117_F078)] ; mm7=z4H >+ >+ movq MMWORD [wk(10)], mm2 ; wk(10)=z3L >+ movq MMWORD [wk(11)], mm0 ; wk(11)=z3H >+ >+ ; (Original) >+ ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2; >+ ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869; >+ ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; tmp0 += z1 + z3; tmp1 += z2 + z4; >+ ; tmp2 += z2 + z3; tmp3 += z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223; >+ ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447; >+ ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447); >+ ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223); >+ ; tmp0 += z3; tmp1 += z4; >+ ; tmp2 += z3; tmp3 += z4; >+ >+ movq mm2,mm3 >+ movq mm0,mm3 >+ punpcklwd mm2,mm4 >+ punpckhwd mm0,mm4 >+ movq mm3,mm2 >+ movq mm4,mm0 >+ pmaddwd mm2,[GOTOFF(ebx,PW_MF060_MF089)] ; mm2=tmp0L >+ pmaddwd mm0,[GOTOFF(ebx,PW_MF060_MF089)] ; mm0=tmp0H >+ pmaddwd mm3,[GOTOFF(ebx,PW_MF089_F060)] ; mm3=tmp3L >+ pmaddwd mm4,[GOTOFF(ebx,PW_MF089_F060)] ; mm4=tmp3H >+ >+ paddd mm2, MMWORD [wk(10)] ; mm2=tmp0L >+ paddd mm0, MMWORD [wk(11)] ; mm0=tmp0H >+ paddd mm3,mm5 ; mm3=tmp3L >+ paddd mm4,mm7 ; mm4=tmp3H >+ >+ movq MMWORD [wk(8)], mm2 ; wk(8)=tmp0L >+ movq MMWORD [wk(9)], mm0 ; wk(9)=tmp0H >+ >+ movq mm2,mm1 >+ movq mm0,mm1 >+ punpcklwd mm2,mm6 >+ punpckhwd mm0,mm6 >+ movq mm1,mm2 >+ movq mm6,mm0 >+ pmaddwd mm2,[GOTOFF(ebx,PW_MF050_MF256)] ; mm2=tmp1L >+ pmaddwd mm0,[GOTOFF(ebx,PW_MF050_MF256)] ; mm0=tmp1H >+ pmaddwd mm1,[GOTOFF(ebx,PW_MF256_F050)] ; mm1=tmp2L >+ pmaddwd mm6,[GOTOFF(ebx,PW_MF256_F050)] ; mm6=tmp2H >+ >+ paddd mm2,mm5 ; mm2=tmp1L >+ paddd mm0,mm7 ; mm0=tmp1H >+ paddd mm1, MMWORD [wk(10)] ; mm1=tmp2L >+ paddd mm6, MMWORD [wk(11)] ; mm6=tmp2H >+ >+ movq MMWORD [wk(10)], mm2 ; wk(10)=tmp1L >+ movq MMWORD [wk(11)], mm0 ; wk(11)=tmp1H >+ >+ ; -- Final output stage >+ >+ movq mm5, MMWORD [wk(0)] ; mm5=tmp10L >+ movq mm7, MMWORD [wk(1)] ; mm7=tmp10H >+ >+ movq mm2,mm5 >+ movq mm0,mm7 >+ paddd mm5,mm3 ; mm5=data0L >+ paddd mm7,mm4 ; mm7=data0H >+ psubd mm2,mm3 ; mm2=data7L >+ psubd mm0,mm4 ; mm0=data7H >+ >+ movq mm3,[GOTOFF(ebx,PD_DESCALE_P2)] ; mm3=[PD_DESCALE_P2] >+ >+ paddd mm5,mm3 >+ paddd mm7,mm3 >+ psrad mm5,DESCALE_P2 >+ psrad mm7,DESCALE_P2 >+ paddd mm2,mm3 >+ paddd mm0,mm3 >+ psrad mm2,DESCALE_P2 >+ psrad mm0,DESCALE_P2 >+ >+ packssdw mm5,mm7 ; mm5=data0=(00 10 20 30) >+ packssdw mm2,mm0 ; mm2=data7=(07 17 27 37) >+ >+ movq mm4, MMWORD [wk(4)] ; mm4=tmp11L >+ movq mm3, MMWORD [wk(5)] ; mm3=tmp11H >+ >+ movq mm7,mm4 >+ movq mm0,mm3 >+ paddd mm4,mm1 ; mm4=data1L >+ paddd mm3,mm6 ; mm3=data1H >+ psubd mm7,mm1 ; mm7=data6L >+ psubd mm0,mm6 ; mm0=data6H >+ >+ movq mm1,[GOTOFF(ebx,PD_DESCALE_P2)] ; mm1=[PD_DESCALE_P2] >+ >+ paddd mm4,mm1 >+ paddd mm3,mm1 >+ psrad mm4,DESCALE_P2 >+ psrad mm3,DESCALE_P2 >+ paddd mm7,mm1 >+ paddd mm0,mm1 >+ psrad mm7,DESCALE_P2 >+ psrad mm0,DESCALE_P2 >+ >+ packssdw mm4,mm3 ; mm4=data1=(01 11 21 31) >+ packssdw mm7,mm0 ; mm7=data6=(06 16 26 36) >+ >+ packsswb mm5,mm7 ; mm5=(00 10 20 30 06 16 26 36) >+ packsswb mm4,mm2 ; mm4=(01 11 21 31 07 17 27 37) >+ >+ movq mm6, MMWORD [wk(6)] ; mm6=tmp12L >+ movq mm1, MMWORD [wk(7)] ; mm1=tmp12H >+ movq mm3, MMWORD [wk(10)] ; mm3=tmp1L >+ movq mm0, MMWORD [wk(11)] ; mm0=tmp1H >+ >+ movq MMWORD [wk(0)], mm5 ; wk(0)=(00 10 20 30 06 16 26 36) >+ movq MMWORD [wk(1)], mm4 ; wk(1)=(01 11 21 31 07 17 27 37) >+ >+ movq mm7,mm6 >+ movq mm2,mm1 >+ paddd mm6,mm3 ; mm6=data2L >+ paddd mm1,mm0 ; mm1=data2H >+ psubd mm7,mm3 ; mm7=data5L >+ psubd mm2,mm0 ; mm2=data5H >+ >+ movq mm5,[GOTOFF(ebx,PD_DESCALE_P2)] ; mm5=[PD_DESCALE_P2] >+ >+ paddd mm6,mm5 >+ paddd mm1,mm5 >+ psrad mm6,DESCALE_P2 >+ psrad mm1,DESCALE_P2 >+ paddd mm7,mm5 >+ paddd mm2,mm5 >+ psrad mm7,DESCALE_P2 >+ psrad mm2,DESCALE_P2 >+ >+ packssdw mm6,mm1 ; mm6=data2=(02 12 22 32) >+ packssdw mm7,mm2 ; mm7=data5=(05 15 25 35) >+ >+ movq mm4, MMWORD [wk(2)] ; mm4=tmp13L >+ movq mm3, MMWORD [wk(3)] ; mm3=tmp13H >+ movq mm0, MMWORD [wk(8)] ; mm0=tmp0L >+ movq mm5, MMWORD [wk(9)] ; mm5=tmp0H >+ >+ movq mm1,mm4 >+ movq mm2,mm3 >+ paddd mm4,mm0 ; mm4=data3L >+ paddd mm3,mm5 ; mm3=data3H >+ psubd mm1,mm0 ; mm1=data4L >+ psubd mm2,mm5 ; mm2=data4H >+ >+ movq mm0,[GOTOFF(ebx,PD_DESCALE_P2)] ; mm0=[PD_DESCALE_P2] >+ >+ paddd mm4,mm0 >+ paddd mm3,mm0 >+ psrad mm4,DESCALE_P2 >+ psrad mm3,DESCALE_P2 >+ paddd mm1,mm0 >+ paddd mm2,mm0 >+ psrad mm1,DESCALE_P2 >+ psrad mm2,DESCALE_P2 >+ >+ movq mm5,[GOTOFF(ebx,PB_CENTERJSAMP)] ; mm5=[PB_CENTERJSAMP] >+ >+ packssdw mm4,mm3 ; mm4=data3=(03 13 23 33) >+ packssdw mm1,mm2 ; mm1=data4=(04 14 24 34) >+ >+ movq mm0, MMWORD [wk(0)] ; mm0=(00 10 20 30 06 16 26 36) >+ movq mm3, MMWORD [wk(1)] ; mm3=(01 11 21 31 07 17 27 37) >+ >+ packsswb mm6,mm1 ; mm6=(02 12 22 32 04 14 24 34) >+ packsswb mm4,mm7 ; mm4=(03 13 23 33 05 15 25 35) >+ >+ paddb mm0,mm5 >+ paddb mm3,mm5 >+ paddb mm6,mm5 >+ paddb mm4,mm5 >+ >+ movq mm2,mm0 ; transpose coefficients(phase 1) >+ punpcklbw mm0,mm3 ; mm0=(00 01 10 11 20 21 30 31) >+ punpckhbw mm2,mm3 ; mm2=(06 07 16 17 26 27 36 37) >+ movq mm1,mm6 ; transpose coefficients(phase 1) >+ punpcklbw mm6,mm4 ; mm6=(02 03 12 13 22 23 32 33) >+ punpckhbw mm1,mm4 ; mm1=(04 05 14 15 24 25 34 35) >+ >+ movq mm7,mm0 ; transpose coefficients(phase 2) >+ punpcklwd mm0,mm6 ; mm0=(00 01 02 03 10 11 12 13) >+ punpckhwd mm7,mm6 ; mm7=(20 21 22 23 30 31 32 33) >+ movq mm5,mm1 ; transpose coefficients(phase 2) >+ punpcklwd mm1,mm2 ; mm1=(04 05 06 07 14 15 16 17) >+ punpckhwd mm5,mm2 ; mm5=(24 25 26 27 34 35 36 37) >+ >+ movq mm3,mm0 ; transpose coefficients(phase 3) >+ punpckldq mm0,mm1 ; mm0=(00 01 02 03 04 05 06 07) >+ punpckhdq mm3,mm1 ; mm3=(10 11 12 13 14 15 16 17) >+ movq mm4,mm7 ; transpose coefficients(phase 3) >+ punpckldq mm7,mm5 ; mm7=(20 21 22 23 24 25 26 27) >+ punpckhdq mm4,mm5 ; mm4=(30 31 32 33 34 35 36 37) >+ >+ pushpic ebx ; save GOT address >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm0 >+ movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm3 >+ mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW] >+ mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW] >+ movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm7 >+ movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm4 >+ >+ poppic ebx ; restore GOT address >+ >+ add esi, byte 4*SIZEOF_JCOEF ; wsptr >+ add edi, byte 4*SIZEOF_JSAMPROW >+ dec ecx ; ctr >+ jnz near .rowloop >+ >+ emms ; empty MMX state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jimmxred.asm b/modules/libjpeg-turbo/simd/jimmxred.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jimmxred.asm >@@ -0,0 +1,706 @@ >+; >+; jimmxred.asm - reduced-size IDCT (MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains inverse-DCT routines that produce reduced-size >+; output: either 4x4 or 2x2 pixels from an 8x8 DCT block. >+; The following code is based directly on the IJG's original jidctred.c; >+; see the jidctred.c for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 13 >+%define PASS1_BITS 2 >+ >+%define DESCALE_P1_4 (CONST_BITS-PASS1_BITS+1) >+%define DESCALE_P2_4 (CONST_BITS+PASS1_BITS+3+1) >+%define DESCALE_P1_2 (CONST_BITS-PASS1_BITS+2) >+%define DESCALE_P2_2 (CONST_BITS+PASS1_BITS+3+2) >+ >+%if CONST_BITS == 13 >+F_0_211 equ 1730 ; FIX(0.211164243) >+F_0_509 equ 4176 ; FIX(0.509795579) >+F_0_601 equ 4926 ; FIX(0.601344887) >+F_0_720 equ 5906 ; FIX(0.720959822) >+F_0_765 equ 6270 ; FIX(0.765366865) >+F_0_850 equ 6967 ; FIX(0.850430095) >+F_0_899 equ 7373 ; FIX(0.899976223) >+F_1_061 equ 8697 ; FIX(1.061594337) >+F_1_272 equ 10426 ; FIX(1.272758580) >+F_1_451 equ 11893 ; FIX(1.451774981) >+F_1_847 equ 15137 ; FIX(1.847759065) >+F_2_172 equ 17799 ; FIX(2.172734803) >+F_2_562 equ 20995 ; FIX(2.562915447) >+F_3_624 equ 29692 ; FIX(3.624509785) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_211 equ DESCALE( 226735879,30-CONST_BITS) ; FIX(0.211164243) >+F_0_509 equ DESCALE( 547388834,30-CONST_BITS) ; FIX(0.509795579) >+F_0_601 equ DESCALE( 645689155,30-CONST_BITS) ; FIX(0.601344887) >+F_0_720 equ DESCALE( 774124714,30-CONST_BITS) ; FIX(0.720959822) >+F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865) >+F_0_850 equ DESCALE( 913142361,30-CONST_BITS) ; FIX(0.850430095) >+F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223) >+F_1_061 equ DESCALE(1139878239,30-CONST_BITS) ; FIX(1.061594337) >+F_1_272 equ DESCALE(1366614119,30-CONST_BITS) ; FIX(1.272758580) >+F_1_451 equ DESCALE(1558831516,30-CONST_BITS) ; FIX(1.451774981) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_2_172 equ DESCALE(2332956230,30-CONST_BITS) ; FIX(2.172734803) >+F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447) >+F_3_624 equ DESCALE(3891787747,30-CONST_BITS) ; FIX(3.624509785) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_idct_red_mmx) >+ >+EXTN(jconst_idct_red_mmx): >+ >+PW_F184_MF076 times 2 dw F_1_847,-F_0_765 >+PW_F256_F089 times 2 dw F_2_562, F_0_899 >+PW_F106_MF217 times 2 dw F_1_061,-F_2_172 >+PW_MF060_MF050 times 2 dw -F_0_601,-F_0_509 >+PW_F145_MF021 times 2 dw F_1_451,-F_0_211 >+PW_F362_MF127 times 2 dw F_3_624,-F_1_272 >+PW_F085_MF072 times 2 dw F_0_850,-F_0_720 >+PD_DESCALE_P1_4 times 2 dd 1 << (DESCALE_P1_4-1) >+PD_DESCALE_P2_4 times 2 dd 1 << (DESCALE_P2_4-1) >+PD_DESCALE_P1_2 times 2 dd 1 << (DESCALE_P1_2-1) >+PD_DESCALE_P2_2 times 2 dd 1 << (DESCALE_P2_2-1) >+PB_CENTERJSAMP times 8 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform dequantization and inverse DCT on one block of coefficients, >+; producing a reduced-size 4x4 output block. >+; >+; GLOBAL(void) >+; jsimd_idct_4x4_mmx (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; void * dct_table >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM] >+%define WK_NUM 2 >+%define workspace wk(0)-DCTSIZE2*SIZEOF_JCOEF >+ ; JCOEF workspace[DCTSIZE2] >+ >+ align 16 >+ global EXTN(jsimd_idct_4x4_mmx) >+ >+EXTN(jsimd_idct_4x4_mmx): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [workspace] >+ pushpic ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input, store into work array. >+ >+; mov eax, [original_ebp] >+ mov edx, POINTER [dct_table(eax)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(eax)] ; inptr >+ lea edi, [workspace] ; JCOEF * wsptr >+ mov ecx, DCTSIZE/4 ; ctr >+ alignx 16,7 >+.columnloop: >+%ifndef NO_ZERO_COLUMN_TEST_4X4_MMX >+ mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ jnz short .columnDCT >+ >+ movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ por mm1, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ por mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ por mm0,mm1 >+ packsswb mm0,mm0 >+ movd eax,mm0 >+ test eax,eax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ psllw mm0,PASS1_BITS >+ >+ movq mm2,mm0 ; mm0=in0=(00 01 02 03) >+ punpcklwd mm0,mm0 ; mm0=(00 00 01 01) >+ punpckhwd mm2,mm2 ; mm2=(02 02 03 03) >+ >+ movq mm1,mm0 >+ punpckldq mm0,mm0 ; mm0=(00 00 00 00) >+ punpckhdq mm1,mm1 ; mm1=(01 01 01 01) >+ movq mm3,mm2 >+ punpckldq mm2,mm2 ; mm2=(02 02 02 02) >+ punpckhdq mm3,mm3 ; mm3=(03 03 03 03) >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1 >+ movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2 >+ movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3 >+ jmp near .nextcolumn >+ alignx 16,7 >+%endif >+.columnDCT: >+ >+ ; -- Odd part >+ >+ movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ pmullw mm0, MMWORD [MMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ movq mm2, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ pmullw mm2, MMWORD [MMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ movq mm4,mm0 >+ movq mm5,mm0 >+ punpcklwd mm4,mm1 >+ punpckhwd mm5,mm1 >+ movq mm0,mm4 >+ movq mm1,mm5 >+ pmaddwd mm4,[GOTOFF(ebx,PW_F256_F089)] ; mm4=(tmp2L) >+ pmaddwd mm5,[GOTOFF(ebx,PW_F256_F089)] ; mm5=(tmp2H) >+ pmaddwd mm0,[GOTOFF(ebx,PW_F106_MF217)] ; mm0=(tmp0L) >+ pmaddwd mm1,[GOTOFF(ebx,PW_F106_MF217)] ; mm1=(tmp0H) >+ >+ movq mm6,mm2 >+ movq mm7,mm2 >+ punpcklwd mm6,mm3 >+ punpckhwd mm7,mm3 >+ movq mm2,mm6 >+ movq mm3,mm7 >+ pmaddwd mm6,[GOTOFF(ebx,PW_MF060_MF050)] ; mm6=(tmp2L) >+ pmaddwd mm7,[GOTOFF(ebx,PW_MF060_MF050)] ; mm7=(tmp2H) >+ pmaddwd mm2,[GOTOFF(ebx,PW_F145_MF021)] ; mm2=(tmp0L) >+ pmaddwd mm3,[GOTOFF(ebx,PW_F145_MF021)] ; mm3=(tmp0H) >+ >+ paddd mm6,mm4 ; mm6=tmp2L >+ paddd mm7,mm5 ; mm7=tmp2H >+ paddd mm2,mm0 ; mm2=tmp0L >+ paddd mm3,mm1 ; mm3=tmp0H >+ >+ movq MMWORD [wk(0)], mm2 ; wk(0)=tmp0L >+ movq MMWORD [wk(1)], mm3 ; wk(1)=tmp0H >+ >+ ; -- Even part >+ >+ movq mm4, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movq mm5, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ movq mm0, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ pmullw mm4, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm5, MMWORD [MMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm0, MMWORD [MMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ pxor mm1,mm1 >+ pxor mm2,mm2 >+ punpcklwd mm1,mm4 ; mm1=tmp0L >+ punpckhwd mm2,mm4 ; mm2=tmp0H >+ psrad mm1,(16-CONST_BITS-1) ; psrad mm1,16 & pslld mm1,CONST_BITS+1 >+ psrad mm2,(16-CONST_BITS-1) ; psrad mm2,16 & pslld mm2,CONST_BITS+1 >+ >+ movq mm3,mm5 ; mm5=in2=z2 >+ punpcklwd mm5,mm0 ; mm0=in6=z3 >+ punpckhwd mm3,mm0 >+ pmaddwd mm5,[GOTOFF(ebx,PW_F184_MF076)] ; mm5=tmp2L >+ pmaddwd mm3,[GOTOFF(ebx,PW_F184_MF076)] ; mm3=tmp2H >+ >+ movq mm4,mm1 >+ movq mm0,mm2 >+ paddd mm1,mm5 ; mm1=tmp10L >+ paddd mm2,mm3 ; mm2=tmp10H >+ psubd mm4,mm5 ; mm4=tmp12L >+ psubd mm0,mm3 ; mm0=tmp12H >+ >+ ; -- Final output stage >+ >+ movq mm5,mm1 >+ movq mm3,mm2 >+ paddd mm1,mm6 ; mm1=data0L >+ paddd mm2,mm7 ; mm2=data0H >+ psubd mm5,mm6 ; mm5=data3L >+ psubd mm3,mm7 ; mm3=data3H >+ >+ movq mm6,[GOTOFF(ebx,PD_DESCALE_P1_4)] ; mm6=[PD_DESCALE_P1_4] >+ >+ paddd mm1,mm6 >+ paddd mm2,mm6 >+ psrad mm1,DESCALE_P1_4 >+ psrad mm2,DESCALE_P1_4 >+ paddd mm5,mm6 >+ paddd mm3,mm6 >+ psrad mm5,DESCALE_P1_4 >+ psrad mm3,DESCALE_P1_4 >+ >+ packssdw mm1,mm2 ; mm1=data0=(00 01 02 03) >+ packssdw mm5,mm3 ; mm5=data3=(30 31 32 33) >+ >+ movq mm7, MMWORD [wk(0)] ; mm7=tmp0L >+ movq mm6, MMWORD [wk(1)] ; mm6=tmp0H >+ >+ movq mm2,mm4 >+ movq mm3,mm0 >+ paddd mm4,mm7 ; mm4=data1L >+ paddd mm0,mm6 ; mm0=data1H >+ psubd mm2,mm7 ; mm2=data2L >+ psubd mm3,mm6 ; mm3=data2H >+ >+ movq mm7,[GOTOFF(ebx,PD_DESCALE_P1_4)] ; mm7=[PD_DESCALE_P1_4] >+ >+ paddd mm4,mm7 >+ paddd mm0,mm7 >+ psrad mm4,DESCALE_P1_4 >+ psrad mm0,DESCALE_P1_4 >+ paddd mm2,mm7 >+ paddd mm3,mm7 >+ psrad mm2,DESCALE_P1_4 >+ psrad mm3,DESCALE_P1_4 >+ >+ packssdw mm4,mm0 ; mm4=data1=(10 11 12 13) >+ packssdw mm2,mm3 ; mm2=data2=(20 21 22 23) >+ >+ movq mm6,mm1 ; transpose coefficients(phase 1) >+ punpcklwd mm1,mm4 ; mm1=(00 10 01 11) >+ punpckhwd mm6,mm4 ; mm6=(02 12 03 13) >+ movq mm7,mm2 ; transpose coefficients(phase 1) >+ punpcklwd mm2,mm5 ; mm2=(20 30 21 31) >+ punpckhwd mm7,mm5 ; mm7=(22 32 23 33) >+ >+ movq mm0,mm1 ; transpose coefficients(phase 2) >+ punpckldq mm1,mm2 ; mm1=(00 10 20 30) >+ punpckhdq mm0,mm2 ; mm0=(01 11 21 31) >+ movq mm3,mm6 ; transpose coefficients(phase 2) >+ punpckldq mm6,mm7 ; mm6=(02 12 22 32) >+ punpckhdq mm3,mm7 ; mm3=(03 13 23 33) >+ >+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm1 >+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm0 >+ movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm6 >+ movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3 >+ >+.nextcolumn: >+ add esi, byte 4*SIZEOF_JCOEF ; coef_block >+ add edx, byte 4*SIZEOF_ISLOW_MULT_TYPE ; quantptr >+ add edi, byte 4*DCTSIZE*SIZEOF_JCOEF ; wsptr >+ dec ecx ; ctr >+ jnz near .columnloop >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov eax, [original_ebp] >+ lea esi, [workspace] ; JCOEF * wsptr >+ mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(eax)] >+ >+ ; -- Odd part >+ >+ movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ movq mm2, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ >+ movq mm4,mm0 >+ movq mm5,mm0 >+ punpcklwd mm4,mm1 >+ punpckhwd mm5,mm1 >+ movq mm0,mm4 >+ movq mm1,mm5 >+ pmaddwd mm4,[GOTOFF(ebx,PW_F256_F089)] ; mm4=(tmp2L) >+ pmaddwd mm5,[GOTOFF(ebx,PW_F256_F089)] ; mm5=(tmp2H) >+ pmaddwd mm0,[GOTOFF(ebx,PW_F106_MF217)] ; mm0=(tmp0L) >+ pmaddwd mm1,[GOTOFF(ebx,PW_F106_MF217)] ; mm1=(tmp0H) >+ >+ movq mm6,mm2 >+ movq mm7,mm2 >+ punpcklwd mm6,mm3 >+ punpckhwd mm7,mm3 >+ movq mm2,mm6 >+ movq mm3,mm7 >+ pmaddwd mm6,[GOTOFF(ebx,PW_MF060_MF050)] ; mm6=(tmp2L) >+ pmaddwd mm7,[GOTOFF(ebx,PW_MF060_MF050)] ; mm7=(tmp2H) >+ pmaddwd mm2,[GOTOFF(ebx,PW_F145_MF021)] ; mm2=(tmp0L) >+ pmaddwd mm3,[GOTOFF(ebx,PW_F145_MF021)] ; mm3=(tmp0H) >+ >+ paddd mm6,mm4 ; mm6=tmp2L >+ paddd mm7,mm5 ; mm7=tmp2H >+ paddd mm2,mm0 ; mm2=tmp0L >+ paddd mm3,mm1 ; mm3=tmp0H >+ >+ movq MMWORD [wk(0)], mm2 ; wk(0)=tmp0L >+ movq MMWORD [wk(1)], mm3 ; wk(1)=tmp0H >+ >+ ; -- Even part >+ >+ movq mm4, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movq mm5, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ movq mm0, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ >+ pxor mm1,mm1 >+ pxor mm2,mm2 >+ punpcklwd mm1,mm4 ; mm1=tmp0L >+ punpckhwd mm2,mm4 ; mm2=tmp0H >+ psrad mm1,(16-CONST_BITS-1) ; psrad mm1,16 & pslld mm1,CONST_BITS+1 >+ psrad mm2,(16-CONST_BITS-1) ; psrad mm2,16 & pslld mm2,CONST_BITS+1 >+ >+ movq mm3,mm5 ; mm5=in2=z2 >+ punpcklwd mm5,mm0 ; mm0=in6=z3 >+ punpckhwd mm3,mm0 >+ pmaddwd mm5,[GOTOFF(ebx,PW_F184_MF076)] ; mm5=tmp2L >+ pmaddwd mm3,[GOTOFF(ebx,PW_F184_MF076)] ; mm3=tmp2H >+ >+ movq mm4,mm1 >+ movq mm0,mm2 >+ paddd mm1,mm5 ; mm1=tmp10L >+ paddd mm2,mm3 ; mm2=tmp10H >+ psubd mm4,mm5 ; mm4=tmp12L >+ psubd mm0,mm3 ; mm0=tmp12H >+ >+ ; -- Final output stage >+ >+ movq mm5,mm1 >+ movq mm3,mm2 >+ paddd mm1,mm6 ; mm1=data0L >+ paddd mm2,mm7 ; mm2=data0H >+ psubd mm5,mm6 ; mm5=data3L >+ psubd mm3,mm7 ; mm3=data3H >+ >+ movq mm6,[GOTOFF(ebx,PD_DESCALE_P2_4)] ; mm6=[PD_DESCALE_P2_4] >+ >+ paddd mm1,mm6 >+ paddd mm2,mm6 >+ psrad mm1,DESCALE_P2_4 >+ psrad mm2,DESCALE_P2_4 >+ paddd mm5,mm6 >+ paddd mm3,mm6 >+ psrad mm5,DESCALE_P2_4 >+ psrad mm3,DESCALE_P2_4 >+ >+ packssdw mm1,mm2 ; mm1=data0=(00 10 20 30) >+ packssdw mm5,mm3 ; mm5=data3=(03 13 23 33) >+ >+ movq mm7, MMWORD [wk(0)] ; mm7=tmp0L >+ movq mm6, MMWORD [wk(1)] ; mm6=tmp0H >+ >+ movq mm2,mm4 >+ movq mm3,mm0 >+ paddd mm4,mm7 ; mm4=data1L >+ paddd mm0,mm6 ; mm0=data1H >+ psubd mm2,mm7 ; mm2=data2L >+ psubd mm3,mm6 ; mm3=data2H >+ >+ movq mm7,[GOTOFF(ebx,PD_DESCALE_P2_4)] ; mm7=[PD_DESCALE_P2_4] >+ >+ paddd mm4,mm7 >+ paddd mm0,mm7 >+ psrad mm4,DESCALE_P2_4 >+ psrad mm0,DESCALE_P2_4 >+ paddd mm2,mm7 >+ paddd mm3,mm7 >+ psrad mm2,DESCALE_P2_4 >+ psrad mm3,DESCALE_P2_4 >+ >+ packssdw mm4,mm0 ; mm4=data1=(01 11 21 31) >+ packssdw mm2,mm3 ; mm2=data2=(02 12 22 32) >+ >+ movq mm6,[GOTOFF(ebx,PB_CENTERJSAMP)] ; mm6=[PB_CENTERJSAMP] >+ >+ packsswb mm1,mm2 ; mm1=(00 10 20 30 02 12 22 32) >+ packsswb mm4,mm5 ; mm4=(01 11 21 31 03 13 23 33) >+ paddb mm1,mm6 >+ paddb mm4,mm6 >+ >+ movq mm7,mm1 ; transpose coefficients(phase 1) >+ punpcklbw mm1,mm4 ; mm1=(00 01 10 11 20 21 30 31) >+ punpckhbw mm7,mm4 ; mm7=(02 03 12 13 22 23 32 33) >+ >+ movq mm0,mm1 ; transpose coefficients(phase 2) >+ punpcklwd mm1,mm7 ; mm1=(00 01 02 03 10 11 12 13) >+ punpckhwd mm0,mm7 ; mm0=(20 21 22 23 30 31 32 33) >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+2*SIZEOF_JSAMPROW] >+ movd DWORD [edx+eax*SIZEOF_JSAMPLE], mm1 >+ movd DWORD [esi+eax*SIZEOF_JSAMPLE], mm0 >+ >+ psrlq mm1,4*BYTE_BIT >+ psrlq mm0,4*BYTE_BIT >+ >+ mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW] >+ movd DWORD [edx+eax*SIZEOF_JSAMPLE], mm1 >+ movd DWORD [esi+eax*SIZEOF_JSAMPLE], mm0 >+ >+ emms ; empty MMX state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ poppic ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+ >+; -------------------------------------------------------------------------- >+; >+; Perform dequantization and inverse DCT on one block of coefficients, >+; producing a reduced-size 2x2 output block. >+; >+; GLOBAL(void) >+; jsimd_idct_2x2_mmx (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; void * dct_table >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+ align 16 >+ global EXTN(jsimd_idct_2x2_mmx) >+ >+EXTN(jsimd_idct_2x2_mmx): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input. >+ >+ mov edx, POINTER [dct_table(ebp)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(ebp)] ; inptr >+ >+ ; | input: | result: | >+ ; | 00 01 ** 03 ** 05 ** 07 | | >+ ; | 10 11 ** 13 ** 15 ** 17 | | >+ ; | ** ** ** ** ** ** ** ** | | >+ ; | 30 31 ** 33 ** 35 ** 37 | A0 A1 A3 A5 A7 | >+ ; | ** ** ** ** ** ** ** ** | B0 B1 B3 B5 B7 | >+ ; | 50 51 ** 53 ** 55 ** 57 | | >+ ; | ** ** ** ** ** ** ** ** | | >+ ; | 70 71 ** 73 ** 75 ** 77 | | >+ >+ ; -- Odd part >+ >+ movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ pmullw mm0, MMWORD [MMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ movq mm2, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ pmullw mm2, MMWORD [MMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ ; mm0=(10 11 ** 13), mm1=(30 31 ** 33) >+ ; mm2=(50 51 ** 53), mm3=(70 71 ** 73) >+ >+ pcmpeqd mm7,mm7 >+ pslld mm7,WORD_BIT ; mm7={0x0000 0xFFFF 0x0000 0xFFFF} >+ >+ movq mm4,mm0 ; mm4=(10 11 ** 13) >+ movq mm5,mm2 ; mm5=(50 51 ** 53) >+ punpcklwd mm4,mm1 ; mm4=(10 30 11 31) >+ punpcklwd mm5,mm3 ; mm5=(50 70 51 71) >+ pmaddwd mm4,[GOTOFF(ebx,PW_F362_MF127)] >+ pmaddwd mm5,[GOTOFF(ebx,PW_F085_MF072)] >+ >+ psrld mm0,WORD_BIT ; mm0=(11 -- 13 --) >+ pand mm1,mm7 ; mm1=(-- 31 -- 33) >+ psrld mm2,WORD_BIT ; mm2=(51 -- 53 --) >+ pand mm3,mm7 ; mm3=(-- 71 -- 73) >+ por mm0,mm1 ; mm0=(11 31 13 33) >+ por mm2,mm3 ; mm2=(51 71 53 73) >+ pmaddwd mm0,[GOTOFF(ebx,PW_F362_MF127)] >+ pmaddwd mm2,[GOTOFF(ebx,PW_F085_MF072)] >+ >+ paddd mm4,mm5 ; mm4=tmp0[col0 col1] >+ >+ movq mm6, MMWORD [MMBLOCK(1,1,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(3,1,esi,SIZEOF_JCOEF)] >+ pmullw mm6, MMWORD [MMBLOCK(1,1,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm1, MMWORD [MMBLOCK(3,1,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ movq mm3, MMWORD [MMBLOCK(5,1,esi,SIZEOF_JCOEF)] >+ movq mm5, MMWORD [MMBLOCK(7,1,esi,SIZEOF_JCOEF)] >+ pmullw mm3, MMWORD [MMBLOCK(5,1,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm5, MMWORD [MMBLOCK(7,1,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ ; mm6=(** 15 ** 17), mm1=(** 35 ** 37) >+ ; mm3=(** 55 ** 57), mm5=(** 75 ** 77) >+ >+ psrld mm6,WORD_BIT ; mm6=(15 -- 17 --) >+ pand mm1,mm7 ; mm1=(-- 35 -- 37) >+ psrld mm3,WORD_BIT ; mm3=(55 -- 57 --) >+ pand mm5,mm7 ; mm5=(-- 75 -- 77) >+ por mm6,mm1 ; mm6=(15 35 17 37) >+ por mm3,mm5 ; mm3=(55 75 57 77) >+ pmaddwd mm6,[GOTOFF(ebx,PW_F362_MF127)] >+ pmaddwd mm3,[GOTOFF(ebx,PW_F085_MF072)] >+ >+ paddd mm0,mm2 ; mm0=tmp0[col1 col3] >+ paddd mm6,mm3 ; mm6=tmp0[col5 col7] >+ >+ ; -- Even part >+ >+ movq mm1, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movq mm5, MMWORD [MMBLOCK(0,1,esi,SIZEOF_JCOEF)] >+ pmullw mm1, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw mm5, MMWORD [MMBLOCK(0,1,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ ; mm1=(00 01 ** 03), mm5=(** 05 ** 07) >+ >+ movq mm2,mm1 ; mm2=(00 01 ** 03) >+ pslld mm1,WORD_BIT ; mm1=(-- 00 -- **) >+ psrad mm1,(WORD_BIT-CONST_BITS-2) ; mm1=tmp10[col0 ****] >+ >+ pand mm2,mm7 ; mm2=(-- 01 -- 03) >+ pand mm5,mm7 ; mm5=(-- 05 -- 07) >+ psrad mm2,(WORD_BIT-CONST_BITS-2) ; mm2=tmp10[col1 col3] >+ psrad mm5,(WORD_BIT-CONST_BITS-2) ; mm5=tmp10[col5 col7] >+ >+ ; -- Final output stage >+ >+ movq mm3,mm1 >+ paddd mm1,mm4 ; mm1=data0[col0 ****]=(A0 **) >+ psubd mm3,mm4 ; mm3=data1[col0 ****]=(B0 **) >+ punpckldq mm1,mm3 ; mm1=(A0 B0) >+ >+ movq mm7,[GOTOFF(ebx,PD_DESCALE_P1_2)] ; mm7=[PD_DESCALE_P1_2] >+ >+ movq mm4,mm2 >+ movq mm3,mm5 >+ paddd mm2,mm0 ; mm2=data0[col1 col3]=(A1 A3) >+ paddd mm5,mm6 ; mm5=data0[col5 col7]=(A5 A7) >+ psubd mm4,mm0 ; mm4=data1[col1 col3]=(B1 B3) >+ psubd mm3,mm6 ; mm3=data1[col5 col7]=(B5 B7) >+ >+ paddd mm1,mm7 >+ psrad mm1,DESCALE_P1_2 >+ >+ paddd mm2,mm7 >+ paddd mm5,mm7 >+ psrad mm2,DESCALE_P1_2 >+ psrad mm5,DESCALE_P1_2 >+ paddd mm4,mm7 >+ paddd mm3,mm7 >+ psrad mm4,DESCALE_P1_2 >+ psrad mm3,DESCALE_P1_2 >+ >+ ; ---- Pass 2: process rows, store into output array. >+ >+ mov edi, JSAMPARRAY [output_buf(ebp)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(ebp)] >+ >+ ; | input:| result:| >+ ; | A0 B0 | | >+ ; | A1 B1 | C0 C1 | >+ ; | A3 B3 | D0 D1 | >+ ; | A5 B5 | | >+ ; | A7 B7 | | >+ >+ ; -- Odd part >+ >+ packssdw mm2,mm4 ; mm2=(A1 A3 B1 B3) >+ packssdw mm5,mm3 ; mm5=(A5 A7 B5 B7) >+ pmaddwd mm2,[GOTOFF(ebx,PW_F362_MF127)] >+ pmaddwd mm5,[GOTOFF(ebx,PW_F085_MF072)] >+ >+ paddd mm2,mm5 ; mm2=tmp0[row0 row1] >+ >+ ; -- Even part >+ >+ pslld mm1,(CONST_BITS+2) ; mm1=tmp10[row0 row1] >+ >+ ; -- Final output stage >+ >+ movq mm0,[GOTOFF(ebx,PD_DESCALE_P2_2)] ; mm0=[PD_DESCALE_P2_2] >+ >+ movq mm6,mm1 >+ paddd mm1,mm2 ; mm1=data0[row0 row1]=(C0 C1) >+ psubd mm6,mm2 ; mm6=data1[row0 row1]=(D0 D1) >+ >+ paddd mm1,mm0 >+ paddd mm6,mm0 >+ psrad mm1,DESCALE_P2_2 >+ psrad mm6,DESCALE_P2_2 >+ >+ movq mm7,mm1 ; transpose coefficients >+ punpckldq mm1,mm6 ; mm1=(C0 D0) >+ punpckhdq mm7,mm6 ; mm7=(C1 D1) >+ >+ packssdw mm1,mm7 ; mm1=(C0 D0 C1 D1) >+ packsswb mm1,mm1 ; mm1=(C0 D0 C1 D1 C0 D0 C1 D1) >+ paddb mm1,[GOTOFF(ebx,PB_CENTERJSAMP)] >+ >+ movd ecx,mm1 >+ movd ebx,mm1 ; ebx=(C0 D0 C1 D1) >+ shr ecx,2*BYTE_BIT ; ecx=(C1 D1 -- --) >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ mov WORD [edx+eax*SIZEOF_JSAMPLE], bx >+ mov WORD [esi+eax*SIZEOF_JSAMPLE], cx >+ >+ emms ; empty MMX state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jiss2flt-64.asm b/modules/libjpeg-turbo/simd/jiss2flt-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jiss2flt-64.asm >@@ -0,0 +1,483 @@ >+; >+; jiss2flt-64.asm - floating-point IDCT (64-bit SSE & SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a floating-point implementation of the inverse DCT >+; (Discrete Cosine Transform). The following code is based directly on >+; the IJG's original jidctflt.c; see the jidctflt.c for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5) >+ shufps %1,%2,0x44 >+%endmacro >+ >+%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7) >+ shufps %1,%2,0xEE >+%endmacro >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_idct_float_sse2) >+ >+EXTN(jconst_idct_float_sse2): >+ >+PD_1_414 times 4 dd 1.414213562373095048801689 >+PD_1_847 times 4 dd 1.847759065022573512256366 >+PD_1_082 times 4 dd 1.082392200292393968799446 >+PD_M2_613 times 4 dd -2.613125929752753055713286 >+PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3) >+PB_CENTERJSAMP times 16 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Perform dequantization and inverse DCT on one block of coefficients. >+; >+; GLOBAL(void) >+; jsimd_idct_float_sse2 (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+; r10 = void * dct_table >+; r11 = JCOEFPTR coef_block >+; r12 = JSAMPARRAY output_buf >+; r13 = JDIMENSION output_col >+ >+%define original_rbp rbp+0 >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+%define workspace wk(0)-DCTSIZE2*SIZEOF_FAST_FLOAT >+ ; FAST_FLOAT workspace[DCTSIZE2] >+ >+ align 16 >+ global EXTN(jsimd_idct_float_sse2) >+ >+EXTN(jsimd_idct_float_sse2): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [workspace] >+ collect_args >+ push rbx >+ >+ ; ---- Pass 1: process columns from input, store into work array. >+ >+ mov rdx, r10 ; quantptr >+ mov rsi, r11 ; inptr >+ lea rdi, [workspace] ; FAST_FLOAT * wsptr >+ mov rcx, DCTSIZE/4 ; ctr >+.columnloop: >+%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE >+ mov eax, DWORD [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ jnz near .columnDCT >+ >+ movq xmm1, XMM_MMWORD [MMBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ movq xmm2, XMM_MMWORD [MMBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ movq xmm3, XMM_MMWORD [MMBLOCK(3,0,rsi,SIZEOF_JCOEF)] >+ movq xmm4, XMM_MMWORD [MMBLOCK(4,0,rsi,SIZEOF_JCOEF)] >+ movq xmm5, XMM_MMWORD [MMBLOCK(5,0,rsi,SIZEOF_JCOEF)] >+ movq xmm6, XMM_MMWORD [MMBLOCK(6,0,rsi,SIZEOF_JCOEF)] >+ movq xmm7, XMM_MMWORD [MMBLOCK(7,0,rsi,SIZEOF_JCOEF)] >+ por xmm1,xmm2 >+ por xmm3,xmm4 >+ por xmm5,xmm6 >+ por xmm1,xmm3 >+ por xmm5,xmm7 >+ por xmm1,xmm5 >+ packsswb xmm1,xmm1 >+ movd eax,xmm1 >+ test rax,rax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movq xmm0, XMM_MMWORD [MMBLOCK(0,0,rsi,SIZEOF_JCOEF)] >+ >+ punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) >+ psrad xmm0,(DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03) >+ cvtdq2ps xmm0,xmm0 ; xmm0=in0=(00 01 02 03) >+ >+ mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movaps xmm1,xmm0 >+ movaps xmm2,xmm0 >+ movaps xmm3,xmm0 >+ >+ shufps xmm0,xmm0,0x00 ; xmm0=(00 00 00 00) >+ shufps xmm1,xmm1,0x55 ; xmm1=(01 01 01 01) >+ shufps xmm2,xmm2,0xAA ; xmm2=(02 02 02 02) >+ shufps xmm3,xmm3,0xFF ; xmm3=(03 03 03 03) >+ >+ movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_FAST_FLOAT)], xmm2 >+ movaps XMMWORD [XMMBLOCK(2,1,rdi,SIZEOF_FAST_FLOAT)], xmm2 >+ movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm3 >+ movaps XMMWORD [XMMBLOCK(3,1,rdi,SIZEOF_FAST_FLOAT)], xmm3 >+ jmp near .nextcolumn >+%endif >+.columnDCT: >+ >+ ; -- Even part >+ >+ movq xmm0, XMM_MMWORD [MMBLOCK(0,0,rsi,SIZEOF_JCOEF)] >+ movq xmm1, XMM_MMWORD [MMBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ movq xmm2, XMM_MMWORD [MMBLOCK(4,0,rsi,SIZEOF_JCOEF)] >+ movq xmm3, XMM_MMWORD [MMBLOCK(6,0,rsi,SIZEOF_JCOEF)] >+ >+ punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) >+ punpcklwd xmm1,xmm1 ; xmm1=(20 20 21 21 22 22 23 23) >+ psrad xmm0,(DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03) >+ psrad xmm1,(DWORD_BIT-WORD_BIT) ; xmm1=in2=(20 21 22 23) >+ cvtdq2ps xmm0,xmm0 ; xmm0=in0=(00 01 02 03) >+ cvtdq2ps xmm1,xmm1 ; xmm1=in2=(20 21 22 23) >+ >+ punpcklwd xmm2,xmm2 ; xmm2=(40 40 41 41 42 42 43 43) >+ punpcklwd xmm3,xmm3 ; xmm3=(60 60 61 61 62 62 63 63) >+ psrad xmm2,(DWORD_BIT-WORD_BIT) ; xmm2=in4=(40 41 42 43) >+ psrad xmm3,(DWORD_BIT-WORD_BIT) ; xmm3=in6=(60 61 62 63) >+ cvtdq2ps xmm2,xmm2 ; xmm2=in4=(40 41 42 43) >+ cvtdq2ps xmm3,xmm3 ; xmm3=in6=(60 61 62 63) >+ >+ mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movaps xmm4,xmm0 >+ movaps xmm5,xmm1 >+ subps xmm0,xmm2 ; xmm0=tmp11 >+ subps xmm1,xmm3 >+ addps xmm4,xmm2 ; xmm4=tmp10 >+ addps xmm5,xmm3 ; xmm5=tmp13 >+ >+ mulps xmm1,[rel PD_1_414] >+ subps xmm1,xmm5 ; xmm1=tmp12 >+ >+ movaps xmm6,xmm4 >+ movaps xmm7,xmm0 >+ subps xmm4,xmm5 ; xmm4=tmp3 >+ subps xmm0,xmm1 ; xmm0=tmp2 >+ addps xmm6,xmm5 ; xmm6=tmp0 >+ addps xmm7,xmm1 ; xmm7=tmp1 >+ >+ movaps XMMWORD [wk(1)], xmm4 ; tmp3 >+ movaps XMMWORD [wk(0)], xmm0 ; tmp2 >+ >+ ; -- Odd part >+ >+ movq xmm2, XMM_MMWORD [MMBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ movq xmm3, XMM_MMWORD [MMBLOCK(3,0,rsi,SIZEOF_JCOEF)] >+ movq xmm5, XMM_MMWORD [MMBLOCK(5,0,rsi,SIZEOF_JCOEF)] >+ movq xmm1, XMM_MMWORD [MMBLOCK(7,0,rsi,SIZEOF_JCOEF)] >+ >+ punpcklwd xmm2,xmm2 ; xmm2=(10 10 11 11 12 12 13 13) >+ punpcklwd xmm3,xmm3 ; xmm3=(30 30 31 31 32 32 33 33) >+ psrad xmm2,(DWORD_BIT-WORD_BIT) ; xmm2=in1=(10 11 12 13) >+ psrad xmm3,(DWORD_BIT-WORD_BIT) ; xmm3=in3=(30 31 32 33) >+ cvtdq2ps xmm2,xmm2 ; xmm2=in1=(10 11 12 13) >+ cvtdq2ps xmm3,xmm3 ; xmm3=in3=(30 31 32 33) >+ >+ punpcklwd xmm5,xmm5 ; xmm5=(50 50 51 51 52 52 53 53) >+ punpcklwd xmm1,xmm1 ; xmm1=(70 70 71 71 72 72 73 73) >+ psrad xmm5,(DWORD_BIT-WORD_BIT) ; xmm5=in5=(50 51 52 53) >+ psrad xmm1,(DWORD_BIT-WORD_BIT) ; xmm1=in7=(70 71 72 73) >+ cvtdq2ps xmm5,xmm5 ; xmm5=in5=(50 51 52 53) >+ cvtdq2ps xmm1,xmm1 ; xmm1=in7=(70 71 72 73) >+ >+ mulps xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm5, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm1, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movaps xmm4,xmm2 >+ movaps xmm0,xmm5 >+ addps xmm2,xmm1 ; xmm2=z11 >+ addps xmm5,xmm3 ; xmm5=z13 >+ subps xmm4,xmm1 ; xmm4=z12 >+ subps xmm0,xmm3 ; xmm0=z10 >+ >+ movaps xmm1,xmm2 >+ subps xmm2,xmm5 >+ addps xmm1,xmm5 ; xmm1=tmp7 >+ >+ mulps xmm2,[rel PD_1_414] ; xmm2=tmp11 >+ >+ movaps xmm3,xmm0 >+ addps xmm0,xmm4 >+ mulps xmm0,[rel PD_1_847] ; xmm0=z5 >+ mulps xmm3,[rel PD_M2_613] ; xmm3=(z10 * -2.613125930) >+ mulps xmm4,[rel PD_1_082] ; xmm4=(z12 * 1.082392200) >+ addps xmm3,xmm0 ; xmm3=tmp12 >+ subps xmm4,xmm0 ; xmm4=tmp10 >+ >+ ; -- Final output stage >+ >+ subps xmm3,xmm1 ; xmm3=tmp6 >+ movaps xmm5,xmm6 >+ movaps xmm0,xmm7 >+ addps xmm6,xmm1 ; xmm6=data0=(00 01 02 03) >+ addps xmm7,xmm3 ; xmm7=data1=(10 11 12 13) >+ subps xmm5,xmm1 ; xmm5=data7=(70 71 72 73) >+ subps xmm0,xmm3 ; xmm0=data6=(60 61 62 63) >+ subps xmm2,xmm3 ; xmm2=tmp5 >+ >+ movaps xmm1,xmm6 ; transpose coefficients(phase 1) >+ unpcklps xmm6,xmm7 ; xmm6=(00 10 01 11) >+ unpckhps xmm1,xmm7 ; xmm1=(02 12 03 13) >+ movaps xmm3,xmm0 ; transpose coefficients(phase 1) >+ unpcklps xmm0,xmm5 ; xmm0=(60 70 61 71) >+ unpckhps xmm3,xmm5 ; xmm3=(62 72 63 73) >+ >+ movaps xmm7, XMMWORD [wk(0)] ; xmm7=tmp2 >+ movaps xmm5, XMMWORD [wk(1)] ; xmm5=tmp3 >+ >+ movaps XMMWORD [wk(0)], xmm0 ; wk(0)=(60 70 61 71) >+ movaps XMMWORD [wk(1)], xmm3 ; wk(1)=(62 72 63 73) >+ >+ addps xmm4,xmm2 ; xmm4=tmp4 >+ movaps xmm0,xmm7 >+ movaps xmm3,xmm5 >+ addps xmm7,xmm2 ; xmm7=data2=(20 21 22 23) >+ addps xmm5,xmm4 ; xmm5=data4=(40 41 42 43) >+ subps xmm0,xmm2 ; xmm0=data5=(50 51 52 53) >+ subps xmm3,xmm4 ; xmm3=data3=(30 31 32 33) >+ >+ movaps xmm2,xmm7 ; transpose coefficients(phase 1) >+ unpcklps xmm7,xmm3 ; xmm7=(20 30 21 31) >+ unpckhps xmm2,xmm3 ; xmm2=(22 32 23 33) >+ movaps xmm4,xmm5 ; transpose coefficients(phase 1) >+ unpcklps xmm5,xmm0 ; xmm5=(40 50 41 51) >+ unpckhps xmm4,xmm0 ; xmm4=(42 52 43 53) >+ >+ movaps xmm3,xmm6 ; transpose coefficients(phase 2) >+ unpcklps2 xmm6,xmm7 ; xmm6=(00 10 20 30) >+ unpckhps2 xmm3,xmm7 ; xmm3=(01 11 21 31) >+ movaps xmm0,xmm1 ; transpose coefficients(phase 2) >+ unpcklps2 xmm1,xmm2 ; xmm1=(02 12 22 32) >+ unpckhps2 xmm0,xmm2 ; xmm0=(03 13 23 33) >+ >+ movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71) >+ movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73) >+ >+ movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm6 >+ movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm3 >+ movaps XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm0 >+ >+ movaps xmm6,xmm5 ; transpose coefficients(phase 2) >+ unpcklps2 xmm5,xmm7 ; xmm5=(40 50 60 70) >+ unpckhps2 xmm6,xmm7 ; xmm6=(41 51 61 71) >+ movaps xmm3,xmm4 ; transpose coefficients(phase 2) >+ unpcklps2 xmm4,xmm2 ; xmm4=(42 52 62 72) >+ unpckhps2 xmm3,xmm2 ; xmm3=(43 53 63 73) >+ >+ movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm6 >+ movaps XMMWORD [XMMBLOCK(2,1,rdi,SIZEOF_FAST_FLOAT)], xmm4 >+ movaps XMMWORD [XMMBLOCK(3,1,rdi,SIZEOF_FAST_FLOAT)], xmm3 >+ >+.nextcolumn: >+ add rsi, byte 4*SIZEOF_JCOEF ; coef_block >+ add rdx, byte 4*SIZEOF_FLOAT_MULT_TYPE ; quantptr >+ add rdi, 4*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr >+ dec rcx ; ctr >+ jnz near .columnloop >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32] >+ prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32] >+ prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32] >+ prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov rax, [original_rbp] >+ lea rsi, [workspace] ; FAST_FLOAT * wsptr >+ mov rdi, r12 ; (JSAMPROW *) >+ mov rax, r13 >+ mov rcx, DCTSIZE/4 ; ctr >+.rowloop: >+ >+ ; -- Even part >+ >+ movaps xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_FAST_FLOAT)] >+ movaps xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_FAST_FLOAT)] >+ >+ movaps xmm4,xmm0 >+ movaps xmm5,xmm1 >+ subps xmm0,xmm2 ; xmm0=tmp11 >+ subps xmm1,xmm3 >+ addps xmm4,xmm2 ; xmm4=tmp10 >+ addps xmm5,xmm3 ; xmm5=tmp13 >+ >+ mulps xmm1,[rel PD_1_414] >+ subps xmm1,xmm5 ; xmm1=tmp12 >+ >+ movaps xmm6,xmm4 >+ movaps xmm7,xmm0 >+ subps xmm4,xmm5 ; xmm4=tmp3 >+ subps xmm0,xmm1 ; xmm0=tmp2 >+ addps xmm6,xmm5 ; xmm6=tmp0 >+ addps xmm7,xmm1 ; xmm7=tmp1 >+ >+ movaps XMMWORD [wk(1)], xmm4 ; tmp3 >+ movaps XMMWORD [wk(0)], xmm0 ; tmp2 >+ >+ ; -- Odd part >+ >+ movaps xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_FAST_FLOAT)] >+ movaps xmm5, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_FAST_FLOAT)] >+ >+ movaps xmm4,xmm2 >+ movaps xmm0,xmm5 >+ addps xmm2,xmm1 ; xmm2=z11 >+ addps xmm5,xmm3 ; xmm5=z13 >+ subps xmm4,xmm1 ; xmm4=z12 >+ subps xmm0,xmm3 ; xmm0=z10 >+ >+ movaps xmm1,xmm2 >+ subps xmm2,xmm5 >+ addps xmm1,xmm5 ; xmm1=tmp7 >+ >+ mulps xmm2,[rel PD_1_414] ; xmm2=tmp11 >+ >+ movaps xmm3,xmm0 >+ addps xmm0,xmm4 >+ mulps xmm0,[rel PD_1_847] ; xmm0=z5 >+ mulps xmm3,[rel PD_M2_613] ; xmm3=(z10 * -2.613125930) >+ mulps xmm4,[rel PD_1_082] ; xmm4=(z12 * 1.082392200) >+ addps xmm3,xmm0 ; xmm3=tmp12 >+ subps xmm4,xmm0 ; xmm4=tmp10 >+ >+ ; -- Final output stage >+ >+ subps xmm3,xmm1 ; xmm3=tmp6 >+ movaps xmm5,xmm6 >+ movaps xmm0,xmm7 >+ addps xmm6,xmm1 ; xmm6=data0=(00 10 20 30) >+ addps xmm7,xmm3 ; xmm7=data1=(01 11 21 31) >+ subps xmm5,xmm1 ; xmm5=data7=(07 17 27 37) >+ subps xmm0,xmm3 ; xmm0=data6=(06 16 26 36) >+ subps xmm2,xmm3 ; xmm2=tmp5 >+ >+ movaps xmm1,[rel PD_RNDINT_MAGIC] ; xmm1=[rel PD_RNDINT_MAGIC] >+ pcmpeqd xmm3,xmm3 >+ psrld xmm3,WORD_BIT ; xmm3={0xFFFF 0x0000 0xFFFF 0x0000 ..} >+ >+ addps xmm6,xmm1 ; xmm6=roundint(data0/8)=(00 ** 10 ** 20 ** 30 **) >+ addps xmm7,xmm1 ; xmm7=roundint(data1/8)=(01 ** 11 ** 21 ** 31 **) >+ addps xmm0,xmm1 ; xmm0=roundint(data6/8)=(06 ** 16 ** 26 ** 36 **) >+ addps xmm5,xmm1 ; xmm5=roundint(data7/8)=(07 ** 17 ** 27 ** 37 **) >+ >+ pand xmm6,xmm3 ; xmm6=(00 -- 10 -- 20 -- 30 --) >+ pslld xmm7,WORD_BIT ; xmm7=(-- 01 -- 11 -- 21 -- 31) >+ pand xmm0,xmm3 ; xmm0=(06 -- 16 -- 26 -- 36 --) >+ pslld xmm5,WORD_BIT ; xmm5=(-- 07 -- 17 -- 27 -- 37) >+ por xmm6,xmm7 ; xmm6=(00 01 10 11 20 21 30 31) >+ por xmm0,xmm5 ; xmm0=(06 07 16 17 26 27 36 37) >+ >+ movaps xmm1, XMMWORD [wk(0)] ; xmm1=tmp2 >+ movaps xmm3, XMMWORD [wk(1)] ; xmm3=tmp3 >+ >+ addps xmm4,xmm2 ; xmm4=tmp4 >+ movaps xmm7,xmm1 >+ movaps xmm5,xmm3 >+ addps xmm1,xmm2 ; xmm1=data2=(02 12 22 32) >+ addps xmm3,xmm4 ; xmm3=data4=(04 14 24 34) >+ subps xmm7,xmm2 ; xmm7=data5=(05 15 25 35) >+ subps xmm5,xmm4 ; xmm5=data3=(03 13 23 33) >+ >+ movaps xmm2,[rel PD_RNDINT_MAGIC] ; xmm2=[rel PD_RNDINT_MAGIC] >+ pcmpeqd xmm4,xmm4 >+ psrld xmm4,WORD_BIT ; xmm4={0xFFFF 0x0000 0xFFFF 0x0000 ..} >+ >+ addps xmm3,xmm2 ; xmm3=roundint(data4/8)=(04 ** 14 ** 24 ** 34 **) >+ addps xmm7,xmm2 ; xmm7=roundint(data5/8)=(05 ** 15 ** 25 ** 35 **) >+ addps xmm1,xmm2 ; xmm1=roundint(data2/8)=(02 ** 12 ** 22 ** 32 **) >+ addps xmm5,xmm2 ; xmm5=roundint(data3/8)=(03 ** 13 ** 23 ** 33 **) >+ >+ pand xmm3,xmm4 ; xmm3=(04 -- 14 -- 24 -- 34 --) >+ pslld xmm7,WORD_BIT ; xmm7=(-- 05 -- 15 -- 25 -- 35) >+ pand xmm1,xmm4 ; xmm1=(02 -- 12 -- 22 -- 32 --) >+ pslld xmm5,WORD_BIT ; xmm5=(-- 03 -- 13 -- 23 -- 33) >+ por xmm3,xmm7 ; xmm3=(04 05 14 15 24 25 34 35) >+ por xmm1,xmm5 ; xmm1=(02 03 12 13 22 23 32 33) >+ >+ movdqa xmm2,[rel PB_CENTERJSAMP] ; xmm2=[rel PB_CENTERJSAMP] >+ >+ packsswb xmm6,xmm3 ; xmm6=(00 01 10 11 20 21 30 31 04 05 14 15 24 25 34 35) >+ packsswb xmm1,xmm0 ; xmm1=(02 03 12 13 22 23 32 33 06 07 16 17 26 27 36 37) >+ paddb xmm6,xmm2 >+ paddb xmm1,xmm2 >+ >+ movdqa xmm4,xmm6 ; transpose coefficients(phase 2) >+ punpcklwd xmm6,xmm1 ; xmm6=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33) >+ punpckhwd xmm4,xmm1 ; xmm4=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37) >+ >+ movdqa xmm7,xmm6 ; transpose coefficients(phase 3) >+ punpckldq xmm6,xmm4 ; xmm6=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17) >+ punpckhdq xmm7,xmm4 ; xmm7=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37) >+ >+ pshufd xmm5,xmm6,0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07) >+ pshufd xmm3,xmm7,0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27) >+ >+ mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] >+ mov rbx, JSAMPROW [rdi+2*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6 >+ movq XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE], xmm7 >+ mov rdx, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] >+ mov rbx, JSAMPROW [rdi+3*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm5 >+ movq XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE], xmm3 >+ >+ add rsi, byte 4*SIZEOF_FAST_FLOAT ; wsptr >+ add rdi, byte 4*SIZEOF_JSAMPROW >+ dec rcx ; ctr >+ jnz near .rowloop >+ >+ pop rbx >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jiss2flt.asm b/modules/libjpeg-turbo/simd/jiss2flt.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jiss2flt.asm >@@ -0,0 +1,498 @@ >+; >+; jiss2flt.asm - floating-point IDCT (SSE & SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a floating-point implementation of the inverse DCT >+; (Discrete Cosine Transform). The following code is based directly on >+; the IJG's original jidctflt.c; see the jidctflt.c for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5) >+ shufps %1,%2,0x44 >+%endmacro >+ >+%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7) >+ shufps %1,%2,0xEE >+%endmacro >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_idct_float_sse2) >+ >+EXTN(jconst_idct_float_sse2): >+ >+PD_1_414 times 4 dd 1.414213562373095048801689 >+PD_1_847 times 4 dd 1.847759065022573512256366 >+PD_1_082 times 4 dd 1.082392200292393968799446 >+PD_M2_613 times 4 dd -2.613125929752753055713286 >+PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3) >+PB_CENTERJSAMP times 16 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform dequantization and inverse DCT on one block of coefficients. >+; >+; GLOBAL(void) >+; jsimd_idct_float_sse2 (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; void * dct_table >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+%define workspace wk(0)-DCTSIZE2*SIZEOF_FAST_FLOAT >+ ; FAST_FLOAT workspace[DCTSIZE2] >+ >+ align 16 >+ global EXTN(jsimd_idct_float_sse2) >+ >+EXTN(jsimd_idct_float_sse2): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [workspace] >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input, store into work array. >+ >+; mov eax, [original_ebp] >+ mov edx, POINTER [dct_table(eax)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(eax)] ; inptr >+ lea edi, [workspace] ; FAST_FLOAT * wsptr >+ mov ecx, DCTSIZE/4 ; ctr >+ alignx 16,7 >+.columnloop: >+%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE >+ mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ jnz near .columnDCT >+ >+ movq xmm1, XMM_MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq xmm2, XMM_MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ movq xmm3, XMM_MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ movq xmm4, XMM_MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ movq xmm5, XMM_MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movq xmm6, XMM_MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ movq xmm7, XMM_MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ por xmm1,xmm2 >+ por xmm3,xmm4 >+ por xmm5,xmm6 >+ por xmm1,xmm3 >+ por xmm5,xmm7 >+ por xmm1,xmm5 >+ packsswb xmm1,xmm1 >+ movd eax,xmm1 >+ test eax,eax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movq xmm0, XMM_MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ >+ punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) >+ psrad xmm0,(DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03) >+ cvtdq2ps xmm0,xmm0 ; xmm0=in0=(00 01 02 03) >+ >+ mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movaps xmm1,xmm0 >+ movaps xmm2,xmm0 >+ movaps xmm3,xmm0 >+ >+ shufps xmm0,xmm0,0x00 ; xmm0=(00 00 00 00) >+ shufps xmm1,xmm1,0x55 ; xmm1=(01 01 01 01) >+ shufps xmm2,xmm2,0xAA ; xmm2=(02 02 02 02) >+ shufps xmm3,xmm3,0xFF ; xmm3=(03 03 03 03) >+ >+ movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm2 >+ movaps XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm2 >+ movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm3 >+ movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3 >+ jmp near .nextcolumn >+ alignx 16,7 >+%endif >+.columnDCT: >+ >+ ; -- Even part >+ >+ movq xmm0, XMM_MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movq xmm1, XMM_MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ movq xmm2, XMM_MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ movq xmm3, XMM_MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ >+ punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) >+ punpcklwd xmm1,xmm1 ; xmm1=(20 20 21 21 22 22 23 23) >+ psrad xmm0,(DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03) >+ psrad xmm1,(DWORD_BIT-WORD_BIT) ; xmm1=in2=(20 21 22 23) >+ cvtdq2ps xmm0,xmm0 ; xmm0=in0=(00 01 02 03) >+ cvtdq2ps xmm1,xmm1 ; xmm1=in2=(20 21 22 23) >+ >+ punpcklwd xmm2,xmm2 ; xmm2=(40 40 41 41 42 42 43 43) >+ punpcklwd xmm3,xmm3 ; xmm3=(60 60 61 61 62 62 63 63) >+ psrad xmm2,(DWORD_BIT-WORD_BIT) ; xmm2=in4=(40 41 42 43) >+ psrad xmm3,(DWORD_BIT-WORD_BIT) ; xmm3=in6=(60 61 62 63) >+ cvtdq2ps xmm2,xmm2 ; xmm2=in4=(40 41 42 43) >+ cvtdq2ps xmm3,xmm3 ; xmm3=in6=(60 61 62 63) >+ >+ mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movaps xmm4,xmm0 >+ movaps xmm5,xmm1 >+ subps xmm0,xmm2 ; xmm0=tmp11 >+ subps xmm1,xmm3 >+ addps xmm4,xmm2 ; xmm4=tmp10 >+ addps xmm5,xmm3 ; xmm5=tmp13 >+ >+ mulps xmm1,[GOTOFF(ebx,PD_1_414)] >+ subps xmm1,xmm5 ; xmm1=tmp12 >+ >+ movaps xmm6,xmm4 >+ movaps xmm7,xmm0 >+ subps xmm4,xmm5 ; xmm4=tmp3 >+ subps xmm0,xmm1 ; xmm0=tmp2 >+ addps xmm6,xmm5 ; xmm6=tmp0 >+ addps xmm7,xmm1 ; xmm7=tmp1 >+ >+ movaps XMMWORD [wk(1)], xmm4 ; tmp3 >+ movaps XMMWORD [wk(0)], xmm0 ; tmp2 >+ >+ ; -- Odd part >+ >+ movq xmm2, XMM_MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq xmm3, XMM_MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ movq xmm5, XMM_MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movq xmm1, XMM_MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ >+ punpcklwd xmm2,xmm2 ; xmm2=(10 10 11 11 12 12 13 13) >+ punpcklwd xmm3,xmm3 ; xmm3=(30 30 31 31 32 32 33 33) >+ psrad xmm2,(DWORD_BIT-WORD_BIT) ; xmm2=in1=(10 11 12 13) >+ psrad xmm3,(DWORD_BIT-WORD_BIT) ; xmm3=in3=(30 31 32 33) >+ cvtdq2ps xmm2,xmm2 ; xmm2=in1=(10 11 12 13) >+ cvtdq2ps xmm3,xmm3 ; xmm3=in3=(30 31 32 33) >+ >+ punpcklwd xmm5,xmm5 ; xmm5=(50 50 51 51 52 52 53 53) >+ punpcklwd xmm1,xmm1 ; xmm1=(70 70 71 71 72 72 73 73) >+ psrad xmm5,(DWORD_BIT-WORD_BIT) ; xmm5=in5=(50 51 52 53) >+ psrad xmm1,(DWORD_BIT-WORD_BIT) ; xmm1=in7=(70 71 72 73) >+ cvtdq2ps xmm5,xmm5 ; xmm5=in5=(50 51 52 53) >+ cvtdq2ps xmm1,xmm1 ; xmm1=in7=(70 71 72 73) >+ >+ mulps xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm5, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm1, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movaps xmm4,xmm2 >+ movaps xmm0,xmm5 >+ addps xmm2,xmm1 ; xmm2=z11 >+ addps xmm5,xmm3 ; xmm5=z13 >+ subps xmm4,xmm1 ; xmm4=z12 >+ subps xmm0,xmm3 ; xmm0=z10 >+ >+ movaps xmm1,xmm2 >+ subps xmm2,xmm5 >+ addps xmm1,xmm5 ; xmm1=tmp7 >+ >+ mulps xmm2,[GOTOFF(ebx,PD_1_414)] ; xmm2=tmp11 >+ >+ movaps xmm3,xmm0 >+ addps xmm0,xmm4 >+ mulps xmm0,[GOTOFF(ebx,PD_1_847)] ; xmm0=z5 >+ mulps xmm3,[GOTOFF(ebx,PD_M2_613)] ; xmm3=(z10 * -2.613125930) >+ mulps xmm4,[GOTOFF(ebx,PD_1_082)] ; xmm4=(z12 * 1.082392200) >+ addps xmm3,xmm0 ; xmm3=tmp12 >+ subps xmm4,xmm0 ; xmm4=tmp10 >+ >+ ; -- Final output stage >+ >+ subps xmm3,xmm1 ; xmm3=tmp6 >+ movaps xmm5,xmm6 >+ movaps xmm0,xmm7 >+ addps xmm6,xmm1 ; xmm6=data0=(00 01 02 03) >+ addps xmm7,xmm3 ; xmm7=data1=(10 11 12 13) >+ subps xmm5,xmm1 ; xmm5=data7=(70 71 72 73) >+ subps xmm0,xmm3 ; xmm0=data6=(60 61 62 63) >+ subps xmm2,xmm3 ; xmm2=tmp5 >+ >+ movaps xmm1,xmm6 ; transpose coefficients(phase 1) >+ unpcklps xmm6,xmm7 ; xmm6=(00 10 01 11) >+ unpckhps xmm1,xmm7 ; xmm1=(02 12 03 13) >+ movaps xmm3,xmm0 ; transpose coefficients(phase 1) >+ unpcklps xmm0,xmm5 ; xmm0=(60 70 61 71) >+ unpckhps xmm3,xmm5 ; xmm3=(62 72 63 73) >+ >+ movaps xmm7, XMMWORD [wk(0)] ; xmm7=tmp2 >+ movaps xmm5, XMMWORD [wk(1)] ; xmm5=tmp3 >+ >+ movaps XMMWORD [wk(0)], xmm0 ; wk(0)=(60 70 61 71) >+ movaps XMMWORD [wk(1)], xmm3 ; wk(1)=(62 72 63 73) >+ >+ addps xmm4,xmm2 ; xmm4=tmp4 >+ movaps xmm0,xmm7 >+ movaps xmm3,xmm5 >+ addps xmm7,xmm2 ; xmm7=data2=(20 21 22 23) >+ addps xmm5,xmm4 ; xmm5=data4=(40 41 42 43) >+ subps xmm0,xmm2 ; xmm0=data5=(50 51 52 53) >+ subps xmm3,xmm4 ; xmm3=data3=(30 31 32 33) >+ >+ movaps xmm2,xmm7 ; transpose coefficients(phase 1) >+ unpcklps xmm7,xmm3 ; xmm7=(20 30 21 31) >+ unpckhps xmm2,xmm3 ; xmm2=(22 32 23 33) >+ movaps xmm4,xmm5 ; transpose coefficients(phase 1) >+ unpcklps xmm5,xmm0 ; xmm5=(40 50 41 51) >+ unpckhps xmm4,xmm0 ; xmm4=(42 52 43 53) >+ >+ movaps xmm3,xmm6 ; transpose coefficients(phase 2) >+ unpcklps2 xmm6,xmm7 ; xmm6=(00 10 20 30) >+ unpckhps2 xmm3,xmm7 ; xmm3=(01 11 21 31) >+ movaps xmm0,xmm1 ; transpose coefficients(phase 2) >+ unpcklps2 xmm1,xmm2 ; xmm1=(02 12 22 32) >+ unpckhps2 xmm0,xmm2 ; xmm0=(03 13 23 33) >+ >+ movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71) >+ movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73) >+ >+ movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm6 >+ movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm3 >+ movaps XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm0 >+ >+ movaps xmm6,xmm5 ; transpose coefficients(phase 2) >+ unpcklps2 xmm5,xmm7 ; xmm5=(40 50 60 70) >+ unpckhps2 xmm6,xmm7 ; xmm6=(41 51 61 71) >+ movaps xmm3,xmm4 ; transpose coefficients(phase 2) >+ unpcklps2 xmm4,xmm2 ; xmm4=(42 52 62 72) >+ unpckhps2 xmm3,xmm2 ; xmm3=(43 53 63 73) >+ >+ movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6 >+ movaps XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm4 >+ movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3 >+ >+.nextcolumn: >+ add esi, byte 4*SIZEOF_JCOEF ; coef_block >+ add edx, byte 4*SIZEOF_FLOAT_MULT_TYPE ; quantptr >+ add edi, 4*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr >+ dec ecx ; ctr >+ jnz near .columnloop >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32] >+ prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32] >+ prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32] >+ prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov eax, [original_ebp] >+ lea esi, [workspace] ; FAST_FLOAT * wsptr >+ mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(eax)] >+ mov ecx, DCTSIZE/4 ; ctr >+ alignx 16,7 >+.rowloop: >+ >+ ; -- Even part >+ >+ movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_FAST_FLOAT)] >+ >+ movaps xmm4,xmm0 >+ movaps xmm5,xmm1 >+ subps xmm0,xmm2 ; xmm0=tmp11 >+ subps xmm1,xmm3 >+ addps xmm4,xmm2 ; xmm4=tmp10 >+ addps xmm5,xmm3 ; xmm5=tmp13 >+ >+ mulps xmm1,[GOTOFF(ebx,PD_1_414)] >+ subps xmm1,xmm5 ; xmm1=tmp12 >+ >+ movaps xmm6,xmm4 >+ movaps xmm7,xmm0 >+ subps xmm4,xmm5 ; xmm4=tmp3 >+ subps xmm0,xmm1 ; xmm0=tmp2 >+ addps xmm6,xmm5 ; xmm6=tmp0 >+ addps xmm7,xmm1 ; xmm7=tmp1 >+ >+ movaps XMMWORD [wk(1)], xmm4 ; tmp3 >+ movaps XMMWORD [wk(0)], xmm0 ; tmp2 >+ >+ ; -- Odd part >+ >+ movaps xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm5, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_FAST_FLOAT)] >+ >+ movaps xmm4,xmm2 >+ movaps xmm0,xmm5 >+ addps xmm2,xmm1 ; xmm2=z11 >+ addps xmm5,xmm3 ; xmm5=z13 >+ subps xmm4,xmm1 ; xmm4=z12 >+ subps xmm0,xmm3 ; xmm0=z10 >+ >+ movaps xmm1,xmm2 >+ subps xmm2,xmm5 >+ addps xmm1,xmm5 ; xmm1=tmp7 >+ >+ mulps xmm2,[GOTOFF(ebx,PD_1_414)] ; xmm2=tmp11 >+ >+ movaps xmm3,xmm0 >+ addps xmm0,xmm4 >+ mulps xmm0,[GOTOFF(ebx,PD_1_847)] ; xmm0=z5 >+ mulps xmm3,[GOTOFF(ebx,PD_M2_613)] ; xmm3=(z10 * -2.613125930) >+ mulps xmm4,[GOTOFF(ebx,PD_1_082)] ; xmm4=(z12 * 1.082392200) >+ addps xmm3,xmm0 ; xmm3=tmp12 >+ subps xmm4,xmm0 ; xmm4=tmp10 >+ >+ ; -- Final output stage >+ >+ subps xmm3,xmm1 ; xmm3=tmp6 >+ movaps xmm5,xmm6 >+ movaps xmm0,xmm7 >+ addps xmm6,xmm1 ; xmm6=data0=(00 10 20 30) >+ addps xmm7,xmm3 ; xmm7=data1=(01 11 21 31) >+ subps xmm5,xmm1 ; xmm5=data7=(07 17 27 37) >+ subps xmm0,xmm3 ; xmm0=data6=(06 16 26 36) >+ subps xmm2,xmm3 ; xmm2=tmp5 >+ >+ movaps xmm1,[GOTOFF(ebx,PD_RNDINT_MAGIC)] ; xmm1=[PD_RNDINT_MAGIC] >+ pcmpeqd xmm3,xmm3 >+ psrld xmm3,WORD_BIT ; xmm3={0xFFFF 0x0000 0xFFFF 0x0000 ..} >+ >+ addps xmm6,xmm1 ; xmm6=roundint(data0/8)=(00 ** 10 ** 20 ** 30 **) >+ addps xmm7,xmm1 ; xmm7=roundint(data1/8)=(01 ** 11 ** 21 ** 31 **) >+ addps xmm0,xmm1 ; xmm0=roundint(data6/8)=(06 ** 16 ** 26 ** 36 **) >+ addps xmm5,xmm1 ; xmm5=roundint(data7/8)=(07 ** 17 ** 27 ** 37 **) >+ >+ pand xmm6,xmm3 ; xmm6=(00 -- 10 -- 20 -- 30 --) >+ pslld xmm7,WORD_BIT ; xmm7=(-- 01 -- 11 -- 21 -- 31) >+ pand xmm0,xmm3 ; xmm0=(06 -- 16 -- 26 -- 36 --) >+ pslld xmm5,WORD_BIT ; xmm5=(-- 07 -- 17 -- 27 -- 37) >+ por xmm6,xmm7 ; xmm6=(00 01 10 11 20 21 30 31) >+ por xmm0,xmm5 ; xmm0=(06 07 16 17 26 27 36 37) >+ >+ movaps xmm1, XMMWORD [wk(0)] ; xmm1=tmp2 >+ movaps xmm3, XMMWORD [wk(1)] ; xmm3=tmp3 >+ >+ addps xmm4,xmm2 ; xmm4=tmp4 >+ movaps xmm7,xmm1 >+ movaps xmm5,xmm3 >+ addps xmm1,xmm2 ; xmm1=data2=(02 12 22 32) >+ addps xmm3,xmm4 ; xmm3=data4=(04 14 24 34) >+ subps xmm7,xmm2 ; xmm7=data5=(05 15 25 35) >+ subps xmm5,xmm4 ; xmm5=data3=(03 13 23 33) >+ >+ movaps xmm2,[GOTOFF(ebx,PD_RNDINT_MAGIC)] ; xmm2=[PD_RNDINT_MAGIC] >+ pcmpeqd xmm4,xmm4 >+ psrld xmm4,WORD_BIT ; xmm4={0xFFFF 0x0000 0xFFFF 0x0000 ..} >+ >+ addps xmm3,xmm2 ; xmm3=roundint(data4/8)=(04 ** 14 ** 24 ** 34 **) >+ addps xmm7,xmm2 ; xmm7=roundint(data5/8)=(05 ** 15 ** 25 ** 35 **) >+ addps xmm1,xmm2 ; xmm1=roundint(data2/8)=(02 ** 12 ** 22 ** 32 **) >+ addps xmm5,xmm2 ; xmm5=roundint(data3/8)=(03 ** 13 ** 23 ** 33 **) >+ >+ pand xmm3,xmm4 ; xmm3=(04 -- 14 -- 24 -- 34 --) >+ pslld xmm7,WORD_BIT ; xmm7=(-- 05 -- 15 -- 25 -- 35) >+ pand xmm1,xmm4 ; xmm1=(02 -- 12 -- 22 -- 32 --) >+ pslld xmm5,WORD_BIT ; xmm5=(-- 03 -- 13 -- 23 -- 33) >+ por xmm3,xmm7 ; xmm3=(04 05 14 15 24 25 34 35) >+ por xmm1,xmm5 ; xmm1=(02 03 12 13 22 23 32 33) >+ >+ movdqa xmm2,[GOTOFF(ebx,PB_CENTERJSAMP)] ; xmm2=[PB_CENTERJSAMP] >+ >+ packsswb xmm6,xmm3 ; xmm6=(00 01 10 11 20 21 30 31 04 05 14 15 24 25 34 35) >+ packsswb xmm1,xmm0 ; xmm1=(02 03 12 13 22 23 32 33 06 07 16 17 26 27 36 37) >+ paddb xmm6,xmm2 >+ paddb xmm1,xmm2 >+ >+ movdqa xmm4,xmm6 ; transpose coefficients(phase 2) >+ punpcklwd xmm6,xmm1 ; xmm6=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33) >+ punpckhwd xmm4,xmm1 ; xmm4=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37) >+ >+ movdqa xmm7,xmm6 ; transpose coefficients(phase 3) >+ punpckldq xmm6,xmm4 ; xmm6=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17) >+ punpckhdq xmm7,xmm4 ; xmm7=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37) >+ >+ pshufd xmm5,xmm6,0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07) >+ pshufd xmm3,xmm7,0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27) >+ >+ pushpic ebx ; save GOT address >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov ebx, JSAMPROW [edi+2*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm6 >+ movq XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE], xmm7 >+ mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm5 >+ movq XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE], xmm3 >+ >+ poppic ebx ; restore GOT address >+ >+ add esi, byte 4*SIZEOF_FAST_FLOAT ; wsptr >+ add edi, byte 4*SIZEOF_JSAMPROW >+ dec ecx ; ctr >+ jnz near .rowloop >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jiss2fst-64.asm b/modules/libjpeg-turbo/simd/jiss2fst-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jiss2fst-64.asm >@@ -0,0 +1,492 @@ >+; >+; jiss2fst-64.asm - fast integer IDCT (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/projecpt/showfiles.php?group_id=6208 >+; >+; This file contains a fast, not so accurate integer implementation of >+; the inverse DCT (Discrete Cosine Transform). The following code is >+; based directly on the IJG's original jidctfst.c; see the jidctfst.c >+; for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 8 ; 14 is also OK. >+%define PASS1_BITS 2 >+ >+%if IFAST_SCALE_BITS != PASS1_BITS >+%error "'IFAST_SCALE_BITS' must be equal to 'PASS1_BITS'." >+%endif >+ >+%if CONST_BITS == 8 >+F_1_082 equ 277 ; FIX(1.082392200) >+F_1_414 equ 362 ; FIX(1.414213562) >+F_1_847 equ 473 ; FIX(1.847759065) >+F_2_613 equ 669 ; FIX(2.613125930) >+F_1_613 equ (F_2_613 - 256) ; FIX(2.613125930) - FIX(1) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_1_082 equ DESCALE(1162209775,30-CONST_BITS) ; FIX(1.082392200) >+F_1_414 equ DESCALE(1518500249,30-CONST_BITS) ; FIX(1.414213562) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_2_613 equ DESCALE(2805822602,30-CONST_BITS) ; FIX(2.613125930) >+F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow) >+; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw) >+ >+%define PRE_MULTIPLY_SCALE_BITS 2 >+%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS) >+ >+ alignz 16 >+ global EXTN(jconst_idct_ifast_sse2) >+ >+EXTN(jconst_idct_ifast_sse2): >+ >+PW_F1414 times 8 dw F_1_414 << CONST_SHIFT >+PW_F1847 times 8 dw F_1_847 << CONST_SHIFT >+PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT >+PW_F1082 times 8 dw F_1_082 << CONST_SHIFT >+PB_CENTERJSAMP times 16 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Perform dequantization and inverse DCT on one block of coefficients. >+; >+; GLOBAL(void) >+; jsimd_idct_ifast_sse2 (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+; r10 = jpeg_component_info * compptr >+; r11 = JCOEFPTR coef_block >+; r12 = JSAMPARRAY output_buf >+; r13 = JDIMENSION output_col >+ >+%define original_rbp rbp+0 >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_idct_ifast_sse2) >+ >+EXTN(jsimd_idct_ifast_sse2): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [wk(0)] >+ collect_args >+ >+ ; ---- Pass 1: process columns from input. >+ >+ mov rdx, r10 ; quantptr >+ mov rsi, r11 ; inptr >+ >+%ifndef NO_ZERO_COLUMN_TEST_IFAST_SSE2 >+ mov eax, DWORD [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ jnz near .columnDCT >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] >+ por xmm1,xmm0 >+ packsswb xmm1,xmm1 >+ packsswb xmm1,xmm1 >+ movd eax,xmm1 >+ test rax,rax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ movdqa xmm7,xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07) >+ punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) >+ punpckhwd xmm7,xmm7 ; xmm7=(04 04 05 05 06 06 07 07) >+ >+ pshufd xmm6,xmm0,0x00 ; xmm6=col0=(00 00 00 00 00 00 00 00) >+ pshufd xmm2,xmm0,0x55 ; xmm2=col1=(01 01 01 01 01 01 01 01) >+ pshufd xmm5,xmm0,0xAA ; xmm5=col2=(02 02 02 02 02 02 02 02) >+ pshufd xmm0,xmm0,0xFF ; xmm0=col3=(03 03 03 03 03 03 03 03) >+ pshufd xmm1,xmm7,0x00 ; xmm1=col4=(04 04 04 04 04 04 04 04) >+ pshufd xmm4,xmm7,0x55 ; xmm4=col5=(05 05 05 05 05 05 05 05) >+ pshufd xmm3,xmm7,0xAA ; xmm3=col6=(06 06 06 06 06 06 06 06) >+ pshufd xmm7,xmm7,0xFF ; xmm7=col7=(07 07 07 07 07 07 07 07) >+ >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=col1 >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=col3 >+ jmp near .column_end >+%endif >+.columnDCT: >+ >+ ; -- Even part >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_IFAST_MULT_TYPE)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_IFAST_MULT_TYPE)] >+ >+ movdqa xmm4,xmm0 >+ movdqa xmm5,xmm1 >+ psubw xmm0,xmm2 ; xmm0=tmp11 >+ psubw xmm1,xmm3 >+ paddw xmm4,xmm2 ; xmm4=tmp10 >+ paddw xmm5,xmm3 ; xmm5=tmp13 >+ >+ psllw xmm1,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm1,[rel PW_F1414] >+ psubw xmm1,xmm5 ; xmm1=tmp12 >+ >+ movdqa xmm6,xmm4 >+ movdqa xmm7,xmm0 >+ psubw xmm4,xmm5 ; xmm4=tmp3 >+ psubw xmm0,xmm1 ; xmm0=tmp2 >+ paddw xmm6,xmm5 ; xmm6=tmp0 >+ paddw xmm7,xmm1 ; xmm7=tmp1 >+ >+ movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=tmp3 >+ movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=tmp2 >+ >+ ; -- Odd part >+ >+ movdqa xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_IFAST_MULT_TYPE)] >+ movdqa xmm5, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm5, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_IFAST_MULT_TYPE)] >+ >+ movdqa xmm4,xmm2 >+ movdqa xmm0,xmm5 >+ psubw xmm2,xmm1 ; xmm2=z12 >+ psubw xmm5,xmm3 ; xmm5=z10 >+ paddw xmm4,xmm1 ; xmm4=z11 >+ paddw xmm0,xmm3 ; xmm0=z13 >+ >+ movdqa xmm1,xmm5 ; xmm1=z10(unscaled) >+ psllw xmm2,PRE_MULTIPLY_SCALE_BITS >+ psllw xmm5,PRE_MULTIPLY_SCALE_BITS >+ >+ movdqa xmm3,xmm4 >+ psubw xmm4,xmm0 >+ paddw xmm3,xmm0 ; xmm3=tmp7 >+ >+ psllw xmm4,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm4,[rel PW_F1414] ; xmm4=tmp11 >+ >+ ; To avoid overflow... >+ ; >+ ; (Original) >+ ; tmp12 = -2.613125930 * z10 + z5; >+ ; >+ ; (This implementation) >+ ; tmp12 = (-1.613125930 - 1) * z10 + z5; >+ ; = -1.613125930 * z10 - z10 + z5; >+ >+ movdqa xmm0,xmm5 >+ paddw xmm5,xmm2 >+ pmulhw xmm5,[rel PW_F1847] ; xmm5=z5 >+ pmulhw xmm0,[rel PW_MF1613] >+ pmulhw xmm2,[rel PW_F1082] >+ psubw xmm0,xmm1 >+ psubw xmm2,xmm5 ; xmm2=tmp10 >+ paddw xmm0,xmm5 ; xmm0=tmp12 >+ >+ ; -- Final output stage >+ >+ psubw xmm0,xmm3 ; xmm0=tmp6 >+ movdqa xmm1,xmm6 >+ movdqa xmm5,xmm7 >+ paddw xmm6,xmm3 ; xmm6=data0=(00 01 02 03 04 05 06 07) >+ paddw xmm7,xmm0 ; xmm7=data1=(10 11 12 13 14 15 16 17) >+ psubw xmm1,xmm3 ; xmm1=data7=(70 71 72 73 74 75 76 77) >+ psubw xmm5,xmm0 ; xmm5=data6=(60 61 62 63 64 65 66 67) >+ psubw xmm4,xmm0 ; xmm4=tmp5 >+ >+ movdqa xmm3,xmm6 ; transpose coefficients(phase 1) >+ punpcklwd xmm6,xmm7 ; xmm6=(00 10 01 11 02 12 03 13) >+ punpckhwd xmm3,xmm7 ; xmm3=(04 14 05 15 06 16 07 17) >+ movdqa xmm0,xmm5 ; transpose coefficients(phase 1) >+ punpcklwd xmm5,xmm1 ; xmm5=(60 70 61 71 62 72 63 73) >+ punpckhwd xmm0,xmm1 ; xmm0=(64 74 65 75 66 76 67 77) >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp2 >+ movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp3 >+ >+ movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(60 70 61 71 62 72 63 73) >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(64 74 65 75 66 76 67 77) >+ >+ paddw xmm2,xmm4 ; xmm2=tmp4 >+ movdqa xmm5,xmm7 >+ movdqa xmm0,xmm1 >+ paddw xmm7,xmm4 ; xmm7=data2=(20 21 22 23 24 25 26 27) >+ paddw xmm1,xmm2 ; xmm1=data4=(40 41 42 43 44 45 46 47) >+ psubw xmm5,xmm4 ; xmm5=data5=(50 51 52 53 54 55 56 57) >+ psubw xmm0,xmm2 ; xmm0=data3=(30 31 32 33 34 35 36 37) >+ >+ movdqa xmm4,xmm7 ; transpose coefficients(phase 1) >+ punpcklwd xmm7,xmm0 ; xmm7=(20 30 21 31 22 32 23 33) >+ punpckhwd xmm4,xmm0 ; xmm4=(24 34 25 35 26 36 27 37) >+ movdqa xmm2,xmm1 ; transpose coefficients(phase 1) >+ punpcklwd xmm1,xmm5 ; xmm1=(40 50 41 51 42 52 43 53) >+ punpckhwd xmm2,xmm5 ; xmm2=(44 54 45 55 46 56 47 57) >+ >+ movdqa xmm0,xmm3 ; transpose coefficients(phase 2) >+ punpckldq xmm3,xmm4 ; xmm3=(04 14 24 34 05 15 25 35) >+ punpckhdq xmm0,xmm4 ; xmm0=(06 16 26 36 07 17 27 37) >+ movdqa xmm5,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm7 ; xmm6=(00 10 20 30 01 11 21 31) >+ punpckhdq xmm5,xmm7 ; xmm5=(02 12 22 32 03 13 23 33) >+ >+ movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(60 70 61 71 62 72 63 73) >+ movdqa xmm7, XMMWORD [wk(1)] ; xmm7=(64 74 65 75 66 76 67 77) >+ >+ movdqa XMMWORD [wk(0)], xmm3 ; wk(0)=(04 14 24 34 05 15 25 35) >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(06 16 26 36 07 17 27 37) >+ >+ movdqa xmm3,xmm1 ; transpose coefficients(phase 2) >+ punpckldq xmm1,xmm4 ; xmm1=(40 50 60 70 41 51 61 71) >+ punpckhdq xmm3,xmm4 ; xmm3=(42 52 62 72 43 53 63 73) >+ movdqa xmm0,xmm2 ; transpose coefficients(phase 2) >+ punpckldq xmm2,xmm7 ; xmm2=(44 54 64 74 45 55 65 75) >+ punpckhdq xmm0,xmm7 ; xmm0=(46 56 66 76 47 57 67 77) >+ >+ movdqa xmm4,xmm6 ; transpose coefficients(phase 3) >+ punpcklqdq xmm6,xmm1 ; xmm6=col0=(00 10 20 30 40 50 60 70) >+ punpckhqdq xmm4,xmm1 ; xmm4=col1=(01 11 21 31 41 51 61 71) >+ movdqa xmm7,xmm5 ; transpose coefficients(phase 3) >+ punpcklqdq xmm5,xmm3 ; xmm5=col2=(02 12 22 32 42 52 62 72) >+ punpckhqdq xmm7,xmm3 ; xmm7=col3=(03 13 23 33 43 53 63 73) >+ >+ movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(04 14 24 34 05 15 25 35) >+ movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(06 16 26 36 07 17 27 37) >+ >+ movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=col1 >+ movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=col3 >+ >+ movdqa xmm4,xmm1 ; transpose coefficients(phase 3) >+ punpcklqdq xmm1,xmm2 ; xmm1=col4=(04 14 24 34 44 54 64 74) >+ punpckhqdq xmm4,xmm2 ; xmm4=col5=(05 15 25 35 45 55 65 75) >+ movdqa xmm7,xmm3 ; transpose coefficients(phase 3) >+ punpcklqdq xmm3,xmm0 ; xmm3=col6=(06 16 26 36 46 56 66 76) >+ punpckhqdq xmm7,xmm0 ; xmm7=col7=(07 17 27 37 47 57 67 77) >+.column_end: >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov rax, [original_rbp] >+ mov rdi, r12 ; (JSAMPROW *) >+ mov rax, r13 >+ >+ ; -- Even part >+ >+ ; xmm6=col0, xmm5=col2, xmm1=col4, xmm3=col6 >+ >+ movdqa xmm2,xmm6 >+ movdqa xmm0,xmm5 >+ psubw xmm6,xmm1 ; xmm6=tmp11 >+ psubw xmm5,xmm3 >+ paddw xmm2,xmm1 ; xmm2=tmp10 >+ paddw xmm0,xmm3 ; xmm0=tmp13 >+ >+ psllw xmm5,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm5,[rel PW_F1414] >+ psubw xmm5,xmm0 ; xmm5=tmp12 >+ >+ movdqa xmm1,xmm2 >+ movdqa xmm3,xmm6 >+ psubw xmm2,xmm0 ; xmm2=tmp3 >+ psubw xmm6,xmm5 ; xmm6=tmp2 >+ paddw xmm1,xmm0 ; xmm1=tmp0 >+ paddw xmm3,xmm5 ; xmm3=tmp1 >+ >+ movdqa xmm0, XMMWORD [wk(0)] ; xmm0=col1 >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=col3 >+ >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp3 >+ movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp2 >+ >+ ; -- Odd part >+ >+ ; xmm0=col1, xmm5=col3, xmm4=col5, xmm7=col7 >+ >+ movdqa xmm2,xmm0 >+ movdqa xmm6,xmm4 >+ psubw xmm0,xmm7 ; xmm0=z12 >+ psubw xmm4,xmm5 ; xmm4=z10 >+ paddw xmm2,xmm7 ; xmm2=z11 >+ paddw xmm6,xmm5 ; xmm6=z13 >+ >+ movdqa xmm7,xmm4 ; xmm7=z10(unscaled) >+ psllw xmm0,PRE_MULTIPLY_SCALE_BITS >+ psllw xmm4,PRE_MULTIPLY_SCALE_BITS >+ >+ movdqa xmm5,xmm2 >+ psubw xmm2,xmm6 >+ paddw xmm5,xmm6 ; xmm5=tmp7 >+ >+ psllw xmm2,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm2,[rel PW_F1414] ; xmm2=tmp11 >+ >+ ; To avoid overflow... >+ ; >+ ; (Original) >+ ; tmp12 = -2.613125930 * z10 + z5; >+ ; >+ ; (This implementation) >+ ; tmp12 = (-1.613125930 - 1) * z10 + z5; >+ ; = -1.613125930 * z10 - z10 + z5; >+ >+ movdqa xmm6,xmm4 >+ paddw xmm4,xmm0 >+ pmulhw xmm4,[rel PW_F1847] ; xmm4=z5 >+ pmulhw xmm6,[rel PW_MF1613] >+ pmulhw xmm0,[rel PW_F1082] >+ psubw xmm6,xmm7 >+ psubw xmm0,xmm4 ; xmm0=tmp10 >+ paddw xmm6,xmm4 ; xmm6=tmp12 >+ >+ ; -- Final output stage >+ >+ psubw xmm6,xmm5 ; xmm6=tmp6 >+ movdqa xmm7,xmm1 >+ movdqa xmm4,xmm3 >+ paddw xmm1,xmm5 ; xmm1=data0=(00 10 20 30 40 50 60 70) >+ paddw xmm3,xmm6 ; xmm3=data1=(01 11 21 31 41 51 61 71) >+ psraw xmm1,(PASS1_BITS+3) ; descale >+ psraw xmm3,(PASS1_BITS+3) ; descale >+ psubw xmm7,xmm5 ; xmm7=data7=(07 17 27 37 47 57 67 77) >+ psubw xmm4,xmm6 ; xmm4=data6=(06 16 26 36 46 56 66 76) >+ psraw xmm7,(PASS1_BITS+3) ; descale >+ psraw xmm4,(PASS1_BITS+3) ; descale >+ psubw xmm2,xmm6 ; xmm2=tmp5 >+ >+ packsswb xmm1,xmm4 ; xmm1=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) >+ packsswb xmm3,xmm7 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) >+ >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp2 >+ movdqa xmm6, XMMWORD [wk(0)] ; xmm6=tmp3 >+ >+ paddw xmm0,xmm2 ; xmm0=tmp4 >+ movdqa xmm4,xmm5 >+ movdqa xmm7,xmm6 >+ paddw xmm5,xmm2 ; xmm5=data2=(02 12 22 32 42 52 62 72) >+ paddw xmm6,xmm0 ; xmm6=data4=(04 14 24 34 44 54 64 74) >+ psraw xmm5,(PASS1_BITS+3) ; descale >+ psraw xmm6,(PASS1_BITS+3) ; descale >+ psubw xmm4,xmm2 ; xmm4=data5=(05 15 25 35 45 55 65 75) >+ psubw xmm7,xmm0 ; xmm7=data3=(03 13 23 33 43 53 63 73) >+ psraw xmm4,(PASS1_BITS+3) ; descale >+ psraw xmm7,(PASS1_BITS+3) ; descale >+ >+ movdqa xmm2,[rel PB_CENTERJSAMP] ; xmm2=[rel PB_CENTERJSAMP] >+ >+ packsswb xmm5,xmm6 ; xmm5=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74) >+ packsswb xmm7,xmm4 ; xmm7=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75) >+ >+ paddb xmm1,xmm2 >+ paddb xmm3,xmm2 >+ paddb xmm5,xmm2 >+ paddb xmm7,xmm2 >+ >+ movdqa xmm0,xmm1 ; transpose coefficients(phase 1) >+ punpcklbw xmm1,xmm3 ; xmm1=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71) >+ punpckhbw xmm0,xmm3 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77) >+ movdqa xmm6,xmm5 ; transpose coefficients(phase 1) >+ punpcklbw xmm5,xmm7 ; xmm5=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73) >+ punpckhbw xmm6,xmm7 ; xmm6=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75) >+ >+ movdqa xmm4,xmm1 ; transpose coefficients(phase 2) >+ punpcklwd xmm1,xmm5 ; xmm1=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33) >+ punpckhwd xmm4,xmm5 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73) >+ movdqa xmm2,xmm6 ; transpose coefficients(phase 2) >+ punpcklwd xmm6,xmm0 ; xmm6=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37) >+ punpckhwd xmm2,xmm0 ; xmm2=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77) >+ >+ movdqa xmm3,xmm1 ; transpose coefficients(phase 3) >+ punpckldq xmm1,xmm6 ; xmm1=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17) >+ punpckhdq xmm3,xmm6 ; xmm3=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37) >+ movdqa xmm7,xmm4 ; transpose coefficients(phase 3) >+ punpckldq xmm4,xmm2 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57) >+ punpckhdq xmm7,xmm2 ; xmm7=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77) >+ >+ pshufd xmm5,xmm1,0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07) >+ pshufd xmm0,xmm3,0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27) >+ pshufd xmm6,xmm4,0x4E ; xmm6=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47) >+ pshufd xmm2,xmm7,0x4E ; xmm2=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67) >+ >+ mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+2*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm1 >+ movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3 >+ mov rdx, JSAMPROW [rdi+4*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+6*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm4 >+ movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm7 >+ >+ mov rdx, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+3*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm5 >+ movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm0 >+ mov rdx, JSAMPROW [rdi+5*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+7*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6 >+ movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm2 >+ >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jiss2fst.asm b/modules/libjpeg-turbo/simd/jiss2fst.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jiss2fst.asm >@@ -0,0 +1,502 @@ >+; >+; jiss2fst.asm - fast integer IDCT (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a fast, not so accurate integer implementation of >+; the inverse DCT (Discrete Cosine Transform). The following code is >+; based directly on the IJG's original jidctfst.c; see the jidctfst.c >+; for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 8 ; 14 is also OK. >+%define PASS1_BITS 2 >+ >+%if IFAST_SCALE_BITS != PASS1_BITS >+%error "'IFAST_SCALE_BITS' must be equal to 'PASS1_BITS'." >+%endif >+ >+%if CONST_BITS == 8 >+F_1_082 equ 277 ; FIX(1.082392200) >+F_1_414 equ 362 ; FIX(1.414213562) >+F_1_847 equ 473 ; FIX(1.847759065) >+F_2_613 equ 669 ; FIX(2.613125930) >+F_1_613 equ (F_2_613 - 256) ; FIX(2.613125930) - FIX(1) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_1_082 equ DESCALE(1162209775,30-CONST_BITS) ; FIX(1.082392200) >+F_1_414 equ DESCALE(1518500249,30-CONST_BITS) ; FIX(1.414213562) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_2_613 equ DESCALE(2805822602,30-CONST_BITS) ; FIX(2.613125930) >+F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow) >+; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw) >+ >+%define PRE_MULTIPLY_SCALE_BITS 2 >+%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS) >+ >+ alignz 16 >+ global EXTN(jconst_idct_ifast_sse2) >+ >+EXTN(jconst_idct_ifast_sse2): >+ >+PW_F1414 times 8 dw F_1_414 << CONST_SHIFT >+PW_F1847 times 8 dw F_1_847 << CONST_SHIFT >+PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT >+PW_F1082 times 8 dw F_1_082 << CONST_SHIFT >+PB_CENTERJSAMP times 16 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform dequantization and inverse DCT on one block of coefficients. >+; >+; GLOBAL(void) >+; jsimd_idct_ifast_sse2 (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; jpeg_component_info * compptr >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_idct_ifast_sse2) >+ >+EXTN(jsimd_idct_ifast_sse2): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic ebx >+; push ecx ; unused >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input. >+ >+; mov eax, [original_ebp] >+ mov edx, POINTER [dct_table(eax)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(eax)] ; inptr >+ >+%ifndef NO_ZERO_COLUMN_TEST_IFAST_SSE2 >+ mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ jnz near .columnDCT >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ por xmm1,xmm0 >+ packsswb xmm1,xmm1 >+ packsswb xmm1,xmm1 >+ movd eax,xmm1 >+ test eax,eax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ movdqa xmm7,xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07) >+ punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) >+ punpckhwd xmm7,xmm7 ; xmm7=(04 04 05 05 06 06 07 07) >+ >+ pshufd xmm6,xmm0,0x00 ; xmm6=col0=(00 00 00 00 00 00 00 00) >+ pshufd xmm2,xmm0,0x55 ; xmm2=col1=(01 01 01 01 01 01 01 01) >+ pshufd xmm5,xmm0,0xAA ; xmm5=col2=(02 02 02 02 02 02 02 02) >+ pshufd xmm0,xmm0,0xFF ; xmm0=col3=(03 03 03 03 03 03 03 03) >+ pshufd xmm1,xmm7,0x00 ; xmm1=col4=(04 04 04 04 04 04 04 04) >+ pshufd xmm4,xmm7,0x55 ; xmm4=col5=(05 05 05 05 05 05 05 05) >+ pshufd xmm3,xmm7,0xAA ; xmm3=col6=(06 06 06 06 06 06 06 06) >+ pshufd xmm7,xmm7,0xFF ; xmm7=col7=(07 07 07 07 07 07 07 07) >+ >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=col1 >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=col3 >+ jmp near .column_end >+ alignx 16,7 >+%endif >+.columnDCT: >+ >+ ; -- Even part >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ >+ movdqa xmm4,xmm0 >+ movdqa xmm5,xmm1 >+ psubw xmm0,xmm2 ; xmm0=tmp11 >+ psubw xmm1,xmm3 >+ paddw xmm4,xmm2 ; xmm4=tmp10 >+ paddw xmm5,xmm3 ; xmm5=tmp13 >+ >+ psllw xmm1,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm1,[GOTOFF(ebx,PW_F1414)] >+ psubw xmm1,xmm5 ; xmm1=tmp12 >+ >+ movdqa xmm6,xmm4 >+ movdqa xmm7,xmm0 >+ psubw xmm4,xmm5 ; xmm4=tmp3 >+ psubw xmm0,xmm1 ; xmm0=tmp2 >+ paddw xmm6,xmm5 ; xmm6=tmp0 >+ paddw xmm7,xmm1 ; xmm7=tmp1 >+ >+ movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=tmp3 >+ movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=tmp2 >+ >+ ; -- Odd part >+ >+ movdqa xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ movdqa xmm5, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm5, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_IFAST_MULT_TYPE)] >+ >+ movdqa xmm4,xmm2 >+ movdqa xmm0,xmm5 >+ psubw xmm2,xmm1 ; xmm2=z12 >+ psubw xmm5,xmm3 ; xmm5=z10 >+ paddw xmm4,xmm1 ; xmm4=z11 >+ paddw xmm0,xmm3 ; xmm0=z13 >+ >+ movdqa xmm1,xmm5 ; xmm1=z10(unscaled) >+ psllw xmm2,PRE_MULTIPLY_SCALE_BITS >+ psllw xmm5,PRE_MULTIPLY_SCALE_BITS >+ >+ movdqa xmm3,xmm4 >+ psubw xmm4,xmm0 >+ paddw xmm3,xmm0 ; xmm3=tmp7 >+ >+ psllw xmm4,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm4,[GOTOFF(ebx,PW_F1414)] ; xmm4=tmp11 >+ >+ ; To avoid overflow... >+ ; >+ ; (Original) >+ ; tmp12 = -2.613125930 * z10 + z5; >+ ; >+ ; (This implementation) >+ ; tmp12 = (-1.613125930 - 1) * z10 + z5; >+ ; = -1.613125930 * z10 - z10 + z5; >+ >+ movdqa xmm0,xmm5 >+ paddw xmm5,xmm2 >+ pmulhw xmm5,[GOTOFF(ebx,PW_F1847)] ; xmm5=z5 >+ pmulhw xmm0,[GOTOFF(ebx,PW_MF1613)] >+ pmulhw xmm2,[GOTOFF(ebx,PW_F1082)] >+ psubw xmm0,xmm1 >+ psubw xmm2,xmm5 ; xmm2=tmp10 >+ paddw xmm0,xmm5 ; xmm0=tmp12 >+ >+ ; -- Final output stage >+ >+ psubw xmm0,xmm3 ; xmm0=tmp6 >+ movdqa xmm1,xmm6 >+ movdqa xmm5,xmm7 >+ paddw xmm6,xmm3 ; xmm6=data0=(00 01 02 03 04 05 06 07) >+ paddw xmm7,xmm0 ; xmm7=data1=(10 11 12 13 14 15 16 17) >+ psubw xmm1,xmm3 ; xmm1=data7=(70 71 72 73 74 75 76 77) >+ psubw xmm5,xmm0 ; xmm5=data6=(60 61 62 63 64 65 66 67) >+ psubw xmm4,xmm0 ; xmm4=tmp5 >+ >+ movdqa xmm3,xmm6 ; transpose coefficients(phase 1) >+ punpcklwd xmm6,xmm7 ; xmm6=(00 10 01 11 02 12 03 13) >+ punpckhwd xmm3,xmm7 ; xmm3=(04 14 05 15 06 16 07 17) >+ movdqa xmm0,xmm5 ; transpose coefficients(phase 1) >+ punpcklwd xmm5,xmm1 ; xmm5=(60 70 61 71 62 72 63 73) >+ punpckhwd xmm0,xmm1 ; xmm0=(64 74 65 75 66 76 67 77) >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp2 >+ movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp3 >+ >+ movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(60 70 61 71 62 72 63 73) >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(64 74 65 75 66 76 67 77) >+ >+ paddw xmm2,xmm4 ; xmm2=tmp4 >+ movdqa xmm5,xmm7 >+ movdqa xmm0,xmm1 >+ paddw xmm7,xmm4 ; xmm7=data2=(20 21 22 23 24 25 26 27) >+ paddw xmm1,xmm2 ; xmm1=data4=(40 41 42 43 44 45 46 47) >+ psubw xmm5,xmm4 ; xmm5=data5=(50 51 52 53 54 55 56 57) >+ psubw xmm0,xmm2 ; xmm0=data3=(30 31 32 33 34 35 36 37) >+ >+ movdqa xmm4,xmm7 ; transpose coefficients(phase 1) >+ punpcklwd xmm7,xmm0 ; xmm7=(20 30 21 31 22 32 23 33) >+ punpckhwd xmm4,xmm0 ; xmm4=(24 34 25 35 26 36 27 37) >+ movdqa xmm2,xmm1 ; transpose coefficients(phase 1) >+ punpcklwd xmm1,xmm5 ; xmm1=(40 50 41 51 42 52 43 53) >+ punpckhwd xmm2,xmm5 ; xmm2=(44 54 45 55 46 56 47 57) >+ >+ movdqa xmm0,xmm3 ; transpose coefficients(phase 2) >+ punpckldq xmm3,xmm4 ; xmm3=(04 14 24 34 05 15 25 35) >+ punpckhdq xmm0,xmm4 ; xmm0=(06 16 26 36 07 17 27 37) >+ movdqa xmm5,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm7 ; xmm6=(00 10 20 30 01 11 21 31) >+ punpckhdq xmm5,xmm7 ; xmm5=(02 12 22 32 03 13 23 33) >+ >+ movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(60 70 61 71 62 72 63 73) >+ movdqa xmm7, XMMWORD [wk(1)] ; xmm7=(64 74 65 75 66 76 67 77) >+ >+ movdqa XMMWORD [wk(0)], xmm3 ; wk(0)=(04 14 24 34 05 15 25 35) >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(06 16 26 36 07 17 27 37) >+ >+ movdqa xmm3,xmm1 ; transpose coefficients(phase 2) >+ punpckldq xmm1,xmm4 ; xmm1=(40 50 60 70 41 51 61 71) >+ punpckhdq xmm3,xmm4 ; xmm3=(42 52 62 72 43 53 63 73) >+ movdqa xmm0,xmm2 ; transpose coefficients(phase 2) >+ punpckldq xmm2,xmm7 ; xmm2=(44 54 64 74 45 55 65 75) >+ punpckhdq xmm0,xmm7 ; xmm0=(46 56 66 76 47 57 67 77) >+ >+ movdqa xmm4,xmm6 ; transpose coefficients(phase 3) >+ punpcklqdq xmm6,xmm1 ; xmm6=col0=(00 10 20 30 40 50 60 70) >+ punpckhqdq xmm4,xmm1 ; xmm4=col1=(01 11 21 31 41 51 61 71) >+ movdqa xmm7,xmm5 ; transpose coefficients(phase 3) >+ punpcklqdq xmm5,xmm3 ; xmm5=col2=(02 12 22 32 42 52 62 72) >+ punpckhqdq xmm7,xmm3 ; xmm7=col3=(03 13 23 33 43 53 63 73) >+ >+ movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(04 14 24 34 05 15 25 35) >+ movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(06 16 26 36 07 17 27 37) >+ >+ movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=col1 >+ movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=col3 >+ >+ movdqa xmm4,xmm1 ; transpose coefficients(phase 3) >+ punpcklqdq xmm1,xmm2 ; xmm1=col4=(04 14 24 34 44 54 64 74) >+ punpckhqdq xmm4,xmm2 ; xmm4=col5=(05 15 25 35 45 55 65 75) >+ movdqa xmm7,xmm3 ; transpose coefficients(phase 3) >+ punpcklqdq xmm3,xmm0 ; xmm3=col6=(06 16 26 36 46 56 66 76) >+ punpckhqdq xmm7,xmm0 ; xmm7=col7=(07 17 27 37 47 57 67 77) >+.column_end: >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov eax, [original_ebp] >+ mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(eax)] >+ >+ ; -- Even part >+ >+ ; xmm6=col0, xmm5=col2, xmm1=col4, xmm3=col6 >+ >+ movdqa xmm2,xmm6 >+ movdqa xmm0,xmm5 >+ psubw xmm6,xmm1 ; xmm6=tmp11 >+ psubw xmm5,xmm3 >+ paddw xmm2,xmm1 ; xmm2=tmp10 >+ paddw xmm0,xmm3 ; xmm0=tmp13 >+ >+ psllw xmm5,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm5,[GOTOFF(ebx,PW_F1414)] >+ psubw xmm5,xmm0 ; xmm5=tmp12 >+ >+ movdqa xmm1,xmm2 >+ movdqa xmm3,xmm6 >+ psubw xmm2,xmm0 ; xmm2=tmp3 >+ psubw xmm6,xmm5 ; xmm6=tmp2 >+ paddw xmm1,xmm0 ; xmm1=tmp0 >+ paddw xmm3,xmm5 ; xmm3=tmp1 >+ >+ movdqa xmm0, XMMWORD [wk(0)] ; xmm0=col1 >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=col3 >+ >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp3 >+ movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp2 >+ >+ ; -- Odd part >+ >+ ; xmm0=col1, xmm5=col3, xmm4=col5, xmm7=col7 >+ >+ movdqa xmm2,xmm0 >+ movdqa xmm6,xmm4 >+ psubw xmm0,xmm7 ; xmm0=z12 >+ psubw xmm4,xmm5 ; xmm4=z10 >+ paddw xmm2,xmm7 ; xmm2=z11 >+ paddw xmm6,xmm5 ; xmm6=z13 >+ >+ movdqa xmm7,xmm4 ; xmm7=z10(unscaled) >+ psllw xmm0,PRE_MULTIPLY_SCALE_BITS >+ psllw xmm4,PRE_MULTIPLY_SCALE_BITS >+ >+ movdqa xmm5,xmm2 >+ psubw xmm2,xmm6 >+ paddw xmm5,xmm6 ; xmm5=tmp7 >+ >+ psllw xmm2,PRE_MULTIPLY_SCALE_BITS >+ pmulhw xmm2,[GOTOFF(ebx,PW_F1414)] ; xmm2=tmp11 >+ >+ ; To avoid overflow... >+ ; >+ ; (Original) >+ ; tmp12 = -2.613125930 * z10 + z5; >+ ; >+ ; (This implementation) >+ ; tmp12 = (-1.613125930 - 1) * z10 + z5; >+ ; = -1.613125930 * z10 - z10 + z5; >+ >+ movdqa xmm6,xmm4 >+ paddw xmm4,xmm0 >+ pmulhw xmm4,[GOTOFF(ebx,PW_F1847)] ; xmm4=z5 >+ pmulhw xmm6,[GOTOFF(ebx,PW_MF1613)] >+ pmulhw xmm0,[GOTOFF(ebx,PW_F1082)] >+ psubw xmm6,xmm7 >+ psubw xmm0,xmm4 ; xmm0=tmp10 >+ paddw xmm6,xmm4 ; xmm6=tmp12 >+ >+ ; -- Final output stage >+ >+ psubw xmm6,xmm5 ; xmm6=tmp6 >+ movdqa xmm7,xmm1 >+ movdqa xmm4,xmm3 >+ paddw xmm1,xmm5 ; xmm1=data0=(00 10 20 30 40 50 60 70) >+ paddw xmm3,xmm6 ; xmm3=data1=(01 11 21 31 41 51 61 71) >+ psraw xmm1,(PASS1_BITS+3) ; descale >+ psraw xmm3,(PASS1_BITS+3) ; descale >+ psubw xmm7,xmm5 ; xmm7=data7=(07 17 27 37 47 57 67 77) >+ psubw xmm4,xmm6 ; xmm4=data6=(06 16 26 36 46 56 66 76) >+ psraw xmm7,(PASS1_BITS+3) ; descale >+ psraw xmm4,(PASS1_BITS+3) ; descale >+ psubw xmm2,xmm6 ; xmm2=tmp5 >+ >+ packsswb xmm1,xmm4 ; xmm1=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) >+ packsswb xmm3,xmm7 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) >+ >+ movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp2 >+ movdqa xmm6, XMMWORD [wk(0)] ; xmm6=tmp3 >+ >+ paddw xmm0,xmm2 ; xmm0=tmp4 >+ movdqa xmm4,xmm5 >+ movdqa xmm7,xmm6 >+ paddw xmm5,xmm2 ; xmm5=data2=(02 12 22 32 42 52 62 72) >+ paddw xmm6,xmm0 ; xmm6=data4=(04 14 24 34 44 54 64 74) >+ psraw xmm5,(PASS1_BITS+3) ; descale >+ psraw xmm6,(PASS1_BITS+3) ; descale >+ psubw xmm4,xmm2 ; xmm4=data5=(05 15 25 35 45 55 65 75) >+ psubw xmm7,xmm0 ; xmm7=data3=(03 13 23 33 43 53 63 73) >+ psraw xmm4,(PASS1_BITS+3) ; descale >+ psraw xmm7,(PASS1_BITS+3) ; descale >+ >+ movdqa xmm2,[GOTOFF(ebx,PB_CENTERJSAMP)] ; xmm2=[PB_CENTERJSAMP] >+ >+ packsswb xmm5,xmm6 ; xmm5=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74) >+ packsswb xmm7,xmm4 ; xmm7=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75) >+ >+ paddb xmm1,xmm2 >+ paddb xmm3,xmm2 >+ paddb xmm5,xmm2 >+ paddb xmm7,xmm2 >+ >+ movdqa xmm0,xmm1 ; transpose coefficients(phase 1) >+ punpcklbw xmm1,xmm3 ; xmm1=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71) >+ punpckhbw xmm0,xmm3 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77) >+ movdqa xmm6,xmm5 ; transpose coefficients(phase 1) >+ punpcklbw xmm5,xmm7 ; xmm5=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73) >+ punpckhbw xmm6,xmm7 ; xmm6=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75) >+ >+ movdqa xmm4,xmm1 ; transpose coefficients(phase 2) >+ punpcklwd xmm1,xmm5 ; xmm1=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33) >+ punpckhwd xmm4,xmm5 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73) >+ movdqa xmm2,xmm6 ; transpose coefficients(phase 2) >+ punpcklwd xmm6,xmm0 ; xmm6=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37) >+ punpckhwd xmm2,xmm0 ; xmm2=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77) >+ >+ movdqa xmm3,xmm1 ; transpose coefficients(phase 3) >+ punpckldq xmm1,xmm6 ; xmm1=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17) >+ punpckhdq xmm3,xmm6 ; xmm3=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37) >+ movdqa xmm7,xmm4 ; transpose coefficients(phase 3) >+ punpckldq xmm4,xmm2 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57) >+ punpckhdq xmm7,xmm2 ; xmm7=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77) >+ >+ pshufd xmm5,xmm1,0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07) >+ pshufd xmm0,xmm3,0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27) >+ pshufd xmm6,xmm4,0x4E ; xmm6=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47) >+ pshufd xmm2,xmm7,0x4E ; xmm2=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67) >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+2*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm1 >+ movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm3 >+ mov edx, JSAMPROW [edi+4*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+6*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm4 >+ movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm7 >+ >+ mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm5 >+ movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm0 >+ mov edx, JSAMPROW [edi+5*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+7*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm6 >+ movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm2 >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; unused >+ poppic ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jiss2int-64.asm b/modules/libjpeg-turbo/simd/jiss2int-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jiss2int-64.asm >@@ -0,0 +1,848 @@ >+; >+; jiss2int-64.asm - accurate integer IDCT (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a slow-but-accurate integer implementation of the >+; inverse DCT (Discrete Cosine Transform). The following code is based >+; directly on the IJG's original jidctint.c; see the jidctint.c for >+; more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 13 >+%define PASS1_BITS 2 >+ >+%define DESCALE_P1 (CONST_BITS-PASS1_BITS) >+%define DESCALE_P2 (CONST_BITS+PASS1_BITS+3) >+ >+%if CONST_BITS == 13 >+F_0_298 equ 2446 ; FIX(0.298631336) >+F_0_390 equ 3196 ; FIX(0.390180644) >+F_0_541 equ 4433 ; FIX(0.541196100) >+F_0_765 equ 6270 ; FIX(0.765366865) >+F_0_899 equ 7373 ; FIX(0.899976223) >+F_1_175 equ 9633 ; FIX(1.175875602) >+F_1_501 equ 12299 ; FIX(1.501321110) >+F_1_847 equ 15137 ; FIX(1.847759065) >+F_1_961 equ 16069 ; FIX(1.961570560) >+F_2_053 equ 16819 ; FIX(2.053119869) >+F_2_562 equ 20995 ; FIX(2.562915447) >+F_3_072 equ 25172 ; FIX(3.072711026) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_298 equ DESCALE( 320652955,30-CONST_BITS) ; FIX(0.298631336) >+F_0_390 equ DESCALE( 418953276,30-CONST_BITS) ; FIX(0.390180644) >+F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100) >+F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865) >+F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223) >+F_1_175 equ DESCALE(1262586813,30-CONST_BITS) ; FIX(1.175875602) >+F_1_501 equ DESCALE(1612031267,30-CONST_BITS) ; FIX(1.501321110) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_1_961 equ DESCALE(2106220350,30-CONST_BITS) ; FIX(1.961570560) >+F_2_053 equ DESCALE(2204520673,30-CONST_BITS) ; FIX(2.053119869) >+F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447) >+F_3_072 equ DESCALE(3299298341,30-CONST_BITS) ; FIX(3.072711026) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_idct_islow_sse2) >+ >+EXTN(jconst_idct_islow_sse2): >+ >+PW_F130_F054 times 4 dw (F_0_541+F_0_765), F_0_541 >+PW_F054_MF130 times 4 dw F_0_541, (F_0_541-F_1_847) >+PW_MF078_F117 times 4 dw (F_1_175-F_1_961), F_1_175 >+PW_F117_F078 times 4 dw F_1_175, (F_1_175-F_0_390) >+PW_MF060_MF089 times 4 dw (F_0_298-F_0_899),-F_0_899 >+PW_MF089_F060 times 4 dw -F_0_899, (F_1_501-F_0_899) >+PW_MF050_MF256 times 4 dw (F_2_053-F_2_562),-F_2_562 >+PW_MF256_F050 times 4 dw -F_2_562, (F_3_072-F_2_562) >+PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1-1) >+PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2-1) >+PB_CENTERJSAMP times 16 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Perform dequantization and inverse DCT on one block of coefficients. >+; >+; GLOBAL(void) >+; jsimd_idct_islow_sse2 (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+; r10 = jpeg_component_info * compptr >+; r11 = JCOEFPTR coef_block >+; r12 = JSAMPARRAY output_buf >+; r13 = JDIMENSION output_col >+ >+%define original_rbp rbp+0 >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 12 >+ >+ align 16 >+ global EXTN(jsimd_idct_islow_sse2) >+ >+EXTN(jsimd_idct_islow_sse2): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [wk(0)] >+ collect_args >+ >+ ; ---- Pass 1: process columns from input. >+ >+ mov rdx, r10 ; quantptr >+ mov rsi, r11 ; inptr >+ >+%ifndef NO_ZERO_COLUMN_TEST_ISLOW_SSE2 >+ mov eax, DWORD [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ jnz near .columnDCT >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] >+ por xmm1,xmm0 >+ packsswb xmm1,xmm1 >+ packsswb xmm1,xmm1 >+ movd eax,xmm1 >+ test rax,rax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movdqa xmm5, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm5, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ psllw xmm5,PASS1_BITS >+ >+ movdqa xmm4,xmm5 ; xmm5=in0=(00 01 02 03 04 05 06 07) >+ punpcklwd xmm5,xmm5 ; xmm5=(00 00 01 01 02 02 03 03) >+ punpckhwd xmm4,xmm4 ; xmm4=(04 04 05 05 06 06 07 07) >+ >+ pshufd xmm7,xmm5,0x00 ; xmm7=col0=(00 00 00 00 00 00 00 00) >+ pshufd xmm6,xmm5,0x55 ; xmm6=col1=(01 01 01 01 01 01 01 01) >+ pshufd xmm1,xmm5,0xAA ; xmm1=col2=(02 02 02 02 02 02 02 02) >+ pshufd xmm5,xmm5,0xFF ; xmm5=col3=(03 03 03 03 03 03 03 03) >+ pshufd xmm0,xmm4,0x00 ; xmm0=col4=(04 04 04 04 04 04 04 04) >+ pshufd xmm3,xmm4,0x55 ; xmm3=col5=(05 05 05 05 05 05 05 05) >+ pshufd xmm2,xmm4,0xAA ; xmm2=col6=(06 06 06 06 06 06 06 06) >+ pshufd xmm4,xmm4,0xFF ; xmm4=col7=(07 07 07 07 07 07 07 07) >+ >+ movdqa XMMWORD [wk(8)], xmm6 ; wk(8)=col1 >+ movdqa XMMWORD [wk(9)], xmm5 ; wk(9)=col3 >+ movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5 >+ movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7 >+ jmp near .column_end >+%endif >+.columnDCT: >+ >+ ; -- Even part >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ ; (Original) >+ ; z1 = (z2 + z3) * 0.541196100; >+ ; tmp2 = z1 + z3 * -1.847759065; >+ ; tmp3 = z1 + z2 * 0.765366865; >+ ; >+ ; (This implementation) >+ ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065); >+ ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100; >+ >+ movdqa xmm4,xmm1 ; xmm1=in2=z2 >+ movdqa xmm5,xmm1 >+ punpcklwd xmm4,xmm3 ; xmm3=in6=z3 >+ punpckhwd xmm5,xmm3 >+ movdqa xmm1,xmm4 >+ movdqa xmm3,xmm5 >+ pmaddwd xmm4,[rel PW_F130_F054] ; xmm4=tmp3L >+ pmaddwd xmm5,[rel PW_F130_F054] ; xmm5=tmp3H >+ pmaddwd xmm1,[rel PW_F054_MF130] ; xmm1=tmp2L >+ pmaddwd xmm3,[rel PW_F054_MF130] ; xmm3=tmp2H >+ >+ movdqa xmm6,xmm0 >+ paddw xmm0,xmm2 ; xmm0=in0+in4 >+ psubw xmm6,xmm2 ; xmm6=in0-in4 >+ >+ pxor xmm7,xmm7 >+ pxor xmm2,xmm2 >+ punpcklwd xmm7,xmm0 ; xmm7=tmp0L >+ punpckhwd xmm2,xmm0 ; xmm2=tmp0H >+ psrad xmm7,(16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS >+ psrad xmm2,(16-CONST_BITS) ; psrad xmm2,16 & pslld xmm2,CONST_BITS >+ >+ movdqa xmm0,xmm7 >+ paddd xmm7,xmm4 ; xmm7=tmp10L >+ psubd xmm0,xmm4 ; xmm0=tmp13L >+ movdqa xmm4,xmm2 >+ paddd xmm2,xmm5 ; xmm2=tmp10H >+ psubd xmm4,xmm5 ; xmm4=tmp13H >+ >+ movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=tmp10L >+ movdqa XMMWORD [wk(1)], xmm2 ; wk(1)=tmp10H >+ movdqa XMMWORD [wk(2)], xmm0 ; wk(2)=tmp13L >+ movdqa XMMWORD [wk(3)], xmm4 ; wk(3)=tmp13H >+ >+ pxor xmm5,xmm5 >+ pxor xmm7,xmm7 >+ punpcklwd xmm5,xmm6 ; xmm5=tmp1L >+ punpckhwd xmm7,xmm6 ; xmm7=tmp1H >+ psrad xmm5,(16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS >+ psrad xmm7,(16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS >+ >+ movdqa xmm2,xmm5 >+ paddd xmm5,xmm1 ; xmm5=tmp11L >+ psubd xmm2,xmm1 ; xmm2=tmp12L >+ movdqa xmm0,xmm7 >+ paddd xmm7,xmm3 ; xmm7=tmp11H >+ psubd xmm0,xmm3 ; xmm0=tmp12H >+ >+ movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L >+ movdqa XMMWORD [wk(5)], xmm7 ; wk(5)=tmp11H >+ movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=tmp12L >+ movdqa XMMWORD [wk(7)], xmm0 ; wk(7)=tmp12H >+ >+ ; -- Odd part >+ >+ movdqa xmm4, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm6, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm4, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm6, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ movdqa xmm5,xmm6 >+ movdqa xmm7,xmm4 >+ paddw xmm5,xmm3 ; xmm5=z3 >+ paddw xmm7,xmm1 ; xmm7=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movdqa xmm2,xmm5 >+ movdqa xmm0,xmm5 >+ punpcklwd xmm2,xmm7 >+ punpckhwd xmm0,xmm7 >+ movdqa xmm5,xmm2 >+ movdqa xmm7,xmm0 >+ pmaddwd xmm2,[rel PW_MF078_F117] ; xmm2=z3L >+ pmaddwd xmm0,[rel PW_MF078_F117] ; xmm0=z3H >+ pmaddwd xmm5,[rel PW_F117_F078] ; xmm5=z4L >+ pmaddwd xmm7,[rel PW_F117_F078] ; xmm7=z4H >+ >+ movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=z3L >+ movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=z3H >+ >+ ; (Original) >+ ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2; >+ ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869; >+ ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; tmp0 += z1 + z3; tmp1 += z2 + z4; >+ ; tmp2 += z2 + z3; tmp3 += z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223; >+ ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447; >+ ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447); >+ ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223); >+ ; tmp0 += z3; tmp1 += z4; >+ ; tmp2 += z3; tmp3 += z4; >+ >+ movdqa xmm2,xmm3 >+ movdqa xmm0,xmm3 >+ punpcklwd xmm2,xmm4 >+ punpckhwd xmm0,xmm4 >+ movdqa xmm3,xmm2 >+ movdqa xmm4,xmm0 >+ pmaddwd xmm2,[rel PW_MF060_MF089] ; xmm2=tmp0L >+ pmaddwd xmm0,[rel PW_MF060_MF089] ; xmm0=tmp0H >+ pmaddwd xmm3,[rel PW_MF089_F060] ; xmm3=tmp3L >+ pmaddwd xmm4,[rel PW_MF089_F060] ; xmm4=tmp3H >+ >+ paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp0L >+ paddd xmm0, XMMWORD [wk(11)] ; xmm0=tmp0H >+ paddd xmm3,xmm5 ; xmm3=tmp3L >+ paddd xmm4,xmm7 ; xmm4=tmp3H >+ >+ movdqa XMMWORD [wk(8)], xmm2 ; wk(8)=tmp0L >+ movdqa XMMWORD [wk(9)], xmm0 ; wk(9)=tmp0H >+ >+ movdqa xmm2,xmm1 >+ movdqa xmm0,xmm1 >+ punpcklwd xmm2,xmm6 >+ punpckhwd xmm0,xmm6 >+ movdqa xmm1,xmm2 >+ movdqa xmm6,xmm0 >+ pmaddwd xmm2,[rel PW_MF050_MF256] ; xmm2=tmp1L >+ pmaddwd xmm0,[rel PW_MF050_MF256] ; xmm0=tmp1H >+ pmaddwd xmm1,[rel PW_MF256_F050] ; xmm1=tmp2L >+ pmaddwd xmm6,[rel PW_MF256_F050] ; xmm6=tmp2H >+ >+ paddd xmm2,xmm5 ; xmm2=tmp1L >+ paddd xmm0,xmm7 ; xmm0=tmp1H >+ paddd xmm1, XMMWORD [wk(10)] ; xmm1=tmp2L >+ paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H >+ >+ movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=tmp1L >+ movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=tmp1H >+ >+ ; -- Final output stage >+ >+ movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L >+ movdqa xmm7, XMMWORD [wk(1)] ; xmm7=tmp10H >+ >+ movdqa xmm2,xmm5 >+ movdqa xmm0,xmm7 >+ paddd xmm5,xmm3 ; xmm5=data0L >+ paddd xmm7,xmm4 ; xmm7=data0H >+ psubd xmm2,xmm3 ; xmm2=data7L >+ psubd xmm0,xmm4 ; xmm0=data7H >+ >+ movdqa xmm3,[rel PD_DESCALE_P1] ; xmm3=[rel PD_DESCALE_P1] >+ >+ paddd xmm5,xmm3 >+ paddd xmm7,xmm3 >+ psrad xmm5,DESCALE_P1 >+ psrad xmm7,DESCALE_P1 >+ paddd xmm2,xmm3 >+ paddd xmm0,xmm3 >+ psrad xmm2,DESCALE_P1 >+ psrad xmm0,DESCALE_P1 >+ >+ packssdw xmm5,xmm7 ; xmm5=data0=(00 01 02 03 04 05 06 07) >+ packssdw xmm2,xmm0 ; xmm2=data7=(70 71 72 73 74 75 76 77) >+ >+ movdqa xmm4, XMMWORD [wk(4)] ; xmm4=tmp11L >+ movdqa xmm3, XMMWORD [wk(5)] ; xmm3=tmp11H >+ >+ movdqa xmm7,xmm4 >+ movdqa xmm0,xmm3 >+ paddd xmm4,xmm1 ; xmm4=data1L >+ paddd xmm3,xmm6 ; xmm3=data1H >+ psubd xmm7,xmm1 ; xmm7=data6L >+ psubd xmm0,xmm6 ; xmm0=data6H >+ >+ movdqa xmm1,[rel PD_DESCALE_P1] ; xmm1=[rel PD_DESCALE_P1] >+ >+ paddd xmm4,xmm1 >+ paddd xmm3,xmm1 >+ psrad xmm4,DESCALE_P1 >+ psrad xmm3,DESCALE_P1 >+ paddd xmm7,xmm1 >+ paddd xmm0,xmm1 >+ psrad xmm7,DESCALE_P1 >+ psrad xmm0,DESCALE_P1 >+ >+ packssdw xmm4,xmm3 ; xmm4=data1=(10 11 12 13 14 15 16 17) >+ packssdw xmm7,xmm0 ; xmm7=data6=(60 61 62 63 64 65 66 67) >+ >+ movdqa xmm6,xmm5 ; transpose coefficients(phase 1) >+ punpcklwd xmm5,xmm4 ; xmm5=(00 10 01 11 02 12 03 13) >+ punpckhwd xmm6,xmm4 ; xmm6=(04 14 05 15 06 16 07 17) >+ movdqa xmm1,xmm7 ; transpose coefficients(phase 1) >+ punpcklwd xmm7,xmm2 ; xmm7=(60 70 61 71 62 72 63 73) >+ punpckhwd xmm1,xmm2 ; xmm1=(64 74 65 75 66 76 67 77) >+ >+ movdqa xmm3, XMMWORD [wk(6)] ; xmm3=tmp12L >+ movdqa xmm0, XMMWORD [wk(7)] ; xmm0=tmp12H >+ movdqa xmm4, XMMWORD [wk(10)] ; xmm4=tmp1L >+ movdqa xmm2, XMMWORD [wk(11)] ; xmm2=tmp1H >+ >+ movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 01 11 02 12 03 13) >+ movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=(04 14 05 15 06 16 07 17) >+ movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=(60 70 61 71 62 72 63 73) >+ movdqa XMMWORD [wk(5)], xmm1 ; wk(5)=(64 74 65 75 66 76 67 77) >+ >+ movdqa xmm5,xmm3 >+ movdqa xmm6,xmm0 >+ paddd xmm3,xmm4 ; xmm3=data2L >+ paddd xmm0,xmm2 ; xmm0=data2H >+ psubd xmm5,xmm4 ; xmm5=data5L >+ psubd xmm6,xmm2 ; xmm6=data5H >+ >+ movdqa xmm7,[rel PD_DESCALE_P1] ; xmm7=[rel PD_DESCALE_P1] >+ >+ paddd xmm3,xmm7 >+ paddd xmm0,xmm7 >+ psrad xmm3,DESCALE_P1 >+ psrad xmm0,DESCALE_P1 >+ paddd xmm5,xmm7 >+ paddd xmm6,xmm7 >+ psrad xmm5,DESCALE_P1 >+ psrad xmm6,DESCALE_P1 >+ >+ packssdw xmm3,xmm0 ; xmm3=data2=(20 21 22 23 24 25 26 27) >+ packssdw xmm5,xmm6 ; xmm5=data5=(50 51 52 53 54 55 56 57) >+ >+ movdqa xmm1, XMMWORD [wk(2)] ; xmm1=tmp13L >+ movdqa xmm4, XMMWORD [wk(3)] ; xmm4=tmp13H >+ movdqa xmm2, XMMWORD [wk(8)] ; xmm2=tmp0L >+ movdqa xmm7, XMMWORD [wk(9)] ; xmm7=tmp0H >+ >+ movdqa xmm0,xmm1 >+ movdqa xmm6,xmm4 >+ paddd xmm1,xmm2 ; xmm1=data3L >+ paddd xmm4,xmm7 ; xmm4=data3H >+ psubd xmm0,xmm2 ; xmm0=data4L >+ psubd xmm6,xmm7 ; xmm6=data4H >+ >+ movdqa xmm2,[rel PD_DESCALE_P1] ; xmm2=[rel PD_DESCALE_P1] >+ >+ paddd xmm1,xmm2 >+ paddd xmm4,xmm2 >+ psrad xmm1,DESCALE_P1 >+ psrad xmm4,DESCALE_P1 >+ paddd xmm0,xmm2 >+ paddd xmm6,xmm2 >+ psrad xmm0,DESCALE_P1 >+ psrad xmm6,DESCALE_P1 >+ >+ packssdw xmm1,xmm4 ; xmm1=data3=(30 31 32 33 34 35 36 37) >+ packssdw xmm0,xmm6 ; xmm0=data4=(40 41 42 43 44 45 46 47) >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 01 11 02 12 03 13) >+ movdqa xmm2, XMMWORD [wk(1)] ; xmm2=(04 14 05 15 06 16 07 17) >+ >+ movdqa xmm4,xmm3 ; transpose coefficients(phase 1) >+ punpcklwd xmm3,xmm1 ; xmm3=(20 30 21 31 22 32 23 33) >+ punpckhwd xmm4,xmm1 ; xmm4=(24 34 25 35 26 36 27 37) >+ movdqa xmm6,xmm0 ; transpose coefficients(phase 1) >+ punpcklwd xmm0,xmm5 ; xmm0=(40 50 41 51 42 52 43 53) >+ punpckhwd xmm6,xmm5 ; xmm6=(44 54 45 55 46 56 47 57) >+ >+ movdqa xmm1,xmm7 ; transpose coefficients(phase 2) >+ punpckldq xmm7,xmm3 ; xmm7=(00 10 20 30 01 11 21 31) >+ punpckhdq xmm1,xmm3 ; xmm1=(02 12 22 32 03 13 23 33) >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 2) >+ punpckldq xmm2,xmm4 ; xmm2=(04 14 24 34 05 15 25 35) >+ punpckhdq xmm5,xmm4 ; xmm5=(06 16 26 36 07 17 27 37) >+ >+ movdqa xmm3, XMMWORD [wk(4)] ; xmm3=(60 70 61 71 62 72 63 73) >+ movdqa xmm4, XMMWORD [wk(5)] ; xmm4=(64 74 65 75 66 76 67 77) >+ >+ movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=(04 14 24 34 05 15 25 35) >+ movdqa XMMWORD [wk(7)], xmm5 ; wk(7)=(06 16 26 36 07 17 27 37) >+ >+ movdqa xmm2,xmm0 ; transpose coefficients(phase 2) >+ punpckldq xmm0,xmm3 ; xmm0=(40 50 60 70 41 51 61 71) >+ punpckhdq xmm2,xmm3 ; xmm2=(42 52 62 72 43 53 63 73) >+ movdqa xmm5,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm4 ; xmm6=(44 54 64 74 45 55 65 75) >+ punpckhdq xmm5,xmm4 ; xmm5=(46 56 66 76 47 57 67 77) >+ >+ movdqa xmm3,xmm7 ; transpose coefficients(phase 3) >+ punpcklqdq xmm7,xmm0 ; xmm7=col0=(00 10 20 30 40 50 60 70) >+ punpckhqdq xmm3,xmm0 ; xmm3=col1=(01 11 21 31 41 51 61 71) >+ movdqa xmm4,xmm1 ; transpose coefficients(phase 3) >+ punpcklqdq xmm1,xmm2 ; xmm1=col2=(02 12 22 32 42 52 62 72) >+ punpckhqdq xmm4,xmm2 ; xmm4=col3=(03 13 23 33 43 53 63 73) >+ >+ movdqa xmm0, XMMWORD [wk(6)] ; xmm0=(04 14 24 34 05 15 25 35) >+ movdqa xmm2, XMMWORD [wk(7)] ; xmm2=(06 16 26 36 07 17 27 37) >+ >+ movdqa XMMWORD [wk(8)], xmm3 ; wk(8)=col1 >+ movdqa XMMWORD [wk(9)], xmm4 ; wk(9)=col3 >+ >+ movdqa xmm3,xmm0 ; transpose coefficients(phase 3) >+ punpcklqdq xmm0,xmm6 ; xmm0=col4=(04 14 24 34 44 54 64 74) >+ punpckhqdq xmm3,xmm6 ; xmm3=col5=(05 15 25 35 45 55 65 75) >+ movdqa xmm4,xmm2 ; transpose coefficients(phase 3) >+ punpcklqdq xmm2,xmm5 ; xmm2=col6=(06 16 26 36 46 56 66 76) >+ punpckhqdq xmm4,xmm5 ; xmm4=col7=(07 17 27 37 47 57 67 77) >+ >+ movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5 >+ movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7 >+.column_end: >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov rax, [original_rbp] >+ mov rdi, r12 ; (JSAMPROW *) >+ mov rax, r13 >+ >+ ; -- Even part >+ >+ ; xmm7=col0, xmm1=col2, xmm0=col4, xmm2=col6 >+ >+ ; (Original) >+ ; z1 = (z2 + z3) * 0.541196100; >+ ; tmp2 = z1 + z3 * -1.847759065; >+ ; tmp3 = z1 + z2 * 0.765366865; >+ ; >+ ; (This implementation) >+ ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065); >+ ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100; >+ >+ movdqa xmm6,xmm1 ; xmm1=in2=z2 >+ movdqa xmm5,xmm1 >+ punpcklwd xmm6,xmm2 ; xmm2=in6=z3 >+ punpckhwd xmm5,xmm2 >+ movdqa xmm1,xmm6 >+ movdqa xmm2,xmm5 >+ pmaddwd xmm6,[rel PW_F130_F054] ; xmm6=tmp3L >+ pmaddwd xmm5,[rel PW_F130_F054] ; xmm5=tmp3H >+ pmaddwd xmm1,[rel PW_F054_MF130] ; xmm1=tmp2L >+ pmaddwd xmm2,[rel PW_F054_MF130] ; xmm2=tmp2H >+ >+ movdqa xmm3,xmm7 >+ paddw xmm7,xmm0 ; xmm7=in0+in4 >+ psubw xmm3,xmm0 ; xmm3=in0-in4 >+ >+ pxor xmm4,xmm4 >+ pxor xmm0,xmm0 >+ punpcklwd xmm4,xmm7 ; xmm4=tmp0L >+ punpckhwd xmm0,xmm7 ; xmm0=tmp0H >+ psrad xmm4,(16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS >+ psrad xmm0,(16-CONST_BITS) ; psrad xmm0,16 & pslld xmm0,CONST_BITS >+ >+ movdqa xmm7,xmm4 >+ paddd xmm4,xmm6 ; xmm4=tmp10L >+ psubd xmm7,xmm6 ; xmm7=tmp13L >+ movdqa xmm6,xmm0 >+ paddd xmm0,xmm5 ; xmm0=tmp10H >+ psubd xmm6,xmm5 ; xmm6=tmp13H >+ >+ movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=tmp10L >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp10H >+ movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=tmp13L >+ movdqa XMMWORD [wk(3)], xmm6 ; wk(3)=tmp13H >+ >+ pxor xmm5,xmm5 >+ pxor xmm4,xmm4 >+ punpcklwd xmm5,xmm3 ; xmm5=tmp1L >+ punpckhwd xmm4,xmm3 ; xmm4=tmp1H >+ psrad xmm5,(16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS >+ psrad xmm4,(16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS >+ >+ movdqa xmm0,xmm5 >+ paddd xmm5,xmm1 ; xmm5=tmp11L >+ psubd xmm0,xmm1 ; xmm0=tmp12L >+ movdqa xmm7,xmm4 >+ paddd xmm4,xmm2 ; xmm4=tmp11H >+ psubd xmm7,xmm2 ; xmm7=tmp12H >+ >+ movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L >+ movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=tmp11H >+ movdqa XMMWORD [wk(6)], xmm0 ; wk(6)=tmp12L >+ movdqa XMMWORD [wk(7)], xmm7 ; wk(7)=tmp12H >+ >+ ; -- Odd part >+ >+ movdqa xmm6, XMMWORD [wk(9)] ; xmm6=col3 >+ movdqa xmm3, XMMWORD [wk(8)] ; xmm3=col1 >+ movdqa xmm1, XMMWORD [wk(11)] ; xmm1=col7 >+ movdqa xmm2, XMMWORD [wk(10)] ; xmm2=col5 >+ >+ movdqa xmm5,xmm6 >+ movdqa xmm4,xmm3 >+ paddw xmm5,xmm1 ; xmm5=z3 >+ paddw xmm4,xmm2 ; xmm4=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movdqa xmm0,xmm5 >+ movdqa xmm7,xmm5 >+ punpcklwd xmm0,xmm4 >+ punpckhwd xmm7,xmm4 >+ movdqa xmm5,xmm0 >+ movdqa xmm4,xmm7 >+ pmaddwd xmm0,[rel PW_MF078_F117] ; xmm0=z3L >+ pmaddwd xmm7,[rel PW_MF078_F117] ; xmm7=z3H >+ pmaddwd xmm5,[rel PW_F117_F078] ; xmm5=z4L >+ pmaddwd xmm4,[rel PW_F117_F078] ; xmm4=z4H >+ >+ movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=z3L >+ movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=z3H >+ >+ ; (Original) >+ ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2; >+ ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869; >+ ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; tmp0 += z1 + z3; tmp1 += z2 + z4; >+ ; tmp2 += z2 + z3; tmp3 += z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223; >+ ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447; >+ ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447); >+ ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223); >+ ; tmp0 += z3; tmp1 += z4; >+ ; tmp2 += z3; tmp3 += z4; >+ >+ movdqa xmm0,xmm1 >+ movdqa xmm7,xmm1 >+ punpcklwd xmm0,xmm3 >+ punpckhwd xmm7,xmm3 >+ movdqa xmm1,xmm0 >+ movdqa xmm3,xmm7 >+ pmaddwd xmm0,[rel PW_MF060_MF089] ; xmm0=tmp0L >+ pmaddwd xmm7,[rel PW_MF060_MF089] ; xmm7=tmp0H >+ pmaddwd xmm1,[rel PW_MF089_F060] ; xmm1=tmp3L >+ pmaddwd xmm3,[rel PW_MF089_F060] ; xmm3=tmp3H >+ >+ paddd xmm0, XMMWORD [wk(10)] ; xmm0=tmp0L >+ paddd xmm7, XMMWORD [wk(11)] ; xmm7=tmp0H >+ paddd xmm1,xmm5 ; xmm1=tmp3L >+ paddd xmm3,xmm4 ; xmm3=tmp3H >+ >+ movdqa XMMWORD [wk(8)], xmm0 ; wk(8)=tmp0L >+ movdqa XMMWORD [wk(9)], xmm7 ; wk(9)=tmp0H >+ >+ movdqa xmm0,xmm2 >+ movdqa xmm7,xmm2 >+ punpcklwd xmm0,xmm6 >+ punpckhwd xmm7,xmm6 >+ movdqa xmm2,xmm0 >+ movdqa xmm6,xmm7 >+ pmaddwd xmm0,[rel PW_MF050_MF256] ; xmm0=tmp1L >+ pmaddwd xmm7,[rel PW_MF050_MF256] ; xmm7=tmp1H >+ pmaddwd xmm2,[rel PW_MF256_F050] ; xmm2=tmp2L >+ pmaddwd xmm6,[rel PW_MF256_F050] ; xmm6=tmp2H >+ >+ paddd xmm0,xmm5 ; xmm0=tmp1L >+ paddd xmm7,xmm4 ; xmm7=tmp1H >+ paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp2L >+ paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H >+ >+ movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=tmp1L >+ movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=tmp1H >+ >+ ; -- Final output stage >+ >+ movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L >+ movdqa xmm4, XMMWORD [wk(1)] ; xmm4=tmp10H >+ >+ movdqa xmm0,xmm5 >+ movdqa xmm7,xmm4 >+ paddd xmm5,xmm1 ; xmm5=data0L >+ paddd xmm4,xmm3 ; xmm4=data0H >+ psubd xmm0,xmm1 ; xmm0=data7L >+ psubd xmm7,xmm3 ; xmm7=data7H >+ >+ movdqa xmm1,[rel PD_DESCALE_P2] ; xmm1=[rel PD_DESCALE_P2] >+ >+ paddd xmm5,xmm1 >+ paddd xmm4,xmm1 >+ psrad xmm5,DESCALE_P2 >+ psrad xmm4,DESCALE_P2 >+ paddd xmm0,xmm1 >+ paddd xmm7,xmm1 >+ psrad xmm0,DESCALE_P2 >+ psrad xmm7,DESCALE_P2 >+ >+ packssdw xmm5,xmm4 ; xmm5=data0=(00 10 20 30 40 50 60 70) >+ packssdw xmm0,xmm7 ; xmm0=data7=(07 17 27 37 47 57 67 77) >+ >+ movdqa xmm3, XMMWORD [wk(4)] ; xmm3=tmp11L >+ movdqa xmm1, XMMWORD [wk(5)] ; xmm1=tmp11H >+ >+ movdqa xmm4,xmm3 >+ movdqa xmm7,xmm1 >+ paddd xmm3,xmm2 ; xmm3=data1L >+ paddd xmm1,xmm6 ; xmm1=data1H >+ psubd xmm4,xmm2 ; xmm4=data6L >+ psubd xmm7,xmm6 ; xmm7=data6H >+ >+ movdqa xmm2,[rel PD_DESCALE_P2] ; xmm2=[rel PD_DESCALE_P2] >+ >+ paddd xmm3,xmm2 >+ paddd xmm1,xmm2 >+ psrad xmm3,DESCALE_P2 >+ psrad xmm1,DESCALE_P2 >+ paddd xmm4,xmm2 >+ paddd xmm7,xmm2 >+ psrad xmm4,DESCALE_P2 >+ psrad xmm7,DESCALE_P2 >+ >+ packssdw xmm3,xmm1 ; xmm3=data1=(01 11 21 31 41 51 61 71) >+ packssdw xmm4,xmm7 ; xmm4=data6=(06 16 26 36 46 56 66 76) >+ >+ packsswb xmm5,xmm4 ; xmm5=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) >+ packsswb xmm3,xmm0 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) >+ >+ movdqa xmm6, XMMWORD [wk(6)] ; xmm6=tmp12L >+ movdqa xmm2, XMMWORD [wk(7)] ; xmm2=tmp12H >+ movdqa xmm1, XMMWORD [wk(10)] ; xmm1=tmp1L >+ movdqa xmm7, XMMWORD [wk(11)] ; xmm7=tmp1H >+ >+ movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) >+ movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) >+ >+ movdqa xmm4,xmm6 >+ movdqa xmm0,xmm2 >+ paddd xmm6,xmm1 ; xmm6=data2L >+ paddd xmm2,xmm7 ; xmm2=data2H >+ psubd xmm4,xmm1 ; xmm4=data5L >+ psubd xmm0,xmm7 ; xmm0=data5H >+ >+ movdqa xmm5,[rel PD_DESCALE_P2] ; xmm5=[rel PD_DESCALE_P2] >+ >+ paddd xmm6,xmm5 >+ paddd xmm2,xmm5 >+ psrad xmm6,DESCALE_P2 >+ psrad xmm2,DESCALE_P2 >+ paddd xmm4,xmm5 >+ paddd xmm0,xmm5 >+ psrad xmm4,DESCALE_P2 >+ psrad xmm0,DESCALE_P2 >+ >+ packssdw xmm6,xmm2 ; xmm6=data2=(02 12 22 32 42 52 62 72) >+ packssdw xmm4,xmm0 ; xmm4=data5=(05 15 25 35 45 55 65 75) >+ >+ movdqa xmm3, XMMWORD [wk(2)] ; xmm3=tmp13L >+ movdqa xmm1, XMMWORD [wk(3)] ; xmm1=tmp13H >+ movdqa xmm7, XMMWORD [wk(8)] ; xmm7=tmp0L >+ movdqa xmm5, XMMWORD [wk(9)] ; xmm5=tmp0H >+ >+ movdqa xmm2,xmm3 >+ movdqa xmm0,xmm1 >+ paddd xmm3,xmm7 ; xmm3=data3L >+ paddd xmm1,xmm5 ; xmm1=data3H >+ psubd xmm2,xmm7 ; xmm2=data4L >+ psubd xmm0,xmm5 ; xmm0=data4H >+ >+ movdqa xmm7,[rel PD_DESCALE_P2] ; xmm7=[rel PD_DESCALE_P2] >+ >+ paddd xmm3,xmm7 >+ paddd xmm1,xmm7 >+ psrad xmm3,DESCALE_P2 >+ psrad xmm1,DESCALE_P2 >+ paddd xmm2,xmm7 >+ paddd xmm0,xmm7 >+ psrad xmm2,DESCALE_P2 >+ psrad xmm0,DESCALE_P2 >+ >+ movdqa xmm5,[rel PB_CENTERJSAMP] ; xmm5=[rel PB_CENTERJSAMP] >+ >+ packssdw xmm3,xmm1 ; xmm3=data3=(03 13 23 33 43 53 63 73) >+ packssdw xmm2,xmm0 ; xmm2=data4=(04 14 24 34 44 54 64 74) >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) >+ movdqa xmm1, XMMWORD [wk(1)] ; xmm1=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) >+ >+ packsswb xmm6,xmm2 ; xmm6=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74) >+ packsswb xmm3,xmm4 ; xmm3=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75) >+ >+ paddb xmm7,xmm5 >+ paddb xmm1,xmm5 >+ paddb xmm6,xmm5 >+ paddb xmm3,xmm5 >+ >+ movdqa xmm0,xmm7 ; transpose coefficients(phase 1) >+ punpcklbw xmm7,xmm1 ; xmm7=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71) >+ punpckhbw xmm0,xmm1 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77) >+ movdqa xmm2,xmm6 ; transpose coefficients(phase 1) >+ punpcklbw xmm6,xmm3 ; xmm6=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73) >+ punpckhbw xmm2,xmm3 ; xmm2=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75) >+ >+ movdqa xmm4,xmm7 ; transpose coefficients(phase 2) >+ punpcklwd xmm7,xmm6 ; xmm7=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33) >+ punpckhwd xmm4,xmm6 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73) >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 2) >+ punpcklwd xmm2,xmm0 ; xmm2=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37) >+ punpckhwd xmm5,xmm0 ; xmm5=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77) >+ >+ movdqa xmm1,xmm7 ; transpose coefficients(phase 3) >+ punpckldq xmm7,xmm2 ; xmm7=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17) >+ punpckhdq xmm1,xmm2 ; xmm1=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37) >+ movdqa xmm3,xmm4 ; transpose coefficients(phase 3) >+ punpckldq xmm4,xmm5 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57) >+ punpckhdq xmm3,xmm5 ; xmm3=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77) >+ >+ pshufd xmm6,xmm7,0x4E ; xmm6=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07) >+ pshufd xmm0,xmm1,0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27) >+ pshufd xmm2,xmm4,0x4E ; xmm2=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47) >+ pshufd xmm5,xmm3,0x4E ; xmm5=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67) >+ >+ mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+2*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm7 >+ movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm1 >+ mov rdx, JSAMPROW [rdi+4*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+6*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm4 >+ movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3 >+ >+ mov rdx, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+3*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6 >+ movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm0 >+ mov rdx, JSAMPROW [rdi+5*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+7*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm2 >+ movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm5 >+ >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jiss2int.asm b/modules/libjpeg-turbo/simd/jiss2int.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jiss2int.asm >@@ -0,0 +1,859 @@ >+; >+; jiss2int.asm - accurate integer IDCT (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a slow-but-accurate integer implementation of the >+; inverse DCT (Discrete Cosine Transform). The following code is based >+; directly on the IJG's original jidctint.c; see the jidctint.c for >+; more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 13 >+%define PASS1_BITS 2 >+ >+%define DESCALE_P1 (CONST_BITS-PASS1_BITS) >+%define DESCALE_P2 (CONST_BITS+PASS1_BITS+3) >+ >+%if CONST_BITS == 13 >+F_0_298 equ 2446 ; FIX(0.298631336) >+F_0_390 equ 3196 ; FIX(0.390180644) >+F_0_541 equ 4433 ; FIX(0.541196100) >+F_0_765 equ 6270 ; FIX(0.765366865) >+F_0_899 equ 7373 ; FIX(0.899976223) >+F_1_175 equ 9633 ; FIX(1.175875602) >+F_1_501 equ 12299 ; FIX(1.501321110) >+F_1_847 equ 15137 ; FIX(1.847759065) >+F_1_961 equ 16069 ; FIX(1.961570560) >+F_2_053 equ 16819 ; FIX(2.053119869) >+F_2_562 equ 20995 ; FIX(2.562915447) >+F_3_072 equ 25172 ; FIX(3.072711026) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_298 equ DESCALE( 320652955,30-CONST_BITS) ; FIX(0.298631336) >+F_0_390 equ DESCALE( 418953276,30-CONST_BITS) ; FIX(0.390180644) >+F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100) >+F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865) >+F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223) >+F_1_175 equ DESCALE(1262586813,30-CONST_BITS) ; FIX(1.175875602) >+F_1_501 equ DESCALE(1612031267,30-CONST_BITS) ; FIX(1.501321110) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_1_961 equ DESCALE(2106220350,30-CONST_BITS) ; FIX(1.961570560) >+F_2_053 equ DESCALE(2204520673,30-CONST_BITS) ; FIX(2.053119869) >+F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447) >+F_3_072 equ DESCALE(3299298341,30-CONST_BITS) ; FIX(3.072711026) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_idct_islow_sse2) >+ >+EXTN(jconst_idct_islow_sse2): >+ >+PW_F130_F054 times 4 dw (F_0_541+F_0_765), F_0_541 >+PW_F054_MF130 times 4 dw F_0_541, (F_0_541-F_1_847) >+PW_MF078_F117 times 4 dw (F_1_175-F_1_961), F_1_175 >+PW_F117_F078 times 4 dw F_1_175, (F_1_175-F_0_390) >+PW_MF060_MF089 times 4 dw (F_0_298-F_0_899),-F_0_899 >+PW_MF089_F060 times 4 dw -F_0_899, (F_1_501-F_0_899) >+PW_MF050_MF256 times 4 dw (F_2_053-F_2_562),-F_2_562 >+PW_MF256_F050 times 4 dw -F_2_562, (F_3_072-F_2_562) >+PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1-1) >+PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2-1) >+PB_CENTERJSAMP times 16 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform dequantization and inverse DCT on one block of coefficients. >+; >+; GLOBAL(void) >+; jsimd_idct_islow_sse2 (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; jpeg_component_info * compptr >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 12 >+ >+ align 16 >+ global EXTN(jsimd_idct_islow_sse2) >+ >+EXTN(jsimd_idct_islow_sse2): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic ebx >+; push ecx ; unused >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input. >+ >+; mov eax, [original_ebp] >+ mov edx, POINTER [dct_table(eax)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(eax)] ; inptr >+ >+%ifndef NO_ZERO_COLUMN_TEST_ISLOW_SSE2 >+ mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ jnz near .columnDCT >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ por xmm1,xmm0 >+ packsswb xmm1,xmm1 >+ packsswb xmm1,xmm1 >+ movd eax,xmm1 >+ test eax,eax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movdqa xmm5, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm5, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ psllw xmm5,PASS1_BITS >+ >+ movdqa xmm4,xmm5 ; xmm5=in0=(00 01 02 03 04 05 06 07) >+ punpcklwd xmm5,xmm5 ; xmm5=(00 00 01 01 02 02 03 03) >+ punpckhwd xmm4,xmm4 ; xmm4=(04 04 05 05 06 06 07 07) >+ >+ pshufd xmm7,xmm5,0x00 ; xmm7=col0=(00 00 00 00 00 00 00 00) >+ pshufd xmm6,xmm5,0x55 ; xmm6=col1=(01 01 01 01 01 01 01 01) >+ pshufd xmm1,xmm5,0xAA ; xmm1=col2=(02 02 02 02 02 02 02 02) >+ pshufd xmm5,xmm5,0xFF ; xmm5=col3=(03 03 03 03 03 03 03 03) >+ pshufd xmm0,xmm4,0x00 ; xmm0=col4=(04 04 04 04 04 04 04 04) >+ pshufd xmm3,xmm4,0x55 ; xmm3=col5=(05 05 05 05 05 05 05 05) >+ pshufd xmm2,xmm4,0xAA ; xmm2=col6=(06 06 06 06 06 06 06 06) >+ pshufd xmm4,xmm4,0xFF ; xmm4=col7=(07 07 07 07 07 07 07 07) >+ >+ movdqa XMMWORD [wk(8)], xmm6 ; wk(8)=col1 >+ movdqa XMMWORD [wk(9)], xmm5 ; wk(9)=col3 >+ movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5 >+ movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7 >+ jmp near .column_end >+ alignx 16,7 >+%endif >+.columnDCT: >+ >+ ; -- Even part >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ ; (Original) >+ ; z1 = (z2 + z3) * 0.541196100; >+ ; tmp2 = z1 + z3 * -1.847759065; >+ ; tmp3 = z1 + z2 * 0.765366865; >+ ; >+ ; (This implementation) >+ ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065); >+ ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100; >+ >+ movdqa xmm4,xmm1 ; xmm1=in2=z2 >+ movdqa xmm5,xmm1 >+ punpcklwd xmm4,xmm3 ; xmm3=in6=z3 >+ punpckhwd xmm5,xmm3 >+ movdqa xmm1,xmm4 >+ movdqa xmm3,xmm5 >+ pmaddwd xmm4,[GOTOFF(ebx,PW_F130_F054)] ; xmm4=tmp3L >+ pmaddwd xmm5,[GOTOFF(ebx,PW_F130_F054)] ; xmm5=tmp3H >+ pmaddwd xmm1,[GOTOFF(ebx,PW_F054_MF130)] ; xmm1=tmp2L >+ pmaddwd xmm3,[GOTOFF(ebx,PW_F054_MF130)] ; xmm3=tmp2H >+ >+ movdqa xmm6,xmm0 >+ paddw xmm0,xmm2 ; xmm0=in0+in4 >+ psubw xmm6,xmm2 ; xmm6=in0-in4 >+ >+ pxor xmm7,xmm7 >+ pxor xmm2,xmm2 >+ punpcklwd xmm7,xmm0 ; xmm7=tmp0L >+ punpckhwd xmm2,xmm0 ; xmm2=tmp0H >+ psrad xmm7,(16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS >+ psrad xmm2,(16-CONST_BITS) ; psrad xmm2,16 & pslld xmm2,CONST_BITS >+ >+ movdqa xmm0,xmm7 >+ paddd xmm7,xmm4 ; xmm7=tmp10L >+ psubd xmm0,xmm4 ; xmm0=tmp13L >+ movdqa xmm4,xmm2 >+ paddd xmm2,xmm5 ; xmm2=tmp10H >+ psubd xmm4,xmm5 ; xmm4=tmp13H >+ >+ movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=tmp10L >+ movdqa XMMWORD [wk(1)], xmm2 ; wk(1)=tmp10H >+ movdqa XMMWORD [wk(2)], xmm0 ; wk(2)=tmp13L >+ movdqa XMMWORD [wk(3)], xmm4 ; wk(3)=tmp13H >+ >+ pxor xmm5,xmm5 >+ pxor xmm7,xmm7 >+ punpcklwd xmm5,xmm6 ; xmm5=tmp1L >+ punpckhwd xmm7,xmm6 ; xmm7=tmp1H >+ psrad xmm5,(16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS >+ psrad xmm7,(16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS >+ >+ movdqa xmm2,xmm5 >+ paddd xmm5,xmm1 ; xmm5=tmp11L >+ psubd xmm2,xmm1 ; xmm2=tmp12L >+ movdqa xmm0,xmm7 >+ paddd xmm7,xmm3 ; xmm7=tmp11H >+ psubd xmm0,xmm3 ; xmm0=tmp12H >+ >+ movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L >+ movdqa XMMWORD [wk(5)], xmm7 ; wk(5)=tmp11H >+ movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=tmp12L >+ movdqa XMMWORD [wk(7)], xmm0 ; wk(7)=tmp12H >+ >+ ; -- Odd part >+ >+ movdqa xmm4, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm6, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm4, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm6, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ movdqa xmm5,xmm6 >+ movdqa xmm7,xmm4 >+ paddw xmm5,xmm3 ; xmm5=z3 >+ paddw xmm7,xmm1 ; xmm7=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movdqa xmm2,xmm5 >+ movdqa xmm0,xmm5 >+ punpcklwd xmm2,xmm7 >+ punpckhwd xmm0,xmm7 >+ movdqa xmm5,xmm2 >+ movdqa xmm7,xmm0 >+ pmaddwd xmm2,[GOTOFF(ebx,PW_MF078_F117)] ; xmm2=z3L >+ pmaddwd xmm0,[GOTOFF(ebx,PW_MF078_F117)] ; xmm0=z3H >+ pmaddwd xmm5,[GOTOFF(ebx,PW_F117_F078)] ; xmm5=z4L >+ pmaddwd xmm7,[GOTOFF(ebx,PW_F117_F078)] ; xmm7=z4H >+ >+ movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=z3L >+ movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=z3H >+ >+ ; (Original) >+ ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2; >+ ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869; >+ ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; tmp0 += z1 + z3; tmp1 += z2 + z4; >+ ; tmp2 += z2 + z3; tmp3 += z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223; >+ ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447; >+ ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447); >+ ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223); >+ ; tmp0 += z3; tmp1 += z4; >+ ; tmp2 += z3; tmp3 += z4; >+ >+ movdqa xmm2,xmm3 >+ movdqa xmm0,xmm3 >+ punpcklwd xmm2,xmm4 >+ punpckhwd xmm0,xmm4 >+ movdqa xmm3,xmm2 >+ movdqa xmm4,xmm0 >+ pmaddwd xmm2,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm2=tmp0L >+ pmaddwd xmm0,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm0=tmp0H >+ pmaddwd xmm3,[GOTOFF(ebx,PW_MF089_F060)] ; xmm3=tmp3L >+ pmaddwd xmm4,[GOTOFF(ebx,PW_MF089_F060)] ; xmm4=tmp3H >+ >+ paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp0L >+ paddd xmm0, XMMWORD [wk(11)] ; xmm0=tmp0H >+ paddd xmm3,xmm5 ; xmm3=tmp3L >+ paddd xmm4,xmm7 ; xmm4=tmp3H >+ >+ movdqa XMMWORD [wk(8)], xmm2 ; wk(8)=tmp0L >+ movdqa XMMWORD [wk(9)], xmm0 ; wk(9)=tmp0H >+ >+ movdqa xmm2,xmm1 >+ movdqa xmm0,xmm1 >+ punpcklwd xmm2,xmm6 >+ punpckhwd xmm0,xmm6 >+ movdqa xmm1,xmm2 >+ movdqa xmm6,xmm0 >+ pmaddwd xmm2,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm2=tmp1L >+ pmaddwd xmm0,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm0=tmp1H >+ pmaddwd xmm1,[GOTOFF(ebx,PW_MF256_F050)] ; xmm1=tmp2L >+ pmaddwd xmm6,[GOTOFF(ebx,PW_MF256_F050)] ; xmm6=tmp2H >+ >+ paddd xmm2,xmm5 ; xmm2=tmp1L >+ paddd xmm0,xmm7 ; xmm0=tmp1H >+ paddd xmm1, XMMWORD [wk(10)] ; xmm1=tmp2L >+ paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H >+ >+ movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=tmp1L >+ movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=tmp1H >+ >+ ; -- Final output stage >+ >+ movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L >+ movdqa xmm7, XMMWORD [wk(1)] ; xmm7=tmp10H >+ >+ movdqa xmm2,xmm5 >+ movdqa xmm0,xmm7 >+ paddd xmm5,xmm3 ; xmm5=data0L >+ paddd xmm7,xmm4 ; xmm7=data0H >+ psubd xmm2,xmm3 ; xmm2=data7L >+ psubd xmm0,xmm4 ; xmm0=data7H >+ >+ movdqa xmm3,[GOTOFF(ebx,PD_DESCALE_P1)] ; xmm3=[PD_DESCALE_P1] >+ >+ paddd xmm5,xmm3 >+ paddd xmm7,xmm3 >+ psrad xmm5,DESCALE_P1 >+ psrad xmm7,DESCALE_P1 >+ paddd xmm2,xmm3 >+ paddd xmm0,xmm3 >+ psrad xmm2,DESCALE_P1 >+ psrad xmm0,DESCALE_P1 >+ >+ packssdw xmm5,xmm7 ; xmm5=data0=(00 01 02 03 04 05 06 07) >+ packssdw xmm2,xmm0 ; xmm2=data7=(70 71 72 73 74 75 76 77) >+ >+ movdqa xmm4, XMMWORD [wk(4)] ; xmm4=tmp11L >+ movdqa xmm3, XMMWORD [wk(5)] ; xmm3=tmp11H >+ >+ movdqa xmm7,xmm4 >+ movdqa xmm0,xmm3 >+ paddd xmm4,xmm1 ; xmm4=data1L >+ paddd xmm3,xmm6 ; xmm3=data1H >+ psubd xmm7,xmm1 ; xmm7=data6L >+ psubd xmm0,xmm6 ; xmm0=data6H >+ >+ movdqa xmm1,[GOTOFF(ebx,PD_DESCALE_P1)] ; xmm1=[PD_DESCALE_P1] >+ >+ paddd xmm4,xmm1 >+ paddd xmm3,xmm1 >+ psrad xmm4,DESCALE_P1 >+ psrad xmm3,DESCALE_P1 >+ paddd xmm7,xmm1 >+ paddd xmm0,xmm1 >+ psrad xmm7,DESCALE_P1 >+ psrad xmm0,DESCALE_P1 >+ >+ packssdw xmm4,xmm3 ; xmm4=data1=(10 11 12 13 14 15 16 17) >+ packssdw xmm7,xmm0 ; xmm7=data6=(60 61 62 63 64 65 66 67) >+ >+ movdqa xmm6,xmm5 ; transpose coefficients(phase 1) >+ punpcklwd xmm5,xmm4 ; xmm5=(00 10 01 11 02 12 03 13) >+ punpckhwd xmm6,xmm4 ; xmm6=(04 14 05 15 06 16 07 17) >+ movdqa xmm1,xmm7 ; transpose coefficients(phase 1) >+ punpcklwd xmm7,xmm2 ; xmm7=(60 70 61 71 62 72 63 73) >+ punpckhwd xmm1,xmm2 ; xmm1=(64 74 65 75 66 76 67 77) >+ >+ movdqa xmm3, XMMWORD [wk(6)] ; xmm3=tmp12L >+ movdqa xmm0, XMMWORD [wk(7)] ; xmm0=tmp12H >+ movdqa xmm4, XMMWORD [wk(10)] ; xmm4=tmp1L >+ movdqa xmm2, XMMWORD [wk(11)] ; xmm2=tmp1H >+ >+ movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 01 11 02 12 03 13) >+ movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=(04 14 05 15 06 16 07 17) >+ movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=(60 70 61 71 62 72 63 73) >+ movdqa XMMWORD [wk(5)], xmm1 ; wk(5)=(64 74 65 75 66 76 67 77) >+ >+ movdqa xmm5,xmm3 >+ movdqa xmm6,xmm0 >+ paddd xmm3,xmm4 ; xmm3=data2L >+ paddd xmm0,xmm2 ; xmm0=data2H >+ psubd xmm5,xmm4 ; xmm5=data5L >+ psubd xmm6,xmm2 ; xmm6=data5H >+ >+ movdqa xmm7,[GOTOFF(ebx,PD_DESCALE_P1)] ; xmm7=[PD_DESCALE_P1] >+ >+ paddd xmm3,xmm7 >+ paddd xmm0,xmm7 >+ psrad xmm3,DESCALE_P1 >+ psrad xmm0,DESCALE_P1 >+ paddd xmm5,xmm7 >+ paddd xmm6,xmm7 >+ psrad xmm5,DESCALE_P1 >+ psrad xmm6,DESCALE_P1 >+ >+ packssdw xmm3,xmm0 ; xmm3=data2=(20 21 22 23 24 25 26 27) >+ packssdw xmm5,xmm6 ; xmm5=data5=(50 51 52 53 54 55 56 57) >+ >+ movdqa xmm1, XMMWORD [wk(2)] ; xmm1=tmp13L >+ movdqa xmm4, XMMWORD [wk(3)] ; xmm4=tmp13H >+ movdqa xmm2, XMMWORD [wk(8)] ; xmm2=tmp0L >+ movdqa xmm7, XMMWORD [wk(9)] ; xmm7=tmp0H >+ >+ movdqa xmm0,xmm1 >+ movdqa xmm6,xmm4 >+ paddd xmm1,xmm2 ; xmm1=data3L >+ paddd xmm4,xmm7 ; xmm4=data3H >+ psubd xmm0,xmm2 ; xmm0=data4L >+ psubd xmm6,xmm7 ; xmm6=data4H >+ >+ movdqa xmm2,[GOTOFF(ebx,PD_DESCALE_P1)] ; xmm2=[PD_DESCALE_P1] >+ >+ paddd xmm1,xmm2 >+ paddd xmm4,xmm2 >+ psrad xmm1,DESCALE_P1 >+ psrad xmm4,DESCALE_P1 >+ paddd xmm0,xmm2 >+ paddd xmm6,xmm2 >+ psrad xmm0,DESCALE_P1 >+ psrad xmm6,DESCALE_P1 >+ >+ packssdw xmm1,xmm4 ; xmm1=data3=(30 31 32 33 34 35 36 37) >+ packssdw xmm0,xmm6 ; xmm0=data4=(40 41 42 43 44 45 46 47) >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 01 11 02 12 03 13) >+ movdqa xmm2, XMMWORD [wk(1)] ; xmm2=(04 14 05 15 06 16 07 17) >+ >+ movdqa xmm4,xmm3 ; transpose coefficients(phase 1) >+ punpcklwd xmm3,xmm1 ; xmm3=(20 30 21 31 22 32 23 33) >+ punpckhwd xmm4,xmm1 ; xmm4=(24 34 25 35 26 36 27 37) >+ movdqa xmm6,xmm0 ; transpose coefficients(phase 1) >+ punpcklwd xmm0,xmm5 ; xmm0=(40 50 41 51 42 52 43 53) >+ punpckhwd xmm6,xmm5 ; xmm6=(44 54 45 55 46 56 47 57) >+ >+ movdqa xmm1,xmm7 ; transpose coefficients(phase 2) >+ punpckldq xmm7,xmm3 ; xmm7=(00 10 20 30 01 11 21 31) >+ punpckhdq xmm1,xmm3 ; xmm1=(02 12 22 32 03 13 23 33) >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 2) >+ punpckldq xmm2,xmm4 ; xmm2=(04 14 24 34 05 15 25 35) >+ punpckhdq xmm5,xmm4 ; xmm5=(06 16 26 36 07 17 27 37) >+ >+ movdqa xmm3, XMMWORD [wk(4)] ; xmm3=(60 70 61 71 62 72 63 73) >+ movdqa xmm4, XMMWORD [wk(5)] ; xmm4=(64 74 65 75 66 76 67 77) >+ >+ movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=(04 14 24 34 05 15 25 35) >+ movdqa XMMWORD [wk(7)], xmm5 ; wk(7)=(06 16 26 36 07 17 27 37) >+ >+ movdqa xmm2,xmm0 ; transpose coefficients(phase 2) >+ punpckldq xmm0,xmm3 ; xmm0=(40 50 60 70 41 51 61 71) >+ punpckhdq xmm2,xmm3 ; xmm2=(42 52 62 72 43 53 63 73) >+ movdqa xmm5,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm4 ; xmm6=(44 54 64 74 45 55 65 75) >+ punpckhdq xmm5,xmm4 ; xmm5=(46 56 66 76 47 57 67 77) >+ >+ movdqa xmm3,xmm7 ; transpose coefficients(phase 3) >+ punpcklqdq xmm7,xmm0 ; xmm7=col0=(00 10 20 30 40 50 60 70) >+ punpckhqdq xmm3,xmm0 ; xmm3=col1=(01 11 21 31 41 51 61 71) >+ movdqa xmm4,xmm1 ; transpose coefficients(phase 3) >+ punpcklqdq xmm1,xmm2 ; xmm1=col2=(02 12 22 32 42 52 62 72) >+ punpckhqdq xmm4,xmm2 ; xmm4=col3=(03 13 23 33 43 53 63 73) >+ >+ movdqa xmm0, XMMWORD [wk(6)] ; xmm0=(04 14 24 34 05 15 25 35) >+ movdqa xmm2, XMMWORD [wk(7)] ; xmm2=(06 16 26 36 07 17 27 37) >+ >+ movdqa XMMWORD [wk(8)], xmm3 ; wk(8)=col1 >+ movdqa XMMWORD [wk(9)], xmm4 ; wk(9)=col3 >+ >+ movdqa xmm3,xmm0 ; transpose coefficients(phase 3) >+ punpcklqdq xmm0,xmm6 ; xmm0=col4=(04 14 24 34 44 54 64 74) >+ punpckhqdq xmm3,xmm6 ; xmm3=col5=(05 15 25 35 45 55 65 75) >+ movdqa xmm4,xmm2 ; transpose coefficients(phase 3) >+ punpcklqdq xmm2,xmm5 ; xmm2=col6=(06 16 26 36 46 56 66 76) >+ punpckhqdq xmm4,xmm5 ; xmm4=col7=(07 17 27 37 47 57 67 77) >+ >+ movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5 >+ movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7 >+.column_end: >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov eax, [original_ebp] >+ mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(eax)] >+ >+ ; -- Even part >+ >+ ; xmm7=col0, xmm1=col2, xmm0=col4, xmm2=col6 >+ >+ ; (Original) >+ ; z1 = (z2 + z3) * 0.541196100; >+ ; tmp2 = z1 + z3 * -1.847759065; >+ ; tmp3 = z1 + z2 * 0.765366865; >+ ; >+ ; (This implementation) >+ ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065); >+ ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100; >+ >+ movdqa xmm6,xmm1 ; xmm1=in2=z2 >+ movdqa xmm5,xmm1 >+ punpcklwd xmm6,xmm2 ; xmm2=in6=z3 >+ punpckhwd xmm5,xmm2 >+ movdqa xmm1,xmm6 >+ movdqa xmm2,xmm5 >+ pmaddwd xmm6,[GOTOFF(ebx,PW_F130_F054)] ; xmm6=tmp3L >+ pmaddwd xmm5,[GOTOFF(ebx,PW_F130_F054)] ; xmm5=tmp3H >+ pmaddwd xmm1,[GOTOFF(ebx,PW_F054_MF130)] ; xmm1=tmp2L >+ pmaddwd xmm2,[GOTOFF(ebx,PW_F054_MF130)] ; xmm2=tmp2H >+ >+ movdqa xmm3,xmm7 >+ paddw xmm7,xmm0 ; xmm7=in0+in4 >+ psubw xmm3,xmm0 ; xmm3=in0-in4 >+ >+ pxor xmm4,xmm4 >+ pxor xmm0,xmm0 >+ punpcklwd xmm4,xmm7 ; xmm4=tmp0L >+ punpckhwd xmm0,xmm7 ; xmm0=tmp0H >+ psrad xmm4,(16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS >+ psrad xmm0,(16-CONST_BITS) ; psrad xmm0,16 & pslld xmm0,CONST_BITS >+ >+ movdqa xmm7,xmm4 >+ paddd xmm4,xmm6 ; xmm4=tmp10L >+ psubd xmm7,xmm6 ; xmm7=tmp13L >+ movdqa xmm6,xmm0 >+ paddd xmm0,xmm5 ; xmm0=tmp10H >+ psubd xmm6,xmm5 ; xmm6=tmp13H >+ >+ movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=tmp10L >+ movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp10H >+ movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=tmp13L >+ movdqa XMMWORD [wk(3)], xmm6 ; wk(3)=tmp13H >+ >+ pxor xmm5,xmm5 >+ pxor xmm4,xmm4 >+ punpcklwd xmm5,xmm3 ; xmm5=tmp1L >+ punpckhwd xmm4,xmm3 ; xmm4=tmp1H >+ psrad xmm5,(16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS >+ psrad xmm4,(16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS >+ >+ movdqa xmm0,xmm5 >+ paddd xmm5,xmm1 ; xmm5=tmp11L >+ psubd xmm0,xmm1 ; xmm0=tmp12L >+ movdqa xmm7,xmm4 >+ paddd xmm4,xmm2 ; xmm4=tmp11H >+ psubd xmm7,xmm2 ; xmm7=tmp12H >+ >+ movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L >+ movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=tmp11H >+ movdqa XMMWORD [wk(6)], xmm0 ; wk(6)=tmp12L >+ movdqa XMMWORD [wk(7)], xmm7 ; wk(7)=tmp12H >+ >+ ; -- Odd part >+ >+ movdqa xmm6, XMMWORD [wk(9)] ; xmm6=col3 >+ movdqa xmm3, XMMWORD [wk(8)] ; xmm3=col1 >+ movdqa xmm1, XMMWORD [wk(11)] ; xmm1=col7 >+ movdqa xmm2, XMMWORD [wk(10)] ; xmm2=col5 >+ >+ movdqa xmm5,xmm6 >+ movdqa xmm4,xmm3 >+ paddw xmm5,xmm1 ; xmm5=z3 >+ paddw xmm4,xmm2 ; xmm4=z4 >+ >+ ; (Original) >+ ; z5 = (z3 + z4) * 1.175875602; >+ ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; >+ ; z3 += z5; z4 += z5; >+ ; >+ ; (This implementation) >+ ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; >+ ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); >+ >+ movdqa xmm0,xmm5 >+ movdqa xmm7,xmm5 >+ punpcklwd xmm0,xmm4 >+ punpckhwd xmm7,xmm4 >+ movdqa xmm5,xmm0 >+ movdqa xmm4,xmm7 >+ pmaddwd xmm0,[GOTOFF(ebx,PW_MF078_F117)] ; xmm0=z3L >+ pmaddwd xmm7,[GOTOFF(ebx,PW_MF078_F117)] ; xmm7=z3H >+ pmaddwd xmm5,[GOTOFF(ebx,PW_F117_F078)] ; xmm5=z4L >+ pmaddwd xmm4,[GOTOFF(ebx,PW_F117_F078)] ; xmm4=z4H >+ >+ movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=z3L >+ movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=z3H >+ >+ ; (Original) >+ ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2; >+ ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869; >+ ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110; >+ ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; >+ ; tmp0 += z1 + z3; tmp1 += z2 + z4; >+ ; tmp2 += z2 + z3; tmp3 += z1 + z4; >+ ; >+ ; (This implementation) >+ ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223; >+ ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447; >+ ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447); >+ ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223); >+ ; tmp0 += z3; tmp1 += z4; >+ ; tmp2 += z3; tmp3 += z4; >+ >+ movdqa xmm0,xmm1 >+ movdqa xmm7,xmm1 >+ punpcklwd xmm0,xmm3 >+ punpckhwd xmm7,xmm3 >+ movdqa xmm1,xmm0 >+ movdqa xmm3,xmm7 >+ pmaddwd xmm0,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm0=tmp0L >+ pmaddwd xmm7,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm7=tmp0H >+ pmaddwd xmm1,[GOTOFF(ebx,PW_MF089_F060)] ; xmm1=tmp3L >+ pmaddwd xmm3,[GOTOFF(ebx,PW_MF089_F060)] ; xmm3=tmp3H >+ >+ paddd xmm0, XMMWORD [wk(10)] ; xmm0=tmp0L >+ paddd xmm7, XMMWORD [wk(11)] ; xmm7=tmp0H >+ paddd xmm1,xmm5 ; xmm1=tmp3L >+ paddd xmm3,xmm4 ; xmm3=tmp3H >+ >+ movdqa XMMWORD [wk(8)], xmm0 ; wk(8)=tmp0L >+ movdqa XMMWORD [wk(9)], xmm7 ; wk(9)=tmp0H >+ >+ movdqa xmm0,xmm2 >+ movdqa xmm7,xmm2 >+ punpcklwd xmm0,xmm6 >+ punpckhwd xmm7,xmm6 >+ movdqa xmm2,xmm0 >+ movdqa xmm6,xmm7 >+ pmaddwd xmm0,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm0=tmp1L >+ pmaddwd xmm7,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm7=tmp1H >+ pmaddwd xmm2,[GOTOFF(ebx,PW_MF256_F050)] ; xmm2=tmp2L >+ pmaddwd xmm6,[GOTOFF(ebx,PW_MF256_F050)] ; xmm6=tmp2H >+ >+ paddd xmm0,xmm5 ; xmm0=tmp1L >+ paddd xmm7,xmm4 ; xmm7=tmp1H >+ paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp2L >+ paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H >+ >+ movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=tmp1L >+ movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=tmp1H >+ >+ ; -- Final output stage >+ >+ movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L >+ movdqa xmm4, XMMWORD [wk(1)] ; xmm4=tmp10H >+ >+ movdqa xmm0,xmm5 >+ movdqa xmm7,xmm4 >+ paddd xmm5,xmm1 ; xmm5=data0L >+ paddd xmm4,xmm3 ; xmm4=data0H >+ psubd xmm0,xmm1 ; xmm0=data7L >+ psubd xmm7,xmm3 ; xmm7=data7H >+ >+ movdqa xmm1,[GOTOFF(ebx,PD_DESCALE_P2)] ; xmm1=[PD_DESCALE_P2] >+ >+ paddd xmm5,xmm1 >+ paddd xmm4,xmm1 >+ psrad xmm5,DESCALE_P2 >+ psrad xmm4,DESCALE_P2 >+ paddd xmm0,xmm1 >+ paddd xmm7,xmm1 >+ psrad xmm0,DESCALE_P2 >+ psrad xmm7,DESCALE_P2 >+ >+ packssdw xmm5,xmm4 ; xmm5=data0=(00 10 20 30 40 50 60 70) >+ packssdw xmm0,xmm7 ; xmm0=data7=(07 17 27 37 47 57 67 77) >+ >+ movdqa xmm3, XMMWORD [wk(4)] ; xmm3=tmp11L >+ movdqa xmm1, XMMWORD [wk(5)] ; xmm1=tmp11H >+ >+ movdqa xmm4,xmm3 >+ movdqa xmm7,xmm1 >+ paddd xmm3,xmm2 ; xmm3=data1L >+ paddd xmm1,xmm6 ; xmm1=data1H >+ psubd xmm4,xmm2 ; xmm4=data6L >+ psubd xmm7,xmm6 ; xmm7=data6H >+ >+ movdqa xmm2,[GOTOFF(ebx,PD_DESCALE_P2)] ; xmm2=[PD_DESCALE_P2] >+ >+ paddd xmm3,xmm2 >+ paddd xmm1,xmm2 >+ psrad xmm3,DESCALE_P2 >+ psrad xmm1,DESCALE_P2 >+ paddd xmm4,xmm2 >+ paddd xmm7,xmm2 >+ psrad xmm4,DESCALE_P2 >+ psrad xmm7,DESCALE_P2 >+ >+ packssdw xmm3,xmm1 ; xmm3=data1=(01 11 21 31 41 51 61 71) >+ packssdw xmm4,xmm7 ; xmm4=data6=(06 16 26 36 46 56 66 76) >+ >+ packsswb xmm5,xmm4 ; xmm5=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) >+ packsswb xmm3,xmm0 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) >+ >+ movdqa xmm6, XMMWORD [wk(6)] ; xmm6=tmp12L >+ movdqa xmm2, XMMWORD [wk(7)] ; xmm2=tmp12H >+ movdqa xmm1, XMMWORD [wk(10)] ; xmm1=tmp1L >+ movdqa xmm7, XMMWORD [wk(11)] ; xmm7=tmp1H >+ >+ movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) >+ movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) >+ >+ movdqa xmm4,xmm6 >+ movdqa xmm0,xmm2 >+ paddd xmm6,xmm1 ; xmm6=data2L >+ paddd xmm2,xmm7 ; xmm2=data2H >+ psubd xmm4,xmm1 ; xmm4=data5L >+ psubd xmm0,xmm7 ; xmm0=data5H >+ >+ movdqa xmm5,[GOTOFF(ebx,PD_DESCALE_P2)] ; xmm5=[PD_DESCALE_P2] >+ >+ paddd xmm6,xmm5 >+ paddd xmm2,xmm5 >+ psrad xmm6,DESCALE_P2 >+ psrad xmm2,DESCALE_P2 >+ paddd xmm4,xmm5 >+ paddd xmm0,xmm5 >+ psrad xmm4,DESCALE_P2 >+ psrad xmm0,DESCALE_P2 >+ >+ packssdw xmm6,xmm2 ; xmm6=data2=(02 12 22 32 42 52 62 72) >+ packssdw xmm4,xmm0 ; xmm4=data5=(05 15 25 35 45 55 65 75) >+ >+ movdqa xmm3, XMMWORD [wk(2)] ; xmm3=tmp13L >+ movdqa xmm1, XMMWORD [wk(3)] ; xmm1=tmp13H >+ movdqa xmm7, XMMWORD [wk(8)] ; xmm7=tmp0L >+ movdqa xmm5, XMMWORD [wk(9)] ; xmm5=tmp0H >+ >+ movdqa xmm2,xmm3 >+ movdqa xmm0,xmm1 >+ paddd xmm3,xmm7 ; xmm3=data3L >+ paddd xmm1,xmm5 ; xmm1=data3H >+ psubd xmm2,xmm7 ; xmm2=data4L >+ psubd xmm0,xmm5 ; xmm0=data4H >+ >+ movdqa xmm7,[GOTOFF(ebx,PD_DESCALE_P2)] ; xmm7=[PD_DESCALE_P2] >+ >+ paddd xmm3,xmm7 >+ paddd xmm1,xmm7 >+ psrad xmm3,DESCALE_P2 >+ psrad xmm1,DESCALE_P2 >+ paddd xmm2,xmm7 >+ paddd xmm0,xmm7 >+ psrad xmm2,DESCALE_P2 >+ psrad xmm0,DESCALE_P2 >+ >+ movdqa xmm5,[GOTOFF(ebx,PB_CENTERJSAMP)] ; xmm5=[PB_CENTERJSAMP] >+ >+ packssdw xmm3,xmm1 ; xmm3=data3=(03 13 23 33 43 53 63 73) >+ packssdw xmm2,xmm0 ; xmm2=data4=(04 14 24 34 44 54 64 74) >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) >+ movdqa xmm1, XMMWORD [wk(1)] ; xmm1=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) >+ >+ packsswb xmm6,xmm2 ; xmm6=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74) >+ packsswb xmm3,xmm4 ; xmm3=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75) >+ >+ paddb xmm7,xmm5 >+ paddb xmm1,xmm5 >+ paddb xmm6,xmm5 >+ paddb xmm3,xmm5 >+ >+ movdqa xmm0,xmm7 ; transpose coefficients(phase 1) >+ punpcklbw xmm7,xmm1 ; xmm7=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71) >+ punpckhbw xmm0,xmm1 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77) >+ movdqa xmm2,xmm6 ; transpose coefficients(phase 1) >+ punpcklbw xmm6,xmm3 ; xmm6=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73) >+ punpckhbw xmm2,xmm3 ; xmm2=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75) >+ >+ movdqa xmm4,xmm7 ; transpose coefficients(phase 2) >+ punpcklwd xmm7,xmm6 ; xmm7=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33) >+ punpckhwd xmm4,xmm6 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73) >+ movdqa xmm5,xmm2 ; transpose coefficients(phase 2) >+ punpcklwd xmm2,xmm0 ; xmm2=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37) >+ punpckhwd xmm5,xmm0 ; xmm5=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77) >+ >+ movdqa xmm1,xmm7 ; transpose coefficients(phase 3) >+ punpckldq xmm7,xmm2 ; xmm7=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17) >+ punpckhdq xmm1,xmm2 ; xmm1=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37) >+ movdqa xmm3,xmm4 ; transpose coefficients(phase 3) >+ punpckldq xmm4,xmm5 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57) >+ punpckhdq xmm3,xmm5 ; xmm3=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77) >+ >+ pshufd xmm6,xmm7,0x4E ; xmm6=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07) >+ pshufd xmm0,xmm1,0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27) >+ pshufd xmm2,xmm4,0x4E ; xmm2=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47) >+ pshufd xmm5,xmm3,0x4E ; xmm5=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67) >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+2*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm7 >+ movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm1 >+ mov edx, JSAMPROW [edi+4*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+6*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm4 >+ movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm3 >+ >+ mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm6 >+ movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm0 >+ mov edx, JSAMPROW [edi+5*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+7*SIZEOF_JSAMPROW] >+ movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm2 >+ movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm5 >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; unused >+ poppic ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jiss2red-64.asm b/modules/libjpeg-turbo/simd/jiss2red-64.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jiss2red-64.asm >@@ -0,0 +1,576 @@ >+; >+; jiss2red-64.asm - reduced-size IDCT (64-bit SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2009 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains inverse-DCT routines that produce reduced-size >+; output: either 4x4 or 2x2 pixels from an 8x8 DCT block. >+; The following code is based directly on the IJG's original jidctred.c; >+; see the jidctred.c for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 13 >+%define PASS1_BITS 2 >+ >+%define DESCALE_P1_4 (CONST_BITS-PASS1_BITS+1) >+%define DESCALE_P2_4 (CONST_BITS+PASS1_BITS+3+1) >+%define DESCALE_P1_2 (CONST_BITS-PASS1_BITS+2) >+%define DESCALE_P2_2 (CONST_BITS+PASS1_BITS+3+2) >+ >+%if CONST_BITS == 13 >+F_0_211 equ 1730 ; FIX(0.211164243) >+F_0_509 equ 4176 ; FIX(0.509795579) >+F_0_601 equ 4926 ; FIX(0.601344887) >+F_0_720 equ 5906 ; FIX(0.720959822) >+F_0_765 equ 6270 ; FIX(0.765366865) >+F_0_850 equ 6967 ; FIX(0.850430095) >+F_0_899 equ 7373 ; FIX(0.899976223) >+F_1_061 equ 8697 ; FIX(1.061594337) >+F_1_272 equ 10426 ; FIX(1.272758580) >+F_1_451 equ 11893 ; FIX(1.451774981) >+F_1_847 equ 15137 ; FIX(1.847759065) >+F_2_172 equ 17799 ; FIX(2.172734803) >+F_2_562 equ 20995 ; FIX(2.562915447) >+F_3_624 equ 29692 ; FIX(3.624509785) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_211 equ DESCALE( 226735879,30-CONST_BITS) ; FIX(0.211164243) >+F_0_509 equ DESCALE( 547388834,30-CONST_BITS) ; FIX(0.509795579) >+F_0_601 equ DESCALE( 645689155,30-CONST_BITS) ; FIX(0.601344887) >+F_0_720 equ DESCALE( 774124714,30-CONST_BITS) ; FIX(0.720959822) >+F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865) >+F_0_850 equ DESCALE( 913142361,30-CONST_BITS) ; FIX(0.850430095) >+F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223) >+F_1_061 equ DESCALE(1139878239,30-CONST_BITS) ; FIX(1.061594337) >+F_1_272 equ DESCALE(1366614119,30-CONST_BITS) ; FIX(1.272758580) >+F_1_451 equ DESCALE(1558831516,30-CONST_BITS) ; FIX(1.451774981) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_2_172 equ DESCALE(2332956230,30-CONST_BITS) ; FIX(2.172734803) >+F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447) >+F_3_624 equ DESCALE(3891787747,30-CONST_BITS) ; FIX(3.624509785) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_idct_red_sse2) >+ >+EXTN(jconst_idct_red_sse2): >+ >+PW_F184_MF076 times 4 dw F_1_847,-F_0_765 >+PW_F256_F089 times 4 dw F_2_562, F_0_899 >+PW_F106_MF217 times 4 dw F_1_061,-F_2_172 >+PW_MF060_MF050 times 4 dw -F_0_601,-F_0_509 >+PW_F145_MF021 times 4 dw F_1_451,-F_0_211 >+PW_F362_MF127 times 4 dw F_3_624,-F_1_272 >+PW_F085_MF072 times 4 dw F_0_850,-F_0_720 >+PD_DESCALE_P1_4 times 4 dd 1 << (DESCALE_P1_4-1) >+PD_DESCALE_P2_4 times 4 dd 1 << (DESCALE_P2_4-1) >+PD_DESCALE_P1_2 times 4 dd 1 << (DESCALE_P1_2-1) >+PD_DESCALE_P2_2 times 4 dd 1 << (DESCALE_P2_2-1) >+PB_CENTERJSAMP times 16 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 64 >+; >+; Perform dequantization and inverse DCT on one block of coefficients, >+; producing a reduced-size 4x4 output block. >+; >+; GLOBAL(void) >+; jsimd_idct_4x4_sse2 (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+; r10 = void * dct_table >+; r11 = JCOEFPTR coef_block >+; r12 = JSAMPARRAY output_buf >+; r13 = JDIMENSION output_col >+ >+%define original_rbp rbp+0 >+%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_idct_4x4_sse2) >+ >+EXTN(jsimd_idct_4x4_sse2): >+ push rbp >+ mov rax,rsp ; rax = original rbp >+ sub rsp, byte 4 >+ and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [rsp],rax >+ mov rbp,rsp ; rbp = aligned rbp >+ lea rsp, [wk(0)] >+ collect_args >+ >+ ; ---- Pass 1: process columns from input. >+ >+ mov rdx, r10 ; quantptr >+ mov rsi, r11 ; inptr >+ >+%ifndef NO_ZERO_COLUMN_TEST_4X4_SSE2 >+ mov eax, DWORD [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ jnz short .columnDCT >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] >+ por xmm0,xmm1 >+ packsswb xmm0,xmm0 >+ packsswb xmm0,xmm0 >+ movd eax,xmm0 >+ test rax,rax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ psllw xmm0,PASS1_BITS >+ >+ movdqa xmm3,xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07) >+ punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) >+ punpckhwd xmm3,xmm3 ; xmm3=(04 04 05 05 06 06 07 07) >+ >+ pshufd xmm1,xmm0,0x50 ; xmm1=[col0 col1]=(00 00 00 00 01 01 01 01) >+ pshufd xmm0,xmm0,0xFA ; xmm0=[col2 col3]=(02 02 02 02 03 03 03 03) >+ pshufd xmm6,xmm3,0x50 ; xmm6=[col4 col5]=(04 04 04 04 05 05 05 05) >+ pshufd xmm3,xmm3,0xFA ; xmm3=[col6 col7]=(06 06 06 06 07 07 07 07) >+ >+ jmp near .column_end >+%endif >+.columnDCT: >+ >+ ; -- Odd part >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm2, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ movdqa xmm4,xmm0 >+ movdqa xmm5,xmm0 >+ punpcklwd xmm4,xmm1 >+ punpckhwd xmm5,xmm1 >+ movdqa xmm0,xmm4 >+ movdqa xmm1,xmm5 >+ pmaddwd xmm4,[rel PW_F256_F089] ; xmm4=(tmp2L) >+ pmaddwd xmm5,[rel PW_F256_F089] ; xmm5=(tmp2H) >+ pmaddwd xmm0,[rel PW_F106_MF217] ; xmm0=(tmp0L) >+ pmaddwd xmm1,[rel PW_F106_MF217] ; xmm1=(tmp0H) >+ >+ movdqa xmm6,xmm2 >+ movdqa xmm7,xmm2 >+ punpcklwd xmm6,xmm3 >+ punpckhwd xmm7,xmm3 >+ movdqa xmm2,xmm6 >+ movdqa xmm3,xmm7 >+ pmaddwd xmm6,[rel PW_MF060_MF050] ; xmm6=(tmp2L) >+ pmaddwd xmm7,[rel PW_MF060_MF050] ; xmm7=(tmp2H) >+ pmaddwd xmm2,[rel PW_F145_MF021] ; xmm2=(tmp0L) >+ pmaddwd xmm3,[rel PW_F145_MF021] ; xmm3=(tmp0H) >+ >+ paddd xmm6,xmm4 ; xmm6=tmp2L >+ paddd xmm7,xmm5 ; xmm7=tmp2H >+ paddd xmm2,xmm0 ; xmm2=tmp0L >+ paddd xmm3,xmm1 ; xmm3=tmp0H >+ >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp0L >+ movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=tmp0H >+ >+ ; -- Even part >+ >+ movdqa xmm4, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm5, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm0, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm4, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm5, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ pxor xmm1,xmm1 >+ pxor xmm2,xmm2 >+ punpcklwd xmm1,xmm4 ; xmm1=tmp0L >+ punpckhwd xmm2,xmm4 ; xmm2=tmp0H >+ psrad xmm1,(16-CONST_BITS-1) ; psrad xmm1,16 & pslld xmm1,CONST_BITS+1 >+ psrad xmm2,(16-CONST_BITS-1) ; psrad xmm2,16 & pslld xmm2,CONST_BITS+1 >+ >+ movdqa xmm3,xmm5 ; xmm5=in2=z2 >+ punpcklwd xmm5,xmm0 ; xmm0=in6=z3 >+ punpckhwd xmm3,xmm0 >+ pmaddwd xmm5,[rel PW_F184_MF076] ; xmm5=tmp2L >+ pmaddwd xmm3,[rel PW_F184_MF076] ; xmm3=tmp2H >+ >+ movdqa xmm4,xmm1 >+ movdqa xmm0,xmm2 >+ paddd xmm1,xmm5 ; xmm1=tmp10L >+ paddd xmm2,xmm3 ; xmm2=tmp10H >+ psubd xmm4,xmm5 ; xmm4=tmp12L >+ psubd xmm0,xmm3 ; xmm0=tmp12H >+ >+ ; -- Final output stage >+ >+ movdqa xmm5,xmm1 >+ movdqa xmm3,xmm2 >+ paddd xmm1,xmm6 ; xmm1=data0L >+ paddd xmm2,xmm7 ; xmm2=data0H >+ psubd xmm5,xmm6 ; xmm5=data3L >+ psubd xmm3,xmm7 ; xmm3=data3H >+ >+ movdqa xmm6,[rel PD_DESCALE_P1_4] ; xmm6=[rel PD_DESCALE_P1_4] >+ >+ paddd xmm1,xmm6 >+ paddd xmm2,xmm6 >+ psrad xmm1,DESCALE_P1_4 >+ psrad xmm2,DESCALE_P1_4 >+ paddd xmm5,xmm6 >+ paddd xmm3,xmm6 >+ psrad xmm5,DESCALE_P1_4 >+ psrad xmm3,DESCALE_P1_4 >+ >+ packssdw xmm1,xmm2 ; xmm1=data0=(00 01 02 03 04 05 06 07) >+ packssdw xmm5,xmm3 ; xmm5=data3=(30 31 32 33 34 35 36 37) >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp0L >+ movdqa xmm6, XMMWORD [wk(1)] ; xmm6=tmp0H >+ >+ movdqa xmm2,xmm4 >+ movdqa xmm3,xmm0 >+ paddd xmm4,xmm7 ; xmm4=data1L >+ paddd xmm0,xmm6 ; xmm0=data1H >+ psubd xmm2,xmm7 ; xmm2=data2L >+ psubd xmm3,xmm6 ; xmm3=data2H >+ >+ movdqa xmm7,[rel PD_DESCALE_P1_4] ; xmm7=[rel PD_DESCALE_P1_4] >+ >+ paddd xmm4,xmm7 >+ paddd xmm0,xmm7 >+ psrad xmm4,DESCALE_P1_4 >+ psrad xmm0,DESCALE_P1_4 >+ paddd xmm2,xmm7 >+ paddd xmm3,xmm7 >+ psrad xmm2,DESCALE_P1_4 >+ psrad xmm3,DESCALE_P1_4 >+ >+ packssdw xmm4,xmm0 ; xmm4=data1=(10 11 12 13 14 15 16 17) >+ packssdw xmm2,xmm3 ; xmm2=data2=(20 21 22 23 24 25 26 27) >+ >+ movdqa xmm6,xmm1 ; transpose coefficients(phase 1) >+ punpcklwd xmm1,xmm4 ; xmm1=(00 10 01 11 02 12 03 13) >+ punpckhwd xmm6,xmm4 ; xmm6=(04 14 05 15 06 16 07 17) >+ movdqa xmm7,xmm2 ; transpose coefficients(phase 1) >+ punpcklwd xmm2,xmm5 ; xmm2=(20 30 21 31 22 32 23 33) >+ punpckhwd xmm7,xmm5 ; xmm7=(24 34 25 35 26 36 27 37) >+ >+ movdqa xmm0,xmm1 ; transpose coefficients(phase 2) >+ punpckldq xmm1,xmm2 ; xmm1=[col0 col1]=(00 10 20 30 01 11 21 31) >+ punpckhdq xmm0,xmm2 ; xmm0=[col2 col3]=(02 12 22 32 03 13 23 33) >+ movdqa xmm3,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm7 ; xmm6=[col4 col5]=(04 14 24 34 05 15 25 35) >+ punpckhdq xmm3,xmm7 ; xmm3=[col6 col7]=(06 16 26 36 07 17 27 37) >+.column_end: >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows, store into output array. >+ >+ mov rax, [original_rbp] >+ mov rdi, r12 ; (JSAMPROW *) >+ mov rax, r13 >+ >+ ; -- Even part >+ >+ pxor xmm4,xmm4 >+ punpcklwd xmm4,xmm1 ; xmm4=tmp0 >+ psrad xmm4,(16-CONST_BITS-1) ; psrad xmm4,16 & pslld xmm4,CONST_BITS+1 >+ >+ ; -- Odd part >+ >+ punpckhwd xmm1,xmm0 >+ punpckhwd xmm6,xmm3 >+ movdqa xmm5,xmm1 >+ movdqa xmm2,xmm6 >+ pmaddwd xmm1,[rel PW_F256_F089] ; xmm1=(tmp2) >+ pmaddwd xmm6,[rel PW_MF060_MF050] ; xmm6=(tmp2) >+ pmaddwd xmm5,[rel PW_F106_MF217] ; xmm5=(tmp0) >+ pmaddwd xmm2,[rel PW_F145_MF021] ; xmm2=(tmp0) >+ >+ paddd xmm6,xmm1 ; xmm6=tmp2 >+ paddd xmm2,xmm5 ; xmm2=tmp0 >+ >+ ; -- Even part >+ >+ punpcklwd xmm0,xmm3 >+ pmaddwd xmm0,[rel PW_F184_MF076] ; xmm0=tmp2 >+ >+ movdqa xmm7,xmm4 >+ paddd xmm4,xmm0 ; xmm4=tmp10 >+ psubd xmm7,xmm0 ; xmm7=tmp12 >+ >+ ; -- Final output stage >+ >+ movdqa xmm1,[rel PD_DESCALE_P2_4] ; xmm1=[rel PD_DESCALE_P2_4] >+ >+ movdqa xmm5,xmm4 >+ movdqa xmm3,xmm7 >+ paddd xmm4,xmm6 ; xmm4=data0=(00 10 20 30) >+ paddd xmm7,xmm2 ; xmm7=data1=(01 11 21 31) >+ psubd xmm5,xmm6 ; xmm5=data3=(03 13 23 33) >+ psubd xmm3,xmm2 ; xmm3=data2=(02 12 22 32) >+ >+ paddd xmm4,xmm1 >+ paddd xmm7,xmm1 >+ psrad xmm4,DESCALE_P2_4 >+ psrad xmm7,DESCALE_P2_4 >+ paddd xmm5,xmm1 >+ paddd xmm3,xmm1 >+ psrad xmm5,DESCALE_P2_4 >+ psrad xmm3,DESCALE_P2_4 >+ >+ packssdw xmm4,xmm3 ; xmm4=(00 10 20 30 02 12 22 32) >+ packssdw xmm7,xmm5 ; xmm7=(01 11 21 31 03 13 23 33) >+ >+ movdqa xmm0,xmm4 ; transpose coefficients(phase 1) >+ punpcklwd xmm4,xmm7 ; xmm4=(00 01 10 11 20 21 30 31) >+ punpckhwd xmm0,xmm7 ; xmm0=(02 03 12 13 22 23 32 33) >+ >+ movdqa xmm6,xmm4 ; transpose coefficients(phase 2) >+ punpckldq xmm4,xmm0 ; xmm4=(00 01 02 03 10 11 12 13) >+ punpckhdq xmm6,xmm0 ; xmm6=(20 21 22 23 30 31 32 33) >+ >+ packsswb xmm4,xmm6 ; xmm4=(00 01 02 03 10 11 12 13 20 ..) >+ paddb xmm4,[rel PB_CENTERJSAMP] >+ >+ pshufd xmm2,xmm4,0x39 ; xmm2=(10 11 12 13 20 21 22 23 30 ..) >+ pshufd xmm1,xmm4,0x4E ; xmm1=(20 21 22 23 30 31 32 33 00 ..) >+ pshufd xmm3,xmm4,0x93 ; xmm3=(30 31 32 33 00 01 02 03 10 ..) >+ >+ mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] >+ movd XMM_DWORD [rdx+rax*SIZEOF_JSAMPLE], xmm4 >+ movd XMM_DWORD [rsi+rax*SIZEOF_JSAMPLE], xmm2 >+ mov rdx, JSAMPROW [rdi+2*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+3*SIZEOF_JSAMPROW] >+ movd XMM_DWORD [rdx+rax*SIZEOF_JSAMPLE], xmm1 >+ movd XMM_DWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3 >+ >+ uncollect_args >+ mov rsp,rbp ; rsp <- aligned rbp >+ pop rsp ; rsp <- original rbp >+ pop rbp >+ ret >+ >+ >+; -------------------------------------------------------------------------- >+; >+; Perform dequantization and inverse DCT on one block of coefficients, >+; producing a reduced-size 2x2 output block. >+; >+; GLOBAL(void) >+; jsimd_idct_2x2_sse2 (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+; r10 = void * dct_table >+; r11 = JCOEFPTR coef_block >+; r12 = JSAMPARRAY output_buf >+; r13 = JDIMENSION output_col >+ >+ align 16 >+ global EXTN(jsimd_idct_2x2_sse2) >+ >+EXTN(jsimd_idct_2x2_sse2): >+ push rbp >+ mov rax,rsp >+ mov rbp,rsp >+ collect_args >+ push rbx >+ >+ ; ---- Pass 1: process columns from input. >+ >+ mov rdx, r10 ; quantptr >+ mov rsi, r11 ; inptr >+ >+ ; | input: | result: | >+ ; | 00 01 ** 03 ** 05 ** 07 | | >+ ; | 10 11 ** 13 ** 15 ** 17 | | >+ ; | ** ** ** ** ** ** ** ** | | >+ ; | 30 31 ** 33 ** 35 ** 37 | A0 A1 A3 A5 A7 | >+ ; | ** ** ** ** ** ** ** ** | B0 B1 B3 B5 B7 | >+ ; | 50 51 ** 53 ** 55 ** 57 | | >+ ; | ** ** ** ** ** ** ** ** | | >+ ; | 70 71 ** 73 ** 75 ** 77 | | >+ >+ ; -- Odd part >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm2, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ ; xmm0=(10 11 ** 13 ** 15 ** 17), xmm1=(30 31 ** 33 ** 35 ** 37) >+ ; xmm2=(50 51 ** 53 ** 55 ** 57), xmm3=(70 71 ** 73 ** 75 ** 77) >+ >+ pcmpeqd xmm7,xmm7 >+ pslld xmm7,WORD_BIT ; xmm7={0x0000 0xFFFF 0x0000 0xFFFF ..} >+ >+ movdqa xmm4,xmm0 ; xmm4=(10 11 ** 13 ** 15 ** 17) >+ movdqa xmm5,xmm2 ; xmm5=(50 51 ** 53 ** 55 ** 57) >+ punpcklwd xmm4,xmm1 ; xmm4=(10 30 11 31 ** ** 13 33) >+ punpcklwd xmm5,xmm3 ; xmm5=(50 70 51 71 ** ** 53 73) >+ pmaddwd xmm4,[rel PW_F362_MF127] >+ pmaddwd xmm5,[rel PW_F085_MF072] >+ >+ psrld xmm0,WORD_BIT ; xmm0=(11 -- 13 -- 15 -- 17 --) >+ pand xmm1,xmm7 ; xmm1=(-- 31 -- 33 -- 35 -- 37) >+ psrld xmm2,WORD_BIT ; xmm2=(51 -- 53 -- 55 -- 57 --) >+ pand xmm3,xmm7 ; xmm3=(-- 71 -- 73 -- 75 -- 77) >+ por xmm0,xmm1 ; xmm0=(11 31 13 33 15 35 17 37) >+ por xmm2,xmm3 ; xmm2=(51 71 53 73 55 75 57 77) >+ pmaddwd xmm0,[rel PW_F362_MF127] >+ pmaddwd xmm2,[rel PW_F085_MF072] >+ >+ paddd xmm4,xmm5 ; xmm4=tmp0[col0 col1 **** col3] >+ paddd xmm0,xmm2 ; xmm0=tmp0[col1 col3 col5 col7] >+ >+ ; -- Even part >+ >+ movdqa xmm6, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] >+ pmullw xmm6, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ ; xmm6=(00 01 ** 03 ** 05 ** 07) >+ >+ movdqa xmm1,xmm6 ; xmm1=(00 01 ** 03 ** 05 ** 07) >+ pslld xmm6,WORD_BIT ; xmm6=(-- 00 -- ** -- ** -- **) >+ pand xmm1,xmm7 ; xmm1=(-- 01 -- 03 -- 05 -- 07) >+ psrad xmm6,(WORD_BIT-CONST_BITS-2) ; xmm6=tmp10[col0 **** **** ****] >+ psrad xmm1,(WORD_BIT-CONST_BITS-2) ; xmm1=tmp10[col1 col3 col5 col7] >+ >+ ; -- Final output stage >+ >+ movdqa xmm3,xmm6 >+ movdqa xmm5,xmm1 >+ paddd xmm6,xmm4 ; xmm6=data0[col0 **** **** ****]=(A0 ** ** **) >+ paddd xmm1,xmm0 ; xmm1=data0[col1 col3 col5 col7]=(A1 A3 A5 A7) >+ psubd xmm3,xmm4 ; xmm3=data1[col0 **** **** ****]=(B0 ** ** **) >+ psubd xmm5,xmm0 ; xmm5=data1[col1 col3 col5 col7]=(B1 B3 B5 B7) >+ >+ movdqa xmm2,[rel PD_DESCALE_P1_2] ; xmm2=[rel PD_DESCALE_P1_2] >+ >+ punpckldq xmm6,xmm3 ; xmm6=(A0 B0 ** **) >+ >+ movdqa xmm7,xmm1 >+ punpcklqdq xmm1,xmm5 ; xmm1=(A1 A3 B1 B3) >+ punpckhqdq xmm7,xmm5 ; xmm7=(A5 A7 B5 B7) >+ >+ paddd xmm6,xmm2 >+ psrad xmm6,DESCALE_P1_2 >+ >+ paddd xmm1,xmm2 >+ paddd xmm7,xmm2 >+ psrad xmm1,DESCALE_P1_2 >+ psrad xmm7,DESCALE_P1_2 >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32] >+ prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows, store into output array. >+ >+ mov rdi, r12 ; (JSAMPROW *) >+ mov rax, r13 >+ >+ ; | input:| result:| >+ ; | A0 B0 | | >+ ; | A1 B1 | C0 C1 | >+ ; | A3 B3 | D0 D1 | >+ ; | A5 B5 | | >+ ; | A7 B7 | | >+ >+ ; -- Odd part >+ >+ packssdw xmm1,xmm1 ; xmm1=(A1 A3 B1 B3 A1 A3 B1 B3) >+ packssdw xmm7,xmm7 ; xmm7=(A5 A7 B5 B7 A5 A7 B5 B7) >+ pmaddwd xmm1,[rel PW_F362_MF127] >+ pmaddwd xmm7,[rel PW_F085_MF072] >+ >+ paddd xmm1,xmm7 ; xmm1=tmp0[row0 row1 row0 row1] >+ >+ ; -- Even part >+ >+ pslld xmm6,(CONST_BITS+2) ; xmm6=tmp10[row0 row1 **** ****] >+ >+ ; -- Final output stage >+ >+ movdqa xmm4,xmm6 >+ paddd xmm6,xmm1 ; xmm6=data0[row0 row1 **** ****]=(C0 C1 ** **) >+ psubd xmm4,xmm1 ; xmm4=data1[row0 row1 **** ****]=(D0 D1 ** **) >+ >+ punpckldq xmm6,xmm4 ; xmm6=(C0 D0 C1 D1) >+ >+ paddd xmm6,[rel PD_DESCALE_P2_2] >+ psrad xmm6,DESCALE_P2_2 >+ >+ packssdw xmm6,xmm6 ; xmm6=(C0 D0 C1 D1 C0 D0 C1 D1) >+ packsswb xmm6,xmm6 ; xmm6=(C0 D0 C1 D1 C0 D0 C1 D1 ..) >+ paddb xmm6,[rel PB_CENTERJSAMP] >+ >+ pextrw ebx,xmm6,0x00 ; ebx=(C0 D0 -- --) >+ pextrw ecx,xmm6,0x01 ; ecx=(C1 D1 -- --) >+ >+ mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] >+ mov rsi, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] >+ mov WORD [rdx+rax*SIZEOF_JSAMPLE], bx >+ mov WORD [rsi+rax*SIZEOF_JSAMPLE], cx >+ >+ pop rbx >+ uncollect_args >+ pop rbp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jiss2red.asm b/modules/libjpeg-turbo/simd/jiss2red.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jiss2red.asm >@@ -0,0 +1,594 @@ >+; >+; jiss2red.asm - reduced-size IDCT (SSE2) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains inverse-DCT routines that produce reduced-size >+; output: either 4x4 or 2x2 pixels from an 8x8 DCT block. >+; The following code is based directly on the IJG's original jidctred.c; >+; see the jidctred.c for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%define CONST_BITS 13 >+%define PASS1_BITS 2 >+ >+%define DESCALE_P1_4 (CONST_BITS-PASS1_BITS+1) >+%define DESCALE_P2_4 (CONST_BITS+PASS1_BITS+3+1) >+%define DESCALE_P1_2 (CONST_BITS-PASS1_BITS+2) >+%define DESCALE_P2_2 (CONST_BITS+PASS1_BITS+3+2) >+ >+%if CONST_BITS == 13 >+F_0_211 equ 1730 ; FIX(0.211164243) >+F_0_509 equ 4176 ; FIX(0.509795579) >+F_0_601 equ 4926 ; FIX(0.601344887) >+F_0_720 equ 5906 ; FIX(0.720959822) >+F_0_765 equ 6270 ; FIX(0.765366865) >+F_0_850 equ 6967 ; FIX(0.850430095) >+F_0_899 equ 7373 ; FIX(0.899976223) >+F_1_061 equ 8697 ; FIX(1.061594337) >+F_1_272 equ 10426 ; FIX(1.272758580) >+F_1_451 equ 11893 ; FIX(1.451774981) >+F_1_847 equ 15137 ; FIX(1.847759065) >+F_2_172 equ 17799 ; FIX(2.172734803) >+F_2_562 equ 20995 ; FIX(2.562915447) >+F_3_624 equ 29692 ; FIX(3.624509785) >+%else >+; NASM cannot do compile-time arithmetic on floating-point constants. >+%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) >+F_0_211 equ DESCALE( 226735879,30-CONST_BITS) ; FIX(0.211164243) >+F_0_509 equ DESCALE( 547388834,30-CONST_BITS) ; FIX(0.509795579) >+F_0_601 equ DESCALE( 645689155,30-CONST_BITS) ; FIX(0.601344887) >+F_0_720 equ DESCALE( 774124714,30-CONST_BITS) ; FIX(0.720959822) >+F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865) >+F_0_850 equ DESCALE( 913142361,30-CONST_BITS) ; FIX(0.850430095) >+F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223) >+F_1_061 equ DESCALE(1139878239,30-CONST_BITS) ; FIX(1.061594337) >+F_1_272 equ DESCALE(1366614119,30-CONST_BITS) ; FIX(1.272758580) >+F_1_451 equ DESCALE(1558831516,30-CONST_BITS) ; FIX(1.451774981) >+F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) >+F_2_172 equ DESCALE(2332956230,30-CONST_BITS) ; FIX(2.172734803) >+F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447) >+F_3_624 equ DESCALE(3891787747,30-CONST_BITS) ; FIX(3.624509785) >+%endif >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_idct_red_sse2) >+ >+EXTN(jconst_idct_red_sse2): >+ >+PW_F184_MF076 times 4 dw F_1_847,-F_0_765 >+PW_F256_F089 times 4 dw F_2_562, F_0_899 >+PW_F106_MF217 times 4 dw F_1_061,-F_2_172 >+PW_MF060_MF050 times 4 dw -F_0_601,-F_0_509 >+PW_F145_MF021 times 4 dw F_1_451,-F_0_211 >+PW_F362_MF127 times 4 dw F_3_624,-F_1_272 >+PW_F085_MF072 times 4 dw F_0_850,-F_0_720 >+PD_DESCALE_P1_4 times 4 dd 1 << (DESCALE_P1_4-1) >+PD_DESCALE_P2_4 times 4 dd 1 << (DESCALE_P2_4-1) >+PD_DESCALE_P1_2 times 4 dd 1 << (DESCALE_P1_2-1) >+PD_DESCALE_P2_2 times 4 dd 1 << (DESCALE_P2_2-1) >+PB_CENTERJSAMP times 16 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform dequantization and inverse DCT on one block of coefficients, >+; producing a reduced-size 4x4 output block. >+; >+; GLOBAL(void) >+; jsimd_idct_4x4_sse2 (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; void * dct_table >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+ >+ align 16 >+ global EXTN(jsimd_idct_4x4_sse2) >+ >+EXTN(jsimd_idct_4x4_sse2): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [wk(0)] >+ pushpic ebx >+; push ecx ; unused >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input. >+ >+; mov eax, [original_ebp] >+ mov edx, POINTER [dct_table(eax)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(eax)] ; inptr >+ >+%ifndef NO_ZERO_COLUMN_TEST_4X4_SSE2 >+ mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ jnz short .columnDCT >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ por xmm0, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ por xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ por xmm0,xmm1 >+ packsswb xmm0,xmm0 >+ packsswb xmm0,xmm0 >+ movd eax,xmm0 >+ test eax,eax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ psllw xmm0,PASS1_BITS >+ >+ movdqa xmm3,xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07) >+ punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) >+ punpckhwd xmm3,xmm3 ; xmm3=(04 04 05 05 06 06 07 07) >+ >+ pshufd xmm1,xmm0,0x50 ; xmm1=[col0 col1]=(00 00 00 00 01 01 01 01) >+ pshufd xmm0,xmm0,0xFA ; xmm0=[col2 col3]=(02 02 02 02 03 03 03 03) >+ pshufd xmm6,xmm3,0x50 ; xmm6=[col4 col5]=(04 04 04 04 05 05 05 05) >+ pshufd xmm3,xmm3,0xFA ; xmm3=[col6 col7]=(06 06 06 06 07 07 07 07) >+ >+ jmp near .column_end >+ alignx 16,7 >+%endif >+.columnDCT: >+ >+ ; -- Odd part >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm2, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ movdqa xmm4,xmm0 >+ movdqa xmm5,xmm0 >+ punpcklwd xmm4,xmm1 >+ punpckhwd xmm5,xmm1 >+ movdqa xmm0,xmm4 >+ movdqa xmm1,xmm5 >+ pmaddwd xmm4,[GOTOFF(ebx,PW_F256_F089)] ; xmm4=(tmp2L) >+ pmaddwd xmm5,[GOTOFF(ebx,PW_F256_F089)] ; xmm5=(tmp2H) >+ pmaddwd xmm0,[GOTOFF(ebx,PW_F106_MF217)] ; xmm0=(tmp0L) >+ pmaddwd xmm1,[GOTOFF(ebx,PW_F106_MF217)] ; xmm1=(tmp0H) >+ >+ movdqa xmm6,xmm2 >+ movdqa xmm7,xmm2 >+ punpcklwd xmm6,xmm3 >+ punpckhwd xmm7,xmm3 >+ movdqa xmm2,xmm6 >+ movdqa xmm3,xmm7 >+ pmaddwd xmm6,[GOTOFF(ebx,PW_MF060_MF050)] ; xmm6=(tmp2L) >+ pmaddwd xmm7,[GOTOFF(ebx,PW_MF060_MF050)] ; xmm7=(tmp2H) >+ pmaddwd xmm2,[GOTOFF(ebx,PW_F145_MF021)] ; xmm2=(tmp0L) >+ pmaddwd xmm3,[GOTOFF(ebx,PW_F145_MF021)] ; xmm3=(tmp0H) >+ >+ paddd xmm6,xmm4 ; xmm6=tmp2L >+ paddd xmm7,xmm5 ; xmm7=tmp2H >+ paddd xmm2,xmm0 ; xmm2=tmp0L >+ paddd xmm3,xmm1 ; xmm3=tmp0H >+ >+ movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp0L >+ movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=tmp0H >+ >+ ; -- Even part >+ >+ movdqa xmm4, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm5, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm0, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm4, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm5, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ pxor xmm1,xmm1 >+ pxor xmm2,xmm2 >+ punpcklwd xmm1,xmm4 ; xmm1=tmp0L >+ punpckhwd xmm2,xmm4 ; xmm2=tmp0H >+ psrad xmm1,(16-CONST_BITS-1) ; psrad xmm1,16 & pslld xmm1,CONST_BITS+1 >+ psrad xmm2,(16-CONST_BITS-1) ; psrad xmm2,16 & pslld xmm2,CONST_BITS+1 >+ >+ movdqa xmm3,xmm5 ; xmm5=in2=z2 >+ punpcklwd xmm5,xmm0 ; xmm0=in6=z3 >+ punpckhwd xmm3,xmm0 >+ pmaddwd xmm5,[GOTOFF(ebx,PW_F184_MF076)] ; xmm5=tmp2L >+ pmaddwd xmm3,[GOTOFF(ebx,PW_F184_MF076)] ; xmm3=tmp2H >+ >+ movdqa xmm4,xmm1 >+ movdqa xmm0,xmm2 >+ paddd xmm1,xmm5 ; xmm1=tmp10L >+ paddd xmm2,xmm3 ; xmm2=tmp10H >+ psubd xmm4,xmm5 ; xmm4=tmp12L >+ psubd xmm0,xmm3 ; xmm0=tmp12H >+ >+ ; -- Final output stage >+ >+ movdqa xmm5,xmm1 >+ movdqa xmm3,xmm2 >+ paddd xmm1,xmm6 ; xmm1=data0L >+ paddd xmm2,xmm7 ; xmm2=data0H >+ psubd xmm5,xmm6 ; xmm5=data3L >+ psubd xmm3,xmm7 ; xmm3=data3H >+ >+ movdqa xmm6,[GOTOFF(ebx,PD_DESCALE_P1_4)] ; xmm6=[PD_DESCALE_P1_4] >+ >+ paddd xmm1,xmm6 >+ paddd xmm2,xmm6 >+ psrad xmm1,DESCALE_P1_4 >+ psrad xmm2,DESCALE_P1_4 >+ paddd xmm5,xmm6 >+ paddd xmm3,xmm6 >+ psrad xmm5,DESCALE_P1_4 >+ psrad xmm3,DESCALE_P1_4 >+ >+ packssdw xmm1,xmm2 ; xmm1=data0=(00 01 02 03 04 05 06 07) >+ packssdw xmm5,xmm3 ; xmm5=data3=(30 31 32 33 34 35 36 37) >+ >+ movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp0L >+ movdqa xmm6, XMMWORD [wk(1)] ; xmm6=tmp0H >+ >+ movdqa xmm2,xmm4 >+ movdqa xmm3,xmm0 >+ paddd xmm4,xmm7 ; xmm4=data1L >+ paddd xmm0,xmm6 ; xmm0=data1H >+ psubd xmm2,xmm7 ; xmm2=data2L >+ psubd xmm3,xmm6 ; xmm3=data2H >+ >+ movdqa xmm7,[GOTOFF(ebx,PD_DESCALE_P1_4)] ; xmm7=[PD_DESCALE_P1_4] >+ >+ paddd xmm4,xmm7 >+ paddd xmm0,xmm7 >+ psrad xmm4,DESCALE_P1_4 >+ psrad xmm0,DESCALE_P1_4 >+ paddd xmm2,xmm7 >+ paddd xmm3,xmm7 >+ psrad xmm2,DESCALE_P1_4 >+ psrad xmm3,DESCALE_P1_4 >+ >+ packssdw xmm4,xmm0 ; xmm4=data1=(10 11 12 13 14 15 16 17) >+ packssdw xmm2,xmm3 ; xmm2=data2=(20 21 22 23 24 25 26 27) >+ >+ movdqa xmm6,xmm1 ; transpose coefficients(phase 1) >+ punpcklwd xmm1,xmm4 ; xmm1=(00 10 01 11 02 12 03 13) >+ punpckhwd xmm6,xmm4 ; xmm6=(04 14 05 15 06 16 07 17) >+ movdqa xmm7,xmm2 ; transpose coefficients(phase 1) >+ punpcklwd xmm2,xmm5 ; xmm2=(20 30 21 31 22 32 23 33) >+ punpckhwd xmm7,xmm5 ; xmm7=(24 34 25 35 26 36 27 37) >+ >+ movdqa xmm0,xmm1 ; transpose coefficients(phase 2) >+ punpckldq xmm1,xmm2 ; xmm1=[col0 col1]=(00 10 20 30 01 11 21 31) >+ punpckhdq xmm0,xmm2 ; xmm0=[col2 col3]=(02 12 22 32 03 13 23 33) >+ movdqa xmm3,xmm6 ; transpose coefficients(phase 2) >+ punpckldq xmm6,xmm7 ; xmm6=[col4 col5]=(04 14 24 34 05 15 25 35) >+ punpckhdq xmm3,xmm7 ; xmm3=[col6 col7]=(06 16 26 36 07 17 27 37) >+.column_end: >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows, store into output array. >+ >+ mov eax, [original_ebp] >+ mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(eax)] >+ >+ ; -- Even part >+ >+ pxor xmm4,xmm4 >+ punpcklwd xmm4,xmm1 ; xmm4=tmp0 >+ psrad xmm4,(16-CONST_BITS-1) ; psrad xmm4,16 & pslld xmm4,CONST_BITS+1 >+ >+ ; -- Odd part >+ >+ punpckhwd xmm1,xmm0 >+ punpckhwd xmm6,xmm3 >+ movdqa xmm5,xmm1 >+ movdqa xmm2,xmm6 >+ pmaddwd xmm1,[GOTOFF(ebx,PW_F256_F089)] ; xmm1=(tmp2) >+ pmaddwd xmm6,[GOTOFF(ebx,PW_MF060_MF050)] ; xmm6=(tmp2) >+ pmaddwd xmm5,[GOTOFF(ebx,PW_F106_MF217)] ; xmm5=(tmp0) >+ pmaddwd xmm2,[GOTOFF(ebx,PW_F145_MF021)] ; xmm2=(tmp0) >+ >+ paddd xmm6,xmm1 ; xmm6=tmp2 >+ paddd xmm2,xmm5 ; xmm2=tmp0 >+ >+ ; -- Even part >+ >+ punpcklwd xmm0,xmm3 >+ pmaddwd xmm0,[GOTOFF(ebx,PW_F184_MF076)] ; xmm0=tmp2 >+ >+ movdqa xmm7,xmm4 >+ paddd xmm4,xmm0 ; xmm4=tmp10 >+ psubd xmm7,xmm0 ; xmm7=tmp12 >+ >+ ; -- Final output stage >+ >+ movdqa xmm1,[GOTOFF(ebx,PD_DESCALE_P2_4)] ; xmm1=[PD_DESCALE_P2_4] >+ >+ movdqa xmm5,xmm4 >+ movdqa xmm3,xmm7 >+ paddd xmm4,xmm6 ; xmm4=data0=(00 10 20 30) >+ paddd xmm7,xmm2 ; xmm7=data1=(01 11 21 31) >+ psubd xmm5,xmm6 ; xmm5=data3=(03 13 23 33) >+ psubd xmm3,xmm2 ; xmm3=data2=(02 12 22 32) >+ >+ paddd xmm4,xmm1 >+ paddd xmm7,xmm1 >+ psrad xmm4,DESCALE_P2_4 >+ psrad xmm7,DESCALE_P2_4 >+ paddd xmm5,xmm1 >+ paddd xmm3,xmm1 >+ psrad xmm5,DESCALE_P2_4 >+ psrad xmm3,DESCALE_P2_4 >+ >+ packssdw xmm4,xmm3 ; xmm4=(00 10 20 30 02 12 22 32) >+ packssdw xmm7,xmm5 ; xmm7=(01 11 21 31 03 13 23 33) >+ >+ movdqa xmm0,xmm4 ; transpose coefficients(phase 1) >+ punpcklwd xmm4,xmm7 ; xmm4=(00 01 10 11 20 21 30 31) >+ punpckhwd xmm0,xmm7 ; xmm0=(02 03 12 13 22 23 32 33) >+ >+ movdqa xmm6,xmm4 ; transpose coefficients(phase 2) >+ punpckldq xmm4,xmm0 ; xmm4=(00 01 02 03 10 11 12 13) >+ punpckhdq xmm6,xmm0 ; xmm6=(20 21 22 23 30 31 32 33) >+ >+ packsswb xmm4,xmm6 ; xmm4=(00 01 02 03 10 11 12 13 20 ..) >+ paddb xmm4,[GOTOFF(ebx,PB_CENTERJSAMP)] >+ >+ pshufd xmm2,xmm4,0x39 ; xmm2=(10 11 12 13 20 21 22 23 30 ..) >+ pshufd xmm1,xmm4,0x4E ; xmm1=(20 21 22 23 30 31 32 33 00 ..) >+ pshufd xmm3,xmm4,0x93 ; xmm3=(30 31 32 33 00 01 02 03 10 ..) >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ movd XMM_DWORD [edx+eax*SIZEOF_JSAMPLE], xmm4 >+ movd XMM_DWORD [esi+eax*SIZEOF_JSAMPLE], xmm2 >+ mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW] >+ movd XMM_DWORD [edx+eax*SIZEOF_JSAMPLE], xmm1 >+ movd XMM_DWORD [esi+eax*SIZEOF_JSAMPLE], xmm3 >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; unused >+ poppic ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+ >+; -------------------------------------------------------------------------- >+; >+; Perform dequantization and inverse DCT on one block of coefficients, >+; producing a reduced-size 2x2 output block. >+; >+; GLOBAL(void) >+; jsimd_idct_2x2_sse2 (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; void * dct_table >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+ align 16 >+ global EXTN(jsimd_idct_2x2_sse2) >+ >+EXTN(jsimd_idct_2x2_sse2): >+ push ebp >+ mov ebp,esp >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input. >+ >+ mov edx, POINTER [dct_table(ebp)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(ebp)] ; inptr >+ >+ ; | input: | result: | >+ ; | 00 01 ** 03 ** 05 ** 07 | | >+ ; | 10 11 ** 13 ** 15 ** 17 | | >+ ; | ** ** ** ** ** ** ** ** | | >+ ; | 30 31 ** 33 ** 35 ** 37 | A0 A1 A3 A5 A7 | >+ ; | ** ** ** ** ** ** ** ** | B0 B1 B3 B5 B7 | >+ ; | 50 51 ** 53 ** 55 ** 57 | | >+ ; | ** ** ** ** ** ** ** ** | | >+ ; | 70 71 ** 73 ** 75 ** 77 | | >+ >+ ; -- Odd part >+ >+ movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm1, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm0, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm1, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ movdqa xmm2, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movdqa xmm3, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm2, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ pmullw xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ ; xmm0=(10 11 ** 13 ** 15 ** 17), xmm1=(30 31 ** 33 ** 35 ** 37) >+ ; xmm2=(50 51 ** 53 ** 55 ** 57), xmm3=(70 71 ** 73 ** 75 ** 77) >+ >+ pcmpeqd xmm7,xmm7 >+ pslld xmm7,WORD_BIT ; xmm7={0x0000 0xFFFF 0x0000 0xFFFF ..} >+ >+ movdqa xmm4,xmm0 ; xmm4=(10 11 ** 13 ** 15 ** 17) >+ movdqa xmm5,xmm2 ; xmm5=(50 51 ** 53 ** 55 ** 57) >+ punpcklwd xmm4,xmm1 ; xmm4=(10 30 11 31 ** ** 13 33) >+ punpcklwd xmm5,xmm3 ; xmm5=(50 70 51 71 ** ** 53 73) >+ pmaddwd xmm4,[GOTOFF(ebx,PW_F362_MF127)] >+ pmaddwd xmm5,[GOTOFF(ebx,PW_F085_MF072)] >+ >+ psrld xmm0,WORD_BIT ; xmm0=(11 -- 13 -- 15 -- 17 --) >+ pand xmm1,xmm7 ; xmm1=(-- 31 -- 33 -- 35 -- 37) >+ psrld xmm2,WORD_BIT ; xmm2=(51 -- 53 -- 55 -- 57 --) >+ pand xmm3,xmm7 ; xmm3=(-- 71 -- 73 -- 75 -- 77) >+ por xmm0,xmm1 ; xmm0=(11 31 13 33 15 35 17 37) >+ por xmm2,xmm3 ; xmm2=(51 71 53 73 55 75 57 77) >+ pmaddwd xmm0,[GOTOFF(ebx,PW_F362_MF127)] >+ pmaddwd xmm2,[GOTOFF(ebx,PW_F085_MF072)] >+ >+ paddd xmm4,xmm5 ; xmm4=tmp0[col0 col1 **** col3] >+ paddd xmm0,xmm2 ; xmm0=tmp0[col1 col3 col5 col7] >+ >+ ; -- Even part >+ >+ movdqa xmm6, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ pmullw xmm6, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)] >+ >+ ; xmm6=(00 01 ** 03 ** 05 ** 07) >+ >+ movdqa xmm1,xmm6 ; xmm1=(00 01 ** 03 ** 05 ** 07) >+ pslld xmm6,WORD_BIT ; xmm6=(-- 00 -- ** -- ** -- **) >+ pand xmm1,xmm7 ; xmm1=(-- 01 -- 03 -- 05 -- 07) >+ psrad xmm6,(WORD_BIT-CONST_BITS-2) ; xmm6=tmp10[col0 **** **** ****] >+ psrad xmm1,(WORD_BIT-CONST_BITS-2) ; xmm1=tmp10[col1 col3 col5 col7] >+ >+ ; -- Final output stage >+ >+ movdqa xmm3,xmm6 >+ movdqa xmm5,xmm1 >+ paddd xmm6,xmm4 ; xmm6=data0[col0 **** **** ****]=(A0 ** ** **) >+ paddd xmm1,xmm0 ; xmm1=data0[col1 col3 col5 col7]=(A1 A3 A5 A7) >+ psubd xmm3,xmm4 ; xmm3=data1[col0 **** **** ****]=(B0 ** ** **) >+ psubd xmm5,xmm0 ; xmm5=data1[col1 col3 col5 col7]=(B1 B3 B5 B7) >+ >+ movdqa xmm2,[GOTOFF(ebx,PD_DESCALE_P1_2)] ; xmm2=[PD_DESCALE_P1_2] >+ >+ punpckldq xmm6,xmm3 ; xmm6=(A0 B0 ** **) >+ >+ movdqa xmm7,xmm1 >+ punpcklqdq xmm1,xmm5 ; xmm1=(A1 A3 B1 B3) >+ punpckhqdq xmm7,xmm5 ; xmm7=(A5 A7 B5 B7) >+ >+ paddd xmm6,xmm2 >+ psrad xmm6,DESCALE_P1_2 >+ >+ paddd xmm1,xmm2 >+ paddd xmm7,xmm2 >+ psrad xmm1,DESCALE_P1_2 >+ psrad xmm7,DESCALE_P1_2 >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32] >+ prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows, store into output array. >+ >+ mov edi, JSAMPARRAY [output_buf(ebp)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(ebp)] >+ >+ ; | input:| result:| >+ ; | A0 B0 | | >+ ; | A1 B1 | C0 C1 | >+ ; | A3 B3 | D0 D1 | >+ ; | A5 B5 | | >+ ; | A7 B7 | | >+ >+ ; -- Odd part >+ >+ packssdw xmm1,xmm1 ; xmm1=(A1 A3 B1 B3 A1 A3 B1 B3) >+ packssdw xmm7,xmm7 ; xmm7=(A5 A7 B5 B7 A5 A7 B5 B7) >+ pmaddwd xmm1,[GOTOFF(ebx,PW_F362_MF127)] >+ pmaddwd xmm7,[GOTOFF(ebx,PW_F085_MF072)] >+ >+ paddd xmm1,xmm7 ; xmm1=tmp0[row0 row1 row0 row1] >+ >+ ; -- Even part >+ >+ pslld xmm6,(CONST_BITS+2) ; xmm6=tmp10[row0 row1 **** ****] >+ >+ ; -- Final output stage >+ >+ movdqa xmm4,xmm6 >+ paddd xmm6,xmm1 ; xmm6=data0[row0 row1 **** ****]=(C0 C1 ** **) >+ psubd xmm4,xmm1 ; xmm4=data1[row0 row1 **** ****]=(D0 D1 ** **) >+ >+ punpckldq xmm6,xmm4 ; xmm6=(C0 D0 C1 D1) >+ >+ paddd xmm6,[GOTOFF(ebx,PD_DESCALE_P2_2)] >+ psrad xmm6,DESCALE_P2_2 >+ >+ packssdw xmm6,xmm6 ; xmm6=(C0 D0 C1 D1 C0 D0 C1 D1) >+ packsswb xmm6,xmm6 ; xmm6=(C0 D0 C1 D1 C0 D0 C1 D1 ..) >+ paddb xmm6,[GOTOFF(ebx,PB_CENTERJSAMP)] >+ >+ pextrw ebx,xmm6,0x00 ; ebx=(C0 D0 -- --) >+ pextrw ecx,xmm6,0x01 ; ecx=(C1 D1 -- --) >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov esi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ mov WORD [edx+eax*SIZEOF_JSAMPLE], bx >+ mov WORD [esi+eax*SIZEOF_JSAMPLE], cx >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jisseflt.asm b/modules/libjpeg-turbo/simd/jisseflt.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jisseflt.asm >@@ -0,0 +1,572 @@ >+; >+; jisseflt.asm - floating-point IDCT (SSE & MMX) >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; This file contains a floating-point implementation of the inverse DCT >+; (Discrete Cosine Transform). The following code is based directly on >+; the IJG's original jidctflt.c; see the jidctflt.c for more details. >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+%include "jdct.inc" >+ >+; -------------------------------------------------------------------------- >+ >+%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5) >+ shufps %1,%2,0x44 >+%endmacro >+ >+%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7) >+ shufps %1,%2,0xEE >+%endmacro >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_CONST >+ >+ alignz 16 >+ global EXTN(jconst_idct_float_sse) >+ >+EXTN(jconst_idct_float_sse): >+ >+PD_1_414 times 4 dd 1.414213562373095048801689 >+PD_1_847 times 4 dd 1.847759065022573512256366 >+PD_1_082 times 4 dd 1.082392200292393968799446 >+PD_M2_613 times 4 dd -2.613125929752753055713286 >+PD_0_125 times 4 dd 0.125 ; 1/8 >+PB_CENTERJSAMP times 8 db CENTERJSAMPLE >+ >+ alignz 16 >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Perform dequantization and inverse DCT on one block of coefficients. >+; >+; GLOBAL(void) >+; jsimd_idct_float_sse (void * dct_table, JCOEFPTR coef_block, >+; JSAMPARRAY output_buf, JDIMENSION output_col) >+; >+ >+%define dct_table(b) (b)+8 ; void * dct_table >+%define coef_block(b) (b)+12 ; JCOEFPTR coef_block >+%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf >+%define output_col(b) (b)+20 ; JDIMENSION output_col >+ >+%define original_ebp ebp+0 >+%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] >+%define WK_NUM 2 >+%define workspace wk(0)-DCTSIZE2*SIZEOF_FAST_FLOAT >+ ; FAST_FLOAT workspace[DCTSIZE2] >+ >+ align 16 >+ global EXTN(jsimd_idct_float_sse) >+ >+EXTN(jsimd_idct_float_sse): >+ push ebp >+ mov eax,esp ; eax = original ebp >+ sub esp, byte 4 >+ and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits >+ mov [esp],eax >+ mov ebp,esp ; ebp = aligned ebp >+ lea esp, [workspace] >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+ push esi >+ push edi >+ >+ get_GOT ebx ; get GOT address >+ >+ ; ---- Pass 1: process columns from input, store into work array. >+ >+; mov eax, [original_ebp] >+ mov edx, POINTER [dct_table(eax)] ; quantptr >+ mov esi, JCOEFPTR [coef_block(eax)] ; inptr >+ lea edi, [workspace] ; FAST_FLOAT * wsptr >+ mov ecx, DCTSIZE/4 ; ctr >+ alignx 16,7 >+.columnloop: >+%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE >+ mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ jnz near .columnDCT >+ >+ movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ por mm1, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ por mm1, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ por mm0, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ por mm1,mm0 >+ packsswb mm1,mm1 >+ movd eax,mm1 >+ test eax,eax >+ jnz short .columnDCT >+ >+ ; -- AC terms all zero >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ >+ punpckhwd mm1,mm0 ; mm1=(** 02 ** 03) >+ punpcklwd mm0,mm0 ; mm0=(00 00 01 01) >+ psrad mm1,(DWORD_BIT-WORD_BIT) ; mm1=in0H=(02 03) >+ psrad mm0,(DWORD_BIT-WORD_BIT) ; mm0=in0L=(00 01) >+ cvtpi2ps xmm3,mm1 ; xmm3=(02 03 ** **) >+ cvtpi2ps xmm0,mm0 ; xmm0=(00 01 ** **) >+ movlhps xmm0,xmm3 ; xmm0=in0=(00 01 02 03) >+ >+ mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movaps xmm1,xmm0 >+ movaps xmm2,xmm0 >+ movaps xmm3,xmm0 >+ >+ shufps xmm0,xmm0,0x00 ; xmm0=(00 00 00 00) >+ shufps xmm1,xmm1,0x55 ; xmm1=(01 01 01 01) >+ shufps xmm2,xmm2,0xAA ; xmm2=(02 02 02 02) >+ shufps xmm3,xmm3,0xFF ; xmm3=(03 03 03 03) >+ >+ movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm0 >+ movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm2 >+ movaps XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm2 >+ movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm3 >+ movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3 >+ jmp near .nextcolumn >+ alignx 16,7 >+%endif >+.columnDCT: >+ >+ ; -- Even part >+ >+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)] >+ movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_JCOEF)] >+ movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)] >+ >+ punpckhwd mm4,mm0 ; mm4=(** 02 ** 03) >+ punpcklwd mm0,mm0 ; mm0=(00 00 01 01) >+ punpckhwd mm5,mm1 ; mm5=(** 22 ** 23) >+ punpcklwd mm1,mm1 ; mm1=(20 20 21 21) >+ >+ psrad mm4,(DWORD_BIT-WORD_BIT) ; mm4=in0H=(02 03) >+ psrad mm0,(DWORD_BIT-WORD_BIT) ; mm0=in0L=(00 01) >+ cvtpi2ps xmm4,mm4 ; xmm4=(02 03 ** **) >+ cvtpi2ps xmm0,mm0 ; xmm0=(00 01 ** **) >+ psrad mm5,(DWORD_BIT-WORD_BIT) ; mm5=in2H=(22 23) >+ psrad mm1,(DWORD_BIT-WORD_BIT) ; mm1=in2L=(20 21) >+ cvtpi2ps xmm5,mm5 ; xmm5=(22 23 ** **) >+ cvtpi2ps xmm1,mm1 ; xmm1=(20 21 ** **) >+ >+ punpckhwd mm6,mm2 ; mm6=(** 42 ** 43) >+ punpcklwd mm2,mm2 ; mm2=(40 40 41 41) >+ punpckhwd mm7,mm3 ; mm7=(** 62 ** 63) >+ punpcklwd mm3,mm3 ; mm3=(60 60 61 61) >+ >+ psrad mm6,(DWORD_BIT-WORD_BIT) ; mm6=in4H=(42 43) >+ psrad mm2,(DWORD_BIT-WORD_BIT) ; mm2=in4L=(40 41) >+ cvtpi2ps xmm6,mm6 ; xmm6=(42 43 ** **) >+ cvtpi2ps xmm2,mm2 ; xmm2=(40 41 ** **) >+ psrad mm7,(DWORD_BIT-WORD_BIT) ; mm7=in6H=(62 63) >+ psrad mm3,(DWORD_BIT-WORD_BIT) ; mm3=in6L=(60 61) >+ cvtpi2ps xmm7,mm7 ; xmm7=(62 63 ** **) >+ cvtpi2ps xmm3,mm3 ; xmm3=(60 61 ** **) >+ >+ movlhps xmm0,xmm4 ; xmm0=in0=(00 01 02 03) >+ movlhps xmm1,xmm5 ; xmm1=in2=(20 21 22 23) >+ mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movlhps xmm2,xmm6 ; xmm2=in4=(40 41 42 43) >+ movlhps xmm3,xmm7 ; xmm3=in6=(60 61 62 63) >+ mulps xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movaps xmm4,xmm0 >+ movaps xmm5,xmm1 >+ subps xmm0,xmm2 ; xmm0=tmp11 >+ subps xmm1,xmm3 >+ addps xmm4,xmm2 ; xmm4=tmp10 >+ addps xmm5,xmm3 ; xmm5=tmp13 >+ >+ mulps xmm1,[GOTOFF(ebx,PD_1_414)] >+ subps xmm1,xmm5 ; xmm1=tmp12 >+ >+ movaps xmm6,xmm4 >+ movaps xmm7,xmm0 >+ subps xmm4,xmm5 ; xmm4=tmp3 >+ subps xmm0,xmm1 ; xmm0=tmp2 >+ addps xmm6,xmm5 ; xmm6=tmp0 >+ addps xmm7,xmm1 ; xmm7=tmp1 >+ >+ movaps XMMWORD [wk(1)], xmm4 ; tmp3 >+ movaps XMMWORD [wk(0)], xmm0 ; tmp2 >+ >+ ; -- Odd part >+ >+ movq mm4, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)] >+ movq mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)] >+ movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)] >+ movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)] >+ >+ punpckhwd mm6,mm4 ; mm6=(** 12 ** 13) >+ punpcklwd mm4,mm4 ; mm4=(10 10 11 11) >+ punpckhwd mm2,mm0 ; mm2=(** 32 ** 33) >+ punpcklwd mm0,mm0 ; mm0=(30 30 31 31) >+ >+ psrad mm6,(DWORD_BIT-WORD_BIT) ; mm6=in1H=(12 13) >+ psrad mm4,(DWORD_BIT-WORD_BIT) ; mm4=in1L=(10 11) >+ cvtpi2ps xmm4,mm6 ; xmm4=(12 13 ** **) >+ cvtpi2ps xmm2,mm4 ; xmm2=(10 11 ** **) >+ psrad mm2,(DWORD_BIT-WORD_BIT) ; mm2=in3H=(32 33) >+ psrad mm0,(DWORD_BIT-WORD_BIT) ; mm0=in3L=(30 31) >+ cvtpi2ps xmm0,mm2 ; xmm0=(32 33 ** **) >+ cvtpi2ps xmm3,mm0 ; xmm3=(30 31 ** **) >+ >+ punpckhwd mm7,mm5 ; mm7=(** 52 ** 53) >+ punpcklwd mm5,mm5 ; mm5=(50 50 51 51) >+ punpckhwd mm3,mm1 ; mm3=(** 72 ** 73) >+ punpcklwd mm1,mm1 ; mm1=(70 70 71 71) >+ >+ movlhps xmm2,xmm4 ; xmm2=in1=(10 11 12 13) >+ movlhps xmm3,xmm0 ; xmm3=in3=(30 31 32 33) >+ >+ psrad mm7,(DWORD_BIT-WORD_BIT) ; mm7=in5H=(52 53) >+ psrad mm5,(DWORD_BIT-WORD_BIT) ; mm5=in5L=(50 51) >+ cvtpi2ps xmm4,mm7 ; xmm4=(52 53 ** **) >+ cvtpi2ps xmm5,mm5 ; xmm5=(50 51 ** **) >+ psrad mm3,(DWORD_BIT-WORD_BIT) ; mm3=in7H=(72 73) >+ psrad mm1,(DWORD_BIT-WORD_BIT) ; mm1=in7L=(70 71) >+ cvtpi2ps xmm0,mm3 ; xmm0=(72 73 ** **) >+ cvtpi2ps xmm1,mm1 ; xmm1=(70 71 ** **) >+ >+ mulps xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movlhps xmm5,xmm4 ; xmm5=in5=(50 51 52 53) >+ movlhps xmm1,xmm0 ; xmm1=in7=(70 71 72 73) >+ mulps xmm5, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ mulps xmm1, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_FLOAT_MULT_TYPE)] >+ >+ movaps xmm4,xmm2 >+ movaps xmm0,xmm5 >+ addps xmm2,xmm1 ; xmm2=z11 >+ addps xmm5,xmm3 ; xmm5=z13 >+ subps xmm4,xmm1 ; xmm4=z12 >+ subps xmm0,xmm3 ; xmm0=z10 >+ >+ movaps xmm1,xmm2 >+ subps xmm2,xmm5 >+ addps xmm1,xmm5 ; xmm1=tmp7 >+ >+ mulps xmm2,[GOTOFF(ebx,PD_1_414)] ; xmm2=tmp11 >+ >+ movaps xmm3,xmm0 >+ addps xmm0,xmm4 >+ mulps xmm0,[GOTOFF(ebx,PD_1_847)] ; xmm0=z5 >+ mulps xmm3,[GOTOFF(ebx,PD_M2_613)] ; xmm3=(z10 * -2.613125930) >+ mulps xmm4,[GOTOFF(ebx,PD_1_082)] ; xmm4=(z12 * 1.082392200) >+ addps xmm3,xmm0 ; xmm3=tmp12 >+ subps xmm4,xmm0 ; xmm4=tmp10 >+ >+ ; -- Final output stage >+ >+ subps xmm3,xmm1 ; xmm3=tmp6 >+ movaps xmm5,xmm6 >+ movaps xmm0,xmm7 >+ addps xmm6,xmm1 ; xmm6=data0=(00 01 02 03) >+ addps xmm7,xmm3 ; xmm7=data1=(10 11 12 13) >+ subps xmm5,xmm1 ; xmm5=data7=(70 71 72 73) >+ subps xmm0,xmm3 ; xmm0=data6=(60 61 62 63) >+ subps xmm2,xmm3 ; xmm2=tmp5 >+ >+ movaps xmm1,xmm6 ; transpose coefficients(phase 1) >+ unpcklps xmm6,xmm7 ; xmm6=(00 10 01 11) >+ unpckhps xmm1,xmm7 ; xmm1=(02 12 03 13) >+ movaps xmm3,xmm0 ; transpose coefficients(phase 1) >+ unpcklps xmm0,xmm5 ; xmm0=(60 70 61 71) >+ unpckhps xmm3,xmm5 ; xmm3=(62 72 63 73) >+ >+ movaps xmm7, XMMWORD [wk(0)] ; xmm7=tmp2 >+ movaps xmm5, XMMWORD [wk(1)] ; xmm5=tmp3 >+ >+ movaps XMMWORD [wk(0)], xmm0 ; wk(0)=(60 70 61 71) >+ movaps XMMWORD [wk(1)], xmm3 ; wk(1)=(62 72 63 73) >+ >+ addps xmm4,xmm2 ; xmm4=tmp4 >+ movaps xmm0,xmm7 >+ movaps xmm3,xmm5 >+ addps xmm7,xmm2 ; xmm7=data2=(20 21 22 23) >+ addps xmm5,xmm4 ; xmm5=data4=(40 41 42 43) >+ subps xmm0,xmm2 ; xmm0=data5=(50 51 52 53) >+ subps xmm3,xmm4 ; xmm3=data3=(30 31 32 33) >+ >+ movaps xmm2,xmm7 ; transpose coefficients(phase 1) >+ unpcklps xmm7,xmm3 ; xmm7=(20 30 21 31) >+ unpckhps xmm2,xmm3 ; xmm2=(22 32 23 33) >+ movaps xmm4,xmm5 ; transpose coefficients(phase 1) >+ unpcklps xmm5,xmm0 ; xmm5=(40 50 41 51) >+ unpckhps xmm4,xmm0 ; xmm4=(42 52 43 53) >+ >+ movaps xmm3,xmm6 ; transpose coefficients(phase 2) >+ unpcklps2 xmm6,xmm7 ; xmm6=(00 10 20 30) >+ unpckhps2 xmm3,xmm7 ; xmm3=(01 11 21 31) >+ movaps xmm0,xmm1 ; transpose coefficients(phase 2) >+ unpcklps2 xmm1,xmm2 ; xmm1=(02 12 22 32) >+ unpckhps2 xmm0,xmm2 ; xmm0=(03 13 23 33) >+ >+ movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71) >+ movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73) >+ >+ movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm6 >+ movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm3 >+ movaps XMMWORD [XMMBLOCK(2,0,edi,SIZEOF_FAST_FLOAT)], xmm1 >+ movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm0 >+ >+ movaps xmm6,xmm5 ; transpose coefficients(phase 2) >+ unpcklps2 xmm5,xmm7 ; xmm5=(40 50 60 70) >+ unpckhps2 xmm6,xmm7 ; xmm6=(41 51 61 71) >+ movaps xmm3,xmm4 ; transpose coefficients(phase 2) >+ unpcklps2 xmm4,xmm2 ; xmm4=(42 52 62 72) >+ unpckhps2 xmm3,xmm2 ; xmm3=(43 53 63 73) >+ >+ movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm5 >+ movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6 >+ movaps XMMWORD [XMMBLOCK(2,1,edi,SIZEOF_FAST_FLOAT)], xmm4 >+ movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3 >+ >+.nextcolumn: >+ add esi, byte 4*SIZEOF_JCOEF ; coef_block >+ add edx, byte 4*SIZEOF_FLOAT_MULT_TYPE ; quantptr >+ add edi, 4*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr >+ dec ecx ; ctr >+ jnz near .columnloop >+ >+ ; -- Prefetch the next coefficient block >+ >+ prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32] >+ prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32] >+ prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32] >+ prefetchnta [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32] >+ >+ ; ---- Pass 2: process rows from work array, store into output array. >+ >+ mov eax, [original_ebp] >+ lea esi, [workspace] ; FAST_FLOAT * wsptr >+ mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *) >+ mov eax, JDIMENSION [output_col(eax)] >+ mov ecx, DCTSIZE/4 ; ctr >+ alignx 16,7 >+.rowloop: >+ >+ ; -- Even part >+ >+ movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_FAST_FLOAT)] >+ >+ movaps xmm4,xmm0 >+ movaps xmm5,xmm1 >+ subps xmm0,xmm2 ; xmm0=tmp11 >+ subps xmm1,xmm3 >+ addps xmm4,xmm2 ; xmm4=tmp10 >+ addps xmm5,xmm3 ; xmm5=tmp13 >+ >+ mulps xmm1,[GOTOFF(ebx,PD_1_414)] >+ subps xmm1,xmm5 ; xmm1=tmp12 >+ >+ movaps xmm6,xmm4 >+ movaps xmm7,xmm0 >+ subps xmm4,xmm5 ; xmm4=tmp3 >+ subps xmm0,xmm1 ; xmm0=tmp2 >+ addps xmm6,xmm5 ; xmm6=tmp0 >+ addps xmm7,xmm1 ; xmm7=tmp1 >+ >+ movaps XMMWORD [wk(1)], xmm4 ; tmp3 >+ movaps XMMWORD [wk(0)], xmm0 ; tmp2 >+ >+ ; -- Odd part >+ >+ movaps xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm3, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm5, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_FAST_FLOAT)] >+ movaps xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_FAST_FLOAT)] >+ >+ movaps xmm4,xmm2 >+ movaps xmm0,xmm5 >+ addps xmm2,xmm1 ; xmm2=z11 >+ addps xmm5,xmm3 ; xmm5=z13 >+ subps xmm4,xmm1 ; xmm4=z12 >+ subps xmm0,xmm3 ; xmm0=z10 >+ >+ movaps xmm1,xmm2 >+ subps xmm2,xmm5 >+ addps xmm1,xmm5 ; xmm1=tmp7 >+ >+ mulps xmm2,[GOTOFF(ebx,PD_1_414)] ; xmm2=tmp11 >+ >+ movaps xmm3,xmm0 >+ addps xmm0,xmm4 >+ mulps xmm0,[GOTOFF(ebx,PD_1_847)] ; xmm0=z5 >+ mulps xmm3,[GOTOFF(ebx,PD_M2_613)] ; xmm3=(z10 * -2.613125930) >+ mulps xmm4,[GOTOFF(ebx,PD_1_082)] ; xmm4=(z12 * 1.082392200) >+ addps xmm3,xmm0 ; xmm3=tmp12 >+ subps xmm4,xmm0 ; xmm4=tmp10 >+ >+ ; -- Final output stage >+ >+ subps xmm3,xmm1 ; xmm3=tmp6 >+ movaps xmm5,xmm6 >+ movaps xmm0,xmm7 >+ addps xmm6,xmm1 ; xmm6=data0=(00 10 20 30) >+ addps xmm7,xmm3 ; xmm7=data1=(01 11 21 31) >+ subps xmm5,xmm1 ; xmm5=data7=(07 17 27 37) >+ subps xmm0,xmm3 ; xmm0=data6=(06 16 26 36) >+ subps xmm2,xmm3 ; xmm2=tmp5 >+ >+ movaps xmm1,[GOTOFF(ebx,PD_0_125)] ; xmm1=[PD_0_125] >+ >+ mulps xmm6,xmm1 ; descale(1/8) >+ mulps xmm7,xmm1 ; descale(1/8) >+ mulps xmm5,xmm1 ; descale(1/8) >+ mulps xmm0,xmm1 ; descale(1/8) >+ >+ movhlps xmm3,xmm6 >+ movhlps xmm1,xmm7 >+ cvtps2pi mm0,xmm6 ; round to int32, mm0=data0L=(00 10) >+ cvtps2pi mm1,xmm7 ; round to int32, mm1=data1L=(01 11) >+ cvtps2pi mm2,xmm3 ; round to int32, mm2=data0H=(20 30) >+ cvtps2pi mm3,xmm1 ; round to int32, mm3=data1H=(21 31) >+ packssdw mm0,mm2 ; mm0=data0=(00 10 20 30) >+ packssdw mm1,mm3 ; mm1=data1=(01 11 21 31) >+ >+ movhlps xmm6,xmm5 >+ movhlps xmm7,xmm0 >+ cvtps2pi mm4,xmm5 ; round to int32, mm4=data7L=(07 17) >+ cvtps2pi mm5,xmm0 ; round to int32, mm5=data6L=(06 16) >+ cvtps2pi mm6,xmm6 ; round to int32, mm6=data7H=(27 37) >+ cvtps2pi mm7,xmm7 ; round to int32, mm7=data6H=(26 36) >+ packssdw mm4,mm6 ; mm4=data7=(07 17 27 37) >+ packssdw mm5,mm7 ; mm5=data6=(06 16 26 36) >+ >+ packsswb mm0,mm5 ; mm0=(00 10 20 30 06 16 26 36) >+ packsswb mm1,mm4 ; mm1=(01 11 21 31 07 17 27 37) >+ >+ movaps xmm3, XMMWORD [wk(0)] ; xmm3=tmp2 >+ movaps xmm1, XMMWORD [wk(1)] ; xmm1=tmp3 >+ >+ movaps xmm6,[GOTOFF(ebx,PD_0_125)] ; xmm6=[PD_0_125] >+ >+ addps xmm4,xmm2 ; xmm4=tmp4 >+ movaps xmm5,xmm3 >+ movaps xmm0,xmm1 >+ addps xmm3,xmm2 ; xmm3=data2=(02 12 22 32) >+ addps xmm1,xmm4 ; xmm1=data4=(04 14 24 34) >+ subps xmm5,xmm2 ; xmm5=data5=(05 15 25 35) >+ subps xmm0,xmm4 ; xmm0=data3=(03 13 23 33) >+ >+ mulps xmm3,xmm6 ; descale(1/8) >+ mulps xmm1,xmm6 ; descale(1/8) >+ mulps xmm5,xmm6 ; descale(1/8) >+ mulps xmm0,xmm6 ; descale(1/8) >+ >+ movhlps xmm7,xmm3 >+ movhlps xmm2,xmm1 >+ cvtps2pi mm2,xmm3 ; round to int32, mm2=data2L=(02 12) >+ cvtps2pi mm3,xmm1 ; round to int32, mm3=data4L=(04 14) >+ cvtps2pi mm6,xmm7 ; round to int32, mm6=data2H=(22 32) >+ cvtps2pi mm7,xmm2 ; round to int32, mm7=data4H=(24 34) >+ packssdw mm2,mm6 ; mm2=data2=(02 12 22 32) >+ packssdw mm3,mm7 ; mm3=data4=(04 14 24 34) >+ >+ movhlps xmm4,xmm5 >+ movhlps xmm6,xmm0 >+ cvtps2pi mm5,xmm5 ; round to int32, mm5=data5L=(05 15) >+ cvtps2pi mm4,xmm0 ; round to int32, mm4=data3L=(03 13) >+ cvtps2pi mm6,xmm4 ; round to int32, mm6=data5H=(25 35) >+ cvtps2pi mm7,xmm6 ; round to int32, mm7=data3H=(23 33) >+ packssdw mm5,mm6 ; mm5=data5=(05 15 25 35) >+ packssdw mm4,mm7 ; mm4=data3=(03 13 23 33) >+ >+ movq mm6,[GOTOFF(ebx,PB_CENTERJSAMP)] ; mm6=[PB_CENTERJSAMP] >+ >+ packsswb mm2,mm3 ; mm2=(02 12 22 32 04 14 24 34) >+ packsswb mm4,mm5 ; mm4=(03 13 23 33 05 15 25 35) >+ >+ paddb mm0,mm6 >+ paddb mm1,mm6 >+ paddb mm2,mm6 >+ paddb mm4,mm6 >+ >+ movq mm7,mm0 ; transpose coefficients(phase 1) >+ punpcklbw mm0,mm1 ; mm0=(00 01 10 11 20 21 30 31) >+ punpckhbw mm7,mm1 ; mm7=(06 07 16 17 26 27 36 37) >+ movq mm3,mm2 ; transpose coefficients(phase 1) >+ punpcklbw mm2,mm4 ; mm2=(02 03 12 13 22 23 32 33) >+ punpckhbw mm3,mm4 ; mm3=(04 05 14 15 24 25 34 35) >+ >+ movq mm5,mm0 ; transpose coefficients(phase 2) >+ punpcklwd mm0,mm2 ; mm0=(00 01 02 03 10 11 12 13) >+ punpckhwd mm5,mm2 ; mm5=(20 21 22 23 30 31 32 33) >+ movq mm6,mm3 ; transpose coefficients(phase 2) >+ punpcklwd mm3,mm7 ; mm3=(04 05 06 07 14 15 16 17) >+ punpckhwd mm6,mm7 ; mm6=(24 25 26 27 34 35 36 37) >+ >+ movq mm1,mm0 ; transpose coefficients(phase 3) >+ punpckldq mm0,mm3 ; mm0=(00 01 02 03 04 05 06 07) >+ punpckhdq mm1,mm3 ; mm1=(10 11 12 13 14 15 16 17) >+ movq mm4,mm5 ; transpose coefficients(phase 3) >+ punpckldq mm5,mm6 ; mm5=(20 21 22 23 24 25 26 27) >+ punpckhdq mm4,mm6 ; mm4=(30 31 32 33 34 35 36 37) >+ >+ pushpic ebx ; save GOT address >+ >+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] >+ mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW] >+ movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm0 >+ movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm1 >+ mov edx, JSAMPROW [edi+2*SIZEOF_JSAMPROW] >+ mov ebx, JSAMPROW [edi+3*SIZEOF_JSAMPROW] >+ movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm5 >+ movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm4 >+ >+ poppic ebx ; restore GOT address >+ >+ add esi, byte 4*SIZEOF_FAST_FLOAT ; wsptr >+ add edi, byte 4*SIZEOF_JSAMPROW >+ dec ecx ; ctr >+ jnz near .rowloop >+ >+ emms ; empty MMX state >+ >+ pop edi >+ pop esi >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ mov esp,ebp ; esp <- aligned ebp >+ pop esp ; esp <- original ebp >+ pop ebp >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jsimd.h b/modules/libjpeg-turbo/simd/jsimd.h >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jsimd.h >@@ -0,0 +1,503 @@ >+/* >+ * simd/jsimd.h >+ * >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+ * >+ * Based on the x86 SIMD extension for IJG JPEG library, >+ * Copyright (C) 1999-2006, MIYASAKA Masaru. >+ * >+ */ >+ >+/* Bitmask for supported acceleration methods */ >+ >+#define JSIMD_NONE 0x00 >+#define JSIMD_MMX 0x01 >+#define JSIMD_3DNOW 0x02 >+#define JSIMD_SSE 0x04 >+#define JSIMD_SSE2 0x08 >+ >+/* Short forms of external names for systems with brain-damaged linkers. */ >+ >+#ifdef NEED_SHORT_EXTERNAL_NAMES >+#define jpeg_simd_cpu_support jSiCpuSupport >+#define jsimd_rgb_ycc_convert_mmx jSRGBYCCM >+#define jsimd_extrgb_ycc_convert_mmx jSEXTRGBYCCM >+#define jsimd_extrgbx_ycc_convert_mmx jSEXTRGBXYCCM >+#define jsimd_extbgr_ycc_convert_mmx jSEXTBGRYCCM >+#define jsimd_extbgrx_ycc_convert_mmx jSEXTBGRXYCCM >+#define jsimd_extxbgr_ycc_convert_mmx jSEXTXBGRYCCM >+#define jsimd_extxrgb_ycc_convert_mmx jSEXTXRGBYCCM >+#define jsimd_ycc_rgb_convert_mmx jSYCCRGBM >+#define jsimd_ycc_extrgb_convert_mmx jSYCCEXTRGBM >+#define jsimd_ycc_extrgbx_convert_mmx jSYCCEXTRGBXM >+#define jsimd_ycc_extbgr_convert_mmx jSYCCEXTBGRM >+#define jsimd_ycc_extbgrx_convert_mmx jSYCCEXTBGRXM >+#define jsimd_ycc_extxbgr_convert_mmx jSYCCEXTXBGRM >+#define jsimd_ycc_extxrgb_convert_mmx jSYCCEXTXRGBM >+#define jconst_rgb_ycc_convert_sse2 jSCRGBYCCS2 >+#define jsimd_rgb_ycc_convert_sse2 jSRGBYCCS2 >+#define jsimd_extrgb_ycc_convert_sse2 jSEXTRGBYCCS2 >+#define jsimd_extrgbx_ycc_convert_sse2 jSEXTRGBXYCCS2 >+#define jsimd_extbgr_ycc_convert_sse2 jSEXTBGRYCCS2 >+#define jsimd_extbgrx_ycc_convert_sse2 jSEXTBGRXYCCS2 >+#define jsimd_extxbgr_ycc_convert_sse2 jSEXTXBGRYCCS2 >+#define jsimd_extxrgb_ycc_convert_sse2 jSEXTXRGBYCCS2 >+#define jconst_ycc_rgb_convert_sse2 jSCYCCRGBS2 >+#define jsimd_ycc_rgb_convert_sse2 jSYCCRGBS2 >+#define jsimd_ycc_extrgb_convert_sse2 jSYCCEXTRGBS2 >+#define jsimd_ycc_extrgbx_convert_sse2 jSYCCEXTRGBXS2 >+#define jsimd_ycc_extbgr_convert_sse2 jSYCCEXTBGRS2 >+#define jsimd_ycc_extbgrx_convert_sse2 jSYCCEXTBGRXS2 >+#define jsimd_ycc_extxbgr_convert_sse2 jSYCCEXTXBGRS2 >+#define jsimd_ycc_extxrgb_convert_sse2 jSYCCEXTXRGBS2 >+#define jsimd_h2v2_downsample_mmx jSDnH2V2M >+#define jsimd_h2v1_downsample_mmx jSDnH2V1M >+#define jsimd_h2v2_downsample_sse2 jSDnH2V2S2 >+#define jsimd_h2v1_downsample_sse2 jSDnH2V1S2 >+#define jsimd_h2v2_upsample_mmx jSUpH2V2M >+#define jsimd_h2v1_upsample_mmx jSUpH2V1M >+#define jsimd_h2v2_fancy_upsample_mmx jSFUpH2V2M >+#define jsimd_h2v1_fancy_upsample_mmx jSFUpH2V1M >+#define jsimd_h2v2_merged_upsample_mmx jSMUpH2V2M >+#define jsimd_h2v2_extrgb_merged_upsample_mmx jSMUpH2V2EXTRGBM >+#define jsimd_h2v2_extrgbx_merged_upsample_mmx jSMUpH2V2EXTRGBXM >+#define jsimd_h2v2_extbgr_merged_upsample_mmx jSMUpH2V2EXTBGRM >+#define jsimd_h2v2_extbgrx_merged_upsample_mmx jSMUpH2V2EXTBGRXM >+#define jsimd_h2v2_extxbgr_merged_upsample_mmx jSMUpH2V2EXTXBGRM >+#define jsimd_h2v2_extxrgb_merged_upsample_mmx jSMUpH2V2EXTXRGBM >+#define jsimd_h2v1_merged_upsample_mmx jSMUpH2V1M >+#define jsimd_h2v1_extrgb_merged_upsample_mmx jSMUpH2V1EXTRGBM >+#define jsimd_h2v1_extrgbx_merged_upsample_mmx jSMUpH2V1EXTRGBXM >+#define jsimd_h2v1_extbgr_merged_upsample_mmx jSMUpH2V1EXTBGRM >+#define jsimd_h2v1_extbgrx_merged_upsample_mmx jSMUpH2V1EXTBGRXM >+#define jsimd_h2v1_extxbgr_merged_upsample_mmx jSMUpH2V1EXTXBGRM >+#define jsimd_h2v1_extxrgb_merged_upsample_mmx jSMUpH2V1EXTXRGBM >+#define jsimd_h2v2_upsample_sse2 jSUpH2V2S2 >+#define jsimd_h2v1_upsample_sse2 jSUpH2V1S2 >+#define jconst_fancy_upsample_sse2 jSCFUpS2 >+#define jsimd_h2v2_fancy_upsample_sse2 jSFUpH2V2S2 >+#define jsimd_h2v1_fancy_upsample_sse2 jSFUpH2V1S2 >+#define jconst_merged_upsample_sse2 jSCMUpS2 >+#define jsimd_h2v2_merged_upsample_sse2 jSMUpH2V2S2 >+#define jsimd_h2v2_extrgb_merged_upsample_sse2 jSMUpH2V2EXTRGBS2 >+#define jsimd_h2v2_extrgbx_merged_upsample_sse2 jSMUpH2V2EXTRGBXS2 >+#define jsimd_h2v2_extbgr_merged_upsample_sse2 jSMUpH2V2EXTBGRS2 >+#define jsimd_h2v2_extbgrx_merged_upsample_sse2 jSMUpH2V2EXTBGRXS2 >+#define jsimd_h2v2_extxbgr_merged_upsample_sse2 jSMUpH2V2EXTXBGRS2 >+#define jsimd_h2v2_extxrgb_merged_upsample_sse2 jSMUpH2V2EXTXRGBS2 >+#define jsimd_h2v1_merged_upsample_sse2 jSMUpH2V1S2 >+#define jsimd_h2v1_extrgb_merged_upsample_sse2 jSMUpH2V1EXTRGBS2 >+#define jsimd_h2v1_extrgbx_merged_upsample_sse2 jSMUpH2V1EXTRGBXS2 >+#define jsimd_h2v1_extbgr_merged_upsample_sse2 jSMUpH2V1EXTBGRS2 >+#define jsimd_h2v1_extbgrx_merged_upsample_sse2 jSMUpH2V1EXTBGRXS2 >+#define jsimd_h2v1_extxbgr_merged_upsample_sse2 jSMUpH2V1EXTXBGRS2 >+#define jsimd_h2v1_extxrgb_merged_upsample_sse2 jSMUpH2V1EXTXRGBS2 >+#define jsimd_convsamp_mmx jSConvM >+#define jsimd_convsamp_sse2 jSConvS2 >+#define jsimd_convsamp_float_3dnow jSConvF3D >+#define jsimd_convsamp_float_sse jSConvFS >+#define jsimd_convsamp_float_sse2 jSConvFS2 >+#define jsimd_fdct_islow_mmx jSFDMIS >+#define jsimd_fdct_ifast_mmx jSFDMIF >+#define jconst_fdct_islow_sse2 jSCFDS2IS >+#define jsimd_fdct_islow_sse2 jSFDS2IS >+#define jconst_fdct_ifast_sse2 jSCFDS2IF >+#define jsimd_fdct_ifast_sse2 jSFDS2IF >+#define jsimd_fdct_float_3dnow jSFD3DF >+#define jconst_fdct_float_sse jSCFDSF >+#define jsimd_fdct_float_sse jSFDSF >+#define jsimd_quantize_mmx jSQuantM >+#define jsimd_quantize_sse2 jSQuantS2 >+#define jsimd_quantize_float_3dnow jSQuantF3D >+#define jsimd_quantize_float_sse jSQuantFS >+#define jsimd_quantize_float_sse2 jSQuantFS2 >+#define jsimd_idct_2x2_mmx jSIDM22 >+#define jsimd_idct_4x4_mmx jSIDM44 >+#define jconst_idct_red_sse2 jSCIDS2R >+#define jsimd_idct_2x2_sse2 jSIDS222 >+#define jsimd_idct_4x4_sse2 jSIDS244 >+#define jsimd_idct_islow_mmx jSIDMIS >+#define jsimd_idct_ifast_mmx jSIDMIF >+#define jconst_idct_islow_sse2 jSCIDS2IS >+#define jsimd_idct_islow_sse2 jSIDS2IS >+#define jconst_idct_ifast_sse2 jSCIDS2IF >+#define jsimd_idct_ifast_sse2 jSIDS2IF >+#define jsimd_idct_float_3dnow jSID3DF >+#define jconst_fdct_float_sse jSCIDSF >+#define jsimd_idct_float_sse jSIDSF >+#define jconst_fdct_float_sse2 jSCIDS2F >+#define jsimd_idct_float_sse2 jSIDS2F >+#endif /* NEED_SHORT_EXTERNAL_NAMES */ >+ >+/* SIMD Ext: retrieve SIMD/CPU information */ >+EXTERN(unsigned int) jpeg_simd_cpu_support JPP((void)); >+ >+/* SIMD Color Space Conversion */ >+EXTERN(void) jsimd_rgb_ycc_convert_mmx >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extrgb_ycc_convert_mmx >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extrgbx_ycc_convert_mmx >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extbgr_ycc_convert_mmx >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extbgrx_ycc_convert_mmx >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extxbgr_ycc_convert_mmx >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extxrgb_ycc_convert_mmx >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+ >+EXTERN(void) jsimd_ycc_rgb_convert_mmx >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extrgb_convert_mmx >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extrgbx_convert_mmx >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extbgr_convert_mmx >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extbgrx_convert_mmx >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extxbgr_convert_mmx >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extxrgb_convert_mmx >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+ >+extern const int jconst_rgb_ycc_convert_sse2[]; >+EXTERN(void) jsimd_rgb_ycc_convert_sse2 >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extrgb_ycc_convert_sse2 >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extrgbx_ycc_convert_sse2 >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extbgr_ycc_convert_sse2 >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extbgrx_ycc_convert_sse2 >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extxbgr_ycc_convert_sse2 >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+EXTERN(void) jsimd_extxrgb_ycc_convert_sse2 >+ JPP((JDIMENSION img_width, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows)); >+ >+extern const int jconst_ycc_rgb_convert_sse2[]; >+EXTERN(void) jsimd_ycc_rgb_convert_sse2 >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extrgb_convert_sse2 >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extrgbx_convert_sse2 >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extbgr_convert_sse2 >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extbgrx_convert_sse2 >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extxbgr_convert_sse2 >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+EXTERN(void) jsimd_ycc_extxrgb_convert_sse2 >+ JPP((JDIMENSION out_width, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows)); >+ >+/* SIMD Downsample */ >+EXTERN(void) jsimd_h2v2_downsample_mmx >+ JPP((JDIMENSION image_width, int max_v_samp_factor, >+ JDIMENSION v_samp_factor, JDIMENSION width_blocks, >+ JSAMPARRAY input_data, JSAMPARRAY output_data)); >+EXTERN(void) jsimd_h2v1_downsample_mmx >+ JPP((JDIMENSION image_width, int max_v_samp_factor, >+ JDIMENSION v_samp_factor, JDIMENSION width_blocks, >+ JSAMPARRAY input_data, JSAMPARRAY output_data)); >+ >+EXTERN(void) jsimd_h2v2_downsample_sse2 >+ JPP((JDIMENSION image_width, int max_v_samp_factor, >+ JDIMENSION v_samp_factor, JDIMENSION width_blocks, >+ JSAMPARRAY input_data, JSAMPARRAY output_data)); >+EXTERN(void) jsimd_h2v1_downsample_sse2 >+ JPP((JDIMENSION image_width, int max_v_samp_factor, >+ JDIMENSION v_samp_factor, JDIMENSION width_blocks, >+ JSAMPARRAY input_data, JSAMPARRAY output_data)); >+ >+/* SIMD Upsample */ >+EXTERN(void) jsimd_h2v2_upsample_mmx >+ JPP((int max_v_samp_factor, JDIMENSION output_width, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+EXTERN(void) jsimd_h2v1_upsample_mmx >+ JPP((int max_v_samp_factor, JDIMENSION output_width, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+ >+EXTERN(void) jsimd_h2v2_fancy_upsample_mmx >+ JPP((int max_v_samp_factor, JDIMENSION downsampled_width, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+EXTERN(void) jsimd_h2v1_fancy_upsample_mmx >+ JPP((int max_v_samp_factor, JDIMENSION downsampled_width, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+ >+EXTERN(void) jsimd_h2v2_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extrgb_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extrgbx_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extbgr_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extbgrx_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extxbgr_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extrgb_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extrgbx_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extbgr_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extbgrx_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extxbgr_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extxrgb_merged_upsample_mmx >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+ >+EXTERN(void) jsimd_h2v2_upsample_sse2 >+ JPP((int max_v_samp_factor, JDIMENSION output_width, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+EXTERN(void) jsimd_h2v1_upsample_sse2 >+ JPP((int max_v_samp_factor, JDIMENSION output_width, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+ >+extern const int jconst_fancy_upsample_sse2[]; >+EXTERN(void) jsimd_h2v2_fancy_upsample_sse2 >+ JPP((int max_v_samp_factor, JDIMENSION downsampled_width, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+EXTERN(void) jsimd_h2v1_fancy_upsample_sse2 >+ JPP((int max_v_samp_factor, JDIMENSION downsampled_width, >+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); >+ >+extern const int jconst_merged_upsample_sse2[]; >+EXTERN(void) jsimd_h2v2_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extrgb_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extrgbx_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extbgr_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extbgrx_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extxbgr_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v2_extxrgb_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extrgb_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extrgbx_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extbgr_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extbgrx_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extxbgr_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+EXTERN(void) jsimd_h2v1_extxrgb_merged_upsample_sse2 >+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)); >+ >+/* SIMD Sample Conversion */ >+EXTERN(void) jsimd_convsamp_mmx JPP((JSAMPARRAY sample_data, >+ JDIMENSION start_col, >+ DCTELEM * workspace)); >+ >+EXTERN(void) jsimd_convsamp_sse2 JPP((JSAMPARRAY sample_data, >+ JDIMENSION start_col, >+ DCTELEM * workspace)); >+ >+EXTERN(void) jsimd_convsamp_float_3dnow JPP((JSAMPARRAY sample_data, >+ JDIMENSION start_col, >+ FAST_FLOAT * workspace)); >+ >+EXTERN(void) jsimd_convsamp_float_sse JPP((JSAMPARRAY sample_data, >+ JDIMENSION start_col, >+ FAST_FLOAT * workspace)); >+ >+EXTERN(void) jsimd_convsamp_float_sse2 JPP((JSAMPARRAY sample_data, >+ JDIMENSION start_col, >+ FAST_FLOAT * workspace)); >+ >+/* SIMD Forward DCT */ >+EXTERN(void) jsimd_fdct_islow_mmx JPP((DCTELEM * data)); >+EXTERN(void) jsimd_fdct_ifast_mmx JPP((DCTELEM * data)); >+ >+extern const int jconst_fdct_ifast_sse2[]; >+EXTERN(void) jsimd_fdct_islow_sse2 JPP((DCTELEM * data)); >+extern const int jconst_fdct_islow_sse2[]; >+EXTERN(void) jsimd_fdct_ifast_sse2 JPP((DCTELEM * data)); >+ >+EXTERN(void) jsimd_fdct_float_3dnow JPP((FAST_FLOAT * data)); >+ >+extern const int jconst_fdct_float_sse[]; >+EXTERN(void) jsimd_fdct_float_sse JPP((FAST_FLOAT * data)); >+ >+/* SIMD Quantization */ >+EXTERN(void) jsimd_quantize_mmx JPP((JCOEFPTR coef_block, >+ DCTELEM * divisors, >+ DCTELEM * workspace)); >+ >+EXTERN(void) jsimd_quantize_sse2 JPP((JCOEFPTR coef_block, >+ DCTELEM * divisors, >+ DCTELEM * workspace)); >+ >+EXTERN(void) jsimd_quantize_float_3dnow JPP((JCOEFPTR coef_block, >+ FAST_FLOAT * divisors, >+ FAST_FLOAT * workspace)); >+ >+EXTERN(void) jsimd_quantize_float_sse JPP((JCOEFPTR coef_block, >+ FAST_FLOAT * divisors, >+ FAST_FLOAT * workspace)); >+ >+EXTERN(void) jsimd_quantize_float_sse2 JPP((JCOEFPTR coef_block, >+ FAST_FLOAT * divisors, >+ FAST_FLOAT * workspace)); >+ >+/* SIMD Reduced Inverse DCT */ >+EXTERN(void) jsimd_idct_2x2_mmx JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+EXTERN(void) jsimd_idct_4x4_mmx JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+ >+extern const int jconst_idct_red_sse2[]; >+EXTERN(void) jsimd_idct_2x2_sse2 JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+EXTERN(void) jsimd_idct_4x4_sse2 JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+ >+/* SIMD Inverse DCT */ >+EXTERN(void) jsimd_idct_islow_mmx JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+EXTERN(void) jsimd_idct_ifast_mmx JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+ >+extern const int jconst_idct_islow_sse2[]; >+EXTERN(void) jsimd_idct_islow_sse2 JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+extern const int jconst_idct_ifast_sse2[]; >+EXTERN(void) jsimd_idct_ifast_sse2 JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+ >+EXTERN(void) jsimd_idct_float_3dnow JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+ >+extern const int jconst_idct_float_sse[]; >+EXTERN(void) jsimd_idct_float_sse JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+ >+extern const int jconst_idct_float_sse2[]; >+EXTERN(void) jsimd_idct_float_sse2 JPP((void * dct_table, >+ JCOEFPTR coef_block, >+ JSAMPARRAY output_buf, >+ JDIMENSION output_col)); >+ >diff --git a/modules/libjpeg-turbo/simd/jsimd_i386.c b/modules/libjpeg-turbo/simd/jsimd_i386.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jsimd_i386.c >@@ -0,0 +1,956 @@ >+/* >+ * jsimd_i386.c >+ * >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+ * Copyright 2009 D. R. Commander >+ * >+ * Based on the x86 SIMD extension for IJG JPEG library, >+ * Copyright (C) 1999-2006, MIYASAKA Masaru. >+ * >+ * This file contains the interface between the "normal" portions >+ * of the library and the SIMD implementations when running on a >+ * 32-bit x86 architecture. >+ */ >+ >+#define JPEG_INTERNALS >+#include "../jinclude.h" >+#include "../jpeglib.h" >+#include "../jsimd.h" >+#include "../jdct.h" >+#include "../jsimddct.h" >+#include "jsimd.h" >+ >+/* >+ * In the PIC cases, we have no guarantee that constants will keep >+ * their alignment. This macro allows us to verify it at runtime. >+ */ >+#define IS_ALIGNED(ptr, order) (((unsigned)ptr & ((1 << order) - 1)) == 0) >+ >+#define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */ >+ >+static unsigned int simd_support = ~0; >+ >+/* >+ * Check what SIMD accelerations are supported. >+ * >+ * FIXME: This code is racy under a multi-threaded environment. >+ */ >+LOCAL(void) >+init_simd (void) >+{ >+ char *env = NULL; >+ >+ if (simd_support != ~0) >+ return; >+ >+ simd_support = jpeg_simd_cpu_support(); >+ >+ /* Force different settings through environment variables */ >+ env = getenv("JSIMD_FORCEMMX"); >+ if ((env != NULL) && (strcmp(env, "1") == 0)) >+ simd_support &= JSIMD_MMX; >+ env = getenv("JSIMD_FORCE3DNOW"); >+ if ((env != NULL) && (strcmp(env, "1") == 0)) >+ simd_support &= JSIMD_3DNOW|JSIMD_MMX; >+ env = getenv("JSIMD_FORCESSE"); >+ if ((env != NULL) && (strcmp(env, "1") == 0)) >+ simd_support &= JSIMD_SSE|JSIMD_MMX; >+ env = getenv("JSIMD_FORCESSE2"); >+ if ((env != NULL) && (strcmp(env, "1") == 0)) >+ simd_support &= JSIMD_SSE2; >+} >+ >+GLOBAL(int) >+jsimd_can_rgb_ycc (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_ycc_rgb (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_rgb_ycc_convert (j_compress_ptr cinfo, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows) >+{ >+ void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); >+ void (*mmxfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); >+ >+ switch(cinfo->in_color_space) >+ { >+ case JCS_EXT_RGB: >+ sse2fct=jsimd_extrgb_ycc_convert_sse2; >+ mmxfct=jsimd_extrgb_ycc_convert_mmx; >+ break; >+ case JCS_EXT_RGBX: >+ sse2fct=jsimd_extrgbx_ycc_convert_sse2; >+ mmxfct=jsimd_extrgbx_ycc_convert_mmx; >+ break; >+ case JCS_EXT_BGR: >+ sse2fct=jsimd_extbgr_ycc_convert_sse2; >+ mmxfct=jsimd_extbgr_ycc_convert_mmx; >+ break; >+ case JCS_EXT_BGRX: >+ sse2fct=jsimd_extbgrx_ycc_convert_sse2; >+ mmxfct=jsimd_extbgrx_ycc_convert_mmx; >+ break; >+ case JCS_EXT_XBGR: >+ sse2fct=jsimd_extxbgr_ycc_convert_sse2; >+ mmxfct=jsimd_extxbgr_ycc_convert_mmx; >+ break; >+ case JCS_EXT_XRGB: >+ sse2fct=jsimd_extxrgb_ycc_convert_sse2; >+ mmxfct=jsimd_extxrgb_ycc_convert_mmx; >+ break; >+ default: >+ sse2fct=jsimd_rgb_ycc_convert_sse2; >+ mmxfct=jsimd_rgb_ycc_convert_mmx; >+ break; >+ } >+ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) >+ sse2fct(cinfo->image_width, input_buf, >+ output_buf, output_row, num_rows); >+ else if (simd_support & JSIMD_MMX) >+ mmxfct(cinfo->image_width, input_buf, >+ output_buf, output_row, num_rows); >+} >+ >+GLOBAL(void) >+jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows) >+{ >+ void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); >+ void (*mmxfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); >+ >+ switch(cinfo->out_color_space) >+ { >+ case JCS_EXT_RGB: >+ sse2fct=jsimd_ycc_extrgb_convert_sse2; >+ mmxfct=jsimd_ycc_extrgb_convert_mmx; >+ break; >+ case JCS_EXT_RGBX: >+ sse2fct=jsimd_ycc_extrgbx_convert_sse2; >+ mmxfct=jsimd_ycc_extrgbx_convert_mmx; >+ break; >+ case JCS_EXT_BGR: >+ sse2fct=jsimd_ycc_extbgr_convert_sse2; >+ mmxfct=jsimd_ycc_extbgr_convert_mmx; >+ break; >+ case JCS_EXT_BGRX: >+ sse2fct=jsimd_ycc_extbgrx_convert_sse2; >+ mmxfct=jsimd_ycc_extbgrx_convert_mmx; >+ break; >+ case JCS_EXT_XBGR: >+ sse2fct=jsimd_ycc_extxbgr_convert_sse2; >+ mmxfct=jsimd_ycc_extxbgr_convert_mmx; >+ break; >+ case JCS_EXT_XRGB: >+ sse2fct=jsimd_ycc_extxrgb_convert_sse2; >+ mmxfct=jsimd_ycc_extxrgb_convert_mmx; >+ break; >+ default: >+ sse2fct=jsimd_ycc_rgb_convert_sse2; >+ mmxfct=jsimd_ycc_rgb_convert_mmx; >+ break; >+ } >+ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) >+ sse2fct(cinfo->output_width, input_buf, >+ input_row, output_buf, num_rows); >+ else if (simd_support & JSIMD_MMX) >+ mmxfct(cinfo->output_width, input_buf, >+ input_row, output_buf, num_rows); >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_downsample (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if (simd_support & JSIMD_SSE2) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_downsample (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if (simd_support & JSIMD_SSE2) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY output_data) >+{ >+ if (simd_support & JSIMD_SSE2) >+ jsimd_h2v2_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor, >+ compptr->v_samp_factor, compptr->width_in_blocks, >+ input_data, output_data); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_h2v2_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor, >+ compptr->v_samp_factor, compptr->width_in_blocks, >+ input_data, output_data); >+} >+ >+GLOBAL(void) >+jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY output_data) >+{ >+ if (simd_support & JSIMD_SSE2) >+ jsimd_h2v1_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor, >+ compptr->v_samp_factor, compptr->width_in_blocks, >+ input_data, output_data); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_h2v1_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor, >+ compptr->v_samp_factor, compptr->width_in_blocks, >+ input_data, output_data); >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_upsample (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if (simd_support & JSIMD_SSE2) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_upsample (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if (simd_support & JSIMD_SSE2) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+ if (simd_support & JSIMD_SSE2) >+ jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, >+ cinfo->output_width, input_data, output_data_ptr); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_h2v2_upsample_mmx(cinfo->max_v_samp_factor, >+ cinfo->output_width, input_data, output_data_ptr); >+} >+ >+GLOBAL(void) >+jsimd_h2v1_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+ if (simd_support & JSIMD_SSE2) >+ jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, >+ cinfo->output_width, input_data, output_data_ptr); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_h2v1_upsample_mmx(cinfo->max_v_samp_factor, >+ cinfo->output_width, input_data, output_data_ptr); >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_fancy_upsample (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_fancy_upsample (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) >+ jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, >+ compptr->downsampled_width, input_data, output_data_ptr); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_h2v2_fancy_upsample_mmx(cinfo->max_v_samp_factor, >+ compptr->downsampled_width, input_data, output_data_ptr); >+} >+ >+GLOBAL(void) >+jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) >+ jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, >+ compptr->downsampled_width, input_data, output_data_ptr); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_h2v1_fancy_upsample_mmx(cinfo->max_v_samp_factor, >+ compptr->downsampled_width, input_data, output_data_ptr); >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_merged_upsample (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_merged_upsample (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, >+ JSAMPARRAY output_buf) >+{ >+ void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); >+ void (*mmxfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); >+ >+ switch(cinfo->out_color_space) >+ { >+ case JCS_EXT_RGB: >+ sse2fct=jsimd_h2v2_extrgb_merged_upsample_sse2; >+ mmxfct=jsimd_h2v2_extrgb_merged_upsample_mmx; >+ break; >+ case JCS_EXT_RGBX: >+ sse2fct=jsimd_h2v2_extrgbx_merged_upsample_sse2; >+ mmxfct=jsimd_h2v2_extrgbx_merged_upsample_mmx; >+ break; >+ case JCS_EXT_BGR: >+ sse2fct=jsimd_h2v2_extbgr_merged_upsample_sse2; >+ mmxfct=jsimd_h2v2_extbgr_merged_upsample_mmx; >+ break; >+ case JCS_EXT_BGRX: >+ sse2fct=jsimd_h2v2_extbgrx_merged_upsample_sse2; >+ mmxfct=jsimd_h2v2_extbgrx_merged_upsample_mmx; >+ break; >+ case JCS_EXT_XBGR: >+ sse2fct=jsimd_h2v2_extxbgr_merged_upsample_sse2; >+ mmxfct=jsimd_h2v2_extxbgr_merged_upsample_mmx; >+ break; >+ case JCS_EXT_XRGB: >+ sse2fct=jsimd_h2v2_extxrgb_merged_upsample_sse2; >+ mmxfct=jsimd_h2v2_extxrgb_merged_upsample_mmx; >+ break; >+ default: >+ sse2fct=jsimd_h2v2_merged_upsample_sse2; >+ mmxfct=jsimd_h2v2_merged_upsample_mmx; >+ break; >+ } >+ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) >+ sse2fct(cinfo->output_width, input_buf, >+ in_row_group_ctr, output_buf); >+ else if (simd_support & JSIMD_MMX) >+ mmxfct(cinfo->output_width, input_buf, >+ in_row_group_ctr, output_buf); >+} >+ >+GLOBAL(void) >+jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, >+ JSAMPARRAY output_buf) >+{ >+ void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); >+ void (*mmxfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); >+ >+ switch(cinfo->out_color_space) >+ { >+ case JCS_EXT_RGB: >+ sse2fct=jsimd_h2v1_extrgb_merged_upsample_sse2; >+ mmxfct=jsimd_h2v1_extrgb_merged_upsample_mmx; >+ break; >+ case JCS_EXT_RGBX: >+ sse2fct=jsimd_h2v1_extrgbx_merged_upsample_sse2; >+ mmxfct=jsimd_h2v1_extrgbx_merged_upsample_mmx; >+ break; >+ case JCS_EXT_BGR: >+ sse2fct=jsimd_h2v1_extbgr_merged_upsample_sse2; >+ mmxfct=jsimd_h2v1_extbgr_merged_upsample_mmx; >+ break; >+ case JCS_EXT_BGRX: >+ sse2fct=jsimd_h2v1_extbgrx_merged_upsample_sse2; >+ mmxfct=jsimd_h2v1_extbgrx_merged_upsample_mmx; >+ break; >+ case JCS_EXT_XBGR: >+ sse2fct=jsimd_h2v1_extxbgr_merged_upsample_sse2; >+ mmxfct=jsimd_h2v1_extxbgr_merged_upsample_mmx; >+ break; >+ case JCS_EXT_XRGB: >+ sse2fct=jsimd_h2v1_extxrgb_merged_upsample_sse2; >+ mmxfct=jsimd_h2v1_extxrgb_merged_upsample_mmx; >+ break; >+ default: >+ sse2fct=jsimd_h2v1_merged_upsample_sse2; >+ mmxfct=jsimd_h2v1_merged_upsample_mmx; >+ break; >+ } >+ >+ if ((simd_support & JSIMD_SSE2) && >+ IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) >+ sse2fct(cinfo->output_width, input_buf, >+ in_row_group_ctr, output_buf); >+ else if (simd_support & JSIMD_MMX) >+ mmxfct(cinfo->output_width, input_buf, >+ in_row_group_ctr, output_buf); >+} >+ >+GLOBAL(int) >+jsimd_can_convsamp (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(DCTELEM) != 2) >+ return 0; >+ >+ if (simd_support & JSIMD_SSE2) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_convsamp_float (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(FAST_FLOAT) != 4) >+ return 0; >+ >+ if (simd_support & JSIMD_SSE2) >+ return 1; >+ if (simd_support & JSIMD_SSE) >+ return 1; >+ if (simd_support & JSIMD_3DNOW) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, >+ DCTELEM * workspace) >+{ >+ if (simd_support & JSIMD_SSE2) >+ jsimd_convsamp_sse2(sample_data, start_col, workspace); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_convsamp_mmx(sample_data, start_col, workspace); >+} >+ >+GLOBAL(void) >+jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, >+ FAST_FLOAT * workspace) >+{ >+ if (simd_support & JSIMD_SSE2) >+ jsimd_convsamp_float_sse2(sample_data, start_col, workspace); >+ else if (simd_support & JSIMD_SSE) >+ jsimd_convsamp_float_sse(sample_data, start_col, workspace); >+ else if (simd_support & JSIMD_3DNOW) >+ jsimd_convsamp_float_3dnow(sample_data, start_col, workspace); >+} >+ >+GLOBAL(int) >+jsimd_can_fdct_islow (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(DCTELEM) != 2) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_fdct_ifast (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(DCTELEM) != 2) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_ifast_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_fdct_float (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(FAST_FLOAT) != 4) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse)) >+ return 1; >+ if (simd_support & JSIMD_3DNOW) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_fdct_islow (DCTELEM * data) >+{ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) >+ jsimd_fdct_islow_sse2(data); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_fdct_islow_mmx(data); >+} >+ >+GLOBAL(void) >+jsimd_fdct_ifast (DCTELEM * data) >+{ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) >+ jsimd_fdct_ifast_sse2(data); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_fdct_ifast_mmx(data); >+} >+ >+GLOBAL(void) >+jsimd_fdct_float (FAST_FLOAT * data) >+{ >+ if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse)) >+ jsimd_fdct_float_sse(data); >+ else if (simd_support & JSIMD_3DNOW) >+ jsimd_fdct_float_3dnow(data); >+} >+ >+GLOBAL(int) >+jsimd_can_quantize (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (sizeof(DCTELEM) != 2) >+ return 0; >+ >+ if (simd_support & JSIMD_SSE2) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_quantize_float (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (sizeof(FAST_FLOAT) != 4) >+ return 0; >+ >+ if (simd_support & JSIMD_SSE2) >+ return 1; >+ if (simd_support & JSIMD_SSE) >+ return 1; >+ if (simd_support & JSIMD_3DNOW) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, >+ DCTELEM * workspace) >+{ >+ if (simd_support & JSIMD_SSE2) >+ jsimd_quantize_sse2(coef_block, divisors, workspace); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_quantize_mmx(coef_block, divisors, workspace); >+} >+ >+GLOBAL(void) >+jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, >+ FAST_FLOAT * workspace) >+{ >+ if (simd_support & JSIMD_SSE2) >+ jsimd_quantize_float_sse2(coef_block, divisors, workspace); >+ else if (simd_support & JSIMD_SSE) >+ jsimd_quantize_float_sse(coef_block, divisors, workspace); >+ else if (simd_support & JSIMD_3DNOW) >+ jsimd_quantize_float_3dnow(coef_block, divisors, workspace); >+} >+ >+GLOBAL(int) >+jsimd_can_idct_2x2 (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(ISLOW_MULT_TYPE) != 2) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_idct_4x4 (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(ISLOW_MULT_TYPE) != 2) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) >+ jsimd_idct_2x2_sse2(compptr->dct_table, coef_block, output_buf, output_col); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_idct_2x2_mmx(compptr->dct_table, coef_block, output_buf, output_col); >+} >+ >+GLOBAL(void) >+jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) >+ jsimd_idct_4x4_sse2(compptr->dct_table, coef_block, output_buf, output_col); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_idct_4x4_mmx(compptr->dct_table, coef_block, output_buf, output_col); >+} >+ >+GLOBAL(int) >+jsimd_can_idct_islow (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(ISLOW_MULT_TYPE) != 2) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_idct_ifast (void) >+{ >+ init_simd(); >+ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(IFAST_MULT_TYPE) != 2) >+ return 0; >+ if (IFAST_SCALE_BITS != 2) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2)) >+ return 1; >+ if (simd_support & JSIMD_MMX) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(int) >+jsimd_can_idct_float (void) >+{ >+ init_simd(); >+ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(FAST_FLOAT) != 4) >+ return 0; >+ if (sizeof(FLOAT_MULT_TYPE) != 4) >+ return 0; >+ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2)) >+ return 1; >+ if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) >+ return 1; >+ if (simd_support & JSIMD_3DNOW) >+ return 1; >+ >+ return 0; >+} >+ >+GLOBAL(void) >+jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2)) >+ jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf, output_col); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_idct_islow_mmx(compptr->dct_table, coef_block, output_buf, output_col); >+} >+ >+GLOBAL(void) >+jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2)) >+ jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf, output_col); >+ else if (simd_support & JSIMD_MMX) >+ jsimd_idct_ifast_mmx(compptr->dct_table, coef_block, output_buf, output_col); >+} >+ >+GLOBAL(void) >+jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+ if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2)) >+ jsimd_idct_float_sse2(compptr->dct_table, coef_block, >+ output_buf, output_col); >+ else if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) >+ jsimd_idct_float_sse(compptr->dct_table, coef_block, >+ output_buf, output_col); >+ else if (simd_support & JSIMD_3DNOW) >+ jsimd_idct_float_3dnow(compptr->dct_table, coef_block, >+ output_buf, output_col); >+} >+ >diff --git a/modules/libjpeg-turbo/simd/jsimd_x86_64.c b/modules/libjpeg-turbo/simd/jsimd_x86_64.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jsimd_x86_64.c >@@ -0,0 +1,680 @@ >+/* >+ * jsimd_x86_64.c >+ * >+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+ * Copyright 2009 D. R. Commander >+ * >+ * Based on the x86 SIMD extension for IJG JPEG library, >+ * Copyright (C) 1999-2006, MIYASAKA Masaru. >+ * >+ * This file contains the interface between the "normal" portions >+ * of the library and the SIMD implementations when running on a >+ * x86_64 architecture. >+ */ >+ >+#define JPEG_INTERNALS >+#include "../jinclude.h" >+#include "../jpeglib.h" >+#include "../jsimd.h" >+#include "../jdct.h" >+#include "../jsimddct.h" >+#include "simd/jsimd.h" >+ >+/* >+ * In the PIC cases, we have no guarantee that constants will keep >+ * their alignment. This macro allows us to verify it at runtime. >+ */ >+#define IS_ALIGNED(ptr, order) (((size_t)ptr & ((1 << order) - 1)) == 0) >+ >+#define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */ >+ >+GLOBAL(int) >+jsimd_can_rgb_ycc (void) >+{ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_ycc_rgb (void) >+{ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(void) >+jsimd_rgb_ycc_convert (j_compress_ptr cinfo, >+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf, >+ JDIMENSION output_row, int num_rows) >+{ >+ void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); >+ >+ switch(cinfo->in_color_space) >+ { >+ case JCS_EXT_RGB: >+ sse2fct=jsimd_extrgb_ycc_convert_sse2; >+ break; >+ case JCS_EXT_RGBX: >+ sse2fct=jsimd_extrgbx_ycc_convert_sse2; >+ break; >+ case JCS_EXT_BGR: >+ sse2fct=jsimd_extbgr_ycc_convert_sse2; >+ break; >+ case JCS_EXT_BGRX: >+ sse2fct=jsimd_extbgrx_ycc_convert_sse2; >+ break; >+ case JCS_EXT_XBGR: >+ sse2fct=jsimd_extxbgr_ycc_convert_sse2; >+ break; >+ case JCS_EXT_XRGB: >+ sse2fct=jsimd_extxrgb_ycc_convert_sse2; >+ break; >+ default: >+ sse2fct=jsimd_rgb_ycc_convert_sse2; >+ break; >+ } >+ >+ sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows); >+} >+ >+GLOBAL(void) >+jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, JDIMENSION input_row, >+ JSAMPARRAY output_buf, int num_rows) >+{ >+ void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); >+ >+ switch(cinfo->out_color_space) >+ { >+ case JCS_EXT_RGB: >+ sse2fct=jsimd_ycc_extrgb_convert_sse2; >+ break; >+ case JCS_EXT_RGBX: >+ sse2fct=jsimd_ycc_extrgbx_convert_sse2; >+ break; >+ case JCS_EXT_BGR: >+ sse2fct=jsimd_ycc_extbgr_convert_sse2; >+ break; >+ case JCS_EXT_BGRX: >+ sse2fct=jsimd_ycc_extbgrx_convert_sse2; >+ break; >+ case JCS_EXT_XBGR: >+ sse2fct=jsimd_ycc_extxbgr_convert_sse2; >+ break; >+ case JCS_EXT_XRGB: >+ sse2fct=jsimd_ycc_extxrgb_convert_sse2; >+ break; >+ default: >+ sse2fct=jsimd_ycc_rgb_convert_sse2; >+ break; >+ } >+ >+ sse2fct(cinfo->output_width, input_buf, input_row, output_buf, num_rows); >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_downsample (void) >+{ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_downsample (void) >+{ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY output_data) >+{ >+ jsimd_h2v2_downsample_sse2(cinfo->image_width, >+ cinfo->max_v_samp_factor, >+ compptr->v_samp_factor, >+ compptr->width_in_blocks, >+ input_data, output_data); >+} >+ >+GLOBAL(void) >+jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, >+ JSAMPARRAY input_data, JSAMPARRAY output_data) >+{ >+ jsimd_h2v1_downsample_sse2(cinfo->image_width, >+ cinfo->max_v_samp_factor, >+ compptr->v_samp_factor, >+ compptr->width_in_blocks, >+ input_data, output_data); >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_upsample (void) >+{ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_upsample (void) >+{ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+ jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, >+ cinfo->output_width, >+ input_data, output_data_ptr); >+} >+ >+GLOBAL(void) >+jsimd_h2v1_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+ jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, >+ cinfo->output_width, >+ input_data, output_data_ptr); >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_fancy_upsample (void) >+{ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_fancy_upsample (void) >+{ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+ jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, >+ compptr->downsampled_width, >+ input_data, output_data_ptr); >+} >+ >+GLOBAL(void) >+jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, >+ jpeg_component_info * compptr, >+ JSAMPARRAY input_data, >+ JSAMPARRAY * output_data_ptr) >+{ >+ jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, >+ compptr->downsampled_width, >+ input_data, output_data_ptr); >+} >+ >+GLOBAL(int) >+jsimd_can_h2v2_merged_upsample (void) >+{ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_h2v1_merged_upsample (void) >+{ >+ /* The code is optimised for these values only */ >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(void) >+jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, >+ JSAMPARRAY output_buf) >+{ >+ void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); >+ >+ switch(cinfo->out_color_space) >+ { >+ case JCS_EXT_RGB: >+ sse2fct=jsimd_h2v2_extrgb_merged_upsample_sse2; >+ break; >+ case JCS_EXT_RGBX: >+ sse2fct=jsimd_h2v2_extrgbx_merged_upsample_sse2; >+ break; >+ case JCS_EXT_BGR: >+ sse2fct=jsimd_h2v2_extbgr_merged_upsample_sse2; >+ break; >+ case JCS_EXT_BGRX: >+ sse2fct=jsimd_h2v2_extbgrx_merged_upsample_sse2; >+ break; >+ case JCS_EXT_XBGR: >+ sse2fct=jsimd_h2v2_extxbgr_merged_upsample_sse2; >+ break; >+ case JCS_EXT_XRGB: >+ sse2fct=jsimd_h2v2_extxrgb_merged_upsample_sse2; >+ break; >+ default: >+ sse2fct=jsimd_h2v2_merged_upsample_sse2; >+ break; >+ } >+ >+ sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); >+} >+ >+GLOBAL(void) >+jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo, >+ JSAMPIMAGE input_buf, >+ JDIMENSION in_row_group_ctr, >+ JSAMPARRAY output_buf) >+{ >+ void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); >+ >+ switch(cinfo->out_color_space) >+ { >+ case JCS_EXT_RGB: >+ sse2fct=jsimd_h2v1_extrgb_merged_upsample_sse2; >+ break; >+ case JCS_EXT_RGBX: >+ sse2fct=jsimd_h2v1_extrgbx_merged_upsample_sse2; >+ break; >+ case JCS_EXT_BGR: >+ sse2fct=jsimd_h2v1_extbgr_merged_upsample_sse2; >+ break; >+ case JCS_EXT_BGRX: >+ sse2fct=jsimd_h2v1_extbgrx_merged_upsample_sse2; >+ break; >+ case JCS_EXT_XBGR: >+ sse2fct=jsimd_h2v1_extxbgr_merged_upsample_sse2; >+ break; >+ case JCS_EXT_XRGB: >+ sse2fct=jsimd_h2v1_extxrgb_merged_upsample_sse2; >+ break; >+ default: >+ sse2fct=jsimd_h2v1_merged_upsample_sse2; >+ break; >+ } >+ >+ sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); >+} >+ >+GLOBAL(int) >+jsimd_can_convsamp (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(DCTELEM) != 2) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_convsamp_float (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(FAST_FLOAT) != 4) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(void) >+jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, >+ DCTELEM * workspace) >+{ >+ jsimd_convsamp_sse2(sample_data, start_col, workspace); >+} >+ >+GLOBAL(void) >+jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, >+ FAST_FLOAT * workspace) >+{ >+ jsimd_convsamp_float_sse2(sample_data, start_col, workspace); >+} >+ >+GLOBAL(int) >+jsimd_can_fdct_islow (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(DCTELEM) != 2) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_fdct_ifast (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(DCTELEM) != 2) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_fdct_ifast_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_fdct_float (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(FAST_FLOAT) != 4) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_fdct_float_sse)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(void) >+jsimd_fdct_islow (DCTELEM * data) >+{ >+ jsimd_fdct_islow_sse2(data); >+} >+ >+GLOBAL(void) >+jsimd_fdct_ifast (DCTELEM * data) >+{ >+ jsimd_fdct_ifast_sse2(data); >+} >+ >+GLOBAL(void) >+jsimd_fdct_float (FAST_FLOAT * data) >+{ >+ jsimd_fdct_float_sse(data); >+} >+ >+GLOBAL(int) >+jsimd_can_quantize (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (sizeof(DCTELEM) != 2) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_quantize_float (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (sizeof(FAST_FLOAT) != 4) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(void) >+jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, >+ DCTELEM * workspace) >+{ >+ jsimd_quantize_sse2(coef_block, divisors, workspace); >+} >+ >+GLOBAL(void) >+jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, >+ FAST_FLOAT * workspace) >+{ >+ jsimd_quantize_float_sse2(coef_block, divisors, workspace); >+} >+ >+GLOBAL(int) >+jsimd_can_idct_2x2 (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(ISLOW_MULT_TYPE) != 2) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_idct_red_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_idct_4x4 (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(ISLOW_MULT_TYPE) != 2) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_idct_red_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(void) >+jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+ jsimd_idct_2x2_sse2(compptr->dct_table, coef_block, output_buf, output_col); >+} >+ >+GLOBAL(void) >+jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+ jsimd_idct_4x4_sse2(compptr->dct_table, coef_block, output_buf, output_col); >+} >+ >+GLOBAL(int) >+jsimd_can_idct_islow (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(ISLOW_MULT_TYPE) != 2) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_idct_islow_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_idct_ifast (void) >+{ >+ /* The code is optimised for these values only */ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(IFAST_MULT_TYPE) != 2) >+ return 0; >+ if (IFAST_SCALE_BITS != 2) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_idct_ifast_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(int) >+jsimd_can_idct_float (void) >+{ >+ if (DCTSIZE != 8) >+ return 0; >+ if (sizeof(JCOEF) != 2) >+ return 0; >+ if (BITS_IN_JSAMPLE != 8) >+ return 0; >+ if (sizeof(JDIMENSION) != 4) >+ return 0; >+ if (sizeof(FAST_FLOAT) != 4) >+ return 0; >+ if (sizeof(FLOAT_MULT_TYPE) != 4) >+ return 0; >+ >+ if (!IS_ALIGNED_SSE(jconst_idct_float_sse2)) >+ return 0; >+ >+ return 1; >+} >+ >+GLOBAL(void) >+jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+ jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf, output_col); >+} >+ >+GLOBAL(void) >+jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+ jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf, output_col); >+} >+ >+GLOBAL(void) >+jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, >+ JCOEFPTR coef_block, JSAMPARRAY output_buf, >+ JDIMENSION output_col) >+{ >+ jsimd_idct_float_sse2(compptr->dct_table, coef_block, >+ output_buf, output_col); >+} >+ >diff --git a/modules/libjpeg-turbo/simd/jsimdcfg.inc b/modules/libjpeg-turbo/simd/jsimdcfg.inc >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jsimdcfg.inc >@@ -0,0 +1,69 @@ >+; >+; Automatically generated include file from jsimdcfg.inc.h >+; >+; >+; -- jpeglib.h >+; >+%define DCTSIZE 8 >+%define DCTSIZE2 64 >+; >+; -- jmorecfg.h >+; >+%define RGB_RED 0 >+%define RGB_GREEN 1 >+%define RGB_BLUE 2 >+%define RGB_PIXELSIZE 3 >+; Representation of a single sample (pixel element value). >+; On this SIMD implementation, this must be 'unsigned char'. >+; >+%define JSAMPLE byte ; unsigned char >+%define SIZEOF_JSAMPLE SIZEOF_BYTE ; sizeof(JSAMPLE) >+%define CENTERJSAMPLE 128 >+; Representation of a DCT frequency coefficient. >+; On this SIMD implementation, this must be 'short'. >+; >+%define JCOEF word ; short >+%define SIZEOF_JCOEF SIZEOF_WORD ; sizeof(JCOEF) >+; Datatype used for image dimensions. >+; On this SIMD implementation, this must be 'unsigned int'. >+; >+%define JDIMENSION dword ; unsigned int >+%define SIZEOF_JDIMENSION SIZEOF_DWORD ; sizeof(JDIMENSION) >+%define JSAMPROW POINTER ; JSAMPLE * (jpeglib.h) >+%define JSAMPARRAY POINTER ; JSAMPROW * (jpeglib.h) >+%define JSAMPIMAGE POINTER ; JSAMPARRAY * (jpeglib.h) >+%define JCOEFPTR POINTER ; JCOEF * (jpeglib.h) >+%define SIZEOF_JSAMPROW SIZEOF_POINTER ; sizeof(JSAMPROW) >+%define SIZEOF_JSAMPARRAY SIZEOF_POINTER ; sizeof(JSAMPARRAY) >+%define SIZEOF_JSAMPIMAGE SIZEOF_POINTER ; sizeof(JSAMPIMAGE) >+%define SIZEOF_JCOEFPTR SIZEOF_POINTER ; sizeof(JCOEFPTR) >+; >+; -- jdct.h >+; >+; A forward DCT routine is given a pointer to a work area of type DCTELEM[]; >+; the DCT is to be performed in-place in that buffer. >+; To maximize parallelism, Type DCTELEM is changed to short (originally, int). >+; >+%define DCTELEM word ; short >+%define SIZEOF_DCTELEM SIZEOF_WORD ; sizeof(DCTELEM) >+%define float FP32 ; float >+%define SIZEOF_FAST_FLOAT SIZEOF_FP32 ; sizeof(float) >+; To maximize parallelism, Type short is changed to short. >+; >+%define ISLOW_MULT_TYPE word ; must be short >+%define SIZEOF_ISLOW_MULT_TYPE SIZEOF_WORD ; sizeof(ISLOW_MULT_TYPE) >+%define IFAST_MULT_TYPE word ; must be short >+%define SIZEOF_IFAST_MULT_TYPE SIZEOF_WORD ; sizeof(IFAST_MULT_TYPE) >+%define IFAST_SCALE_BITS 2 ; fractional bits in scale factors >+%define FLOAT_MULT_TYPE FP32 ; must be float >+%define SIZEOF_FLOAT_MULT_TYPE SIZEOF_FP32 ; sizeof(FLOAT_MULT_TYPE) >+; >+; -- jsimd.h >+; >+%define JSIMD_NONE 0x00 >+%define JSIMD_MMX 0x01 >+%define JSIMD_3DNOW 0x02 >+%define JSIMD_SSE 0x04 >+%define JSIMD_SSE2 0x08 >+; Short forms of external names for systems with brain-damaged linkers. >+; >diff --git a/modules/libjpeg-turbo/simd/jsimdcfg.inc.h b/modules/libjpeg-turbo/simd/jsimdcfg.inc.h >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jsimdcfg.inc.h >@@ -0,0 +1,168 @@ >+// This file generates the include file for the assembly >+// implementations by abusing the C preprocessor. >+// >+// Note: Some things are manually defined as they need to >+// be mapped to NASM types. >+ >+; >+; Automatically generated include file from jsimdcfg.inc.h >+; >+ >+#define JPEG_INTERNALS >+ >+#include "../jpeglib.h" >+#include "../jconfig.h" >+#include "../jmorecfg.h" >+#include "jsimd.h" >+ >+#define define(var) %define _cpp_protection_##var >+#define definev(var) %define _cpp_protection_##var var >+ >+; >+; -- jpeglib.h >+; >+ >+definev(DCTSIZE) >+definev(DCTSIZE2) >+ >+; >+; -- jmorecfg.h >+; >+ >+definev(RGB_RED) >+definev(RGB_GREEN) >+definev(RGB_BLUE) >+ >+definev(RGB_PIXELSIZE) >+ >+; Representation of a single sample (pixel element value). >+; On this SIMD implementation, this must be 'unsigned char'. >+; >+ >+%define JSAMPLE byte ; unsigned char >+%define SIZEOF_JSAMPLE SIZEOF_BYTE ; sizeof(JSAMPLE) >+ >+definev(CENTERJSAMPLE) >+ >+; Representation of a DCT frequency coefficient. >+; On this SIMD implementation, this must be 'short'. >+; >+%define JCOEF word ; short >+%define SIZEOF_JCOEF SIZEOF_WORD ; sizeof(JCOEF) >+ >+; Datatype used for image dimensions. >+; On this SIMD implementation, this must be 'unsigned int'. >+; >+%define JDIMENSION dword ; unsigned int >+%define SIZEOF_JDIMENSION SIZEOF_DWORD ; sizeof(JDIMENSION) >+ >+%define JSAMPROW POINTER ; JSAMPLE FAR * (jpeglib.h) >+%define JSAMPARRAY POINTER ; JSAMPROW * (jpeglib.h) >+%define JSAMPIMAGE POINTER ; JSAMPARRAY * (jpeglib.h) >+%define JCOEFPTR POINTER ; JCOEF FAR * (jpeglib.h) >+%define SIZEOF_JSAMPROW SIZEOF_POINTER ; sizeof(JSAMPROW) >+%define SIZEOF_JSAMPARRAY SIZEOF_POINTER ; sizeof(JSAMPARRAY) >+%define SIZEOF_JSAMPIMAGE SIZEOF_POINTER ; sizeof(JSAMPIMAGE) >+%define SIZEOF_JCOEFPTR SIZEOF_POINTER ; sizeof(JCOEFPTR) >+ >+; >+; -- jdct.h >+; >+ >+; A forward DCT routine is given a pointer to a work area of type DCTELEM[]; >+; the DCT is to be performed in-place in that buffer. >+; To maximize parallelism, Type DCTELEM is changed to short (originally, int). >+; >+%define DCTELEM word ; short >+%define SIZEOF_DCTELEM SIZEOF_WORD ; sizeof(DCTELEM) >+ >+%define FAST_FLOAT FP32 ; float >+%define SIZEOF_FAST_FLOAT SIZEOF_FP32 ; sizeof(FAST_FLOAT) >+ >+; To maximize parallelism, Type MULTIPLIER is changed to short. >+; >+%define ISLOW_MULT_TYPE word ; must be short >+%define SIZEOF_ISLOW_MULT_TYPE SIZEOF_WORD ; sizeof(ISLOW_MULT_TYPE) >+ >+%define IFAST_MULT_TYPE word ; must be short >+%define SIZEOF_IFAST_MULT_TYPE SIZEOF_WORD ; sizeof(IFAST_MULT_TYPE) >+%define IFAST_SCALE_BITS 2 ; fractional bits in scale factors >+ >+%define FLOAT_MULT_TYPE FP32 ; must be float >+%define SIZEOF_FLOAT_MULT_TYPE SIZEOF_FP32 ; sizeof(FLOAT_MULT_TYPE) >+ >+; >+; -- jsimd.h >+; >+ >+definev(JSIMD_NONE) >+definev(JSIMD_MMX) >+definev(JSIMD_3DNOW) >+definev(JSIMD_SSE) >+definev(JSIMD_SSE2) >+ >+; Short forms of external names for systems with brain-damaged linkers. >+; >+#ifdef NEED_SHORT_EXTERNAL_NAMES >+definev(jpeg_simd_cpu_support) >+definev(jsimd_rgb_ycc_convert_mmx) >+definev(jsimd_ycc_rgb_convert_mmx) >+definev(jconst_rgb_ycc_convert_sse2) >+definev(jsimd_rgb_ycc_convert_sse2) >+definev(jconst_ycc_rgb_convert_sse2) >+definev(jsimd_ycc_rgb_convert_sse2) >+definev(jsimd_h2v2_downsample_mmx) >+definev(jsimd_h2v1_downsample_mmx) >+definev(jsimd_h2v2_downsample_sse2) >+definev(jsimd_h2v1_downsample_sse2) >+definev(jsimd_h2v2_upsample_mmx) >+definev(jsimd_h2v1_upsample_mmx) >+definev(jsimd_h2v1_fancy_upsample_mmx) >+definev(jsimd_h2v2_fancy_upsample_mmx) >+definev(jsimd_h2v1_merged_upsample_mmx) >+definev(jsimd_h2v2_merged_upsample_mmx) >+definev(jsimd_h2v2_upsample_sse2) >+definev(jsimd_h2v1_upsample_sse2) >+definev(jconst_fancy_upsample_sse2) >+definev(jsimd_h2v1_fancy_upsample_sse2) >+definev(jsimd_h2v2_fancy_upsample_sse2) >+definev(jconst_merged_upsample_sse2) >+definev(jsimd_h2v1_merged_upsample_sse2) >+definev(jsimd_h2v2_merged_upsample_sse2) >+definev(jsimd_convsamp_mmx) >+definev(jsimd_convsamp_sse2) >+definev(jsimd_convsamp_float_3dnow) >+definev(jsimd_convsamp_float_sse) >+definev(jsimd_convsamp_float_sse2) >+definev(jsimd_fdct_islow_mmx) >+definev(jsimd_fdct_ifast_mmx) >+definev(jconst_fdct_islow_sse2) >+definev(jsimd_fdct_islow_sse2) >+definev(jconst_fdct_ifast_sse2) >+definev(jsimd_fdct_ifast_sse2) >+definev(jsimd_fdct_float_3dnow) >+definev(jconst_fdct_float_sse) >+definev(jsimd_fdct_float_sse) >+definev(jsimd_quantize_mmx) >+definev(jsimd_quantize_sse2) >+definev(jsimd_quantize_float_3dnow) >+definev(jsimd_quantize_float_sse) >+definev(jsimd_quantize_float_sse2) >+definev(jsimd_idct_2x2_mmx) >+definev(jsimd_idct_4x4_mmx) >+definev(jconst_idct_red_sse2) >+definev(jsimd_idct_2x2_sse2) >+definev(jsimd_idct_4x4_sse2) >+definev(jsimd_idct_islow_mmx) >+definev(jsimd_idct_ifast_mmx) >+definev(jconst_idct_islow_sse2) >+definev(jsimd_idct_islow_sse2) >+definev(jconst_idct_ifast_sse2) >+definev(jsimd_idct_ifast_sse2) >+definev(jsimd_idct_float_3dnow) >+definev(jconst_idct_float_sse) >+definev(jsimd_idct_float_sse) >+definev(jconst_idct_float_sse2) >+definev(jsimd_idct_float_sse2) >+#endif /* NEED_SHORT_EXTERNAL_NAMES */ >+ >diff --git a/modules/libjpeg-turbo/simd/jsimdcpu.asm b/modules/libjpeg-turbo/simd/jsimdcpu.asm >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jsimdcpu.asm >@@ -0,0 +1,105 @@ >+; >+; jsimdcpu.asm - SIMD instruction support check >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; For conditions of distribution and use, see copyright notice in jsimdext.inc >+; >+; This file should be assembled with NASM (Netwide Assembler), >+; can *not* be assembled with Microsoft's MASM or any compatible >+; assembler (including Borland's Turbo Assembler). >+; NASM is available from http://nasm.sourceforge.net/ or >+; http://sourceforge.net/project/showfiles.php?group_id=6208 >+; >+; [TAB8] >+ >+%include "jsimdext.inc" >+ >+; -------------------------------------------------------------------------- >+ SECTION SEG_TEXT >+ BITS 32 >+; >+; Check if the CPU supports SIMD instructions >+; >+; GLOBAL(unsigned int) >+; jpeg_simd_cpu_support (void) >+; >+ >+ align 16 >+ global EXTN(jpeg_simd_cpu_support) >+ >+EXTN(jpeg_simd_cpu_support): >+ push ebx >+; push ecx ; need not be preserved >+; push edx ; need not be preserved >+; push esi ; unused >+ push edi >+ >+ xor edi,edi ; simd support flag >+ >+ pushfd >+ pop eax >+ mov edx,eax >+ xor eax, 1<<21 ; flip ID bit in EFLAGS >+ push eax >+ popfd >+ pushfd >+ pop eax >+ xor eax,edx >+ jz short .return ; CPUID is not supported >+ >+ ; Check for MMX instruction support >+ xor eax,eax >+ cpuid >+ test eax,eax >+ jz short .return >+ >+ xor eax,eax >+ inc eax >+ cpuid >+ mov eax,edx ; eax = Standard feature flags >+ >+ test eax, 1<<23 ; bit23:MMX >+ jz short .no_mmx >+ or edi, byte JSIMD_MMX >+.no_mmx: >+ test eax, 1<<25 ; bit25:SSE >+ jz short .no_sse >+ or edi, byte JSIMD_SSE >+.no_sse: >+ test eax, 1<<26 ; bit26:SSE2 >+ jz short .no_sse2 >+ or edi, byte JSIMD_SSE2 >+.no_sse2: >+ >+ ; Check for 3DNow! instruction support >+ mov eax, 0x80000000 >+ cpuid >+ cmp eax, 0x80000000 >+ jbe short .return >+ >+ mov eax, 0x80000001 >+ cpuid >+ mov eax,edx ; eax = Extended feature flags >+ >+ test eax, 1<<31 ; bit31:3DNow!(vendor independent) >+ jz short .no_3dnow >+ or edi, byte JSIMD_3DNOW >+.no_3dnow: >+ >+.return: >+ mov eax,edi >+ >+ pop edi >+; pop esi ; unused >+; pop edx ; need not be preserved >+; pop ecx ; need not be preserved >+ pop ebx >+ ret >+ >+; For some reason, the OS X linker does not honor the request to align the >+; segment unless we do this. >+ align 16 >diff --git a/modules/libjpeg-turbo/simd/jsimdext.inc b/modules/libjpeg-turbo/simd/jsimdext.inc >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/jsimdext.inc >@@ -0,0 +1,372 @@ >+; >+; jsimdext.inc - common declarations >+; >+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB >+; Copyright 2010 D. R. Commander >+; >+; Based on >+; x86 SIMD extension for IJG JPEG library - version 1.02 >+; >+; Copyright (C) 1999-2006, MIYASAKA Masaru. >+; >+; This software is provided 'as-is', without any express or implied >+; warranty. In no event will the authors be held liable for any damages >+; arising from the use of this software. >+; >+; Permission is granted to anyone to use this software for any purpose, >+; including commercial applications, and to alter it and redistribute it >+; freely, subject to the following restrictions: >+; >+; 1. The origin of this software must not be misrepresented; you must not >+; claim that you wrote the original software. If you use this software >+; in a product, an acknowledgment in the product documentation would be >+; appreciated but is not required. >+; 2. Altered source versions must be plainly marked as such, and must not be >+; misrepresented as being the original software. >+; 3. This notice may not be removed or altered from any source distribution. >+; >+; [TAB8] >+ >+; ========================================================================== >+; System-dependent configurations >+ >+%ifdef WIN32 ; ----(nasm -fwin32 -DWIN32 ...)-------- >+; * Microsoft Visual C++ >+; * MinGW (Minimalist GNU for Windows) >+; * CygWin >+; * LCC-Win32 >+ >+; -- segment definition -- >+; >+%define SEG_TEXT .text align=16 public use32 class=CODE >+%define SEG_CONST .rdata align=16 public use32 class=CONST >+ >+%elifdef WIN64 ; ----(nasm -fwin64 -DWIN64 ...)-------- >+; * Microsoft Visual C++ >+ >+; -- segment definition -- >+; >+%define SEG_TEXT .text align=16 public use64 class=CODE >+%define SEG_CONST .rdata align=16 public use64 class=CONST >+%ifdef MSVC >+%define EXTN(name) name ; foo() -> foo >+%endif >+ >+%elifdef OBJ32 ; ----(nasm -fobj -DOBJ32 ...)---------- >+; * Borland C++ (Win32) >+ >+; -- segment definition -- >+; >+%define SEG_TEXT .text align=16 public use32 class=CODE >+%define SEG_CONST .data align=16 public use32 class=DATA >+ >+%elifdef ELF ; ----(nasm -felf[64] -DELF ...)------------ >+; * Linux >+; * *BSD family Unix using elf format >+; * Unix System V, including Solaris x86, UnixWare and SCO Unix >+ >+; mark stack as non-executable >+section .note.GNU-stack noalloc noexec nowrite progbits >+ >+; -- segment definition -- >+; >+%ifdef __x86_64__ >+%define SEG_TEXT .text progbits align=16 >+%define SEG_CONST .rodata progbits align=16 >+%else >+%define SEG_TEXT .text progbits alloc exec nowrite align=16 >+%define SEG_CONST .rodata progbits alloc noexec nowrite align=16 >+%endif >+ >+; To make the code position-independent, append -DPIC to the commandline >+; >+%define GOT_SYMBOL _GLOBAL_OFFSET_TABLE_ ; ELF supports PIC >+%define EXTN(name) name ; foo() -> foo >+ >+%elifdef AOUT ; ----(nasm -faoutb/aout -DAOUT ...)---- >+; * Older Linux using a.out format (nasm -f aout -DAOUT ...) >+; * *BSD family Unix using a.out format (nasm -f aoutb -DAOUT ...) >+ >+; -- segment definition -- >+; >+%define SEG_TEXT .text >+%define SEG_CONST .data >+ >+; To make the code position-independent, append -DPIC to the commandline >+; >+%define GOT_SYMBOL __GLOBAL_OFFSET_TABLE_ ; BSD-style a.out supports PIC >+ >+%elifdef MACHO ; ----(nasm -fmacho -DMACHO ...)-------- >+; * NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (Mach-O format) >+ >+; -- segment definition -- >+; >+%define SEG_TEXT .text ;align=16 ; nasm doesn't accept align=16. why? >+%define SEG_CONST .rodata align=16 >+ >+; The generation of position-independent code (PIC) is the default on Darwin. >+; >+%define PIC >+%define GOT_SYMBOL _MACHO_PIC_ ; Mach-O style code-relative addressing >+ >+%else ; ----(Other case)---------------------- >+ >+; -- segment definition -- >+; >+%define SEG_TEXT .text >+%define SEG_CONST .data >+ >+%endif ; ---------------------------------------------- >+ >+; ========================================================================== >+ >+; -------------------------------------------------------------------------- >+; Common types >+; >+%ifdef __x86_64__ >+%define POINTER qword ; general pointer type >+%define SIZEOF_POINTER SIZEOF_QWORD ; sizeof(POINTER) >+%define POINTER_BIT QWORD_BIT ; sizeof(POINTER)*BYTE_BIT >+%else >+%define POINTER dword ; general pointer type >+%define SIZEOF_POINTER SIZEOF_DWORD ; sizeof(POINTER) >+%define POINTER_BIT DWORD_BIT ; sizeof(POINTER)*BYTE_BIT >+%endif >+ >+%define INT dword ; signed integer type >+%define SIZEOF_INT SIZEOF_DWORD ; sizeof(INT) >+%define INT_BIT DWORD_BIT ; sizeof(INT)*BYTE_BIT >+ >+%define FP32 dword ; IEEE754 single >+%define SIZEOF_FP32 SIZEOF_DWORD ; sizeof(FP32) >+%define FP32_BIT DWORD_BIT ; sizeof(FP32)*BYTE_BIT >+ >+%define MMWORD qword ; int64 (MMX register) >+%define SIZEOF_MMWORD SIZEOF_QWORD ; sizeof(MMWORD) >+%define MMWORD_BIT QWORD_BIT ; sizeof(MMWORD)*BYTE_BIT >+ >+; NASM is buggy and doesn't properly handle operand sizes for SSE >+; instructions, so for now we have to define XMMWORD as blank. >+%define XMMWORD ; int128 (SSE register) >+%define SIZEOF_XMMWORD SIZEOF_OWORD ; sizeof(XMMWORD) >+%define XMMWORD_BIT OWORD_BIT ; sizeof(XMMWORD)*BYTE_BIT >+ >+; Similar hacks for when we load a dword or MMWORD into an xmm# register >+%define XMM_DWORD >+%define XMM_MMWORD >+ >+%define SIZEOF_BYTE 1 ; sizeof(BYTE) >+%define SIZEOF_WORD 2 ; sizeof(WORD) >+%define SIZEOF_DWORD 4 ; sizeof(DWORD) >+%define SIZEOF_QWORD 8 ; sizeof(QWORD) >+%define SIZEOF_OWORD 16 ; sizeof(OWORD) >+ >+%define BYTE_BIT 8 ; CHAR_BIT in C >+%define WORD_BIT 16 ; sizeof(WORD)*BYTE_BIT >+%define DWORD_BIT 32 ; sizeof(DWORD)*BYTE_BIT >+%define QWORD_BIT 64 ; sizeof(QWORD)*BYTE_BIT >+%define OWORD_BIT 128 ; sizeof(OWORD)*BYTE_BIT >+ >+; -------------------------------------------------------------------------- >+; External Symbol Name >+; >+%ifndef EXTN >+%define EXTN(name) _ %+ name ; foo() -> _foo >+%endif >+ >+; -------------------------------------------------------------------------- >+; Macros for position-independent code (PIC) support >+; >+%ifndef GOT_SYMBOL >+%undef PIC >+%endif >+ >+%ifdef PIC ; ------------------------------------------- >+ >+%ifidn GOT_SYMBOL,_MACHO_PIC_ ; -------------------- >+ >+; At present, nasm doesn't seem to support PIC generation for Mach-O. >+; The PIC support code below is a little tricky. >+ >+ SECTION SEG_CONST >+const_base: >+ >+%define GOTOFF(got,sym) (got) + (sym) - const_base >+ >+%imacro get_GOT 1 >+ ; NOTE: this macro destroys ecx resister. >+ call %%geteip >+ add ecx, byte (%%ref - $) >+ jmp short %%adjust >+%%geteip: >+ mov ecx, POINTER [esp] >+ ret >+%%adjust: >+ push ebp >+ xor ebp,ebp ; ebp = 0 >+%ifidni %1,ebx ; (%1 == ebx) >+ ; db 0x8D,0x9C + jmp near const_base = >+ ; lea ebx, [ecx+ebp*8+(const_base-%%ref)] ; 8D,9C,E9,(offset32) >+ db 0x8D,0x9C ; 8D,9C >+ jmp near const_base ; E9,(const_base-%%ref) >+%%ref: >+%else ; (%1 != ebx) >+ ; db 0x8D,0x8C + jmp near const_base = >+ ; lea ecx, [ecx+ebp*8+(const_base-%%ref)] ; 8D,8C,E9,(offset32) >+ db 0x8D,0x8C ; 8D,8C >+ jmp near const_base ; E9,(const_base-%%ref) >+%%ref: mov %1, ecx >+%endif ; (%1 == ebx) >+ pop ebp >+%endmacro >+ >+%else ; GOT_SYMBOL != _MACHO_PIC_ ---------------- >+ >+%define GOTOFF(got,sym) (got) + (sym) wrt ..gotoff >+ >+%imacro get_GOT 1 >+ extern GOT_SYMBOL >+ call %%geteip >+ add %1, GOT_SYMBOL + $$ - $ wrt ..gotpc >+ jmp short %%done >+%%geteip: >+ mov %1, POINTER [esp] >+ ret >+%%done: >+%endmacro >+ >+%endif ; GOT_SYMBOL == _MACHO_PIC_ ---------------- >+ >+%imacro pushpic 1.nolist >+ push %1 >+%endmacro >+%imacro poppic 1.nolist >+ pop %1 >+%endmacro >+%imacro movpic 2.nolist >+ mov %1,%2 >+%endmacro >+ >+%else ; !PIC ----------------------------------------- >+ >+%define GOTOFF(got,sym) (sym) >+ >+%imacro get_GOT 1.nolist >+%endmacro >+%imacro pushpic 1.nolist >+%endmacro >+%imacro poppic 1.nolist >+%endmacro >+%imacro movpic 2.nolist >+%endmacro >+ >+%endif ; PIC ----------------------------------------- >+ >+; -------------------------------------------------------------------------- >+; Align the next instruction on {2,4,8,16,..}-byte boundary. >+; ".balign n,,m" in GNU as >+; >+%define MSKLE(x,y) (~(((y) & 0xFFFF) - ((x) & 0xFFFF)) >> 16) >+%define FILLB(b,n) (($$-(b)) & ((n)-1)) >+ >+%imacro alignx 1-2.nolist 0xFFFF >+%%bs: times MSKLE(FILLB(%%bs,%1),%2) & MSKLE(16,FILLB($,%1)) & FILLB($,%1) \ >+ db 0x90 ; nop >+ times MSKLE(FILLB(%%bs,%1),%2) & FILLB($,%1)/9 \ >+ db 0x8D,0x9C,0x23,0x00,0x00,0x00,0x00 ; lea ebx,[ebx+0x00000000] >+ times MSKLE(FILLB(%%bs,%1),%2) & FILLB($,%1)/7 \ >+ db 0x8D,0xAC,0x25,0x00,0x00,0x00,0x00 ; lea ebp,[ebp+0x00000000] >+ times MSKLE(FILLB(%%bs,%1),%2) & FILLB($,%1)/6 \ >+ db 0x8D,0xAD,0x00,0x00,0x00,0x00 ; lea ebp,[ebp+0x00000000] >+ times MSKLE(FILLB(%%bs,%1),%2) & FILLB($,%1)/4 \ >+ db 0x8D,0x6C,0x25,0x00 ; lea ebp,[ebp+0x00] >+ times MSKLE(FILLB(%%bs,%1),%2) & FILLB($,%1)/3 \ >+ db 0x8D,0x6D,0x00 ; lea ebp,[ebp+0x00] >+ times MSKLE(FILLB(%%bs,%1),%2) & FILLB($,%1)/2 \ >+ db 0x8B,0xED ; mov ebp,ebp >+ times MSKLE(FILLB(%%bs,%1),%2) & FILLB($,%1)/1 \ >+ db 0x90 ; nop >+%endmacro >+ >+; Align the next data on {2,4,8,16,..}-byte boundary. >+; >+%imacro alignz 1.nolist >+ align %1, db 0 ; filling zeros >+%endmacro >+ >+%ifdef __x86_64__ >+ >+%ifdef WIN64 >+ >+%imacro collect_args 0 >+ push r10 >+ push r11 >+ push r12 >+ push r13 >+ push r14 >+ push r15 >+ mov r10, rcx >+ mov r11, rdx >+ mov r12, r8 >+ mov r13, r9 >+ mov r14, [rax+48] >+ mov r15, [rax+56] >+ push rsi >+ push rdi >+ sub rsp, SIZEOF_XMMWORD >+ movlpd XMMWORD [rsp], xmm6 >+ sub rsp, SIZEOF_XMMWORD >+ movlpd XMMWORD [rsp], xmm7 >+%endmacro >+ >+%imacro uncollect_args 0 >+ movlpd xmm7, XMMWORD [rsp] >+ add rsp, SIZEOF_XMMWORD >+ movlpd xmm6, XMMWORD [rsp] >+ add rsp, SIZEOF_XMMWORD >+ pop rdi >+ pop rsi >+ pop r15 >+ pop r14 >+ pop r13 >+ pop r12 >+ pop r11 >+ pop r10 >+%endmacro >+ >+%else >+ >+%imacro collect_args 0 >+ push r10 >+ push r11 >+ push r12 >+ push r13 >+ push r14 >+ push r15 >+ mov r10, rdi >+ mov r11, rsi >+ mov r12, rdx >+ mov r13, rcx >+ mov r14, r8 >+ mov r15, r9 >+%endmacro >+ >+%imacro uncollect_args 0 >+ pop r15 >+ pop r14 >+ pop r13 >+ pop r12 >+ pop r11 >+ pop r10 >+%endmacro >+ >+%endif >+ >+%endif >+ >+; -------------------------------------------------------------------------- >+; Defines picked up from the C headers >+; >+%include "jsimdcfg.inc" >+ >+; -------------------------------------------------------------------------- >diff --git a/modules/libjpeg-turbo/simd/nasm_lt.sh b/modules/libjpeg-turbo/simd/nasm_lt.sh >new file mode 100755 >--- /dev/null >+++ b/modules/libjpeg-turbo/simd/nasm_lt.sh >@@ -0,0 +1,57 @@ >+#! /bin/sh >+command="" >+infile="" >+o_opt=no >+pic=no >+while [ $# -gt 0 ]; do >+ case "$1" in >+ -DPIC|-fPIC|-fpic|-Kpic|-KPIC) >+ if [ "$pic" != "yes" ] ; then >+ command="$command -DPIC" >+ pic=yes >+ fi >+ ;; >+ -f|-fbin|-faout|-faoutb|-fcoff|-felf|-felf64|-fas86| \ >+ -fobj|-fwin32|-fwin64|-frdf|-fieee|-fmacho|-fmacho64) >+ # it's a file format specifier for nasm. >+ command="$command $1" >+ ;; >+ -f*) >+ # maybe a code-generation flag for gcc. >+ ;; >+ -[Ii]*) >+ incdir=`echo "$1" | sed 's/^-[Ii]//'` >+ if [ "x$incdir" = x -a "x$2" != x ] ; then >+ case "$2" in >+ -*) ;; >+ *) incdir="$2"; shift;; >+ esac >+ fi >+ if [ "x$incdir" != x ] ; then >+ # In the case of NASM, the trailing slash is necessary. >+ incdir=`echo "$incdir" | sed 's%/*$%/%'` >+ command="$command -I$incdir" >+ fi >+ ;; >+ -o*) >+ o_opt=yes >+ command="$command $1" >+ ;; >+ *.asm) >+ infile=$1 >+ command="$command $1" >+ ;; >+ *) >+ command="$command $1" >+ ;; >+ esac >+ shift >+done >+if [ "$o_opt" != yes ] ; then >+ # By default, NASM creates an output file >+ # in the same directory as the input file. >+ outfile="-o `echo $infile | sed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.o" >+ command="$command $outfile" >+fi >+echo $command >+exec $command >diff --git a/jpeg/structure.doc b/modules/libjpeg-turbo/structure.doc >rename from jpeg/structure.doc >rename to modules/libjpeg-turbo/structure.doc >diff --git a/modules/libjpeg-turbo/transupp.c b/modules/libjpeg-turbo/transupp.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/transupp.c >@@ -0,0 +1,928 @@ >+/* >+ * transupp.c >+ * >+ * Copyright (C) 1997, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains image transformation routines and other utility code >+ * used by the jpegtran sample application. These are NOT part of the core >+ * JPEG library. But we keep these routines separate from jpegtran.c to >+ * ease the task of maintaining jpegtran-like programs that have other user >+ * interfaces. >+ */ >+ >+/* Although this file really shouldn't have access to the library internals, >+ * it's helpful to let it call jround_up() and jcopy_block_row(). >+ */ >+#define JPEG_INTERNALS >+ >+#include "jinclude.h" >+#include "jpeglib.h" >+#include "transupp.h" /* My own external interface */ >+ >+ >+#if TRANSFORMS_SUPPORTED >+ >+/* >+ * Lossless image transformation routines. These routines work on DCT >+ * coefficient arrays and thus do not require any lossy decompression >+ * or recompression of the image. >+ * Thanks to Guido Vollbeding for the initial design and code of this feature. >+ * >+ * Horizontal flipping is done in-place, using a single top-to-bottom >+ * pass through the virtual source array. It will thus be much the >+ * fastest option for images larger than main memory. >+ * >+ * The other routines require a set of destination virtual arrays, so they >+ * need twice as much memory as jpegtran normally does. The destination >+ * arrays are always written in normal scan order (top to bottom) because >+ * the virtual array manager expects this. The source arrays will be scanned >+ * in the corresponding order, which means multiple passes through the source >+ * arrays for most of the transforms. That could result in much thrashing >+ * if the image is larger than main memory. >+ * >+ * Some notes about the operating environment of the individual transform >+ * routines: >+ * 1. Both the source and destination virtual arrays are allocated from the >+ * source JPEG object, and therefore should be manipulated by calling the >+ * source's memory manager. >+ * 2. The destination's component count should be used. It may be smaller >+ * than the source's when forcing to grayscale. >+ * 3. Likewise the destination's sampling factors should be used. When >+ * forcing to grayscale the destination's sampling factors will be all 1, >+ * and we may as well take that as the effective iMCU size. >+ * 4. When "trim" is in effect, the destination's dimensions will be the >+ * trimmed values but the source's will be untrimmed. >+ * 5. All the routines assume that the source and destination buffers are >+ * padded out to a full iMCU boundary. This is true, although for the >+ * source buffer it is an undocumented property of jdcoefct.c. >+ * Notes 2,3,4 boil down to this: generally we should use the destination's >+ * dimensions and ignore the source's. >+ */ >+ >+ >+LOCAL(void) >+do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays) >+/* Horizontal flip; done in-place, so no separate dest array is required */ >+{ >+ JDIMENSION MCU_cols, comp_width, blk_x, blk_y; >+ int ci, k, offset_y; >+ JBLOCKARRAY buffer; >+ JCOEFPTR ptr1, ptr2; >+ JCOEF temp1, temp2; >+ jpeg_component_info *compptr; >+ >+ /* Horizontal mirroring of DCT blocks is accomplished by swapping >+ * pairs of blocks in-place. Within a DCT block, we perform horizontal >+ * mirroring by changing the signs of odd-numbered columns. >+ * Partial iMCUs at the right edge are left untouched. >+ */ >+ MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); >+ >+ for (ci = 0; ci < dstinfo->num_components; ci++) { >+ compptr = dstinfo->comp_info + ci; >+ comp_width = MCU_cols * compptr->h_samp_factor; >+ for (blk_y = 0; blk_y < compptr->height_in_blocks; >+ blk_y += compptr->v_samp_factor) { >+ buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y, >+ (JDIMENSION) compptr->v_samp_factor, TRUE); >+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { >+ for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) { >+ ptr1 = buffer[offset_y][blk_x]; >+ ptr2 = buffer[offset_y][comp_width - blk_x - 1]; >+ /* this unrolled loop doesn't need to know which row it's on... */ >+ for (k = 0; k < DCTSIZE2; k += 2) { >+ temp1 = *ptr1; /* swap even column */ >+ temp2 = *ptr2; >+ *ptr1++ = temp2; >+ *ptr2++ = temp1; >+ temp1 = *ptr1; /* swap odd column with sign change */ >+ temp2 = *ptr2; >+ *ptr1++ = -temp2; >+ *ptr2++ = -temp1; >+ } >+ } >+ } >+ } >+ } >+} >+ >+ >+LOCAL(void) >+do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays, >+ jvirt_barray_ptr *dst_coef_arrays) >+/* Vertical flip */ >+{ >+ JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; >+ int ci, i, j, offset_y; >+ JBLOCKARRAY src_buffer, dst_buffer; >+ JBLOCKROW src_row_ptr, dst_row_ptr; >+ JCOEFPTR src_ptr, dst_ptr; >+ jpeg_component_info *compptr; >+ >+ /* We output into a separate array because we can't touch different >+ * rows of the source virtual array simultaneously. Otherwise, this >+ * is a pretty straightforward analog of horizontal flip. >+ * Within a DCT block, vertical mirroring is done by changing the signs >+ * of odd-numbered rows. >+ * Partial iMCUs at the bottom edge are copied verbatim. >+ */ >+ MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); >+ >+ for (ci = 0; ci < dstinfo->num_components; ci++) { >+ compptr = dstinfo->comp_info + ci; >+ comp_height = MCU_rows * compptr->v_samp_factor; >+ for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; >+ dst_blk_y += compptr->v_samp_factor) { >+ dst_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, >+ (JDIMENSION) compptr->v_samp_factor, TRUE); >+ if (dst_blk_y < comp_height) { >+ /* Row is within the mirrorable area. */ >+ src_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], >+ comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, >+ (JDIMENSION) compptr->v_samp_factor, FALSE); >+ } else { >+ /* Bottom-edge blocks will be copied verbatim. */ >+ src_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, >+ (JDIMENSION) compptr->v_samp_factor, FALSE); >+ } >+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { >+ if (dst_blk_y < comp_height) { >+ /* Row is within the mirrorable area. */ >+ dst_row_ptr = dst_buffer[offset_y]; >+ src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; >+ for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; >+ dst_blk_x++) { >+ dst_ptr = dst_row_ptr[dst_blk_x]; >+ src_ptr = src_row_ptr[dst_blk_x]; >+ for (i = 0; i < DCTSIZE; i += 2) { >+ /* copy even row */ >+ for (j = 0; j < DCTSIZE; j++) >+ *dst_ptr++ = *src_ptr++; >+ /* copy odd row with sign change */ >+ for (j = 0; j < DCTSIZE; j++) >+ *dst_ptr++ = - *src_ptr++; >+ } >+ } >+ } else { >+ /* Just copy row verbatim. */ >+ jcopy_block_row(src_buffer[offset_y], dst_buffer[offset_y], >+ compptr->width_in_blocks); >+ } >+ } >+ } >+ } >+} >+ >+ >+LOCAL(void) >+do_transpose (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays, >+ jvirt_barray_ptr *dst_coef_arrays) >+/* Transpose source into destination */ >+{ >+ JDIMENSION dst_blk_x, dst_blk_y; >+ int ci, i, j, offset_x, offset_y; >+ JBLOCKARRAY src_buffer, dst_buffer; >+ JCOEFPTR src_ptr, dst_ptr; >+ jpeg_component_info *compptr; >+ >+ /* Transposing pixels within a block just requires transposing the >+ * DCT coefficients. >+ * Partial iMCUs at the edges require no special treatment; we simply >+ * process all the available DCT blocks for every component. >+ */ >+ for (ci = 0; ci < dstinfo->num_components; ci++) { >+ compptr = dstinfo->comp_info + ci; >+ for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; >+ dst_blk_y += compptr->v_samp_factor) { >+ dst_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, >+ (JDIMENSION) compptr->v_samp_factor, TRUE); >+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { >+ for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; >+ dst_blk_x += compptr->h_samp_factor) { >+ src_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, >+ (JDIMENSION) compptr->h_samp_factor, FALSE); >+ for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { >+ src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; >+ dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; >+ for (i = 0; i < DCTSIZE; i++) >+ for (j = 0; j < DCTSIZE; j++) >+ dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; >+ } >+ } >+ } >+ } >+ } >+} >+ >+ >+LOCAL(void) >+do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays, >+ jvirt_barray_ptr *dst_coef_arrays) >+/* 90 degree rotation is equivalent to >+ * 1. Transposing the image; >+ * 2. Horizontal mirroring. >+ * These two steps are merged into a single processing routine. >+ */ >+{ >+ JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; >+ int ci, i, j, offset_x, offset_y; >+ JBLOCKARRAY src_buffer, dst_buffer; >+ JCOEFPTR src_ptr, dst_ptr; >+ jpeg_component_info *compptr; >+ >+ /* Because of the horizontal mirror step, we can't process partial iMCUs >+ * at the (output) right edge properly. They just get transposed and >+ * not mirrored. >+ */ >+ MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); >+ >+ for (ci = 0; ci < dstinfo->num_components; ci++) { >+ compptr = dstinfo->comp_info + ci; >+ comp_width = MCU_cols * compptr->h_samp_factor; >+ for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; >+ dst_blk_y += compptr->v_samp_factor) { >+ dst_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, >+ (JDIMENSION) compptr->v_samp_factor, TRUE); >+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { >+ for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; >+ dst_blk_x += compptr->h_samp_factor) { >+ src_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, >+ (JDIMENSION) compptr->h_samp_factor, FALSE); >+ for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { >+ src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; >+ if (dst_blk_x < comp_width) { >+ /* Block is within the mirrorable area. */ >+ dst_ptr = dst_buffer[offset_y] >+ [comp_width - dst_blk_x - offset_x - 1]; >+ for (i = 0; i < DCTSIZE; i++) { >+ for (j = 0; j < DCTSIZE; j++) >+ dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; >+ i++; >+ for (j = 0; j < DCTSIZE; j++) >+ dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; >+ } >+ } else { >+ /* Edge blocks are transposed but not mirrored. */ >+ dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; >+ for (i = 0; i < DCTSIZE; i++) >+ for (j = 0; j < DCTSIZE; j++) >+ dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; >+ } >+ } >+ } >+ } >+ } >+ } >+} >+ >+ >+LOCAL(void) >+do_rot_270 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays, >+ jvirt_barray_ptr *dst_coef_arrays) >+/* 270 degree rotation is equivalent to >+ * 1. Horizontal mirroring; >+ * 2. Transposing the image. >+ * These two steps are merged into a single processing routine. >+ */ >+{ >+ JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; >+ int ci, i, j, offset_x, offset_y; >+ JBLOCKARRAY src_buffer, dst_buffer; >+ JCOEFPTR src_ptr, dst_ptr; >+ jpeg_component_info *compptr; >+ >+ /* Because of the horizontal mirror step, we can't process partial iMCUs >+ * at the (output) bottom edge properly. They just get transposed and >+ * not mirrored. >+ */ >+ MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); >+ >+ for (ci = 0; ci < dstinfo->num_components; ci++) { >+ compptr = dstinfo->comp_info + ci; >+ comp_height = MCU_rows * compptr->v_samp_factor; >+ for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; >+ dst_blk_y += compptr->v_samp_factor) { >+ dst_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, >+ (JDIMENSION) compptr->v_samp_factor, TRUE); >+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { >+ for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; >+ dst_blk_x += compptr->h_samp_factor) { >+ src_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, >+ (JDIMENSION) compptr->h_samp_factor, FALSE); >+ for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { >+ dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; >+ if (dst_blk_y < comp_height) { >+ /* Block is within the mirrorable area. */ >+ src_ptr = src_buffer[offset_x] >+ [comp_height - dst_blk_y - offset_y - 1]; >+ for (i = 0; i < DCTSIZE; i++) { >+ for (j = 0; j < DCTSIZE; j++) { >+ dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; >+ j++; >+ dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; >+ } >+ } >+ } else { >+ /* Edge blocks are transposed but not mirrored. */ >+ src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; >+ for (i = 0; i < DCTSIZE; i++) >+ for (j = 0; j < DCTSIZE; j++) >+ dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; >+ } >+ } >+ } >+ } >+ } >+ } >+} >+ >+ >+LOCAL(void) >+do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays, >+ jvirt_barray_ptr *dst_coef_arrays) >+/* 180 degree rotation is equivalent to >+ * 1. Vertical mirroring; >+ * 2. Horizontal mirroring. >+ * These two steps are merged into a single processing routine. >+ */ >+{ >+ JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; >+ int ci, i, j, offset_y; >+ JBLOCKARRAY src_buffer, dst_buffer; >+ JBLOCKROW src_row_ptr, dst_row_ptr; >+ JCOEFPTR src_ptr, dst_ptr; >+ jpeg_component_info *compptr; >+ >+ MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); >+ MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); >+ >+ for (ci = 0; ci < dstinfo->num_components; ci++) { >+ compptr = dstinfo->comp_info + ci; >+ comp_width = MCU_cols * compptr->h_samp_factor; >+ comp_height = MCU_rows * compptr->v_samp_factor; >+ for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; >+ dst_blk_y += compptr->v_samp_factor) { >+ dst_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, >+ (JDIMENSION) compptr->v_samp_factor, TRUE); >+ if (dst_blk_y < comp_height) { >+ /* Row is within the vertically mirrorable area. */ >+ src_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], >+ comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, >+ (JDIMENSION) compptr->v_samp_factor, FALSE); >+ } else { >+ /* Bottom-edge rows are only mirrored horizontally. */ >+ src_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, >+ (JDIMENSION) compptr->v_samp_factor, FALSE); >+ } >+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { >+ if (dst_blk_y < comp_height) { >+ /* Row is within the mirrorable area. */ >+ dst_row_ptr = dst_buffer[offset_y]; >+ src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; >+ /* Process the blocks that can be mirrored both ways. */ >+ for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { >+ dst_ptr = dst_row_ptr[dst_blk_x]; >+ src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; >+ for (i = 0; i < DCTSIZE; i += 2) { >+ /* For even row, negate every odd column. */ >+ for (j = 0; j < DCTSIZE; j += 2) { >+ *dst_ptr++ = *src_ptr++; >+ *dst_ptr++ = - *src_ptr++; >+ } >+ /* For odd row, negate every even column. */ >+ for (j = 0; j < DCTSIZE; j += 2) { >+ *dst_ptr++ = - *src_ptr++; >+ *dst_ptr++ = *src_ptr++; >+ } >+ } >+ } >+ /* Any remaining right-edge blocks are only mirrored vertically. */ >+ for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { >+ dst_ptr = dst_row_ptr[dst_blk_x]; >+ src_ptr = src_row_ptr[dst_blk_x]; >+ for (i = 0; i < DCTSIZE; i += 2) { >+ for (j = 0; j < DCTSIZE; j++) >+ *dst_ptr++ = *src_ptr++; >+ for (j = 0; j < DCTSIZE; j++) >+ *dst_ptr++ = - *src_ptr++; >+ } >+ } >+ } else { >+ /* Remaining rows are just mirrored horizontally. */ >+ dst_row_ptr = dst_buffer[offset_y]; >+ src_row_ptr = src_buffer[offset_y]; >+ /* Process the blocks that can be mirrored. */ >+ for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { >+ dst_ptr = dst_row_ptr[dst_blk_x]; >+ src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; >+ for (i = 0; i < DCTSIZE2; i += 2) { >+ *dst_ptr++ = *src_ptr++; >+ *dst_ptr++ = - *src_ptr++; >+ } >+ } >+ /* Any remaining right-edge blocks are only copied. */ >+ for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { >+ dst_ptr = dst_row_ptr[dst_blk_x]; >+ src_ptr = src_row_ptr[dst_blk_x]; >+ for (i = 0; i < DCTSIZE2; i++) >+ *dst_ptr++ = *src_ptr++; >+ } >+ } >+ } >+ } >+ } >+} >+ >+ >+LOCAL(void) >+do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays, >+ jvirt_barray_ptr *dst_coef_arrays) >+/* Transverse transpose is equivalent to >+ * 1. 180 degree rotation; >+ * 2. Transposition; >+ * or >+ * 1. Horizontal mirroring; >+ * 2. Transposition; >+ * 3. Horizontal mirroring. >+ * These steps are merged into a single processing routine. >+ */ >+{ >+ JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; >+ int ci, i, j, offset_x, offset_y; >+ JBLOCKARRAY src_buffer, dst_buffer; >+ JCOEFPTR src_ptr, dst_ptr; >+ jpeg_component_info *compptr; >+ >+ MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); >+ MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); >+ >+ for (ci = 0; ci < dstinfo->num_components; ci++) { >+ compptr = dstinfo->comp_info + ci; >+ comp_width = MCU_cols * compptr->h_samp_factor; >+ comp_height = MCU_rows * compptr->v_samp_factor; >+ for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; >+ dst_blk_y += compptr->v_samp_factor) { >+ dst_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, >+ (JDIMENSION) compptr->v_samp_factor, TRUE); >+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { >+ for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; >+ dst_blk_x += compptr->h_samp_factor) { >+ src_buffer = (*srcinfo->mem->access_virt_barray) >+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, >+ (JDIMENSION) compptr->h_samp_factor, FALSE); >+ for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { >+ if (dst_blk_y < comp_height) { >+ src_ptr = src_buffer[offset_x] >+ [comp_height - dst_blk_y - offset_y - 1]; >+ if (dst_blk_x < comp_width) { >+ /* Block is within the mirrorable area. */ >+ dst_ptr = dst_buffer[offset_y] >+ [comp_width - dst_blk_x - offset_x - 1]; >+ for (i = 0; i < DCTSIZE; i++) { >+ for (j = 0; j < DCTSIZE; j++) { >+ dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; >+ j++; >+ dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; >+ } >+ i++; >+ for (j = 0; j < DCTSIZE; j++) { >+ dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; >+ j++; >+ dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; >+ } >+ } >+ } else { >+ /* Right-edge blocks are mirrored in y only */ >+ dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; >+ for (i = 0; i < DCTSIZE; i++) { >+ for (j = 0; j < DCTSIZE; j++) { >+ dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; >+ j++; >+ dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; >+ } >+ } >+ } >+ } else { >+ src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; >+ if (dst_blk_x < comp_width) { >+ /* Bottom-edge blocks are mirrored in x only */ >+ dst_ptr = dst_buffer[offset_y] >+ [comp_width - dst_blk_x - offset_x - 1]; >+ for (i = 0; i < DCTSIZE; i++) { >+ for (j = 0; j < DCTSIZE; j++) >+ dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; >+ i++; >+ for (j = 0; j < DCTSIZE; j++) >+ dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; >+ } >+ } else { >+ /* At lower right corner, just transpose, no mirroring */ >+ dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; >+ for (i = 0; i < DCTSIZE; i++) >+ for (j = 0; j < DCTSIZE; j++) >+ dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; >+ } >+ } >+ } >+ } >+ } >+ } >+ } >+} >+ >+ >+/* Request any required workspace. >+ * >+ * We allocate the workspace virtual arrays from the source decompression >+ * object, so that all the arrays (both the original data and the workspace) >+ * will be taken into account while making memory management decisions. >+ * Hence, this routine must be called after jpeg_read_header (which reads >+ * the image dimensions) and before jpeg_read_coefficients (which realizes >+ * the source's virtual arrays). >+ */ >+ >+GLOBAL(void) >+jtransform_request_workspace (j_decompress_ptr srcinfo, >+ jpeg_transform_info *info) >+{ >+ jvirt_barray_ptr *coef_arrays = NULL; >+ jpeg_component_info *compptr; >+ int ci; >+ >+ if (info->force_grayscale && >+ srcinfo->jpeg_color_space == JCS_YCbCr && >+ srcinfo->num_components == 3) { >+ /* We'll only process the first component */ >+ info->num_components = 1; >+ } else { >+ /* Process all the components */ >+ info->num_components = srcinfo->num_components; >+ } >+ >+ switch (info->transform) { >+ case JXFORM_NONE: >+ case JXFORM_FLIP_H: >+ /* Don't need a workspace array */ >+ break; >+ case JXFORM_FLIP_V: >+ case JXFORM_ROT_180: >+ /* Need workspace arrays having same dimensions as source image. >+ * Note that we allocate arrays padded out to the next iMCU boundary, >+ * so that transform routines need not worry about missing edge blocks. >+ */ >+ coef_arrays = (jvirt_barray_ptr *) >+ (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, >+ SIZEOF(jvirt_barray_ptr) * info->num_components); >+ for (ci = 0; ci < info->num_components; ci++) { >+ compptr = srcinfo->comp_info + ci; >+ coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) >+ ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, >+ (JDIMENSION) jround_up((long) compptr->width_in_blocks, >+ (long) compptr->h_samp_factor), >+ (JDIMENSION) jround_up((long) compptr->height_in_blocks, >+ (long) compptr->v_samp_factor), >+ (JDIMENSION) compptr->v_samp_factor); >+ } >+ break; >+ case JXFORM_TRANSPOSE: >+ case JXFORM_TRANSVERSE: >+ case JXFORM_ROT_90: >+ case JXFORM_ROT_270: >+ /* Need workspace arrays having transposed dimensions. >+ * Note that we allocate arrays padded out to the next iMCU boundary, >+ * so that transform routines need not worry about missing edge blocks. >+ */ >+ coef_arrays = (jvirt_barray_ptr *) >+ (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, >+ SIZEOF(jvirt_barray_ptr) * info->num_components); >+ for (ci = 0; ci < info->num_components; ci++) { >+ compptr = srcinfo->comp_info + ci; >+ coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) >+ ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, >+ (JDIMENSION) jround_up((long) compptr->height_in_blocks, >+ (long) compptr->v_samp_factor), >+ (JDIMENSION) jround_up((long) compptr->width_in_blocks, >+ (long) compptr->h_samp_factor), >+ (JDIMENSION) compptr->h_samp_factor); >+ } >+ break; >+ } >+ info->workspace_coef_arrays = coef_arrays; >+} >+ >+ >+/* Transpose destination image parameters */ >+ >+LOCAL(void) >+transpose_critical_parameters (j_compress_ptr dstinfo) >+{ >+ int tblno, i, j, ci, itemp; >+ jpeg_component_info *compptr; >+ JQUANT_TBL *qtblptr; >+ JDIMENSION dtemp; >+ UINT16 qtemp; >+ >+ /* Transpose basic image dimensions */ >+ dtemp = dstinfo->image_width; >+ dstinfo->image_width = dstinfo->image_height; >+ dstinfo->image_height = dtemp; >+ >+ /* Transpose sampling factors */ >+ for (ci = 0; ci < dstinfo->num_components; ci++) { >+ compptr = dstinfo->comp_info + ci; >+ itemp = compptr->h_samp_factor; >+ compptr->h_samp_factor = compptr->v_samp_factor; >+ compptr->v_samp_factor = itemp; >+ } >+ >+ /* Transpose quantization tables */ >+ for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { >+ qtblptr = dstinfo->quant_tbl_ptrs[tblno]; >+ if (qtblptr != NULL) { >+ for (i = 0; i < DCTSIZE; i++) { >+ for (j = 0; j < i; j++) { >+ qtemp = qtblptr->quantval[i*DCTSIZE+j]; >+ qtblptr->quantval[i*DCTSIZE+j] = qtblptr->quantval[j*DCTSIZE+i]; >+ qtblptr->quantval[j*DCTSIZE+i] = qtemp; >+ } >+ } >+ } >+ } >+} >+ >+ >+/* Trim off any partial iMCUs on the indicated destination edge */ >+ >+LOCAL(void) >+trim_right_edge (j_compress_ptr dstinfo) >+{ >+ int ci, max_h_samp_factor; >+ JDIMENSION MCU_cols; >+ >+ /* We have to compute max_h_samp_factor ourselves, >+ * because it hasn't been set yet in the destination >+ * (and we don't want to use the source's value). >+ */ >+ max_h_samp_factor = 1; >+ for (ci = 0; ci < dstinfo->num_components; ci++) { >+ int h_samp_factor = dstinfo->comp_info[ci].h_samp_factor; >+ max_h_samp_factor = MAX(max_h_samp_factor, h_samp_factor); >+ } >+ MCU_cols = dstinfo->image_width / (max_h_samp_factor * DCTSIZE); >+ if (MCU_cols > 0) /* can't trim to 0 pixels */ >+ dstinfo->image_width = MCU_cols * (max_h_samp_factor * DCTSIZE); >+} >+ >+LOCAL(void) >+trim_bottom_edge (j_compress_ptr dstinfo) >+{ >+ int ci, max_v_samp_factor; >+ JDIMENSION MCU_rows; >+ >+ /* We have to compute max_v_samp_factor ourselves, >+ * because it hasn't been set yet in the destination >+ * (and we don't want to use the source's value). >+ */ >+ max_v_samp_factor = 1; >+ for (ci = 0; ci < dstinfo->num_components; ci++) { >+ int v_samp_factor = dstinfo->comp_info[ci].v_samp_factor; >+ max_v_samp_factor = MAX(max_v_samp_factor, v_samp_factor); >+ } >+ MCU_rows = dstinfo->image_height / (max_v_samp_factor * DCTSIZE); >+ if (MCU_rows > 0) /* can't trim to 0 pixels */ >+ dstinfo->image_height = MCU_rows * (max_v_samp_factor * DCTSIZE); >+} >+ >+ >+/* Adjust output image parameters as needed. >+ * >+ * This must be called after jpeg_copy_critical_parameters() >+ * and before jpeg_write_coefficients(). >+ * >+ * The return value is the set of virtual coefficient arrays to be written >+ * (either the ones allocated by jtransform_request_workspace, or the >+ * original source data arrays). The caller will need to pass this value >+ * to jpeg_write_coefficients(). >+ */ >+ >+GLOBAL(jvirt_barray_ptr *) >+jtransform_adjust_parameters (j_decompress_ptr srcinfo, >+ j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays, >+ jpeg_transform_info *info) >+{ >+ /* If force-to-grayscale is requested, adjust destination parameters */ >+ if (info->force_grayscale) { >+ /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed >+ * properly. Among other things, the target h_samp_factor & v_samp_factor >+ * will get set to 1, which typically won't match the source. >+ * In fact we do this even if the source is already grayscale; that >+ * provides an easy way of coercing a grayscale JPEG with funny sampling >+ * factors to the customary 1,1. (Some decoders fail on other factors.) >+ */ >+ if ((dstinfo->jpeg_color_space == JCS_YCbCr && >+ dstinfo->num_components == 3) || >+ (dstinfo->jpeg_color_space == JCS_GRAYSCALE && >+ dstinfo->num_components == 1)) { >+ /* We have to preserve the source's quantization table number. */ >+ int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no; >+ jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE); >+ dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no; >+ } else { >+ /* Sorry, can't do it */ >+ ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL); >+ } >+ } >+ >+ /* Correct the destination's image dimensions etc if necessary */ >+ switch (info->transform) { >+ case JXFORM_NONE: >+ /* Nothing to do */ >+ break; >+ case JXFORM_FLIP_H: >+ if (info->trim) >+ trim_right_edge(dstinfo); >+ break; >+ case JXFORM_FLIP_V: >+ if (info->trim) >+ trim_bottom_edge(dstinfo); >+ break; >+ case JXFORM_TRANSPOSE: >+ transpose_critical_parameters(dstinfo); >+ /* transpose does NOT have to trim anything */ >+ break; >+ case JXFORM_TRANSVERSE: >+ transpose_critical_parameters(dstinfo); >+ if (info->trim) { >+ trim_right_edge(dstinfo); >+ trim_bottom_edge(dstinfo); >+ } >+ break; >+ case JXFORM_ROT_90: >+ transpose_critical_parameters(dstinfo); >+ if (info->trim) >+ trim_right_edge(dstinfo); >+ break; >+ case JXFORM_ROT_180: >+ if (info->trim) { >+ trim_right_edge(dstinfo); >+ trim_bottom_edge(dstinfo); >+ } >+ break; >+ case JXFORM_ROT_270: >+ transpose_critical_parameters(dstinfo); >+ if (info->trim) >+ trim_bottom_edge(dstinfo); >+ break; >+ } >+ >+ /* Return the appropriate output data set */ >+ if (info->workspace_coef_arrays != NULL) >+ return info->workspace_coef_arrays; >+ return src_coef_arrays; >+} >+ >+ >+/* Execute the actual transformation, if any. >+ * >+ * This must be called *after* jpeg_write_coefficients, because it depends >+ * on jpeg_write_coefficients to have computed subsidiary values such as >+ * the per-component width and height fields in the destination object. >+ * >+ * Note that some transformations will modify the source data arrays! >+ */ >+ >+GLOBAL(void) >+jtransform_execute_transformation (j_decompress_ptr srcinfo, >+ j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays, >+ jpeg_transform_info *info) >+{ >+ jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays; >+ >+ switch (info->transform) { >+ case JXFORM_NONE: >+ break; >+ case JXFORM_FLIP_H: >+ do_flip_h(srcinfo, dstinfo, src_coef_arrays); >+ break; >+ case JXFORM_FLIP_V: >+ do_flip_v(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); >+ break; >+ case JXFORM_TRANSPOSE: >+ do_transpose(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); >+ break; >+ case JXFORM_TRANSVERSE: >+ do_transverse(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); >+ break; >+ case JXFORM_ROT_90: >+ do_rot_90(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); >+ break; >+ case JXFORM_ROT_180: >+ do_rot_180(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); >+ break; >+ case JXFORM_ROT_270: >+ do_rot_270(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); >+ break; >+ } >+} >+ >+#endif /* TRANSFORMS_SUPPORTED */ >+ >+ >+/* Setup decompression object to save desired markers in memory. >+ * This must be called before jpeg_read_header() to have the desired effect. >+ */ >+ >+GLOBAL(void) >+jcopy_markers_setup (j_decompress_ptr srcinfo, JCOPY_OPTION option) >+{ >+#ifdef SAVE_MARKERS_SUPPORTED >+ int m; >+ >+ /* Save comments except under NONE option */ >+ if (option != JCOPYOPT_NONE) { >+ jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF); >+ } >+ /* Save all types of APPn markers iff ALL option */ >+ if (option == JCOPYOPT_ALL) { >+ for (m = 0; m < 16; m++) >+ jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF); >+ } >+#endif /* SAVE_MARKERS_SUPPORTED */ >+} >+ >+/* Copy markers saved in the given source object to the destination object. >+ * This should be called just after jpeg_start_compress() or >+ * jpeg_write_coefficients(). >+ * Note that those routines will have written the SOI, and also the >+ * JFIF APP0 or Adobe APP14 markers if selected. >+ */ >+ >+GLOBAL(void) >+jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ JCOPY_OPTION option) >+{ >+ jpeg_saved_marker_ptr marker; >+ >+ /* In the current implementation, we don't actually need to examine the >+ * option flag here; we just copy everything that got saved. >+ * But to avoid confusion, we do not output JFIF and Adobe APP14 markers >+ * if the encoder library already wrote one. >+ */ >+ for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) { >+ if (dstinfo->write_JFIF_header && >+ marker->marker == JPEG_APP0 && >+ marker->data_length >= 5 && >+ GETJOCTET(marker->data[0]) == 0x4A && >+ GETJOCTET(marker->data[1]) == 0x46 && >+ GETJOCTET(marker->data[2]) == 0x49 && >+ GETJOCTET(marker->data[3]) == 0x46 && >+ GETJOCTET(marker->data[4]) == 0) >+ continue; /* reject duplicate JFIF */ >+ if (dstinfo->write_Adobe_marker && >+ marker->marker == JPEG_APP0+14 && >+ marker->data_length >= 5 && >+ GETJOCTET(marker->data[0]) == 0x41 && >+ GETJOCTET(marker->data[1]) == 0x64 && >+ GETJOCTET(marker->data[2]) == 0x6F && >+ GETJOCTET(marker->data[3]) == 0x62 && >+ GETJOCTET(marker->data[4]) == 0x65) >+ continue; /* reject duplicate Adobe */ >+#ifdef NEED_FAR_POINTERS >+ /* We could use jpeg_write_marker if the data weren't FAR... */ >+ { >+ unsigned int i; >+ jpeg_write_m_header(dstinfo, marker->marker, marker->data_length); >+ for (i = 0; i < marker->data_length; i++) >+ jpeg_write_m_byte(dstinfo, marker->data[i]); >+ } >+#else >+ jpeg_write_marker(dstinfo, marker->marker, >+ marker->data, marker->data_length); >+#endif >+ } >+} >diff --git a/modules/libjpeg-turbo/transupp.h b/modules/libjpeg-turbo/transupp.h >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/transupp.h >@@ -0,0 +1,135 @@ >+/* >+ * transupp.h >+ * >+ * Copyright (C) 1997, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains declarations for image transformation routines and >+ * other utility code used by the jpegtran sample application. These are >+ * NOT part of the core JPEG library. But we keep these routines separate >+ * from jpegtran.c to ease the task of maintaining jpegtran-like programs >+ * that have other user interfaces. >+ * >+ * NOTE: all the routines declared here have very specific requirements >+ * about when they are to be executed during the reading and writing of the >+ * source and destination files. See the comments in transupp.c, or see >+ * jpegtran.c for an example of correct usage. >+ */ >+ >+/* If you happen not to want the image transform support, disable it here */ >+#ifndef TRANSFORMS_SUPPORTED >+#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ >+#endif >+ >+/* Short forms of external names for systems with brain-damaged linkers. */ >+ >+#ifdef NEED_SHORT_EXTERNAL_NAMES >+#define jtransform_request_workspace jTrRequest >+#define jtransform_adjust_parameters jTrAdjust >+#define jtransform_execute_transformation jTrExec >+#define jcopy_markers_setup jCMrkSetup >+#define jcopy_markers_execute jCMrkExec >+#endif /* NEED_SHORT_EXTERNAL_NAMES */ >+ >+ >+/* >+ * Codes for supported types of image transformations. >+ */ >+ >+typedef enum { >+ JXFORM_NONE, /* no transformation */ >+ JXFORM_FLIP_H, /* horizontal flip */ >+ JXFORM_FLIP_V, /* vertical flip */ >+ JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ >+ JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ >+ JXFORM_ROT_90, /* 90-degree clockwise rotation */ >+ JXFORM_ROT_180, /* 180-degree rotation */ >+ JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ >+} JXFORM_CODE; >+ >+/* >+ * Although rotating and flipping data expressed as DCT coefficients is not >+ * hard, there is an asymmetry in the JPEG format specification for images >+ * whose dimensions aren't multiples of the iMCU size. The right and bottom >+ * image edges are padded out to the next iMCU boundary with junk data; but >+ * no padding is possible at the top and left edges. If we were to flip >+ * the whole image including the pad data, then pad garbage would become >+ * visible at the top and/or left, and real pixels would disappear into the >+ * pad margins --- perhaps permanently, since encoders & decoders may not >+ * bother to preserve DCT blocks that appear to be completely outside the >+ * nominal image area. So, we have to exclude any partial iMCUs from the >+ * basic transformation. >+ * >+ * Transpose is the only transformation that can handle partial iMCUs at the >+ * right and bottom edges completely cleanly. flip_h can flip partial iMCUs >+ * at the bottom, but leaves any partial iMCUs at the right edge untouched. >+ * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched. >+ * The other transforms are defined as combinations of these basic transforms >+ * and process edge blocks in a way that preserves the equivalence. >+ * >+ * The "trim" option causes untransformable partial iMCUs to be dropped; >+ * this is not strictly lossless, but it usually gives the best-looking >+ * result for odd-size images. Note that when this option is active, >+ * the expected mathematical equivalences between the transforms may not hold. >+ * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim >+ * followed by -rot 180 -trim trims both edges.) >+ * >+ * We also offer a "force to grayscale" option, which simply discards the >+ * chrominance channels of a YCbCr image. This is lossless in the sense that >+ * the luminance channel is preserved exactly. It's not the same kind of >+ * thing as the rotate/flip transformations, but it's convenient to handle it >+ * as part of this package, mainly because the transformation routines have to >+ * be aware of the option to know how many components to work on. >+ */ >+ >+typedef struct { >+ /* Options: set by caller */ >+ JXFORM_CODE transform; /* image transform operator */ >+ boolean trim; /* if TRUE, trim partial MCUs as needed */ >+ boolean force_grayscale; /* if TRUE, convert color image to grayscale */ >+ >+ /* Internal workspace: caller should not touch these */ >+ int num_components; /* # of components in workspace */ >+ jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ >+} jpeg_transform_info; >+ >+ >+#if TRANSFORMS_SUPPORTED >+ >+/* Request any required workspace */ >+EXTERN(void) jtransform_request_workspace >+ JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); >+/* Adjust output image parameters */ >+EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters >+ JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays, >+ jpeg_transform_info *info)); >+/* Execute the actual transformation, if any */ >+EXTERN(void) jtransform_execute_transformation >+ JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ jvirt_barray_ptr *src_coef_arrays, >+ jpeg_transform_info *info)); >+ >+#endif /* TRANSFORMS_SUPPORTED */ >+ >+ >+/* >+ * Support for copying optional markers from source to destination file. >+ */ >+ >+typedef enum { >+ JCOPYOPT_NONE, /* copy no optional markers */ >+ JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */ >+ JCOPYOPT_ALL /* copy all optional markers */ >+} JCOPY_OPTION; >+ >+#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */ >+ >+/* Setup decompression object to save desired markers in memory */ >+EXTERN(void) jcopy_markers_setup >+ JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option)); >+/* Copy markers saved in the given source object to the destination object */ >+EXTERN(void) jcopy_markers_execute >+ JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, >+ JCOPY_OPTION option)); >diff --git a/modules/libjpeg-turbo/turbojpeg-mapfile b/modules/libjpeg-turbo/turbojpeg-mapfile >new file mode 100755 >--- /dev/null >+++ b/modules/libjpeg-turbo/turbojpeg-mapfile >@@ -0,0 +1,13 @@ >+{ >+ global: >+ tjInitCompress; >+ tjCompress; >+ TJBUFSIZE; >+ tjInitDecompress; >+ tjDecompressHeader; >+ tjDecompress; >+ tjDestroy; >+ tjGetErrorStr; >+ local: >+ *; >+}; >diff --git a/jpeg/usage.doc b/modules/libjpeg-turbo/usage.doc >rename from jpeg/usage.doc >rename to modules/libjpeg-turbo/usage.doc >diff --git a/jpeg/wizard.doc b/modules/libjpeg-turbo/wizard.doc >rename from jpeg/wizard.doc >rename to modules/libjpeg-turbo/wizard.doc >diff --git a/modules/libjpeg-turbo/wrbmp.c b/modules/libjpeg-turbo/wrbmp.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/wrbmp.c >@@ -0,0 +1,442 @@ >+/* >+ * wrbmp.c >+ * >+ * Copyright (C) 1994-1996, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to write output images in Microsoft "BMP" >+ * format (MS Windows 3.x and OS/2 1.x flavors). >+ * Either 8-bit colormapped or 24-bit full-color format can be written. >+ * No compression is supported. >+ * >+ * These routines may need modification for non-Unix environments or >+ * specialized applications. As they stand, they assume output to >+ * an ordinary stdio stream. >+ * >+ * This code contributed by James Arthur Boucher. >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef BMP_SUPPORTED >+ >+ >+/* >+ * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. >+ * This is not yet implemented. >+ */ >+ >+#if BITS_IN_JSAMPLE != 8 >+ Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ >+#endif >+ >+/* >+ * Since BMP stores scanlines bottom-to-top, we have to invert the image >+ * from JPEG's top-to-bottom order. To do this, we save the outgoing data >+ * in a virtual array during put_pixel_row calls, then actually emit the >+ * BMP file during finish_output. The virtual array contains one JSAMPLE per >+ * pixel if the output is grayscale or colormapped, three if it is full color. >+ */ >+ >+/* Private version of data destination object */ >+ >+typedef struct { >+ struct djpeg_dest_struct pub; /* public fields */ >+ >+ boolean is_os2; /* saves the OS2 format request flag */ >+ >+ jvirt_sarray_ptr whole_image; /* needed to reverse row order */ >+ JDIMENSION data_width; /* JSAMPLEs per row */ >+ JDIMENSION row_width; /* physical width of one row in the BMP file */ >+ int pad_bytes; /* number of padding bytes needed per row */ >+ JDIMENSION cur_output_row; /* next row# to write to virtual array */ >+} bmp_dest_struct; >+ >+typedef bmp_dest_struct * bmp_dest_ptr; >+ >+ >+/* Forward declarations */ >+LOCAL(void) write_colormap >+ JPP((j_decompress_ptr cinfo, bmp_dest_ptr dest, >+ int map_colors, int map_entry_size)); >+ >+ >+/* >+ * Write some pixel data. >+ * In this module rows_supplied will always be 1. >+ */ >+ >+METHODDEF(void) >+put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+/* This version is for writing 24-bit pixels */ >+{ >+ bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; >+ JSAMPARRAY image_ptr; >+ register JSAMPROW inptr, outptr; >+ register JDIMENSION col; >+ int pad; >+ >+ /* Access next row in virtual array */ >+ image_ptr = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, dest->whole_image, >+ dest->cur_output_row, (JDIMENSION) 1, TRUE); >+ dest->cur_output_row++; >+ >+ /* Transfer data. Note destination values must be in BGR order >+ * (even though Microsoft's own documents say the opposite). >+ */ >+ inptr = dest->pub.buffer[0]; >+ outptr = image_ptr[0]; >+ for (col = cinfo->output_width; col > 0; col--) { >+ outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ >+ outptr[1] = *inptr++; >+ outptr[0] = *inptr++; >+ outptr += 3; >+ } >+ >+ /* Zero out the pad bytes. */ >+ pad = dest->pad_bytes; >+ while (--pad >= 0) >+ *outptr++ = 0; >+} >+ >+METHODDEF(void) >+put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+/* This version is for grayscale OR quantized color output */ >+{ >+ bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; >+ JSAMPARRAY image_ptr; >+ register JSAMPROW inptr, outptr; >+ register JDIMENSION col; >+ int pad; >+ >+ /* Access next row in virtual array */ >+ image_ptr = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, dest->whole_image, >+ dest->cur_output_row, (JDIMENSION) 1, TRUE); >+ dest->cur_output_row++; >+ >+ /* Transfer data. */ >+ inptr = dest->pub.buffer[0]; >+ outptr = image_ptr[0]; >+ for (col = cinfo->output_width; col > 0; col--) { >+ *outptr++ = *inptr++; /* can omit GETJSAMPLE() safely */ >+ } >+ >+ /* Zero out the pad bytes. */ >+ pad = dest->pad_bytes; >+ while (--pad >= 0) >+ *outptr++ = 0; >+} >+ >+ >+/* >+ * Startup: normally writes the file header. >+ * In this module we may as well postpone everything until finish_output. >+ */ >+ >+METHODDEF(void) >+start_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) >+{ >+ /* no work here */ >+} >+ >+ >+/* >+ * Finish up at the end of the file. >+ * >+ * Here is where we really output the BMP file. >+ * >+ * First, routines to write the Windows and OS/2 variants of the file header. >+ */ >+ >+LOCAL(void) >+write_bmp_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) >+/* Write a Windows-style BMP file header, including colormap if needed */ >+{ >+ char bmpfileheader[14]; >+ char bmpinfoheader[40]; >+#define PUT_2B(array,offset,value) \ >+ (array[offset] = (char) ((value) & 0xFF), \ >+ array[offset+1] = (char) (((value) >> 8) & 0xFF)) >+#define PUT_4B(array,offset,value) \ >+ (array[offset] = (char) ((value) & 0xFF), \ >+ array[offset+1] = (char) (((value) >> 8) & 0xFF), \ >+ array[offset+2] = (char) (((value) >> 16) & 0xFF), \ >+ array[offset+3] = (char) (((value) >> 24) & 0xFF)) >+ INT32 headersize, bfSize; >+ int bits_per_pixel, cmap_entries; >+ >+ /* Compute colormap size and total file size */ >+ if (cinfo->out_color_space == JCS_RGB) { >+ if (cinfo->quantize_colors) { >+ /* Colormapped RGB */ >+ bits_per_pixel = 8; >+ cmap_entries = 256; >+ } else { >+ /* Unquantized, full color RGB */ >+ bits_per_pixel = 24; >+ cmap_entries = 0; >+ } >+ } else { >+ /* Grayscale output. We need to fake a 256-entry colormap. */ >+ bits_per_pixel = 8; >+ cmap_entries = 256; >+ } >+ /* File size */ >+ headersize = 14 + 40 + cmap_entries * 4; /* Header and colormap */ >+ bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; >+ >+ /* Set unused fields of header to 0 */ >+ MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); >+ MEMZERO(bmpinfoheader, SIZEOF(bmpinfoheader)); >+ >+ /* Fill the file header */ >+ bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ >+ bmpfileheader[1] = 0x4D; >+ PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ >+ /* we leave bfReserved1 & bfReserved2 = 0 */ >+ PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ >+ >+ /* Fill the info header (Microsoft calls this a BITMAPINFOHEADER) */ >+ PUT_2B(bmpinfoheader, 0, 40); /* biSize */ >+ PUT_4B(bmpinfoheader, 4, cinfo->output_width); /* biWidth */ >+ PUT_4B(bmpinfoheader, 8, cinfo->output_height); /* biHeight */ >+ PUT_2B(bmpinfoheader, 12, 1); /* biPlanes - must be 1 */ >+ PUT_2B(bmpinfoheader, 14, bits_per_pixel); /* biBitCount */ >+ /* we leave biCompression = 0, for none */ >+ /* we leave biSizeImage = 0; this is correct for uncompressed data */ >+ if (cinfo->density_unit == 2) { /* if have density in dots/cm, then */ >+ PUT_4B(bmpinfoheader, 24, (INT32) (cinfo->X_density*100)); /* XPels/M */ >+ PUT_4B(bmpinfoheader, 28, (INT32) (cinfo->Y_density*100)); /* XPels/M */ >+ } >+ PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */ >+ /* we leave biClrImportant = 0 */ >+ >+ if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) >+ ERREXIT(cinfo, JERR_FILE_WRITE); >+ if (JFWRITE(dest->pub.output_file, bmpinfoheader, 40) != (size_t) 40) >+ ERREXIT(cinfo, JERR_FILE_WRITE); >+ >+ if (cmap_entries > 0) >+ write_colormap(cinfo, dest, cmap_entries, 4); >+} >+ >+ >+LOCAL(void) >+write_os2_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) >+/* Write an OS2-style BMP file header, including colormap if needed */ >+{ >+ char bmpfileheader[14]; >+ char bmpcoreheader[12]; >+ INT32 headersize, bfSize; >+ int bits_per_pixel, cmap_entries; >+ >+ /* Compute colormap size and total file size */ >+ if (cinfo->out_color_space == JCS_RGB) { >+ if (cinfo->quantize_colors) { >+ /* Colormapped RGB */ >+ bits_per_pixel = 8; >+ cmap_entries = 256; >+ } else { >+ /* Unquantized, full color RGB */ >+ bits_per_pixel = 24; >+ cmap_entries = 0; >+ } >+ } else { >+ /* Grayscale output. We need to fake a 256-entry colormap. */ >+ bits_per_pixel = 8; >+ cmap_entries = 256; >+ } >+ /* File size */ >+ headersize = 14 + 12 + cmap_entries * 3; /* Header and colormap */ >+ bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; >+ >+ /* Set unused fields of header to 0 */ >+ MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); >+ MEMZERO(bmpcoreheader, SIZEOF(bmpcoreheader)); >+ >+ /* Fill the file header */ >+ bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ >+ bmpfileheader[1] = 0x4D; >+ PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ >+ /* we leave bfReserved1 & bfReserved2 = 0 */ >+ PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ >+ >+ /* Fill the info header (Microsoft calls this a BITMAPCOREHEADER) */ >+ PUT_2B(bmpcoreheader, 0, 12); /* bcSize */ >+ PUT_2B(bmpcoreheader, 4, cinfo->output_width); /* bcWidth */ >+ PUT_2B(bmpcoreheader, 6, cinfo->output_height); /* bcHeight */ >+ PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */ >+ PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */ >+ >+ if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) >+ ERREXIT(cinfo, JERR_FILE_WRITE); >+ if (JFWRITE(dest->pub.output_file, bmpcoreheader, 12) != (size_t) 12) >+ ERREXIT(cinfo, JERR_FILE_WRITE); >+ >+ if (cmap_entries > 0) >+ write_colormap(cinfo, dest, cmap_entries, 3); >+} >+ >+ >+/* >+ * Write the colormap. >+ * Windows uses BGR0 map entries; OS/2 uses BGR entries. >+ */ >+ >+LOCAL(void) >+write_colormap (j_decompress_ptr cinfo, bmp_dest_ptr dest, >+ int map_colors, int map_entry_size) >+{ >+ JSAMPARRAY colormap = cinfo->colormap; >+ int num_colors = cinfo->actual_number_of_colors; >+ FILE * outfile = dest->pub.output_file; >+ int i; >+ >+ if (colormap != NULL) { >+ if (cinfo->out_color_components == 3) { >+ /* Normal case with RGB colormap */ >+ for (i = 0; i < num_colors; i++) { >+ putc(GETJSAMPLE(colormap[2][i]), outfile); >+ putc(GETJSAMPLE(colormap[1][i]), outfile); >+ putc(GETJSAMPLE(colormap[0][i]), outfile); >+ if (map_entry_size == 4) >+ putc(0, outfile); >+ } >+ } else { >+ /* Grayscale colormap (only happens with grayscale quantization) */ >+ for (i = 0; i < num_colors; i++) { >+ putc(GETJSAMPLE(colormap[0][i]), outfile); >+ putc(GETJSAMPLE(colormap[0][i]), outfile); >+ putc(GETJSAMPLE(colormap[0][i]), outfile); >+ if (map_entry_size == 4) >+ putc(0, outfile); >+ } >+ } >+ } else { >+ /* If no colormap, must be grayscale data. Generate a linear "map". */ >+ for (i = 0; i < 256; i++) { >+ putc(i, outfile); >+ putc(i, outfile); >+ putc(i, outfile); >+ if (map_entry_size == 4) >+ putc(0, outfile); >+ } >+ } >+ /* Pad colormap with zeros to ensure specified number of colormap entries */ >+ if (i > map_colors) >+ ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, i); >+ for (; i < map_colors; i++) { >+ putc(0, outfile); >+ putc(0, outfile); >+ putc(0, outfile); >+ if (map_entry_size == 4) >+ putc(0, outfile); >+ } >+} >+ >+ >+METHODDEF(void) >+finish_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) >+{ >+ bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; >+ register FILE * outfile = dest->pub.output_file; >+ JSAMPARRAY image_ptr; >+ register JSAMPROW data_ptr; >+ JDIMENSION row; >+ register JDIMENSION col; >+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; >+ >+ /* Write the header and colormap */ >+ if (dest->is_os2) >+ write_os2_header(cinfo, dest); >+ else >+ write_bmp_header(cinfo, dest); >+ >+ /* Write the file body from our virtual array */ >+ for (row = cinfo->output_height; row > 0; row--) { >+ if (progress != NULL) { >+ progress->pub.pass_counter = (long) (cinfo->output_height - row); >+ progress->pub.pass_limit = (long) cinfo->output_height; >+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); >+ } >+ image_ptr = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, dest->whole_image, row-1, (JDIMENSION) 1, FALSE); >+ data_ptr = image_ptr[0]; >+ for (col = dest->row_width; col > 0; col--) { >+ putc(GETJSAMPLE(*data_ptr), outfile); >+ data_ptr++; >+ } >+ } >+ if (progress != NULL) >+ progress->completed_extra_passes++; >+ >+ /* Make sure we wrote the output file OK */ >+ fflush(outfile); >+ if (ferror(outfile)) >+ ERREXIT(cinfo, JERR_FILE_WRITE); >+} >+ >+ >+/* >+ * The module selection routine for BMP format output. >+ */ >+ >+GLOBAL(djpeg_dest_ptr) >+jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2) >+{ >+ bmp_dest_ptr dest; >+ JDIMENSION row_width; >+ >+ /* Create module interface object, fill in method pointers */ >+ dest = (bmp_dest_ptr) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(bmp_dest_struct)); >+ dest->pub.start_output = start_output_bmp; >+ dest->pub.finish_output = finish_output_bmp; >+ dest->is_os2 = is_os2; >+ >+ if (cinfo->out_color_space == JCS_GRAYSCALE) { >+ dest->pub.put_pixel_rows = put_gray_rows; >+ } else if (cinfo->out_color_space == JCS_RGB) { >+ if (cinfo->quantize_colors) >+ dest->pub.put_pixel_rows = put_gray_rows; >+ else >+ dest->pub.put_pixel_rows = put_pixel_rows; >+ } else { >+ ERREXIT(cinfo, JERR_BMP_COLORSPACE); >+ } >+ >+ /* Calculate output image dimensions so we can allocate space */ >+ jpeg_calc_output_dimensions(cinfo); >+ >+ /* Determine width of rows in the BMP file (padded to 4-byte boundary). */ >+ row_width = cinfo->output_width * cinfo->output_components; >+ dest->data_width = row_width; >+ while ((row_width & 3) != 0) row_width++; >+ dest->row_width = row_width; >+ dest->pad_bytes = (int) (row_width - dest->data_width); >+ >+ /* Allocate space for inversion array, prepare for write pass */ >+ dest->whole_image = (*cinfo->mem->request_virt_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, >+ row_width, cinfo->output_height, (JDIMENSION) 1); >+ dest->cur_output_row = 0; >+ if (cinfo->progress != NULL) { >+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; >+ progress->total_extra_passes++; /* count file input as separate pass */ >+ } >+ >+ /* Create decompressor output buffer. */ >+ dest->pub.buffer = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, row_width, (JDIMENSION) 1); >+ dest->pub.buffer_height = 1; >+ >+ return (djpeg_dest_ptr) dest; >+} >+ >+#endif /* BMP_SUPPORTED */ >diff --git a/modules/libjpeg-turbo/wrgif.c b/modules/libjpeg-turbo/wrgif.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/wrgif.c >@@ -0,0 +1,399 @@ >+/* >+ * wrgif.c >+ * >+ * Copyright (C) 1991-1997, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to write output images in GIF format. >+ * >+ ************************************************************************** >+ * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * >+ * this code has been modified to output "uncompressed GIF" files. * >+ * There is no trace of the LZW algorithm in this file. * >+ ************************************************************************** >+ * >+ * These routines may need modification for non-Unix environments or >+ * specialized applications. As they stand, they assume output to >+ * an ordinary stdio stream. >+ */ >+ >+/* >+ * This code is loosely based on ppmtogif from the PBMPLUS distribution >+ * of Feb. 1991. That file contains the following copyright notice: >+ * Based on GIFENCODE by David Rowley <mgardi@watdscu.waterloo.edu>. >+ * Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al. >+ * Copyright (C) 1989 by Jef Poskanzer. >+ * Permission to use, copy, modify, and distribute this software and its >+ * documentation for any purpose and without fee is hereby granted, provided >+ * that the above copyright notice appear in all copies and that both that >+ * copyright notice and this permission notice appear in supporting >+ * documentation. This software is provided "as is" without express or >+ * implied warranty. >+ * >+ * We are also required to state that >+ * "The Graphics Interchange Format(c) is the Copyright property of >+ * CompuServe Incorporated. GIF(sm) is a Service Mark property of >+ * CompuServe Incorporated." >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef GIF_SUPPORTED >+ >+ >+/* Private version of data destination object */ >+ >+typedef struct { >+ struct djpeg_dest_struct pub; /* public fields */ >+ >+ j_decompress_ptr cinfo; /* back link saves passing separate parm */ >+ >+ /* State for packing variable-width codes into a bitstream */ >+ int n_bits; /* current number of bits/code */ >+ int maxcode; /* maximum code, given n_bits */ >+ INT32 cur_accum; /* holds bits not yet output */ >+ int cur_bits; /* # of bits in cur_accum */ >+ >+ /* State for GIF code assignment */ >+ int ClearCode; /* clear code (doesn't change) */ >+ int EOFCode; /* EOF code (ditto) */ >+ int code_counter; /* counts output symbols */ >+ >+ /* GIF data packet construction buffer */ >+ int bytesinpkt; /* # of bytes in current packet */ >+ char packetbuf[256]; /* workspace for accumulating packet */ >+ >+} gif_dest_struct; >+ >+typedef gif_dest_struct * gif_dest_ptr; >+ >+/* Largest value that will fit in N bits */ >+#define MAXCODE(n_bits) ((1 << (n_bits)) - 1) >+ >+ >+/* >+ * Routines to package finished data bytes into GIF data blocks. >+ * A data block consists of a count byte (1..255) and that many data bytes. >+ */ >+ >+LOCAL(void) >+flush_packet (gif_dest_ptr dinfo) >+/* flush any accumulated data */ >+{ >+ if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */ >+ dinfo->packetbuf[0] = (char) dinfo->bytesinpkt++; >+ if (JFWRITE(dinfo->pub.output_file, dinfo->packetbuf, dinfo->bytesinpkt) >+ != (size_t) dinfo->bytesinpkt) >+ ERREXIT(dinfo->cinfo, JERR_FILE_WRITE); >+ dinfo->bytesinpkt = 0; >+ } >+} >+ >+ >+/* Add a character to current packet; flush to disk if necessary */ >+#define CHAR_OUT(dinfo,c) \ >+ { (dinfo)->packetbuf[++(dinfo)->bytesinpkt] = (char) (c); \ >+ if ((dinfo)->bytesinpkt >= 255) \ >+ flush_packet(dinfo); \ >+ } >+ >+ >+/* Routine to convert variable-width codes into a byte stream */ >+ >+LOCAL(void) >+output (gif_dest_ptr dinfo, int code) >+/* Emit a code of n_bits bits */ >+/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */ >+{ >+ dinfo->cur_accum |= ((INT32) code) << dinfo->cur_bits; >+ dinfo->cur_bits += dinfo->n_bits; >+ >+ while (dinfo->cur_bits >= 8) { >+ CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); >+ dinfo->cur_accum >>= 8; >+ dinfo->cur_bits -= 8; >+ } >+} >+ >+ >+/* The pseudo-compression algorithm. >+ * >+ * In this module we simply output each pixel value as a separate symbol; >+ * thus, no compression occurs. In fact, there is expansion of one bit per >+ * pixel, because we use a symbol width one bit wider than the pixel width. >+ * >+ * GIF ordinarily uses variable-width symbols, and the decoder will expect >+ * to ratchet up the symbol width after a fixed number of symbols. >+ * To simplify the logic and keep the expansion penalty down, we emit a >+ * GIF Clear code to reset the decoder just before the width would ratchet up. >+ * Thus, all the symbols in the output file will have the same bit width. >+ * Note that emitting the Clear codes at the right times is a mere matter of >+ * counting output symbols and is in no way dependent on the LZW patent. >+ * >+ * With a small basic pixel width (low color count), Clear codes will be >+ * needed very frequently, causing the file to expand even more. So this >+ * simplistic approach wouldn't work too well on bilevel images, for example. >+ * But for output of JPEG conversions the pixel width will usually be 8 bits >+ * (129 to 256 colors), so the overhead added by Clear symbols is only about >+ * one symbol in every 256. >+ */ >+ >+LOCAL(void) >+compress_init (gif_dest_ptr dinfo, int i_bits) >+/* Initialize pseudo-compressor */ >+{ >+ /* init all the state variables */ >+ dinfo->n_bits = i_bits; >+ dinfo->maxcode = MAXCODE(dinfo->n_bits); >+ dinfo->ClearCode = (1 << (i_bits - 1)); >+ dinfo->EOFCode = dinfo->ClearCode + 1; >+ dinfo->code_counter = dinfo->ClearCode + 2; >+ /* init output buffering vars */ >+ dinfo->bytesinpkt = 0; >+ dinfo->cur_accum = 0; >+ dinfo->cur_bits = 0; >+ /* GIF specifies an initial Clear code */ >+ output(dinfo, dinfo->ClearCode); >+} >+ >+ >+LOCAL(void) >+compress_pixel (gif_dest_ptr dinfo, int c) >+/* Accept and "compress" one pixel value. >+ * The given value must be less than n_bits wide. >+ */ >+{ >+ /* Output the given pixel value as a symbol. */ >+ output(dinfo, c); >+ /* Issue Clear codes often enough to keep the reader from ratcheting up >+ * its symbol size. >+ */ >+ if (dinfo->code_counter < dinfo->maxcode) { >+ dinfo->code_counter++; >+ } else { >+ output(dinfo, dinfo->ClearCode); >+ dinfo->code_counter = dinfo->ClearCode + 2; /* reset the counter */ >+ } >+} >+ >+ >+LOCAL(void) >+compress_term (gif_dest_ptr dinfo) >+/* Clean up at end */ >+{ >+ /* Send an EOF code */ >+ output(dinfo, dinfo->EOFCode); >+ /* Flush the bit-packing buffer */ >+ if (dinfo->cur_bits > 0) { >+ CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); >+ } >+ /* Flush the packet buffer */ >+ flush_packet(dinfo); >+} >+ >+ >+/* GIF header construction */ >+ >+ >+LOCAL(void) >+put_word (gif_dest_ptr dinfo, unsigned int w) >+/* Emit a 16-bit word, LSB first */ >+{ >+ putc(w & 0xFF, dinfo->pub.output_file); >+ putc((w >> 8) & 0xFF, dinfo->pub.output_file); >+} >+ >+ >+LOCAL(void) >+put_3bytes (gif_dest_ptr dinfo, int val) >+/* Emit 3 copies of same byte value --- handy subr for colormap construction */ >+{ >+ putc(val, dinfo->pub.output_file); >+ putc(val, dinfo->pub.output_file); >+ putc(val, dinfo->pub.output_file); >+} >+ >+ >+LOCAL(void) >+emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap) >+/* Output the GIF file header, including color map */ >+/* If colormap==NULL, synthesize a gray-scale colormap */ >+{ >+ int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte; >+ int cshift = dinfo->cinfo->data_precision - 8; >+ int i; >+ >+ if (num_colors > 256) >+ ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors); >+ /* Compute bits/pixel and related values */ >+ BitsPerPixel = 1; >+ while (num_colors > (1 << BitsPerPixel)) >+ BitsPerPixel++; >+ ColorMapSize = 1 << BitsPerPixel; >+ if (BitsPerPixel <= 1) >+ InitCodeSize = 2; >+ else >+ InitCodeSize = BitsPerPixel; >+ /* >+ * Write the GIF header. >+ * Note that we generate a plain GIF87 header for maximum compatibility. >+ */ >+ putc('G', dinfo->pub.output_file); >+ putc('I', dinfo->pub.output_file); >+ putc('F', dinfo->pub.output_file); >+ putc('8', dinfo->pub.output_file); >+ putc('7', dinfo->pub.output_file); >+ putc('a', dinfo->pub.output_file); >+ /* Write the Logical Screen Descriptor */ >+ put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); >+ put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); >+ FlagByte = 0x80; /* Yes, there is a global color table */ >+ FlagByte |= (BitsPerPixel-1) << 4; /* color resolution */ >+ FlagByte |= (BitsPerPixel-1); /* size of global color table */ >+ putc(FlagByte, dinfo->pub.output_file); >+ putc(0, dinfo->pub.output_file); /* Background color index */ >+ putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */ >+ /* Write the Global Color Map */ >+ /* If the color map is more than 8 bits precision, */ >+ /* we reduce it to 8 bits by shifting */ >+ for (i=0; i < ColorMapSize; i++) { >+ if (i < num_colors) { >+ if (colormap != NULL) { >+ if (dinfo->cinfo->out_color_space == JCS_RGB) { >+ /* Normal case: RGB color map */ >+ putc(GETJSAMPLE(colormap[0][i]) >> cshift, dinfo->pub.output_file); >+ putc(GETJSAMPLE(colormap[1][i]) >> cshift, dinfo->pub.output_file); >+ putc(GETJSAMPLE(colormap[2][i]) >> cshift, dinfo->pub.output_file); >+ } else { >+ /* Grayscale "color map": possible if quantizing grayscale image */ >+ put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift); >+ } >+ } else { >+ /* Create a gray-scale map of num_colors values, range 0..255 */ >+ put_3bytes(dinfo, (i * 255 + (num_colors-1)/2) / (num_colors-1)); >+ } >+ } else { >+ /* fill out the map to a power of 2 */ >+ put_3bytes(dinfo, 0); >+ } >+ } >+ /* Write image separator and Image Descriptor */ >+ putc(',', dinfo->pub.output_file); /* separator */ >+ put_word(dinfo, 0); /* left/top offset */ >+ put_word(dinfo, 0); >+ put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); /* image size */ >+ put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); >+ /* flag byte: not interlaced, no local color map */ >+ putc(0x00, dinfo->pub.output_file); >+ /* Write Initial Code Size byte */ >+ putc(InitCodeSize, dinfo->pub.output_file); >+ >+ /* Initialize for "compression" of image data */ >+ compress_init(dinfo, InitCodeSize+1); >+} >+ >+ >+/* >+ * Startup: write the file header. >+ */ >+ >+METHODDEF(void) >+start_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) >+{ >+ gif_dest_ptr dest = (gif_dest_ptr) dinfo; >+ >+ if (cinfo->quantize_colors) >+ emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap); >+ else >+ emit_header(dest, 256, (JSAMPARRAY) NULL); >+} >+ >+ >+/* >+ * Write some pixel data. >+ * In this module rows_supplied will always be 1. >+ */ >+ >+METHODDEF(void) >+put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+{ >+ gif_dest_ptr dest = (gif_dest_ptr) dinfo; >+ register JSAMPROW ptr; >+ register JDIMENSION col; >+ >+ ptr = dest->pub.buffer[0]; >+ for (col = cinfo->output_width; col > 0; col--) { >+ compress_pixel(dest, GETJSAMPLE(*ptr++)); >+ } >+} >+ >+ >+/* >+ * Finish up at the end of the file. >+ */ >+ >+METHODDEF(void) >+finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) >+{ >+ gif_dest_ptr dest = (gif_dest_ptr) dinfo; >+ >+ /* Flush "compression" mechanism */ >+ compress_term(dest); >+ /* Write a zero-length data block to end the series */ >+ putc(0, dest->pub.output_file); >+ /* Write the GIF terminator mark */ >+ putc(';', dest->pub.output_file); >+ /* Make sure we wrote the output file OK */ >+ fflush(dest->pub.output_file); >+ if (ferror(dest->pub.output_file)) >+ ERREXIT(cinfo, JERR_FILE_WRITE); >+} >+ >+ >+/* >+ * The module selection routine for GIF format output. >+ */ >+ >+GLOBAL(djpeg_dest_ptr) >+jinit_write_gif (j_decompress_ptr cinfo) >+{ >+ gif_dest_ptr dest; >+ >+ /* Create module interface object, fill in method pointers */ >+ dest = (gif_dest_ptr) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(gif_dest_struct)); >+ dest->cinfo = cinfo; /* make back link for subroutines */ >+ dest->pub.start_output = start_output_gif; >+ dest->pub.put_pixel_rows = put_pixel_rows; >+ dest->pub.finish_output = finish_output_gif; >+ >+ if (cinfo->out_color_space != JCS_GRAYSCALE && >+ cinfo->out_color_space != JCS_RGB) >+ ERREXIT(cinfo, JERR_GIF_COLORSPACE); >+ >+ /* Force quantization if color or if > 8 bits input */ >+ if (cinfo->out_color_space != JCS_GRAYSCALE || cinfo->data_precision > 8) { >+ /* Force quantization to at most 256 colors */ >+ cinfo->quantize_colors = TRUE; >+ if (cinfo->desired_number_of_colors > 256) >+ cinfo->desired_number_of_colors = 256; >+ } >+ >+ /* Calculate output image dimensions so we can allocate space */ >+ jpeg_calc_output_dimensions(cinfo); >+ >+ if (cinfo->output_components != 1) /* safety check: just one component? */ >+ ERREXIT(cinfo, JERR_GIF_BUG); >+ >+ /* Create decompressor output buffer. */ >+ dest->pub.buffer = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) 1); >+ dest->pub.buffer_height = 1; >+ >+ return (djpeg_dest_ptr) dest; >+} >+ >+#endif /* GIF_SUPPORTED */ >diff --git a/modules/libjpeg-turbo/wrjpgcom.1 b/modules/libjpeg-turbo/wrjpgcom.1 >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/wrjpgcom.1 >@@ -0,0 +1,103 @@ >+.TH WRJPGCOM 1 "15 June 1995" >+.SH NAME >+wrjpgcom \- insert text comments into a JPEG file >+.SH SYNOPSIS >+.B wrjpgcom >+[ >+.B \-replace >+] >+[ >+.BI \-comment " text" >+] >+[ >+.BI \-cfile " name" >+] >+[ >+.I filename >+] >+.LP >+.SH DESCRIPTION >+.LP >+.B wrjpgcom >+reads the named JPEG/JFIF file, or the standard input if no file is named, >+and generates a new JPEG/JFIF file on standard output. A comment block is >+added to the file. >+.PP >+The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. >+Although the standard doesn't actually define what COM blocks are for, they >+are widely used to hold user-supplied text strings. This lets you add >+annotations, titles, index terms, etc to your JPEG files, and later retrieve >+them as text. COM blocks do not interfere with the image stored in the JPEG >+file. The maximum size of a COM block is 64K, but you can have as many of >+them as you like in one JPEG file. >+.PP >+.B wrjpgcom >+adds a COM block, containing text you provide, to a JPEG file. >+Ordinarily, the COM block is added after any existing COM blocks; but you >+can delete the old COM blocks if you wish. >+.SH OPTIONS >+Switch names may be abbreviated, and are not case sensitive. >+.TP >+.B \-replace >+Delete any existing COM blocks from the file. >+.TP >+.BI \-comment " text" >+Supply text for new COM block on command line. >+.TP >+.BI \-cfile " name" >+Read text for new COM block from named file. >+.PP >+If you have only one line of comment text to add, you can provide it on the >+command line with >+.BR \-comment . >+The comment text must be surrounded with quotes so that it is treated as a >+single argument. Longer comments can be read from a text file. >+.PP >+If you give neither >+.B \-comment >+nor >+.BR \-cfile , >+then >+.B wrjpgcom >+will read the comment text from standard input. (In this case an input image >+file name MUST be supplied, so that the source JPEG file comes from somewhere >+else.) You can enter multiple lines, up to 64KB worth. Type an end-of-file >+indicator (usually control-D) to terminate the comment text entry. >+.PP >+.B wrjpgcom >+will not add a COM block if the provided comment string is empty. Therefore >+\fB\-replace \-comment ""\fR can be used to delete all COM blocks from a file. >+.SH EXAMPLES >+.LP >+Add a short comment to in.jpg, producing out.jpg: >+.IP >+.B wrjpgcom \-c >+\fI"View of my back yard" in.jpg >+.B > >+.I out.jpg >+.PP >+Attach a long comment previously stored in comment.txt: >+.IP >+.B wrjpgcom >+.I in.jpg >+.B < >+.I comment.txt >+.B > >+.I out.jpg >+.PP >+or equivalently >+.IP >+.B wrjpgcom >+.B -cfile >+.I comment.txt >+.B < >+.I in.jpg >+.B > >+.I out.jpg >+.SH SEE ALSO >+.BR cjpeg (1), >+.BR djpeg (1), >+.BR jpegtran (1), >+.BR rdjpgcom (1) >+.SH AUTHOR >+Independent JPEG Group >diff --git a/modules/libjpeg-turbo/wrjpgcom.c b/modules/libjpeg-turbo/wrjpgcom.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/wrjpgcom.c >@@ -0,0 +1,583 @@ >+/* >+ * wrjpgcom.c >+ * >+ * Copyright (C) 1994-1997, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains a very simple stand-alone application that inserts >+ * user-supplied text as a COM (comment) marker in a JFIF file. >+ * This may be useful as an example of the minimum logic needed to parse >+ * JPEG markers. >+ */ >+ >+#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ >+#include "jinclude.h" /* get auto-config symbols, <stdio.h> */ >+ >+#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc() */ >+extern void * malloc (); >+#endif >+#include <ctype.h> /* to declare isupper(), tolower() */ >+#ifdef USE_SETMODE >+#include <fcntl.h> /* to declare setmode()'s parameter macros */ >+/* If you have setmode() but not <io.h>, just delete this line: */ >+#include <io.h> /* to declare setmode() */ >+#endif >+ >+#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ >+#ifdef __MWERKS__ >+#include <SIOUX.h> /* Metrowerks needs this */ >+#include <console.h> /* ... and this */ >+#endif >+#ifdef THINK_C >+#include <console.h> /* Think declares it here */ >+#endif >+#endif >+ >+#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ >+#define READ_BINARY "r" >+#define WRITE_BINARY "w" >+#else >+#ifdef VMS /* VMS is very nonstandard */ >+#define READ_BINARY "rb", "ctx=stm" >+#define WRITE_BINARY "wb", "ctx=stm" >+#else /* standard ANSI-compliant case */ >+#define READ_BINARY "rb" >+#define WRITE_BINARY "wb" >+#endif >+#endif >+ >+#ifndef EXIT_FAILURE /* define exit() codes if not provided */ >+#define EXIT_FAILURE 1 >+#endif >+#ifndef EXIT_SUCCESS >+#ifdef VMS >+#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ >+#else >+#define EXIT_SUCCESS 0 >+#endif >+#endif >+ >+/* Reduce this value if your malloc() can't allocate blocks up to 64K. >+ * On DOS, compiling in large model is usually a better solution. >+ */ >+ >+#ifndef MAX_COM_LENGTH >+#define MAX_COM_LENGTH 65000L /* must be <= 65533 in any case */ >+#endif >+ >+ >+/* >+ * These macros are used to read the input file and write the output file. >+ * To reuse this code in another application, you might need to change these. >+ */ >+ >+static FILE * infile; /* input JPEG file */ >+ >+/* Return next input byte, or EOF if no more */ >+#define NEXTBYTE() getc(infile) >+ >+static FILE * outfile; /* output JPEG file */ >+ >+/* Emit an output byte */ >+#define PUTBYTE(x) putc((x), outfile) >+ >+ >+/* Error exit handler */ >+#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) >+ >+ >+/* Read one byte, testing for EOF */ >+static int >+read_1_byte (void) >+{ >+ int c; >+ >+ c = NEXTBYTE(); >+ if (c == EOF) >+ ERREXIT("Premature EOF in JPEG file"); >+ return c; >+} >+ >+/* Read 2 bytes, convert to unsigned int */ >+/* All 2-byte quantities in JPEG markers are MSB first */ >+static unsigned int >+read_2_bytes (void) >+{ >+ int c1, c2; >+ >+ c1 = NEXTBYTE(); >+ if (c1 == EOF) >+ ERREXIT("Premature EOF in JPEG file"); >+ c2 = NEXTBYTE(); >+ if (c2 == EOF) >+ ERREXIT("Premature EOF in JPEG file"); >+ return (((unsigned int) c1) << 8) + ((unsigned int) c2); >+} >+ >+ >+/* Routines to write data to output file */ >+ >+static void >+write_1_byte (int c) >+{ >+ PUTBYTE(c); >+} >+ >+static void >+write_2_bytes (unsigned int val) >+{ >+ PUTBYTE((val >> 8) & 0xFF); >+ PUTBYTE(val & 0xFF); >+} >+ >+static void >+write_marker (int marker) >+{ >+ PUTBYTE(0xFF); >+ PUTBYTE(marker); >+} >+ >+static void >+copy_rest_of_file (void) >+{ >+ int c; >+ >+ while ((c = NEXTBYTE()) != EOF) >+ PUTBYTE(c); >+} >+ >+ >+/* >+ * JPEG markers consist of one or more 0xFF bytes, followed by a marker >+ * code byte (which is not an FF). Here are the marker codes of interest >+ * in this program. (See jdmarker.c for a more complete list.) >+ */ >+ >+#define M_SOF0 0xC0 /* Start Of Frame N */ >+#define M_SOF1 0xC1 /* N indicates which compression process */ >+#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ >+#define M_SOF3 0xC3 >+#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ >+#define M_SOF6 0xC6 >+#define M_SOF7 0xC7 >+#define M_SOF9 0xC9 >+#define M_SOF10 0xCA >+#define M_SOF11 0xCB >+#define M_SOF13 0xCD >+#define M_SOF14 0xCE >+#define M_SOF15 0xCF >+#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ >+#define M_EOI 0xD9 /* End Of Image (end of datastream) */ >+#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ >+#define M_COM 0xFE /* COMment */ >+ >+ >+/* >+ * Find the next JPEG marker and return its marker code. >+ * We expect at least one FF byte, possibly more if the compressor used FFs >+ * to pad the file. (Padding FFs will NOT be replicated in the output file.) >+ * There could also be non-FF garbage between markers. The treatment of such >+ * garbage is unspecified; we choose to skip over it but emit a warning msg. >+ * NB: this routine must not be used after seeing SOS marker, since it will >+ * not deal correctly with FF/00 sequences in the compressed image data... >+ */ >+ >+static int >+next_marker (void) >+{ >+ int c; >+ int discarded_bytes = 0; >+ >+ /* Find 0xFF byte; count and skip any non-FFs. */ >+ c = read_1_byte(); >+ while (c != 0xFF) { >+ discarded_bytes++; >+ c = read_1_byte(); >+ } >+ /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs >+ * are legal as pad bytes, so don't count them in discarded_bytes. >+ */ >+ do { >+ c = read_1_byte(); >+ } while (c == 0xFF); >+ >+ if (discarded_bytes != 0) { >+ fprintf(stderr, "Warning: garbage data found in JPEG file\n"); >+ } >+ >+ return c; >+} >+ >+ >+/* >+ * Read the initial marker, which should be SOI. >+ * For a JFIF file, the first two bytes of the file should be literally >+ * 0xFF M_SOI. To be more general, we could use next_marker, but if the >+ * input file weren't actually JPEG at all, next_marker might read the whole >+ * file and then return a misleading error message... >+ */ >+ >+static int >+first_marker (void) >+{ >+ int c1, c2; >+ >+ c1 = NEXTBYTE(); >+ c2 = NEXTBYTE(); >+ if (c1 != 0xFF || c2 != M_SOI) >+ ERREXIT("Not a JPEG file"); >+ return c2; >+} >+ >+ >+/* >+ * Most types of marker are followed by a variable-length parameter segment. >+ * This routine skips over the parameters for any marker we don't otherwise >+ * want to process. >+ * Note that we MUST skip the parameter segment explicitly in order not to >+ * be fooled by 0xFF bytes that might appear within the parameter segment; >+ * such bytes do NOT introduce new markers. >+ */ >+ >+static void >+copy_variable (void) >+/* Copy an unknown or uninteresting variable-length marker */ >+{ >+ unsigned int length; >+ >+ /* Get the marker parameter length count */ >+ length = read_2_bytes(); >+ write_2_bytes(length); >+ /* Length includes itself, so must be at least 2 */ >+ if (length < 2) >+ ERREXIT("Erroneous JPEG marker length"); >+ length -= 2; >+ /* Skip over the remaining bytes */ >+ while (length > 0) { >+ write_1_byte(read_1_byte()); >+ length--; >+ } >+} >+ >+static void >+skip_variable (void) >+/* Skip over an unknown or uninteresting variable-length marker */ >+{ >+ unsigned int length; >+ >+ /* Get the marker parameter length count */ >+ length = read_2_bytes(); >+ /* Length includes itself, so must be at least 2 */ >+ if (length < 2) >+ ERREXIT("Erroneous JPEG marker length"); >+ length -= 2; >+ /* Skip over the remaining bytes */ >+ while (length > 0) { >+ (void) read_1_byte(); >+ length--; >+ } >+} >+ >+ >+/* >+ * Parse the marker stream until SOFn or EOI is seen; >+ * copy data to output, but discard COM markers unless keep_COM is true. >+ */ >+ >+static int >+scan_JPEG_header (int keep_COM) >+{ >+ int marker; >+ >+ /* Expect SOI at start of file */ >+ if (first_marker() != M_SOI) >+ ERREXIT("Expected SOI marker first"); >+ write_marker(M_SOI); >+ >+ /* Scan miscellaneous markers until we reach SOFn. */ >+ for (;;) { >+ marker = next_marker(); >+ switch (marker) { >+ /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, >+ * treated as SOFn. C4 in particular is actually DHT. >+ */ >+ case M_SOF0: /* Baseline */ >+ case M_SOF1: /* Extended sequential, Huffman */ >+ case M_SOF2: /* Progressive, Huffman */ >+ case M_SOF3: /* Lossless, Huffman */ >+ case M_SOF5: /* Differential sequential, Huffman */ >+ case M_SOF6: /* Differential progressive, Huffman */ >+ case M_SOF7: /* Differential lossless, Huffman */ >+ case M_SOF9: /* Extended sequential, arithmetic */ >+ case M_SOF10: /* Progressive, arithmetic */ >+ case M_SOF11: /* Lossless, arithmetic */ >+ case M_SOF13: /* Differential sequential, arithmetic */ >+ case M_SOF14: /* Differential progressive, arithmetic */ >+ case M_SOF15: /* Differential lossless, arithmetic */ >+ return marker; >+ >+ case M_SOS: /* should not see compressed data before SOF */ >+ ERREXIT("SOS without prior SOFn"); >+ break; >+ >+ case M_EOI: /* in case it's a tables-only JPEG stream */ >+ return marker; >+ >+ case M_COM: /* Existing COM: conditionally discard */ >+ if (keep_COM) { >+ write_marker(marker); >+ copy_variable(); >+ } else { >+ skip_variable(); >+ } >+ break; >+ >+ default: /* Anything else just gets copied */ >+ write_marker(marker); >+ copy_variable(); /* we assume it has a parameter count... */ >+ break; >+ } >+ } /* end loop */ >+} >+ >+ >+/* Command line parsing code */ >+ >+static const char * progname; /* program name for error messages */ >+ >+ >+static void >+usage (void) >+/* complain about bad command line */ >+{ >+ fprintf(stderr, "wrjpgcom inserts a textual comment in a JPEG file.\n"); >+ fprintf(stderr, "You can add to or replace any existing comment(s).\n"); >+ >+ fprintf(stderr, "Usage: %s [switches] ", progname); >+#ifdef TWO_FILE_COMMANDLINE >+ fprintf(stderr, "inputfile outputfile\n"); >+#else >+ fprintf(stderr, "[inputfile]\n"); >+#endif >+ >+ fprintf(stderr, "Switches (names may be abbreviated):\n"); >+ fprintf(stderr, " -replace Delete any existing comments\n"); >+ fprintf(stderr, " -comment \"text\" Insert comment with given text\n"); >+ fprintf(stderr, " -cfile name Read comment from named file\n"); >+ fprintf(stderr, "Notice that you must put quotes around the comment text\n"); >+ fprintf(stderr, "when you use -comment.\n"); >+ fprintf(stderr, "If you do not give either -comment or -cfile on the command line,\n"); >+ fprintf(stderr, "then the comment text is read from standard input.\n"); >+ fprintf(stderr, "It can be multiple lines, up to %u characters total.\n", >+ (unsigned int) MAX_COM_LENGTH); >+#ifndef TWO_FILE_COMMANDLINE >+ fprintf(stderr, "You must specify an input JPEG file name when supplying\n"); >+ fprintf(stderr, "comment text from standard input.\n"); >+#endif >+ >+ exit(EXIT_FAILURE); >+} >+ >+ >+static int >+keymatch (char * arg, const char * keyword, int minchars) >+/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ >+/* keyword is the constant keyword (must be lower case already), */ >+/* minchars is length of minimum legal abbreviation. */ >+{ >+ register int ca, ck; >+ register int nmatched = 0; >+ >+ while ((ca = *arg++) != '\0') { >+ if ((ck = *keyword++) == '\0') >+ return 0; /* arg longer than keyword, no good */ >+ if (isupper(ca)) /* force arg to lcase (assume ck is already) */ >+ ca = tolower(ca); >+ if (ca != ck) >+ return 0; /* no good */ >+ nmatched++; /* count matched characters */ >+ } >+ /* reached end of argument; fail if it's too short for unique abbrev */ >+ if (nmatched < minchars) >+ return 0; >+ return 1; /* A-OK */ >+} >+ >+ >+/* >+ * The main program. >+ */ >+ >+int >+main (int argc, char **argv) >+{ >+ int argn; >+ char * arg; >+ int keep_COM = 1; >+ char * comment_arg = NULL; >+ FILE * comment_file = NULL; >+ unsigned int comment_length = 0; >+ int marker; >+ >+ /* On Mac, fetch a command line. */ >+#ifdef USE_CCOMMAND >+ argc = ccommand(&argv); >+#endif >+ >+ progname = argv[0]; >+ if (progname == NULL || progname[0] == 0) >+ progname = "wrjpgcom"; /* in case C library doesn't provide it */ >+ >+ /* Parse switches, if any */ >+ for (argn = 1; argn < argc; argn++) { >+ arg = argv[argn]; >+ if (arg[0] != '-') >+ break; /* not switch, must be file name */ >+ arg++; /* advance over '-' */ >+ if (keymatch(arg, "replace", 1)) { >+ keep_COM = 0; >+ } else if (keymatch(arg, "cfile", 2)) { >+ if (++argn >= argc) usage(); >+ if ((comment_file = fopen(argv[argn], "r")) == NULL) { >+ fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); >+ exit(EXIT_FAILURE); >+ } >+ } else if (keymatch(arg, "comment", 1)) { >+ if (++argn >= argc) usage(); >+ comment_arg = argv[argn]; >+ /* If the comment text starts with '"', then we are probably running >+ * under MS-DOG and must parse out the quoted string ourselves. Sigh. >+ */ >+ if (comment_arg[0] == '"') { >+ comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); >+ if (comment_arg == NULL) >+ ERREXIT("Insufficient memory"); >+ strcpy(comment_arg, argv[argn]+1); >+ for (;;) { >+ comment_length = (unsigned int) strlen(comment_arg); >+ if (comment_length > 0 && comment_arg[comment_length-1] == '"') { >+ comment_arg[comment_length-1] = '\0'; /* zap terminating quote */ >+ break; >+ } >+ if (++argn >= argc) >+ ERREXIT("Missing ending quote mark"); >+ strcat(comment_arg, " "); >+ strcat(comment_arg, argv[argn]); >+ } >+ } >+ comment_length = (unsigned int) strlen(comment_arg); >+ } else >+ usage(); >+ } >+ >+ /* Cannot use both -comment and -cfile. */ >+ if (comment_arg != NULL && comment_file != NULL) >+ usage(); >+ /* If there is neither -comment nor -cfile, we will read the comment text >+ * from stdin; in this case there MUST be an input JPEG file name. >+ */ >+ if (comment_arg == NULL && comment_file == NULL && argn >= argc) >+ usage(); >+ >+ /* Open the input file. */ >+ if (argn < argc) { >+ if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { >+ fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); >+ exit(EXIT_FAILURE); >+ } >+ } else { >+ /* default input file is stdin */ >+#ifdef USE_SETMODE /* need to hack file mode? */ >+ setmode(fileno(stdin), O_BINARY); >+#endif >+#ifdef USE_FDOPEN /* need to re-open in binary mode? */ >+ if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { >+ fprintf(stderr, "%s: can't open stdin\n", progname); >+ exit(EXIT_FAILURE); >+ } >+#else >+ infile = stdin; >+#endif >+ } >+ >+ /* Open the output file. */ >+#ifdef TWO_FILE_COMMANDLINE >+ /* Must have explicit output file name */ >+ if (argn != argc-2) { >+ fprintf(stderr, "%s: must name one input and one output file\n", >+ progname); >+ usage(); >+ } >+ if ((outfile = fopen(argv[argn+1], WRITE_BINARY)) == NULL) { >+ fprintf(stderr, "%s: can't open %s\n", progname, argv[argn+1]); >+ exit(EXIT_FAILURE); >+ } >+#else >+ /* Unix style: expect zero or one file name */ >+ if (argn < argc-1) { >+ fprintf(stderr, "%s: only one input file\n", progname); >+ usage(); >+ } >+ /* default output file is stdout */ >+#ifdef USE_SETMODE /* need to hack file mode? */ >+ setmode(fileno(stdout), O_BINARY); >+#endif >+#ifdef USE_FDOPEN /* need to re-open in binary mode? */ >+ if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { >+ fprintf(stderr, "%s: can't open stdout\n", progname); >+ exit(EXIT_FAILURE); >+ } >+#else >+ outfile = stdout; >+#endif >+#endif /* TWO_FILE_COMMANDLINE */ >+ >+ /* Collect comment text from comment_file or stdin, if necessary */ >+ if (comment_arg == NULL) { >+ FILE * src_file; >+ int c; >+ >+ comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); >+ if (comment_arg == NULL) >+ ERREXIT("Insufficient memory"); >+ comment_length = 0; >+ src_file = (comment_file != NULL ? comment_file : stdin); >+ while ((c = getc(src_file)) != EOF) { >+ if (comment_length >= (unsigned int) MAX_COM_LENGTH) { >+ fprintf(stderr, "Comment text may not exceed %u bytes\n", >+ (unsigned int) MAX_COM_LENGTH); >+ exit(EXIT_FAILURE); >+ } >+ comment_arg[comment_length++] = (char) c; >+ } >+ if (comment_file != NULL) >+ fclose(comment_file); >+ } >+ >+ /* Copy JPEG headers until SOFn marker; >+ * we will insert the new comment marker just before SOFn. >+ * This (a) causes the new comment to appear after, rather than before, >+ * existing comments; and (b) ensures that comments come after any JFIF >+ * or JFXX markers, as required by the JFIF specification. >+ */ >+ marker = scan_JPEG_header(keep_COM); >+ /* Insert the new COM marker, but only if nonempty text has been supplied */ >+ if (comment_length > 0) { >+ write_marker(M_COM); >+ write_2_bytes(comment_length + 2); >+ while (comment_length > 0) { >+ write_1_byte(*comment_arg++); >+ comment_length--; >+ } >+ } >+ /* Duplicate the remainder of the source file. >+ * Note that any COM markers occuring after SOF will not be touched. >+ */ >+ write_marker(marker); >+ copy_rest_of_file(); >+ >+ /* All done. */ >+ exit(EXIT_SUCCESS); >+ return 0; /* suppress no-return-value warnings */ >+} >diff --git a/modules/libjpeg-turbo/wrppm.c b/modules/libjpeg-turbo/wrppm.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/wrppm.c >@@ -0,0 +1,268 @@ >+/* >+ * wrppm.c >+ * >+ * Copyright (C) 1991-1996, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to write output images in PPM/PGM format. >+ * The extended 2-byte-per-sample raw PPM/PGM formats are supported. >+ * The PBMPLUS library is NOT required to compile this software >+ * (but it is highly useful as a set of PPM image manipulation programs). >+ * >+ * These routines may need modification for non-Unix environments or >+ * specialized applications. As they stand, they assume output to >+ * an ordinary stdio stream. >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef PPM_SUPPORTED >+ >+ >+/* >+ * For 12-bit JPEG data, we either downscale the values to 8 bits >+ * (to write standard byte-per-sample PPM/PGM files), or output >+ * nonstandard word-per-sample PPM/PGM files. Downscaling is done >+ * if PPM_NORAWWORD is defined (this can be done in the Makefile >+ * or in jconfig.h). >+ * (When the core library supports data precision reduction, a cleaner >+ * implementation will be to ask for that instead.) >+ */ >+ >+#if BITS_IN_JSAMPLE == 8 >+#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v) >+#define BYTESPERSAMPLE 1 >+#define PPM_MAXVAL 255 >+#else >+#ifdef PPM_NORAWWORD >+#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8)) >+#define BYTESPERSAMPLE 1 >+#define PPM_MAXVAL 255 >+#else >+/* The word-per-sample format always puts the LSB first. */ >+#define PUTPPMSAMPLE(ptr,v) \ >+ { register int val_ = v; \ >+ *ptr++ = (char) (val_ & 0xFF); \ >+ *ptr++ = (char) ((val_ >> 8) & 0xFF); \ >+ } >+#define BYTESPERSAMPLE 2 >+#define PPM_MAXVAL ((1<<BITS_IN_JSAMPLE)-1) >+#endif >+#endif >+ >+ >+/* >+ * When JSAMPLE is the same size as char, we can just fwrite() the >+ * decompressed data to the PPM or PGM file. On PCs, in order to make this >+ * work the output buffer must be allocated in near data space, because we are >+ * assuming small-data memory model wherein fwrite() can't reach far memory. >+ * If you need to process very wide images on a PC, you might have to compile >+ * in large-memory model, or else replace fwrite() with a putc() loop --- >+ * which will be much slower. >+ */ >+ >+ >+/* Private version of data destination object */ >+ >+typedef struct { >+ struct djpeg_dest_struct pub; /* public fields */ >+ >+ /* Usually these two pointers point to the same place: */ >+ char *iobuffer; /* fwrite's I/O buffer */ >+ JSAMPROW pixrow; /* decompressor output buffer */ >+ size_t buffer_width; /* width of I/O buffer */ >+ JDIMENSION samples_per_row; /* JSAMPLEs per output row */ >+} ppm_dest_struct; >+ >+typedef ppm_dest_struct * ppm_dest_ptr; >+ >+ >+/* >+ * Write some pixel data. >+ * In this module rows_supplied will always be 1. >+ * >+ * put_pixel_rows handles the "normal" 8-bit case where the decompressor >+ * output buffer is physically the same as the fwrite buffer. >+ */ >+ >+METHODDEF(void) >+put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+{ >+ ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; >+ >+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); >+} >+ >+ >+/* >+ * This code is used when we have to copy the data and apply a pixel >+ * format translation. Typically this only happens in 12-bit mode. >+ */ >+ >+METHODDEF(void) >+copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+{ >+ ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; >+ register char * bufferptr; >+ register JSAMPROW ptr; >+ register JDIMENSION col; >+ >+ ptr = dest->pub.buffer[0]; >+ bufferptr = dest->iobuffer; >+ for (col = dest->samples_per_row; col > 0; col--) { >+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(*ptr++)); >+ } >+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); >+} >+ >+ >+/* >+ * Write some pixel data when color quantization is in effect. >+ * We have to demap the color index values to straight data. >+ */ >+ >+METHODDEF(void) >+put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+{ >+ ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; >+ register char * bufferptr; >+ register int pixval; >+ register JSAMPROW ptr; >+ register JSAMPROW color_map0 = cinfo->colormap[0]; >+ register JSAMPROW color_map1 = cinfo->colormap[1]; >+ register JSAMPROW color_map2 = cinfo->colormap[2]; >+ register JDIMENSION col; >+ >+ ptr = dest->pub.buffer[0]; >+ bufferptr = dest->iobuffer; >+ for (col = cinfo->output_width; col > 0; col--) { >+ pixval = GETJSAMPLE(*ptr++); >+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[pixval])); >+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map1[pixval])); >+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map2[pixval])); >+ } >+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); >+} >+ >+ >+METHODDEF(void) >+put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+{ >+ ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; >+ register char * bufferptr; >+ register JSAMPROW ptr; >+ register JSAMPROW color_map = cinfo->colormap[0]; >+ register JDIMENSION col; >+ >+ ptr = dest->pub.buffer[0]; >+ bufferptr = dest->iobuffer; >+ for (col = cinfo->output_width; col > 0; col--) { >+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map[GETJSAMPLE(*ptr++)])); >+ } >+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); >+} >+ >+ >+/* >+ * Startup: write the file header. >+ */ >+ >+METHODDEF(void) >+start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) >+{ >+ ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; >+ >+ /* Emit file header */ >+ switch (cinfo->out_color_space) { >+ case JCS_GRAYSCALE: >+ /* emit header for raw PGM format */ >+ fprintf(dest->pub.output_file, "P5\n%ld %ld\n%d\n", >+ (long) cinfo->output_width, (long) cinfo->output_height, >+ PPM_MAXVAL); >+ break; >+ case JCS_RGB: >+ /* emit header for raw PPM format */ >+ fprintf(dest->pub.output_file, "P6\n%ld %ld\n%d\n", >+ (long) cinfo->output_width, (long) cinfo->output_height, >+ PPM_MAXVAL); >+ break; >+ default: >+ ERREXIT(cinfo, JERR_PPM_COLORSPACE); >+ } >+} >+ >+ >+/* >+ * Finish up at the end of the file. >+ */ >+ >+METHODDEF(void) >+finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) >+{ >+ /* Make sure we wrote the output file OK */ >+ fflush(dinfo->output_file); >+ if (ferror(dinfo->output_file)) >+ ERREXIT(cinfo, JERR_FILE_WRITE); >+} >+ >+ >+/* >+ * The module selection routine for PPM format output. >+ */ >+ >+GLOBAL(djpeg_dest_ptr) >+jinit_write_ppm (j_decompress_ptr cinfo) >+{ >+ ppm_dest_ptr dest; >+ >+ /* Create module interface object, fill in method pointers */ >+ dest = (ppm_dest_ptr) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(ppm_dest_struct)); >+ dest->pub.start_output = start_output_ppm; >+ dest->pub.finish_output = finish_output_ppm; >+ >+ /* Calculate output image dimensions so we can allocate space */ >+ jpeg_calc_output_dimensions(cinfo); >+ >+ /* Create physical I/O buffer. Note we make this near on a PC. */ >+ dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; >+ dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char)); >+ dest->iobuffer = (char *) (*cinfo->mem->alloc_small) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width); >+ >+ if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 || >+ SIZEOF(JSAMPLE) != SIZEOF(char)) { >+ /* When quantizing, we need an output buffer for colormap indexes >+ * that's separate from the physical I/O buffer. We also need a >+ * separate buffer if pixel format translation must take place. >+ */ >+ dest->pub.buffer = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ cinfo->output_width * cinfo->output_components, (JDIMENSION) 1); >+ dest->pub.buffer_height = 1; >+ if (! cinfo->quantize_colors) >+ dest->pub.put_pixel_rows = copy_pixel_rows; >+ else if (cinfo->out_color_space == JCS_GRAYSCALE) >+ dest->pub.put_pixel_rows = put_demapped_gray; >+ else >+ dest->pub.put_pixel_rows = put_demapped_rgb; >+ } else { >+ /* We will fwrite() directly from decompressor output buffer. */ >+ /* Synthesize a JSAMPARRAY pointer structure */ >+ /* Cast here implies near->far pointer conversion on PCs */ >+ dest->pixrow = (JSAMPROW) dest->iobuffer; >+ dest->pub.buffer = & dest->pixrow; >+ dest->pub.buffer_height = 1; >+ dest->pub.put_pixel_rows = put_pixel_rows; >+ } >+ >+ return (djpeg_dest_ptr) dest; >+} >+ >+#endif /* PPM_SUPPORTED */ >diff --git a/modules/libjpeg-turbo/wrrle.c b/modules/libjpeg-turbo/wrrle.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/wrrle.c >@@ -0,0 +1,305 @@ >+/* >+ * wrrle.c >+ * >+ * Copyright (C) 1991-1996, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to write output images in RLE format. >+ * The Utah Raster Toolkit library is required (version 3.1 or later). >+ * >+ * These routines may need modification for non-Unix environments or >+ * specialized applications. As they stand, they assume output to >+ * an ordinary stdio stream. >+ * >+ * Based on code contributed by Mike Lijewski, >+ * with updates from Robert Hutchinson. >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef RLE_SUPPORTED >+ >+/* rle.h is provided by the Utah Raster Toolkit. */ >+ >+#include <rle.h> >+ >+/* >+ * We assume that JSAMPLE has the same representation as rle_pixel, >+ * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. >+ */ >+ >+#if BITS_IN_JSAMPLE != 8 >+ Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ >+#endif >+ >+ >+/* >+ * Since RLE stores scanlines bottom-to-top, we have to invert the image >+ * from JPEG's top-to-bottom order. To do this, we save the outgoing data >+ * in a virtual array during put_pixel_row calls, then actually emit the >+ * RLE file during finish_output. >+ */ >+ >+ >+/* >+ * For now, if we emit an RLE color map then it is always 256 entries long, >+ * though not all of the entries need be used. >+ */ >+ >+#define CMAPBITS 8 >+#define CMAPLENGTH (1<<(CMAPBITS)) >+ >+typedef struct { >+ struct djpeg_dest_struct pub; /* public fields */ >+ >+ jvirt_sarray_ptr image; /* virtual array to store the output image */ >+ rle_map *colormap; /* RLE-style color map, or NULL if none */ >+ rle_pixel **rle_row; /* To pass rows to rle_putrow() */ >+ >+} rle_dest_struct; >+ >+typedef rle_dest_struct * rle_dest_ptr; >+ >+/* Forward declarations */ >+METHODDEF(void) rle_put_pixel_rows >+ JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied)); >+ >+ >+/* >+ * Write the file header. >+ * >+ * In this module it's easier to wait till finish_output to write anything. >+ */ >+ >+METHODDEF(void) >+start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) >+{ >+ rle_dest_ptr dest = (rle_dest_ptr) dinfo; >+ size_t cmapsize; >+ int i, ci; >+#ifdef PROGRESS_REPORT >+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; >+#endif >+ >+ /* >+ * Make sure the image can be stored in RLE format. >+ * >+ * - RLE stores image dimensions as *signed* 16 bit integers. JPEG >+ * uses unsigned, so we have to check the width. >+ * >+ * - Colorspace is expected to be grayscale or RGB. >+ * >+ * - The number of channels (components) is expected to be 1 (grayscale/ >+ * pseudocolor) or 3 (truecolor/directcolor). >+ * (could be 2 or 4 if using an alpha channel, but we aren't) >+ */ >+ >+ if (cinfo->output_width > 32767 || cinfo->output_height > 32767) >+ ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width, >+ cinfo->output_height); >+ >+ if (cinfo->out_color_space != JCS_GRAYSCALE && >+ cinfo->out_color_space != JCS_RGB) >+ ERREXIT(cinfo, JERR_RLE_COLORSPACE); >+ >+ if (cinfo->output_components != 1 && cinfo->output_components != 3) >+ ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components); >+ >+ /* Convert colormap, if any, to RLE format. */ >+ >+ dest->colormap = NULL; >+ >+ if (cinfo->quantize_colors) { >+ /* Allocate storage for RLE-style cmap, zero any extra entries */ >+ cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); >+ dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); >+ MEMZERO(dest->colormap, cmapsize); >+ >+ /* Save away data in RLE format --- note 8-bit left shift! */ >+ /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */ >+ for (ci = 0; ci < cinfo->out_color_components; ci++) { >+ for (i = 0; i < cinfo->actual_number_of_colors; i++) { >+ dest->colormap[ci * CMAPLENGTH + i] = >+ GETJSAMPLE(cinfo->colormap[ci][i]) << 8; >+ } >+ } >+ } >+ >+ /* Set the output buffer to the first row */ >+ dest->pub.buffer = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE); >+ dest->pub.buffer_height = 1; >+ >+ dest->pub.put_pixel_rows = rle_put_pixel_rows; >+ >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) { >+ progress->total_extra_passes++; /* count file writing as separate pass */ >+ } >+#endif >+} >+ >+ >+/* >+ * Write some pixel data. >+ * >+ * This routine just saves the data away in a virtual array. >+ */ >+ >+METHODDEF(void) >+rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+{ >+ rle_dest_ptr dest = (rle_dest_ptr) dinfo; >+ >+ if (cinfo->output_scanline < cinfo->output_height) { >+ dest->pub.buffer = (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, dest->image, >+ cinfo->output_scanline, (JDIMENSION) 1, TRUE); >+ } >+} >+ >+/* >+ * Finish up at the end of the file. >+ * >+ * Here is where we really output the RLE file. >+ */ >+ >+METHODDEF(void) >+finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) >+{ >+ rle_dest_ptr dest = (rle_dest_ptr) dinfo; >+ rle_hdr header; /* Output file information */ >+ rle_pixel **rle_row, *red, *green, *blue; >+ JSAMPROW output_row; >+ char cmapcomment[80]; >+ int row, col; >+ int ci; >+#ifdef PROGRESS_REPORT >+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; >+#endif >+ >+ /* Initialize the header info */ >+ header = *rle_hdr_init(NULL); >+ header.rle_file = dest->pub.output_file; >+ header.xmin = 0; >+ header.xmax = cinfo->output_width - 1; >+ header.ymin = 0; >+ header.ymax = cinfo->output_height - 1; >+ header.alpha = 0; >+ header.ncolors = cinfo->output_components; >+ for (ci = 0; ci < cinfo->output_components; ci++) { >+ RLE_SET_BIT(header, ci); >+ } >+ if (cinfo->quantize_colors) { >+ header.ncmap = cinfo->out_color_components; >+ header.cmaplen = CMAPBITS; >+ header.cmap = dest->colormap; >+ /* Add a comment to the output image with the true colormap length. */ >+ sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors); >+ rle_putcom(cmapcomment, &header); >+ } >+ >+ /* Emit the RLE header and color map (if any) */ >+ rle_put_setup(&header); >+ >+ /* Now output the RLE data from our virtual array. >+ * We assume here that (a) rle_pixel is represented the same as JSAMPLE, >+ * and (b) we are not on a machine where FAR pointers differ from regular. >+ */ >+ >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) { >+ progress->pub.pass_limit = cinfo->output_height; >+ progress->pub.pass_counter = 0; >+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); >+ } >+#endif >+ >+ if (cinfo->output_components == 1) { >+ for (row = cinfo->output_height-1; row >= 0; row--) { >+ rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, dest->image, >+ (JDIMENSION) row, (JDIMENSION) 1, FALSE); >+ rle_putrow(rle_row, (int) cinfo->output_width, &header); >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) { >+ progress->pub.pass_counter++; >+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); >+ } >+#endif >+ } >+ } else { >+ for (row = cinfo->output_height-1; row >= 0; row--) { >+ rle_row = (rle_pixel **) dest->rle_row; >+ output_row = * (*cinfo->mem->access_virt_sarray) >+ ((j_common_ptr) cinfo, dest->image, >+ (JDIMENSION) row, (JDIMENSION) 1, FALSE); >+ red = rle_row[0]; >+ green = rle_row[1]; >+ blue = rle_row[2]; >+ for (col = cinfo->output_width; col > 0; col--) { >+ *red++ = GETJSAMPLE(*output_row++); >+ *green++ = GETJSAMPLE(*output_row++); >+ *blue++ = GETJSAMPLE(*output_row++); >+ } >+ rle_putrow(rle_row, (int) cinfo->output_width, &header); >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) { >+ progress->pub.pass_counter++; >+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); >+ } >+#endif >+ } >+ } >+ >+#ifdef PROGRESS_REPORT >+ if (progress != NULL) >+ progress->completed_extra_passes++; >+#endif >+ >+ /* Emit file trailer */ >+ rle_puteof(&header); >+ fflush(dest->pub.output_file); >+ if (ferror(dest->pub.output_file)) >+ ERREXIT(cinfo, JERR_FILE_WRITE); >+} >+ >+ >+/* >+ * The module selection routine for RLE format output. >+ */ >+ >+GLOBAL(djpeg_dest_ptr) >+jinit_write_rle (j_decompress_ptr cinfo) >+{ >+ rle_dest_ptr dest; >+ >+ /* Create module interface object, fill in method pointers */ >+ dest = (rle_dest_ptr) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(rle_dest_struct)); >+ dest->pub.start_output = start_output_rle; >+ dest->pub.finish_output = finish_output_rle; >+ >+ /* Calculate output image dimensions so we can allocate space */ >+ jpeg_calc_output_dimensions(cinfo); >+ >+ /* Allocate a work array for output to the RLE library. */ >+ dest->rle_row = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ cinfo->output_width, (JDIMENSION) cinfo->output_components); >+ >+ /* Allocate a virtual array to hold the image. */ >+ dest->image = (*cinfo->mem->request_virt_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, >+ (JDIMENSION) (cinfo->output_width * cinfo->output_components), >+ cinfo->output_height, (JDIMENSION) 1); >+ >+ return (djpeg_dest_ptr) dest; >+} >+ >+#endif /* RLE_SUPPORTED */ >diff --git a/modules/libjpeg-turbo/wrtarga.c b/modules/libjpeg-turbo/wrtarga.c >new file mode 100644 >--- /dev/null >+++ b/modules/libjpeg-turbo/wrtarga.c >@@ -0,0 +1,253 @@ >+/* >+ * wrtarga.c >+ * >+ * Copyright (C) 1991-1996, Thomas G. Lane. >+ * This file is part of the Independent JPEG Group's software. >+ * For conditions of distribution and use, see the accompanying README file. >+ * >+ * This file contains routines to write output images in Targa format. >+ * >+ * These routines may need modification for non-Unix environments or >+ * specialized applications. As they stand, they assume output to >+ * an ordinary stdio stream. >+ * >+ * Based on code contributed by Lee Daniel Crocker. >+ */ >+ >+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ >+ >+#ifdef TARGA_SUPPORTED >+ >+ >+/* >+ * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. >+ * This is not yet implemented. >+ */ >+ >+#if BITS_IN_JSAMPLE != 8 >+ Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ >+#endif >+ >+/* >+ * The output buffer needs to be writable by fwrite(). On PCs, we must >+ * allocate the buffer in near data space, because we are assuming small-data >+ * memory model, wherein fwrite() can't reach far memory. If you need to >+ * process very wide images on a PC, you might have to compile in large-memory >+ * model, or else replace fwrite() with a putc() loop --- which will be much >+ * slower. >+ */ >+ >+ >+/* Private version of data destination object */ >+ >+typedef struct { >+ struct djpeg_dest_struct pub; /* public fields */ >+ >+ char *iobuffer; /* physical I/O buffer */ >+ JDIMENSION buffer_width; /* width of one row */ >+} tga_dest_struct; >+ >+typedef tga_dest_struct * tga_dest_ptr; >+ >+ >+LOCAL(void) >+write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors) >+/* Create and write a Targa header */ >+{ >+ char targaheader[18]; >+ >+ /* Set unused fields of header to 0 */ >+ MEMZERO(targaheader, SIZEOF(targaheader)); >+ >+ if (num_colors > 0) { >+ targaheader[1] = 1; /* color map type 1 */ >+ targaheader[5] = (char) (num_colors & 0xFF); >+ targaheader[6] = (char) (num_colors >> 8); >+ targaheader[7] = 24; /* 24 bits per cmap entry */ >+ } >+ >+ targaheader[12] = (char) (cinfo->output_width & 0xFF); >+ targaheader[13] = (char) (cinfo->output_width >> 8); >+ targaheader[14] = (char) (cinfo->output_height & 0xFF); >+ targaheader[15] = (char) (cinfo->output_height >> 8); >+ targaheader[17] = 0x20; /* Top-down, non-interlaced */ >+ >+ if (cinfo->out_color_space == JCS_GRAYSCALE) { >+ targaheader[2] = 3; /* image type = uncompressed gray-scale */ >+ targaheader[16] = 8; /* bits per pixel */ >+ } else { /* must be RGB */ >+ if (num_colors > 0) { >+ targaheader[2] = 1; /* image type = colormapped RGB */ >+ targaheader[16] = 8; >+ } else { >+ targaheader[2] = 2; /* image type = uncompressed RGB */ >+ targaheader[16] = 24; >+ } >+ } >+ >+ if (JFWRITE(dinfo->output_file, targaheader, 18) != (size_t) 18) >+ ERREXIT(cinfo, JERR_FILE_WRITE); >+} >+ >+ >+/* >+ * Write some pixel data. >+ * In this module rows_supplied will always be 1. >+ */ >+ >+METHODDEF(void) >+put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+/* used for unquantized full-color output */ >+{ >+ tga_dest_ptr dest = (tga_dest_ptr) dinfo; >+ register JSAMPROW inptr; >+ register char * outptr; >+ register JDIMENSION col; >+ >+ inptr = dest->pub.buffer[0]; >+ outptr = dest->iobuffer; >+ for (col = cinfo->output_width; col > 0; col--) { >+ outptr[0] = (char) GETJSAMPLE(inptr[2]); /* RGB to BGR order */ >+ outptr[1] = (char) GETJSAMPLE(inptr[1]); >+ outptr[2] = (char) GETJSAMPLE(inptr[0]); >+ inptr += 3, outptr += 3; >+ } >+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); >+} >+ >+METHODDEF(void) >+put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+/* used for grayscale OR quantized color output */ >+{ >+ tga_dest_ptr dest = (tga_dest_ptr) dinfo; >+ register JSAMPROW inptr; >+ register char * outptr; >+ register JDIMENSION col; >+ >+ inptr = dest->pub.buffer[0]; >+ outptr = dest->iobuffer; >+ for (col = cinfo->output_width; col > 0; col--) { >+ *outptr++ = (char) GETJSAMPLE(*inptr++); >+ } >+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); >+} >+ >+ >+/* >+ * Write some demapped pixel data when color quantization is in effect. >+ * For Targa, this is only applied to grayscale data. >+ */ >+ >+METHODDEF(void) >+put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, >+ JDIMENSION rows_supplied) >+{ >+ tga_dest_ptr dest = (tga_dest_ptr) dinfo; >+ register JSAMPROW inptr; >+ register char * outptr; >+ register JSAMPROW color_map0 = cinfo->colormap[0]; >+ register JDIMENSION col; >+ >+ inptr = dest->pub.buffer[0]; >+ outptr = dest->iobuffer; >+ for (col = cinfo->output_width; col > 0; col--) { >+ *outptr++ = (char) GETJSAMPLE(color_map0[GETJSAMPLE(*inptr++)]); >+ } >+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); >+} >+ >+ >+/* >+ * Startup: write the file header. >+ */ >+ >+METHODDEF(void) >+start_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) >+{ >+ tga_dest_ptr dest = (tga_dest_ptr) dinfo; >+ int num_colors, i; >+ FILE *outfile; >+ >+ if (cinfo->out_color_space == JCS_GRAYSCALE) { >+ /* Targa doesn't have a mapped grayscale format, so we will */ >+ /* demap quantized gray output. Never emit a colormap. */ >+ write_header(cinfo, dinfo, 0); >+ if (cinfo->quantize_colors) >+ dest->pub.put_pixel_rows = put_demapped_gray; >+ else >+ dest->pub.put_pixel_rows = put_gray_rows; >+ } else if (cinfo->out_color_space == JCS_RGB) { >+ if (cinfo->quantize_colors) { >+ /* We only support 8-bit colormap indexes, so only 256 colors */ >+ num_colors = cinfo->actual_number_of_colors; >+ if (num_colors > 256) >+ ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors); >+ write_header(cinfo, dinfo, num_colors); >+ /* Write the colormap. Note Targa uses BGR byte order */ >+ outfile = dest->pub.output_file; >+ for (i = 0; i < num_colors; i++) { >+ putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile); >+ putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile); >+ putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile); >+ } >+ dest->pub.put_pixel_rows = put_gray_rows; >+ } else { >+ write_header(cinfo, dinfo, 0); >+ dest->pub.put_pixel_rows = put_pixel_rows; >+ } >+ } else { >+ ERREXIT(cinfo, JERR_TGA_COLORSPACE); >+ } >+} >+ >+ >+/* >+ * Finish up at the end of the file. >+ */ >+ >+METHODDEF(void) >+finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) >+{ >+ /* Make sure we wrote the output file OK */ >+ fflush(dinfo->output_file); >+ if (ferror(dinfo->output_file)) >+ ERREXIT(cinfo, JERR_FILE_WRITE); >+} >+ >+ >+/* >+ * The module selection routine for Targa format output. >+ */ >+ >+GLOBAL(djpeg_dest_ptr) >+jinit_write_targa (j_decompress_ptr cinfo) >+{ >+ tga_dest_ptr dest; >+ >+ /* Create module interface object, fill in method pointers */ >+ dest = (tga_dest_ptr) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ SIZEOF(tga_dest_struct)); >+ dest->pub.start_output = start_output_tga; >+ dest->pub.finish_output = finish_output_tga; >+ >+ /* Calculate output image dimensions so we can allocate space */ >+ jpeg_calc_output_dimensions(cinfo); >+ >+ /* Create I/O buffer. Note we make this near on a PC. */ >+ dest->buffer_width = cinfo->output_width * cinfo->output_components; >+ dest->iobuffer = (char *) >+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, >+ (size_t) (dest->buffer_width * SIZEOF(char))); >+ >+ /* Create decompressor output buffer. */ >+ dest->pub.buffer = (*cinfo->mem->alloc_sarray) >+ ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width, (JDIMENSION) 1); >+ dest->pub.buffer_height = 1; >+ >+ return (djpeg_dest_ptr) dest; >+} >+ >+#endif /* TARGA_SUPPORTED */ >diff --git a/toolkit/toolkit-makefiles.sh b/toolkit/toolkit-makefiles.sh >--- a/toolkit/toolkit-makefiles.sh >+++ b/toolkit/toolkit-makefiles.sh >@@ -1036,17 +1036,17 @@ if test -n "$MOZ_PSM"; then > security/manager/pki/src/Makefile > security/manager/pki/public/Makefile > security/manager/locales/Makefile > " > fi > > if [ ! "$SYSTEM_JPEG" ]; then > add_makefiles " >- jpeg/Makefile >+ modules/libjpeg-turbo/Makefile > " > fi > > if [ ! "$SYSTEM_ZLIB" ]; then > add_makefiles " > modules/zlib/Makefile > modules/zlib/src/Makefile > " >diff --git a/toolkit/toolkit-tiers.mk b/toolkit/toolkit-tiers.mk >--- a/toolkit/toolkit-tiers.mk >+++ b/toolkit/toolkit-tiers.mk >@@ -72,17 +72,17 @@ ifdef MOZ_AUTH_EXTENSION > tier_platform_dirs += extensions/auth > endif > > # > # "external" - 3rd party individual libraries > # > > ifndef MOZ_NATIVE_JPEG >-tier_platform_dirs += jpeg >+tier_platform_dirs += modules/libjpeg-turbo > endif > > # Installer needs standalone libjar, hence standalone zlib > ifdef MOZ_INSTALLER > tier_platform_dirs += modules/zlib/standalone > endif > > ifdef MOZ_UPDATER
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
|
Review
Attachments on
bug 573948
:
458811
|
463214
|
463217
|
463225
|
463272
|
463675
|
463677
|
463692
|
463695
|
464561
|
471713
|
522445
|
522446
|
522449
|
522459
|
522544
|
522583
|
522674