Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f154ccc091 | ||
|
|
9be7a47841 | ||
|
|
e5c1613ccd | ||
|
|
4d77515bc9 | ||
|
|
fb27709ab1 | ||
|
|
b0971e47d7 | ||
|
|
e248d430e2 | ||
|
|
acb634931a | ||
|
|
1db1ce45da | ||
|
|
d0c3aa900b | ||
|
|
6a2b067428 | ||
|
|
11eec4a398 | ||
|
|
301ba4f305 | ||
|
|
a9bfef2a57 | ||
|
|
12909e6a0f | ||
|
|
60a61a34fc | ||
|
|
216ccd6702 | ||
|
|
88e99ac246 | ||
|
|
70f236ddd7 | ||
|
|
2a4f189444 | ||
|
|
78e3171864 | ||
|
|
075a1e1afc | ||
|
|
2dd5ae7b83 | ||
|
|
e95be67503 | ||
|
|
9d64f3c60b | ||
|
|
da2a27ef05 | ||
|
|
c082dc039d | ||
|
|
d4c41fe0da | ||
|
|
499bd1da89 | ||
|
|
a0b7de9a47 | ||
|
|
2252795571 | ||
|
|
eb38b61bfe | ||
|
|
47b29e8cd9 | ||
|
|
e1e816e665 | ||
|
|
6441018150 | ||
|
|
fcfc6c5eed | ||
|
|
786b649331 | ||
|
|
f4ba09b33a | ||
|
|
0f4fcced0a | ||
|
|
82bf7f5858 | ||
|
|
3582ce90bb | ||
|
|
d6d7b53968 | ||
|
|
f9f0c75bb8 | ||
|
|
3da94de248 | ||
|
|
ab664e35fc | ||
|
|
ce26e83f47 | ||
|
|
74e4c793cd | ||
|
|
a280fa630c | ||
|
|
6aae007745 | ||
|
|
4ad94b2963 | ||
|
|
2d4b2f14d0 | ||
|
|
9366cf0bca | ||
|
|
13e6b151b0 | ||
|
|
1ee329d617 | ||
|
|
b47c5e737f | ||
|
|
ce262eb5d7 | ||
|
|
27f817cd11 | ||
|
|
0df2e2188b | ||
|
|
6d22430a3a | ||
|
|
e9e3a2edd7 | ||
|
|
211c69f317 | ||
|
|
1625253d49 | ||
|
|
a0047bdea4 | ||
|
|
7bfb22af12 | ||
|
|
ac4a899511 | ||
|
|
dfefba7752 | ||
|
|
4cf67f2363 | ||
|
|
9407cf7f47 | ||
|
|
cb88e5da80 | ||
|
|
e9d9c31fd2 | ||
|
|
077e5bb4e0 | ||
|
|
a1dd35680d | ||
|
|
a09ba29a55 | ||
|
|
8ce2c9119a | ||
|
|
db04435165 | ||
|
|
7723d7f7d0 | ||
|
|
628c168c86 | ||
|
|
1120ff29a1 | ||
|
|
1945ad961b | ||
|
|
6e9d43e085 | ||
|
|
9055fb408d | ||
|
|
9e6c6a14f8 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -43,3 +43,6 @@ Makefile
|
|||||||
/tjunittest
|
/tjunittest
|
||||||
/wrjpgcom
|
/wrjpgcom
|
||||||
/yuvjpeg
|
/yuvjpeg
|
||||||
|
test_yuv*.jpg
|
||||||
|
CMakeCache.txt
|
||||||
|
CTestTestfile.cmake
|
||||||
811
BUILDING.md
811
BUILDING.md
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@ if(POLICY CMP0022)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(mozjpeg C)
|
project(mozjpeg C)
|
||||||
set(VERSION 3.2)
|
set(VERSION 3.3.1)
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.")
|
message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.")
|
||||||
@@ -349,8 +349,20 @@ if(WITH_12BIT)
|
|||||||
set(MD5_PPM_GRAY_ISLOW 7213c10af507ad467da5578ca5ee1fca)
|
set(MD5_PPM_GRAY_ISLOW 7213c10af507ad467da5578ca5ee1fca)
|
||||||
set(MD5_PPM_GRAY_ISLOW_RGB e96ee81c30a6ed422d466338bd3de65d)
|
set(MD5_PPM_GRAY_ISLOW_RGB e96ee81c30a6ed422d466338bd3de65d)
|
||||||
set(MD5_JPEG_420S_IFAST_OPT 7af8e60be4d9c227ec63ac9b6630855e)
|
set(MD5_JPEG_420S_IFAST_OPT 7af8e60be4d9c227ec63ac9b6630855e)
|
||||||
|
if(64BIT)
|
||||||
|
# Windows/x64 uses SSE for floating point
|
||||||
set(MD5_JPEG_3x2_FLOAT_PROG a8c17daf77b457725ec929e215b603f8)
|
set(MD5_JPEG_3x2_FLOAT_PROG a8c17daf77b457725ec929e215b603f8)
|
||||||
set(MD5_PPM_3x2_FLOAT 42876ab9e5c2f76a87d08db5fbd57956)
|
set(MD5_PPM_3x2_FLOAT 42876ab9e5c2f76a87d08db5fbd57956)
|
||||||
|
else()
|
||||||
|
# Windows/x86 uses the 387 FPU for floating point
|
||||||
|
if(MSVC)
|
||||||
|
set(MD5_JPEG_3x2_FLOAT_PROG e27840755870fa849872e58aa0cd1400)
|
||||||
|
set(MD5_PPM_3x2_FLOAT 6c2880b83bb1aa41dfe330e7a9768690)
|
||||||
|
else()
|
||||||
|
set(MD5_JPEG_3x2_FLOAT_PROG bc6dbbefac2872f6b9d6c4a0ae60c3c0)
|
||||||
|
set(MD5_PPM_3x2_FLOAT f58119ee294198ac9b4a9f5645a34266)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
set(MD5_PPM_420M_ISLOW_2_1 4ca6be2a6f326ff9eaab63e70a8259c0)
|
set(MD5_PPM_420M_ISLOW_2_1 4ca6be2a6f326ff9eaab63e70a8259c0)
|
||||||
set(MD5_PPM_420M_ISLOW_15_8 12aa9f9534c1b3d7ba047322226365eb)
|
set(MD5_PPM_420M_ISLOW_15_8 12aa9f9534c1b3d7ba047322226365eb)
|
||||||
set(MD5_PPM_420M_ISLOW_13_8 f7e22817c7b25e1393e4ec101e9d4e96)
|
set(MD5_PPM_420M_ISLOW_13_8 f7e22817c7b25e1393e4ec101e9d4e96)
|
||||||
@@ -392,8 +404,18 @@ else()
|
|||||||
set(MD5_JPEG_3x2_FLOAT_PROG 343e3f8caf8af5986ebaf0bdc13b5c71)
|
set(MD5_JPEG_3x2_FLOAT_PROG 343e3f8caf8af5986ebaf0bdc13b5c71)
|
||||||
set(MD5_PPM_3x2_FLOAT 1a75f36e5904d6fc3a85a43da9ad89bb)
|
set(MD5_PPM_3x2_FLOAT 1a75f36e5904d6fc3a85a43da9ad89bb)
|
||||||
else()
|
else()
|
||||||
|
if(64BIT)
|
||||||
set(MD5_JPEG_3x2_FLOAT_PROG 9bca803d2042bd1eb03819e2bf92b3e5)
|
set(MD5_JPEG_3x2_FLOAT_PROG 9bca803d2042bd1eb03819e2bf92b3e5)
|
||||||
set(MD5_PPM_3x2_FLOAT f6bfab038438ed8f5522fbd33595dcdc)
|
set(MD5_PPM_3x2_FLOAT f6bfab038438ed8f5522fbd33595dcdc)
|
||||||
|
else()
|
||||||
|
if(MSVC)
|
||||||
|
set(MD5_JPEG_3x2_FLOAT_PROG 7999ce9cd0ee9b6c7043b7351ab7639d)
|
||||||
|
set(MD5_PPM_3x2_FLOAT 28cdc448a6b75e97892f0e0f8d4b21f3)
|
||||||
|
else()
|
||||||
|
set(MD5_JPEG_3x2_FLOAT_PROG 1657664a410e0822c924b54f6f65e6e9)
|
||||||
|
set(MD5_PPM_3x2_FLOAT cb0a1f027f3d2917c902b5640214e025)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
|
set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
|
||||||
set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617)
|
set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617)
|
||||||
@@ -826,7 +848,7 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
add_custom_target(testclean COMMAND ${MD5CMP} -P
|
add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
|
||||||
${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake)
|
${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake)
|
||||||
|
|
||||||
|
|
||||||
@@ -915,3 +937,8 @@ install(FILES ${CMAKE_SOURCE_DIR}/README.ijg ${CMAKE_SOURCE_DIR}/README-mozilla.
|
|||||||
install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
|
install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
|
||||||
${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
|
${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
|
||||||
DESTINATION include)
|
DESTINATION include)
|
||||||
|
|
||||||
|
configure_file("${CMAKE_SOURCE_DIR}/cmakescripts/cmake_uninstall.cmake.in"
|
||||||
|
"cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||||
|
|
||||||
|
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake)
|
||||||
|
|||||||
162
ChangeLog.md
162
ChangeLog.md
@@ -1,3 +1,165 @@
|
|||||||
|
1.5.2
|
||||||
|
=====
|
||||||
|
|
||||||
|
### Significant changes relative to 1.5.1:
|
||||||
|
|
||||||
|
1. Fixed a regression introduced by 1.5.1[7] that prevented libjpeg-turbo from
|
||||||
|
building with Android NDK platforms prior to android-21 (5.0).
|
||||||
|
|
||||||
|
2. Fixed a regression introduced by 1.5.1[1] that prevented the MIPS DSPR2 SIMD
|
||||||
|
code in libjpeg-turbo from building.
|
||||||
|
|
||||||
|
3. Fixed a regression introduced by 1.5 beta1[11] that prevented the Java
|
||||||
|
version of TJBench from outputting any reference images (the `-nowrite` switch
|
||||||
|
was accidentally enabled by default.)
|
||||||
|
|
||||||
|
4. libjpeg-turbo should now build and run with full AltiVec SIMD acceleration
|
||||||
|
on PowerPC-based AmigaOS 4 and OpenBSD systems.
|
||||||
|
|
||||||
|
5. Fixed build and runtime errors on Windows that occurred when building
|
||||||
|
libjpeg-turbo with libjpeg v7 API/ABI emulation and the in-memory
|
||||||
|
source/destination managers. Due to an oversight, the `jpeg_skip_scanlines()`
|
||||||
|
and `jpeg_crop_scanlines()` functions were not being included in jpeg7.dll when
|
||||||
|
libjpeg-turbo was built with `-DWITH_JPEG7=1` and `-DWITH_MEMSRCDST=1`.
|
||||||
|
|
||||||
|
6. Fixed "Bogus virtual array access" error that occurred when using the
|
||||||
|
lossless crop feature in jpegtran or the TurboJPEG API, if libjpeg-turbo was
|
||||||
|
built with libjpeg v7 API/ABI emulation. This was apparently a long-standing
|
||||||
|
bug that has existed since the introduction of libjpeg v7/v8 API/ABI emulation
|
||||||
|
in libjpeg-turbo v1.1.
|
||||||
|
|
||||||
|
7. The lossless transform features in jpegtran and the TurboJPEG API will now
|
||||||
|
always attempt to adjust the EXIF image width and height tags if the image size
|
||||||
|
changed as a result of the transform. This behavior has always existed when
|
||||||
|
using libjpeg v8 API/ABI emulation. It was supposed to be available with
|
||||||
|
libjpeg v7 API/ABI emulation as well but did not work properly due to a bug.
|
||||||
|
Furthermore, there was never any good reason not to enable it with libjpeg v6b
|
||||||
|
API/ABI emulation, since the behavior is entirely internal. Note that
|
||||||
|
`-copy all` must be passed to jpegtran in order to transfer the EXIF tags from
|
||||||
|
the source image to the destination image.
|
||||||
|
|
||||||
|
8. Fixed several memory leaks in the TurboJPEG API library that could occur
|
||||||
|
if the library was built with certain compilers and optimization levels
|
||||||
|
(known to occur with GCC 4.x and clang with `-O1` and higher but not with
|
||||||
|
GCC 5.x or 6.x) and one of the underlying libjpeg API functions threw an error
|
||||||
|
after a TurboJPEG API function allocated a local buffer.
|
||||||
|
|
||||||
|
9. The libjpeg-turbo memory manager will now honor the `max_memory_to_use`
|
||||||
|
structure member in jpeg\_memory\_mgr, which can be set to the maximum amount
|
||||||
|
of memory (in bytes) that libjpeg-turbo should use during decompression or
|
||||||
|
multi-pass (including progressive) compression. This limit can also be set
|
||||||
|
using the `JPEGMEM` environment variable or using the `-maxmemory` switch in
|
||||||
|
cjpeg/djpeg/jpegtran (refer to the respective man pages for more details.)
|
||||||
|
This has been a documented feature of libjpeg since v5, but the
|
||||||
|
`malloc()`/`free()` implementation of the memory manager (jmemnobs.c) never
|
||||||
|
implemented the feature. Restricting libjpeg-turbo's memory usage is useful
|
||||||
|
for two reasons: it allows testers to more easily work around the 2 GB limit
|
||||||
|
in libFuzzer, and it allows developers of security-sensitive applications to
|
||||||
|
more easily defend against one of the progressive JPEG exploits (LJT-01-004)
|
||||||
|
identified in
|
||||||
|
[this report](http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
|
||||||
|
|
||||||
|
10. TJBench will now run each benchmark for 1 second prior to starting the
|
||||||
|
timer, in order to improve the consistency of the results. Furthermore, the
|
||||||
|
`-warmup` option is now used to specify the amount of warmup time rather than
|
||||||
|
the number of warmup iterations.
|
||||||
|
|
||||||
|
11. Fixed an error (`short jump is out of range`) that occurred when assembling
|
||||||
|
the 32-bit x86 SIMD extensions with NASM versions prior to 2.04. This was a
|
||||||
|
regression introduced by 1.5 beta1[12].
|
||||||
|
|
||||||
|
|
||||||
|
1.5.1
|
||||||
|
=====
|
||||||
|
|
||||||
|
### Significant changes relative to 1.5.0:
|
||||||
|
|
||||||
|
1. Previously, the undocumented `JSIMD_FORCE*` environment variables could be
|
||||||
|
used to force-enable a particular SIMD instruction set if multiple instruction
|
||||||
|
sets were available on a particular platform. On x86 platforms, where CPU
|
||||||
|
feature detection is bulletproof and multiple SIMD instruction sets are
|
||||||
|
available, it makes sense for those environment variables to allow forcing the
|
||||||
|
use of an instruction set only if that instruction set is available. However,
|
||||||
|
since the ARM implementations of libjpeg-turbo can only use one SIMD
|
||||||
|
instruction set, and since their feature detection code is less bulletproof
|
||||||
|
(parsing /proc/cpuinfo), it makes sense for the `JSIMD_FORCENEON` environment
|
||||||
|
variable to bypass the feature detection code and really force the use of NEON
|
||||||
|
instructions. A new environment variable (`JSIMD_FORCEDSPR2`) was introduced
|
||||||
|
in the MIPS implementation for the same reasons, and the existing
|
||||||
|
`JSIMD_FORCENONE` environment variable was extended to that implementation.
|
||||||
|
These environment variables provide a workaround for those attempting to test
|
||||||
|
ARM and MIPS builds of libjpeg-turbo in QEMU, which passes through
|
||||||
|
/proc/cpuinfo from the host system.
|
||||||
|
|
||||||
|
2. libjpeg-turbo previously assumed that AltiVec instructions were always
|
||||||
|
available on PowerPC platforms, which led to "illegal instruction" errors when
|
||||||
|
running on PowerPC chips that lack AltiVec support (such as the older 7xx/G3
|
||||||
|
and newer e5500 series.) libjpeg-turbo now examines /proc/cpuinfo on
|
||||||
|
Linux/Android systems and enables AltiVec instructions only if the CPU supports
|
||||||
|
them. It also now provides two environment variables, `JSIMD_FORCEALTIVEC` and
|
||||||
|
`JSIMD_FORCENONE`, to force-enable and force-disable AltiVec instructions in
|
||||||
|
environments where /proc/cpuinfo is an unreliable means of CPU feature
|
||||||
|
detection (such as when running in QEMU.) On OS X, libjpeg-turbo continues to
|
||||||
|
assume that AltiVec support is always available, which means that libjpeg-turbo
|
||||||
|
cannot be used with G3 Macs unless you set the environment variable
|
||||||
|
`JSIMD_FORCENONE` to `1`.
|
||||||
|
|
||||||
|
3. Fixed an issue whereby 64-bit ARM (AArch64) builds of libjpeg-turbo would
|
||||||
|
crash when built with recent releases of the Clang/LLVM compiler. This was
|
||||||
|
caused by an ABI conformance issue in some of libjpeg-turbo's 64-bit NEON SIMD
|
||||||
|
routines. Those routines were incorrectly using 64-bit instructions to
|
||||||
|
transfer a 32-bit JDIMENSION argument, whereas the ABI allows the upper
|
||||||
|
(unused) 32 bits of a 32-bit argument's register to be undefined. The new
|
||||||
|
Clang/LLVM optimizer uses load combining to transfer multiple adjacent 32-bit
|
||||||
|
structure members into a single 64-bit register, and this exposed the ABI
|
||||||
|
conformance issue.
|
||||||
|
|
||||||
|
4. Fancy upsampling is now supported when decompressing JPEG images that use
|
||||||
|
4:4:0 (h1v2) chroma subsampling. These images are generated when losslessly
|
||||||
|
rotating or transposing JPEG images that use 4:2:2 (h2v1) chroma subsampling.
|
||||||
|
The h1v2 fancy upsampling algorithm is not currently SIMD-accelerated.
|
||||||
|
|
||||||
|
5. If merged upsampling isn't SIMD-accelerated but YCbCr-to-RGB conversion is,
|
||||||
|
then libjpeg-turbo will now disable merged upsampling when decompressing YCbCr
|
||||||
|
JPEG images into RGB or extended RGB output images. This significantly speeds
|
||||||
|
up the decompression of 4:2:0 and 4:2:2 JPEGs on ARM platforms if fancy
|
||||||
|
upsampling is not used (for example, if the `-nosmooth` option to djpeg is
|
||||||
|
specified.)
|
||||||
|
|
||||||
|
6. The TurboJPEG API will now decompress 4:2:2 and 4:4:0 JPEG images with
|
||||||
|
2x2 luminance sampling factors and 2x1 or 1x2 chrominance sampling factors.
|
||||||
|
This is a non-standard way of specifying 2x subsampling (normally 4:2:2 JPEGs
|
||||||
|
have 2x1 luminance and 1x1 chrominance sampling factors, and 4:4:0 JPEGs have
|
||||||
|
1x2 luminance and 1x1 chrominance sampling factors), but the JPEG specification
|
||||||
|
and the libjpeg API both allow it.
|
||||||
|
|
||||||
|
7. Fixed an unsigned integer overflow in the libjpeg memory manager, detected
|
||||||
|
by the Clang undefined behavior sanitizer, that could be triggered by
|
||||||
|
attempting to decompress a specially-crafted malformed JPEG image. This issue
|
||||||
|
affected only 32-bit code and did not pose a security threat, but removing the
|
||||||
|
warning makes it easier to detect actual security issues, should they arise in
|
||||||
|
the future.
|
||||||
|
|
||||||
|
8. Fixed additional negative left shifts and other issues reported by the GCC
|
||||||
|
and Clang undefined behavior sanitizers when attempting to decompress
|
||||||
|
specially-crafted malformed JPEG images. None of these issues posed a security
|
||||||
|
threat, but removing the warnings makes it easier to detect actual security
|
||||||
|
issues, should they arise in the future.
|
||||||
|
|
||||||
|
9. Fixed an out-of-bounds array reference, introduced by 1.4.90[2] (partial
|
||||||
|
image decompression) and detected by the Clang undefined behavior sanitizer,
|
||||||
|
that could be triggered by a specially-crafted malformed JPEG image with more
|
||||||
|
than four components. Because the out-of-bounds reference was still within the
|
||||||
|
same structure, it was not known to pose a security threat, but removing the
|
||||||
|
warning makes it easier to detect actual security issues, should they arise in
|
||||||
|
the future.
|
||||||
|
|
||||||
|
10. Fixed another ABI conformance issue in the 64-bit ARM (AArch64) NEON SIMD
|
||||||
|
code. Some of the routines were incorrectly reading and storing data below the
|
||||||
|
stack pointer, which caused segfaults in certain applications under specific
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
|
||||||
1.5.0
|
1.5.0
|
||||||
=====
|
=====
|
||||||
|
|
||||||
|
|||||||
57
LICENSE.md
57
LICENSE.md
@@ -9,12 +9,11 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
|
|||||||
This license applies to the libjpeg API library and associated programs
|
This license applies to the libjpeg API library and associated programs
|
||||||
(any code inherited from libjpeg, and any modifications to that code.)
|
(any code inherited from libjpeg, and any modifications to that code.)
|
||||||
|
|
||||||
- The Modified (3-clause) BSD License, which is listed in
|
- The Modified (3-clause) BSD License, which is listed below
|
||||||
[turbojpeg.c](turbojpeg.c)
|
|
||||||
|
|
||||||
This license covers the TurboJPEG API library and associated programs.
|
This license covers the TurboJPEG API library and associated programs.
|
||||||
|
|
||||||
- The zlib License, which is listed in [simd/jsimdext.inc](simd/jsimdext.inc)
|
- The zlib License, which is listed below
|
||||||
|
|
||||||
This license is a subset of the other two, and it covers the libjpeg-turbo
|
This license is a subset of the other two, and it covers the libjpeg-turbo
|
||||||
SIMD extensions.
|
SIMD extensions.
|
||||||
@@ -86,3 +85,55 @@ best of our understanding.
|
|||||||
- IJG License
|
- IJG License
|
||||||
- Modified BSD License
|
- Modified BSD License
|
||||||
- zlib License
|
- zlib License
|
||||||
|
|
||||||
|
|
||||||
|
The Modified (3-clause) BSD License
|
||||||
|
===================================
|
||||||
|
|
||||||
|
Copyright (C)\<YEAR\> \<AUTHOR\>. All Rights Reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
- Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of the libjpeg-turbo Project nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from this
|
||||||
|
software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
The zlib License
|
||||||
|
================
|
||||||
|
|
||||||
|
Copyright (C) \<YEAR\>, \<AUTHOR\>.
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|||||||
24
Makefile.am
24
Makefile.am
@@ -11,7 +11,10 @@ endif
|
|||||||
nodist_include_HEADERS = jconfig.h
|
nodist_include_HEADERS = jconfig.h
|
||||||
|
|
||||||
pkgconfigdir = $(libdir)/pkgconfig
|
pkgconfigdir = $(libdir)/pkgconfig
|
||||||
pkgconfig_DATA = pkgscripts/libjpeg.pc pkgscripts/libturbojpeg.pc
|
pkgconfig_DATA = pkgscripts/libjpeg.pc
|
||||||
|
if WITH_TURBOJPEG
|
||||||
|
pkgconfig_DATA += pkgscripts/libturbojpeg.pc
|
||||||
|
endif
|
||||||
|
|
||||||
HDRS = jchuff.h jcmaster.h jdct.h jdhuff.h jerror.h jinclude.h jmemsys.h \
|
HDRS = jchuff.h jcmaster.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 \
|
jmorecfg.h jpegint.h jpeglib.h jversion.h jsimd.h jsimddct.h jpegcomp.h \
|
||||||
@@ -213,6 +216,8 @@ MD5_PPM_3x2_FLOAT_SSE = 42876ab9e5c2f76a87d08db5fbd57956
|
|||||||
MD5_JPEG_3x2_FLOAT_PROG_32BIT = a8c17daf77b457725ec929e215b603f8
|
MD5_JPEG_3x2_FLOAT_PROG_32BIT = a8c17daf77b457725ec929e215b603f8
|
||||||
MD5_PPM_3x2_FLOAT_32BIT = 42876ab9e5c2f76a87d08db5fbd57956
|
MD5_PPM_3x2_FLOAT_32BIT = 42876ab9e5c2f76a87d08db5fbd57956
|
||||||
MD5_PPM_3x2_FLOAT_64BIT = d6fbc71153b3d8ded484dbc17c7b9cf4
|
MD5_PPM_3x2_FLOAT_64BIT = d6fbc71153b3d8ded484dbc17c7b9cf4
|
||||||
|
MD5_JPEG_3x2_FLOAT_PROG_387 = bc6dbbefac2872f6b9d6c4a0ae60c3c0
|
||||||
|
MD5_PPM_3x2_FLOAT_387 = bcc5723c61560463ac60f772e742d092
|
||||||
MD5_JPEG_3x2_IFAST_PROG = 1396cc2b7185cfe943d408c9d305339e
|
MD5_JPEG_3x2_IFAST_PROG = 1396cc2b7185cfe943d408c9d305339e
|
||||||
MD5_PPM_3x2_IFAST = 3975985ef6eeb0a2cdc58daa651ccc00
|
MD5_PPM_3x2_IFAST = 3975985ef6eeb0a2cdc58daa651ccc00
|
||||||
MD5_PPM_420M_ISLOW_2_1 = 4ca6be2a6f326ff9eaab63e70a8259c0
|
MD5_PPM_420M_ISLOW_2_1 = 4ca6be2a6f326ff9eaab63e70a8259c0
|
||||||
@@ -260,6 +265,8 @@ MD5_PPM_3x2_FLOAT_SSE = 1a75f36e5904d6fc3a85a43da9ad89bb
|
|||||||
MD5_JPEG_3x2_FLOAT_PROG_32BIT = 9bca803d2042bd1eb03819e2bf92b3e5
|
MD5_JPEG_3x2_FLOAT_PROG_32BIT = 9bca803d2042bd1eb03819e2bf92b3e5
|
||||||
MD5_PPM_3x2_FLOAT_32BIT = f6bfab038438ed8f5522fbd33595dcdc
|
MD5_PPM_3x2_FLOAT_32BIT = f6bfab038438ed8f5522fbd33595dcdc
|
||||||
MD5_PPM_3x2_FLOAT_64BIT = 0e917a34193ef976b679a6b069b1be26
|
MD5_PPM_3x2_FLOAT_64BIT = 0e917a34193ef976b679a6b069b1be26
|
||||||
|
MD5_JPEG_3x2_FLOAT_PROG_387 = 1657664a410e0822c924b54f6f65e6e9
|
||||||
|
MD5_PPM_3x2_FLOAT_387 = cb0a1f027f3d2917c902b5640214e025
|
||||||
MD5_JPEG_3x2_IFAST_PROG = 1ee5d2c1a77f2da495f993c8c7cceca5
|
MD5_JPEG_3x2_IFAST_PROG = 1ee5d2c1a77f2da495f993c8c7cceca5
|
||||||
MD5_PPM_3x2_IFAST = fd283664b3b49127984af0a7f118fccd
|
MD5_PPM_3x2_IFAST = fd283664b3b49127984af0a7f118fccd
|
||||||
MD5_JPEG_420_ISLOW_ARI = e986fb0a637a8d833d96e8a6d6d84ea1
|
MD5_JPEG_420_ISLOW_ARI = e986fb0a637a8d833d96e8a6d6d84ea1
|
||||||
@@ -348,7 +355,7 @@ MD5_PPM_444_TILE = 7964e41e67cfb8d0a587c0aa4798f9c3
|
|||||||
# Test compressing from/decompressing to an arbitrary subregion of a larger
|
# Test compressing from/decompressing to an arbitrary subregion of a larger
|
||||||
# image buffer
|
# image buffer
|
||||||
cp $(srcdir)/testimages/testorig.ppm testout_tile.ppm
|
cp $(srcdir)/testimages/testorig.ppm testout_tile.ppm
|
||||||
TJ_REVERT=1 ./tjbench testout_tile.ppm 95 -rgb -quiet -tile -benchtime 0.01 >/dev/null 2>&1
|
TJ_REVERT=1 ./tjbench testout_tile.ppm 95 -rgb -quiet -tile -benchtime 0.01 -warmup 0 >/dev/null 2>&1
|
||||||
for i in 8 16 32 64 128; do \
|
for i in 8 16 32 64 128; do \
|
||||||
md5/md5cmp $(MD5_PPM_GRAY_TILE) testout_tile_GRAY_Q95_$$i\x$$i.ppm; \
|
md5/md5cmp $(MD5_PPM_GRAY_TILE) testout_tile_GRAY_Q95_$$i\x$$i.ppm; \
|
||||||
done
|
done
|
||||||
@@ -367,7 +374,7 @@ MD5_PPM_444_TILE = 7964e41e67cfb8d0a587c0aa4798f9c3
|
|||||||
done
|
done
|
||||||
rm -f testout_tile_GRAY_* testout_tile_420_* testout_tile_422_* testout_tile_444_*
|
rm -f testout_tile_GRAY_* testout_tile_420_* testout_tile_422_* testout_tile_444_*
|
||||||
|
|
||||||
TJ_REVERT=1 ./tjbench testout_tile.ppm 95 -rgb -fastupsample -quiet -tile -benchtime 0.01 >/dev/null 2>&1
|
TJ_REVERT=1 ./tjbench testout_tile.ppm 95 -rgb -fastupsample -quiet -tile -benchtime 0.01 -warmup 0 >/dev/null 2>&1
|
||||||
md5/md5cmp $(MD5_PPM_420M_8x8_TILE) testout_tile_420_Q95_8x8.ppm
|
md5/md5cmp $(MD5_PPM_420M_8x8_TILE) testout_tile_420_Q95_8x8.ppm
|
||||||
for i in 16 32 64 128; do \
|
for i in 16 32 64 128; do \
|
||||||
md5/md5cmp $(MD5_PPM_420M_TILE) testout_tile_420_Q95_$$i\x$$i.ppm; \
|
md5/md5cmp $(MD5_PPM_420M_TILE) testout_tile_420_Q95_$$i\x$$i.ppm; \
|
||||||
@@ -492,6 +499,9 @@ endif
|
|||||||
# x86-64 compilers)
|
# x86-64 compilers)
|
||||||
# FLOATTEST=64bit validate against the exepected results from the C code
|
# FLOATTEST=64bit validate against the exepected results from the C code
|
||||||
# when running on a 64-bit FPU
|
# when running on a 64-bit FPU
|
||||||
|
# FLOATTEST=387 validate against the expected results from the C code when
|
||||||
|
# the 387 FPU is being used for floating point math (which is
|
||||||
|
# generally the default with x86 compilers)
|
||||||
|
|
||||||
# CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff
|
# CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff
|
||||||
./cjpeg -revert -sample 3x2 -dct float -prog -outfile testout_3x2_float_prog.jpg $(srcdir)/testimages/testorig.ppm
|
./cjpeg -revert -sample 3x2 -dct float -prog -outfile testout_3x2_float_prog.jpg $(srcdir)/testimages/testorig.ppm
|
||||||
@@ -499,6 +509,8 @@ endif
|
|||||||
md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_SSE) testout_3x2_float_prog.jpg; \
|
md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_SSE) testout_3x2_float_prog.jpg; \
|
||||||
elif [ "${FLOATTEST}" = "32bit" -o "${FLOATTEST}" = "64bit" ]; then \
|
elif [ "${FLOATTEST}" = "32bit" -o "${FLOATTEST}" = "64bit" ]; then \
|
||||||
md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_32BIT) testout_3x2_float_prog.jpg; \
|
md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_32BIT) testout_3x2_float_prog.jpg; \
|
||||||
|
elif [ "${FLOATTEST}" = "387" ]; then \
|
||||||
|
md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_387) testout_3x2_float_prog.jpg; \
|
||||||
fi
|
fi
|
||||||
# CC: YCC->RGB SAMP: fullsize/int IDCT: float ENT: prog huff
|
# CC: YCC->RGB SAMP: fullsize/int IDCT: float ENT: prog huff
|
||||||
./djpeg -dct float -outfile testout_3x2_float.ppm testout_3x2_float_prog.jpg
|
./djpeg -dct float -outfile testout_3x2_float.ppm testout_3x2_float_prog.jpg
|
||||||
@@ -508,6 +520,8 @@ endif
|
|||||||
md5/md5cmp $(MD5_PPM_3x2_FLOAT_32BIT) testout_3x2_float.ppm; \
|
md5/md5cmp $(MD5_PPM_3x2_FLOAT_32BIT) testout_3x2_float.ppm; \
|
||||||
elif [ "${FLOATTEST}" = "64bit" ]; then \
|
elif [ "${FLOATTEST}" = "64bit" ]; then \
|
||||||
md5/md5cmp $(MD5_PPM_3x2_FLOAT_64BIT) testout_3x2_float.ppm; \
|
md5/md5cmp $(MD5_PPM_3x2_FLOAT_64BIT) testout_3x2_float.ppm; \
|
||||||
|
elif [ "${FLOATTEST}" = "387" ]; then \
|
||||||
|
md5/md5cmp $(MD5_PPM_3x2_FLOAT_387) testout_3x2_float.ppm; \
|
||||||
fi
|
fi
|
||||||
rm -f testout_3x2_float.ppm testout_3x2_float_prog.jpg
|
rm -f testout_3x2_float.ppm testout_3x2_float_prog.jpg
|
||||||
|
|
||||||
@@ -771,12 +785,12 @@ udmg: all pkgscripts/makemacpkg pkgscripts/uninstall
|
|||||||
sh pkgscripts/makemacpkg -build32 ${BUILDDIR32}
|
sh pkgscripts/makemacpkg -build32 ${BUILDDIR32}
|
||||||
|
|
||||||
iosdmg: all pkgscripts/makemacpkg pkgscripts/uninstall
|
iosdmg: all pkgscripts/makemacpkg pkgscripts/uninstall
|
||||||
sh pkgscripts/makemacpkg -build32 ${BUILDDIR32} -buildarmv6 ${BUILDDIRARMV6} -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S} -buildarmv8 ${BUILDDIRARMV8} -lipo "${LIPO}"
|
sh pkgscripts/makemacpkg -build32 ${BUILDDIR32} -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S} -buildarmv8 ${BUILDDIRARMV8} -lipo "${LIPO}"
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
iosdmg: all pkgscripts/makemacpkg pkgscripts/uninstall
|
iosdmg: all pkgscripts/makemacpkg pkgscripts/uninstall
|
||||||
sh pkgscripts/makemacpkg -buildarmv6 ${BUILDDIRARMV6} -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S} -buildarmv8 ${BUILDDIRARMV8} -lipo "${LIPO}"
|
sh pkgscripts/makemacpkg -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S} -buildarmv8 ${BUILDDIRARMV8} -lipo "${LIPO}"
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
21
bmp.c
21
bmp.c
@@ -108,10 +108,14 @@ static void pixelconvert(unsigned char *srcbuf, int srcpf, int srcbottomup,
|
|||||||
m=(m-k)/(1.0-k);
|
m=(m-k)/(1.0-k);
|
||||||
y=(y-k)/(1.0-k);
|
y=(y-k)/(1.0-k);
|
||||||
}
|
}
|
||||||
if(c>1.0) c=1.0; if(c<0.) c=0.;
|
if(c>1.0) c=1.0;
|
||||||
if(m>1.0) m=1.0; if(m<0.) m=0.;
|
if(c<0.) c=0.;
|
||||||
if(y>1.0) y=1.0; if(y<0.) y=0.;
|
if(m>1.0) m=1.0;
|
||||||
if(k>1.0) k=1.0; if(k<0.) k=0.;
|
if(m<0.) m=0.;
|
||||||
|
if(y>1.0) y=1.0;
|
||||||
|
if(y<0.) y=0.;
|
||||||
|
if(k>1.0) k=1.0;
|
||||||
|
if(k<0.) k=0.;
|
||||||
*dstcolptr++=(unsigned char)(255.0-c*255.0+0.5);
|
*dstcolptr++=(unsigned char)(255.0-c*255.0+0.5);
|
||||||
*dstcolptr++=(unsigned char)(255.0-m*255.0+0.5);
|
*dstcolptr++=(unsigned char)(255.0-m*255.0+0.5);
|
||||||
*dstcolptr++=(unsigned char)(255.0-y*255.0+0.5);
|
*dstcolptr++=(unsigned char)(255.0-y*255.0+0.5);
|
||||||
@@ -133,9 +137,12 @@ static void pixelconvert(unsigned char *srcbuf, int srcpf, int srcbottomup,
|
|||||||
double r=c*k/255.;
|
double r=c*k/255.;
|
||||||
double g=m*k/255.;
|
double g=m*k/255.;
|
||||||
double b=y*k/255.;
|
double b=y*k/255.;
|
||||||
if(r>255.0) r=255.0; if(r<0.) r=0.;
|
if(r>255.0) r=255.0;
|
||||||
if(g>255.0) g=255.0; if(g<0.) g=0.;
|
if(r<0.) r=0.;
|
||||||
if(b>255.0) b=255.0; if(b<0.) b=0.;
|
if(g>255.0) g=255.0;
|
||||||
|
if(g<0.) g=0.;
|
||||||
|
if(b>255.0) b=255.0;
|
||||||
|
if(b<0.) b=0.;
|
||||||
dstcolptr[tjRedOffset[dstpf]]=(unsigned char)(r+0.5);
|
dstcolptr[tjRedOffset[dstpf]]=(unsigned char)(r+0.5);
|
||||||
dstcolptr[tjGreenOffset[dstpf]]=(unsigned char)(g+0.5);
|
dstcolptr[tjGreenOffset[dstpf]]=(unsigned char)(g+0.5);
|
||||||
dstcolptr[tjBlueOffset[dstpf]]=(unsigned char)(b+0.5);
|
dstcolptr[tjBlueOffset[dstpf]]=(unsigned char)(b+0.5);
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format")
|
|||||||
|
|
||||||
#ifdef PNG_SUPPORTED
|
#ifdef PNG_SUPPORTED
|
||||||
JMESSAGE(JERR_PNG_ERROR, "Unable to read PNG file: %s")
|
JMESSAGE(JERR_PNG_ERROR, "Unable to read PNG file: %s")
|
||||||
|
JMESSAGE(JERR_PNG_PROFILETOOLARGE, "Embedded profile was too large for this tool - dropped.")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef JMAKE_ENUM_LIST
|
#ifdef JMAKE_ENUM_LIST
|
||||||
|
|||||||
4
cjpeg.1
4
cjpeg.1
@@ -1,4 +1,4 @@
|
|||||||
.TH CJPEG 1 "17 February 2016"
|
.TH CJPEG 1 "18 March 2017"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
cjpeg \- compress an image file to a JPEG file
|
cjpeg \- compress an image file to a JPEG file
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -202,7 +202,7 @@ Set limit for amount of memory to use in processing large images. Value is
|
|||||||
in thousands of bytes, or millions of bytes if "M" is attached to the
|
in thousands of bytes, or millions of bytes if "M" is attached to the
|
||||||
number. For example,
|
number. For example,
|
||||||
.B \-max 4m
|
.B \-max 4m
|
||||||
selects 4000000 bytes. If more space is needed, temporary files will be used.
|
selects 4000000 bytes. If more space is needed, an error will occur.
|
||||||
.TP
|
.TP
|
||||||
.BI \-outfile " name"
|
.BI \-outfile " name"
|
||||||
Send output image to the named file, not to standard output.
|
Send output image to the named file, not to standard output.
|
||||||
|
|||||||
11
cjpeg.c
11
cjpeg.c
@@ -5,7 +5,7 @@
|
|||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modified 2003-2011 by Guido Vollbeding.
|
* Modified 2003-2011 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, 2013-2014, D. R. Commander.
|
* Copyright (C) 2010, 2013-2014, 2017, D. R. Commander.
|
||||||
* mozjpeg Modifications:
|
* mozjpeg Modifications:
|
||||||
* Copyright (C) 2014, Mozilla Corporation.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
@@ -81,6 +81,7 @@ static const char * const cdjpeg_message_table[] = {
|
|||||||
|
|
||||||
static boolean is_targa; /* records user -targa switch */
|
static boolean is_targa; /* records user -targa switch */
|
||||||
static boolean is_jpeg;
|
static boolean is_jpeg;
|
||||||
|
static boolean copy_markers;
|
||||||
|
|
||||||
LOCAL(cjpeg_source_ptr)
|
LOCAL(cjpeg_source_ptr)
|
||||||
select_file_type (j_compress_ptr cinfo, FILE *infile)
|
select_file_type (j_compress_ptr cinfo, FILE *infile)
|
||||||
@@ -115,6 +116,7 @@ select_file_type (j_compress_ptr cinfo, FILE *infile)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef PNG_SUPPORTED
|
#ifdef PNG_SUPPORTED
|
||||||
case 0x89:
|
case 0x89:
|
||||||
|
copy_markers = TRUE;
|
||||||
return jinit_read_png(cinfo);
|
return jinit_read_png(cinfo);
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLE_SUPPORTED
|
#ifdef RLE_SUPPORTED
|
||||||
@@ -127,6 +129,7 @@ select_file_type (j_compress_ptr cinfo, FILE *infile)
|
|||||||
#endif
|
#endif
|
||||||
case 0xff:
|
case 0xff:
|
||||||
is_jpeg = TRUE;
|
is_jpeg = TRUE;
|
||||||
|
copy_markers = TRUE;
|
||||||
return jinit_read_jpeg(cinfo);
|
return jinit_read_jpeg(cinfo);
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_UNKNOWN_FORMAT);
|
ERREXIT(cinfo, JERR_UNKNOWN_FORMAT);
|
||||||
@@ -228,11 +231,11 @@ usage (void)
|
|||||||
fprintf(stderr, " -verbose or -debug Emit debug output\n");
|
fprintf(stderr, " -verbose or -debug Emit debug output\n");
|
||||||
fprintf(stderr, " -version Print version information and exit\n");
|
fprintf(stderr, " -version Print version information and exit\n");
|
||||||
fprintf(stderr, "Switches for wizards:\n");
|
fprintf(stderr, "Switches for wizards:\n");
|
||||||
fprintf(stderr, " -qtables file Use quantization tables given in file\n");
|
fprintf(stderr, " -qtables FILE Use quantization tables given in FILE\n");
|
||||||
fprintf(stderr, " -qslots N[,...] Set component quantization tables\n");
|
fprintf(stderr, " -qslots N[,...] Set component quantization tables\n");
|
||||||
fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n");
|
fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n");
|
||||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||||
fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n");
|
fprintf(stderr, " -scans FILE Create multi-scan JPEG per script FILE\n");
|
||||||
#endif
|
#endif
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -766,7 +769,7 @@ main (int argc, char **argv)
|
|||||||
jpeg_start_compress(&cinfo, TRUE);
|
jpeg_start_compress(&cinfo, TRUE);
|
||||||
|
|
||||||
/* Copy metadata */
|
/* Copy metadata */
|
||||||
if (is_jpeg) {
|
if (copy_markers) {
|
||||||
jpeg_saved_marker_ptr marker;
|
jpeg_saved_marker_ptr marker;
|
||||||
|
|
||||||
/* In the current implementation, we don't actually need to examine the
|
/* In the current implementation, we don't actually need to examine the
|
||||||
|
|||||||
24
cmakescripts/cmake_uninstall.cmake.in
Normal file
24
cmakescripts/cmake_uninstall.cmake.in
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# This code is from the CMake FAQ
|
||||||
|
|
||||||
|
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||||
|
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
|
||||||
|
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||||
|
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||||
|
list(REVERSE files)
|
||||||
|
foreach (file ${files})
|
||||||
|
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||||
|
if (EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
execute_process(
|
||||||
|
COMMAND "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}"
|
||||||
|
OUTPUT_VARIABLE rm_out
|
||||||
|
RESULT_VARIABLE rm_retval
|
||||||
|
)
|
||||||
|
if(NOT ${rm_retval} EQUAL 0)
|
||||||
|
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||||
|
endif (NOT ${rm_retval} EQUAL 0)
|
||||||
|
else (EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||||
|
endif (EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
endforeach(file)
|
||||||
@@ -24,7 +24,12 @@ file(GLOB FILES
|
|||||||
*_440_*.png
|
*_440_*.png
|
||||||
*_440_*.ppm
|
*_440_*.ppm
|
||||||
*_440_*.jpg
|
*_440_*.jpg
|
||||||
*_440.yuv)
|
*_440.yuv
|
||||||
|
*_411_*.bmp
|
||||||
|
*_411_*.png
|
||||||
|
*_411_*.ppm
|
||||||
|
*_411_*.jpg
|
||||||
|
*_411.yuv)
|
||||||
|
|
||||||
if(NOT FILES STREQUAL "")
|
if(NOT FILES STREQUAL "")
|
||||||
message(STATUS "Removing test files")
|
message(STATUS "Removing test files")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ([2.56])
|
AC_PREREQ([2.56])
|
||||||
AC_INIT([mozjpeg], [3.2])
|
AC_INIT([mozjpeg], [3.3.1])
|
||||||
BUILD=`date +%Y%m%d`
|
BUILD=`date +%Y%m%d`
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
|
AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
|
||||||
@@ -233,9 +233,9 @@ AC_SUBST(MEM_SRCDST_FUNCTIONS)
|
|||||||
AC_DEFINE_UNQUOTED(MOZJPEG_VERSION, [$VERSION], [mozjpeg version])
|
AC_DEFINE_UNQUOTED(MOZJPEG_VERSION, [$VERSION], [mozjpeg version])
|
||||||
|
|
||||||
m4_define(version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
|
m4_define(version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
|
||||||
m4_define(version_major,m4_argn(1,version_triplet))
|
m4_define(version_major,m4_car(m4_shiftn(1,[],version_triplet)))
|
||||||
m4_define(version_minor,m4_argn(2,version_triplet))
|
m4_define(version_minor,m4_car(m4_shiftn(2,[],version_triplet)))
|
||||||
m4_define(version_revision,m4_argn(3,version_triplet))
|
m4_define(version_revision,m4_car(m4_shiftn(3,[],version_triplet)))
|
||||||
VERSION_MAJOR=version_major
|
VERSION_MAJOR=version_major
|
||||||
VERSION_MINOR=version_minor
|
VERSION_MINOR=version_minor
|
||||||
VERSION_REVISION=version_revision
|
VERSION_REVISION=version_revision
|
||||||
|
|||||||
4
djpeg.1
4
djpeg.1
@@ -1,4 +1,4 @@
|
|||||||
.TH DJPEG 1 "18 February 2016"
|
.TH DJPEG 1 "18 March 2017"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
djpeg \- decompress a JPEG file to an image file
|
djpeg \- decompress a JPEG file to an image file
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -185,7 +185,7 @@ Set limit for amount of memory to use in processing large images. Value is
|
|||||||
in thousands of bytes, or millions of bytes if "M" is attached to the
|
in thousands of bytes, or millions of bytes if "M" is attached to the
|
||||||
number. For example,
|
number. For example,
|
||||||
.B \-max 4m
|
.B \-max 4m
|
||||||
selects 4000000 bytes. If more space is needed, temporary files will be used.
|
selects 4000000 bytes. If more space is needed, an error will occur.
|
||||||
.TP
|
.TP
|
||||||
.BI \-outfile " name"
|
.BI \-outfile " name"
|
||||||
Send output image to the named file, not to standard output.
|
Send output image to the named file, not to standard output.
|
||||||
|
|||||||
@@ -455,7 +455,7 @@ Variables</h2></td></tr>
|
|||||||
</div><div class="memdoc">
|
</div><div class="memdoc">
|
||||||
|
|
||||||
<p>Disable buffer (re)allocation. </p>
|
<p>Disable buffer (re)allocation. </p>
|
||||||
<p>If passed to <a class="el" href="group___turbo_j_p_e_g.html#gaf38f2ed44bdc88e730e08b632fa6e88e" title="Compress an RGB, grayscale, or CMYK image into a JPEG image.">tjCompress2()</a> or <a class="el" href="group___turbo_j_p_e_g.html#gad02cd42b69f193a0623a9c801788df3a" title="Losslessly transform a JPEG image into another JPEG image.">tjTransform()</a>, this flag will cause those functions to generate an error if the JPEG image buffer is invalid or too small rather than attempting to allocate or reallocate that buffer. This reproduces the behavior of earlier versions of TurboJPEG. </p>
|
<p>If passed to one of the JPEG compression or transform functions, this flag will cause those functions to generate an error if the JPEG image buffer is invalid or too small rather than attempting to allocate or reallocate that buffer. This reproduces the behavior of earlier versions of TurboJPEG. </p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -812,7 +812,7 @@ Variables</h2></td></tr>
|
|||||||
</div><div class="memdoc">
|
</div><div class="memdoc">
|
||||||
|
|
||||||
<p>Allocate an image buffer for use with TurboJPEG. </p>
|
<p>Allocate an image buffer for use with TurboJPEG. </p>
|
||||||
<p>You should always use this function to allocate the JPEG destination buffer(s) for <a class="el" href="group___turbo_j_p_e_g.html#gaf38f2ed44bdc88e730e08b632fa6e88e" title="Compress an RGB, grayscale, or CMYK image into a JPEG image.">tjCompress2()</a> and <a class="el" href="group___turbo_j_p_e_g.html#gad02cd42b69f193a0623a9c801788df3a" title="Losslessly transform a JPEG image into another JPEG image.">tjTransform()</a> unless you are disabling automatic buffer (re)allocation (by setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>.)</p>
|
<p>You should always use this function to allocate the JPEG destination buffer(s) for the compression and transform functions unless you are disabling automatic buffer (re)allocation (by setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>.)</p>
|
||||||
<dl class="params"><dt>Parameters</dt><dd>
|
<dl class="params"><dt>Parameters</dt><dd>
|
||||||
<table class="params">
|
<table class="params">
|
||||||
<tr><td class="paramname">bytes</td><td>the number of bytes to allocate</td></tr>
|
<tr><td class="paramname">bytes</td><td>the number of bytes to allocate</td></tr>
|
||||||
@@ -1008,7 +1008,7 @@ Variables</h2></td></tr>
|
|||||||
<tr><td class="paramname">jpegBuf</td><td>address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
<tr><td class="paramname">jpegBuf</td><td>address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
||||||
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
||||||
<li>set <code>*jpegBuf</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
<li>set <code>*jpegBuf</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
||||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
|
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees that it won't be.)</li>
|
||||||
</ol>
|
</ol>
|
||||||
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
|
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
|
||||||
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
|
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
|
||||||
@@ -1106,7 +1106,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
|||||||
<tr><td class="paramname">jpegBuf</td><td>address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
<tr><td class="paramname">jpegBuf</td><td>address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
||||||
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
||||||
<li>set <code>*jpegBuf</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
<li>set <code>*jpegBuf</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
||||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
|
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees that it won't be.)</li>
|
||||||
</ol>
|
</ol>
|
||||||
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
|
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
|
||||||
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
|
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
|
||||||
@@ -1203,7 +1203,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
|||||||
<tr><td class="paramname">jpegBuf</td><td>address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
<tr><td class="paramname">jpegBuf</td><td>address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
||||||
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
||||||
<li>set <code>*jpegBuf</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
<li>set <code>*jpegBuf</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
||||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
|
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees that it won't be.)</li>
|
||||||
</ol>
|
</ol>
|
||||||
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
|
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
|
||||||
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
|
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
|
||||||
@@ -1942,7 +1942,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
|||||||
</div><div class="memdoc">
|
</div><div class="memdoc">
|
||||||
|
|
||||||
<p>Free an image buffer previously allocated by TurboJPEG. </p>
|
<p>Free an image buffer previously allocated by TurboJPEG. </p>
|
||||||
<p>You should always use this function to free JPEG destination buffer(s) that were automatically (re)allocated by <a class="el" href="group___turbo_j_p_e_g.html#gaf38f2ed44bdc88e730e08b632fa6e88e" title="Compress an RGB, grayscale, or CMYK image into a JPEG image.">tjCompress2()</a> or <a class="el" href="group___turbo_j_p_e_g.html#gad02cd42b69f193a0623a9c801788df3a" title="Losslessly transform a JPEG image into another JPEG image.">tjTransform()</a> or that were manually allocated using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a>.</p>
|
<p>You should always use this function to free JPEG destination buffer(s) that were automatically (re)allocated by the compression and transform functions or that were manually allocated using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a>.</p>
|
||||||
<dl class="params"><dt>Parameters</dt><dd>
|
<dl class="params"><dt>Parameters</dt><dd>
|
||||||
<table class="params">
|
<table class="params">
|
||||||
<tr><td class="paramname">buffer</td><td>address of the buffer to free</td></tr>
|
<tr><td class="paramname">buffer</td><td>address of the buffer to free</td></tr>
|
||||||
@@ -2270,7 +2270,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
|||||||
<tr><td class="paramname">dstBufs</td><td>pointer to an array of n image buffers. <code>dstBufs[i]</code> will receive a JPEG image that has been transformed using the parameters in <code>transforms[i]</code>. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
<tr><td class="paramname">dstBufs</td><td>pointer to an array of n image buffers. <code>dstBufs[i]</code> will receive a JPEG image that has been transformed using the parameters in <code>transforms[i]</code>. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
||||||
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
||||||
<li>set <code>dstBufs[i]</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
<li>set <code>dstBufs[i]</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
||||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a> with the transformed or cropped width and height. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
|
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a> with the transformed or cropped width and height. Under normal circumstances, this should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees that it won't be.) Note, however, that there are some rare cases (such as transforming images with a large amount of embedded EXIF or ICC profile data) in which the output image will be larger than the worst-case size, and <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> cannot be used in those cases.</li>
|
||||||
</ol>
|
</ol>
|
||||||
If you choose option 1, <code>dstSizes[i]</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>dstBufs[i]</code> upon return from this function, as it may have changed.</td></tr>
|
If you choose option 1, <code>dstSizes[i]</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>dstBufs[i]</code> upon return from this function, as it may have changed.</td></tr>
|
||||||
<tr><td class="paramname">dstSizes</td><td>pointer to an array of n unsigned long variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If <code>dstBufs[i]</code> points to a pre-allocated buffer, then <code>dstSizes[i]</code> should be set to the size of the buffer. Upon return, <code>dstSizes[i]</code> will contain the size of the JPEG image (in bytes.)</td></tr>
|
<tr><td class="paramname">dstSizes</td><td>pointer to an array of n unsigned long variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If <code>dstBufs[i]</code> points to a pre-allocated buffer, then <code>dstSizes[i]</code> should be set to the size of the buffer. Upon return, <code>dstSizes[i]</code> will contain the size of the JPEG image (in bytes.)</td></tr>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2009-2014, 2016 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2009-2014, 2016-2017 D. R. Commander. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -34,8 +34,8 @@ import org.libjpegturbo.turbojpeg.*;
|
|||||||
|
|
||||||
class TJBench {
|
class TJBench {
|
||||||
|
|
||||||
static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1, warmup = 1;
|
static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1;
|
||||||
static boolean compOnly, decompOnly, doTile, doYUV, write;
|
static boolean compOnly, decompOnly, doTile, doYUV, write = true;
|
||||||
|
|
||||||
static final String[] pixFormatStr = {
|
static final String[] pixFormatStr = {
|
||||||
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY"
|
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY"
|
||||||
@@ -55,7 +55,7 @@ class TJBench {
|
|||||||
|
|
||||||
static TJScalingFactor sf;
|
static TJScalingFactor sf;
|
||||||
static int xformOp = TJTransform.OP_NONE, xformOpt = 0;
|
static int xformOp = TJTransform.OP_NONE, xformOpt = 0;
|
||||||
static double benchTime = 5.0;
|
static double benchTime = 5.0, warmup = 1.0;
|
||||||
|
|
||||||
|
|
||||||
static final double getTime() {
|
static final double getTime() {
|
||||||
@@ -162,7 +162,7 @@ class TJBench {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Benchmark */
|
/* Benchmark */
|
||||||
iter -= warmup;
|
iter = -1;
|
||||||
elapsed = elapsedDecode = 0.0;
|
elapsed = elapsedDecode = 0.0;
|
||||||
while (true) {
|
while (true) {
|
||||||
int tile = 0;
|
int tile = 0;
|
||||||
@@ -184,11 +184,14 @@ class TJBench {
|
|||||||
tjd.decompress(dstBuf, x, y, width, pitch, height, pf, flags);
|
tjd.decompress(dstBuf, x, y, width, pitch, height, pf, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iter++;
|
elapsed += getTime() - start;
|
||||||
if (iter >= 1) {
|
if (iter >= 0) {
|
||||||
elapsed += getTime() - start;
|
iter++;
|
||||||
if (elapsed >= benchTime)
|
if (elapsed >= benchTime)
|
||||||
break;
|
break;
|
||||||
|
} else if (elapsed >= warmup) {
|
||||||
|
iter = 0;
|
||||||
|
elapsed = elapsedDecode = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(doYUV)
|
if(doYUV)
|
||||||
@@ -321,7 +324,7 @@ class TJBench {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Benchmark */
|
/* Benchmark */
|
||||||
iter = -warmup;
|
iter = -1;
|
||||||
elapsed = elapsedEncode = 0.0;
|
elapsed = elapsedEncode = 0.0;
|
||||||
while (true) {
|
while (true) {
|
||||||
int tile = 0;
|
int tile = 0;
|
||||||
@@ -346,11 +349,14 @@ class TJBench {
|
|||||||
totalJpegSize += jpegSize[tile];
|
totalJpegSize += jpegSize[tile];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iter++;
|
elapsed += getTime() - start;
|
||||||
if (iter >= 1) {
|
if (iter >= 0) {
|
||||||
elapsed += getTime() - start;
|
iter++;
|
||||||
if (elapsed >= benchTime)
|
if (elapsed >= benchTime)
|
||||||
break;
|
break;
|
||||||
|
} else if (elapsed >= warmup) {
|
||||||
|
iter = 0;
|
||||||
|
elapsed = elapsedEncode = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doYUV)
|
if (doYUV)
|
||||||
@@ -541,17 +547,20 @@ class TJBench {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iter = -warmup;
|
iter = -1;
|
||||||
elapsed = 0.;
|
elapsed = 0.;
|
||||||
while (true) {
|
while (true) {
|
||||||
start = getTime();
|
start = getTime();
|
||||||
tjt.transform(jpegBuf, t, flags);
|
tjt.transform(jpegBuf, t, flags);
|
||||||
jpegSize = tjt.getTransformedSizes();
|
jpegSize = tjt.getTransformedSizes();
|
||||||
iter++;
|
elapsed += getTime() - start;
|
||||||
if (iter >= 1) {
|
if (iter >= 0) {
|
||||||
elapsed += getTime() - start;
|
iter++;
|
||||||
if (elapsed >= benchTime)
|
if (elapsed >= benchTime)
|
||||||
break;
|
break;
|
||||||
|
} else if (elapsed >= warmup) {
|
||||||
|
iter = 0;
|
||||||
|
elapsed = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t = null;
|
t = null;
|
||||||
@@ -582,8 +591,8 @@ class TJBench {
|
|||||||
System.out.print("N/A N/A ");
|
System.out.print("N/A N/A ");
|
||||||
jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)];
|
jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)];
|
||||||
jpegSize = new int[1];
|
jpegSize = new int[1];
|
||||||
|
jpegBuf[0] = srcBuf;
|
||||||
jpegSize[0] = srcSize;
|
jpegSize[0] = srcSize;
|
||||||
System.arraycopy(srcBuf, 0, jpegBuf[0], 0, srcSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w == tilew)
|
if (w == tilew)
|
||||||
@@ -659,8 +668,9 @@ class TJBench {
|
|||||||
System.out.println("-grayscale = Perform lossless grayscale conversion prior to decompression");
|
System.out.println("-grayscale = Perform lossless grayscale conversion prior to decompression");
|
||||||
System.out.println(" test (can be combined with the other transforms above)");
|
System.out.println(" test (can be combined with the other transforms above)");
|
||||||
System.out.println("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)");
|
System.out.println("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)");
|
||||||
System.out.println("-warmup <w> = Execute each benchmark <w> times to prime the cache before");
|
System.out.println("-warmup <t> = Run each benchmark for <t> seconds (default = 1.0) prior to");
|
||||||
System.out.println(" taking performance measurements (default = 1)");
|
System.out.println(" starting the timer, in order to prime the caches and thus improve the");
|
||||||
|
System.out.println(" consistency of the results.");
|
||||||
System.out.println("-componly = Stop after running compression tests. Do not test decompression.");
|
System.out.println("-componly = Stop after running compression tests. Do not test decompression.");
|
||||||
System.out.println("-nowrite = Do not write reference or output images (improves consistency");
|
System.out.println("-nowrite = Do not write reference or output images (improves consistency");
|
||||||
System.out.println(" of performance measurements.)\n");
|
System.out.println(" of performance measurements.)\n");
|
||||||
@@ -824,14 +834,15 @@ class TJBench {
|
|||||||
if (argv[i].equalsIgnoreCase("-nowrite"))
|
if (argv[i].equalsIgnoreCase("-nowrite"))
|
||||||
write = false;
|
write = false;
|
||||||
if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) {
|
if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) {
|
||||||
int temp = -1;
|
double temp = -1;
|
||||||
try {
|
try {
|
||||||
temp = Integer.parseInt(argv[++i]);
|
temp = Double.parseDouble(argv[++i]);
|
||||||
} catch (NumberFormatException e) {}
|
} catch (NumberFormatException e) {}
|
||||||
if (temp >= 0) {
|
if (temp >= 0.0) {
|
||||||
warmup = temp;
|
warmup = temp;
|
||||||
System.out.format("Warmup runs = %d\n\n", warmup);
|
System.out.format("Warmup time = %.1f seconds\n\n", warmup);
|
||||||
}
|
} else
|
||||||
|
usage();
|
||||||
}
|
}
|
||||||
if (argv[i].equalsIgnoreCase("-?"))
|
if (argv[i].equalsIgnoreCase("-?"))
|
||||||
usage();
|
usage();
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
/* libjpeg-turbo build number */
|
/* libjpeg-turbo build number */
|
||||||
#undef BUILD
|
#undef BUILD
|
||||||
|
|
||||||
|
/* Compiler's inline keyword */
|
||||||
|
#undef inline
|
||||||
|
|
||||||
/* How to obtain function inlining. */
|
/* How to obtain function inlining. */
|
||||||
#undef INLINE
|
#undef INLINE
|
||||||
|
|
||||||
|
|||||||
16
jcparam.c
16
jcparam.c
@@ -864,16 +864,20 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
|||||||
if (cinfo->global_state != CSTATE_START)
|
if (cinfo->global_state != CSTATE_START)
|
||||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||||
|
|
||||||
/* Figure space needed for script. Calculation must match code below! */
|
/* Figure space needed for script. Calculation must match code below! */
|
||||||
ncomps = cinfo->num_components;
|
ncomps = cinfo->num_components;
|
||||||
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||||
/* Custom script for YCbCr color images. */
|
/* Custom script for YCbCr color images. */
|
||||||
if (cinfo->master->dc_scan_opt_mode == 0) {
|
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
|
||||||
nscans = 8; /* 1 DC scan for all components */
|
if (cinfo->master->dc_scan_opt_mode == 0) {
|
||||||
} else if (cinfo->master->dc_scan_opt_mode == 1) {
|
nscans = 9; /* 1 DC scan for all components */
|
||||||
nscans = 10; /* 1 DC scan for each component */
|
} else if (cinfo->master->dc_scan_opt_mode == 1) {
|
||||||
|
nscans = 11; /* 1 DC scan for each component */
|
||||||
|
} else {
|
||||||
|
nscans = 10; /* 1 DC scan for luminance and 1 DC scan for chroma */
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nscans = 9; /* 1 DC scan for luminance and 1 DC scan for chroma */
|
nscans = 10; /* 2 DC scans and 8 AC scans */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* All-purpose script for other color spaces. */
|
/* All-purpose script for other color spaces. */
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Developed 1997-2015 by Guido Vollbeding.
|
* Developed 1997-2015 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015, D. R. Commander.
|
* Copyright (C) 2015-2016, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -21,6 +21,9 @@
|
|||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define NEG_1 ((unsigned int)-1)
|
||||||
|
|
||||||
|
|
||||||
/* Expanded entropy decoder object for arithmetic decoding. */
|
/* Expanded entropy decoder object for arithmetic decoding. */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -382,7 +385,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
if (arith_decode(cinfo, st)) v |= m;
|
if (arith_decode(cinfo, st)) v |= m;
|
||||||
v += 1; if (sign) v = -v;
|
v += 1; if (sign) v = -v;
|
||||||
/* Scale and output coefficient in natural (dezigzagged) order */
|
/* Scale and output coefficient in natural (dezigzagged) order */
|
||||||
(*block)[jpeg_natural_order[k]] = (JCOEF) (v << cinfo->Al);
|
(*block)[jpeg_natural_order[k]] = (JCOEF) ((unsigned)v << cinfo->Al);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -450,7 +453,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
|
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
|
||||||
|
|
||||||
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||||
m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
|
m1 = (NEG_1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||||
|
|
||||||
/* Establish EOBx (previous stage end-of-block) index */
|
/* Establish EOBx (previous stage end-of-block) index */
|
||||||
for (kex = cinfo->Se; kex > 0; kex--)
|
for (kex = cinfo->Se; kex > 0; kex--)
|
||||||
|
|||||||
4
jdhuff.c
4
jdhuff.c
@@ -109,9 +109,9 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
|||||||
actbl = compptr->ac_tbl_no;
|
actbl = compptr->ac_tbl_no;
|
||||||
/* Compute derived values for Huffman tables */
|
/* Compute derived values for Huffman tables */
|
||||||
/* We may do this more than once for a table, but it's not expensive */
|
/* We may do this more than once for a table, but it's not expensive */
|
||||||
pdtbl = entropy->dc_derived_tbls + dctbl;
|
pdtbl = (d_derived_tbl **)(entropy->dc_derived_tbls) + dctbl;
|
||||||
jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, pdtbl);
|
jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, pdtbl);
|
||||||
pdtbl = entropy->ac_derived_tbls + actbl;
|
pdtbl = (d_derived_tbl **)(entropy->ac_derived_tbls) + actbl;
|
||||||
jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, pdtbl);
|
jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, pdtbl);
|
||||||
/* Initialize DC predictions to 0 */
|
/* Initialize DC predictions to 0 */
|
||||||
entropy->saved.last_dc_val[ci] = 0;
|
entropy->saved.last_dc_val[ci] = 0;
|
||||||
|
|||||||
12
jdmaster.c
12
jdmaster.c
@@ -22,6 +22,7 @@
|
|||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
#include "jpegcomp.h"
|
#include "jpegcomp.h"
|
||||||
#include "jdmaster.h"
|
#include "jdmaster.h"
|
||||||
|
#include "jsimd.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -69,6 +70,17 @@ use_merged_upsample (j_decompress_ptr cinfo)
|
|||||||
cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
|
cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
|
||||||
cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
|
cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
#ifdef WITH_SIMD
|
||||||
|
/* If YCbCr-to-RGB color conversion is SIMD-accelerated but merged upsampling
|
||||||
|
isn't, then disabling merged upsampling is likely to be faster when
|
||||||
|
decompressing YCbCr JPEG images. */
|
||||||
|
if (!jsimd_can_h2v2_merged_upsample() && !jsimd_can_h2v1_merged_upsample() &&
|
||||||
|
jsimd_can_ycc_rgb() && cinfo->jpeg_color_space == JCS_YCbCr &&
|
||||||
|
(cinfo->out_color_space == JCS_RGB ||
|
||||||
|
(cinfo->out_color_space >= JCS_EXT_RGB &&
|
||||||
|
cinfo->out_color_space <= JCS_EXT_ARGB)))
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
/* ??? also need to test for upsample-time rescaling, when & if supported */
|
/* ??? also need to test for upsample-time rescaling, when & if supported */
|
||||||
return TRUE; /* by golly, it'll work... */
|
return TRUE; /* by golly, it'll work... */
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015, D. R. Commander.
|
* Copyright (C) 2015-2016, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -170,12 +170,12 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
|||||||
if (is_DC_band) {
|
if (is_DC_band) {
|
||||||
if (cinfo->Ah == 0) { /* DC refinement needs no table */
|
if (cinfo->Ah == 0) { /* DC refinement needs no table */
|
||||||
tbl = compptr->dc_tbl_no;
|
tbl = compptr->dc_tbl_no;
|
||||||
pdtbl = entropy->derived_tbls + tbl;
|
pdtbl = (d_derived_tbl **)(entropy->derived_tbls) + tbl;
|
||||||
jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, pdtbl);
|
jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, pdtbl);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tbl = compptr->ac_tbl_no;
|
tbl = compptr->ac_tbl_no;
|
||||||
pdtbl = entropy->derived_tbls + tbl;
|
pdtbl = (d_derived_tbl **)(entropy->derived_tbls) + tbl;
|
||||||
jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, pdtbl);
|
jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, pdtbl);
|
||||||
/* remember the single active table */
|
/* remember the single active table */
|
||||||
entropy->ac_derived_tbl = entropy->derived_tbls[tbl];
|
entropy->ac_derived_tbl = entropy->derived_tbls[tbl];
|
||||||
|
|||||||
47
jdsample.c
47
jdsample.c
@@ -303,6 +303,48 @@ h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fancy processing for 1:1 horizontal and 2:1 vertical (4:4:0 subsampling).
|
||||||
|
*
|
||||||
|
* This is a less common case, but it can be encountered when losslessly
|
||||||
|
* rotating/transposing a JPEG file that uses 4:2:2 chroma subsampling.
|
||||||
|
*/
|
||||||
|
|
||||||
|
METHODDEF(void)
|
||||||
|
h1v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||||
|
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||||
|
{
|
||||||
|
JSAMPARRAY output_data = *output_data_ptr;
|
||||||
|
JSAMPROW inptr0, inptr1, outptr;
|
||||||
|
#if BITS_IN_JSAMPLE == 8
|
||||||
|
int thiscolsum;
|
||||||
|
#else
|
||||||
|
JLONG thiscolsum;
|
||||||
|
#endif
|
||||||
|
JDIMENSION colctr;
|
||||||
|
int inrow, outrow, v;
|
||||||
|
|
||||||
|
inrow = outrow = 0;
|
||||||
|
while (outrow < cinfo->max_v_samp_factor) {
|
||||||
|
for (v = 0; v < 2; v++) {
|
||||||
|
/* inptr0 points to nearest input row, inptr1 points to next nearest */
|
||||||
|
inptr0 = input_data[inrow];
|
||||||
|
if (v == 0) /* next nearest is row above */
|
||||||
|
inptr1 = input_data[inrow-1];
|
||||||
|
else /* next nearest is row below */
|
||||||
|
inptr1 = input_data[inrow+1];
|
||||||
|
outptr = output_data[outrow++];
|
||||||
|
|
||||||
|
for(colctr = 0; colctr < compptr->downsampled_width; colctr++) {
|
||||||
|
thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||||
|
*outptr++ = (JSAMPLE) ((thiscolsum + 1) >> 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inrow++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
|
* Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
|
||||||
* Again a triangle filter; see comments for h2v1 case, above.
|
* Again a triangle filter; see comments for h2v1 case, above.
|
||||||
@@ -431,6 +473,11 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
|||||||
else
|
else
|
||||||
upsample->methods[ci] = h2v1_upsample;
|
upsample->methods[ci] = h2v1_upsample;
|
||||||
}
|
}
|
||||||
|
} else if (h_in_group == h_out_group &&
|
||||||
|
v_in_group * 2 == v_out_group && do_fancy) {
|
||||||
|
/* Non-fancy upsampling is handled by the generic method */
|
||||||
|
upsample->methods[ci] = h1v2_fancy_upsample;
|
||||||
|
upsample->pub.need_context_rows = TRUE;
|
||||||
} else if (h_in_group * 2 == h_out_group &&
|
} else if (h_in_group * 2 == h_out_group &&
|
||||||
v_in_group * 2 == v_out_group) {
|
v_in_group * 2 == v_out_group) {
|
||||||
/* Special cases for 2h2v upsampling */
|
/* Special cases for 2h2v upsampling */
|
||||||
|
|||||||
20
jmemmgr.c
20
jmemmgr.c
@@ -32,6 +32,10 @@
|
|||||||
#include "jinclude.h"
|
#include "jinclude.h"
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
#include "jmemsys.h" /* import the system-dependent declarations */
|
#include "jmemsys.h" /* import the system-dependent declarations */
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#ifndef NO_GETENV
|
#ifndef NO_GETENV
|
||||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */
|
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */
|
||||||
@@ -650,18 +654,26 @@ realize_virt_arrays (j_common_ptr cinfo)
|
|||||||
maximum_space = 0;
|
maximum_space = 0;
|
||||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||||
|
size_t new_space = (long) sptr->rows_in_array *
|
||||||
|
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||||
|
|
||||||
space_per_minheight += (long) sptr->maxaccess *
|
space_per_minheight += (long) sptr->maxaccess *
|
||||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||||
maximum_space += (long) sptr->rows_in_array *
|
if (SIZE_MAX - maximum_space < new_space)
|
||||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
out_of_memory(cinfo, 10);
|
||||||
|
maximum_space += new_space;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||||
|
size_t new_space = (long) bptr->rows_in_array *
|
||||||
|
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||||
|
|
||||||
space_per_minheight += (long) bptr->maxaccess *
|
space_per_minheight += (long) bptr->maxaccess *
|
||||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||||
maximum_space += (long) bptr->rows_in_array *
|
if (SIZE_MAX - maximum_space < new_space)
|
||||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
out_of_memory(cinfo, 11);
|
||||||
|
maximum_space += new_space;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
jmemnobs.c
16
jmemnobs.c
@@ -3,8 +3,8 @@
|
|||||||
*
|
*
|
||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1992-1996, Thomas G. Lane.
|
* Copyright (C) 1992-1996, Thomas G. Lane.
|
||||||
* It was modified by The libjpeg-turbo Project to include only code and
|
* libjpeg-turbo Modifications:
|
||||||
* information relevant to libjpeg-turbo.
|
* Copyright (C) 2017, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
* This is very portable in the sense that it'll compile on almost anything,
|
* This is very portable in the sense that it'll compile on almost anything,
|
||||||
* but you'd better have lots of main memory (or virtual memory) if you want
|
* but you'd better have lots of main memory (or virtual memory) if you want
|
||||||
* to process big images.
|
* to process big images.
|
||||||
* Note that the max_memory_to_use option is ignored by this implementation.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
@@ -66,14 +65,21 @@ jpeg_free_large (j_common_ptr cinfo, void *object, size_t sizeofobject)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine computes the total memory space available for allocation.
|
* This routine computes the total memory space available for allocation.
|
||||||
* Here we always say, "we got all you want bud!"
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(size_t)
|
GLOBAL(size_t)
|
||||||
jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
|
jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
|
||||||
size_t max_bytes_needed, size_t already_allocated)
|
size_t max_bytes_needed, size_t already_allocated)
|
||||||
{
|
{
|
||||||
return max_bytes_needed;
|
if (cinfo->mem->max_memory_to_use) {
|
||||||
|
if (cinfo->mem->max_memory_to_use > already_allocated)
|
||||||
|
return cinfo->mem->max_memory_to_use - already_allocated;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
/* Here we always say, "we got all you want bud!" */
|
||||||
|
return max_bytes_needed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -217,8 +217,8 @@ struct jpeg_decomp_master {
|
|||||||
/* Partial decompression variables */
|
/* Partial decompression variables */
|
||||||
JDIMENSION first_iMCU_col;
|
JDIMENSION first_iMCU_col;
|
||||||
JDIMENSION last_iMCU_col;
|
JDIMENSION last_iMCU_col;
|
||||||
JDIMENSION first_MCU_col[MAX_COMPS_IN_SCAN];
|
JDIMENSION first_MCU_col[MAX_COMPONENTS];
|
||||||
JDIMENSION last_MCU_col[MAX_COMPS_IN_SCAN];
|
JDIMENSION last_MCU_col[MAX_COMPONENTS];
|
||||||
boolean jinit_upsampler_no_alloc;
|
boolean jinit_upsampler_no_alloc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.TH JPEGTRAN 1 "18 February 2016"
|
.TH JPEGTRAN 1 "18 March 2017"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
jpegtran \- lossless transformation of JPEG files
|
jpegtran \- lossless transformation of JPEG files
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -222,7 +222,7 @@ Set limit for amount of memory to use in processing large images. Value is
|
|||||||
in thousands of bytes, or millions of bytes if "M" is attached to the
|
in thousands of bytes, or millions of bytes if "M" is attached to the
|
||||||
number. For example,
|
number. For example,
|
||||||
.B \-max 4m
|
.B \-max 4m
|
||||||
selects 4000000 bytes. If more space is needed, temporary files will be used.
|
selects 4000000 bytes. If more space is needed, an error will occur.
|
||||||
.TP
|
.TP
|
||||||
.BI \-outfile " name"
|
.BI \-outfile " name"
|
||||||
Send output image to the named file, not to standard output.
|
Send output image to the named file, not to standard output.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1995-2010, Thomas G. Lane, Guido Vollbeding.
|
* Copyright (C) 1995-2010, Thomas G. Lane, Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, 2014, D. R. Commander.
|
* Copyright (C) 2010, 2014, 2017, D. R. Commander.
|
||||||
* mozjpeg Modifications:
|
* mozjpeg Modifications:
|
||||||
* Copyright (C) 2014, Mozilla Corporation.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
@@ -95,7 +95,7 @@ usage (void)
|
|||||||
fprintf(stderr, " -version Print version information and exit\n");
|
fprintf(stderr, " -version Print version information and exit\n");
|
||||||
fprintf(stderr, "Switches for wizards:\n");
|
fprintf(stderr, "Switches for wizards:\n");
|
||||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||||
fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n");
|
fprintf(stderr, " -scans FILE Create multi-scan JPEG per script FILE\n");
|
||||||
#endif
|
#endif
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
|
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, 2012-2016, D. R. Commander.
|
* Copyright (C) 2010, 2012-2017, D. R. Commander.
|
||||||
* mozjpeg Modifications:
|
* mozjpeg Modifications:
|
||||||
* Copyright (C) 2014, Mozilla Corporation.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
* their code
|
* their code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JCOPYRIGHT "Copyright (C) 2009-2016 D. R. Commander\n" \
|
#define JCOPYRIGHT "Copyright (C) 2009-2017 D. R. Commander\n" \
|
||||||
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
||||||
"Copyright (C) 2015-2016 Matthieu Darbois\n" \
|
"Copyright (C) 2015-2016 Matthieu Darbois\n" \
|
||||||
"Copyright (C) 2015 Google, Inc.\n" \
|
"Copyright (C) 2015 Google, Inc.\n" \
|
||||||
@@ -48,4 +48,4 @@
|
|||||||
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
|
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
|
||||||
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding" \
|
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding" \
|
||||||
|
|
||||||
#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2016 The libjpeg-turbo Project and many others"
|
#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2017 The libjpeg-turbo Project and many others"
|
||||||
|
|||||||
15
libjpeg.txt
15
libjpeg.txt
@@ -3,7 +3,7 @@ USING THE IJG JPEG LIBRARY
|
|||||||
This file was part of the Independent JPEG Group's software:
|
This file was part of the Independent JPEG Group's software:
|
||||||
Copyright (C) 1994-2013, Thomas G. Lane, Guido Vollbeding.
|
Copyright (C) 1994-2013, Thomas G. Lane, Guido Vollbeding.
|
||||||
libjpeg-turbo Modifications:
|
libjpeg-turbo Modifications:
|
||||||
Copyright (C) 2010, 2014-2016, D. R. Commander.
|
Copyright (C) 2010, 2014-2017, D. R. Commander.
|
||||||
Copyright (C) 2015, Google, Inc.
|
Copyright (C) 2015, Google, Inc.
|
||||||
For conditions of distribution and use, see the accompanying README.ijg file.
|
For conditions of distribution and use, see the accompanying README.ijg file.
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ Basic library usage:
|
|||||||
Data formats
|
Data formats
|
||||||
Compression details
|
Compression details
|
||||||
Decompression details
|
Decompression details
|
||||||
|
Partial image decompression
|
||||||
Mechanics of usage: include files, linking, etc
|
Mechanics of usage: include files, linking, etc
|
||||||
Advanced features:
|
Advanced features:
|
||||||
Compression parameter selection
|
Compression parameter selection
|
||||||
@@ -2941,13 +2942,6 @@ Some operating modes (eg, two-pass color quantization) require full-image
|
|||||||
buffers. Such buffers are treated as "virtual arrays": only the current strip
|
buffers. Such buffers are treated as "virtual arrays": only the current strip
|
||||||
need be in memory, and the rest can be swapped out to a temporary file.
|
need be in memory, and the rest can be swapped out to a temporary file.
|
||||||
|
|
||||||
If you use the simplest memory manager back end (jmemnobs.c), then no
|
|
||||||
temporary files are used; virtual arrays are simply malloc()'d. Images bigger
|
|
||||||
than memory can be processed only if your system supports virtual memory.
|
|
||||||
The other memory manager back ends support temporary files of various flavors
|
|
||||||
and thus work in machines without virtual memory. They may also be useful on
|
|
||||||
Unix machines if you need to process images that exceed available swap space.
|
|
||||||
|
|
||||||
When using temporary files, the library will make the in-memory buffers for
|
When using temporary files, the library will make the in-memory buffers for
|
||||||
its virtual arrays just big enough to stay within a "maximum memory" setting.
|
its virtual arrays just big enough to stay within a "maximum memory" setting.
|
||||||
Your application can set this limit by setting cinfo->mem->max_memory_to_use
|
Your application can set this limit by setting cinfo->mem->max_memory_to_use
|
||||||
@@ -2960,6 +2954,11 @@ 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
|
it's too small to be worth worrying about; so a reasonable safety margin
|
||||||
should be left when setting max_memory_to_use.
|
should be left when setting max_memory_to_use.
|
||||||
|
|
||||||
|
NOTE: Unless you develop your own memory manager back end, then temporary files
|
||||||
|
will never be used. The back end provided in libjpeg-turbo (jmemnobs.c) simply
|
||||||
|
malloc()s and free()s virtual arrays, and an error occurs if the required
|
||||||
|
memory exceeds the limit specified in cinfo->mem->max_memory_to_use.
|
||||||
|
|
||||||
|
|
||||||
Memory usage
|
Memory usage
|
||||||
------------
|
------------
|
||||||
|
|||||||
@@ -31,6 +31,15 @@
|
|||||||
|
|
||||||
#include "./md5.h"
|
#include "./md5.h"
|
||||||
|
|
||||||
|
#ifdef __amigaos4__
|
||||||
|
#include <machine/endian.h>
|
||||||
|
#define le32toh(x) (((x & 0xff) << 24) | \
|
||||||
|
((x & 0xff00) << 8) | \
|
||||||
|
((x & 0xff0000) >> 8) | \
|
||||||
|
((x & 0xff000000) >> 24))
|
||||||
|
#define htole32(x) le32toh(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
static void MD5Transform(unsigned int [4], const unsigned char [64]);
|
static void MD5Transform(unsigned int [4], const unsigned char [64]);
|
||||||
|
|
||||||
#if (BYTE_ORDER == LITTLE_ENDIAN)
|
#if (BYTE_ORDER == LITTLE_ENDIAN)
|
||||||
|
|||||||
69
rdpng.c
69
rdpng.c
@@ -43,6 +43,27 @@ METHODDEF(void) error_input_png(png_structp png_ptr, png_const_charp msg) {
|
|||||||
ERREXITS(cinfo, JERR_PNG_ERROR, msg);
|
ERREXITS(cinfo, JERR_PNG_ERROR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is a small ICC profile for sRGB */
|
||||||
|
static unsigned char tiny_srgb[] = {0,0,2,24,108,99,109,115,2,16,0,0,109,110,
|
||||||
|
116,114,82,71,66,32,88,89,90,32,7,220,0,1,0,25,0,3,0,41,0,57,97,99,115,112,65,
|
||||||
|
80,80,76,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,246,214,0,1,0,0,0,
|
||||||
|
0,211,45,108,99,109,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,100,101,115,99,0,0,0,252,0,0,0,106,
|
||||||
|
99,112,114,116,0,0,1,104,0,0,0,11,119,116,112,116,0,0,1,116,0,0,0,20,98,107,
|
||||||
|
112,116,0,0,1,136,0,0,0,20,114,88,89,90,0,0,1,156,0,0,0,20,103,88,89,90,0,0,1,
|
||||||
|
176,0,0,0,20,98,88,89,90,0,0,1,196,0,0,0,20,114,84,82,67,0,0,1,216,0,0,0,64,98,
|
||||||
|
84,82,67,0,0,1,216,0,0,0,64,103,84,82,67,0,0,1,216,0,0,0,64,100,101,115,99,0,0,
|
||||||
|
0,0,0,0,0,13,115,82,71,66,32,77,111,122,74,80,69,71,0,0,0,0,0,0,0,0,1,0,0,0,0,
|
||||||
|
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,101,120,
|
||||||
|
116,0,0,0,0,80,68,0,0,88,89,90,32,0,0,0,0,0,0,246,214,0,1,0,0,0,0,211,45,88,89,
|
||||||
|
90,32,0,0,0,0,0,0,3,22,0,0,3,51,0,0,2,164,88,89,90,32,0,0,0,0,0,0,111,162,0,0,
|
||||||
|
56,245,0,0,3,144,88,89,90,32,0,0,0,0,0,0,98,153,0,0,183,133,0,0,24,218,88,89,
|
||||||
|
90,32,0,0,0,0,0,0,36,160,0,0,15,132,0,0,182,207,99,117,114,118,0,0,0,0,0,0,0,
|
||||||
|
26,0,0,0,203,1,201,3,99,5,146,8,107,11,246,16,63,21,81,27,52,33,241,41,144,50,
|
||||||
|
24,59,146,70,5,81,119,93,237,107,112,122,5,137,177,154,124,172,105,191,125,211,
|
||||||
|
195,233,48,255,255,};
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
start_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
start_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||||
{
|
{
|
||||||
@@ -69,7 +90,12 @@ start_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
png_get_IHDR(source->png_ptr, source->info_ptr, &width, &height,
|
png_get_IHDR(source->png_ptr, source->info_ptr, &width, &height,
|
||||||
&bit_depth, &color_type, NULL, NULL, NULL);
|
&bit_depth, &color_type, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY) {
|
if (width > 65535 || height > 65535) {
|
||||||
|
ERREXITS(cinfo, JERR_PNG_ERROR, "Image too large");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||||
cinfo->in_color_space = JCS_GRAYSCALE;
|
cinfo->in_color_space = JCS_GRAYSCALE;
|
||||||
cinfo->input_components = 1;
|
cinfo->input_components = 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -77,20 +103,57 @@ start_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
cinfo->input_components = 3;
|
cinfo->input_components = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bit_depth == 16)
|
if (bit_depth == 16) {
|
||||||
png_set_strip_16(source->png_ptr);
|
png_set_strip_16(source->png_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
cinfo->data_precision = 8;
|
cinfo->data_precision = 8;
|
||||||
cinfo->image_width = width;
|
cinfo->image_width = width;
|
||||||
cinfo->image_height = height;
|
cinfo->image_height = height;
|
||||||
|
|
||||||
|
int has_srgb_chunk = png_get_valid(source->png_ptr, source->info_ptr, PNG_INFO_sRGB);
|
||||||
|
|
||||||
double gamma = 0.45455;
|
double gamma = 0.45455;
|
||||||
if (!png_get_valid(source->png_ptr, source->info_ptr, PNG_INFO_sRGB)) {
|
if (!has_srgb_chunk) {
|
||||||
png_get_gAMA(source->png_ptr, source->info_ptr, &gamma);
|
png_get_gAMA(source->png_ptr, source->info_ptr, &gamma);
|
||||||
}
|
}
|
||||||
cinfo->input_gamma = gamma;
|
cinfo->input_gamma = gamma;
|
||||||
sinfo->get_pixel_rows = get_pixel_rows_png;
|
sinfo->get_pixel_rows = get_pixel_rows_png;
|
||||||
|
|
||||||
|
source->pub.marker_list = NULL;
|
||||||
|
png_bytep profile = NULL;
|
||||||
|
png_charp unused1 = NULL;
|
||||||
|
int unused2 = 0;
|
||||||
|
png_uint_32 proflen = 0;
|
||||||
|
int has_profile = 0;
|
||||||
|
|
||||||
|
if (has_srgb_chunk) {
|
||||||
|
/* PNG can declare use of an sRGB profile without embedding an ICC file, but JPEG doesn't have such feature */
|
||||||
|
has_profile = 1;
|
||||||
|
profile = tiny_srgb;
|
||||||
|
proflen = sizeof(tiny_srgb);
|
||||||
|
} else {
|
||||||
|
has_profile = png_get_iCCP(source->png_ptr, source->info_ptr, &unused1, &unused2, &profile, &proflen); /* your libpng is out of date if you get a warning here */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_profile && profile && proflen) {
|
||||||
|
if (proflen < 65535-14) {
|
||||||
|
size_t datalen = proflen + 14;
|
||||||
|
JOCTET *dataptr = (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_IMAGE, datalen);
|
||||||
|
memcpy(dataptr, "ICC_PROFILE\0\x01\x01", 14);
|
||||||
|
memcpy(dataptr + 14, profile, proflen);
|
||||||
|
struct jpeg_marker_struct *marker = (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_IMAGE, sizeof(struct jpeg_marker_struct));
|
||||||
|
marker->next = NULL;
|
||||||
|
marker->marker = JPEG_APP0+2;
|
||||||
|
marker->original_length = 0;
|
||||||
|
marker->data_length = datalen;
|
||||||
|
marker->data = dataptr;
|
||||||
|
source->pub.marker_list = marker;
|
||||||
|
} else {
|
||||||
|
WARNMS(cinfo, JERR_PNG_PROFILETOOLARGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
png_read_update_info(source->png_ptr, source->info_ptr);
|
png_read_update_info(source->png_ptr, source->info_ptr);
|
||||||
|
|
||||||
png_size_t rowbytes = png_get_rowbytes(source->png_ptr, source->info_ptr);
|
png_size_t rowbytes = png_get_rowbytes(source->png_ptr, source->info_ptr);
|
||||||
|
|||||||
4
rdppm.c
4
rdppm.c
@@ -251,7 +251,7 @@ get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
ptr = source->pub.buffer[0];
|
ptr = source->pub.buffer[0];
|
||||||
bufferptr = source->iobuffer;
|
bufferptr = source->iobuffer;
|
||||||
for (col = cinfo->image_width; col > 0; col--) {
|
for (col = cinfo->image_width; col > 0; col--) {
|
||||||
register int temp;
|
register unsigned int temp;
|
||||||
temp = UCH(*bufferptr++) << 8;
|
temp = UCH(*bufferptr++) << 8;
|
||||||
temp |= UCH(*bufferptr++);
|
temp |= UCH(*bufferptr++);
|
||||||
if (temp > maxval)
|
if (temp > maxval)
|
||||||
@@ -278,7 +278,7 @@ get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
ptr = source->pub.buffer[0];
|
ptr = source->pub.buffer[0];
|
||||||
bufferptr = source->iobuffer;
|
bufferptr = source->iobuffer;
|
||||||
for (col = cinfo->image_width; col > 0; col--) {
|
for (col = cinfo->image_width; col > 0; col--) {
|
||||||
register int temp;
|
register unsigned int temp;
|
||||||
temp = UCH(*bufferptr++) << 8;
|
temp = UCH(*bufferptr++) << 8;
|
||||||
temp |= UCH(*bufferptr++);
|
temp |= UCH(*bufferptr++);
|
||||||
if (temp > maxval)
|
if (temp > maxval)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
if(NOT DEFINED NASM)
|
if(NOT DEFINED NASM)
|
||||||
set(NASM nasm CACHE FILEPATH "Path to NASM/YASM executable")
|
find_program(NASM NAMES nasm yasm DOC "Path to NASM/YASM executable")
|
||||||
endif()
|
endif()
|
||||||
|
message(STATUS "NASM = ${NASM}")
|
||||||
|
|
||||||
if(SIMD_X86_64)
|
if(SIMD_X86_64)
|
||||||
set(NAFLAGS -fwin64 -DWIN64 -D__x86_64__)
|
set(NAFLAGS -fwin64 -DWIN64 -D__x86_64__)
|
||||||
|
|||||||
@@ -73,19 +73,24 @@ endif
|
|||||||
|
|
||||||
if SIMD_POWERPC
|
if SIMD_POWERPC
|
||||||
|
|
||||||
libsimd_la_SOURCES = jsimd_powerpc.c jsimd_altivec.h jcsample.h \
|
noinst_LTLIBRARIES += libsimd_altivec.la
|
||||||
|
|
||||||
|
libsimd_altivec_la_SOURCES = \
|
||||||
jccolor-altivec.c jcgray-altivec.c jcsample-altivec.c \
|
jccolor-altivec.c jcgray-altivec.c jcsample-altivec.c \
|
||||||
jdcolor-altivec.c jdmerge-altivec.c jdsample-altivec.c \
|
jdcolor-altivec.c jdmerge-altivec.c jdsample-altivec.c \
|
||||||
jfdctfst-altivec.c jfdctint-altivec.c \
|
jfdctfst-altivec.c jfdctint-altivec.c \
|
||||||
jidctfst-altivec.c jidctint-altivec.c \
|
jidctfst-altivec.c jidctint-altivec.c \
|
||||||
jquanti-altivec.c
|
jquanti-altivec.c
|
||||||
libsimd_la_CFLAGS = -maltivec
|
libsimd_altivec_la_CFLAGS = -maltivec
|
||||||
|
|
||||||
jccolor-altivec.lo: jccolext-altivec.c
|
jccolor-altivec.lo: jccolext-altivec.c
|
||||||
jcgray-altivec.lo: jcgryext-altivec.c
|
jcgray-altivec.lo: jcgryext-altivec.c
|
||||||
jdcolor-altivec.lo: jdcolext-altivec.c
|
jdcolor-altivec.lo: jdcolext-altivec.c
|
||||||
jdmerge-altivec.lo: jdmrgext-altivec.c
|
jdmerge-altivec.lo: jdmrgext-altivec.c
|
||||||
|
|
||||||
|
libsimd_la_SOURCES = jsimd_powerpc.c jsimd_altivec.h jcsample.h
|
||||||
|
libsimd_la_LIBADD = libsimd_altivec.la
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)
|
AM_CPPFLAGS = -I$(top_srcdir)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
;
|
;
|
||||||
; jchuff-sse2.asm - Huffman entropy encoding (SSE2)
|
; jchuff-sse2.asm - Huffman entropy encoding (SSE2)
|
||||||
;
|
;
|
||||||
; Copyright (C) 2009-2011, 2014-2016, D. R. Commander.
|
; Copyright (C) 2009-2011, 2014-2017, D. R. Commander.
|
||||||
; Copyright (C) 2015, Matthieu Darbois.
|
; Copyright (C) 2015, Matthieu Darbois.
|
||||||
;
|
;
|
||||||
; Based on the x86 SIMD extension for IJG JPEG library
|
; Based on the x86 SIMD extension for IJG JPEG library
|
||||||
@@ -288,13 +288,13 @@ EXTN(jsimd_huff_encode_one_block_sse2):
|
|||||||
|
|
||||||
.BLOOP:
|
.BLOOP:
|
||||||
bsf ecx, edx ; r = __builtin_ctzl(index);
|
bsf ecx, edx ; r = __builtin_ctzl(index);
|
||||||
jz .ELOOP
|
jz near .ELOOP
|
||||||
lea esi, [esi+ecx*2] ; k += r;
|
lea esi, [esi+ecx*2] ; k += r;
|
||||||
shr edx, cl ; index >>= r;
|
shr edx, cl ; index >>= r;
|
||||||
mov DWORD [esp+temp3], edx
|
mov DWORD [esp+temp3], edx
|
||||||
.BRLOOP:
|
.BRLOOP:
|
||||||
cmp ecx, 16 ; while (r > 15) {
|
cmp ecx, 16 ; while (r > 15) {
|
||||||
jl .ERLOOP
|
jl near .ERLOOP
|
||||||
sub ecx, 16 ; r -= 16;
|
sub ecx, 16 ; r -= 16;
|
||||||
mov DWORD [esp+temp], ecx
|
mov DWORD [esp+temp], ecx
|
||||||
mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0];
|
mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0];
|
||||||
@@ -348,7 +348,7 @@ EXTN(jsimd_huff_encode_one_block_sse2):
|
|||||||
sub eax, esi
|
sub eax, esi
|
||||||
shr eax, 1
|
shr eax, 1
|
||||||
bsf ecx, edx ; r = __builtin_ctzl(index);
|
bsf ecx, edx ; r = __builtin_ctzl(index);
|
||||||
jz .ELOOP2
|
jz near .ELOOP2
|
||||||
shr edx, cl ; index >>= r;
|
shr edx, cl ; index >>= r;
|
||||||
add ecx, eax
|
add ecx, eax
|
||||||
lea esi, [esi+ecx*2] ; k += r;
|
lea esi, [esi+ecx*2] ; k += r;
|
||||||
@@ -356,13 +356,13 @@ EXTN(jsimd_huff_encode_one_block_sse2):
|
|||||||
jmp .BRLOOP2
|
jmp .BRLOOP2
|
||||||
.BLOOP2:
|
.BLOOP2:
|
||||||
bsf ecx, edx ; r = __builtin_ctzl(index);
|
bsf ecx, edx ; r = __builtin_ctzl(index);
|
||||||
jz .ELOOP2
|
jz near .ELOOP2
|
||||||
lea esi, [esi+ecx*2] ; k += r;
|
lea esi, [esi+ecx*2] ; k += r;
|
||||||
shr edx, cl ; index >>= r;
|
shr edx, cl ; index >>= r;
|
||||||
mov DWORD [esp+temp3], edx
|
mov DWORD [esp+temp3], edx
|
||||||
.BRLOOP2:
|
.BRLOOP2:
|
||||||
cmp ecx, 16 ; while (r > 15) {
|
cmp ecx, 16 ; while (r > 15) {
|
||||||
jl .ERLOOP2
|
jl near .ERLOOP2
|
||||||
sub ecx, 16 ; r -= 16;
|
sub ecx, 16 ; r -= 16;
|
||||||
mov DWORD [esp+temp], ecx
|
mov DWORD [esp+temp], ecx
|
||||||
mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0];
|
mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0];
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* jsimd_arm.c
|
* jsimd_arm.c
|
||||||
*
|
*
|
||||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||||
|
* Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
|
||||||
* Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander.
|
* Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander.
|
||||||
* Copyright (C) 2015-2016, Matthieu Darbois.
|
* Copyright (C) 2015-2016, Matthieu Darbois.
|
||||||
*
|
*
|
||||||
@@ -125,7 +126,7 @@ init_simd (void)
|
|||||||
/* Force different settings through environment variables */
|
/* Force different settings through environment variables */
|
||||||
env = getenv("JSIMD_FORCENEON");
|
env = getenv("JSIMD_FORCENEON");
|
||||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||||
simd_support &= JSIMD_ARM_NEON;
|
simd_support = JSIMD_ARM_NEON;
|
||||||
env = getenv("JSIMD_FORCENONE");
|
env = getenv("JSIMD_FORCENONE");
|
||||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||||
simd_support = 0;
|
simd_support = 0;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* jsimd_arm64.c
|
* jsimd_arm64.c
|
||||||
*
|
*
|
||||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||||
|
* Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
|
||||||
* Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander.
|
* Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander.
|
||||||
* Copyright (C) 2015-2016, Matthieu Darbois.
|
* Copyright (C) 2015-2016, Matthieu Darbois.
|
||||||
*
|
*
|
||||||
@@ -142,7 +143,7 @@ init_simd (void)
|
|||||||
/* Force different settings through environment variables */
|
/* Force different settings through environment variables */
|
||||||
env = getenv("JSIMD_FORCENEON");
|
env = getenv("JSIMD_FORCENEON");
|
||||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||||
simd_support &= JSIMD_ARM_NEON;
|
simd_support = JSIMD_ARM_NEON;
|
||||||
env = getenv("JSIMD_FORCENONE");
|
env = getenv("JSIMD_FORCENONE");
|
||||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||||
simd_support = 0;
|
simd_support = 0;
|
||||||
|
|||||||
@@ -210,10 +210,16 @@ asm_function jsimd_idct_islow_neon
|
|||||||
TMP7 .req x13
|
TMP7 .req x13
|
||||||
TMP8 .req x14
|
TMP8 .req x14
|
||||||
|
|
||||||
|
/* OUTPUT_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
|
||||||
|
guarantee that the upper (unused) 32 bits of x3 are valid. This
|
||||||
|
instruction ensures that those bits are set to zero. */
|
||||||
|
uxtw x3, w3
|
||||||
|
|
||||||
sub sp, sp, #64
|
sub sp, sp, #64
|
||||||
adr x15, Ljsimd_idct_islow_neon_consts
|
adr x15, Ljsimd_idct_islow_neon_consts
|
||||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], #32
|
mov x10, sp
|
||||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], #32
|
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x10], #32
|
||||||
|
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x10], #32
|
||||||
ld1 {v0.8h, v1.8h}, [x15]
|
ld1 {v0.8h, v1.8h}, [x15]
|
||||||
ld1 {v2.8h, v3.8h, v4.8h, v5.8h}, [COEF_BLOCK], #64
|
ld1 {v2.8h, v3.8h, v4.8h, v5.8h}, [COEF_BLOCK], #64
|
||||||
ld1 {v18.8h, v19.8h, v20.8h, v21.8h}, [DCT_TABLE], #64
|
ld1 {v18.8h, v19.8h, v20.8h, v21.8h}, [DCT_TABLE], #64
|
||||||
@@ -238,7 +244,6 @@ asm_function jsimd_idct_islow_neon
|
|||||||
shl v10.8h, v2.8h, #(PASS1_BITS)
|
shl v10.8h, v2.8h, #(PASS1_BITS)
|
||||||
sqxtn v16.8b, v15.8h
|
sqxtn v16.8b, v15.8h
|
||||||
mov TMP1, v16.d[0]
|
mov TMP1, v16.d[0]
|
||||||
sub sp, sp, #64
|
|
||||||
mvn TMP2, TMP1
|
mvn TMP2, TMP1
|
||||||
|
|
||||||
cbnz TMP2, 2f
|
cbnz TMP2, 2f
|
||||||
@@ -807,6 +812,11 @@ asm_function jsimd_idct_ifast_neon
|
|||||||
TMP7 .req x13
|
TMP7 .req x13
|
||||||
TMP8 .req x14
|
TMP8 .req x14
|
||||||
|
|
||||||
|
/* OUTPUT_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
|
||||||
|
guarantee that the upper (unused) 32 bits of x3 are valid. This
|
||||||
|
instruction ensures that those bits are set to zero. */
|
||||||
|
uxtw x3, w3
|
||||||
|
|
||||||
/* Load and dequantize coefficients into NEON registers
|
/* Load and dequantize coefficients into NEON registers
|
||||||
* with the following allocation:
|
* with the following allocation:
|
||||||
* 0 1 2 3 | 4 5 6 7
|
* 0 1 2 3 | 4 5 6 7
|
||||||
@@ -1101,19 +1111,18 @@ asm_function jsimd_idct_4x4_neon
|
|||||||
TMP3 .req x2
|
TMP3 .req x2
|
||||||
TMP4 .req x15
|
TMP4 .req x15
|
||||||
|
|
||||||
|
/* OUTPUT_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
|
||||||
|
guarantee that the upper (unused) 32 bits of x3 are valid. This
|
||||||
|
instruction ensures that those bits are set to zero. */
|
||||||
|
uxtw x3, w3
|
||||||
|
|
||||||
/* Save all used NEON registers */
|
/* Save all used NEON registers */
|
||||||
sub sp, sp, 272
|
sub sp, sp, 64
|
||||||
str x15, [sp], 16
|
mov x9, sp
|
||||||
/* Load constants (v3.4h is just used for padding) */
|
/* Load constants (v3.4h is just used for padding) */
|
||||||
adr TMP4, Ljsimd_idct_4x4_neon_consts
|
adr TMP4, Ljsimd_idct_4x4_neon_consts
|
||||||
st1 {v0.8b, v1.8b, v2.8b, v3.8b}, [sp], 32
|
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x9], 32
|
||||||
st1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x9], 32
|
||||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
|
||||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
|
||||||
st1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
|
||||||
st1 {v20.8b, v21.8b, v22.8b, v23.8b}, [sp], 32
|
|
||||||
st1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
|
||||||
st1 {v28.8b, v29.8b, v30.8b, v31.8b}, [sp], 32
|
|
||||||
ld1 {v0.4h, v1.4h, v2.4h, v3.4h}, [TMP4]
|
ld1 {v0.4h, v1.4h, v2.4h, v3.4h}, [TMP4]
|
||||||
|
|
||||||
/* Load all COEF_BLOCK into NEON registers with the following allocation:
|
/* Load all COEF_BLOCK into NEON registers with the following allocation:
|
||||||
@@ -1222,16 +1231,8 @@ asm_function jsimd_idct_4x4_neon
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* vpop {v8.4h - v15.4h} ;not available */
|
/* vpop {v8.4h - v15.4h} ;not available */
|
||||||
sub sp, sp, #272
|
|
||||||
ldr x15, [sp], 16
|
|
||||||
ld1 {v0.8b, v1.8b, v2.8b, v3.8b}, [sp], 32
|
|
||||||
ld1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
|
||||||
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||||
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||||
ld1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
|
||||||
ld1 {v20.8b, v21.8b, v22.8b, v23.8b}, [sp], 32
|
|
||||||
ld1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
|
||||||
ld1 {v28.8b, v29.8b, v30.8b, v31.8b}, [sp], 32
|
|
||||||
blr x30
|
blr x30
|
||||||
|
|
||||||
.unreq DCT_TABLE
|
.unreq DCT_TABLE
|
||||||
@@ -1299,19 +1300,19 @@ asm_function jsimd_idct_2x2_neon
|
|||||||
TMP1 .req x0
|
TMP1 .req x0
|
||||||
TMP2 .req x15
|
TMP2 .req x15
|
||||||
|
|
||||||
|
/* OUTPUT_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
|
||||||
|
guarantee that the upper (unused) 32 bits of x3 are valid. This
|
||||||
|
instruction ensures that those bits are set to zero. */
|
||||||
|
uxtw x3, w3
|
||||||
|
|
||||||
/* vpush {v8.4h - v15.4h} ; not available */
|
/* vpush {v8.4h - v15.4h} ; not available */
|
||||||
sub sp, sp, 208
|
sub sp, sp, 64
|
||||||
str x15, [sp], 16
|
mov x9, sp
|
||||||
|
|
||||||
/* Load constants */
|
/* Load constants */
|
||||||
adr TMP2, Ljsimd_idct_2x2_neon_consts
|
adr TMP2, Ljsimd_idct_2x2_neon_consts
|
||||||
st1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x9], 32
|
||||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x9], 32
|
||||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
|
||||||
st1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
|
||||||
st1 {v21.8b, v22.8b}, [sp], 16
|
|
||||||
st1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
|
||||||
st1 {v30.8b, v31.8b}, [sp], 16
|
|
||||||
ld1 {v14.4h}, [TMP2]
|
ld1 {v14.4h}, [TMP2]
|
||||||
|
|
||||||
/* Load all COEF_BLOCK into NEON registers with the following allocation:
|
/* Load all COEF_BLOCK into NEON registers with the following allocation:
|
||||||
@@ -1411,15 +1412,8 @@ asm_function jsimd_idct_2x2_neon
|
|||||||
st1 {v26.b}[1], [TMP2], 1
|
st1 {v26.b}[1], [TMP2], 1
|
||||||
st1 {v27.b}[5], [TMP2], 1
|
st1 {v27.b}[5], [TMP2], 1
|
||||||
|
|
||||||
sub sp, sp, #208
|
|
||||||
ldr x15, [sp], 16
|
|
||||||
ld1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
|
||||||
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||||
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||||
ld1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
|
||||||
ld1 {v21.8b, v22.8b}, [sp], 16
|
|
||||||
ld1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
|
||||||
ld1 {v30.8b, v31.8b}, [sp], 16
|
|
||||||
blr x30
|
blr x30
|
||||||
|
|
||||||
.unreq DCT_TABLE
|
.unreq DCT_TABLE
|
||||||
@@ -1688,24 +1682,24 @@ asm_function jsimd_ycc_\colorid\()_convert_neon
|
|||||||
.else
|
.else
|
||||||
asm_function jsimd_ycc_\colorid\()_convert_neon_slowst3
|
asm_function jsimd_ycc_\colorid\()_convert_neon_slowst3
|
||||||
.endif
|
.endif
|
||||||
OUTPUT_WIDTH .req x0
|
OUTPUT_WIDTH .req w0
|
||||||
INPUT_BUF .req x1
|
INPUT_BUF .req x1
|
||||||
INPUT_ROW .req x2
|
INPUT_ROW .req w2
|
||||||
OUTPUT_BUF .req x3
|
OUTPUT_BUF .req x3
|
||||||
NUM_ROWS .req x4
|
NUM_ROWS .req w4
|
||||||
|
|
||||||
INPUT_BUF0 .req x5
|
INPUT_BUF0 .req x5
|
||||||
INPUT_BUF1 .req x6
|
INPUT_BUF1 .req x6
|
||||||
INPUT_BUF2 .req x1
|
INPUT_BUF2 .req x1
|
||||||
|
|
||||||
RGB .req x7
|
RGB .req x7
|
||||||
Y .req x8
|
Y .req x9
|
||||||
U .req x9
|
U .req x10
|
||||||
V .req x10
|
V .req x11
|
||||||
N .req x15
|
N .req w15
|
||||||
|
|
||||||
sub sp, sp, 336
|
sub sp, sp, 64
|
||||||
str x15, [sp], 16
|
mov x9, sp
|
||||||
|
|
||||||
/* Load constants to d1, d2, d3 (v0.4h is just used for padding) */
|
/* Load constants to d1, d2, d3 (v0.4h is just used for padding) */
|
||||||
.if \fast_st3 == 1
|
.if \fast_st3 == 1
|
||||||
@@ -1715,23 +1709,11 @@ asm_function jsimd_ycc_\colorid\()_convert_neon_slowst3
|
|||||||
.endif
|
.endif
|
||||||
|
|
||||||
/* Save NEON registers */
|
/* Save NEON registers */
|
||||||
st1 {v0.8b, v1.8b, v2.8b, v3.8b}, [sp], 32
|
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x9], 32
|
||||||
st1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x9], 32
|
||||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
|
||||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
|
||||||
st1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
|
||||||
st1 {v20.8b, v21.8b, v22.8b, v23.8b}, [sp], 32
|
|
||||||
st1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
|
||||||
st1 {v28.8b, v29.8b, v30.8b, v31.8b}, [sp], 32
|
|
||||||
ld1 {v0.4h, v1.4h}, [x15], 16
|
ld1 {v0.4h, v1.4h}, [x15], 16
|
||||||
ld1 {v2.8h}, [x15]
|
ld1 {v2.8h}, [x15]
|
||||||
|
|
||||||
/* Save ARM registers and handle input arguments */
|
|
||||||
/* push {x4, x5, x6, x7, x8, x9, x10, x30} */
|
|
||||||
stp x4, x5, [sp], 16
|
|
||||||
stp x6, x7, [sp], 16
|
|
||||||
stp x8, x9, [sp], 16
|
|
||||||
stp x10, x30, [sp], 16
|
|
||||||
ldr INPUT_BUF0, [INPUT_BUF]
|
ldr INPUT_BUF0, [INPUT_BUF]
|
||||||
ldr INPUT_BUF1, [INPUT_BUF, #8]
|
ldr INPUT_BUF1, [INPUT_BUF, #8]
|
||||||
ldr INPUT_BUF2, [INPUT_BUF, #16]
|
ldr INPUT_BUF2, [INPUT_BUF, #16]
|
||||||
@@ -1745,11 +1727,10 @@ asm_function jsimd_ycc_\colorid\()_convert_neon_slowst3
|
|||||||
cmp NUM_ROWS, #1
|
cmp NUM_ROWS, #1
|
||||||
b.lt 9f
|
b.lt 9f
|
||||||
0:
|
0:
|
||||||
lsl x16, INPUT_ROW, #3
|
ldr Y, [INPUT_BUF0, INPUT_ROW, uxtw #3]
|
||||||
ldr Y, [INPUT_BUF0, x16]
|
ldr U, [INPUT_BUF1, INPUT_ROW, uxtw #3]
|
||||||
ldr U, [INPUT_BUF1, x16]
|
|
||||||
mov N, OUTPUT_WIDTH
|
mov N, OUTPUT_WIDTH
|
||||||
ldr V, [INPUT_BUF2, x16]
|
ldr V, [INPUT_BUF2, INPUT_ROW, uxtw #3]
|
||||||
add INPUT_ROW, INPUT_ROW, #1
|
add INPUT_ROW, INPUT_ROW, #1
|
||||||
ldr RGB, [OUTPUT_BUF], #8
|
ldr RGB, [OUTPUT_BUF], #8
|
||||||
|
|
||||||
@@ -1799,21 +1780,8 @@ asm_function jsimd_ycc_\colorid\()_convert_neon_slowst3
|
|||||||
b.gt 0b
|
b.gt 0b
|
||||||
9:
|
9:
|
||||||
/* Restore all registers and return */
|
/* Restore all registers and return */
|
||||||
sub sp, sp, #336
|
|
||||||
ldr x15, [sp], 16
|
|
||||||
ld1 {v0.8b, v1.8b, v2.8b, v3.8b}, [sp], 32
|
|
||||||
ld1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
|
||||||
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||||
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||||
ld1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
|
||||||
ld1 {v20.8b, v21.8b, v22.8b, v23.8b}, [sp], 32
|
|
||||||
ld1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
|
||||||
ld1 {v28.8b, v29.8b, v30.8b, v31.8b}, [sp], 32
|
|
||||||
/* pop {r4, r5, r6, r7, r8, r9, r10, pc} */
|
|
||||||
ldp x4, x5, [sp], 16
|
|
||||||
ldp x6, x7, [sp], 16
|
|
||||||
ldp x8, x9, [sp], 16
|
|
||||||
ldp x10, x30, [sp], 16
|
|
||||||
br x30
|
br x30
|
||||||
.unreq OUTPUT_WIDTH
|
.unreq OUTPUT_WIDTH
|
||||||
.unreq INPUT_ROW
|
.unreq INPUT_ROW
|
||||||
@@ -2054,8 +2022,8 @@ asm_function jsimd_\colorid\()_ycc_convert_neon_slowld3
|
|||||||
OUTPUT_WIDTH .req w0
|
OUTPUT_WIDTH .req w0
|
||||||
INPUT_BUF .req x1
|
INPUT_BUF .req x1
|
||||||
OUTPUT_BUF .req x2
|
OUTPUT_BUF .req x2
|
||||||
OUTPUT_ROW .req x3
|
OUTPUT_ROW .req w3
|
||||||
NUM_ROWS .req x4
|
NUM_ROWS .req w4
|
||||||
|
|
||||||
OUTPUT_BUF0 .req x5
|
OUTPUT_BUF0 .req x5
|
||||||
OUTPUT_BUF1 .req x6
|
OUTPUT_BUF1 .req x6
|
||||||
@@ -2082,17 +2050,18 @@ asm_function jsimd_\colorid\()_ycc_convert_neon_slowld3
|
|||||||
|
|
||||||
/* Save NEON registers */
|
/* Save NEON registers */
|
||||||
sub sp, sp, #64
|
sub sp, sp, #64
|
||||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
mov x9, sp
|
||||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x9], 32
|
||||||
|
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x9], 32
|
||||||
|
|
||||||
/* Outer loop over scanlines */
|
/* Outer loop over scanlines */
|
||||||
cmp NUM_ROWS, #1
|
cmp NUM_ROWS, #1
|
||||||
b.lt 9f
|
b.lt 9f
|
||||||
0:
|
0:
|
||||||
ldr Y, [OUTPUT_BUF0, OUTPUT_ROW, lsl #3]
|
ldr Y, [OUTPUT_BUF0, OUTPUT_ROW, uxtw #3]
|
||||||
ldr U, [OUTPUT_BUF1, OUTPUT_ROW, lsl #3]
|
ldr U, [OUTPUT_BUF1, OUTPUT_ROW, uxtw #3]
|
||||||
mov N, OUTPUT_WIDTH
|
mov N, OUTPUT_WIDTH
|
||||||
ldr V, [OUTPUT_BUF2, OUTPUT_ROW, lsl #3]
|
ldr V, [OUTPUT_BUF2, OUTPUT_ROW, uxtw #3]
|
||||||
add OUTPUT_ROW, OUTPUT_ROW, #1
|
add OUTPUT_ROW, OUTPUT_ROW, #1
|
||||||
ldr RGB, [INPUT_BUF], #8
|
ldr RGB, [INPUT_BUF], #8
|
||||||
|
|
||||||
@@ -2136,7 +2105,6 @@ asm_function jsimd_\colorid\()_ycc_convert_neon_slowld3
|
|||||||
b.gt 0b
|
b.gt 0b
|
||||||
9:
|
9:
|
||||||
/* Restore all registers and return */
|
/* Restore all registers and return */
|
||||||
sub sp, sp, #64
|
|
||||||
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||||
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||||
br x30
|
br x30
|
||||||
@@ -2199,6 +2167,11 @@ asm_function jsimd_convsamp_neon
|
|||||||
TMP8 .req x4
|
TMP8 .req x4
|
||||||
TMPDUP .req w3
|
TMPDUP .req w3
|
||||||
|
|
||||||
|
/* START_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
|
||||||
|
guarantee that the upper (unused) 32 bits of x1 are valid. This
|
||||||
|
instruction ensures that those bits are set to zero. */
|
||||||
|
uxtw x1, w1
|
||||||
|
|
||||||
mov TMPDUP, #128
|
mov TMPDUP, #128
|
||||||
ldp TMP1, TMP2, [SAMPLE_DATA], 16
|
ldp TMP1, TMP2, [SAMPLE_DATA], 16
|
||||||
ldp TMP3, TMP4, [SAMPLE_DATA], 16
|
ldp TMP3, TMP4, [SAMPLE_DATA], 16
|
||||||
@@ -2335,8 +2308,9 @@ asm_function jsimd_fdct_islow_neon
|
|||||||
|
|
||||||
/* Save NEON registers */
|
/* Save NEON registers */
|
||||||
sub sp, sp, #64
|
sub sp, sp, #64
|
||||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
mov x10, sp
|
||||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x10], 32
|
||||||
|
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x10], 32
|
||||||
|
|
||||||
/* Load all DATA into NEON registers with the following allocation:
|
/* Load all DATA into NEON registers with the following allocation:
|
||||||
* 0 1 2 3 | 4 5 6 7
|
* 0 1 2 3 | 4 5 6 7
|
||||||
@@ -2566,7 +2540,6 @@ asm_function jsimd_fdct_islow_neon
|
|||||||
st1 {v20.8h, v21.8h, v22.8h, v23.8h}, [DATA]
|
st1 {v20.8h, v21.8h, v22.8h, v23.8h}, [DATA]
|
||||||
|
|
||||||
/* Restore NEON registers */
|
/* Restore NEON registers */
|
||||||
sub sp, sp, #64
|
|
||||||
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||||
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||||
|
|
||||||
@@ -3080,7 +3053,7 @@ asm_function jsimd_huff_encode_one_block_neon_slowtbl
|
|||||||
sub sp, sp, 272
|
sub sp, sp, 272
|
||||||
sub BUFFER, BUFFER, #0x1 /* BUFFER=buffer-- */
|
sub BUFFER, BUFFER, #0x1 /* BUFFER=buffer-- */
|
||||||
/* Save ARM registers */
|
/* Save ARM registers */
|
||||||
stp x19, x20, [sp], 16
|
stp x19, x20, [sp]
|
||||||
.if \fast_tbl == 1
|
.if \fast_tbl == 1
|
||||||
adr x15, Ljsimd_huff_encode_one_block_neon_consts
|
adr x15, Ljsimd_huff_encode_one_block_neon_consts
|
||||||
.else
|
.else
|
||||||
@@ -3294,7 +3267,7 @@ asm_function jsimd_huff_encode_one_block_neon_slowtbl
|
|||||||
and v18.16b, v18.16b, v23.16b
|
and v18.16b, v18.16b, v23.16b
|
||||||
add x3, x4, #0x400 /* r1 = dctbl->ehufsi */
|
add x3, x4, #0x400 /* r1 = dctbl->ehufsi */
|
||||||
and v20.16b, v20.16b, v23.16b
|
and v20.16b, v20.16b, v23.16b
|
||||||
add x15, sp, #0x80 /* x15 = t2 */
|
add x15, sp, #0x90 /* x15 = t2 */
|
||||||
and v22.16b, v22.16b, v23.16b
|
and v22.16b, v22.16b, v23.16b
|
||||||
ldr w10, [x4, x12, lsl #2]
|
ldr w10, [x4, x12, lsl #2]
|
||||||
addp v16.16b, v16.16b, v18.16b
|
addp v16.16b, v16.16b, v18.16b
|
||||||
@@ -3317,7 +3290,7 @@ asm_function jsimd_huff_encode_one_block_neon_slowtbl
|
|||||||
rbit x9, x9 /* x9 = index0 */
|
rbit x9, x9 /* x9 = index0 */
|
||||||
ldrb w14, [x4, #0xf0] /* x14 = actbl->ehufsi[0xf0] */
|
ldrb w14, [x4, #0xf0] /* x14 = actbl->ehufsi[0xf0] */
|
||||||
cmp w12, #(64-8)
|
cmp w12, #(64-8)
|
||||||
mov x11, sp
|
add x11, sp, #16
|
||||||
b.lt 4f
|
b.lt 4f
|
||||||
cbz x9, 6f
|
cbz x9, 6f
|
||||||
st1 {v0.8h, v1.8h, v2.8h, v3.8h}, [x11], #64
|
st1 {v0.8h, v1.8h, v2.8h, v3.8h}, [x11], #64
|
||||||
@@ -3421,7 +3394,7 @@ asm_function jsimd_huff_encode_one_block_neon_slowtbl
|
|||||||
put_bits x3, x11
|
put_bits x3, x11
|
||||||
cbnz x9, 1b
|
cbnz x9, 1b
|
||||||
6:
|
6:
|
||||||
add x13, sp, #0xfe
|
add x13, sp, #0x10e
|
||||||
cmp x15, x13
|
cmp x15, x13
|
||||||
b.hs 1f
|
b.hs 1f
|
||||||
ldr w12, [x5]
|
ldr w12, [x5]
|
||||||
@@ -3429,7 +3402,6 @@ asm_function jsimd_huff_encode_one_block_neon_slowtbl
|
|||||||
checkbuf47
|
checkbuf47
|
||||||
put_bits x12, x14
|
put_bits x12, x14
|
||||||
1:
|
1:
|
||||||
sub sp, sp, 16
|
|
||||||
str PUT_BUFFER, [x0, #0x10]
|
str PUT_BUFFER, [x0, #0x10]
|
||||||
str PUT_BITSw, [x0, #0x18]
|
str PUT_BITSw, [x0, #0x18]
|
||||||
ldp x19, x20, [sp], 16
|
ldp x19, x20, [sp], 16
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* jsimd_mips.c
|
* jsimd_mips.c
|
||||||
*
|
*
|
||||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||||
* Copyright (C) 2009-2011, 2014, D. R. Commander.
|
* Copyright (C) 2009-2011, 2014, 2016, D. R. Commander.
|
||||||
* Copyright (C) 2013-2014, MIPS Technologies, Inc., California.
|
* Copyright (C) 2013-2014, MIPS Technologies, Inc., California.
|
||||||
* Copyright (C) 2015, Matthieu Darbois.
|
* Copyright (C) 2015, Matthieu Darbois.
|
||||||
*
|
*
|
||||||
@@ -63,6 +63,8 @@ parse_proc_cpuinfo(const char* search_string)
|
|||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
init_simd (void)
|
init_simd (void)
|
||||||
{
|
{
|
||||||
|
char *env = NULL;
|
||||||
|
|
||||||
if (simd_support != ~0U)
|
if (simd_support != ~0U)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -77,6 +79,14 @@ init_simd (void)
|
|||||||
if (!parse_proc_cpuinfo("MIPS 74K"))
|
if (!parse_proc_cpuinfo("MIPS 74K"))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Force different settings through environment variables */
|
||||||
|
env = getenv("JSIMD_FORCEDSPR2");
|
||||||
|
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||||
|
simd_support = JSIMD_MIPS_DSPR2;
|
||||||
|
env = getenv("JSIMD_FORCENONE");
|
||||||
|
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||||
|
simd_support = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int mips_idct_ifast_coefs[4] = {
|
static const int mips_idct_ifast_coefs[4] = {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* jsimd_powerpc.c
|
* jsimd_powerpc.c
|
||||||
*
|
*
|
||||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||||
* Copyright (C) 2009-2011, 2014-2015, D. R. Commander.
|
* Copyright (C) 2009-2011, 2014-2016, D. R. Commander.
|
||||||
* Copyright (C) 2015, Matthieu Darbois.
|
* Copyright (C) 2015, Matthieu Darbois.
|
||||||
*
|
*
|
||||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||||
@@ -14,6 +14,11 @@
|
|||||||
* PowerPC architecture.
|
* PowerPC architecture.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef __amigaos4__
|
||||||
|
/* This must be defined first as it re-defines GLOBAL otherwise */
|
||||||
|
#include <proto/exec.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
#include "../jinclude.h"
|
#include "../jinclude.h"
|
||||||
#include "../jpeglib.h"
|
#include "../jpeglib.h"
|
||||||
@@ -22,19 +27,125 @@
|
|||||||
#include "../jsimddct.h"
|
#include "../jsimddct.h"
|
||||||
#include "jsimd.h"
|
#include "jsimd.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#if defined(__OpenBSD__)
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <machine/cpu.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static unsigned int simd_support = ~0;
|
static unsigned int simd_support = ~0;
|
||||||
|
|
||||||
|
#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
|
||||||
|
|
||||||
|
#define SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT (1024 * 1024)
|
||||||
|
|
||||||
|
LOCAL(int)
|
||||||
|
check_feature (char *buffer, char *feature)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
if (*feature == 0)
|
||||||
|
return 0;
|
||||||
|
if (strncmp(buffer, "cpu", 3) != 0)
|
||||||
|
return 0;
|
||||||
|
buffer += 3;
|
||||||
|
while (isspace(*buffer))
|
||||||
|
buffer++;
|
||||||
|
|
||||||
|
/* Check if 'feature' is present in the buffer as a separate word */
|
||||||
|
while ((p = strstr(buffer, feature))) {
|
||||||
|
if (p > buffer && !isspace(*(p - 1))) {
|
||||||
|
buffer++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
p += strlen(feature);
|
||||||
|
if (*p != 0 && !isspace(*p)) {
|
||||||
|
buffer++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCAL(int)
|
||||||
|
parse_proc_cpuinfo (int bufsize)
|
||||||
|
{
|
||||||
|
char *buffer = (char *)malloc(bufsize);
|
||||||
|
FILE *fd;
|
||||||
|
simd_support = 0;
|
||||||
|
|
||||||
|
if (!buffer)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fd = fopen("/proc/cpuinfo", "r");
|
||||||
|
if (fd) {
|
||||||
|
while (fgets(buffer, bufsize, fd)) {
|
||||||
|
if (!strchr(buffer, '\n') && !feof(fd)) {
|
||||||
|
/* "impossible" happened - insufficient size of the buffer! */
|
||||||
|
fclose(fd);
|
||||||
|
free(buffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (check_feature(buffer, "altivec"))
|
||||||
|
simd_support |= JSIMD_ALTIVEC;
|
||||||
|
}
|
||||||
|
fclose(fd);
|
||||||
|
}
|
||||||
|
free(buffer);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check what SIMD accelerations are supported.
|
||||||
|
*
|
||||||
|
* FIXME: This code is racy under a multi-threaded environment.
|
||||||
|
*/
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
init_simd (void)
|
init_simd (void)
|
||||||
{
|
{
|
||||||
char *env = NULL;
|
char *env = NULL;
|
||||||
|
#if !defined(__ALTIVEC__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__))
|
||||||
|
int bufsize = 1024; /* an initial guess for the line buffer size limit */
|
||||||
|
#elif defined(__amigaos4__)
|
||||||
|
uint32 altivec = 0;
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC };
|
||||||
|
int altivec;
|
||||||
|
size_t len = sizeof(altivec);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (simd_support != ~0U)
|
if (simd_support != ~0U)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
simd_support = JSIMD_ALTIVEC;
|
simd_support = 0;
|
||||||
|
|
||||||
|
#if defined(__ALTIVEC__) || defined(__APPLE__)
|
||||||
|
simd_support |= JSIMD_ALTIVEC;
|
||||||
|
#elif defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
|
||||||
|
while (!parse_proc_cpuinfo(bufsize)) {
|
||||||
|
bufsize *= 2;
|
||||||
|
if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#elif defined(__amigaos4__)
|
||||||
|
IExec->GetCPUInfoTags(GCIT_VectorUnit, &altivec, TAG_DONE);
|
||||||
|
if(altivec == VECTORTYPE_ALTIVEC)
|
||||||
|
simd_support |= JSIMD_ALTIVEC;
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
if (sysctl(mib, 2, &altivec, &len, NULL, 0) == 0 && altivec != 0)
|
||||||
|
simd_support |= JSIMD_ALTIVEC;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Force different settings through environment variables */
|
/* Force different settings through environment variables */
|
||||||
|
env = getenv("JSIMD_FORCEALTIVEC");
|
||||||
|
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||||
|
simd_support = JSIMD_ALTIVEC;
|
||||||
env = getenv("JSIMD_FORCENONE");
|
env = getenv("JSIMD_FORCENONE");
|
||||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||||
simd_support = 0;
|
simd_support = 0;
|
||||||
|
|||||||
@@ -832,21 +832,19 @@ read_backing_store, manipulate a backing-store object
|
|||||||
write_backing_store,
|
write_backing_store,
|
||||||
close_backing_store
|
close_backing_store
|
||||||
|
|
||||||
On some systems there will be more than one type of backing-store object
|
On some systems there will be more than one type of backing-store object.
|
||||||
(specifically, in MS-DOS a backing store file might be an area of extended
|
jpeg_open_backing_store is responsible for choosing how to implement a given
|
||||||
memory as well as a disk file). jpeg_open_backing_store is responsible for
|
object. The read/write/close routines are method pointers in the structure
|
||||||
choosing how to implement a given object. The read/write/close routines
|
that describes a given object; this lets them be different for different object
|
||||||
are method pointers in the structure that describes a given object; this
|
types.
|
||||||
lets them be different for different object types.
|
|
||||||
|
|
||||||
It may be necessary to ensure that backing store objects are explicitly
|
It may be necessary to ensure that backing store objects are explicitly
|
||||||
released upon abnormal program termination. For example, MS-DOS won't free
|
released upon abnormal program termination. To support this, we will expect
|
||||||
extended memory by itself. To support this, we will expect the main program
|
the main program or surrounding application to arrange to call self_destruct
|
||||||
or surrounding application to arrange to call self_destruct (typically via
|
(typically via jpeg_destroy) upon abnormal termination. This may require a
|
||||||
jpeg_destroy) upon abnormal termination. This may require a SIGINT signal
|
SIGINT signal handler or equivalent. We don't want to have the back end module
|
||||||
handler or equivalent. We don't want to have the back end module install its
|
install its own signal handler, because that would pre-empt the surrounding
|
||||||
own signal handler, because that would pre-empt the surrounding application's
|
application's ability to control signal handling.
|
||||||
ability to control signal handling.
|
|
||||||
|
|
||||||
The IJG distribution includes several memory manager back end implementations.
|
The IJG distribution includes several memory manager back end implementations.
|
||||||
Usually the same back end should be suitable for all applications on a given
|
Usually the same back end should be suitable for all applications on a given
|
||||||
|
|||||||
85
tjbench.c
85
tjbench.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2009-2016 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2009-2017 D. R. Commander. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -40,13 +40,13 @@
|
|||||||
|
|
||||||
#define _throw(op, err) { \
|
#define _throw(op, err) { \
|
||||||
printf("ERROR in line %d while %s:\n%s\n", __LINE__, op, err); \
|
printf("ERROR in line %d while %s:\n%s\n", __LINE__, op, err); \
|
||||||
retval=-1; goto bailout;}
|
retval=-1; goto bailout;}
|
||||||
#define _throwunix(m) _throw(m, strerror(errno))
|
#define _throwunix(m) _throw(m, strerror(errno))
|
||||||
#define _throwtj(m) _throw(m, tjGetErrorStr())
|
#define _throwtj(m) _throw(m, tjGetErrorStr())
|
||||||
#define _throwbmp(m) _throw(m, bmpgeterr())
|
#define _throwbmp(m) _throw(m, bmpgeterr())
|
||||||
|
|
||||||
int flags=TJFLAG_NOREALLOC, componly=0, decomponly=0, doyuv=0, quiet=0,
|
int flags=TJFLAG_NOREALLOC, componly=0, decomponly=0, doyuv=0, quiet=0,
|
||||||
dotile=0, pf=TJPF_BGR, yuvpad=1, warmup=1, dowrite=1;
|
dotile=0, pf=TJPF_BGR, yuvpad=1, dowrite=1;
|
||||||
char *ext="ppm";
|
char *ext="ppm";
|
||||||
const char *pixFormatStr[TJ_NUMPF]=
|
const char *pixFormatStr[TJ_NUMPF]=
|
||||||
{
|
{
|
||||||
@@ -64,7 +64,7 @@ const char *subName[TJ_NUMSAMP]={"444", "422", "420", "GRAY", "440", "411"};
|
|||||||
tjscalingfactor *scalingfactors=NULL, sf={1, 1}; int nsf=0;
|
tjscalingfactor *scalingfactors=NULL, sf={1, 1}; int nsf=0;
|
||||||
int xformop=TJXOP_NONE, xformopt=0;
|
int xformop=TJXOP_NONE, xformopt=0;
|
||||||
int (*customFilter)(short *, tjregion, tjregion, int, int, tjtransform *);
|
int (*customFilter)(short *, tjregion, tjregion, int, int, tjtransform *);
|
||||||
double benchtime=5.0;
|
double benchtime=5.0, warmup=1.0;
|
||||||
|
|
||||||
|
|
||||||
char *formatName(int subsamp, int cs, char *buf)
|
char *formatName(int subsamp, int cs, char *buf)
|
||||||
@@ -146,7 +146,7 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Benchmark */
|
/* Benchmark */
|
||||||
iter=-warmup;
|
iter=-1;
|
||||||
elapsed=elapsedDecode=0.;
|
elapsed=elapsedDecode=0.;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
@@ -176,12 +176,17 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
|
|||||||
_throwtj("executing tjDecompress2()");
|
_throwtj("executing tjDecompress2()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iter++;
|
elapsed+=gettime()-start;
|
||||||
if(iter>=1)
|
if(iter>=0)
|
||||||
{
|
{
|
||||||
elapsed+=gettime()-start;
|
iter++;
|
||||||
if(elapsed>=benchtime) break;
|
if(elapsed>=benchtime) break;
|
||||||
}
|
}
|
||||||
|
else if(elapsed>=warmup)
|
||||||
|
{
|
||||||
|
iter=0;
|
||||||
|
elapsed=elapsedDecode=0.;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(doyuv) elapsed-=elapsedDecode;
|
if(doyuv) elapsed-=elapsedDecode;
|
||||||
|
|
||||||
@@ -207,7 +212,7 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
|
|||||||
(double)(w*h)/1000000.*(double)iter/elapsed);
|
(double)(w*h)/1000000.*(double)iter/elapsed);
|
||||||
if(doyuv)
|
if(doyuv)
|
||||||
{
|
{
|
||||||
printf("YUV Decode --> Frame rate: %f fps\n",
|
printf("YUV Decode --> Frame rate: %f fps\n",
|
||||||
(double)iter/elapsedDecode);
|
(double)iter/elapsedDecode);
|
||||||
printf(" Throughput: %f Megapixels/sec\n",
|
printf(" Throughput: %f Megapixels/sec\n",
|
||||||
(double)(w*h)/1000000.*(double)iter/elapsedDecode);
|
(double)(w*h)/1000000.*(double)iter/elapsedDecode);
|
||||||
@@ -248,7 +253,8 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
|
|||||||
int y=(int)((double)srcbuf[rindex]*0.299
|
int y=(int)((double)srcbuf[rindex]*0.299
|
||||||
+ (double)srcbuf[gindex]*0.587
|
+ (double)srcbuf[gindex]*0.587
|
||||||
+ (double)srcbuf[bindex]*0.114 + 0.5);
|
+ (double)srcbuf[bindex]*0.114 + 0.5);
|
||||||
if(y>255) y=255; if(y<0) y=0;
|
if(y>255) y=255;
|
||||||
|
if(y<0) y=0;
|
||||||
dstbuf[rindex]=abs(dstbuf[rindex]-y);
|
dstbuf[rindex]=abs(dstbuf[rindex]-y);
|
||||||
dstbuf[gindex]=abs(dstbuf[gindex]-y);
|
dstbuf[gindex]=abs(dstbuf[gindex]-y);
|
||||||
dstbuf[bindex]=abs(dstbuf[bindex]-y);
|
dstbuf[bindex]=abs(dstbuf[bindex]-y);
|
||||||
@@ -300,7 +306,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
|
|||||||
|
|
||||||
for(tilew=dotile? 8:w, tileh=dotile? 8:h; ; tilew*=2, tileh*=2)
|
for(tilew=dotile? 8:w, tileh=dotile? 8:h; ; tilew*=2, tileh*=2)
|
||||||
{
|
{
|
||||||
if(tilew>w) tilew=w; if(tileh>h) tileh=h;
|
if(tilew>w) tilew=w;
|
||||||
|
if(tileh>h) tileh=h;
|
||||||
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;
|
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;
|
||||||
|
|
||||||
if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
|
if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
|
||||||
@@ -338,7 +345,7 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Benchmark */
|
/* Benchmark */
|
||||||
iter=-warmup;
|
iter=-1;
|
||||||
elapsed=elapsedEncode=0.;
|
elapsed=elapsedEncode=0.;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
@@ -372,12 +379,17 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
|
|||||||
totaljpegsize+=jpegsize[tile];
|
totaljpegsize+=jpegsize[tile];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iter++;
|
elapsed+=gettime()-start;
|
||||||
if(iter>=1)
|
if(iter>=0)
|
||||||
{
|
{
|
||||||
elapsed+=gettime()-start;
|
iter++;
|
||||||
if(elapsed>=benchtime) break;
|
if(elapsed>=benchtime) break;
|
||||||
}
|
}
|
||||||
|
else if(elapsed>=warmup)
|
||||||
|
{
|
||||||
|
iter=0;
|
||||||
|
elapsed=elapsedEncode=0.;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(doyuv) elapsed-=elapsedEncode;
|
if(doyuv) elapsed-=elapsedEncode;
|
||||||
|
|
||||||
@@ -447,7 +459,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
|
|||||||
|
|
||||||
for(i=0; i<ntilesw*ntilesh; i++)
|
for(i=0; i<ntilesw*ntilesh; i++)
|
||||||
{
|
{
|
||||||
if(jpegbuf[i]) tjFree(jpegbuf[i]); jpegbuf[i]=NULL;
|
if(jpegbuf[i]) tjFree(jpegbuf[i]);
|
||||||
|
jpegbuf[i]=NULL;
|
||||||
}
|
}
|
||||||
free(jpegbuf); jpegbuf=NULL;
|
free(jpegbuf); jpegbuf=NULL;
|
||||||
free(jpegsize); jpegsize=NULL;
|
free(jpegsize); jpegsize=NULL;
|
||||||
@@ -465,7 +478,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
|
|||||||
{
|
{
|
||||||
for(i=0; i<ntilesw*ntilesh; i++)
|
for(i=0; i<ntilesw*ntilesh; i++)
|
||||||
{
|
{
|
||||||
if(jpegbuf[i]) tjFree(jpegbuf[i]); jpegbuf[i]=NULL;
|
if(jpegbuf[i]) tjFree(jpegbuf[i]);
|
||||||
|
jpegbuf[i]=NULL;
|
||||||
}
|
}
|
||||||
free(jpegbuf); jpegbuf=NULL;
|
free(jpegbuf); jpegbuf=NULL;
|
||||||
}
|
}
|
||||||
@@ -532,7 +546,8 @@ int decompTest(char *filename)
|
|||||||
|
|
||||||
for(tilew=dotile? 16:w, tileh=dotile? 16:h; ; tilew*=2, tileh*=2)
|
for(tilew=dotile? 16:w, tileh=dotile? 16:h; ; tilew*=2, tileh*=2)
|
||||||
{
|
{
|
||||||
if(tilew>w) tilew=w; if(tileh>h) tileh=h;
|
if(tilew>w) tilew=w;
|
||||||
|
if(tileh>h) tileh=h;
|
||||||
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;
|
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;
|
||||||
|
|
||||||
if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
|
if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
|
||||||
@@ -618,7 +633,7 @@ int decompTest(char *filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iter=-warmup;
|
iter=-1;
|
||||||
elapsed=0.;
|
elapsed=0.;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
@@ -626,12 +641,17 @@ int decompTest(char *filename)
|
|||||||
if(tjTransform(handle, srcbuf, srcsize, _ntilesw*_ntilesh, jpegbuf,
|
if(tjTransform(handle, srcbuf, srcsize, _ntilesw*_ntilesh, jpegbuf,
|
||||||
jpegsize, t, flags)==-1)
|
jpegsize, t, flags)==-1)
|
||||||
_throwtj("executing tjTransform()");
|
_throwtj("executing tjTransform()");
|
||||||
iter++;
|
elapsed+=gettime()-start;
|
||||||
if(iter>=1)
|
if(iter>=0)
|
||||||
{
|
{
|
||||||
elapsed+=gettime()-start;
|
iter++;
|
||||||
if(elapsed>=benchtime) break;
|
if(elapsed>=benchtime) break;
|
||||||
}
|
}
|
||||||
|
else if(elapsed>=warmup)
|
||||||
|
{
|
||||||
|
iter=0;
|
||||||
|
elapsed=0.;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(t); t=NULL;
|
free(t); t=NULL;
|
||||||
@@ -663,7 +683,9 @@ int decompTest(char *filename)
|
|||||||
{
|
{
|
||||||
if(quiet==1) printf("N/A N/A ");
|
if(quiet==1) printf("N/A N/A ");
|
||||||
jpegsize[0]=srcsize;
|
jpegsize[0]=srcsize;
|
||||||
memcpy(jpegbuf[0], srcbuf, srcsize);
|
free(jpegbuf[0]);
|
||||||
|
jpegbuf[0]=srcbuf;
|
||||||
|
srcbuf=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(w==tilew) _tilew=_w;
|
if(w==tilew) _tilew=_w;
|
||||||
@@ -692,7 +714,8 @@ int decompTest(char *filename)
|
|||||||
{
|
{
|
||||||
for(i=0; i<ntilesw*ntilesh; i++)
|
for(i=0; i<ntilesw*ntilesh; i++)
|
||||||
{
|
{
|
||||||
if(jpegbuf[i]) tjFree(jpegbuf[i]); jpegbuf[i]=NULL;
|
if(jpegbuf[i]) tjFree(jpegbuf[i]);
|
||||||
|
jpegbuf[i]=NULL;
|
||||||
}
|
}
|
||||||
free(jpegbuf); jpegbuf=NULL;
|
free(jpegbuf); jpegbuf=NULL;
|
||||||
}
|
}
|
||||||
@@ -757,8 +780,9 @@ void usage(char *progname)
|
|||||||
printf("-grayscale = Perform lossless grayscale conversion prior to decompression\n");
|
printf("-grayscale = Perform lossless grayscale conversion prior to decompression\n");
|
||||||
printf(" test (can be combined with the other transforms above)\n");
|
printf(" test (can be combined with the other transforms above)\n");
|
||||||
printf("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)\n");
|
printf("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)\n");
|
||||||
printf("-warmup <w> = Execute each benchmark <w> times to prime the cache before\n");
|
printf("-warmup <t> = Run each benchmark for <t> seconds (default = 1.0) prior to\n");
|
||||||
printf(" taking performance measurements (default = 1)\n");
|
printf(" starting the timer, in order to prime the caches and thus improve the\n");
|
||||||
|
printf(" consistency of the results.\n");
|
||||||
printf("-componly = Stop after running compression tests. Do not test decompression.\n");
|
printf("-componly = Stop after running compression tests. Do not test decompression.\n");
|
||||||
printf("-nowrite = Do not write reference or output images (improves consistency of\n");
|
printf("-nowrite = Do not write reference or output images (improves consistency of\n");
|
||||||
printf(" performance measurements.)\n\n");
|
printf(" performance measurements.)\n\n");
|
||||||
@@ -872,13 +896,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if(!strcasecmp(argv[i], "-warmup") && i<argc-1)
|
if(!strcasecmp(argv[i], "-warmup") && i<argc-1)
|
||||||
{
|
{
|
||||||
int temp=atoi(argv[++i]);
|
double temp=atof(argv[++i]);
|
||||||
if(temp>=0)
|
if(temp>=0.0) warmup=temp;
|
||||||
{
|
|
||||||
warmup=temp;
|
|
||||||
printf("Warmup runs = %d\n\n", warmup);
|
|
||||||
}
|
|
||||||
else usage(argv[0]);
|
else usage(argv[0]);
|
||||||
|
printf("Warmup time = %.1f seconds\n\n", warmup);
|
||||||
}
|
}
|
||||||
if(!strcmp(argv[i], "-?")) usage(argv[0]);
|
if(!strcmp(argv[i], "-?")) usage(argv[0]);
|
||||||
if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC);
|
if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC);
|
||||||
|
|||||||
19
transupp.c
19
transupp.c
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding.
|
* Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, D. R. Commander.
|
* Copyright (C) 2010, 2017, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -1177,7 +1177,6 @@ transpose_critical_parameters (j_compress_ptr dstinfo)
|
|||||||
* We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible.
|
* We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 70
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
adjust_exif_parameters (JOCTET *data, unsigned int length,
|
adjust_exif_parameters (JOCTET *data, unsigned int length,
|
||||||
JDIMENSION new_width, JDIMENSION new_height)
|
JDIMENSION new_width, JDIMENSION new_height)
|
||||||
@@ -1327,7 +1326,6 @@ adjust_exif_parameters (JOCTET *data, unsigned int length,
|
|||||||
offset += 12;
|
offset += 12;
|
||||||
} while (--number_of_tags);
|
} while (--number_of_tags);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Adjust output image parameters as needed.
|
/* Adjust output image parameters as needed.
|
||||||
@@ -1384,7 +1382,7 @@ jtransform_adjust_parameters (j_decompress_ptr srcinfo,
|
|||||||
/* Correct the destination's image dimensions as necessary
|
/* Correct the destination's image dimensions as necessary
|
||||||
* for rotate/flip, resize, and crop operations.
|
* for rotate/flip, resize, and crop operations.
|
||||||
*/
|
*/
|
||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 80
|
||||||
dstinfo->jpeg_width = info->output_width;
|
dstinfo->jpeg_width = info->output_width;
|
||||||
dstinfo->jpeg_height = info->output_height;
|
dstinfo->jpeg_height = info->output_height;
|
||||||
#endif
|
#endif
|
||||||
@@ -1395,14 +1393,14 @@ jtransform_adjust_parameters (j_decompress_ptr srcinfo,
|
|||||||
case JXFORM_TRANSVERSE:
|
case JXFORM_TRANSVERSE:
|
||||||
case JXFORM_ROT_90:
|
case JXFORM_ROT_90:
|
||||||
case JXFORM_ROT_270:
|
case JXFORM_ROT_270:
|
||||||
#if JPEG_LIB_VERSION < 70
|
#if JPEG_LIB_VERSION < 80
|
||||||
dstinfo->image_width = info->output_height;
|
dstinfo->image_width = info->output_height;
|
||||||
dstinfo->image_height = info->output_width;
|
dstinfo->image_height = info->output_width;
|
||||||
#endif
|
#endif
|
||||||
transpose_critical_parameters(dstinfo);
|
transpose_critical_parameters(dstinfo);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
#if JPEG_LIB_VERSION < 70
|
#if JPEG_LIB_VERSION < 80
|
||||||
dstinfo->image_width = info->output_width;
|
dstinfo->image_width = info->output_width;
|
||||||
dstinfo->image_height = info->output_height;
|
dstinfo->image_height = info->output_height;
|
||||||
#endif
|
#endif
|
||||||
@@ -1421,14 +1419,21 @@ jtransform_adjust_parameters (j_decompress_ptr srcinfo,
|
|||||||
GETJOCTET(srcinfo->marker_list->data[5]) == 0) {
|
GETJOCTET(srcinfo->marker_list->data[5]) == 0) {
|
||||||
/* Suppress output of JFIF marker */
|
/* Suppress output of JFIF marker */
|
||||||
dstinfo->write_JFIF_header = FALSE;
|
dstinfo->write_JFIF_header = FALSE;
|
||||||
#if JPEG_LIB_VERSION >= 70
|
|
||||||
/* Adjust Exif image parameters */
|
/* Adjust Exif image parameters */
|
||||||
|
#if JPEG_LIB_VERSION >= 80
|
||||||
if (dstinfo->jpeg_width != srcinfo->image_width ||
|
if (dstinfo->jpeg_width != srcinfo->image_width ||
|
||||||
dstinfo->jpeg_height != srcinfo->image_height)
|
dstinfo->jpeg_height != srcinfo->image_height)
|
||||||
/* Align data segment to start of TIFF structure for parsing */
|
/* Align data segment to start of TIFF structure for parsing */
|
||||||
adjust_exif_parameters(srcinfo->marker_list->data + 6,
|
adjust_exif_parameters(srcinfo->marker_list->data + 6,
|
||||||
srcinfo->marker_list->data_length - 6,
|
srcinfo->marker_list->data_length - 6,
|
||||||
dstinfo->jpeg_width, dstinfo->jpeg_height);
|
dstinfo->jpeg_width, dstinfo->jpeg_height);
|
||||||
|
#else
|
||||||
|
if (dstinfo->image_width != srcinfo->image_width ||
|
||||||
|
dstinfo->image_height != srcinfo->image_height)
|
||||||
|
/* Align data segment to start of TIFF structure for parsing */
|
||||||
|
adjust_exif_parameters(srcinfo->marker_list->data + 6,
|
||||||
|
srcinfo->marker_list->data_length - 6,
|
||||||
|
dstinfo->image_width, dstinfo->image_height);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
112
turbojpeg.c
112
turbojpeg.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2009-2016 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2009-2017 D. R. Commander. All Rights Reserved.
|
||||||
* mozjpeg Modifications:
|
* mozjpeg Modifications:
|
||||||
* Copyright (C) 2014, Mozilla Corporation.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
*
|
*
|
||||||
@@ -376,6 +376,29 @@ static int getSubsamp(j_decompress_ptr dinfo)
|
|||||||
retval=i; break;
|
retval=i; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Handle 4:2:2 and 4:4:0 images whose sampling factors are specified
|
||||||
|
in non-standard ways. */
|
||||||
|
if(dinfo->comp_info[0].h_samp_factor==2 &&
|
||||||
|
dinfo->comp_info[0].v_samp_factor==2 &&
|
||||||
|
(i==TJSAMP_422 || i==TJSAMP_440))
|
||||||
|
{
|
||||||
|
int match=0;
|
||||||
|
for(k=1; k<dinfo->num_components; k++)
|
||||||
|
{
|
||||||
|
int href=tjMCUHeight[i]/8, vref=tjMCUWidth[i]/8;
|
||||||
|
if(dinfo->jpeg_color_space==JCS_YCCK && k==3)
|
||||||
|
{
|
||||||
|
href=vref=2;
|
||||||
|
}
|
||||||
|
if(dinfo->comp_info[k].h_samp_factor==href
|
||||||
|
&& dinfo->comp_info[k].v_samp_factor==vref)
|
||||||
|
match++;
|
||||||
|
}
|
||||||
|
if(match==dinfo->num_components-1)
|
||||||
|
{
|
||||||
|
retval=i; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
@@ -578,7 +601,8 @@ static tjhandle _tjInitCompress(tjinstance *this)
|
|||||||
if(setjmp(this->jerr.setjmp_buffer))
|
if(setjmp(this->jerr.setjmp_buffer))
|
||||||
{
|
{
|
||||||
/* If we get here, the JPEG code has signaled an error. */
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
if(this) free(this); return NULL;
|
if(this) free(this);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
jpeg_create_compress(&this->cinfo);
|
jpeg_create_compress(&this->cinfo);
|
||||||
@@ -756,13 +780,6 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
|
|||||||
|| jpegSubsamp<0 || jpegSubsamp>=NUMSUBOPT || jpegQual<0 || jpegQual>100)
|
|| jpegSubsamp<0 || jpegSubsamp>=NUMSUBOPT || jpegQual<0 || jpegQual>100)
|
||||||
_throw("tjCompress2(): Invalid argument");
|
_throw("tjCompress2(): Invalid argument");
|
||||||
|
|
||||||
if(setjmp(this->jerr.setjmp_buffer))
|
|
||||||
{
|
|
||||||
/* If we get here, the JPEG code has signaled an error. */
|
|
||||||
retval=-1;
|
|
||||||
goto bailout;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pitch==0) pitch=width*tjPixelSize[pixelFormat];
|
if(pitch==0) pitch=width*tjPixelSize[pixelFormat];
|
||||||
|
|
||||||
#ifndef JCS_EXTENSIONS
|
#ifndef JCS_EXTENSIONS
|
||||||
@@ -775,6 +792,16 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*height))==NULL)
|
||||||
|
_throw("tjCompress2(): Memory allocation failure");
|
||||||
|
|
||||||
|
if(setjmp(this->jerr.setjmp_buffer))
|
||||||
|
{
|
||||||
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
|
retval=-1;
|
||||||
|
goto bailout;
|
||||||
|
}
|
||||||
|
|
||||||
cinfo->image_width=width;
|
cinfo->image_width=width;
|
||||||
cinfo->image_height=height;
|
cinfo->image_height=height;
|
||||||
|
|
||||||
@@ -791,8 +818,6 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
jpeg_start_compress(cinfo, TRUE);
|
jpeg_start_compress(cinfo, TRUE);
|
||||||
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*height))==NULL)
|
|
||||||
_throw("tjCompress2(): Memory allocation failure");
|
|
||||||
for(i=0; i<height; i++)
|
for(i=0; i<height; i++)
|
||||||
{
|
{
|
||||||
if(flags&TJFLAG_BOTTOMUP)
|
if(flags&TJFLAG_BOTTOMUP)
|
||||||
@@ -872,13 +897,6 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
|
|||||||
if(subsamp!=TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
|
if(subsamp!=TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
|
||||||
_throw("tjEncodeYUVPlanes(): Invalid argument");
|
_throw("tjEncodeYUVPlanes(): Invalid argument");
|
||||||
|
|
||||||
if(setjmp(this->jerr.setjmp_buffer))
|
|
||||||
{
|
|
||||||
/* If we get here, the JPEG code has signaled an error. */
|
|
||||||
retval=-1;
|
|
||||||
goto bailout;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pixelFormat==TJPF_CMYK)
|
if(pixelFormat==TJPF_CMYK)
|
||||||
_throw("tjEncodeYUVPlanes(): Cannot generate YUV images from CMYK pixels");
|
_throw("tjEncodeYUVPlanes(): Cannot generate YUV images from CMYK pixels");
|
||||||
|
|
||||||
@@ -894,6 +912,13 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(setjmp(this->jerr.setjmp_buffer))
|
||||||
|
{
|
||||||
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
|
retval=-1;
|
||||||
|
goto bailout;
|
||||||
|
}
|
||||||
|
|
||||||
cinfo->image_width=width;
|
cinfo->image_width=width;
|
||||||
cinfo->image_height=height;
|
cinfo->image_height=height;
|
||||||
|
|
||||||
@@ -970,6 +995,13 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(setjmp(this->jerr.setjmp_buffer))
|
||||||
|
{
|
||||||
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
|
retval=-1;
|
||||||
|
goto bailout;
|
||||||
|
}
|
||||||
|
|
||||||
for(row=0; row<ph0; row+=cinfo->max_v_samp_factor)
|
for(row=0; row<ph0; row+=cinfo->max_v_samp_factor)
|
||||||
{
|
{
|
||||||
(*cinfo->cconvert->color_convert)(cinfo, &row_pointer[row], tmpbuf, 0,
|
(*cinfo->cconvert->color_convert)(cinfo, &row_pointer[row], tmpbuf, 0,
|
||||||
@@ -1144,6 +1176,13 @@ DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(setjmp(this->jerr.setjmp_buffer))
|
||||||
|
{
|
||||||
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
|
retval=-1;
|
||||||
|
goto bailout;
|
||||||
|
}
|
||||||
|
|
||||||
for(row=0; row<(int)cinfo->image_height;
|
for(row=0; row<(int)cinfo->image_height;
|
||||||
row+=cinfo->max_v_samp_factor*DCTSIZE)
|
row+=cinfo->max_v_samp_factor*DCTSIZE)
|
||||||
{
|
{
|
||||||
@@ -1239,7 +1278,8 @@ static tjhandle _tjInitDecompress(tjinstance *this)
|
|||||||
if(setjmp(this->jerr.setjmp_buffer))
|
if(setjmp(this->jerr.setjmp_buffer))
|
||||||
{
|
{
|
||||||
/* If we get here, the JPEG code has signaled an error. */
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
if(this) free(this); return NULL;
|
if(this) free(this);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
jpeg_create_decompress(&this->dinfo);
|
jpeg_create_decompress(&this->dinfo);
|
||||||
@@ -1421,6 +1461,12 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
|
|||||||
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)
|
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)
|
||||||
*dinfo->output_height))==NULL)
|
*dinfo->output_height))==NULL)
|
||||||
_throw("tjDecompress2(): Memory allocation failure");
|
_throw("tjDecompress2(): Memory allocation failure");
|
||||||
|
if(setjmp(this->jerr.setjmp_buffer))
|
||||||
|
{
|
||||||
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
|
retval=-1;
|
||||||
|
goto bailout;
|
||||||
|
}
|
||||||
for(i=0; i<(int)dinfo->output_height; i++)
|
for(i=0; i<(int)dinfo->output_height; i++)
|
||||||
{
|
{
|
||||||
if(flags&TJFLAG_BOTTOMUP)
|
if(flags&TJFLAG_BOTTOMUP)
|
||||||
@@ -1643,6 +1689,13 @@ DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(setjmp(this->jerr.setjmp_buffer))
|
||||||
|
{
|
||||||
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
|
retval=-1;
|
||||||
|
goto bailout;
|
||||||
|
}
|
||||||
|
|
||||||
for(row=0; row<ph0; row+=dinfo->max_v_samp_factor)
|
for(row=0; row<ph0; row+=dinfo->max_v_samp_factor)
|
||||||
{
|
{
|
||||||
JDIMENSION inrow=0, outrow=0;
|
JDIMENSION inrow=0, outrow=0;
|
||||||
@@ -1823,6 +1876,13 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(setjmp(this->jerr.setjmp_buffer))
|
||||||
|
{
|
||||||
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
|
retval=-1;
|
||||||
|
goto bailout;
|
||||||
|
}
|
||||||
|
|
||||||
if(flags&TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling=FALSE;
|
if(flags&TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling=FALSE;
|
||||||
if(flags&TJFLAG_FASTDCT) dinfo->dct_method=JDCT_FASTEST;
|
if(flags&TJFLAG_FASTDCT) dinfo->dct_method=JDCT_FASTEST;
|
||||||
dinfo->raw_data_out=TRUE;
|
dinfo->raw_data_out=TRUE;
|
||||||
@@ -2000,6 +2060,11 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle,
|
|||||||
else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1");
|
else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1");
|
||||||
else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1");
|
else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1");
|
||||||
|
|
||||||
|
if((xinfo=(jpeg_transform_info *)malloc(sizeof(jpeg_transform_info)*n))
|
||||||
|
==NULL)
|
||||||
|
_throw("tjTransform(): Memory allocation failure");
|
||||||
|
MEMZERO(xinfo, sizeof(jpeg_transform_info)*n);
|
||||||
|
|
||||||
if(setjmp(this->jerr.setjmp_buffer))
|
if(setjmp(this->jerr.setjmp_buffer))
|
||||||
{
|
{
|
||||||
/* If we get here, the JPEG code has signaled an error. */
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
@@ -2009,11 +2074,6 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle,
|
|||||||
|
|
||||||
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
|
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
|
||||||
|
|
||||||
if((xinfo=(jpeg_transform_info *)malloc(sizeof(jpeg_transform_info)*n))
|
|
||||||
==NULL)
|
|
||||||
_throw("tjTransform(): Memory allocation failure");
|
|
||||||
MEMZERO(xinfo, sizeof(jpeg_transform_info)*n);
|
|
||||||
|
|
||||||
for(i=0; i<n; i++)
|
for(i=0; i<n; i++)
|
||||||
{
|
{
|
||||||
xinfo[i].transform=xformtypes[t[i].op];
|
xinfo[i].transform=xformtypes[t[i].op];
|
||||||
@@ -2090,6 +2150,10 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle,
|
|||||||
&xinfo[i]);
|
&xinfo[i]);
|
||||||
if(!(t[i].options&TJXOPT_NOOUTPUT))
|
if(!(t[i].options&TJXOPT_NOOUTPUT))
|
||||||
{
|
{
|
||||||
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
|
if (cinfo->num_scans != 0) /* process -progressive; -scans can override */
|
||||||
|
jpeg_simple_progression(cinfo);
|
||||||
|
#endif
|
||||||
jpeg_write_coefficients(cinfo, dstcoefs);
|
jpeg_write_coefficients(cinfo, dstcoefs);
|
||||||
jcopy_markers_execute(dinfo, cinfo, JCOPYOPT_ALL);
|
jcopy_markers_execute(dinfo, cinfo, JCOPYOPT_ALL);
|
||||||
}
|
}
|
||||||
|
|||||||
38
turbojpeg.h
38
turbojpeg.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2009-2015 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2009-2015, 2017 D. R. Commander. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -348,7 +348,7 @@ enum TJCS
|
|||||||
* The uncompressed source/destination image is stored in bottom-up (Windows,
|
* The uncompressed source/destination image is stored in bottom-up (Windows,
|
||||||
* OpenGL) order, not top-down (X11) order.
|
* OpenGL) order, not top-down (X11) order.
|
||||||
*/
|
*/
|
||||||
#define TJFLAG_BOTTOMUP 2
|
#define TJFLAG_BOTTOMUP 2
|
||||||
/**
|
/**
|
||||||
* When decompressing an image that was compressed using chrominance
|
* When decompressing an image that was compressed using chrominance
|
||||||
* subsampling, use the fastest chrominance upsampling algorithm available in
|
* subsampling, use the fastest chrominance upsampling algorithm available in
|
||||||
@@ -358,11 +358,11 @@ enum TJCS
|
|||||||
*/
|
*/
|
||||||
#define TJFLAG_FASTUPSAMPLE 256
|
#define TJFLAG_FASTUPSAMPLE 256
|
||||||
/**
|
/**
|
||||||
* Disable buffer (re)allocation. If passed to #tjCompress2() or
|
* Disable buffer (re)allocation. If passed to one of the JPEG compression or
|
||||||
* #tjTransform(), this flag will cause those functions to generate an error if
|
* transform functions, this flag will cause those functions to generate an
|
||||||
* the JPEG image buffer is invalid or too small rather than attempting to
|
* error if the JPEG image buffer is invalid or too small rather than
|
||||||
* allocate or reallocate that buffer. This reproduces the behavior of earlier
|
* attempting to allocate or reallocate that buffer. This reproduces the
|
||||||
* versions of TurboJPEG.
|
* behavior of earlier versions of TurboJPEG.
|
||||||
*/
|
*/
|
||||||
#define TJFLAG_NOREALLOC 1024
|
#define TJFLAG_NOREALLOC 1024
|
||||||
/**
|
/**
|
||||||
@@ -645,7 +645,7 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void);
|
|||||||
* for you, or
|
* for you, or
|
||||||
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
||||||
* #tjBufSize(). This should ensure that the buffer never has to be
|
* #tjBufSize(). This should ensure that the buffer never has to be
|
||||||
* re-allocated (setting #TJFLAG_NOREALLOC guarantees this.)
|
* re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
|
||||||
* .
|
* .
|
||||||
* If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
|
* If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
|
||||||
* pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
|
* pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
|
||||||
@@ -713,7 +713,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
|
|||||||
* for you, or
|
* for you, or
|
||||||
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
||||||
* #tjBufSize(). This should ensure that the buffer never has to be
|
* #tjBufSize(). This should ensure that the buffer never has to be
|
||||||
* re-allocated (setting #TJFLAG_NOREALLOC guarantees this.)
|
* re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
|
||||||
* .
|
* .
|
||||||
* If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
|
* If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
|
||||||
* pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
|
* pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
|
||||||
@@ -783,7 +783,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle,
|
|||||||
* for you, or
|
* for you, or
|
||||||
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
||||||
* #tjBufSize(). This should ensure that the buffer never has to be
|
* #tjBufSize(). This should ensure that the buffer never has to be
|
||||||
* re-allocated (setting #TJFLAG_NOREALLOC guarantees this.)
|
* re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
|
||||||
* .
|
* .
|
||||||
* If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
|
* If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
|
||||||
* pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
|
* pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
|
||||||
@@ -1392,9 +1392,13 @@ DLLEXPORT tjhandle DLLCALL tjInitTransform(void);
|
|||||||
* -# set <tt>dstBufs[i]</tt> to NULL to tell TurboJPEG to allocate the buffer
|
* -# set <tt>dstBufs[i]</tt> to NULL to tell TurboJPEG to allocate the buffer
|
||||||
* for you, or
|
* for you, or
|
||||||
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
||||||
* #tjBufSize() with the transformed or cropped width and height. This should
|
* #tjBufSize() with the transformed or cropped width and height. Under normal
|
||||||
* ensure that the buffer never has to be re-allocated (setting
|
* circumstances, this should ensure that the buffer never has to be
|
||||||
* #TJFLAG_NOREALLOC guarantees this.)
|
* re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.) Note,
|
||||||
|
* however, that there are some rare cases (such as transforming images with a
|
||||||
|
* large amount of embedded EXIF or ICC profile data) in which the output image
|
||||||
|
* will be larger than the worst-case size, and #TJFLAG_NOREALLOC cannot be
|
||||||
|
* used in those cases.
|
||||||
* .
|
* .
|
||||||
* If you choose option 1, <tt>dstSizes[i]</tt> should be set to the size of
|
* If you choose option 1, <tt>dstSizes[i]</tt> should be set to the size of
|
||||||
* your pre-allocated buffer. In any case, unless you have set
|
* your pre-allocated buffer. In any case, unless you have set
|
||||||
@@ -1435,8 +1439,8 @@ DLLEXPORT int DLLCALL tjDestroy(tjhandle handle);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate an image buffer for use with TurboJPEG. You should always use
|
* Allocate an image buffer for use with TurboJPEG. You should always use
|
||||||
* this function to allocate the JPEG destination buffer(s) for #tjCompress2()
|
* this function to allocate the JPEG destination buffer(s) for the compression
|
||||||
* and #tjTransform() unless you are disabling automatic buffer
|
* and transform functions unless you are disabling automatic buffer
|
||||||
* (re)allocation (by setting #TJFLAG_NOREALLOC.)
|
* (re)allocation (by setting #TJFLAG_NOREALLOC.)
|
||||||
*
|
*
|
||||||
* @param bytes the number of bytes to allocate
|
* @param bytes the number of bytes to allocate
|
||||||
@@ -1452,8 +1456,8 @@ DLLEXPORT unsigned char* DLLCALL tjAlloc(int bytes);
|
|||||||
/**
|
/**
|
||||||
* Free an image buffer previously allocated by TurboJPEG. You should always
|
* Free an image buffer previously allocated by TurboJPEG. You should always
|
||||||
* use this function to free JPEG destination buffer(s) that were automatically
|
* use this function to free JPEG destination buffer(s) that were automatically
|
||||||
* (re)allocated by #tjCompress2() or #tjTransform() or that were manually
|
* (re)allocated by the compression and transform functions or that were
|
||||||
* allocated using #tjAlloc().
|
* manually allocated using #tjAlloc().
|
||||||
*
|
*
|
||||||
* @param buffer address of the buffer to free
|
* @param buffer address of the buffer to free
|
||||||
*
|
*
|
||||||
|
|||||||
35
usage.txt
35
usage.txt
@@ -212,7 +212,7 @@ Switches for advanced users:
|
|||||||
large images. Value is in thousands of bytes, or
|
large images. Value is in thousands of bytes, or
|
||||||
millions of bytes if "M" is attached to the number.
|
millions of bytes if "M" is attached to the number.
|
||||||
For example, -max 4m selects 4000000 bytes. If more
|
For example, -max 4m selects 4000000 bytes. If more
|
||||||
space is needed, temporary files will be used.
|
space is needed, an error will occur.
|
||||||
|
|
||||||
-verbose Enable debug printout. More -v's give more printout.
|
-verbose Enable debug printout. More -v's give more printout.
|
||||||
or -debug Also, version information is printed at startup.
|
or -debug Also, version information is printed at startup.
|
||||||
@@ -372,7 +372,7 @@ Switches for advanced users:
|
|||||||
large images. Value is in thousands of bytes, or
|
large images. Value is in thousands of bytes, or
|
||||||
millions of bytes if "M" is attached to the number.
|
millions of bytes if "M" is attached to the number.
|
||||||
For example, -max 4m selects 4000000 bytes. If more
|
For example, -max 4m selects 4000000 bytes. If more
|
||||||
space is needed, temporary files will be used.
|
space is needed, an error will occur.
|
||||||
|
|
||||||
-verbose Enable debug printout. More -v's give more printout.
|
-verbose Enable debug printout. More -v's give more printout.
|
||||||
or -debug Also, version information is printed at startup.
|
or -debug Also, version information is printed at startup.
|
||||||
@@ -418,11 +418,6 @@ When producing a color-quantized image, "-onepass -dither ordered" is fast but
|
|||||||
much lower quality than the default behavior. "-dither none" may give
|
much lower quality than the default behavior. "-dither none" may give
|
||||||
acceptable results in two-pass mode, but is seldom tolerable in one-pass mode.
|
acceptable results in two-pass mode, but is seldom tolerable in one-pass mode.
|
||||||
|
|
||||||
Two-pass color quantization requires a good deal of memory; on MS-DOS machines
|
|
||||||
it may run out of memory even with -maxmemory 0. In that case you can still
|
|
||||||
decompress, with some loss of image quality, by specifying -onepass for
|
|
||||||
one-pass quantization.
|
|
||||||
|
|
||||||
To avoid the Unisys LZW patent (now expired), djpeg produces uncompressed GIF
|
To avoid the Unisys LZW patent (now expired), djpeg produces uncompressed GIF
|
||||||
files. These are larger than they should be, but are readable by standard GIF
|
files. These are larger than they should be, but are readable by standard GIF
|
||||||
decoders.
|
decoders.
|
||||||
@@ -430,24 +425,9 @@ decoders.
|
|||||||
|
|
||||||
HINTS FOR BOTH PROGRAMS
|
HINTS FOR BOTH PROGRAMS
|
||||||
|
|
||||||
If more space is needed than will fit in the available main memory (as
|
If the memory needed by cjpeg or djpeg exceeds the limit specified by
|
||||||
determined by -maxmemory), temporary files will be used. (MS-DOS versions
|
-maxmemory, an error will occur. You can leave out -progressive and -optimize
|
||||||
will try to get extended or expanded memory first.) The temporary files are
|
(for cjpeg) or specify -onepass (for djpeg) to reduce memory usage.
|
||||||
often rather large: in typical cases they occupy three bytes per pixel, for
|
|
||||||
example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough
|
|
||||||
free disk space, leave out -progressive and -optimize (for cjpeg) or specify
|
|
||||||
-onepass (for djpeg).
|
|
||||||
|
|
||||||
On MS-DOS, the temporary files are created in the directory named by the TMP
|
|
||||||
or TEMP environment variable, or in the current directory if neither of those
|
|
||||||
exist. Amiga implementations put the temp files in the directory named by
|
|
||||||
JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free
|
|
||||||
space.
|
|
||||||
|
|
||||||
The default memory usage limit (-maxmemory) is set when the software is
|
|
||||||
compiled. If you get an "insufficient memory" error, try specifying a smaller
|
|
||||||
-maxmemory value, even -maxmemory 0 to use the absolute minimum space. You
|
|
||||||
may want to recompile with a smaller default value if this happens often.
|
|
||||||
|
|
||||||
On machines that have "environment" variables, you can define the environment
|
On machines that have "environment" variables, you can define the environment
|
||||||
variable JPEGMEM to set the default memory limit. The value is specified as
|
variable JPEGMEM to set the default memory limit. The value is specified as
|
||||||
@@ -455,11 +435,6 @@ described for the -maxmemory switch. JPEGMEM overrides the default value
|
|||||||
specified when the program was compiled, and itself is overridden by an
|
specified when the program was compiled, and itself is overridden by an
|
||||||
explicit -maxmemory switch.
|
explicit -maxmemory switch.
|
||||||
|
|
||||||
On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to
|
|
||||||
use. (Extended or expanded memory is also used if available.) Most
|
|
||||||
DOS-specific versions of this software do their own memory space estimation
|
|
||||||
and do not need you to specify -maxmemory.
|
|
||||||
|
|
||||||
|
|
||||||
JPEGTRAN
|
JPEGTRAN
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ EXPORTS
|
|||||||
jzero_far @ 103 ;
|
jzero_far @ 103 ;
|
||||||
jpeg_mem_dest @ 104 ;
|
jpeg_mem_dest @ 104 ;
|
||||||
jpeg_mem_src @ 105 ;
|
jpeg_mem_src @ 105 ;
|
||||||
|
jpeg_skip_scanlines @ 106 ;
|
||||||
|
jpeg_crop_scanline @ 107 ;
|
||||||
jpeg_c_bool_param_supported @ 200 ;
|
jpeg_c_bool_param_supported @ 200 ;
|
||||||
jpeg_c_set_bool_param @ 201 ;
|
jpeg_c_set_bool_param @ 201 ;
|
||||||
jpeg_c_get_bool_param @ 202 ;
|
jpeg_c_get_bool_param @ 202 ;
|
||||||
|
|||||||
Reference in New Issue
Block a user