Merge libjpeg-turbo r1325
* commit 'b8d044a666056d4d8d28d7a5d0805ac32b619b36': (58 commits) Big oops. wrjpgcom on Windows was being built using the rdjpgcom source. Prevent a buffer overrun if the comment begins with a literal quote character and the string exceeds 65k characters. Also prevent comments longer than 65k characters from being written, since this will produce an incorrect JPEG file. Remove VMS-specific code Our copyright string is longer than JMSG_LENGTH_MAX, and this was causing a buffer overrun if output_message() was called with msg_code set to JMSG_COPYRIGHT, or if format_message() was called with msg_code set to JMSG_COPYRIGHT and with a buffer of length JMSG_LENGTH_MAX. We don't support non-ANSI C compilers Allow for building the MIPS DSPr2 extensions if the host is mips-* as well as mipsel-*. The DSPr2 extensions are little endian, so we still have to check that the compiler defines __MIPSEL__ before enabling them. This paves the way for supporting big-endian MIPS, and in the near term, it allows the SIMD extensions to be built with Sourcery CodeBench. SIMD-accelerated int upsample routine for MIPS DSPr2 Fix MIPS build libjpeg-turbo has never supported non-ANSI compilers, so get rid of the crufty SIZEOF() macro. It was not being used consistently anyhow, so it would not have been possible to build prior releases of libjpeg-turbo using the broken compilers for which that macro was designed. Remove MS-DOS code and information, and adjust copyright headers to reflect the removal of features in r1307 and r1308. libjpeg-turbo has never supported MS-DOS, nor is it even possible for us to do so. Further copyright header cleanup Further copyright header cleanup Get rid of the HAVE_PROTOTYPES configuration option, as well as the related JMETHOD and JPP macros. libjpeg-turbo has never supported compilers that don't handle prototypes. Doing so requires ansi2knr, which isn't even supported in the IJG code anymore. Remove all of the NEED_SHORT_EXTERNAL_NAMES stuff. There is scant information available as to which linkers ever had a 15-character global symbol name limit. AFAICT, it might have been a VMS and/or a.out BSD thing, but none of those platforms have ever been supported by libjpeg-turbo (nor are such systems supported by other open source libraries of this nature.) Clean up code formatting in the SIMD interface functions SIMD-accelerated NULL convert routine for MIPS DSPr2 Fix build, which was broken by the checkin of the MIPS DSPr2 accelerated smooth downsampling routine. Until/unless other platforms include SIMD support for that function, it's just easier to #ifdef around it rather than adding stubs for the other platforms. Fix error in MIPS DSPr2 accelerated smooth downsample routine SIMD-accelerated h2v2 smooth downsampling routine for MIPS DSPr2 Minor tweak to improve code readability ... Conflicts: BUILDING.txt CMakeLists.txt Makefile.am cdjpeg.h cjpeg.1 cjpeg.c configure.ac djpeg.1 example.c jccoefct.c jcdctmgr.c jchuff.c jchuff.h jcinit.c jcmaster.c jcparam.c jcphuff.c jidctflt.c jpegint.h jpeglib.h jversion.h libjpeg.txt rdswitch.c simd/CMakeLists.txt tjbench.c turbojpeg.c usage.txt wrjpgcom.c
This commit is contained in:
99
BUILDING.txt
99
BUILDING.txt
@@ -319,17 +319,15 @@ This release of libmozjpeg can use ARM NEON SIMD instructions to accelerate
|
||||
JPEG compression/decompression by approximately 2-4x on ARMv7 and later
|
||||
platforms. If libmozjpeg is configured on an ARM Linux platform, then the
|
||||
build system will automatically include the NEON SIMD routines, if they are
|
||||
supported.
|
||||
supported. Build instructions for other ARM-based platforms follow.
|
||||
|
||||
|
||||
Building libmozjpeg for iOS
|
||||
------------------------------
|
||||
|
||||
iOS platforms, such as the iPhone and iPad, also use ARM processors, some of
|
||||
which support NEON instructions. Additional steps are required to build
|
||||
libmozjpeg for these platforms. The steps below assume iOS SDK v4.3. If
|
||||
you are using a different SDK version, then you will need to modify the
|
||||
examples accordingly.
|
||||
iOS platforms, such as the iPhone and iPad, use ARM processors, some of which
|
||||
support NEON instructions. Additional steps are required in order to build
|
||||
libmozjpeg for these platforms.
|
||||
|
||||
Additional build requirements:
|
||||
|
||||
@@ -395,6 +393,45 @@ described above. Otherwise, you may get a libtool error such as "unable to
|
||||
infer tagged configuration."
|
||||
|
||||
|
||||
Building libjpeg-turbo for Android
|
||||
----------------------------------
|
||||
|
||||
Building libjpeg-turbo for Android platforms requires the Android NDK
|
||||
(https://developer.android.com/tools/sdk/ndk) and autotools. The following is
|
||||
a general recipe script that can be modified for your specific needs.
|
||||
|
||||
# Set these variables to suit your needs
|
||||
NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/ndk}
|
||||
BUILD_PLATFORM={the platform name for the NDK package you installed--
|
||||
for example, "windows-x86" or "linux-x86_64"}
|
||||
TOOLCHAIN_VERSION={"4.6", "4.8", etc. This corresponds to a toolchain
|
||||
directory under ${NDK_PATH}/toolchains/.}
|
||||
ANDROID_VERSION={The minimum version of Android to support-- for example,
|
||||
"9", "19", etc.}
|
||||
|
||||
HOST=arm-linux-androideabi
|
||||
TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
|
||||
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm
|
||||
ANDROID_INCLUDES="-I${SYSROOT}/usr/include -I${TOOLCHAIN}/include"
|
||||
ANDROID_CFLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays \
|
||||
-fstrict-aliasing --sysroot=${SYSROOT}"
|
||||
export CPP=${TOOLCHAIN}/bin/${HOST}-cpp
|
||||
export AR=${TOOLCHAIN}/bin/${HOST}-ar
|
||||
export AS=${TOOLCHAIN}/bin/${HOST}-as
|
||||
export NM=${TOOLCHAIN}/bin/${HOST}-nm
|
||||
export CC=${TOOLCHAIN}/bin/${HOST}-gcc
|
||||
export LD=${TOOLCHAIN}/bin/${HOST}-ld
|
||||
export RANLIB=${TOOLCHAIN}/bin/${HOST}-ranlib
|
||||
export OBJDUMP=${TOOLCHAIN}/bin/${HOST}-objdump
|
||||
export STRIP=${TOOLCHAIN}/bin/${HOST}-strip
|
||||
cd {build_directory}
|
||||
sh {source_directory}/configure --host=${HOST} \
|
||||
CFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS} -O3" \
|
||||
CPPFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS}" \
|
||||
LDFLAGS="${ANDROID_CFLAGS}" --with-simd ${1+"$@"}
|
||||
make
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
** Building on Windows (Visual C++ or MinGW)
|
||||
*******************************************************************************
|
||||
@@ -404,7 +441,7 @@ infer tagged configuration."
|
||||
Build Requirements
|
||||
==================
|
||||
|
||||
-- CMake (http://www.cmake.org) v2.6 or later
|
||||
-- CMake (http://www.cmake.org) v2.8.8 or later
|
||||
|
||||
-- Microsoft Visual C++ 2005 or later
|
||||
|
||||
@@ -416,8 +453,9 @@ Build Requirements
|
||||
The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and
|
||||
everything necessary to build libmozjpeg.
|
||||
|
||||
* For 32-bit builds, you can also use Microsoft Visual C++ Express
|
||||
Edition. Visual C++ Express Edition is a free download.
|
||||
* You can also use Microsoft Visual Studio Express Edition, which is a free
|
||||
download. (NOTE: versions prior to 2012 can only be used to build 32-bit
|
||||
code.)
|
||||
* If you intend to build libmozjpeg from the command line, then add the
|
||||
appropriate compiler and SDK directories to the INCLUDE, LIB, and PATH
|
||||
environment variables. This is generally accomplished by executing
|
||||
@@ -431,7 +469,11 @@ Build Requirements
|
||||
|
||||
-- MinGW
|
||||
|
||||
GCC v4.1 or later recommended for best performance
|
||||
MinGW-builds (http://sourceforge.net/projects/mingwbuilds/) or
|
||||
tdm-gcc (http://tdm-gcc.tdragon.net/) recommended if building on a Windows
|
||||
machine. Both distributions install a Start Menu link that can be used to
|
||||
launch a command prompt with the appropriate compiler paths automatically
|
||||
set.
|
||||
|
||||
-- NASM (http://www.nasm.us/) 0.98 or later (NASM 2.05 or later is required for
|
||||
a 64-bit build)
|
||||
@@ -496,7 +538,12 @@ Choose the appropriate CMake generator option for your version of Visual Studio
|
||||
instance:
|
||||
|
||||
cd {build_directory}
|
||||
cmake -G "Visual Studio 9 2008" {source_directory}
|
||||
cmake -G "Visual Studio 10" {source_directory}
|
||||
|
||||
NOTE: Add "Win64" to the generator name (for example, "Visual Studio 10
|
||||
Win64") to build a 64-bit version of libjpeg-turbo. Recent versions of CMake
|
||||
no longer document that. A separate build directory must be used for 32-bit
|
||||
and 64-bit builds.
|
||||
|
||||
You can then open ALL_BUILD.vcproj in Visual Studio and build one of the
|
||||
configurations in that project ("Debug", "Release", etc.) to generate a full
|
||||
@@ -525,9 +572,12 @@ depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
|
||||
MinGW
|
||||
-----
|
||||
|
||||
NOTE: This assumes that you are building on a Windows machine. If you are
|
||||
cross-compiling on a Linux/Unix machine, then see "Build Recipes" below.
|
||||
|
||||
cd {build_directory}
|
||||
cmake -G "MSYS Makefiles" {source_directory}
|
||||
make
|
||||
cmake -G "MinGW Makefiles" {source_directory}
|
||||
mingw32-make
|
||||
|
||||
This will generate the following files under {build_directory}
|
||||
|
||||
@@ -636,8 +686,8 @@ Build Recipes
|
||||
cd {build_directory}
|
||||
CC=/usr/bin/x86_64-w64-mingw32-gcc \
|
||||
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_AR=/usr/bin/x86_64-w64-mingw32-ar \
|
||||
-DCMAKE_RANLIB=/usr/bin/x86_64-w64-mingw32-ranlib {source_directory}
|
||||
-DCMAKE_RC_COMPILER=/usr/bin/x86_64-w64-mingw32-windres.exe \
|
||||
{source_directory}
|
||||
make
|
||||
|
||||
This produces a 64-bit build of libmozjpeg that does not depend on
|
||||
@@ -651,8 +701,8 @@ mingw64-x86_64-gcc-g++ packages (and their dependencies) must be installed.
|
||||
cd {build_directory}
|
||||
CC=/usr/bin/i686-w64-mingw32-gcc \
|
||||
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DDCMAKE_AR=/usr/bin/i686-w64-mingw32-ar \
|
||||
-DCMAKE_RANLIB=/usr/bin/i686-w64-mingw32-ranlib {source_directory}
|
||||
-DCMAKE_RC_COMPILER=/usr/bin/i686-w64-mingw32-windres.exe \
|
||||
{source_directory}
|
||||
make
|
||||
|
||||
This produces a 32-bit build of libmozjpeg that does not depend on
|
||||
@@ -660,21 +710,6 @@ cygwin1.dll or other Cygwin DLL's. The mingw64-i686-gcc-core and
|
||||
mingw64-i686-gcc-g++ packages (and their dependencies) must be installed.
|
||||
|
||||
|
||||
MinGW-w64 Build on Windows
|
||||
--------------------------
|
||||
|
||||
This produces a 64-bit build of libmozjpeg using the "native" MinGW-w64
|
||||
toolchain (which is faster than the Cygwin version):
|
||||
|
||||
cd {build_directory}
|
||||
CC={mingw-w64_binary_path}/x86_64-w64-mingw32-gcc \
|
||||
cmake -G "MSYS Makefiles" \
|
||||
-DCMAKE_AR={mingw-w64_binary_path}/x86_64-w64-mingw32-ar \
|
||||
-DCMAKE_RANLIB={mingw-w64_binary_path}/x86_64-w64-mingw32-ranlib \
|
||||
{source_directory}
|
||||
make
|
||||
|
||||
|
||||
MinGW Build on Linux
|
||||
--------------------
|
||||
|
||||
|
||||
549
CMakeLists.txt
549
CMakeLists.txt
@@ -3,12 +3,15 @@
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
cmake_policy(SET CMP0022 OLD)
|
||||
# Use LINK_INTERFACE_LIBRARIES instead of INTERFACE_LINK_LIBRARIES
|
||||
if(POLICY CMP0022)
|
||||
cmake_policy(SET CMP0022 OLD)
|
||||
endif()
|
||||
|
||||
project(libmozjpeg C)
|
||||
set(VERSION 2.0.1)
|
||||
|
||||
if(MINGW OR CYGWIN)
|
||||
if(CYGWIN OR NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
||||
execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
|
||||
string(REGEX REPLACE "\n" "" BUILD "${BUILD}")
|
||||
elseif(WIN32)
|
||||
@@ -140,7 +143,7 @@ endif()
|
||||
message(STATUS "Install directory = ${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
configure_file(win/jconfig.h.in jconfig.h)
|
||||
configure_file(win/config.h.in config.h)
|
||||
configure_file(win/jconfigint.h.in jconfigint.h)
|
||||
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_SOURCE_DIR}")
|
||||
|
||||
@@ -280,167 +283,397 @@ endif()
|
||||
|
||||
enable_testing()
|
||||
|
||||
set(MD5_JPEG_INT 9a68f56bc76e466aa7e52f415d0f4a5f)
|
||||
set(MD5_JPEG_FAST 0e1502e7fa421835e376a314fac2a39f)
|
||||
set(MD5_JPEG_FAST_100 7bf72a8e741d64eecb960c97323af77c)
|
||||
set(MD5_JPEG_FLOAT d1623885ffafcd40c684af09e3d65cd5)
|
||||
set(MD5_JPEG_FLOAT_NOSIMD fb4884c35f8273f498cb32879de5c455)
|
||||
set(MD5_JPEG_INT_GRAY 72b51f894b8f4a10b3ee3066770aa38d)
|
||||
set(MD5_PPM_INT d1ed0d11f076b842525271647716aeb8)
|
||||
set(MD5_PPM_FAST 048298a2d2410261c0533cb97bcfef23)
|
||||
set(MD5_PPM_FLOAT 7f5b446ee36b2630e06785b8d42af15f)
|
||||
set(MD5_PPM_FLOAT_NOSIMD 64072f1dbdc5b3a187777788604971a5)
|
||||
set(MD5_PPM_INT_2_1 9f9de8c0612f8d06869b960b05abf9c9)
|
||||
set(MD5_PPM_INT_15_8 b6875bc070720b899566cc06459b63b7)
|
||||
set(MD5_PPM_INT_7_4 06a177eae05f164fac57f7a2c346ee87)
|
||||
set(MD5_PPM_INT_13_8 bc3452573c8152f6ae552939ee19f82f)
|
||||
set(MD5_PPM_INT_3_2 f5a8b88a8a7f96016f04d259cf82ed67)
|
||||
set(MD5_PPM_INT_11_8 d8cc73c0aaacd4556569b59437ba00a5)
|
||||
set(MD5_PPM_INT_5_4 32775dd9ad2ab90f4c5b219b53e0c86c)
|
||||
set(MD5_PPM_INT_9_8 d25e61bc7eac0002f5b393aa223747b6)
|
||||
set(MD5_PPM_INT_7_8 ddb564b7c74a09494016d6cd7502a946)
|
||||
set(MD5_PPM_INT_3_4 8ed8e68808c3fbc4ea764fc9d2968646)
|
||||
set(MD5_PPM_INT_5_8 a3363274999da2366a024efae6d16c9b)
|
||||
set(MD5_PPM_INT_1_2 e692a315cea26b988c8e8b29a5dbcd81)
|
||||
set(MD5_PPM_INT_3_8 79eca9175652ced755155c90e785a996)
|
||||
set(MD5_PPM_INT_1_4 79cd778f8bf1a117690052cacdd54eca)
|
||||
set(MD5_PPM_INT_1_8 391b3d4aca640c8567d6f8745eb2142f)
|
||||
set(MD5_PPM_FAST_1_2 f30bcf6d32ccd44cbdd9aeaacbd9454f)
|
||||
set(MD5_BMP_256 4980185e3776e89bd931736e1cddeee6)
|
||||
set(MD5_JPEG_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
|
||||
set(MD5_PPM_ARI 72b59a99bcf1de24c5b27d151bde2437)
|
||||
set(MD5_JPEG_PROG 1c4afddc05c0a43489ee54438a482d92)
|
||||
set(MD5_JPEG_PROG_ARI 0a8f1c8f66e113c3cf635df0a475a617)
|
||||
set(MD5_JPEG_RGB_ISLOW 768e970dd57b340ff1b83c9d3d47c77b)
|
||||
set(MD5_PPM_RGB_ISLOW 00a257f5393fef8821f2b88ac7421291)
|
||||
set(MD5_BMP_RGB_ISLOW_565 f07d2e75073e4bb10f6c6f4d36e2e3be)
|
||||
set(MD5_BMP_RGB_ISLOW_565D 4cfa0928ef3e6bb626d7728c924cfda4)
|
||||
set(MD5_JPEG_422_IFAST_OPT 2540287b79d913f91665e660303ab2c8)
|
||||
set(MD5_PPM_422_IFAST 35bd6b3f833bad23de82acea847129fa)
|
||||
set(MD5_PPM_422M_IFAST 8dbc65323d62cca7c91ba02dd1cfa81d)
|
||||
set(MD5_BMP_422M_IFAST_565 3294bd4d9a1f2b3d08ea6020d0db7065)
|
||||
set(MD5_BMP_422M_IFAST_565D da98c9c7b6039511be4a79a878a9abc1)
|
||||
set(MD5_JPEG_420_IFAST_Q100_PROG 990cbe0329c882420a2094da7e5adade)
|
||||
set(MD5_PPM_420_Q100_IFAST 5a732542015c278ff43635e473a8a294)
|
||||
set(MD5_PPM_420M_Q100_IFAST ff692ee9323a3b424894862557c092f1)
|
||||
set(MD5_JPEG_GRAY_ISLOW 72b51f894b8f4a10b3ee3066770aa38d)
|
||||
set(MD5_PPM_GRAY_ISLOW 8d3596c56eace32f205deccc229aa5ed)
|
||||
set(MD5_PPM_GRAY_ISLOW_RGB 116424ac07b79e5e801f00508eab48ec)
|
||||
set(MD5_BMP_GRAY_ISLOW_565 12f78118e56a2f48b966f792fedf23cc)
|
||||
set(MD5_BMP_GRAY_ISLOW_565D bdbbd616441a24354c98553df5dc82db)
|
||||
set(MD5_JPEG_420S_IFAST_OPT 388708217ac46273ca33086b22827ed8)
|
||||
if(WITH_SIMD)
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG 343e3f8caf8af5986ebaf0bdc13b5c71)
|
||||
set(MD5_PPM_3x2_FLOAT 1a75f36e5904d6fc3a85a43da9ad89bb)
|
||||
else()
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG 9bca803d2042bd1eb03819e2bf92b3e5)
|
||||
set(MD5_PPM_3x2_FLOAT f6bfab038438ed8f5522fbd33595dcdc)
|
||||
endif()
|
||||
set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
|
||||
set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617)
|
||||
set(MD5_PPM_420M_IFAST_ARI 72b59a99bcf1de24c5b27d151bde2437)
|
||||
set(MD5_JPEG_420_ISLOW 9a68f56bc76e466aa7e52f415d0f4a5f)
|
||||
set(MD5_PPM_420M_ISLOW_2_1 9f9de8c0612f8d06869b960b05abf9c9)
|
||||
set(MD5_PPM_420M_ISLOW_15_8 b6875bc070720b899566cc06459b63b7)
|
||||
set(MD5_PPM_420M_ISLOW_13_8 bc3452573c8152f6ae552939ee19f82f)
|
||||
set(MD5_PPM_420M_ISLOW_11_8 d8cc73c0aaacd4556569b59437ba00a5)
|
||||
set(MD5_PPM_420M_ISLOW_9_8 d25e61bc7eac0002f5b393aa223747b6)
|
||||
set(MD5_PPM_420M_ISLOW_7_8 ddb564b7c74a09494016d6cd7502a946)
|
||||
set(MD5_PPM_420M_ISLOW_3_4 8ed8e68808c3fbc4ea764fc9d2968646)
|
||||
set(MD5_PPM_420M_ISLOW_5_8 a3363274999da2366a024efae6d16c9b)
|
||||
set(MD5_PPM_420M_ISLOW_1_2 e692a315cea26b988c8e8b29a5dbcd81)
|
||||
set(MD5_PPM_420M_ISLOW_3_8 79eca9175652ced755155c90e785a996)
|
||||
set(MD5_PPM_420M_ISLOW_1_4 79cd778f8bf1a117690052cacdd54eca)
|
||||
set(MD5_PPM_420M_ISLOW_1_8 391b3d4aca640c8567d6f8745eb2142f)
|
||||
set(MD5_BMP_420_ISLOW_256 4980185e3776e89bd931736e1cddeee6)
|
||||
set(MD5_BMP_420_ISLOW_565 bf9d13e16c4923b92e1faa604d7922cb)
|
||||
set(MD5_BMP_420_ISLOW_565D 6bde71526acc44bcff76f696df8638d2)
|
||||
set(MD5_BMP_420M_ISLOW_565 8dc0185245353cfa32ad97027342216f)
|
||||
set(MD5_BMP_420M_ISLOW_565D d1be3a3339166255e76fa50a0d70d73e)
|
||||
set(MD5_JPEG_CROP b4197f377e621c4e9b1d20471432610d)
|
||||
|
||||
if(WITH_JAVA)
|
||||
add_test(TJUnitTest ${JAVA_RUNTIME} -cp "java/${OBJDIR}turbojpeg.jar" "-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}" TJUnitTest)
|
||||
add_test(TJUnitTest-yuv ${JAVA_RUNTIME} -cp "java/${OBJDIR}turbojpeg.jar" "-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}" TJUnitTest -yuv)
|
||||
add_test(TJUnitTest-yuv-nopad ${JAVA_RUNTIME} -cp "java/${OBJDIR}turbojpeg.jar" "-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}" TJUnitTest -yuv -noyuvpad)
|
||||
add_test(TJUnitTest-bi ${JAVA_RUNTIME} -cp "java/${OBJDIR}turbojpeg.jar" "-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}" TJUnitTest -bi)
|
||||
add_test(TJUnitTest-bi-yuv ${JAVA_RUNTIME} -cp "java/${OBJDIR}turbojpeg.jar" "-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}" TJUnitTest -bi -yuv)
|
||||
add_test(TJUnitTest-bi-yuv-nopad ${JAVA_RUNTIME} -cp "java/${OBJDIR}turbojpeg.jar" "-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}" TJUnitTest -bi -yuv -noyuvpad)
|
||||
add_test(TJUnitTest
|
||||
${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
|
||||
-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
|
||||
TJUnitTest)
|
||||
add_test(TJUnitTest-yuv
|
||||
${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
|
||||
-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
|
||||
TJUnitTest -yuv)
|
||||
add_test(TJUnitTest-yuv-nopad
|
||||
${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
|
||||
-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
|
||||
TJUnitTest -yuv -noyuvpad)
|
||||
add_test(TJUnitTest-bi
|
||||
${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
|
||||
-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
|
||||
TJUnitTest -bi)
|
||||
add_test(TJUnitTest-bi-yuv
|
||||
${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
|
||||
-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
|
||||
TJUnitTest -bi -yuv)
|
||||
add_test(TJUnitTest-bi-yuv-nopad
|
||||
${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
|
||||
-Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
|
||||
TJUnitTest -bi -yuv -noyuvpad)
|
||||
endif()
|
||||
add_test(tjunittest tjunittest)
|
||||
add_test(tjunittest-alloc tjunittest -alloc)
|
||||
add_test(tjunittest-yuv tjunittest -yuv)
|
||||
add_test(tjunittest-yuv-alloc tjunittest -yuv -alloc)
|
||||
add_test(tjunittest-yuv-nopad tjunittest -yuv -noyuvpad)
|
||||
add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-int-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_INT} -DFILE=testoutint.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(cjpeg-fast sharedlib/cjpeg -dct fast -opt -outfile testoutfst.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-fast-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_FAST} -DFILE=testoutfst.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(cjpeg-fast-100 sharedlib/cjpeg -dct fast -quality 100 -opt -outfile testoutfst100.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-fast-100-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_FAST_100} -DFILE=testoutfst100.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(cjpeg-float sharedlib/cjpeg -dct float -outfile testoutflt.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
if(WITH_SIMD)
|
||||
add_test(cjpeg-float-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_FLOAT} -DFILE=testoutflt.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
else()
|
||||
add_test(cjpeg-float-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_FLOAT_NOSIMD} -DFILE=testoutflt.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
endif()
|
||||
add_test(cjpeg-int-gray sharedlib/cjpeg -dct int -grayscale -outfile testoutgray.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-int-gray-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_INT_GRAY} -DFILE=testoutgray.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(djpeg-int sharedlib/djpeg -dct int -fast -ppm -outfile testoutint.ppm "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(djpeg-int-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_INT} -DFILE=testoutint.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(djpeg-fast sharedlib/djpeg -dct fast -ppm -outfile testoutfst.ppm "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(djpeg-fast-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_FAST} -DFILE=testoutfst.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(djpeg-float sharedlib/djpeg -dct float -ppm -outfile testoutflt.ppm "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
if(WITH_SIMD)
|
||||
add_test(djpeg-float-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_FLOAT} -DFILE=testoutflt.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
else()
|
||||
add_test(djpeg-float-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_FLOAT_NOSIMD} -DFILE=testoutflt.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
endif()
|
||||
foreach(scale 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8)
|
||||
string(REGEX REPLACE "_" "/" scalearg ${scale})
|
||||
add_test(djpeg-int-${scale} sharedlib/djpeg -dct int -nosmooth -scale ${scalearg} -ppm -outfile testoutint${scale}.ppm "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(djpeg-int-${scale}-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_INT_${scale}} -DFILE=testoutint${scale}.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
endforeach()
|
||||
add_test(djpeg-fast-1_2 sharedlib/djpeg -dct fast -scale 1/2 -ppm -outfile testoutfst1_2.ppm "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(djpeg-fast-1_2-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_FAST_1_2} -DFILE=testoutfst1_2.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(djpeg-256 sharedlib/djpeg -dct int -bmp -colors 256 -outfile testout.bmp "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(djpeg-256-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_BMP_256} -DFILE=testout.bmp -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(cjpeg-prog sharedlib/cjpeg -dct int -progressive -outfile testoutp.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-prog-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_PROG} -DFILE=testoutp.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(jpegtran-prog sharedlib/jpegtran -outfile testoutt.jpg testoutp.jpg")
|
||||
add_test(jpegtran-prog-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_INT} -DFILE=testoutt.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
if(WITH_ARITH_ENC)
|
||||
add_test(cjpeg-ari sharedlib/cjpeg -dct int -arithmetic -outfile testoutari.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-ari-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_ARI} -DFILE=testoutari.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(jpegtran-toari sharedlib/jpegtran -arithmetic -outfile testouta.jpg "${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg")
|
||||
add_test(jpegtran-toari-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_ARI} -DFILE=testouta.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(cjpeg-prog-ari sharedlib/cjpeg -dct int -progressive -arithmetic -sample 1x1 -outfile testoutpa.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-prog-ari-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_PROG_ARI} -DFILE=testoutpa.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
endif()
|
||||
if(WITH_ARITH_DEC)
|
||||
add_test(djpeg-ari sharedlib/djpeg -dct int -fast -ppm -outfile testoutari.ppm "${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg")
|
||||
add_test(djpeg-ari-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_ARI} -DFILE=testoutari.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(jpegtran-fromari sharedlib/jpegtran -outfile testouta.jpg "${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg")
|
||||
add_test(jpegtran-fromari-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_INT} -DFILE=testouta.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
endif()
|
||||
add_test(jpegtran-crop sharedlib/jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(jpegtran-crop-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_CROP} -DFILE=testoutcrop.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
|
||||
add_test(tjunittest-static tjunittest-static)
|
||||
add_test(tjunittest-static-alloc tjunittest-static -alloc)
|
||||
add_test(tjunittest-static-yuv tjunittest-static -yuv)
|
||||
add_test(tjunittest-static-yuv-alloc tjunittest-static -yuv -alloc)
|
||||
add_test(tjunittest-static-yuv-nopad tjunittest-static -yuv -noyuvpad)
|
||||
add_test(cjpeg-static-int cjpeg-static -dct int -outfile testoutint.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-static-int-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_INT} -DFILE=testoutint.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(cjpeg-static-fast cjpeg-static -dct fast -opt -outfile testoutfst.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-static-fast-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_FAST} -DFILE=testoutfst.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(cjpeg-static-fast-100 cjpeg-static -dct fast -quality 100 -opt -outfile testoutfst100.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-static-fast-100-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_FAST_100} -DFILE=testoutfst100.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(cjpeg-static-float cjpeg-static -dct float -outfile testoutflt.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
if(WITH_SIMD)
|
||||
add_test(cjpeg-static-float-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_FLOAT} -DFILE=testoutflt.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
else()
|
||||
add_test(cjpeg-static-float-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_FLOAT_NOSIMD} -DFILE=testoutflt.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
endif()
|
||||
add_test(cjpeg-static-int-gray cjpeg-static -dct int -grayscale -outfile testoutgray.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-static-int-gray-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_INT_GRAY} -DFILE=testoutgray.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(djpeg-static-int djpeg-static -dct int -fast -ppm -outfile testoutint.ppm "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(djpeg-static-int-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_INT} -DFILE=testoutint.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(djpeg-static-fast djpeg-static -dct fast -ppm -outfile testoutfst.ppm "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(djpeg-static-fast-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_FAST} -DFILE=testoutfst.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(djpeg-static-float djpeg-static -dct float -ppm -outfile testoutflt.ppm "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
if(WITH_SIMD)
|
||||
add_test(djpeg-static-float-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_FLOAT} -DFILE=testoutflt.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
else()
|
||||
add_test(djpeg-static-float-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_FLOAT_NOSIMD} -DFILE=testoutflt.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
endif()
|
||||
foreach(scale 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8)
|
||||
string(REGEX REPLACE "_" "/" scalearg ${scale})
|
||||
add_test(djpeg-static-int-${scale} djpeg-static -dct int -nosmooth -scale ${scalearg} -ppm -outfile testoutint${scale}.ppm "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(djpeg-static-int-${scale}-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_INT_${scale}} -DFILE=testoutint${scale}.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
endforeach()
|
||||
add_test(djpeg-static-fast-1_2 djpeg-static -dct fast -scale 1/2 -ppm -outfile testoutfst1_2.ppm "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(djpeg-static-fast-1_2-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_FAST_1_2} -DFILE=testoutfst1_2.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(djpeg-static-256 djpeg-static -dct int -bmp -colors 256 -outfile testout.bmp "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(djpeg-static-256-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_BMP_256} -DFILE=testout.bmp -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(cjpeg-static-prog cjpeg-static -dct int -progressive -outfile testoutp.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-static-prog-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_PROG} -DFILE=testoutp.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(jpegtran-static-prog jpegtran-static -outfile testoutt.jpg testoutp.jpg")
|
||||
add_test(jpegtran-static-prog-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_INT} -DFILE=testoutt.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
if(WITH_ARITH_ENC)
|
||||
add_test(cjpeg-static-ari cjpeg-static -dct int -arithmetic -outfile testoutari.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-static-ari-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_ARI} -DFILE=testoutari.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(jpegtran-static-toari jpegtran-static -arithmetic -outfile testouta.jpg "${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg")
|
||||
add_test(jpegtran-static-toari-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_ARI} -DFILE=testouta.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(cjpeg-static-prog-ari cjpeg-static -dct int -progressive -arithmetic -sample 1x1 -outfile testoutpa.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.ppm")
|
||||
add_test(cjpeg-static-prog-ari-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_PROG_ARI} -DFILE=testoutpa.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
endif()
|
||||
if(WITH_ARITH_DEC)
|
||||
add_test(djpeg-static-ari djpeg-static -dct int -fast -ppm -outfile testoutari.ppm "${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg")
|
||||
add_test(djpeg-static-ari-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_PPM_ARI} -DFILE=testoutari.ppm -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
add_test(jpegtran-static-fromari jpegtran-static -outfile testouta.jpg "${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg")
|
||||
add_test(jpegtran-static-fromari-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_INT} -DFILE=testouta.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
endif()
|
||||
add_test(jpegtran-static-crop jpegtran-static -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg "${CMAKE_SOURCE_DIR}/testimages/testorig.jpg")
|
||||
add_test(jpegtran-static-crop-cmp "${CMAKE_COMMAND}" -DMD5=${MD5_JPEG_CROP} -DFILE=testoutcrop.jpg -P "${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake")
|
||||
foreach(libtype shared static)
|
||||
if(libtype STREQUAL "shared")
|
||||
set(dir sharedlib/)
|
||||
else()
|
||||
set(dir "")
|
||||
set(suffix -static)
|
||||
endif()
|
||||
add_test(tjunittest${suffix} tjunittest${suffix})
|
||||
add_test(tjunittest${suffix}-alloc tjunittest${suffix} -alloc)
|
||||
add_test(tjunittest${suffix}-yuv tjunittest${suffix} -yuv)
|
||||
add_test(tjunittest${suffix}-yuv-alloc tjunittest${suffix} -yuv -alloc)
|
||||
add_test(tjunittest${suffix}-yuv-nopad tjunittest${suffix} -yuv -noyuvpad)
|
||||
|
||||
add_custom_target(testclean COMMAND "${CMAKE_COMMAND}" -P
|
||||
"${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake" VERBATIM)
|
||||
# These tests are carefully chosen to provide full coverage of as many of the
|
||||
# underlying algorithms as possible (including all of the SIMD-accelerated
|
||||
# ones.)
|
||||
|
||||
# CC: null SAMP: fullsize FDCT: islow ENT: huff
|
||||
add_test(cjpeg${suffix}-rgb-islow
|
||||
${dir}cjpeg${suffix} -rgb -dct int -outfile testout_rgb_islow.jpg
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
|
||||
add_test(cjpeg${suffix}-rgb-islow-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_RGB_ISLOW} -DFILE=testout_rgb_islow.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: null SAMP: fullsize IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-rgb-islow
|
||||
${dir}djpeg${suffix} -dct int -ppm -outfile testout_rgb_islow.ppm
|
||||
testout_rgb_islow.jpg)
|
||||
add_test(djpeg${suffix}-rgb-islow-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_PPM_RGB_ISLOW} -DFILE=testout_rgb_islow.ppm
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: RGB->RGB565 SAMP: fullsize IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-rgb-islow-565
|
||||
${dir}djpeg${suffix} -dct int -rgb565 -dither none -bmp
|
||||
-outfile testout_rgb_islow_565.bmp testout_rgb_islow.jpg)
|
||||
add_test(djpeg${suffix}-rgb-islow-565-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_RGB_ISLOW_565}
|
||||
-DFILE=testout_rgb_islow_565.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: RGB->RGB565 (dithered) SAMP: fullsize IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-rgb-islow-565D
|
||||
${dir}djpeg${suffix} -dct int -rgb565 -bmp
|
||||
-outfile testout_rgb_islow_565D.bmp testout_rgb_islow.jpg)
|
||||
add_test(djpeg${suffix}-rgb-islow-565D-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_RGB_ISLOW_565D}
|
||||
-DFILE=testout_rgb_islow_565D.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
|
||||
# CC: RGB->YCC SAMP: fullsize/h2v1 FDCT: ifast ENT: 2-pass huff
|
||||
add_test(cjpeg${suffix}-422-ifast-opt
|
||||
${dir}cjpeg${suffix} -sample 2x1 -dct fast -opt
|
||||
-outfile testout_422_ifast_opt.jpg
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
|
||||
add_test(cjpeg${suffix}-422-ifast-opt-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_422_IFAST_OPT}
|
||||
-DFILE=testout_422_ifast_opt.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB SAMP: fullsize/h2v1 fancy IDCT: ifast ENT: huff
|
||||
add_test(djpeg${suffix}-422-ifast
|
||||
${dir}djpeg${suffix} -dct fast -outfile testout_422_ifast.ppm
|
||||
testout_422_ifast_opt.jpg)
|
||||
add_test(djpeg${suffix}-422-ifast-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_PPM_422_IFAST} -DFILE=testout_422_ifast.ppm
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB SAMP: h2v1 merged IDCT: ifast ENT: huff
|
||||
add_test(djpeg${suffix}-422m-ifast
|
||||
${dir}djpeg${suffix} -dct fast -nosmooth -outfile testout_422m_ifast.ppm
|
||||
testout_422_ifast_opt.jpg)
|
||||
add_test(djpeg${suffix}-422m-ifast-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_PPM_422M_IFAST} -DFILE=testout_422m_ifast.ppm
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB565 SAMP: h2v1 merged IDCT: ifast ENT: huff
|
||||
add_test(djpeg${suffix}-422m-ifast-565
|
||||
${dir}djpeg${suffix} -dct int -nosmooth -rgb565 -dither none -bmp
|
||||
-outfile testout_422m_ifast_565.bmp testout_422_ifast_opt.jpg)
|
||||
add_test(djpeg${suffix}-422m-ifast-565-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_422M_IFAST_565}
|
||||
-DFILE=testout_422m_ifast_565.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB565 (dithered) SAMP: h2v1 merged IDCT: ifast ENT: huff
|
||||
add_test(djpeg${suffix}-422m-ifast-565D
|
||||
${dir}djpeg${suffix} -dct int -nosmooth -rgb565 -bmp
|
||||
-outfile testout_422m_ifast_565D.bmp testout_422_ifast_opt.jpg)
|
||||
add_test(djpeg${suffix}-422m-ifast-565D-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_422M_IFAST_565D}
|
||||
-DFILE=testout_422m_ifast_565D.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
|
||||
# CC: RGB->YCC SAMP: fullsize/h2v2 FDCT: ifast ENT: prog huff
|
||||
add_test(cjpeg${suffix}-420-q100-ifast-prog
|
||||
${dir}cjpeg${suffix} -sample 2x2 -quality 100 -dct fast -prog
|
||||
-outfile testout_420_q100_ifast_prog.jpg
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
|
||||
add_test(cjpeg${suffix}-420-q100-ifast-prog-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_420_IFAST_Q100_PROG}
|
||||
-DFILE=testout_420_q100_ifast_prog.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB SAMP: fullsize/h2v2 fancy IDCT: ifast ENT: prog huff
|
||||
add_test(djpeg${suffix}-420-q100-ifast-prog
|
||||
${dir}djpeg${suffix} -dct fast -outfile testout_420_q100_ifast.ppm
|
||||
testout_420_q100_ifast_prog.jpg)
|
||||
add_test(djpeg${suffix}-420-q100-ifast-prog-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_PPM_420_Q100_IFAST}
|
||||
-DFILE=testout_420_q100_ifast.ppm
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: ifast ENT: prog huff
|
||||
add_test(djpeg${suffix}-420m-q100-ifast-prog
|
||||
${dir}djpeg${suffix} -dct fast -nosmooth
|
||||
-outfile testout_420m_q100_ifast.ppm testout_420_q100_ifast_prog.jpg)
|
||||
add_test(djpeg${suffix}-420m-q100-ifast-prog-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_PPM_420M_Q100_IFAST}
|
||||
-DFILE=testout_420m_q100_ifast.ppm
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
|
||||
# CC: RGB->Gray SAMP: fullsize FDCT: islow ENT: huff
|
||||
add_test(cjpeg${suffix}-gray-islow
|
||||
${dir}cjpeg${suffix} -gray -dct int -outfile testout_gray_islow.jpg
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
|
||||
add_test(cjpeg${suffix}-gray-islow-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_GRAY_ISLOW}
|
||||
-DFILE=testout_gray_islow.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: Gray->Gray SAMP: fullsize IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-gray-islow
|
||||
${dir}djpeg${suffix} -dct int -outfile testout_gray_islow.ppm
|
||||
testout_gray_islow.jpg)
|
||||
add_test(djpeg${suffix}-gray-islow-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_PPM_GRAY_ISLOW}
|
||||
-DFILE=testout_gray_islow.ppm
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: Gray->RGB SAMP: fullsize IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-gray-islow-rgb
|
||||
${dir}djpeg${suffix} -dct int -rgb -outfile testout_gray_islow_rgb.ppm
|
||||
testout_gray_islow.jpg)
|
||||
add_test(cjpeg${suffix}-gray-islow-rgb-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_PPM_GRAY_ISLOW_RGB}
|
||||
-DFILE=testout_gray_islow_rgb.ppm
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: Gray->RGB565 SAMP: fullsize IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-gray-islow-565
|
||||
${dir}djpeg${suffix} -dct int -rgb565 -dither none -bmp
|
||||
-outfile testout_gray_islow_565.bmp testout_gray_islow.jpg)
|
||||
add_test(djpeg${suffix}-gray-islow-565-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_GRAY_ISLOW_565}
|
||||
-DFILE=testout_gray_islow_565.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: Gray->RGB565 (dithered) SAMP: fullsize IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-gray-islow-565D
|
||||
${dir}djpeg${suffix} -dct int -rgb565 -bmp
|
||||
-outfile testout_gray_islow_565D.bmp testout_gray_islow.jpg)
|
||||
add_test(djpeg${suffix}-gray-islow-565D-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_GRAY_ISLOW_565D}
|
||||
-DFILE=testout_gray_islow_565D.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
|
||||
# CC: RGB->YCC SAMP: fullsize smooth/h2v2 smooth FDCT: islow
|
||||
# ENT: 2-pass huff
|
||||
add_test(cjpeg${suffix}-420s-ifast-opt
|
||||
${dir}cjpeg${suffix} -sample 2x2 -smooth 1 -dct int -opt -outfile
|
||||
testout_420s_ifast_opt.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
|
||||
add_test(cjpeg${suffix}-420s-ifast-opt-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_420S_IFAST_OPT}
|
||||
-DFILE=testout_420s_ifast_opt.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
|
||||
# CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff
|
||||
add_test(cjpeg${suffix}-3x2-float-prog
|
||||
${dir}cjpeg${suffix} -sample 3x2 -dct float -prog
|
||||
-outfile testout_3x2_float_prog.jpg
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
|
||||
add_test(cjpeg${suffix}-3x2-float-prog-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_3x2_FLOAT_PROG}
|
||||
-DFILE=testout_3x2_float_prog.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB SAMP: fullsize/int IDCT: float ENT: prog huff
|
||||
add_test(djpeg${suffix}-3x2-float-prog
|
||||
${dir}djpeg${suffix} -dct float -outfile testout_3x2_float.ppm
|
||||
testout_3x2_float_prog.jpg)
|
||||
add_test(djpeg${suffix}-3x2-float-prog-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_PPM_3x2_FLOAT} -DFILE=testout_3x2_float.ppm
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
|
||||
if(WITH_ARITH_ENC)
|
||||
# CC: YCC->RGB SAMP: fullsize/h2v2 FDCT: islow ENT: arith
|
||||
add_test(cjpeg${suffix}-420-islow-ari
|
||||
${dir}cjpeg${suffix} -dct int -arithmetic
|
||||
-outfile testout_420_islow_ari.jpg
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
|
||||
add_test(cjpeg${suffix}-420-islow-ari-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_420_ISLOW_ARI}
|
||||
-DFILE=testout_420_islow_ari.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
add_test(jpegtran${suffix}-420-islow-ari
|
||||
${dir}jpegtran${suffix} -arithmetic
|
||||
-outfile testout_420_islow_ari.jpg
|
||||
${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg)
|
||||
add_test(jpegtran${suffix}-420-islow-ari-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_420_ISLOW_ARI}
|
||||
-DFILE=testout_420_islow_ari.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB SAMP: fullsize FDCT: islow ENT: prog arith
|
||||
add_test(cjpeg${suffix}-444-islow-progari
|
||||
${dir}cjpeg${suffix} -sample 1x1 -dct int -progressive -arithmetic
|
||||
-outfile testout_444_islow_progari.jpg
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
|
||||
add_test(cjpeg${suffix}-444-islow-progari-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_444_ISLOW_PROGARI}
|
||||
-DFILE=testout_444_islow_progari.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
endif()
|
||||
if(WITH_ARITH_DEC)
|
||||
# CC: RGB->YCC SAMP: h2v2 merged IDCT: ifast ENT: arith
|
||||
add_test(cjpeg${suffix}-420m-ifast-ari
|
||||
${dir}djpeg${suffix} -fast -ppm -outfile testout_420m_ifast_ari.ppm
|
||||
${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
|
||||
add_test(cjpeg${suffix}-420m-ifast-ari-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_PPM_420M_IFAST_ARI}
|
||||
-DFILE=testout_420m_ifast_ari.ppm
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
add_test(jpegtran${suffix}-420-islow
|
||||
${dir}jpegtran${suffix} -outfile testout_420_islow.jpg
|
||||
${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
|
||||
add_test(jpegtran${suffix}-420-islow-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_420_ISLOW}
|
||||
-DFILE=testout_420_islow.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
endif()
|
||||
|
||||
# 2/1-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 16x16 islow ENT: huff
|
||||
# 15/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 15x15 islow ENT: huff
|
||||
# 13/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 13x13 islow ENT: huff
|
||||
# 11/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 11x11 islow ENT: huff
|
||||
# 9/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 9x9 islow ENT: huff
|
||||
# 7/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 7x7 islow/14x14 islow
|
||||
# ENT: huff
|
||||
# 3/4-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 6x6 islow/12x12 islow
|
||||
# ENT: huff
|
||||
# 5/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 5x5 islow/10x10 islow
|
||||
# ENT: huff
|
||||
# 1/2-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 4x4 islow/8x8 islow
|
||||
# ENT: huff
|
||||
# 3/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 3x3 islow/6x6 islow
|
||||
# ENT: huff
|
||||
# 1/4-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 2x2 islow/4x4 islow
|
||||
# ENT: huff
|
||||
# 1/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 1x1 islow/2x2 islow
|
||||
# ENT: huff
|
||||
foreach(scale 2_1 15_8 13_8 11_8 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8)
|
||||
string(REGEX REPLACE "_" "/" scalearg ${scale})
|
||||
add_test(djpeg${suffix}-420m-islow-${scale}
|
||||
${dir}djpeg${suffix} -dct int -scale ${scalearg} -nosmooth -ppm
|
||||
-outfile testout_420m_islow_${scale}.ppm
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
|
||||
add_test(djpeg${suffix}-420m-islow-${scale}-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_PPM_420M_ISLOW_${scale}}
|
||||
-DFILE=testout_420m_islow_${scale}.ppm
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
endforeach()
|
||||
|
||||
# CC: YCC->RGB (dithered) SAMP: h2v2 fancy IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-420-islow-256
|
||||
${dir}djpeg${suffix} -dct int -colors 256 -bmp
|
||||
-outfile testout_420_islow_256.bmp
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
|
||||
add_test(djpeg${suffix}-420-islow-256-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_420_ISLOW_256}
|
||||
-DFILE=testout_420_islow_256.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB565 SAMP: h2v2 fancy IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-420-islow-565
|
||||
${dir}djpeg${suffix} -dct int -rgb565 -dither none -bmp
|
||||
-outfile testout_420_islow_565.bmp
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
|
||||
add_test(djpeg${suffix}-420-islow-565-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_420_ISLOW_565}
|
||||
-DFILE=testout_420_islow_565.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB565 (dithered) SAMP: h2v2 fancy IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-420-islow-565D
|
||||
${dir}djpeg${suffix} -dct int -rgb565 -bmp
|
||||
-outfile testout_420_islow_565D.bmp
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
|
||||
add_test(djpeg${suffix}-420-islow-565D-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_420_ISLOW_565D}
|
||||
-DFILE=testout_420_islow_565D.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB565 SAMP: h2v2 merged IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-420m-islow-565
|
||||
${dir}djpeg${suffix} -dct int -nosmooth -rgb565 -dither none -bmp
|
||||
-outfile testout_420m_islow_565.bmp
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
|
||||
add_test(djpeg${suffix}-420m-islow-565-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_420M_ISLOW_565}
|
||||
-DFILE=testout_420m_islow_565.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
# CC: YCC->RGB565 (dithered) SAMP: h2v2 merged IDCT: islow ENT: huff
|
||||
add_test(djpeg${suffix}-420m-islow-565D
|
||||
${dir}djpeg${suffix} -dct int -nosmooth -rgb565 -bmp
|
||||
-outfile testout_420m_islow_565D.bmp
|
||||
${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
|
||||
add_test(djpeg${suffix}-420m-islow-565D-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_BMP_420M_ISLOW_565D}
|
||||
-DFILE=testout_420m_islow_565D.bmp
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
|
||||
add_test(jpegtran${suffix}-crop
|
||||
${dir}jpegtran${suffix} -crop 120x90+20+50 -transpose -perfect
|
||||
-outfile testout_crop.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
|
||||
add_test(jpegtran${suffix}-crop-cmp
|
||||
${CMAKE_COMMAND} -DMD5=${MD5_JPEG_CROP} -DFILE=testout_crop.jpg
|
||||
-P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
|
||||
|
||||
endforeach()
|
||||
|
||||
add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
|
||||
${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake)
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -42,11 +42,43 @@ later. OS X 10.4 "Tiger" is no longer supported.
|
||||
[5] The Huffman encoder now uses clz and bsr instructions for bit counting on
|
||||
ARM platforms rather than a lookup table. This reduces the memory footprint
|
||||
by 64k, which may be important for some mobile applications. Out of four
|
||||
Android devices that were tested, two demonstrated a small loss (~3-4% on
|
||||
average) with ARMv6 code and a small gain (also ~3-4%) with ARMv7 code when
|
||||
enabling this new feature, but the other two devices demonstrated a
|
||||
significant performance gain across the board (~10-20%.) Actual mileage may
|
||||
vary.
|
||||
Android devices that were tested, two demonstrated a small overall performance
|
||||
loss (~3-4% on average) with ARMv6 code and a small gain (also ~3-4%) with
|
||||
ARMv7 code when enabling this new feature, but the other two devices
|
||||
demonstrated a significant overall performance gain with both ARMv6 and ARMv7
|
||||
code (~10-20%.) Actual mileage may vary.
|
||||
|
||||
[6] Worked around an issue with Visual C++ 2010 and later that caused incorrect
|
||||
pixels to be generated when decompressing a JPEG image to a 256-color bitmap,
|
||||
if compiler optimization was enabled when libjpeg-turbo was built. This caused
|
||||
the regression tests to fail when doing a release build under Visual C++ 2010
|
||||
and later.
|
||||
|
||||
[7] Improved the accuracy and performance of the non-SIMD implementation of the
|
||||
floating point inverse DCT (using code borrowed from libjpeg v8a and later.)
|
||||
The accuracy of this implementation now matches the accuracy of the SSE/SSE2
|
||||
implementation. Note, however, that the floating point DCT/IDCT algorithms are
|
||||
mainly a legacy feature. They generally do not produce significantly better
|
||||
accuracy than the slow integer DCT/IDCT algorithms, and they are quite a bit
|
||||
slower.
|
||||
|
||||
[8] Added a new output colorspace (JCS_RGB565) to the libjpeg API that allows
|
||||
for decompressing JPEG images into RGB565 (16-bit) pixels.
|
||||
|
||||
[9] Numerous obsolete features, such as support for compilers that can't
|
||||
handle prototypes and support for the MS-DOS memory model, were removed from
|
||||
the libjpeg code, greatly improving its readability and making it easier to
|
||||
maintain and extend.
|
||||
|
||||
[10] Fixed a segfault that occurred when calling output_message() with msg_code
|
||||
set to JMSG_COPYRIGHT.
|
||||
|
||||
[11] Fixed an issue whereby wrjpgcom was allowing comments longer than 65k
|
||||
characters to be passed on the command line, which was causing it to generate
|
||||
incorrect JPEG files.
|
||||
|
||||
[12] Fixed a bug in the build system that was causing the Windows version of
|
||||
wrjpgcom to be built using the rdjpgcom code.
|
||||
|
||||
[7] Improved the accuracy and performance of the non-SIMD implementation of the
|
||||
floating point inverse DCT (using code borrowed from libjpeg v8a and later.)
|
||||
|
||||
336
Makefile.am
336
Makefile.am
@@ -12,7 +12,8 @@ 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 jpegcomp.h
|
||||
jpegint.h jpeglib.h jversion.h jsimd.h jsimddct.h jpegcomp.h \
|
||||
jpeg_nbits_table.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 \
|
||||
@@ -162,7 +163,7 @@ dist_example_DATA = example.c
|
||||
|
||||
EXTRA_DIST = win release $(DOCS) testimages CMakeLists.txt \
|
||||
sharedlib/CMakeLists.txt cmakescripts libjpeg.map.in doc doxygen.config \
|
||||
jccolext.c jdcolext.c jdmrgext.c jstdhuff.c
|
||||
jccolext.c jdcolext.c jdcol565.c jdmrgext.c jstdhuff.c
|
||||
|
||||
dist-hook:
|
||||
rm -rf `find $(distdir) -name .svn`
|
||||
@@ -170,40 +171,57 @@ dist-hook:
|
||||
|
||||
SUBDIRS += md5
|
||||
|
||||
MD5_JPEG_INT = 9a68f56bc76e466aa7e52f415d0f4a5f
|
||||
MD5_JPEG_FAST = 0e1502e7fa421835e376a314fac2a39f
|
||||
MD5_JPEG_FAST_100 = 7bf72a8e741d64eecb960c97323af77c
|
||||
MD5_JPEG_FLOAT = d1623885ffafcd40c684af09e3d65cd5
|
||||
MD5_JPEG_FLOAT_NOSIMD = fb4884c35f8273f498cb32879de5c455
|
||||
MD5_JPEG_INT_GRAY = 72b51f894b8f4a10b3ee3066770aa38d
|
||||
MD5_PPM_INT = d1ed0d11f076b842525271647716aeb8
|
||||
MD5_PPM_FAST = 048298a2d2410261c0533cb97bcfef23
|
||||
MD5_PPM_FLOAT = 7f5b446ee36b2630e06785b8d42af15f
|
||||
MD5_PPM_FLOAT_NOSIMD = 64072f1dbdc5b3a187777788604971a5
|
||||
MD5_PPM_INT_2_1 = 9f9de8c0612f8d06869b960b05abf9c9
|
||||
MD5_PPM_INT_15_8 = b6875bc070720b899566cc06459b63b7
|
||||
MD5_PPM_INT_7_4 = 06a177eae05f164fac57f7a2c346ee87
|
||||
MD5_PPM_INT_13_8 = bc3452573c8152f6ae552939ee19f82f
|
||||
MD5_PPM_INT_3_2 = f5a8b88a8a7f96016f04d259cf82ed67
|
||||
MD5_PPM_INT_11_8 = d8cc73c0aaacd4556569b59437ba00a5
|
||||
MD5_PPM_INT_5_4 = 32775dd9ad2ab90f4c5b219b53e0c86c
|
||||
MD5_PPM_INT_9_8 = d25e61bc7eac0002f5b393aa223747b6
|
||||
MD5_PPM_INT_7_8 = ddb564b7c74a09494016d6cd7502a946
|
||||
MD5_PPM_INT_3_4 = 8ed8e68808c3fbc4ea764fc9d2968646
|
||||
MD5_PPM_INT_5_8 = a3363274999da2366a024efae6d16c9b
|
||||
MD5_PPM_INT_1_2 = e692a315cea26b988c8e8b29a5dbcd81
|
||||
MD5_PPM_INT_3_8 = 79eca9175652ced755155c90e785a996
|
||||
MD5_PPM_INT_1_4 = 79cd778f8bf1a117690052cacdd54eca
|
||||
MD5_PPM_INT_1_8 = 391b3d4aca640c8567d6f8745eb2142f
|
||||
MD5_PPM_FAST_1_2 = f30bcf6d32ccd44cbdd9aeaacbd9454f
|
||||
MD5_BMP_256 = 4980185e3776e89bd931736e1cddeee6
|
||||
MD5_JPEG_ARI = e986fb0a637a8d833d96e8a6d6d84ea1
|
||||
MD5_PPM_ARI = 72b59a99bcf1de24c5b27d151bde2437
|
||||
MD5_JPEG_PROG = 1c4afddc05c0a43489ee54438a482d92
|
||||
MD5_JPEG_PROG_ARI = 0a8f1c8f66e113c3cf635df0a475a617
|
||||
MD5_JPEG_RGB_ISLOW = 768e970dd57b340ff1b83c9d3d47c77b
|
||||
MD5_PPM_RGB_ISLOW = 00a257f5393fef8821f2b88ac7421291
|
||||
MD5_BMP_RGB_ISLOW_565 = f07d2e75073e4bb10f6c6f4d36e2e3be
|
||||
MD5_BMP_RGB_ISLOW_565D = 4cfa0928ef3e6bb626d7728c924cfda4
|
||||
MD5_JPEG_422_IFAST_OPT = 2540287b79d913f91665e660303ab2c8
|
||||
MD5_PPM_422_IFAST = 35bd6b3f833bad23de82acea847129fa
|
||||
MD5_PPM_422M_IFAST = 8dbc65323d62cca7c91ba02dd1cfa81d
|
||||
MD5_BMP_422M_IFAST_565 = 3294bd4d9a1f2b3d08ea6020d0db7065
|
||||
MD5_BMP_422M_IFAST_565D = da98c9c7b6039511be4a79a878a9abc1
|
||||
MD5_JPEG_420_IFAST_Q100_PROG = 990cbe0329c882420a2094da7e5adade
|
||||
MD5_PPM_420_Q100_IFAST = 5a732542015c278ff43635e473a8a294
|
||||
MD5_PPM_420M_Q100_IFAST = ff692ee9323a3b424894862557c092f1
|
||||
MD5_JPEG_GRAY_ISLOW = 72b51f894b8f4a10b3ee3066770aa38d
|
||||
MD5_PPM_GRAY_ISLOW = 8d3596c56eace32f205deccc229aa5ed
|
||||
MD5_PPM_GRAY_ISLOW_RGB = 116424ac07b79e5e801f00508eab48ec
|
||||
MD5_BMP_GRAY_ISLOW_565 = 12f78118e56a2f48b966f792fedf23cc
|
||||
MD5_BMP_GRAY_ISLOW_565D = bdbbd616441a24354c98553df5dc82db
|
||||
MD5_JPEG_420S_IFAST_OPT = 388708217ac46273ca33086b22827ed8
|
||||
# See README-turbo.txt for more details on why this next bit is necessary.
|
||||
if WITH_SSE_FLOAT_DCT
|
||||
MD5_JPEG_3x2_FLOAT_PROG = 343e3f8caf8af5986ebaf0bdc13b5c71
|
||||
MD5_PPM_3x2_FLOAT = 1a75f36e5904d6fc3a85a43da9ad89bb
|
||||
else
|
||||
MD5_JPEG_3x2_FLOAT_PROG = 9bca803d2042bd1eb03819e2bf92b3e5
|
||||
MD5_PPM_3x2_FLOAT = f6bfab038438ed8f5522fbd33595dcdc
|
||||
endif
|
||||
MD5_JPEG_420_ISLOW_ARI = e986fb0a637a8d833d96e8a6d6d84ea1
|
||||
MD5_JPEG_444_ISLOW_PROGARI = 0a8f1c8f66e113c3cf635df0a475a617
|
||||
MD5_PPM_420M_IFAST_ARI = 72b59a99bcf1de24c5b27d151bde2437
|
||||
MD5_JPEG_420_ISLOW = 9a68f56bc76e466aa7e52f415d0f4a5f
|
||||
MD5_PPM_420M_ISLOW_2_1 = 9f9de8c0612f8d06869b960b05abf9c9
|
||||
MD5_PPM_420M_ISLOW_15_8 = b6875bc070720b899566cc06459b63b7
|
||||
MD5_PPM_420M_ISLOW_13_8 = bc3452573c8152f6ae552939ee19f82f
|
||||
MD5_PPM_420M_ISLOW_11_8 = d8cc73c0aaacd4556569b59437ba00a5
|
||||
MD5_PPM_420M_ISLOW_9_8 = d25e61bc7eac0002f5b393aa223747b6
|
||||
MD5_PPM_420M_ISLOW_7_8 = ddb564b7c74a09494016d6cd7502a946
|
||||
MD5_PPM_420M_ISLOW_3_4 = 8ed8e68808c3fbc4ea764fc9d2968646
|
||||
MD5_PPM_420M_ISLOW_5_8 = a3363274999da2366a024efae6d16c9b
|
||||
MD5_PPM_420M_ISLOW_1_2 = e692a315cea26b988c8e8b29a5dbcd81
|
||||
MD5_PPM_420M_ISLOW_3_8 = 79eca9175652ced755155c90e785a996
|
||||
MD5_PPM_420M_ISLOW_1_4 = 79cd778f8bf1a117690052cacdd54eca
|
||||
MD5_PPM_420M_ISLOW_1_8 = 391b3d4aca640c8567d6f8745eb2142f
|
||||
MD5_BMP_420_ISLOW_256 = 4980185e3776e89bd931736e1cddeee6
|
||||
MD5_BMP_420_ISLOW_565 = bf9d13e16c4923b92e1faa604d7922cb
|
||||
MD5_BMP_420_ISLOW_565D = 6bde71526acc44bcff76f696df8638d2
|
||||
MD5_BMP_420M_ISLOW_565 = 8dc0185245353cfa32ad97027342216f
|
||||
MD5_BMP_420M_ISLOW_565D =d1be3a3339166255e76fa50a0d70d73e
|
||||
MD5_JPEG_CROP = b4197f377e621c4e9b1d20471432610d
|
||||
|
||||
test: testclean all
|
||||
|
||||
if WITH_TURBOJPEG
|
||||
if WITH_JAVA
|
||||
$(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest
|
||||
@@ -219,84 +237,188 @@ endif
|
||||
./tjunittest -yuv -alloc
|
||||
./tjunittest -yuv -noyuvpad
|
||||
endif
|
||||
./cjpeg -dct int -outfile testoutint.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_INT) testoutint.jpg
|
||||
./cjpeg -dct fast -opt -outfile testoutfst.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_FAST) testoutfst.jpg
|
||||
./cjpeg -dct fast -quality 100 -opt -outfile testoutfst100.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_FAST_100) testoutfst100.jpg
|
||||
./cjpeg -dct float -outfile testoutflt.jpg $(srcdir)/testimages/testorig.ppm
|
||||
if WITH_SSE_FLOAT_DCT
|
||||
md5/md5cmp $(MD5_JPEG_FLOAT) testoutflt.jpg
|
||||
else
|
||||
md5/md5cmp $(MD5_JPEG_FLOAT_NOSIMD) testoutflt.jpg
|
||||
endif
|
||||
./cjpeg -dct int -grayscale -outfile testoutgray.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_INT_GRAY) testoutgray.jpg
|
||||
./djpeg -dct int -fast -ppm -outfile testoutint.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_INT) testoutint.ppm
|
||||
./djpeg -dct fast -ppm -outfile testoutfst.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_FAST) testoutfst.ppm
|
||||
./djpeg -dct float -ppm -outfile testoutflt.ppm $(srcdir)/testimages/testorig.jpg
|
||||
if WITH_SSE_FLOAT_DCT
|
||||
md5/md5cmp $(MD5_PPM_FLOAT) testoutflt.ppm
|
||||
else
|
||||
md5/md5cmp $(MD5_PPM_FLOAT_NOSIMD) testoutflt.ppm
|
||||
endif
|
||||
./djpeg -dct int -nosmooth -scale 2/1 -ppm -outfile testoutint2_1.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_2_1) testoutint2_1.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 15/8 -ppm -outfile testoutint15_8.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_15_8) testoutint15_8.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 7/4 -ppm -outfile testoutint7_4.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_7_4) testoutint7_4.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 13/8 -ppm -outfile testoutint13_8.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_13_8) testoutint13_8.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 3/2 -ppm -outfile testoutint3_2.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_3_2) testoutint3_2.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 11/8 -ppm -outfile testoutint11_8.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_11_8) testoutint11_8.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 5/4 -ppm -outfile testoutint5_4.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_5_4) testoutint5_4.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 9/8 -ppm -outfile testoutint9_8.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_9_8) testoutint9_8.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 7/8 -ppm -outfile testoutint7_8.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_7_8) testoutint7_8.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 3/4 -ppm -outfile testoutint3_4.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_3_4) testoutint3_4.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 5/8 -ppm -outfile testoutint5_8.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_5_8) testoutint5_8.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 1/2 -ppm -outfile testoutint1_2.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_1_2) testoutint1_2.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 3/8 -ppm -outfile testoutint3_8.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_3_8) testoutint3_8.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 1/4 -ppm -outfile testoutint1_4.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_1_4) testoutint1_4.ppm;
|
||||
./djpeg -dct int -nosmooth -scale 1/8 -ppm -outfile testoutint1_8.ppm $(srcdir)/testimages/testorig.jpg;
|
||||
md5/md5cmp $(MD5_PPM_INT_1_8) testoutint1_8.ppm;
|
||||
./djpeg -dct fast -scale 1/2 -ppm -outfile testoutfst1_2.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_FAST_1_2) testoutfst1_2.ppm
|
||||
./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_BMP_256) testout.bmp
|
||||
|
||||
# These tests are carefully crafted to provide full coverage of as many of the
|
||||
# underlying algorithms as possible (including all of the SIMD-accelerated
|
||||
# ones.)
|
||||
|
||||
# CC: null SAMP: fullsize FDCT: islow ENT: huff
|
||||
./cjpeg -rgb -dct int -outfile testout_rgb_islow.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_RGB_ISLOW) testout_rgb_islow.jpg
|
||||
# CC: null SAMP: fullsize IDCT: islow ENT: huff
|
||||
./djpeg -dct int -ppm -outfile testout_rgb_islow.ppm testout_rgb_islow.jpg
|
||||
md5/md5cmp $(MD5_PPM_RGB_ISLOW) testout_rgb_islow.ppm
|
||||
rm testout_rgb_islow.ppm
|
||||
# CC: RGB->RGB565 SAMP: fullsize IDCT: islow ENT: huff
|
||||
./djpeg -dct int -rgb565 -dither none -bmp -outfile testout_rgb_islow_565.bmp testout_rgb_islow.jpg
|
||||
md5/md5cmp $(MD5_BMP_RGB_ISLOW_565) testout_rgb_islow_565.bmp
|
||||
rm testout_rgb_islow_565.bmp
|
||||
# CC: RGB->RGB565 (dithered) SAMP: fullsize IDCT: islow ENT: huff
|
||||
./djpeg -dct int -rgb565 -bmp -outfile testout_rgb_islow_565D.bmp testout_rgb_islow.jpg
|
||||
md5/md5cmp $(MD5_BMP_RGB_ISLOW_565D) testout_rgb_islow_565D.bmp
|
||||
rm testout_rgb_islow_565D.bmp testout_rgb_islow.jpg
|
||||
|
||||
# CC: RGB->YCC SAMP: fullsize/h2v1 FDCT: ifast ENT: 2-pass huff
|
||||
./cjpeg -sample 2x1 -dct fast -opt -outfile testout_422_ifast_opt.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_422_IFAST_OPT) testout_422_ifast_opt.jpg
|
||||
# CC: YCC->RGB SAMP: fullsize/h2v1 fancy IDCT: ifast ENT: huff
|
||||
./djpeg -dct fast -outfile testout_422_ifast.ppm testout_422_ifast_opt.jpg
|
||||
md5/md5cmp $(MD5_PPM_422_IFAST) testout_422_ifast.ppm
|
||||
rm testout_422_ifast.ppm
|
||||
# CC: YCC->RGB SAMP: h2v1 merged IDCT: ifast ENT: huff
|
||||
./djpeg -dct fast -nosmooth -outfile testout_422m_ifast.ppm testout_422_ifast_opt.jpg
|
||||
md5/md5cmp $(MD5_PPM_422M_IFAST) testout_422m_ifast.ppm
|
||||
rm testout_422m_ifast.ppm
|
||||
# CC: YCC->RGB565 SAMP: h2v1 merged IDCT: ifast ENT: huff
|
||||
./djpeg -dct int -nosmooth -rgb565 -dither none -bmp -outfile testout_422m_ifast_565.bmp testout_422_ifast_opt.jpg
|
||||
md5/md5cmp $(MD5_BMP_422M_IFAST_565) testout_422m_ifast_565.bmp
|
||||
rm testout_422m_ifast_565.bmp
|
||||
# CC: YCC->RGB565 (dithered) SAMP: h2v1 merged IDCT: ifast ENT: huff
|
||||
./djpeg -dct int -nosmooth -rgb565 -bmp -outfile testout_422m_ifast_565D.bmp testout_422_ifast_opt.jpg
|
||||
md5/md5cmp $(MD5_BMP_422M_IFAST_565D) testout_422m_ifast_565D.bmp
|
||||
rm testout_422m_ifast_565D.bmp testout_422_ifast_opt.jpg
|
||||
|
||||
# CC: RGB->YCC SAMP: fullsize/h2v2 FDCT: ifast ENT: prog huff
|
||||
./cjpeg -sample 2x2 -quality 100 -dct fast -prog -outfile testout_420_q100_ifast_prog.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_420_IFAST_Q100_PROG) testout_420_q100_ifast_prog.jpg
|
||||
# CC: YCC->RGB SAMP: fullsize/h2v2 fancy IDCT: ifast ENT: prog huff
|
||||
./djpeg -dct fast -outfile testout_420_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
|
||||
md5/md5cmp $(MD5_PPM_420_Q100_IFAST) testout_420_q100_ifast.ppm
|
||||
rm testout_420_q100_ifast.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: ifast ENT: prog huff
|
||||
./djpeg -dct fast -nosmooth -outfile testout_420m_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_Q100_IFAST) testout_420m_q100_ifast.ppm
|
||||
rm testout_420m_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
|
||||
|
||||
# CC: RGB->Gray SAMP: fullsize FDCT: islow ENT: huff
|
||||
./cjpeg -gray -dct int -outfile testout_gray_islow.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_GRAY_ISLOW) testout_gray_islow.jpg
|
||||
# CC: Gray->Gray SAMP: fullsize IDCT: islow ENT: huff
|
||||
./djpeg -dct int -outfile testout_gray_islow.ppm testout_gray_islow.jpg
|
||||
md5/md5cmp $(MD5_PPM_GRAY_ISLOW) testout_gray_islow.ppm
|
||||
rm testout_gray_islow.ppm
|
||||
# CC: Gray->RGB SAMP: fullsize IDCT: islow ENT: huff
|
||||
./djpeg -dct int -rgb -outfile testout_gray_islow_rgb.ppm testout_gray_islow.jpg
|
||||
md5/md5cmp $(MD5_PPM_GRAY_ISLOW_RGB) testout_gray_islow_rgb.ppm
|
||||
rm testout_gray_islow_rgb.ppm
|
||||
# CC: Gray->RGB565 SAMP: fullsize IDCT: islow ENT: huff
|
||||
./djpeg -dct int -rgb565 -dither none -bmp -outfile testout_gray_islow_565.bmp testout_gray_islow.jpg
|
||||
md5/md5cmp $(MD5_BMP_GRAY_ISLOW_565) testout_gray_islow_565.bmp
|
||||
rm testout_gray_islow_565.bmp
|
||||
# CC: Gray->RGB565 (dithered) SAMP: fullsize IDCT: islow ENT: huff
|
||||
./djpeg -dct int -rgb565 -bmp -outfile testout_gray_islow_565D.bmp testout_gray_islow.jpg
|
||||
md5/md5cmp $(MD5_BMP_GRAY_ISLOW_565D) testout_gray_islow_565D.bmp
|
||||
rm testout_gray_islow_565D.bmp testout_gray_islow.jpg
|
||||
|
||||
# CC: RGB->YCC SAMP: fullsize smooth/h2v2 smooth FDCT: islow
|
||||
# ENT: 2-pass huff
|
||||
./cjpeg -sample 2x2 -smooth 1 -dct int -opt -outfile testout_420s_ifast_opt.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_420S_IFAST_OPT) testout_420s_ifast_opt.jpg
|
||||
rm testout_420s_ifast_opt.jpg
|
||||
|
||||
# CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff
|
||||
./cjpeg -sample 3x2 -dct float -prog -outfile testout_3x2_float_prog.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG) testout_3x2_float_prog.jpg
|
||||
# CC: YCC->RGB SAMP: fullsize/int IDCT: float ENT: prog huff
|
||||
./djpeg -dct float -outfile testout_3x2_float.ppm testout_3x2_float_prog.jpg
|
||||
md5/md5cmp $(MD5_PPM_3x2_FLOAT) testout_3x2_float.ppm
|
||||
rm testout_3x2_float.ppm testout_3x2_float_prog.jpg
|
||||
|
||||
if WITH_ARITH_ENC
|
||||
./cjpeg -dct int -arithmetic -outfile testoutari.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_ARI) testoutari.jpg
|
||||
./jpegtran -arithmetic -outfile testouta.jpg $(srcdir)/testimages/testimgint.jpg
|
||||
md5/md5cmp $(MD5_JPEG_ARI) testouta.jpg
|
||||
./cjpeg -dct int -progressive -arithmetic -sample 1x1 -outfile testoutpa.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_PROG_ARI) testoutpa.jpg
|
||||
# CC: YCC->RGB SAMP: fullsize/h2v2 FDCT: islow ENT: arith
|
||||
./cjpeg -dct int -arithmetic -outfile testout_420_islow_ari.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_420_ISLOW_ARI) testout_420_islow_ari.jpg
|
||||
rm testout_420_islow_ari.jpg
|
||||
./jpegtran -arithmetic -outfile testout_420_islow_ari.jpg $(srcdir)/testimages/testimgint.jpg
|
||||
md5/md5cmp $(MD5_JPEG_420_ISLOW_ARI) testout_420_islow_ari.jpg
|
||||
rm testout_420_islow_ari.jpg
|
||||
# CC: YCC->RGB SAMP: fullsize FDCT: islow ENT: prog arith
|
||||
./cjpeg -sample 1x1 -dct int -progressive -arithmetic -outfile testout_444_islow_progari.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_444_ISLOW_PROGARI) testout_444_islow_progari.jpg
|
||||
rm testout_444_islow_progari.jpg
|
||||
endif
|
||||
if WITH_ARITH_DEC
|
||||
./djpeg -dct int -fast -ppm -outfile testoutari.ppm $(srcdir)/testimages/testimgari.jpg
|
||||
md5/md5cmp $(MD5_PPM_ARI) testoutari.ppm
|
||||
./jpegtran -outfile testouta.jpg $(srcdir)/testimages/testimgari.jpg
|
||||
md5/md5cmp $(MD5_JPEG_INT) testouta.jpg
|
||||
# CC: RGB->YCC SAMP: h2v2 merged IDCT: ifast ENT: arith
|
||||
./djpeg -fast -ppm -outfile testout_420m_ifast_ari.ppm $(srcdir)/testimages/testimgari.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_IFAST_ARI) testout_420m_ifast_ari.ppm
|
||||
rm testout_420m_ifast_ari.ppm
|
||||
./jpegtran -outfile testout_420_islow.jpg $(srcdir)/testimages/testimgari.jpg
|
||||
md5/md5cmp $(MD5_JPEG_420_ISLOW) testout_420_islow.jpg
|
||||
rm testout_420_islow.jpg
|
||||
endif
|
||||
./cjpeg -dct int -progressive -outfile testoutp.jpg $(srcdir)/testimages/testorig.ppm
|
||||
md5/md5cmp $(MD5_JPEG_PROG) testoutp.jpg
|
||||
./jpegtran -outfile testoutt.jpg testoutp.jpg
|
||||
md5/md5cmp $(MD5_JPEG_INT) testoutt.jpg
|
||||
./jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_JPEG_CROP) testoutcrop.jpg
|
||||
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 16x16 islow ENT: huff
|
||||
./djpeg -dct int -scale 2/1 -nosmooth -ppm -outfile testout_420m_islow_2_1.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_2_1) testout_420m_islow_2_1.ppm
|
||||
rm testout_420m_islow_2_1.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 15x15 islow ENT: huff
|
||||
./djpeg -dct int -scale 15/8 -nosmooth -ppm -outfile testout_420m_islow_15_8.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_15_8) testout_420m_islow_15_8.ppm
|
||||
rm testout_420m_islow_15_8.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 13x13 islow ENT: huff
|
||||
./djpeg -dct int -scale 13/8 -nosmooth -ppm -outfile testout_420m_islow_13_8.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_13_8) testout_420m_islow_13_8.ppm
|
||||
rm testout_420m_islow_13_8.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 11x11 islow ENT: huff
|
||||
./djpeg -dct int -scale 11/8 -nosmooth -ppm -outfile testout_420m_islow_11_8.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_11_8) testout_420m_islow_11_8.ppm
|
||||
rm testout_420m_islow_11_8.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 9x9 islow ENT: huff
|
||||
./djpeg -dct int -scale 9/8 -nosmooth -ppm -outfile testout_420m_islow_9_8.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_9_8) testout_420m_islow_9_8.ppm
|
||||
rm testout_420m_islow_9_8.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 7x7 islow/14x14 islow ENT: huff
|
||||
./djpeg -dct int -scale 7/8 -nosmooth -ppm -outfile testout_420m_islow_7_8.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_7_8) testout_420m_islow_7_8.ppm
|
||||
rm testout_420m_islow_7_8.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 6x6 islow/12x12 islow ENT: huff
|
||||
./djpeg -dct int -scale 3/4 -nosmooth -ppm -outfile testout_420m_islow_3_4.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_3_4) testout_420m_islow_3_4.ppm
|
||||
rm testout_420m_islow_3_4.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 5x5 islow/10x10 islow ENT: huff
|
||||
./djpeg -dct int -scale 5/8 -nosmooth -ppm -outfile testout_420m_islow_5_8.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_5_8) testout_420m_islow_5_8.ppm
|
||||
rm testout_420m_islow_5_8.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 4x4 islow/8x8 islow ENT: huff
|
||||
./djpeg -dct int -scale 1/2 -nosmooth -ppm -outfile testout_420m_islow_1_2.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_1_2) testout_420m_islow_1_2.ppm
|
||||
rm testout_420m_islow_1_2.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 3x3 islow/6x6 islow ENT: huff
|
||||
./djpeg -dct int -scale 3/8 -nosmooth -ppm -outfile testout_420m_islow_3_8.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_3_8) testout_420m_islow_3_8.ppm
|
||||
rm testout_420m_islow_3_8.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 2x2 islow/4x4 islow ENT: huff
|
||||
./djpeg -dct int -scale 1/4 -nosmooth -ppm -outfile testout_420m_islow_1_4.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_1_4) testout_420m_islow_1_4.ppm
|
||||
rm testout_420m_islow_1_4.ppm
|
||||
# CC: YCC->RGB SAMP: h2v2 merged IDCT: 1x1 islow/2x2 islow ENT: huff
|
||||
./djpeg -dct int -scale 1/8 -nosmooth -ppm -outfile testout_420m_islow_1_8.ppm $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_PPM_420M_ISLOW_1_8) testout_420m_islow_1_8.ppm
|
||||
rm testout_420m_islow_1_8.ppm
|
||||
# CC: YCC->RGB (dithered) SAMP: h2v2 fancy IDCT: islow ENT: huff
|
||||
./djpeg -dct int -colors 256 -bmp -outfile testout_420_islow_256.bmp $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_BMP_420_ISLOW_256) testout_420_islow_256.bmp
|
||||
rm testout_420_islow_256.bmp
|
||||
# CC: YCC->RGB565 SAMP: h2v2 fancy IDCT: islow ENT: huff
|
||||
./djpeg -dct int -rgb565 -dither none -bmp -outfile testout_420_islow_565.bmp $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_BMP_420_ISLOW_565) testout_420_islow_565.bmp
|
||||
rm testout_420_islow_565.bmp
|
||||
# CC: YCC->RGB565 (dithered) SAMP: h2v2 fancy IDCT: islow ENT: huff
|
||||
./djpeg -dct int -rgb565 -bmp -outfile testout_420_islow_565D.bmp $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_BMP_420_ISLOW_565D) testout_420_islow_565D.bmp
|
||||
rm testout_420_islow_565D.bmp
|
||||
# CC: YCC->RGB565 SAMP: h2v2 merged IDCT: islow ENT: huff
|
||||
./djpeg -dct int -nosmooth -rgb565 -dither none -bmp -outfile testout_420m_islow_565.bmp $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_BMP_420M_ISLOW_565) testout_420m_islow_565.bmp
|
||||
rm testout_420m_islow_565.bmp
|
||||
# CC: YCC->RGB565 (dithered) SAMP: h2v2 merged IDCT: islow ENT: huff
|
||||
./djpeg -dct int -nosmooth -rgb565 -bmp -outfile testout_420m_islow_565D.bmp $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_BMP_420M_ISLOW_565D) testout_420m_islow_565D.bmp
|
||||
rm testout_420m_islow_565D.bmp
|
||||
|
||||
./jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testout_crop.jpg $(srcdir)/testimages/testorig.jpg
|
||||
md5/md5cmp $(MD5_JPEG_CROP) testout_crop.jpg
|
||||
rm testout_crop.jpg
|
||||
|
||||
|
||||
testclean:
|
||||
|
||||
2
README
2
README
@@ -62,7 +62,7 @@ OVERVIEW
|
||||
|
||||
This package contains C software to implement JPEG image encoding, decoding,
|
||||
and transcoding. JPEG (pronounced "jay-peg") is a standardized compression
|
||||
method for full-color and gray-scale images. JPEG's strong suit is compressing
|
||||
method for full-color and grayscale images. JPEG's strong suit is compressing
|
||||
photographic images or other types of images that have smooth color and
|
||||
brightness transitions between neighboring pixels. Images with sharp lines or
|
||||
other abrupt features may not compress well with JPEG, and a higher JPEG
|
||||
|
||||
@@ -184,7 +184,7 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE],[
|
||||
# AC_CHECK_COMPATIBLE_MIPSEL_ASSEMBLER_IFELSE
|
||||
# --------------------------
|
||||
# Test whether the assembler is suitable and supports MIPS instructions
|
||||
AC_DEFUN([AC_CHECK_COMPATIBLE_MIPSEL_ASSEMBLER_IFELSE],[
|
||||
AC_DEFUN([AC_CHECK_COMPATIBLE_MIPS_ASSEMBLER_IFELSE],[
|
||||
have_mips_dspr2=no
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CCASFLAGS -mdspr2"
|
||||
|
||||
44
cdjpeg.c
44
cdjpeg.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* cdjpeg.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains common support routines used by the IJG application
|
||||
@@ -11,9 +13,6 @@
|
||||
|
||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||
#include <ctype.h> /* to declare isupper(), tolower() */
|
||||
#ifdef NEED_SIGNAL_CATCHER
|
||||
#include <signal.h> /* to declare signal() */
|
||||
#endif
|
||||
#ifdef USE_SETMODE
|
||||
#include <fcntl.h> /* to declare setmode()'s parameter macros */
|
||||
/* If you have setmode() but not <io.h>, just delete this line: */
|
||||
@@ -21,43 +20,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Signal catcher to ensure that temporary files are removed before aborting.
|
||||
* NB: for Amiga Manx C this is actually a global routine named _abort();
|
||||
* we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus...
|
||||
*/
|
||||
|
||||
#ifdef NEED_SIGNAL_CATCHER
|
||||
|
||||
static j_common_ptr sig_cinfo;
|
||||
|
||||
void /* must be global for Manx C */
|
||||
signal_catcher (int signum)
|
||||
{
|
||||
if (sig_cinfo != NULL) {
|
||||
if (sig_cinfo->err != NULL) /* turn off trace output */
|
||||
sig_cinfo->err->trace_level = 0;
|
||||
jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
enable_signal_catcher (j_common_ptr cinfo)
|
||||
{
|
||||
sig_cinfo = cinfo;
|
||||
#ifdef SIGINT /* not all systems have SIGINT */
|
||||
signal(SIGINT, signal_catcher);
|
||||
#endif
|
||||
#ifdef SIGTERM /* not all systems have SIGTERM */
|
||||
signal(SIGTERM, signal_catcher);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Optional progress monitor: display a percent-done figure on stderr.
|
||||
*/
|
||||
|
||||
118
cdjpeg.h
118
cdjpeg.h
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* cdjpeg.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
@@ -27,12 +29,9 @@
|
||||
typedef struct cjpeg_source_struct * cjpeg_source_ptr;
|
||||
|
||||
struct cjpeg_source_struct {
|
||||
JMETHOD(void, start_input, (j_compress_ptr cinfo,
|
||||
cjpeg_source_ptr sinfo));
|
||||
JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo,
|
||||
cjpeg_source_ptr sinfo));
|
||||
JMETHOD(void, finish_input, (j_compress_ptr cinfo,
|
||||
cjpeg_source_ptr sinfo));
|
||||
void (*start_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
|
||||
JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
|
||||
void (*finish_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
|
||||
|
||||
FILE *input_file;
|
||||
|
||||
@@ -58,15 +57,12 @@ struct djpeg_dest_struct {
|
||||
/* start_output is called after jpeg_start_decompress finishes.
|
||||
* The color map will be ready at this time, if one is needed.
|
||||
*/
|
||||
JMETHOD(void, start_output, (j_decompress_ptr cinfo,
|
||||
djpeg_dest_ptr dinfo));
|
||||
void (*start_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
|
||||
/* Emit the specified number of pixel rows from the buffer. */
|
||||
JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo,
|
||||
djpeg_dest_ptr dinfo,
|
||||
JDIMENSION rows_supplied));
|
||||
void (*put_pixel_rows) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
||||
JDIMENSION rows_supplied);
|
||||
/* Finish up at the end of the image. */
|
||||
JMETHOD(void, finish_output, (j_decompress_ptr cinfo,
|
||||
djpeg_dest_ptr dinfo));
|
||||
void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
|
||||
|
||||
/* Target file spec; filled in by djpeg.c after object is created. */
|
||||
FILE * output_file;
|
||||
@@ -99,71 +95,44 @@ struct cdjpeg_progress_mgr {
|
||||
typedef struct cdjpeg_progress_mgr * cd_progress_ptr;
|
||||
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||
|
||||
#ifdef NEED_SHORT_EXTERNAL_NAMES
|
||||
#define jinit_read_bmp jIRdBMP
|
||||
#define jinit_write_bmp jIWrBMP
|
||||
#define jinit_read_jpeg jIRdJPG
|
||||
#define jinit_read_gif jIRdGIF
|
||||
#define jinit_write_gif jIWrGIF
|
||||
#define jinit_read_ppm jIRdPPM
|
||||
#define jinit_write_ppm jIWrPPM
|
||||
#define jinit_read_rle jIRdRLE
|
||||
#define jinit_write_rle jIWrRLE
|
||||
#define jinit_read_targa jIRdTarga
|
||||
#define jinit_write_targa jIWrTarga
|
||||
#define read_quant_tables RdQTables
|
||||
#define read_scan_script RdScnScript
|
||||
#define set_quality_ratings SetQRates
|
||||
#define set_quant_slots SetQSlots
|
||||
#define set_sample_factors SetSFacts
|
||||
#define read_color_map RdCMap
|
||||
#define enable_signal_catcher EnSigCatcher
|
||||
#define start_progress_monitor StProgMon
|
||||
#define end_progress_monitor EnProgMon
|
||||
#define read_stdin RdStdin
|
||||
#define write_stdout WrStdout
|
||||
#endif /* NEED_SHORT_EXTERNAL_NAMES */
|
||||
|
||||
/* Module selection routines for I/O modules. */
|
||||
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo));
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo,
|
||||
boolean is_os2));
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo));
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_jpeg JPP((j_compress_ptr cinfo));
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo));
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo));
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo));
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_bmp (j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_bmp (j_decompress_ptr cinfo,
|
||||
boolean is_os2);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_gif (j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_gif (j_decompress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_jpeg (j_compress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_ppm (j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_ppm (j_decompress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_rle (j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_rle (j_decompress_ptr cinfo);
|
||||
EXTERN(cjpeg_source_ptr) jinit_read_targa (j_compress_ptr cinfo);
|
||||
EXTERN(djpeg_dest_ptr) jinit_write_targa (j_decompress_ptr cinfo);
|
||||
|
||||
/* cjpeg support routines (in rdswitch.c) */
|
||||
|
||||
EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename,
|
||||
boolean force_baseline));
|
||||
EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename));
|
||||
EXTERN(boolean) set_quality_ratings JPP((j_compress_ptr cinfo, char *arg,
|
||||
boolean force_baseline));
|
||||
EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg));
|
||||
EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg));
|
||||
EXTERN(boolean) read_quant_tables (j_compress_ptr cinfo, char * filename,
|
||||
boolean force_baseline);
|
||||
EXTERN(boolean) read_scan_script (j_compress_ptr cinfo, char * filename);
|
||||
EXTERN(boolean) set_quality_ratings (j_compress_ptr cinfo, char *arg,
|
||||
boolean force_baseline);
|
||||
EXTERN(boolean) set_quant_slots (j_compress_ptr cinfo, char *arg);
|
||||
EXTERN(boolean) set_sample_factors (j_compress_ptr cinfo, char *arg);
|
||||
|
||||
/* djpeg support routines (in rdcolmap.c) */
|
||||
|
||||
EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile));
|
||||
EXTERN(void) read_color_map (j_decompress_ptr cinfo, FILE * infile);
|
||||
|
||||
/* common support routines (in cdjpeg.c) */
|
||||
|
||||
EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo));
|
||||
EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo,
|
||||
cd_progress_ptr progress));
|
||||
EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo));
|
||||
EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars));
|
||||
EXTERN(FILE *) read_stdin JPP((void));
|
||||
EXTERN(FILE *) write_stdout JPP((void));
|
||||
EXTERN(void) enable_signal_catcher (j_common_ptr cinfo);
|
||||
EXTERN(void) start_progress_monitor (j_common_ptr cinfo,
|
||||
cd_progress_ptr progress);
|
||||
EXTERN(void) end_progress_monitor (j_common_ptr cinfo);
|
||||
EXTERN(boolean) keymatch (char * arg, const char * keyword, int minchars);
|
||||
EXTERN(FILE *) read_stdin (void);
|
||||
EXTERN(FILE *) write_stdout (void);
|
||||
|
||||
/* miscellaneous useful macros */
|
||||
|
||||
@@ -171,29 +140,16 @@ EXTERN(FILE *) write_stdout JPP((void));
|
||||
#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
|
||||
#ifndef EXIT_WARNING
|
||||
#ifdef VMS
|
||||
#define EXIT_WARNING 1 /* VMS is very nonstandard */
|
||||
#else
|
||||
#define EXIT_WARNING 2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
8
cjpeg.1
8
cjpeg.1
@@ -16,7 +16,7 @@ cjpeg \- compress an image file to a JPEG file
|
||||
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
|
||||
format), PGM (PBMPLUS grayscale 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,
|
||||
@@ -176,11 +176,13 @@ With quality=97, for instance, the fast method incurs generally about a 1-3 dB
|
||||
loss (in PSNR) relative to the int method, but this can be larger for some
|
||||
images. Do not use the fast method with quality levels above 97. The
|
||||
algorithm often degenerates at quality=98 and above and can actually produce a
|
||||
more lossy image than if lower quality levels had been used.
|
||||
more lossy image than if lower quality levels had been used. Also, in
|
||||
libjpeg-turbo, the fast method is not fully accelerated for quality levels
|
||||
above 97, so it will be slower than the int method.
|
||||
.TP
|
||||
.B \-dct float
|
||||
Use floating-point DCT method.
|
||||
The float method is mostly a legacy feature. It does not produce significantly
|
||||
The float method is mainly a legacy feature. It does not produce significantly
|
||||
more accurate results than the int method, and it is much slower. The float
|
||||
method may also give different results on different machines due to varying
|
||||
roundoff behavior, whereas the integer methods should give the same results on
|
||||
|
||||
7
cjpeg.c
7
cjpeg.c
@@ -30,7 +30,7 @@
|
||||
|
||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||
#include "jversion.h" /* for version message */
|
||||
#include "config.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */
|
||||
#ifdef __MWERKS__
|
||||
@@ -598,11 +598,6 @@ main (int argc, char **argv)
|
||||
jerr.first_addon_message = JMSG_FIRSTADDONCODE;
|
||||
jerr.last_addon_message = JMSG_LASTADDONCODE;
|
||||
|
||||
/* Now safe to enable signal catcher. */
|
||||
#ifdef NEED_SIGNAL_CATCHER
|
||||
enable_signal_catcher((j_common_ptr) &cinfo);
|
||||
#endif
|
||||
|
||||
/* Initialize JPEG parameters.
|
||||
* Much of this may be overridden later.
|
||||
* In particular, we don't yet know the input file's color space,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
IJG JPEG LIBRARY: CODING RULES
|
||||
|
||||
This file was part of the Independent JPEG Group's software:
|
||||
Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
This file is part of the Independent JPEG Group's software.
|
||||
It was modified by The libjpeg-turbo Project to include only information
|
||||
relevant to libjpeg-turbo.
|
||||
For conditions of distribution and use, see the accompanying README file.
|
||||
|
||||
|
||||
@@ -32,22 +34,7 @@ handled automatically by GNU Emacs and many other text editors.)
|
||||
Multi-word names should be written in lower case with underscores, e.g.,
|
||||
multi_word_name (not multiWordName). Preprocessor symbols and enum constants
|
||||
are similar but upper case (MULTI_WORD_NAME). Names should be unique within
|
||||
the first fifteen characters. (On some older systems, global names must be
|
||||
unique within six characters. We accommodate this without cluttering the
|
||||
source code by using macros to substitute shorter names.)
|
||||
|
||||
We use function prototypes everywhere; we rely on automatic source code
|
||||
transformation to feed prototype-less C compilers. Transformation is done
|
||||
by the simple and portable tool 'ansi2knr.c' (courtesy of Ghostscript).
|
||||
ansi2knr is not very bright, so it imposes a format requirement on function
|
||||
declarations: the function name MUST BEGIN IN COLUMN 1. Thus all functions
|
||||
should be written in the following style:
|
||||
|
||||
LOCAL(int *)
|
||||
function_name (int a, char *b)
|
||||
{
|
||||
code...
|
||||
}
|
||||
the first fifteen characters.
|
||||
|
||||
Note that each function definition must begin with GLOBAL(type), LOCAL(type),
|
||||
or METHODDEF(type). These macros expand to "static type" or just "type" as
|
||||
@@ -55,32 +42,8 @@ appropriate. They provide a readable indication of the routine's usage and
|
||||
can readily be changed for special needs. (For instance, special linkage
|
||||
keywords can be inserted for use in Windows DLLs.)
|
||||
|
||||
ansi2knr does not transform method declarations (function pointers in
|
||||
structs). We handle these with a macro JMETHOD, defined as
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
|
||||
#else
|
||||
#define JMETHOD(type,methodname,arglist) type (*methodname) ()
|
||||
#endif
|
||||
which is used like this:
|
||||
struct function_pointers {
|
||||
JMETHOD(void, init_entropy_encoder, (int somearg, jparms *jp));
|
||||
JMETHOD(void, term_entropy_encoder, (void));
|
||||
};
|
||||
Note the set of parentheses surrounding the parameter list.
|
||||
|
||||
A similar solution is used for forward and external function declarations
|
||||
(see the EXTERN and JPP macros).
|
||||
|
||||
If the code is to work on non-ANSI compilers, we cannot rely on a prototype
|
||||
declaration to coerce actual parameters into the right types. Therefore, use
|
||||
explicit casts on actual parameters whenever the actual parameter type is not
|
||||
identical to the formal parameter. Beware of implicit conversions to "int".
|
||||
|
||||
It seems there are some non-ANSI compilers in which the sizeof() operator
|
||||
is defined to return int, yet size_t is defined as long. Needless to say,
|
||||
this is brain-damaged. Always use the SIZEOF() macro in place of sizeof(),
|
||||
so that the result is guaranteed to be of type size_t.
|
||||
A similar solution is used for external function declarations (see the EXTERN
|
||||
macro.)
|
||||
|
||||
|
||||
The JPEG library is intended to be used within larger programs. Furthermore,
|
||||
@@ -94,9 +57,7 @@ pass these through the common routines provided.
|
||||
wherever possible. (Note that our method-based calling conventions help this
|
||||
a lot: in many modules only the initialization function will ever need to be
|
||||
called directly, so only that function need be externally visible.) All
|
||||
global function names should begin with "jpeg_", and should have an
|
||||
abbreviated name (unique in the first six characters) substituted by macro
|
||||
when NEED_SHORT_EXTERNAL_NAMES is set.
|
||||
global function names should begin with "jpeg_".
|
||||
|
||||
3. Don't use global variables; anything that must be used in another module
|
||||
should be in the common data structures.
|
||||
@@ -107,10 +68,9 @@ the system architecture document, structure.txt).
|
||||
|
||||
5. Source file names should begin with "j" for files that are part of the
|
||||
library proper; source files that are not part of the library, such as cjpeg.c
|
||||
and djpeg.c, do not begin with "j". Keep source file names to eight
|
||||
characters (plus ".c" or ".h", etc) to make life easy for MS-DOSers. Keep
|
||||
compression and decompression code in separate source files --- some
|
||||
applications may want only one half of the library.
|
||||
and djpeg.c, do not begin with "j". Keep compression and decompression code in
|
||||
separate source files --- some applications may want only one half of the
|
||||
library.
|
||||
|
||||
Note: these rules (particularly #4) are not followed religiously in the
|
||||
modules that are used in cjpeg/djpeg but are not part of the JPEG library
|
||||
|
||||
46
configure.ac
46
configure.ac
@@ -9,9 +9,6 @@ AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
|
||||
AC_PREFIX_DEFAULT(/opt/libmozjpeg)
|
||||
|
||||
# Always build with prototypes
|
||||
AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
|
||||
|
||||
# Checks for programs.
|
||||
SAVED_CFLAGS=${CFLAGS}
|
||||
SAVED_CPPFLAGS=${CPPFLAGS}
|
||||
@@ -98,9 +95,9 @@ AC_CHECK_LIB([m],[pow])
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
|
||||
AC_CHECK_HEADERS([stddef.h stdlib.h locale.h string.h])
|
||||
AC_CHECK_HEADER([sys/types.h],
|
||||
AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you have sys/types.h]))
|
||||
AC_DEFINE([NEED_SYS_TYPES_H], 1, [Define if you need to include <sys/types.h> to get size_t.]))
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
@@ -132,24 +129,15 @@ AC_TRY_RUN(
|
||||
exit(is_shifting_signed(-0x7F7E80B1L));
|
||||
}],
|
||||
[AC_MSG_RESULT(no)
|
||||
AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1, [Define if shift is unsigned])],
|
||||
AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], 1,
|
||||
[Define if your (broken) compiler shifts signed values as if they were 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])])
|
||||
[Define if you have BSD-like bzero and bcopy in <strings.h> rather than memset/memcpy in <string.h>.])])
|
||||
|
||||
AC_MSG_CHECKING([libjpeg API version])
|
||||
AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
|
||||
@@ -266,7 +254,7 @@ AC_SUBST(VERSION_SCRIPT_FLAG)
|
||||
# Check for non-broken inline under various spellings
|
||||
AC_MSG_CHECKING(for inline)
|
||||
ljt_cv_inline=""
|
||||
AC_TRY_COMPILE(, [} __attribute__((always_inline)) int foo() { return 0; }
|
||||
AC_TRY_COMPILE(, [} inline __attribute__((always_inline)) int foo() { return 0; }
|
||||
int bar() { return foo();], ljt_cv_inline="inline __attribute__((always_inline))",
|
||||
AC_TRY_COMPILE(, [} __inline__ int foo() { return 0; }
|
||||
int bar() { return foo();], ljt_cv_inline="__inline__",
|
||||
@@ -454,12 +442,12 @@ if test "x${with_simd}" != "xno"; then
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
mipsel*)
|
||||
AC_MSG_RESULT([yes (mipsel)])
|
||||
mips*)
|
||||
AC_MSG_RESULT([yes (mips)])
|
||||
AC_MSG_CHECKING([if the assembler is GNU-compatible and can be used])
|
||||
AC_CHECK_COMPATIBLE_MIPSEL_ASSEMBLER_IFELSE(
|
||||
AC_CHECK_COMPATIBLE_MIPS_ASSEMBLER_IFELSE(
|
||||
[AC_MSG_RESULT([yes])
|
||||
simd_arch=mipsel],
|
||||
simd_arch=mips],
|
||||
[AC_MSG_RESULT([no])
|
||||
with_simd=no])
|
||||
if test "x${with_simd}" = "xno"; then
|
||||
@@ -494,7 +482,7 @@ AM_CONDITIONAL([SIMD_I386], [test "x$simd_arch" = "xi386"])
|
||||
AM_CONDITIONAL([SIMD_X86_64], [test "x$simd_arch" = "xx86_64"])
|
||||
AM_CONDITIONAL([SIMD_ARM], [test "x$simd_arch" = "xarm"])
|
||||
AM_CONDITIONAL([SIMD_ARM_64], [test "x$simd_arch" = "xaarch64"])
|
||||
AM_CONDITIONAL([SIMD_MIPSEL], [test "x$simd_arch" = "xmipsel"])
|
||||
AM_CONDITIONAL([SIMD_MIPS], [test "x$simd_arch" = "xmips"])
|
||||
AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
|
||||
AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"])
|
||||
|
||||
@@ -519,14 +507,16 @@ AC_SUBST(RPMARCH)
|
||||
AC_SUBST(RPM_CONFIG_ARGS)
|
||||
AC_SUBST(DEBARCH)
|
||||
AC_SUBST(BUILD)
|
||||
AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
|
||||
AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [libjpeg-turbo build number])
|
||||
|
||||
# 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
|
||||
# NOTE: autoheader automatically modifies the input file of the first
|
||||
# invocation of AC_CONFIG_HEADERS, so we put config.h first to prevent
|
||||
# jconfig.h.in from being clobbered. config.h is used only internally, whereas
|
||||
# jconfig.h contains macros that are relevant to external programs (macros that
|
||||
# specify which features were built into the library.)
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_HEADERS([jconfig.h])
|
||||
AC_CONFIG_HEADERS([jconfigint.h])
|
||||
AC_CONFIG_FILES([pkgscripts/libmozjpeg.spec.tmpl:release/libmozjpeg.spec.in])
|
||||
AC_CONFIG_FILES([pkgscripts/makecygwinpkg.tmpl:release/makecygwinpkg.in])
|
||||
AC_CONFIG_FILES([pkgscripts/makedpkg.tmpl:release/makedpkg.in])
|
||||
|
||||
19
djpeg.1
19
djpeg.1
@@ -55,11 +55,14 @@ 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
|
||||
Force grayscale output even if JPEG file is color. Useful for viewing on
|
||||
monochrome displays; also,
|
||||
.B djpeg
|
||||
runs noticeably faster in this mode.
|
||||
.TP
|
||||
.B \-rgb
|
||||
Force RGB output even if JPEG file is grayscale.
|
||||
.TP
|
||||
.BI \-scale " M/N"
|
||||
Scale the output image by a factor M/N. Currently the scale factor must be
|
||||
M/8, where M is an integer between 1 and 16 inclusive, or any reduced fraction
|
||||
@@ -74,7 +77,7 @@ emitted if
|
||||
.B \-colors
|
||||
or
|
||||
.B \-grayscale
|
||||
is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color
|
||||
is specified, or if the JPEG file is grayscale; otherwise, 24-bit full-color
|
||||
format is emitted.
|
||||
.TP
|
||||
.B \-gif
|
||||
@@ -88,12 +91,12 @@ emitted if
|
||||
.B \-colors
|
||||
or
|
||||
.B \-grayscale
|
||||
is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color
|
||||
is specified, or if the JPEG file is grayscale; 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
|
||||
PGM is emitted if the JPEG file is grayscale or if
|
||||
.B \-grayscale
|
||||
is specified; otherwise PPM is emitted.
|
||||
.TP
|
||||
@@ -101,8 +104,8 @@ is specified; otherwise PPM is emitted.
|
||||
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
|
||||
Select Targa output format. Grayscale format is emitted if the JPEG file is
|
||||
grayscale or if
|
||||
.B \-grayscale
|
||||
is specified; otherwise, colormapped format is emitted if
|
||||
.B \-colors
|
||||
@@ -132,7 +135,7 @@ compressed using lower quality levels.
|
||||
.TP
|
||||
.B \-dct float
|
||||
Use floating-point DCT method.
|
||||
The float method is mostly a legacy feature. It does not produce significantly
|
||||
The float method is mainly a legacy feature. It does not produce significantly
|
||||
more accurate results than the int method, and it is much slower. The float
|
||||
method may also give different results on different machines due to varying
|
||||
roundoff behavior, whereas the integer methods should give the same results on
|
||||
@@ -174,7 +177,7 @@ faster and needs less memory, but it produces a lower-quality image.
|
||||
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
|
||||
Also, the one-pass method is always used for grayscale output (the two-pass
|
||||
method is no improvement then).
|
||||
.TP
|
||||
.BI \-maxmemory " N"
|
||||
|
||||
14
djpeg.c
14
djpeg.c
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010-2011, 2013, D. R. Commander.
|
||||
* Copyright (C) 2010-2011, 2013-2014, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains a command-line user interface for the JPEG decompressor.
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||
#include "jversion.h" /* for version message */
|
||||
#include "config.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
#include <ctype.h> /* to declare isprint() */
|
||||
|
||||
@@ -107,6 +107,7 @@ usage (void)
|
||||
fprintf(stderr, " -fast Fast, low-quality processing\n");
|
||||
fprintf(stderr, " -grayscale Force grayscale output\n");
|
||||
fprintf(stderr, " -rgb Force RGB output\n");
|
||||
fprintf(stderr, " -rgb565 Force RGB565 output\n");
|
||||
#ifdef IDCT_SCALING_SUPPORTED
|
||||
fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n");
|
||||
#endif
|
||||
@@ -281,6 +282,10 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
||||
/* Force RGB output. */
|
||||
cinfo->out_color_space = JCS_RGB;
|
||||
|
||||
} else if (keymatch(arg, "rgb565", 2)) {
|
||||
/* Force RGB565 output. */
|
||||
cinfo->out_color_space = JCS_RGB565;
|
||||
|
||||
} else if (keymatch(arg, "map", 3)) {
|
||||
/* Quantize to a color map taken from an input file. */
|
||||
if (++argn >= argc) /* advance to next argument */
|
||||
@@ -490,11 +495,6 @@ main (int argc, char **argv)
|
||||
jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker);
|
||||
jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker);
|
||||
|
||||
/* Now safe to enable signal catcher. */
|
||||
#ifdef NEED_SIGNAL_CATCHER
|
||||
enable_signal_catcher((j_common_ptr) &cinfo);
|
||||
#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 ignored; we will rescan the switches after opening
|
||||
|
||||
12
jcapimin.c
12
jcapimin.c
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
* jcapimin.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||
* Modified 2003-2010 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains application interface code for the compression half
|
||||
@@ -36,9 +38,9 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
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_compress_struct))
|
||||
if (structsize != sizeof(struct jpeg_compress_struct))
|
||||
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
|
||||
(int) SIZEOF(struct jpeg_compress_struct), (int) structsize);
|
||||
(int) sizeof(struct jpeg_compress_struct), (int) structsize);
|
||||
|
||||
/* For debugging purposes, we zero the whole master structure.
|
||||
* But the application has already set the err pointer, and may have set
|
||||
@@ -49,7 +51,7 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
{
|
||||
struct jpeg_error_mgr * err = cinfo->err;
|
||||
void * client_data = cinfo->client_data; /* ignore Purify complaint here */
|
||||
MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct));
|
||||
MEMZERO(cinfo, sizeof(struct jpeg_compress_struct));
|
||||
cinfo->err = err;
|
||||
cinfo->client_data = client_data;
|
||||
}
|
||||
@@ -204,7 +206,7 @@ GLOBAL(void)
|
||||
jpeg_write_marker (j_compress_ptr cinfo, int marker,
|
||||
const JOCTET *dataptr, unsigned int datalen)
|
||||
{
|
||||
JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val));
|
||||
void (*write_marker_byte) (j_compress_ptr info, int val);
|
||||
|
||||
if (cinfo->next_scanline != 0 ||
|
||||
(cinfo->global_state != CSTATE_SCANNING &&
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jcarith.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Developed 1997-2009 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains portable arithmetic entropy encoding routines for JPEG
|
||||
@@ -909,7 +911,7 @@ jinit_arith_encoder (j_compress_ptr cinfo)
|
||||
|
||||
entropy = (arith_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(arith_entropy_encoder));
|
||||
sizeof(arith_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
entropy->pub.start_pass = start_pass;
|
||||
entropy->pub.finish_pass = finish_pass;
|
||||
|
||||
43
jccoefct.c
43
jccoefct.c
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* jccoefct.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
* 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 coefficient buffer controller for compression.
|
||||
@@ -44,11 +46,8 @@ typedef struct {
|
||||
/* For single-pass compression, it's sufficient to buffer just one MCU
|
||||
* (although this may prove a bit slow in practice). We allocate a
|
||||
* workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each
|
||||
* MCU constructed and sent. (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.
|
||||
* MCU constructed and sent. In multi-pass modes, this array points to the
|
||||
* current MCU's blocks within the virtual arrays.
|
||||
*/
|
||||
JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU];
|
||||
|
||||
@@ -65,15 +64,15 @@ typedef my_coef_controller * my_coef_ptr;
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) compress_data
|
||||
JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf));
|
||||
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
#ifdef FULL_COEF_BUFFER_SUPPORTED
|
||||
METHODDEF(boolean) compress_first_pass
|
||||
JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf));
|
||||
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
METHODDEF(boolean) compress_output
|
||||
JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf));
|
||||
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
#endif
|
||||
METHODDEF(boolean) compress_trellis_pass
|
||||
JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf));
|
||||
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
@@ -194,16 +193,16 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
ypos, xpos, (JDIMENSION) blockcnt, NULL);
|
||||
if (blockcnt < compptr->MCU_width) {
|
||||
/* Create some dummy blocks at the right edge of the image. */
|
||||
jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt],
|
||||
(compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK));
|
||||
jzero_far((void *) coef->MCU_buffer[blkn + blockcnt],
|
||||
(compptr->MCU_width - blockcnt) * sizeof(JBLOCK));
|
||||
for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
|
||||
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Create a row of dummy blocks at the bottom of the image. */
|
||||
jzero_far((void FAR *) coef->MCU_buffer[blkn],
|
||||
compptr->MCU_width * SIZEOF(JBLOCK));
|
||||
jzero_far((void *) coef->MCU_buffer[blkn],
|
||||
compptr->MCU_width * sizeof(JBLOCK));
|
||||
for (bi = 0; bi < compptr->MCU_width; bi++) {
|
||||
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0];
|
||||
}
|
||||
@@ -307,7 +306,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
if (ndummy > 0) {
|
||||
/* Create dummy blocks at the right edge of the image. */
|
||||
thisblockrow += blocks_across; /* => first dummy block */
|
||||
jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK));
|
||||
jzero_far((void *) thisblockrow, ndummy * sizeof(JBLOCK));
|
||||
lastDC = thisblockrow[-1][0];
|
||||
for (bi = 0; bi < ndummy; bi++) {
|
||||
thisblockrow[bi][0] = lastDC;
|
||||
@@ -326,8 +325,8 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
block_row++) {
|
||||
thisblockrow = buffer[block_row];
|
||||
lastblockrow = buffer[block_row-1];
|
||||
jzero_far((void FAR *) thisblockrow,
|
||||
(size_t) (blocks_across * SIZEOF(JBLOCK)));
|
||||
jzero_far((void *) thisblockrow,
|
||||
(size_t) (blocks_across * sizeof(JBLOCK)));
|
||||
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
|
||||
lastDC = lastblockrow[h_samp_factor-1][0];
|
||||
for (bi = 0; bi < h_samp_factor; bi++) {
|
||||
@@ -402,7 +401,7 @@ compress_trellis_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
if (ndummy > 0) {
|
||||
/* Create dummy blocks at the right edge of the image. */
|
||||
thisblockrow += blocks_across; /* => first dummy block */
|
||||
jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK));
|
||||
jzero_far((void *) thisblockrow, ndummy * sizeof(JBLOCK));
|
||||
lastDC = thisblockrow[-1][0];
|
||||
for (bi = 0; bi < ndummy; bi++) {
|
||||
thisblockrow[bi][0] = lastDC;
|
||||
@@ -421,8 +420,8 @@ compress_trellis_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
block_row++) {
|
||||
thisblockrow = buffer[block_row];
|
||||
lastblockrow = buffer[block_row-1];
|
||||
jzero_far((void FAR *) thisblockrow,
|
||||
(size_t) (blocks_across * SIZEOF(JBLOCK)));
|
||||
jzero_far((void *) thisblockrow,
|
||||
(size_t) (blocks_across * sizeof(JBLOCK)));
|
||||
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
|
||||
lastDC = lastblockrow[h_samp_factor-1][0];
|
||||
for (bi = 0; bi < h_samp_factor; bi++) {
|
||||
@@ -525,7 +524,7 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
|
||||
coef = (my_coef_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_coef_controller));
|
||||
sizeof(my_coef_controller));
|
||||
cinfo->coef = (struct jpeg_c_coef_controller *) coef;
|
||||
coef->pub.start_pass = start_pass_coef;
|
||||
|
||||
@@ -565,7 +564,7 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
|
||||
buffer = (JBLOCKROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
||||
C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->MCU_buffer[i] = buffer + i;
|
||||
}
|
||||
|
||||
48
jccolor.c
48
jccolor.c
@@ -6,6 +6,7 @@
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2009-2012, D. R. Commander.
|
||||
* Copyright (C) 2014, MIPS Technologies, Inc., California
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains input colorspace conversion routines.
|
||||
@@ -15,7 +16,7 @@
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jsimd.h"
|
||||
#include "config.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
@@ -202,7 +203,7 @@ rgb_ycc_start (j_compress_ptr cinfo)
|
||||
/* Allocate and fill in the conversion tables. */
|
||||
cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(TABLE_SIZE * SIZEOF(INT32)));
|
||||
(TABLE_SIZE * sizeof(INT32)));
|
||||
|
||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i;
|
||||
@@ -507,7 +508,7 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
|
||||
cconvert = (my_cconvert_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_color_converter));
|
||||
sizeof(my_color_converter));
|
||||
cinfo->cconvert = (struct jpeg_color_converter *) cconvert;
|
||||
/* set start_pass to null method until we find out differently */
|
||||
cconvert->pub.start_pass = null_method;
|
||||
@@ -587,9 +588,14 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
if (rgb_red[cinfo->in_color_space] == 0 &&
|
||||
rgb_green[cinfo->in_color_space] == 1 &&
|
||||
rgb_blue[cinfo->in_color_space] == 2 &&
|
||||
rgb_pixelsize[cinfo->in_color_space] == 3)
|
||||
rgb_pixelsize[cinfo->in_color_space] == 3) {
|
||||
#if defined(__mips__)
|
||||
if (jsimd_c_can_null_convert())
|
||||
cconvert->pub.color_convert = jsimd_c_null_convert;
|
||||
else
|
||||
#endif
|
||||
cconvert->pub.color_convert = null_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 ||
|
||||
@@ -625,18 +631,28 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
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 if (cinfo->in_color_space == JCS_YCbCr) {
|
||||
#if defined(__mips__)
|
||||
if (jsimd_c_can_null_convert())
|
||||
cconvert->pub.color_convert = jsimd_c_null_convert;
|
||||
else
|
||||
#endif
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
} else
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
break;
|
||||
|
||||
case JCS_CMYK:
|
||||
if (cinfo->num_components != 4)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
if (cinfo->in_color_space == JCS_CMYK)
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
if (cinfo->in_color_space == JCS_CMYK) {
|
||||
#if defined(__mips__)
|
||||
if (jsimd_c_can_null_convert())
|
||||
cconvert->pub.color_convert = jsimd_c_null_convert;
|
||||
else
|
||||
#endif
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
} else
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
break;
|
||||
|
||||
@@ -646,9 +662,14 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
if (cinfo->in_color_space == JCS_CMYK) {
|
||||
cconvert->pub.start_pass = rgb_ycc_start;
|
||||
cconvert->pub.color_convert = cmyk_ycck_convert;
|
||||
} else if (cinfo->in_color_space == JCS_YCCK)
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
} else if (cinfo->in_color_space == JCS_YCCK) {
|
||||
#if defined(__mips__)
|
||||
if (jsimd_c_can_null_convert())
|
||||
cconvert->pub.color_convert = jsimd_c_null_convert;
|
||||
else
|
||||
#endif
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
} else
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
break;
|
||||
|
||||
@@ -656,6 +677,11 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
if (cinfo->jpeg_color_space != cinfo->in_color_space ||
|
||||
cinfo->num_components != cinfo->input_components)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
#if defined(__mips__)
|
||||
if (jsimd_c_can_null_convert())
|
||||
cconvert->pub.color_convert = jsimd_c_null_convert;
|
||||
else
|
||||
#endif
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
break;
|
||||
}
|
||||
|
||||
47
jcdctmgr.c
47
jcdctmgr.c
@@ -27,22 +27,21 @@
|
||||
|
||||
/* 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 void (*forward_DCT_method_ptr) (DCTELEM * data);
|
||||
typedef 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 void (*convsamp_method_ptr) (JSAMPARRAY sample_data,
|
||||
JDIMENSION start_col,
|
||||
DCTELEM * workspace);
|
||||
typedef 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 void (*quantize_method_ptr) (JCOEFPTR coef_block, DCTELEM * divisors,
|
||||
DCTELEM * workspace);
|
||||
typedef void (*float_quantize_method_ptr) (JCOEFPTR coef_block,
|
||||
FAST_FLOAT * divisors,
|
||||
FAST_FLOAT * workspace);
|
||||
|
||||
METHODDEF(void) quantize (JCOEFPTR, DCTELEM *, DCTELEM *);
|
||||
|
||||
@@ -238,7 +237,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
if (fdct->divisors[qtblno] == NULL) {
|
||||
fdct->divisors[qtblno] = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(DCTSIZE2 * 4) * SIZEOF(DCTELEM));
|
||||
(DCTSIZE2 * 4) * sizeof(DCTELEM));
|
||||
}
|
||||
dtbl = fdct->divisors[qtblno];
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
@@ -274,7 +273,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
if (fdct->divisors[qtblno] == NULL) {
|
||||
fdct->divisors[qtblno] = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(DCTSIZE2 * 4) * SIZEOF(DCTELEM));
|
||||
(DCTSIZE2 * 4) * sizeof(DCTELEM));
|
||||
}
|
||||
dtbl = fdct->divisors[qtblno];
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
@@ -309,7 +308,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
if (fdct->float_divisors[qtblno] == NULL) {
|
||||
fdct->float_divisors[qtblno] = (FAST_FLOAT *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
DCTSIZE2 * SIZEOF(FAST_FLOAT));
|
||||
DCTSIZE2 * sizeof(FAST_FLOAT));
|
||||
}
|
||||
fdtbl = fdct->float_divisors[qtblno];
|
||||
i = 0;
|
||||
@@ -649,10 +648,10 @@ quantize_trellis(j_compress_ptr cinfo, c_derived_tbl *actbl, JBLOCKROW coef_bloc
|
||||
if (Se < Ss)
|
||||
return;
|
||||
if (cinfo->trellis_eob_opt) {
|
||||
accumulated_zero_block_cost = (float *)malloc((num_blocks + 1) * SIZEOF(float));
|
||||
accumulated_block_cost = (float *)malloc((num_blocks + 1) * SIZEOF(float));
|
||||
block_run_start = (int *)malloc(num_blocks * SIZEOF(int));
|
||||
requires_eob = (int *)malloc((num_blocks + 1) * SIZEOF(int));
|
||||
accumulated_zero_block_cost = (float *)malloc((num_blocks + 1) * sizeof(float));
|
||||
accumulated_block_cost = (float *)malloc((num_blocks + 1) * sizeof(float));
|
||||
block_run_start = (int *)malloc(num_blocks * sizeof(int));
|
||||
requires_eob = (int *)malloc((num_blocks + 1) * sizeof(int));
|
||||
accumulated_zero_block_cost[0] = 0;
|
||||
accumulated_block_cost[0] = 0;
|
||||
requires_eob[0] = 0;
|
||||
@@ -879,7 +878,7 @@ jinit_forward_dct (j_compress_ptr cinfo)
|
||||
|
||||
fdct = (my_fdct_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_fdct_controller));
|
||||
sizeof(my_fdct_controller));
|
||||
cinfo->fdct = (struct jpeg_forward_dct *) fdct;
|
||||
fdct->pub.start_pass = start_pass_fdctmgr;
|
||||
|
||||
@@ -958,12 +957,12 @@ jinit_forward_dct (j_compress_ptr cinfo)
|
||||
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);
|
||||
sizeof(FAST_FLOAT) * DCTSIZE2);
|
||||
else
|
||||
#endif
|
||||
fdct->workspace = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(DCTELEM) * DCTSIZE2);
|
||||
sizeof(DCTELEM) * DCTSIZE2);
|
||||
|
||||
/* Mark divisor tables unallocated */
|
||||
for (i = 0; i < NUM_QUANT_TBLS; i++) {
|
||||
|
||||
37
jchuff.c
37
jchuff.c
@@ -47,9 +47,9 @@
|
||||
#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
|
||||
#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
|
||||
#else
|
||||
#include "jpeg_nbits_table.h"
|
||||
#define JPEG_NBITS(x) (jpeg_nbits_table[x])
|
||||
#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
|
||||
#include "jpeg_nbits_table.h"
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
@@ -123,13 +123,12 @@ typedef struct {
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) encode_mcu_huff JPP((j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
METHODDEF(void) finish_pass_huff JPP((j_compress_ptr cinfo));
|
||||
METHODDEF(boolean) encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_huff (j_compress_ptr cinfo);
|
||||
#ifdef ENTROPY_OPT_SUPPORTED
|
||||
METHODDEF(boolean) encode_mcu_gather JPP((j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
METHODDEF(void) finish_pass_gather JPP((j_compress_ptr cinfo));
|
||||
METHODDEF(boolean) encode_mcu_gather (j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_gather (j_compress_ptr cinfo);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -175,13 +174,13 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
if (entropy->dc_count_ptrs[dctbl] == NULL)
|
||||
entropy->dc_count_ptrs[dctbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
257 * SIZEOF(long));
|
||||
MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long));
|
||||
257 * sizeof(long));
|
||||
MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * sizeof(long));
|
||||
if (entropy->ac_count_ptrs[actbl] == NULL)
|
||||
entropy->ac_count_ptrs[actbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
257 * SIZEOF(long));
|
||||
MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long));
|
||||
257 * sizeof(long));
|
||||
MEMZERO(entropy->ac_count_ptrs[actbl], 257 * sizeof(long));
|
||||
#endif
|
||||
} else {
|
||||
/* Compute derived values for Huffman tables */
|
||||
@@ -239,7 +238,7 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
if (*pdtbl == NULL)
|
||||
*pdtbl = (c_derived_tbl *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(c_derived_tbl));
|
||||
sizeof(c_derived_tbl));
|
||||
dtbl = *pdtbl;
|
||||
|
||||
/* Figure C.1: make table of Huffman code length for each symbol */
|
||||
@@ -282,7 +281,7 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
* this lets us detect duplicate VAL entries here, and later
|
||||
* allows emit_bits to detect any attempt to emit such symbols.
|
||||
*/
|
||||
MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi));
|
||||
MEMZERO(dtbl->ehufsi, sizeof(dtbl->ehufsi));
|
||||
|
||||
/* This is also a convenient place to check for out-of-range
|
||||
* and duplicated VAL entries. We allow 0..255 for AC symbols
|
||||
@@ -848,8 +847,8 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
|
||||
/* This algorithm is explained in section K.2 of the JPEG standard */
|
||||
|
||||
MEMZERO(bits, SIZEOF(bits));
|
||||
MEMZERO(codesize, SIZEOF(codesize));
|
||||
MEMZERO(bits, sizeof(bits));
|
||||
MEMZERO(codesize, sizeof(codesize));
|
||||
for (i = 0; i < 257; i++)
|
||||
others[i] = -1; /* init links to empty */
|
||||
|
||||
@@ -951,7 +950,7 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
bits[i]--;
|
||||
|
||||
/* Return final symbol counts (only for lengths 0..16) */
|
||||
MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));
|
||||
MEMCOPY(htbl->bits, bits, sizeof(htbl->bits));
|
||||
|
||||
/* Return a list of the symbols sorted by code length */
|
||||
/* It's not real clear to me why we don't need to consider the codelength
|
||||
@@ -989,8 +988,8 @@ finish_pass_gather (j_compress_ptr cinfo)
|
||||
/* It's important not to apply jpeg_gen_optimal_table more than once
|
||||
* per table, because it clobbers the input frequency counts!
|
||||
*/
|
||||
MEMZERO(did_dc, SIZEOF(did_dc));
|
||||
MEMZERO(did_ac, SIZEOF(did_ac));
|
||||
MEMZERO(did_dc, sizeof(did_dc));
|
||||
MEMZERO(did_ac, sizeof(did_ac));
|
||||
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
@@ -1029,7 +1028,7 @@ jinit_huff_encoder (j_compress_ptr cinfo)
|
||||
|
||||
entropy = (huff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(huff_entropy_encoder));
|
||||
sizeof(huff_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
entropy->pub.start_pass = start_pass_huff;
|
||||
|
||||
|
||||
21
jchuff.h
21
jchuff.h
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* jchuff.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
* 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 Huffman entropy encoding routines
|
||||
@@ -32,22 +34,15 @@ typedef struct {
|
||||
/* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */
|
||||
} c_derived_tbl;
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||
|
||||
#ifdef NEED_SHORT_EXTERNAL_NAMES
|
||||
#define jpeg_make_c_derived_tbl jMkCDerived
|
||||
#define jpeg_gen_optimal_table jGenOptTbl
|
||||
#endif /* NEED_SHORT_EXTERNAL_NAMES */
|
||||
|
||||
/* Expand a Huffman table definition into the derived format */
|
||||
EXTERN(void) jpeg_make_c_derived_tbl
|
||||
JPP((j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
c_derived_tbl ** pdtbl));
|
||||
(j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
c_derived_tbl ** pdtbl);
|
||||
|
||||
/* Generate an optimal table definition given the specified counts */
|
||||
EXTERN(void) jpeg_gen_optimal_table
|
||||
JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]));
|
||||
(j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]);
|
||||
|
||||
EXTERN(void) quantize_trellis
|
||||
JPP((j_compress_ptr cinfo, c_derived_tbl *actbl, JBLOCKROW coef_blocks, JBLOCKROW src, JDIMENSION num_blocks,
|
||||
JQUANT_TBL * qtbl, double *norm_src, double *norm_coef));
|
||||
(j_compress_ptr cinfo, c_derived_tbl *actbl, JBLOCKROW coef_blocks, JBLOCKROW src, JDIMENSION num_blocks,
|
||||
JQUANT_TBL * qtbl, double *norm_src, double *norm_coef);
|
||||
|
||||
14
jcmainct.c
14
jcmainct.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jcmainct.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains the main buffer controller for compression.
|
||||
@@ -52,12 +54,12 @@ typedef my_main_controller * my_main_ptr;
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(void) process_data_simple_main
|
||||
JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail));
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail);
|
||||
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
||||
METHODDEF(void) process_data_buffer_main
|
||||
JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail));
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -250,7 +252,7 @@ jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
|
||||
main_ptr = (my_main_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_main_controller));
|
||||
sizeof(my_main_controller));
|
||||
cinfo->main = (struct jpeg_c_main_controller *) main_ptr;
|
||||
main_ptr->pub.start_pass = start_pass_main;
|
||||
|
||||
|
||||
@@ -649,7 +649,7 @@ jinit_marker_writer (j_compress_ptr cinfo)
|
||||
/* Create the subobject */
|
||||
marker = (my_marker_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_marker_writer));
|
||||
sizeof(my_marker_writer));
|
||||
cinfo->marker = (struct jpeg_marker_writer *) marker;
|
||||
/* Initialize method pointers */
|
||||
marker->pub.write_file_header = write_file_header;
|
||||
|
||||
@@ -891,7 +891,7 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
||||
|
||||
master = (my_master_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_comp_master));
|
||||
sizeof(my_comp_master));
|
||||
cinfo->master = (struct jpeg_comp_master *) master;
|
||||
master->pub.prepare_for_pass = prepare_for_pass;
|
||||
master->pub.pass_startup = pass_startup;
|
||||
@@ -942,7 +942,7 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
||||
|
||||
for (i = 0; i < cinfo->num_scans; i++)
|
||||
master->scan_buffer[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (cinfo->trellis_quant)
|
||||
master->pass_number_scan_opt_base = ((cinfo->use_scans_in_trellis) ? 4 : 2) * cinfo->num_components * cinfo->trellis_num_loops;
|
||||
|
||||
10
jcomapi.c
10
jcomapi.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jcomapi.c
|
||||
*
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.0
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains application interface routines that are used for both
|
||||
@@ -88,7 +90,7 @@ jpeg_alloc_quant_table (j_common_ptr cinfo)
|
||||
JQUANT_TBL *tbl;
|
||||
|
||||
tbl = (JQUANT_TBL *)
|
||||
(*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL));
|
||||
(*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, sizeof(JQUANT_TBL));
|
||||
tbl->sent_table = FALSE; /* make sure this is false in any new table */
|
||||
return tbl;
|
||||
}
|
||||
@@ -100,7 +102,7 @@ jpeg_alloc_huff_table (j_common_ptr cinfo)
|
||||
JHUFF_TBL *tbl;
|
||||
|
||||
tbl = (JHUFF_TBL *)
|
||||
(*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL));
|
||||
(*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, sizeof(JHUFF_TBL));
|
||||
tbl->sent_table = FALSE; /* make sure this is false in any new table */
|
||||
return tbl;
|
||||
}
|
||||
|
||||
27
jconfig.h.in
27
jconfig.h.in
@@ -12,11 +12,8 @@
|
||||
/* Support arithmetic decoding */
|
||||
#undef D_ARITH_CODING_SUPPORTED
|
||||
|
||||
/* Support in-memory source/destination managers */
|
||||
#undef MEM_SRCDST_SUPPORTED
|
||||
|
||||
/* Compiler supports function prototypes. */
|
||||
#undef HAVE_PROTOTYPES
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#undef HAVE_STDDEF_H
|
||||
@@ -24,25 +21,27 @@
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Compiler supports 'unsigned char'. */
|
||||
/* Define to 1 if the system has the type `unsigned char'. */
|
||||
#undef HAVE_UNSIGNED_CHAR
|
||||
|
||||
/* Compiler supports 'unsigned short'. */
|
||||
/* Define to 1 if the system has the type `unsigned short'. */
|
||||
#undef HAVE_UNSIGNED_SHORT
|
||||
|
||||
/* Compiler does not support pointers to unspecified structures. */
|
||||
/* Compiler does not support pointers to undefined structures. */
|
||||
#undef INCOMPLETE_TYPES_BROKEN
|
||||
|
||||
/* Compiler has <strings.h> rather than standard <string.h>. */
|
||||
/* Support in-memory source/destination managers */
|
||||
#undef MEM_SRCDST_SUPPORTED
|
||||
|
||||
/* Define if you have BSD-like bzero and bcopy in <strings.h> rather than
|
||||
memset/memcpy in <string.h>. */
|
||||
#undef NEED_BSD_STRINGS
|
||||
|
||||
/* Linker requires that global names be unique in first 15 characters. */
|
||||
#undef NEED_SHORT_EXTERNAL_NAMES
|
||||
|
||||
/* Need to include <sys/types.h> in order to obtain size_t. */
|
||||
/* Define if you need to include <sys/types.h> to get size_t. */
|
||||
#undef NEED_SYS_TYPES_H
|
||||
|
||||
/* Broken compiler shifts signed values as an unsigned shift. */
|
||||
/* Define if your (broken) compiler shifts signed values as if they were
|
||||
unsigned. */
|
||||
#undef RIGHT_SHIFT_IS_UNSIGNED
|
||||
|
||||
/* Use accelerated SIMD routines. */
|
||||
|
||||
30
jconfig.txt
30
jconfig.txt
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jconfig.txt
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1994, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file documents the configuration options that are required to
|
||||
@@ -23,11 +25,6 @@
|
||||
* #define the symbol if yes, #undef it if no.
|
||||
*/
|
||||
|
||||
/* Does your compiler support function prototypes?
|
||||
* (If not, you also need to use ansi2knr, see install.txt)
|
||||
*/
|
||||
#define HAVE_PROTOTYPES
|
||||
|
||||
/* Does your compiler support the declaration "unsigned char" ?
|
||||
* How about "unsigned short" ?
|
||||
*/
|
||||
@@ -48,7 +45,7 @@
|
||||
* If you're not sure, leaving it undefined will work at some cost in speed.
|
||||
* If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal.
|
||||
*/
|
||||
#undef CHAR_IS_UNSIGNED
|
||||
#undef __CHAR_UNSIGNED__
|
||||
|
||||
/* Define this if your system has an ANSI-conforming <stddef.h> file.
|
||||
*/
|
||||
@@ -69,19 +66,6 @@
|
||||
*/
|
||||
#undef NEED_SYS_TYPES_H
|
||||
|
||||
/* For 80x86 machines, you need to define NEED_FAR_POINTERS,
|
||||
* unless you are using a large-data memory model or 80386 flat-memory mode.
|
||||
* On less brain-damaged CPUs this symbol must not be defined.
|
||||
* (Defining this symbol causes large data structures to be referenced through
|
||||
* "far" pointers and to be allocated with a special version of malloc.)
|
||||
*/
|
||||
#undef NEED_FAR_POINTERS
|
||||
|
||||
/* Define this if your linker needs global names to be unique in less
|
||||
* than the first 15 characters.
|
||||
*/
|
||||
#undef NEED_SHORT_EXTERNAL_NAMES
|
||||
|
||||
/* Although a real ANSI C compiler can deal perfectly well with pointers to
|
||||
* unspecified structures (see "incomplete types" in the spec), a few pre-ANSI
|
||||
* and pseudo-ANSI compilers get confused. To keep one of these bozos happy,
|
||||
@@ -143,12 +127,6 @@ typedef unsigned char boolean;
|
||||
*/
|
||||
#undef TWO_FILE_COMMANDLINE
|
||||
|
||||
/* Define this if your system needs explicit cleanup of temporary files.
|
||||
* This is crucial under MS-DOS, where the temporary "files" may be areas
|
||||
* of extended memory; on most other systems it's not as important.
|
||||
*/
|
||||
#undef NEED_SIGNAL_CATCHER
|
||||
|
||||
/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
|
||||
* This is necessary on systems that distinguish text files from binary files,
|
||||
* and is harmless on most systems that don't. If you have one of the rare
|
||||
|
||||
11
jconfigint.h.in
Normal file
11
jconfigint.h.in
Normal file
@@ -0,0 +1,11 @@
|
||||
/* libjpeg-turbo build number */
|
||||
#undef BUILD
|
||||
|
||||
/* How to obtain function inlining. */
|
||||
#undef INLINE
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
12
jcparam.c
12
jcparam.c
@@ -121,7 +121,7 @@ jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
|
||||
cinfo->q_scale_factor[0], force_baseline);
|
||||
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
|
||||
cinfo->q_scale_factor[1], force_baseline);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -146,7 +146,7 @@ jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||
scale_factor, force_baseline);
|
||||
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
|
||||
scale_factor, force_baseline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
if (cinfo->comp_info == NULL)
|
||||
cinfo->comp_info = (jpeg_component_info *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
MAX_COMPONENTS * SIZEOF(jpeg_component_info));
|
||||
MAX_COMPONENTS * sizeof(jpeg_component_info));
|
||||
|
||||
/* Initialize everything not dependent on the color space */
|
||||
|
||||
@@ -582,7 +582,7 @@ jpeg_search_progression (j_compress_ptr cinfo)
|
||||
cinfo->script_space_size = MAX(nscans, 64);
|
||||
cinfo->script_space = (jpeg_scan_info *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
cinfo->script_space_size * SIZEOF(jpeg_scan_info));
|
||||
cinfo->script_space_size * sizeof(jpeg_scan_info));
|
||||
}
|
||||
scanptr = cinfo->script_space;
|
||||
cinfo->scan_info = scanptr;
|
||||
@@ -717,7 +717,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
||||
cinfo->script_space_size = MAX(nscans, 10);
|
||||
cinfo->script_space = (jpeg_scan_info *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
cinfo->script_space_size * SIZEOF(jpeg_scan_info));
|
||||
cinfo->script_space_size * sizeof(jpeg_scan_info));
|
||||
}
|
||||
scanptr = cinfo->script_space;
|
||||
cinfo->scan_info = scanptr;
|
||||
@@ -790,7 +790,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
||||
scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
|
||||
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
34
jcphuff.c
34
jcphuff.c
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* jcphuff.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
* 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 Huffman entropy encoding routines for progressive JPEG.
|
||||
@@ -88,16 +90,16 @@ typedef phuff_entropy_encoder * phuff_entropy_ptr;
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo));
|
||||
METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo));
|
||||
METHODDEF(boolean) encode_mcu_DC_first (j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) encode_mcu_AC_first (j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) encode_mcu_DC_refine (j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) encode_mcu_AC_refine (j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_phuff (j_compress_ptr cinfo);
|
||||
METHODDEF(void) finish_pass_gather_phuff (j_compress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
@@ -134,7 +136,7 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
if (entropy->bit_buffer == NULL)
|
||||
entropy->bit_buffer = (char *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
MAX_CORR_BITS * SIZEOF(char));
|
||||
MAX_CORR_BITS * sizeof(char));
|
||||
}
|
||||
}
|
||||
if (gather_statistics)
|
||||
@@ -167,8 +169,8 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
if (entropy->count_ptrs[tbl] == NULL)
|
||||
entropy->count_ptrs[tbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
257 * SIZEOF(long));
|
||||
MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long));
|
||||
257 * sizeof(long));
|
||||
MEMZERO(entropy->count_ptrs[tbl], 257 * sizeof(long));
|
||||
if (cinfo->trellis_passes) {
|
||||
/* When generating tables for trellis passes, make sure that all */
|
||||
/* codewords have an assigned length */
|
||||
@@ -786,7 +788,7 @@ finish_pass_gather_phuff (j_compress_ptr cinfo)
|
||||
/* It's important not to apply jpeg_gen_optimal_table more than once
|
||||
* per table, because it clobbers the input frequency counts!
|
||||
*/
|
||||
MEMZERO(did, SIZEOF(did));
|
||||
MEMZERO(did, sizeof(did));
|
||||
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
@@ -823,7 +825,7 @@ jinit_phuff_encoder (j_compress_ptr cinfo)
|
||||
|
||||
entropy = (phuff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(phuff_entropy_encoder));
|
||||
sizeof(phuff_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
entropy->pub.start_pass = start_pass_phuff;
|
||||
|
||||
|
||||
10
jcprepct.c
10
jcprepct.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jcprepct.c
|
||||
*
|
||||
* This file is part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains the compression preprocessing controller.
|
||||
@@ -278,7 +280,7 @@ create_context_buffer (j_compress_ptr cinfo)
|
||||
fake_buffer = (JSAMPARRAY)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(cinfo->num_components * 5 * rgroup_height) *
|
||||
SIZEOF(JSAMPROW));
|
||||
sizeof(JSAMPROW));
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
@@ -293,7 +295,7 @@ create_context_buffer (j_compress_ptr cinfo)
|
||||
(JDIMENSION) (3 * rgroup_height));
|
||||
/* Copy true buffer row pointers into the middle of the fake row array */
|
||||
MEMCOPY(fake_buffer + rgroup_height, true_buffer,
|
||||
3 * rgroup_height * SIZEOF(JSAMPROW));
|
||||
3 * rgroup_height * sizeof(JSAMPROW));
|
||||
/* Fill in the above and below wraparound pointers */
|
||||
for (i = 0; i < rgroup_height; i++) {
|
||||
fake_buffer[i] = true_buffer[2 * rgroup_height + i];
|
||||
@@ -323,7 +325,7 @@ jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
|
||||
prep = (my_prep_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_prep_controller));
|
||||
sizeof(my_prep_controller));
|
||||
cinfo->prep = (struct jpeg_c_prep_controller *) prep;
|
||||
prep->pub.start_pass = start_pass_prep;
|
||||
|
||||
|
||||
21
jcsample.c
21
jcsample.c
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
* jcsample.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* Copyright (C) 2014, MIPS Technologies, Inc., California
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains downsampling routines.
|
||||
@@ -53,9 +55,10 @@
|
||||
|
||||
|
||||
/* 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));
|
||||
typedef void (*downsample1_ptr) (j_compress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY output_data);
|
||||
|
||||
/* Private subobject */
|
||||
|
||||
@@ -472,7 +475,7 @@ jinit_downsampler (j_compress_ptr cinfo)
|
||||
|
||||
downsample = (my_downsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_downsampler));
|
||||
sizeof(my_downsampler));
|
||||
cinfo->downsample = (struct jpeg_downsampler *) downsample;
|
||||
downsample->pub.start_pass = start_pass_downsample;
|
||||
downsample->pub.downsample = sep_downsample;
|
||||
@@ -504,14 +507,20 @@ jinit_downsampler (j_compress_ptr cinfo)
|
||||
compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {
|
||||
#ifdef INPUT_SMOOTHING_SUPPORTED
|
||||
if (cinfo->smoothing_factor) {
|
||||
#if defined(__mips__)
|
||||
if (jsimd_can_h2v2_smooth_downsample())
|
||||
downsample->methods[ci] = jsimd_h2v2_smooth_downsample;
|
||||
else
|
||||
#endif
|
||||
downsample->methods[ci] = h2v2_smooth_downsample;
|
||||
downsample->pub.need_context_rows = TRUE;
|
||||
} else
|
||||
} else {
|
||||
#endif
|
||||
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;
|
||||
|
||||
16
jctrans.c
16
jctrans.c
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
* jctrans.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1998, Thomas G. Lane.
|
||||
* Modified 2000-2009 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains library routines for transcoding compression,
|
||||
@@ -18,9 +20,9 @@
|
||||
|
||||
/* Forward declarations */
|
||||
LOCAL(void) transencode_master_selection
|
||||
JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays));
|
||||
(j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays);
|
||||
LOCAL(void) transencode_coef_controller
|
||||
JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays));
|
||||
(j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays);
|
||||
|
||||
|
||||
/*
|
||||
@@ -105,7 +107,7 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo);
|
||||
MEMCOPY((*qtblptr)->quantval,
|
||||
srcinfo->quant_tbl_ptrs[tblno]->quantval,
|
||||
SIZEOF((*qtblptr)->quantval));
|
||||
sizeof((*qtblptr)->quantval));
|
||||
(*qtblptr)->sent_table = FALSE;
|
||||
}
|
||||
}
|
||||
@@ -386,7 +388,7 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
||||
|
||||
coef = (my_coef_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_coef_controller));
|
||||
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;
|
||||
@@ -397,8 +399,8 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
||||
/* 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));
|
||||
C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
jzero_far((void *) buffer, C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->dummy_buffer[i] = buffer + i;
|
||||
}
|
||||
|
||||
10
jdapimin.c
10
jdapimin.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jdapimin.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains application interface code for the decompression half
|
||||
@@ -35,9 +37,9 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
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))
|
||||
if (structsize != sizeof(struct jpeg_decompress_struct))
|
||||
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
|
||||
(int) SIZEOF(struct jpeg_decompress_struct), (int) structsize);
|
||||
(int) sizeof(struct jpeg_decompress_struct), (int) structsize);
|
||||
|
||||
/* For debugging purposes, we zero the whole master structure.
|
||||
* But the application has already set the err pointer, and may have set
|
||||
@@ -48,7 +50,7 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
{
|
||||
struct jpeg_error_mgr * err = cinfo->err;
|
||||
void * client_data = cinfo->client_data; /* ignore Purify complaint here */
|
||||
MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct));
|
||||
MEMZERO(cinfo, sizeof(struct jpeg_decompress_struct));
|
||||
cinfo->err = err;
|
||||
cinfo->client_data = client_data;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo));
|
||||
LOCAL(boolean) output_pass_setup (j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jdarith.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Developed 1997-2009 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains portable arithmetic entropy decoding routines for JPEG
|
||||
@@ -734,7 +736,7 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
|
||||
|
||||
entropy = (arith_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(arith_entropy_decoder));
|
||||
sizeof(arith_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
entropy->pub.start_pass = start_pass;
|
||||
|
||||
@@ -752,7 +754,7 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
|
||||
int *coef_bit_ptr, ci;
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2])
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components*DCTSIZE2*SIZEOF(int));
|
||||
cinfo->num_components*DCTSIZE2*sizeof(int));
|
||||
coef_bit_ptr = & cinfo->coef_bits[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (i = 0; i < DCTSIZE2; i++)
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include "jerror.h"
|
||||
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
||||
extern void * malloc JPP((size_t size));
|
||||
extern void free JPP((void *ptr));
|
||||
extern void * malloc (size_t size);
|
||||
extern void free (void *ptr);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ jpeg_mem_dest_tj (j_compress_ptr cinfo,
|
||||
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_mem_destination_mgr));
|
||||
sizeof(my_mem_destination_mgr));
|
||||
dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
dest->newbuffer = NULL;
|
||||
}
|
||||
|
||||
10
jdatadst.c
10
jdatadst.c
@@ -23,8 +23,8 @@
|
||||
#include "jerror.h"
|
||||
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
||||
extern void * malloc JPP((size_t size));
|
||||
extern void free JPP((void *ptr));
|
||||
extern void * malloc (size_t size);
|
||||
extern void free (void *ptr);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ init_destination (j_compress_ptr cinfo)
|
||||
/* Allocate the output buffer --- it will be released when done with image */
|
||||
dest->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
OUTPUT_BUF_SIZE * sizeof(JOCTET));
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
||||
@@ -216,7 +216,7 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
|
||||
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));
|
||||
sizeof(my_destination_mgr));
|
||||
}
|
||||
|
||||
dest = (my_dest_ptr) cinfo->dest;
|
||||
@@ -254,7 +254,7 @@ jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
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_mem_destination_mgr));
|
||||
sizeof(my_mem_destination_mgr));
|
||||
}
|
||||
|
||||
dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
|
||||
@@ -171,7 +171,7 @@ jpeg_mem_src_tj (j_decompress_ptr cinfo,
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(struct jpeg_source_mgr));
|
||||
sizeof(struct jpeg_source_mgr));
|
||||
}
|
||||
|
||||
src = cinfo->src;
|
||||
|
||||
@@ -227,11 +227,11 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_source_mgr));
|
||||
sizeof(my_source_mgr));
|
||||
src = (my_src_ptr) cinfo->src;
|
||||
src->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
INPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
INPUT_BUF_SIZE * sizeof(JOCTET));
|
||||
}
|
||||
|
||||
src = (my_src_ptr) cinfo->src;
|
||||
@@ -268,7 +268,7 @@ jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(struct jpeg_source_mgr));
|
||||
sizeof(struct jpeg_source_mgr));
|
||||
}
|
||||
|
||||
src = cinfo->src;
|
||||
|
||||
23
jdcoefct.c
23
jdcoefct.c
@@ -42,9 +42,6 @@ typedef struct {
|
||||
/* In single-pass modes, it's sufficient to buffer just one MCU.
|
||||
* We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,
|
||||
* and let the entropy decoder write into that workspace each time.
|
||||
* (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.
|
||||
*/
|
||||
@@ -69,15 +66,15 @@ typedef my_coef_controller * my_coef_ptr;
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(int) decompress_onepass
|
||||
JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
#ifdef D_MULTISCAN_FILES_SUPPORTED
|
||||
METHODDEF(int) decompress_data
|
||||
JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
#endif
|
||||
#ifdef BLOCK_SMOOTHING_SUPPORTED
|
||||
LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo));
|
||||
LOCAL(boolean) smoothing_ok (j_decompress_ptr cinfo);
|
||||
METHODDEF(int) decompress_smooth_data
|
||||
JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -168,8 +165,8 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
|
||||
MCU_col_num++) {
|
||||
/* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
|
||||
jzero_far((void FAR *) coef->MCU_buffer[0],
|
||||
(size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
|
||||
jzero_far((void *) coef->MCU_buffer[0],
|
||||
(size_t) (cinfo->blocks_in_MCU * sizeof(JBLOCK)));
|
||||
if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
@@ -426,7 +423,7 @@ smoothing_ok (j_decompress_ptr cinfo)
|
||||
coef->coef_bits_latch = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components *
|
||||
(SAVED_COEFS * SIZEOF(int)));
|
||||
(SAVED_COEFS * sizeof(int)));
|
||||
coef_bits_latch = coef->coef_bits_latch;
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
@@ -688,7 +685,7 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
|
||||
coef = (my_coef_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_coef_controller));
|
||||
sizeof(my_coef_controller));
|
||||
cinfo->coef = (struct jpeg_d_coef_controller *) coef;
|
||||
coef->pub.start_input_pass = start_input_pass;
|
||||
coef->pub.start_output_pass = start_output_pass;
|
||||
@@ -734,7 +731,7 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
|
||||
buffer = (JBLOCKROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
||||
D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->MCU_buffer[i] = buffer + i;
|
||||
}
|
||||
@@ -746,5 +743,5 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
/* Allocate the workspace buffer */
|
||||
coef->workspace = (JCOEF *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(JCOEF) * DCTSIZE2);
|
||||
sizeof(JCOEF) * DCTSIZE2);
|
||||
}
|
||||
|
||||
408
jdcol565.c
Normal file
408
jdcol565.c
Normal file
@@ -0,0 +1,408 @@
|
||||
/*
|
||||
* jdcol565.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modifications:
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains output colorspace conversion routines.
|
||||
*/
|
||||
|
||||
/* This file is included by jdcolor.c */
|
||||
|
||||
|
||||
#define PACK_SHORT_565(r, g, b) ((((r) << 8) & 0xf800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_TWO_PIXELS(l, r) ((r << 16) | l)
|
||||
#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
|
||||
|
||||
#define WRITE_TWO_PIXELS(addr, pixels) { \
|
||||
((INT16*)(addr))[0] = (pixels); \
|
||||
((INT16*)(addr))[1] = (pixels) >> 16; \
|
||||
}
|
||||
#define WRITE_TWO_ALIGNED_PIXELS(addr, pixels) ((*(INT32 *)(addr)) = pixels)
|
||||
|
||||
#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
|
||||
#define DITHER_565_G(g, dither) ((g) + (((dither) & 0xFF) >> 1))
|
||||
#define DITHER_565_B(b, dither) ((b) + ((dither) & 0xFF))
|
||||
|
||||
|
||||
/* Declarations for ordered dithering
|
||||
*
|
||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||
* sufficent for dithering RGB888 to RGB565.
|
||||
*/
|
||||
|
||||
#define DITHER_MASK 0x3
|
||||
#define DITHER_ROTATE(x) (((x) << 24) | (((x) >> 8) & 0x00FFFFFF))
|
||||
static const INT32 dither_matrix[4] = {
|
||||
0x0008020A,
|
||||
0x0C040E06,
|
||||
0x030B0109,
|
||||
0x0F070D05
|
||||
};
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb565_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;
|
||||
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) {
|
||||
INT32 rgb;
|
||||
unsigned int r, g, b;
|
||||
inptr0 = input_buf[0][input_row];
|
||||
inptr1 = input_buf[1][input_row];
|
||||
inptr2 = input_buf[2][input_row];
|
||||
input_row++;
|
||||
outptr = *output_buf++;
|
||||
|
||||
if (PACK_NEED_ALIGNMENT(outptr)) {
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
r = range_limit[y + Crrtab[cr]];
|
||||
g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS))];
|
||||
b = range_limit[y + Cbbtab[cb]];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
for (col = 0; col < (num_cols >> 1); col++) {
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
r = range_limit[y + Crrtab[cr]];
|
||||
g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS))];
|
||||
b = range_limit[y + Cbbtab[cb]];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
r = range_limit[y + Crrtab[cr]];
|
||||
g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS))];
|
||||
b = range_limit[y + Cbbtab[cb]];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
if (num_cols & 1) {
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
r = range_limit[y + Crrtab[cr]];
|
||||
g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS))];
|
||||
b = range_limit[y + Cbbtab[cb]];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb565D_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;
|
||||
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;
|
||||
INT32 d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
SHIFT_TEMPS
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
INT32 rgb;
|
||||
unsigned int r, g, b;
|
||||
|
||||
inptr0 = input_buf[0][input_row];
|
||||
inptr1 = input_buf[1][input_row];
|
||||
inptr2 = input_buf[2][input_row];
|
||||
input_row++;
|
||||
outptr = *output_buf++;
|
||||
if (PACK_NEED_ALIGNMENT(outptr)) {
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
|
||||
g = range_limit[DITHER_565_G(y +
|
||||
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS)), d0)];
|
||||
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
for (col = 0; col < (num_cols >> 1); col++) {
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
|
||||
g = range_limit[DITHER_565_G(y +
|
||||
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS)), d0)];
|
||||
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
|
||||
g = range_limit[DITHER_565_G(y +
|
||||
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS)), d0)];
|
||||
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
if (num_cols & 1) {
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
|
||||
g = range_limit[DITHER_565_G(y +
|
||||
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS)), d0)];
|
||||
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
SHIFT_TEMPS
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
INT32 rgb;
|
||||
unsigned int r, g, b;
|
||||
|
||||
inptr0 = input_buf[0][input_row];
|
||||
inptr1 = input_buf[1][input_row];
|
||||
inptr2 = input_buf[2][input_row];
|
||||
input_row++;
|
||||
outptr = *output_buf++;
|
||||
if (PACK_NEED_ALIGNMENT(outptr)) {
|
||||
r = GETJSAMPLE(*inptr0++);
|
||||
g = GETJSAMPLE(*inptr1++);
|
||||
b = GETJSAMPLE(*inptr2++);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
for (col = 0; col < (num_cols >> 1); col++) {
|
||||
r = GETJSAMPLE(*inptr0++);
|
||||
g = GETJSAMPLE(*inptr1++);
|
||||
b = GETJSAMPLE(*inptr2++);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
r = GETJSAMPLE(*inptr0++);
|
||||
g = GETJSAMPLE(*inptr1++);
|
||||
b = GETJSAMPLE(*inptr2++);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
if (num_cols & 1) {
|
||||
r = GETJSAMPLE(*inptr0);
|
||||
g = GETJSAMPLE(*inptr1);
|
||||
b = GETJSAMPLE(*inptr2);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
INT32 d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
SHIFT_TEMPS
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
INT32 rgb;
|
||||
unsigned int r, g, b;
|
||||
|
||||
inptr0 = input_buf[0][input_row];
|
||||
inptr1 = input_buf[1][input_row];
|
||||
inptr2 = input_buf[2][input_row];
|
||||
input_row++;
|
||||
outptr = *output_buf++;
|
||||
if (PACK_NEED_ALIGNMENT(outptr)) {
|
||||
r = range_limit[DITHER_565_R(GETJSAMPLE(*inptr0++), d0)];
|
||||
g = range_limit[DITHER_565_G(GETJSAMPLE(*inptr1++), d0)];
|
||||
b = range_limit[DITHER_565_B(GETJSAMPLE(*inptr2++), d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
for (col = 0; col < (num_cols >> 1); col++) {
|
||||
r = range_limit[DITHER_565_R(GETJSAMPLE(*inptr0++), d0)];
|
||||
g = range_limit[DITHER_565_G(GETJSAMPLE(*inptr1++), d0)];
|
||||
b = range_limit[DITHER_565_B(GETJSAMPLE(*inptr2++), d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
r = range_limit[DITHER_565_R(GETJSAMPLE(*inptr0++), d0)];
|
||||
g = range_limit[DITHER_565_G(GETJSAMPLE(*inptr1++), d0)];
|
||||
b = range_limit[DITHER_565_B(GETJSAMPLE(*inptr2++), d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
if (num_cols & 1) {
|
||||
r = range_limit[DITHER_565_R(GETJSAMPLE(*inptr0), d0)];
|
||||
g = range_limit[DITHER_565_G(GETJSAMPLE(*inptr1), d0)];
|
||||
b = range_limit[DITHER_565_B(GETJSAMPLE(*inptr2), d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
INT32 rgb;
|
||||
unsigned int g;
|
||||
|
||||
inptr = input_buf[0][input_row++];
|
||||
outptr = *output_buf++;
|
||||
if (PACK_NEED_ALIGNMENT(outptr)) {
|
||||
g = *inptr++;
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
for (col = 0; col < (num_cols >> 1); col++) {
|
||||
g = *inptr++;
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
g = *inptr++;
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(g, g, g));
|
||||
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
if (num_cols & 1) {
|
||||
g = *inptr;
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
INT32 d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
INT32 rgb;
|
||||
unsigned int g;
|
||||
|
||||
inptr = input_buf[0][input_row++];
|
||||
outptr = *output_buf++;
|
||||
if (PACK_NEED_ALIGNMENT(outptr)) {
|
||||
g = *inptr++;
|
||||
g = range_limit[DITHER_565_R(g, d0)];
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
for (col = 0; col < (num_cols >> 1); col++) {
|
||||
g = *inptr++;
|
||||
g = range_limit[DITHER_565_R(g, d0)];
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
|
||||
g = *inptr++;
|
||||
g = range_limit[DITHER_565_R(g, d0)];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(g, g, g));
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
|
||||
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
if (num_cols & 1) {
|
||||
g = *inptr;
|
||||
g = range_limit[DITHER_565_R(g, d0)];
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
jdcolor.c
44
jdcolor.c
@@ -7,6 +7,7 @@
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2009, 2011-2012, D. R. Commander.
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains output colorspace conversion routines.
|
||||
@@ -16,7 +17,7 @@
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jsimd.h"
|
||||
#include "config.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
@@ -215,16 +216,16 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
|
||||
cconvert->Cr_r_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(int));
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
cconvert->Cb_b_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(int));
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
cconvert->Cr_g_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||
(MAXJSAMPLE+1) * sizeof(INT32));
|
||||
cconvert->Cb_g_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||
(MAXJSAMPLE+1) * sizeof(INT32));
|
||||
|
||||
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
||||
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
|
||||
@@ -307,7 +308,7 @@ build_rgb_y_table (j_decompress_ptr cinfo)
|
||||
/* Allocate and fill in the conversion tables. */
|
||||
cconvert->rgb_y_tab = rgb_y_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(TABLE_SIZE * SIZEOF(INT32)));
|
||||
(TABLE_SIZE * sizeof(INT32)));
|
||||
|
||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||
rgb_y_tab[i+R_Y_OFF] = FIX(0.29900) * i;
|
||||
@@ -543,6 +544,9 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
#include "jdcol565.c"
|
||||
|
||||
|
||||
/*
|
||||
* Empty method for start_pass.
|
||||
*/
|
||||
@@ -566,7 +570,7 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
|
||||
cconvert = (my_cconvert_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_color_deconverter));
|
||||
sizeof(my_color_deconverter));
|
||||
cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;
|
||||
cconvert->pub.start_pass = start_pass_dcolor;
|
||||
|
||||
@@ -649,6 +653,32 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
break;
|
||||
|
||||
case JCS_RGB565:
|
||||
cinfo->out_color_components = 3;
|
||||
if (cinfo->dither_mode == JDITHER_NONE) {
|
||||
if (cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||
cconvert->pub.color_convert = ycc_rgb565_convert;
|
||||
build_ycc_rgb_table(cinfo);
|
||||
} else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
|
||||
cconvert->pub.color_convert = gray_rgb565_convert;
|
||||
} else if (cinfo->jpeg_color_space == JCS_RGB) {
|
||||
cconvert->pub.color_convert = rgb_rgb565_convert;
|
||||
} else
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
} else {
|
||||
/* only ordered dithering is supported */
|
||||
if (cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||
cconvert->pub.color_convert = ycc_rgb565D_convert;
|
||||
build_ycc_rgb_table(cinfo);
|
||||
} else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
|
||||
cconvert->pub.color_convert = gray_rgb565D_convert;
|
||||
} else if (cinfo->jpeg_color_space == JCS_RGB) {
|
||||
cconvert->pub.color_convert = rgb_rgb565D_convert;
|
||||
} else
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_CMYK:
|
||||
cinfo->out_color_components = 4;
|
||||
if (cinfo->jpeg_color_space == JCS_YCCK) {
|
||||
|
||||
108
jdct.h
108
jdct.h
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jdct.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This include file contains common declarations for the forward and
|
||||
@@ -86,92 +88,66 @@ typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
|
||||
#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */
|
||||
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||
|
||||
#ifdef NEED_SHORT_EXTERNAL_NAMES
|
||||
#define jpeg_fdct_islow jFDislow
|
||||
#define jpeg_fdct_ifast jFDifast
|
||||
#define jpeg_fdct_float jFDfloat
|
||||
#define jpeg_idct_islow jRDislow
|
||||
#define jpeg_idct_ifast jRDifast
|
||||
#define jpeg_idct_float jRDfloat
|
||||
#define jpeg_idct_7x7 jRD7x7
|
||||
#define jpeg_idct_6x6 jRD6x6
|
||||
#define jpeg_idct_5x5 jRD5x5
|
||||
#define jpeg_idct_4x4 jRD4x4
|
||||
#define jpeg_idct_3x3 jRD3x3
|
||||
#define jpeg_idct_2x2 jRD2x2
|
||||
#define jpeg_idct_1x1 jRD1x1
|
||||
#define jpeg_idct_9x9 jRD9x9
|
||||
#define jpeg_idct_10x10 jRD10x10
|
||||
#define jpeg_idct_11x11 jRD11x11
|
||||
#define jpeg_idct_12x12 jRD12x12
|
||||
#define jpeg_idct_13x13 jRD13x13
|
||||
#define jpeg_idct_14x14 jRD14x14
|
||||
#define jpeg_idct_15x15 jRD15x15
|
||||
#define jpeg_idct_16x16 jRD16x16
|
||||
#endif /* NEED_SHORT_EXTERNAL_NAMES */
|
||||
|
||||
/* Extern declarations for the forward and inverse DCT routines. */
|
||||
|
||||
EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data));
|
||||
EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data));
|
||||
EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data));
|
||||
EXTERN(void) jpeg_fdct_islow (DCTELEM * data);
|
||||
EXTERN(void) jpeg_fdct_ifast (DCTELEM * data);
|
||||
EXTERN(void) jpeg_fdct_float (FAST_FLOAT * data);
|
||||
|
||||
EXTERN(void) jpeg_idct_islow
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_ifast
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_float
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_7x7
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_6x6
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_5x5
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_4x4
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_3x3
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_2x2
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_1x1
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_9x9
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_10x10
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_11x11
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_12x12
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_13x13
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_14x14
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_15x15
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_16x16
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2010, D. R. Commander.
|
||||
* Copyright (C) 2013, MIPS Technologies, Inc., California
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains the inverse-DCT management logic.
|
||||
@@ -331,7 +332,7 @@ jinit_inverse_dct (j_decompress_ptr cinfo)
|
||||
|
||||
idct = (my_idct_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_idct_controller));
|
||||
sizeof(my_idct_controller));
|
||||
cinfo->idct = (struct jpeg_inverse_dct *) idct;
|
||||
idct->pub.start_pass = start_pass;
|
||||
|
||||
@@ -340,8 +341,8 @@ jinit_inverse_dct (j_decompress_ptr cinfo)
|
||||
/* Allocate and pre-zero a multiplier table for each component */
|
||||
compptr->dct_table =
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(multiplier_table));
|
||||
MEMZERO(compptr->dct_table, SIZEOF(multiplier_table));
|
||||
sizeof(multiplier_table));
|
||||
MEMZERO(compptr->dct_table, sizeof(multiplier_table));
|
||||
/* Mark multiplier table not yet set up for any method */
|
||||
idct->cur_method[ci] = -1;
|
||||
}
|
||||
|
||||
4
jdhuff.c
4
jdhuff.c
@@ -177,7 +177,7 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
if (*pdtbl == NULL)
|
||||
*pdtbl = (d_derived_tbl *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(d_derived_tbl));
|
||||
sizeof(d_derived_tbl));
|
||||
dtbl = *pdtbl;
|
||||
dtbl->pub = htbl; /* fill in back link */
|
||||
|
||||
@@ -804,7 +804,7 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
|
||||
|
||||
entropy = (huff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(huff_entropy_decoder));
|
||||
sizeof(huff_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
entropy->pub.start_pass = start_pass_huff_decoder;
|
||||
entropy->pub.decode_mcu = decode_mcu;
|
||||
|
||||
22
jdhuff.h
22
jdhuff.h
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modifications:
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010-2011, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -12,14 +12,6 @@
|
||||
* progressive decoder (jdphuff.c). No other modules need to see these.
|
||||
*/
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||
|
||||
#ifdef NEED_SHORT_EXTERNAL_NAMES
|
||||
#define jpeg_make_d_derived_tbl jMkDDerived
|
||||
#define jpeg_fill_bit_buffer jFilBitBuf
|
||||
#define jpeg_huff_decode jHufDecode
|
||||
#endif /* NEED_SHORT_EXTERNAL_NAMES */
|
||||
|
||||
|
||||
/* Derived data constructed for each Huffman table */
|
||||
|
||||
@@ -53,8 +45,8 @@ typedef struct {
|
||||
|
||||
/* Expand a Huffman table definition into the derived format */
|
||||
EXTERN(void) jpeg_make_d_derived_tbl
|
||||
JPP((j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
d_derived_tbl ** pdtbl));
|
||||
(j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
d_derived_tbl ** pdtbl);
|
||||
|
||||
|
||||
/*
|
||||
@@ -167,8 +159,8 @@ typedef struct { /* Bitreading working state within an MCU */
|
||||
|
||||
/* Load up the bit buffer to a depth of at least nbits */
|
||||
EXTERN(boolean) jpeg_fill_bit_buffer
|
||||
JPP((bitread_working_state * state, register bit_buf_type get_buffer,
|
||||
register int bits_left, int nbits));
|
||||
(bitread_working_state * state, register bit_buf_type get_buffer,
|
||||
register int bits_left, int nbits);
|
||||
|
||||
|
||||
/*
|
||||
@@ -231,5 +223,5 @@ slowlabel: \
|
||||
|
||||
/* Out-of-line case for Huffman code fetching */
|
||||
EXTERN(int) jpeg_huff_decode
|
||||
JPP((bitread_working_state * state, register bit_buf_type get_buffer,
|
||||
register int bits_left, d_derived_tbl * htbl, int min_bits));
|
||||
(bitread_working_state * state, register bit_buf_type get_buffer,
|
||||
register int bits_left, d_derived_tbl * htbl, int min_bits);
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef my_input_controller * my_inputctl_ptr;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo));
|
||||
METHODDEF(int) consume_markers (j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
@@ -253,8 +253,8 @@ latch_quant_tables (j_decompress_ptr cinfo)
|
||||
/* OK, save away the quantization table */
|
||||
qtbl = (JQUANT_TBL *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(JQUANT_TBL));
|
||||
MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL));
|
||||
sizeof(JQUANT_TBL));
|
||||
MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], sizeof(JQUANT_TBL));
|
||||
compptr->quant_table = qtbl;
|
||||
}
|
||||
}
|
||||
@@ -382,7 +382,7 @@ jinit_input_controller (j_decompress_ptr cinfo)
|
||||
/* Create subobject in permanent pool */
|
||||
inputctl = (my_inputctl_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_input_controller));
|
||||
sizeof(my_input_controller));
|
||||
cinfo->inputctl = (struct jpeg_input_controller *) inputctl;
|
||||
/* Initialize method pointers */
|
||||
inputctl->pub.consume_input = consume_markers;
|
||||
|
||||
18
jdmainct.c
18
jdmainct.c
@@ -144,15 +144,15 @@ typedef my_main_controller * my_main_ptr;
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(void) process_data_simple_main
|
||||
JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));
|
||||
(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) process_data_context_main
|
||||
JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));
|
||||
(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
METHODDEF(void) process_data_crank_post
|
||||
JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));
|
||||
(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
*/
|
||||
main_ptr->xbuffer[0] = (JSAMPIMAGE)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * 2 * SIZEOF(JSAMPARRAY));
|
||||
cinfo->num_components * 2 * sizeof(JSAMPARRAY));
|
||||
main_ptr->xbuffer[1] = main_ptr->xbuffer[0] + cinfo->num_components;
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
@@ -185,7 +185,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
*/
|
||||
xbuf = (JSAMPARRAY)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));
|
||||
2 * (rgroup * (M + 4)) * sizeof(JSAMPROW));
|
||||
xbuf += rgroup; /* want one row group at negative offsets */
|
||||
main_ptr->xbuffer[0][ci] = xbuf;
|
||||
xbuf += rgroup * (M + 4);
|
||||
@@ -484,7 +484,7 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
|
||||
main_ptr = (my_main_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_main_controller));
|
||||
sizeof(my_main_controller));
|
||||
cinfo->main = (struct jpeg_d_main_controller *) main_ptr;
|
||||
main_ptr->pub.start_pass = start_pass_main;
|
||||
|
||||
|
||||
26
jdmarker.c
26
jdmarker.c
@@ -276,7 +276,7 @@ get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
if (cinfo->comp_info == NULL) /* do only once, even if suspend */
|
||||
cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * SIZEOF(jpeg_component_info));
|
||||
cinfo->num_components * sizeof(jpeg_component_info));
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
@@ -472,7 +472,7 @@ get_dht (j_decompress_ptr cinfo)
|
||||
for (i = 0; i < count; i++)
|
||||
INPUT_BYTE(cinfo, huffval[i], return FALSE);
|
||||
|
||||
MEMZERO(&huffval[count], (256 - count) * SIZEOF(UINT8));
|
||||
MEMZERO(&huffval[count], (256 - count) * sizeof(UINT8));
|
||||
|
||||
length -= count;
|
||||
|
||||
@@ -490,8 +490,8 @@ get_dht (j_decompress_ptr cinfo)
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
|
||||
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
|
||||
MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval));
|
||||
MEMCOPY((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
|
||||
MEMCOPY((*htblptr)->huffval, huffval, sizeof((*htblptr)->huffval));
|
||||
}
|
||||
|
||||
if (length != 0)
|
||||
@@ -597,7 +597,7 @@ get_dri (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
|
||||
examine_app0 (j_decompress_ptr cinfo, JOCTET * data,
|
||||
unsigned int datalen, INT32 remaining)
|
||||
/* Examine first few bytes from an APP0.
|
||||
* Take appropriate action if it is a JFIF marker.
|
||||
@@ -673,7 +673,7 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data,
|
||||
examine_app14 (j_decompress_ptr cinfo, JOCTET * data,
|
||||
unsigned int datalen, INT32 remaining)
|
||||
/* Examine first few bytes from an APP14.
|
||||
* Take appropriate action if it is an Adobe marker.
|
||||
@@ -729,10 +729,10 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
/* process it */
|
||||
switch (cinfo->unread_marker) {
|
||||
case M_APP0:
|
||||
examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length);
|
||||
examine_app0(cinfo, (JOCTET *) b, numtoread, length);
|
||||
break;
|
||||
case M_APP14:
|
||||
examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length);
|
||||
examine_app14(cinfo, (JOCTET *) b, numtoread, length);
|
||||
break;
|
||||
default:
|
||||
/* can't get here unless jpeg_save_markers chooses wrong processor */
|
||||
@@ -758,7 +758,7 @@ save_marker (j_decompress_ptr cinfo)
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
jpeg_saved_marker_ptr cur_marker = marker->cur_marker;
|
||||
unsigned int bytes_read, data_length;
|
||||
JOCTET FAR * data;
|
||||
JOCTET * data;
|
||||
INT32 length = 0;
|
||||
INPUT_VARS(cinfo);
|
||||
|
||||
@@ -778,13 +778,13 @@ save_marker (j_decompress_ptr cinfo)
|
||||
/* allocate and initialize the marker item */
|
||||
cur_marker = (jpeg_saved_marker_ptr)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(struct jpeg_marker_struct) + limit);
|
||||
sizeof(struct jpeg_marker_struct) + limit);
|
||||
cur_marker->next = NULL;
|
||||
cur_marker->marker = (UINT8) cinfo->unread_marker;
|
||||
cur_marker->original_length = (unsigned int) length;
|
||||
cur_marker->data_length = limit;
|
||||
/* data area is just beyond the jpeg_marker_struct */
|
||||
data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1);
|
||||
data = cur_marker->data = (JOCTET *) (cur_marker + 1);
|
||||
marker->cur_marker = cur_marker;
|
||||
marker->bytes_read = 0;
|
||||
bytes_read = 0;
|
||||
@@ -1283,7 +1283,7 @@ jinit_marker_reader (j_decompress_ptr cinfo)
|
||||
/* Create subobject in permanent pool */
|
||||
marker = (my_marker_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_marker_reader));
|
||||
sizeof(my_marker_reader));
|
||||
cinfo->marker = (struct jpeg_marker_reader *) marker;
|
||||
/* Initialize public method pointers */
|
||||
marker->pub.reset_marker_reader = reset_marker_reader;
|
||||
@@ -1323,7 +1323,7 @@ jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
/* Length limit mustn't be larger than what we can allocate
|
||||
* (should only be a concern in a 16-bit environment).
|
||||
*/
|
||||
maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct);
|
||||
maxlength = cinfo->mem->max_alloc_chunk - sizeof(struct jpeg_marker_struct);
|
||||
if (((long) length_limit) > maxlength)
|
||||
length_limit = (unsigned int) maxlength;
|
||||
|
||||
|
||||
26
jdmaster.c
26
jdmaster.c
@@ -6,6 +6,7 @@
|
||||
* Modified 2002-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009-2011, D. R. Commander.
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains master control logic for the JPEG decompressor.
|
||||
@@ -51,9 +52,10 @@ use_merged_upsample (j_decompress_ptr cinfo)
|
||||
/* 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 */
|
||||
/* jdmerge.c only supports YCC=>RGB and YCC=>RGB565 color conversion */
|
||||
if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
|
||||
(cinfo->out_color_space != JCS_RGB &&
|
||||
cinfo->out_color_space != JCS_RGB565 &&
|
||||
cinfo->out_color_space != JCS_EXT_RGB &&
|
||||
cinfo->out_color_space != JCS_EXT_RGBX &&
|
||||
cinfo->out_color_space != JCS_EXT_BGR &&
|
||||
@@ -63,8 +65,12 @@ use_merged_upsample (j_decompress_ptr cinfo)
|
||||
cinfo->out_color_space != JCS_EXT_RGBA &&
|
||||
cinfo->out_color_space != JCS_EXT_BGRA &&
|
||||
cinfo->out_color_space != JCS_EXT_ABGR &&
|
||||
cinfo->out_color_space != JCS_EXT_ARGB) ||
|
||||
cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space])
|
||||
cinfo->out_color_space != JCS_EXT_ARGB))
|
||||
return FALSE;
|
||||
if ((cinfo->out_color_space == JCS_RGB565 &&
|
||||
cinfo->out_color_components != 3) ||
|
||||
(cinfo->out_color_space != JCS_RGB565 &&
|
||||
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 ||
|
||||
@@ -352,6 +358,7 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
|
||||
break;
|
||||
case JCS_YCbCr:
|
||||
case JCS_RGB565:
|
||||
cinfo->out_color_components = 3;
|
||||
break;
|
||||
case JCS_CMYK:
|
||||
@@ -411,9 +418,6 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
* We can save some space by overlapping the start of the post-IDCT table
|
||||
* with the simpler range limiting table. The post-IDCT table begins at
|
||||
* sample_range_limit + CENTERJSAMPLE.
|
||||
*
|
||||
* 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)
|
||||
@@ -425,11 +429,11 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
|
||||
|
||||
table = (JSAMPLE *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));
|
||||
(5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
|
||||
table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
|
||||
cinfo->sample_range_limit = table;
|
||||
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
|
||||
MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
|
||||
MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * sizeof(JSAMPLE));
|
||||
/* Main part of "simple" table: limit[x] = x */
|
||||
for (i = 0; i <= MAXJSAMPLE; i++)
|
||||
table[i] = (JSAMPLE) i;
|
||||
@@ -439,9 +443,9 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
|
||||
table[i] = MAXJSAMPLE;
|
||||
/* Second half of post-IDCT table */
|
||||
MEMZERO(table + (2 * (MAXJSAMPLE+1)),
|
||||
(2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
|
||||
(2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
|
||||
MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
|
||||
cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
|
||||
cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
|
||||
}
|
||||
|
||||
|
||||
@@ -722,7 +726,7 @@ jinit_master_decompress (j_decompress_ptr cinfo)
|
||||
|
||||
master = (my_master_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_decomp_master));
|
||||
sizeof(my_decomp_master));
|
||||
cinfo->master = (struct jpeg_decomp_master *) master;
|
||||
master->pub.prepare_for_output_pass = prepare_for_output_pass;
|
||||
master->pub.finish_output_pass = finish_output_pass;
|
||||
|
||||
406
jdmerge.c
406
jdmerge.c
@@ -6,6 +6,7 @@
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, 2011, D. R. Commander.
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains code for merged upsampling/color conversion.
|
||||
@@ -39,20 +40,51 @@
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jsimd.h"
|
||||
#include "config.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
|
||||
|
||||
#define PACK_SHORT_565(r, g, b) ((((r) << 8) & 0xf800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_TWO_PIXELS(l, r) ((r << 16) | l)
|
||||
#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
|
||||
|
||||
#define WRITE_TWO_PIXELS(addr, pixels) { \
|
||||
((INT16*)(addr))[0] = (pixels); \
|
||||
((INT16*)(addr))[1] = (pixels) >> 16; \
|
||||
}
|
||||
#define WRITE_TWO_ALIGNED_PIXELS(addr, pixels) ((*(INT32 *)(addr)) = pixels)
|
||||
|
||||
#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
|
||||
#define DITHER_565_G(g, dither) ((g) + (((dither) & 0xFF) >> 1))
|
||||
#define DITHER_565_B(b, dither) ((b) + ((dither) & 0xFF))
|
||||
|
||||
|
||||
/* Declarations for ordered dithering
|
||||
*
|
||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||
* sufficent for dithering RGB888 to RGB565.
|
||||
*/
|
||||
|
||||
#define DITHER_MASK 0x3
|
||||
#define DITHER_ROTATE(x) (((x) << 24) | (((x) >> 8) & 0x00FFFFFF))
|
||||
static const INT32 dither_matrix[4] = {
|
||||
0x0008020A,
|
||||
0x0C040E06,
|
||||
0x030B0109,
|
||||
0x0F070D05
|
||||
};
|
||||
|
||||
|
||||
/* 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,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf));
|
||||
void (*upmethod) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
|
||||
/* Private state for YCC->RGB conversion */
|
||||
int * Cr_r_tab; /* => table for Cr to R conversion */
|
||||
@@ -195,16 +227,16 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
|
||||
upsample->Cr_r_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(int));
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
upsample->Cb_b_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(int));
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
upsample->Cr_g_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||
(MAXJSAMPLE+1) * sizeof(INT32));
|
||||
upsample->Cb_g_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||
(MAXJSAMPLE+1) * sizeof(INT32));
|
||||
|
||||
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
||||
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
|
||||
@@ -260,8 +292,11 @@ merged_2v_upsample (j_decompress_ptr cinfo,
|
||||
|
||||
if (upsample->spare_full) {
|
||||
/* If we have a spare row saved from a previous cycle, just return it. */
|
||||
JDIMENSION size = upsample->out_row_width;
|
||||
if (cinfo->out_color_space == JCS_RGB565)
|
||||
size = cinfo->output_width * 2;
|
||||
jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0,
|
||||
1, upsample->out_row_width);
|
||||
1, size);
|
||||
num_rows = 1;
|
||||
upsample->spare_full = FALSE;
|
||||
} else {
|
||||
@@ -416,6 +451,341 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample_565 (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 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;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
INT32 * Crgtab = upsample->Cr_g_tab;
|
||||
INT32 * Cbgtab = upsample->Cb_g_tab;
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr0 = input_buf[0][in_row_group_ctr];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr = output_buf[0];
|
||||
|
||||
/* Loop for each pair 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 2 Y values and emit 2 pixels */
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample_565D (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 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;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
INT32 * Crgtab = upsample->Cr_g_tab;
|
||||
INT32 * Cbgtab = upsample->Cb_g_tab;
|
||||
INT32 d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr0 = input_buf[0][in_row_group_ctr];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr = output_buf[0];
|
||||
|
||||
/* Loop for each pair 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 2 Y values and emit 2 pixels */
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample_565 (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;
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
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++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr0, rgb);
|
||||
outptr0 += 4;
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr1, rgb);
|
||||
outptr1 += 4;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr0 = rgb;
|
||||
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr1 = rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample_565D (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;
|
||||
INT32 d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
INT32 d1 = dither_matrix[(cinfo->output_scanline+1) & DITHER_MASK];
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
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++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
d1 = DITHER_ROTATE(d1);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr0, rgb);
|
||||
outptr0 += 4;
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
d1 = DITHER_ROTATE(d1);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr1, rgb);
|
||||
outptr1 += 4;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr0 = rgb;
|
||||
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr1 = rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Module initialization routine for merged upsampling/color conversion.
|
||||
*
|
||||
@@ -431,7 +801,7 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
|
||||
upsample = (my_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_upsampler));
|
||||
sizeof(my_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *) upsample;
|
||||
upsample->pub.start_pass = start_pass_merged_upsample;
|
||||
upsample->pub.need_context_rows = FALSE;
|
||||
@@ -444,16 +814,30 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
upsample->upmethod = jsimd_h2v2_merged_upsample;
|
||||
else
|
||||
upsample->upmethod = h2v2_merged_upsample;
|
||||
if (cinfo->out_color_space == JCS_RGB565) {
|
||||
if (cinfo->dither_mode != JDITHER_NONE) {
|
||||
upsample->upmethod = h2v2_merged_upsample_565D;
|
||||
} else {
|
||||
upsample->upmethod = h2v2_merged_upsample_565;
|
||||
}
|
||||
}
|
||||
/* 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)));
|
||||
(size_t) (upsample->out_row_width * sizeof(JSAMPLE)));
|
||||
} else {
|
||||
upsample->pub.upsample = merged_1v_upsample;
|
||||
if (jsimd_can_h2v1_merged_upsample())
|
||||
upsample->upmethod = jsimd_h2v1_merged_upsample;
|
||||
else
|
||||
upsample->upmethod = h2v1_merged_upsample;
|
||||
if (cinfo->out_color_space == JCS_RGB565) {
|
||||
if (cinfo->dither_mode != JDITHER_NONE) {
|
||||
upsample->upmethod = h2v1_merged_upsample_565D;
|
||||
} else {
|
||||
upsample->upmethod = h2v1_merged_upsample_565;
|
||||
}
|
||||
}
|
||||
/* No spare row needed */
|
||||
upsample->spare_row = NULL;
|
||||
}
|
||||
|
||||
24
jdphuff.c
24
jdphuff.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jdphuff.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains Huffman entropy decoding routines for progressive JPEG.
|
||||
@@ -74,14 +76,14 @@ typedef struct {
|
||||
typedef phuff_entropy_decoder * phuff_entropy_ptr;
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
METHODDEF(boolean) decode_mcu_DC_first (j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) decode_mcu_AC_first (j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) decode_mcu_DC_refine (j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) decode_mcu_AC_refine (j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
|
||||
|
||||
/*
|
||||
@@ -647,7 +649,7 @@ jinit_phuff_decoder (j_decompress_ptr cinfo)
|
||||
|
||||
entropy = (phuff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(phuff_entropy_decoder));
|
||||
sizeof(phuff_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
entropy->pub.start_pass = start_pass_phuff_decoder;
|
||||
|
||||
@@ -659,7 +661,7 @@ jinit_phuff_decoder (j_decompress_ptr cinfo)
|
||||
/* Create progression status table */
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2])
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components*DCTSIZE2*SIZEOF(int));
|
||||
cinfo->num_components*DCTSIZE2*sizeof(int));
|
||||
coef_bit_ptr = & cinfo->coef_bits[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (i = 0; i < DCTSIZE2; i++)
|
||||
|
||||
27
jdpostct.c
27
jdpostct.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jdpostct.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains the decompression postprocessing controller.
|
||||
@@ -44,24 +46,21 @@ typedef my_post_controller * my_post_ptr;
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(void) post_process_1pass
|
||||
JPP((j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail));
|
||||
JDIMENSION out_rows_avail);
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
METHODDEF(void) post_process_prepass
|
||||
JPP((j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail));
|
||||
JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) post_process_2pass
|
||||
JPP((j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail));
|
||||
JDIMENSION out_rows_avail);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -253,7 +252,7 @@ jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
|
||||
post = (my_post_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_post_controller));
|
||||
sizeof(my_post_controller));
|
||||
cinfo->post = (struct jpeg_d_post_controller *) post;
|
||||
post->pub.start_pass = start_pass_dpost;
|
||||
post->whole_image = NULL; /* flag for no virtual arrays */
|
||||
|
||||
15
jdsample.c
15
jdsample.c
@@ -6,6 +6,7 @@
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2010, D. R. Commander.
|
||||
* Copyright (C) 2014, MIPS Technologies, Inc., California
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains upsampling routines.
|
||||
@@ -29,9 +30,10 @@
|
||||
|
||||
|
||||
/* 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));
|
||||
typedef void (*upsample1_ptr) (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY * output_data_ptr);
|
||||
|
||||
/* Private subobject */
|
||||
|
||||
@@ -411,7 +413,7 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
|
||||
upsample = (my_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_upsampler));
|
||||
sizeof(my_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *) upsample;
|
||||
upsample->pub.start_pass = start_pass_upsample;
|
||||
upsample->pub.upsample = sep_upsample;
|
||||
@@ -481,6 +483,11 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
} else if ((h_out_group % h_in_group) == 0 &&
|
||||
(v_out_group % v_in_group) == 0) {
|
||||
/* Generic integral-factors upsampling method */
|
||||
#if defined(__mips__)
|
||||
if (jsimd_can_int_upsample())
|
||||
upsample->methods[ci] = jsimd_int_upsample;
|
||||
else
|
||||
#endif
|
||||
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);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jdtrans.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains library routines for transcoding decompression,
|
||||
@@ -16,7 +18,7 @@
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo));
|
||||
LOCAL(void) transdecode_master_selection (j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
8
jerror.c
8
jerror.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jerror.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains simple error-reporting and trace-message routines.
|
||||
@@ -41,10 +43,6 @@
|
||||
* want to refer to it directly.
|
||||
*/
|
||||
|
||||
#ifdef NEED_SHORT_EXTERNAL_NAMES
|
||||
#define jpeg_std_message_table jMsgTable
|
||||
#endif
|
||||
|
||||
#define JMESSAGE(code,string) string ,
|
||||
|
||||
const char * const jpeg_std_message_table[] = {
|
||||
|
||||
6
jerror.h
6
jerror.h
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
* jerror.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2014, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file defines the error and message codes for the JPEG library.
|
||||
@@ -132,7 +134,7 @@ JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up")
|
||||
JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation")
|
||||
JMESSAGE(JERR_XMS_READ, "Read from XMS failed")
|
||||
JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed")
|
||||
JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT)
|
||||
JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT_SHORT)
|
||||
JMESSAGE(JMSG_VERSION, JVERSION)
|
||||
JMESSAGE(JTRC_16BIT_TABLES,
|
||||
"Caution: quantization tables are too coarse for baseline JPEG")
|
||||
|
||||
14
jinclude.h
14
jinclude.h
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jinclude.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1994, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file exists to provide a single place to fix any problems with
|
||||
@@ -69,16 +71,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* In ANSI C, and indeed any rational implementation, size_t is also the
|
||||
* type returned by sizeof(). However, it seems there are some irrational
|
||||
* implementations out there, in which sizeof() returns an int even though
|
||||
* size_t is defined as long or unsigned long. To ensure consistent results
|
||||
* we always use this SIZEOF() macro in place of using sizeof() directly.
|
||||
*/
|
||||
|
||||
#define SIZEOF(object) ((size_t) sizeof(object))
|
||||
|
||||
/*
|
||||
* The modules that use fread() and fwrite() always invoke them through
|
||||
* these macros. On some systems you may need to twiddle the argument casts.
|
||||
|
||||
111
jmemmgr.c
111
jmemmgr.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jmemmgr.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains the JPEG system-independent memory management
|
||||
@@ -32,7 +34,7 @@
|
||||
|
||||
#ifndef NO_GETENV
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */
|
||||
extern char * getenv JPP((const char * name));
|
||||
extern char * getenv (const char * name);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -80,7 +82,7 @@ round_up_pow2 (size_t a, size_t b)
|
||||
|
||||
#ifndef ALIGN_SIZE /* so can override from jconfig.h */
|
||||
#ifndef WITH_SIMD
|
||||
#define ALIGN_SIZE SIZEOF(double)
|
||||
#define ALIGN_SIZE sizeof(double)
|
||||
#else
|
||||
#define ALIGN_SIZE 16 /* Most SIMD implementations require this */
|
||||
#endif
|
||||
@@ -91,8 +93,7 @@ round_up_pow2 (size_t a, size_t b)
|
||||
* 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.
|
||||
* Small and large pool headers are identical.
|
||||
*/
|
||||
|
||||
typedef struct small_pool_struct * small_pool_ptr;
|
||||
@@ -103,7 +104,7 @@ typedef struct small_pool_struct {
|
||||
size_t bytes_left; /* bytes still available in this pool */
|
||||
} small_pool_hdr;
|
||||
|
||||
typedef struct large_pool_struct FAR * large_pool_ptr;
|
||||
typedef struct large_pool_struct * large_pool_ptr;
|
||||
|
||||
typedef struct large_pool_struct {
|
||||
large_pool_ptr next; /* next in list of pools */
|
||||
@@ -277,7 +278,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
|
||||
|
||||
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
||||
if ((SIZEOF(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
|
||||
if ((sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
|
||||
out_of_memory(cinfo, 1); /* request exceeds malloc's ability */
|
||||
|
||||
/* See if space is available in any existing pool */
|
||||
@@ -295,7 +296,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
/* 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 = SIZEOF(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1;
|
||||
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
|
||||
@@ -325,7 +326,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
|
||||
/* OK, allocate the object from the current pool */
|
||||
data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr += SIZEOF(small_pool_hdr); /* ...by skipping the header... */
|
||||
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 */
|
||||
@@ -339,9 +340,8 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
/*
|
||||
* Allocation of "large" objects.
|
||||
*
|
||||
* The external semantics of these are the same as "small" objects,
|
||||
* except that FAR pointers are used on 80x86. However the pool
|
||||
* management heuristics are quite different. We assume that each
|
||||
* The external semantics of these are the same as "small" objects. However,
|
||||
* the pool management heuristics are quite different. We assume that each
|
||||
* request is large enough that it may as well be passed directly to
|
||||
* jpeg_get_large; the pool management just links everything together
|
||||
* so that we can free it all on demand.
|
||||
@@ -350,13 +350,13 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
* deliberately bunch rows together to ensure a large request size.
|
||||
*/
|
||||
|
||||
METHODDEF(void FAR *)
|
||||
METHODDEF(void *)
|
||||
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;
|
||||
char FAR * data_ptr;
|
||||
char * data_ptr;
|
||||
|
||||
/*
|
||||
* Round up the requested size to a multiple of ALIGN_SIZE so that
|
||||
@@ -366,7 +366,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
|
||||
|
||||
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
||||
if ((SIZEOF(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
|
||||
if ((sizeof(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
|
||||
out_of_memory(cinfo, 3); /* request exceeds malloc's ability */
|
||||
|
||||
/* Always make a new pool */
|
||||
@@ -374,11 +374,11 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
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) + ALIGN_SIZE - 1;
|
||||
mem->total_space_allocated += sizeofobject + sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
|
||||
|
||||
/* Success, initialize the new pool header and add to list */
|
||||
hdr_ptr->next = mem->large_list[pool_id];
|
||||
@@ -390,17 +390,16 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
mem->large_list[pool_id] = hdr_ptr;
|
||||
|
||||
data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr += SIZEOF(small_pool_hdr); /* ...by skipping the header... */
|
||||
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;
|
||||
return (void *) 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
|
||||
@@ -427,13 +426,13 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
long ltemp;
|
||||
|
||||
/* Make sure each row is properly aligned */
|
||||
if ((ALIGN_SIZE % SIZEOF(JSAMPLE)) != 0)
|
||||
if ((ALIGN_SIZE % sizeof(JSAMPLE)) != 0)
|
||||
out_of_memory(cinfo, 5); /* safety check */
|
||||
samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) / SIZEOF(JSAMPLE));
|
||||
samplesperrow = (JDIMENSION)round_up_pow2(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));
|
||||
ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
|
||||
((long) samplesperrow * sizeof(JSAMPLE));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
if (ltemp < (long) numrows)
|
||||
@@ -444,7 +443,7 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JSAMPARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * SIZEOF(JSAMPROW)));
|
||||
(size_t) (numrows * sizeof(JSAMPROW)));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
@@ -452,7 +451,7 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JSAMPROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow
|
||||
* SIZEOF(JSAMPLE)));
|
||||
* sizeof(JSAMPLE)));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += samplesperrow;
|
||||
@@ -480,12 +479,12 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
long ltemp;
|
||||
|
||||
/* Make sure each row is properly aligned */
|
||||
if ((SIZEOF(JBLOCK) % ALIGN_SIZE) != 0)
|
||||
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));
|
||||
ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
|
||||
((long) blocksperrow * sizeof(JBLOCK));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
if (ltemp < (long) numrows)
|
||||
@@ -496,7 +495,7 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * SIZEOF(JBLOCKROW)));
|
||||
(size_t) (numrows * sizeof(JBLOCKROW)));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
@@ -504,7 +503,7 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow
|
||||
* SIZEOF(JBLOCK)));
|
||||
* sizeof(JBLOCK)));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += blocksperrow;
|
||||
@@ -567,7 +566,7 @@ request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
|
||||
/* get control block */
|
||||
result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id,
|
||||
SIZEOF(struct jvirt_sarray_control));
|
||||
sizeof(struct jvirt_sarray_control));
|
||||
|
||||
result->mem_buffer = NULL; /* marks array not yet realized */
|
||||
result->rows_in_array = numrows;
|
||||
@@ -597,7 +596,7 @@ request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
|
||||
/* get control block */
|
||||
result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id,
|
||||
SIZEOF(struct jvirt_barray_control));
|
||||
sizeof(struct jvirt_barray_control));
|
||||
|
||||
result->mem_buffer = NULL; /* marks array not yet realized */
|
||||
result->rows_in_array = numrows;
|
||||
@@ -631,17 +630,17 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
space_per_minheight += (long) sptr->maxaccess *
|
||||
(long) sptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
maximum_space += (long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
}
|
||||
}
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
space_per_minheight += (long) bptr->maxaccess *
|
||||
(long) bptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
maximum_space += (long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,7 +680,7 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
jpeg_open_backing_store(cinfo, & sptr->b_s_info,
|
||||
(long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow *
|
||||
(long) SIZEOF(JSAMPLE));
|
||||
(long) sizeof(JSAMPLE));
|
||||
sptr->b_s_open = TRUE;
|
||||
}
|
||||
sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,
|
||||
@@ -705,7 +704,7 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
jpeg_open_backing_store(cinfo, & bptr->b_s_info,
|
||||
(long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow *
|
||||
(long) SIZEOF(JBLOCK));
|
||||
(long) sizeof(JBLOCK));
|
||||
bptr->b_s_open = TRUE;
|
||||
}
|
||||
bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,
|
||||
@@ -725,7 +724,7 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
{
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
bytesperrow = (long) ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
@@ -741,11 +740,11 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
byte_count = rows * bytesperrow;
|
||||
if (writing)
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void FAR *) ptr->mem_buffer[i],
|
||||
(void *) ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
else
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void FAR *) ptr->mem_buffer[i],
|
||||
(void *) ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
file_offset += byte_count;
|
||||
}
|
||||
@@ -758,7 +757,7 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
{
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
bytesperrow = (long) ptr->blocksperrow * sizeof(JBLOCK);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
@@ -774,11 +773,11 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
byte_count = rows * bytesperrow;
|
||||
if (writing)
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void FAR *) ptr->mem_buffer[i],
|
||||
(void *) ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
else
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void FAR *) ptr->mem_buffer[i],
|
||||
(void *) ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
file_offset += byte_count;
|
||||
}
|
||||
@@ -850,11 +849,11 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
if (writable)
|
||||
ptr->first_undef_row = end_row;
|
||||
if (ptr->pre_zero) {
|
||||
size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
size_t bytesperrow = (size_t) ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
|
||||
end_row -= ptr->cur_start_row;
|
||||
while (undef_row < end_row) {
|
||||
jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
jzero_far((void *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
undef_row++;
|
||||
}
|
||||
} else {
|
||||
@@ -935,11 +934,11 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
if (writable)
|
||||
ptr->first_undef_row = end_row;
|
||||
if (ptr->pre_zero) {
|
||||
size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
size_t bytesperrow = (size_t) ptr->blocksperrow * sizeof(JBLOCK);
|
||||
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
|
||||
end_row -= ptr->cur_start_row;
|
||||
while (undef_row < end_row) {
|
||||
jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
jzero_far((void *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
undef_row++;
|
||||
}
|
||||
} else {
|
||||
@@ -1004,8 +1003,8 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
||||
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);
|
||||
sizeof(large_pool_hdr);
|
||||
jpeg_free_large(cinfo, (void *) lhdr_ptr, space_freed);
|
||||
mem->total_space_allocated -= space_freed;
|
||||
lhdr_ptr = next_lhdr_ptr;
|
||||
}
|
||||
@@ -1018,7 +1017,7 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
||||
small_pool_ptr next_shdr_ptr = shdr_ptr->next;
|
||||
space_freed = shdr_ptr->bytes_used +
|
||||
shdr_ptr->bytes_left +
|
||||
SIZEOF(small_pool_hdr);
|
||||
sizeof(small_pool_hdr);
|
||||
jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed);
|
||||
mem->total_space_allocated -= space_freed;
|
||||
shdr_ptr = next_shdr_ptr;
|
||||
@@ -1045,7 +1044,7 @@ self_destruct (j_common_ptr cinfo)
|
||||
}
|
||||
|
||||
/* Release the memory manager control block too. */
|
||||
jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr));
|
||||
jpeg_free_small(cinfo, (void *) cinfo->mem, sizeof(my_memory_mgr));
|
||||
cinfo->mem = NULL; /* ensures I will be called only once */
|
||||
|
||||
jpeg_mem_term(cinfo); /* system-dependent cleanup */
|
||||
@@ -1068,7 +1067,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
cinfo->mem = NULL; /* for safety if init fails */
|
||||
|
||||
/* Check for configuration errors.
|
||||
* SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably
|
||||
* 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.
|
||||
@@ -1089,7 +1088,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
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));
|
||||
mem = (my_mem_ptr) jpeg_get_small(cinfo, sizeof(my_memory_mgr));
|
||||
|
||||
if (mem == NULL) {
|
||||
jpeg_mem_term(cinfo); /* system-dependent cleanup */
|
||||
@@ -1122,7 +1121,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
mem->virt_sarray_list = NULL;
|
||||
mem->virt_barray_list = NULL;
|
||||
|
||||
mem->total_space_allocated = SIZEOF(my_memory_mgr);
|
||||
mem->total_space_allocated = sizeof(my_memory_mgr);
|
||||
|
||||
/* Declare ourselves open for business */
|
||||
cinfo->mem = & mem->pub;
|
||||
|
||||
17
jmemnobs.c
17
jmemnobs.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jmemnobs.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1992-1996, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file provides a really simple implementation of the system-
|
||||
@@ -21,8 +23,8 @@
|
||||
#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));
|
||||
extern void * malloc (size_t size);
|
||||
extern void free (void *ptr);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -46,19 +48,16 @@ jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
|
||||
|
||||
/*
|
||||
* "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 *)
|
||||
GLOBAL(void *)
|
||||
jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
|
||||
{
|
||||
return (void FAR *) malloc(sizeofobject);
|
||||
return (void *) malloc(sizeofobject);
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
|
||||
jpeg_free_large (j_common_ptr cinfo, void * object, size_t sizeofobject)
|
||||
{
|
||||
free(object);
|
||||
}
|
||||
|
||||
77
jmemsys.h
77
jmemsys.h
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jmemsys.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1992-1997, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This include file defines the interface between the system-independent
|
||||
@@ -14,25 +16,10 @@
|
||||
* in the IJG distribution. You may need to modify it if you write a
|
||||
* custom memory manager. If system-dependent changes are needed in
|
||||
* this file, the best method is to #ifdef them based on a configuration
|
||||
* symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR
|
||||
* and USE_MAC_MEMMGR.
|
||||
* symbol supplied in jconfig.h.
|
||||
*/
|
||||
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||
|
||||
#ifdef NEED_SHORT_EXTERNAL_NAMES
|
||||
#define jpeg_get_small jGetSmall
|
||||
#define jpeg_free_small jFreeSmall
|
||||
#define jpeg_get_large jGetLarge
|
||||
#define jpeg_free_large jFreeLarge
|
||||
#define jpeg_mem_available jMemAvail
|
||||
#define jpeg_open_backing_store jOpenBackStore
|
||||
#define jpeg_mem_init jMemInit
|
||||
#define jpeg_mem_term jMemTerm
|
||||
#endif /* NEED_SHORT_EXTERNAL_NAMES */
|
||||
|
||||
|
||||
/*
|
||||
* These two functions are used to allocate and release small chunks of
|
||||
* memory. (Typically the total amount requested through jpeg_get_small is
|
||||
@@ -41,34 +28,30 @@
|
||||
* and free; in particular, jpeg_get_small must return NULL on failure.
|
||||
* On most systems, these ARE malloc and free. jpeg_free_small is passed the
|
||||
* size of the object being freed, just in case it's needed.
|
||||
* On an 80x86 machine using small-data memory model, these manage near heap.
|
||||
*/
|
||||
|
||||
EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject));
|
||||
EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object,
|
||||
size_t sizeofobject));
|
||||
EXTERN(void *) jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject);
|
||||
EXTERN(void) jpeg_free_small (j_common_ptr cinfo, void * object,
|
||||
size_t sizeofobject);
|
||||
|
||||
/*
|
||||
* These two functions are used to allocate and release large chunks of
|
||||
* memory (up to the total free space designated by jpeg_mem_available).
|
||||
* The interface is the same as above, except that on an 80x86 machine,
|
||||
* far pointers are used. On most other machines these are identical to
|
||||
* the jpeg_get/free_small routines; but we keep them separate anyway,
|
||||
* in case a different allocation strategy is desirable for large chunks.
|
||||
* These are identical to the jpeg_get/free_small routines; but we keep them
|
||||
* separate anyway, in case a different allocation strategy is desirable for
|
||||
* large chunks.
|
||||
*/
|
||||
|
||||
EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo,
|
||||
size_t sizeofobject));
|
||||
EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object,
|
||||
size_t sizeofobject));
|
||||
EXTERN(void *) jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject);
|
||||
EXTERN(void) jpeg_free_large (j_common_ptr cinfo, void * object,
|
||||
size_t sizeofobject);
|
||||
|
||||
/*
|
||||
* The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may
|
||||
* be requested in a single call to jpeg_get_large (and jpeg_get_small for that
|
||||
* matter, but that case should never come into play). This macro is needed
|
||||
* matter, but that case should never come into play). This macro was needed
|
||||
* to model the 64Kb-segment-size limit of far addressing on 80x86 machines.
|
||||
* On those machines, we expect that jconfig.h will provide a proper value.
|
||||
* On machines with 32-bit flat address spaces, any large constant may be used.
|
||||
* On machines with flat address spaces, any large constant may be used.
|
||||
*
|
||||
* NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type
|
||||
* size_t and will be a multiple of sizeof(align_type).
|
||||
@@ -100,10 +83,9 @@ EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object,
|
||||
* Conversely, zero may be returned to always use the minimum amount of memory.
|
||||
*/
|
||||
|
||||
EXTERN(size_t) jpeg_mem_available JPP((j_common_ptr cinfo,
|
||||
size_t min_bytes_needed,
|
||||
EXTERN(size_t) jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
|
||||
size_t max_bytes_needed,
|
||||
size_t already_allocated));
|
||||
size_t already_allocated);
|
||||
|
||||
|
||||
/*
|
||||
@@ -138,16 +120,13 @@ typedef struct backing_store_struct * backing_store_ptr;
|
||||
|
||||
typedef struct backing_store_struct {
|
||||
/* Methods for reading/writing/closing this backing-store object */
|
||||
JMETHOD(void, read_backing_store, (j_common_ptr cinfo,
|
||||
backing_store_ptr info,
|
||||
void FAR * buffer_address,
|
||||
long file_offset, long byte_count));
|
||||
JMETHOD(void, write_backing_store, (j_common_ptr cinfo,
|
||||
backing_store_ptr info,
|
||||
void FAR * buffer_address,
|
||||
long file_offset, long byte_count));
|
||||
JMETHOD(void, close_backing_store, (j_common_ptr cinfo,
|
||||
backing_store_ptr info));
|
||||
void (*read_backing_store) (j_common_ptr cinfo, backing_store_ptr info,
|
||||
void * buffer_address, long file_offset,
|
||||
long byte_count);
|
||||
void (*write_backing_store) (j_common_ptr cinfo, backing_store_ptr info,
|
||||
void * buffer_address, long file_offset,
|
||||
long byte_count);
|
||||
void (*close_backing_store) (j_common_ptr cinfo, backing_store_ptr info);
|
||||
|
||||
/* Private fields for system-dependent backing-store management */
|
||||
#ifdef USE_MSDOS_MEMMGR
|
||||
@@ -177,9 +156,9 @@ typedef struct backing_store_struct {
|
||||
* just take an error exit.)
|
||||
*/
|
||||
|
||||
EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo,
|
||||
EXTERN(void) jpeg_open_backing_store (j_common_ptr cinfo,
|
||||
backing_store_ptr info,
|
||||
long total_bytes_needed));
|
||||
long total_bytes_needed);
|
||||
|
||||
|
||||
/*
|
||||
@@ -194,5 +173,5 @@ EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo,
|
||||
* all opened backing-store objects have been closed.
|
||||
*/
|
||||
|
||||
EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo));
|
||||
EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo));
|
||||
EXTERN(long) jpeg_mem_init (j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_mem_term (j_common_ptr cinfo);
|
||||
|
||||
84
jmorecfg.h
84
jmorecfg.h
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modifications:
|
||||
* Copyright (C) 2009, 2011, D. R. Commander.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, 2011, 2014, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains additional configuration options that customize the
|
||||
@@ -192,35 +192,6 @@ typedef unsigned int JDIMENSION;
|
||||
#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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
|
||||
#else
|
||||
#define JMETHOD(type,methodname,arglist) type (*methodname) ()
|
||||
#endif
|
||||
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifdef NEED_FAR_POINTERS
|
||||
#ifndef FAR
|
||||
#define FAR far
|
||||
#endif
|
||||
#else
|
||||
#undef FAR
|
||||
#define FAR
|
||||
#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-
|
||||
@@ -298,18 +269,24 @@ typedef int boolean;
|
||||
|
||||
|
||||
/*
|
||||
* 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
|
||||
* (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
|
||||
* the offsets will also change the order in which colormap data is organized.
|
||||
* RESTRICTIONS:
|
||||
* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
|
||||
* 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
|
||||
* useful if you are using JPEG color spaces other than YCbCr or grayscale.
|
||||
* 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
|
||||
* is not 3 (they don't understand about dummy color components!). So you
|
||||
* can't use color quantization if you change that value.
|
||||
* The RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros are a vestigial
|
||||
* feature of libjpeg. The idea was that, if an application developer needed
|
||||
* to compress from/decompress to a BGR/BGRX/RGBX/XBGR/XRGB buffer, they could
|
||||
* change these macros, rebuild libjpeg, and link their application statically
|
||||
* with it. In reality, few people ever did this, because there were some
|
||||
* severe restrictions involved (cjpeg and djpeg no longer worked properly,
|
||||
* compressing/decompressing RGB JPEGs no longer worked properly, and the color
|
||||
* quantizer wouldn't work with pixel sizes other than 3.) Further, since all
|
||||
* of the O/S-supplied versions of libjpeg were built with the default values
|
||||
* of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications have
|
||||
* come to regard these values as immutable.
|
||||
*
|
||||
* The libjpeg-turbo colorspace extensions provide a much cleaner way of
|
||||
* compressing from/decompressing to buffers with arbitrary component orders
|
||||
* and pixel sizes. Thus, we do not support changing the values of RGB_RED,
|
||||
* RGB_GREEN, RGB_BLUE, or RGB_PIXELSIZE. In addition to the restrictions
|
||||
* listed above, changing these values will also break the SIMD extensions and
|
||||
* the regression tests.
|
||||
*/
|
||||
|
||||
#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
|
||||
@@ -317,7 +294,7 @@ typedef int boolean;
|
||||
#define RGB_BLUE 2 /* Offset of Blue */
|
||||
#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
|
||||
|
||||
#define JPEG_NUMCS 16
|
||||
#define JPEG_NUMCS 17
|
||||
|
||||
#define EXT_RGB_RED 0
|
||||
#define EXT_RGB_GREEN 1
|
||||
@@ -352,25 +329,29 @@ typedef int boolean;
|
||||
static const int rgb_red[JPEG_NUMCS] = {
|
||||
-1, -1, RGB_RED, -1, -1, -1, EXT_RGB_RED, EXT_RGBX_RED,
|
||||
EXT_BGR_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
|
||||
EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED
|
||||
EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int rgb_green[JPEG_NUMCS] = {
|
||||
-1, -1, RGB_GREEN, -1, -1, -1, EXT_RGB_GREEN, EXT_RGBX_GREEN,
|
||||
EXT_BGR_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
|
||||
EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN
|
||||
EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int rgb_blue[JPEG_NUMCS] = {
|
||||
-1, -1, RGB_BLUE, -1, -1, -1, EXT_RGB_BLUE, EXT_RGBX_BLUE,
|
||||
EXT_BGR_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
|
||||
EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE
|
||||
EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int rgb_pixelsize[JPEG_NUMCS] = {
|
||||
-1, -1, RGB_PIXELSIZE, -1, -1, -1, EXT_RGB_PIXELSIZE, EXT_RGBX_PIXELSIZE,
|
||||
EXT_BGR_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
|
||||
EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE
|
||||
EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
|
||||
-1
|
||||
};
|
||||
|
||||
/* Definitions for speed-related optimizations. */
|
||||
@@ -392,17 +373,10 @@ static const int rgb_pixelsize[JPEG_NUMCS] = {
|
||||
/* 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).
|
||||
* The code below therefore chooses float if we have ANSI-style prototypes.
|
||||
*/
|
||||
|
||||
#ifndef FAST_FLOAT
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
#define FAST_FLOAT float
|
||||
#else
|
||||
#define FAST_FLOAT double
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* JPEG_INTERNAL_OPTIONS */
|
||||
|
||||
290
jpegint.h
290
jpegint.h
@@ -1,11 +1,13 @@
|
||||
/*
|
||||
* jpegint.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
* 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 common declarations for the various JPEG modules.
|
||||
@@ -48,9 +50,9 @@ typedef enum { /* Operating modes for buffer controllers */
|
||||
|
||||
/* Master control module */
|
||||
struct jpeg_comp_master {
|
||||
JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo));
|
||||
JMETHOD(void, pass_startup, (j_compress_ptr cinfo));
|
||||
JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
|
||||
void (*prepare_for_pass) (j_compress_ptr cinfo);
|
||||
void (*pass_startup) (j_compress_ptr cinfo);
|
||||
void (*finish_pass) (j_compress_ptr cinfo);
|
||||
|
||||
/* State variables made visible to other modules */
|
||||
boolean call_pass_startup; /* True if pass_startup must be called */
|
||||
@@ -59,80 +61,74 @@ struct jpeg_comp_master {
|
||||
|
||||
/* Main buffer control (downsampled-data buffer) */
|
||||
struct jpeg_c_main_controller {
|
||||
JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
|
||||
JMETHOD(void, process_data, (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail));
|
||||
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
|
||||
void (*process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail);
|
||||
};
|
||||
|
||||
/* Compression preprocessing (downsampling input buffer control) */
|
||||
struct jpeg_c_prep_controller {
|
||||
JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
|
||||
JMETHOD(void, pre_process_data, (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail,
|
||||
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
|
||||
void (*pre_process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
|
||||
JSAMPIMAGE output_buf,
|
||||
JDIMENSION *out_row_group_ctr,
|
||||
JDIMENSION out_row_groups_avail));
|
||||
JDIMENSION out_row_groups_avail);
|
||||
};
|
||||
|
||||
/* Coefficient buffer control */
|
||||
struct jpeg_c_coef_controller {
|
||||
JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
|
||||
JMETHOD(boolean, compress_data, (j_compress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf));
|
||||
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
|
||||
boolean (*compress_data) (j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
};
|
||||
|
||||
/* Colorspace conversion */
|
||||
struct jpeg_color_converter {
|
||||
JMETHOD(void, start_pass, (j_compress_ptr cinfo));
|
||||
JMETHOD(void, color_convert, (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows));
|
||||
void (*start_pass) (j_compress_ptr cinfo);
|
||||
void (*color_convert) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows);
|
||||
};
|
||||
|
||||
/* Downsampling */
|
||||
struct jpeg_downsampler {
|
||||
JMETHOD(void, start_pass, (j_compress_ptr cinfo));
|
||||
JMETHOD(void, downsample, (j_compress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_index,
|
||||
JSAMPIMAGE output_buf,
|
||||
JDIMENSION out_row_group_index));
|
||||
void (*start_pass) (j_compress_ptr cinfo);
|
||||
void (*downsample) (j_compress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_index, JSAMPIMAGE output_buf,
|
||||
JDIMENSION out_row_group_index);
|
||||
|
||||
boolean need_context_rows; /* TRUE if need rows above & below */
|
||||
};
|
||||
|
||||
/* Forward DCT (also controls coefficient quantization) */
|
||||
struct jpeg_forward_dct {
|
||||
JMETHOD(void, start_pass, (j_compress_ptr cinfo));
|
||||
void (*start_pass) (j_compress_ptr cinfo);
|
||||
/* perhaps this should be an array??? */
|
||||
JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
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, JBLOCKROW dst));
|
||||
JDIMENSION num_blocks, JBLOCKROW dst);
|
||||
};
|
||||
|
||||
/* Entropy encoding */
|
||||
struct jpeg_entropy_encoder {
|
||||
JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));
|
||||
JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data));
|
||||
JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
|
||||
void (*start_pass) (j_compress_ptr cinfo, boolean gather_statistics);
|
||||
boolean (*encode_mcu) (j_compress_ptr cinfo, JBLOCKROW *MCU_data);
|
||||
void (*finish_pass) (j_compress_ptr cinfo);
|
||||
};
|
||||
|
||||
/* Marker writing */
|
||||
struct jpeg_marker_writer {
|
||||
JMETHOD(void, write_file_header, (j_compress_ptr cinfo));
|
||||
JMETHOD(void, write_frame_header, (j_compress_ptr cinfo));
|
||||
JMETHOD(void, write_scan_header, (j_compress_ptr cinfo));
|
||||
JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo));
|
||||
JMETHOD(void, write_tables_only, (j_compress_ptr cinfo));
|
||||
void (*write_file_header) (j_compress_ptr cinfo);
|
||||
void (*write_frame_header) (j_compress_ptr cinfo);
|
||||
void (*write_scan_header) (j_compress_ptr cinfo);
|
||||
void (*write_file_trailer) (j_compress_ptr cinfo);
|
||||
void (*write_tables_only) (j_compress_ptr cinfo);
|
||||
/* These routines are exported to allow insertion of extra markers */
|
||||
/* Probably only COM and APPn markers should be written this way */
|
||||
JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker,
|
||||
unsigned int datalen));
|
||||
JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val));
|
||||
void (*write_marker_header) (j_compress_ptr cinfo, int marker,
|
||||
unsigned int datalen);
|
||||
void (*write_marker_byte) (j_compress_ptr cinfo, int val);
|
||||
};
|
||||
|
||||
|
||||
@@ -140,8 +136,8 @@ struct jpeg_marker_writer {
|
||||
|
||||
/* Master control module */
|
||||
struct jpeg_decomp_master {
|
||||
JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));
|
||||
JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));
|
||||
void (*prepare_for_output_pass) (j_decompress_ptr cinfo);
|
||||
void (*finish_output_pass) (j_decompress_ptr cinfo);
|
||||
|
||||
/* State variables made visible to other modules */
|
||||
boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */
|
||||
@@ -149,10 +145,10 @@ struct jpeg_decomp_master {
|
||||
|
||||
/* Input control module */
|
||||
struct jpeg_input_controller {
|
||||
JMETHOD(int, consume_input, (j_decompress_ptr cinfo));
|
||||
JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo));
|
||||
JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
|
||||
JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo));
|
||||
int (*consume_input) (j_decompress_ptr cinfo);
|
||||
void (*reset_input_controller) (j_decompress_ptr cinfo);
|
||||
void (*start_input_pass) (j_decompress_ptr cinfo);
|
||||
void (*finish_input_pass) (j_decompress_ptr cinfo);
|
||||
|
||||
/* State variables made visible to other modules */
|
||||
boolean has_multiple_scans; /* True if file has multiple scans */
|
||||
@@ -161,43 +157,39 @@ struct jpeg_input_controller {
|
||||
|
||||
/* Main buffer control (downsampled-data buffer) */
|
||||
struct jpeg_d_main_controller {
|
||||
JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
|
||||
JMETHOD(void, process_data, (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail));
|
||||
void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
|
||||
void (*process_data) (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
};
|
||||
|
||||
/* Coefficient buffer control */
|
||||
struct jpeg_d_coef_controller {
|
||||
JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
|
||||
JMETHOD(int, consume_data, (j_decompress_ptr cinfo));
|
||||
JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo));
|
||||
JMETHOD(int, decompress_data, (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE output_buf));
|
||||
void (*start_input_pass) (j_decompress_ptr cinfo);
|
||||
int (*consume_data) (j_decompress_ptr cinfo);
|
||||
void (*start_output_pass) (j_decompress_ptr cinfo);
|
||||
int (*decompress_data) (j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
/* Pointer to array of coefficient virtual arrays, or NULL if none */
|
||||
jvirt_barray_ptr *coef_arrays;
|
||||
};
|
||||
|
||||
/* Decompression postprocessing (color quantization buffer control) */
|
||||
struct jpeg_d_post_controller {
|
||||
JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
|
||||
JMETHOD(void, post_process_data, (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
|
||||
void (*post_process_data) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail));
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
};
|
||||
|
||||
/* Marker reading & parsing */
|
||||
struct jpeg_marker_reader {
|
||||
JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo));
|
||||
void (*reset_marker_reader) (j_decompress_ptr cinfo);
|
||||
/* Read markers until SOS or EOI.
|
||||
* Returns same codes as are defined for jpeg_consume_input:
|
||||
* JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
|
||||
*/
|
||||
JMETHOD(int, read_markers, (j_decompress_ptr cinfo));
|
||||
int (*read_markers) (j_decompress_ptr cinfo);
|
||||
/* Read a restart marker --- exported for use by entropy decoder only */
|
||||
jpeg_marker_parser_method read_restart_marker;
|
||||
|
||||
@@ -212,9 +204,8 @@ struct jpeg_marker_reader {
|
||||
|
||||
/* Entropy decoding */
|
||||
struct jpeg_entropy_decoder {
|
||||
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
|
||||
JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data));
|
||||
void (*start_pass) (j_decompress_ptr cinfo);
|
||||
boolean (*decode_mcu) (j_decompress_ptr cinfo, JBLOCKROW *MCU_data);
|
||||
|
||||
/* This is here to share code between baseline and progressive decoders; */
|
||||
/* other modules probably should not use it */
|
||||
@@ -222,47 +213,44 @@ struct jpeg_entropy_decoder {
|
||||
};
|
||||
|
||||
/* Inverse DCT (also performs dequantization) */
|
||||
typedef JMETHOD(void, inverse_DCT_method_ptr,
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
typedef void (*inverse_DCT_method_ptr) (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col));
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
|
||||
struct jpeg_inverse_dct {
|
||||
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
|
||||
void (*start_pass) (j_decompress_ptr cinfo);
|
||||
/* It is useful to allow each component to have a separate IDCT method. */
|
||||
inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
|
||||
};
|
||||
|
||||
/* Upsampling (note that upsampler must also call color converter) */
|
||||
struct jpeg_upsampler {
|
||||
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
|
||||
JMETHOD(void, upsample, (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
void (*start_pass) (j_decompress_ptr cinfo);
|
||||
void (*upsample) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail));
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
|
||||
boolean need_context_rows; /* TRUE if need rows above & below */
|
||||
};
|
||||
|
||||
/* Colorspace conversion */
|
||||
struct jpeg_color_deconverter {
|
||||
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
|
||||
JMETHOD(void, color_convert, (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows));
|
||||
void (*start_pass) (j_decompress_ptr cinfo);
|
||||
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows);
|
||||
};
|
||||
|
||||
/* Color quantization or color precision reduction */
|
||||
struct jpeg_color_quantizer {
|
||||
JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));
|
||||
JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPARRAY output_buf,
|
||||
int num_rows));
|
||||
JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
|
||||
JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
|
||||
void (*start_pass) (j_decompress_ptr cinfo, boolean is_pre_scan);
|
||||
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows);
|
||||
void (*finish_pass) (j_decompress_ptr cinfo);
|
||||
void (*new_color_map) (j_decompress_ptr cinfo);
|
||||
};
|
||||
|
||||
|
||||
@@ -296,96 +284,54 @@ struct jpeg_color_quantizer {
|
||||
#endif
|
||||
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||
|
||||
#ifdef NEED_SHORT_EXTERNAL_NAMES
|
||||
#define jinit_compress_master jICompress
|
||||
#define jinit_c_master_control jICMaster
|
||||
#define jinit_c_main_controller jICMainC
|
||||
#define jinit_c_prep_controller jICPrepC
|
||||
#define jinit_c_coef_controller jICCoefC
|
||||
#define jinit_color_converter jICColor
|
||||
#define jinit_downsampler jIDownsampler
|
||||
#define jinit_forward_dct jIFDCT
|
||||
#define jinit_huff_encoder jIHEncoder
|
||||
#define jinit_phuff_encoder jIPHEncoder
|
||||
#define jinit_arith_encoder jIAEncoder
|
||||
#define jinit_marker_writer jIMWriter
|
||||
#define jinit_master_decompress jIDMaster
|
||||
#define jinit_d_main_controller jIDMainC
|
||||
#define jinit_d_coef_controller jIDCoefC
|
||||
#define jinit_d_post_controller jIDPostC
|
||||
#define jinit_input_controller jIInCtlr
|
||||
#define jinit_marker_reader jIMReader
|
||||
#define jinit_huff_decoder jIHDecoder
|
||||
#define jinit_phuff_decoder jIPHDecoder
|
||||
#define jinit_arith_decoder jIADecoder
|
||||
#define jinit_inverse_dct jIIDCT
|
||||
#define jinit_upsampler jIUpsampler
|
||||
#define jinit_color_deconverter jIDColor
|
||||
#define jinit_1pass_quantizer jI1Quant
|
||||
#define jinit_2pass_quantizer jI2Quant
|
||||
#define jinit_merged_upsampler jIMUpsampler
|
||||
#define jinit_memory_mgr jIMemMgr
|
||||
#define jdiv_round_up jDivRound
|
||||
#define jround_up jRound
|
||||
#define jcopy_sample_rows jCopySamples
|
||||
#define jcopy_block_row jCopyBlocks
|
||||
#define jzero_far jZeroFar
|
||||
#define jpeg_zigzag_order jZIGTable
|
||||
#define jpeg_natural_order jZAGTable
|
||||
#define jpeg_aritab jAriTab
|
||||
#endif /* NEED_SHORT_EXTERNAL_NAMES */
|
||||
|
||||
|
||||
/* Compression module initialization routines */
|
||||
EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
|
||||
boolean transcode_only));
|
||||
EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo,
|
||||
boolean need_full_buffer));
|
||||
EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo,
|
||||
boolean need_full_buffer));
|
||||
EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo,
|
||||
boolean need_full_buffer));
|
||||
EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jinit_arith_encoder JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jinit_compress_master (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_c_master_control (j_compress_ptr cinfo,
|
||||
boolean transcode_only);
|
||||
EXTERN(void) jinit_c_main_controller (j_compress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_c_prep_controller (j_compress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_c_coef_controller (j_compress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_color_converter (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_downsampler (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_forward_dct (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_huff_encoder (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_phuff_encoder (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_arith_encoder (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_marker_writer (j_compress_ptr cinfo);
|
||||
/* Decompression module initialization routines */
|
||||
EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer));
|
||||
EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer));
|
||||
EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer));
|
||||
EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jinit_arith_decoder JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo));
|
||||
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));
|
||||
EXTERN(void) jinit_master_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_d_main_controller (j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_d_coef_controller (j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_d_post_controller (j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_input_controller (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_marker_reader (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_huff_decoder (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_phuff_decoder (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_arith_decoder (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_inverse_dct (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_upsampler (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_color_deconverter (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_1pass_quantizer (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_2pass_quantizer (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_merged_upsampler (j_decompress_ptr cinfo);
|
||||
/* Memory manager initialization */
|
||||
EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
|
||||
EXTERN(void) jinit_memory_mgr (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(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
|
||||
EXTERN(long) jdiv_round_up (long a, long b);
|
||||
EXTERN(long) jround_up (long a, long b);
|
||||
EXTERN(void) jcopy_sample_rows (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));
|
||||
int num_rows, JDIMENSION num_cols);
|
||||
EXTERN(void) jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
JDIMENSION num_blocks);
|
||||
EXTERN(void) jzero_far (void * target, size_t bytestozero);
|
||||
/* Constant tables in jutils.c */
|
||||
#if 0 /* This table is not actually needed in v6a */
|
||||
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
|
||||
|
||||
365
jpeglib.h
365
jpeglib.h
@@ -4,8 +4,8 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2002-2009 by Guido Vollbeding.
|
||||
* Modifications:
|
||||
* Copyright (C) 2009-2011, 2013, D. R. Commander.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009-2011, 2013-2014, D. R. Commander.
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
@@ -64,20 +64,18 @@ extern "C" {
|
||||
|
||||
|
||||
/* Data structures for images (arrays of samples and of DCT coefficients).
|
||||
* On 80x86 machines, the image arrays are too big for near pointers,
|
||||
* but the pointer arrays can fit in near memory.
|
||||
*/
|
||||
|
||||
typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */
|
||||
typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */
|
||||
typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
|
||||
typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
|
||||
|
||||
typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
|
||||
typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */
|
||||
typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */
|
||||
typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
|
||||
typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
|
||||
|
||||
typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */
|
||||
typedef JCOEF *JCOEFPTR; /* useful in a couple of places */
|
||||
|
||||
|
||||
/* Types for JPEG compression parameters and working tables. */
|
||||
@@ -146,8 +144,8 @@ typedef struct {
|
||||
/* Size of a DCT block in samples. Always DCTSIZE for compression.
|
||||
* For decompression this is the size of the output from one DCT block,
|
||||
* reflecting any scaling we choose to apply during the IDCT step.
|
||||
* Values of 1,2,4,8 are likely to be supported. Note that different
|
||||
* components may receive different IDCT scalings.
|
||||
* Values from 1 to 16 are supported.
|
||||
* Note that different components may receive different IDCT scalings.
|
||||
*/
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
int DCT_h_scaled_size;
|
||||
@@ -200,14 +198,14 @@ typedef struct {
|
||||
|
||||
/* The decompressor can save APPn and COM markers in a list of these: */
|
||||
|
||||
typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr;
|
||||
typedef struct jpeg_marker_struct * jpeg_saved_marker_ptr;
|
||||
|
||||
struct jpeg_marker_struct {
|
||||
jpeg_saved_marker_ptr next; /* next in list, or NULL */
|
||||
UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
|
||||
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 */
|
||||
JOCTET * data; /* the data contained in the marker */
|
||||
/* the marker length word is not counted in data_length or original_length */
|
||||
};
|
||||
|
||||
@@ -219,8 +217,8 @@ struct jpeg_marker_struct {
|
||||
typedef enum {
|
||||
JCS_UNKNOWN, /* error/unspecified */
|
||||
JCS_GRAYSCALE, /* monochrome */
|
||||
JCS_RGB, /* red/green/blue as specified by the RGB_RED, RGB_GREEN,
|
||||
RGB_BLUE, and RGB_PIXELSIZE macros */
|
||||
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 */
|
||||
@@ -230,17 +228,17 @@ typedef enum {
|
||||
JCS_EXT_BGRX, /* blue/green/red/x */
|
||||
JCS_EXT_XBGR, /* x/blue/green/red */
|
||||
JCS_EXT_XRGB, /* x/red/green/blue */
|
||||
/* When out_color_space it set to JCS_EXT_RGBX, JCS_EXT_BGRX,
|
||||
JCS_EXT_XBGR, or JCS_EXT_XRGB during decompression, the X byte is
|
||||
undefined, and in order to ensure the best performance,
|
||||
libjpeg-turbo can set that byte to whatever value it wishes. Use
|
||||
the following colorspace constants to ensure that the X byte is set
|
||||
to 0xFF, so that it can be interpreted as an opaque alpha
|
||||
channel. */
|
||||
/* When out_color_space it set to JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
|
||||
or JCS_EXT_XRGB during decompression, the X byte is undefined, and in
|
||||
order to ensure the best performance, libjpeg-turbo can set that byte to
|
||||
whatever value it wishes. Use the following colorspace constants to
|
||||
ensure that the X byte is set to 0xFF, so that it can be interpreted as an
|
||||
opaque alpha channel. */
|
||||
JCS_EXT_RGBA, /* red/green/blue/alpha */
|
||||
JCS_EXT_BGRA, /* blue/green/red/alpha */
|
||||
JCS_EXT_ABGR, /* alpha/blue/green/red */
|
||||
JCS_EXT_ARGB /* alpha/red/green/blue */
|
||||
JCS_EXT_ARGB, /* alpha/red/green/blue */
|
||||
JCS_RGB565 /* 5-bit red/6-bit green/5-bit blue */
|
||||
} J_COLOR_SPACE;
|
||||
|
||||
/* DCT/IDCT algorithm options. */
|
||||
@@ -749,16 +747,16 @@ struct jpeg_decompress_struct {
|
||||
|
||||
struct jpeg_error_mgr {
|
||||
/* Error exit handler: does not return to caller */
|
||||
JMETHOD(void, error_exit, (j_common_ptr cinfo));
|
||||
void (*error_exit) (j_common_ptr cinfo);
|
||||
/* Conditionally emit a trace or warning message */
|
||||
JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));
|
||||
void (*emit_message) (j_common_ptr cinfo, int msg_level);
|
||||
/* Routine that actually outputs a trace or error message */
|
||||
JMETHOD(void, output_message, (j_common_ptr cinfo));
|
||||
void (*output_message) (j_common_ptr cinfo);
|
||||
/* Format a message string for the most recent JPEG error or message */
|
||||
JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer));
|
||||
void (*format_message) (j_common_ptr cinfo, char * buffer);
|
||||
#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
|
||||
/* Reset error state variables at start of a new image */
|
||||
JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo));
|
||||
void (*reset_error_mgr) (j_common_ptr cinfo);
|
||||
|
||||
/* The message ID code and any parameters are saved here.
|
||||
* A message can have one string parameter or up to 8 int parameters.
|
||||
@@ -806,7 +804,7 @@ struct jpeg_error_mgr {
|
||||
/* Progress monitor object */
|
||||
|
||||
struct jpeg_progress_mgr {
|
||||
JMETHOD(void, progress_monitor, (j_common_ptr cinfo));
|
||||
void (*progress_monitor) (j_common_ptr cinfo);
|
||||
|
||||
long pass_counter; /* work units completed in this pass */
|
||||
long pass_limit; /* total number of work units in this pass */
|
||||
@@ -821,9 +819,9 @@ struct jpeg_destination_mgr {
|
||||
JOCTET * next_output_byte; /* => next byte to write in buffer */
|
||||
size_t free_in_buffer; /* # of byte spaces remaining in buffer */
|
||||
|
||||
JMETHOD(void, init_destination, (j_compress_ptr cinfo));
|
||||
JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo));
|
||||
JMETHOD(void, term_destination, (j_compress_ptr cinfo));
|
||||
void (*init_destination) (j_compress_ptr cinfo);
|
||||
boolean (*empty_output_buffer) (j_compress_ptr cinfo);
|
||||
void (*term_destination) (j_compress_ptr cinfo);
|
||||
};
|
||||
|
||||
|
||||
@@ -833,11 +831,11 @@ struct jpeg_source_mgr {
|
||||
const JOCTET * next_input_byte; /* => next byte to read from buffer */
|
||||
size_t bytes_in_buffer; /* # of bytes remaining in buffer */
|
||||
|
||||
JMETHOD(void, init_source, (j_decompress_ptr cinfo));
|
||||
JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo));
|
||||
JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes));
|
||||
JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired));
|
||||
JMETHOD(void, term_source, (j_decompress_ptr cinfo));
|
||||
void (*init_source) (j_decompress_ptr cinfo);
|
||||
boolean (*fill_input_buffer) (j_decompress_ptr cinfo);
|
||||
void (*skip_input_data) (j_decompress_ptr cinfo, long num_bytes);
|
||||
boolean (*resync_to_restart) (j_decompress_ptr cinfo, int desired);
|
||||
void (*term_source) (j_decompress_ptr cinfo);
|
||||
};
|
||||
|
||||
|
||||
@@ -862,41 +860,32 @@ typedef struct jvirt_barray_control * jvirt_barray_ptr;
|
||||
|
||||
struct jpeg_memory_mgr {
|
||||
/* Method pointers */
|
||||
JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id,
|
||||
size_t sizeofobject));
|
||||
JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id,
|
||||
size_t sizeofobject));
|
||||
JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id,
|
||||
JDIMENSION samplesperrow,
|
||||
JDIMENSION numrows));
|
||||
JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id,
|
||||
JDIMENSION blocksperrow,
|
||||
JDIMENSION numrows));
|
||||
JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo,
|
||||
int pool_id,
|
||||
void * (*alloc_small) (j_common_ptr cinfo, int pool_id, size_t sizeofobject);
|
||||
void * (*alloc_large) (j_common_ptr cinfo, int pool_id,
|
||||
size_t sizeofobject);
|
||||
JSAMPARRAY (*alloc_sarray) (j_common_ptr cinfo, int pool_id,
|
||||
JDIMENSION samplesperrow, JDIMENSION numrows);
|
||||
JBLOCKARRAY (*alloc_barray) (j_common_ptr cinfo, int pool_id,
|
||||
JDIMENSION blocksperrow, JDIMENSION numrows);
|
||||
jvirt_sarray_ptr (*request_virt_sarray) (j_common_ptr cinfo, int pool_id,
|
||||
boolean pre_zero,
|
||||
JDIMENSION samplesperrow,
|
||||
JDIMENSION numrows,
|
||||
JDIMENSION maxaccess));
|
||||
JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo,
|
||||
int pool_id,
|
||||
JDIMENSION maxaccess);
|
||||
jvirt_barray_ptr (*request_virt_barray) (j_common_ptr cinfo, int pool_id,
|
||||
boolean pre_zero,
|
||||
JDIMENSION blocksperrow,
|
||||
JDIMENSION numrows,
|
||||
JDIMENSION maxaccess));
|
||||
JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo));
|
||||
JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo,
|
||||
jvirt_sarray_ptr ptr,
|
||||
JDIMENSION start_row,
|
||||
JDIMENSION num_rows,
|
||||
boolean writable));
|
||||
JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo,
|
||||
jvirt_barray_ptr ptr,
|
||||
JDIMENSION start_row,
|
||||
JDIMENSION num_rows,
|
||||
boolean writable));
|
||||
JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id));
|
||||
JMETHOD(void, self_destruct, (j_common_ptr cinfo));
|
||||
JDIMENSION maxaccess);
|
||||
void (*realize_virt_arrays) (j_common_ptr cinfo);
|
||||
JSAMPARRAY (*access_virt_sarray) (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows,
|
||||
boolean writable);
|
||||
JBLOCKARRAY (*access_virt_barray) (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows,
|
||||
boolean writable);
|
||||
void (*free_pool) (j_common_ptr cinfo, int pool_id);
|
||||
void (*self_destruct) (j_common_ptr cinfo);
|
||||
|
||||
/* Limit on memory allocation for this JPEG object. (Note that this is
|
||||
* merely advisory, not a guaranteed maximum; it only affects the space
|
||||
@@ -913,96 +902,11 @@ struct jpeg_memory_mgr {
|
||||
/* Routine signature for application-supplied marker processing methods.
|
||||
* Need not pass marker code since it is stored in cinfo->unread_marker.
|
||||
*/
|
||||
typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
|
||||
|
||||
|
||||
/* Declarations for routines called by application.
|
||||
* The JPP macro hides prototype parameters from compilers that can't cope.
|
||||
* Note JPP requires double parentheses.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
#define JPP(arglist) arglist
|
||||
#else
|
||||
#define JPP(arglist) ()
|
||||
#endif
|
||||
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers.
|
||||
* We shorten external names to be unique in the first six letters, which
|
||||
* is good enough for all known systems.
|
||||
* (If your compiler itself needs names to be unique in less than 15
|
||||
* characters, you are out of luck. Get a better compiler.)
|
||||
*/
|
||||
|
||||
#ifdef NEED_SHORT_EXTERNAL_NAMES
|
||||
#define jpeg_std_error jStdError
|
||||
#define jpeg_CreateCompress jCreaCompress
|
||||
#define jpeg_CreateDecompress jCreaDecompress
|
||||
#define jpeg_destroy_compress jDestCompress
|
||||
#define jpeg_destroy_decompress jDestDecompress
|
||||
#define jpeg_stdio_dest jStdDest
|
||||
#define jpeg_stdio_src jStdSrc
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
#define jpeg_mem_dest jMemDest
|
||||
#define jpeg_mem_src jMemSrc
|
||||
#endif
|
||||
#define jpeg_set_defaults jSetDefaults
|
||||
#define jpeg_set_colorspace jSetColorspace
|
||||
#define jpeg_default_colorspace jDefColorspace
|
||||
#define jpeg_set_quality jSetQuality
|
||||
#define jpeg_set_linear_quality jSetLQuality
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
#define jpeg_default_qtables jDefQTables
|
||||
#endif
|
||||
#define jpeg_add_quant_table jAddQuantTable
|
||||
#define jpeg_quality_scaling jQualityScaling
|
||||
#define jpeg_simple_progression jSimProgress
|
||||
#define jpeg_suppress_tables jSuppressTables
|
||||
#define jpeg_alloc_quant_table jAlcQTable
|
||||
#define jpeg_alloc_huff_table jAlcHTable
|
||||
#define jpeg_start_compress jStrtCompress
|
||||
#define jpeg_write_scanlines jWrtScanlines
|
||||
#define jpeg_finish_compress jFinCompress
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
#define jpeg_calc_jpeg_dimensions jCjpegDimensions
|
||||
#endif
|
||||
#define jpeg_write_raw_data jWrtRawData
|
||||
#define jpeg_write_marker jWrtMarker
|
||||
#define jpeg_write_m_header jWrtMHeader
|
||||
#define jpeg_write_m_byte jWrtMByte
|
||||
#define jpeg_write_tables jWrtTables
|
||||
#define jpeg_read_header jReadHeader
|
||||
#define jpeg_start_decompress jStrtDecompress
|
||||
#define jpeg_read_scanlines jReadScanlines
|
||||
#define jpeg_finish_decompress jFinDecompress
|
||||
#define jpeg_read_raw_data jReadRawData
|
||||
#define jpeg_has_multiple_scans jHasMultScn
|
||||
#define jpeg_start_output jStrtOutput
|
||||
#define jpeg_finish_output jFinOutput
|
||||
#define jpeg_input_complete jInComplete
|
||||
#define jpeg_new_colormap jNewCMap
|
||||
#define jpeg_consume_input jConsumeInput
|
||||
#if JPEG_LIB_VERSION >= 80
|
||||
#define jpeg_core_output_dimensions jCoreDimensions
|
||||
#endif
|
||||
#define jpeg_calc_output_dimensions jCalcDimensions
|
||||
#define jpeg_save_markers jSaveMarkers
|
||||
#define jpeg_set_marker_processor jSetMarker
|
||||
#define jpeg_read_coefficients jReadCoefs
|
||||
#define jpeg_write_coefficients jWrtCoefs
|
||||
#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 */
|
||||
typedef boolean (*jpeg_marker_parser_method) (j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/* Default error-management setup */
|
||||
EXTERN(struct jpeg_error_mgr *) jpeg_std_error
|
||||
JPP((struct jpeg_error_mgr * err));
|
||||
EXTERN(struct jpeg_error_mgr *) jpeg_std_error (struct jpeg_error_mgr * err);
|
||||
|
||||
/* Initialization of JPEG compression objects.
|
||||
* jpeg_create_compress() and jpeg_create_decompress() are the exported
|
||||
@@ -1017,89 +921,80 @@ EXTERN(struct jpeg_error_mgr *) jpeg_std_error
|
||||
#define jpeg_create_decompress(cinfo) \
|
||||
jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
|
||||
(size_t) sizeof(struct jpeg_decompress_struct))
|
||||
EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo,
|
||||
int version, size_t structsize));
|
||||
EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo,
|
||||
int version, size_t structsize));
|
||||
EXTERN(void) jpeg_CreateCompress (j_compress_ptr cinfo, int version,
|
||||
size_t structsize);
|
||||
EXTERN(void) jpeg_CreateDecompress (j_decompress_ptr cinfo, int version,
|
||||
size_t structsize);
|
||||
/* Destruction of JPEG compression objects */
|
||||
EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jpeg_destroy_compress (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy_decompress (j_decompress_ptr cinfo);
|
||||
|
||||
/* Standard data source and destination managers: stdio streams. */
|
||||
/* Caller is responsible for opening the file before and closing after. */
|
||||
EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));
|
||||
EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
|
||||
EXTERN(void) jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile);
|
||||
EXTERN(void) jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile);
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
/* Data source and destination managers: memory buffers. */
|
||||
EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
|
||||
unsigned char ** outbuffer,
|
||||
unsigned long * outsize));
|
||||
EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
|
||||
unsigned char * inbuffer,
|
||||
unsigned long insize));
|
||||
EXTERN(void) jpeg_mem_dest (j_compress_ptr cinfo, unsigned char ** outbuffer,
|
||||
unsigned long * outsize);
|
||||
EXTERN(void) jpeg_mem_src (j_decompress_ptr cinfo, unsigned char * inbuffer,
|
||||
unsigned long insize);
|
||||
#endif
|
||||
|
||||
/* Default parameter setup for compression */
|
||||
EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jpeg_set_defaults (j_compress_ptr cinfo);
|
||||
/* Compression parameter setup aids */
|
||||
EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo,
|
||||
J_COLOR_SPACE colorspace));
|
||||
EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality,
|
||||
boolean force_baseline));
|
||||
EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo,
|
||||
int scale_factor,
|
||||
boolean force_baseline));
|
||||
EXTERN(void) jpeg_set_colorspace (j_compress_ptr cinfo,
|
||||
J_COLOR_SPACE colorspace);
|
||||
EXTERN(void) jpeg_default_colorspace (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_set_quality (j_compress_ptr cinfo, int quality,
|
||||
boolean force_baseline);
|
||||
EXTERN(void) jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||
boolean force_baseline);
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
EXTERN(void) jpeg_default_qtables JPP((j_compress_ptr cinfo,
|
||||
boolean force_baseline));
|
||||
EXTERN(void) jpeg_default_qtables (j_compress_ptr cinfo,
|
||||
boolean force_baseline);
|
||||
#endif
|
||||
EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,
|
||||
EXTERN(void) jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||
const unsigned int *basic_table,
|
||||
int scale_factor,
|
||||
boolean force_baseline));
|
||||
EXTERN(int) jpeg_quality_scaling JPP((int quality));
|
||||
EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo,
|
||||
boolean suppress));
|
||||
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo));
|
||||
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo));
|
||||
int scale_factor, boolean force_baseline);
|
||||
EXTERN(int) jpeg_quality_scaling (int quality);
|
||||
EXTERN(void) jpeg_simple_progression (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress);
|
||||
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table (j_common_ptr cinfo);
|
||||
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table (j_common_ptr cinfo);
|
||||
|
||||
/* Main entry points for compression */
|
||||
EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo,
|
||||
boolean write_all_tables));
|
||||
EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo,
|
||||
EXTERN(void) jpeg_start_compress (j_compress_ptr cinfo,
|
||||
boolean write_all_tables);
|
||||
EXTERN(JDIMENSION) jpeg_write_scanlines (j_compress_ptr cinfo,
|
||||
JSAMPARRAY scanlines,
|
||||
JDIMENSION num_lines));
|
||||
EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo));
|
||||
JDIMENSION num_lines);
|
||||
EXTERN(void) jpeg_finish_compress (j_compress_ptr cinfo);
|
||||
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
/* Precalculate JPEG dimensions for current compression parameters. */
|
||||
EXTERN(void) jpeg_calc_jpeg_dimensions JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo);
|
||||
#endif
|
||||
|
||||
/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
|
||||
EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo,
|
||||
JSAMPIMAGE data,
|
||||
JDIMENSION num_lines));
|
||||
EXTERN(JDIMENSION) jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
JDIMENSION num_lines);
|
||||
|
||||
/* Write a special marker. See libjpeg.txt concerning safe usage. */
|
||||
EXTERN(void) jpeg_write_marker
|
||||
JPP((j_compress_ptr cinfo, int marker,
|
||||
const JOCTET * dataptr, unsigned int datalen));
|
||||
EXTERN(void) jpeg_write_marker (j_compress_ptr cinfo, int marker,
|
||||
const JOCTET * dataptr, unsigned int datalen);
|
||||
/* Same, but piecemeal. */
|
||||
EXTERN(void) jpeg_write_m_header
|
||||
JPP((j_compress_ptr cinfo, int marker, unsigned int datalen));
|
||||
EXTERN(void) jpeg_write_m_byte
|
||||
JPP((j_compress_ptr cinfo, int val));
|
||||
EXTERN(void) jpeg_write_m_header (j_compress_ptr cinfo, int marker,
|
||||
unsigned int datalen);
|
||||
EXTERN(void) jpeg_write_m_byte (j_compress_ptr cinfo, int val);
|
||||
|
||||
/* Alternate compression function: just write an abbreviated table file */
|
||||
EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jpeg_write_tables (j_compress_ptr cinfo);
|
||||
|
||||
/* Decompression startup: read start of JPEG datastream to see what's there */
|
||||
EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo,
|
||||
boolean require_image));
|
||||
EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
|
||||
/* Return value is one of: */
|
||||
#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
|
||||
#define JPEG_HEADER_OK 1 /* Found valid image datastream */
|
||||
@@ -1111,25 +1006,23 @@ EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
/* Main entry points for decompression */
|
||||
EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo,
|
||||
EXTERN(boolean) jpeg_start_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(JDIMENSION) jpeg_read_scanlines (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY scanlines,
|
||||
JDIMENSION max_lines));
|
||||
EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo));
|
||||
JDIMENSION max_lines);
|
||||
EXTERN(boolean) jpeg_finish_decompress (j_decompress_ptr cinfo);
|
||||
|
||||
/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
|
||||
EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE data,
|
||||
JDIMENSION max_lines));
|
||||
EXTERN(JDIMENSION) jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
JDIMENSION max_lines);
|
||||
|
||||
/* Additional entry points for buffered-image mode. */
|
||||
EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo,
|
||||
int scan_number));
|
||||
EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(boolean) jpeg_has_multiple_scans (j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_start_output (j_decompress_ptr cinfo, int scan_number);
|
||||
EXTERN(boolean) jpeg_finish_output (j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_input_complete (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_new_colormap (j_decompress_ptr cinfo);
|
||||
EXTERN(int) jpeg_consume_input (j_decompress_ptr cinfo);
|
||||
/* Return value is one of: */
|
||||
/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
|
||||
#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
|
||||
@@ -1139,26 +1032,25 @@ EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo));
|
||||
|
||||
/* Precalculate output dimensions for current decompression parameters. */
|
||||
#if JPEG_LIB_VERSION >= 80
|
||||
EXTERN(void) jpeg_core_output_dimensions JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jpeg_core_output_dimensions (j_decompress_ptr cinfo);
|
||||
#endif
|
||||
EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jpeg_calc_output_dimensions (j_decompress_ptr cinfo);
|
||||
|
||||
/* Control saving of COM and APPn markers into marker_list. */
|
||||
EXTERN(void) jpeg_save_markers
|
||||
JPP((j_decompress_ptr cinfo, int marker_code,
|
||||
unsigned int length_limit));
|
||||
EXTERN(void) jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
unsigned int length_limit);
|
||||
|
||||
/* Install a special processing method for COM or APPn markers. */
|
||||
EXTERN(void) jpeg_set_marker_processor
|
||||
JPP((j_decompress_ptr cinfo, int marker_code,
|
||||
jpeg_marker_parser_method routine));
|
||||
EXTERN(void) jpeg_set_marker_processor (j_decompress_ptr cinfo,
|
||||
int marker_code,
|
||||
jpeg_marker_parser_method routine);
|
||||
|
||||
/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
|
||||
EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr * coef_arrays));
|
||||
EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo,
|
||||
j_compress_ptr dstinfo));
|
||||
EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_write_coefficients (j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr * coef_arrays);
|
||||
EXTERN(void) jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
j_compress_ptr dstinfo);
|
||||
|
||||
/* If you choose to abort compression or decompression before completing
|
||||
* jpeg_finish_(de)compress, then you need to clean up to release memory,
|
||||
@@ -1166,18 +1058,17 @@ EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo,
|
||||
* if you're done with the JPEG object, but if you want to clean it up and
|
||||
* reuse it, call this:
|
||||
*/
|
||||
EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo));
|
||||
EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo));
|
||||
EXTERN(void) jpeg_abort_compress (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_abort_decompress (j_decompress_ptr cinfo);
|
||||
|
||||
/* Generic versions of jpeg_abort and jpeg_destroy that work on either
|
||||
* flavor of JPEG object. These may be more convenient in some places.
|
||||
*/
|
||||
EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo));
|
||||
EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo));
|
||||
EXTERN(void) jpeg_abort (j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy (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));
|
||||
EXTERN(boolean) jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired);
|
||||
|
||||
|
||||
/* These marker codes are exported since applications and data source modules
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||
#include "transupp.h" /* Support routines for jpegtran */
|
||||
#include "jversion.h" /* for version message */
|
||||
#include "config.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */
|
||||
#ifdef __MWERKS__
|
||||
@@ -417,13 +417,6 @@ main (int argc, char **argv)
|
||||
jpeg_create_compress(&dstinfo);
|
||||
dstinfo.use_moz_defaults = TRUE;
|
||||
|
||||
/* 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
|
||||
|
||||
29
jquant1.c
29
jquant1.c
@@ -121,9 +121,6 @@ static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = {
|
||||
* The fserrors[] array is indexed [component#][position].
|
||||
* We provide (#columns + 2) entries per component; the extra entry at each
|
||||
* end saves us from special-casing the first and last pixels.
|
||||
*
|
||||
* Note: on a wide image, we might not have enough room in a PC's near data
|
||||
* segment to hold the error array; so it is allocated with alloc_large.
|
||||
*/
|
||||
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
@@ -134,7 +131,7 @@ typedef INT32 FSERROR; /* may need more than 16 bits */
|
||||
typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */
|
||||
#endif
|
||||
|
||||
typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */
|
||||
typedef FSERROR *FSERRPTR; /* pointer to error array */
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
@@ -406,7 +403,7 @@ make_odither_array (j_decompress_ptr cinfo, int ncolors)
|
||||
|
||||
odither = (ODITHER_MATRIX_PTR)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(ODITHER_MATRIX));
|
||||
sizeof(ODITHER_MATRIX));
|
||||
/* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1).
|
||||
* Hence the dither value for the matrix cell with fill order f
|
||||
* (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1).
|
||||
@@ -535,8 +532,7 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
for (row = 0; row < num_rows; row++) {
|
||||
/* Initialize output values to 0 so can process components separately */
|
||||
jzero_far((void FAR *) output_buf[row],
|
||||
(size_t) (width * SIZEOF(JSAMPLE)));
|
||||
jzero_far((void *) output_buf[row], (size_t) (width * sizeof(JSAMPLE)));
|
||||
row_index = cquantize->row_index;
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
input_ptr = input_buf[row] + ci;
|
||||
@@ -640,8 +636,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
for (row = 0; row < num_rows; row++) {
|
||||
/* Initialize output values to 0 so can process components separately */
|
||||
jzero_far((void FAR *) output_buf[row],
|
||||
(size_t) (width * SIZEOF(JSAMPLE)));
|
||||
jzero_far((void *) output_buf[row], (size_t) (width * sizeof(JSAMPLE)));
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
input_ptr = input_buf[row] + ci;
|
||||
output_ptr = output_buf[row];
|
||||
@@ -730,7 +725,7 @@ alloc_fs_workspace (j_decompress_ptr cinfo)
|
||||
size_t arraysize;
|
||||
int i;
|
||||
|
||||
arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR));
|
||||
arraysize = (size_t) ((cinfo->output_width + 2) * sizeof(FSERROR));
|
||||
for (i = 0; i < cinfo->out_color_components; i++) {
|
||||
cquantize->fserrors[i] = (FSERRPTR)
|
||||
(*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
|
||||
@@ -784,9 +779,9 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
if (cquantize->fserrors[0] == NULL)
|
||||
alloc_fs_workspace(cinfo);
|
||||
/* Initialize the propagated errors to zero. */
|
||||
arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR));
|
||||
arraysize = (size_t) ((cinfo->output_width + 2) * sizeof(FSERROR));
|
||||
for (i = 0; i < cinfo->out_color_components; i++)
|
||||
jzero_far((void FAR *) cquantize->fserrors[i], arraysize);
|
||||
jzero_far((void *) cquantize->fserrors[i], arraysize);
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||
@@ -829,7 +824,7 @@ jinit_1pass_quantizer (j_decompress_ptr cinfo)
|
||||
|
||||
cquantize = (my_cquantize_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_cquantizer));
|
||||
sizeof(my_cquantizer));
|
||||
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
|
||||
cquantize->pub.start_pass = start_pass_1_quant;
|
||||
cquantize->pub.finish_pass = finish_pass_1_quant;
|
||||
@@ -849,10 +844,10 @@ jinit_1pass_quantizer (j_decompress_ptr cinfo)
|
||||
create_colorindex(cinfo);
|
||||
|
||||
/* Allocate Floyd-Steinberg workspace now if requested.
|
||||
* We do this now since it is FAR storage and may affect the memory
|
||||
* manager's space calculations. If the user changes to FS dither
|
||||
* mode in a later pass, we will allocate the space then, and will
|
||||
* possibly overrun the max_memory_to_use setting.
|
||||
* We do this now since it may affect the memory manager's space
|
||||
* calculations. If the user changes to FS dither mode in a later pass, we
|
||||
* will allocate the space then, and will possibly overrun the
|
||||
* max_memory_to_use setting.
|
||||
*/
|
||||
if (cinfo->dither_mode == JDITHER_FS)
|
||||
alloc_fs_workspace(cinfo);
|
||||
|
||||
75
jquant2.c
75
jquant2.c
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, D. R. Commander.
|
||||
* Copyright (C) 2009, 2014, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains 2-pass color quantization (color mapping) routines.
|
||||
@@ -102,9 +102,7 @@ static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE};
|
||||
* machines, we can't just allocate the histogram in one chunk. Instead
|
||||
* of a true 3-D array, we use a row of pointers to 2-D arrays. Each
|
||||
* pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and
|
||||
* each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that
|
||||
* on 80x86 machines, the pointer row is in near memory but the actual
|
||||
* arrays are in far memory (same arrangement as we use for image arrays).
|
||||
* each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries.
|
||||
*/
|
||||
|
||||
#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */
|
||||
@@ -129,10 +127,10 @@ static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE};
|
||||
|
||||
typedef UINT16 histcell; /* histogram cell; prefer an unsigned type */
|
||||
|
||||
typedef histcell FAR * histptr; /* for pointers to histogram cells */
|
||||
typedef histcell * histptr; /* for pointers to histogram cells */
|
||||
|
||||
typedef histcell hist1d[HIST_C2_ELEMS]; /* typedefs for the array */
|
||||
typedef hist1d FAR * hist2d; /* type for the 2nd-level pointers */
|
||||
typedef hist1d * hist2d; /* type for the 2nd-level pointers */
|
||||
typedef hist2d * hist3d; /* type for top-level pointer */
|
||||
|
||||
|
||||
@@ -155,9 +153,6 @@ typedef hist2d * hist3d; /* type for top-level pointer */
|
||||
* The fserrors[] array has (#columns + 2) entries; the extra entry at
|
||||
* each end saves us from special-casing the first and last pixels.
|
||||
* Each entry is three values long, one value for each color component.
|
||||
*
|
||||
* Note: on a wide image, we might not have enough room in a PC's near data
|
||||
* segment to hold the error array; so it is allocated with alloc_large.
|
||||
*/
|
||||
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
@@ -168,7 +163,7 @@ typedef INT32 FSERROR; /* may need more than 16 bits */
|
||||
typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */
|
||||
#endif
|
||||
|
||||
typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */
|
||||
typedef FSERROR *FSERRPTR; /* pointer to error array */
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
@@ -529,7 +524,7 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
|
||||
/* Allocate workspace for box list */
|
||||
boxlist = (boxptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box));
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * sizeof(box));
|
||||
/* Initialize one box containing whole space */
|
||||
numboxes = 1;
|
||||
boxlist[0].c0min = 0;
|
||||
@@ -1025,32 +1020,23 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
* Add these into the running sums, and simultaneously shift the
|
||||
* next-line error sums left by 1 column.
|
||||
*/
|
||||
{ register LOCFSERROR bnexterr, delta;
|
||||
{ register LOCFSERROR bnexterr;
|
||||
|
||||
bnexterr = cur0; /* Process component 0 */
|
||||
delta = cur0 * 2;
|
||||
cur0 += delta; /* form error * 3 */
|
||||
errorptr[0] = (FSERROR) (bpreverr0 + cur0);
|
||||
cur0 += delta; /* form error * 5 */
|
||||
bpreverr0 = belowerr0 + cur0;
|
||||
errorptr[0] = (FSERROR) (bpreverr0 + cur0 * 3);
|
||||
bpreverr0 = belowerr0 + cur0 * 5;
|
||||
belowerr0 = bnexterr;
|
||||
cur0 += delta; /* form error * 7 */
|
||||
cur0 *= 7;
|
||||
bnexterr = cur1; /* Process component 1 */
|
||||
delta = cur1 * 2;
|
||||
cur1 += delta; /* form error * 3 */
|
||||
errorptr[1] = (FSERROR) (bpreverr1 + cur1);
|
||||
cur1 += delta; /* form error * 5 */
|
||||
bpreverr1 = belowerr1 + cur1;
|
||||
errorptr[1] = (FSERROR) (bpreverr1 + cur1 * 3);
|
||||
bpreverr1 = belowerr1 + cur1 * 5;
|
||||
belowerr1 = bnexterr;
|
||||
cur1 += delta; /* form error * 7 */
|
||||
cur1 *= 7;
|
||||
bnexterr = cur2; /* Process component 2 */
|
||||
delta = cur2 * 2;
|
||||
cur2 += delta; /* form error * 3 */
|
||||
errorptr[2] = (FSERROR) (bpreverr2 + cur2);
|
||||
cur2 += delta; /* form error * 5 */
|
||||
bpreverr2 = belowerr2 + cur2;
|
||||
errorptr[2] = (FSERROR) (bpreverr2 + cur2 * 3);
|
||||
bpreverr2 = belowerr2 + cur2 * 5;
|
||||
belowerr2 = bnexterr;
|
||||
cur2 += delta; /* form error * 7 */
|
||||
cur2 *= 7;
|
||||
}
|
||||
/* At this point curN contains the 7/16 error value to be propagated
|
||||
* to the next pixel on the current line, and all the errors for the
|
||||
@@ -1097,7 +1083,7 @@ init_error_limit (j_decompress_ptr cinfo)
|
||||
int in, out;
|
||||
|
||||
table = (int *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int));
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * sizeof(int));
|
||||
table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */
|
||||
cquantize->error_limiter = table;
|
||||
|
||||
@@ -1181,13 +1167,13 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
|
||||
if (cinfo->dither_mode == JDITHER_FS) {
|
||||
size_t arraysize = (size_t) ((cinfo->output_width + 2) *
|
||||
(3 * SIZEOF(FSERROR)));
|
||||
(3 * sizeof(FSERROR)));
|
||||
/* Allocate Floyd-Steinberg workspace if we didn't already. */
|
||||
if (cquantize->fserrors == NULL)
|
||||
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
|
||||
/* Initialize the propagated errors to zero. */
|
||||
jzero_far((void FAR *) cquantize->fserrors, arraysize);
|
||||
jzero_far((void *) cquantize->fserrors, arraysize);
|
||||
/* Make the error-limit table if we didn't already. */
|
||||
if (cquantize->error_limiter == NULL)
|
||||
init_error_limit(cinfo);
|
||||
@@ -1198,8 +1184,8 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
/* Zero the histogram or inverse color map, if necessary */
|
||||
if (cquantize->needs_zeroed) {
|
||||
for (i = 0; i < HIST_C0_ELEMS; i++) {
|
||||
jzero_far((void FAR *) histogram[i],
|
||||
HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell));
|
||||
jzero_far((void *) histogram[i],
|
||||
HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell));
|
||||
}
|
||||
cquantize->needs_zeroed = FALSE;
|
||||
}
|
||||
@@ -1232,7 +1218,7 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
|
||||
cquantize = (my_cquantize_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_cquantizer));
|
||||
sizeof(my_cquantizer));
|
||||
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
|
||||
cquantize->pub.start_pass = start_pass_2_quant;
|
||||
cquantize->pub.new_color_map = new_color_map_2_quant;
|
||||
@@ -1245,17 +1231,17 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
|
||||
/* Allocate the histogram/inverse colormap storage */
|
||||
cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d));
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * sizeof(hist2d));
|
||||
for (i = 0; i < HIST_C0_ELEMS; i++) {
|
||||
cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell));
|
||||
HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell));
|
||||
}
|
||||
cquantize->needs_zeroed = TRUE; /* histogram is garbage now */
|
||||
|
||||
/* Allocate storage for the completed colormap, if required.
|
||||
* We do this now since it is FAR storage and may affect
|
||||
* the memory manager's space calculations.
|
||||
* We do this now since it may affect the memory manager's space
|
||||
* calculations.
|
||||
*/
|
||||
if (cinfo->enable_2pass_quant) {
|
||||
/* Make sure color count is acceptable */
|
||||
@@ -1278,14 +1264,15 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
cinfo->dither_mode = JDITHER_FS;
|
||||
|
||||
/* Allocate Floyd-Steinberg workspace if necessary.
|
||||
* This isn't really needed until pass 2, but again it is FAR storage.
|
||||
* Although we will cope with a later change in dither_mode,
|
||||
* we do not promise to honor max_memory_to_use if dither_mode changes.
|
||||
* This isn't really needed until pass 2, but again it may affect the memory
|
||||
* manager's space calculations. Although we will cope with a later change
|
||||
* in dither_mode, we do not promise to honor max_memory_to_use if
|
||||
* dither_mode changes.
|
||||
*/
|
||||
if (cinfo->dither_mode == JDITHER_FS) {
|
||||
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR))));
|
||||
(size_t) ((cinfo->output_width + 2) * (3 * sizeof(FSERROR))));
|
||||
/* Might as well create the error-limiting table too. */
|
||||
init_error_limit(cinfo);
|
||||
}
|
||||
|
||||
116
jsimd.h
116
jsimd.h
@@ -10,89 +10,71 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* 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_rgb_gray jSCanRgbGry
|
||||
#define jsimd_can_ycc_rgb jSCanYccRgb
|
||||
#define jsimd_rgb_ycc_convert jSRgbYccConv
|
||||
#define jsimd_rgb_gray_convert jSRgbGryConv
|
||||
#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_rgb_gray JPP((void));
|
||||
EXTERN(int) jsimd_can_ycc_rgb JPP((void));
|
||||
EXTERN(int) jsimd_can_rgb_ycc (void);
|
||||
EXTERN(int) jsimd_can_rgb_gray (void);
|
||||
EXTERN(int) jsimd_can_ycc_rgb (void);
|
||||
EXTERN(int) jsimd_c_can_null_convert (void);
|
||||
|
||||
EXTERN(void) jsimd_rgb_ycc_convert
|
||||
JPP((j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows));
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows);
|
||||
EXTERN(void) jsimd_rgb_gray_convert
|
||||
JPP((j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows));
|
||||
(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));
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows);
|
||||
EXTERN(void) jsimd_c_null_convert
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_downsample JPP((void));
|
||||
EXTERN(int) jsimd_can_h2v1_downsample JPP((void));
|
||||
EXTERN(int) jsimd_can_h2v2_downsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_downsample (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));
|
||||
(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(int) jsimd_can_h2v2_smooth_downsample (void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_smooth_downsample
|
||||
(j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data);
|
||||
|
||||
EXTERN(void) jsimd_h2v1_downsample
|
||||
(j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_upsample (void);
|
||||
EXTERN(int) jsimd_can_int_upsample (void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_upsample
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
|
||||
(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));
|
||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr);
|
||||
EXTERN(void) jsimd_int_upsample
|
||||
(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(int) jsimd_can_h2v2_fancy_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_fancy_upsample (void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_fancy_upsample
|
||||
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
|
||||
(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));
|
||||
(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(int) jsimd_can_h2v2_merged_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_merged_upsample (void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_merged_upsample
|
||||
JPP((j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf));
|
||||
(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));
|
||||
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
|
||||
37
jsimd_none.c
37
jsimd_none.c
@@ -36,6 +36,12 @@ jsimd_can_ycc_rgb (void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_c_can_null_convert (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
@@ -57,6 +63,13 @@ jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_c_null_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_downsample (void)
|
||||
{
|
||||
@@ -69,12 +82,24 @@ jsimd_can_h2v1_downsample (void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_smooth_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_h2v2_smooth_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)
|
||||
@@ -93,6 +118,18 @@ jsimd_can_h2v1_upsample (void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_int_upsample (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
|
||||
132
jsimddct.h
132
jsimddct.h
@@ -9,106 +9,66 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||
EXTERN(int) jsimd_can_convsamp (void);
|
||||
EXTERN(int) jsimd_can_convsamp_float (void);
|
||||
|
||||
#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,
|
||||
EXTERN(void) jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
DCTELEM * workspace);
|
||||
EXTERN(void) jsimd_convsamp_float (JSAMPARRAY sample_data,
|
||||
JDIMENSION start_col,
|
||||
DCTELEM * workspace));
|
||||
EXTERN(void) jsimd_convsamp_float JPP((JSAMPARRAY sample_data,
|
||||
JDIMENSION start_col,
|
||||
FAST_FLOAT * workspace));
|
||||
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(int) jsimd_can_fdct_islow (void);
|
||||
EXTERN(int) jsimd_can_fdct_ifast (void);
|
||||
EXTERN(int) jsimd_can_fdct_float (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(void) jsimd_fdct_islow (DCTELEM * data);
|
||||
EXTERN(void) jsimd_fdct_ifast (DCTELEM * data);
|
||||
EXTERN(void) jsimd_fdct_float (FAST_FLOAT * data);
|
||||
|
||||
EXTERN(int) jsimd_can_quantize JPP((void));
|
||||
EXTERN(int) jsimd_can_quantize_float JPP((void));
|
||||
EXTERN(int) jsimd_can_quantize (void);
|
||||
EXTERN(int) jsimd_can_quantize_float (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(void) jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors,
|
||||
DCTELEM * workspace);
|
||||
EXTERN(void) jsimd_quantize_float (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(int) jsimd_can_idct_6x6 JPP((void));
|
||||
EXTERN(int) jsimd_can_idct_12x12 JPP((void));
|
||||
EXTERN(int) jsimd_can_idct_2x2 (void);
|
||||
EXTERN(int) jsimd_can_idct_4x4 (void);
|
||||
EXTERN(int) jsimd_can_idct_6x6 (void);
|
||||
EXTERN(int) jsimd_can_idct_12x12 (void);
|
||||
|
||||
EXTERN(void) jsimd_idct_2x2 JPP((j_decompress_ptr cinfo,
|
||||
EXTERN(void) jsimd_idct_2x2 (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,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_4x4 (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col));
|
||||
EXTERN(void) jsimd_idct_6x6 JPP((j_decompress_ptr cinfo,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_6x6 (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col));
|
||||
EXTERN(void) jsimd_idct_12x12 JPP((j_decompress_ptr cinfo,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_12x12 (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col));
|
||||
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(int) jsimd_can_idct_islow (void);
|
||||
EXTERN(int) jsimd_can_idct_ifast (void);
|
||||
EXTERN(int) jsimd_can_idct_float (void);
|
||||
|
||||
EXTERN(void) jsimd_idct_islow JPP((j_decompress_ptr cinfo,
|
||||
EXTERN(void) jsimd_idct_islow (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,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_ifast (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,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_float (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col));
|
||||
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
|
||||
@@ -28,7 +28,7 @@ add_huff_table (j_common_ptr cinfo,
|
||||
return;
|
||||
|
||||
/* Copy the number-of-symbols-of-each-code-length counts */
|
||||
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
|
||||
MEMCOPY((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
|
||||
|
||||
/* Validate the counts. We do this here mainly so we can copy the right
|
||||
* number of symbols from the val[] array, without risking marching off
|
||||
@@ -40,7 +40,7 @@ add_huff_table (j_common_ptr cinfo,
|
||||
if (nsymbols < 1 || nsymbols > 256)
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
|
||||
MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8));
|
||||
MEMCOPY((*htblptr)->huffval, val, nsymbols * sizeof(UINT8));
|
||||
|
||||
/* Initialize sent_table FALSE so table will be written to JPEG file. */
|
||||
(*htblptr)->sent_table = FALSE;
|
||||
|
||||
65
jutils.c
65
jutils.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jutils.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code
|
||||
* relevant to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains tables and miscellaneous utility routines needed
|
||||
@@ -87,26 +89,6 @@ jround_up (long a, long b)
|
||||
}
|
||||
|
||||
|
||||
/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays
|
||||
* and coefficient-block arrays. This won't work on 80x86 because the arrays
|
||||
* are FAR and we're assuming a small-pointer memory model. However, some
|
||||
* DOS compilers provide far-pointer versions of memcpy() and memset() even
|
||||
* in the small-model libraries. These will be used if USE_FMEM is defined.
|
||||
* Otherwise, the routines below do it the hard way. (The performance cost
|
||||
* is not all that great, because these routines aren't very heavily used.)
|
||||
*/
|
||||
|
||||
#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */
|
||||
#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size)
|
||||
#define FMEMZERO(target,size) MEMZERO(target,size)
|
||||
#else /* 80x86 case, define if we can */
|
||||
#ifdef USE_FMEM
|
||||
#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size))
|
||||
#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
JSAMPARRAY output_array, int dest_row,
|
||||
@@ -118,11 +100,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
*/
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
#ifdef FMEMCOPY
|
||||
register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE));
|
||||
#else
|
||||
register JDIMENSION count;
|
||||
#endif
|
||||
register size_t count = (size_t) (num_cols * sizeof(JSAMPLE));
|
||||
register int row;
|
||||
|
||||
input_array += source_row;
|
||||
@@ -131,12 +109,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
for (row = num_rows; row > 0; row--) {
|
||||
inptr = *input_array++;
|
||||
outptr = *output_array++;
|
||||
#ifdef FMEMCOPY
|
||||
FMEMCOPY(outptr, inptr, count);
|
||||
#else
|
||||
for (count = num_cols; count > 0; count--)
|
||||
*outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */
|
||||
#endif
|
||||
MEMCOPY(outptr, inptr, count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,34 +119,14 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
JDIMENSION num_blocks)
|
||||
/* Copy a row of coefficient blocks from one place to another. */
|
||||
{
|
||||
#ifdef FMEMCOPY
|
||||
FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));
|
||||
#else
|
||||
register JCOEFPTR inptr, outptr;
|
||||
register long count;
|
||||
|
||||
inptr = (JCOEFPTR) input_row;
|
||||
outptr = (JCOEFPTR) output_row;
|
||||
for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) {
|
||||
*outptr++ = *inptr++;
|
||||
}
|
||||
#endif
|
||||
MEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * sizeof(JCOEF)));
|
||||
}
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jzero_far (void FAR * target, size_t bytestozero)
|
||||
/* Zero out a chunk of FAR memory. */
|
||||
jzero_far (void * target, size_t bytestozero)
|
||||
/* Zero out a chunk of memory. */
|
||||
/* This might be sample-array data, block-array data, or alloc_large data. */
|
||||
{
|
||||
#ifdef FMEMZERO
|
||||
FMEMZERO(target, bytestozero);
|
||||
#else
|
||||
register char FAR * ptr = (char FAR *) target;
|
||||
register size_t count;
|
||||
|
||||
for (count = bytestozero; count > 0; count--) {
|
||||
*ptr++ = 0;
|
||||
}
|
||||
#endif
|
||||
MEMZERO(target, bytestozero);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
|
||||
* Modifications:
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2012-2014, D. R. Commander.
|
||||
* mozjpeg Modifications:
|
||||
* Copyright (C) 2014, Mozilla Corporation.
|
||||
@@ -33,5 +33,7 @@
|
||||
"Copyright (C) 2009-2014 D. R. Commander\n" \
|
||||
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
|
||||
"Copyright (C) 2014 Mozilla Corporation\n" \
|
||||
"Copyright (C) 2013 MIPS Technologies, Inc.\n" \
|
||||
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
|
||||
"Copyright (C) 2013 Linaro Limited"
|
||||
|
||||
#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2014 The libjpeg-turbo Project and many others"
|
||||
|
||||
95
libjpeg.txt
95
libjpeg.txt
@@ -2,7 +2,7 @@ USING THE IJG JPEG LIBRARY
|
||||
|
||||
This file was part of the Independent JPEG Group's software:
|
||||
Copyright (C) 1994-2011, Thomas G. Lane, Guido Vollbeding.
|
||||
Modifications:
|
||||
libjpeg-turbo Modifications:
|
||||
Copyright (C) 2010, 2014, D. R. Commander.
|
||||
For conditions of distribution and use, see the accompanying README file.
|
||||
|
||||
@@ -52,7 +52,6 @@ Advanced features:
|
||||
Memory usage
|
||||
Library compile-time options
|
||||
Portability considerations
|
||||
Notes for MS-DOS implementors
|
||||
|
||||
You should read at least the overview and basic usage sections before trying
|
||||
to program with the library. The sections on advanced features can be read
|
||||
@@ -764,12 +763,6 @@ compatible across versions; we only try to ensure source-code compatibility.
|
||||
applications and introduce a ton of access functions instead. Too late now,
|
||||
however.)
|
||||
|
||||
On some systems your application may need to set up a signal handler to ensure
|
||||
that temporary files are deleted if the program is interrupted. This is most
|
||||
critical if you are on MS-DOS and use the jmemdos.c memory manager back end;
|
||||
it will try to grab extended memory for temp files, and that space will NOT be
|
||||
freed automatically. See cjpeg.c or djpeg.c for an example signal handler.
|
||||
|
||||
It may be worth pointing out that the core JPEG library does not actually
|
||||
require the stdio library: only the default source/destination managers and
|
||||
error handler need it. You can use the library in a stdio-less environment
|
||||
@@ -897,12 +890,14 @@ J_DCT_METHOD dct_method
|
||||
JDCT_ISLOW, but this can be larger for some images. Do not use
|
||||
JDCT_IFAST with quality levels above 97. The algorithm often
|
||||
degenerates at quality=98 and above and can actually produce a more
|
||||
lossy image than if lower quality levels had been used. JDCT_FLOAT is
|
||||
mostly a legacy feature. It does not produce significantly more
|
||||
accurate results than the ISLOW method, and it is much slower. The
|
||||
FLOAT method may also give different results on different machines due
|
||||
to varying roundoff behavior, whereas the integer methods should give
|
||||
the same results on all machines.
|
||||
lossy image than if lower quality levels had been used. Also, in
|
||||
libjpeg-turbo, JDCT_IFAST is not fully accelerated for quality levels
|
||||
above 97, so it will be slower than JDCT_ISLOW. JDCT_FLOAT is mainly a
|
||||
legacy feature. It does not produce significantly more accurate
|
||||
results than the ISLOW method, and it is much slower. The FLOAT method
|
||||
may also give different results on different machines due to varying
|
||||
roundoff behavior, whereas the integer methods should give the same
|
||||
results on all machines.
|
||||
|
||||
J_COLOR_SPACE jpeg_color_space
|
||||
int num_components
|
||||
@@ -1199,7 +1194,7 @@ J_DCT_METHOD dct_method
|
||||
when decompressing images that were compressed using quality levels
|
||||
above 97. The algorithm often degenerates for such images and can
|
||||
actually produce a more lossy output image than if the JPEG image had
|
||||
been compressed using lower quality levels. JDCT_FLOAT is mostly a
|
||||
been compressed using lower quality levels. JDCT_FLOAT is mainly a
|
||||
legacy feature. It does not produce significantly more accurate
|
||||
results than the ISLOW method, and it is much slower. The FLOAT method
|
||||
may also give different results on different machines due to varying
|
||||
@@ -2875,18 +2870,6 @@ that space allocated with alloc_small() is ignored, on the assumption that
|
||||
it's too small to be worth worrying about; so a reasonable safety margin
|
||||
should be left when setting max_memory_to_use.
|
||||
|
||||
If you use the jmemname.c or jmemdos.c memory manager back end, it is
|
||||
important to clean up the JPEG object properly to ensure that the temporary
|
||||
files get deleted. (This is especially crucial with jmemdos.c, where the
|
||||
"temporary files" may be extended-memory segments; if they are not freed,
|
||||
DOS will require a reboot to recover the memory.) Thus, with these memory
|
||||
managers, it's a good idea to provide a signal handler that will trap any
|
||||
early exit from your program. The handler should call either jpeg_abort()
|
||||
or jpeg_destroy() for any active JPEG objects. A handler is not needed with
|
||||
jmemnobs.c, and shouldn't be necessary with jmemansi.c or jmemmac.c either,
|
||||
since the C library is supposed to take care of deleting files made with
|
||||
tmpfile().
|
||||
|
||||
|
||||
Memory usage
|
||||
------------
|
||||
@@ -2947,11 +2930,7 @@ The sample applications cjpeg and djpeg can support 12-bit mode only for PPM
|
||||
and GIF file formats; you must disable the other file formats to compile a
|
||||
12-bit cjpeg or djpeg. (install.txt has more information about that.)
|
||||
At present, a 12-bit library can handle *only* 12-bit images, not both
|
||||
precisions. (If you need to include both 8- and 12-bit libraries in a single
|
||||
application, you could probably do it by defining NEED_SHORT_EXTERNAL_NAMES
|
||||
for just one of the copies. You'd have to access the 8-bit and 12-bit copies
|
||||
from separate application source files. This is untested ... if you try it,
|
||||
we'd like to hear whether it works!)
|
||||
precisions.
|
||||
|
||||
Note that a 12-bit library always compresses in Huffman optimization mode,
|
||||
in order to generate valid Huffman tables. This is necessary because our
|
||||
@@ -2996,9 +2975,8 @@ the design goals in this area. (If you encounter any bugs that cause the
|
||||
library to be less portable than is claimed here, we'd appreciate hearing
|
||||
about them.)
|
||||
|
||||
The code works fine on ANSI C, C++, and pre-ANSI C compilers, using any of
|
||||
the popular system include file setups, and some not-so-popular ones too.
|
||||
See install.txt for configuration procedures.
|
||||
The code works fine on ANSI C and C++ compilers, using any of the popular
|
||||
system include file setups, and some not-so-popular ones too.
|
||||
|
||||
The code is not dependent on the exact sizes of the C data types. As
|
||||
distributed, we make the assumptions that
|
||||
@@ -3033,52 +3011,5 @@ heavily dependent on stdio.) malloc and free are called only from the memory
|
||||
manager "back end" module, so you can use a different memory allocator by
|
||||
replacing that one file.
|
||||
|
||||
The code generally assumes that C names must be unique in the first 15
|
||||
characters. However, global function names can be made unique in the
|
||||
first 6 characters by defining NEED_SHORT_EXTERNAL_NAMES.
|
||||
|
||||
More info about porting the code may be gleaned by reading jconfig.txt,
|
||||
jmorecfg.h, and jinclude.h.
|
||||
|
||||
|
||||
Notes for MS-DOS implementors
|
||||
-----------------------------
|
||||
|
||||
The IJG code is designed to work efficiently in 80x86 "small" or "medium"
|
||||
memory models (i.e., data pointers are 16 bits unless explicitly declared
|
||||
"far"; code pointers can be either size). You may be able to use small
|
||||
model to compile cjpeg or djpeg by itself, but you will probably have to use
|
||||
medium model for any larger application. This won't make much difference in
|
||||
performance. You *will* take a noticeable performance hit if you use a
|
||||
large-data memory model (perhaps 10%-25%), and you should avoid "huge" model
|
||||
if at all possible.
|
||||
|
||||
The JPEG library typically needs 2Kb-3Kb of stack space. It will also
|
||||
malloc about 20K-30K of near heap space while executing (and lots of far
|
||||
heap, but that doesn't count in this calculation). This figure will vary
|
||||
depending on selected operating mode, and to a lesser extent on image size.
|
||||
There is also about 5Kb-6Kb of constant data which will be allocated in the
|
||||
near data segment (about 4Kb of this is the error message table).
|
||||
Thus you have perhaps 20K available for other modules' static data and near
|
||||
heap space before you need to go to a larger memory model. The C library's
|
||||
static data will account for several K of this, but that still leaves a good
|
||||
deal for your needs. (If you are tight on space, you could reduce the sizes
|
||||
of the I/O buffers allocated by jdatasrc.c and jdatadst.c, say from 4K to
|
||||
1K. Another possibility is to move the error message table to far memory;
|
||||
this should be doable with only localized hacking on jerror.c.)
|
||||
|
||||
About 2K of the near heap space is "permanent" memory that will not be
|
||||
released until you destroy the JPEG object. This is only an issue if you
|
||||
save a JPEG object between compression or decompression operations.
|
||||
|
||||
Far data space may also be a tight resource when you are dealing with large
|
||||
images. The most memory-intensive case is decompression with two-pass color
|
||||
quantization, or single-pass quantization to an externally supplied color
|
||||
map. This requires a 128Kb color lookup table plus strip buffers amounting
|
||||
to about 40 bytes per column for typical sampling ratios (eg, about 25600
|
||||
bytes for a 640-pixel-wide image). You may not be able to process wide
|
||||
images if you have large data structures of your own.
|
||||
|
||||
Of course, all of these concerns vanish if you use a 32-bit flat-memory-model
|
||||
compiler, such as DJGPP or Watcom C. We highly recommend flat model if you
|
||||
can use it; the JPEG library is significantly faster in flat model.
|
||||
|
||||
4
rdbmp.c
4
rdbmp.c
@@ -35,7 +35,7 @@
|
||||
typedef unsigned char U_CHAR;
|
||||
#define UCH(x) ((int) (x))
|
||||
#else /* !HAVE_UNSIGNED_CHAR */
|
||||
#ifdef CHAR_IS_UNSIGNED
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
typedef char U_CHAR;
|
||||
#define UCH(x) ((int) (x))
|
||||
#else
|
||||
@@ -469,7 +469,7 @@ jinit_read_bmp (j_compress_ptr cinfo)
|
||||
/* Create module interface object */
|
||||
source = (bmp_source_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(bmp_source_struct));
|
||||
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;
|
||||
|
||||
2
rdjpeg.c
2
rdjpeg.c
@@ -150,7 +150,7 @@ jinit_read_jpeg (j_compress_ptr cinfo)
|
||||
/* Create module interface object */
|
||||
source = (jpeg_source_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(jpeg_source_struct));
|
||||
sizeof(jpeg_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_jpeg;
|
||||
|
||||
12
rdjpgcom.c
12
rdjpgcom.c
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
* rdjpgcom.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 2009 by Bill Allombert, Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains a very simple stand-alone application that displays
|
||||
@@ -38,23 +40,15 @@
|
||||
#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
|
||||
|
||||
|
||||
/*
|
||||
|
||||
33
rdppm.c
33
rdppm.c
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
* rdppm.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2009 by Bill Allombert, Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains routines to read input images in PPM/PGM format.
|
||||
@@ -43,7 +45,7 @@
|
||||
typedef unsigned char U_CHAR;
|
||||
#define UCH(x) ((int) (x))
|
||||
#else /* !HAVE_UNSIGNED_CHAR */
|
||||
#ifdef CHAR_IS_UNSIGNED
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
typedef char U_CHAR;
|
||||
#define UCH(x) ((int) (x))
|
||||
#else
|
||||
@@ -56,24 +58,14 @@ typedef char U_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 */
|
||||
/* Usually these two pointers point to the same place: */
|
||||
U_CHAR *iobuffer; /* fread's I/O buffer */
|
||||
JSAMPROW pixrow; /* compressor input buffer */
|
||||
size_t buffer_width; /* width of I/O buffer */
|
||||
JSAMPLE *rescale; /* => maxval-remapping array, or NULL */
|
||||
} ppm_source_struct;
|
||||
@@ -358,7 +350,7 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
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)) {
|
||||
} else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR)) {
|
||||
source->pub.get_pixel_rows = get_raw_row;
|
||||
use_raw_buffer = TRUE;
|
||||
need_rescale = FALSE;
|
||||
@@ -373,7 +365,7 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
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)) {
|
||||
} else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR)) {
|
||||
source->pub.get_pixel_rows = get_raw_row;
|
||||
use_raw_buffer = TRUE;
|
||||
need_rescale = FALSE;
|
||||
@@ -386,7 +378,7 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* 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)));
|
||||
((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);
|
||||
@@ -396,7 +388,6 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
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;
|
||||
@@ -415,7 +406,7 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
/* 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)));
|
||||
(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 */
|
||||
@@ -448,7 +439,7 @@ jinit_read_ppm (j_compress_ptr cinfo)
|
||||
/* Create module interface object */
|
||||
source = (ppm_source_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(ppm_source_struct));
|
||||
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;
|
||||
|
||||
9
rdrle.c
9
rdrle.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* rdrle.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains routines to read input images in Utah RLE format.
|
||||
@@ -254,8 +256,7 @@ load_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
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.
|
||||
* We assume here that rle_pixel is represented the same as JSAMPLE.
|
||||
*/
|
||||
RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */
|
||||
|
||||
@@ -375,7 +376,7 @@ jinit_read_rle (j_compress_ptr cinfo)
|
||||
/* Create module interface object */
|
||||
source = (rle_source_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(rle_source_struct));
|
||||
sizeof(rle_source_struct));
|
||||
/* Fill in method ptrs */
|
||||
source->pub.start_input = start_input_rle;
|
||||
source->pub.finish_input = finish_input_rle;
|
||||
|
||||
@@ -261,8 +261,8 @@ bogus:
|
||||
*/
|
||||
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));
|
||||
scanno * sizeof(jpeg_scan_info));
|
||||
MEMCOPY(scanptr, scans, scanno * sizeof(jpeg_scan_info));
|
||||
cinfo->scan_info = scanptr;
|
||||
cinfo->num_scans = scanno;
|
||||
}
|
||||
@@ -324,7 +324,7 @@ jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
|
||||
q_scale_factor[0], force_baseline);
|
||||
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
|
||||
q_scale_factor[1], force_baseline);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
13
rdtarga.c
13
rdtarga.c
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* rdtarga.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains routines to read input images in Targa format.
|
||||
@@ -28,7 +30,7 @@
|
||||
typedef unsigned char U_CHAR;
|
||||
#define UCH(x) ((int) (x))
|
||||
#else /* !HAVE_UNSIGNED_CHAR */
|
||||
#ifdef CHAR_IS_UNSIGNED
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
typedef char U_CHAR;
|
||||
#define UCH(x) ((int) (x))
|
||||
#else
|
||||
@@ -56,7 +58,7 @@ typedef struct _tga_source_struct {
|
||||
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));
|
||||
void (*read_pixel) (tga_source_ptr sinfo);
|
||||
|
||||
/* Result of read_pixel is delivered here: */
|
||||
U_CHAR tga_pixel[4];
|
||||
@@ -68,8 +70,7 @@ typedef struct _tga_source_struct {
|
||||
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));
|
||||
JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
|
||||
} tga_source_struct;
|
||||
|
||||
|
||||
@@ -488,7 +489,7 @@ jinit_read_targa (j_compress_ptr cinfo)
|
||||
/* Create module interface object */
|
||||
source = (tga_source_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(tga_source_struct));
|
||||
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;
|
||||
|
||||
@@ -18,16 +18,18 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug"
|
||||
endif()
|
||||
|
||||
if(SIMD_X86_64)
|
||||
set(SIMD_BASENAMES jfsseflt-64 jccolss2-64 jdcolss2-64 jcgrass2-64
|
||||
jcsamss2-64 jdsamss2-64 jdmerss2-64 jcqnts2i-64 jfss2fst-64 jfss2int-64
|
||||
jiss2red-64 jiss2int-64 jiss2fst-64 jcqnts2f-64 jiss2flt-64)
|
||||
set(SIMD_BASENAMES jfdctflt-sse-64 jccolor-sse2-64 jcgray-sse2-64
|
||||
jcsample-sse2-64 jdcolor-sse2-64 jdmerge-sse2-64 jdsample-sse2-64
|
||||
jfdctfst-sse2-64 jfdctint-sse2-64 jidctflt-sse2-64 jidctfst-sse2-64
|
||||
jidctint-sse2-64 jidctred-sse2-64 jquantf-sse2-64 jquanti-sse2-64)
|
||||
message(STATUS "Building x86_64 SIMD extensions")
|
||||
else()
|
||||
set(SIMD_BASENAMES jsimdcpu jccolmmx jcgrammx jdcolmmx jcsammmx jdsammmx
|
||||
jdmermmx jcqntmmx jfmmxfst jfmmxint jimmxred jimmxint jimmxfst jcqnt3dn
|
||||
jf3dnflt ji3dnflt jcqntsse jfsseflt jisseflt jccolss2 jcgrass2 jdcolss2
|
||||
jcsamss2 jdsamss2 jdmerss2 jcqnts2i jfss2fst jfss2int jiss2red jiss2int
|
||||
jiss2fst jcqnts2f jiss2flt)
|
||||
set(SIMD_BASENAMES jsimdcpu jfdctflt-3dn jidctflt-3dn jquant-3dn jccolor-mmx
|
||||
jcgray-mmx jcsample-mmx jdcolor-mmx jdmerge-mmx jdsample-mmx jfdctfst-mmx
|
||||
jfdctint-mmx jidctfst-mmx jidctint-mmx jidctred-mmx jquant-mmx jfdctflt-sse
|
||||
jidctflt-sse jquant-sse jccolor-sse2 jcgray-sse2 jcsample-sse2 jdcolor-sse2
|
||||
jdmerge-sse2 jdsample-sse2 jfdctfst-sse2 jfdctint-sse2 jidctflt-sse2
|
||||
jidctfst-sse2 jidctint-sse2 jidctred-sse2 jquantf-sse2 jquanti-sse2)
|
||||
message(STATUS "Building i386 SIMD extensions")
|
||||
endif()
|
||||
|
||||
@@ -41,28 +43,32 @@ file(GLOB INC_FILES *.inc)
|
||||
|
||||
foreach(file ${SIMD_BASENAMES})
|
||||
set(DEPFILE "")
|
||||
set(SIMD_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${file}.asm")
|
||||
if("${file}" MATCHES col)
|
||||
set(DEPFILE "${file}")
|
||||
string(REGEX REPLACE "col" "clr" DEPFILE "${DEPFILE}")
|
||||
set(DEPFILE "${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm")
|
||||
set(SIMD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${file}.asm)
|
||||
if(${file} MATCHES jccolor)
|
||||
set(DEPFILE ${file})
|
||||
string(REGEX REPLACE "jccolor" "jccolext" DEPFILE ${DEPFILE})
|
||||
set(DEPFILE ${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm)
|
||||
endif()
|
||||
if("${file}" MATCHES mer)
|
||||
set(DEPFILE "${file}")
|
||||
string(REGEX REPLACE "mer" "mrg" DEPFILE "${DEPFILE}")
|
||||
set(DEPFILE "${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm")
|
||||
if(${file} MATCHES jcgray)
|
||||
set(DEPFILE ${file})
|
||||
string(REGEX REPLACE "jcgray" "jcgryext" DEPFILE ${DEPFILE})
|
||||
set(DEPFILE ${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm)
|
||||
endif()
|
||||
if("${file}" MATCHES gra)
|
||||
set(DEPFILE "${file}")
|
||||
string(REGEX REPLACE "gra" "gry" DEPFILE "${DEPFILE}")
|
||||
set(DEPFILE "${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm")
|
||||
if(${file} MATCHES jdcolor)
|
||||
set(DEPFILE ${file})
|
||||
string(REGEX REPLACE "jdcolor" "jdcolext" DEPFILE ${DEPFILE})
|
||||
set(DEPFILE ${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm)
|
||||
endif()
|
||||
set(SIMD_OBJ "${OBJDIR}/${file}.obj")
|
||||
add_custom_command(OUTPUT "${SIMD_OBJ}"
|
||||
DEPENDS "${SIMD_SRC}" "${DEPFILE}" ${INC_FILES}
|
||||
COMMAND "${NASM}" ${NAFLAGS} "${SIMD_SRC}" "-o${SIMD_OBJ}"
|
||||
VERBATIM)
|
||||
list(APPEND SIMD_OBJS "${SIMD_OBJ}")
|
||||
if(${file} MATCHES jdmerge)
|
||||
set(DEPFILE ${file})
|
||||
string(REGEX REPLACE "jdmerge" "jdmrgext" DEPFILE ${DEPFILE})
|
||||
set(DEPFILE ${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}.asm)
|
||||
endif()
|
||||
set(SIMD_OBJ ${OBJDIR}/${file}.obj)
|
||||
add_custom_command(OUTPUT ${SIMD_OBJ}
|
||||
DEPENDS ${SIMD_SRC} ${DEPFILE} ${INC_FILES}
|
||||
COMMAND ${NASM} ${NAFLAGS} ${SIMD_SRC} -o${SIMD_OBJ})
|
||||
set(SIMD_OBJS ${SIMD_OBJS} ${SIMD_OBJ})
|
||||
endforeach()
|
||||
|
||||
set(SIMD_OBJS ${SIMD_OBJS} PARENT_SCOPE)
|
||||
|
||||
@@ -2,54 +2,54 @@ 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 jcgryss2-64.asm jcgrymmx.asm jcgryss2.asm CMakeLists.txt
|
||||
EXTRA_DIST = nasm_lt.sh CMakeLists.txt \
|
||||
jccolext-mmx.asm jcgryext-mmx.asm jdcolext-mmx.asm jdmrgext-mmx.asm \
|
||||
jccolext-sse2.asm jcgryext-sse2.asm jdcolext-sse2.asm jdmrgext-sse2.asm \
|
||||
jccolext-sse2-64.asm jcgryext-sse2-64.asm jdcolext-sse2-64.asm \
|
||||
jdmrgext-sse2-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 jcgrass2-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
|
||||
libsimd_la_SOURCES = jsimd_x86_64.c jsimd.h jsimdcfg.inc.h jsimdext.inc \
|
||||
jcolsamp.inc jdct.inc jfdctflt-sse-64.asm \
|
||||
jccolor-sse2-64.asm jcgray-sse2-64.asm jcsample-sse2-64.asm \
|
||||
jdcolor-sse2-64.asm jdmerge-sse2-64.asm jdsample-sse2-64.asm \
|
||||
jfdctfst-sse2-64.asm jfdctint-sse2-64.asm jidctflt-sse2-64.asm \
|
||||
jidctfst-sse2-64.asm jidctint-sse2-64.asm jidctred-sse2-64.asm \
|
||||
jquantf-sse2-64.asm jquanti-sse2-64.asm
|
||||
|
||||
jccolor-sse2-64.lo: jccolext-sse2-64.asm
|
||||
jcgray-sse2-64.lo: jcgryext-sse2-64.asm
|
||||
jdcolor-sse2-64.lo: jdcolext-sse2-64.asm
|
||||
jdmerge-sse2-64.lo: jdmrgext-sse2-64.asm
|
||||
|
||||
jccolss2-64.lo: jcclrss2-64.asm
|
||||
jdcolss2-64.lo: jdclrss2-64.asm
|
||||
jcgrass2-64.lo: jcgryss2-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 jcgrammx.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 jcgrass2.asm \
|
||||
jcsamss2.asm jdsamss2.asm jdmerss2.asm \
|
||||
jcqnts2i.asm jfss2fst.asm jfss2int.asm \
|
||||
jiss2red.asm jiss2int.asm jiss2fst.asm \
|
||||
jcqnts2f.asm jiss2flt.asm
|
||||
libsimd_la_SOURCES = jsimd_i386.c jsimd.h jsimdcfg.inc.h jsimdext.inc \
|
||||
jcolsamp.inc jdct.inc jsimdcpu.asm \
|
||||
jfdctflt-3dn.asm jidctflt-3dn.asm jquant-3dn.asm \
|
||||
jccolor-mmx.asm jcgray-mmx.asm jcsample-mmx.asm \
|
||||
jdcolor-mmx.asm jdmerge-mmx.asm jdsample-mmx.asm \
|
||||
jfdctfst-mmx.asm jfdctint-mmx.asm jidctfst-mmx.asm \
|
||||
jidctint-mmx.asm jidctred-mmx.asm jquant-mmx.asm \
|
||||
jfdctflt-sse.asm jidctflt-sse.asm jquant-sse.asm \
|
||||
jccolor-sse2.asm jcgray-sse2.asm jcsample-sse2.asm \
|
||||
jdcolor-sse2.asm jdmerge-sse2.asm jdsample-sse2.asm \
|
||||
jfdctfst-sse2.asm jfdctint-sse2.asm jidctflt-sse2.asm \
|
||||
jidctfst-sse2.asm jidctint-sse2.asm jidctred-sse2.asm \
|
||||
jquantf-sse2.asm jquanti-sse2.asm
|
||||
|
||||
jccolor-mmx.lo: jccolext-mmx.asm
|
||||
jcgray.-mmx.lo: jcgryext-mmx.asm
|
||||
jdcolor-mmx.lo: jdcolext-mmx.asm
|
||||
jdmerge-mmx.lo: jdmrgext-mmx.asm
|
||||
jccolor-sse2.lo: jccolext-sse2.asm
|
||||
jcgray-sse2.lo: jcgryext-sse2.asm
|
||||
jdcolor-sse2.lo: jdcolext-sse2.asm
|
||||
jdmerge-sse2.lo: jdmrgext-sse2.asm
|
||||
|
||||
jccolmmx.lo: jcclrmmx.asm
|
||||
jcgrammx.lo: jcgrymmx.asm
|
||||
jccolss2.lo: jcclrss2.asm
|
||||
jcgrass2.lo: jcgryss2.asm
|
||||
jdcolmmx.lo: jdclrmmx.asm
|
||||
jdcolss2.lo: jdclrss2.asm
|
||||
jdmermmx.lo: jdmrgmmx.asm
|
||||
jdmerss2.lo: jdmrgss2.asm
|
||||
endif
|
||||
|
||||
if SIMD_ARM
|
||||
@@ -64,7 +64,7 @@ libsimd_la_SOURCES = jsimd_arm64.c jsimd_arm_neon_64.S
|
||||
|
||||
endif
|
||||
|
||||
if SIMD_MIPSEL
|
||||
if SIMD_MIPS
|
||||
|
||||
libsimd_la_SOURCES = jsimd_mips.c jsimd_mips_dspr2_asm.h jsimd_mips_dspr2.S
|
||||
|
||||
|
||||
@@ -1,477 +0,0 @@
|
||||
;
|
||||
; 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"
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; 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
|
||||
@@ -1,485 +0,0 @@
|
||||
;
|
||||
; 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"
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; 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
|
||||
@@ -1,503 +0,0 @@
|
||||
;
|
||||
; 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"
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; 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
|
||||
477
simd/jccolext-mmx.asm
Normal file
477
simd/jccolext-mmx.asm
Normal file
@@ -0,0 +1,477 @@
|
||||
;
|
||||
; jccolext.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"
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; 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
|
||||
485
simd/jccolext-sse2-64.asm
Normal file
485
simd/jccolext-sse2-64.asm
Normal file
@@ -0,0 +1,485 @@
|
||||
;
|
||||
; jccolext.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"
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; 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
|
||||
503
simd/jccolext-sse2.asm
Normal file
503
simd/jccolext-sse2.asm
Normal file
@@ -0,0 +1,503 @@
|
||||
;
|
||||
; jccolext.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"
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; 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
|
||||
@@ -1,5 +1,5 @@
|
||||
;
|
||||
; jccolmmx.asm - colorspace conversion (MMX)
|
||||
; jccolor.asm - colorspace conversion (MMX)
|
||||
;
|
||||
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
; Copyright 2009 D. R. Commander
|
||||
@@ -54,7 +54,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
SECTION SEG_TEXT
|
||||
BITS 32
|
||||
|
||||
%include "jcclrmmx.asm"
|
||||
%include "jccolext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -65,7 +65,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_mmx jsimd_extrgb_ycc_convert_mmx
|
||||
%include "jcclrmmx.asm"
|
||||
%include "jccolext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -76,7 +76,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGBX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_mmx jsimd_extrgbx_ycc_convert_mmx
|
||||
%include "jcclrmmx.asm"
|
||||
%include "jccolext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -87,7 +87,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_mmx jsimd_extbgr_ycc_convert_mmx
|
||||
%include "jcclrmmx.asm"
|
||||
%include "jccolext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -98,7 +98,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGRX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_mmx jsimd_extbgrx_ycc_convert_mmx
|
||||
%include "jcclrmmx.asm"
|
||||
%include "jccolext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -109,7 +109,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XBGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_mmx jsimd_extxbgr_ycc_convert_mmx
|
||||
%include "jcclrmmx.asm"
|
||||
%include "jccolext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -120,4 +120,4 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XRGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_mmx jsimd_extxrgb_ycc_convert_mmx
|
||||
%include "jcclrmmx.asm"
|
||||
%include "jccolext-mmx.asm"
|
||||
@@ -1,5 +1,5 @@
|
||||
;
|
||||
; jccolss2.asm - colorspace conversion (SSE2)
|
||||
; jccolor.asm - colorspace conversion (64-bit SSE2)
|
||||
;
|
||||
; x86 SIMD extension for IJG JPEG library
|
||||
; Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
@@ -49,9 +49,9 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
SECTION SEG_TEXT
|
||||
BITS 32
|
||||
BITS 64
|
||||
|
||||
%include "jcclrss2.asm"
|
||||
%include "jccolext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -62,7 +62,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgb_ycc_convert_sse2
|
||||
%include "jcclrss2.asm"
|
||||
%include "jccolext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -73,7 +73,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGBX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgbx_ycc_convert_sse2
|
||||
%include "jcclrss2.asm"
|
||||
%include "jccolext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -84,7 +84,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgr_ycc_convert_sse2
|
||||
%include "jcclrss2.asm"
|
||||
%include "jccolext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -95,7 +95,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGRX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgrx_ycc_convert_sse2
|
||||
%include "jcclrss2.asm"
|
||||
%include "jccolext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -106,7 +106,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XBGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extxbgr_ycc_convert_sse2
|
||||
%include "jcclrss2.asm"
|
||||
%include "jccolext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -117,4 +117,4 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XRGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extxrgb_ycc_convert_sse2
|
||||
%include "jcclrss2.asm"
|
||||
%include "jccolext-sse2-64.asm"
|
||||
@@ -1,5 +1,5 @@
|
||||
;
|
||||
; jccolss2-64.asm - colorspace conversion (64-bit SSE2)
|
||||
; jccolor.asm - colorspace conversion (SSE2)
|
||||
;
|
||||
; x86 SIMD extension for IJG JPEG library
|
||||
; Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
@@ -49,9 +49,9 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
SECTION SEG_TEXT
|
||||
BITS 64
|
||||
BITS 32
|
||||
|
||||
%include "jcclrss2-64.asm"
|
||||
%include "jccolext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -62,7 +62,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgb_ycc_convert_sse2
|
||||
%include "jcclrss2-64.asm"
|
||||
%include "jccolext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -73,7 +73,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGBX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extrgbx_ycc_convert_sse2
|
||||
%include "jcclrss2-64.asm"
|
||||
%include "jccolext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -84,7 +84,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgr_ycc_convert_sse2
|
||||
%include "jcclrss2-64.asm"
|
||||
%include "jccolext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -95,7 +95,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGRX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extbgrx_ycc_convert_sse2
|
||||
%include "jcclrss2-64.asm"
|
||||
%include "jccolext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -106,7 +106,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XBGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extxbgr_ycc_convert_sse2
|
||||
%include "jcclrss2-64.asm"
|
||||
%include "jccolext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -117,4 +117,4 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XRGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
|
||||
%define jsimd_rgb_ycc_convert_sse2 jsimd_extxrgb_ycc_convert_sse2
|
||||
%include "jcclrss2-64.asm"
|
||||
%include "jccolext-sse2.asm"
|
||||
@@ -1,5 +1,5 @@
|
||||
;
|
||||
; jcgrammx.asm - grayscale colorspace conversion (MMX)
|
||||
; jcgray.asm - grayscale colorspace conversion (MMX)
|
||||
;
|
||||
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
; Copyright 2011 D. R. Commander
|
||||
@@ -47,7 +47,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
SECTION SEG_TEXT
|
||||
BITS 32
|
||||
|
||||
%include "jcgrymmx.asm"
|
||||
%include "jcgryext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -58,7 +58,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_mmx jsimd_extrgb_gray_convert_mmx
|
||||
%include "jcgrymmx.asm"
|
||||
%include "jcgryext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -69,7 +69,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGBX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_mmx jsimd_extrgbx_gray_convert_mmx
|
||||
%include "jcgrymmx.asm"
|
||||
%include "jcgryext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -80,7 +80,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_mmx jsimd_extbgr_gray_convert_mmx
|
||||
%include "jcgrymmx.asm"
|
||||
%include "jcgryext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -91,7 +91,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGRX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_mmx jsimd_extbgrx_gray_convert_mmx
|
||||
%include "jcgrymmx.asm"
|
||||
%include "jcgryext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -102,7 +102,7 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XBGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_mmx jsimd_extxbgr_gray_convert_mmx
|
||||
%include "jcgrymmx.asm"
|
||||
%include "jcgryext-mmx.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -113,4 +113,4 @@ PD_ONEHALF times 2 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XRGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_mmx jsimd_extxrgb_gray_convert_mmx
|
||||
%include "jcgrymmx.asm"
|
||||
%include "jcgryext-mmx.asm"
|
||||
@@ -1,5 +1,5 @@
|
||||
;
|
||||
; jcgrass2-64.asm - grayscale colorspace conversion (64-bit SSE2)
|
||||
; jcgray.asm - grayscale colorspace conversion (64-bit SSE2)
|
||||
;
|
||||
; x86 SIMD extension for IJG JPEG library
|
||||
; Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
@@ -44,7 +44,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
SECTION SEG_TEXT
|
||||
BITS 64
|
||||
|
||||
%include "jcgryss2-64.asm"
|
||||
%include "jcgryext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -55,7 +55,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extrgb_gray_convert_sse2
|
||||
%include "jcgryss2-64.asm"
|
||||
%include "jcgryext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -66,7 +66,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGBX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extrgbx_gray_convert_sse2
|
||||
%include "jcgryss2-64.asm"
|
||||
%include "jcgryext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -77,7 +77,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extbgr_gray_convert_sse2
|
||||
%include "jcgryss2-64.asm"
|
||||
%include "jcgryext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -88,7 +88,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGRX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extbgrx_gray_convert_sse2
|
||||
%include "jcgryss2-64.asm"
|
||||
%include "jcgryext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -99,7 +99,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XBGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extxbgr_gray_convert_sse2
|
||||
%include "jcgryss2-64.asm"
|
||||
%include "jcgryext-sse2-64.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -110,4 +110,4 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XRGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extxrgb_gray_convert_sse2
|
||||
%include "jcgryss2-64.asm"
|
||||
%include "jcgryext-sse2-64.asm"
|
||||
@@ -1,5 +1,5 @@
|
||||
;
|
||||
; jcgrass2.asm - grayscale colorspace conversion (SSE2)
|
||||
; jcgray.asm - grayscale colorspace conversion (SSE2)
|
||||
;
|
||||
; x86 SIMD extension for IJG JPEG library
|
||||
; Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
@@ -44,7 +44,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
SECTION SEG_TEXT
|
||||
BITS 32
|
||||
|
||||
%include "jcgryss2.asm"
|
||||
%include "jcgryext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -55,7 +55,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extrgb_gray_convert_sse2
|
||||
%include "jcgryss2.asm"
|
||||
%include "jcgryext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -66,7 +66,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_RGBX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extrgbx_gray_convert_sse2
|
||||
%include "jcgryss2.asm"
|
||||
%include "jcgryext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -77,7 +77,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extbgr_gray_convert_sse2
|
||||
%include "jcgryss2.asm"
|
||||
%include "jcgryext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -88,7 +88,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_BGRX_BLUE
|
||||
%define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extbgrx_gray_convert_sse2
|
||||
%include "jcgryss2.asm"
|
||||
%include "jcgryext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -99,7 +99,7 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XBGR_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extxbgr_gray_convert_sse2
|
||||
%include "jcgryss2.asm"
|
||||
%include "jcgryext-sse2.asm"
|
||||
|
||||
%undef RGB_RED
|
||||
%undef RGB_GREEN
|
||||
@@ -110,4 +110,4 @@ PD_ONEHALF times 4 dd (1 << (SCALEBITS-1))
|
||||
%define RGB_BLUE EXT_XRGB_BLUE
|
||||
%define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
|
||||
%define jsimd_rgb_gray_convert_sse2 jsimd_extxrgb_gray_convert_sse2
|
||||
%include "jcgryss2.asm"
|
||||
%include "jcgryext-sse2.asm"
|
||||
357
simd/jcgryext-mmx.asm
Normal file
357
simd/jcgryext-mmx.asm
Normal file
@@ -0,0 +1,357 @@
|
||||
;
|
||||
; jcgryext.asm - grayscale colorspace conversion (MMX)
|
||||
;
|
||||
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
; Copyright 2011 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"
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; Convert some rows of samples to the output colorspace.
|
||||
;
|
||||
; GLOBAL(void)
|
||||
; jsimd_rgb_gray_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 2
|
||||
%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr
|
||||
|
||||
align 16
|
||||
global EXTN(jsimd_rgb_gray_convert_mmx)
|
||||
|
||||
EXTN(jsimd_rgb_gray_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]
|
||||
lea edi, [edi+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 edi
|
||||
push esi
|
||||
push ecx ; col
|
||||
|
||||
mov esi, JSAMPROW [esi] ; inptr
|
||||
mov edi, JSAMPROW [edi] ; outptr0
|
||||
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_gray_cnv
|
||||
.column_ld16:
|
||||
test cl, 2*SIZEOF_MMWORD
|
||||
mov ecx, SIZEOF_MMWORD
|
||||
jz short .rgb_gray_cnv
|
||||
movq mmF,mmA
|
||||
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
|
||||
movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
|
||||
jmp short .rgb_gray_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_gray_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_gray_cnv
|
||||
movq mmD,mmA
|
||||
movq mmC,mmF
|
||||
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
|
||||
movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
|
||||
jmp short .rgb_gray_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_gray_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
|
||||
;
|
||||
; (This implementation)
|
||||
; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
|
||||
|
||||
movq mm6,mm1
|
||||
punpcklwd mm1,mm3
|
||||
punpckhwd mm6,mm3
|
||||
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)
|
||||
|
||||
movq mm7, mm6 ; mm7=ROH*FIX(0.299)+GOH*FIX(0.337)
|
||||
|
||||
movq mm6,mm0
|
||||
punpcklwd mm0,mm2
|
||||
punpckhwd mm6,mm2
|
||||
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)
|
||||
|
||||
movq MMWORD [wk(0)], mm0 ; wk(0)=REL*FIX(0.299)+GEL*FIX(0.337)
|
||||
movq MMWORD [wk(1)], mm6 ; wk(1)=REH*FIX(0.299)+GEH*FIX(0.337)
|
||||
|
||||
movq mm0, mm5 ; mm0=BO
|
||||
movq mm6, mm4 ; mm6=BE
|
||||
|
||||
movq mm4,mm0
|
||||
punpcklwd mm0,mm3
|
||||
punpckhwd mm4,mm3
|
||||
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)
|
||||
|
||||
movq mm3,[GOTOFF(eax,PD_ONEHALF)] ; mm3=[PD_ONEHALF]
|
||||
|
||||
paddd mm0, mm1
|
||||
paddd mm4, mm7
|
||||
paddd mm0,mm3
|
||||
paddd mm4,mm3
|
||||
psrld mm0,SCALEBITS ; mm0=YOL
|
||||
psrld mm4,SCALEBITS ; mm4=YOH
|
||||
packssdw mm0,mm4 ; mm0=YO
|
||||
|
||||
movq mm4,mm6
|
||||
punpcklwd mm6,mm2
|
||||
punpckhwd mm4,mm2
|
||||
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)
|
||||
|
||||
movq mm2,[GOTOFF(eax,PD_ONEHALF)] ; mm2=[PD_ONEHALF]
|
||||
|
||||
paddd mm6, MMWORD [wk(0)]
|
||||
paddd mm4, MMWORD [wk(1)]
|
||||
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
|
||||
|
||||
sub ecx, byte SIZEOF_MMWORD
|
||||
add esi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; inptr
|
||||
add edi, byte SIZEOF_MMWORD ; outptr0
|
||||
cmp ecx, byte SIZEOF_MMWORD
|
||||
jae near .columnloop
|
||||
test ecx,ecx
|
||||
jnz near .column_ld1
|
||||
|
||||
pop ecx ; col
|
||||
pop esi
|
||||
pop edi
|
||||
poppic eax
|
||||
|
||||
add esi, byte SIZEOF_JSAMPROW ; input_buf
|
||||
add edi, 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
|
||||
364
simd/jcgryext-sse2-64.asm
Normal file
364
simd/jcgryext-sse2-64.asm
Normal file
@@ -0,0 +1,364 @@
|
||||
;
|
||||
; jcgryext.asm - grayscale colorspace conversion (64-bit SSE2)
|
||||
;
|
||||
; x86 SIMD extension for IJG JPEG library
|
||||
; Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
; Copyright (C) 2011, 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"
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; Convert some rows of samples to the output colorspace.
|
||||
;
|
||||
; GLOBAL(void)
|
||||
; jsimd_rgb_gray_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 2
|
||||
|
||||
align 16
|
||||
|
||||
global EXTN(jsimd_rgb_gray_convert_sse2)
|
||||
|
||||
EXTN(jsimd_rgb_gray_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]
|
||||
lea rdi, [rdi+rcx*SIZEOF_JSAMPROW]
|
||||
|
||||
pop rcx
|
||||
|
||||
mov rsi, r11
|
||||
mov eax, r14d
|
||||
test rax,rax
|
||||
jle near .return
|
||||
.rowloop:
|
||||
push rdi
|
||||
push rsi
|
||||
push rcx ; col
|
||||
|
||||
mov rsi, JSAMPROW [rsi] ; inptr
|
||||
mov rdi, JSAMPROW [rdi] ; outptr0
|
||||
|
||||
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_gray_cnv
|
||||
.column_ld32:
|
||||
test cl, 2*SIZEOF_XMMWORD
|
||||
mov rcx, SIZEOF_XMMWORD
|
||||
jz short .rgb_gray_cnv
|
||||
movdqa xmmB,xmmA
|
||||
movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
|
||||
movdqu xmmF, XMMWORD [rsi+1*SIZEOF_XMMWORD]
|
||||
jmp short .rgb_gray_cnv
|
||||
|
||||
.columnloop:
|
||||
movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
|
||||
movdqu xmmF, XMMWORD [rsi+1*SIZEOF_XMMWORD]
|
||||
movdqu xmmB, XMMWORD [rsi+2*SIZEOF_XMMWORD]
|
||||
|
||||
.rgb_gray_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_gray_cnv
|
||||
movdqa xmmF,xmmA
|
||||
movdqa xmmH,xmmE
|
||||
movdqu xmmA, XMMWORD [rsi+0*SIZEOF_XMMWORD]
|
||||
movdqu xmmE, XMMWORD [rsi+1*SIZEOF_XMMWORD]
|
||||
jmp short .rgb_gray_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_gray_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
|
||||
;
|
||||
; (This implementation)
|
||||
; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
|
||||
|
||||
movdqa xmm6,xmm1
|
||||
punpcklwd xmm1,xmm3
|
||||
punpckhwd xmm6,xmm3
|
||||
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)
|
||||
|
||||
movdqa xmm7, xmm6 ; xmm7=ROH*FIX(0.299)+GOH*FIX(0.337)
|
||||
|
||||
movdqa xmm6,xmm0
|
||||
punpcklwd xmm0,xmm2
|
||||
punpckhwd xmm6,xmm2
|
||||
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)
|
||||
|
||||
movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=REL*FIX(0.299)+GEL*FIX(0.337)
|
||||
movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=REH*FIX(0.299)+GEH*FIX(0.337)
|
||||
|
||||
movdqa xmm0, xmm5 ; xmm0=BO
|
||||
movdqa xmm6, xmm4 ; xmm6=BE
|
||||
|
||||
movdqa xmm4,xmm0
|
||||
punpcklwd xmm0,xmm3
|
||||
punpckhwd xmm4,xmm3
|
||||
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)
|
||||
|
||||
movdqa xmm3,[rel PD_ONEHALF] ; xmm3=[PD_ONEHALF]
|
||||
|
||||
paddd xmm0, xmm1
|
||||
paddd xmm4, xmm7
|
||||
paddd xmm0,xmm3
|
||||
paddd xmm4,xmm3
|
||||
psrld xmm0,SCALEBITS ; xmm0=YOL
|
||||
psrld xmm4,SCALEBITS ; xmm4=YOH
|
||||
packssdw xmm0,xmm4 ; xmm0=YO
|
||||
|
||||
movdqa xmm4,xmm6
|
||||
punpcklwd xmm6,xmm2
|
||||
punpckhwd xmm4,xmm2
|
||||
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)
|
||||
|
||||
movdqa xmm2,[rel PD_ONEHALF] ; xmm2=[PD_ONEHALF]
|
||||
|
||||
paddd xmm6, XMMWORD [wk(0)]
|
||||
paddd xmm4, XMMWORD [wk(1)]
|
||||
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
|
||||
|
||||
sub rcx, byte SIZEOF_XMMWORD
|
||||
add rsi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; inptr
|
||||
add rdi, byte SIZEOF_XMMWORD ; outptr0
|
||||
cmp rcx, byte SIZEOF_XMMWORD
|
||||
jae near .columnloop
|
||||
test rcx,rcx
|
||||
jnz near .column_ld1
|
||||
|
||||
pop rcx ; col
|
||||
pop rsi
|
||||
pop rdi
|
||||
|
||||
add rsi, byte SIZEOF_JSAMPROW ; input_buf
|
||||
add rdi, 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
|
||||
383
simd/jcgryext-sse2.asm
Normal file
383
simd/jcgryext-sse2.asm
Normal file
@@ -0,0 +1,383 @@
|
||||
;
|
||||
; jcgryext.asm - grayscale colorspace conversion (SSE2)
|
||||
;
|
||||
; x86 SIMD extension for IJG JPEG library
|
||||
; Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
; Copyright (C) 2011, 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"
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; Convert some rows of samples to the output colorspace.
|
||||
;
|
||||
; GLOBAL(void)
|
||||
; jsimd_rgb_gray_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 2
|
||||
%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr
|
||||
|
||||
align 16
|
||||
|
||||
global EXTN(jsimd_rgb_gray_convert_sse2)
|
||||
|
||||
EXTN(jsimd_rgb_gray_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]
|
||||
lea edi, [edi+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 edi
|
||||
push esi
|
||||
push ecx ; col
|
||||
|
||||
mov esi, JSAMPROW [esi] ; inptr
|
||||
mov edi, JSAMPROW [edi] ; outptr0
|
||||
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_gray_cnv
|
||||
.column_ld32:
|
||||
test cl, 2*SIZEOF_XMMWORD
|
||||
mov ecx, SIZEOF_XMMWORD
|
||||
jz short .rgb_gray_cnv
|
||||
movdqa xmmB,xmmA
|
||||
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
|
||||
movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD]
|
||||
jmp short .rgb_gray_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_gray_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_gray_cnv
|
||||
movdqa xmmF,xmmA
|
||||
movdqa xmmH,xmmE
|
||||
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
|
||||
movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD]
|
||||
jmp short .rgb_gray_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_gray_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
|
||||
;
|
||||
; (This implementation)
|
||||
; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
|
||||
|
||||
movdqa xmm6,xmm1
|
||||
punpcklwd xmm1,xmm3
|
||||
punpckhwd xmm6,xmm3
|
||||
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)
|
||||
|
||||
movdqa xmm7, xmm6 ; xmm7=ROH*FIX(0.299)+GOH*FIX(0.337)
|
||||
|
||||
movdqa xmm6,xmm0
|
||||
punpcklwd xmm0,xmm2
|
||||
punpckhwd xmm6,xmm2
|
||||
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)
|
||||
|
||||
movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=REL*FIX(0.299)+GEL*FIX(0.337)
|
||||
movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=REH*FIX(0.299)+GEH*FIX(0.337)
|
||||
|
||||
movdqa xmm0, xmm5 ; xmm0=BO
|
||||
movdqa xmm6, xmm4 ; xmm6=BE
|
||||
|
||||
movdqa xmm4,xmm0
|
||||
punpcklwd xmm0,xmm3
|
||||
punpckhwd xmm4,xmm3
|
||||
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)
|
||||
|
||||
movdqa xmm3,[GOTOFF(eax,PD_ONEHALF)] ; xmm3=[PD_ONEHALF]
|
||||
|
||||
paddd xmm0, xmm1
|
||||
paddd xmm4, xmm7
|
||||
paddd xmm0,xmm3
|
||||
paddd xmm4,xmm3
|
||||
psrld xmm0,SCALEBITS ; xmm0=YOL
|
||||
psrld xmm4,SCALEBITS ; xmm4=YOH
|
||||
packssdw xmm0,xmm4 ; xmm0=YO
|
||||
|
||||
movdqa xmm4,xmm6
|
||||
punpcklwd xmm6,xmm2
|
||||
punpckhwd xmm4,xmm2
|
||||
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)
|
||||
|
||||
movdqa xmm2,[GOTOFF(eax,PD_ONEHALF)] ; xmm2=[PD_ONEHALF]
|
||||
|
||||
paddd xmm6, XMMWORD [wk(0)]
|
||||
paddd xmm4, XMMWORD [wk(1)]
|
||||
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
|
||||
|
||||
sub ecx, byte SIZEOF_XMMWORD
|
||||
add esi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; inptr
|
||||
add edi, byte SIZEOF_XMMWORD ; outptr0
|
||||
cmp ecx, byte SIZEOF_XMMWORD
|
||||
jae near .columnloop
|
||||
test ecx,ecx
|
||||
jnz near .column_ld1
|
||||
|
||||
pop ecx ; col
|
||||
pop esi
|
||||
pop edi
|
||||
poppic eax
|
||||
|
||||
add esi, byte SIZEOF_JSAMPROW ; input_buf
|
||||
add edi, 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
|
||||
@@ -1,357 +0,0 @@
|
||||
;
|
||||
; jcgrymmx.asm - grayscale colorspace conversion (MMX)
|
||||
;
|
||||
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
; Copyright 2011 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"
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; Convert some rows of samples to the output colorspace.
|
||||
;
|
||||
; GLOBAL(void)
|
||||
; jsimd_rgb_gray_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 2
|
||||
%define gotptr wk(0)-SIZEOF_POINTER ; void * gotptr
|
||||
|
||||
align 16
|
||||
global EXTN(jsimd_rgb_gray_convert_mmx)
|
||||
|
||||
EXTN(jsimd_rgb_gray_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]
|
||||
lea edi, [edi+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 edi
|
||||
push esi
|
||||
push ecx ; col
|
||||
|
||||
mov esi, JSAMPROW [esi] ; inptr
|
||||
mov edi, JSAMPROW [edi] ; outptr0
|
||||
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_gray_cnv
|
||||
.column_ld16:
|
||||
test cl, 2*SIZEOF_MMWORD
|
||||
mov ecx, SIZEOF_MMWORD
|
||||
jz short .rgb_gray_cnv
|
||||
movq mmF,mmA
|
||||
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
|
||||
movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
|
||||
jmp short .rgb_gray_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_gray_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_gray_cnv
|
||||
movq mmD,mmA
|
||||
movq mmC,mmF
|
||||
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
|
||||
movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
|
||||
jmp short .rgb_gray_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_gray_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
|
||||
;
|
||||
; (This implementation)
|
||||
; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G
|
||||
|
||||
movq mm6,mm1
|
||||
punpcklwd mm1,mm3
|
||||
punpckhwd mm6,mm3
|
||||
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)
|
||||
|
||||
movq mm7, mm6 ; mm7=ROH*FIX(0.299)+GOH*FIX(0.337)
|
||||
|
||||
movq mm6,mm0
|
||||
punpcklwd mm0,mm2
|
||||
punpckhwd mm6,mm2
|
||||
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)
|
||||
|
||||
movq MMWORD [wk(0)], mm0 ; wk(0)=REL*FIX(0.299)+GEL*FIX(0.337)
|
||||
movq MMWORD [wk(1)], mm6 ; wk(1)=REH*FIX(0.299)+GEH*FIX(0.337)
|
||||
|
||||
movq mm0, mm5 ; mm0=BO
|
||||
movq mm6, mm4 ; mm6=BE
|
||||
|
||||
movq mm4,mm0
|
||||
punpcklwd mm0,mm3
|
||||
punpckhwd mm4,mm3
|
||||
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)
|
||||
|
||||
movq mm3,[GOTOFF(eax,PD_ONEHALF)] ; mm3=[PD_ONEHALF]
|
||||
|
||||
paddd mm0, mm1
|
||||
paddd mm4, mm7
|
||||
paddd mm0,mm3
|
||||
paddd mm4,mm3
|
||||
psrld mm0,SCALEBITS ; mm0=YOL
|
||||
psrld mm4,SCALEBITS ; mm4=YOH
|
||||
packssdw mm0,mm4 ; mm0=YO
|
||||
|
||||
movq mm4,mm6
|
||||
punpcklwd mm6,mm2
|
||||
punpckhwd mm4,mm2
|
||||
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)
|
||||
|
||||
movq mm2,[GOTOFF(eax,PD_ONEHALF)] ; mm2=[PD_ONEHALF]
|
||||
|
||||
paddd mm6, MMWORD [wk(0)]
|
||||
paddd mm4, MMWORD [wk(1)]
|
||||
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
|
||||
|
||||
sub ecx, byte SIZEOF_MMWORD
|
||||
add esi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; inptr
|
||||
add edi, byte SIZEOF_MMWORD ; outptr0
|
||||
cmp ecx, byte SIZEOF_MMWORD
|
||||
jae near .columnloop
|
||||
test ecx,ecx
|
||||
jnz near .column_ld1
|
||||
|
||||
pop ecx ; col
|
||||
pop esi
|
||||
pop edi
|
||||
poppic eax
|
||||
|
||||
add esi, byte SIZEOF_JSAMPROW ; input_buf
|
||||
add edi, 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
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user