mirror of
https://github.com/opencv/opencv.git
synced 2025-06-29 08:00:57 +08:00
Update libjpeg-turbo from 1.5.3 to 2.0.2
This commit is contained in:
parent
5421d0866b
commit
30cf5e0164
8
3rdparty/libjpeg-turbo/CMakeLists.txt
vendored
8
3rdparty/libjpeg-turbo/CMakeLists.txt
vendored
@ -2,11 +2,11 @@ project(${JPEG_LIBRARY} C)
|
||||
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter -Wsign-compare -Wshorten-64-to-32 -Wimplicit-fallthrough)
|
||||
|
||||
set(VERSION_MAJOR 1)
|
||||
set(VERSION_MINOR 5)
|
||||
set(VERSION_REVISION 3)
|
||||
set(VERSION_MAJOR 2)
|
||||
set(VERSION_MINOR 0)
|
||||
set(VERSION_REVISION 2)
|
||||
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION})
|
||||
set(LIBJPEG_TURBO_VERSION_NUMBER 1005003)
|
||||
set(LIBJPEG_TURBO_VERSION_NUMBER 2000002)
|
||||
|
||||
string(TIMESTAMP BUILD "opencv-${OPENCV_VERSION}-libjpeg-turbo")
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
39
3rdparty/libjpeg-turbo/LICENSE.md
vendored
39
3rdparty/libjpeg-turbo/LICENSE.md
vendored
@ -11,9 +11,10 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
|
||||
|
||||
- The Modified (3-clause) BSD License, which is listed below
|
||||
|
||||
This license covers the TurboJPEG API library and associated programs.
|
||||
This license covers the TurboJPEG API library and associated programs, as
|
||||
well as the build system.
|
||||
|
||||
- The zlib License, which is listed below
|
||||
- The [zlib License](https://opensource.org/licenses/Zlib)
|
||||
|
||||
This license is a subset of the other two, and it covers the libjpeg-turbo
|
||||
SIMD extensions.
|
||||
@ -65,7 +66,7 @@ best of our understanding.
|
||||
|
||||
2. If your binary distribution includes or uses the TurboJPEG API, then
|
||||
your product documentation must include the text of the Modified BSD
|
||||
License.
|
||||
License (see below.)
|
||||
|
||||
**Origin**
|
||||
- Clause 2 of the Modified BSD License
|
||||
@ -90,7 +91,8 @@ best of our understanding.
|
||||
The Modified (3-clause) BSD License
|
||||
===================================
|
||||
|
||||
Copyright (C)\<YEAR\> \<AUTHOR\>. All Rights Reserved.
|
||||
Copyright (C)2009-2019 D. R. Commander. All Rights Reserved.
|
||||
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@ -117,23 +119,14 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
The zlib License
|
||||
================
|
||||
Why Three Licenses?
|
||||
===================
|
||||
|
||||
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.
|
||||
The zlib License could have been used instead of the Modified (3-clause) BSD
|
||||
License, and since the IJG License effectively subsumes the distribution
|
||||
conditions of the zlib License, this would have effectively placed
|
||||
libjpeg-turbo binary distributions under the IJG License. However, the IJG
|
||||
License specifically refers to the Independent JPEG Group and does not extend
|
||||
attribution and endorsement protections to other entities. Thus, it was
|
||||
desirable to choose a license that granted us the same protections for new code
|
||||
that were granted to the IJG for code derived from their software.
|
||||
|
50
3rdparty/libjpeg-turbo/README.ijg
vendored
50
3rdparty/libjpeg-turbo/README.ijg
vendored
@ -43,7 +43,7 @@ User documentation:
|
||||
change.log Version-to-version change highlights.
|
||||
Programmer and internal documentation:
|
||||
libjpeg.txt How to use the JPEG library in your own programs.
|
||||
example.c Sample code for calling the JPEG library.
|
||||
example.txt Sample code for calling the JPEG library.
|
||||
structure.txt Overview of the JPEG library's internal structure.
|
||||
coderules.txt Coding style rules --- please read if you contribute code.
|
||||
|
||||
@ -159,12 +159,6 @@ commercial products, provided that all warranty or liability claims are
|
||||
assumed by the product vendor.
|
||||
|
||||
|
||||
The Unix configuration script "configure" was produced with GNU Autoconf.
|
||||
It is copyright by the Free Software Foundation but is freely distributable.
|
||||
The same holds for its supporting scripts (config.guess, config.sub,
|
||||
ltmain.sh). Another support script, install-sh, is copyright by X Consortium
|
||||
but is also freely distributable.
|
||||
|
||||
The IJG distribution formerly included code to read and write GIF files.
|
||||
To avoid entanglement with the Unisys LZW patent (now expired), GIF reading
|
||||
support has been removed altogether, and the GIF writer has been simplified
|
||||
@ -220,14 +214,14 @@ Continuous-tone Still Images, Part 2: Compliance testing" and has document
|
||||
numbers ISO/IEC IS 10918-2, ITU-T T.83.
|
||||
|
||||
The JPEG standard does not specify all details of an interchangeable file
|
||||
format. For the omitted details we follow the "JFIF" conventions, revision
|
||||
1.02. JFIF 1.02 has been adopted as an Ecma International Technical Report
|
||||
and thus received a formal publication status. It is available as a free
|
||||
download in PDF format from
|
||||
http://www.ecma-international.org/publications/techreports/E-TR-098.htm.
|
||||
A PostScript version of the JFIF document is available at
|
||||
http://www.ijg.org/files/jfif.ps.gz. There is also a plain text version at
|
||||
http://www.ijg.org/files/jfif.txt.gz, but it is missing the figures.
|
||||
format. For the omitted details, we follow the "JFIF" conventions, revision
|
||||
1.02. JFIF version 1 has been adopted as ISO/IEC 10918-5 (05/2013) and
|
||||
Recommendation ITU-T T.871 (05/2011): Information technology - Digital
|
||||
compression and coding of continuous-tone still images: JPEG File Interchange
|
||||
Format (JFIF). It is available as a free download in PDF file format from
|
||||
https://www.iso.org/standard/54989.html and http://www.itu.int/rec/T-REC-T.871.
|
||||
A PDF file of the older JFIF 1.02 specification is available at
|
||||
http://www.w3.org/Graphics/JPEG/jfif3.pdf.
|
||||
|
||||
The TIFF 6.0 file format specification can be obtained by FTP from
|
||||
ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme
|
||||
@ -259,18 +253,22 @@ with body
|
||||
send usenet/news.answers/jpeg-faq/part2
|
||||
|
||||
|
||||
FILE FORMAT WARS
|
||||
================
|
||||
FILE FORMAT COMPATIBILITY
|
||||
=========================
|
||||
|
||||
The ISO/IEC JTC1/SC29/WG1 standards committee (also known as JPEG, together
|
||||
with ITU-T SG16) currently promotes different formats containing the name
|
||||
"JPEG" which are incompatible with original DCT-based JPEG. IJG therefore does
|
||||
not support these formats (see REFERENCES). Indeed, one of the original
|
||||
reasons for developing this free software was to help force convergence on
|
||||
common, interoperable format standards for JPEG files.
|
||||
Don't use an incompatible file format!
|
||||
(In any case, our decoder will remain capable of reading existing JPEG
|
||||
image files indefinitely.)
|
||||
This software implements ITU T.81 | ISO/IEC 10918 with some extensions from
|
||||
ITU T.871 | ISO/IEC 10918-5 (JPEG File Interchange Format-- see REFERENCES).
|
||||
Informally, the term "JPEG image" or "JPEG file" most often refers to JFIF or
|
||||
a subset thereof, but there are other formats containing the name "JPEG" that
|
||||
are incompatible with the DCT-based JPEG standard or with JFIF (for instance,
|
||||
JPEG 2000 and JPEG XR). This software therefore does not support these
|
||||
formats. Indeed, one of the original reasons for developing this free software
|
||||
was to help force convergence on a common, interoperable format standard for
|
||||
JPEG files.
|
||||
|
||||
JFIF is a minimal or "low end" representation. TIFF/JPEG (TIFF revision 6.0 as
|
||||
modified by TIFF Technical Note #2) can be used for "high end" applications
|
||||
that need to record a lot of additional data about an image.
|
||||
|
||||
|
||||
TO DO
|
||||
|
13
3rdparty/libjpeg-turbo/README.md
vendored
13
3rdparty/libjpeg-turbo/README.md
vendored
@ -2,8 +2,9 @@ Background
|
||||
==========
|
||||
|
||||
libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2,
|
||||
NEON, AltiVec) to accelerate baseline JPEG compression and decompression on
|
||||
x86, x86-64, ARM, and PowerPC systems. On such systems, libjpeg-turbo is
|
||||
AVX2, NEON, AltiVec) to accelerate baseline JPEG compression and decompression
|
||||
on x86, x86-64, ARM, and PowerPC systems, as well as progressive JPEG
|
||||
compression on x86 and x86-64 systems. On such systems, libjpeg-turbo is
|
||||
generally 2-6x as fast as libjpeg, all else being equal. On other types of
|
||||
systems, libjpeg-turbo can still outperform libjpeg by a significant amount, by
|
||||
virtue of its highly-optimized Huffman coding routines. In many cases, the
|
||||
@ -48,7 +49,10 @@ JPEG images:
|
||||
straightforward to achieve using the underlying libjpeg API, such as
|
||||
generating planar YUV images and performing multiple simultaneous lossless
|
||||
transforms on an image. The Java interface for libjpeg-turbo is written on
|
||||
top of the TurboJPEG API.
|
||||
top of the TurboJPEG API. The TurboJPEG API is recommended for first-time
|
||||
users of libjpeg-turbo. Refer to [tjexample.c](tjexample.c) and
|
||||
[TJExample.java](java/TJExample.java) for examples of its usage and to
|
||||
<http://libjpeg-turbo.org/Documentation/Documentation> for API documentation.
|
||||
|
||||
- **libjpeg API**<br>
|
||||
This is the de facto industry-standard API for compressing and decompressing
|
||||
@ -56,7 +60,8 @@ JPEG images:
|
||||
more powerful. The libjpeg API implementation in libjpeg-turbo is both
|
||||
API/ABI-compatible and mathematically compatible with libjpeg v6b. It can
|
||||
also optionally be configured to be API/ABI-compatible with libjpeg v7 and v8
|
||||
(see below.)
|
||||
(see below.) Refer to [cjpeg.c](cjpeg.c) and [djpeg.c](djpeg.c) for examples
|
||||
of its usage and to [libjpeg.txt](libjpeg.txt) for API documentation.
|
||||
|
||||
There is no significant performance advantage to either API when both are used
|
||||
to perform similar operations.
|
||||
|
88
3rdparty/libjpeg-turbo/jconfig.h.in
vendored
88
3rdparty/libjpeg-turbo/jconfig.h.in
vendored
@ -1,12 +1,25 @@
|
||||
/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */
|
||||
/* see jconfig.txt for explanations */
|
||||
|
||||
/* Version ID for the JPEG library.
|
||||
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
|
||||
*/
|
||||
#define JPEG_LIB_VERSION @JPEG_LIB_VERSION@
|
||||
|
||||
/* libjpeg-turbo version */
|
||||
#define LIBJPEG_TURBO_VERSION @VERSION@
|
||||
|
||||
/* libjpeg-turbo version in integer form */
|
||||
#define LIBJPEG_TURBO_VERSION_NUMBER @LIBJPEG_TURBO_VERSION_NUMBER@
|
||||
#cmakedefine C_ARITH_CODING_SUPPORTED
|
||||
#cmakedefine D_ARITH_CODING_SUPPORTED
|
||||
#cmakedefine MEM_SRCDST_SUPPORTED
|
||||
|
||||
/* Support arithmetic encoding */
|
||||
#cmakedefine C_ARITH_CODING_SUPPORTED 1
|
||||
|
||||
/* Support arithmetic decoding */
|
||||
#cmakedefine D_ARITH_CODING_SUPPORTED 1
|
||||
|
||||
/* Support in-memory source/destination managers */
|
||||
#cmakedefine MEM_SRCDST_SUPPORTED 1
|
||||
|
||||
/* Use accelerated SIMD routines. */
|
||||
#cmakedefine WITH_SIMD 1
|
||||
|
||||
/*
|
||||
* Define BITS_IN_JSAMPLE as either
|
||||
@ -19,35 +32,42 @@
|
||||
|
||||
#define BITS_IN_JSAMPLE @BITS_IN_JSAMPLE@ /* use 8 or 12 */
|
||||
|
||||
#define HAVE_UNSIGNED_CHAR
|
||||
#define HAVE_UNSIGNED_SHORT
|
||||
/* #define void char */
|
||||
/* #define const */
|
||||
#undef __CHAR_UNSIGNED__
|
||||
#define HAVE_STDDEF_H
|
||||
#define HAVE_STDLIB_H
|
||||
#undef NEED_BSD_STRINGS
|
||||
#undef NEED_SYS_TYPES_H
|
||||
#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */
|
||||
#undef INCOMPLETE_TYPES_BROKEN
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#cmakedefine HAVE_LOCALE_H 1
|
||||
|
||||
/* Define "boolean" as unsigned char, not int, per Windows custom */
|
||||
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
|
||||
typedef unsigned char boolean;
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#cmakedefine HAVE_STDDEF_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#cmakedefine HAVE_STDLIB_H 1
|
||||
|
||||
/* Define if you need to include <sys/types.h> to get size_t. */
|
||||
#cmakedefine NEED_SYS_TYPES_H 1
|
||||
|
||||
/* Define if you have BSD-like bzero and bcopy in <strings.h> rather than
|
||||
memset/memcpy in <string.h>. */
|
||||
#cmakedefine NEED_BSD_STRINGS 1
|
||||
|
||||
/* Define to 1 if the system has the type `unsigned char'. */
|
||||
#cmakedefine HAVE_UNSIGNED_CHAR 1
|
||||
|
||||
/* Define to 1 if the system has the type `unsigned short'. */
|
||||
#cmakedefine HAVE_UNSIGNED_SHORT 1
|
||||
|
||||
/* Compiler does not support pointers to undefined structures. */
|
||||
#cmakedefine INCOMPLETE_TYPES_BROKEN 1
|
||||
|
||||
/* Define if your (broken) compiler shifts signed values as if they were
|
||||
unsigned. */
|
||||
#cmakedefine RIGHT_SHIFT_IS_UNSIGNED 1
|
||||
|
||||
/* Define to 1 if type `char' is unsigned and you are not using gcc. */
|
||||
#ifndef __CHAR_UNSIGNED__
|
||||
#cmakedefine __CHAR_UNSIGNED__ 1
|
||||
#endif
|
||||
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
||||
|
||||
/* Define "INT32" as int, not long, per Windows custom */
|
||||
#if !(defined(_BASETSD_H_) || defined(_BASETSD_H)) /* don't conflict if basetsd.h already read */
|
||||
typedef short INT16;
|
||||
typedef signed int INT32;
|
||||
#endif
|
||||
#define XMD_H /* prevent jmorecfg.h from redefining it */
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
#ifdef JPEG_INTERNALS
|
||||
|
||||
#undef RIGHT_SHIFT_IS_UNSIGNED
|
||||
|
||||
#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@
|
||||
|
||||
#endif /* JPEG_INTERNALS */
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
34
3rdparty/libjpeg-turbo/jconfig.h.win.in
vendored
Normal file
34
3rdparty/libjpeg-turbo/jconfig.h.win.in
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
#define JPEG_LIB_VERSION @JPEG_LIB_VERSION@
|
||||
#define LIBJPEG_TURBO_VERSION @VERSION@
|
||||
#define LIBJPEG_TURBO_VERSION_NUMBER @LIBJPEG_TURBO_VERSION_NUMBER@
|
||||
|
||||
#cmakedefine C_ARITH_CODING_SUPPORTED
|
||||
#cmakedefine D_ARITH_CODING_SUPPORTED
|
||||
#cmakedefine MEM_SRCDST_SUPPORTED
|
||||
#cmakedefine WITH_SIMD
|
||||
|
||||
#define BITS_IN_JSAMPLE @BITS_IN_JSAMPLE@ /* use 8 or 12 */
|
||||
|
||||
#define HAVE_STDDEF_H
|
||||
#define HAVE_STDLIB_H
|
||||
#undef NEED_SYS_TYPES_H
|
||||
#undef NEED_BSD_STRINGS
|
||||
|
||||
#define HAVE_UNSIGNED_CHAR
|
||||
#define HAVE_UNSIGNED_SHORT
|
||||
#undef INCOMPLETE_TYPES_BROKEN
|
||||
#undef RIGHT_SHIFT_IS_UNSIGNED
|
||||
#undef __CHAR_UNSIGNED__
|
||||
|
||||
/* Define "boolean" as unsigned char, not int, per Windows custom */
|
||||
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
|
||||
typedef unsigned char boolean;
|
||||
#endif
|
||||
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
||||
|
||||
/* Define "INT32" as int, not long, per Windows custom */
|
||||
#if !(defined(_BASETSD_H_) || defined(_BASETSD_H)) /* don't conflict if basetsd.h already read */
|
||||
typedef short INT16;
|
||||
typedef signed int INT32;
|
||||
#endif
|
||||
#define XMD_H /* prevent jmorecfg.h from redefining it */
|
34
3rdparty/libjpeg-turbo/jconfigint.h.in
vendored
34
3rdparty/libjpeg-turbo/jconfigint.h.in
vendored
@ -1,13 +1,31 @@
|
||||
#define VERSION "@VERSION@"
|
||||
/* libjpeg-turbo build number */
|
||||
#define BUILD "@BUILD@"
|
||||
|
||||
/* Compiler's inline keyword */
|
||||
#undef inline
|
||||
|
||||
/* How to obtain function inlining. */
|
||||
#define INLINE @INLINE@
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "@CMAKE_PROJECT_NAME@"
|
||||
|
||||
#ifndef INLINE
|
||||
#if defined(__GNUC__)
|
||||
#define INLINE inline __attribute__((always_inline))
|
||||
#elif defined(_MSC_VER)
|
||||
#define INLINE __forceinline
|
||||
#else
|
||||
#define INLINE
|
||||
/* Version number of package */
|
||||
#define VERSION "@VERSION@"
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#define SIZEOF_SIZE_T @SIZE_T@
|
||||
|
||||
/* Define if your compiler has __builtin_ctzl() and sizeof(unsigned long) == sizeof(size_t). */
|
||||
#cmakedefine HAVE_BUILTIN_CTZL
|
||||
|
||||
/* Define to 1 if you have the <intrin.h> header file. */
|
||||
#cmakedefine HAVE_INTRIN_H
|
||||
|
||||
#if defined(_MSC_VER) && defined(HAVE_INTRIN_H)
|
||||
#if (SIZEOF_SIZE_T == 8)
|
||||
#define HAVE_BITSCANFORWARD64
|
||||
#elif (SIZEOF_SIZE_T == 4)
|
||||
#define HAVE_BITSCANFORWARD
|
||||
#endif
|
||||
#endif
|
||||
|
13
3rdparty/libjpeg-turbo/src/jaricom.c
vendored
13
3rdparty/libjpeg-turbo/src/jaricom.c
vendored
@ -4,16 +4,16 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Developed 1997-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* Copyright (C) 2015, 2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
* This file contains probability estimation tables for common use in
|
||||
* arithmetic entropy encoding and decoding routines.
|
||||
*
|
||||
* This data represents Table D.2 in the JPEG spec (ISO/IEC IS 10918-1
|
||||
* and CCITT Recommendation ITU-T T.81) and Table 24 in the JBIG spec
|
||||
* (ISO/IEC IS 11544 and CCITT Recommendation ITU-T T.82).
|
||||
* This data represents Table D.2 in
|
||||
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994 and Table 24 in
|
||||
* Recommendation ITU-T T.82 (1993) | ISO/IEC 11544:1993.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
@ -29,9 +29,10 @@
|
||||
* implementation (jbig_tab.c).
|
||||
*/
|
||||
|
||||
#define V(i,a,b,c,d) (((JLONG)a << 16) | ((JLONG)c << 8) | ((JLONG)d << 7) | b)
|
||||
#define V(i, a, b, c, d) \
|
||||
(((JLONG)a << 16) | ((JLONG)c << 8) | ((JLONG)d << 7) | b)
|
||||
|
||||
const JLONG jpeg_aritab[113+1] = {
|
||||
const JLONG jpeg_aritab[113 + 1] = {
|
||||
/*
|
||||
* Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS
|
||||
*/
|
||||
|
44
3rdparty/libjpeg-turbo/src/jcapimin.c
vendored
44
3rdparty/libjpeg-turbo/src/jcapimin.c
vendored
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
jpeg_CreateCompress(j_compress_ptr cinfo, int version, size_t structsize)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -41,7 +41,7 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
|
||||
if (structsize != sizeof(struct jpeg_compress_struct))
|
||||
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
|
||||
(int) sizeof(struct jpeg_compress_struct), (int) structsize);
|
||||
(int)sizeof(struct jpeg_compress_struct), (int)structsize);
|
||||
|
||||
/* For debugging purposes, we zero the whole master structure.
|
||||
* But the application has already set the err pointer, and may have set
|
||||
@ -59,7 +59,7 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
cinfo->is_decompressor = FALSE;
|
||||
|
||||
/* Initialize a memory manager instance for this object */
|
||||
jinit_memory_mgr((j_common_ptr) cinfo);
|
||||
jinit_memory_mgr((j_common_ptr)cinfo);
|
||||
|
||||
/* Zero out pointers to permanent structures. */
|
||||
cinfo->progress = NULL;
|
||||
@ -83,7 +83,7 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
/* Must do it here for emit_dqt in case jpeg_write_tables is used */
|
||||
cinfo->block_size = DCTSIZE;
|
||||
cinfo->natural_order = jpeg_natural_order;
|
||||
cinfo->lim_Se = DCTSIZE2-1;
|
||||
cinfo->lim_Se = DCTSIZE2 - 1;
|
||||
#endif
|
||||
|
||||
cinfo->script_space = NULL;
|
||||
@ -100,9 +100,9 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_destroy_compress (j_compress_ptr cinfo)
|
||||
jpeg_destroy_compress(j_compress_ptr cinfo)
|
||||
{
|
||||
jpeg_destroy((j_common_ptr) cinfo); /* use common routine */
|
||||
jpeg_destroy((j_common_ptr)cinfo); /* use common routine */
|
||||
}
|
||||
|
||||
|
||||
@ -112,9 +112,9 @@ jpeg_destroy_compress (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_abort_compress (j_compress_ptr cinfo)
|
||||
jpeg_abort_compress(j_compress_ptr cinfo)
|
||||
{
|
||||
jpeg_abort((j_common_ptr) cinfo); /* use common routine */
|
||||
jpeg_abort((j_common_ptr)cinfo); /* use common routine */
|
||||
}
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ jpeg_abort_compress (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress)
|
||||
jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress)
|
||||
{
|
||||
int i;
|
||||
JQUANT_TBL *qtbl;
|
||||
@ -159,7 +159,7 @@ jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_finish_compress (j_compress_ptr cinfo)
|
||||
jpeg_finish_compress(j_compress_ptr cinfo)
|
||||
{
|
||||
JDIMENSION iMCU_row;
|
||||
|
||||
@ -172,18 +172,18 @@ jpeg_finish_compress (j_compress_ptr cinfo)
|
||||
} else if (cinfo->global_state != CSTATE_WRCOEFS)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
/* Perform any remaining passes */
|
||||
while (! cinfo->master->is_last_pass) {
|
||||
while (!cinfo->master->is_last_pass) {
|
||||
(*cinfo->master->prepare_for_pass) (cinfo);
|
||||
for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) {
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) iMCU_row;
|
||||
cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)iMCU_row;
|
||||
cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
/* We bypass the main controller and invoke coef controller directly;
|
||||
* all work is being done from the coefficient buffer.
|
||||
*/
|
||||
if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL))
|
||||
if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
(*cinfo->master->finish_pass) (cinfo);
|
||||
@ -192,7 +192,7 @@ jpeg_finish_compress (j_compress_ptr cinfo)
|
||||
(*cinfo->marker->write_file_trailer) (cinfo);
|
||||
(*cinfo->dest->term_destination) (cinfo);
|
||||
/* We can use jpeg_abort to release memory and reset global_state */
|
||||
jpeg_abort((j_common_ptr) cinfo);
|
||||
jpeg_abort((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
|
||||
@ -204,8 +204,8 @@ jpeg_finish_compress (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_marker (j_compress_ptr cinfo, int marker,
|
||||
const JOCTET *dataptr, unsigned int datalen)
|
||||
jpeg_write_marker(j_compress_ptr cinfo, int marker, const JOCTET *dataptr,
|
||||
unsigned int datalen)
|
||||
{
|
||||
void (*write_marker_byte) (j_compress_ptr info, int val);
|
||||
|
||||
@ -226,7 +226,7 @@ jpeg_write_marker (j_compress_ptr cinfo, int marker,
|
||||
/* Same, but piecemeal. */
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||
jpeg_write_m_header(j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||
{
|
||||
if (cinfo->next_scanline != 0 ||
|
||||
(cinfo->global_state != CSTATE_SCANNING &&
|
||||
@ -238,7 +238,7 @@ jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_m_byte (j_compress_ptr cinfo, int val)
|
||||
jpeg_write_m_byte(j_compress_ptr cinfo, int val)
|
||||
{
|
||||
(*cinfo->marker->write_marker_byte) (cinfo, val);
|
||||
}
|
||||
@ -266,13 +266,13 @@ jpeg_write_m_byte (j_compress_ptr cinfo, int val)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_tables (j_compress_ptr cinfo)
|
||||
jpeg_write_tables(j_compress_ptr cinfo)
|
||||
{
|
||||
if (cinfo->global_state != CSTATE_START)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
|
||||
/* (Re)initialize error mgr and destination modules */
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
||||
(*cinfo->dest->init_destination) (cinfo);
|
||||
/* Initialize the marker writer ... bit of a crock to do it here. */
|
||||
jinit_marker_writer(cinfo);
|
||||
|
22
3rdparty/libjpeg-turbo/src/jcapistd.c
vendored
22
3rdparty/libjpeg-turbo/src/jcapistd.c
vendored
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)
|
||||
jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
|
||||
{
|
||||
if (cinfo->global_state != CSTATE_START)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
@ -45,7 +45,7 @@ jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)
|
||||
jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */
|
||||
|
||||
/* (Re)initialize error mgr and destination modules */
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
||||
(*cinfo->dest->init_destination) (cinfo);
|
||||
/* Perform master selection of active modules */
|
||||
jinit_compress_master(cinfo);
|
||||
@ -75,7 +75,7 @@ jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)
|
||||
*/
|
||||
|
||||
GLOBAL(JDIMENSION)
|
||||
jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
JDIMENSION num_lines)
|
||||
{
|
||||
JDIMENSION row_ctr, rows_left;
|
||||
@ -87,9 +87,9 @@ jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) cinfo->next_scanline;
|
||||
cinfo->progress->pass_limit = (long) cinfo->image_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)cinfo->next_scanline;
|
||||
cinfo->progress->pass_limit = (long)cinfo->image_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
/* Give master control module another chance if this is first call to
|
||||
@ -118,7 +118,7 @@ jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
*/
|
||||
|
||||
GLOBAL(JDIMENSION)
|
||||
jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
JDIMENSION num_lines)
|
||||
{
|
||||
JDIMENSION lines_per_iMCU_row;
|
||||
@ -132,9 +132,9 @@ jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) cinfo->next_scanline;
|
||||
cinfo->progress->pass_limit = (long) cinfo->image_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)cinfo->next_scanline;
|
||||
cinfo->progress->pass_limit = (long)cinfo->image_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
/* Give master control module another chance if this is first call to
|
||||
@ -151,7 +151,7 @@ jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
|
||||
/* Directly compress the row. */
|
||||
if (! (*cinfo->coef->compress_data) (cinfo, data)) {
|
||||
if (!(*cinfo->coef->compress_data) (cinfo, data)) {
|
||||
/* If compressor did not consume the whole row, suspend processing. */
|
||||
return 0;
|
||||
}
|
||||
|
86
3rdparty/libjpeg-turbo/src/jcarith.c
vendored
86
3rdparty/libjpeg-turbo/src/jcarith.c
vendored
@ -4,16 +4,19 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Developed 1997-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* Copyright (C) 2015, 2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
* This file contains portable arithmetic entropy encoding routines for JPEG
|
||||
* (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81).
|
||||
* (implementing Recommendation ITU-T T.81 | ISO/IEC 10918-1).
|
||||
*
|
||||
* Both sequential and progressive modes are supported in this single module.
|
||||
*
|
||||
* Suspension is not currently supported in this module.
|
||||
*
|
||||
* NOTE: All referenced figures are from
|
||||
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
@ -105,25 +108,25 @@ typedef arith_entropy_encoder *arith_entropy_ptr;
|
||||
|
||||
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
||||
#define ISHIFT_TEMPS int ishift_temp;
|
||||
#define IRIGHT_SHIFT(x,shft) \
|
||||
#define IRIGHT_SHIFT(x, shft) \
|
||||
((ishift_temp = (x)) < 0 ? \
|
||||
(ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
|
||||
(ishift_temp >> (shft)) | ((~0) << (16 - (shft))) : \
|
||||
(ishift_temp >> (shft)))
|
||||
#else
|
||||
#define ISHIFT_TEMPS
|
||||
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||
#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_byte (int val, j_compress_ptr cinfo)
|
||||
emit_byte(int val, j_compress_ptr cinfo)
|
||||
/* Write next output byte; we do not support suspension in this module. */
|
||||
{
|
||||
struct jpeg_destination_mgr *dest = cinfo->dest;
|
||||
|
||||
*dest->next_output_byte++ = (JOCTET) val;
|
||||
*dest->next_output_byte++ = (JOCTET)val;
|
||||
if (--dest->free_in_buffer == 0)
|
||||
if (! (*dest->empty_output_buffer) (cinfo))
|
||||
if (!(*dest->empty_output_buffer) (cinfo))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
|
||||
@ -133,22 +136,22 @@ emit_byte (int val, j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass (j_compress_ptr cinfo)
|
||||
finish_pass(j_compress_ptr cinfo)
|
||||
{
|
||||
arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
|
||||
JLONG temp;
|
||||
|
||||
/* Section D.1.8: Termination of encoding */
|
||||
|
||||
/* Find the e->c in the coding interval with the largest
|
||||
* number of trailing zero bits */
|
||||
if ((temp = (e->a - 1 + e->c) & 0xFFFF0000L) < e->c)
|
||||
if ((temp = (e->a - 1 + e->c) & 0xFFFF0000UL) < e->c)
|
||||
e->c = temp + 0x8000L;
|
||||
else
|
||||
e->c = temp;
|
||||
/* Send remaining bytes to output */
|
||||
e->c <<= e->ct;
|
||||
if (e->c & 0xF8000000L) {
|
||||
if (e->c & 0xF8000000UL) {
|
||||
/* One final overflow has to be handled */
|
||||
if (e->buffer >= 0) {
|
||||
if (e->zc)
|
||||
@ -219,9 +222,9 @@ finish_pass (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
arith_encode(j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
{
|
||||
register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
|
||||
register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
|
||||
register unsigned char nl, nm;
|
||||
register JLONG qe, temp;
|
||||
register int sv;
|
||||
@ -319,9 +322,9 @@ arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_restart (j_compress_ptr cinfo, int restart_num)
|
||||
emit_restart(j_compress_ptr cinfo, int restart_num)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@ -362,9 +365,9 @@ emit_restart (j_compress_ptr cinfo, int restart_num)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int blkn, ci, tbl;
|
||||
@ -391,7 +394,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Compute the DC value after the required point transform by Al.
|
||||
* This is simply an arithmetic right shift.
|
||||
*/
|
||||
m = IRIGHT_SHIFT((int) ((*block)[0]), cinfo->Al);
|
||||
m = IRIGHT_SHIFT((int)((*block)[0]), cinfo->Al);
|
||||
|
||||
/* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
|
||||
|
||||
@ -432,9 +435,9 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
arith_encode(cinfo, st, 0);
|
||||
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
|
||||
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 0; /* zero diff category */
|
||||
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
entropy->dc_context[ci] += 8; /* large diff category */
|
||||
/* Figure F.9: Encoding the magnitude bit pattern of v */
|
||||
st += 14;
|
||||
@ -453,9 +456,9 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int tbl, k, ke;
|
||||
@ -552,9 +555,9 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
unsigned char *st;
|
||||
int Al, blkn;
|
||||
|
||||
@ -587,9 +590,9 @@ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int tbl, k, ke, kex;
|
||||
@ -680,9 +683,9 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
jpeg_component_info *compptr;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
@ -747,9 +750,9 @@ encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
arith_encode(cinfo, st, 0);
|
||||
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
|
||||
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 0; /* zero diff category */
|
||||
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
entropy->dc_context[ci] += 8; /* large diff category */
|
||||
/* Figure F.9: Encoding the magnitude bit pattern of v */
|
||||
st += 14;
|
||||
@ -822,9 +825,9 @@ encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
start_pass(j_compress_ptr cinfo, boolean gather_statistics)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
int ci, tbl;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@ -862,8 +865,8 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
||||
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
||||
if (entropy->dc_stats[tbl] == NULL)
|
||||
entropy->dc_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, DC_STAT_BINS);
|
||||
entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
|
||||
MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS);
|
||||
/* Initialize DC predictions to 0 */
|
||||
entropy->last_dc_val[ci] = 0;
|
||||
@ -875,13 +878,14 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
||||
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
||||
if (entropy->ac_stats[tbl] == NULL)
|
||||
entropy->ac_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS);
|
||||
entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
|
||||
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
|
||||
#ifdef CALCULATE_SPECTRAL_CONDITIONING
|
||||
if (cinfo->progressive_mode)
|
||||
/* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
|
||||
cinfo->arith_ac_K[tbl] = cinfo->Ss + ((8 + cinfo->Se - cinfo->Ss) >> 4);
|
||||
cinfo->arith_ac_K[tbl] = cinfo->Ss +
|
||||
((8 + cinfo->Se - cinfo->Ss) >> 4);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -905,15 +909,15 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_arith_encoder (j_compress_ptr cinfo)
|
||||
jinit_arith_encoder(j_compress_ptr cinfo)
|
||||
{
|
||||
arith_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (arith_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(arith_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass;
|
||||
entropy->pub.finish_pass = finish_pass;
|
||||
|
||||
|
102
3rdparty/libjpeg-turbo/src/jccoefct.c
vendored
102
3rdparty/libjpeg-turbo/src/jccoefct.c
vendored
@ -58,21 +58,19 @@ typedef my_coef_controller *my_coef_ptr;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) compress_data
|
||||
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
METHODDEF(boolean) compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
#ifdef FULL_COEF_BUFFER_SUPPORTED
|
||||
METHODDEF(boolean) compress_first_pass
|
||||
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
METHODDEF(boolean) compress_output
|
||||
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
METHODDEF(boolean) compress_first_pass(j_compress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf);
|
||||
METHODDEF(boolean) compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
start_iMCU_row (j_compress_ptr cinfo)
|
||||
start_iMCU_row(j_compress_ptr cinfo)
|
||||
/* Reset within-iMCU-row counters for a new row */
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
/* In an interleaved scan, an MCU row is the same as an iMCU row.
|
||||
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
|
||||
@ -81,7 +79,7 @@ start_iMCU_row (j_compress_ptr cinfo)
|
||||
if (cinfo->comps_in_scan > 1) {
|
||||
coef->MCU_rows_per_iMCU_row = 1;
|
||||
} else {
|
||||
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1))
|
||||
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
|
||||
else
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
||||
@ -97,9 +95,9 @@ start_iMCU_row (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
coef->iMCU_row_num = 0;
|
||||
start_iMCU_row(cinfo);
|
||||
@ -140,9 +138,9 @@ start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
@ -167,31 +165,33 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
blkn = 0;
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
||||
: compptr->last_col_width;
|
||||
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width :
|
||||
compptr->last_col_width;
|
||||
xpos = MCU_col_num * compptr->MCU_sample_width;
|
||||
ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */
|
||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||
if (coef->iMCU_row_num < last_iMCU_row ||
|
||||
yoffset+yindex < compptr->last_row_height) {
|
||||
yoffset + yindex < compptr->last_row_height) {
|
||||
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
||||
input_buf[compptr->component_index],
|
||||
coef->MCU_buffer[blkn],
|
||||
ypos, xpos, (JDIMENSION) blockcnt);
|
||||
ypos, xpos, (JDIMENSION)blockcnt);
|
||||
if (blockcnt < compptr->MCU_width) {
|
||||
/* Create some dummy blocks at the right edge of the image. */
|
||||
jzero_far((void *) coef->MCU_buffer[blkn + blockcnt],
|
||||
jzero_far((void *)coef->MCU_buffer[blkn + blockcnt],
|
||||
(compptr->MCU_width - blockcnt) * sizeof(JBLOCK));
|
||||
for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
|
||||
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0];
|
||||
coef->MCU_buffer[blkn + bi][0][0] =
|
||||
coef->MCU_buffer[blkn + bi - 1][0][0];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Create a row of dummy blocks at the bottom of the image. */
|
||||
jzero_far((void *) coef->MCU_buffer[blkn],
|
||||
jzero_far((void *)coef->MCU_buffer[blkn],
|
||||
compptr->MCU_width * sizeof(JBLOCK));
|
||||
for (bi = 0; bi < compptr->MCU_width; bi++) {
|
||||
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0];
|
||||
coef->MCU_buffer[blkn + bi][0][0] =
|
||||
coef->MCU_buffer[blkn - 1][0][0];
|
||||
}
|
||||
}
|
||||
blkn += compptr->MCU_width;
|
||||
@ -201,7 +201,7 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
/* Try to write the MCU. In event of a suspension failure, we will
|
||||
* re-DCT the MCU on restart (a bit inefficient, could be fixed...)
|
||||
*/
|
||||
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
coef->mcu_ctr = MCU_col_num;
|
||||
@ -242,9 +242,9 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
compress_first_pass(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
JDIMENSION blocks_across, MCUs_across, MCUindex;
|
||||
int bi, ci, h_samp_factor, block_row, block_rows, ndummy;
|
||||
@ -257,21 +257,21 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
ci++, compptr++) {
|
||||
/* Align the virtual buffer for this component. */
|
||||
buffer = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[ci],
|
||||
((j_common_ptr)cinfo, coef->whole_image[ci],
|
||||
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||
(JDIMENSION) compptr->v_samp_factor, TRUE);
|
||||
(JDIMENSION)compptr->v_samp_factor, TRUE);
|
||||
/* Count non-dummy DCT block rows in this iMCU row. */
|
||||
if (coef->iMCU_row_num < last_iMCU_row)
|
||||
block_rows = compptr->v_samp_factor;
|
||||
else {
|
||||
/* NB: can't use last_row_height here, since may not be set! */
|
||||
block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
if (block_rows == 0) block_rows = compptr->v_samp_factor;
|
||||
}
|
||||
blocks_across = compptr->width_in_blocks;
|
||||
h_samp_factor = compptr->h_samp_factor;
|
||||
/* Count number of dummy blocks to be added at the right margin. */
|
||||
ndummy = (int) (blocks_across % h_samp_factor);
|
||||
ndummy = (int)(blocks_across % h_samp_factor);
|
||||
if (ndummy > 0)
|
||||
ndummy = h_samp_factor - ndummy;
|
||||
/* Perform DCT for all non-dummy blocks in this iMCU row. Each call
|
||||
@ -281,12 +281,12 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
thisblockrow = buffer[block_row];
|
||||
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
||||
input_buf[ci], thisblockrow,
|
||||
(JDIMENSION) (block_row * DCTSIZE),
|
||||
(JDIMENSION) 0, blocks_across);
|
||||
(JDIMENSION)(block_row * DCTSIZE),
|
||||
(JDIMENSION)0, blocks_across);
|
||||
if (ndummy > 0) {
|
||||
/* Create dummy blocks at the right edge of the image. */
|
||||
thisblockrow += blocks_across; /* => first dummy block */
|
||||
jzero_far((void *) thisblockrow, ndummy * sizeof(JBLOCK));
|
||||
jzero_far((void *)thisblockrow, ndummy * sizeof(JBLOCK));
|
||||
lastDC = thisblockrow[-1][0];
|
||||
for (bi = 0; bi < ndummy; bi++) {
|
||||
thisblockrow[bi][0] = lastDC;
|
||||
@ -304,11 +304,11 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
for (block_row = block_rows; block_row < compptr->v_samp_factor;
|
||||
block_row++) {
|
||||
thisblockrow = buffer[block_row];
|
||||
lastblockrow = buffer[block_row-1];
|
||||
jzero_far((void *) thisblockrow,
|
||||
(size_t) (blocks_across * sizeof(JBLOCK)));
|
||||
lastblockrow = buffer[block_row - 1];
|
||||
jzero_far((void *)thisblockrow,
|
||||
(size_t)(blocks_across * sizeof(JBLOCK)));
|
||||
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
|
||||
lastDC = lastblockrow[h_samp_factor-1][0];
|
||||
lastDC = lastblockrow[h_samp_factor - 1][0];
|
||||
for (bi = 0; bi < h_samp_factor; bi++) {
|
||||
thisblockrow[bi][0] = lastDC;
|
||||
}
|
||||
@ -338,9 +338,9 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||
int blkn, ci, xindex, yindex, yoffset;
|
||||
JDIMENSION start_col;
|
||||
@ -355,9 +355,9 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
buffer[ci] = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
|
||||
((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
|
||||
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||
(JDIMENSION) compptr->v_samp_factor, FALSE);
|
||||
(JDIMENSION)compptr->v_samp_factor, FALSE);
|
||||
}
|
||||
|
||||
/* Loop to process one whole iMCU row */
|
||||
@ -371,14 +371,14 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
start_col = MCU_col_num * compptr->MCU_width;
|
||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
||||
buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
|
||||
for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
|
||||
coef->MCU_buffer[blkn++] = buffer_ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Try to write the MCU. */
|
||||
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
if (!(*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
coef->mcu_ctr = MCU_col_num;
|
||||
@ -402,14 +402,14 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_c_coef_controller(j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_coef_ptr coef;
|
||||
|
||||
coef = (my_coef_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_coef_controller));
|
||||
cinfo->coef = (struct jpeg_c_coef_controller *) coef;
|
||||
cinfo->coef = (struct jpeg_c_coef_controller *)coef;
|
||||
coef->pub.start_pass = start_pass_coef;
|
||||
|
||||
/* Create the coefficient buffer. */
|
||||
@ -423,12 +423,12 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
|
||||
(JDIMENSION) jround_up((long) compptr->width_in_blocks,
|
||||
(long) compptr->h_samp_factor),
|
||||
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
|
||||
(long) compptr->v_samp_factor),
|
||||
(JDIMENSION) compptr->v_samp_factor);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
|
||||
(JDIMENSION)jround_up((long)compptr->width_in_blocks,
|
||||
(long)compptr->h_samp_factor),
|
||||
(JDIMENSION)jround_up((long)compptr->height_in_blocks,
|
||||
(long)compptr->v_samp_factor),
|
||||
(JDIMENSION)compptr->v_samp_factor);
|
||||
}
|
||||
#else
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
@ -439,7 +439,7 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
int i;
|
||||
|
||||
buffer = (JBLOCKROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->MCU_buffer[i] = buffer + i;
|
||||
|
46
3rdparty/libjpeg-turbo/src/jccolext.c
vendored
46
3rdparty/libjpeg-turbo/src/jccolext.c
vendored
@ -29,13 +29,13 @@
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_ycc_convert_internal (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_ycc_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register JLONG * ctab = cconvert->rgb_ycc_tab;
|
||||
register JLONG *ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr0, outptr1, outptr2;
|
||||
register JDIMENSION col;
|
||||
@ -58,17 +58,14 @@ rgb_ycc_convert_internal (j_compress_ptr cinfo,
|
||||
* need the general RIGHT_SHIFT macro.
|
||||
*/
|
||||
/* Y */
|
||||
outptr0[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
|
||||
ctab[b + B_Y_OFF]) >> SCALEBITS);
|
||||
/* Cb */
|
||||
outptr1[col] = (JSAMPLE)
|
||||
((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
|
||||
ctab[b + B_CB_OFF]) >> SCALEBITS);
|
||||
/* Cr */
|
||||
outptr2[col] = (JSAMPLE)
|
||||
((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
|
||||
ctab[b + B_CR_OFF]) >> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,13 +83,13 @@ rgb_ycc_convert_internal (j_compress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_gray_convert_internal (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_gray_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register JLONG * ctab = cconvert->rgb_ycc_tab;
|
||||
register JLONG *ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
register JDIMENSION col;
|
||||
@ -108,9 +105,8 @@ rgb_gray_convert_internal (j_compress_ptr cinfo,
|
||||
b = GETJSAMPLE(inptr[RGB_BLUE]);
|
||||
inptr += RGB_PIXELSIZE;
|
||||
/* Y */
|
||||
outptr[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
|
||||
ctab[b + B_Y_OFF]) >> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,9 +119,9 @@ rgb_gray_convert_internal (j_compress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_rgb_convert_internal (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_rgb_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr0, outptr1, outptr2;
|
||||
|
99
3rdparty/libjpeg-turbo/src/jccolor.c
vendored
99
3rdparty/libjpeg-turbo/src/jccolor.c
vendored
@ -63,9 +63,9 @@ typedef my_color_converter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
||||
#define CBCR_OFFSET ((JLONG) CENTERJSAMPLE << SCALEBITS)
|
||||
#define ONE_HALF ((JLONG) 1 << (SCALEBITS-1))
|
||||
#define FIX(x) ((JLONG) ((x) * (1L<<SCALEBITS) + 0.5))
|
||||
#define CBCR_OFFSET ((JLONG)CENTERJSAMPLE << SCALEBITS)
|
||||
#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
|
||||
#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
|
||||
|
||||
/* We allocate one big table and divide it up into eight parts, instead of
|
||||
* doing eight alloc_small requests. This lets us use a single table base
|
||||
@ -74,15 +74,15 @@ typedef my_color_converter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
#define R_Y_OFF 0 /* offset to R => Y section */
|
||||
#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */
|
||||
#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */
|
||||
#define R_CB_OFF (3*(MAXJSAMPLE+1))
|
||||
#define G_CB_OFF (4*(MAXJSAMPLE+1))
|
||||
#define B_CB_OFF (5*(MAXJSAMPLE+1))
|
||||
#define G_Y_OFF (1 * (MAXJSAMPLE + 1)) /* offset to G => Y section */
|
||||
#define B_Y_OFF (2 * (MAXJSAMPLE + 1)) /* etc. */
|
||||
#define R_CB_OFF (3 * (MAXJSAMPLE + 1))
|
||||
#define G_CB_OFF (4 * (MAXJSAMPLE + 1))
|
||||
#define B_CB_OFF (5 * (MAXJSAMPLE + 1))
|
||||
#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */
|
||||
#define G_CR_OFF (6*(MAXJSAMPLE+1))
|
||||
#define B_CR_OFF (7*(MAXJSAMPLE+1))
|
||||
#define TABLE_SIZE (8*(MAXJSAMPLE+1))
|
||||
#define G_CR_OFF (6 * (MAXJSAMPLE + 1))
|
||||
#define B_CR_OFF (7 * (MAXJSAMPLE + 1))
|
||||
#define TABLE_SIZE (8 * (MAXJSAMPLE + 1))
|
||||
|
||||
|
||||
/* Include inline routines for colorspace extensions */
|
||||
@ -195,33 +195,33 @@ typedef my_color_converter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_ycc_start (j_compress_ptr cinfo)
|
||||
rgb_ycc_start(j_compress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
JLONG *rgb_ycc_tab;
|
||||
JLONG i;
|
||||
|
||||
/* Allocate and fill in the conversion tables. */
|
||||
cconvert->rgb_ycc_tab = rgb_ycc_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(TABLE_SIZE * sizeof(JLONG)));
|
||||
|
||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i;
|
||||
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i;
|
||||
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
||||
rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i;
|
||||
rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i;
|
||||
rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
|
||||
rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
|
||||
rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
||||
rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
|
||||
rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
|
||||
/* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
|
||||
* This ensures that the maximum output will round to MAXJSAMPLE
|
||||
* not MAXJSAMPLE+1, and thus that we don't have to range-limit.
|
||||
*/
|
||||
rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1;
|
||||
rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF - 1;
|
||||
/* B=>Cb and R=>Cr tables are the same
|
||||
rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1;
|
||||
rgb_ycc_tab[i + R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF - 1;
|
||||
*/
|
||||
rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i;
|
||||
rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i;
|
||||
rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
|
||||
rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,9 +231,8 @@ rgb_ycc_start (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@ -280,9 +279,8 @@ rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_gray_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@ -326,9 +324,8 @@ rgb_gray_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
rgb_rgb_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@ -376,11 +373,10 @@ rgb_rgb_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
cmyk_ycck_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
cmyk_ycck_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register JLONG *ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
@ -408,17 +404,14 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
|
||||
* need the general RIGHT_SHIFT macro.
|
||||
*/
|
||||
/* Y */
|
||||
outptr0[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
|
||||
ctab[b + B_Y_OFF]) >> SCALEBITS);
|
||||
/* Cb */
|
||||
outptr1[col] = (JSAMPLE)
|
||||
((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
|
||||
ctab[b + B_CB_OFF]) >> SCALEBITS);
|
||||
/* Cr */
|
||||
outptr2[col] = (JSAMPLE)
|
||||
((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
|
||||
ctab[b + B_CR_OFF]) >> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -431,9 +424,8 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
grayscale_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
grayscale_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
@ -460,8 +452,7 @@ grayscale_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
null_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
@ -522,7 +513,7 @@ null_convert (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
null_method (j_compress_ptr cinfo)
|
||||
null_method(j_compress_ptr cinfo)
|
||||
{
|
||||
/* no work needed */
|
||||
}
|
||||
@ -533,14 +524,14 @@ null_method (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_color_converter (j_compress_ptr cinfo)
|
||||
jinit_color_converter(j_compress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert;
|
||||
|
||||
cconvert = (my_cconvert_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_color_converter));
|
||||
cinfo->cconvert = (struct jpeg_color_converter *) cconvert;
|
||||
cinfo->cconvert = (struct jpeg_color_converter *)cconvert;
|
||||
/* set start_pass to null method until we find out differently */
|
||||
cconvert->pub.start_pass = null_method;
|
||||
|
||||
|
98
3rdparty/libjpeg-turbo/src/jcdctmgr.c
vendored
98
3rdparty/libjpeg-turbo/src/jcdctmgr.c
vendored
@ -41,7 +41,7 @@ typedef void (*float_quantize_method_ptr) (JCOEFPTR coef_block,
|
||||
FAST_FLOAT *divisors,
|
||||
FAST_FLOAT *workspace);
|
||||
|
||||
METHODDEF(void) quantize (JCOEFPTR, DCTELEM *, DCTELEM *);
|
||||
METHODDEF(void) quantize(JCOEFPTR, DCTELEM *, DCTELEM *);
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_forward_dct pub; /* public fields */
|
||||
@ -80,7 +80,7 @@ typedef my_fdct_controller *my_fdct_ptr;
|
||||
*/
|
||||
|
||||
LOCAL(int)
|
||||
flss (UINT16 val)
|
||||
flss(UINT16 val)
|
||||
{
|
||||
int bit;
|
||||
|
||||
@ -170,7 +170,7 @@ flss (UINT16 val)
|
||||
*/
|
||||
|
||||
LOCAL(int)
|
||||
compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
|
||||
compute_reciprocal(UINT16 divisor, DCTELEM *dtbl)
|
||||
{
|
||||
UDCTELEM2 fq, fr;
|
||||
UDCTELEM c;
|
||||
@ -182,10 +182,10 @@ compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
|
||||
* identity function. Since only the C quantization algorithm is used in
|
||||
* these cases, the scale value is irrelevant.
|
||||
*/
|
||||
dtbl[DCTSIZE2 * 0] = (DCTELEM) 1; /* reciprocal */
|
||||
dtbl[DCTSIZE2 * 1] = (DCTELEM) 0; /* correction */
|
||||
dtbl[DCTSIZE2 * 2] = (DCTELEM) 1; /* scale */
|
||||
dtbl[DCTSIZE2 * 3] = -(DCTELEM) (sizeof(DCTELEM) * 8); /* shift */
|
||||
dtbl[DCTSIZE2 * 0] = (DCTELEM)1; /* reciprocal */
|
||||
dtbl[DCTSIZE2 * 1] = (DCTELEM)0; /* correction */
|
||||
dtbl[DCTSIZE2 * 2] = (DCTELEM)1; /* scale */
|
||||
dtbl[DCTSIZE2 * 3] = -(DCTELEM)(sizeof(DCTELEM) * 8); /* shift */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -207,14 +207,14 @@ compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
|
||||
fq++;
|
||||
}
|
||||
|
||||
dtbl[DCTSIZE2 * 0] = (DCTELEM) fq; /* reciprocal */
|
||||
dtbl[DCTSIZE2 * 1] = (DCTELEM) c; /* correction + roundfactor */
|
||||
dtbl[DCTSIZE2 * 0] = (DCTELEM)fq; /* reciprocal */
|
||||
dtbl[DCTSIZE2 * 1] = (DCTELEM)c; /* correction + roundfactor */
|
||||
#ifdef WITH_SIMD
|
||||
dtbl[DCTSIZE2 * 2] = (DCTELEM) (1 << (sizeof(DCTELEM)*8*2 - r)); /* scale */
|
||||
dtbl[DCTSIZE2 * 2] = (DCTELEM)(1 << (sizeof(DCTELEM) * 8 * 2 - r)); /* scale */
|
||||
#else
|
||||
dtbl[DCTSIZE2 * 2] = 1;
|
||||
#endif
|
||||
dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */
|
||||
dtbl[DCTSIZE2 * 3] = (DCTELEM)r - sizeof(DCTELEM) * 8; /* shift */
|
||||
|
||||
if (r <= 16) return 0;
|
||||
else return 1;
|
||||
@ -233,9 +233,9 @@ compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
start_pass_fdctmgr(j_compress_ptr cinfo)
|
||||
{
|
||||
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
||||
my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
|
||||
int ci, qtblno, i;
|
||||
jpeg_component_info *compptr;
|
||||
JQUANT_TBL *qtbl;
|
||||
@ -259,7 +259,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
*/
|
||||
if (fdct->divisors[qtblno] == NULL) {
|
||||
fdct->divisors[qtblno] = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(DCTSIZE2 * 4) * sizeof(DCTELEM));
|
||||
}
|
||||
dtbl = fdct->divisors[qtblno];
|
||||
@ -269,7 +269,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
fdct->quantize == jsimd_quantize)
|
||||
fdct->quantize = quantize;
|
||||
#else
|
||||
dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3;
|
||||
dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@ -299,23 +299,23 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
|
||||
if (fdct->divisors[qtblno] == NULL) {
|
||||
fdct->divisors[qtblno] = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(DCTSIZE2 * 4) * sizeof(DCTELEM));
|
||||
}
|
||||
dtbl = fdct->divisors[qtblno];
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
if (!compute_reciprocal(
|
||||
DESCALE(MULTIPLY16V16((JLONG) qtbl->quantval[i],
|
||||
(JLONG) aanscales[i]),
|
||||
CONST_BITS-3), &dtbl[i]) &&
|
||||
DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
|
||||
(JLONG)aanscales[i]),
|
||||
CONST_BITS - 3), &dtbl[i]) &&
|
||||
fdct->quantize == jsimd_quantize)
|
||||
fdct->quantize = quantize;
|
||||
#else
|
||||
dtbl[i] = (DCTELEM)
|
||||
DESCALE(MULTIPLY16V16((JLONG) qtbl->quantval[i],
|
||||
(JLONG) aanscales[i]),
|
||||
CONST_BITS-3);
|
||||
DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
|
||||
(JLONG)aanscales[i]),
|
||||
CONST_BITS - 3);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -341,7 +341,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
|
||||
if (fdct->float_divisors[qtblno] == NULL) {
|
||||
fdct->float_divisors[qtblno] = (FAST_FLOAT *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
DCTSIZE2 * sizeof(FAST_FLOAT));
|
||||
}
|
||||
fdtbl = fdct->float_divisors[qtblno];
|
||||
@ -349,7 +349,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
for (row = 0; row < DCTSIZE; row++) {
|
||||
for (col = 0; col < DCTSIZE; col++) {
|
||||
fdtbl[i] = (FAST_FLOAT)
|
||||
(1.0 / (((double) qtbl->quantval[i] *
|
||||
(1.0 / (((double)qtbl->quantval[i] *
|
||||
aanscalefactor[row] * aanscalefactor[col] * 8.0)));
|
||||
i++;
|
||||
}
|
||||
@ -370,7 +370,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
|
||||
convsamp(JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
|
||||
{
|
||||
register DCTELEM *workspaceptr;
|
||||
register JSAMPROW elemptr;
|
||||
@ -405,7 +405,7 @@ convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
quantize (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
{
|
||||
int i;
|
||||
DCTELEM temp;
|
||||
@ -426,15 +426,15 @@ quantize (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
if (temp < 0) {
|
||||
temp = -temp;
|
||||
product = (UDCTELEM2)(temp + corr) * recip;
|
||||
product >>= shift + sizeof(DCTELEM)*8;
|
||||
product >>= shift + sizeof(DCTELEM) * 8;
|
||||
temp = (DCTELEM)product;
|
||||
temp = -temp;
|
||||
} else {
|
||||
product = (UDCTELEM2)(temp + corr) * recip;
|
||||
product >>= shift + sizeof(DCTELEM)*8;
|
||||
product >>= shift + sizeof(DCTELEM) * 8;
|
||||
temp = (DCTELEM)product;
|
||||
}
|
||||
output_ptr[i] = (JCOEF) temp;
|
||||
output_ptr[i] = (JCOEF)temp;
|
||||
}
|
||||
|
||||
#else
|
||||
@ -457,20 +457,20 @@ quantize (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
* If your machine's division is fast enough, define FAST_DIVIDE.
|
||||
*/
|
||||
#ifdef FAST_DIVIDE
|
||||
#define DIVIDE_BY(a,b) a /= b
|
||||
#define DIVIDE_BY(a, b) a /= b
|
||||
#else
|
||||
#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0
|
||||
#define DIVIDE_BY(a, b) if (a >= b) a /= b; else a = 0
|
||||
#endif
|
||||
if (temp < 0) {
|
||||
temp = -temp;
|
||||
temp += qval>>1; /* for rounding */
|
||||
temp += qval >> 1; /* for rounding */
|
||||
DIVIDE_BY(temp, qval);
|
||||
temp = -temp;
|
||||
} else {
|
||||
temp += qval>>1; /* for rounding */
|
||||
temp += qval >> 1; /* for rounding */
|
||||
DIVIDE_BY(temp, qval);
|
||||
}
|
||||
output_ptr[i] = (JCOEF) temp;
|
||||
output_ptr[i] = (JCOEF)temp;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -487,14 +487,13 @@ quantize (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
forward_DCT (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
forward_DCT(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
||||
JDIMENSION start_row, JDIMENSION start_col,
|
||||
JDIMENSION num_blocks)
|
||||
JDIMENSION start_row, JDIMENSION start_col, JDIMENSION num_blocks)
|
||||
/* This version is used for integer DCT implementations. */
|
||||
{
|
||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
||||
my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
|
||||
DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no];
|
||||
DCTELEM *workspace;
|
||||
JDIMENSION bi;
|
||||
@ -522,9 +521,9 @@ forward_DCT (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
#ifdef DCT_FLOAT_SUPPORTED
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, FAST_FLOAT *workspace)
|
||||
convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
FAST_FLOAT *workspace)
|
||||
{
|
||||
register FAST_FLOAT *workspaceptr;
|
||||
register JSAMPROW elemptr;
|
||||
@ -555,7 +554,8 @@ convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, FAST_FLOAT *worksp
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors, FAST_FLOAT *workspace)
|
||||
quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
||||
FAST_FLOAT *workspace)
|
||||
{
|
||||
register FAST_FLOAT temp;
|
||||
register int i;
|
||||
@ -571,20 +571,20 @@ quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors, FAST_FLOAT *workspace
|
||||
* The maximum coefficient size is +-16K (for 12-bit data), so this
|
||||
* code should work for either 16-bit or 32-bit ints.
|
||||
*/
|
||||
output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384);
|
||||
output_ptr[i] = (JCOEF)((int)(temp + (FAST_FLOAT)16384.5) - 16384);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
forward_DCT_float(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
||||
JDIMENSION start_row, JDIMENSION start_col,
|
||||
JDIMENSION num_blocks)
|
||||
/* This version is used for floating-point DCT implementations. */
|
||||
{
|
||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
||||
my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
|
||||
FAST_FLOAT *divisors = fdct->float_divisors[compptr->quant_tbl_no];
|
||||
FAST_FLOAT *workspace;
|
||||
JDIMENSION bi;
|
||||
@ -618,15 +618,15 @@ forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_forward_dct (j_compress_ptr cinfo)
|
||||
jinit_forward_dct(j_compress_ptr cinfo)
|
||||
{
|
||||
my_fdct_ptr fdct;
|
||||
int i;
|
||||
|
||||
fdct = (my_fdct_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_fdct_controller));
|
||||
cinfo->fdct = (struct jpeg_forward_dct *) fdct;
|
||||
cinfo->fdct = (struct jpeg_forward_dct *)fdct;
|
||||
fdct->pub.start_pass = start_pass_fdctmgr;
|
||||
|
||||
/* First determine the DCT... */
|
||||
@ -703,12 +703,12 @@ jinit_forward_dct (j_compress_ptr cinfo)
|
||||
#ifdef DCT_FLOAT_SUPPORTED
|
||||
if (cinfo->dct_method == JDCT_FLOAT)
|
||||
fdct->float_workspace = (FAST_FLOAT *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(FAST_FLOAT) * DCTSIZE2);
|
||||
else
|
||||
#endif
|
||||
fdct->workspace = (DCTELEM *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(DCTELEM) * DCTSIZE2);
|
||||
|
||||
/* Mark divisor tables unallocated */
|
||||
|
185
3rdparty/libjpeg-turbo/src/jchuff.c
vendored
185
3rdparty/libjpeg-turbo/src/jchuff.c
vendored
@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009-2011, 2014-2016, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2014-2016, 2018, D. R. Commander.
|
||||
* Copyright (C) 2015, Matthieu Darbois.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@ -16,6 +16,9 @@
|
||||
* back up to the start of the current MCU. To do this, we copy state
|
||||
* variables into local working storage, and update them back to the
|
||||
* permanent JPEG objects only upon successful completion of an MCU.
|
||||
*
|
||||
* NOTE: All referenced figures are from
|
||||
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
@ -55,10 +58,6 @@
|
||||
#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
|
||||
/* Expanded entropy encoder object for Huffman encoding.
|
||||
*
|
||||
@ -78,10 +77,10 @@ typedef struct {
|
||||
*/
|
||||
|
||||
#ifndef NO_STRUCT_ASSIGN
|
||||
#define ASSIGN_STATE(dest,src) ((dest) = (src))
|
||||
#define ASSIGN_STATE(dest, src) ((dest) = (src))
|
||||
#else
|
||||
#if MAX_COMPS_IN_SCAN == 4
|
||||
#define ASSIGN_STATE(dest,src) \
|
||||
#define ASSIGN_STATE(dest, src) \
|
||||
((dest).put_buffer = (src).put_buffer, \
|
||||
(dest).put_bits = (src).put_bits, \
|
||||
(dest).last_dc_val[0] = (src).last_dc_val[0], \
|
||||
@ -128,12 +127,12 @@ typedef struct {
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_huff (j_compress_ptr cinfo);
|
||||
METHODDEF(boolean) encode_mcu_huff(j_compress_ptr cinfo, JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_huff(j_compress_ptr cinfo);
|
||||
#ifdef ENTROPY_OPT_SUPPORTED
|
||||
METHODDEF(boolean) encode_mcu_gather (j_compress_ptr cinfo,
|
||||
METHODDEF(boolean) encode_mcu_gather(j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_gather (j_compress_ptr cinfo);
|
||||
METHODDEF(void) finish_pass_gather(j_compress_ptr cinfo);
|
||||
#endif
|
||||
|
||||
|
||||
@ -144,9 +143,9 @@ METHODDEF(void) finish_pass_gather (j_compress_ptr cinfo);
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
start_pass_huff(j_compress_ptr cinfo, boolean gather_statistics)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int ci, dctbl, actbl;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@ -180,12 +179,12 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
/* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
|
||||
if (entropy->dc_count_ptrs[dctbl] == NULL)
|
||||
entropy->dc_count_ptrs[dctbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
257 * sizeof(long));
|
||||
MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * sizeof(long));
|
||||
if (entropy->ac_count_ptrs[actbl] == NULL)
|
||||
entropy->ac_count_ptrs[actbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
257 * sizeof(long));
|
||||
MEMZERO(entropy->ac_count_ptrs[actbl], 257 * sizeof(long));
|
||||
#endif
|
||||
@ -193,9 +192,9 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
/* Compute derived values for Huffman tables */
|
||||
/* We may do this more than once for a table, but it's not expensive */
|
||||
jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl,
|
||||
& entropy->dc_derived_tbls[dctbl]);
|
||||
&entropy->dc_derived_tbls[dctbl]);
|
||||
jpeg_make_c_derived_tbl(cinfo, FALSE, actbl,
|
||||
& entropy->ac_derived_tbls[actbl]);
|
||||
&entropy->ac_derived_tbls[actbl]);
|
||||
}
|
||||
/* Initialize DC predictions to 0 */
|
||||
entropy->saved.last_dc_val[ci] = 0;
|
||||
@ -219,7 +218,7 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
c_derived_tbl **pdtbl)
|
||||
{
|
||||
JHUFF_TBL *htbl;
|
||||
@ -244,7 +243,7 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
/* Allocate a workspace if we haven't already done so. */
|
||||
if (*pdtbl == NULL)
|
||||
*pdtbl = (c_derived_tbl *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(c_derived_tbl));
|
||||
dtbl = *pdtbl;
|
||||
|
||||
@ -252,11 +251,11 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
|
||||
p = 0;
|
||||
for (l = 1; l <= 16; l++) {
|
||||
i = (int) htbl->bits[l];
|
||||
i = (int)htbl->bits[l];
|
||||
if (i < 0 || p + i > 256) /* protect against table overrun */
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
while (i--)
|
||||
huffsize[p++] = (char) l;
|
||||
huffsize[p++] = (char)l;
|
||||
}
|
||||
huffsize[p] = 0;
|
||||
lastp = p;
|
||||
@ -268,14 +267,14 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
si = huffsize[0];
|
||||
p = 0;
|
||||
while (huffsize[p]) {
|
||||
while (((int) huffsize[p]) == si) {
|
||||
while (((int)huffsize[p]) == si) {
|
||||
huffcode[p++] = code;
|
||||
code++;
|
||||
}
|
||||
/* code is now 1 more than the last code used for codelength si; but
|
||||
* it must still fit in si bits, since no code is allowed to be all ones.
|
||||
*/
|
||||
if (((JLONG) code) >= (((JLONG) 1) << si))
|
||||
if (((JLONG)code) >= (((JLONG)1) << si))
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
code <<= 1;
|
||||
si++;
|
||||
@ -310,20 +309,21 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
/* Outputting bytes to the file */
|
||||
|
||||
/* Emit a byte, taking 'action' if must suspend. */
|
||||
#define emit_byte(state,val,action) \
|
||||
{ *(state)->next_output_byte++ = (JOCTET) (val); \
|
||||
#define emit_byte(state, val, action) { \
|
||||
*(state)->next_output_byte++ = (JOCTET)(val); \
|
||||
if (--(state)->free_in_buffer == 0) \
|
||||
if (! dump_buffer(state)) \
|
||||
{ action; } }
|
||||
if (!dump_buffer(state)) \
|
||||
{ action; } \
|
||||
}
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
dump_buffer (working_state *state)
|
||||
dump_buffer(working_state *state)
|
||||
/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */
|
||||
{
|
||||
struct jpeg_destination_mgr *dest = state->cinfo->dest;
|
||||
|
||||
if (! (*dest->empty_output_buffer) (state->cinfo))
|
||||
if (!(*dest->empty_output_buffer) (state->cinfo))
|
||||
return FALSE;
|
||||
/* After a successful buffer dump, must reset buffer pointers */
|
||||
state->next_output_byte = dest->next_output_byte;
|
||||
@ -349,7 +349,7 @@ dump_buffer (working_state *state)
|
||||
*buffer++ = c; \
|
||||
if (c == 0xFF) /* need to stuff a zero byte? */ \
|
||||
*buffer++ = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
#define PUT_BITS(code, size) { \
|
||||
put_bits += size; \
|
||||
@ -387,7 +387,7 @@ dump_buffer (working_state *state)
|
||||
#error Cannot determine word size
|
||||
#endif
|
||||
|
||||
#if SIZEOF_SIZE_T==8 || defined(_WIN64)
|
||||
#if SIZEOF_SIZE_T == 8 || defined(_WIN64)
|
||||
|
||||
#define EMIT_BITS(code, size) { \
|
||||
CHECKBUF47() \
|
||||
@ -395,11 +395,11 @@ dump_buffer (working_state *state)
|
||||
}
|
||||
|
||||
#define EMIT_CODE(code, size) { \
|
||||
temp2 &= (((JLONG) 1)<<nbits) - 1; \
|
||||
temp2 &= (((JLONG)1) << nbits) - 1; \
|
||||
CHECKBUF31() \
|
||||
PUT_BITS(code, size) \
|
||||
PUT_BITS(temp2, nbits) \
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@ -409,12 +409,12 @@ dump_buffer (working_state *state)
|
||||
}
|
||||
|
||||
#define EMIT_CODE(code, size) { \
|
||||
temp2 &= (((JLONG) 1)<<nbits) - 1; \
|
||||
temp2 &= (((JLONG)1) << nbits) - 1; \
|
||||
PUT_BITS(code, size) \
|
||||
CHECKBUF15() \
|
||||
PUT_BITS(temp2, nbits) \
|
||||
CHECKBUF15() \
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -434,34 +434,33 @@ dump_buffer (working_state *state)
|
||||
if (state->free_in_buffer < BUFSIZE) { \
|
||||
localbuf = 1; \
|
||||
buffer = _buffer; \
|
||||
} \
|
||||
else buffer = state->next_output_byte; \
|
||||
}
|
||||
} else \
|
||||
buffer = state->next_output_byte; \
|
||||
}
|
||||
|
||||
#define STORE_BUFFER() { \
|
||||
if (localbuf) { \
|
||||
bytes = buffer - _buffer; \
|
||||
buffer = _buffer; \
|
||||
while (bytes > 0) { \
|
||||
bytestocopy = min(bytes, state->free_in_buffer); \
|
||||
bytestocopy = MIN(bytes, state->free_in_buffer); \
|
||||
MEMCOPY(state->next_output_byte, buffer, bytestocopy); \
|
||||
state->next_output_byte += bytestocopy; \
|
||||
buffer += bytestocopy; \
|
||||
state->free_in_buffer -= bytestocopy; \
|
||||
if (state->free_in_buffer == 0) \
|
||||
if (! dump_buffer(state)) return FALSE; \
|
||||
if (!dump_buffer(state)) return FALSE; \
|
||||
bytes -= bytestocopy; \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
} else { \
|
||||
state->free_in_buffer -= (buffer - state->next_output_byte); \
|
||||
state->next_output_byte = buffer; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
flush_bits (working_state *state)
|
||||
flush_bits(working_state *state)
|
||||
{
|
||||
JOCTET _buffer[BUFSIZE], *buffer;
|
||||
size_t put_buffer; int put_bits;
|
||||
@ -486,7 +485,7 @@ flush_bits (working_state *state)
|
||||
/* Encode a single block's worth of coefficients */
|
||||
|
||||
LOCAL(boolean)
|
||||
encode_one_block_simd (working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
encode_one_block_simd(working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
c_derived_tbl *dctbl, c_derived_tbl *actbl)
|
||||
{
|
||||
JOCTET _buffer[BUFSIZE], *buffer;
|
||||
@ -503,7 +502,7 @@ encode_one_block_simd (working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
}
|
||||
|
||||
LOCAL(boolean)
|
||||
encode_one_block (working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
encode_one_block(working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
c_derived_tbl *dctbl, c_derived_tbl *actbl)
|
||||
{
|
||||
int temp, temp2, temp3;
|
||||
@ -544,7 +543,7 @@ encode_one_block (working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
EMIT_BITS(code, size)
|
||||
|
||||
/* Mask off any extra bits in code */
|
||||
temp2 &= (((JLONG) 1)<<nbits) - 1;
|
||||
temp2 &= (((JLONG)1) << nbits) - 1;
|
||||
|
||||
/* Emit that number of bits of the value, if positive, */
|
||||
/* or the complement of its magnitude, if negative. */
|
||||
@ -616,11 +615,11 @@ encode_one_block (working_state *state, JCOEFPTR block, int last_dc_val,
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
emit_restart (working_state *state, int restart_num)
|
||||
emit_restart(working_state *state, int restart_num)
|
||||
{
|
||||
int ci;
|
||||
|
||||
if (! flush_bits(state))
|
||||
if (!flush_bits(state))
|
||||
return FALSE;
|
||||
|
||||
emit_byte(state, 0xFF, return FALSE);
|
||||
@ -641,9 +640,9 @@ emit_restart (working_state *state, int restart_num)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_huff(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
working_state state;
|
||||
int blkn, ci;
|
||||
jpeg_component_info *compptr;
|
||||
@ -657,7 +656,7 @@ encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Emit restart marker if needed */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! emit_restart(&state, entropy->next_restart_num))
|
||||
if (!emit_restart(&state, entropy->next_restart_num))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -666,7 +665,7 @@ encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
ci = cinfo->MCU_membership[blkn];
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
if (! encode_one_block_simd(&state,
|
||||
if (!encode_one_block_simd(&state,
|
||||
MCU_data[blkn][0], state.cur.last_dc_val[ci],
|
||||
entropy->dc_derived_tbls[compptr->dc_tbl_no],
|
||||
entropy->ac_derived_tbls[compptr->ac_tbl_no]))
|
||||
@ -678,7 +677,7 @@ encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
ci = cinfo->MCU_membership[blkn];
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
if (! encode_one_block(&state,
|
||||
if (!encode_one_block(&state,
|
||||
MCU_data[blkn][0], state.cur.last_dc_val[ci],
|
||||
entropy->dc_derived_tbls[compptr->dc_tbl_no],
|
||||
entropy->ac_derived_tbls[compptr->ac_tbl_no]))
|
||||
@ -712,9 +711,9 @@ encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_huff (j_compress_ptr cinfo)
|
||||
finish_pass_huff(j_compress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
working_state state;
|
||||
|
||||
/* Load up working state ... flush_bits needs it */
|
||||
@ -724,7 +723,7 @@ finish_pass_huff (j_compress_ptr cinfo)
|
||||
state.cinfo = cinfo;
|
||||
|
||||
/* Flush out the last data */
|
||||
if (! flush_bits(&state))
|
||||
if (!flush_bits(&state))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
|
||||
/* Update state */
|
||||
@ -751,7 +750,7 @@ finish_pass_huff (j_compress_ptr cinfo)
|
||||
/* Process a single block's worth of coefficients */
|
||||
|
||||
LOCAL(void)
|
||||
htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
||||
htest_one_block(j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
||||
long dc_counts[], long ac_counts[])
|
||||
{
|
||||
register int temp;
|
||||
@ -773,7 +772,7 @@ htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
||||
/* Check for out-of-range coefficient values.
|
||||
* Since we're encoding a difference, the range limit is twice as much.
|
||||
*/
|
||||
if (nbits > MAX_COEF_BITS+1)
|
||||
if (nbits > MAX_COEF_BITS + 1)
|
||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||
|
||||
/* Count the Huffman symbol for the number of bits */
|
||||
@ -824,9 +823,9 @@ htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_gather(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int blkn, ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@ -863,13 +862,14 @@ encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
* one bits (so that padding bits added at the end of a compressed segment
|
||||
* can't look like a valid code). Because of the canonical ordering of
|
||||
* codewords, this just means that there must be an unused slot in the
|
||||
* longest codeword length category. Section K.2 of the JPEG spec suggests
|
||||
* reserving such a slot by pretending that symbol 256 is a valid symbol
|
||||
* with count 1. In theory that's not optimal; giving it count zero but
|
||||
* including it in the symbol set anyway should give a better Huffman code.
|
||||
* But the theoretically better code actually seems to come out worse in
|
||||
* practice, because it produces more all-ones bytes (which incur stuffed
|
||||
* zero bytes in the final file). In any case the difference is tiny.
|
||||
* longest codeword length category. Annex K (Clause K.2) of
|
||||
* Rec. ITU-T T.81 (1992) | ISO/IEC 10918-1:1994 suggests reserving such a slot
|
||||
* by pretending that symbol 256 is a valid symbol with count 1. In theory
|
||||
* that's not optimal; giving it count zero but including it in the symbol set
|
||||
* anyway should give a better Huffman code. But the theoretically better code
|
||||
* actually seems to come out worse in practice, because it produces more
|
||||
* all-ones bytes (which incur stuffed zero bytes in the final file). In any
|
||||
* case the difference is tiny.
|
||||
*
|
||||
* The JPEG standard requires Huffman codes to be no more than 16 bits long.
|
||||
* If some symbols have a very small but nonzero probability, the Huffman tree
|
||||
@ -884,10 +884,10 @@ encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
||||
jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
||||
{
|
||||
#define MAX_CLEN 32 /* assumed maximum initial code length */
|
||||
UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */
|
||||
UINT8 bits[MAX_CLEN + 1]; /* bits[k] = # of symbols with code length k */
|
||||
int codesize[257]; /* codesize[k] = code length of symbol k */
|
||||
int others[257]; /* next symbol in current branch of tree */
|
||||
int c1, c2;
|
||||
@ -971,13 +971,13 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
||||
|
||||
/* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure
|
||||
* Huffman procedure assigned any such lengths, we must adjust the coding.
|
||||
* Here is what the JPEG spec says about how this next bit works:
|
||||
* Since symbols are paired for the longest Huffman code, the symbols are
|
||||
* removed from this length category two at a time. The prefix for the pair
|
||||
* (which is one bit shorter) is allocated to one of the pair; then,
|
||||
* skipping the BITS entry for that prefix length, a code word from the next
|
||||
* shortest nonzero BITS entry is converted into a prefix for two code words
|
||||
* one bit longer.
|
||||
* Here is what Rec. ITU-T T.81 | ISO/IEC 10918-1 says about how this next
|
||||
* bit works: Since symbols are paired for the longest Huffman code, the
|
||||
* symbols are removed from this length category two at a time. The prefix
|
||||
* for the pair (which is one bit shorter) is allocated to one of the pair;
|
||||
* then, skipping the BITS entry for that prefix length, a code word from the
|
||||
* next shortest nonzero BITS entry is converted into a prefix for two code
|
||||
* words one bit longer.
|
||||
*/
|
||||
|
||||
for (i = MAX_CLEN; i > 16; i--) {
|
||||
@ -987,8 +987,8 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
||||
j--;
|
||||
|
||||
bits[i] -= 2; /* remove two symbols */
|
||||
bits[i-1]++; /* one goes in this length */
|
||||
bits[j+1] += 2; /* two new symbols in this length */
|
||||
bits[i - 1]++; /* one goes in this length */
|
||||
bits[j + 1] += 2; /* two new symbols in this length */
|
||||
bits[j]--; /* symbol of this length is now a prefix */
|
||||
}
|
||||
}
|
||||
@ -1003,13 +1003,14 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
||||
|
||||
/* Return a list of the symbols sorted by code length */
|
||||
/* It's not real clear to me why we don't need to consider the codelength
|
||||
* changes made above, but the JPEG spec seems to think this works.
|
||||
* changes made above, but Rec. ITU-T T.81 | ISO/IEC 10918-1 seems to think
|
||||
* this works.
|
||||
*/
|
||||
p = 0;
|
||||
for (i = 1; i <= MAX_CLEN; i++) {
|
||||
for (j = 0; j <= 255; j++) {
|
||||
if (codesize[j] == i) {
|
||||
htbl->huffval[p] = (UINT8) j;
|
||||
htbl->huffval[p] = (UINT8)j;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
@ -1025,9 +1026,9 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_gather (j_compress_ptr cinfo)
|
||||
finish_pass_gather(j_compress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int ci, dctbl, actbl;
|
||||
jpeg_component_info *compptr;
|
||||
JHUFF_TBL **htblptr;
|
||||
@ -1044,17 +1045,17 @@ finish_pass_gather (j_compress_ptr cinfo)
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
dctbl = compptr->dc_tbl_no;
|
||||
actbl = compptr->ac_tbl_no;
|
||||
if (! did_dc[dctbl]) {
|
||||
htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl];
|
||||
if (!did_dc[dctbl]) {
|
||||
htblptr = &cinfo->dc_huff_tbl_ptrs[dctbl];
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
|
||||
jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]);
|
||||
did_dc[dctbl] = TRUE;
|
||||
}
|
||||
if (! did_ac[actbl]) {
|
||||
htblptr = & cinfo->ac_huff_tbl_ptrs[actbl];
|
||||
if (!did_ac[actbl]) {
|
||||
htblptr = &cinfo->ac_huff_tbl_ptrs[actbl];
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
|
||||
jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]);
|
||||
did_ac[actbl] = TRUE;
|
||||
}
|
||||
@ -1070,15 +1071,15 @@ finish_pass_gather (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_huff_encoder (j_compress_ptr cinfo)
|
||||
jinit_huff_encoder(j_compress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (huff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(huff_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass_huff;
|
||||
|
||||
/* Mark tables unallocated */
|
||||
|
9
3rdparty/libjpeg-turbo/src/jchuff.h
vendored
9
3rdparty/libjpeg-turbo/src/jchuff.h
vendored
@ -34,10 +34,9 @@ typedef struct {
|
||||
} c_derived_tbl;
|
||||
|
||||
/* Expand a Huffman table definition into the derived format */
|
||||
EXTERN(void) jpeg_make_c_derived_tbl
|
||||
(j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
c_derived_tbl ** pdtbl);
|
||||
EXTERN(void) jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC,
|
||||
int tblno, c_derived_tbl **pdtbl);
|
||||
|
||||
/* Generate an optimal table definition given the specified counts */
|
||||
EXTERN(void) jpeg_gen_optimal_table
|
||||
(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[]);
|
||||
EXTERN(void) jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl,
|
||||
long freq[]);
|
||||
|
10
3rdparty/libjpeg-turbo/src/jcinit.c
vendored
10
3rdparty/libjpeg-turbo/src/jcinit.c
vendored
@ -28,13 +28,13 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_compress_master (j_compress_ptr cinfo)
|
||||
jinit_compress_master(j_compress_ptr cinfo)
|
||||
{
|
||||
/* Initialize master control (includes parameter checking/processing) */
|
||||
jinit_c_master_control(cinfo, FALSE /* full compression */);
|
||||
|
||||
/* Preprocessing */
|
||||
if (! cinfo->raw_data_in) {
|
||||
if (!cinfo->raw_data_in) {
|
||||
jinit_color_converter(cinfo);
|
||||
jinit_downsampler(cinfo);
|
||||
jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
|
||||
@ -60,14 +60,14 @@ jinit_compress_master (j_compress_ptr cinfo)
|
||||
}
|
||||
|
||||
/* Need a full-image coefficient buffer in any multi-pass mode. */
|
||||
jinit_c_coef_controller(cinfo,
|
||||
(boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding));
|
||||
jinit_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
|
||||
cinfo->optimize_coding));
|
||||
jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
|
||||
|
||||
jinit_marker_writer(cinfo);
|
||||
|
||||
/* We can now tell the memory manager to allocate virtual arrays. */
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
|
||||
|
||||
/* Write the datastream header (SOI) immediately.
|
||||
* Frame and scan headers are postponed till later.
|
||||
|
38
3rdparty/libjpeg-turbo/src/jcmainct.c
vendored
38
3rdparty/libjpeg-turbo/src/jcmainct.c
vendored
@ -39,8 +39,9 @@ typedef my_main_controller *my_main_ptr;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(void) process_data_simple_main
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
METHODDEF(void) process_data_simple_main(j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail);
|
||||
|
||||
|
||||
@ -49,9 +50,9 @@ METHODDEF(void) process_data_simple_main
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_main(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
|
||||
/* Do nothing in raw-data mode. */
|
||||
if (cinfo->raw_data_in)
|
||||
@ -75,19 +76,18 @@ start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
process_data_simple_main (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail)
|
||||
process_data_simple_main(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
|
||||
while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
|
||||
/* Read input data if we haven't filled the main buffer yet */
|
||||
if (main_ptr->rowgroup_ctr < DCTSIZE)
|
||||
(*cinfo->prep->pre_process_data) (cinfo,
|
||||
input_buf, in_row_ctr, in_rows_avail,
|
||||
main_ptr->buffer, &main_ptr->rowgroup_ctr,
|
||||
(JDIMENSION) DCTSIZE);
|
||||
(*cinfo->prep->pre_process_data) (cinfo, input_buf, in_row_ctr,
|
||||
in_rows_avail, main_ptr->buffer,
|
||||
&main_ptr->rowgroup_ctr,
|
||||
(JDIMENSION)DCTSIZE);
|
||||
|
||||
/* If we don't have a full iMCU row buffered, return to application for
|
||||
* more data. Note that preprocessor will always pad to fill the iMCU row
|
||||
@ -97,14 +97,14 @@ process_data_simple_main (j_compress_ptr cinfo,
|
||||
return;
|
||||
|
||||
/* Send the completed row to the compressor */
|
||||
if (! (*cinfo->coef->compress_data) (cinfo, main_ptr->buffer)) {
|
||||
if (!(*cinfo->coef->compress_data) (cinfo, main_ptr->buffer)) {
|
||||
/* If compressor did not consume the whole row, then we must need to
|
||||
* suspend processing and return to the application. In this situation
|
||||
* we pretend we didn't yet consume the last input row; otherwise, if
|
||||
* it happened to be the last row of the image, the application would
|
||||
* think we were done.
|
||||
*/
|
||||
if (! main_ptr->suspended) {
|
||||
if (!main_ptr->suspended) {
|
||||
(*in_row_ctr)--;
|
||||
main_ptr->suspended = TRUE;
|
||||
}
|
||||
@ -128,16 +128,16 @@ process_data_simple_main (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_c_main_controller(j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_main_ptr main_ptr;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
main_ptr = (my_main_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_main_controller));
|
||||
cinfo->main = (struct jpeg_c_main_controller *) main_ptr;
|
||||
cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
|
||||
main_ptr->pub.start_pass = start_pass_main;
|
||||
|
||||
/* We don't need to create a buffer in raw-data mode. */
|
||||
@ -154,9 +154,9 @@ jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
compptr->width_in_blocks * DCTSIZE,
|
||||
(JDIMENSION) (compptr->v_samp_factor * DCTSIZE));
|
||||
(JDIMENSION)(compptr->v_samp_factor * DCTSIZE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
93
3rdparty/libjpeg-turbo/src/jcmarker.c
vendored
93
3rdparty/libjpeg-turbo/src/jcmarker.c
vendored
@ -110,30 +110,30 @@ typedef my_marker_writer *my_marker_ptr;
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_byte (j_compress_ptr cinfo, int val)
|
||||
emit_byte(j_compress_ptr cinfo, int val)
|
||||
/* Emit a byte */
|
||||
{
|
||||
struct jpeg_destination_mgr *dest = cinfo->dest;
|
||||
|
||||
*(dest->next_output_byte)++ = (JOCTET) val;
|
||||
*(dest->next_output_byte)++ = (JOCTET)val;
|
||||
if (--dest->free_in_buffer == 0) {
|
||||
if (! (*dest->empty_output_buffer) (cinfo))
|
||||
if (!(*dest->empty_output_buffer) (cinfo))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark)
|
||||
emit_marker(j_compress_ptr cinfo, JPEG_MARKER mark)
|
||||
/* Emit a marker code */
|
||||
{
|
||||
emit_byte(cinfo, 0xFF);
|
||||
emit_byte(cinfo, (int) mark);
|
||||
emit_byte(cinfo, (int)mark);
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_2bytes (j_compress_ptr cinfo, int value)
|
||||
emit_2bytes(j_compress_ptr cinfo, int value)
|
||||
/* Emit a 2-byte integer; these are always MSB first in JPEG files */
|
||||
{
|
||||
emit_byte(cinfo, (value >> 8) & 0xFF);
|
||||
@ -146,7 +146,7 @@ emit_2bytes (j_compress_ptr cinfo, int value)
|
||||
*/
|
||||
|
||||
LOCAL(int)
|
||||
emit_dqt (j_compress_ptr cinfo, int index)
|
||||
emit_dqt(j_compress_ptr cinfo, int index)
|
||||
/* Emit a DQT marker */
|
||||
/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */
|
||||
{
|
||||
@ -163,19 +163,19 @@ emit_dqt (j_compress_ptr cinfo, int index)
|
||||
prec = 1;
|
||||
}
|
||||
|
||||
if (! qtbl->sent_table) {
|
||||
if (!qtbl->sent_table) {
|
||||
emit_marker(cinfo, M_DQT);
|
||||
|
||||
emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2);
|
||||
emit_2bytes(cinfo, prec ? DCTSIZE2 * 2 + 1 + 2 : DCTSIZE2 + 1 + 2);
|
||||
|
||||
emit_byte(cinfo, index + (prec<<4));
|
||||
emit_byte(cinfo, index + (prec << 4));
|
||||
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
/* The table entries must be emitted in zigzag order. */
|
||||
unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
|
||||
if (prec)
|
||||
emit_byte(cinfo, (int) (qval >> 8));
|
||||
emit_byte(cinfo, (int) (qval & 0xFF));
|
||||
emit_byte(cinfo, (int)(qval >> 8));
|
||||
emit_byte(cinfo, (int)(qval & 0xFF));
|
||||
}
|
||||
|
||||
qtbl->sent_table = TRUE;
|
||||
@ -186,7 +186,7 @@ emit_dqt (j_compress_ptr cinfo, int index)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
|
||||
emit_dht(j_compress_ptr cinfo, int index, boolean is_ac)
|
||||
/* Emit a DHT marker */
|
||||
{
|
||||
JHUFF_TBL *htbl;
|
||||
@ -202,7 +202,7 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
|
||||
if (htbl == NULL)
|
||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
|
||||
|
||||
if (! htbl->sent_table) {
|
||||
if (!htbl->sent_table) {
|
||||
emit_marker(cinfo, M_DHT);
|
||||
|
||||
length = 0;
|
||||
@ -224,7 +224,7 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_dac (j_compress_ptr cinfo)
|
||||
emit_dac(j_compress_ptr cinfo)
|
||||
/* Emit a DAC marker */
|
||||
/* Since the useful info is so small, we want to emit all the tables in */
|
||||
/* one DAC marker. Therefore this routine does its own scan of the table. */
|
||||
@ -255,12 +255,12 @@ emit_dac (j_compress_ptr cinfo)
|
||||
if (length) {
|
||||
emit_marker(cinfo, M_DAC);
|
||||
|
||||
emit_2bytes(cinfo, length*2 + 2);
|
||||
emit_2bytes(cinfo, length * 2 + 2);
|
||||
|
||||
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
||||
if (dc_in_use[i]) {
|
||||
emit_byte(cinfo, i);
|
||||
emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4));
|
||||
emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i] << 4));
|
||||
}
|
||||
if (ac_in_use[i]) {
|
||||
emit_byte(cinfo, i + 0x10);
|
||||
@ -273,19 +273,19 @@ emit_dac (j_compress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_dri (j_compress_ptr cinfo)
|
||||
emit_dri(j_compress_ptr cinfo)
|
||||
/* Emit a DRI marker */
|
||||
{
|
||||
emit_marker(cinfo, M_DRI);
|
||||
|
||||
emit_2bytes(cinfo, 4); /* fixed length */
|
||||
|
||||
emit_2bytes(cinfo, (int) cinfo->restart_interval);
|
||||
emit_2bytes(cinfo, (int)cinfo->restart_interval);
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
|
||||
emit_sof(j_compress_ptr cinfo, JPEG_MARKER code)
|
||||
/* Emit a SOF marker */
|
||||
{
|
||||
int ci;
|
||||
@ -296,13 +296,12 @@ emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
|
||||
emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
|
||||
|
||||
/* Make sure image isn't bigger than SOF field can handle */
|
||||
if ((long) cinfo->_jpeg_height > 65535L ||
|
||||
(long) cinfo->_jpeg_width > 65535L)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535);
|
||||
if ((long)cinfo->_jpeg_height > 65535L || (long)cinfo->_jpeg_width > 65535L)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)65535);
|
||||
|
||||
emit_byte(cinfo, cinfo->data_precision);
|
||||
emit_2bytes(cinfo, (int) cinfo->_jpeg_height);
|
||||
emit_2bytes(cinfo, (int) cinfo->_jpeg_width);
|
||||
emit_2bytes(cinfo, (int)cinfo->_jpeg_height);
|
||||
emit_2bytes(cinfo, (int)cinfo->_jpeg_width);
|
||||
|
||||
emit_byte(cinfo, cinfo->num_components);
|
||||
|
||||
@ -316,7 +315,7 @@ emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_sos (j_compress_ptr cinfo)
|
||||
emit_sos(j_compress_ptr cinfo)
|
||||
/* Emit a SOS marker */
|
||||
{
|
||||
int i, td, ta;
|
||||
@ -351,7 +350,7 @@ emit_sos (j_compress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_jfif_app0 (j_compress_ptr cinfo)
|
||||
emit_jfif_app0(j_compress_ptr cinfo)
|
||||
/* Emit a JFIF-compliant APP0 marker */
|
||||
{
|
||||
/*
|
||||
@ -378,15 +377,15 @@ emit_jfif_app0 (j_compress_ptr cinfo)
|
||||
emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */
|
||||
emit_byte(cinfo, cinfo->JFIF_minor_version);
|
||||
emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
|
||||
emit_2bytes(cinfo, (int) cinfo->X_density);
|
||||
emit_2bytes(cinfo, (int) cinfo->Y_density);
|
||||
emit_2bytes(cinfo, (int)cinfo->X_density);
|
||||
emit_2bytes(cinfo, (int)cinfo->Y_density);
|
||||
emit_byte(cinfo, 0); /* No thumbnail image */
|
||||
emit_byte(cinfo, 0);
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
emit_adobe_app14 (j_compress_ptr cinfo)
|
||||
emit_adobe_app14(j_compress_ptr cinfo)
|
||||
/* Emit an Adobe APP14 marker */
|
||||
{
|
||||
/*
|
||||
@ -440,19 +439,19 @@ emit_adobe_app14 (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||
write_marker_header(j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||
/* Emit an arbitrary marker header */
|
||||
{
|
||||
if (datalen > (unsigned int) 65533) /* safety check */
|
||||
if (datalen > (unsigned int)65533) /* safety check */
|
||||
ERREXIT(cinfo, JERR_BAD_LENGTH);
|
||||
|
||||
emit_marker(cinfo, (JPEG_MARKER) marker);
|
||||
emit_marker(cinfo, (JPEG_MARKER)marker);
|
||||
|
||||
emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */
|
||||
emit_2bytes(cinfo, (int)(datalen + 2)); /* total length */
|
||||
}
|
||||
|
||||
METHODDEF(void)
|
||||
write_marker_byte (j_compress_ptr cinfo, int val)
|
||||
write_marker_byte(j_compress_ptr cinfo, int val)
|
||||
/* Emit one byte of marker parameters following write_marker_header */
|
||||
{
|
||||
emit_byte(cinfo, val);
|
||||
@ -471,9 +470,9 @@ write_marker_byte (j_compress_ptr cinfo, int val)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_file_header (j_compress_ptr cinfo)
|
||||
write_file_header(j_compress_ptr cinfo)
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
|
||||
emit_marker(cinfo, M_SOI); /* first the SOI */
|
||||
|
||||
@ -496,7 +495,7 @@ write_file_header (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_frame_header (j_compress_ptr cinfo)
|
||||
write_frame_header(j_compress_ptr cinfo)
|
||||
{
|
||||
int ci, prec;
|
||||
boolean is_baseline;
|
||||
@ -556,9 +555,9 @@ write_frame_header (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_scan_header (j_compress_ptr cinfo)
|
||||
write_scan_header(j_compress_ptr cinfo)
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
int i;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@ -600,7 +599,7 @@ write_scan_header (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_file_trailer (j_compress_ptr cinfo)
|
||||
write_file_trailer(j_compress_ptr cinfo)
|
||||
{
|
||||
emit_marker(cinfo, M_EOI);
|
||||
}
|
||||
@ -614,7 +613,7 @@ write_file_trailer (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
write_tables_only (j_compress_ptr cinfo)
|
||||
write_tables_only(j_compress_ptr cinfo)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -622,10 +621,10 @@ write_tables_only (j_compress_ptr cinfo)
|
||||
|
||||
for (i = 0; i < NUM_QUANT_TBLS; i++) {
|
||||
if (cinfo->quant_tbl_ptrs[i] != NULL)
|
||||
(void) emit_dqt(cinfo, i);
|
||||
(void)emit_dqt(cinfo, i);
|
||||
}
|
||||
|
||||
if (! cinfo->arith_code) {
|
||||
if (!cinfo->arith_code) {
|
||||
for (i = 0; i < NUM_HUFF_TBLS; i++) {
|
||||
if (cinfo->dc_huff_tbl_ptrs[i] != NULL)
|
||||
emit_dht(cinfo, i, FALSE);
|
||||
@ -643,15 +642,15 @@ write_tables_only (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_marker_writer (j_compress_ptr cinfo)
|
||||
jinit_marker_writer(j_compress_ptr cinfo)
|
||||
{
|
||||
my_marker_ptr marker;
|
||||
|
||||
/* Create the subobject */
|
||||
marker = (my_marker_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_marker_writer));
|
||||
cinfo->marker = (struct jpeg_marker_writer *) marker;
|
||||
cinfo->marker = (struct jpeg_marker_writer *)marker;
|
||||
/* Initialize method pointers */
|
||||
marker->pub.write_file_header = write_file_header;
|
||||
marker->pub.write_frame_header = write_frame_header;
|
||||
|
123
3rdparty/libjpeg-turbo/src/jcmaster.c
vendored
123
3rdparty/libjpeg-turbo/src/jcmaster.c
vendored
@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2003-2010 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2016, D. R. Commander.
|
||||
* Copyright (C) 2010, 2016, 2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@ -66,7 +66,7 @@ typedef my_comp_master *my_master_ptr;
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
|
||||
jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo)
|
||||
/* Do computations that are needed before master selection phase */
|
||||
{
|
||||
/* Hardwire it to "no scaling" */
|
||||
@ -79,7 +79,7 @@ jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
initial_setup(j_compress_ptr cinfo, boolean transcode_only)
|
||||
/* Do computations that are needed before master selection phase */
|
||||
{
|
||||
int ci;
|
||||
@ -95,19 +95,19 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
#endif
|
||||
|
||||
/* Sanity check on image dimensions */
|
||||
if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0
|
||||
|| cinfo->num_components <= 0 || cinfo->input_components <= 0)
|
||||
if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0 ||
|
||||
cinfo->num_components <= 0 || cinfo->input_components <= 0)
|
||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||
|
||||
/* Make sure image isn't bigger than I can handle */
|
||||
if ((long) cinfo->_jpeg_height > (long) JPEG_MAX_DIMENSION ||
|
||||
(long) cinfo->_jpeg_width > (long) JPEG_MAX_DIMENSION)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
||||
if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
|
||||
(long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
|
||||
|
||||
/* Width of an input scanline must be representable as JDIMENSION. */
|
||||
samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components;
|
||||
jd_samplesperrow = (JDIMENSION) samplesperrow;
|
||||
if ((long) jd_samplesperrow != samplesperrow)
|
||||
samplesperrow = (long)cinfo->image_width * (long)cinfo->input_components;
|
||||
jd_samplesperrow = (JDIMENSION)samplesperrow;
|
||||
if ((long)jd_samplesperrow != samplesperrow)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
|
||||
/* For now, precision must match compiled-in value... */
|
||||
@ -124,8 +124,10 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
cinfo->max_v_samp_factor = 1;
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
|
||||
compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
|
||||
if (compptr->h_samp_factor <= 0 ||
|
||||
compptr->h_samp_factor > MAX_SAMP_FACTOR ||
|
||||
compptr->v_samp_factor <= 0 ||
|
||||
compptr->v_samp_factor > MAX_SAMP_FACTOR)
|
||||
ERREXIT(cinfo, JERR_BAD_SAMPLING);
|
||||
cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
|
||||
compptr->h_samp_factor);
|
||||
@ -146,18 +148,18 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
#endif
|
||||
/* Size in DCT blocks */
|
||||
compptr->width_in_blocks = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
|
||||
(long) (cinfo->max_h_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
|
||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
||||
compptr->height_in_blocks = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
|
||||
(long) (cinfo->max_v_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
/* Size in samples */
|
||||
compptr->downsampled_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
|
||||
(long) cinfo->max_h_samp_factor);
|
||||
jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
|
||||
(long)cinfo->max_h_samp_factor);
|
||||
compptr->downsampled_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
|
||||
(long) cinfo->max_v_samp_factor);
|
||||
jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
|
||||
(long)cinfo->max_v_samp_factor);
|
||||
/* Mark component needed (this flag isn't actually used for compression) */
|
||||
compptr->component_needed = TRUE;
|
||||
}
|
||||
@ -166,15 +168,15 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||
* main controller will call coefficient controller).
|
||||
*/
|
||||
cinfo->total_iMCU_rows = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_height,
|
||||
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->_jpeg_height,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
}
|
||||
|
||||
|
||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||
|
||||
LOCAL(void)
|
||||
validate_script (j_compress_ptr cinfo)
|
||||
validate_script(j_compress_ptr cinfo)
|
||||
/* Verify that the scan script in cinfo->scan_info[] is valid; also
|
||||
* determine whether it uses progressive JPEG, and set cinfo->progressive_mode.
|
||||
*/
|
||||
@ -196,10 +198,10 @@ validate_script (j_compress_ptr cinfo)
|
||||
* for progressive JPEG, no scan can have this.
|
||||
*/
|
||||
scanptr = cinfo->scan_info;
|
||||
if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) {
|
||||
if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2 - 1) {
|
||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||
cinfo->progressive_mode = TRUE;
|
||||
last_bitpos_ptr = & last_bitpos[0][0];
|
||||
last_bitpos_ptr = &last_bitpos[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (coefi = 0; coefi < DCTSIZE2; coefi++)
|
||||
*last_bitpos_ptr++ = -1;
|
||||
@ -222,7 +224,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
if (thisi < 0 || thisi >= cinfo->num_components)
|
||||
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
||||
/* Components must appear in SOF order within each scan */
|
||||
if (ci > 0 && thisi <= scanptr->component_index[ci-1])
|
||||
if (ci > 0 && thisi <= scanptr->component_index[ci - 1])
|
||||
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
||||
}
|
||||
/* Validate progression parameters */
|
||||
@ -232,9 +234,9 @@ validate_script (j_compress_ptr cinfo)
|
||||
Al = scanptr->Al;
|
||||
if (cinfo->progressive_mode) {
|
||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||
/* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that
|
||||
* seems wrong: the upper bound ought to depend on data precision.
|
||||
* Perhaps they really meant 0..N+1 for N-bit precision.
|
||||
/* Rec. ITU-T T.81 | ISO/IEC 10918-1 simply gives the ranges 0..13 for Ah
|
||||
* and Al, but that seems wrong: the upper bound ought to depend on data
|
||||
* precision. Perhaps they really meant 0..N+1 for N-bit precision.
|
||||
* Here we allow 0..10 for 8-bit data; Al larger than 10 results in
|
||||
* out-of-range reconstructed DC values during the first DC scan,
|
||||
* which might cause problems for some decoders.
|
||||
@ -255,7 +257,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
}
|
||||
for (ci = 0; ci < ncomps; ci++) {
|
||||
last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0];
|
||||
last_bitpos_ptr = &last_bitpos[scanptr->component_index[ci]][0];
|
||||
if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
for (coefi = Ss; coefi <= Se; coefi++) {
|
||||
@ -265,7 +267,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
} else {
|
||||
/* not first scan */
|
||||
if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1)
|
||||
if (Ah != last_bitpos_ptr[coefi] || Al != Ah - 1)
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
}
|
||||
last_bitpos_ptr[coefi] = Al;
|
||||
@ -274,7 +276,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
#endif
|
||||
} else {
|
||||
/* For sequential JPEG, all progression parameters must be these: */
|
||||
if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0)
|
||||
if (Ss != 0 || Se != DCTSIZE2 - 1 || Ah != 0 || Al != 0)
|
||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||
/* Make sure components are not sent twice */
|
||||
for (ci = 0; ci < ncomps; ci++) {
|
||||
@ -301,7 +303,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
#endif
|
||||
} else {
|
||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||
if (! component_sent[ci])
|
||||
if (!component_sent[ci])
|
||||
ERREXIT(cinfo, JERR_MISSING_DATA);
|
||||
}
|
||||
}
|
||||
@ -311,7 +313,7 @@ validate_script (j_compress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
select_scan_parameters (j_compress_ptr cinfo)
|
||||
select_scan_parameters(j_compress_ptr cinfo)
|
||||
/* Set up the scan parameters for the current scan */
|
||||
{
|
||||
int ci;
|
||||
@ -319,7 +321,7 @@ select_scan_parameters (j_compress_ptr cinfo)
|
||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||
if (cinfo->scan_info != NULL) {
|
||||
/* Prepare for current scan --- the script is already validated */
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
|
||||
|
||||
cinfo->comps_in_scan = scanptr->comps_in_scan;
|
||||
@ -331,8 +333,7 @@ select_scan_parameters (j_compress_ptr cinfo)
|
||||
cinfo->Se = scanptr->Se;
|
||||
cinfo->Ah = scanptr->Ah;
|
||||
cinfo->Al = scanptr->Al;
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* Prepare for single sequential-JPEG scan containing all components */
|
||||
@ -344,7 +345,7 @@ select_scan_parameters (j_compress_ptr cinfo)
|
||||
cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
|
||||
}
|
||||
cinfo->Ss = 0;
|
||||
cinfo->Se = DCTSIZE2-1;
|
||||
cinfo->Se = DCTSIZE2 - 1;
|
||||
cinfo->Ah = 0;
|
||||
cinfo->Al = 0;
|
||||
}
|
||||
@ -352,7 +353,7 @@ select_scan_parameters (j_compress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
per_scan_setup (j_compress_ptr cinfo)
|
||||
per_scan_setup(j_compress_ptr cinfo)
|
||||
/* Do computations that are needed before processing a JPEG scan */
|
||||
/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */
|
||||
{
|
||||
@ -377,7 +378,7 @@ per_scan_setup (j_compress_ptr cinfo)
|
||||
/* For noninterleaved scans, it is convenient to define last_row_height
|
||||
* as the number of block rows present in the last iMCU row.
|
||||
*/
|
||||
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
if (tmp == 0) tmp = compptr->v_samp_factor;
|
||||
compptr->last_row_height = tmp;
|
||||
|
||||
@ -394,11 +395,11 @@ per_scan_setup (j_compress_ptr cinfo)
|
||||
|
||||
/* Overall image size in MCUs */
|
||||
cinfo->MCUs_per_row = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_width,
|
||||
(long) (cinfo->max_h_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->_jpeg_width,
|
||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
||||
cinfo->MCU_rows_in_scan = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->_jpeg_height,
|
||||
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->_jpeg_height,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
|
||||
cinfo->blocks_in_MCU = 0;
|
||||
|
||||
@ -410,10 +411,10 @@ per_scan_setup (j_compress_ptr cinfo)
|
||||
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
|
||||
compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE;
|
||||
/* Figure number of non-dummy blocks in last MCU column & row */
|
||||
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
|
||||
tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
|
||||
if (tmp == 0) tmp = compptr->MCU_width;
|
||||
compptr->last_col_width = tmp;
|
||||
tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);
|
||||
tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
|
||||
if (tmp == 0) tmp = compptr->MCU_height;
|
||||
compptr->last_row_height = tmp;
|
||||
/* Prepare array describing MCU composition */
|
||||
@ -430,8 +431,8 @@ per_scan_setup (j_compress_ptr cinfo)
|
||||
/* Convert restart specified in rows to actual MCU count. */
|
||||
/* Note that count must fit in 16 bits, so we provide limiting. */
|
||||
if (cinfo->restart_in_rows > 0) {
|
||||
long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row;
|
||||
cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L);
|
||||
long nominal = (long)cinfo->restart_in_rows * (long)cinfo->MCUs_per_row;
|
||||
cinfo->restart_interval = (unsigned int)MIN(nominal, 65535L);
|
||||
}
|
||||
}
|
||||
|
||||
@ -445,9 +446,9 @@ per_scan_setup (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
prepare_for_pass (j_compress_ptr cinfo)
|
||||
prepare_for_pass(j_compress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
switch (master->pass_type) {
|
||||
case main_pass:
|
||||
@ -456,7 +457,7 @@ prepare_for_pass (j_compress_ptr cinfo)
|
||||
*/
|
||||
select_scan_parameters(cinfo);
|
||||
per_scan_setup(cinfo);
|
||||
if (! cinfo->raw_data_in) {
|
||||
if (!cinfo->raw_data_in) {
|
||||
(*cinfo->cconvert->start_pass) (cinfo);
|
||||
(*cinfo->downsample->start_pass) (cinfo);
|
||||
(*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
|
||||
@ -496,7 +497,7 @@ prepare_for_pass (j_compress_ptr cinfo)
|
||||
case output_pass:
|
||||
/* Do a data-output pass. */
|
||||
/* We need not repeat per-scan setup if prior optimization pass did it. */
|
||||
if (! cinfo->optimize_coding) {
|
||||
if (!cinfo->optimize_coding) {
|
||||
select_scan_parameters(cinfo);
|
||||
per_scan_setup(cinfo);
|
||||
}
|
||||
@ -512,7 +513,7 @@ prepare_for_pass (j_compress_ptr cinfo)
|
||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||
}
|
||||
|
||||
master->pub.is_last_pass = (master->pass_number == master->total_passes-1);
|
||||
master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
|
||||
|
||||
/* Set up progress monitor's pass info if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
@ -533,7 +534,7 @@ prepare_for_pass (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
pass_startup (j_compress_ptr cinfo)
|
||||
pass_startup(j_compress_ptr cinfo)
|
||||
{
|
||||
cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */
|
||||
|
||||
@ -547,9 +548,9 @@ pass_startup (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_master (j_compress_ptr cinfo)
|
||||
finish_pass_master(j_compress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
/* The entropy coder always needs an end-of-pass call,
|
||||
* either to analyze statistics or to flush its output buffer.
|
||||
@ -563,7 +564,7 @@ finish_pass_master (j_compress_ptr cinfo)
|
||||
* or output of scan 1 (if no optimization).
|
||||
*/
|
||||
master->pass_type = output_pass;
|
||||
if (! cinfo->optimize_coding)
|
||||
if (!cinfo->optimize_coding)
|
||||
master->scan_number++;
|
||||
break;
|
||||
case huff_opt_pass:
|
||||
@ -587,14 +588,14 @@ finish_pass_master (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
||||
jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
|
||||
{
|
||||
my_master_ptr master;
|
||||
|
||||
master = (my_master_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_comp_master));
|
||||
cinfo->master = (struct jpeg_comp_master *) master;
|
||||
cinfo->master = (struct jpeg_comp_master *)master;
|
||||
master->pub.prepare_for_pass = prepare_for_pass;
|
||||
master->pub.pass_startup = pass_startup;
|
||||
master->pub.finish_pass = finish_pass_master;
|
||||
|
12
3rdparty/libjpeg-turbo/src/jcomapi.c
vendored
12
3rdparty/libjpeg-turbo/src/jcomapi.c
vendored
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_abort (j_common_ptr cinfo)
|
||||
jpeg_abort(j_common_ptr cinfo)
|
||||
{
|
||||
int pool;
|
||||
|
||||
@ -40,7 +40,7 @@ jpeg_abort (j_common_ptr cinfo)
|
||||
/* Releasing pools in reverse order might help avoid fragmentation
|
||||
* with some (brain-damaged) malloc libraries.
|
||||
*/
|
||||
for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {
|
||||
for (pool = JPOOL_NUMPOOLS - 1; pool > JPOOL_PERMANENT; pool--) {
|
||||
(*cinfo->mem->free_pool) (cinfo, pool);
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ jpeg_abort (j_common_ptr cinfo)
|
||||
/* Try to keep application from accessing now-deleted marker list.
|
||||
* A bit kludgy to do it here, but this is the most central place.
|
||||
*/
|
||||
((j_decompress_ptr) cinfo)->marker_list = NULL;
|
||||
((j_decompress_ptr)cinfo)->marker_list = NULL;
|
||||
} else {
|
||||
cinfo->global_state = CSTATE_START;
|
||||
}
|
||||
@ -69,7 +69,7 @@ jpeg_abort (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_destroy (j_common_ptr cinfo)
|
||||
jpeg_destroy(j_common_ptr cinfo)
|
||||
{
|
||||
/* We need only tell the memory manager to release everything. */
|
||||
/* NB: mem pointer is NULL if memory mgr failed to initialize. */
|
||||
@ -86,7 +86,7 @@ jpeg_destroy (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(JQUANT_TBL *)
|
||||
jpeg_alloc_quant_table (j_common_ptr cinfo)
|
||||
jpeg_alloc_quant_table(j_common_ptr cinfo)
|
||||
{
|
||||
JQUANT_TBL *tbl;
|
||||
|
||||
@ -98,7 +98,7 @@ jpeg_alloc_quant_table (j_common_ptr cinfo)
|
||||
|
||||
|
||||
GLOBAL(JHUFF_TBL *)
|
||||
jpeg_alloc_huff_table (j_common_ptr cinfo)
|
||||
jpeg_alloc_huff_table(j_common_ptr cinfo)
|
||||
{
|
||||
JHUFF_TBL *tbl;
|
||||
|
||||
|
85
3rdparty/libjpeg-turbo/src/jcparam.c
vendored
85
3rdparty/libjpeg-turbo/src/jcparam.c
vendored
@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2003-2008 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009-2011, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@ -25,9 +25,9 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||
const unsigned int *basic_table,
|
||||
int scale_factor, boolean force_baseline)
|
||||
jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
|
||||
const unsigned int *basic_table, int scale_factor,
|
||||
boolean force_baseline)
|
||||
/* Define a quantization table equal to the basic_table times
|
||||
* a scale factor (given as a percentage).
|
||||
* If force_baseline is TRUE, the computed quantization table entries
|
||||
@ -45,19 +45,19 @@ jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||
if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS)
|
||||
ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl);
|
||||
|
||||
qtblptr = & cinfo->quant_tbl_ptrs[which_tbl];
|
||||
qtblptr = &cinfo->quant_tbl_ptrs[which_tbl];
|
||||
|
||||
if (*qtblptr == NULL)
|
||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo);
|
||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr)cinfo);
|
||||
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
temp = ((long) basic_table[i] * scale_factor + 50L) / 100L;
|
||||
temp = ((long)basic_table[i] * scale_factor + 50L) / 100L;
|
||||
/* limit the values to the valid range */
|
||||
if (temp <= 0L) temp = 1L;
|
||||
if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */
|
||||
if (force_baseline && temp > 255L)
|
||||
temp = 255L; /* limit to baseline range if requested */
|
||||
(*qtblptr)->quantval[i] = (UINT16) temp;
|
||||
(*qtblptr)->quantval[i] = (UINT16)temp;
|
||||
}
|
||||
|
||||
/* Initialize sent_table FALSE so table will be written to JPEG file. */
|
||||
@ -65,7 +65,8 @@ jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||
}
|
||||
|
||||
|
||||
/* These are the sample quantization tables given in JPEG spec section K.1.
|
||||
/* These are the sample quantization tables given in Annex K (Clause K.1) of
|
||||
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||
* The spec says that the values given produce "good" quality, and
|
||||
* when divided by 2, "very good" quality.
|
||||
*/
|
||||
@ -93,7 +94,7 @@ static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
|
||||
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
GLOBAL(void)
|
||||
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
|
||||
jpeg_default_qtables(j_compress_ptr cinfo, boolean force_baseline)
|
||||
/* Set or change the 'quality' (quantization) setting, using default tables
|
||||
* and straight percentage-scaling quality scales.
|
||||
* This entry point allows different scalings for luminance and chrominance.
|
||||
@ -109,7 +110,7 @@ jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||
jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor,
|
||||
boolean force_baseline)
|
||||
/* Set or change the 'quality' (quantization) setting, using default tables
|
||||
* and a straight percentage-scaling quality scale. In most cases it's better
|
||||
@ -126,7 +127,7 @@ jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||
|
||||
|
||||
GLOBAL(int)
|
||||
jpeg_quality_scaling (int quality)
|
||||
jpeg_quality_scaling(int quality)
|
||||
/* Convert a user-specified quality rating to a percentage scaling factor
|
||||
* for an underlying quantization table, using our recommended scaling curve.
|
||||
* The input 'quality' factor should be 0 (terrible) to 100 (very good).
|
||||
@ -145,14 +146,14 @@ jpeg_quality_scaling (int quality)
|
||||
if (quality < 50)
|
||||
quality = 5000 / quality;
|
||||
else
|
||||
quality = 200 - quality*2;
|
||||
quality = 200 - quality * 2;
|
||||
|
||||
return quality;
|
||||
}
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
|
||||
jpeg_set_quality(j_compress_ptr cinfo, int quality, boolean force_baseline)
|
||||
/* Set or change the 'quality' (quantization) setting, using default tables.
|
||||
* This is the standard quality-adjusting entry point for typical user
|
||||
* interfaces; only those who want detailed control over quantization tables
|
||||
@ -178,7 +179,7 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
jpeg_set_defaults(j_compress_ptr cinfo)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -192,7 +193,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
*/
|
||||
if (cinfo->comp_info == NULL)
|
||||
cinfo->comp_info = (jpeg_component_info *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
MAX_COMPONENTS * sizeof(jpeg_component_info));
|
||||
|
||||
/* Initialize everything not dependent on the color space */
|
||||
@ -205,7 +206,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
/* Set up two quantization tables using default quality of 75 */
|
||||
jpeg_set_quality(cinfo, 75, TRUE);
|
||||
/* Set up two Huffman tables */
|
||||
std_huff_tables((j_common_ptr) cinfo);
|
||||
std_huff_tables((j_common_ptr)cinfo);
|
||||
|
||||
/* Initialize default arithmetic coding conditioning */
|
||||
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
||||
@ -278,7 +279,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_default_colorspace (j_compress_ptr cinfo)
|
||||
jpeg_default_colorspace(j_compress_ptr cinfo)
|
||||
{
|
||||
switch (cinfo->in_color_space) {
|
||||
case JCS_GRAYSCALE:
|
||||
@ -320,12 +321,12 @@ jpeg_default_colorspace (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
jpeg_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
{
|
||||
jpeg_component_info *compptr;
|
||||
int ci;
|
||||
|
||||
#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \
|
||||
#define SET_COMP(index, id, hsamp, vsamp, quant, dctbl, actbl) \
|
||||
(compptr = &cinfo->comp_info[index], \
|
||||
compptr->component_id = (id), \
|
||||
compptr->h_samp_factor = (hsamp), \
|
||||
@ -352,39 +353,39 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||
cinfo->num_components = 1;
|
||||
/* JFIF specifies component ID 1 */
|
||||
SET_COMP(0, 1, 1,1, 0, 0,0);
|
||||
SET_COMP(0, 1, 1, 1, 0, 0, 0);
|
||||
break;
|
||||
case JCS_RGB:
|
||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
|
||||
cinfo->num_components = 3;
|
||||
SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0);
|
||||
SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0);
|
||||
SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0);
|
||||
SET_COMP(0, 0x52 /* 'R' */, 1, 1, 0, 0, 0);
|
||||
SET_COMP(1, 0x47 /* 'G' */, 1, 1, 0, 0, 0);
|
||||
SET_COMP(2, 0x42 /* 'B' */, 1, 1, 0, 0, 0);
|
||||
break;
|
||||
case JCS_YCbCr:
|
||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||
cinfo->num_components = 3;
|
||||
/* JFIF specifies component IDs 1,2,3 */
|
||||
/* We default to 2x2 subsamples of chrominance */
|
||||
SET_COMP(0, 1, 2,2, 0, 0,0);
|
||||
SET_COMP(1, 2, 1,1, 1, 1,1);
|
||||
SET_COMP(2, 3, 1,1, 1, 1,1);
|
||||
SET_COMP(0, 1, 2, 2, 0, 0, 0);
|
||||
SET_COMP(1, 2, 1, 1, 1, 1, 1);
|
||||
SET_COMP(2, 3, 1, 1, 1, 1, 1);
|
||||
break;
|
||||
case JCS_CMYK:
|
||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
|
||||
cinfo->num_components = 4;
|
||||
SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0);
|
||||
SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0);
|
||||
SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0);
|
||||
SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0);
|
||||
SET_COMP(0, 0x43 /* 'C' */, 1, 1, 0, 0, 0);
|
||||
SET_COMP(1, 0x4D /* 'M' */, 1, 1, 0, 0, 0);
|
||||
SET_COMP(2, 0x59 /* 'Y' */, 1, 1, 0, 0, 0);
|
||||
SET_COMP(3, 0x4B /* 'K' */, 1, 1, 0, 0, 0);
|
||||
break;
|
||||
case JCS_YCCK:
|
||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
|
||||
cinfo->num_components = 4;
|
||||
SET_COMP(0, 1, 2,2, 0, 0,0);
|
||||
SET_COMP(1, 2, 1,1, 1, 1,1);
|
||||
SET_COMP(2, 3, 1,1, 1, 1,1);
|
||||
SET_COMP(3, 4, 2,2, 0, 0,0);
|
||||
SET_COMP(0, 1, 2, 2, 0, 0, 0);
|
||||
SET_COMP(1, 2, 1, 1, 1, 1, 1);
|
||||
SET_COMP(2, 3, 1, 1, 1, 1, 1);
|
||||
SET_COMP(3, 4, 2, 2, 0, 0, 0);
|
||||
break;
|
||||
case JCS_UNKNOWN:
|
||||
cinfo->num_components = cinfo->input_components;
|
||||
@ -392,7 +393,7 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
||||
MAX_COMPONENTS);
|
||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||
SET_COMP(ci, ci, 1,1, 0, 0,0);
|
||||
SET_COMP(ci, ci, 1, 1, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -404,8 +405,7 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||
|
||||
LOCAL(jpeg_scan_info *)
|
||||
fill_a_scan (jpeg_scan_info *scanptr, int ci,
|
||||
int Ss, int Se, int Ah, int Al)
|
||||
fill_a_scan(jpeg_scan_info *scanptr, int ci, int Ss, int Se, int Ah, int Al)
|
||||
/* Support routine: generate one scan for specified component */
|
||||
{
|
||||
scanptr->comps_in_scan = 1;
|
||||
@ -419,8 +419,7 @@ fill_a_scan (jpeg_scan_info *scanptr, int ci,
|
||||
}
|
||||
|
||||
LOCAL(jpeg_scan_info *)
|
||||
fill_scans (jpeg_scan_info *scanptr, int ncomps,
|
||||
int Ss, int Se, int Ah, int Al)
|
||||
fill_scans(jpeg_scan_info *scanptr, int ncomps, int Ss, int Se, int Ah, int Al)
|
||||
/* Support routine: generate one scan for each component */
|
||||
{
|
||||
int ci;
|
||||
@ -438,7 +437,7 @@ fill_scans (jpeg_scan_info *scanptr, int ncomps,
|
||||
}
|
||||
|
||||
LOCAL(jpeg_scan_info *)
|
||||
fill_dc_scans (jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
|
||||
fill_dc_scans(jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
|
||||
/* Support routine: generate interleaved DC scan if possible, else N scans */
|
||||
{
|
||||
int ci;
|
||||
@ -466,7 +465,7 @@ fill_dc_scans (jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_simple_progression (j_compress_ptr cinfo)
|
||||
jpeg_simple_progression(j_compress_ptr cinfo)
|
||||
{
|
||||
int ncomps = cinfo->num_components;
|
||||
int nscans;
|
||||
@ -498,7 +497,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
||||
if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
|
||||
cinfo->script_space_size = MAX(nscans, 10);
|
||||
cinfo->script_space = (jpeg_scan_info *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
cinfo->script_space_size * sizeof(jpeg_scan_info));
|
||||
}
|
||||
scanptr = cinfo->script_space;
|
||||
|
663
3rdparty/libjpeg-turbo/src/jcphuff.c
vendored
663
3rdparty/libjpeg-turbo/src/jcphuff.c
vendored
@ -4,7 +4,8 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* Copyright (C) 2011, 2015, 2018, D. R. Commander.
|
||||
* Copyright (C) 2016, 2018, Matthieu Darbois.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@ -18,15 +19,69 @@
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jchuff.h" /* Declarations shared with jchuff.c */
|
||||
#include "jsimd.h"
|
||||
#include "jconfigint.h"
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef HAVE_INTRIN_H
|
||||
#include <intrin.h>
|
||||
#ifdef _MSC_VER
|
||||
#ifdef HAVE_BITSCANFORWARD64
|
||||
#pragma intrinsic(_BitScanForward64)
|
||||
#endif
|
||||
#ifdef HAVE_BITSCANFORWARD
|
||||
#pragma intrinsic(_BitScanForward)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||
|
||||
/*
|
||||
* NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
|
||||
* used for bit counting rather than the lookup table. This will reduce the
|
||||
* memory footprint by 64k, which is important for some mobile applications
|
||||
* that create many isolated instances of libjpeg-turbo (web browsers, for
|
||||
* instance.) This may improve performance on some mobile platforms as well.
|
||||
* This feature is enabled by default only on ARM processors, because some x86
|
||||
* chips have a slow implementation of bsr, and the use of clz/bsr cannot be
|
||||
* shown to have a significant performance impact even on the x86 chips that
|
||||
* have a fast implementation of it. When building for ARMv6, you can
|
||||
* explicitly disable the use of clz/bsr by adding -mthumb to the compiler
|
||||
* flags (this defines __thumb__).
|
||||
*/
|
||||
|
||||
/* NOTE: Both GCC and Clang define __GNUC__ */
|
||||
#if defined __GNUC__ && (defined __arm__ || defined __aarch64__)
|
||||
#if !defined __thumb__ || defined __thumb2__
|
||||
#define USE_CLZ_INTRINSIC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_CLZ_INTRINSIC
|
||||
#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
|
||||
#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
|
||||
#else
|
||||
#include "jpeg_nbits_table.h"
|
||||
#define JPEG_NBITS(x) (jpeg_nbits_table[x])
|
||||
#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
|
||||
#endif
|
||||
|
||||
|
||||
/* Expanded entropy encoder object for progressive Huffman encoding. */
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_entropy_encoder pub; /* public fields */
|
||||
|
||||
/* Pointer to routine to prepare data for encode_mcu_AC_first() */
|
||||
void (*AC_first_prepare) (const JCOEF *block,
|
||||
const int *jpeg_natural_order_start, int Sl,
|
||||
int Al, JCOEF *values, size_t *zerobits);
|
||||
/* Pointer to routine to prepare data for encode_mcu_AC_refine() */
|
||||
int (*AC_refine_prepare) (const JCOEF *block,
|
||||
const int *jpeg_natural_order_start, int Sl,
|
||||
int Al, JCOEF *absvalues, size_t *bits);
|
||||
|
||||
/* Mode flag: TRUE for optimization, FALSE for actual data output */
|
||||
boolean gather_statistics;
|
||||
|
||||
@ -79,26 +134,60 @@ typedef phuff_entropy_encoder *phuff_entropy_ptr;
|
||||
|
||||
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
||||
#define ISHIFT_TEMPS int ishift_temp;
|
||||
#define IRIGHT_SHIFT(x,shft) \
|
||||
#define IRIGHT_SHIFT(x, shft) \
|
||||
((ishift_temp = (x)) < 0 ? \
|
||||
(ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
|
||||
(ishift_temp >> (shft)) | ((~0) << (16 - (shft))) : \
|
||||
(ishift_temp >> (shft)))
|
||||
#else
|
||||
#define ISHIFT_TEMPS
|
||||
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||
#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
|
||||
#endif
|
||||
|
||||
#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) encode_mcu_DC_first (j_compress_ptr cinfo,
|
||||
METHODDEF(boolean) encode_mcu_DC_first(j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) encode_mcu_AC_first (j_compress_ptr cinfo,
|
||||
METHODDEF(void) encode_mcu_AC_first_prepare
|
||||
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
|
||||
JCOEF *values, size_t *zerobits);
|
||||
METHODDEF(boolean) encode_mcu_AC_first(j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) encode_mcu_DC_refine (j_compress_ptr cinfo,
|
||||
METHODDEF(boolean) encode_mcu_DC_refine(j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) encode_mcu_AC_refine (j_compress_ptr cinfo,
|
||||
METHODDEF(int) encode_mcu_AC_refine_prepare
|
||||
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
|
||||
JCOEF *absvalues, size_t *bits);
|
||||
METHODDEF(boolean) encode_mcu_AC_refine(j_compress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(void) finish_pass_phuff (j_compress_ptr cinfo);
|
||||
METHODDEF(void) finish_pass_gather_phuff (j_compress_ptr cinfo);
|
||||
METHODDEF(void) finish_pass_phuff(j_compress_ptr cinfo);
|
||||
METHODDEF(void) finish_pass_gather_phuff(j_compress_ptr cinfo);
|
||||
|
||||
|
||||
/* Count bit loop zeroes */
|
||||
INLINE
|
||||
METHODDEF(int)
|
||||
count_zeroes(size_t *x)
|
||||
{
|
||||
int result;
|
||||
#if defined(HAVE_BUILTIN_CTZL)
|
||||
result = __builtin_ctzl(*x);
|
||||
*x >>= result;
|
||||
#elif defined(HAVE_BITSCANFORWARD64)
|
||||
_BitScanForward64(&result, *x);
|
||||
*x >>= result;
|
||||
#elif defined(HAVE_BITSCANFORWARD)
|
||||
_BitScanForward(&result, *x);
|
||||
*x >>= result;
|
||||
#else
|
||||
result = 0;
|
||||
while ((*x & 1) == 0) {
|
||||
++result;
|
||||
*x >>= 1;
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -106,9 +195,9 @@ METHODDEF(void) finish_pass_gather_phuff (j_compress_ptr cinfo);
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
boolean is_DC_band;
|
||||
int ci, tbl;
|
||||
jpeg_component_info *compptr;
|
||||
@ -126,15 +215,23 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
entropy->pub.encode_mcu = encode_mcu_DC_first;
|
||||
else
|
||||
entropy->pub.encode_mcu = encode_mcu_AC_first;
|
||||
if (jsimd_can_encode_mcu_AC_first_prepare())
|
||||
entropy->AC_first_prepare = jsimd_encode_mcu_AC_first_prepare;
|
||||
else
|
||||
entropy->AC_first_prepare = encode_mcu_AC_first_prepare;
|
||||
} else {
|
||||
if (is_DC_band)
|
||||
entropy->pub.encode_mcu = encode_mcu_DC_refine;
|
||||
else {
|
||||
entropy->pub.encode_mcu = encode_mcu_AC_refine;
|
||||
if (jsimd_can_encode_mcu_AC_refine_prepare())
|
||||
entropy->AC_refine_prepare = jsimd_encode_mcu_AC_refine_prepare;
|
||||
else
|
||||
entropy->AC_refine_prepare = encode_mcu_AC_refine_prepare;
|
||||
/* AC refinement needs a correction bit buffer */
|
||||
if (entropy->bit_buffer == NULL)
|
||||
entropy->bit_buffer = (char *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
MAX_CORR_BITS * sizeof(char));
|
||||
}
|
||||
}
|
||||
@ -167,14 +264,14 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
/* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
|
||||
if (entropy->count_ptrs[tbl] == NULL)
|
||||
entropy->count_ptrs[tbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
257 * sizeof(long));
|
||||
MEMZERO(entropy->count_ptrs[tbl], 257 * sizeof(long));
|
||||
} else {
|
||||
/* Compute derived values for Huffman table */
|
||||
/* We may do this more than once for a table, but it's not expensive */
|
||||
jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl,
|
||||
& entropy->derived_tbls[tbl]);
|
||||
&entropy->derived_tbls[tbl]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,19 +295,20 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
*/
|
||||
|
||||
/* Emit a byte */
|
||||
#define emit_byte(entropy,val) \
|
||||
{ *(entropy)->next_output_byte++ = (JOCTET) (val); \
|
||||
#define emit_byte(entropy, val) { \
|
||||
*(entropy)->next_output_byte++ = (JOCTET)(val); \
|
||||
if (--(entropy)->free_in_buffer == 0) \
|
||||
dump_buffer(entropy); }
|
||||
dump_buffer(entropy); \
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
dump_buffer (phuff_entropy_ptr entropy)
|
||||
dump_buffer(phuff_entropy_ptr entropy)
|
||||
/* Empty the output buffer; we do not support suspension in this module. */
|
||||
{
|
||||
struct jpeg_destination_mgr *dest = entropy->cinfo->dest;
|
||||
|
||||
if (! (*dest->empty_output_buffer) (entropy->cinfo))
|
||||
if (!(*dest->empty_output_buffer) (entropy->cinfo))
|
||||
ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
|
||||
/* After a successful buffer dump, must reset buffer pointers */
|
||||
entropy->next_output_byte = dest->next_output_byte;
|
||||
@ -227,11 +325,11 @@ dump_buffer (phuff_entropy_ptr entropy)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||
emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||
/* Emit some bits, unless we are in gather mode */
|
||||
{
|
||||
/* This routine is heavily used, so it's worth coding tightly. */
|
||||
register size_t put_buffer = (size_t) code;
|
||||
register size_t put_buffer = (size_t)code;
|
||||
register int put_bits = entropy->put_bits;
|
||||
|
||||
/* if size is 0, caller used an invalid Huffman table entry */
|
||||
@ -241,7 +339,7 @@ emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||
if (entropy->gather_statistics)
|
||||
return; /* do nothing if we're only getting stats */
|
||||
|
||||
put_buffer &= (((size_t) 1)<<size) - 1; /* mask off any extra bits in code */
|
||||
put_buffer &= (((size_t)1) << size) - 1; /* mask off any extra bits in code */
|
||||
|
||||
put_bits += size; /* new number of bits in buffer */
|
||||
|
||||
@ -250,7 +348,7 @@ emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||
put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */
|
||||
|
||||
while (put_bits >= 8) {
|
||||
int c = (int) ((put_buffer >> 16) & 0xFF);
|
||||
int c = (int)((put_buffer >> 16) & 0xFF);
|
||||
|
||||
emit_byte(entropy, c);
|
||||
if (c == 0xFF) { /* need to stuff a zero byte? */
|
||||
@ -266,7 +364,7 @@ emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
flush_bits (phuff_entropy_ptr entropy)
|
||||
flush_bits(phuff_entropy_ptr entropy)
|
||||
{
|
||||
emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */
|
||||
entropy->put_buffer = 0; /* and reset bit-buffer to empty */
|
||||
@ -279,7 +377,7 @@ flush_bits (phuff_entropy_ptr entropy)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol)
|
||||
emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol)
|
||||
{
|
||||
if (entropy->gather_statistics)
|
||||
entropy->count_ptrs[tbl_no][symbol]++;
|
||||
@ -295,14 +393,14 @@ emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_buffered_bits (phuff_entropy_ptr entropy, char *bufstart,
|
||||
emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart,
|
||||
unsigned int nbits)
|
||||
{
|
||||
if (entropy->gather_statistics)
|
||||
return; /* no real work */
|
||||
|
||||
while (nbits > 0) {
|
||||
emit_bits(entropy, (unsigned int) (*bufstart), 1);
|
||||
emit_bits(entropy, (unsigned int)(*bufstart), 1);
|
||||
bufstart++;
|
||||
nbits--;
|
||||
}
|
||||
@ -314,15 +412,13 @@ emit_buffered_bits (phuff_entropy_ptr entropy, char *bufstart,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_eobrun (phuff_entropy_ptr entropy)
|
||||
emit_eobrun(phuff_entropy_ptr entropy)
|
||||
{
|
||||
register int temp, nbits;
|
||||
|
||||
if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */
|
||||
temp = entropy->EOBRUN;
|
||||
nbits = 0;
|
||||
while ((temp >>= 1))
|
||||
nbits++;
|
||||
nbits = JPEG_NBITS_NONZERO(temp) - 1;
|
||||
/* safety check: shouldn't happen given limited correction-bit buffer */
|
||||
if (nbits > 14)
|
||||
ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
|
||||
@ -345,13 +441,13 @@ emit_eobrun (phuff_entropy_ptr entropy)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
emit_restart (phuff_entropy_ptr entropy, int restart_num)
|
||||
emit_restart(phuff_entropy_ptr entropy, int restart_num)
|
||||
{
|
||||
int ci;
|
||||
|
||||
emit_eobrun(entropy);
|
||||
|
||||
if (! entropy->gather_statistics) {
|
||||
if (!entropy->gather_statistics) {
|
||||
flush_bits(entropy);
|
||||
emit_byte(entropy, 0xFF);
|
||||
emit_byte(entropy, JPEG_RST0 + restart_num);
|
||||
@ -375,10 +471,10 @@ emit_restart (phuff_entropy_ptr entropy, int restart_num)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
register int temp, temp2;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
register int temp, temp2, temp3;
|
||||
register int nbits;
|
||||
int blkn, ci;
|
||||
int Al = cinfo->Al;
|
||||
@ -403,31 +499,31 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Compute the DC value after the required point transform by Al.
|
||||
* This is simply an arithmetic right shift.
|
||||
*/
|
||||
temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al);
|
||||
temp2 = IRIGHT_SHIFT((int)((*block)[0]), Al);
|
||||
|
||||
/* DC differences are figured on the point-transformed values. */
|
||||
temp = temp2 - entropy->last_dc_val[ci];
|
||||
entropy->last_dc_val[ci] = temp2;
|
||||
|
||||
/* Encode the DC coefficient difference per section G.1.2.1 */
|
||||
temp2 = temp;
|
||||
if (temp < 0) {
|
||||
temp = -temp; /* temp is abs value of input */
|
||||
|
||||
/* This is a well-known technique for obtaining the absolute value without
|
||||
* a branch. It is derived from an assembly language technique presented
|
||||
* in "How to Optimize for the Pentium Processors", Copyright (c) 1996,
|
||||
* 1997 by Agner Fog.
|
||||
*/
|
||||
temp3 = temp >> (CHAR_BIT * sizeof(int) - 1);
|
||||
temp ^= temp3;
|
||||
temp -= temp3; /* temp is abs value of input */
|
||||
/* For a negative input, want temp2 = bitwise complement of abs(input) */
|
||||
/* This code assumes we are on a two's complement machine */
|
||||
temp2--;
|
||||
}
|
||||
temp2 = temp ^ temp3;
|
||||
|
||||
/* Find the number of bits needed for the magnitude of the coefficient */
|
||||
nbits = 0;
|
||||
while (temp) {
|
||||
nbits++;
|
||||
temp >>= 1;
|
||||
}
|
||||
nbits = JPEG_NBITS(temp);
|
||||
/* Check for out-of-range coefficient values.
|
||||
* Since we're encoding a difference, the range limit is twice as much.
|
||||
*/
|
||||
if (nbits > MAX_COEF_BITS+1)
|
||||
if (nbits > MAX_COEF_BITS + 1)
|
||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||
|
||||
/* Count/emit the Huffman-coded symbol for the number of bits */
|
||||
@ -436,7 +532,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Emit that number of bits of the value, if positive, */
|
||||
/* or the complement of its magnitude, if negative. */
|
||||
if (nbits) /* emit_bits rejects calls with size 0 */
|
||||
emit_bits(entropy, (unsigned int) temp2, nbits);
|
||||
emit_bits(entropy, (unsigned int)temp2, nbits);
|
||||
}
|
||||
|
||||
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
||||
@ -456,21 +552,116 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Data preparation for encode_mcu_AC_first().
|
||||
*/
|
||||
|
||||
#define COMPUTE_ABSVALUES_AC_FIRST(Sl) { \
|
||||
for (k = 0; k < Sl; k++) { \
|
||||
temp = block[jpeg_natural_order_start[k]]; \
|
||||
if (temp == 0) \
|
||||
continue; \
|
||||
/* We must apply the point transform by Al. For AC coefficients this \
|
||||
* is an integer division with rounding towards 0. To do this portably \
|
||||
* in C, we shift after obtaining the absolute value; so the code is \
|
||||
* interwoven with finding the abs value (temp) and output bits (temp2). \
|
||||
*/ \
|
||||
temp2 = temp >> (CHAR_BIT * sizeof(int) - 1); \
|
||||
temp ^= temp2; \
|
||||
temp -= temp2; /* temp is abs value of input */ \
|
||||
temp >>= Al; /* apply the point transform */ \
|
||||
/* Watch out for case that nonzero coef is zero after point transform */ \
|
||||
if (temp == 0) \
|
||||
continue; \
|
||||
/* For a negative coef, want temp2 = bitwise complement of abs(coef) */ \
|
||||
temp2 ^= temp; \
|
||||
values[k] = temp; \
|
||||
values[k + DCTSIZE2] = temp2; \
|
||||
zerobits |= ((size_t)1U) << k; \
|
||||
} \
|
||||
}
|
||||
|
||||
METHODDEF(void)
|
||||
encode_mcu_AC_first_prepare(const JCOEF *block,
|
||||
const int *jpeg_natural_order_start, int Sl,
|
||||
int Al, JCOEF *values, size_t *bits)
|
||||
{
|
||||
register int k, temp, temp2;
|
||||
size_t zerobits = 0U;
|
||||
int Sl0 = Sl;
|
||||
|
||||
#if SIZEOF_SIZE_T == 4
|
||||
if (Sl0 > 32)
|
||||
Sl0 = 32;
|
||||
#endif
|
||||
|
||||
COMPUTE_ABSVALUES_AC_FIRST(Sl0);
|
||||
|
||||
bits[0] = zerobits;
|
||||
#if SIZEOF_SIZE_T == 4
|
||||
zerobits = 0U;
|
||||
|
||||
if (Sl > 32) {
|
||||
Sl -= 32;
|
||||
jpeg_natural_order_start += 32;
|
||||
values += 32;
|
||||
|
||||
COMPUTE_ABSVALUES_AC_FIRST(Sl);
|
||||
}
|
||||
bits[1] = zerobits;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* MCU encoding for AC initial scan (either spectral selection,
|
||||
* or first pass of successive approximation).
|
||||
*/
|
||||
|
||||
#define ENCODE_COEFS_AC_FIRST(label) { \
|
||||
while (zerobits) { \
|
||||
r = count_zeroes(&zerobits); \
|
||||
cvalue += r; \
|
||||
label \
|
||||
temp = cvalue[0]; \
|
||||
temp2 = cvalue[DCTSIZE2]; \
|
||||
\
|
||||
/* if run length > 15, must emit special run-length-16 codes (0xF0) */ \
|
||||
while (r > 15) { \
|
||||
emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
|
||||
r -= 16; \
|
||||
} \
|
||||
\
|
||||
/* Find the number of bits needed for the magnitude of the coefficient */ \
|
||||
nbits = JPEG_NBITS_NONZERO(temp); /* there must be at least one 1 bit */ \
|
||||
/* Check for out-of-range coefficient values */ \
|
||||
if (nbits > MAX_COEF_BITS) \
|
||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF); \
|
||||
\
|
||||
/* Count/emit Huffman symbol for run length / number of bits */ \
|
||||
emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); \
|
||||
\
|
||||
/* Emit that number of bits of the value, if positive, */ \
|
||||
/* or the complement of its magnitude, if negative. */ \
|
||||
emit_bits(entropy, (unsigned int)temp2, nbits); \
|
||||
\
|
||||
cvalue++; \
|
||||
zerobits >>= 1; \
|
||||
} \
|
||||
}
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
register int temp, temp2;
|
||||
register int nbits;
|
||||
register int r, k;
|
||||
int Se = cinfo->Se;
|
||||
register int nbits, r;
|
||||
int Sl = cinfo->Se - cinfo->Ss + 1;
|
||||
int Al = cinfo->Al;
|
||||
JBLOCKROW block;
|
||||
JCOEF values_unaligned[2 * DCTSIZE2 + 15];
|
||||
JCOEF *values;
|
||||
const JCOEF *cvalue;
|
||||
size_t zerobits;
|
||||
size_t bits[8 / SIZEOF_SIZE_T];
|
||||
|
||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||
@ -480,66 +671,48 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (entropy->restarts_to_go == 0)
|
||||
emit_restart(entropy, entropy->next_restart_num);
|
||||
|
||||
/* Encode the MCU data block */
|
||||
block = MCU_data[0];
|
||||
#ifdef WITH_SIMD
|
||||
cvalue = values = (JCOEF *)PAD((size_t)values_unaligned, 16);
|
||||
#else
|
||||
/* Not using SIMD, so alignment is not needed */
|
||||
cvalue = values = values_unaligned;
|
||||
#endif
|
||||
|
||||
/* Prepare data */
|
||||
entropy->AC_first_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss,
|
||||
Sl, Al, values, bits);
|
||||
|
||||
zerobits = bits[0];
|
||||
#if SIZEOF_SIZE_T == 4
|
||||
zerobits |= bits[1];
|
||||
#endif
|
||||
|
||||
/* Emit any pending EOBRUN */
|
||||
if (zerobits && (entropy->EOBRUN > 0))
|
||||
emit_eobrun(entropy);
|
||||
|
||||
#if SIZEOF_SIZE_T == 4
|
||||
zerobits = bits[0];
|
||||
#endif
|
||||
|
||||
/* Encode the AC coefficients per section G.1.2.2, fig. G.3 */
|
||||
|
||||
r = 0; /* r = run length of zeros */
|
||||
ENCODE_COEFS_AC_FIRST((void)0;);
|
||||
|
||||
for (k = cinfo->Ss; k <= Se; k++) {
|
||||
if ((temp = (*block)[jpeg_natural_order[k]]) == 0) {
|
||||
r++;
|
||||
continue;
|
||||
}
|
||||
/* We must apply the point transform by Al. For AC coefficients this
|
||||
* is an integer division with rounding towards 0. To do this portably
|
||||
* in C, we shift after obtaining the absolute value; so the code is
|
||||
* interwoven with finding the abs value (temp) and output bits (temp2).
|
||||
*/
|
||||
if (temp < 0) {
|
||||
temp = -temp; /* temp is abs value of input */
|
||||
temp >>= Al; /* apply the point transform */
|
||||
/* For a negative coef, want temp2 = bitwise complement of abs(coef) */
|
||||
temp2 = ~temp;
|
||||
} else {
|
||||
temp >>= Al; /* apply the point transform */
|
||||
temp2 = temp;
|
||||
}
|
||||
/* Watch out for case that nonzero coef is zero after point transform */
|
||||
if (temp == 0) {
|
||||
r++;
|
||||
continue;
|
||||
#if SIZEOF_SIZE_T == 4
|
||||
zerobits = bits[1];
|
||||
if (zerobits) {
|
||||
int diff = ((values + DCTSIZE2 / 2) - cvalue);
|
||||
r = count_zeroes(&zerobits);
|
||||
r += diff;
|
||||
cvalue += r;
|
||||
goto first_iter_ac_first;
|
||||
}
|
||||
|
||||
/* Emit any pending EOBRUN */
|
||||
if (entropy->EOBRUN > 0)
|
||||
emit_eobrun(entropy);
|
||||
/* if run length > 15, must emit special run-length-16 codes (0xF0) */
|
||||
while (r > 15) {
|
||||
emit_symbol(entropy, entropy->ac_tbl_no, 0xF0);
|
||||
r -= 16;
|
||||
}
|
||||
ENCODE_COEFS_AC_FIRST(first_iter_ac_first:);
|
||||
#endif
|
||||
|
||||
/* Find the number of bits needed for the magnitude of the coefficient */
|
||||
nbits = 1; /* there must be at least one 1 bit */
|
||||
while ((temp >>= 1))
|
||||
nbits++;
|
||||
/* Check for out-of-range coefficient values */
|
||||
if (nbits > MAX_COEF_BITS)
|
||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||
|
||||
/* Count/emit Huffman symbol for run length / number of bits */
|
||||
emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits);
|
||||
|
||||
/* Emit that number of bits of the value, if positive, */
|
||||
/* or the complement of its magnitude, if negative. */
|
||||
emit_bits(entropy, (unsigned int) temp2, nbits);
|
||||
|
||||
r = 0; /* reset zero run length */
|
||||
}
|
||||
|
||||
if (r > 0) { /* If there are trailing zeroes, */
|
||||
if (cvalue < (values + Sl)) { /* If there are trailing zeroes, */
|
||||
entropy->EOBRUN++; /* count an EOB */
|
||||
if (entropy->EOBRUN == 0x7FFF)
|
||||
emit_eobrun(entropy); /* force it out to avoid overflow */
|
||||
@ -569,9 +742,9 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
register int temp;
|
||||
int blkn;
|
||||
int Al = cinfo->Al;
|
||||
@ -591,7 +764,7 @@ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
/* We simply emit the Al'th bit of the DC coefficient value. */
|
||||
temp = (*block)[0];
|
||||
emit_bits(entropy, (unsigned int) (temp >> Al), 1);
|
||||
emit_bits(entropy, (unsigned int)(temp >> Al), 1);
|
||||
}
|
||||
|
||||
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
||||
@ -611,23 +784,149 @@ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Data preparation for encode_mcu_AC_refine().
|
||||
*/
|
||||
|
||||
#define COMPUTE_ABSVALUES_AC_REFINE(Sl, koffset) { \
|
||||
/* It is convenient to make a pre-pass to determine the transformed \
|
||||
* coefficients' absolute values and the EOB position. \
|
||||
*/ \
|
||||
for (k = 0; k < Sl; k++) { \
|
||||
temp = block[jpeg_natural_order_start[k]]; \
|
||||
/* We must apply the point transform by Al. For AC coefficients this \
|
||||
* is an integer division with rounding towards 0. To do this portably \
|
||||
* in C, we shift after obtaining the absolute value. \
|
||||
*/ \
|
||||
temp2 = temp >> (CHAR_BIT * sizeof(int) - 1); \
|
||||
temp ^= temp2; \
|
||||
temp -= temp2; /* temp is abs value of input */ \
|
||||
temp >>= Al; /* apply the point transform */ \
|
||||
if (temp != 0) { \
|
||||
zerobits |= ((size_t)1U) << k; \
|
||||
signbits |= ((size_t)(temp2 + 1)) << k; \
|
||||
} \
|
||||
absvalues[k] = (JCOEF)temp; /* save abs value for main pass */ \
|
||||
if (temp == 1) \
|
||||
EOB = k + koffset; /* EOB = index of last newly-nonzero coef */ \
|
||||
} \
|
||||
}
|
||||
|
||||
METHODDEF(int)
|
||||
encode_mcu_AC_refine_prepare(const JCOEF *block,
|
||||
const int *jpeg_natural_order_start, int Sl,
|
||||
int Al, JCOEF *absvalues, size_t *bits)
|
||||
{
|
||||
register int k, temp, temp2;
|
||||
int EOB = 0;
|
||||
size_t zerobits = 0U, signbits = 0U;
|
||||
int Sl0 = Sl;
|
||||
|
||||
#if SIZEOF_SIZE_T == 4
|
||||
if (Sl0 > 32)
|
||||
Sl0 = 32;
|
||||
#endif
|
||||
|
||||
COMPUTE_ABSVALUES_AC_REFINE(Sl0, 0);
|
||||
|
||||
bits[0] = zerobits;
|
||||
#if SIZEOF_SIZE_T == 8
|
||||
bits[1] = signbits;
|
||||
#else
|
||||
bits[2] = signbits;
|
||||
|
||||
zerobits = 0U;
|
||||
signbits = 0U;
|
||||
|
||||
if (Sl > 32) {
|
||||
Sl -= 32;
|
||||
jpeg_natural_order_start += 32;
|
||||
absvalues += 32;
|
||||
|
||||
COMPUTE_ABSVALUES_AC_REFINE(Sl, 32);
|
||||
}
|
||||
|
||||
bits[1] = zerobits;
|
||||
bits[3] = signbits;
|
||||
#endif
|
||||
|
||||
return EOB;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* MCU encoding for AC successive approximation refinement scan.
|
||||
*/
|
||||
|
||||
#define ENCODE_COEFS_AC_REFINE(label) { \
|
||||
while (zerobits) { \
|
||||
int idx = count_zeroes(&zerobits); \
|
||||
r += idx; \
|
||||
cabsvalue += idx; \
|
||||
signbits >>= idx; \
|
||||
label \
|
||||
/* Emit any required ZRLs, but not if they can be folded into EOB */ \
|
||||
while (r > 15 && (cabsvalue <= EOBPTR)) { \
|
||||
/* emit any pending EOBRUN and the BE correction bits */ \
|
||||
emit_eobrun(entropy); \
|
||||
/* Emit ZRL */ \
|
||||
emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
|
||||
r -= 16; \
|
||||
/* Emit buffered correction bits that must be associated with ZRL */ \
|
||||
emit_buffered_bits(entropy, BR_buffer, BR); \
|
||||
BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
|
||||
BR = 0; \
|
||||
} \
|
||||
\
|
||||
temp = *cabsvalue++; \
|
||||
\
|
||||
/* If the coef was previously nonzero, it only needs a correction bit. \
|
||||
* NOTE: a straight translation of the spec's figure G.7 would suggest \
|
||||
* that we also need to test r > 15. But if r > 15, we can only get here \
|
||||
* if k > EOB, which implies that this coefficient is not 1. \
|
||||
*/ \
|
||||
if (temp > 1) { \
|
||||
/* The correction bit is the next bit of the absolute value. */ \
|
||||
BR_buffer[BR++] = (char)(temp & 1); \
|
||||
signbits >>= 1; \
|
||||
zerobits >>= 1; \
|
||||
continue; \
|
||||
} \
|
||||
\
|
||||
/* Emit any pending EOBRUN and the BE correction bits */ \
|
||||
emit_eobrun(entropy); \
|
||||
\
|
||||
/* Count/emit Huffman symbol for run length / number of bits */ \
|
||||
emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); \
|
||||
\
|
||||
/* Emit output bit for newly-nonzero coef */ \
|
||||
temp = signbits & 1; /* ((*block)[jpeg_natural_order_start[k]] < 0) ? 0 : 1 */ \
|
||||
emit_bits(entropy, (unsigned int)temp, 1); \
|
||||
\
|
||||
/* Emit buffered correction bits that must be associated with this code */ \
|
||||
emit_buffered_bits(entropy, BR_buffer, BR); \
|
||||
BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
|
||||
BR = 0; \
|
||||
r = 0; /* reset zero run length */ \
|
||||
signbits >>= 1; \
|
||||
zerobits >>= 1; \
|
||||
} \
|
||||
}
|
||||
|
||||
METHODDEF(boolean)
|
||||
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
register int temp;
|
||||
register int r, k;
|
||||
int EOB;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
register int temp, r;
|
||||
char *BR_buffer;
|
||||
unsigned int BR;
|
||||
int Se = cinfo->Se;
|
||||
int Sl = cinfo->Se - cinfo->Ss + 1;
|
||||
int Al = cinfo->Al;
|
||||
JBLOCKROW block;
|
||||
int absvalues[DCTSIZE2];
|
||||
JCOEF absvalues_unaligned[DCTSIZE2 + 15];
|
||||
JCOEF *absvalues;
|
||||
const JCOEF *cabsvalue, *EOBPTR;
|
||||
size_t zerobits, signbits;
|
||||
size_t bits[16 / SIZEOF_SIZE_T];
|
||||
|
||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||
@ -637,26 +936,17 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (entropy->restarts_to_go == 0)
|
||||
emit_restart(entropy, entropy->next_restart_num);
|
||||
|
||||
/* Encode the MCU data block */
|
||||
block = MCU_data[0];
|
||||
#ifdef WITH_SIMD
|
||||
cabsvalue = absvalues = (JCOEF *)PAD((size_t)absvalues_unaligned, 16);
|
||||
#else
|
||||
/* Not using SIMD, so alignment is not needed */
|
||||
cabsvalue = absvalues = absvalues_unaligned;
|
||||
#endif
|
||||
|
||||
/* It is convenient to make a pre-pass to determine the transformed
|
||||
* coefficients' absolute values and the EOB position.
|
||||
*/
|
||||
EOB = 0;
|
||||
for (k = cinfo->Ss; k <= Se; k++) {
|
||||
temp = (*block)[jpeg_natural_order[k]];
|
||||
/* We must apply the point transform by Al. For AC coefficients this
|
||||
* is an integer division with rounding towards 0. To do this portably
|
||||
* in C, we shift after obtaining the absolute value.
|
||||
*/
|
||||
if (temp < 0)
|
||||
temp = -temp; /* temp is abs value of input */
|
||||
temp >>= Al; /* apply the point transform */
|
||||
absvalues[k] = temp; /* save abs value for main pass */
|
||||
if (temp == 1)
|
||||
EOB = k; /* EOB = index of last newly-nonzero coef */
|
||||
}
|
||||
/* Prepare data */
|
||||
EOBPTR = absvalues +
|
||||
entropy->AC_refine_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss,
|
||||
Sl, Al, absvalues, bits);
|
||||
|
||||
/* Encode the AC coefficients per section G.1.2.3, fig. G.7 */
|
||||
|
||||
@ -664,52 +954,32 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
BR = 0; /* BR = count of buffered bits added now */
|
||||
BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */
|
||||
|
||||
for (k = cinfo->Ss; k <= Se; k++) {
|
||||
if ((temp = absvalues[k]) == 0) {
|
||||
r++;
|
||||
continue;
|
||||
zerobits = bits[0];
|
||||
#if SIZEOF_SIZE_T == 8
|
||||
signbits = bits[1];
|
||||
#else
|
||||
signbits = bits[2];
|
||||
#endif
|
||||
ENCODE_COEFS_AC_REFINE((void)0;);
|
||||
|
||||
#if SIZEOF_SIZE_T == 4
|
||||
zerobits = bits[1];
|
||||
signbits = bits[3];
|
||||
|
||||
if (zerobits) {
|
||||
int diff = ((absvalues + DCTSIZE2 / 2) - cabsvalue);
|
||||
int idx = count_zeroes(&zerobits);
|
||||
signbits >>= idx;
|
||||
idx += diff;
|
||||
r += idx;
|
||||
cabsvalue += idx;
|
||||
goto first_iter_ac_refine;
|
||||
}
|
||||
|
||||
/* Emit any required ZRLs, but not if they can be folded into EOB */
|
||||
while (r > 15 && k <= EOB) {
|
||||
/* emit any pending EOBRUN and the BE correction bits */
|
||||
emit_eobrun(entropy);
|
||||
/* Emit ZRL */
|
||||
emit_symbol(entropy, entropy->ac_tbl_no, 0xF0);
|
||||
r -= 16;
|
||||
/* Emit buffered correction bits that must be associated with ZRL */
|
||||
emit_buffered_bits(entropy, BR_buffer, BR);
|
||||
BR_buffer = entropy->bit_buffer; /* BE bits are gone now */
|
||||
BR = 0;
|
||||
}
|
||||
ENCODE_COEFS_AC_REFINE(first_iter_ac_refine:);
|
||||
#endif
|
||||
|
||||
/* If the coef was previously nonzero, it only needs a correction bit.
|
||||
* NOTE: a straight translation of the spec's figure G.7 would suggest
|
||||
* that we also need to test r > 15. But if r > 15, we can only get here
|
||||
* if k > EOB, which implies that this coefficient is not 1.
|
||||
*/
|
||||
if (temp > 1) {
|
||||
/* The correction bit is the next bit of the absolute value. */
|
||||
BR_buffer[BR++] = (char) (temp & 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Emit any pending EOBRUN and the BE correction bits */
|
||||
emit_eobrun(entropy);
|
||||
|
||||
/* Count/emit Huffman symbol for run length / number of bits */
|
||||
emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1);
|
||||
|
||||
/* Emit output bit for newly-nonzero coef */
|
||||
temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1;
|
||||
emit_bits(entropy, (unsigned int) temp, 1);
|
||||
|
||||
/* Emit buffered correction bits that must be associated with this code */
|
||||
emit_buffered_bits(entropy, BR_buffer, BR);
|
||||
BR_buffer = entropy->bit_buffer; /* BE bits are gone now */
|
||||
BR = 0;
|
||||
r = 0; /* reset zero run length */
|
||||
}
|
||||
r |= (int)((absvalues + Sl) - cabsvalue);
|
||||
|
||||
if (r > 0 || BR > 0) { /* If there are trailing zeroes, */
|
||||
entropy->EOBRUN++; /* count an EOB */
|
||||
@ -718,7 +988,8 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
* 1. overflow of the EOB counter;
|
||||
* 2. overflow of the correction bit buffer during the next MCU.
|
||||
*/
|
||||
if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1))
|
||||
if (entropy->EOBRUN == 0x7FFF ||
|
||||
entropy->BE > (MAX_CORR_BITS - DCTSIZE2 + 1))
|
||||
emit_eobrun(entropy);
|
||||
}
|
||||
|
||||
@ -744,9 +1015,9 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_phuff (j_compress_ptr cinfo)
|
||||
finish_pass_phuff(j_compress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
|
||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||
@ -765,9 +1036,9 @@ finish_pass_phuff (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_gather_phuff (j_compress_ptr cinfo)
|
||||
finish_pass_gather_phuff(j_compress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
boolean is_DC_band;
|
||||
int ci, tbl;
|
||||
jpeg_component_info *compptr;
|
||||
@ -793,13 +1064,13 @@ finish_pass_gather_phuff (j_compress_ptr cinfo)
|
||||
} else {
|
||||
tbl = compptr->ac_tbl_no;
|
||||
}
|
||||
if (! did[tbl]) {
|
||||
if (!did[tbl]) {
|
||||
if (is_DC_band)
|
||||
htblptr = & cinfo->dc_huff_tbl_ptrs[tbl];
|
||||
htblptr = &cinfo->dc_huff_tbl_ptrs[tbl];
|
||||
else
|
||||
htblptr = & cinfo->ac_huff_tbl_ptrs[tbl];
|
||||
htblptr = &cinfo->ac_huff_tbl_ptrs[tbl];
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
|
||||
jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]);
|
||||
did[tbl] = TRUE;
|
||||
}
|
||||
@ -812,15 +1083,15 @@ finish_pass_gather_phuff (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_phuff_encoder (j_compress_ptr cinfo)
|
||||
jinit_phuff_encoder(j_compress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (phuff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(phuff_entropy_encoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass_phuff;
|
||||
|
||||
/* Mark tables unallocated */
|
||||
|
80
3rdparty/libjpeg-turbo/src/jcprepct.c
vendored
80
3rdparty/libjpeg-turbo/src/jcprepct.c
vendored
@ -78,9 +78,9 @@ typedef my_prep_controller *my_prep_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_prep(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_prep_ptr prep = (my_prep_ptr) cinfo->prep;
|
||||
my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
|
||||
|
||||
if (pass_mode != JBUF_PASS_THRU)
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
@ -106,14 +106,14 @@ start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols,
|
||||
int input_rows, int output_rows)
|
||||
expand_bottom_edge(JSAMPARRAY image_data, JDIMENSION num_cols, int input_rows,
|
||||
int output_rows)
|
||||
{
|
||||
register int row;
|
||||
|
||||
for (row = input_rows; row < output_rows; row++) {
|
||||
jcopy_sample_rows(image_data, input_rows-1, image_data, row,
|
||||
1, num_cols);
|
||||
jcopy_sample_rows(image_data, input_rows - 1, image_data, row, 1,
|
||||
num_cols);
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,13 +128,12 @@ expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
pre_process_data (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail,
|
||||
pre_process_data(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
|
||||
JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
|
||||
JDIMENSION out_row_groups_avail)
|
||||
{
|
||||
my_prep_ptr prep = (my_prep_ptr) cinfo->prep;
|
||||
my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
|
||||
int numrows, ci;
|
||||
JDIMENSION inrows;
|
||||
jpeg_component_info *compptr;
|
||||
@ -144,10 +143,10 @@ pre_process_data (j_compress_ptr cinfo,
|
||||
/* Do color conversion to fill the conversion buffer. */
|
||||
inrows = in_rows_avail - *in_row_ctr;
|
||||
numrows = cinfo->max_v_samp_factor - prep->next_buf_row;
|
||||
numrows = (int) MIN((JDIMENSION) numrows, inrows);
|
||||
numrows = (int)MIN((JDIMENSION)numrows, inrows);
|
||||
(*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,
|
||||
prep->color_buf,
|
||||
(JDIMENSION) prep->next_buf_row,
|
||||
(JDIMENSION)prep->next_buf_row,
|
||||
numrows);
|
||||
*in_row_ctr += numrows;
|
||||
prep->next_buf_row += numrows;
|
||||
@ -164,7 +163,7 @@ pre_process_data (j_compress_ptr cinfo,
|
||||
/* If we've filled the conversion buffer, empty it. */
|
||||
if (prep->next_buf_row == cinfo->max_v_samp_factor) {
|
||||
(*cinfo->downsample->downsample) (cinfo,
|
||||
prep->color_buf, (JDIMENSION) 0,
|
||||
prep->color_buf, (JDIMENSION)0,
|
||||
output_buf, *out_row_group_ctr);
|
||||
prep->next_buf_row = 0;
|
||||
(*out_row_group_ctr)++;
|
||||
@ -172,14 +171,12 @@ pre_process_data (j_compress_ptr cinfo,
|
||||
/* If at bottom of image, pad the output to a full iMCU height.
|
||||
* Note we assume the caller is providing a one-iMCU-height output buffer!
|
||||
*/
|
||||
if (prep->rows_to_go == 0 &&
|
||||
*out_row_group_ctr < out_row_groups_avail) {
|
||||
if (prep->rows_to_go == 0 && *out_row_group_ctr < out_row_groups_avail) {
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
expand_bottom_edge(output_buf[ci],
|
||||
compptr->width_in_blocks * DCTSIZE,
|
||||
(int) (*out_row_group_ctr * compptr->v_samp_factor),
|
||||
(int) (out_row_groups_avail * compptr->v_samp_factor));
|
||||
expand_bottom_edge(output_buf[ci], compptr->width_in_blocks * DCTSIZE,
|
||||
(int)(*out_row_group_ctr * compptr->v_samp_factor),
|
||||
(int)(out_row_groups_avail * compptr->v_samp_factor));
|
||||
}
|
||||
*out_row_group_ctr = out_row_groups_avail;
|
||||
break; /* can exit outer loop without test */
|
||||
@ -195,13 +192,12 @@ pre_process_data (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
pre_process_context (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
||||
JDIMENSION in_rows_avail,
|
||||
pre_process_context(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
|
||||
JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
|
||||
JDIMENSION out_row_groups_avail)
|
||||
{
|
||||
my_prep_ptr prep = (my_prep_ptr) cinfo->prep;
|
||||
my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
|
||||
int numrows, ci;
|
||||
int buf_height = cinfo->max_v_samp_factor * 3;
|
||||
JDIMENSION inrows;
|
||||
@ -211,19 +207,18 @@ pre_process_context (j_compress_ptr cinfo,
|
||||
/* Do color conversion to fill the conversion buffer. */
|
||||
inrows = in_rows_avail - *in_row_ctr;
|
||||
numrows = prep->next_buf_stop - prep->next_buf_row;
|
||||
numrows = (int) MIN((JDIMENSION) numrows, inrows);
|
||||
numrows = (int)MIN((JDIMENSION)numrows, inrows);
|
||||
(*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,
|
||||
prep->color_buf,
|
||||
(JDIMENSION) prep->next_buf_row,
|
||||
(JDIMENSION)prep->next_buf_row,
|
||||
numrows);
|
||||
/* Pad at top of image, if first time through */
|
||||
if (prep->rows_to_go == cinfo->image_height) {
|
||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||
int row;
|
||||
for (row = 1; row <= cinfo->max_v_samp_factor; row++) {
|
||||
jcopy_sample_rows(prep->color_buf[ci], 0,
|
||||
prep->color_buf[ci], -row,
|
||||
1, cinfo->image_width);
|
||||
jcopy_sample_rows(prep->color_buf[ci], 0, prep->color_buf[ci],
|
||||
-row, 1, cinfo->image_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -245,9 +240,8 @@ pre_process_context (j_compress_ptr cinfo,
|
||||
}
|
||||
/* If we've gotten enough data, downsample a row group. */
|
||||
if (prep->next_buf_row == prep->next_buf_stop) {
|
||||
(*cinfo->downsample->downsample) (cinfo,
|
||||
prep->color_buf,
|
||||
(JDIMENSION) prep->this_row_group,
|
||||
(*cinfo->downsample->downsample) (cinfo, prep->color_buf,
|
||||
(JDIMENSION)prep->this_row_group,
|
||||
output_buf, *out_row_group_ctr);
|
||||
(*out_row_group_ctr)++;
|
||||
/* Advance pointers with wraparound as necessary. */
|
||||
@ -267,9 +261,9 @@ pre_process_context (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
create_context_buffer (j_compress_ptr cinfo)
|
||||
create_context_buffer(j_compress_ptr cinfo)
|
||||
{
|
||||
my_prep_ptr prep = (my_prep_ptr) cinfo->prep;
|
||||
my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
|
||||
int rgroup_height = cinfo->max_v_samp_factor;
|
||||
int ci, i;
|
||||
jpeg_component_info *compptr;
|
||||
@ -279,7 +273,7 @@ create_context_buffer (j_compress_ptr cinfo)
|
||||
* we need five row groups' worth of pointers for each component.
|
||||
*/
|
||||
fake_buffer = (JSAMPARRAY)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(cinfo->num_components * 5 * rgroup_height) *
|
||||
sizeof(JSAMPROW));
|
||||
|
||||
@ -290,10 +284,10 @@ create_context_buffer (j_compress_ptr cinfo)
|
||||
* horizontally within the buffer, if it so chooses.
|
||||
*/
|
||||
true_buffer = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE *
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)(((long)compptr->width_in_blocks * DCTSIZE *
|
||||
cinfo->max_h_samp_factor) / compptr->h_samp_factor),
|
||||
(JDIMENSION) (3 * rgroup_height));
|
||||
(JDIMENSION)(3 * rgroup_height));
|
||||
/* Copy true buffer row pointers into the middle of the fake row array */
|
||||
MEMCOPY(fake_buffer + rgroup_height, true_buffer,
|
||||
3 * rgroup_height * sizeof(JSAMPROW));
|
||||
@ -315,7 +309,7 @@ create_context_buffer (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_c_prep_controller(j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_prep_ptr prep;
|
||||
int ci;
|
||||
@ -325,9 +319,9 @@ jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
|
||||
prep = (my_prep_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_prep_controller));
|
||||
cinfo->prep = (struct jpeg_c_prep_controller *) prep;
|
||||
cinfo->prep = (struct jpeg_c_prep_controller *)prep;
|
||||
prep->pub.start_pass = start_pass_prep;
|
||||
|
||||
/* Allocate the color conversion buffer.
|
||||
@ -348,10 +342,10 @@ jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
prep->color_buf[ci] = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE *
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)(((long)compptr->width_in_blocks * DCTSIZE *
|
||||
cinfo->max_h_samp_factor) / compptr->h_samp_factor),
|
||||
(JDIMENSION) cinfo->max_v_samp_factor);
|
||||
(JDIMENSION)cinfo->max_v_samp_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
96
3rdparty/libjpeg-turbo/src/jcsample.c
vendored
96
3rdparty/libjpeg-turbo/src/jcsample.c
vendored
@ -79,7 +79,7 @@ typedef my_downsampler *my_downsample_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_downsample (j_compress_ptr cinfo)
|
||||
start_pass_downsample(j_compress_ptr cinfo)
|
||||
{
|
||||
/* no work for now */
|
||||
}
|
||||
@ -91,14 +91,14 @@ start_pass_downsample (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
expand_right_edge (JSAMPARRAY image_data, int num_rows,
|
||||
JDIMENSION input_cols, JDIMENSION output_cols)
|
||||
expand_right_edge(JSAMPARRAY image_data, int num_rows, JDIMENSION input_cols,
|
||||
JDIMENSION output_cols)
|
||||
{
|
||||
register JSAMPROW ptr;
|
||||
register JSAMPLE pixval;
|
||||
register int count;
|
||||
int row;
|
||||
int numcols = (int) (output_cols - input_cols);
|
||||
int numcols = (int)(output_cols - input_cols);
|
||||
|
||||
if (numcols > 0) {
|
||||
for (row = 0; row < num_rows; row++) {
|
||||
@ -118,11 +118,11 @@ expand_right_edge (JSAMPARRAY image_data, int num_rows,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
sep_downsample (j_compress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_index,
|
||||
JSAMPIMAGE output_buf, JDIMENSION out_row_group_index)
|
||||
sep_downsample(j_compress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_index, JSAMPIMAGE output_buf,
|
||||
JDIMENSION out_row_group_index)
|
||||
{
|
||||
my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample;
|
||||
my_downsample_ptr downsample = (my_downsample_ptr)cinfo->downsample;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
JSAMPARRAY in_ptr, out_ptr;
|
||||
@ -144,7 +144,7 @@ sep_downsample (j_compress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
int_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
int_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
|
||||
@ -156,14 +156,14 @@ int_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;
|
||||
v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor;
|
||||
numpix = h_expand * v_expand;
|
||||
numpix2 = numpix/2;
|
||||
numpix2 = numpix / 2;
|
||||
|
||||
/* Expand input data enough to let all the output samples be generated
|
||||
* by the standard loop. Special-casing padded output would be more
|
||||
* efficient.
|
||||
*/
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor,
|
||||
cinfo->image_width, output_cols * h_expand);
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
|
||||
output_cols * h_expand);
|
||||
|
||||
inrow = 0;
|
||||
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
|
||||
@ -172,12 +172,12 @@ int_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
outcol++, outcol_h += h_expand) {
|
||||
outvalue = 0;
|
||||
for (v = 0; v < v_expand; v++) {
|
||||
inptr = input_data[inrow+v] + outcol_h;
|
||||
inptr = input_data[inrow + v] + outcol_h;
|
||||
for (h = 0; h < h_expand; h++) {
|
||||
outvalue += (JLONG) GETJSAMPLE(*inptr++);
|
||||
outvalue += (JLONG)GETJSAMPLE(*inptr++);
|
||||
}
|
||||
}
|
||||
*outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix);
|
||||
*outptr++ = (JSAMPLE)((outvalue + numpix2) / numpix);
|
||||
}
|
||||
inrow += v_expand;
|
||||
}
|
||||
@ -191,15 +191,15 @@ int_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
fullsize_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
/* Copy the data */
|
||||
jcopy_sample_rows(input_data, 0, output_data, 0,
|
||||
cinfo->max_v_samp_factor, cinfo->image_width);
|
||||
jcopy_sample_rows(input_data, 0, output_data, 0, cinfo->max_v_samp_factor,
|
||||
cinfo->image_width);
|
||||
/* Edge-expand */
|
||||
expand_right_edge(output_data, cinfo->max_v_samp_factor,
|
||||
cinfo->image_width, compptr->width_in_blocks * DCTSIZE);
|
||||
expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
|
||||
compptr->width_in_blocks * DCTSIZE);
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +216,7 @@ fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
int outrow;
|
||||
@ -229,16 +229,16 @@ h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
* by the standard loop. Special-casing padded output would be more
|
||||
* efficient.
|
||||
*/
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor,
|
||||
cinfo->image_width, output_cols * 2);
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
|
||||
output_cols * 2);
|
||||
|
||||
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
|
||||
outptr = output_data[outrow];
|
||||
inptr = input_data[outrow];
|
||||
bias = 0; /* bias = 0,1,0,1,... for successive samples */
|
||||
for (outcol = 0; outcol < output_cols; outcol++) {
|
||||
*outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1])
|
||||
+ bias) >> 1);
|
||||
*outptr++ =
|
||||
(JSAMPLE)((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) + bias) >> 1);
|
||||
bias ^= 1; /* 0=>1, 1=>0 */
|
||||
inptr += 2;
|
||||
}
|
||||
@ -253,7 +253,7 @@ h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
int inrow, outrow;
|
||||
@ -266,19 +266,19 @@ h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
* by the standard loop. Special-casing padded output would be more
|
||||
* efficient.
|
||||
*/
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor,
|
||||
cinfo->image_width, output_cols * 2);
|
||||
expand_right_edge(input_data, cinfo->max_v_samp_factor, cinfo->image_width,
|
||||
output_cols * 2);
|
||||
|
||||
inrow = 0;
|
||||
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
|
||||
outptr = output_data[outrow];
|
||||
inptr0 = input_data[inrow];
|
||||
inptr1 = input_data[inrow+1];
|
||||
inptr1 = input_data[inrow + 1];
|
||||
bias = 1; /* bias = 1,2,1,2,... for successive samples */
|
||||
for (outcol = 0; outcol < output_cols; outcol++) {
|
||||
*outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
|
||||
GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1])
|
||||
+ bias) >> 2);
|
||||
*outptr++ =
|
||||
(JSAMPLE)((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
|
||||
GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) + bias) >> 2);
|
||||
bias ^= 3; /* 1=>2, 2=>1 */
|
||||
inptr0 += 2; inptr1 += 2;
|
||||
}
|
||||
@ -296,7 +296,7 @@ h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v2_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
int inrow, outrow;
|
||||
@ -332,9 +332,9 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
|
||||
outptr = output_data[outrow];
|
||||
inptr0 = input_data[inrow];
|
||||
inptr1 = input_data[inrow+1];
|
||||
above_ptr = input_data[inrow-1];
|
||||
below_ptr = input_data[inrow+2];
|
||||
inptr1 = input_data[inrow + 1];
|
||||
above_ptr = input_data[inrow - 1];
|
||||
below_ptr = input_data[inrow + 2];
|
||||
|
||||
/* Special case for first column: pretend column -1 is same as column 0 */
|
||||
membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
|
||||
@ -347,7 +347,7 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) +
|
||||
GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]);
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
*outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
|
||||
|
||||
for (colctr = output_cols - 2; colctr > 0; colctr--) {
|
||||
@ -367,7 +367,7 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* form final output scaled up by 2^16 */
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
/* round, descale and output it */
|
||||
*outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) +
|
||||
GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]);
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
*outptr = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
|
||||
inrow += 2;
|
||||
}
|
||||
@ -396,7 +396,7 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
fullsize_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
int outrow;
|
||||
@ -425,8 +425,8 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
|
||||
outptr = output_data[outrow];
|
||||
inptr = input_data[outrow];
|
||||
above_ptr = input_data[outrow-1];
|
||||
below_ptr = input_data[outrow+1];
|
||||
above_ptr = input_data[outrow - 1];
|
||||
below_ptr = input_data[outrow + 1];
|
||||
|
||||
/* Special case for first column */
|
||||
colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) +
|
||||
@ -436,7 +436,7 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
GETJSAMPLE(*inptr);
|
||||
neighsum = colsum + (colsum - membersum) + nextcolsum;
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
*outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
lastcolsum = colsum; colsum = nextcolsum;
|
||||
|
||||
for (colctr = output_cols - 2; colctr > 0; colctr--) {
|
||||
@ -446,7 +446,7 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
GETJSAMPLE(*inptr);
|
||||
neighsum = lastcolsum + (colsum - membersum) + nextcolsum;
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
*outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
lastcolsum = colsum; colsum = nextcolsum;
|
||||
}
|
||||
|
||||
@ -454,7 +454,7 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
membersum = GETJSAMPLE(*inptr);
|
||||
neighsum = lastcolsum + (colsum - membersum) + colsum;
|
||||
membersum = membersum * memberscale + neighsum * neighscale;
|
||||
*outptr = (JSAMPLE) ((membersum + 32768) >> 16);
|
||||
*outptr = (JSAMPLE)((membersum + 32768) >> 16);
|
||||
|
||||
}
|
||||
}
|
||||
@ -468,7 +468,7 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_downsampler (j_compress_ptr cinfo)
|
||||
jinit_downsampler(j_compress_ptr cinfo)
|
||||
{
|
||||
my_downsample_ptr downsample;
|
||||
int ci;
|
||||
@ -476,9 +476,9 @@ jinit_downsampler (j_compress_ptr cinfo)
|
||||
boolean smoothok = TRUE;
|
||||
|
||||
downsample = (my_downsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_downsampler));
|
||||
cinfo->downsample = (struct jpeg_downsampler *) downsample;
|
||||
cinfo->downsample = (struct jpeg_downsampler *)downsample;
|
||||
downsample->pub.start_pass = start_pass_downsample;
|
||||
downsample->pub.downsample = sep_downsample;
|
||||
downsample->pub.need_context_rows = FALSE;
|
||||
|
66
3rdparty/libjpeg-turbo/src/jctrans.c
vendored
66
3rdparty/libjpeg-turbo/src/jctrans.c
vendored
@ -20,10 +20,10 @@
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
LOCAL(void) transencode_master_selection
|
||||
(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays);
|
||||
LOCAL(void) transencode_coef_controller
|
||||
(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays);
|
||||
LOCAL(void) transencode_master_selection(j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr *coef_arrays);
|
||||
LOCAL(void) transencode_coef_controller(j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr *coef_arrays);
|
||||
|
||||
|
||||
/*
|
||||
@ -39,14 +39,14 @@ LOCAL(void) transencode_coef_controller
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
||||
jpeg_write_coefficients(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
||||
{
|
||||
if (cinfo->global_state != CSTATE_START)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
/* Mark all tables to be written */
|
||||
jpeg_suppress_tables(cinfo, FALSE);
|
||||
/* (Re)initialize error mgr and destination modules */
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
||||
(*cinfo->dest->init_destination) (cinfo);
|
||||
/* Perform master selection of active modules */
|
||||
transencode_master_selection(cinfo, coef_arrays);
|
||||
@ -64,8 +64,7 @@ jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
j_compress_ptr dstinfo)
|
||||
jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
|
||||
{
|
||||
JQUANT_TBL **qtblptr;
|
||||
jpeg_component_info *incomp, *outcomp;
|
||||
@ -97,11 +96,10 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
/* Copy the source's quantization tables. */
|
||||
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
|
||||
if (srcinfo->quant_tbl_ptrs[tblno] != NULL) {
|
||||
qtblptr = & dstinfo->quant_tbl_ptrs[tblno];
|
||||
qtblptr = &dstinfo->quant_tbl_ptrs[tblno];
|
||||
if (*qtblptr == NULL)
|
||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo);
|
||||
MEMCOPY((*qtblptr)->quantval,
|
||||
srcinfo->quant_tbl_ptrs[tblno]->quantval,
|
||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr)dstinfo);
|
||||
MEMCOPY((*qtblptr)->quantval, srcinfo->quant_tbl_ptrs[tblno]->quantval,
|
||||
sizeof((*qtblptr)->quantval));
|
||||
(*qtblptr)->sent_table = FALSE;
|
||||
}
|
||||
@ -165,7 +163,7 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
transencode_master_selection (j_compress_ptr cinfo,
|
||||
transencode_master_selection(j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr *coef_arrays)
|
||||
{
|
||||
/* Although we don't actually use input_components for transcoding,
|
||||
@ -199,7 +197,7 @@ transencode_master_selection (j_compress_ptr cinfo,
|
||||
jinit_marker_writer(cinfo);
|
||||
|
||||
/* We can now tell the memory manager to allocate virtual arrays. */
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
|
||||
|
||||
/* Write the datastream header (SOI, JFIF) immediately.
|
||||
* Frame and scan headers are postponed till later.
|
||||
@ -238,10 +236,10 @@ typedef my_coef_controller *my_coef_ptr;
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
start_iMCU_row (j_compress_ptr cinfo)
|
||||
start_iMCU_row(j_compress_ptr cinfo)
|
||||
/* Reset within-iMCU-row counters for a new row */
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
/* In an interleaved scan, an MCU row is the same as an iMCU row.
|
||||
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
|
||||
@ -250,7 +248,7 @@ start_iMCU_row (j_compress_ptr cinfo)
|
||||
if (cinfo->comps_in_scan > 1) {
|
||||
coef->MCU_rows_per_iMCU_row = 1;
|
||||
} else {
|
||||
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1))
|
||||
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
|
||||
else
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
||||
@ -266,9 +264,9 @@ start_iMCU_row (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
if (pass_mode != JBUF_CRANK_DEST)
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
@ -289,9 +287,9 @@ start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
@ -306,9 +304,9 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
buffer[ci] = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
|
||||
((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
|
||||
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||
(JDIMENSION) compptr->v_samp_factor, FALSE);
|
||||
(JDIMENSION)compptr->v_samp_factor, FALSE);
|
||||
}
|
||||
|
||||
/* Loop to process one whole iMCU row */
|
||||
@ -321,13 +319,13 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
start_col = MCU_col_num * compptr->MCU_width;
|
||||
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
||||
: compptr->last_col_width;
|
||||
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width :
|
||||
compptr->last_col_width;
|
||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||
if (coef->iMCU_row_num < last_iMCU_row ||
|
||||
yindex+yoffset < compptr->last_row_height) {
|
||||
yindex + yoffset < compptr->last_row_height) {
|
||||
/* Fill in pointers to real blocks in this row */
|
||||
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
||||
buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
|
||||
for (xindex = 0; xindex < blockcnt; xindex++)
|
||||
MCU_buffer[blkn++] = buffer_ptr++;
|
||||
} else {
|
||||
@ -342,13 +340,13 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
*/
|
||||
for (; xindex < compptr->MCU_width; xindex++) {
|
||||
MCU_buffer[blkn] = coef->dummy_buffer[blkn];
|
||||
MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0];
|
||||
MCU_buffer[blkn][0][0] = MCU_buffer[blkn - 1][0][0];
|
||||
blkn++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Try to write the MCU. */
|
||||
if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
|
||||
if (!(*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
coef->mcu_ctr = MCU_col_num;
|
||||
@ -374,7 +372,7 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
transencode_coef_controller (j_compress_ptr cinfo,
|
||||
transencode_coef_controller(j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr *coef_arrays)
|
||||
{
|
||||
my_coef_ptr coef;
|
||||
@ -382,9 +380,9 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
||||
int i;
|
||||
|
||||
coef = (my_coef_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_coef_controller));
|
||||
cinfo->coef = (struct jpeg_c_coef_controller *) coef;
|
||||
cinfo->coef = (struct jpeg_c_coef_controller *)coef;
|
||||
coef->pub.start_pass = start_pass_coef;
|
||||
coef->pub.compress_data = compress_output;
|
||||
|
||||
@ -393,9 +391,9 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
||||
|
||||
/* Allocate and pre-zero space for dummy DCT blocks. */
|
||||
buffer = (JBLOCKROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
jzero_far((void *) buffer, C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
jzero_far((void *)buffer, C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->dummy_buffer[i] = buffer + i;
|
||||
}
|
||||
|
40
3rdparty/libjpeg-turbo/src/jdapimin.c
vendored
40
3rdparty/libjpeg-turbo/src/jdapimin.c
vendored
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -41,7 +41,7 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
|
||||
if (structsize != sizeof(struct jpeg_decompress_struct))
|
||||
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
|
||||
(int) sizeof(struct jpeg_decompress_struct), (int) structsize);
|
||||
(int)sizeof(struct jpeg_decompress_struct), (int)structsize);
|
||||
|
||||
/* For debugging purposes, we zero the whole master structure.
|
||||
* But the application has already set the err pointer, and may have set
|
||||
@ -50,8 +50,8 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
* complain here.
|
||||
*/
|
||||
{
|
||||
struct jpeg_error_mgr * err = cinfo->err;
|
||||
void * client_data = cinfo->client_data; /* ignore Purify complaint here */
|
||||
struct jpeg_error_mgr *err = cinfo->err;
|
||||
void *client_data = cinfo->client_data; /* ignore Purify complaint here */
|
||||
MEMZERO(cinfo, sizeof(struct jpeg_decompress_struct));
|
||||
cinfo->err = err;
|
||||
cinfo->client_data = client_data;
|
||||
@ -59,7 +59,7 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
cinfo->is_decompressor = TRUE;
|
||||
|
||||
/* Initialize a memory manager instance for this object */
|
||||
jinit_memory_mgr((j_common_ptr) cinfo);
|
||||
jinit_memory_mgr((j_common_ptr)cinfo);
|
||||
|
||||
/* Zero out pointers to permanent structures. */
|
||||
cinfo->progress = NULL;
|
||||
@ -89,7 +89,7 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
* here.
|
||||
*/
|
||||
cinfo->master = (struct jpeg_decomp_master *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_decomp_master));
|
||||
MEMZERO(cinfo->master, sizeof(my_decomp_master));
|
||||
}
|
||||
@ -100,9 +100,9 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_destroy_decompress (j_decompress_ptr cinfo)
|
||||
jpeg_destroy_decompress(j_decompress_ptr cinfo)
|
||||
{
|
||||
jpeg_destroy((j_common_ptr) cinfo); /* use common routine */
|
||||
jpeg_destroy((j_common_ptr)cinfo); /* use common routine */
|
||||
}
|
||||
|
||||
|
||||
@ -112,9 +112,9 @@ jpeg_destroy_decompress (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_abort_decompress (j_decompress_ptr cinfo)
|
||||
jpeg_abort_decompress(j_decompress_ptr cinfo)
|
||||
{
|
||||
jpeg_abort((j_common_ptr) cinfo); /* use common routine */
|
||||
jpeg_abort((j_common_ptr)cinfo); /* use common routine */
|
||||
}
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ jpeg_abort_decompress (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
default_decompress_parms (j_decompress_ptr cinfo)
|
||||
default_decompress_parms(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* Guess the input colorspace, and set output colorspace accordingly. */
|
||||
/* (Wish JPEG committee had provided a real way to specify this...) */
|
||||
@ -250,7 +250,7 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(int)
|
||||
jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
|
||||
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
|
||||
{
|
||||
int retcode;
|
||||
|
||||
@ -271,7 +271,7 @@ jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
|
||||
* call jpeg_abort, but we can't change it now for compatibility reasons.
|
||||
* A side effect is to free any temporary memory (there shouldn't be any).
|
||||
*/
|
||||
jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */
|
||||
jpeg_abort((j_common_ptr)cinfo); /* sets state = DSTATE_START */
|
||||
retcode = JPEG_HEADER_TABLES_ONLY;
|
||||
break;
|
||||
case JPEG_SUSPENDED:
|
||||
@ -296,7 +296,7 @@ jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
|
||||
*/
|
||||
|
||||
GLOBAL(int)
|
||||
jpeg_consume_input (j_decompress_ptr cinfo)
|
||||
jpeg_consume_input(j_decompress_ptr cinfo)
|
||||
{
|
||||
int retcode = JPEG_SUSPENDED;
|
||||
|
||||
@ -343,7 +343,7 @@ jpeg_consume_input (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_input_complete (j_decompress_ptr cinfo)
|
||||
jpeg_input_complete(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* Check for valid jpeg object */
|
||||
if (cinfo->global_state < DSTATE_START ||
|
||||
@ -358,7 +358,7 @@ jpeg_input_complete (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_has_multiple_scans (j_decompress_ptr cinfo)
|
||||
jpeg_has_multiple_scans(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* Only valid after jpeg_read_header completes */
|
||||
if (cinfo->global_state < DSTATE_READY ||
|
||||
@ -378,10 +378,10 @@ jpeg_has_multiple_scans (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_finish_decompress (j_decompress_ptr cinfo)
|
||||
jpeg_finish_decompress(j_decompress_ptr cinfo)
|
||||
{
|
||||
if ((cinfo->global_state == DSTATE_SCANNING ||
|
||||
cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) {
|
||||
cinfo->global_state == DSTATE_RAW_OK) && !cinfo->buffered_image) {
|
||||
/* Terminate final pass of non-buffered mode */
|
||||
if (cinfo->output_scanline < cinfo->output_height)
|
||||
ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
|
||||
@ -395,13 +395,13 @@ jpeg_finish_decompress (j_decompress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
}
|
||||
/* Read until EOI */
|
||||
while (! cinfo->inputctl->eoi_reached) {
|
||||
while (!cinfo->inputctl->eoi_reached) {
|
||||
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
||||
return FALSE; /* Suspend, come back later */
|
||||
}
|
||||
/* Do final cleanup */
|
||||
(*cinfo->src->term_source) (cinfo);
|
||||
/* We can use jpeg_abort to release memory and reset global_state */
|
||||
jpeg_abort((j_common_ptr) cinfo);
|
||||
jpeg_abort((j_common_ptr)cinfo);
|
||||
return TRUE;
|
||||
}
|
||||
|
96
3rdparty/libjpeg-turbo/src/jdapistd.c
vendored
96
3rdparty/libjpeg-turbo/src/jdapistd.c
vendored
@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2015-2017, D. R. Commander.
|
||||
* Copyright (C) 2010, 2015-2018, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@ -25,7 +25,7 @@
|
||||
#include "jmemsys.h"
|
||||
|
||||
/* Forward declarations */
|
||||
LOCAL(boolean) output_pass_setup (j_decompress_ptr cinfo);
|
||||
LOCAL(boolean) output_pass_setup(j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
@ -40,7 +40,7 @@ LOCAL(boolean) output_pass_setup (j_decompress_ptr cinfo);
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_start_decompress (j_decompress_ptr cinfo)
|
||||
jpeg_start_decompress(j_decompress_ptr cinfo)
|
||||
{
|
||||
if (cinfo->global_state == DSTATE_READY) {
|
||||
/* First call: initialize master control, select active modules */
|
||||
@ -60,7 +60,7 @@ jpeg_start_decompress (j_decompress_ptr cinfo)
|
||||
int retcode;
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL)
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
/* Absorb some more input */
|
||||
retcode = (*cinfo->inputctl->consume_input) (cinfo);
|
||||
if (retcode == JPEG_SUSPENDED)
|
||||
@ -72,7 +72,7 @@ jpeg_start_decompress (j_decompress_ptr cinfo)
|
||||
(retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
|
||||
if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
|
||||
/* jdmaster underestimated number of scans; ratchet up one scan */
|
||||
cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
|
||||
cinfo->progress->pass_limit += (long)cinfo->total_iMCU_rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ jpeg_start_decompress (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
output_pass_setup (j_decompress_ptr cinfo)
|
||||
output_pass_setup(j_decompress_ptr cinfo)
|
||||
{
|
||||
if (cinfo->global_state != DSTATE_PRESCAN) {
|
||||
/* First call: do pass setup */
|
||||
@ -113,14 +113,14 @@ output_pass_setup (j_decompress_ptr cinfo)
|
||||
JDIMENSION last_scanline;
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long) cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long)cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
/* Process some data */
|
||||
last_scanline = cinfo->output_scanline;
|
||||
(*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,
|
||||
&cinfo->output_scanline, (JDIMENSION) 0);
|
||||
(*cinfo->main->process_data) (cinfo, (JSAMPARRAY)NULL,
|
||||
&cinfo->output_scanline, (JDIMENSION)0);
|
||||
if (cinfo->output_scanline == last_scanline)
|
||||
return FALSE; /* No progress made, must suspend */
|
||||
}
|
||||
@ -150,7 +150,7 @@ output_pass_setup (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
JDIMENSION *width)
|
||||
{
|
||||
int ci, align, orig_downsampled_width;
|
||||
@ -210,11 +210,10 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
/* Set the first and last iMCU columns that we must decompress. These values
|
||||
* will be used in single-scan decompressions.
|
||||
*/
|
||||
cinfo->master->first_iMCU_col =
|
||||
(JDIMENSION) (long) (*xoffset) / (long) align;
|
||||
cinfo->master->first_iMCU_col = (JDIMENSION)(long)(*xoffset) / (long)align;
|
||||
cinfo->master->last_iMCU_col =
|
||||
(JDIMENSION) jdiv_round_up((long) (*xoffset + cinfo->output_width),
|
||||
(long) align) - 1;
|
||||
(JDIMENSION)jdiv_round_up((long)(*xoffset + cinfo->output_width),
|
||||
(long)align) - 1;
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
@ -224,9 +223,9 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
/* Set downsampled_width to the new output width. */
|
||||
orig_downsampled_width = compptr->downsampled_width;
|
||||
compptr->downsampled_width =
|
||||
(JDIMENSION) jdiv_round_up((long) (cinfo->output_width *
|
||||
(JDIMENSION)jdiv_round_up((long)(cinfo->output_width *
|
||||
compptr->h_samp_factor),
|
||||
(long) cinfo->max_h_samp_factor);
|
||||
(long)cinfo->max_h_samp_factor);
|
||||
if (compptr->downsampled_width < 2 && orig_downsampled_width >= 2)
|
||||
reinit_upsampler = TRUE;
|
||||
|
||||
@ -234,11 +233,10 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
* values will be used in multi-scan decompressions.
|
||||
*/
|
||||
cinfo->master->first_MCU_col[ci] =
|
||||
(JDIMENSION) (long) (*xoffset * hsf) / (long) align;
|
||||
(JDIMENSION)(long)(*xoffset * hsf) / (long)align;
|
||||
cinfo->master->last_MCU_col[ci] =
|
||||
(JDIMENSION) jdiv_round_up((long) ((*xoffset + cinfo->output_width) *
|
||||
hsf),
|
||||
(long) align) - 1;
|
||||
(JDIMENSION)jdiv_round_up((long)((*xoffset + cinfo->output_width) * hsf),
|
||||
(long)align) - 1;
|
||||
}
|
||||
|
||||
if (reinit_upsampler) {
|
||||
@ -263,7 +261,7 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
*/
|
||||
|
||||
GLOBAL(JDIMENSION)
|
||||
jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
JDIMENSION max_lines)
|
||||
{
|
||||
JDIMENSION row_ctr;
|
||||
@ -277,9 +275,9 @@ jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long) cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long)cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
/* Process some data */
|
||||
@ -292,7 +290,7 @@ jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,
|
||||
|
||||
/* Dummy color convert function used by jpeg_skip_scanlines() */
|
||||
LOCAL(void)
|
||||
noop_convert (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
noop_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
}
|
||||
@ -300,7 +298,7 @@ noop_convert (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
|
||||
/* Dummy quantize function used by jpeg_skip_scanlines() */
|
||||
LOCAL(void)
|
||||
noop_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
noop_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
}
|
||||
@ -315,17 +313,20 @@ noop_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
{
|
||||
JDIMENSION n;
|
||||
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows);
|
||||
int num_rows) = NULL;
|
||||
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows) = NULL;
|
||||
|
||||
if (cinfo->cconvert && cinfo->cconvert->color_convert) {
|
||||
color_convert = cinfo->cconvert->color_convert;
|
||||
cinfo->cconvert->color_convert = noop_convert;
|
||||
}
|
||||
|
||||
if (cinfo->cquantize && cinfo->cquantize->color_quantize) {
|
||||
color_quantize = cinfo->cquantize->color_quantize;
|
||||
cinfo->cquantize->color_quantize = noop_quantize;
|
||||
@ -334,7 +335,9 @@ read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
for (n = 0; n < num_lines; n++)
|
||||
jpeg_read_scanlines(cinfo, NULL, 1);
|
||||
|
||||
if (color_convert)
|
||||
cinfo->cconvert->color_convert = color_convert;
|
||||
|
||||
if (color_quantize)
|
||||
cinfo->cquantize->color_quantize = color_quantize;
|
||||
}
|
||||
@ -346,10 +349,10 @@ read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
increment_simple_rowgroup_ctr (j_decompress_ptr cinfo, JDIMENSION rows)
|
||||
increment_simple_rowgroup_ctr(j_decompress_ptr cinfo, JDIMENSION rows)
|
||||
{
|
||||
JDIMENSION rows_left;
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
|
||||
/* Increment the counter to the next row group after the skipped rows. */
|
||||
main_ptr->rowgroup_ctr += rows / cinfo->max_v_samp_factor;
|
||||
@ -375,11 +378,11 @@ increment_simple_rowgroup_ctr (j_decompress_ptr cinfo, JDIMENSION rows)
|
||||
*/
|
||||
|
||||
GLOBAL(JDIMENSION)
|
||||
jpeg_skip_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
JDIMENSION i, x;
|
||||
int y;
|
||||
JDIMENSION lines_per_iMCU_row, lines_left_in_iMCU_row, lines_after_iMCU_row;
|
||||
@ -481,7 +484,7 @@ jpeg_skip_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
if (cinfo->upsample->need_context_rows) {
|
||||
cinfo->output_scanline += lines_to_skip;
|
||||
cinfo->output_iMCU_row += lines_to_skip / lines_per_iMCU_row;
|
||||
main_ptr->iMCU_row_ctr += lines_after_iMCU_row / lines_per_iMCU_row;
|
||||
main_ptr->iMCU_row_ctr += lines_to_skip / lines_per_iMCU_row;
|
||||
/* It is complex to properly move to the middle of a context block, so
|
||||
* read the remaining lines instead of skipping them.
|
||||
*/
|
||||
@ -544,7 +547,7 @@ jpeg_skip_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
*/
|
||||
|
||||
GLOBAL(JDIMENSION)
|
||||
jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
JDIMENSION max_lines)
|
||||
{
|
||||
JDIMENSION lines_per_iMCU_row;
|
||||
@ -558,9 +561,9 @@ jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL) {
|
||||
cinfo->progress->pass_counter = (long) cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long) cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
cinfo->progress->pass_counter = (long)cinfo->output_scanline;
|
||||
cinfo->progress->pass_limit = (long)cinfo->output_height;
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
}
|
||||
|
||||
/* Verify that at least one iMCU row can be returned. */
|
||||
@ -569,7 +572,7 @@ jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
|
||||
/* Decompress directly into user's buffer. */
|
||||
if (! (*cinfo->coef->decompress_data) (cinfo, data))
|
||||
if (!(*cinfo->coef->decompress_data) (cinfo, data))
|
||||
return 0; /* suspension forced, can do nothing more */
|
||||
|
||||
/* OK, we processed one iMCU row. */
|
||||
@ -587,7 +590,7 @@ jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_start_output (j_decompress_ptr cinfo, int scan_number)
|
||||
jpeg_start_output(j_decompress_ptr cinfo, int scan_number)
|
||||
{
|
||||
if (cinfo->global_state != DSTATE_BUFIMAGE &&
|
||||
cinfo->global_state != DSTATE_PRESCAN)
|
||||
@ -595,8 +598,7 @@ jpeg_start_output (j_decompress_ptr cinfo, int scan_number)
|
||||
/* Limit scan number to valid range */
|
||||
if (scan_number <= 0)
|
||||
scan_number = 1;
|
||||
if (cinfo->inputctl->eoi_reached &&
|
||||
scan_number > cinfo->input_scan_number)
|
||||
if (cinfo->inputctl->eoi_reached && scan_number > cinfo->input_scan_number)
|
||||
scan_number = cinfo->input_scan_number;
|
||||
cinfo->output_scan_number = scan_number;
|
||||
/* Perform any dummy output passes, and set up for the real pass */
|
||||
@ -612,7 +614,7 @@ jpeg_start_output (j_decompress_ptr cinfo, int scan_number)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_finish_output (j_decompress_ptr cinfo)
|
||||
jpeg_finish_output(j_decompress_ptr cinfo)
|
||||
{
|
||||
if ((cinfo->global_state == DSTATE_SCANNING ||
|
||||
cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) {
|
||||
@ -626,7 +628,7 @@ jpeg_finish_output (j_decompress_ptr cinfo)
|
||||
}
|
||||
/* Read markers looking for SOS or EOI */
|
||||
while (cinfo->input_scan_number <= cinfo->output_scan_number &&
|
||||
! cinfo->inputctl->eoi_reached) {
|
||||
!cinfo->inputctl->eoi_reached) {
|
||||
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
||||
return FALSE; /* Suspend, come back later */
|
||||
}
|
||||
|
94
3rdparty/libjpeg-turbo/src/jdarith.c
vendored
94
3rdparty/libjpeg-turbo/src/jdarith.c
vendored
@ -4,16 +4,19 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Developed 1997-2015 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015-2016, D. R. Commander.
|
||||
* Copyright (C) 2015-2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
* This file contains portable arithmetic entropy decoding routines for JPEG
|
||||
* (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81).
|
||||
* This file contains portable arithmetic entropy encoding routines for JPEG
|
||||
* (implementing Recommendation ITU-T T.81 | ISO/IEC 10918-1).
|
||||
*
|
||||
* Both sequential and progressive modes are supported in this single module.
|
||||
*
|
||||
* Suspension is not currently supported in this module.
|
||||
*
|
||||
* NOTE: All referenced figures are from
|
||||
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
@ -68,13 +71,13 @@ typedef arith_entropy_decoder *arith_entropy_ptr;
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
get_byte (j_decompress_ptr cinfo)
|
||||
get_byte(j_decompress_ptr cinfo)
|
||||
/* Read next input byte; we do not support suspension in this module. */
|
||||
{
|
||||
struct jpeg_source_mgr *src = cinfo->src;
|
||||
|
||||
if (src->bytes_in_buffer == 0)
|
||||
if (! (*src->fill_input_buffer) (cinfo))
|
||||
if (!(*src->fill_input_buffer) (cinfo))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
src->bytes_in_buffer--;
|
||||
return GETJOCTET(*src->next_input_byte++);
|
||||
@ -109,9 +112,9 @@ get_byte (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(int)
|
||||
arith_decode (j_decompress_ptr cinfo, unsigned char *st)
|
||||
arith_decode(j_decompress_ptr cinfo, unsigned char *st)
|
||||
{
|
||||
register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
|
||||
register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy;
|
||||
register unsigned char nl, nm;
|
||||
register JLONG qe, temp;
|
||||
register int sv, data;
|
||||
@ -193,14 +196,14 @@ arith_decode (j_decompress_ptr cinfo, unsigned char *st)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
process_restart (j_decompress_ptr cinfo)
|
||||
process_restart(j_decompress_ptr cinfo)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
/* Advance past the RSTn marker */
|
||||
if (! (*cinfo->marker->read_restart_marker) (cinfo))
|
||||
if (!(*cinfo->marker->read_restart_marker) (cinfo))
|
||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||
|
||||
/* Re-initialize statistics areas */
|
||||
@ -244,9 +247,9 @@ process_restart (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int blkn, ci, tbl, sign;
|
||||
@ -294,9 +297,9 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
}
|
||||
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
|
||||
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 0; /* zero diff category */
|
||||
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */
|
||||
else
|
||||
entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */
|
||||
@ -306,11 +309,11 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
while (m >>= 1)
|
||||
if (arith_decode(cinfo, st)) v |= m;
|
||||
v += 1; if (sign) v = -v;
|
||||
entropy->last_dc_val[ci] += v;
|
||||
entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
|
||||
}
|
||||
|
||||
/* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
|
||||
(*block)[0] = (JCOEF) LEFT_SHIFT(entropy->last_dc_val[ci], cinfo->Al);
|
||||
(*block)[0] = (JCOEF)LEFT_SHIFT(entropy->last_dc_val[ci], cinfo->Al);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -323,9 +326,9 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
int tbl, sign, k;
|
||||
@ -385,7 +388,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (arith_decode(cinfo, st)) v |= m;
|
||||
v += 1; if (sign) v = -v;
|
||||
/* Scale and output coefficient in natural (dezigzagged) order */
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) ((unsigned)v << cinfo->Al);
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF)((unsigned)v << cinfo->Al);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -397,9 +400,9 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
unsigned char *st;
|
||||
int p1, blkn;
|
||||
|
||||
@ -430,9 +433,9 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_AC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
JBLOCKROW block;
|
||||
JCOEFPTR thiscoef;
|
||||
unsigned char *st;
|
||||
@ -499,9 +502,9 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
jpeg_component_info *compptr;
|
||||
JBLOCKROW block;
|
||||
unsigned char *st;
|
||||
@ -552,9 +555,9 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
}
|
||||
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
|
||||
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 0; /* zero diff category */
|
||||
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1))
|
||||
entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */
|
||||
else
|
||||
entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */
|
||||
@ -564,11 +567,11 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
while (m >>= 1)
|
||||
if (arith_decode(cinfo, st)) v |= m;
|
||||
v += 1; if (sign) v = -v;
|
||||
entropy->last_dc_val[ci] += v;
|
||||
entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
|
||||
}
|
||||
|
||||
if (block)
|
||||
(*block)[0] = (JCOEF) entropy->last_dc_val[ci];
|
||||
(*block)[0] = (JCOEF)entropy->last_dc_val[ci];
|
||||
|
||||
/* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */
|
||||
|
||||
@ -613,7 +616,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (arith_decode(cinfo, st)) v |= m;
|
||||
v += 1; if (sign) v = -v;
|
||||
if (block)
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) v;
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF)v;
|
||||
}
|
||||
}
|
||||
|
||||
@ -626,9 +629,9 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass (j_decompress_ptr cinfo)
|
||||
start_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||
int ci, tbl;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
@ -647,11 +650,11 @@ start_pass (j_decompress_ptr cinfo)
|
||||
}
|
||||
if (cinfo->Ah != 0) {
|
||||
/* Successive approximation refinement scan: must have Al = Ah-1. */
|
||||
if (cinfo->Ah-1 != cinfo->Al)
|
||||
if (cinfo->Ah - 1 != cinfo->Al)
|
||||
goto bad;
|
||||
}
|
||||
if (cinfo->Al > 13) { /* need not check for < 0 */
|
||||
bad:
|
||||
bad:
|
||||
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
|
||||
cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
|
||||
}
|
||||
@ -661,7 +664,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
int coefi, cindex = cinfo->cur_comp_info[ci]->component_index;
|
||||
int *coef_bit_ptr = & cinfo->coef_bits[cindex][0];
|
||||
int *coef_bit_ptr = &cinfo->coef_bits[cindex][0];
|
||||
if (cinfo->Ss && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
|
||||
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
|
||||
for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
|
||||
@ -702,8 +705,8 @@ start_pass (j_decompress_ptr cinfo)
|
||||
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
||||
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
||||
if (entropy->dc_stats[tbl] == NULL)
|
||||
entropy->dc_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, DC_STAT_BINS);
|
||||
entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
|
||||
MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS);
|
||||
/* Initialize DC predictions to 0 */
|
||||
entropy->last_dc_val[ci] = 0;
|
||||
@ -714,8 +717,8 @@ start_pass (j_decompress_ptr cinfo)
|
||||
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
||||
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
||||
if (entropy->ac_stats[tbl] == NULL)
|
||||
entropy->ac_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS);
|
||||
entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
|
||||
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
|
||||
}
|
||||
}
|
||||
@ -735,15 +738,15 @@ start_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_arith_decoder (j_decompress_ptr cinfo)
|
||||
jinit_arith_decoder(j_decompress_ptr cinfo)
|
||||
{
|
||||
arith_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (arith_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(arith_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass;
|
||||
|
||||
/* Mark tables unallocated */
|
||||
@ -759,9 +762,10 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
|
||||
/* Create progression status table */
|
||||
int *coef_bit_ptr, ci;
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2])
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components*DCTSIZE2*sizeof(int));
|
||||
coef_bit_ptr = & cinfo->coef_bits[0][0];
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * DCTSIZE2 *
|
||||
sizeof(int));
|
||||
coef_bit_ptr = &cinfo->coef_bits[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (i = 0; i < DCTSIZE2; i++)
|
||||
*coef_bit_ptr++ = -1;
|
||||
|
48
3rdparty/libjpeg-turbo/src/jdatadst.c
vendored
48
3rdparty/libjpeg-turbo/src/jdatadst.c
vendored
@ -24,8 +24,8 @@
|
||||
#include "jerror.h"
|
||||
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
||||
extern void *malloc (size_t size);
|
||||
extern void free (void *ptr);
|
||||
extern void *malloc(size_t size);
|
||||
extern void free(void *ptr);
|
||||
#endif
|
||||
|
||||
|
||||
@ -66,13 +66,13 @@ typedef my_mem_destination_mgr *my_mem_dest_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
init_destination (j_compress_ptr cinfo)
|
||||
init_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
||||
|
||||
/* Allocate the output buffer --- it will be released when done with image */
|
||||
dest->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
OUTPUT_BUF_SIZE * sizeof(JOCTET));
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
@ -81,7 +81,7 @@ init_destination (j_compress_ptr cinfo)
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
METHODDEF(void)
|
||||
init_mem_destination (j_compress_ptr cinfo)
|
||||
init_mem_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
/* no work necessary here */
|
||||
}
|
||||
@ -112,12 +112,12 @@ init_mem_destination (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
empty_output_buffer (j_compress_ptr cinfo)
|
||||
empty_output_buffer(j_compress_ptr cinfo)
|
||||
{
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
||||
|
||||
if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
|
||||
(size_t) OUTPUT_BUF_SIZE)
|
||||
(size_t)OUTPUT_BUF_SIZE)
|
||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
@ -128,15 +128,15 @@ empty_output_buffer (j_compress_ptr cinfo)
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
METHODDEF(boolean)
|
||||
empty_mem_output_buffer (j_compress_ptr cinfo)
|
||||
empty_mem_output_buffer(j_compress_ptr cinfo)
|
||||
{
|
||||
size_t nextsize;
|
||||
JOCTET *nextbuffer;
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
|
||||
|
||||
/* Try to allocate new buffer with double size */
|
||||
nextsize = dest->bufsize * 2;
|
||||
nextbuffer = (JOCTET *) malloc(nextsize);
|
||||
nextbuffer = (JOCTET *)malloc(nextsize);
|
||||
|
||||
if (nextbuffer == NULL)
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||
@ -169,9 +169,9 @@ empty_mem_output_buffer (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
term_destination (j_compress_ptr cinfo)
|
||||
term_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
||||
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
|
||||
|
||||
/* Write any data remaining in the buffer */
|
||||
@ -187,9 +187,9 @@ term_destination (j_compress_ptr cinfo)
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
METHODDEF(void)
|
||||
term_mem_destination (j_compress_ptr cinfo)
|
||||
term_mem_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
|
||||
|
||||
*dest->outbuffer = dest->buffer;
|
||||
*dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
|
||||
@ -204,7 +204,7 @@ term_mem_destination (j_compress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
|
||||
jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
|
||||
{
|
||||
my_dest_ptr dest;
|
||||
|
||||
@ -213,7 +213,7 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
|
||||
*/
|
||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_destination_mgr));
|
||||
} else if (cinfo->dest->init_destination != init_destination) {
|
||||
/* It is unsafe to reuse the existing destination manager unless it was
|
||||
@ -225,7 +225,7 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
dest = (my_dest_ptr) cinfo->dest;
|
||||
dest = (my_dest_ptr)cinfo->dest;
|
||||
dest->pub.init_destination = init_destination;
|
||||
dest->pub.empty_output_buffer = empty_output_buffer;
|
||||
dest->pub.term_destination = term_destination;
|
||||
@ -249,8 +249,8 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
unsigned char **outbuffer, unsigned long *outsize)
|
||||
jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
|
||||
unsigned long *outsize)
|
||||
{
|
||||
my_mem_dest_ptr dest;
|
||||
|
||||
@ -262,7 +262,7 @@ jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
*/
|
||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_mem_destination_mgr));
|
||||
} else if (cinfo->dest->init_destination != init_mem_destination) {
|
||||
/* It is unsafe to reuse the existing destination manager unless it was
|
||||
@ -271,7 +271,7 @@ jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
dest = (my_mem_dest_ptr)cinfo->dest;
|
||||
dest->pub.init_destination = init_mem_destination;
|
||||
dest->pub.empty_output_buffer = empty_mem_output_buffer;
|
||||
dest->pub.term_destination = term_mem_destination;
|
||||
@ -281,7 +281,7 @@ jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
|
||||
if (*outbuffer == NULL || *outsize == 0) {
|
||||
/* Allocate initial buffer */
|
||||
dest->newbuffer = *outbuffer = (unsigned char *) malloc(OUTPUT_BUF_SIZE);
|
||||
dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE);
|
||||
if (dest->newbuffer == NULL)
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||
*outsize = OUTPUT_BUF_SIZE;
|
||||
|
52
3rdparty/libjpeg-turbo/src/jdatasrc.c
vendored
52
3rdparty/libjpeg-turbo/src/jdatasrc.c
vendored
@ -45,9 +45,9 @@ typedef my_source_mgr *my_src_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
init_source (j_decompress_ptr cinfo)
|
||||
init_source(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_src_ptr src = (my_src_ptr) cinfo->src;
|
||||
my_src_ptr src = (my_src_ptr)cinfo->src;
|
||||
|
||||
/* We reset the empty-input-file flag for each image,
|
||||
* but we don't clear the input buffer.
|
||||
@ -58,7 +58,7 @@ init_source (j_decompress_ptr cinfo)
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
METHODDEF(void)
|
||||
init_mem_source (j_decompress_ptr cinfo)
|
||||
init_mem_source(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work necessary here */
|
||||
}
|
||||
@ -99,9 +99,9 @@ init_mem_source (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
fill_input_buffer (j_decompress_ptr cinfo)
|
||||
fill_input_buffer(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_src_ptr src = (my_src_ptr) cinfo->src;
|
||||
my_src_ptr src = (my_src_ptr)cinfo->src;
|
||||
size_t nbytes;
|
||||
|
||||
nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE);
|
||||
@ -111,8 +111,8 @@ fill_input_buffer (j_decompress_ptr cinfo)
|
||||
ERREXIT(cinfo, JERR_INPUT_EMPTY);
|
||||
WARNMS(cinfo, JWRN_JPEG_EOF);
|
||||
/* Insert a fake EOI marker */
|
||||
src->buffer[0] = (JOCTET) 0xFF;
|
||||
src->buffer[1] = (JOCTET) JPEG_EOI;
|
||||
src->buffer[0] = (JOCTET)0xFF;
|
||||
src->buffer[1] = (JOCTET)JPEG_EOI;
|
||||
nbytes = 2;
|
||||
}
|
||||
|
||||
@ -125,10 +125,10 @@ fill_input_buffer (j_decompress_ptr cinfo)
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
METHODDEF(boolean)
|
||||
fill_mem_input_buffer (j_decompress_ptr cinfo)
|
||||
fill_mem_input_buffer(j_decompress_ptr cinfo)
|
||||
{
|
||||
static const JOCTET mybuffer[4] = {
|
||||
(JOCTET) 0xFF, (JOCTET) JPEG_EOI, 0, 0
|
||||
(JOCTET)0xFF, (JOCTET)JPEG_EOI, 0, 0
|
||||
};
|
||||
|
||||
/* The whole JPEG data is expected to reside in the supplied memory
|
||||
@ -160,7 +160,7 @@ fill_mem_input_buffer (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
skip_input_data(j_decompress_ptr cinfo, long num_bytes)
|
||||
{
|
||||
struct jpeg_source_mgr *src = cinfo->src;
|
||||
|
||||
@ -169,15 +169,15 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
* any trouble anyway --- large skips are infrequent.
|
||||
*/
|
||||
if (num_bytes > 0) {
|
||||
while (num_bytes > (long) src->bytes_in_buffer) {
|
||||
num_bytes -= (long) src->bytes_in_buffer;
|
||||
(void) (*src->fill_input_buffer) (cinfo);
|
||||
while (num_bytes > (long)src->bytes_in_buffer) {
|
||||
num_bytes -= (long)src->bytes_in_buffer;
|
||||
(void)(*src->fill_input_buffer) (cinfo);
|
||||
/* note we assume that fill_input_buffer will never return FALSE,
|
||||
* so suspension need not be handled.
|
||||
*/
|
||||
}
|
||||
src->next_input_byte += (size_t) num_bytes;
|
||||
src->bytes_in_buffer -= (size_t) num_bytes;
|
||||
src->next_input_byte += (size_t)num_bytes;
|
||||
src->bytes_in_buffer -= (size_t)num_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
term_source (j_decompress_ptr cinfo)
|
||||
term_source(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work necessary here */
|
||||
}
|
||||
@ -214,7 +214,7 @@ term_source (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile)
|
||||
jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile)
|
||||
{
|
||||
my_src_ptr src;
|
||||
|
||||
@ -225,11 +225,11 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile)
|
||||
*/
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_source_mgr));
|
||||
src = (my_src_ptr) cinfo->src;
|
||||
src = (my_src_ptr)cinfo->src;
|
||||
src->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
INPUT_BUF_SIZE * sizeof(JOCTET));
|
||||
} else if (cinfo->src->init_source != init_source) {
|
||||
/* It is unsafe to reuse the existing source manager unless it was created
|
||||
@ -241,7 +241,7 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile)
|
||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
src = (my_src_ptr) cinfo->src;
|
||||
src = (my_src_ptr)cinfo->src;
|
||||
src->pub.init_source = init_source;
|
||||
src->pub.fill_input_buffer = fill_input_buffer;
|
||||
src->pub.skip_input_data = skip_input_data;
|
||||
@ -260,8 +260,8 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
const unsigned char *inbuffer, unsigned long insize)
|
||||
jpeg_mem_src(j_decompress_ptr cinfo, const unsigned char *inbuffer,
|
||||
unsigned long insize)
|
||||
{
|
||||
struct jpeg_source_mgr *src;
|
||||
|
||||
@ -274,7 +274,7 @@ jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
*/
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(struct jpeg_source_mgr));
|
||||
} else if (cinfo->src->init_source != init_mem_source) {
|
||||
/* It is unsafe to reuse the existing source manager unless it was created
|
||||
@ -289,7 +289,7 @@ jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
src->skip_input_data = skip_input_data;
|
||||
src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
|
||||
src->term_source = term_source;
|
||||
src->bytes_in_buffer = (size_t) insize;
|
||||
src->next_input_byte = (const JOCTET *) inbuffer;
|
||||
src->bytes_in_buffer = (size_t)insize;
|
||||
src->next_input_byte = (const JOCTET *)inbuffer;
|
||||
}
|
||||
#endif
|
||||
|
235
3rdparty/libjpeg-turbo/src/jdcoefct.c
vendored
235
3rdparty/libjpeg-turbo/src/jdcoefct.c
vendored
@ -25,16 +25,15 @@
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(int) decompress_onepass
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
METHODDEF(int) decompress_onepass(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE output_buf);
|
||||
#ifdef D_MULTISCAN_FILES_SUPPORTED
|
||||
METHODDEF(int) decompress_data
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
METHODDEF(int) decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
#endif
|
||||
#ifdef BLOCK_SMOOTHING_SUPPORTED
|
||||
LOCAL(boolean) smoothing_ok (j_decompress_ptr cinfo);
|
||||
METHODDEF(int) decompress_smooth_data
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
||||
LOCAL(boolean) smoothing_ok(j_decompress_ptr cinfo);
|
||||
METHODDEF(int) decompress_smooth_data(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE output_buf);
|
||||
#endif
|
||||
|
||||
|
||||
@ -43,7 +42,7 @@ METHODDEF(int) decompress_smooth_data
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_input_pass (j_decompress_ptr cinfo)
|
||||
start_input_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
cinfo->input_iMCU_row = 0;
|
||||
start_iMCU_row(cinfo);
|
||||
@ -55,10 +54,10 @@ start_input_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_output_pass (j_decompress_ptr cinfo)
|
||||
start_output_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
#ifdef BLOCK_SMOOTHING_SUPPORTED
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
/* If multipass, check to see whether to use block smoothing on this pass */
|
||||
if (coef->pub.coef_arrays != NULL) {
|
||||
@ -83,9 +82,9 @@ start_output_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
decompress_onepass(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
@ -101,9 +100,9 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
|
||||
MCU_col_num++) {
|
||||
/* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
|
||||
jzero_far((void *) coef->MCU_buffer[0],
|
||||
(size_t) (cinfo->blocks_in_MCU * sizeof(JBLOCK)));
|
||||
if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
jzero_far((void *)coef->MCU_buffer[0],
|
||||
(size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
|
||||
if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
coef->MCU_ctr = MCU_col_num;
|
||||
@ -124,24 +123,24 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
/* Don't bother to IDCT an uninteresting component. */
|
||||
if (! compptr->component_needed) {
|
||||
if (!compptr->component_needed) {
|
||||
blkn += compptr->MCU_blocks;
|
||||
continue;
|
||||
}
|
||||
inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
|
||||
useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
||||
: compptr->last_col_width;
|
||||
useful_width = (MCU_col_num < last_MCU_col) ?
|
||||
compptr->MCU_width : compptr->last_col_width;
|
||||
output_ptr = output_buf[compptr->component_index] +
|
||||
yoffset * compptr->_DCT_scaled_size;
|
||||
start_col = (MCU_col_num - cinfo->master->first_iMCU_col) *
|
||||
compptr->MCU_sample_width;
|
||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||
if (cinfo->input_iMCU_row < last_iMCU_row ||
|
||||
yoffset+yindex < compptr->last_row_height) {
|
||||
yoffset + yindex < compptr->last_row_height) {
|
||||
output_col = start_col;
|
||||
for (xindex = 0; xindex < useful_width; xindex++) {
|
||||
(*inverse_DCT) (cinfo, compptr,
|
||||
(JCOEFPTR) coef->MCU_buffer[blkn+xindex],
|
||||
(JCOEFPTR)coef->MCU_buffer[blkn + xindex],
|
||||
output_ptr, output_col);
|
||||
output_col += compptr->_DCT_scaled_size;
|
||||
}
|
||||
@ -172,7 +171,7 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
dummy_consume_data (j_decompress_ptr cinfo)
|
||||
dummy_consume_data(j_decompress_ptr cinfo)
|
||||
{
|
||||
return JPEG_SUSPENDED; /* Always indicate nothing was done */
|
||||
}
|
||||
@ -188,9 +187,9 @@ dummy_consume_data (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
consume_data (j_decompress_ptr cinfo)
|
||||
consume_data(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||
int blkn, ci, xindex, yindex, yoffset;
|
||||
JDIMENSION start_col;
|
||||
@ -202,9 +201,9 @@ consume_data (j_decompress_ptr cinfo)
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
buffer[ci] = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
|
||||
((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
|
||||
cinfo->input_iMCU_row * compptr->v_samp_factor,
|
||||
(JDIMENSION) compptr->v_samp_factor, TRUE);
|
||||
(JDIMENSION)compptr->v_samp_factor, TRUE);
|
||||
/* Note: entropy decoder expects buffer to be zeroed,
|
||||
* but this is handled automatically by the memory manager
|
||||
* because we requested a pre-zeroed array.
|
||||
@ -222,14 +221,14 @@ consume_data (j_decompress_ptr cinfo)
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
start_col = MCU_col_num * compptr->MCU_width;
|
||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
||||
buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
|
||||
for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
|
||||
coef->MCU_buffer[blkn++] = buffer_ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Try to fetch the MCU. */
|
||||
if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||
/* Suspension forced; update state counters and exit */
|
||||
coef->MCU_vert_offset = yoffset;
|
||||
coef->MCU_ctr = MCU_col_num;
|
||||
@ -259,9 +258,9 @@ consume_data (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
JDIMENSION block_num;
|
||||
int ci, block_row, block_rows;
|
||||
@ -276,7 +275,7 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
while (cinfo->input_scan_number < cinfo->output_scan_number ||
|
||||
(cinfo->input_scan_number == cinfo->output_scan_number &&
|
||||
cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
|
||||
if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
|
||||
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
||||
return JPEG_SUSPENDED;
|
||||
}
|
||||
|
||||
@ -284,19 +283,19 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
/* Don't bother to IDCT an uninteresting component. */
|
||||
if (! compptr->component_needed)
|
||||
if (!compptr->component_needed)
|
||||
continue;
|
||||
/* Align the virtual buffer for this component. */
|
||||
buffer = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[ci],
|
||||
((j_common_ptr)cinfo, coef->whole_image[ci],
|
||||
cinfo->output_iMCU_row * compptr->v_samp_factor,
|
||||
(JDIMENSION) compptr->v_samp_factor, FALSE);
|
||||
(JDIMENSION)compptr->v_samp_factor, FALSE);
|
||||
/* Count non-dummy DCT block rows in this iMCU row. */
|
||||
if (cinfo->output_iMCU_row < last_iMCU_row)
|
||||
block_rows = compptr->v_samp_factor;
|
||||
else {
|
||||
/* NB: can't use last_row_height here; it is input-side-dependent! */
|
||||
block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
if (block_rows == 0) block_rows = compptr->v_samp_factor;
|
||||
}
|
||||
inverse_DCT = cinfo->idct->inverse_DCT[ci];
|
||||
@ -307,8 +306,8 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
output_col = 0;
|
||||
for (block_num = cinfo->master->first_MCU_col[ci];
|
||||
block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
|
||||
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
|
||||
output_ptr, output_col);
|
||||
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr,
|
||||
output_col);
|
||||
buffer_ptr++;
|
||||
output_col += compptr->_DCT_scaled_size;
|
||||
}
|
||||
@ -350,9 +349,9 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
smoothing_ok (j_decompress_ptr cinfo)
|
||||
smoothing_ok(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
boolean smoothing_useful = FALSE;
|
||||
int ci, coefi;
|
||||
jpeg_component_info *compptr;
|
||||
@ -360,13 +359,13 @@ smoothing_ok (j_decompress_ptr cinfo)
|
||||
int *coef_bits;
|
||||
int *coef_bits_latch;
|
||||
|
||||
if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)
|
||||
if (!cinfo->progressive_mode || cinfo->coef_bits == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* Allocate latch area if not already done */
|
||||
if (coef->coef_bits_latch == NULL)
|
||||
coef->coef_bits_latch = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components *
|
||||
(SAVED_COEFS * sizeof(int)));
|
||||
coef_bits_latch = coef->coef_bits_latch;
|
||||
@ -406,9 +405,9 @@ smoothing_ok (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||
JDIMENSION block_num, last_block_column;
|
||||
int ci, block_row, block_rows, access_rows;
|
||||
@ -422,8 +421,8 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
JCOEF *workspace;
|
||||
int *coef_bits;
|
||||
JQUANT_TBL *quanttbl;
|
||||
JLONG Q00,Q01,Q02,Q10,Q11,Q20, num;
|
||||
int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
|
||||
JLONG Q00, Q01, Q02, Q10, Q11, Q20, num;
|
||||
int DC1, DC2, DC3, DC4, DC5, DC6, DC7, DC8, DC9;
|
||||
int Al, pred;
|
||||
|
||||
/* Keep a local variable to avoid looking it up more than once */
|
||||
@ -431,7 +430,7 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
|
||||
/* Force some input to be done if we are getting ahead of the input. */
|
||||
while (cinfo->input_scan_number <= cinfo->output_scan_number &&
|
||||
! cinfo->inputctl->eoi_reached) {
|
||||
!cinfo->inputctl->eoi_reached) {
|
||||
if (cinfo->input_scan_number == cinfo->output_scan_number) {
|
||||
/* If input is working on current scan, we ordinarily want it to
|
||||
* have completed the current row. But if input scan is DC,
|
||||
@ -439,10 +438,10 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
* values are up to date.
|
||||
*/
|
||||
JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;
|
||||
if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)
|
||||
if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta)
|
||||
break;
|
||||
}
|
||||
if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
|
||||
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
||||
return JPEG_SUSPENDED;
|
||||
}
|
||||
|
||||
@ -450,7 +449,7 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
/* Don't bother to IDCT an uninteresting component. */
|
||||
if (! compptr->component_needed)
|
||||
if (!compptr->component_needed)
|
||||
continue;
|
||||
/* Count non-dummy DCT block rows in this iMCU row. */
|
||||
if (cinfo->output_iMCU_row < last_iMCU_row) {
|
||||
@ -459,7 +458,7 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
last_row = FALSE;
|
||||
} else {
|
||||
/* NB: can't use last_row_height here; it is input-side-dependent! */
|
||||
block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
if (block_rows == 0) block_rows = compptr->v_samp_factor;
|
||||
access_rows = block_rows; /* this iMCU row only */
|
||||
last_row = TRUE;
|
||||
@ -468,15 +467,15 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
if (cinfo->output_iMCU_row > 0) {
|
||||
access_rows += compptr->v_samp_factor; /* prior iMCU row too */
|
||||
buffer = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[ci],
|
||||
((j_common_ptr)cinfo, coef->whole_image[ci],
|
||||
(cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
|
||||
(JDIMENSION) access_rows, FALSE);
|
||||
(JDIMENSION)access_rows, FALSE);
|
||||
buffer += compptr->v_samp_factor; /* point to current iMCU row */
|
||||
first_row = FALSE;
|
||||
} else {
|
||||
buffer = (*cinfo->mem->access_virt_barray)
|
||||
((j_common_ptr) cinfo, coef->whole_image[ci],
|
||||
(JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);
|
||||
((j_common_ptr)cinfo, coef->whole_image[ci],
|
||||
(JDIMENSION)0, (JDIMENSION)access_rows, FALSE);
|
||||
first_row = TRUE;
|
||||
}
|
||||
/* Fetch component-dependent info */
|
||||
@ -496,111 +495,111 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
if (first_row && block_row == 0)
|
||||
prev_block_row = buffer_ptr;
|
||||
else
|
||||
prev_block_row = buffer[block_row-1];
|
||||
if (last_row && block_row == block_rows-1)
|
||||
prev_block_row = buffer[block_row - 1];
|
||||
if (last_row && block_row == block_rows - 1)
|
||||
next_block_row = buffer_ptr;
|
||||
else
|
||||
next_block_row = buffer[block_row+1];
|
||||
next_block_row = buffer[block_row + 1];
|
||||
/* We fetch the surrounding DC values using a sliding-register approach.
|
||||
* Initialize all nine here so as to do the right thing on narrow pics.
|
||||
*/
|
||||
DC1 = DC2 = DC3 = (int) prev_block_row[0][0];
|
||||
DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];
|
||||
DC7 = DC8 = DC9 = (int) next_block_row[0][0];
|
||||
DC1 = DC2 = DC3 = (int)prev_block_row[0][0];
|
||||
DC4 = DC5 = DC6 = (int)buffer_ptr[0][0];
|
||||
DC7 = DC8 = DC9 = (int)next_block_row[0][0];
|
||||
output_col = 0;
|
||||
last_block_column = compptr->width_in_blocks - 1;
|
||||
for (block_num = cinfo->master->first_MCU_col[ci];
|
||||
block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
|
||||
/* Fetch current DCT block into workspace so we can modify it. */
|
||||
jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);
|
||||
jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1);
|
||||
/* Update DC values */
|
||||
if (block_num < last_block_column) {
|
||||
DC3 = (int) prev_block_row[1][0];
|
||||
DC6 = (int) buffer_ptr[1][0];
|
||||
DC9 = (int) next_block_row[1][0];
|
||||
DC3 = (int)prev_block_row[1][0];
|
||||
DC6 = (int)buffer_ptr[1][0];
|
||||
DC9 = (int)next_block_row[1][0];
|
||||
}
|
||||
/* Compute coefficient estimates per K.8.
|
||||
* An estimate is applied only if coefficient is still zero,
|
||||
* and is not known to be fully accurate.
|
||||
*/
|
||||
/* AC01 */
|
||||
if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
|
||||
if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) {
|
||||
num = 36 * Q00 * (DC4 - DC6);
|
||||
if (num >= 0) {
|
||||
pred = (int) (((Q01<<7) + num) / (Q01<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q01 << 7) + num) / (Q01 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
} else {
|
||||
pred = (int) (((Q01<<7) - num) / (Q01<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q01 << 7) - num) / (Q01 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
pred = -pred;
|
||||
}
|
||||
workspace[1] = (JCOEF) pred;
|
||||
workspace[1] = (JCOEF)pred;
|
||||
}
|
||||
/* AC10 */
|
||||
if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {
|
||||
if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) {
|
||||
num = 36 * Q00 * (DC2 - DC8);
|
||||
if (num >= 0) {
|
||||
pred = (int) (((Q10<<7) + num) / (Q10<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q10 << 7) + num) / (Q10 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
} else {
|
||||
pred = (int) (((Q10<<7) - num) / (Q10<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q10 << 7) - num) / (Q10 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
pred = -pred;
|
||||
}
|
||||
workspace[8] = (JCOEF) pred;
|
||||
workspace[8] = (JCOEF)pred;
|
||||
}
|
||||
/* AC20 */
|
||||
if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {
|
||||
num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
|
||||
if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) {
|
||||
num = 9 * Q00 * (DC2 + DC8 - 2 * DC5);
|
||||
if (num >= 0) {
|
||||
pred = (int) (((Q20<<7) + num) / (Q20<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q20 << 7) + num) / (Q20 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
} else {
|
||||
pred = (int) (((Q20<<7) - num) / (Q20<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q20 << 7) - num) / (Q20 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
pred = -pred;
|
||||
}
|
||||
workspace[16] = (JCOEF) pred;
|
||||
workspace[16] = (JCOEF)pred;
|
||||
}
|
||||
/* AC11 */
|
||||
if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {
|
||||
if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) {
|
||||
num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
|
||||
if (num >= 0) {
|
||||
pred = (int) (((Q11<<7) + num) / (Q11<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q11 << 7) + num) / (Q11 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
} else {
|
||||
pred = (int) (((Q11<<7) - num) / (Q11<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q11 << 7) - num) / (Q11 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
pred = -pred;
|
||||
}
|
||||
workspace[9] = (JCOEF) pred;
|
||||
workspace[9] = (JCOEF)pred;
|
||||
}
|
||||
/* AC02 */
|
||||
if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {
|
||||
num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
|
||||
if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) {
|
||||
num = 9 * Q00 * (DC4 + DC6 - 2 * DC5);
|
||||
if (num >= 0) {
|
||||
pred = (int) (((Q02<<7) + num) / (Q02<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q02 << 7) + num) / (Q02 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
} else {
|
||||
pred = (int) (((Q02<<7) - num) / (Q02<<8));
|
||||
if (Al > 0 && pred >= (1<<Al))
|
||||
pred = (1<<Al)-1;
|
||||
pred = (int)(((Q02 << 7) - num) / (Q02 << 8));
|
||||
if (Al > 0 && pred >= (1 << Al))
|
||||
pred = (1 << Al) - 1;
|
||||
pred = -pred;
|
||||
}
|
||||
workspace[2] = (JCOEF) pred;
|
||||
workspace[2] = (JCOEF)pred;
|
||||
}
|
||||
/* OK, do the IDCT */
|
||||
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,
|
||||
output_ptr, output_col);
|
||||
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr,
|
||||
output_col);
|
||||
/* Advance for next column */
|
||||
DC1 = DC2; DC2 = DC3;
|
||||
DC4 = DC5; DC5 = DC6;
|
||||
@ -625,14 +624,14 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_coef_ptr coef;
|
||||
|
||||
coef = (my_coef_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_coef_controller));
|
||||
cinfo->coef = (struct jpeg_d_coef_controller *) coef;
|
||||
cinfo->coef = (struct jpeg_d_coef_controller *)coef;
|
||||
coef->pub.start_input_pass = start_input_pass;
|
||||
coef->pub.start_output_pass = start_output_pass;
|
||||
#ifdef BLOCK_SMOOTHING_SUPPORTED
|
||||
@ -657,12 +656,12 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
access_rows *= 3;
|
||||
#endif
|
||||
coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE,
|
||||
(JDIMENSION) jround_up((long) compptr->width_in_blocks,
|
||||
(long) compptr->h_samp_factor),
|
||||
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
|
||||
(long) compptr->v_samp_factor),
|
||||
(JDIMENSION) access_rows);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
|
||||
(JDIMENSION)jround_up((long)compptr->width_in_blocks,
|
||||
(long)compptr->h_samp_factor),
|
||||
(JDIMENSION)jround_up((long)compptr->height_in_blocks,
|
||||
(long)compptr->v_samp_factor),
|
||||
(JDIMENSION)access_rows);
|
||||
}
|
||||
coef->pub.consume_data = consume_data;
|
||||
coef->pub.decompress_data = decompress_data;
|
||||
@ -676,7 +675,7 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
int i;
|
||||
|
||||
buffer = (JBLOCKROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||
for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
|
||||
coef->MCU_buffer[i] = buffer + i;
|
||||
@ -688,6 +687,6 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
|
||||
/* Allocate the workspace buffer */
|
||||
coef->workspace = (JCOEF *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(JCOEF) * DCTSIZE2);
|
||||
}
|
||||
|
6
3rdparty/libjpeg-turbo/src/jdcoefct.h
vendored
6
3rdparty/libjpeg-turbo/src/jdcoefct.h
vendored
@ -59,10 +59,10 @@ typedef my_coef_controller *my_coef_ptr;
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
start_iMCU_row (j_decompress_ptr cinfo)
|
||||
start_iMCU_row(j_decompress_ptr cinfo)
|
||||
/* Reset within-iMCU-row counters for a new row (input side) */
|
||||
{
|
||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
|
||||
/* In an interleaved scan, an MCU row is the same as an iMCU row.
|
||||
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
|
||||
@ -71,7 +71,7 @@ start_iMCU_row (j_decompress_ptr cinfo)
|
||||
if (cinfo->comps_in_scan > 1) {
|
||||
coef->MCU_rows_per_iMCU_row = 1;
|
||||
} else {
|
||||
if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))
|
||||
if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows - 1))
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
|
||||
else
|
||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
||||
|
88
3rdparty/libjpeg-turbo/src/jdcol565.c
vendored
88
3rdparty/libjpeg-turbo/src/jdcol565.c
vendored
@ -17,22 +17,22 @@
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
ycc_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int y, cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
register int * Crrtab = cconvert->Cr_r_tab;
|
||||
register int * Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG * Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG * Cbgtab = cconvert->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
register int *Crrtab = cconvert->Cr_r_tab;
|
||||
register int *Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG *Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG *Cbgtab = cconvert->Cb_g_tab;
|
||||
SHIFT_TEMPS
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
@ -53,7 +53,7 @@ ycc_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
SCALEBITS))];
|
||||
b = range_limit[y + Cbbtab[cb]];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@ -88,7 +88,7 @@ ycc_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
SCALEBITS))];
|
||||
b = range_limit[y + Cbbtab[cb]];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,22 +96,22 @@ ycc_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
ycc_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int y, cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
register int * Crrtab = cconvert->Cr_r_tab;
|
||||
register int * Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG * Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG * Cbgtab = cconvert->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
register int *Crrtab = cconvert->Cr_r_tab;
|
||||
register int *Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG *Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG *Cbgtab = cconvert->Cb_g_tab;
|
||||
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
SHIFT_TEMPS
|
||||
|
||||
@ -134,7 +134,7 @@ ycc_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
SCALEBITS)), d0)];
|
||||
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@ -174,7 +174,7 @@ ycc_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
SCALEBITS)), d0)];
|
||||
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -182,9 +182,9 @@ ycc_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
@ -206,7 +206,7 @@ rgb_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
g = GETJSAMPLE(*inptr1++);
|
||||
b = GETJSAMPLE(*inptr2++);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@ -229,7 +229,7 @@ rgb_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
g = GETJSAMPLE(*inptr1);
|
||||
b = GETJSAMPLE(*inptr2);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -237,14 +237,14 @@ rgb_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
SHIFT_TEMPS
|
||||
@ -263,7 +263,7 @@ rgb_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
g = range_limit[DITHER_565_G(GETJSAMPLE(*inptr1++), d0)];
|
||||
b = range_limit[DITHER_565_B(GETJSAMPLE(*inptr2++), d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@ -288,7 +288,7 @@ rgb_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
g = range_limit[DITHER_565_G(GETJSAMPLE(*inptr1), d0)];
|
||||
b = range_limit[DITHER_565_B(GETJSAMPLE(*inptr2), d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -296,9 +296,9 @@ rgb_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
gray_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
@ -313,7 +313,7 @@ gray_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
if (PACK_NEED_ALIGNMENT(outptr)) {
|
||||
g = *inptr++;
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@ -328,7 +328,7 @@ gray_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
if (num_cols & 1) {
|
||||
g = *inptr;
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -336,13 +336,13 @@ gray_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
gray_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
|
||||
@ -356,7 +356,7 @@ gray_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
g = *inptr++;
|
||||
g = range_limit[DITHER_565_R(g, d0)];
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
outptr += 2;
|
||||
num_cols--;
|
||||
}
|
||||
@ -378,7 +378,7 @@ gray_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
g = *inptr;
|
||||
g = range_limit[DITHER_565_R(g, d0)];
|
||||
rgb = PACK_SHORT_565(g, g, g);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
3rdparty/libjpeg-turbo/src/jdcolext.c
vendored
32
3rdparty/libjpeg-turbo/src/jdcolext.c
vendored
@ -28,22 +28,22 @@
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
ycc_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int y, cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
register int * Crrtab = cconvert->Cr_r_tab;
|
||||
register int * Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG * Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG * Cbgtab = cconvert->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
register int *Crrtab = cconvert->Cr_r_tab;
|
||||
register int *Cbbtab = cconvert->Cb_b_tab;
|
||||
register JLONG *Crgtab = cconvert->Cr_g_tab;
|
||||
register JLONG *Cbgtab = cconvert->Cb_g_tab;
|
||||
SHIFT_TEMPS
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
@ -59,7 +59,7 @@ ycc_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
/* Range-limiting is essential due to noise introduced by DCT losses. */
|
||||
outptr[RGB_RED] = range_limit[y + Crrtab[cr]];
|
||||
outptr[RGB_GREEN] = range_limit[y +
|
||||
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS))];
|
||||
outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]];
|
||||
/* Set unused byte to 0xFF so it can be interpreted as an opaque */
|
||||
@ -81,9 +81,9 @@ ycc_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
gray_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
@ -112,9 +112,9 @@ gray_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JSAMPROW outptr;
|
||||
|
136
3rdparty/libjpeg-turbo/src/jdcolor.c
vendored
136
3rdparty/libjpeg-turbo/src/jdcolor.c
vendored
@ -74,8 +74,8 @@ typedef my_color_deconverter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
||||
#define ONE_HALF ((JLONG) 1 << (SCALEBITS-1))
|
||||
#define FIX(x) ((JLONG) ((x) * (1L<<SCALEBITS) + 0.5))
|
||||
#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
|
||||
#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
|
||||
|
||||
/* We allocate one big table for RGB->Y conversion and divide it up into
|
||||
* three parts, instead of doing three alloc_small requests. This lets us
|
||||
@ -85,9 +85,9 @@ typedef my_color_deconverter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
#define R_Y_OFF 0 /* offset to R => Y section */
|
||||
#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */
|
||||
#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */
|
||||
#define TABLE_SIZE (3*(MAXJSAMPLE+1))
|
||||
#define G_Y_OFF (1 * (MAXJSAMPLE + 1)) /* offset to G => Y section */
|
||||
#define B_Y_OFF (2 * (MAXJSAMPLE + 1)) /* etc. */
|
||||
#define TABLE_SIZE (3 * (MAXJSAMPLE + 1))
|
||||
|
||||
|
||||
/* Include inline routines for colorspace extensions */
|
||||
@ -208,25 +208,25 @@ typedef my_color_deconverter *my_cconvert_ptr;
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
build_ycc_rgb_table(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
int i;
|
||||
JLONG x;
|
||||
SHIFT_TEMPS
|
||||
|
||||
cconvert->Cr_r_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(int));
|
||||
cconvert->Cb_b_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(int));
|
||||
cconvert->Cr_g_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(JLONG));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(JLONG));
|
||||
cconvert->Cb_g_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(JLONG));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(JLONG));
|
||||
|
||||
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
||||
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
|
||||
@ -238,10 +238,10 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
cconvert->Cb_b_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.71414 * x */
|
||||
cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x;
|
||||
cconvert->Cr_g_tab[i] = (-FIX(0.71414)) * x;
|
||||
/* Cb=>G value is scaled-up -0.34414 * x */
|
||||
/* We also add in ONE_HALF so that need not do it in inner loop */
|
||||
cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;
|
||||
cconvert->Cb_g_tab[i] = (-FIX(0.34414)) * x + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,9 +251,8 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@ -300,21 +299,21 @@ ycc_rgb_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
build_rgb_y_table (j_decompress_ptr cinfo)
|
||||
build_rgb_y_table(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
JLONG *rgb_y_tab;
|
||||
JLONG i;
|
||||
|
||||
/* Allocate and fill in the conversion tables. */
|
||||
cconvert->rgb_y_tab = rgb_y_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(TABLE_SIZE * sizeof(JLONG)));
|
||||
|
||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||
rgb_y_tab[i+R_Y_OFF] = FIX(0.29900) * i;
|
||||
rgb_y_tab[i+G_Y_OFF] = FIX(0.58700) * i;
|
||||
rgb_y_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
||||
rgb_y_tab[i + R_Y_OFF] = FIX(0.29900) * i;
|
||||
rgb_y_tab[i + G_Y_OFF] = FIX(0.58700) * i;
|
||||
rgb_y_tab[i + B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,11 +323,10 @@ build_rgb_y_table (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_gray_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_gray_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register JLONG *ctab = cconvert->rgb_y_tab;
|
||||
register JSAMPROW outptr;
|
||||
@ -347,9 +345,8 @@ rgb_gray_convert (j_decompress_ptr cinfo,
|
||||
g = GETJSAMPLE(inptr1[col]);
|
||||
b = GETJSAMPLE(inptr2[col]);
|
||||
/* Y */
|
||||
outptr[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
|
||||
ctab[b + B_Y_OFF]) >> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -361,9 +358,8 @@ rgb_gray_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
null_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
null_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, inptr0, inptr1, inptr2, inptr3, outptr;
|
||||
register JDIMENSION col;
|
||||
@ -423,12 +419,11 @@ null_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
grayscale_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
grayscale_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0,
|
||||
num_rows, cinfo->output_width);
|
||||
jcopy_sample_rows(input_buf[0], (int)input_row, output_buf, 0, num_rows,
|
||||
cinfo->output_width);
|
||||
}
|
||||
|
||||
|
||||
@ -437,9 +432,8 @@ grayscale_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@ -483,9 +477,8 @@ gray_rgb_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@ -532,11 +525,10 @@ rgb_rgb_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
ycck_cmyk_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycck_cmyk_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
||||
register int y, cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2, inptr3;
|
||||
@ -564,7 +556,7 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
|
||||
/* Range-limiting is essential due to noise introduced by DCT losses. */
|
||||
outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */
|
||||
outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */
|
||||
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS)))];
|
||||
outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */
|
||||
/* K passes through unchanged */
|
||||
@ -600,7 +592,7 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
|
||||
/* Declarations for ordered dithering
|
||||
*
|
||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||
* sufficent for dithering RGB888 to RGB565.
|
||||
* sufficient for dithering RGB888 to RGB565.
|
||||
*/
|
||||
|
||||
#define DITHER_MASK 0x3
|
||||
@ -662,9 +654,8 @@ static INLINE boolean is_big_endian(void)
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
ycc_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@ -674,9 +665,8 @@ ycc_rgb565_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
ycc_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
ycc_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@ -686,9 +676,8 @@ ycc_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
rgb_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@ -698,9 +687,8 @@ rgb_rgb565_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
rgb_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
rgb_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@ -710,9 +698,8 @@ rgb_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
gray_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@ -722,9 +709,8 @@ gray_rgb565_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
gray_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
gray_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
@ -738,7 +724,7 @@ gray_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_dcolor (j_decompress_ptr cinfo)
|
||||
start_pass_dcolor(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work needed */
|
||||
}
|
||||
@ -749,15 +735,15 @@ start_pass_dcolor (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
jinit_color_deconverter(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert;
|
||||
int ci;
|
||||
|
||||
cconvert = (my_cconvert_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_color_deconverter));
|
||||
cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;
|
||||
cinfo->cconvert = (struct jpeg_color_deconverter *)cconvert;
|
||||
cconvert->pub.start_pass = start_pass_dcolor;
|
||||
|
||||
/* Make sure num_components agrees with jpeg_color_space */
|
||||
|
130
3rdparty/libjpeg-turbo/src/jdct.h
vendored
130
3rdparty/libjpeg-turbo/src/jdct.h
vendored
@ -90,64 +90,64 @@ typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
|
||||
|
||||
/* Extern declarations for the forward and inverse DCT routines. */
|
||||
|
||||
EXTERN(void) jpeg_fdct_islow (DCTELEM *data);
|
||||
EXTERN(void) jpeg_fdct_ifast (DCTELEM *data);
|
||||
EXTERN(void) jpeg_fdct_float (FAST_FLOAT *data);
|
||||
EXTERN(void) jpeg_fdct_islow(DCTELEM *data);
|
||||
EXTERN(void) jpeg_fdct_ifast(DCTELEM *data);
|
||||
EXTERN(void) jpeg_fdct_float(FAST_FLOAT *data);
|
||||
|
||||
EXTERN(void) jpeg_idct_islow
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_ifast
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_float
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_7x7
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_6x6
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_5x5
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_4x4
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_3x3
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_2x2
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_1x1
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_9x9
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_10x10
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_11x11
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_12x12
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_13x13
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_14x14
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_15x15
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_16x16
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_islow(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_ifast(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_float(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_7x7(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_6x6(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_5x5(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_4x4(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_3x3(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_2x2(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_1x1(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_9x9(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_10x10(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_11x11(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_12x12(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_13x13(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_14x14(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_15x15(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jpeg_idct_16x16(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
|
||||
|
||||
/*
|
||||
@ -160,7 +160,7 @@ EXTERN(void) jpeg_idct_16x16
|
||||
* and may differ from one module to the next.
|
||||
*/
|
||||
|
||||
#define ONE ((JLONG) 1)
|
||||
#define ONE ((JLONG)1)
|
||||
#define CONST_SCALE (ONE << CONST_BITS)
|
||||
|
||||
/* Convert a positive real constant to an integer scaled by CONST_SCALE.
|
||||
@ -168,14 +168,14 @@ EXTERN(void) jpeg_idct_16x16
|
||||
* thus causing a lot of useless floating-point operations at run time.
|
||||
*/
|
||||
|
||||
#define FIX(x) ((JLONG) ((x) * CONST_SCALE + 0.5))
|
||||
#define FIX(x) ((JLONG)((x) * CONST_SCALE + 0.5))
|
||||
|
||||
/* Descale and correctly round a JLONG value that's scaled by N bits.
|
||||
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
|
||||
* the fudge factor is correct for either sign of X.
|
||||
*/
|
||||
|
||||
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
|
||||
#define DESCALE(x, n) RIGHT_SHIFT((x) + (ONE << ((n) - 1)), n)
|
||||
|
||||
/* Multiply a JLONG variable by a JLONG constant to yield a JLONG result.
|
||||
* This macro is used only when the two inputs will actually be no more than
|
||||
@ -187,22 +187,22 @@ EXTERN(void) jpeg_idct_16x16
|
||||
*/
|
||||
|
||||
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
|
||||
#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const)))
|
||||
#define MULTIPLY16C16(var, const) (((INT16)(var)) * ((INT16)(const)))
|
||||
#endif
|
||||
#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
|
||||
#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((JLONG) (const)))
|
||||
#define MULTIPLY16C16(var, const) (((INT16)(var)) * ((JLONG)(const)))
|
||||
#endif
|
||||
|
||||
#ifndef MULTIPLY16C16 /* default definition */
|
||||
#define MULTIPLY16C16(var,const) ((var) * (const))
|
||||
#define MULTIPLY16C16(var, const) ((var) * (const))
|
||||
#endif
|
||||
|
||||
/* Same except both inputs are variables. */
|
||||
|
||||
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
|
||||
#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2)))
|
||||
#define MULTIPLY16V16(var1, var2) (((INT16)(var1)) * ((INT16)(var2)))
|
||||
#endif
|
||||
|
||||
#ifndef MULTIPLY16V16 /* default definition */
|
||||
#define MULTIPLY16V16(var1,var2) ((var1) * (var2))
|
||||
#define MULTIPLY16V16(var1, var2) ((var1) * (var2))
|
||||
#endif
|
||||
|
30
3rdparty/libjpeg-turbo/src/jddctmgr.c
vendored
30
3rdparty/libjpeg-turbo/src/jddctmgr.c
vendored
@ -94,9 +94,9 @@ typedef union {
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass (j_decompress_ptr cinfo)
|
||||
start_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_idct_ptr idct = (my_idct_ptr) cinfo->idct;
|
||||
my_idct_ptr idct = (my_idct_ptr)cinfo->idct;
|
||||
int ci, i;
|
||||
jpeg_component_info *compptr;
|
||||
int method = 0;
|
||||
@ -233,7 +233,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
* multiplier table all-zero; we'll be reading zeroes from the
|
||||
* coefficient controller's buffer anyway.
|
||||
*/
|
||||
if (! compptr->component_needed || idct->cur_method[ci] == method)
|
||||
if (!compptr->component_needed || idct->cur_method[ci] == method)
|
||||
continue;
|
||||
qtbl = compptr->quant_table;
|
||||
if (qtbl == NULL) /* happens if no data yet for component */
|
||||
@ -246,9 +246,9 @@ start_pass (j_decompress_ptr cinfo)
|
||||
/* For LL&M IDCT method, multipliers are equal to raw quantization
|
||||
* coefficients, but are stored as ints to ensure access efficiency.
|
||||
*/
|
||||
ISLOW_MULT_TYPE *ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table;
|
||||
ISLOW_MULT_TYPE *ismtbl = (ISLOW_MULT_TYPE *)compptr->dct_table;
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i];
|
||||
ismtbl[i] = (ISLOW_MULT_TYPE)qtbl->quantval[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -263,7 +263,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
* For integer operation, the multiplier table is to be scaled by
|
||||
* IFAST_SCALE_BITS.
|
||||
*/
|
||||
IFAST_MULT_TYPE *ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table;
|
||||
IFAST_MULT_TYPE *ifmtbl = (IFAST_MULT_TYPE *)compptr->dct_table;
|
||||
#define CONST_BITS 14
|
||||
static const INT16 aanscales[DCTSIZE2] = {
|
||||
/* precomputed values scaled up by 14 bits */
|
||||
@ -280,9 +280,9 @@ start_pass (j_decompress_ptr cinfo)
|
||||
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
ifmtbl[i] = (IFAST_MULT_TYPE)
|
||||
DESCALE(MULTIPLY16V16((JLONG) qtbl->quantval[i],
|
||||
(JLONG) aanscales[i]),
|
||||
CONST_BITS-IFAST_SCALE_BITS);
|
||||
DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
|
||||
(JLONG)aanscales[i]),
|
||||
CONST_BITS - IFAST_SCALE_BITS);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -295,7 +295,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
* scalefactor[0] = 1
|
||||
* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
|
||||
*/
|
||||
FLOAT_MULT_TYPE *fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table;
|
||||
FLOAT_MULT_TYPE *fmtbl = (FLOAT_MULT_TYPE *)compptr->dct_table;
|
||||
int row, col;
|
||||
static const double aanscalefactor[DCTSIZE] = {
|
||||
1.0, 1.387039845, 1.306562965, 1.175875602,
|
||||
@ -306,7 +306,7 @@ start_pass (j_decompress_ptr cinfo)
|
||||
for (row = 0; row < DCTSIZE; row++) {
|
||||
for (col = 0; col < DCTSIZE; col++) {
|
||||
fmtbl[i] = (FLOAT_MULT_TYPE)
|
||||
((double) qtbl->quantval[i] *
|
||||
((double)qtbl->quantval[i] *
|
||||
aanscalefactor[row] * aanscalefactor[col]);
|
||||
i++;
|
||||
}
|
||||
@ -327,23 +327,23 @@ start_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_inverse_dct (j_decompress_ptr cinfo)
|
||||
jinit_inverse_dct(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_idct_ptr idct;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
idct = (my_idct_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_idct_controller));
|
||||
cinfo->idct = (struct jpeg_inverse_dct *) idct;
|
||||
cinfo->idct = (struct jpeg_inverse_dct *)idct;
|
||||
idct->pub.start_pass = start_pass;
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
/* Allocate and pre-zero a multiplier table for each component */
|
||||
compptr->dct_table =
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(multiplier_table));
|
||||
MEMZERO(compptr->dct_table, sizeof(multiplier_table));
|
||||
/* Mark multiplier table not yet set up for any method */
|
||||
|
141
3rdparty/libjpeg-turbo/src/jdhuff.c
vendored
141
3rdparty/libjpeg-turbo/src/jdhuff.c
vendored
@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009-2011, 2016, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2016, 2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@ -15,6 +15,9 @@
|
||||
* up to the start of the current MCU. To do this, we copy state variables
|
||||
* into local working storage, and update them back to the permanent
|
||||
* storage only upon successful completion of an MCU.
|
||||
*
|
||||
* NOTE: All referenced figures are from
|
||||
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
@ -42,10 +45,10 @@ typedef struct {
|
||||
*/
|
||||
|
||||
#ifndef NO_STRUCT_ASSIGN
|
||||
#define ASSIGN_STATE(dest,src) ((dest) = (src))
|
||||
#define ASSIGN_STATE(dest, src) ((dest) = (src))
|
||||
#else
|
||||
#if MAX_COMPS_IN_SCAN == 4
|
||||
#define ASSIGN_STATE(dest,src) \
|
||||
#define ASSIGN_STATE(dest, src) \
|
||||
((dest).last_dc_val[0] = (src).last_dc_val[0], \
|
||||
(dest).last_dc_val[1] = (src).last_dc_val[1], \
|
||||
(dest).last_dc_val[2] = (src).last_dc_val[2], \
|
||||
@ -88,9 +91,9 @@ typedef huff_entropy_decoder *huff_entropy_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
start_pass_huff_decoder(j_decompress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int ci, blkn, dctbl, actbl;
|
||||
d_derived_tbl **pdtbl;
|
||||
jpeg_component_info *compptr;
|
||||
@ -99,7 +102,7 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
* This ought to be an error condition, but we make it a warning because
|
||||
* there are some baseline files out there with all zeroes in these bytes.
|
||||
*/
|
||||
if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 ||
|
||||
if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2 - 1 ||
|
||||
cinfo->Ah != 0 || cinfo->Al != 0)
|
||||
WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
|
||||
|
||||
@ -152,7 +155,7 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
d_derived_tbl **pdtbl)
|
||||
{
|
||||
JHUFF_TBL *htbl;
|
||||
@ -178,7 +181,7 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
/* Allocate a workspace if we haven't already done so. */
|
||||
if (*pdtbl == NULL)
|
||||
*pdtbl = (d_derived_tbl *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(d_derived_tbl));
|
||||
dtbl = *pdtbl;
|
||||
dtbl->pub = htbl; /* fill in back link */
|
||||
@ -187,11 +190,11 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
|
||||
p = 0;
|
||||
for (l = 1; l <= 16; l++) {
|
||||
i = (int) htbl->bits[l];
|
||||
i = (int)htbl->bits[l];
|
||||
if (i < 0 || p + i > 256) /* protect against table overrun */
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
while (i--)
|
||||
huffsize[p++] = (char) l;
|
||||
huffsize[p++] = (char)l;
|
||||
}
|
||||
huffsize[p] = 0;
|
||||
numsymbols = p;
|
||||
@ -203,14 +206,14 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
si = huffsize[0];
|
||||
p = 0;
|
||||
while (huffsize[p]) {
|
||||
while (((int) huffsize[p]) == si) {
|
||||
while (((int)huffsize[p]) == si) {
|
||||
huffcode[p++] = code;
|
||||
code++;
|
||||
}
|
||||
/* code is now 1 more than the last code used for codelength si; but
|
||||
* it must still fit in si bits, since no code is allowed to be all ones.
|
||||
*/
|
||||
if (((JLONG) code) >= (((JLONG) 1) << si))
|
||||
if (((JLONG)code) >= (((JLONG)1) << si))
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
code <<= 1;
|
||||
si++;
|
||||
@ -224,9 +227,9 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
/* valoffset[l] = huffval[] index of 1st symbol of code length l,
|
||||
* minus the minimum code of length l
|
||||
*/
|
||||
dtbl->valoffset[l] = (JLONG) p - (JLONG) huffcode[p];
|
||||
dtbl->valoffset[l] = (JLONG)p - (JLONG)huffcode[p];
|
||||
p += htbl->bits[l];
|
||||
dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */
|
||||
dtbl->maxcode[l] = huffcode[p - 1]; /* maximum code of length l */
|
||||
} else {
|
||||
dtbl->maxcode[l] = -1; /* -1 if no codes of this length */
|
||||
}
|
||||
@ -246,11 +249,11 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
|
||||
p = 0;
|
||||
for (l = 1; l <= HUFF_LOOKAHEAD; l++) {
|
||||
for (i = 1; i <= (int) htbl->bits[l]; i++, p++) {
|
||||
for (i = 1; i <= (int)htbl->bits[l]; i++, p++) {
|
||||
/* l = current code's length, p = its index in huffcode[] & huffval[]. */
|
||||
/* Generate left-justified code followed by all possible bit sequences */
|
||||
lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);
|
||||
for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {
|
||||
lookbits = huffcode[p] << (HUFF_LOOKAHEAD - l);
|
||||
for (ctr = 1 << (HUFF_LOOKAHEAD - l); ctr > 0; ctr--) {
|
||||
dtbl->lookup[lookbits] = (l << HUFF_LOOKAHEAD) | htbl->huffval[p];
|
||||
lookbits++;
|
||||
}
|
||||
@ -291,12 +294,12 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
#ifdef SLOW_SHIFT_32
|
||||
#define MIN_GET_BITS 15 /* minimum allowable value */
|
||||
#else
|
||||
#define MIN_GET_BITS (BIT_BUF_SIZE-7)
|
||||
#define MIN_GET_BITS (BIT_BUF_SIZE - 7)
|
||||
#endif
|
||||
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
jpeg_fill_bit_buffer(bitread_working_state *state,
|
||||
register bit_buf_type get_buffer, register int bits_left,
|
||||
int nbits)
|
||||
/* Load up the bit buffer to a depth of at least nbits */
|
||||
@ -316,7 +319,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
|
||||
/* Attempt to read a byte */
|
||||
if (bytes_in_buffer == 0) {
|
||||
if (! (*cinfo->src->fill_input_buffer) (cinfo))
|
||||
if (!(*cinfo->src->fill_input_buffer) (cinfo))
|
||||
return FALSE;
|
||||
next_input_byte = cinfo->src->next_input_byte;
|
||||
bytes_in_buffer = cinfo->src->bytes_in_buffer;
|
||||
@ -333,7 +336,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
*/
|
||||
do {
|
||||
if (bytes_in_buffer == 0) {
|
||||
if (! (*cinfo->src->fill_input_buffer) (cinfo))
|
||||
if (!(*cinfo->src->fill_input_buffer) (cinfo))
|
||||
return FALSE;
|
||||
next_input_byte = cinfo->src->next_input_byte;
|
||||
bytes_in_buffer = cinfo->src->bytes_in_buffer;
|
||||
@ -365,7 +368,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
bits_left += 8;
|
||||
} /* end while */
|
||||
} else {
|
||||
no_more_bytes:
|
||||
no_more_bytes:
|
||||
/* We get here if we've read the marker that terminates the compressed
|
||||
* data segment. There should be enough bits in the buffer register
|
||||
* to satisfy the request; if so, no problem.
|
||||
@ -376,7 +379,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
* We use a nonvolatile flag to ensure that only one warning message
|
||||
* appears per data segment.
|
||||
*/
|
||||
if (! cinfo->entropy->insufficient_data) {
|
||||
if (!cinfo->entropy->insufficient_data) {
|
||||
WARNMS(cinfo, JWRN_HIT_MARKER);
|
||||
cinfo->entropy->insufficient_data = TRUE;
|
||||
}
|
||||
@ -400,8 +403,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
handle markers. We have to hand off any blocks with markers to the
|
||||
slower routines. */
|
||||
|
||||
#define GET_BYTE \
|
||||
{ \
|
||||
#define GET_BYTE { \
|
||||
register int c0, c1; \
|
||||
c0 = GETJOCTET(*buffer++); \
|
||||
c1 = GETJOCTET(*buffer); \
|
||||
@ -421,7 +423,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
} \
|
||||
}
|
||||
|
||||
#if SIZEOF_SIZE_T==8 || defined(_WIN64)
|
||||
#if SIZEOF_SIZE_T == 8 || defined(_WIN64)
|
||||
|
||||
/* Pre-fetch 48 bytes, because the holding register is 64-bit */
|
||||
#define FILL_BIT_BUFFER_FAST \
|
||||
@ -446,7 +448,7 @@ jpeg_fill_bit_buffer (bitread_working_state *state,
|
||||
*/
|
||||
|
||||
GLOBAL(int)
|
||||
jpeg_huff_decode (bitread_working_state *state,
|
||||
jpeg_huff_decode(bitread_working_state *state,
|
||||
register bit_buf_type get_buffer, register int bits_left,
|
||||
d_derived_tbl *htbl, int min_bits)
|
||||
{
|
||||
@ -460,7 +462,7 @@ jpeg_huff_decode (bitread_working_state *state,
|
||||
code = GET_BITS(l);
|
||||
|
||||
/* Collect the rest of the Huffman code one bit at a time. */
|
||||
/* This is per Figure F.16 in the JPEG spec. */
|
||||
/* This is per Figure F.16. */
|
||||
|
||||
while (code > htbl->maxcode[l]) {
|
||||
code <<= 1;
|
||||
@ -480,7 +482,7 @@ jpeg_huff_decode (bitread_working_state *state,
|
||||
return 0; /* fake a zero as the safest result */
|
||||
}
|
||||
|
||||
return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ];
|
||||
return htbl->pub->huffval[(int)(code + htbl->valoffset[l])];
|
||||
}
|
||||
|
||||
|
||||
@ -493,21 +495,25 @@ jpeg_huff_decode (bitread_working_state *state,
|
||||
#ifdef AVOID_TABLES
|
||||
|
||||
#define NEG_1 ((unsigned int)-1)
|
||||
#define HUFF_EXTEND(x,s) ((x) + ((((x) - (1<<((s)-1))) >> 31) & (((NEG_1)<<(s)) + 1)))
|
||||
#define HUFF_EXTEND(x, s) \
|
||||
((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
|
||||
|
||||
#else
|
||||
|
||||
#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
|
||||
#define HUFF_EXTEND(x, s) \
|
||||
((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
|
||||
|
||||
static const int extend_test[16] = /* entry n is 2**(n-1) */
|
||||
{ 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
|
||||
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
|
||||
static const int extend_test[16] = { /* entry n is 2**(n-1) */
|
||||
0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
|
||||
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000
|
||||
};
|
||||
|
||||
static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
|
||||
{ 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,
|
||||
((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,
|
||||
((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
|
||||
((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
|
||||
static const int extend_offset[16] = { /* entry n is (-1 << n) + 1 */
|
||||
0, ((-1) << 1) + 1, ((-1) << 2) + 1, ((-1) << 3) + 1, ((-1) << 4) + 1,
|
||||
((-1) << 5) + 1, ((-1) << 6) + 1, ((-1) << 7) + 1, ((-1) << 8) + 1,
|
||||
((-1) << 9) + 1, ((-1) << 10) + 1, ((-1) << 11) + 1, ((-1) << 12) + 1,
|
||||
((-1) << 13) + 1, ((-1) << 14) + 1, ((-1) << 15) + 1
|
||||
};
|
||||
|
||||
#endif /* AVOID_TABLES */
|
||||
|
||||
@ -518,9 +524,9 @@ static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
process_restart (j_decompress_ptr cinfo)
|
||||
process_restart(j_decompress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int ci;
|
||||
|
||||
/* Throw away any unused bits remaining in bit buffer; */
|
||||
@ -529,7 +535,7 @@ process_restart (j_decompress_ptr cinfo)
|
||||
entropy->bitstate.bits_left = 0;
|
||||
|
||||
/* Advance past the RSTn marker */
|
||||
if (! (*cinfo->marker->read_restart_marker) (cinfo))
|
||||
if (!(*cinfo->marker->read_restart_marker) (cinfo))
|
||||
return FALSE;
|
||||
|
||||
/* Re-initialize DC predictions to 0 */
|
||||
@ -552,16 +558,16 @@ process_restart (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_slow(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
BITREAD_STATE_VARS;
|
||||
int blkn;
|
||||
savable_state state;
|
||||
/* Outer loop handles each block in the MCU */
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
@ -587,7 +593,7 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
state.last_dc_val[ci] = s;
|
||||
if (block) {
|
||||
/* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
|
||||
(*block)[0] = (JCOEF) s;
|
||||
(*block)[0] = (JCOEF)s;
|
||||
}
|
||||
}
|
||||
|
||||
@ -610,7 +616,7 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
* Note: the extra entries in jpeg_natural_order[] will save us
|
||||
* if k >= DCTSIZE2, which could happen if the data is corrupted.
|
||||
*/
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) s;
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF)s;
|
||||
} else {
|
||||
if (r != 15)
|
||||
break;
|
||||
@ -642,16 +648,16 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_fast(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
BITREAD_STATE_VARS;
|
||||
JOCTET *buffer;
|
||||
int blkn;
|
||||
@ -659,8 +665,8 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Outer loop handles each block in the MCU */
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
buffer = (JOCTET *) br_state.next_input_byte;
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
buffer = (JOCTET *)br_state.next_input_byte;
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||
@ -681,7 +687,7 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
s += state.last_dc_val[ci];
|
||||
state.last_dc_val[ci] = s;
|
||||
if (block)
|
||||
(*block)[0] = (JCOEF) s;
|
||||
(*block)[0] = (JCOEF)s;
|
||||
}
|
||||
|
||||
if (entropy->ac_needed[blkn] && block) {
|
||||
@ -696,7 +702,7 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
FILL_BIT_BUFFER_FAST
|
||||
r = GET_BITS(s);
|
||||
s = HUFF_EXTEND(r, s);
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) s;
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF)s;
|
||||
} else {
|
||||
if (r != 15) break;
|
||||
k += 15;
|
||||
@ -729,7 +735,7 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
br_state.bytes_in_buffer -= (buffer - br_state.next_input_byte);
|
||||
br_state.next_input_byte = buffer;
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
return TRUE;
|
||||
}
|
||||
@ -753,33 +759,32 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
#define BUFSIZE (DCTSIZE2 * 8)
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
|
||||
int usefast = 1;
|
||||
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! process_restart(cinfo))
|
||||
if (!process_restart(cinfo))
|
||||
return FALSE;
|
||||
usefast = 0;
|
||||
}
|
||||
|
||||
if (cinfo->src->bytes_in_buffer < BUFSIZE * (size_t)cinfo->blocks_in_MCU
|
||||
|| cinfo->unread_marker != 0)
|
||||
if (cinfo->src->bytes_in_buffer < BUFSIZE * (size_t)cinfo->blocks_in_MCU ||
|
||||
cinfo->unread_marker != 0)
|
||||
usefast = 0;
|
||||
|
||||
/* If we've run out of data, just leave the MCU set to zeroes.
|
||||
* This way, we return uniform gray for the remainder of the segment.
|
||||
*/
|
||||
if (! entropy->pub.insufficient_data) {
|
||||
if (!entropy->pub.insufficient_data) {
|
||||
|
||||
if (usefast) {
|
||||
if (!decode_mcu_fast(cinfo, MCU_data)) goto use_slow;
|
||||
}
|
||||
else {
|
||||
use_slow:
|
||||
} else {
|
||||
use_slow:
|
||||
if (!decode_mcu_slow(cinfo, MCU_data)) return FALSE;
|
||||
}
|
||||
|
||||
@ -797,7 +802,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_huff_decoder (j_decompress_ptr cinfo)
|
||||
jinit_huff_decoder(j_decompress_ptr cinfo)
|
||||
{
|
||||
huff_entropy_ptr entropy;
|
||||
int i;
|
||||
@ -806,12 +811,12 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
|
||||
are the default tables. Thus, if the tables are not set by the time
|
||||
the Huffman decoder is initialized (usually within the body of
|
||||
jpeg_start_decompress()), we set them to default values. */
|
||||
std_huff_tables((j_common_ptr) cinfo);
|
||||
std_huff_tables((j_common_ptr)cinfo);
|
||||
|
||||
entropy = (huff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(huff_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass_huff_decoder;
|
||||
entropy->pub.decode_mcu = decode_mcu;
|
||||
|
||||
|
54
3rdparty/libjpeg-turbo/src/jdhuff.h
vendored
54
3rdparty/libjpeg-turbo/src/jdhuff.h
vendored
@ -43,13 +43,12 @@ typedef struct {
|
||||
* if too long. The next 8 bits of each entry contain the
|
||||
* symbol.
|
||||
*/
|
||||
int lookup[1<<HUFF_LOOKAHEAD];
|
||||
int lookup[1 << HUFF_LOOKAHEAD];
|
||||
} d_derived_tbl;
|
||||
|
||||
/* Expand a Huffman table definition into the derived format */
|
||||
EXTERN(void) jpeg_make_d_derived_tbl
|
||||
(j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
d_derived_tbl ** pdtbl);
|
||||
EXTERN(void) jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC,
|
||||
int tblno, d_derived_tbl **pdtbl);
|
||||
|
||||
|
||||
/*
|
||||
@ -74,7 +73,7 @@ EXTERN(void) jpeg_make_d_derived_tbl
|
||||
#error Cannot determine word size
|
||||
#endif
|
||||
|
||||
#if SIZEOF_SIZE_T==8 || defined(_WIN64)
|
||||
#if SIZEOF_SIZE_T == 8 || defined(_WIN64)
|
||||
|
||||
typedef size_t bit_buf_type; /* type of bit-extraction buffer */
|
||||
#define BIT_BUF_SIZE 64 /* size of buffer in bits */
|
||||
@ -118,14 +117,14 @@ typedef struct { /* Bitreading working state within an MCU */
|
||||
register int bits_left; \
|
||||
bitread_working_state br_state
|
||||
|
||||
#define BITREAD_LOAD_STATE(cinfop,permstate) \
|
||||
#define BITREAD_LOAD_STATE(cinfop, permstate) \
|
||||
br_state.cinfo = cinfop; \
|
||||
br_state.next_input_byte = cinfop->src->next_input_byte; \
|
||||
br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
|
||||
get_buffer = permstate.get_buffer; \
|
||||
bits_left = permstate.bits_left;
|
||||
|
||||
#define BITREAD_SAVE_STATE(cinfop,permstate) \
|
||||
#define BITREAD_SAVE_STATE(cinfop, permstate) \
|
||||
cinfop->src->next_input_byte = br_state.next_input_byte; \
|
||||
cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
|
||||
permstate.get_buffer = get_buffer; \
|
||||
@ -137,7 +136,7 @@ typedef struct { /* Bitreading working state within an MCU */
|
||||
* before using GET_BITS, PEEK_BITS, or DROP_BITS.
|
||||
* The variables get_buffer and bits_left are assumed to be locals,
|
||||
* but the state struct might not be (jpeg_huff_decode needs this).
|
||||
* CHECK_BIT_BUFFER(state,n,action);
|
||||
* CHECK_BIT_BUFFER(state, n, action);
|
||||
* Ensure there are N bits in get_buffer; if suspend, take action.
|
||||
* val = GET_BITS(n);
|
||||
* Fetch next N bits.
|
||||
@ -149,24 +148,26 @@ typedef struct { /* Bitreading working state within an MCU */
|
||||
* is evaluated multiple times.
|
||||
*/
|
||||
|
||||
#define CHECK_BIT_BUFFER(state,nbits,action) \
|
||||
{ if (bits_left < (nbits)) { \
|
||||
if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \
|
||||
#define CHECK_BIT_BUFFER(state, nbits, action) { \
|
||||
if (bits_left < (nbits)) { \
|
||||
if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
|
||||
{ action; } \
|
||||
get_buffer = (state).get_buffer; bits_left = (state).bits_left; } }
|
||||
get_buffer = (state).get_buffer; bits_left = (state).bits_left; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define GET_BITS(nbits) \
|
||||
(((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1))
|
||||
(((int)(get_buffer >> (bits_left -= (nbits)))) & ((1 << (nbits)) - 1))
|
||||
|
||||
#define PEEK_BITS(nbits) \
|
||||
(((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1))
|
||||
(((int)(get_buffer >> (bits_left - (nbits)))) & ((1 << (nbits)) - 1))
|
||||
|
||||
#define DROP_BITS(nbits) \
|
||||
(bits_left -= (nbits))
|
||||
|
||||
/* Load up the bit buffer to a depth of at least nbits */
|
||||
EXTERN(boolean) jpeg_fill_bit_buffer
|
||||
(bitread_working_state *state, register bit_buf_type get_buffer,
|
||||
EXTERN(boolean) jpeg_fill_bit_buffer(bitread_working_state *state,
|
||||
register bit_buf_type get_buffer,
|
||||
register int bits_left, int nbits);
|
||||
|
||||
|
||||
@ -187,10 +188,11 @@ EXTERN(boolean) jpeg_fill_bit_buffer
|
||||
* 3. jpeg_huff_decode returns -1 if forced to suspend.
|
||||
*/
|
||||
|
||||
#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \
|
||||
{ register int nb, look; \
|
||||
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel) { \
|
||||
register int nb, look; \
|
||||
if (bits_left < HUFF_LOOKAHEAD) { \
|
||||
if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \
|
||||
if (!jpeg_fill_bit_buffer(&state, get_buffer, bits_left, 0)) \
|
||||
{ failaction; } \
|
||||
get_buffer = state.get_buffer; bits_left = state.bits_left; \
|
||||
if (bits_left < HUFF_LOOKAHEAD) { \
|
||||
nb = 1; goto slowlabel; \
|
||||
@ -202,13 +204,14 @@ EXTERN(boolean) jpeg_fill_bit_buffer
|
||||
result = htbl->lookup[look] & ((1 << HUFF_LOOKAHEAD) - 1); \
|
||||
} else { \
|
||||
slowlabel: \
|
||||
if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \
|
||||
if ((result = \
|
||||
jpeg_huff_decode(&state, get_buffer, bits_left, htbl, nb)) < 0) \
|
||||
{ failaction; } \
|
||||
get_buffer = state.get_buffer; bits_left = state.bits_left; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define HUFF_DECODE_FAST(s,nb,htbl) \
|
||||
#define HUFF_DECODE_FAST(s, nb, htbl) \
|
||||
FILL_BIT_BUFFER_FAST; \
|
||||
s = PEEK_BITS(HUFF_LOOKAHEAD); \
|
||||
s = htbl->lookup[s]; \
|
||||
@ -225,10 +228,11 @@ slowlabel: \
|
||||
s |= GET_BITS(1); \
|
||||
nb++; \
|
||||
} \
|
||||
s = htbl->pub->huffval[ (int) (s + htbl->valoffset[nb]) & 0xFF ]; \
|
||||
s = htbl->pub->huffval[(int)(s + htbl->valoffset[nb]) & 0xFF]; \
|
||||
}
|
||||
|
||||
/* Out-of-line case for Huffman code fetching */
|
||||
EXTERN(int) jpeg_huff_decode
|
||||
(bitread_working_state *state, register bit_buf_type get_buffer,
|
||||
register int bits_left, d_derived_tbl *htbl, int min_bits);
|
||||
EXTERN(int) jpeg_huff_decode(bitread_working_state *state,
|
||||
register bit_buf_type get_buffer,
|
||||
register int bits_left, d_derived_tbl *htbl,
|
||||
int min_bits);
|
||||
|
95
3rdparty/libjpeg-turbo/src/jdinput.c
vendored
95
3rdparty/libjpeg-turbo/src/jdinput.c
vendored
@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2016, D. R. Commander.
|
||||
* Copyright (C) 2010, 2016, 2018, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@ -33,7 +33,7 @@ typedef my_input_controller *my_inputctl_ptr;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(int) consume_markers (j_decompress_ptr cinfo);
|
||||
METHODDEF(int) consume_markers(j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
@ -41,16 +41,16 @@ METHODDEF(int) consume_markers (j_decompress_ptr cinfo);
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
initial_setup (j_decompress_ptr cinfo)
|
||||
initial_setup(j_decompress_ptr cinfo)
|
||||
/* Called once, when first SOS marker is reached */
|
||||
{
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
/* Make sure image isn't bigger than I can handle */
|
||||
if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||
|
||||
(long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
||||
if ((long)cinfo->image_height > (long)JPEG_MAX_DIMENSION ||
|
||||
(long)cinfo->image_width > (long)JPEG_MAX_DIMENSION)
|
||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
|
||||
|
||||
/* For now, precision must match compiled-in value... */
|
||||
if (cinfo->data_precision != BITS_IN_JSAMPLE)
|
||||
@ -66,8 +66,10 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
cinfo->max_v_samp_factor = 1;
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
|
||||
compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
|
||||
if (compptr->h_samp_factor <= 0 ||
|
||||
compptr->h_samp_factor > MAX_SAMP_FACTOR ||
|
||||
compptr->v_samp_factor <= 0 ||
|
||||
compptr->v_samp_factor > MAX_SAMP_FACTOR)
|
||||
ERREXIT(cinfo, JERR_BAD_SAMPLING);
|
||||
cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
|
||||
compptr->h_samp_factor);
|
||||
@ -75,10 +77,10 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
compptr->v_samp_factor);
|
||||
}
|
||||
|
||||
#if JPEG_LIB_VERSION >=80
|
||||
#if JPEG_LIB_VERSION >= 80
|
||||
cinfo->block_size = DCTSIZE;
|
||||
cinfo->natural_order = jpeg_natural_order;
|
||||
cinfo->lim_Se = DCTSIZE2-1;
|
||||
cinfo->lim_Se = DCTSIZE2 - 1;
|
||||
#endif
|
||||
|
||||
/* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.
|
||||
@ -101,11 +103,11 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
#endif
|
||||
/* Size in DCT blocks */
|
||||
compptr->width_in_blocks = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
|
||||
(long) (cinfo->max_h_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
|
||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
||||
compptr->height_in_blocks = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
|
||||
(long) (cinfo->max_v_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
/* Set the first and last MCU columns to decompress from multi-scan images.
|
||||
* By default, decompress all of the MCU columns.
|
||||
*/
|
||||
@ -117,11 +119,11 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
*/
|
||||
/* Size in samples */
|
||||
compptr->downsampled_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
|
||||
(long) cinfo->max_h_samp_factor);
|
||||
jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
|
||||
(long)cinfo->max_h_samp_factor);
|
||||
compptr->downsampled_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
|
||||
(long) cinfo->max_v_samp_factor);
|
||||
jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
|
||||
(long)cinfo->max_v_samp_factor);
|
||||
/* Mark component needed, until color conversion says otherwise */
|
||||
compptr->component_needed = TRUE;
|
||||
/* Mark no quantization table yet saved for component */
|
||||
@ -130,8 +132,8 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
|
||||
/* Compute number of fully interleaved MCU rows. */
|
||||
cinfo->total_iMCU_rows = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height,
|
||||
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_height,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
|
||||
/* Decide whether file contains multiple scans */
|
||||
if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)
|
||||
@ -142,7 +144,7 @@ initial_setup (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
per_scan_setup (j_decompress_ptr cinfo)
|
||||
per_scan_setup(j_decompress_ptr cinfo)
|
||||
/* Do computations that are needed before processing a JPEG scan */
|
||||
/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */
|
||||
{
|
||||
@ -167,7 +169,7 @@ per_scan_setup (j_decompress_ptr cinfo)
|
||||
/* For noninterleaved scans, it is convenient to define last_row_height
|
||||
* as the number of block rows present in the last iMCU row.
|
||||
*/
|
||||
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
||||
if (tmp == 0) tmp = compptr->v_samp_factor;
|
||||
compptr->last_row_height = tmp;
|
||||
|
||||
@ -184,11 +186,11 @@ per_scan_setup (j_decompress_ptr cinfo)
|
||||
|
||||
/* Overall image size in MCUs */
|
||||
cinfo->MCUs_per_row = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width,
|
||||
(long) (cinfo->max_h_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_width,
|
||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
||||
cinfo->MCU_rows_in_scan = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height,
|
||||
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_height,
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
|
||||
cinfo->blocks_in_MCU = 0;
|
||||
|
||||
@ -198,12 +200,13 @@ per_scan_setup (j_decompress_ptr cinfo)
|
||||
compptr->MCU_width = compptr->h_samp_factor;
|
||||
compptr->MCU_height = compptr->v_samp_factor;
|
||||
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
|
||||
compptr->MCU_sample_width = compptr->MCU_width * compptr->_DCT_scaled_size;
|
||||
compptr->MCU_sample_width = compptr->MCU_width *
|
||||
compptr->_DCT_scaled_size;
|
||||
/* Figure number of non-dummy blocks in last MCU column & row */
|
||||
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
|
||||
tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
|
||||
if (tmp == 0) tmp = compptr->MCU_width;
|
||||
compptr->last_col_width = tmp;
|
||||
tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);
|
||||
tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
|
||||
if (tmp == 0) tmp = compptr->MCU_height;
|
||||
compptr->last_row_height = tmp;
|
||||
/* Prepare array describing MCU composition */
|
||||
@ -231,17 +234,17 @@ per_scan_setup (j_decompress_ptr cinfo)
|
||||
* means that we have to save away the table actually used for each component.
|
||||
* We do this by copying the table at the start of the first scan containing
|
||||
* the component.
|
||||
* The JPEG spec prohibits the encoder from changing the contents of a Q-table
|
||||
* slot between scans of a component using that slot. If the encoder does so
|
||||
* anyway, this decoder will simply use the Q-table values that were current
|
||||
* at the start of the first scan for the component.
|
||||
* Rec. ITU-T T.81 | ISO/IEC 10918-1 prohibits the encoder from changing the
|
||||
* contents of a Q-table slot between scans of a component using that slot. If
|
||||
* the encoder does so anyway, this decoder will simply use the Q-table values
|
||||
* that were current at the start of the first scan for the component.
|
||||
*
|
||||
* The decompressor output side looks only at the saved quant tables,
|
||||
* not at the current Q-table slots.
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
latch_quant_tables (j_decompress_ptr cinfo)
|
||||
latch_quant_tables(j_decompress_ptr cinfo)
|
||||
{
|
||||
int ci, qtblno;
|
||||
jpeg_component_info *compptr;
|
||||
@ -259,7 +262,7 @@ latch_quant_tables (j_decompress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
|
||||
/* OK, save away the quantization table */
|
||||
qtbl = (JQUANT_TBL *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(JQUANT_TBL));
|
||||
MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], sizeof(JQUANT_TBL));
|
||||
compptr->quant_table = qtbl;
|
||||
@ -275,7 +278,7 @@ latch_quant_tables (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_input_pass (j_decompress_ptr cinfo)
|
||||
start_input_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
per_scan_setup(cinfo);
|
||||
latch_quant_tables(cinfo);
|
||||
@ -292,7 +295,7 @@ start_input_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_input_pass (j_decompress_ptr cinfo)
|
||||
finish_input_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
cinfo->inputctl->consume_input = consume_markers;
|
||||
}
|
||||
@ -309,9 +312,9 @@ finish_input_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
consume_markers (j_decompress_ptr cinfo)
|
||||
consume_markers(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;
|
||||
my_inputctl_ptr inputctl = (my_inputctl_ptr)cinfo->inputctl;
|
||||
int val;
|
||||
|
||||
if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */
|
||||
@ -329,7 +332,7 @@ consume_markers (j_decompress_ptr cinfo)
|
||||
* responsible for enforcing this sequencing.
|
||||
*/
|
||||
} else { /* 2nd or later SOS marker */
|
||||
if (! inputctl->pub.has_multiple_scans)
|
||||
if (!inputctl->pub.has_multiple_scans)
|
||||
ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */
|
||||
start_input_pass(cinfo);
|
||||
}
|
||||
@ -360,16 +363,16 @@ consume_markers (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
reset_input_controller (j_decompress_ptr cinfo)
|
||||
reset_input_controller(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;
|
||||
my_inputctl_ptr inputctl = (my_inputctl_ptr)cinfo->inputctl;
|
||||
|
||||
inputctl->pub.consume_input = consume_markers;
|
||||
inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
|
||||
inputctl->pub.eoi_reached = FALSE;
|
||||
inputctl->inheaders = TRUE;
|
||||
/* Reset other modules */
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
||||
(*cinfo->marker->reset_marker_reader) (cinfo);
|
||||
/* Reset progression state -- would be cleaner if entropy decoder did this */
|
||||
cinfo->coef_bits = NULL;
|
||||
@ -382,15 +385,15 @@ reset_input_controller (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_input_controller (j_decompress_ptr cinfo)
|
||||
jinit_input_controller(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_inputctl_ptr inputctl;
|
||||
|
||||
/* Create subobject in permanent pool */
|
||||
inputctl = (my_inputctl_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_input_controller));
|
||||
cinfo->inputctl = (struct jpeg_input_controller *) inputctl;
|
||||
cinfo->inputctl = (struct jpeg_input_controller *)inputctl;
|
||||
/* Initialize method pointers */
|
||||
inputctl->pub.consume_input = consume_markers;
|
||||
inputctl->pub.reset_input_controller = reset_input_controller;
|
||||
|
116
3rdparty/libjpeg-turbo/src/jdmainct.c
vendored
116
3rdparty/libjpeg-turbo/src/jdmainct.c
vendored
@ -112,26 +112,29 @@
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(void) process_data_simple_main
|
||||
(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) process_data_context_main
|
||||
(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) process_data_simple_main(j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) process_data_context_main(j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
METHODDEF(void) process_data_crank_post
|
||||
(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) process_data_crank_post(j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
alloc_funny_pointers(j_decompress_ptr cinfo)
|
||||
/* Allocate space for the funny pointer lists.
|
||||
* This is done only once, not once per pass.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
int ci, rgroup;
|
||||
int M = cinfo->_min_DCT_scaled_size;
|
||||
jpeg_component_info *compptr;
|
||||
@ -141,7 +144,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
* We alloc both arrays with one call to save a few cycles.
|
||||
*/
|
||||
main_ptr->xbuffer[0] = (JSAMPIMAGE)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * 2 * sizeof(JSAMPARRAY));
|
||||
main_ptr->xbuffer[1] = main_ptr->xbuffer[0] + cinfo->num_components;
|
||||
|
||||
@ -153,7 +156,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
* We alloc both pointer lists with one call to save a few cycles.
|
||||
*/
|
||||
xbuf = (JSAMPARRAY)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
2 * (rgroup * (M + 4)) * sizeof(JSAMPROW));
|
||||
xbuf += rgroup; /* want one row group at negative offsets */
|
||||
main_ptr->xbuffer[0][ci] = xbuf;
|
||||
@ -164,7 +167,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
make_funny_pointers (j_decompress_ptr cinfo)
|
||||
make_funny_pointers(j_decompress_ptr cinfo)
|
||||
/* Create the funny pointer lists discussed in the comments above.
|
||||
* The actual workspace is already allocated (in main_ptr->buffer),
|
||||
* and the space for the pointer lists is allocated too.
|
||||
@ -172,7 +175,7 @@ make_funny_pointers (j_decompress_ptr cinfo)
|
||||
* This will be repeated at the beginning of each pass.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
int ci, i, rgroup;
|
||||
int M = cinfo->_min_DCT_scaled_size;
|
||||
jpeg_component_info *compptr;
|
||||
@ -191,8 +194,8 @@ make_funny_pointers (j_decompress_ptr cinfo)
|
||||
}
|
||||
/* In the second list, put the last four row groups in swapped order */
|
||||
for (i = 0; i < rgroup * 2; i++) {
|
||||
xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i];
|
||||
xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i];
|
||||
xbuf1[rgroup * (M - 2) + i] = buf[rgroup * M + i];
|
||||
xbuf1[rgroup * M + i] = buf[rgroup * (M - 2) + i];
|
||||
}
|
||||
/* The wraparound pointers at top and bottom will be filled later
|
||||
* (see set_wraparound_pointers, below). Initially we want the "above"
|
||||
@ -207,13 +210,13 @@ make_funny_pointers (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
set_bottom_pointers (j_decompress_ptr cinfo)
|
||||
set_bottom_pointers(j_decompress_ptr cinfo)
|
||||
/* Change the pointer lists to duplicate the last sample row at the bottom
|
||||
* of the image. whichptr indicates which xbuffer holds the final iMCU row.
|
||||
* Also sets rowgroups_avail to indicate number of nondummy row groups in row.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
int ci, i, rgroup, iMCUheight, rows_left;
|
||||
jpeg_component_info *compptr;
|
||||
JSAMPARRAY xbuf;
|
||||
@ -224,20 +227,20 @@ set_bottom_pointers (j_decompress_ptr cinfo)
|
||||
iMCUheight = compptr->v_samp_factor * compptr->_DCT_scaled_size;
|
||||
rgroup = iMCUheight / cinfo->_min_DCT_scaled_size;
|
||||
/* Count nondummy sample rows remaining for this component */
|
||||
rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);
|
||||
rows_left = (int)(compptr->downsampled_height % (JDIMENSION)iMCUheight);
|
||||
if (rows_left == 0) rows_left = iMCUheight;
|
||||
/* Count nondummy row groups. Should get same answer for each component,
|
||||
* so we need only do it once.
|
||||
*/
|
||||
if (ci == 0) {
|
||||
main_ptr->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1);
|
||||
main_ptr->rowgroups_avail = (JDIMENSION)((rows_left - 1) / rgroup + 1);
|
||||
}
|
||||
/* Duplicate the last real sample row rgroup*2 times; this pads out the
|
||||
* last partial rowgroup and ensures at least one full rowgroup of context.
|
||||
*/
|
||||
xbuf = main_ptr->xbuffer[main_ptr->whichptr][ci];
|
||||
for (i = 0; i < rgroup * 2; i++) {
|
||||
xbuf[rows_left + i] = xbuf[rows_left-1];
|
||||
xbuf[rows_left + i] = xbuf[rows_left - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -248,9 +251,9 @@ set_bottom_pointers (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_main(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
|
||||
switch (pass_mode) {
|
||||
case JBUF_PASS_THRU:
|
||||
@ -286,22 +289,21 @@ start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
process_data_simple_main (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
JDIMENSION rowgroups_avail;
|
||||
|
||||
/* Read input data if we haven't filled the main buffer yet */
|
||||
if (! main_ptr->buffer_full) {
|
||||
if (! (*cinfo->coef->decompress_data) (cinfo, main_ptr->buffer))
|
||||
if (!main_ptr->buffer_full) {
|
||||
if (!(*cinfo->coef->decompress_data) (cinfo, main_ptr->buffer))
|
||||
return; /* suspension forced, can do nothing more */
|
||||
main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
||||
}
|
||||
|
||||
/* There are always min_DCT_scaled_size row groups in an iMCU row. */
|
||||
rowgroups_avail = (JDIMENSION) cinfo->_min_DCT_scaled_size;
|
||||
rowgroups_avail = (JDIMENSION)cinfo->_min_DCT_scaled_size;
|
||||
/* Note: at the bottom of the image, we may pass extra garbage row groups
|
||||
* to the postprocessor. The postprocessor has to check for bottom
|
||||
* of image anyway (at row resolution), so no point in us doing it too.
|
||||
@ -326,15 +328,14 @@ process_data_simple_main (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
process_data_context_main (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
|
||||
/* Read input data if we haven't filled the main buffer yet */
|
||||
if (! main_ptr->buffer_full) {
|
||||
if (! (*cinfo->coef->decompress_data) (cinfo,
|
||||
if (!main_ptr->buffer_full) {
|
||||
if (!(*cinfo->coef->decompress_data) (cinfo,
|
||||
main_ptr->xbuffer[main_ptr->whichptr]))
|
||||
return; /* suspension forced, can do nothing more */
|
||||
main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
||||
@ -349,9 +350,11 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
switch (main_ptr->context_state) {
|
||||
case CTX_POSTPONED_ROW:
|
||||
/* Call postprocessor using previously set pointers for postponed row */
|
||||
(*cinfo->post->post_process_data) (cinfo, main_ptr->xbuffer[main_ptr->whichptr],
|
||||
&main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail,
|
||||
output_buf, out_row_ctr, out_rows_avail);
|
||||
(*cinfo->post->post_process_data) (cinfo,
|
||||
main_ptr->xbuffer[main_ptr->whichptr],
|
||||
&main_ptr->rowgroup_ctr,
|
||||
main_ptr->rowgroups_avail, output_buf,
|
||||
out_row_ctr, out_rows_avail);
|
||||
if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail)
|
||||
return; /* Need to suspend */
|
||||
main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
|
||||
@ -361,7 +364,7 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
case CTX_PREPARE_FOR_IMCU:
|
||||
/* Prepare to process first M-1 row groups of this iMCU row */
|
||||
main_ptr->rowgroup_ctr = 0;
|
||||
main_ptr->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size - 1);
|
||||
main_ptr->rowgroups_avail = (JDIMENSION)(cinfo->_min_DCT_scaled_size - 1);
|
||||
/* Check for bottom of image: if so, tweak pointers to "duplicate"
|
||||
* the last sample row, and adjust rowgroups_avail to ignore padding rows.
|
||||
*/
|
||||
@ -371,9 +374,11 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
/*FALLTHROUGH*/
|
||||
case CTX_PROCESS_IMCU:
|
||||
/* Call postprocessor using previously set pointers */
|
||||
(*cinfo->post->post_process_data) (cinfo, main_ptr->xbuffer[main_ptr->whichptr],
|
||||
&main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail,
|
||||
output_buf, out_row_ctr, out_rows_avail);
|
||||
(*cinfo->post->post_process_data) (cinfo,
|
||||
main_ptr->xbuffer[main_ptr->whichptr],
|
||||
&main_ptr->rowgroup_ctr,
|
||||
main_ptr->rowgroups_avail, output_buf,
|
||||
out_row_ctr, out_rows_avail);
|
||||
if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail)
|
||||
return; /* Need to suspend */
|
||||
/* After the first iMCU, change wraparound pointers to normal state */
|
||||
@ -384,8 +389,8 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
main_ptr->buffer_full = FALSE;
|
||||
/* Still need to process last row group of this iMCU row, */
|
||||
/* which is saved at index M+1 of the other xbuffer */
|
||||
main_ptr->rowgroup_ctr = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 1);
|
||||
main_ptr->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 2);
|
||||
main_ptr->rowgroup_ctr = (JDIMENSION)(cinfo->_min_DCT_scaled_size + 1);
|
||||
main_ptr->rowgroups_avail = (JDIMENSION)(cinfo->_min_DCT_scaled_size + 2);
|
||||
main_ptr->context_state = CTX_POSTPONED_ROW;
|
||||
}
|
||||
}
|
||||
@ -400,12 +405,11 @@ process_data_context_main (j_decompress_ptr cinfo,
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
|
||||
METHODDEF(void)
|
||||
process_data_crank_post (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
process_data_crank_post(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
(*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL,
|
||||
(JDIMENSION *) NULL, (JDIMENSION) 0,
|
||||
(*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE)NULL,
|
||||
(JDIMENSION *)NULL, (JDIMENSION)0,
|
||||
output_buf, out_row_ctr, out_rows_avail);
|
||||
}
|
||||
|
||||
@ -417,16 +421,16 @@ process_data_crank_post (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_d_main_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_main_ptr main_ptr;
|
||||
int ci, rgroup, ngroups;
|
||||
jpeg_component_info *compptr;
|
||||
|
||||
main_ptr = (my_main_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_main_controller));
|
||||
cinfo->main = (struct jpeg_d_main_controller *) main_ptr;
|
||||
cinfo->main = (struct jpeg_d_main_controller *)main_ptr;
|
||||
main_ptr->pub.start_pass = start_pass_main;
|
||||
|
||||
if (need_full_buffer) /* shouldn't happen */
|
||||
@ -449,8 +453,8 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
|
||||
cinfo->_min_DCT_scaled_size; /* height of a row group of component */
|
||||
main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
compptr->width_in_blocks * compptr->_DCT_scaled_size,
|
||||
(JDIMENSION) (rgroup * ngroups));
|
||||
(JDIMENSION)(rgroup * ngroups));
|
||||
}
|
||||
}
|
||||
|
12
3rdparty/libjpeg-turbo/src/jdmainct.h
vendored
12
3rdparty/libjpeg-turbo/src/jdmainct.h
vendored
@ -44,12 +44,12 @@ typedef my_main_controller *my_main_ptr;
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
set_wraparound_pointers (j_decompress_ptr cinfo)
|
||||
set_wraparound_pointers(j_decompress_ptr cinfo)
|
||||
/* Set up the "wraparound" pointers at top and bottom of the pointer lists.
|
||||
* This changes the pointer list state from top-of-image to the normal state.
|
||||
*/
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
int ci, i, rgroup;
|
||||
int M = cinfo->_min_DCT_scaled_size;
|
||||
jpeg_component_info *compptr;
|
||||
@ -62,10 +62,10 @@ set_wraparound_pointers (j_decompress_ptr cinfo)
|
||||
xbuf0 = main_ptr->xbuffer[0][ci];
|
||||
xbuf1 = main_ptr->xbuffer[1][ci];
|
||||
for (i = 0; i < rgroup; i++) {
|
||||
xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i];
|
||||
xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i];
|
||||
xbuf0[rgroup*(M+2) + i] = xbuf0[i];
|
||||
xbuf1[rgroup*(M+2) + i] = xbuf1[i];
|
||||
xbuf0[i - rgroup] = xbuf0[rgroup * (M + 1) + i];
|
||||
xbuf1[i - rgroup] = xbuf1[rgroup * (M + 1) + i];
|
||||
xbuf0[rgroup * (M + 2) + i] = xbuf0[i];
|
||||
xbuf1[rgroup * (M + 2) + i] = xbuf1[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
248
3rdparty/libjpeg-turbo/src/jdmarker.c
vendored
248
3rdparty/libjpeg-turbo/src/jdmarker.c
vendored
@ -138,9 +138,9 @@ typedef my_marker_reader *my_marker_ptr;
|
||||
* Note we do *not* do INPUT_SYNC before calling fill_input_buffer,
|
||||
* but we must reload the local copies after a successful fill.
|
||||
*/
|
||||
#define MAKE_BYTE_AVAIL(cinfo,action) \
|
||||
#define MAKE_BYTE_AVAIL(cinfo, action) \
|
||||
if (bytes_in_buffer == 0) { \
|
||||
if (! (*datasrc->fill_input_buffer) (cinfo)) \
|
||||
if (!(*datasrc->fill_input_buffer) (cinfo)) \
|
||||
{ action; } \
|
||||
INPUT_RELOAD(cinfo); \
|
||||
}
|
||||
@ -148,19 +148,19 @@ typedef my_marker_reader *my_marker_ptr;
|
||||
/* Read a byte into variable V.
|
||||
* If must suspend, take the specified action (typically "return FALSE").
|
||||
*/
|
||||
#define INPUT_BYTE(cinfo,V,action) \
|
||||
MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
|
||||
#define INPUT_BYTE(cinfo, V, action) \
|
||||
MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
|
||||
bytes_in_buffer--; \
|
||||
V = GETJOCTET(*next_input_byte++); )
|
||||
|
||||
/* As above, but read two bytes interpreted as an unsigned 16-bit integer.
|
||||
* V should be declared unsigned int or perhaps JLONG.
|
||||
*/
|
||||
#define INPUT_2BYTES(cinfo,V,action) \
|
||||
MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
|
||||
#define INPUT_2BYTES(cinfo, V, action) \
|
||||
MAKESTMT( MAKE_BYTE_AVAIL(cinfo, action); \
|
||||
bytes_in_buffer--; \
|
||||
V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \
|
||||
MAKE_BYTE_AVAIL(cinfo,action); \
|
||||
V = ((unsigned int)GETJOCTET(*next_input_byte++)) << 8; \
|
||||
MAKE_BYTE_AVAIL(cinfo, action); \
|
||||
bytes_in_buffer--; \
|
||||
V += GETJOCTET(*next_input_byte++); )
|
||||
|
||||
@ -197,7 +197,7 @@ typedef my_marker_reader *my_marker_ptr;
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_soi (j_decompress_ptr cinfo)
|
||||
get_soi(j_decompress_ptr cinfo)
|
||||
/* Process an SOI marker */
|
||||
{
|
||||
int i;
|
||||
@ -237,7 +237,7 @@ get_soi (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
/* Process a SOFn marker */
|
||||
{
|
||||
JLONG length;
|
||||
@ -258,7 +258,7 @@ get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
length -= 8;
|
||||
|
||||
TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,
|
||||
(int) cinfo->image_width, (int) cinfo->image_height,
|
||||
(int)cinfo->image_width, (int)cinfo->image_height,
|
||||
cinfo->num_components);
|
||||
|
||||
if (cinfo->marker->saw_SOF)
|
||||
@ -267,16 +267,16 @@ get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
/* We don't support files in which the image height is initially specified */
|
||||
/* as 0 and is later redefined by DNL. As long as we have to check that, */
|
||||
/* might as well have a general sanity check. */
|
||||
if (cinfo->image_height <= 0 || cinfo->image_width <= 0
|
||||
|| cinfo->num_components <= 0)
|
||||
if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
|
||||
cinfo->num_components <= 0)
|
||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||
|
||||
if (length != (cinfo->num_components * 3))
|
||||
ERREXIT(cinfo, JERR_BAD_LENGTH);
|
||||
|
||||
if (cinfo->comp_info == NULL) /* do only once, even if suspend */
|
||||
cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->comp_info = (jpeg_component_info *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * sizeof(jpeg_component_info));
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
@ -301,7 +301,7 @@ get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_sos (j_decompress_ptr cinfo)
|
||||
get_sos(j_decompress_ptr cinfo)
|
||||
/* Process a SOS marker */
|
||||
{
|
||||
JLONG length;
|
||||
@ -309,7 +309,7 @@ get_sos (j_decompress_ptr cinfo)
|
||||
jpeg_component_info *compptr;
|
||||
INPUT_VARS(cinfo);
|
||||
|
||||
if (! cinfo->marker->saw_SOF)
|
||||
if (!cinfo->marker->saw_SOF)
|
||||
ERREXIT(cinfo, JERR_SOS_NO_SOF);
|
||||
|
||||
INPUT_2BYTES(cinfo, length, return FALSE);
|
||||
@ -341,7 +341,7 @@ get_sos (j_decompress_ptr cinfo)
|
||||
|
||||
ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
|
||||
|
||||
id_found:
|
||||
id_found:
|
||||
|
||||
cinfo->cur_comp_info[i] = compptr;
|
||||
compptr->dc_tbl_no = (c >> 4) & 15;
|
||||
@ -384,7 +384,7 @@ get_sos (j_decompress_ptr cinfo)
|
||||
#ifdef D_ARITH_CODING_SUPPORTED
|
||||
|
||||
LOCAL(boolean)
|
||||
get_dac (j_decompress_ptr cinfo)
|
||||
get_dac(j_decompress_ptr cinfo)
|
||||
/* Process a DAC marker */
|
||||
{
|
||||
JLONG length;
|
||||
@ -402,14 +402,14 @@ get_dac (j_decompress_ptr cinfo)
|
||||
|
||||
TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
|
||||
|
||||
if (index < 0 || index >= (2*NUM_ARITH_TBLS))
|
||||
if (index < 0 || index >= (2 * NUM_ARITH_TBLS))
|
||||
ERREXIT1(cinfo, JERR_DAC_INDEX, index);
|
||||
|
||||
if (index >= NUM_ARITH_TBLS) { /* define AC table */
|
||||
cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val;
|
||||
cinfo->arith_ac_K[index - NUM_ARITH_TBLS] = (UINT8)val;
|
||||
} else { /* define DC table */
|
||||
cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F);
|
||||
cinfo->arith_dc_U[index] = (UINT8) (val >> 4);
|
||||
cinfo->arith_dc_L[index] = (UINT8)(val & 0x0F);
|
||||
cinfo->arith_dc_U[index] = (UINT8)(val >> 4);
|
||||
if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])
|
||||
ERREXIT1(cinfo, JERR_DAC_VALUE, val);
|
||||
}
|
||||
@ -422,7 +422,7 @@ get_dac (j_decompress_ptr cinfo)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else /* ! D_ARITH_CODING_SUPPORTED */
|
||||
#else /* !D_ARITH_CODING_SUPPORTED */
|
||||
|
||||
#define get_dac(cinfo) skip_variable(cinfo)
|
||||
|
||||
@ -430,7 +430,7 @@ get_dac (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_dht (j_decompress_ptr cinfo)
|
||||
get_dht(j_decompress_ptr cinfo)
|
||||
/* Process a DHT marker */
|
||||
{
|
||||
JLONG length;
|
||||
@ -467,7 +467,7 @@ get_dht (j_decompress_ptr cinfo)
|
||||
/* Here we just do minimal validation of the counts to avoid walking
|
||||
* off the end of our table space. jdhuff.c will check more carefully.
|
||||
*/
|
||||
if (count > 256 || ((JLONG) count) > length)
|
||||
if (count > 256 || ((JLONG)count) > length)
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
@ -489,7 +489,7 @@ get_dht (j_decompress_ptr cinfo)
|
||||
}
|
||||
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
|
||||
|
||||
MEMCOPY((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
|
||||
MEMCOPY((*htblptr)->huffval, huffval, sizeof((*htblptr)->huffval));
|
||||
@ -504,7 +504,7 @@ get_dht (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_dqt (j_decompress_ptr cinfo)
|
||||
get_dqt(j_decompress_ptr cinfo)
|
||||
/* Process a DQT marker */
|
||||
{
|
||||
JLONG length;
|
||||
@ -527,7 +527,7 @@ get_dqt (j_decompress_ptr cinfo)
|
||||
ERREXIT1(cinfo, JERR_DQT_INDEX, n);
|
||||
|
||||
if (cinfo->quant_tbl_ptrs[n] == NULL)
|
||||
cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);
|
||||
cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr)cinfo);
|
||||
quant_ptr = cinfo->quant_tbl_ptrs[n];
|
||||
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
@ -536,20 +536,20 @@ get_dqt (j_decompress_ptr cinfo)
|
||||
else
|
||||
INPUT_BYTE(cinfo, tmp, return FALSE);
|
||||
/* We convert the zigzag-order table to natural array order. */
|
||||
quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp;
|
||||
quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16)tmp;
|
||||
}
|
||||
|
||||
if (cinfo->err->trace_level >= 2) {
|
||||
for (i = 0; i < DCTSIZE2; i += 8) {
|
||||
TRACEMS8(cinfo, 2, JTRC_QUANTVALS,
|
||||
quant_ptr->quantval[i], quant_ptr->quantval[i+1],
|
||||
quant_ptr->quantval[i+2], quant_ptr->quantval[i+3],
|
||||
quant_ptr->quantval[i+4], quant_ptr->quantval[i+5],
|
||||
quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]);
|
||||
quant_ptr->quantval[i], quant_ptr->quantval[i + 1],
|
||||
quant_ptr->quantval[i + 2], quant_ptr->quantval[i + 3],
|
||||
quant_ptr->quantval[i + 4], quant_ptr->quantval[i + 5],
|
||||
quant_ptr->quantval[i + 6], quant_ptr->quantval[i + 7]);
|
||||
}
|
||||
}
|
||||
|
||||
length -= DCTSIZE2+1;
|
||||
length -= DCTSIZE2 + 1;
|
||||
if (prec) length -= DCTSIZE2;
|
||||
}
|
||||
|
||||
@ -562,7 +562,7 @@ get_dqt (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_dri (j_decompress_ptr cinfo)
|
||||
get_dri(j_decompress_ptr cinfo)
|
||||
/* Process a DRI marker */
|
||||
{
|
||||
JLONG length;
|
||||
@ -598,14 +598,14 @@ get_dri (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
examine_app0 (j_decompress_ptr cinfo, JOCTET *data,
|
||||
unsigned int datalen, JLONG remaining)
|
||||
examine_app0(j_decompress_ptr cinfo, JOCTET *data, unsigned int datalen,
|
||||
JLONG remaining)
|
||||
/* Examine first few bytes from an APP0.
|
||||
* Take appropriate action if it is a JFIF marker.
|
||||
* datalen is # of bytes at data[], remaining is length of rest of marker data.
|
||||
*/
|
||||
{
|
||||
JLONG totallen = (JLONG) datalen + remaining;
|
||||
JLONG totallen = (JLONG)datalen + remaining;
|
||||
|
||||
if (datalen >= APP0_DATA_LEN &&
|
||||
GETJOCTET(data[0]) == 0x4A &&
|
||||
@ -639,8 +639,8 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET *data,
|
||||
GETJOCTET(data[12]), GETJOCTET(data[13]));
|
||||
totallen -= APP0_DATA_LEN;
|
||||
if (totallen !=
|
||||
((JLONG)GETJOCTET(data[12]) * (JLONG)GETJOCTET(data[13]) * (JLONG) 3))
|
||||
TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen);
|
||||
((JLONG)GETJOCTET(data[12]) * (JLONG)GETJOCTET(data[13]) * (JLONG)3))
|
||||
TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int)totallen);
|
||||
} else if (datalen >= 6 &&
|
||||
GETJOCTET(data[0]) == 0x4A &&
|
||||
GETJOCTET(data[1]) == 0x46 &&
|
||||
@ -653,29 +653,29 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET *data,
|
||||
*/
|
||||
switch (GETJOCTET(data[5])) {
|
||||
case 0x10:
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen);
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int)totallen);
|
||||
break;
|
||||
case 0x11:
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen);
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int)totallen);
|
||||
break;
|
||||
case 0x13:
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen);
|
||||
TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int)totallen);
|
||||
break;
|
||||
default:
|
||||
TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
|
||||
GETJOCTET(data[5]), (int) totallen);
|
||||
GETJOCTET(data[5]), (int)totallen);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Start of APP0 does not match "JFIF" or "JFXX", or too short */
|
||||
TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen);
|
||||
TRACEMS1(cinfo, 1, JTRC_APP0, (int)totallen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
examine_app14 (j_decompress_ptr cinfo, JOCTET *data,
|
||||
unsigned int datalen, JLONG remaining)
|
||||
examine_app14(j_decompress_ptr cinfo, JOCTET *data, unsigned int datalen,
|
||||
JLONG remaining)
|
||||
/* Examine first few bytes from an APP14.
|
||||
* Take appropriate action if it is an Adobe marker.
|
||||
* datalen is # of bytes at data[], remaining is length of rest of marker data.
|
||||
@ -696,16 +696,16 @@ examine_app14 (j_decompress_ptr cinfo, JOCTET *data,
|
||||
transform = GETJOCTET(data[11]);
|
||||
TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
|
||||
cinfo->saw_Adobe_marker = TRUE;
|
||||
cinfo->Adobe_transform = (UINT8) transform;
|
||||
cinfo->Adobe_transform = (UINT8)transform;
|
||||
} else {
|
||||
/* Start of APP14 does not match "Adobe", or too short */
|
||||
TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining));
|
||||
TRACEMS1(cinfo, 1, JTRC_APP14, (int)(datalen + remaining));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(boolean)
|
||||
get_interesting_appn (j_decompress_ptr cinfo)
|
||||
get_interesting_appn(j_decompress_ptr cinfo)
|
||||
/* Process an APP0 or APP14 marker without saving it */
|
||||
{
|
||||
JLONG length;
|
||||
@ -720,7 +720,7 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
if (length >= APPN_DATA_LEN)
|
||||
numtoread = APPN_DATA_LEN;
|
||||
else if (length > 0)
|
||||
numtoread = (unsigned int) length;
|
||||
numtoread = (unsigned int)length;
|
||||
else
|
||||
numtoread = 0;
|
||||
for (i = 0; i < numtoread; i++)
|
||||
@ -730,10 +730,10 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
/* process it */
|
||||
switch (cinfo->unread_marker) {
|
||||
case M_APP0:
|
||||
examine_app0(cinfo, (JOCTET *) b, numtoread, length);
|
||||
examine_app0(cinfo, (JOCTET *)b, numtoread, length);
|
||||
break;
|
||||
case M_APP14:
|
||||
examine_app14(cinfo, (JOCTET *) b, numtoread, length);
|
||||
examine_app14(cinfo, (JOCTET *)b, numtoread, length);
|
||||
break;
|
||||
default:
|
||||
/* can't get here unless jpeg_save_markers chooses wrong processor */
|
||||
@ -744,7 +744,7 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
/* skip any remaining data -- could be lots */
|
||||
INPUT_SYNC(cinfo);
|
||||
if (length > 0)
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long) length);
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long)length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -753,10 +753,10 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
#ifdef SAVE_MARKERS_SUPPORTED
|
||||
|
||||
METHODDEF(boolean)
|
||||
save_marker (j_decompress_ptr cinfo)
|
||||
save_marker(j_decompress_ptr cinfo)
|
||||
/* Save an APPn or COM marker into the marker list */
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
jpeg_saved_marker_ptr cur_marker = marker->cur_marker;
|
||||
unsigned int bytes_read, data_length;
|
||||
JOCTET *data;
|
||||
@ -770,22 +770,22 @@ save_marker (j_decompress_ptr cinfo)
|
||||
if (length >= 0) { /* watch out for bogus length word */
|
||||
/* figure out how much we want to save */
|
||||
unsigned int limit;
|
||||
if (cinfo->unread_marker == (int) M_COM)
|
||||
if (cinfo->unread_marker == (int)M_COM)
|
||||
limit = marker->length_limit_COM;
|
||||
else
|
||||
limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0];
|
||||
if ((unsigned int) length < limit)
|
||||
limit = (unsigned int) length;
|
||||
limit = marker->length_limit_APPn[cinfo->unread_marker - (int)M_APP0];
|
||||
if ((unsigned int)length < limit)
|
||||
limit = (unsigned int)length;
|
||||
/* allocate and initialize the marker item */
|
||||
cur_marker = (jpeg_saved_marker_ptr)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(struct jpeg_marker_struct) + limit);
|
||||
cur_marker->next = NULL;
|
||||
cur_marker->marker = (UINT8) cinfo->unread_marker;
|
||||
cur_marker->original_length = (unsigned int) length;
|
||||
cur_marker->marker = (UINT8)cinfo->unread_marker;
|
||||
cur_marker->original_length = (unsigned int)length;
|
||||
cur_marker->data_length = limit;
|
||||
/* data area is just beyond the jpeg_marker_struct */
|
||||
data = cur_marker->data = (JOCTET *) (cur_marker + 1);
|
||||
data = cur_marker->data = (JOCTET *)(cur_marker + 1);
|
||||
marker->cur_marker = cur_marker;
|
||||
marker->bytes_read = 0;
|
||||
bytes_read = 0;
|
||||
@ -843,14 +843,14 @@ save_marker (j_decompress_ptr cinfo)
|
||||
break;
|
||||
default:
|
||||
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
|
||||
(int) (data_length + length));
|
||||
(int)(data_length + length));
|
||||
break;
|
||||
}
|
||||
|
||||
/* skip any remaining data -- could be lots */
|
||||
INPUT_SYNC(cinfo); /* do before skip_input_data */
|
||||
if (length > 0)
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long) length);
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long)length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -859,7 +859,7 @@ save_marker (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
METHODDEF(boolean)
|
||||
skip_variable (j_decompress_ptr cinfo)
|
||||
skip_variable(j_decompress_ptr cinfo)
|
||||
/* Skip over an unknown or uninteresting variable-length marker */
|
||||
{
|
||||
JLONG length;
|
||||
@ -868,11 +868,11 @@ skip_variable (j_decompress_ptr cinfo)
|
||||
INPUT_2BYTES(cinfo, length, return FALSE);
|
||||
length -= 2;
|
||||
|
||||
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length);
|
||||
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int)length);
|
||||
|
||||
INPUT_SYNC(cinfo); /* do before skip_input_data */
|
||||
if (length > 0)
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long) length);
|
||||
(*cinfo->src->skip_input_data) (cinfo, (long)length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -888,7 +888,7 @@ skip_variable (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
next_marker (j_decompress_ptr cinfo)
|
||||
next_marker(j_decompress_ptr cinfo)
|
||||
{
|
||||
int c;
|
||||
INPUT_VARS(cinfo);
|
||||
@ -935,7 +935,7 @@ next_marker (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
first_marker (j_decompress_ptr cinfo)
|
||||
first_marker(j_decompress_ptr cinfo)
|
||||
/* Like next_marker, but used to obtain the initial SOI marker. */
|
||||
/* For this marker, we do not allow preceding garbage or fill; otherwise,
|
||||
* we might well scan an entire input file before realizing it ain't JPEG.
|
||||
@ -948,7 +948,7 @@ first_marker (j_decompress_ptr cinfo)
|
||||
|
||||
INPUT_BYTE(cinfo, c, return FALSE);
|
||||
INPUT_BYTE(cinfo, c2, return FALSE);
|
||||
if (c != 0xFF || c2 != (int) M_SOI)
|
||||
if (c != 0xFF || c2 != (int)M_SOI)
|
||||
ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
|
||||
|
||||
cinfo->unread_marker = c2;
|
||||
@ -966,18 +966,18 @@ first_marker (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
read_markers (j_decompress_ptr cinfo)
|
||||
read_markers(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* Outer loop repeats once for each marker. */
|
||||
for (;;) {
|
||||
/* Collect the marker proper, unless we already did. */
|
||||
/* NB: first_marker() enforces the requirement that SOI appear first. */
|
||||
if (cinfo->unread_marker == 0) {
|
||||
if (! cinfo->marker->saw_SOI) {
|
||||
if (! first_marker(cinfo))
|
||||
if (!cinfo->marker->saw_SOI) {
|
||||
if (!first_marker(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
} else {
|
||||
if (! next_marker(cinfo))
|
||||
if (!next_marker(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
}
|
||||
}
|
||||
@ -987,28 +987,28 @@ read_markers (j_decompress_ptr cinfo)
|
||||
*/
|
||||
switch (cinfo->unread_marker) {
|
||||
case M_SOI:
|
||||
if (! get_soi(cinfo))
|
||||
if (!get_soi(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF0: /* Baseline */
|
||||
case M_SOF1: /* Extended sequential, Huffman */
|
||||
if (! get_sof(cinfo, FALSE, FALSE))
|
||||
if (!get_sof(cinfo, FALSE, FALSE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF2: /* Progressive, Huffman */
|
||||
if (! get_sof(cinfo, TRUE, FALSE))
|
||||
if (!get_sof(cinfo, TRUE, FALSE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF9: /* Extended sequential, arithmetic */
|
||||
if (! get_sof(cinfo, FALSE, TRUE))
|
||||
if (!get_sof(cinfo, FALSE, TRUE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF10: /* Progressive, arithmetic */
|
||||
if (! get_sof(cinfo, TRUE, TRUE))
|
||||
if (!get_sof(cinfo, TRUE, TRUE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
@ -1026,7 +1026,7 @@ read_markers (j_decompress_ptr cinfo)
|
||||
break;
|
||||
|
||||
case M_SOS:
|
||||
if (! get_sos(cinfo))
|
||||
if (!get_sos(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
cinfo->unread_marker = 0; /* processed the marker */
|
||||
return JPEG_REACHED_SOS;
|
||||
@ -1037,22 +1037,22 @@ read_markers (j_decompress_ptr cinfo)
|
||||
return JPEG_REACHED_EOI;
|
||||
|
||||
case M_DAC:
|
||||
if (! get_dac(cinfo))
|
||||
if (!get_dac(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_DHT:
|
||||
if (! get_dht(cinfo))
|
||||
if (!get_dht(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_DQT:
|
||||
if (! get_dqt(cinfo))
|
||||
if (!get_dqt(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_DRI:
|
||||
if (! get_dri(cinfo))
|
||||
if (!get_dri(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
@ -1072,13 +1072,13 @@ read_markers (j_decompress_ptr cinfo)
|
||||
case M_APP13:
|
||||
case M_APP14:
|
||||
case M_APP15:
|
||||
if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[
|
||||
cinfo->unread_marker - (int) M_APP0]) (cinfo))
|
||||
if (!(*((my_marker_ptr)cinfo->marker)->process_APPn[
|
||||
cinfo->unread_marker - (int)M_APP0]) (cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_COM:
|
||||
if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo))
|
||||
if (!(*((my_marker_ptr)cinfo->marker)->process_COM) (cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
@ -1095,7 +1095,7 @@ read_markers (j_decompress_ptr cinfo)
|
||||
break;
|
||||
|
||||
case M_DNL: /* Ignore DNL ... perhaps the wrong thing */
|
||||
if (! skip_variable(cinfo))
|
||||
if (!skip_variable(cinfo))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
@ -1127,24 +1127,24 @@ read_markers (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
read_restart_marker (j_decompress_ptr cinfo)
|
||||
read_restart_marker(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* Obtain a marker unless we already did. */
|
||||
/* Note that next_marker will complain if it skips any data. */
|
||||
if (cinfo->unread_marker == 0) {
|
||||
if (! next_marker(cinfo))
|
||||
if (!next_marker(cinfo))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (cinfo->unread_marker ==
|
||||
((int) M_RST0 + cinfo->marker->next_restart_num)) {
|
||||
((int)M_RST0 + cinfo->marker->next_restart_num)) {
|
||||
/* Normal case --- swallow the marker and let entropy decoder continue */
|
||||
TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
|
||||
cinfo->unread_marker = 0;
|
||||
} else {
|
||||
/* Uh-oh, the restart markers have been messed up. */
|
||||
/* Let the data source manager determine how to resync. */
|
||||
if (! (*cinfo->src->resync_to_restart) (cinfo,
|
||||
if (!(*cinfo->src->resync_to_restart) (cinfo,
|
||||
cinfo->marker->next_restart_num))
|
||||
return FALSE;
|
||||
}
|
||||
@ -1206,7 +1206,7 @@ read_restart_marker (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(boolean)
|
||||
jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
|
||||
jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
|
||||
{
|
||||
int marker = cinfo->unread_marker;
|
||||
int action = 1;
|
||||
@ -1216,16 +1216,16 @@ jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
|
||||
|
||||
/* Outer loop handles repeated decision after scanning forward. */
|
||||
for (;;) {
|
||||
if (marker < (int) M_SOF0)
|
||||
if (marker < (int)M_SOF0)
|
||||
action = 2; /* invalid marker */
|
||||
else if (marker < (int) M_RST0 || marker > (int) M_RST7)
|
||||
else if (marker < (int)M_RST0 || marker > (int)M_RST7)
|
||||
action = 3; /* valid non-restart marker */
|
||||
else {
|
||||
if (marker == ((int) M_RST0 + ((desired+1) & 7)) ||
|
||||
marker == ((int) M_RST0 + ((desired+2) & 7)))
|
||||
if (marker == ((int)M_RST0 + ((desired + 1) & 7)) ||
|
||||
marker == ((int)M_RST0 + ((desired + 2) & 7)))
|
||||
action = 3; /* one of the next two expected restarts */
|
||||
else if (marker == ((int) M_RST0 + ((desired-1) & 7)) ||
|
||||
marker == ((int) M_RST0 + ((desired-2) & 7)))
|
||||
else if (marker == ((int)M_RST0 + ((desired - 1) & 7)) ||
|
||||
marker == ((int)M_RST0 + ((desired - 2) & 7)))
|
||||
action = 2; /* a prior restart, so advance */
|
||||
else
|
||||
action = 1; /* desired restart or too far away */
|
||||
@ -1238,7 +1238,7 @@ jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
|
||||
return TRUE;
|
||||
case 2:
|
||||
/* Scan to the next marker, and repeat the decision loop. */
|
||||
if (! next_marker(cinfo))
|
||||
if (!next_marker(cinfo))
|
||||
return FALSE;
|
||||
marker = cinfo->unread_marker;
|
||||
break;
|
||||
@ -1256,9 +1256,9 @@ jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
reset_marker_reader (j_decompress_ptr cinfo)
|
||||
reset_marker_reader(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
|
||||
cinfo->comp_info = NULL; /* until allocated by get_sof */
|
||||
cinfo->input_scan_number = 0; /* no SOS seen yet */
|
||||
@ -1276,16 +1276,16 @@ reset_marker_reader (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_marker_reader (j_decompress_ptr cinfo)
|
||||
jinit_marker_reader(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_marker_ptr marker;
|
||||
int i;
|
||||
|
||||
/* Create subobject in permanent pool */
|
||||
marker = (my_marker_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
||||
sizeof(my_marker_reader));
|
||||
cinfo->marker = (struct jpeg_marker_reader *) marker;
|
||||
cinfo->marker = (struct jpeg_marker_reader *)marker;
|
||||
/* Initialize public method pointers */
|
||||
marker->pub.reset_marker_reader = reset_marker_reader;
|
||||
marker->pub.read_markers = read_markers;
|
||||
@ -1314,10 +1314,10 @@ jinit_marker_reader (j_decompress_ptr cinfo)
|
||||
#ifdef SAVE_MARKERS_SUPPORTED
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
jpeg_save_markers(j_decompress_ptr cinfo, int marker_code,
|
||||
unsigned int length_limit)
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
long maxlength;
|
||||
jpeg_marker_parser_method processor;
|
||||
|
||||
@ -1325,8 +1325,8 @@ jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
* (should only be a concern in a 16-bit environment).
|
||||
*/
|
||||
maxlength = cinfo->mem->max_alloc_chunk - sizeof(struct jpeg_marker_struct);
|
||||
if (((long) length_limit) > maxlength)
|
||||
length_limit = (unsigned int) maxlength;
|
||||
if (((long)length_limit) > maxlength)
|
||||
length_limit = (unsigned int)maxlength;
|
||||
|
||||
/* Choose processor routine to use.
|
||||
* APP0/APP14 have special requirements.
|
||||
@ -1334,23 +1334,23 @@ jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
if (length_limit) {
|
||||
processor = save_marker;
|
||||
/* If saving APP0/APP14, save at least enough for our internal use. */
|
||||
if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN)
|
||||
if (marker_code == (int)M_APP0 && length_limit < APP0_DATA_LEN)
|
||||
length_limit = APP0_DATA_LEN;
|
||||
else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN)
|
||||
else if (marker_code == (int)M_APP14 && length_limit < APP14_DATA_LEN)
|
||||
length_limit = APP14_DATA_LEN;
|
||||
} else {
|
||||
processor = skip_variable;
|
||||
/* If discarding APP0/APP14, use our regular on-the-fly processor. */
|
||||
if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14)
|
||||
if (marker_code == (int)M_APP0 || marker_code == (int)M_APP14)
|
||||
processor = get_interesting_appn;
|
||||
}
|
||||
|
||||
if (marker_code == (int) M_COM) {
|
||||
if (marker_code == (int)M_COM) {
|
||||
marker->process_COM = processor;
|
||||
marker->length_limit_COM = length_limit;
|
||||
} else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) {
|
||||
marker->process_APPn[marker_code - (int) M_APP0] = processor;
|
||||
marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit;
|
||||
} else if (marker_code >= (int)M_APP0 && marker_code <= (int)M_APP15) {
|
||||
marker->process_APPn[marker_code - (int)M_APP0] = processor;
|
||||
marker->length_limit_APPn[marker_code - (int)M_APP0] = length_limit;
|
||||
} else
|
||||
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
|
||||
}
|
||||
@ -1363,15 +1363,15 @@ jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code,
|
||||
jpeg_set_marker_processor(j_decompress_ptr cinfo, int marker_code,
|
||||
jpeg_marker_parser_method routine)
|
||||
{
|
||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||
my_marker_ptr marker = (my_marker_ptr)cinfo->marker;
|
||||
|
||||
if (marker_code == (int) M_COM)
|
||||
if (marker_code == (int)M_COM)
|
||||
marker->process_COM = routine;
|
||||
else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15)
|
||||
marker->process_APPn[marker_code - (int) M_APP0] = routine;
|
||||
else if (marker_code >= (int)M_APP0 && marker_code <= (int)M_APP15)
|
||||
marker->process_APPn[marker_code - (int)M_APP0] = routine;
|
||||
else
|
||||
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
|
||||
}
|
||||
|
147
3rdparty/libjpeg-turbo/src/jdmaster.c
vendored
147
3rdparty/libjpeg-turbo/src/jdmaster.c
vendored
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
use_merged_upsample (j_decompress_ptr cinfo)
|
||||
use_merged_upsample(j_decompress_ptr cinfo)
|
||||
{
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
/* Merging is the equivalent of plain box-filter upsampling */
|
||||
@ -100,7 +100,7 @@ GLOBAL(void)
|
||||
#else
|
||||
LOCAL(void)
|
||||
#endif
|
||||
jpeg_core_output_dimensions (j_decompress_ptr cinfo)
|
||||
jpeg_core_output_dimensions(j_decompress_ptr cinfo)
|
||||
/* Do computations that are needed before master selection phase.
|
||||
* This function is used for transcoding and full decompression.
|
||||
*/
|
||||
@ -113,129 +113,129 @@ jpeg_core_output_dimensions (j_decompress_ptr cinfo)
|
||||
if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom) {
|
||||
/* Provide 1/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 1;
|
||||
cinfo->_min_DCT_v_scaled_size = 1;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 2) {
|
||||
/* Provide 2/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 2L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 2L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 2L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 2L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 2;
|
||||
cinfo->_min_DCT_v_scaled_size = 2;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 3) {
|
||||
/* Provide 3/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 3L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 3L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 3L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 3L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 3;
|
||||
cinfo->_min_DCT_v_scaled_size = 3;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 4) {
|
||||
/* Provide 4/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 4L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 4L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 4L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 4L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 4;
|
||||
cinfo->_min_DCT_v_scaled_size = 4;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 5) {
|
||||
/* Provide 5/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 5L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 5L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 5L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 5L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 5;
|
||||
cinfo->_min_DCT_v_scaled_size = 5;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 6) {
|
||||
/* Provide 6/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 6L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 6L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 6L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 6L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 6;
|
||||
cinfo->_min_DCT_v_scaled_size = 6;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 7) {
|
||||
/* Provide 7/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 7L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 7L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 7L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 7L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 7;
|
||||
cinfo->_min_DCT_v_scaled_size = 7;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 8) {
|
||||
/* Provide 8/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 8L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 8L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 8L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 8L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 8;
|
||||
cinfo->_min_DCT_v_scaled_size = 8;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 9) {
|
||||
/* Provide 9/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 9L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 9L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 9L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 9L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 9;
|
||||
cinfo->_min_DCT_v_scaled_size = 9;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 10) {
|
||||
/* Provide 10/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 10L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 10L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 10L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 10L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 10;
|
||||
cinfo->_min_DCT_v_scaled_size = 10;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 11) {
|
||||
/* Provide 11/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 11L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 11L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 11L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 11L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 11;
|
||||
cinfo->_min_DCT_v_scaled_size = 11;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 12) {
|
||||
/* Provide 12/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 12L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 12L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 12L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 12L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 12;
|
||||
cinfo->_min_DCT_v_scaled_size = 12;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 13) {
|
||||
/* Provide 13/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 13L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 13L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 13L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 13L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 13;
|
||||
cinfo->_min_DCT_v_scaled_size = 13;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 14) {
|
||||
/* Provide 14/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 14L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 14L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 14L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 14L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 14;
|
||||
cinfo->_min_DCT_v_scaled_size = 14;
|
||||
} else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 15) {
|
||||
/* Provide 15/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 15L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 15L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 15L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 15L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 15;
|
||||
cinfo->_min_DCT_v_scaled_size = 15;
|
||||
} else {
|
||||
/* Provide 16/block_size scaling */
|
||||
cinfo->output_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width * 16L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_width * 16L, (long)DCTSIZE);
|
||||
cinfo->output_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height * 16L, (long) DCTSIZE);
|
||||
jdiv_round_up((long)cinfo->image_height * 16L, (long)DCTSIZE);
|
||||
cinfo->_min_DCT_h_scaled_size = 16;
|
||||
cinfo->_min_DCT_v_scaled_size = 16;
|
||||
}
|
||||
@ -268,7 +268,7 @@ jpeg_core_output_dimensions (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
|
||||
/* Do computations that are needed before master selection phase */
|
||||
{
|
||||
#ifdef IDCT_SCALING_SUPPORTED
|
||||
@ -314,13 +314,13 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
ci++, compptr++) {
|
||||
/* Size in samples, after IDCT scaling */
|
||||
compptr->downsampled_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width *
|
||||
(long) (compptr->h_samp_factor * compptr->_DCT_scaled_size),
|
||||
(long) (cinfo->max_h_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_width *
|
||||
(long)(compptr->h_samp_factor * compptr->_DCT_scaled_size),
|
||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
||||
compptr->downsampled_height = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_height *
|
||||
(long) (compptr->v_samp_factor * compptr->_DCT_scaled_size),
|
||||
(long) (cinfo->max_v_samp_factor * DCTSIZE));
|
||||
jdiv_round_up((long)cinfo->image_height *
|
||||
(long)(compptr->v_samp_factor * compptr->_DCT_scaled_size),
|
||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
||||
}
|
||||
|
||||
#else /* !IDCT_SCALING_SUPPORTED */
|
||||
@ -417,30 +417,30 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
prepare_range_limit_table (j_decompress_ptr cinfo)
|
||||
prepare_range_limit_table(j_decompress_ptr cinfo)
|
||||
/* Allocate and fill in the sample_range_limit table */
|
||||
{
|
||||
JSAMPLE *table;
|
||||
int i;
|
||||
|
||||
table = (JSAMPLE *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
|
||||
table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
|
||||
table += (MAXJSAMPLE + 1); /* allow negative subscripts of simple table */
|
||||
cinfo->sample_range_limit = table;
|
||||
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
|
||||
MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * sizeof(JSAMPLE));
|
||||
MEMZERO(table - (MAXJSAMPLE + 1), (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
|
||||
/* Main part of "simple" table: limit[x] = x */
|
||||
for (i = 0; i <= MAXJSAMPLE; i++)
|
||||
table[i] = (JSAMPLE) i;
|
||||
table[i] = (JSAMPLE)i;
|
||||
table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
|
||||
/* End of simple table, rest of first half of post-IDCT table */
|
||||
for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
|
||||
for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
|
||||
table[i] = MAXJSAMPLE;
|
||||
/* Second half of post-IDCT table */
|
||||
MEMZERO(table + (2 * (MAXJSAMPLE+1)),
|
||||
(2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
|
||||
MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
|
||||
MEMZERO(table + (2 * (MAXJSAMPLE + 1)),
|
||||
(2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
|
||||
MEMCOPY(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
|
||||
cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
|
||||
}
|
||||
|
||||
@ -457,9 +457,9 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
master_selection (j_decompress_ptr cinfo)
|
||||
master_selection(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
boolean use_c_buffer;
|
||||
long samplesperrow;
|
||||
JDIMENSION jd_samplesperrow;
|
||||
@ -469,9 +469,10 @@ master_selection (j_decompress_ptr cinfo)
|
||||
prepare_range_limit_table(cinfo);
|
||||
|
||||
/* Width of an output scanline must be representable as JDIMENSION. */
|
||||
samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
|
||||
jd_samplesperrow = (JDIMENSION) samplesperrow;
|
||||
if ((long) jd_samplesperrow != samplesperrow)
|
||||
samplesperrow = (long)cinfo->output_width *
|
||||
(long)cinfo->out_color_components;
|
||||
jd_samplesperrow = (JDIMENSION)samplesperrow;
|
||||
if ((long)jd_samplesperrow != samplesperrow)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
|
||||
/* Initialize my private state */
|
||||
@ -482,7 +483,7 @@ master_selection (j_decompress_ptr cinfo)
|
||||
master->quantizer_1pass = NULL;
|
||||
master->quantizer_2pass = NULL;
|
||||
/* No mode changes if not using buffered-image mode. */
|
||||
if (! cinfo->quantize_colors || ! cinfo->buffered_image) {
|
||||
if (!cinfo->quantize_colors || !cinfo->buffered_image) {
|
||||
cinfo->enable_1pass_quant = FALSE;
|
||||
cinfo->enable_external_quant = FALSE;
|
||||
cinfo->enable_2pass_quant = FALSE;
|
||||
@ -528,7 +529,7 @@ master_selection (j_decompress_ptr cinfo)
|
||||
}
|
||||
|
||||
/* Post-processing: in particular, color conversion first */
|
||||
if (! cinfo->raw_data_out) {
|
||||
if (!cinfo->raw_data_out) {
|
||||
if (master->using_merged_upsample) {
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
jinit_merged_upsampler(cinfo); /* does color conversion too */
|
||||
@ -565,11 +566,11 @@ master_selection (j_decompress_ptr cinfo)
|
||||
use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
|
||||
jinit_d_coef_controller(cinfo, use_c_buffer);
|
||||
|
||||
if (! cinfo->raw_data_out)
|
||||
if (!cinfo->raw_data_out)
|
||||
jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
|
||||
|
||||
/* We can now tell the memory manager to allocate virtual arrays. */
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
|
||||
|
||||
/* Initialize input side of decompressor to consume first scan. */
|
||||
(*cinfo->inputctl->start_input_pass) (cinfo);
|
||||
@ -585,7 +586,7 @@ master_selection (j_decompress_ptr cinfo)
|
||||
* progress monitoring appropriately. The input step is counted
|
||||
* as one pass.
|
||||
*/
|
||||
if (cinfo->progress != NULL && ! cinfo->buffered_image &&
|
||||
if (cinfo->progress != NULL && !cinfo->buffered_image &&
|
||||
cinfo->inputctl->has_multiple_scans) {
|
||||
int nscans;
|
||||
/* Estimate number of scans to set pass_limit. */
|
||||
@ -597,7 +598,7 @@ master_selection (j_decompress_ptr cinfo)
|
||||
nscans = cinfo->num_components;
|
||||
}
|
||||
cinfo->progress->pass_counter = 0L;
|
||||
cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
|
||||
cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
|
||||
cinfo->progress->completed_passes = 0;
|
||||
cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
|
||||
/* Count the input pass as done */
|
||||
@ -617,9 +618,9 @@ master_selection (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
prepare_for_output_pass (j_decompress_ptr cinfo)
|
||||
prepare_for_output_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
if (master->pub.is_dummy_pass) {
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
@ -645,8 +646,8 @@ prepare_for_output_pass (j_decompress_ptr cinfo)
|
||||
}
|
||||
(*cinfo->idct->start_pass) (cinfo);
|
||||
(*cinfo->coef->start_output_pass) (cinfo);
|
||||
if (! cinfo->raw_data_out) {
|
||||
if (! master->using_merged_upsample)
|
||||
if (!cinfo->raw_data_out) {
|
||||
if (!master->using_merged_upsample)
|
||||
(*cinfo->cconvert->start_pass) (cinfo);
|
||||
(*cinfo->upsample->start_pass) (cinfo);
|
||||
if (cinfo->quantize_colors)
|
||||
@ -665,7 +666,7 @@ prepare_for_output_pass (j_decompress_ptr cinfo)
|
||||
/* In buffered-image mode, we assume one more output pass if EOI not
|
||||
* yet reached, but no more passes if EOI has been reached.
|
||||
*/
|
||||
if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
|
||||
if (cinfo->buffered_image && !cinfo->inputctl->eoi_reached) {
|
||||
cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
|
||||
}
|
||||
}
|
||||
@ -677,9 +678,9 @@ prepare_for_output_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_output_pass (j_decompress_ptr cinfo)
|
||||
finish_output_pass(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
if (cinfo->quantize_colors)
|
||||
(*cinfo->cquantize->finish_pass) (cinfo);
|
||||
@ -694,9 +695,9 @@ finish_output_pass (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_new_colormap (j_decompress_ptr cinfo)
|
||||
jpeg_new_colormap(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
/* Prevent application from calling me at wrong times */
|
||||
if (cinfo->global_state != DSTATE_BUFIMAGE)
|
||||
@ -722,9 +723,9 @@ jpeg_new_colormap (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_master_decompress (j_decompress_ptr cinfo)
|
||||
jinit_master_decompress(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
master->pub.prepare_for_output_pass = prepare_for_output_pass;
|
||||
master->pub.finish_output_pass = finish_output_pass;
|
||||
|
112
3rdparty/libjpeg-turbo/src/jdmerge.c
vendored
112
3rdparty/libjpeg-turbo/src/jdmerge.c
vendored
@ -76,8 +76,8 @@ typedef struct {
|
||||
typedef my_upsampler *my_upsample_ptr;
|
||||
|
||||
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
||||
#define ONE_HALF ((JLONG) 1 << (SCALEBITS-1))
|
||||
#define FIX(x) ((JLONG) ((x) * (1L<<SCALEBITS) + 0.5))
|
||||
#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
|
||||
#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
|
||||
|
||||
|
||||
/* Include inline routines for colorspace extensions */
|
||||
@ -187,25 +187,25 @@ typedef my_upsampler *my_upsample_ptr;
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
build_ycc_rgb_table(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
int i;
|
||||
JLONG x;
|
||||
SHIFT_TEMPS
|
||||
|
||||
upsample->Cr_r_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(int));
|
||||
upsample->Cb_b_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(int));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(int));
|
||||
upsample->Cr_g_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(JLONG));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(JLONG));
|
||||
upsample->Cb_g_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(JLONG));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(JLONG));
|
||||
|
||||
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
||||
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
|
||||
@ -217,10 +217,10 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
upsample->Cb_b_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.71414 * x */
|
||||
upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x;
|
||||
upsample->Cr_g_tab[i] = (-FIX(0.71414)) * x;
|
||||
/* Cb=>G value is scaled-up -0.34414 * x */
|
||||
/* We also add in ONE_HALF so that need not do it in inner loop */
|
||||
upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;
|
||||
upsample->Cb_g_tab[i] = (-FIX(0.34414)) * x + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,9 +230,9 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_merged_upsample (j_decompress_ptr cinfo)
|
||||
start_pass_merged_upsample(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Mark the spare buffer empty */
|
||||
upsample->spare_full = FALSE;
|
||||
@ -248,14 +248,13 @@ start_pass_merged_upsample (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
merged_2v_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
merged_2v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
/* 2:1 vertical sampling case: may need a spare row. */
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
JSAMPROW work_ptrs[2];
|
||||
JDIMENSION num_rows; /* number of rows returned to caller */
|
||||
|
||||
@ -264,8 +263,8 @@ merged_2v_upsample (j_decompress_ptr cinfo,
|
||||
JDIMENSION size = upsample->out_row_width;
|
||||
if (cinfo->out_color_space == JCS_RGB565)
|
||||
size = cinfo->output_width * 2;
|
||||
jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0,
|
||||
1, size);
|
||||
jcopy_sample_rows(&upsample->spare_row, 0, output_buf + *out_row_ctr, 0, 1,
|
||||
size);
|
||||
num_rows = 1;
|
||||
upsample->spare_full = FALSE;
|
||||
} else {
|
||||
@ -294,20 +293,19 @@ merged_2v_upsample (j_decompress_ptr cinfo,
|
||||
*out_row_ctr += num_rows;
|
||||
upsample->rows_to_go -= num_rows;
|
||||
/* When the buffer is emptied, declare this input row group consumed */
|
||||
if (! upsample->spare_full)
|
||||
if (!upsample->spare_full)
|
||||
(*in_row_group_ctr)++;
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
merged_1v_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
merged_1v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
/* 1:1 vertical sampling case: much easier, never need a spare row. */
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Just do the upsampling. */
|
||||
(*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr,
|
||||
@ -333,9 +331,8 @@ merged_1v_upsample (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@ -379,9 +376,8 @@ h2v1_merged_upsample (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
@ -436,12 +432,12 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
|
||||
|
||||
#define WRITE_TWO_PIXELS_LE(addr, pixels) { \
|
||||
((INT16*)(addr))[0] = (INT16)(pixels); \
|
||||
((INT16*)(addr))[1] = (INT16)((pixels) >> 16); \
|
||||
((INT16 *)(addr))[0] = (INT16)(pixels); \
|
||||
((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \
|
||||
}
|
||||
#define WRITE_TWO_PIXELS_BE(addr, pixels) { \
|
||||
((INT16*)(addr))[1] = (INT16)(pixels); \
|
||||
((INT16*)(addr))[0] = (INT16)((pixels) >> 16); \
|
||||
((INT16 *)(addr))[1] = (INT16)(pixels); \
|
||||
((INT16 *)(addr))[0] = (INT16)((pixels) >> 16); \
|
||||
}
|
||||
|
||||
#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
|
||||
@ -452,7 +448,7 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
/* Declarations for ordered dithering
|
||||
*
|
||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||
* sufficent for dithering RGB888 to RGB565.
|
||||
* sufficient for dithering RGB888 to RGB565.
|
||||
*/
|
||||
|
||||
#define DITHER_MASK 0x3
|
||||
@ -510,9 +506,8 @@ static INLINE boolean is_big_endian(void)
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v1_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v1_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
|
||||
@ -520,13 +515,12 @@ h2v1_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
else
|
||||
h2v1_merged_upsample_565_le(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v1_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v1_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
|
||||
@ -538,9 +532,8 @@ h2v1_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v2_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v2_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
|
||||
@ -552,9 +545,8 @@ h2v2_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v2_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v2_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
|
||||
@ -574,14 +566,14 @@ h2v2_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
jinit_merged_upsampler(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample;
|
||||
|
||||
upsample = (my_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *) upsample;
|
||||
cinfo->upsample = (struct jpeg_upsampler *)upsample;
|
||||
upsample->pub.start_pass = start_pass_merged_upsample;
|
||||
upsample->pub.need_context_rows = FALSE;
|
||||
|
||||
@ -602,8 +594,8 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
}
|
||||
/* Allocate a spare row buffer */
|
||||
upsample->spare_row = (JSAMPROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) (upsample->out_row_width * sizeof(JSAMPLE)));
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(size_t)(upsample->out_row_width * sizeof(JSAMPLE)));
|
||||
} else {
|
||||
upsample->pub.upsample = merged_1v_upsample;
|
||||
if (jsimd_can_h2v1_merged_upsample())
|
||||
|
112
3rdparty/libjpeg-turbo/src/jdmrg565.c
vendored
112
3rdparty/libjpeg-turbo/src/jdmrg565.c
vendored
@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* Copyright (C) 2014-2015, D. R. Commander.
|
||||
* Copyright (C) 2014-2015, 2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@ -15,23 +15,22 @@
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v1_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
h2v1_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
unsigned int r, g, b;
|
||||
JLONG rgb;
|
||||
SHIFT_TEMPS
|
||||
@ -47,7 +46,7 @@ h2v1_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 2 Y values and emit 2 pixels */
|
||||
@ -72,37 +71,37 @@ h2v1_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
}
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v1_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
h2v1_merged_upsample_565D_internal(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
unsigned int r, g, b;
|
||||
JLONG rgb;
|
||||
@ -119,7 +118,7 @@ h2v1_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 2 Y values and emit 2 pixels */
|
||||
@ -146,37 +145,36 @@ h2v1_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = (INT16)rgb;
|
||||
*(INT16 *)outptr = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v2_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
h2v2_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
JSAMPROW inptr00, inptr01, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
unsigned int r, g, b;
|
||||
JLONG rgb;
|
||||
SHIFT_TEMPS
|
||||
@ -194,7 +192,7 @@ h2v2_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 4 Y values and emit 4 pixels */
|
||||
@ -234,7 +232,7 @@ h2v2_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
y = GETJSAMPLE(*inptr00);
|
||||
@ -242,45 +240,45 @@ h2v2_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr0 = (INT16)rgb;
|
||||
*(INT16 *)outptr0 = (INT16)rgb;
|
||||
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr1 = (INT16)rgb;
|
||||
*(INT16 *)outptr1 = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
h2v2_merged_upsample_565D_internal(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
JSAMPROW inptr00, inptr01, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
JLONG d1 = dither_matrix[(cinfo->output_scanline+1) & DITHER_MASK];
|
||||
JLONG d1 = dither_matrix[(cinfo->output_scanline + 1) & DITHER_MASK];
|
||||
unsigned int r, g, b;
|
||||
JLONG rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr00 = input_buf[0][in_row_group_ctr*2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr*2 + 1];
|
||||
inptr00 = input_buf[0][in_row_group_ctr * 2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr0 = output_buf[0];
|
||||
@ -292,7 +290,7 @@ h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 4 Y values and emit 4 pixels */
|
||||
@ -304,20 +302,20 @@ h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
d1 = DITHER_ROTATE(d1);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr0, rgb);
|
||||
outptr0 += 4;
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
d1 = DITHER_ROTATE(d1);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
@ -336,7 +334,7 @@ h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
y = GETJSAMPLE(*inptr00);
|
||||
@ -344,13 +342,13 @@ h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr0 = (INT16)rgb;
|
||||
*(INT16 *)outptr0 = (INT16)rgb;
|
||||
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr1 = (INT16)rgb;
|
||||
*(INT16 *)outptr1 = (INT16)rgb;
|
||||
}
|
||||
}
|
||||
|
42
3rdparty/libjpeg-turbo/src/jdmrgext.c
vendored
42
3rdparty/libjpeg-turbo/src/jdmrgext.c
vendored
@ -21,23 +21,22 @@
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v1_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr0 = input_buf[0][in_row_group_ctr];
|
||||
@ -50,7 +49,7 @@ h2v1_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
/* Fetch 2 Y values and emit 2 pixels */
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
@ -75,7 +74,7 @@ h2v1_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
outptr[RGB_RED] = range_limit[y + cred];
|
||||
@ -94,27 +93,26 @@ h2v1_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v2_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
JSAMPROW inptr00, inptr01, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG * Crgtab = upsample->Cr_g_tab;
|
||||
JLONG * Cbgtab = upsample->Cb_g_tab;
|
||||
register JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int *Crrtab = upsample->Cr_r_tab;
|
||||
int *Cbbtab = upsample->Cb_b_tab;
|
||||
JLONG *Crgtab = upsample->Cr_g_tab;
|
||||
JLONG *Cbgtab = upsample->Cb_g_tab;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr00 = input_buf[0][in_row_group_ctr*2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr*2 + 1];
|
||||
inptr00 = input_buf[0][in_row_group_ctr * 2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr0 = output_buf[0];
|
||||
@ -125,7 +123,7 @@ h2v2_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
/* Fetch 4 Y values and emit 4 pixels */
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
@ -166,7 +164,7 @@ h2v2_merged_upsample_internal (j_decompress_ptr cinfo,
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr00);
|
||||
outptr0[RGB_RED] = range_limit[y + cred];
|
||||
|
125
3rdparty/libjpeg-turbo/src/jdphuff.c
vendored
125
3rdparty/libjpeg-turbo/src/jdphuff.c
vendored
@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015-2016, D. R. Commander.
|
||||
* Copyright (C) 2015-2016, 2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@ -15,12 +15,16 @@
|
||||
* up to the start of the current MCU. To do this, we copy state variables
|
||||
* into local working storage, and update them back to the permanent
|
||||
* storage only upon successful completion of an MCU.
|
||||
*
|
||||
* NOTE: All referenced figures are from
|
||||
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jdhuff.h" /* Declarations shared with jdhuff.c */
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
#ifdef D_PROGRESSIVE_SUPPORTED
|
||||
@ -43,10 +47,10 @@ typedef struct {
|
||||
*/
|
||||
|
||||
#ifndef NO_STRUCT_ASSIGN
|
||||
#define ASSIGN_STATE(dest,src) ((dest) = (src))
|
||||
#define ASSIGN_STATE(dest, src) ((dest) = (src))
|
||||
#else
|
||||
#if MAX_COMPS_IN_SCAN == 4
|
||||
#define ASSIGN_STATE(dest,src) \
|
||||
#define ASSIGN_STATE(dest, src) \
|
||||
((dest).EOBRUN = (src).EOBRUN, \
|
||||
(dest).last_dc_val[0] = (src).last_dc_val[0], \
|
||||
(dest).last_dc_val[1] = (src).last_dc_val[1], \
|
||||
@ -77,13 +81,13 @@ typedef struct {
|
||||
typedef phuff_entropy_decoder *phuff_entropy_ptr;
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(boolean) decode_mcu_DC_first (j_decompress_ptr cinfo,
|
||||
METHODDEF(boolean) decode_mcu_DC_first(j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) decode_mcu_AC_first (j_decompress_ptr cinfo,
|
||||
METHODDEF(boolean) decode_mcu_AC_first(j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) decode_mcu_DC_refine (j_decompress_ptr cinfo,
|
||||
METHODDEF(boolean) decode_mcu_DC_refine(j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
METHODDEF(boolean) decode_mcu_AC_refine (j_decompress_ptr cinfo,
|
||||
METHODDEF(boolean) decode_mcu_AC_refine(j_decompress_ptr cinfo,
|
||||
JBLOCKROW *MCU_data);
|
||||
|
||||
|
||||
@ -92,9 +96,9 @@ METHODDEF(boolean) decode_mcu_AC_refine (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
start_pass_phuff_decoder(j_decompress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
boolean is_DC_band, bad;
|
||||
int ci, coefi, tbl;
|
||||
d_derived_tbl **pdtbl;
|
||||
@ -118,7 +122,7 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
}
|
||||
if (cinfo->Ah != 0) {
|
||||
/* Successive approximation refinement scan: must have Al = Ah-1. */
|
||||
if (cinfo->Al != cinfo->Ah-1)
|
||||
if (cinfo->Al != cinfo->Ah - 1)
|
||||
bad = TRUE;
|
||||
}
|
||||
if (cinfo->Al > 13) /* need not check for < 0 */
|
||||
@ -138,7 +142,7 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
*/
|
||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||
int cindex = cinfo->cur_comp_info[ci]->component_index;
|
||||
coef_bit_ptr = & cinfo->coef_bits[cindex][0];
|
||||
coef_bit_ptr = &cinfo->coef_bits[cindex][0];
|
||||
if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
|
||||
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
|
||||
for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
|
||||
@ -206,21 +210,25 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
#ifdef AVOID_TABLES
|
||||
|
||||
#define NEG_1 ((unsigned)-1)
|
||||
#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((NEG_1)<<(s)) + 1) : (x))
|
||||
#define HUFF_EXTEND(x, s) \
|
||||
((x) < (1 << ((s) - 1)) ? (x) + (((NEG_1) << (s)) + 1) : (x))
|
||||
|
||||
#else
|
||||
|
||||
#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
|
||||
#define HUFF_EXTEND(x, s) \
|
||||
((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
|
||||
|
||||
static const int extend_test[16] = /* entry n is 2**(n-1) */
|
||||
{ 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
|
||||
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
|
||||
static const int extend_test[16] = { /* entry n is 2**(n-1) */
|
||||
0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
|
||||
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000
|
||||
};
|
||||
|
||||
static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
|
||||
{ 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,
|
||||
((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,
|
||||
((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
|
||||
((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
|
||||
static const int extend_offset[16] = { /* entry n is (-1 << n) + 1 */
|
||||
0, ((-1) << 1) + 1, ((-1) << 2) + 1, ((-1) << 3) + 1, ((-1) << 4) + 1,
|
||||
((-1) << 5) + 1, ((-1) << 6) + 1, ((-1) << 7) + 1, ((-1) << 8) + 1,
|
||||
((-1) << 9) + 1, ((-1) << 10) + 1, ((-1) << 11) + 1, ((-1) << 12) + 1,
|
||||
((-1) << 13) + 1, ((-1) << 14) + 1, ((-1) << 15) + 1
|
||||
};
|
||||
|
||||
#endif /* AVOID_TABLES */
|
||||
|
||||
@ -231,9 +239,9 @@ static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
|
||||
*/
|
||||
|
||||
LOCAL(boolean)
|
||||
process_restart (j_decompress_ptr cinfo)
|
||||
process_restart(j_decompress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
int ci;
|
||||
|
||||
/* Throw away any unused bits remaining in bit buffer; */
|
||||
@ -242,7 +250,7 @@ process_restart (j_decompress_ptr cinfo)
|
||||
entropy->bitstate.bits_left = 0;
|
||||
|
||||
/* Advance past the RSTn marker */
|
||||
if (! (*cinfo->marker->read_restart_marker) (cinfo))
|
||||
if (!(*cinfo->marker->read_restart_marker) (cinfo))
|
||||
return FALSE;
|
||||
|
||||
/* Re-initialize DC predictions to 0 */
|
||||
@ -289,9 +297,9 @@ process_restart (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
int Al = cinfo->Al;
|
||||
register int s, r;
|
||||
int blkn, ci;
|
||||
@ -304,17 +312,17 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! process_restart(cinfo))
|
||||
if (!process_restart(cinfo))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If we've run out of data, just leave the MCU set to zeroes.
|
||||
* This way, we return uniform gray for the remainder of the segment.
|
||||
*/
|
||||
if (! entropy->pub.insufficient_data) {
|
||||
if (!entropy->pub.insufficient_data) {
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
@ -336,14 +344,18 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Convert DC difference to actual value, update last_dc_val */
|
||||
if ((state.last_dc_val[ci] >= 0 &&
|
||||
s > INT_MAX - state.last_dc_val[ci]) ||
|
||||
(state.last_dc_val[ci] < 0 && s < INT_MIN - state.last_dc_val[ci]))
|
||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||
s += state.last_dc_val[ci];
|
||||
state.last_dc_val[ci] = s;
|
||||
/* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
|
||||
(*block)[0] = (JCOEF) LEFT_SHIFT(s, Al);
|
||||
(*block)[0] = (JCOEF)LEFT_SHIFT(s, Al);
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
}
|
||||
|
||||
@ -360,9 +372,9 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
int Se = cinfo->Se;
|
||||
int Al = cinfo->Al;
|
||||
register int s, k, r;
|
||||
@ -374,14 +386,14 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! process_restart(cinfo))
|
||||
if (!process_restart(cinfo))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If we've run out of data, just leave the MCU set to zeroes.
|
||||
* This way, we return uniform gray for the remainder of the segment.
|
||||
*/
|
||||
if (! entropy->pub.insufficient_data) {
|
||||
if (!entropy->pub.insufficient_data) {
|
||||
|
||||
/* Load up working state.
|
||||
* We can avoid loading/saving bitread state if in an EOB run.
|
||||
@ -393,7 +405,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (EOBRUN > 0) /* if it's a band of zeroes... */
|
||||
EOBRUN--; /* ...process it now (we do nothing) */
|
||||
else {
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
block = MCU_data[0];
|
||||
tbl = entropy->ac_derived_tbl;
|
||||
|
||||
@ -407,7 +419,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
r = GET_BITS(s);
|
||||
s = HUFF_EXTEND(r, s);
|
||||
/* Scale and output coefficient in natural (dezigzagged) order */
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) LEFT_SHIFT(s, Al);
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF)LEFT_SHIFT(s, Al);
|
||||
} else {
|
||||
if (r == 15) { /* ZRL */
|
||||
k += 15; /* skip 15 zeroes in band */
|
||||
@ -424,7 +436,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
}
|
||||
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
@ -445,9 +457,9 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
int blkn;
|
||||
JBLOCKROW block;
|
||||
@ -456,7 +468,7 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! process_restart(cinfo))
|
||||
if (!process_restart(cinfo))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -465,7 +477,7 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
|
||||
@ -480,7 +492,7 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
entropy->restarts_to_go--;
|
||||
@ -494,9 +506,9 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
decode_mcu_AC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
||||
int Se = cinfo->Se;
|
||||
int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
int m1 = (NEG_1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||
@ -512,16 +524,16 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
if (cinfo->restart_interval) {
|
||||
if (entropy->restarts_to_go == 0)
|
||||
if (! process_restart(cinfo))
|
||||
if (!process_restart(cinfo))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If we've run out of data, don't modify the MCU.
|
||||
*/
|
||||
if (! entropy->pub.insufficient_data) {
|
||||
if (!entropy->pub.insufficient_data) {
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
|
||||
|
||||
/* There is always only one block per MCU */
|
||||
@ -589,7 +601,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (s) {
|
||||
int pos = jpeg_natural_order[k];
|
||||
/* Output newly nonzero coefficient */
|
||||
(*block)[pos] = (JCOEF) s;
|
||||
(*block)[pos] = (JCOEF)s;
|
||||
/* Remember its position in case we have to suspend */
|
||||
newnz_pos[num_newnz++] = pos;
|
||||
}
|
||||
@ -621,7 +633,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
|
||||
}
|
||||
|
||||
@ -644,16 +656,16 @@ undoit:
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_phuff_decoder (j_decompress_ptr cinfo)
|
||||
jinit_phuff_decoder(j_decompress_ptr cinfo)
|
||||
{
|
||||
phuff_entropy_ptr entropy;
|
||||
int *coef_bit_ptr;
|
||||
int ci, i;
|
||||
|
||||
entropy = (phuff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(phuff_entropy_decoder));
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
|
||||
cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
|
||||
entropy->pub.start_pass = start_pass_phuff_decoder;
|
||||
|
||||
/* Mark derived tables unallocated */
|
||||
@ -663,9 +675,10 @@ jinit_phuff_decoder (j_decompress_ptr cinfo)
|
||||
|
||||
/* Create progression status table */
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2])
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components*DCTSIZE2*sizeof(int));
|
||||
coef_bit_ptr = & cinfo->coef_bits[0][0];
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * DCTSIZE2 *
|
||||
sizeof(int));
|
||||
coef_bit_ptr = &cinfo->coef_bits[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (i = 0; i < DCTSIZE2; i++)
|
||||
*coef_bit_ptr++ = -1;
|
||||
|
116
3rdparty/libjpeg-turbo/src/jdpostct.c
vendored
116
3rdparty/libjpeg-turbo/src/jdpostct.c
vendored
@ -46,21 +46,27 @@ typedef my_post_controller *my_post_ptr;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
METHODDEF(void) post_process_1pass
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
METHODDEF(void) post_process_1pass(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
METHODDEF(void) post_process_prepass
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
METHODDEF(void) post_process_prepass(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
METHODDEF(void) post_process_2pass
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
METHODDEF(void) post_process_2pass(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail);
|
||||
#endif
|
||||
|
||||
@ -70,9 +76,9 @@ METHODDEF(void) post_process_2pass
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
start_pass_dpost(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
{
|
||||
my_post_ptr post = (my_post_ptr) cinfo->post;
|
||||
my_post_ptr post = (my_post_ptr)cinfo->post;
|
||||
|
||||
switch (pass_mode) {
|
||||
case JBUF_PASS_THRU:
|
||||
@ -85,8 +91,8 @@ start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
if (post->buffer == NULL) {
|
||||
post->buffer = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, post->whole_image,
|
||||
(JDIMENSION) 0, post->strip_height, TRUE);
|
||||
((j_common_ptr)cinfo, post->whole_image,
|
||||
(JDIMENSION)0, post->strip_height, TRUE);
|
||||
}
|
||||
} else {
|
||||
/* For single-pass processing without color quantization,
|
||||
@ -123,13 +129,12 @@ start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
post_process_1pass (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
post_process_1pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_post_ptr post = (my_post_ptr) cinfo->post;
|
||||
my_post_ptr post = (my_post_ptr)cinfo->post;
|
||||
JDIMENSION num_rows, max_rows;
|
||||
|
||||
/* Fill the buffer, but not more than what we can dump out in one go. */
|
||||
@ -138,12 +143,13 @@ post_process_1pass (j_decompress_ptr cinfo,
|
||||
if (max_rows > post->strip_height)
|
||||
max_rows = post->strip_height;
|
||||
num_rows = 0;
|
||||
(*cinfo->upsample->upsample) (cinfo,
|
||||
input_buf, in_row_group_ctr, in_row_groups_avail,
|
||||
post->buffer, &num_rows, max_rows);
|
||||
(*cinfo->upsample->upsample) (cinfo, input_buf, in_row_group_ctr,
|
||||
in_row_groups_avail, post->buffer, &num_rows,
|
||||
max_rows);
|
||||
/* Quantize and emit data. */
|
||||
(*cinfo->cquantize->color_quantize) (cinfo,
|
||||
post->buffer, output_buf + *out_row_ctr, (int) num_rows);
|
||||
(*cinfo->cquantize->color_quantize) (cinfo, post->buffer,
|
||||
output_buf + *out_row_ctr,
|
||||
(int)num_rows);
|
||||
*out_row_ctr += num_rows;
|
||||
}
|
||||
|
||||
@ -155,34 +161,33 @@ post_process_1pass (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
post_process_prepass (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
post_process_prepass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_post_ptr post = (my_post_ptr) cinfo->post;
|
||||
my_post_ptr post = (my_post_ptr)cinfo->post;
|
||||
JDIMENSION old_next_row, num_rows;
|
||||
|
||||
/* Reposition virtual buffer if at start of strip. */
|
||||
if (post->next_row == 0) {
|
||||
post->buffer = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, post->whole_image,
|
||||
((j_common_ptr)cinfo, post->whole_image,
|
||||
post->starting_row, post->strip_height, TRUE);
|
||||
}
|
||||
|
||||
/* Upsample some data (up to a strip height's worth). */
|
||||
old_next_row = post->next_row;
|
||||
(*cinfo->upsample->upsample) (cinfo,
|
||||
input_buf, in_row_group_ctr, in_row_groups_avail,
|
||||
post->buffer, &post->next_row, post->strip_height);
|
||||
(*cinfo->upsample->upsample) (cinfo, input_buf, in_row_group_ctr,
|
||||
in_row_groups_avail, post->buffer,
|
||||
&post->next_row, post->strip_height);
|
||||
|
||||
/* Allow quantizer to scan new data. No data is emitted, */
|
||||
/* but we advance out_row_ctr so outer loop can tell when we're done. */
|
||||
if (post->next_row > old_next_row) {
|
||||
num_rows = post->next_row - old_next_row;
|
||||
(*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row,
|
||||
(JSAMPARRAY) NULL, (int) num_rows);
|
||||
(JSAMPARRAY)NULL, (int)num_rows);
|
||||
*out_row_ctr += num_rows;
|
||||
}
|
||||
|
||||
@ -199,19 +204,18 @@ post_process_prepass (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
post_process_2pass (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
post_process_2pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_post_ptr post = (my_post_ptr) cinfo->post;
|
||||
my_post_ptr post = (my_post_ptr)cinfo->post;
|
||||
JDIMENSION num_rows, max_rows;
|
||||
|
||||
/* Reposition virtual buffer if at start of strip. */
|
||||
if (post->next_row == 0) {
|
||||
post->buffer = (*cinfo->mem->access_virt_sarray)
|
||||
((j_common_ptr) cinfo, post->whole_image,
|
||||
((j_common_ptr)cinfo, post->whole_image,
|
||||
post->starting_row, post->strip_height, FALSE);
|
||||
}
|
||||
|
||||
@ -226,9 +230,9 @@ post_process_2pass (j_decompress_ptr cinfo,
|
||||
num_rows = max_rows;
|
||||
|
||||
/* Quantize and emit data. */
|
||||
(*cinfo->cquantize->color_quantize) (cinfo,
|
||||
post->buffer + post->next_row, output_buf + *out_row_ctr,
|
||||
(int) num_rows);
|
||||
(*cinfo->cquantize->color_quantize) (cinfo, post->buffer + post->next_row,
|
||||
output_buf + *out_row_ctr,
|
||||
(int)num_rows);
|
||||
*out_row_ctr += num_rows;
|
||||
|
||||
/* Advance if we filled the strip. */
|
||||
@ -247,14 +251,14 @@ post_process_2pass (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
{
|
||||
my_post_ptr post;
|
||||
|
||||
post = (my_post_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_post_controller));
|
||||
cinfo->post = (struct jpeg_d_post_controller *) post;
|
||||
cinfo->post = (struct jpeg_d_post_controller *)post;
|
||||
post->pub.start_pass = start_pass_dpost;
|
||||
post->whole_image = NULL; /* flag for no virtual arrays */
|
||||
post->buffer = NULL; /* flag for no strip buffer */
|
||||
@ -265,16 +269,16 @@ jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
* an efficient number of rows for upsampling to return.
|
||||
* (In the presence of output rescaling, we might want to be smarter?)
|
||||
*/
|
||||
post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor;
|
||||
post->strip_height = (JDIMENSION)cinfo->max_v_samp_factor;
|
||||
if (need_full_buffer) {
|
||||
/* Two-pass color quantization: need full-image storage. */
|
||||
/* We round up the number of rows to a multiple of the strip height. */
|
||||
#ifdef QUANT_2PASS_SUPPORTED
|
||||
post->whole_image = (*cinfo->mem->request_virt_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
|
||||
cinfo->output_width * cinfo->out_color_components,
|
||||
(JDIMENSION) jround_up((long) cinfo->output_height,
|
||||
(long) post->strip_height),
|
||||
(JDIMENSION)jround_up((long)cinfo->output_height,
|
||||
(long)post->strip_height),
|
||||
post->strip_height);
|
||||
#else
|
||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||
@ -282,7 +286,7 @@ jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
||||
} else {
|
||||
/* One-pass color quantization: just make a strip buffer. */
|
||||
post->buffer = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
cinfo->output_width * cinfo->out_color_components,
|
||||
post->strip_height);
|
||||
}
|
||||
|
105
3rdparty/libjpeg-turbo/src/jdsample.c
vendored
105
3rdparty/libjpeg-turbo/src/jdsample.c
vendored
@ -36,9 +36,9 @@
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_upsample (j_decompress_ptr cinfo)
|
||||
start_pass_upsample(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Mark the conversion buffer empty */
|
||||
upsample->next_row_out = cinfo->max_v_samp_factor;
|
||||
@ -56,13 +56,12 @@ start_pass_upsample (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
sep_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
sep_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
int ci;
|
||||
jpeg_component_info *compptr;
|
||||
JDIMENSION num_rows;
|
||||
@ -84,7 +83,7 @@ sep_upsample (j_decompress_ptr cinfo,
|
||||
/* Color-convert and emit rows */
|
||||
|
||||
/* How many we have in the buffer: */
|
||||
num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out);
|
||||
num_rows = (JDIMENSION)(cinfo->max_v_samp_factor - upsample->next_row_out);
|
||||
/* Not more than the distance to the end of the image. Need this test
|
||||
* in case the image height is not a multiple of max_v_samp_factor:
|
||||
*/
|
||||
@ -96,9 +95,8 @@ sep_upsample (j_decompress_ptr cinfo,
|
||||
num_rows = out_rows_avail;
|
||||
|
||||
(*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,
|
||||
(JDIMENSION) upsample->next_row_out,
|
||||
output_buf + *out_row_ctr,
|
||||
(int) num_rows);
|
||||
(JDIMENSION)upsample->next_row_out,
|
||||
output_buf + *out_row_ctr, (int)num_rows);
|
||||
|
||||
/* Adjust counts */
|
||||
*out_row_ctr += num_rows;
|
||||
@ -124,7 +122,7 @@ sep_upsample (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
fullsize_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
*output_data_ptr = input_data;
|
||||
@ -137,7 +135,7 @@ fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
noop_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
noop_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
*output_data_ptr = NULL; /* safety check */
|
||||
@ -156,10 +154,10 @@ noop_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JSAMPLE invalue;
|
||||
@ -185,8 +183,8 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
}
|
||||
/* Generate any additional output rows by duplicating the first one */
|
||||
if (v_expand > 1) {
|
||||
jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
|
||||
v_expand-1, cinfo->output_width);
|
||||
jcopy_sample_rows(output_data, outrow, output_data, outrow + 1,
|
||||
v_expand - 1, cinfo->output_width);
|
||||
}
|
||||
inrow++;
|
||||
outrow += v_expand;
|
||||
@ -200,7 +198,7 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
@ -228,7 +226,7 @@ h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
@ -247,8 +245,8 @@ h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*outptr++ = invalue;
|
||||
*outptr++ = invalue;
|
||||
}
|
||||
jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
|
||||
1, cinfo->output_width);
|
||||
jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, 1,
|
||||
cinfo->output_width);
|
||||
inrow++;
|
||||
outrow += 2;
|
||||
}
|
||||
@ -271,7 +269,7 @@ h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
@ -285,20 +283,20 @@ h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
outptr = output_data[inrow];
|
||||
/* Special case for first column */
|
||||
invalue = GETJSAMPLE(*inptr++);
|
||||
*outptr++ = (JSAMPLE) invalue;
|
||||
*outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2);
|
||||
*outptr++ = (JSAMPLE)invalue;
|
||||
*outptr++ = (JSAMPLE)((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2);
|
||||
|
||||
for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
|
||||
/* General case: 3/4 * nearer pixel + 1/4 * further pixel */
|
||||
invalue = GETJSAMPLE(*inptr++) * 3;
|
||||
*outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2);
|
||||
*outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2);
|
||||
*outptr++ = (JSAMPLE)((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2);
|
||||
*outptr++ = (JSAMPLE)((invalue + GETJSAMPLE(*inptr) + 2) >> 2);
|
||||
}
|
||||
|
||||
/* Special case for last column */
|
||||
invalue = GETJSAMPLE(*inptr);
|
||||
*outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2);
|
||||
*outptr++ = (JSAMPLE) invalue;
|
||||
*outptr++ = (JSAMPLE)((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2);
|
||||
*outptr++ = (JSAMPLE)invalue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,7 +309,7 @@ h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h1v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
@ -330,14 +328,14 @@ h1v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* 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];
|
||||
inptr1 = input_data[inrow - 1];
|
||||
else /* next nearest is row below */
|
||||
inptr1 = input_data[inrow+1];
|
||||
inptr1 = input_data[inrow + 1];
|
||||
outptr = output_data[outrow++];
|
||||
|
||||
for(colctr = 0; colctr < compptr->downsampled_width; colctr++) {
|
||||
for (colctr = 0; colctr < compptr->downsampled_width; colctr++) {
|
||||
thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum + 1) >> 2);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum + 1) >> 2);
|
||||
}
|
||||
}
|
||||
inrow++;
|
||||
@ -354,7 +352,7 @@ h1v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
@ -373,30 +371,30 @@ h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* 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];
|
||||
inptr1 = input_data[inrow - 1];
|
||||
else /* next nearest is row below */
|
||||
inptr1 = input_data[inrow+1];
|
||||
inptr1 = input_data[inrow + 1];
|
||||
outptr = output_data[outrow++];
|
||||
|
||||
/* Special case for first column */
|
||||
thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||
nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 4 + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4);
|
||||
lastcolsum = thiscolsum; thiscolsum = nextcolsum;
|
||||
|
||||
for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
|
||||
/* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
|
||||
/* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
|
||||
nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4);
|
||||
lastcolsum = thiscolsum; thiscolsum = nextcolsum;
|
||||
}
|
||||
|
||||
/* Special case for last column */
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4);
|
||||
*outptr++ = (JSAMPLE)((thiscolsum * 4 + 7) >> 4);
|
||||
}
|
||||
inrow++;
|
||||
}
|
||||
@ -408,7 +406,7 @@ h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_upsampler (j_decompress_ptr cinfo)
|
||||
jinit_upsampler(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample;
|
||||
int ci;
|
||||
@ -418,14 +416,14 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
|
||||
if (!cinfo->master->jinit_upsampler_no_alloc) {
|
||||
upsample = (my_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *) upsample;
|
||||
cinfo->upsample = (struct jpeg_upsampler *)upsample;
|
||||
upsample->pub.start_pass = start_pass_upsample;
|
||||
upsample->pub.upsample = sep_upsample;
|
||||
upsample->pub.need_context_rows = FALSE; /* until we find out differently */
|
||||
} else
|
||||
upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
|
||||
if (cinfo->CCIR601_sampling) /* this isn't supported */
|
||||
ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
|
||||
@ -451,7 +449,7 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
v_out_group = cinfo->max_v_samp_factor;
|
||||
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
|
||||
need_buffer = TRUE;
|
||||
if (! compptr->component_needed) {
|
||||
if (!compptr->component_needed) {
|
||||
/* Don't bother to upsample an uninteresting component. */
|
||||
upsample->methods[ci] = noop_upsample;
|
||||
need_buffer = FALSE;
|
||||
@ -459,8 +457,7 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
/* Fullsize components can be processed without any work. */
|
||||
upsample->methods[ci] = fullsize_upsample;
|
||||
need_buffer = FALSE;
|
||||
} else if (h_in_group * 2 == h_out_group &&
|
||||
v_in_group == v_out_group) {
|
||||
} else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
|
||||
/* Special cases for 2h1v upsampling */
|
||||
if (do_fancy && compptr->downsampled_width > 2) {
|
||||
if (jsimd_can_h2v1_fancy_upsample())
|
||||
@ -502,16 +499,16 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
else
|
||||
#endif
|
||||
upsample->methods[ci] = int_upsample;
|
||||
upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group);
|
||||
upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);
|
||||
upsample->h_expand[ci] = (UINT8)(h_out_group / h_in_group);
|
||||
upsample->v_expand[ci] = (UINT8)(v_out_group / v_in_group);
|
||||
} else
|
||||
ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
|
||||
if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) {
|
||||
upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) jround_up((long) cinfo->output_width,
|
||||
(long) cinfo->max_h_samp_factor),
|
||||
(JDIMENSION) cinfo->max_v_samp_factor);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)jround_up((long)cinfo->output_width,
|
||||
(long)cinfo->max_h_samp_factor),
|
||||
(JDIMENSION)cinfo->max_v_samp_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
3rdparty/libjpeg-turbo/src/jdtrans.c
vendored
14
3rdparty/libjpeg-turbo/src/jdtrans.c
vendored
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
LOCAL(void) transdecode_master_selection (j_decompress_ptr cinfo);
|
||||
LOCAL(void) transdecode_master_selection(j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/*
|
||||
@ -45,7 +45,7 @@ LOCAL(void) transdecode_master_selection (j_decompress_ptr cinfo);
|
||||
*/
|
||||
|
||||
GLOBAL(jvirt_barray_ptr *)
|
||||
jpeg_read_coefficients (j_decompress_ptr cinfo)
|
||||
jpeg_read_coefficients(j_decompress_ptr cinfo)
|
||||
{
|
||||
if (cinfo->global_state == DSTATE_READY) {
|
||||
/* First call: initialize active modules */
|
||||
@ -58,7 +58,7 @@ jpeg_read_coefficients (j_decompress_ptr cinfo)
|
||||
int retcode;
|
||||
/* Call progress monitor hook if present */
|
||||
if (cinfo->progress != NULL)
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
|
||||
(*cinfo->progress->progress_monitor) ((j_common_ptr)cinfo);
|
||||
/* Absorb some more input */
|
||||
retcode = (*cinfo->inputctl->consume_input) (cinfo);
|
||||
if (retcode == JPEG_SUSPENDED)
|
||||
@ -70,7 +70,7 @@ jpeg_read_coefficients (j_decompress_ptr cinfo)
|
||||
(retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
|
||||
if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
|
||||
/* startup underestimated number of scans; ratchet up one scan */
|
||||
cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
|
||||
cinfo->progress->pass_limit += (long)cinfo->total_iMCU_rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ jpeg_read_coefficients (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
transdecode_master_selection (j_decompress_ptr cinfo)
|
||||
transdecode_master_selection(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* This is effectively a buffered-image operation. */
|
||||
cinfo->buffered_image = TRUE;
|
||||
@ -129,7 +129,7 @@ transdecode_master_selection (j_decompress_ptr cinfo)
|
||||
jinit_d_coef_controller(cinfo, TRUE);
|
||||
|
||||
/* We can now tell the memory manager to allocate virtual arrays. */
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
|
||||
|
||||
/* Initialize input side of decompressor to consume first scan. */
|
||||
(*cinfo->inputctl->start_input_pass) (cinfo);
|
||||
@ -148,7 +148,7 @@ transdecode_master_selection (j_decompress_ptr cinfo)
|
||||
nscans = 1;
|
||||
}
|
||||
cinfo->progress->pass_counter = 0L;
|
||||
cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
|
||||
cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
|
||||
cinfo->progress->completed_passes = 0;
|
||||
cinfo->progress->total_passes = 1;
|
||||
}
|
||||
|
16
3rdparty/libjpeg-turbo/src/jerror.c
vendored
16
3rdparty/libjpeg-turbo/src/jerror.c
vendored
@ -44,7 +44,7 @@
|
||||
* want to refer to it directly.
|
||||
*/
|
||||
|
||||
#define JMESSAGE(code,string) string ,
|
||||
#define JMESSAGE(code, string) string,
|
||||
|
||||
const char * const jpeg_std_message_table[] = {
|
||||
#include "jerror.h"
|
||||
@ -66,7 +66,7 @@ const char * const jpeg_std_message_table[] = {
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
error_exit (j_common_ptr cinfo)
|
||||
error_exit(j_common_ptr cinfo)
|
||||
{
|
||||
/* Always display the message */
|
||||
(*cinfo->err->output_message) (cinfo);
|
||||
@ -94,7 +94,7 @@ error_exit (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
output_message (j_common_ptr cinfo)
|
||||
output_message(j_common_ptr cinfo)
|
||||
{
|
||||
char buffer[JMSG_LENGTH_MAX];
|
||||
|
||||
@ -124,7 +124,7 @@ output_message (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
emit_message (j_common_ptr cinfo, int msg_level)
|
||||
emit_message(j_common_ptr cinfo, int msg_level)
|
||||
{
|
||||
struct jpeg_error_mgr *err = cinfo->err;
|
||||
|
||||
@ -153,7 +153,7 @@ emit_message (j_common_ptr cinfo, int msg_level)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
format_message (j_common_ptr cinfo, char *buffer)
|
||||
format_message(j_common_ptr cinfo, char *buffer)
|
||||
{
|
||||
struct jpeg_error_mgr *err = cinfo->err;
|
||||
int msg_code = err->msg_code;
|
||||
@ -208,7 +208,7 @@ format_message (j_common_ptr cinfo, char *buffer)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
reset_error_mgr (j_common_ptr cinfo)
|
||||
reset_error_mgr(j_common_ptr cinfo)
|
||||
{
|
||||
cinfo->err->num_warnings = 0;
|
||||
/* trace_level is not reset since it is an application-supplied parameter */
|
||||
@ -227,7 +227,7 @@ reset_error_mgr (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(struct jpeg_error_mgr *)
|
||||
jpeg_std_error (struct jpeg_error_mgr *err)
|
||||
jpeg_std_error(struct jpeg_error_mgr *err)
|
||||
{
|
||||
err->error_exit = error_exit;
|
||||
err->emit_message = emit_message;
|
||||
@ -241,7 +241,7 @@ jpeg_std_error (struct jpeg_error_mgr *err)
|
||||
|
||||
/* Initialize message table pointers */
|
||||
err->jpeg_message_table = jpeg_std_message_table;
|
||||
err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1;
|
||||
err->last_jpeg_message = (int)JMSG_LASTMSGCODE - 1;
|
||||
|
||||
err->addon_message_table = NULL;
|
||||
err->first_addon_message = 0; /* for safety */
|
||||
|
89
3rdparty/libjpeg-turbo/src/jerror.h
vendored
89
3rdparty/libjpeg-turbo/src/jerror.h
vendored
@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2014, D. R. Commander.
|
||||
* Copyright (C) 2014, 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@ -28,7 +28,7 @@
|
||||
#define JMAKE_ENUM_LIST
|
||||
#else
|
||||
/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
|
||||
#define JMESSAGE(code,string)
|
||||
#define JMESSAGE(code, string)
|
||||
#endif /* JERROR_H */
|
||||
#endif /* JMESSAGE */
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
typedef enum {
|
||||
|
||||
#define JMESSAGE(code,string) code ,
|
||||
#define JMESSAGE(code, string) code,
|
||||
|
||||
#endif /* JMAKE_ENUM_LIST */
|
||||
|
||||
@ -44,8 +44,7 @@ JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
|
||||
|
||||
/* For maintenance convenience, list is alphabetical by message code name */
|
||||
#if JPEG_LIB_VERSION < 70
|
||||
JMESSAGE(JERR_ARITH_NOTIMPL,
|
||||
"Sorry, arithmetic coding is not implemented")
|
||||
JMESSAGE(JERR_ARITH_NOTIMPL, "Sorry, arithmetic coding is not implemented")
|
||||
#endif
|
||||
JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
|
||||
JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
|
||||
@ -154,8 +153,7 @@ JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d")
|
||||
JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d")
|
||||
JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,
|
||||
"Warning: thumbnail image size does not match data length %u")
|
||||
JMESSAGE(JTRC_JFIF_EXTENSION,
|
||||
"JFIF extension marker: type 0x%02x, length %u")
|
||||
JMESSAGE(JTRC_JFIF_EXTENSION, "JFIF extension marker: type 0x%02x, length %u")
|
||||
JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image")
|
||||
JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u")
|
||||
JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x")
|
||||
@ -208,6 +206,7 @@ JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
|
||||
JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
|
||||
#endif
|
||||
#endif
|
||||
JMESSAGE(JWRN_BOGUS_ICC, "Corrupt JPEG data: bad ICC marker")
|
||||
|
||||
#ifdef JMAKE_ENUM_LIST
|
||||
|
||||
@ -228,90 +227,90 @@ JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
|
||||
/* The first parameter is either type of cinfo pointer */
|
||||
|
||||
/* Fatal errors (print message and exit) */
|
||||
#define ERREXIT(cinfo,code) \
|
||||
#define ERREXIT(cinfo, code) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
#define ERREXIT1(cinfo,code,p1) \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
#define ERREXIT1(cinfo, code, p1) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
#define ERREXIT2(cinfo,code,p1,p2) \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
#define ERREXIT2(cinfo, code, p1, p2) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
#define ERREXIT3(cinfo,code,p1,p2,p3) \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
#define ERREXIT3(cinfo, code, p1, p2, p3) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||
(cinfo)->err->msg_parm.i[2] = (p3), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
#define ERREXIT4(cinfo, code, p1, p2, p3, p4) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||
(cinfo)->err->msg_parm.i[2] = (p3), \
|
||||
(cinfo)->err->msg_parm.i[3] = (p4), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
#define ERREXITS(cinfo,code,str) \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
#define ERREXITS(cinfo, code, str) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
||||
|
||||
#define MAKESTMT(stuff) do { stuff } while (0)
|
||||
|
||||
/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
|
||||
#define WARNMS(cinfo,code) \
|
||||
#define WARNMS(cinfo, code) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
|
||||
#define WARNMS1(cinfo,code,p1) \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
|
||||
#define WARNMS1(cinfo, code, p1) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
|
||||
#define WARNMS2(cinfo,code,p1,p2) \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
|
||||
#define WARNMS2(cinfo, code, p1, p2) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
|
||||
|
||||
/* Informational/debugging messages */
|
||||
#define TRACEMS(cinfo,lvl,code) \
|
||||
#define TRACEMS(cinfo, lvl, code) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||
#define TRACEMS1(cinfo,lvl,code,p1) \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
||||
#define TRACEMS1(cinfo, lvl, code, p1) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||
#define TRACEMS2(cinfo,lvl,code,p1,p2) \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
||||
#define TRACEMS2(cinfo, lvl, code, p1, p2) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||
#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \
|
||||
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
||||
#define TRACEMS3(cinfo, lvl, code, p1, p2, p3) \
|
||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
|
||||
(cinfo)->err->msg_code = (code); \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||
#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \
|
||||
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
||||
#define TRACEMS4(cinfo, lvl, code, p1, p2, p3, p4) \
|
||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
||||
(cinfo)->err->msg_code = (code); \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||
#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \
|
||||
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
||||
#define TRACEMS5(cinfo, lvl, code, p1, p2, p3, p4, p5) \
|
||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
||||
_mp[4] = (p5); \
|
||||
(cinfo)->err->msg_code = (code); \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||
#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \
|
||||
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
||||
#define TRACEMS8(cinfo, lvl, code, p1, p2, p3, p4, p5, p6, p7, p8) \
|
||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
||||
_mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
|
||||
(cinfo)->err->msg_code = (code); \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||
#define TRACEMSS(cinfo,lvl,code,str) \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
||||
#define TRACEMSS(cinfo, lvl, code, str) \
|
||||
((cinfo)->err->msg_code = (code), \
|
||||
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
||||
|
||||
#endif /* JERROR_H */
|
||||
|
58
3rdparty/libjpeg-turbo/src/jfdctflt.c
vendored
58
3rdparty/libjpeg-turbo/src/jfdctflt.c
vendored
@ -57,7 +57,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_fdct_float (FAST_FLOAT *data)
|
||||
jpeg_fdct_float(FAST_FLOAT *data)
|
||||
{
|
||||
FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
||||
FAST_FLOAT tmp10, tmp11, tmp12, tmp13;
|
||||
@ -68,7 +68,7 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
/* Pass 1: process rows. */
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[0] + dataptr[7];
|
||||
tmp7 = dataptr[0] - dataptr[7];
|
||||
tmp1 = dataptr[1] + dataptr[6];
|
||||
@ -88,7 +88,7 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
dataptr[0] = tmp10 + tmp11; /* phase 3 */
|
||||
dataptr[4] = tmp10 - tmp11;
|
||||
|
||||
z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */
|
||||
z1 = (tmp12 + tmp13) * ((FAST_FLOAT)0.707106781); /* c4 */
|
||||
dataptr[2] = tmp13 + z1; /* phase 5 */
|
||||
dataptr[6] = tmp13 - z1;
|
||||
|
||||
@ -99,10 +99,10 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
tmp12 = tmp6 + tmp7;
|
||||
|
||||
/* The rotator is modified from fig 4-8 to avoid extra negations. */
|
||||
z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */
|
||||
z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */
|
||||
z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */
|
||||
z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */
|
||||
z5 = (tmp10 - tmp12) * ((FAST_FLOAT)0.382683433); /* c6 */
|
||||
z2 = ((FAST_FLOAT)0.541196100) * tmp10 + z5; /* c2-c6 */
|
||||
z4 = ((FAST_FLOAT)1.306562965) * tmp12 + z5; /* c2+c6 */
|
||||
z3 = tmp11 * ((FAST_FLOAT)0.707106781); /* c4 */
|
||||
|
||||
z11 = tmp7 + z3; /* phase 5 */
|
||||
z13 = tmp7 - z3;
|
||||
@ -118,15 +118,15 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
/* Pass 2: process columns. */
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
|
||||
tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
|
||||
tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
|
||||
tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
|
||||
tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
|
||||
tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
|
||||
tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
|
||||
tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
|
||||
tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
|
||||
tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
|
||||
tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
|
||||
tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
|
||||
tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
|
||||
tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
|
||||
tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
|
||||
|
||||
/* Even part */
|
||||
|
||||
@ -135,12 +135,12 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */
|
||||
dataptr[DCTSIZE*4] = tmp10 - tmp11;
|
||||
dataptr[DCTSIZE * 0] = tmp10 + tmp11; /* phase 3 */
|
||||
dataptr[DCTSIZE * 4] = tmp10 - tmp11;
|
||||
|
||||
z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */
|
||||
dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */
|
||||
dataptr[DCTSIZE*6] = tmp13 - z1;
|
||||
z1 = (tmp12 + tmp13) * ((FAST_FLOAT)0.707106781); /* c4 */
|
||||
dataptr[DCTSIZE * 2] = tmp13 + z1; /* phase 5 */
|
||||
dataptr[DCTSIZE * 6] = tmp13 - z1;
|
||||
|
||||
/* Odd part */
|
||||
|
||||
@ -149,18 +149,18 @@ jpeg_fdct_float (FAST_FLOAT *data)
|
||||
tmp12 = tmp6 + tmp7;
|
||||
|
||||
/* The rotator is modified from fig 4-8 to avoid extra negations. */
|
||||
z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */
|
||||
z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */
|
||||
z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */
|
||||
z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */
|
||||
z5 = (tmp10 - tmp12) * ((FAST_FLOAT)0.382683433); /* c6 */
|
||||
z2 = ((FAST_FLOAT)0.541196100) * tmp10 + z5; /* c2-c6 */
|
||||
z4 = ((FAST_FLOAT)1.306562965) * tmp12 + z5; /* c2+c6 */
|
||||
z3 = tmp11 * ((FAST_FLOAT)0.707106781); /* c4 */
|
||||
|
||||
z11 = tmp7 + z3; /* phase 5 */
|
||||
z13 = tmp7 - z3;
|
||||
|
||||
dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */
|
||||
dataptr[DCTSIZE*3] = z13 - z2;
|
||||
dataptr[DCTSIZE*1] = z11 + z4;
|
||||
dataptr[DCTSIZE*7] = z11 - z4;
|
||||
dataptr[DCTSIZE * 5] = z13 + z2; /* phase 6 */
|
||||
dataptr[DCTSIZE * 3] = z13 - z2;
|
||||
dataptr[DCTSIZE * 1] = z11 + z4;
|
||||
dataptr[DCTSIZE * 7] = z11 - z4;
|
||||
|
||||
dataptr++; /* advance pointer to next column */
|
||||
}
|
||||
|
50
3rdparty/libjpeg-turbo/src/jfdctfst.c
vendored
50
3rdparty/libjpeg-turbo/src/jfdctfst.c
vendored
@ -79,10 +79,10 @@
|
||||
*/
|
||||
|
||||
#if CONST_BITS == 8
|
||||
#define FIX_0_382683433 ((JLONG) 98) /* FIX(0.382683433) */
|
||||
#define FIX_0_541196100 ((JLONG) 139) /* FIX(0.541196100) */
|
||||
#define FIX_0_707106781 ((JLONG) 181) /* FIX(0.707106781) */
|
||||
#define FIX_1_306562965 ((JLONG) 334) /* FIX(1.306562965) */
|
||||
#define FIX_0_382683433 ((JLONG)98) /* FIX(0.382683433) */
|
||||
#define FIX_0_541196100 ((JLONG)139) /* FIX(0.541196100) */
|
||||
#define FIX_0_707106781 ((JLONG)181) /* FIX(0.707106781) */
|
||||
#define FIX_1_306562965 ((JLONG)334) /* FIX(1.306562965) */
|
||||
#else
|
||||
#define FIX_0_382683433 FIX(0.382683433)
|
||||
#define FIX_0_541196100 FIX(0.541196100)
|
||||
@ -98,7 +98,7 @@
|
||||
|
||||
#ifndef USE_ACCURATE_ROUNDING
|
||||
#undef DESCALE
|
||||
#define DESCALE(x,n) RIGHT_SHIFT(x, n)
|
||||
#define DESCALE(x, n) RIGHT_SHIFT(x, n)
|
||||
#endif
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@
|
||||
* descale to yield a DCTELEM result.
|
||||
*/
|
||||
|
||||
#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
|
||||
#define MULTIPLY(var, const) ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
|
||||
|
||||
|
||||
/*
|
||||
@ -114,7 +114,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_fdct_ifast (DCTELEM *data)
|
||||
jpeg_fdct_ifast(DCTELEM *data)
|
||||
{
|
||||
DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
||||
DCTELEM tmp10, tmp11, tmp12, tmp13;
|
||||
@ -126,7 +126,7 @@ jpeg_fdct_ifast (DCTELEM *data)
|
||||
/* Pass 1: process rows. */
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[0] + dataptr[7];
|
||||
tmp7 = dataptr[0] - dataptr[7];
|
||||
tmp1 = dataptr[1] + dataptr[6];
|
||||
@ -176,15 +176,15 @@ jpeg_fdct_ifast (DCTELEM *data)
|
||||
/* Pass 2: process columns. */
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
|
||||
tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
|
||||
tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
|
||||
tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
|
||||
tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
|
||||
tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
|
||||
tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
|
||||
tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
|
||||
tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
|
||||
tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
|
||||
tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
|
||||
tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
|
||||
tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
|
||||
tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
|
||||
tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
|
||||
|
||||
/* Even part */
|
||||
|
||||
@ -193,12 +193,12 @@ jpeg_fdct_ifast (DCTELEM *data)
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */
|
||||
dataptr[DCTSIZE*4] = tmp10 - tmp11;
|
||||
dataptr[DCTSIZE * 0] = tmp10 + tmp11; /* phase 3 */
|
||||
dataptr[DCTSIZE * 4] = tmp10 - tmp11;
|
||||
|
||||
z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */
|
||||
dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */
|
||||
dataptr[DCTSIZE*6] = tmp13 - z1;
|
||||
dataptr[DCTSIZE * 2] = tmp13 + z1; /* phase 5 */
|
||||
dataptr[DCTSIZE * 6] = tmp13 - z1;
|
||||
|
||||
/* Odd part */
|
||||
|
||||
@ -215,10 +215,10 @@ jpeg_fdct_ifast (DCTELEM *data)
|
||||
z11 = tmp7 + z3; /* phase 5 */
|
||||
z13 = tmp7 - z3;
|
||||
|
||||
dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */
|
||||
dataptr[DCTSIZE*3] = z13 - z2;
|
||||
dataptr[DCTSIZE*1] = z11 + z4;
|
||||
dataptr[DCTSIZE*7] = z11 - z4;
|
||||
dataptr[DCTSIZE * 5] = z13 + z2; /* phase 6 */
|
||||
dataptr[DCTSIZE * 3] = z13 - z2;
|
||||
dataptr[DCTSIZE * 1] = z11 + z4;
|
||||
dataptr[DCTSIZE * 7] = z11 - z4;
|
||||
|
||||
dataptr++; /* advance pointer to next column */
|
||||
}
|
||||
|
116
3rdparty/libjpeg-turbo/src/jfdctint.c
vendored
116
3rdparty/libjpeg-turbo/src/jfdctint.c
vendored
@ -93,18 +93,18 @@
|
||||
*/
|
||||
|
||||
#if CONST_BITS == 13
|
||||
#define FIX_0_298631336 ((JLONG) 2446) /* FIX(0.298631336) */
|
||||
#define FIX_0_390180644 ((JLONG) 3196) /* FIX(0.390180644) */
|
||||
#define FIX_0_541196100 ((JLONG) 4433) /* FIX(0.541196100) */
|
||||
#define FIX_0_765366865 ((JLONG) 6270) /* FIX(0.765366865) */
|
||||
#define FIX_0_899976223 ((JLONG) 7373) /* FIX(0.899976223) */
|
||||
#define FIX_1_175875602 ((JLONG) 9633) /* FIX(1.175875602) */
|
||||
#define FIX_1_501321110 ((JLONG) 12299) /* FIX(1.501321110) */
|
||||
#define FIX_1_847759065 ((JLONG) 15137) /* FIX(1.847759065) */
|
||||
#define FIX_1_961570560 ((JLONG) 16069) /* FIX(1.961570560) */
|
||||
#define FIX_2_053119869 ((JLONG) 16819) /* FIX(2.053119869) */
|
||||
#define FIX_2_562915447 ((JLONG) 20995) /* FIX(2.562915447) */
|
||||
#define FIX_3_072711026 ((JLONG) 25172) /* FIX(3.072711026) */
|
||||
#define FIX_0_298631336 ((JLONG)2446) /* FIX(0.298631336) */
|
||||
#define FIX_0_390180644 ((JLONG)3196) /* FIX(0.390180644) */
|
||||
#define FIX_0_541196100 ((JLONG)4433) /* FIX(0.541196100) */
|
||||
#define FIX_0_765366865 ((JLONG)6270) /* FIX(0.765366865) */
|
||||
#define FIX_0_899976223 ((JLONG)7373) /* FIX(0.899976223) */
|
||||
#define FIX_1_175875602 ((JLONG)9633) /* FIX(1.175875602) */
|
||||
#define FIX_1_501321110 ((JLONG)12299) /* FIX(1.501321110) */
|
||||
#define FIX_1_847759065 ((JLONG)15137) /* FIX(1.847759065) */
|
||||
#define FIX_1_961570560 ((JLONG)16069) /* FIX(1.961570560) */
|
||||
#define FIX_2_053119869 ((JLONG)16819) /* FIX(2.053119869) */
|
||||
#define FIX_2_562915447 ((JLONG)20995) /* FIX(2.562915447) */
|
||||
#define FIX_3_072711026 ((JLONG)25172) /* FIX(3.072711026) */
|
||||
#else
|
||||
#define FIX_0_298631336 FIX(0.298631336)
|
||||
#define FIX_0_390180644 FIX(0.390180644)
|
||||
@ -129,9 +129,9 @@
|
||||
*/
|
||||
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
#define MULTIPLY(var,const) MULTIPLY16C16(var,const)
|
||||
#define MULTIPLY(var, const) MULTIPLY16C16(var, const)
|
||||
#else
|
||||
#define MULTIPLY(var,const) ((var) * (const))
|
||||
#define MULTIPLY(var, const) ((var) * (const))
|
||||
#endif
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_fdct_islow (DCTELEM *data)
|
||||
jpeg_fdct_islow(DCTELEM *data)
|
||||
{
|
||||
JLONG tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
||||
JLONG tmp10, tmp11, tmp12, tmp13;
|
||||
@ -154,7 +154,7 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
/* furthermore, we scale the results by 2**PASS1_BITS. */
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[0] + dataptr[7];
|
||||
tmp7 = dataptr[0] - dataptr[7];
|
||||
tmp1 = dataptr[1] + dataptr[6];
|
||||
@ -173,14 +173,14 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
dataptr[0] = (DCTELEM) LEFT_SHIFT(tmp10 + tmp11, PASS1_BITS);
|
||||
dataptr[4] = (DCTELEM) LEFT_SHIFT(tmp10 - tmp11, PASS1_BITS);
|
||||
dataptr[0] = (DCTELEM)LEFT_SHIFT(tmp10 + tmp11, PASS1_BITS);
|
||||
dataptr[4] = (DCTELEM)LEFT_SHIFT(tmp10 - tmp11, PASS1_BITS);
|
||||
|
||||
z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
|
||||
dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
|
||||
CONST_BITS-PASS1_BITS);
|
||||
dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
|
||||
CONST_BITS-PASS1_BITS);
|
||||
dataptr[2] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
|
||||
CONST_BITS - PASS1_BITS);
|
||||
dataptr[6] = (DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, -FIX_1_847759065),
|
||||
CONST_BITS - PASS1_BITS);
|
||||
|
||||
/* Odd part per figure 8 --- note paper omits factor of sqrt(2).
|
||||
* cK represents cos(K*pi/16).
|
||||
@ -197,18 +197,18 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
|
||||
tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
|
||||
tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
|
||||
z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
|
||||
z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
|
||||
z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
|
||||
z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
|
||||
z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
|
||||
z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
|
||||
z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
|
||||
z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
|
||||
|
||||
z3 += z5;
|
||||
z4 += z5;
|
||||
|
||||
dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS);
|
||||
dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS);
|
||||
dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS);
|
||||
dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS);
|
||||
dataptr[7] = (DCTELEM)DESCALE(tmp4 + z1 + z3, CONST_BITS - PASS1_BITS);
|
||||
dataptr[5] = (DCTELEM)DESCALE(tmp5 + z2 + z4, CONST_BITS - PASS1_BITS);
|
||||
dataptr[3] = (DCTELEM)DESCALE(tmp6 + z2 + z3, CONST_BITS - PASS1_BITS);
|
||||
dataptr[1] = (DCTELEM)DESCALE(tmp7 + z1 + z4, CONST_BITS - PASS1_BITS);
|
||||
|
||||
dataptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
@ -219,15 +219,15 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
*/
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
|
||||
tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
|
||||
tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
|
||||
tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
|
||||
tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
|
||||
tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
|
||||
tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
|
||||
tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
|
||||
for (ctr = DCTSIZE - 1; ctr >= 0; ctr--) {
|
||||
tmp0 = dataptr[DCTSIZE * 0] + dataptr[DCTSIZE * 7];
|
||||
tmp7 = dataptr[DCTSIZE * 0] - dataptr[DCTSIZE * 7];
|
||||
tmp1 = dataptr[DCTSIZE * 1] + dataptr[DCTSIZE * 6];
|
||||
tmp6 = dataptr[DCTSIZE * 1] - dataptr[DCTSIZE * 6];
|
||||
tmp2 = dataptr[DCTSIZE * 2] + dataptr[DCTSIZE * 5];
|
||||
tmp5 = dataptr[DCTSIZE * 2] - dataptr[DCTSIZE * 5];
|
||||
tmp3 = dataptr[DCTSIZE * 3] + dataptr[DCTSIZE * 4];
|
||||
tmp4 = dataptr[DCTSIZE * 3] - dataptr[DCTSIZE * 4];
|
||||
|
||||
/* Even part per LL&M figure 1 --- note that published figure is faulty;
|
||||
* rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
|
||||
@ -238,14 +238,16 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
tmp11 = tmp1 + tmp2;
|
||||
tmp12 = tmp1 - tmp2;
|
||||
|
||||
dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);
|
||||
dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);
|
||||
dataptr[DCTSIZE * 0] = (DCTELEM)DESCALE(tmp10 + tmp11, PASS1_BITS);
|
||||
dataptr[DCTSIZE * 4] = (DCTELEM)DESCALE(tmp10 - tmp11, PASS1_BITS);
|
||||
|
||||
z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
|
||||
dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE * 2] =
|
||||
(DCTELEM)DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
|
||||
CONST_BITS + PASS1_BITS);
|
||||
dataptr[DCTSIZE * 6] =
|
||||
(DCTELEM)DESCALE(z1 + MULTIPLY(tmp12, -FIX_1_847759065),
|
||||
CONST_BITS + PASS1_BITS);
|
||||
|
||||
/* Odd part per figure 8 --- note paper omits factor of sqrt(2).
|
||||
* cK represents cos(K*pi/16).
|
||||
@ -262,22 +264,22 @@ jpeg_fdct_islow (DCTELEM *data)
|
||||
tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
|
||||
tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
|
||||
tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
|
||||
z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
|
||||
z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
|
||||
z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
|
||||
z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
|
||||
z1 = MULTIPLY(z1, -FIX_0_899976223); /* sqrt(2) * ( c7-c3) */
|
||||
z2 = MULTIPLY(z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
|
||||
z3 = MULTIPLY(z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
|
||||
z4 = MULTIPLY(z4, -FIX_0_390180644); /* sqrt(2) * ( c5-c3) */
|
||||
|
||||
z3 += z5;
|
||||
z4 += z5;
|
||||
|
||||
dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3,
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4,
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3,
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4,
|
||||
CONST_BITS+PASS1_BITS);
|
||||
dataptr[DCTSIZE * 7] = (DCTELEM)DESCALE(tmp4 + z1 + z3,
|
||||
CONST_BITS + PASS1_BITS);
|
||||
dataptr[DCTSIZE * 5] = (DCTELEM)DESCALE(tmp5 + z2 + z4,
|
||||
CONST_BITS + PASS1_BITS);
|
||||
dataptr[DCTSIZE * 3] = (DCTELEM)DESCALE(tmp6 + z2 + z3,
|
||||
CONST_BITS + PASS1_BITS);
|
||||
dataptr[DCTSIZE * 1] = (DCTELEM)DESCALE(tmp7 + z1 + z4,
|
||||
CONST_BITS + PASS1_BITS);
|
||||
|
||||
dataptr++; /* advance pointer to next column */
|
||||
}
|
||||
|
110
3rdparty/libjpeg-turbo/src/jidctflt.c
vendored
110
3rdparty/libjpeg-turbo/src/jidctflt.c
vendored
@ -61,7 +61,7 @@
|
||||
* entry; produce a float result.
|
||||
*/
|
||||
|
||||
#define DEQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval))
|
||||
#define DEQUANTIZE(coef, quantval) (((FAST_FLOAT)(coef)) * (quantval))
|
||||
|
||||
|
||||
/*
|
||||
@ -69,9 +69,9 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col)
|
||||
jpeg_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
||||
FAST_FLOAT tmp10, tmp11, tmp12, tmp13;
|
||||
@ -83,12 +83,12 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPLE *range_limit = cinfo->sample_range_limit;
|
||||
int ctr;
|
||||
FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
|
||||
#define _0_125 ((FLOAT_MULT_TYPE)0.125)
|
||||
#define _0_125 ((FLOAT_MULT_TYPE)0.125)
|
||||
|
||||
/* Pass 1: process columns from input, store into work array. */
|
||||
|
||||
inptr = coef_block;
|
||||
quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table;
|
||||
quantptr = (FLOAT_MULT_TYPE *)compptr->dct_table;
|
||||
wsptr = workspace;
|
||||
for (ctr = DCTSIZE; ctr > 0; ctr--) {
|
||||
/* Due to quantization, we will usually find that many of the input
|
||||
@ -100,22 +100,22 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
* column DCT calculations can be simplified this way.
|
||||
*/
|
||||
|
||||
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
|
||||
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
|
||||
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
|
||||
inptr[DCTSIZE*7] == 0) {
|
||||
if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 &&
|
||||
inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 4] == 0 &&
|
||||
inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 6] == 0 &&
|
||||
inptr[DCTSIZE * 7] == 0) {
|
||||
/* AC terms all zero */
|
||||
FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0],
|
||||
quantptr[DCTSIZE*0] * _0_125);
|
||||
FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE * 0],
|
||||
quantptr[DCTSIZE * 0] * _0_125);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
wsptr[DCTSIZE*2] = dcval;
|
||||
wsptr[DCTSIZE*3] = dcval;
|
||||
wsptr[DCTSIZE*4] = dcval;
|
||||
wsptr[DCTSIZE*5] = dcval;
|
||||
wsptr[DCTSIZE*6] = dcval;
|
||||
wsptr[DCTSIZE*7] = dcval;
|
||||
wsptr[DCTSIZE * 0] = dcval;
|
||||
wsptr[DCTSIZE * 1] = dcval;
|
||||
wsptr[DCTSIZE * 2] = dcval;
|
||||
wsptr[DCTSIZE * 3] = dcval;
|
||||
wsptr[DCTSIZE * 4] = dcval;
|
||||
wsptr[DCTSIZE * 5] = dcval;
|
||||
wsptr[DCTSIZE * 6] = dcval;
|
||||
wsptr[DCTSIZE * 7] = dcval;
|
||||
|
||||
inptr++; /* advance pointers to next column */
|
||||
quantptr++;
|
||||
@ -125,16 +125,16 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0] * _0_125);
|
||||
tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2] * _0_125);
|
||||
tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4] * _0_125);
|
||||
tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6] * _0_125);
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0] * _0_125);
|
||||
tmp1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2] * _0_125);
|
||||
tmp2 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4] * _0_125);
|
||||
tmp3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6] * _0_125);
|
||||
|
||||
tmp10 = tmp0 + tmp2; /* phase 3 */
|
||||
tmp11 = tmp0 - tmp2;
|
||||
|
||||
tmp13 = tmp1 + tmp3; /* phases 5-3 */
|
||||
tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */
|
||||
tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT)1.414213562) - tmp13; /* 2*c4 */
|
||||
|
||||
tmp0 = tmp10 + tmp13; /* phase 2 */
|
||||
tmp3 = tmp10 - tmp13;
|
||||
@ -143,10 +143,10 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Odd part */
|
||||
|
||||
tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1] * _0_125);
|
||||
tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3] * _0_125);
|
||||
tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5] * _0_125);
|
||||
tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7] * _0_125);
|
||||
tmp4 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1] * _0_125);
|
||||
tmp5 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3] * _0_125);
|
||||
tmp6 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5] * _0_125);
|
||||
tmp7 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7] * _0_125);
|
||||
|
||||
z13 = tmp6 + tmp5; /* phase 6 */
|
||||
z10 = tmp6 - tmp5;
|
||||
@ -154,24 +154,24 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
z12 = tmp4 - tmp7;
|
||||
|
||||
tmp7 = z11 + z13; /* phase 5 */
|
||||
tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */
|
||||
tmp11 = (z11 - z13) * ((FAST_FLOAT)1.414213562); /* 2*c4 */
|
||||
|
||||
z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
|
||||
tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
|
||||
tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
|
||||
z5 = (z10 + z12) * ((FAST_FLOAT)1.847759065); /* 2*c2 */
|
||||
tmp10 = z5 - z12 * ((FAST_FLOAT)1.082392200); /* 2*(c2-c6) */
|
||||
tmp12 = z5 - z10 * ((FAST_FLOAT)2.613125930); /* 2*(c2+c6) */
|
||||
|
||||
tmp6 = tmp12 - tmp7; /* phase 2 */
|
||||
tmp5 = tmp11 - tmp6;
|
||||
tmp4 = tmp10 - tmp5;
|
||||
|
||||
wsptr[DCTSIZE*0] = tmp0 + tmp7;
|
||||
wsptr[DCTSIZE*7] = tmp0 - tmp7;
|
||||
wsptr[DCTSIZE*1] = tmp1 + tmp6;
|
||||
wsptr[DCTSIZE*6] = tmp1 - tmp6;
|
||||
wsptr[DCTSIZE*2] = tmp2 + tmp5;
|
||||
wsptr[DCTSIZE*5] = tmp2 - tmp5;
|
||||
wsptr[DCTSIZE*3] = tmp3 + tmp4;
|
||||
wsptr[DCTSIZE*4] = tmp3 - tmp4;
|
||||
wsptr[DCTSIZE * 0] = tmp0 + tmp7;
|
||||
wsptr[DCTSIZE * 7] = tmp0 - tmp7;
|
||||
wsptr[DCTSIZE * 1] = tmp1 + tmp6;
|
||||
wsptr[DCTSIZE * 6] = tmp1 - tmp6;
|
||||
wsptr[DCTSIZE * 2] = tmp2 + tmp5;
|
||||
wsptr[DCTSIZE * 5] = tmp2 - tmp5;
|
||||
wsptr[DCTSIZE * 3] = tmp3 + tmp4;
|
||||
wsptr[DCTSIZE * 4] = tmp3 - tmp4;
|
||||
|
||||
inptr++; /* advance pointers to next column */
|
||||
quantptr++;
|
||||
@ -192,12 +192,12 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* Even part */
|
||||
|
||||
/* Apply signed->unsigned and prepare float->int conversion */
|
||||
z5 = wsptr[0] + ((FAST_FLOAT) CENTERJSAMPLE + (FAST_FLOAT) 0.5);
|
||||
z5 = wsptr[0] + ((FAST_FLOAT)CENTERJSAMPLE + (FAST_FLOAT)0.5);
|
||||
tmp10 = z5 + wsptr[4];
|
||||
tmp11 = z5 - wsptr[4];
|
||||
|
||||
tmp13 = wsptr[2] + wsptr[6];
|
||||
tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13;
|
||||
tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT)1.414213562) - tmp13;
|
||||
|
||||
tmp0 = tmp10 + tmp13;
|
||||
tmp3 = tmp10 - tmp13;
|
||||
@ -212,11 +212,11 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
z12 = wsptr[1] - wsptr[7];
|
||||
|
||||
tmp7 = z11 + z13;
|
||||
tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562);
|
||||
tmp11 = (z11 - z13) * ((FAST_FLOAT)1.414213562);
|
||||
|
||||
z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
|
||||
tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
|
||||
tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
|
||||
z5 = (z10 + z12) * ((FAST_FLOAT)1.847759065); /* 2*c2 */
|
||||
tmp10 = z5 - z12 * ((FAST_FLOAT)1.082392200); /* 2*(c2-c6) */
|
||||
tmp12 = z5 - z10 * ((FAST_FLOAT)2.613125930); /* 2*(c2+c6) */
|
||||
|
||||
tmp6 = tmp12 - tmp7;
|
||||
tmp5 = tmp11 - tmp6;
|
||||
@ -224,14 +224,14 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Final output stage: float->int conversion and range-limit */
|
||||
|
||||
outptr[0] = range_limit[((int) (tmp0 + tmp7)) & RANGE_MASK];
|
||||
outptr[7] = range_limit[((int) (tmp0 - tmp7)) & RANGE_MASK];
|
||||
outptr[1] = range_limit[((int) (tmp1 + tmp6)) & RANGE_MASK];
|
||||
outptr[6] = range_limit[((int) (tmp1 - tmp6)) & RANGE_MASK];
|
||||
outptr[2] = range_limit[((int) (tmp2 + tmp5)) & RANGE_MASK];
|
||||
outptr[5] = range_limit[((int) (tmp2 - tmp5)) & RANGE_MASK];
|
||||
outptr[3] = range_limit[((int) (tmp3 + tmp4)) & RANGE_MASK];
|
||||
outptr[4] = range_limit[((int) (tmp3 - tmp4)) & RANGE_MASK];
|
||||
outptr[0] = range_limit[((int)(tmp0 + tmp7)) & RANGE_MASK];
|
||||
outptr[7] = range_limit[((int)(tmp0 - tmp7)) & RANGE_MASK];
|
||||
outptr[1] = range_limit[((int)(tmp1 + tmp6)) & RANGE_MASK];
|
||||
outptr[6] = range_limit[((int)(tmp1 - tmp6)) & RANGE_MASK];
|
||||
outptr[2] = range_limit[((int)(tmp2 + tmp5)) & RANGE_MASK];
|
||||
outptr[5] = range_limit[((int)(tmp2 - tmp5)) & RANGE_MASK];
|
||||
outptr[3] = range_limit[((int)(tmp3 + tmp4)) & RANGE_MASK];
|
||||
outptr[4] = range_limit[((int)(tmp3 - tmp4)) & RANGE_MASK];
|
||||
|
||||
wsptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
|
152
3rdparty/libjpeg-turbo/src/jidctfst.c
vendored
152
3rdparty/libjpeg-turbo/src/jidctfst.c
vendored
@ -92,10 +92,10 @@
|
||||
*/
|
||||
|
||||
#if CONST_BITS == 8
|
||||
#define FIX_1_082392200 ((JLONG) 277) /* FIX(1.082392200) */
|
||||
#define FIX_1_414213562 ((JLONG) 362) /* FIX(1.414213562) */
|
||||
#define FIX_1_847759065 ((JLONG) 473) /* FIX(1.847759065) */
|
||||
#define FIX_2_613125930 ((JLONG) 669) /* FIX(2.613125930) */
|
||||
#define FIX_1_082392200 ((JLONG)277) /* FIX(1.082392200) */
|
||||
#define FIX_1_414213562 ((JLONG)362) /* FIX(1.414213562) */
|
||||
#define FIX_1_847759065 ((JLONG)473) /* FIX(1.847759065) */
|
||||
#define FIX_2_613125930 ((JLONG)669) /* FIX(2.613125930) */
|
||||
#else
|
||||
#define FIX_1_082392200 FIX(1.082392200)
|
||||
#define FIX_1_414213562 FIX(1.414213562)
|
||||
@ -111,7 +111,7 @@
|
||||
|
||||
#ifndef USE_ACCURATE_ROUNDING
|
||||
#undef DESCALE
|
||||
#define DESCALE(x,n) RIGHT_SHIFT(x, n)
|
||||
#define DESCALE(x, n) RIGHT_SHIFT(x, n)
|
||||
#endif
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@
|
||||
* descale to yield a DCTELEM result.
|
||||
*/
|
||||
|
||||
#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
|
||||
#define MULTIPLY(var, const) ((DCTELEM)DESCALE((var) * (const), CONST_BITS))
|
||||
|
||||
|
||||
/* Dequantize a coefficient by multiplying it by the multiplier-table
|
||||
@ -129,10 +129,10 @@
|
||||
*/
|
||||
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
#define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval))
|
||||
#define DEQUANTIZE(coef, quantval) (((IFAST_MULT_TYPE)(coef)) * (quantval))
|
||||
#else
|
||||
#define DEQUANTIZE(coef,quantval) \
|
||||
DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS)
|
||||
#define DEQUANTIZE(coef, quantval) \
|
||||
DESCALE((coef) * (quantval), IFAST_SCALE_BITS - PASS1_BITS)
|
||||
#endif
|
||||
|
||||
|
||||
@ -147,19 +147,19 @@
|
||||
#else
|
||||
#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
|
||||
#endif
|
||||
#define IRIGHT_SHIFT(x,shft) \
|
||||
#define IRIGHT_SHIFT(x, shft) \
|
||||
((ishift_temp = (x)) < 0 ? \
|
||||
(ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \
|
||||
(ishift_temp >> (shft)) | ((~((DCTELEM)0)) << (DCTELEMBITS - (shft))) : \
|
||||
(ishift_temp >> (shft)))
|
||||
#else
|
||||
#define ISHIFT_TEMPS
|
||||
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||
#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
|
||||
#endif
|
||||
|
||||
#ifdef USE_ACCURATE_ROUNDING
|
||||
#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n))
|
||||
#define IDESCALE(x, n) ((int)IRIGHT_SHIFT((x) + (1 << ((n) - 1)), n))
|
||||
#else
|
||||
#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n))
|
||||
#define IDESCALE(x, n) ((int)IRIGHT_SHIFT(x, n))
|
||||
#endif
|
||||
|
||||
|
||||
@ -168,9 +168,9 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col)
|
||||
jpeg_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
||||
DCTELEM tmp10, tmp11, tmp12, tmp13;
|
||||
@ -188,7 +188,7 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* Pass 1: process columns from input, store into work array. */
|
||||
|
||||
inptr = coef_block;
|
||||
quantptr = (IFAST_MULT_TYPE *) compptr->dct_table;
|
||||
quantptr = (IFAST_MULT_TYPE *)compptr->dct_table;
|
||||
wsptr = workspace;
|
||||
for (ctr = DCTSIZE; ctr > 0; ctr--) {
|
||||
/* Due to quantization, we will usually find that many of the input
|
||||
@ -200,21 +200,21 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
* column DCT calculations can be simplified this way.
|
||||
*/
|
||||
|
||||
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
|
||||
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
|
||||
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
|
||||
inptr[DCTSIZE*7] == 0) {
|
||||
if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 &&
|
||||
inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 4] == 0 &&
|
||||
inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 6] == 0 &&
|
||||
inptr[DCTSIZE * 7] == 0) {
|
||||
/* AC terms all zero */
|
||||
int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
int dcval = (int)DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
wsptr[DCTSIZE*2] = dcval;
|
||||
wsptr[DCTSIZE*3] = dcval;
|
||||
wsptr[DCTSIZE*4] = dcval;
|
||||
wsptr[DCTSIZE*5] = dcval;
|
||||
wsptr[DCTSIZE*6] = dcval;
|
||||
wsptr[DCTSIZE*7] = dcval;
|
||||
wsptr[DCTSIZE * 0] = dcval;
|
||||
wsptr[DCTSIZE * 1] = dcval;
|
||||
wsptr[DCTSIZE * 2] = dcval;
|
||||
wsptr[DCTSIZE * 3] = dcval;
|
||||
wsptr[DCTSIZE * 4] = dcval;
|
||||
wsptr[DCTSIZE * 5] = dcval;
|
||||
wsptr[DCTSIZE * 6] = dcval;
|
||||
wsptr[DCTSIZE * 7] = dcval;
|
||||
|
||||
inptr++; /* advance pointers to next column */
|
||||
quantptr++;
|
||||
@ -224,10 +224,10 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
|
||||
tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
|
||||
tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
|
||||
tmp1 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
|
||||
tmp2 = DEQUANTIZE(inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4]);
|
||||
tmp3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
|
||||
|
||||
tmp10 = tmp0 + tmp2; /* phase 3 */
|
||||
tmp11 = tmp0 - tmp2;
|
||||
@ -242,10 +242,10 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Odd part */
|
||||
|
||||
tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
|
||||
tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
|
||||
tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
|
||||
tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
|
||||
tmp4 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
|
||||
tmp5 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
|
||||
tmp6 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
|
||||
tmp7 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
|
||||
|
||||
z13 = tmp6 + tmp5; /* phase 6 */
|
||||
z10 = tmp6 - tmp5;
|
||||
@ -257,20 +257,20 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
|
||||
tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
|
||||
tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
||||
tmp12 = MULTIPLY(z10, -FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
||||
|
||||
tmp6 = tmp12 - tmp7; /* phase 2 */
|
||||
tmp5 = tmp11 - tmp6;
|
||||
tmp4 = tmp10 + tmp5;
|
||||
|
||||
wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7);
|
||||
wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7);
|
||||
wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6);
|
||||
wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6);
|
||||
wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5);
|
||||
wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5);
|
||||
wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4);
|
||||
wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4);
|
||||
wsptr[DCTSIZE * 0] = (int)(tmp0 + tmp7);
|
||||
wsptr[DCTSIZE * 7] = (int)(tmp0 - tmp7);
|
||||
wsptr[DCTSIZE * 1] = (int)(tmp1 + tmp6);
|
||||
wsptr[DCTSIZE * 6] = (int)(tmp1 - tmp6);
|
||||
wsptr[DCTSIZE * 2] = (int)(tmp2 + tmp5);
|
||||
wsptr[DCTSIZE * 5] = (int)(tmp2 - tmp5);
|
||||
wsptr[DCTSIZE * 4] = (int)(tmp3 + tmp4);
|
||||
wsptr[DCTSIZE * 3] = (int)(tmp3 - tmp4);
|
||||
|
||||
inptr++; /* advance pointers to next column */
|
||||
quantptr++;
|
||||
@ -296,8 +296,8 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
|
||||
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
|
||||
/* AC terms all zero */
|
||||
JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
JSAMPLE dcval =
|
||||
range_limit[IDESCALE(wsptr[0], PASS1_BITS + 3) & RANGE_MASK];
|
||||
|
||||
outptr[0] = dcval;
|
||||
outptr[1] = dcval;
|
||||
@ -315,12 +315,12 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);
|
||||
tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]);
|
||||
tmp10 = ((DCTELEM)wsptr[0] + (DCTELEM)wsptr[4]);
|
||||
tmp11 = ((DCTELEM)wsptr[0] - (DCTELEM)wsptr[4]);
|
||||
|
||||
tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]);
|
||||
tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562)
|
||||
- tmp13;
|
||||
tmp13 = ((DCTELEM)wsptr[2] + (DCTELEM)wsptr[6]);
|
||||
tmp12 =
|
||||
MULTIPLY((DCTELEM)wsptr[2] - (DCTELEM)wsptr[6], FIX_1_414213562) - tmp13;
|
||||
|
||||
tmp0 = tmp10 + tmp13;
|
||||
tmp3 = tmp10 - tmp13;
|
||||
@ -329,17 +329,17 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Odd part */
|
||||
|
||||
z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3];
|
||||
z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3];
|
||||
z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7];
|
||||
z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7];
|
||||
z13 = (DCTELEM)wsptr[5] + (DCTELEM)wsptr[3];
|
||||
z10 = (DCTELEM)wsptr[5] - (DCTELEM)wsptr[3];
|
||||
z11 = (DCTELEM)wsptr[1] + (DCTELEM)wsptr[7];
|
||||
z12 = (DCTELEM)wsptr[1] - (DCTELEM)wsptr[7];
|
||||
|
||||
tmp7 = z11 + z13; /* phase 5 */
|
||||
tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
|
||||
|
||||
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
|
||||
tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
|
||||
tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
||||
tmp12 = MULTIPLY(z10, -FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
||||
|
||||
tmp6 = tmp12 - tmp7; /* phase 2 */
|
||||
tmp5 = tmp11 - tmp6;
|
||||
@ -347,22 +347,22 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Final output stage: scale down by a factor of 8 and range-limit */
|
||||
|
||||
outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
outptr[0] =
|
||||
range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[7] =
|
||||
range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[1] =
|
||||
range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[6] =
|
||||
range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[2] =
|
||||
range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[5] =
|
||||
range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[4] =
|
||||
range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS + 3) & RANGE_MASK];
|
||||
outptr[3] =
|
||||
range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS + 3) & RANGE_MASK];
|
||||
|
||||
wsptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
|
1720
3rdparty/libjpeg-turbo/src/jidctint.c
vendored
1720
3rdparty/libjpeg-turbo/src/jidctint.c
vendored
File diff suppressed because it is too large
Load Diff
252
3rdparty/libjpeg-turbo/src/jidctred.c
vendored
252
3rdparty/libjpeg-turbo/src/jidctred.c
vendored
@ -58,20 +58,20 @@
|
||||
*/
|
||||
|
||||
#if CONST_BITS == 13
|
||||
#define FIX_0_211164243 ((JLONG) 1730) /* FIX(0.211164243) */
|
||||
#define FIX_0_509795579 ((JLONG) 4176) /* FIX(0.509795579) */
|
||||
#define FIX_0_601344887 ((JLONG) 4926) /* FIX(0.601344887) */
|
||||
#define FIX_0_720959822 ((JLONG) 5906) /* FIX(0.720959822) */
|
||||
#define FIX_0_765366865 ((JLONG) 6270) /* FIX(0.765366865) */
|
||||
#define FIX_0_850430095 ((JLONG) 6967) /* FIX(0.850430095) */
|
||||
#define FIX_0_899976223 ((JLONG) 7373) /* FIX(0.899976223) */
|
||||
#define FIX_1_061594337 ((JLONG) 8697) /* FIX(1.061594337) */
|
||||
#define FIX_1_272758580 ((JLONG) 10426) /* FIX(1.272758580) */
|
||||
#define FIX_1_451774981 ((JLONG) 11893) /* FIX(1.451774981) */
|
||||
#define FIX_1_847759065 ((JLONG) 15137) /* FIX(1.847759065) */
|
||||
#define FIX_2_172734803 ((JLONG) 17799) /* FIX(2.172734803) */
|
||||
#define FIX_2_562915447 ((JLONG) 20995) /* FIX(2.562915447) */
|
||||
#define FIX_3_624509785 ((JLONG) 29692) /* FIX(3.624509785) */
|
||||
#define FIX_0_211164243 ((JLONG)1730) /* FIX(0.211164243) */
|
||||
#define FIX_0_509795579 ((JLONG)4176) /* FIX(0.509795579) */
|
||||
#define FIX_0_601344887 ((JLONG)4926) /* FIX(0.601344887) */
|
||||
#define FIX_0_720959822 ((JLONG)5906) /* FIX(0.720959822) */
|
||||
#define FIX_0_765366865 ((JLONG)6270) /* FIX(0.765366865) */
|
||||
#define FIX_0_850430095 ((JLONG)6967) /* FIX(0.850430095) */
|
||||
#define FIX_0_899976223 ((JLONG)7373) /* FIX(0.899976223) */
|
||||
#define FIX_1_061594337 ((JLONG)8697) /* FIX(1.061594337) */
|
||||
#define FIX_1_272758580 ((JLONG)10426) /* FIX(1.272758580) */
|
||||
#define FIX_1_451774981 ((JLONG)11893) /* FIX(1.451774981) */
|
||||
#define FIX_1_847759065 ((JLONG)15137) /* FIX(1.847759065) */
|
||||
#define FIX_2_172734803 ((JLONG)17799) /* FIX(2.172734803) */
|
||||
#define FIX_2_562915447 ((JLONG)20995) /* FIX(2.562915447) */
|
||||
#define FIX_3_624509785 ((JLONG)29692) /* FIX(3.624509785) */
|
||||
#else
|
||||
#define FIX_0_211164243 FIX(0.211164243)
|
||||
#define FIX_0_509795579 FIX(0.509795579)
|
||||
@ -98,9 +98,9 @@
|
||||
*/
|
||||
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
#define MULTIPLY(var,const) MULTIPLY16C16(var,const)
|
||||
#define MULTIPLY(var, const) MULTIPLY16C16(var, const)
|
||||
#else
|
||||
#define MULTIPLY(var,const) ((var) * (const))
|
||||
#define MULTIPLY(var, const) ((var) * (const))
|
||||
#endif
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@
|
||||
* are 16 bits or less, so either int or short multiply will work.
|
||||
*/
|
||||
|
||||
#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval))
|
||||
#define DEQUANTIZE(coef, quantval) (((ISLOW_MULT_TYPE)(coef)) * (quantval))
|
||||
|
||||
|
||||
/*
|
||||
@ -118,9 +118,9 @@
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col)
|
||||
jpeg_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
JLONG tmp0, tmp2, tmp10, tmp12;
|
||||
JLONG z1, z2, z3, z4;
|
||||
@ -130,69 +130,73 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPROW outptr;
|
||||
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
|
||||
int ctr;
|
||||
int workspace[DCTSIZE*4]; /* buffers data between passes */
|
||||
int workspace[DCTSIZE * 4]; /* buffers data between passes */
|
||||
SHIFT_TEMPS
|
||||
|
||||
/* Pass 1: process columns from input, store into work array. */
|
||||
|
||||
inptr = coef_block;
|
||||
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
|
||||
quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
|
||||
wsptr = workspace;
|
||||
for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
|
||||
/* Don't bother to process column 4, because second pass won't use it */
|
||||
if (ctr == DCTSIZE-4)
|
||||
if (ctr == DCTSIZE - 4)
|
||||
continue;
|
||||
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
|
||||
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 &&
|
||||
inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) {
|
||||
if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 &&
|
||||
inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 5] == 0 &&
|
||||
inptr[DCTSIZE * 6] == 0 && inptr[DCTSIZE * 7] == 0) {
|
||||
/* AC terms all zero; we need not examine term 4 for 4x4 output */
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
|
||||
PASS1_BITS);
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE * 0],
|
||||
quantptr[DCTSIZE * 0]), PASS1_BITS);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
wsptr[DCTSIZE*2] = dcval;
|
||||
wsptr[DCTSIZE*3] = dcval;
|
||||
wsptr[DCTSIZE * 0] = dcval;
|
||||
wsptr[DCTSIZE * 1] = dcval;
|
||||
wsptr[DCTSIZE * 2] = dcval;
|
||||
wsptr[DCTSIZE * 3] = dcval;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS+1);
|
||||
tmp0 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
|
||||
tmp0 = LEFT_SHIFT(tmp0, CONST_BITS + 1);
|
||||
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6]);
|
||||
|
||||
tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865);
|
||||
tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, -FIX_0_765366865);
|
||||
|
||||
tmp10 = tmp0 + tmp2;
|
||||
tmp12 = tmp0 - tmp2;
|
||||
|
||||
/* Odd part */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
|
||||
z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
|
||||
z2 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
|
||||
z3 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
|
||||
z4 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
|
||||
|
||||
tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
|
||||
+ MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
|
||||
+ MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
|
||||
+ MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
|
||||
tmp0 = MULTIPLY(z1, -FIX_0_211164243) + /* sqrt(2) * ( c3-c1) */
|
||||
MULTIPLY(z2, FIX_1_451774981) + /* sqrt(2) * ( c3+c7) */
|
||||
MULTIPLY(z3, -FIX_2_172734803) + /* sqrt(2) * (-c1-c5) */
|
||||
MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * ( c5+c7) */
|
||||
|
||||
tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
|
||||
+ MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
|
||||
+ MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
|
||||
+ MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
|
||||
tmp2 = MULTIPLY(z1, -FIX_0_509795579) + /* sqrt(2) * (c7-c5) */
|
||||
MULTIPLY(z2, -FIX_0_601344887) + /* sqrt(2) * (c5-c1) */
|
||||
MULTIPLY(z3, FIX_0_899976223) + /* sqrt(2) * (c3-c7) */
|
||||
MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1);
|
||||
wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1);
|
||||
wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1);
|
||||
wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1);
|
||||
wsptr[DCTSIZE * 0] =
|
||||
(int)DESCALE(tmp10 + tmp2, CONST_BITS - PASS1_BITS + 1);
|
||||
wsptr[DCTSIZE * 3] =
|
||||
(int)DESCALE(tmp10 - tmp2, CONST_BITS - PASS1_BITS + 1);
|
||||
wsptr[DCTSIZE * 1] =
|
||||
(int)DESCALE(tmp12 + tmp0, CONST_BITS - PASS1_BITS + 1);
|
||||
wsptr[DCTSIZE * 2] =
|
||||
(int)DESCALE(tmp12 - tmp0, CONST_BITS - PASS1_BITS + 1);
|
||||
}
|
||||
|
||||
/* Pass 2: process 4 rows from work array, store into output array. */
|
||||
@ -206,8 +210,8 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 &&
|
||||
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
|
||||
/* AC terms all zero */
|
||||
JSAMPLE dcval = range_limit[(int) DESCALE((JLONG) wsptr[0], PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
|
||||
PASS1_BITS + 3) & RANGE_MASK];
|
||||
|
||||
outptr[0] = dcval;
|
||||
outptr[1] = dcval;
|
||||
@ -221,45 +225,45 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp0 = LEFT_SHIFT((JLONG) wsptr[0], CONST_BITS+1);
|
||||
tmp0 = LEFT_SHIFT((JLONG)wsptr[0], CONST_BITS + 1);
|
||||
|
||||
tmp2 = MULTIPLY((JLONG) wsptr[2], FIX_1_847759065)
|
||||
+ MULTIPLY((JLONG) wsptr[6], - FIX_0_765366865);
|
||||
tmp2 = MULTIPLY((JLONG)wsptr[2], FIX_1_847759065) +
|
||||
MULTIPLY((JLONG)wsptr[6], -FIX_0_765366865);
|
||||
|
||||
tmp10 = tmp0 + tmp2;
|
||||
tmp12 = tmp0 - tmp2;
|
||||
|
||||
/* Odd part */
|
||||
|
||||
z1 = (JLONG) wsptr[7];
|
||||
z2 = (JLONG) wsptr[5];
|
||||
z3 = (JLONG) wsptr[3];
|
||||
z4 = (JLONG) wsptr[1];
|
||||
z1 = (JLONG)wsptr[7];
|
||||
z2 = (JLONG)wsptr[5];
|
||||
z3 = (JLONG)wsptr[3];
|
||||
z4 = (JLONG)wsptr[1];
|
||||
|
||||
tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
|
||||
+ MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
|
||||
+ MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
|
||||
+ MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
|
||||
tmp0 = MULTIPLY(z1, -FIX_0_211164243) + /* sqrt(2) * ( c3-c1) */
|
||||
MULTIPLY(z2, FIX_1_451774981) + /* sqrt(2) * ( c3+c7) */
|
||||
MULTIPLY(z3, -FIX_2_172734803) + /* sqrt(2) * (-c1-c5) */
|
||||
MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * ( c5+c7) */
|
||||
|
||||
tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
|
||||
+ MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
|
||||
+ MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
|
||||
+ MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
|
||||
tmp2 = MULTIPLY(z1, -FIX_0_509795579) + /* sqrt(2) * (c7-c5) */
|
||||
MULTIPLY(z2, -FIX_0_601344887) + /* sqrt(2) * (c5-c1) */
|
||||
MULTIPLY(z3, FIX_0_899976223) + /* sqrt(2) * (c3-c7) */
|
||||
MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2,
|
||||
CONST_BITS+PASS1_BITS+3+1)
|
||||
& RANGE_MASK];
|
||||
outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2,
|
||||
CONST_BITS+PASS1_BITS+3+1)
|
||||
& RANGE_MASK];
|
||||
outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0,
|
||||
CONST_BITS+PASS1_BITS+3+1)
|
||||
& RANGE_MASK];
|
||||
outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0,
|
||||
CONST_BITS+PASS1_BITS+3+1)
|
||||
& RANGE_MASK];
|
||||
outptr[0] = range_limit[(int)DESCALE(tmp10 + tmp2,
|
||||
CONST_BITS + PASS1_BITS + 3 + 1) &
|
||||
RANGE_MASK];
|
||||
outptr[3] = range_limit[(int)DESCALE(tmp10 - tmp2,
|
||||
CONST_BITS + PASS1_BITS + 3 + 1) &
|
||||
RANGE_MASK];
|
||||
outptr[1] = range_limit[(int)DESCALE(tmp12 + tmp0,
|
||||
CONST_BITS + PASS1_BITS + 3 + 1) &
|
||||
RANGE_MASK];
|
||||
outptr[2] = range_limit[(int)DESCALE(tmp12 - tmp0,
|
||||
CONST_BITS + PASS1_BITS + 3 + 1) &
|
||||
RANGE_MASK];
|
||||
|
||||
wsptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
@ -272,9 +276,9 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col)
|
||||
jpeg_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
JLONG tmp0, tmp10, z1;
|
||||
JCOEFPTR inptr;
|
||||
@ -283,50 +287,52 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPROW outptr;
|
||||
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
|
||||
int ctr;
|
||||
int workspace[DCTSIZE*2]; /* buffers data between passes */
|
||||
int workspace[DCTSIZE * 2]; /* buffers data between passes */
|
||||
SHIFT_TEMPS
|
||||
|
||||
/* Pass 1: process columns from input, store into work array. */
|
||||
|
||||
inptr = coef_block;
|
||||
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
|
||||
quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
|
||||
wsptr = workspace;
|
||||
for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
|
||||
/* Don't bother to process columns 2,4,6 */
|
||||
if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6)
|
||||
if (ctr == DCTSIZE - 2 || ctr == DCTSIZE - 4 || ctr == DCTSIZE - 6)
|
||||
continue;
|
||||
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 &&
|
||||
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) {
|
||||
if (inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 3] == 0 &&
|
||||
inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 7] == 0) {
|
||||
/* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
|
||||
PASS1_BITS);
|
||||
int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE * 0],
|
||||
quantptr[DCTSIZE * 0]), PASS1_BITS);
|
||||
|
||||
wsptr[DCTSIZE*0] = dcval;
|
||||
wsptr[DCTSIZE*1] = dcval;
|
||||
wsptr[DCTSIZE * 0] = dcval;
|
||||
wsptr[DCTSIZE * 1] = dcval;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Even part */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
||||
tmp10 = LEFT_SHIFT(z1, CONST_BITS+2);
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0]);
|
||||
tmp10 = LEFT_SHIFT(z1, CONST_BITS + 2);
|
||||
|
||||
/* Odd part */
|
||||
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
|
||||
tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7]);
|
||||
tmp0 = MULTIPLY(z1, -FIX_0_720959822); /* sqrt(2) * ( c7-c5+c3-c1) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5]);
|
||||
tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
|
||||
tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
|
||||
tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3]);
|
||||
tmp0 += MULTIPLY(z1, -FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
|
||||
z1 = DEQUANTIZE(inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1]);
|
||||
tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * ( c1+c3+c5+c7) */
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2);
|
||||
wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2);
|
||||
wsptr[DCTSIZE * 0] =
|
||||
(int)DESCALE(tmp10 + tmp0, CONST_BITS - PASS1_BITS + 2);
|
||||
wsptr[DCTSIZE * 1] =
|
||||
(int)DESCALE(tmp10 - tmp0, CONST_BITS - PASS1_BITS + 2);
|
||||
}
|
||||
|
||||
/* Pass 2: process 2 rows from work array, store into output array. */
|
||||
@ -339,8 +345,8 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
#ifndef NO_ZERO_ROW_TEST
|
||||
if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) {
|
||||
/* AC terms all zero */
|
||||
JSAMPLE dcval = range_limit[(int) DESCALE((JLONG) wsptr[0], PASS1_BITS+3)
|
||||
& RANGE_MASK];
|
||||
JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
|
||||
PASS1_BITS + 3) & RANGE_MASK];
|
||||
|
||||
outptr[0] = dcval;
|
||||
outptr[1] = dcval;
|
||||
@ -352,23 +358,23 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
|
||||
/* Even part */
|
||||
|
||||
tmp10 = LEFT_SHIFT((JLONG) wsptr[0], CONST_BITS+2);
|
||||
tmp10 = LEFT_SHIFT((JLONG)wsptr[0], CONST_BITS + 2);
|
||||
|
||||
/* Odd part */
|
||||
|
||||
tmp0 = MULTIPLY((JLONG) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */
|
||||
+ MULTIPLY((JLONG) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */
|
||||
+ MULTIPLY((JLONG) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */
|
||||
+ MULTIPLY((JLONG) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
|
||||
tmp0 = MULTIPLY((JLONG)wsptr[7], -FIX_0_720959822) + /* sqrt(2) * ( c7-c5+c3-c1) */
|
||||
MULTIPLY((JLONG)wsptr[5], FIX_0_850430095) + /* sqrt(2) * (-c1+c3+c5+c7) */
|
||||
MULTIPLY((JLONG)wsptr[3], -FIX_1_272758580) + /* sqrt(2) * (-c1+c3-c5-c7) */
|
||||
MULTIPLY((JLONG)wsptr[1], FIX_3_624509785); /* sqrt(2) * ( c1+c3+c5+c7) */
|
||||
|
||||
/* Final output stage */
|
||||
|
||||
outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0,
|
||||
CONST_BITS+PASS1_BITS+3+2)
|
||||
& RANGE_MASK];
|
||||
outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0,
|
||||
CONST_BITS+PASS1_BITS+3+2)
|
||||
& RANGE_MASK];
|
||||
outptr[0] = range_limit[(int)DESCALE(tmp10 + tmp0,
|
||||
CONST_BITS + PASS1_BITS + 3 + 2) &
|
||||
RANGE_MASK];
|
||||
outptr[1] = range_limit[(int)DESCALE(tmp10 - tmp0,
|
||||
CONST_BITS + PASS1_BITS + 3 + 2) &
|
||||
RANGE_MASK];
|
||||
|
||||
wsptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
@ -381,9 +387,9 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col)
|
||||
jpeg_idct_1x1(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
int dcval;
|
||||
ISLOW_MULT_TYPE *quantptr;
|
||||
@ -393,9 +399,9 @@ jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
/* We hardly need an inverse DCT routine for this: just take the
|
||||
* average pixel value, which is one-eighth of the DC coefficient.
|
||||
*/
|
||||
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
|
||||
quantptr = (ISLOW_MULT_TYPE *)compptr->dct_table;
|
||||
dcval = DEQUANTIZE(coef_block[0], quantptr[0]);
|
||||
dcval = (int) DESCALE((JLONG) dcval, 3);
|
||||
dcval = (int)DESCALE((JLONG)dcval, 3);
|
||||
|
||||
output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];
|
||||
}
|
||||
|
20
3rdparty/libjpeg-turbo/src/jinclude.h
vendored
20
3rdparty/libjpeg-turbo/src/jinclude.h
vendored
@ -61,14 +61,18 @@
|
||||
#ifdef NEED_BSD_STRINGS
|
||||
|
||||
#include <strings.h>
|
||||
#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
|
||||
#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
|
||||
#define MEMZERO(target, size) \
|
||||
bzero((void *)(target), (size_t)(size))
|
||||
#define MEMCOPY(dest, src, size) \
|
||||
bcopy((const void *)(src), (void *)(dest), (size_t)(size))
|
||||
|
||||
#else /* not BSD, assume ANSI/SysV string lib */
|
||||
|
||||
#include <string.h>
|
||||
#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
|
||||
#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
|
||||
#define MEMZERO(target, size) \
|
||||
memset((void *)(target), 0, (size_t)(size))
|
||||
#define MEMCOPY(dest, src, size) \
|
||||
memcpy((void *)(dest), (const void *)(src), (size_t)(size))
|
||||
|
||||
#endif
|
||||
|
||||
@ -78,7 +82,7 @@
|
||||
* CAUTION: argument order is different from underlying functions!
|
||||
*/
|
||||
|
||||
#define JFREAD(file,buf,sizeofbuf) \
|
||||
((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||
#define JFWRITE(file,buf,sizeofbuf) \
|
||||
((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||
#define JFREAD(file, buf, sizeofbuf) \
|
||||
((size_t)fread((void *)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))
|
||||
#define JFWRITE(file, buf, sizeofbuf) \
|
||||
((size_t)fwrite((const void *)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))
|
||||
|
276
3rdparty/libjpeg-turbo/src/jmemmgr.c
vendored
276
3rdparty/libjpeg-turbo/src/jmemmgr.c
vendored
@ -32,20 +32,20 @@
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jmemsys.h" /* import the system-dependent declarations */
|
||||
#ifndef _WIN32
|
||||
#if !defined(_MSC_VER) || _MSC_VER > 1600
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef NO_GETENV
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */
|
||||
extern char *getenv (const char *name);
|
||||
extern char *getenv(const char *name);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL(size_t)
|
||||
round_up_pow2 (size_t a, size_t b)
|
||||
round_up_pow2(size_t a, size_t b)
|
||||
/* a rounded up to the next multiple of b, i.e. ceil(a/b)*b */
|
||||
/* Assumes a >= 0, b > 0, and b is a power of 2 */
|
||||
{
|
||||
@ -89,7 +89,9 @@ round_up_pow2 (size_t a, size_t b)
|
||||
#ifndef WITH_SIMD
|
||||
#define ALIGN_SIZE sizeof(double)
|
||||
#else
|
||||
#define ALIGN_SIZE 16 /* Most SIMD implementations require this */
|
||||
#define ALIGN_SIZE 32 /* Most of the SIMD instructions we support require
|
||||
16-byte (128-bit) alignment, but AVX2 requires
|
||||
32-byte alignment. */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -191,9 +193,9 @@ struct jvirt_barray_control {
|
||||
#ifdef MEM_STATS /* optional extra stuff for statistics */
|
||||
|
||||
LOCAL(void)
|
||||
print_mem_stats (j_common_ptr cinfo, int pool_id)
|
||||
print_mem_stats(j_common_ptr cinfo, int pool_id)
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
small_pool_ptr shdr_ptr;
|
||||
large_pool_ptr lhdr_ptr;
|
||||
|
||||
@ -206,15 +208,13 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
|
||||
|
||||
for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL;
|
||||
lhdr_ptr = lhdr_ptr->next) {
|
||||
fprintf(stderr, " Large chunk used %ld\n",
|
||||
(long) lhdr_ptr->bytes_used);
|
||||
fprintf(stderr, " Large chunk used %ld\n", (long)lhdr_ptr->bytes_used);
|
||||
}
|
||||
|
||||
for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL;
|
||||
shdr_ptr = shdr_ptr->next) {
|
||||
fprintf(stderr, " Small chunk used %ld free %ld\n",
|
||||
(long) shdr_ptr->bytes_used,
|
||||
(long) shdr_ptr->bytes_left);
|
||||
(long)shdr_ptr->bytes_used, (long)shdr_ptr->bytes_left);
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
out_of_memory (j_common_ptr cinfo, int which)
|
||||
out_of_memory(j_common_ptr cinfo, int which)
|
||||
/* Report an out-of-memory error and stop execution */
|
||||
/* If we compiled MEM_STATS support, report alloc requests before dying */
|
||||
{
|
||||
@ -250,14 +250,12 @@ out_of_memory (j_common_ptr cinfo, int which)
|
||||
* adjustment.
|
||||
*/
|
||||
|
||||
static const size_t first_pool_slop[JPOOL_NUMPOOLS] =
|
||||
{
|
||||
static const size_t first_pool_slop[JPOOL_NUMPOOLS] = {
|
||||
1600, /* first PERMANENT pool */
|
||||
16000 /* first IMAGE pool */
|
||||
};
|
||||
|
||||
static const size_t extra_pool_slop[JPOOL_NUMPOOLS] =
|
||||
{
|
||||
static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = {
|
||||
0, /* additional PERMANENT pools */
|
||||
5000 /* additional IMAGE pools */
|
||||
};
|
||||
@ -266,10 +264,10 @@ static const size_t extra_pool_slop[JPOOL_NUMPOOLS] =
|
||||
|
||||
|
||||
METHODDEF(void *)
|
||||
alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
alloc_small(j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
/* Allocate a "small" object */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
small_pool_ptr hdr_ptr, prev_hdr_ptr;
|
||||
char *data_ptr;
|
||||
size_t min_request, slop;
|
||||
@ -313,11 +311,11 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
else
|
||||
slop = extra_pool_slop[pool_id];
|
||||
/* Don't ask for more than MAX_ALLOC_CHUNK */
|
||||
if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request))
|
||||
slop = (size_t) (MAX_ALLOC_CHUNK-min_request);
|
||||
if (slop > (size_t)(MAX_ALLOC_CHUNK - min_request))
|
||||
slop = (size_t)(MAX_ALLOC_CHUNK - min_request);
|
||||
/* Try to get space, if fail reduce slop and try again */
|
||||
for (;;) {
|
||||
hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop);
|
||||
hdr_ptr = (small_pool_ptr)jpeg_get_small(cinfo, min_request + slop);
|
||||
if (hdr_ptr != NULL)
|
||||
break;
|
||||
slop /= 2;
|
||||
@ -336,7 +334,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
}
|
||||
|
||||
/* OK, allocate the object from the current pool */
|
||||
data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
|
||||
if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
|
||||
data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
|
||||
@ -344,7 +342,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
hdr_ptr->bytes_used += sizeofobject;
|
||||
hdr_ptr->bytes_left -= sizeofobject;
|
||||
|
||||
return (void *) data_ptr;
|
||||
return (void *)data_ptr;
|
||||
}
|
||||
|
||||
|
||||
@ -362,10 +360,10 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
*/
|
||||
|
||||
METHODDEF(void *)
|
||||
alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
alloc_large(j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
/* Allocate a "large" object */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
large_pool_ptr hdr_ptr;
|
||||
char *data_ptr;
|
||||
|
||||
@ -390,7 +388,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)
|
||||
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
|
||||
|
||||
hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject +
|
||||
hdr_ptr = (large_pool_ptr)jpeg_get_large(cinfo, sizeofobject +
|
||||
sizeof(large_pool_hdr) +
|
||||
ALIGN_SIZE - 1);
|
||||
if (hdr_ptr == NULL)
|
||||
@ -407,12 +405,12 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
hdr_ptr->bytes_left = 0;
|
||||
mem->large_list[pool_id] = hdr_ptr;
|
||||
|
||||
data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr = (char *)hdr_ptr; /* point to first data byte in pool... */
|
||||
data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
|
||||
if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
|
||||
data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
|
||||
|
||||
return (void *) data_ptr;
|
||||
return (void *)data_ptr;
|
||||
}
|
||||
|
||||
|
||||
@ -433,11 +431,11 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
*/
|
||||
|
||||
METHODDEF(JSAMPARRAY)
|
||||
alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
JDIMENSION samplesperrow, JDIMENSION numrows)
|
||||
alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
|
||||
JDIMENSION numrows)
|
||||
/* Allocate a 2-D sample array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
JSAMPARRAY result;
|
||||
JSAMPROW workspace;
|
||||
JDIMENSION rowsperchunk, currow, i;
|
||||
@ -456,27 +454,27 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
sizeof(JSAMPLE));
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
|
||||
((long) samplesperrow * sizeof(JSAMPLE));
|
||||
ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
|
||||
((long)samplesperrow * sizeof(JSAMPLE));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
if (ltemp < (long) numrows)
|
||||
rowsperchunk = (JDIMENSION) ltemp;
|
||||
if (ltemp < (long)numrows)
|
||||
rowsperchunk = (JDIMENSION)ltemp;
|
||||
else
|
||||
rowsperchunk = numrows;
|
||||
mem->last_rowsperchunk = rowsperchunk;
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JSAMPARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * sizeof(JSAMPROW)));
|
||||
result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
|
||||
(size_t)(numrows * sizeof(JSAMPROW)));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
while (currow < numrows) {
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JSAMPROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow
|
||||
* sizeof(JSAMPLE)));
|
||||
workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
|
||||
(size_t)((size_t)rowsperchunk * (size_t)samplesperrow *
|
||||
sizeof(JSAMPLE)));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += samplesperrow;
|
||||
@ -493,11 +491,11 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
*/
|
||||
|
||||
METHODDEF(JBLOCKARRAY)
|
||||
alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
JDIMENSION blocksperrow, JDIMENSION numrows)
|
||||
alloc_barray(j_common_ptr cinfo, int pool_id, JDIMENSION blocksperrow,
|
||||
JDIMENSION numrows)
|
||||
/* Allocate a 2-D coefficient-block array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
JBLOCKARRAY result;
|
||||
JBLOCKROW workspace;
|
||||
JDIMENSION rowsperchunk, currow, i;
|
||||
@ -508,27 +506,27 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
out_of_memory(cinfo, 6); /* safety check */
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
|
||||
((long) blocksperrow * sizeof(JBLOCK));
|
||||
ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
|
||||
((long)blocksperrow * sizeof(JBLOCK));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
if (ltemp < (long) numrows)
|
||||
rowsperchunk = (JDIMENSION) ltemp;
|
||||
if (ltemp < (long)numrows)
|
||||
rowsperchunk = (JDIMENSION)ltemp;
|
||||
else
|
||||
rowsperchunk = numrows;
|
||||
mem->last_rowsperchunk = rowsperchunk;
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * sizeof(JBLOCKROW)));
|
||||
result = (JBLOCKARRAY)alloc_small(cinfo, pool_id,
|
||||
(size_t)(numrows * sizeof(JBLOCKROW)));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
while (currow < numrows) {
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow
|
||||
* sizeof(JBLOCK)));
|
||||
workspace = (JBLOCKROW)alloc_large(cinfo, pool_id,
|
||||
(size_t)((size_t)rowsperchunk * (size_t)blocksperrow *
|
||||
sizeof(JBLOCK)));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += blocksperrow;
|
||||
@ -577,12 +575,12 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
|
||||
|
||||
METHODDEF(jvirt_sarray_ptr)
|
||||
request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
request_virt_sarray(j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
JDIMENSION samplesperrow, JDIMENSION numrows,
|
||||
JDIMENSION maxaccess)
|
||||
/* Request a virtual 2-D sample array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
jvirt_sarray_ptr result;
|
||||
|
||||
/* Only IMAGE-lifetime virtual arrays are currently supported */
|
||||
@ -590,7 +588,7 @@ request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
|
||||
|
||||
/* get control block */
|
||||
result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id,
|
||||
result = (jvirt_sarray_ptr)alloc_small(cinfo, pool_id,
|
||||
sizeof(struct jvirt_sarray_control));
|
||||
|
||||
result->mem_buffer = NULL; /* marks array not yet realized */
|
||||
@ -607,12 +605,12 @@ request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
|
||||
|
||||
METHODDEF(jvirt_barray_ptr)
|
||||
request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
request_virt_barray(j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
JDIMENSION blocksperrow, JDIMENSION numrows,
|
||||
JDIMENSION maxaccess)
|
||||
/* Request a virtual 2-D coefficient-block array */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
jvirt_barray_ptr result;
|
||||
|
||||
/* Only IMAGE-lifetime virtual arrays are currently supported */
|
||||
@ -620,7 +618,7 @@ request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
|
||||
|
||||
/* get control block */
|
||||
result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id,
|
||||
result = (jvirt_barray_ptr)alloc_small(cinfo, pool_id,
|
||||
sizeof(struct jvirt_barray_control));
|
||||
|
||||
result->mem_buffer = NULL; /* marks array not yet realized */
|
||||
@ -637,10 +635,10 @@ request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
realize_virt_arrays (j_common_ptr cinfo)
|
||||
realize_virt_arrays(j_common_ptr cinfo)
|
||||
/* Allocate the in-memory buffers for any unrealized virtual arrays */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
size_t space_per_minheight, maximum_space, avail_mem;
|
||||
size_t minheights, max_minheights;
|
||||
jvirt_sarray_ptr sptr;
|
||||
@ -654,11 +652,11 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
maximum_space = 0;
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
size_t new_space = (long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
size_t new_space = (long)sptr->rows_in_array *
|
||||
(long)sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
|
||||
space_per_minheight += (long) sptr->maxaccess *
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
space_per_minheight += (long)sptr->maxaccess *
|
||||
(long)sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
if (SIZE_MAX - maximum_space < new_space)
|
||||
out_of_memory(cinfo, 10);
|
||||
maximum_space += new_space;
|
||||
@ -666,11 +664,11 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
}
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
size_t new_space = (long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
size_t new_space = (long)bptr->rows_in_array *
|
||||
(long)bptr->blocksperrow * sizeof(JBLOCK);
|
||||
|
||||
space_per_minheight += (long) bptr->maxaccess *
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
space_per_minheight += (long)bptr->maxaccess *
|
||||
(long)bptr->blocksperrow * sizeof(JBLOCK);
|
||||
if (SIZE_MAX - maximum_space < new_space)
|
||||
out_of_memory(cinfo, 11);
|
||||
maximum_space += new_space;
|
||||
@ -703,17 +701,17 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;
|
||||
minheights = ((long)sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;
|
||||
if (minheights <= max_minheights) {
|
||||
/* This buffer fits in memory */
|
||||
sptr->rows_in_mem = sptr->rows_in_array;
|
||||
} else {
|
||||
/* It doesn't fit in memory, create backing store. */
|
||||
sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, & sptr->b_s_info,
|
||||
(long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow *
|
||||
(long) sizeof(JSAMPLE));
|
||||
sptr->rows_in_mem = (JDIMENSION)(max_minheights * sptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, &sptr->b_s_info,
|
||||
(long)sptr->rows_in_array *
|
||||
(long)sptr->samplesperrow *
|
||||
(long)sizeof(JSAMPLE));
|
||||
sptr->b_s_open = TRUE;
|
||||
}
|
||||
sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,
|
||||
@ -727,17 +725,17 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;
|
||||
minheights = ((long)bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;
|
||||
if (minheights <= max_minheights) {
|
||||
/* This buffer fits in memory */
|
||||
bptr->rows_in_mem = bptr->rows_in_array;
|
||||
} else {
|
||||
/* It doesn't fit in memory, create backing store. */
|
||||
bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, & bptr->b_s_info,
|
||||
(long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow *
|
||||
(long) sizeof(JBLOCK));
|
||||
bptr->rows_in_mem = (JDIMENSION)(max_minheights * bptr->maxaccess);
|
||||
jpeg_open_backing_store(cinfo, &bptr->b_s_info,
|
||||
(long)bptr->rows_in_array *
|
||||
(long)bptr->blocksperrow *
|
||||
(long)sizeof(JBLOCK));
|
||||
bptr->b_s_open = TRUE;
|
||||
}
|
||||
bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,
|
||||
@ -752,32 +750,32 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
/* Do backing store read or write of a virtual sample array */
|
||||
{
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
bytesperrow = (long)ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
for (i = 0; i < (long)ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
/* One chunk, but check for short chunk at end of buffer */
|
||||
rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i);
|
||||
rows = MIN((long)ptr->rowsperchunk, (long)ptr->rows_in_mem - i);
|
||||
/* Transfer no more than is currently defined */
|
||||
thisrow = (long) ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long) ptr->first_undef_row - thisrow);
|
||||
thisrow = (long)ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long)ptr->first_undef_row - thisrow);
|
||||
/* Transfer no more than fits in file */
|
||||
rows = MIN(rows, (long) ptr->rows_in_array - thisrow);
|
||||
rows = MIN(rows, (long)ptr->rows_in_array - thisrow);
|
||||
if (rows <= 0) /* this chunk might be past end of file! */
|
||||
break;
|
||||
byte_count = rows * bytesperrow;
|
||||
if (writing)
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
else
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
file_offset += byte_count;
|
||||
}
|
||||
@ -785,32 +783,32 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
do_barray_io(j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
/* Do backing store read or write of a virtual coefficient-block array */
|
||||
{
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->blocksperrow * sizeof(JBLOCK);
|
||||
bytesperrow = (long)ptr->blocksperrow * sizeof(JBLOCK);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
for (i = 0; i < (long)ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
/* One chunk, but check for short chunk at end of buffer */
|
||||
rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i);
|
||||
rows = MIN((long)ptr->rowsperchunk, (long)ptr->rows_in_mem - i);
|
||||
/* Transfer no more than is currently defined */
|
||||
thisrow = (long) ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long) ptr->first_undef_row - thisrow);
|
||||
thisrow = (long)ptr->cur_start_row + i;
|
||||
rows = MIN(rows, (long)ptr->first_undef_row - thisrow);
|
||||
/* Transfer no more than fits in file */
|
||||
rows = MIN(rows, (long) ptr->rows_in_array - thisrow);
|
||||
rows = MIN(rows, (long)ptr->rows_in_array - thisrow);
|
||||
if (rows <= 0) /* this chunk might be past end of file! */
|
||||
break;
|
||||
byte_count = rows * bytesperrow;
|
||||
if (writing)
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
else
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,
|
||||
(void *) ptr->mem_buffer[i],
|
||||
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
|
||||
(void *)ptr->mem_buffer[i],
|
||||
file_offset, byte_count);
|
||||
file_offset += byte_count;
|
||||
}
|
||||
@ -818,9 +816,8 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
|
||||
|
||||
METHODDEF(JSAMPARRAY)
|
||||
access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows,
|
||||
boolean writable)
|
||||
access_virt_sarray(j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows, boolean writable)
|
||||
/* Access the part of a virtual sample array starting at start_row */
|
||||
/* and extending for num_rows rows. writable is true if */
|
||||
/* caller intends to modify the accessed area. */
|
||||
@ -835,8 +832,8 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
|
||||
/* Make the desired part of the virtual array accessible */
|
||||
if (start_row < ptr->cur_start_row ||
|
||||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
|
||||
if (! ptr->b_s_open)
|
||||
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
|
||||
if (!ptr->b_s_open)
|
||||
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
|
||||
/* Flush old buffer contents if necessary */
|
||||
if (ptr->dirty) {
|
||||
@ -856,10 +853,10 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
/* use long arithmetic here to avoid overflow & unsigned problems */
|
||||
long ltemp;
|
||||
|
||||
ltemp = (long) end_row - (long) ptr->rows_in_mem;
|
||||
ltemp = (long)end_row - (long)ptr->rows_in_mem;
|
||||
if (ltemp < 0)
|
||||
ltemp = 0; /* don't fall off front end of file */
|
||||
ptr->cur_start_row = (JDIMENSION) ltemp;
|
||||
ptr->cur_start_row = (JDIMENSION)ltemp;
|
||||
}
|
||||
/* Read in the selected part of the array.
|
||||
* During the initial write pass, we will do no actual read
|
||||
@ -882,15 +879,15 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
if (writable)
|
||||
ptr->first_undef_row = end_row;
|
||||
if (ptr->pre_zero) {
|
||||
size_t bytesperrow = (size_t) ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
size_t bytesperrow = (size_t)ptr->samplesperrow * sizeof(JSAMPLE);
|
||||
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
|
||||
end_row -= ptr->cur_start_row;
|
||||
while (undef_row < end_row) {
|
||||
jzero_far((void *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
jzero_far((void *)ptr->mem_buffer[undef_row], bytesperrow);
|
||||
undef_row++;
|
||||
}
|
||||
} else {
|
||||
if (! writable) /* reader looking at undefined data */
|
||||
if (!writable) /* reader looking at undefined data */
|
||||
ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
|
||||
}
|
||||
}
|
||||
@ -903,9 +900,8 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
|
||||
|
||||
METHODDEF(JBLOCKARRAY)
|
||||
access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows,
|
||||
boolean writable)
|
||||
access_virt_barray(j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
JDIMENSION start_row, JDIMENSION num_rows, boolean writable)
|
||||
/* Access the part of a virtual block array starting at start_row */
|
||||
/* and extending for num_rows rows. writable is true if */
|
||||
/* caller intends to modify the accessed area. */
|
||||
@ -920,8 +916,8 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
|
||||
/* Make the desired part of the virtual array accessible */
|
||||
if (start_row < ptr->cur_start_row ||
|
||||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
|
||||
if (! ptr->b_s_open)
|
||||
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
|
||||
if (!ptr->b_s_open)
|
||||
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
|
||||
/* Flush old buffer contents if necessary */
|
||||
if (ptr->dirty) {
|
||||
@ -941,10 +937,10 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
/* use long arithmetic here to avoid overflow & unsigned problems */
|
||||
long ltemp;
|
||||
|
||||
ltemp = (long) end_row - (long) ptr->rows_in_mem;
|
||||
ltemp = (long)end_row - (long)ptr->rows_in_mem;
|
||||
if (ltemp < 0)
|
||||
ltemp = 0; /* don't fall off front end of file */
|
||||
ptr->cur_start_row = (JDIMENSION) ltemp;
|
||||
ptr->cur_start_row = (JDIMENSION)ltemp;
|
||||
}
|
||||
/* Read in the selected part of the array.
|
||||
* During the initial write pass, we will do no actual read
|
||||
@ -967,15 +963,15 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
if (writable)
|
||||
ptr->first_undef_row = end_row;
|
||||
if (ptr->pre_zero) {
|
||||
size_t bytesperrow = (size_t) ptr->blocksperrow * sizeof(JBLOCK);
|
||||
size_t bytesperrow = (size_t)ptr->blocksperrow * sizeof(JBLOCK);
|
||||
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
|
||||
end_row -= ptr->cur_start_row;
|
||||
while (undef_row < end_row) {
|
||||
jzero_far((void *) ptr->mem_buffer[undef_row], bytesperrow);
|
||||
jzero_far((void *)ptr->mem_buffer[undef_row], bytesperrow);
|
||||
undef_row++;
|
||||
}
|
||||
} else {
|
||||
if (! writable) /* reader looking at undefined data */
|
||||
if (!writable) /* reader looking at undefined data */
|
||||
ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);
|
||||
}
|
||||
}
|
||||
@ -992,9 +988,9 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
free_pool (j_common_ptr cinfo, int pool_id)
|
||||
free_pool(j_common_ptr cinfo, int pool_id)
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
|
||||
small_pool_ptr shdr_ptr;
|
||||
large_pool_ptr lhdr_ptr;
|
||||
size_t space_freed;
|
||||
@ -1015,14 +1011,14 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->b_s_open) { /* there may be no backing store */
|
||||
sptr->b_s_open = FALSE; /* prevent recursive close if error */
|
||||
(*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info);
|
||||
(*sptr->b_s_info.close_backing_store) (cinfo, &sptr->b_s_info);
|
||||
}
|
||||
}
|
||||
mem->virt_sarray_list = NULL;
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->b_s_open) { /* there may be no backing store */
|
||||
bptr->b_s_open = FALSE; /* prevent recursive close if error */
|
||||
(*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info);
|
||||
(*bptr->b_s_info.close_backing_store) (cinfo, &bptr->b_s_info);
|
||||
}
|
||||
}
|
||||
mem->virt_barray_list = NULL;
|
||||
@ -1037,7 +1033,7 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
||||
space_freed = lhdr_ptr->bytes_used +
|
||||
lhdr_ptr->bytes_left +
|
||||
sizeof(large_pool_hdr);
|
||||
jpeg_free_large(cinfo, (void *) lhdr_ptr, space_freed);
|
||||
jpeg_free_large(cinfo, (void *)lhdr_ptr, space_freed);
|
||||
mem->total_space_allocated -= space_freed;
|
||||
lhdr_ptr = next_lhdr_ptr;
|
||||
}
|
||||
@ -1048,10 +1044,9 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
||||
|
||||
while (shdr_ptr != NULL) {
|
||||
small_pool_ptr next_shdr_ptr = shdr_ptr->next;
|
||||
space_freed = shdr_ptr->bytes_used +
|
||||
shdr_ptr->bytes_left +
|
||||
space_freed = shdr_ptr->bytes_used + shdr_ptr->bytes_left +
|
||||
sizeof(small_pool_hdr);
|
||||
jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed);
|
||||
jpeg_free_small(cinfo, (void *)shdr_ptr, space_freed);
|
||||
mem->total_space_allocated -= space_freed;
|
||||
shdr_ptr = next_shdr_ptr;
|
||||
}
|
||||
@ -1064,7 +1059,7 @@ free_pool (j_common_ptr cinfo, int pool_id)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
self_destruct (j_common_ptr cinfo)
|
||||
self_destruct(j_common_ptr cinfo)
|
||||
{
|
||||
int pool;
|
||||
|
||||
@ -1072,12 +1067,12 @@ self_destruct (j_common_ptr cinfo)
|
||||
* Releasing pools in reverse order might help avoid fragmentation
|
||||
* with some (brain-damaged) malloc libraries.
|
||||
*/
|
||||
for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
free_pool(cinfo, pool);
|
||||
}
|
||||
|
||||
/* Release the memory manager control block too. */
|
||||
jpeg_free_small(cinfo, (void *) cinfo->mem, sizeof(my_memory_mgr));
|
||||
jpeg_free_small(cinfo, (void *)cinfo->mem, sizeof(my_memory_mgr));
|
||||
cinfo->mem = NULL; /* ensures I will be called only once */
|
||||
|
||||
jpeg_mem_term(cinfo); /* system-dependent cleanup */
|
||||
@ -1090,7 +1085,7 @@ self_destruct (j_common_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_memory_mgr (j_common_ptr cinfo)
|
||||
jinit_memory_mgr(j_common_ptr cinfo)
|
||||
{
|
||||
my_mem_ptr mem;
|
||||
long max_to_use;
|
||||
@ -1106,22 +1101,22 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
* in common if and only if X is a power of 2, ie has only one one-bit.
|
||||
* Some compilers may give an "unreachable code" warning here; ignore it.
|
||||
*/
|
||||
if ((ALIGN_SIZE & (ALIGN_SIZE-1)) != 0)
|
||||
if ((ALIGN_SIZE & (ALIGN_SIZE - 1)) != 0)
|
||||
ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE);
|
||||
/* MAX_ALLOC_CHUNK must be representable as type size_t, and must be
|
||||
* a multiple of ALIGN_SIZE.
|
||||
* Again, an "unreachable code" warning may be ignored here.
|
||||
* But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK.
|
||||
*/
|
||||
test_mac = (size_t) MAX_ALLOC_CHUNK;
|
||||
if ((long) test_mac != MAX_ALLOC_CHUNK ||
|
||||
test_mac = (size_t)MAX_ALLOC_CHUNK;
|
||||
if ((long)test_mac != MAX_ALLOC_CHUNK ||
|
||||
(MAX_ALLOC_CHUNK % ALIGN_SIZE) != 0)
|
||||
ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
|
||||
|
||||
max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */
|
||||
|
||||
/* Attempt to allocate memory manager's control block */
|
||||
mem = (my_mem_ptr) jpeg_get_small(cinfo, sizeof(my_memory_mgr));
|
||||
mem = (my_mem_ptr)jpeg_get_small(cinfo, sizeof(my_memory_mgr));
|
||||
|
||||
if (mem == NULL) {
|
||||
jpeg_mem_term(cinfo); /* system-dependent cleanup */
|
||||
@ -1147,7 +1142,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
/* Initialize working state */
|
||||
mem->pub.max_memory_to_use = max_to_use;
|
||||
|
||||
for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
for (pool = JPOOL_NUMPOOLS - 1; pool >= JPOOL_PERMANENT; pool--) {
|
||||
mem->small_list[pool] = NULL;
|
||||
mem->large_list[pool] = NULL;
|
||||
}
|
||||
@ -1157,7 +1152,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
mem->total_space_allocated = sizeof(my_memory_mgr);
|
||||
|
||||
/* Declare ourselves open for business */
|
||||
cinfo->mem = & mem->pub;
|
||||
cinfo->mem = &mem->pub;
|
||||
|
||||
/* Check for an environment variable JPEGMEM; if found, override the
|
||||
* default max_memory setting from jpeg_mem_init. Note that the
|
||||
@ -1166,7 +1161,8 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
* this feature.
|
||||
*/
|
||||
#ifndef NO_GETENV
|
||||
{ char *memenv;
|
||||
{
|
||||
char *memenv;
|
||||
|
||||
if ((memenv = getenv("JPEGMEM")) != NULL) {
|
||||
char ch = 'x';
|
||||
|
28
3rdparty/libjpeg-turbo/src/jmemnobs.c
vendored
28
3rdparty/libjpeg-turbo/src/jmemnobs.c
vendored
@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1992-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2017, D. R. Commander.
|
||||
* Copyright (C) 2017-2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@ -23,8 +23,8 @@
|
||||
#include "jmemsys.h" /* import the system-dependent declarations */
|
||||
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
||||
extern void *malloc (size_t size);
|
||||
extern void free (void *ptr);
|
||||
extern void *malloc(size_t size);
|
||||
extern void free(void *ptr);
|
||||
#endif
|
||||
|
||||
|
||||
@ -34,13 +34,13 @@ extern void free (void *ptr);
|
||||
*/
|
||||
|
||||
GLOBAL(void *)
|
||||
jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
|
||||
jpeg_get_small(j_common_ptr cinfo, size_t sizeofobject)
|
||||
{
|
||||
return (void *) malloc(sizeofobject);
|
||||
return (void *)malloc(sizeofobject);
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_free_small (j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
jpeg_free_small(j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
{
|
||||
free(object);
|
||||
}
|
||||
@ -51,13 +51,13 @@ jpeg_free_small (j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
*/
|
||||
|
||||
GLOBAL(void *)
|
||||
jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
|
||||
jpeg_get_large(j_common_ptr cinfo, size_t sizeofobject)
|
||||
{
|
||||
return (void *) malloc(sizeofobject);
|
||||
return (void *)malloc(sizeofobject);
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_free_large (j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
jpeg_free_large(j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
{
|
||||
free(object);
|
||||
}
|
||||
@ -68,11 +68,11 @@ jpeg_free_large (j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
*/
|
||||
|
||||
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)
|
||||
{
|
||||
if (cinfo->mem->max_memory_to_use) {
|
||||
if (cinfo->mem->max_memory_to_use > already_allocated)
|
||||
if ((size_t)cinfo->mem->max_memory_to_use > already_allocated)
|
||||
return cinfo->mem->max_memory_to_use - already_allocated;
|
||||
else
|
||||
return 0;
|
||||
@ -90,7 +90,7 @@ jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
|
||||
jpeg_open_backing_store(j_common_ptr cinfo, backing_store_ptr info,
|
||||
long total_bytes_needed)
|
||||
{
|
||||
ERREXIT(cinfo, JERR_NO_BACKING_STORE);
|
||||
@ -103,13 +103,13 @@ jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
|
||||
*/
|
||||
|
||||
GLOBAL(long)
|
||||
jpeg_mem_init (j_common_ptr cinfo)
|
||||
jpeg_mem_init(j_common_ptr cinfo)
|
||||
{
|
||||
return 0; /* just set max_memory_to_use to 0 */
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_term (j_common_ptr cinfo)
|
||||
jpeg_mem_term(j_common_ptr cinfo)
|
||||
{
|
||||
/* no work */
|
||||
}
|
||||
|
16
3rdparty/libjpeg-turbo/src/jmemsys.h
vendored
16
3rdparty/libjpeg-turbo/src/jmemsys.h
vendored
@ -31,8 +31,8 @@
|
||||
* size of the object being freed, just in case it's needed.
|
||||
*/
|
||||
|
||||
EXTERN(void *) jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject);
|
||||
EXTERN(void) jpeg_free_small (j_common_ptr cinfo, void *object,
|
||||
EXTERN(void *) jpeg_get_small(j_common_ptr cinfo, size_t sizeofobject);
|
||||
EXTERN(void) jpeg_free_small(j_common_ptr cinfo, void *object,
|
||||
size_t sizeofobject);
|
||||
|
||||
/*
|
||||
@ -43,8 +43,8 @@ EXTERN(void) jpeg_free_small (j_common_ptr cinfo, void *object,
|
||||
* large chunks.
|
||||
*/
|
||||
|
||||
EXTERN(void *) jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject);
|
||||
EXTERN(void) jpeg_free_large (j_common_ptr cinfo, void *object,
|
||||
EXTERN(void *) jpeg_get_large(j_common_ptr cinfo, size_t sizeofobject);
|
||||
EXTERN(void) jpeg_free_large(j_common_ptr cinfo, void *object,
|
||||
size_t sizeofobject);
|
||||
|
||||
/*
|
||||
@ -84,7 +84,7 @@ EXTERN(void) jpeg_free_large (j_common_ptr cinfo, void *object,
|
||||
* Conversely, zero may be returned to always use the minimum amount of memory.
|
||||
*/
|
||||
|
||||
EXTERN(size_t) jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
|
||||
EXTERN(size_t) jpeg_mem_available(j_common_ptr cinfo, size_t min_bytes_needed,
|
||||
size_t max_bytes_needed,
|
||||
size_t already_allocated);
|
||||
|
||||
@ -157,7 +157,7 @@ typedef struct backing_store_struct {
|
||||
* just take an error exit.)
|
||||
*/
|
||||
|
||||
EXTERN(void) jpeg_open_backing_store (j_common_ptr cinfo,
|
||||
EXTERN(void) jpeg_open_backing_store(j_common_ptr cinfo,
|
||||
backing_store_ptr info,
|
||||
long total_bytes_needed);
|
||||
|
||||
@ -174,5 +174,5 @@ EXTERN(void) jpeg_open_backing_store (j_common_ptr cinfo,
|
||||
* all opened backing-store objects have been closed.
|
||||
*/
|
||||
|
||||
EXTERN(long) jpeg_mem_init (j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_mem_term (j_common_ptr cinfo);
|
||||
EXTERN(long) jpeg_mem_init(j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_mem_term(j_common_ptr cinfo);
|
||||
|
26
3rdparty/libjpeg-turbo/src/jmorecfg.h
vendored
26
3rdparty/libjpeg-turbo/src/jmorecfg.h
vendored
@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, 2011, 2014-2015, D. R. Commander.
|
||||
* Copyright (C) 2009, 2011, 2014-2015, 2018, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@ -17,9 +17,9 @@
|
||||
|
||||
/*
|
||||
* Maximum number of components (color channels) allowed in JPEG image.
|
||||
* To meet the letter of the JPEG spec, set this to 255. However, darn
|
||||
* few applications need more than 4 channels (maybe 5 for CMYK + alpha
|
||||
* mask). We recommend 10 as a reasonable compromise; use 4 if you are
|
||||
* To meet the letter of Rec. ITU-T T.81 | ISO/IEC 10918-1, set this to 255.
|
||||
* However, darn few applications need more than 4 channels (maybe 5 for CMYK +
|
||||
* alpha mask). We recommend 10 as a reasonable compromise; use 4 if you are
|
||||
* really short on memory. (Each allowed component costs a hundred or so
|
||||
* bytes of storage, whether actually used in an image or not.)
|
||||
*/
|
||||
@ -49,15 +49,15 @@
|
||||
#ifdef HAVE_UNSIGNED_CHAR
|
||||
|
||||
typedef unsigned char JSAMPLE;
|
||||
#define GETJSAMPLE(value) ((int) (value))
|
||||
#define GETJSAMPLE(value) ((int)(value))
|
||||
|
||||
#else /* not HAVE_UNSIGNED_CHAR */
|
||||
|
||||
typedef char JSAMPLE;
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
#define GETJSAMPLE(value) ((int) (value))
|
||||
#define GETJSAMPLE(value) ((int)(value))
|
||||
#else
|
||||
#define GETJSAMPLE(value) ((int) (value) & 0xFF)
|
||||
#define GETJSAMPLE(value) ((int)(value) & 0xFF)
|
||||
#endif /* __CHAR_UNSIGNED__ */
|
||||
|
||||
#endif /* HAVE_UNSIGNED_CHAR */
|
||||
@ -74,7 +74,7 @@ typedef char JSAMPLE;
|
||||
*/
|
||||
|
||||
typedef short JSAMPLE;
|
||||
#define GETJSAMPLE(value) ((int) (value))
|
||||
#define GETJSAMPLE(value) ((int)(value))
|
||||
|
||||
#define MAXJSAMPLE 4095
|
||||
#define CENTERJSAMPLE 2048
|
||||
@ -220,7 +220,7 @@ typedef unsigned int JDIMENSION;
|
||||
* software out there that uses it.
|
||||
*/
|
||||
|
||||
#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
|
||||
#define JMETHOD(type, methodname, arglist) type (*methodname) arglist
|
||||
|
||||
|
||||
/* libjpeg-turbo no longer supports platforms that have far symbols (MS-DOS),
|
||||
@ -315,10 +315,10 @@ typedef int boolean;
|
||||
* with it. In reality, few people ever did this, because there were some
|
||||
* severe restrictions involved (cjpeg and djpeg no longer worked properly,
|
||||
* compressing/decompressing RGB JPEGs no longer worked properly, and the color
|
||||
* quantizer wouldn't work with pixel sizes other than 3.) Further, since all
|
||||
* of the O/S-supplied versions of libjpeg were built with the default values
|
||||
* of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications have
|
||||
* come to regard these values as immutable.
|
||||
* quantizer wouldn't work with pixel sizes other than 3.) Furthermore, since
|
||||
* all of the O/S-supplied versions of libjpeg were built with the default
|
||||
* values of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications
|
||||
* have come to regard these values as immutable.
|
||||
*
|
||||
* The libjpeg-turbo colorspace extensions provide a much cleaner way of
|
||||
* compressing from/decompressing to buffers with arbitrary component orders
|
||||
|
76
3rdparty/libjpeg-turbo/src/jpegint.h
vendored
76
3rdparty/libjpeg-turbo/src/jpegint.h
vendored
@ -274,9 +274,9 @@ struct jpeg_color_quantizer {
|
||||
/* Miscellaneous useful macros */
|
||||
|
||||
#undef MAX
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#undef MIN
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
|
||||
/* We assume that right shift corresponds to signed division by 2 with
|
||||
@ -291,64 +291,64 @@ struct jpeg_color_quantizer {
|
||||
|
||||
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
||||
#define SHIFT_TEMPS JLONG shift_temp;
|
||||
#define RIGHT_SHIFT(x,shft) \
|
||||
#define RIGHT_SHIFT(x, shft) \
|
||||
((shift_temp = (x)) < 0 ? \
|
||||
(shift_temp >> (shft)) | ((~((JLONG) 0)) << (32-(shft))) : \
|
||||
(shift_temp >> (shft)) | ((~((JLONG)0)) << (32 - (shft))) : \
|
||||
(shift_temp >> (shft)))
|
||||
#else
|
||||
#define SHIFT_TEMPS
|
||||
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||
#define RIGHT_SHIFT(x, shft) ((x) >> (shft))
|
||||
#endif
|
||||
|
||||
|
||||
/* Compression module initialization routines */
|
||||
EXTERN(void) jinit_compress_master (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_c_master_control (j_compress_ptr cinfo,
|
||||
EXTERN(void) jinit_compress_master(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_c_master_control(j_compress_ptr cinfo,
|
||||
boolean transcode_only);
|
||||
EXTERN(void) jinit_c_main_controller (j_compress_ptr cinfo,
|
||||
EXTERN(void) jinit_c_main_controller(j_compress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_c_prep_controller (j_compress_ptr cinfo,
|
||||
EXTERN(void) jinit_c_prep_controller(j_compress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_c_coef_controller (j_compress_ptr cinfo,
|
||||
EXTERN(void) jinit_c_coef_controller(j_compress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_color_converter (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_downsampler (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_forward_dct (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_huff_encoder (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_phuff_encoder (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_arith_encoder (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_marker_writer (j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_color_converter(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_downsampler(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_forward_dct(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_huff_encoder(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_phuff_encoder(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_arith_encoder(j_compress_ptr cinfo);
|
||||
EXTERN(void) jinit_marker_writer(j_compress_ptr cinfo);
|
||||
/* Decompression module initialization routines */
|
||||
EXTERN(void) jinit_master_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_d_main_controller (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jinit_master_decompress(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_d_main_controller(j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_d_coef_controller (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jinit_d_coef_controller(j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_d_post_controller (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jinit_d_post_controller(j_decompress_ptr cinfo,
|
||||
boolean need_full_buffer);
|
||||
EXTERN(void) jinit_input_controller (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_marker_reader (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_huff_decoder (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_phuff_decoder (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_arith_decoder (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_inverse_dct (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_upsampler (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_color_deconverter (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_1pass_quantizer (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_2pass_quantizer (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_merged_upsampler (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_input_controller(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_marker_reader(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_huff_decoder(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_phuff_decoder(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_arith_decoder(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_inverse_dct(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo);
|
||||
/* Memory manager initialization */
|
||||
EXTERN(void) jinit_memory_mgr (j_common_ptr cinfo);
|
||||
EXTERN(void) jinit_memory_mgr(j_common_ptr cinfo);
|
||||
|
||||
/* Utility routines in jutils.c */
|
||||
EXTERN(long) jdiv_round_up (long a, long b);
|
||||
EXTERN(long) jround_up (long a, long b);
|
||||
EXTERN(void) jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
EXTERN(long) jdiv_round_up(long a, long b);
|
||||
EXTERN(long) jround_up(long a, long b);
|
||||
EXTERN(void) jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
|
||||
JSAMPARRAY output_array, int dest_row,
|
||||
int num_rows, JDIMENSION num_cols);
|
||||
EXTERN(void) jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
EXTERN(void) jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
JDIMENSION num_blocks);
|
||||
EXTERN(void) jzero_far (void *target, size_t bytestozero);
|
||||
EXTERN(void) jzero_far(void *target, size_t bytestozero);
|
||||
/* Constant tables in jutils.c */
|
||||
#if 0 /* This table is not actually needed in v6a */
|
||||
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
|
||||
|
140
3rdparty/libjpeg-turbo/src/jpeglib.h
vendored
140
3rdparty/libjpeg-turbo/src/jpeglib.h
vendored
@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2002-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2013-2014, 2016-2017, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@ -268,11 +268,11 @@ typedef enum {
|
||||
/* Common fields between JPEG compression and decompression master structs. */
|
||||
|
||||
#define jpeg_common_fields \
|
||||
struct jpeg_error_mgr *err; /* Error handler module */\
|
||||
struct jpeg_memory_mgr *mem; /* Memory manager module */\
|
||||
struct jpeg_progress_mgr *progress; /* Progress monitor, or NULL if none */\
|
||||
void *client_data; /* Available for use by application */\
|
||||
boolean is_decompressor; /* So common code can tell which is which */\
|
||||
struct jpeg_error_mgr *err; /* Error handler module */ \
|
||||
struct jpeg_memory_mgr *mem; /* Memory manager module */ \
|
||||
struct jpeg_progress_mgr *progress; /* Progress monitor, or NULL if none */ \
|
||||
void *client_data; /* Available for use by application */ \
|
||||
boolean is_decompressor; /* So common code can tell which is which */ \
|
||||
int global_state /* For checking call sequence validity */
|
||||
|
||||
/* Routines that are to be used by both halves of the library are declared
|
||||
@ -888,7 +888,7 @@ typedef boolean (*jpeg_marker_parser_method) (j_decompress_ptr cinfo);
|
||||
|
||||
|
||||
/* Default error-management setup */
|
||||
EXTERN(struct jpeg_error_mgr *) jpeg_std_error (struct jpeg_error_mgr *err);
|
||||
EXTERN(struct jpeg_error_mgr *) jpeg_std_error(struct jpeg_error_mgr *err);
|
||||
|
||||
/* Initialization of JPEG compression objects.
|
||||
* jpeg_create_compress() and jpeg_create_decompress() are the exported
|
||||
@ -899,85 +899,90 @@ EXTERN(struct jpeg_error_mgr *) jpeg_std_error (struct jpeg_error_mgr *err);
|
||||
*/
|
||||
#define jpeg_create_compress(cinfo) \
|
||||
jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
|
||||
(size_t) sizeof(struct jpeg_compress_struct))
|
||||
(size_t)sizeof(struct jpeg_compress_struct))
|
||||
#define jpeg_create_decompress(cinfo) \
|
||||
jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
|
||||
(size_t) sizeof(struct jpeg_decompress_struct))
|
||||
EXTERN(void) jpeg_CreateCompress (j_compress_ptr cinfo, int version,
|
||||
(size_t)sizeof(struct jpeg_decompress_struct))
|
||||
EXTERN(void) jpeg_CreateCompress(j_compress_ptr cinfo, int version,
|
||||
size_t structsize);
|
||||
EXTERN(void) jpeg_CreateDecompress (j_decompress_ptr cinfo, int version,
|
||||
EXTERN(void) jpeg_CreateDecompress(j_decompress_ptr cinfo, int version,
|
||||
size_t structsize);
|
||||
/* Destruction of JPEG compression objects */
|
||||
EXTERN(void) jpeg_destroy_compress (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy_compress(j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy_decompress(j_decompress_ptr cinfo);
|
||||
|
||||
/* Standard data source and destination managers: stdio streams. */
|
||||
/* Caller is responsible for opening the file before and closing after. */
|
||||
EXTERN(void) jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile);
|
||||
EXTERN(void) jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile);
|
||||
EXTERN(void) jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile);
|
||||
EXTERN(void) jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile);
|
||||
|
||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||
/* Data source and destination managers: memory buffers. */
|
||||
EXTERN(void) jpeg_mem_dest (j_compress_ptr cinfo, unsigned char **outbuffer,
|
||||
EXTERN(void) jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
|
||||
unsigned long *outsize);
|
||||
EXTERN(void) jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
const unsigned char *inbuffer,
|
||||
unsigned long insize);
|
||||
EXTERN(void) jpeg_mem_src(j_decompress_ptr cinfo,
|
||||
const unsigned char *inbuffer, unsigned long insize);
|
||||
#endif
|
||||
|
||||
/* Default parameter setup for compression */
|
||||
EXTERN(void) jpeg_set_defaults (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_set_defaults(j_compress_ptr cinfo);
|
||||
/* Compression parameter setup aids */
|
||||
EXTERN(void) jpeg_set_colorspace (j_compress_ptr cinfo,
|
||||
EXTERN(void) jpeg_set_colorspace(j_compress_ptr cinfo,
|
||||
J_COLOR_SPACE colorspace);
|
||||
EXTERN(void) jpeg_default_colorspace (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_set_quality (j_compress_ptr cinfo, int quality,
|
||||
EXTERN(void) jpeg_default_colorspace(j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_set_quality(j_compress_ptr cinfo, int quality,
|
||||
boolean force_baseline);
|
||||
EXTERN(void) jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||
EXTERN(void) jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor,
|
||||
boolean force_baseline);
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
EXTERN(void) jpeg_default_qtables (j_compress_ptr cinfo,
|
||||
EXTERN(void) jpeg_default_qtables(j_compress_ptr cinfo,
|
||||
boolean force_baseline);
|
||||
#endif
|
||||
EXTERN(void) jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||
EXTERN(void) jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
|
||||
const unsigned int *basic_table,
|
||||
int scale_factor, boolean force_baseline);
|
||||
EXTERN(int) jpeg_quality_scaling (int quality);
|
||||
EXTERN(void) jpeg_simple_progression (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress);
|
||||
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table (j_common_ptr cinfo);
|
||||
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table (j_common_ptr cinfo);
|
||||
EXTERN(int) jpeg_quality_scaling(int quality);
|
||||
EXTERN(void) jpeg_simple_progression(j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress);
|
||||
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table(j_common_ptr cinfo);
|
||||
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table(j_common_ptr cinfo);
|
||||
|
||||
/* Main entry points for compression */
|
||||
EXTERN(void) jpeg_start_compress (j_compress_ptr cinfo,
|
||||
EXTERN(void) jpeg_start_compress(j_compress_ptr cinfo,
|
||||
boolean write_all_tables);
|
||||
EXTERN(JDIMENSION) jpeg_write_scanlines (j_compress_ptr cinfo,
|
||||
EXTERN(JDIMENSION) jpeg_write_scanlines(j_compress_ptr cinfo,
|
||||
JSAMPARRAY scanlines,
|
||||
JDIMENSION num_lines);
|
||||
EXTERN(void) jpeg_finish_compress (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_finish_compress(j_compress_ptr cinfo);
|
||||
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
/* Precalculate JPEG dimensions for current compression parameters. */
|
||||
EXTERN(void) jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo);
|
||||
#endif
|
||||
|
||||
/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
|
||||
EXTERN(JDIMENSION) jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
EXTERN(JDIMENSION) jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||
JDIMENSION num_lines);
|
||||
|
||||
/* Write a special marker. See libjpeg.txt concerning safe usage. */
|
||||
EXTERN(void) jpeg_write_marker (j_compress_ptr cinfo, int marker,
|
||||
EXTERN(void) jpeg_write_marker(j_compress_ptr cinfo, int marker,
|
||||
const JOCTET *dataptr, unsigned int datalen);
|
||||
/* Same, but piecemeal. */
|
||||
EXTERN(void) jpeg_write_m_header (j_compress_ptr cinfo, int marker,
|
||||
EXTERN(void) jpeg_write_m_header(j_compress_ptr cinfo, int marker,
|
||||
unsigned int datalen);
|
||||
EXTERN(void) jpeg_write_m_byte (j_compress_ptr cinfo, int val);
|
||||
EXTERN(void) jpeg_write_m_byte(j_compress_ptr cinfo, int val);
|
||||
|
||||
/* Alternate compression function: just write an abbreviated table file */
|
||||
EXTERN(void) jpeg_write_tables (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_write_tables(j_compress_ptr cinfo);
|
||||
|
||||
/* Write ICC profile. See libjpeg.txt for usage information. */
|
||||
EXTERN(void) jpeg_write_icc_profile(j_compress_ptr cinfo,
|
||||
const JOCTET *icc_data_ptr,
|
||||
unsigned int icc_data_len);
|
||||
|
||||
|
||||
/* Decompression startup: read start of JPEG datastream to see what's there */
|
||||
EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
|
||||
EXTERN(int) jpeg_read_header(j_decompress_ptr cinfo, boolean require_image);
|
||||
/* Return value is one of: */
|
||||
#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
|
||||
#define JPEG_HEADER_OK 1 /* Found valid image datastream */
|
||||
@ -989,27 +994,27 @@ EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
|
||||
*/
|
||||
|
||||
/* Main entry points for decompression */
|
||||
EXTERN(boolean) jpeg_start_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(JDIMENSION) jpeg_read_scanlines (j_decompress_ptr cinfo,
|
||||
EXTERN(boolean) jpeg_start_decompress(j_decompress_ptr cinfo);
|
||||
EXTERN(JDIMENSION) jpeg_read_scanlines(j_decompress_ptr cinfo,
|
||||
JSAMPARRAY scanlines,
|
||||
JDIMENSION max_lines);
|
||||
EXTERN(JDIMENSION) jpeg_skip_scanlines (j_decompress_ptr cinfo,
|
||||
EXTERN(JDIMENSION) jpeg_skip_scanlines(j_decompress_ptr cinfo,
|
||||
JDIMENSION num_lines);
|
||||
EXTERN(void) jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
EXTERN(void) jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
JDIMENSION *width);
|
||||
EXTERN(boolean) jpeg_finish_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_finish_decompress(j_decompress_ptr cinfo);
|
||||
|
||||
/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
|
||||
EXTERN(JDIMENSION) jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
EXTERN(JDIMENSION) jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||
JDIMENSION max_lines);
|
||||
|
||||
/* Additional entry points for buffered-image mode. */
|
||||
EXTERN(boolean) jpeg_has_multiple_scans (j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_start_output (j_decompress_ptr cinfo, int scan_number);
|
||||
EXTERN(boolean) jpeg_finish_output (j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_input_complete (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_new_colormap (j_decompress_ptr cinfo);
|
||||
EXTERN(int) jpeg_consume_input (j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_has_multiple_scans(j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_start_output(j_decompress_ptr cinfo, int scan_number);
|
||||
EXTERN(boolean) jpeg_finish_output(j_decompress_ptr cinfo);
|
||||
EXTERN(boolean) jpeg_input_complete(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_new_colormap(j_decompress_ptr cinfo);
|
||||
EXTERN(int) jpeg_consume_input(j_decompress_ptr cinfo);
|
||||
/* Return value is one of: */
|
||||
/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
|
||||
#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
|
||||
@ -1019,24 +1024,24 @@ EXTERN(int) jpeg_consume_input (j_decompress_ptr cinfo);
|
||||
|
||||
/* Precalculate output dimensions for current decompression parameters. */
|
||||
#if JPEG_LIB_VERSION >= 80
|
||||
EXTERN(void) jpeg_core_output_dimensions (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_core_output_dimensions(j_decompress_ptr cinfo);
|
||||
#endif
|
||||
EXTERN(void) jpeg_calc_output_dimensions (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_calc_output_dimensions(j_decompress_ptr cinfo);
|
||||
|
||||
/* Control saving of COM and APPn markers into marker_list. */
|
||||
EXTERN(void) jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||
EXTERN(void) jpeg_save_markers(j_decompress_ptr cinfo, int marker_code,
|
||||
unsigned int length_limit);
|
||||
|
||||
/* Install a special processing method for COM or APPn markers. */
|
||||
EXTERN(void) jpeg_set_marker_processor (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jpeg_set_marker_processor(j_decompress_ptr cinfo,
|
||||
int marker_code,
|
||||
jpeg_marker_parser_method routine);
|
||||
|
||||
/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
|
||||
EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_write_coefficients (j_compress_ptr cinfo,
|
||||
EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients(j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_write_coefficients(j_compress_ptr cinfo,
|
||||
jvirt_barray_ptr *coef_arrays);
|
||||
EXTERN(void) jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
EXTERN(void) jpeg_copy_critical_parameters(j_decompress_ptr srcinfo,
|
||||
j_compress_ptr dstinfo);
|
||||
|
||||
/* If you choose to abort compression or decompression before completing
|
||||
@ -1045,17 +1050,22 @@ EXTERN(void) jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
||||
* if you're done with the JPEG object, but if you want to clean it up and
|
||||
* reuse it, call this:
|
||||
*/
|
||||
EXTERN(void) jpeg_abort_compress (j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_abort_decompress (j_decompress_ptr cinfo);
|
||||
EXTERN(void) jpeg_abort_compress(j_compress_ptr cinfo);
|
||||
EXTERN(void) jpeg_abort_decompress(j_decompress_ptr cinfo);
|
||||
|
||||
/* Generic versions of jpeg_abort and jpeg_destroy that work on either
|
||||
* flavor of JPEG object. These may be more convenient in some places.
|
||||
*/
|
||||
EXTERN(void) jpeg_abort (j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy (j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_abort(j_common_ptr cinfo);
|
||||
EXTERN(void) jpeg_destroy(j_common_ptr cinfo);
|
||||
|
||||
/* Default restart-marker-resync procedure for use by data source modules */
|
||||
EXTERN(boolean) jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired);
|
||||
EXTERN(boolean) jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired);
|
||||
|
||||
/* Read ICC profile. See libjpeg.txt for usage information. */
|
||||
EXTERN(boolean) jpeg_read_icc_profile(j_decompress_ptr cinfo,
|
||||
JOCTET **icc_data_ptr,
|
||||
unsigned int *icc_data_len);
|
||||
|
||||
|
||||
/* These marker codes are exported since applications and data source modules
|
||||
|
178
3rdparty/libjpeg-turbo/src/jquant1.c
vendored
178
3rdparty/libjpeg-turbo/src/jquant1.c
vendored
@ -73,8 +73,9 @@
|
||||
|
||||
#define ODITHER_SIZE 16 /* dimension of dither matrix */
|
||||
/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */
|
||||
#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */
|
||||
#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */
|
||||
#define ODITHER_CELLS (ODITHER_SIZE * ODITHER_SIZE) /* # cells in matrix */
|
||||
#define ODITHER_MASK (ODITHER_SIZE - 1) /* mask for wrapping around
|
||||
counters */
|
||||
|
||||
typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE];
|
||||
typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE];
|
||||
@ -153,7 +154,7 @@ typedef struct {
|
||||
*/
|
||||
boolean is_padded; /* is the colorindex padded for odither? */
|
||||
|
||||
int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */
|
||||
int Ncolors[MAX_Q_COMPS]; /* # of values allocated to each component */
|
||||
|
||||
/* Variables for ordered dithering */
|
||||
int row_index; /* cur row's vertical index in dither matrix */
|
||||
@ -183,7 +184,7 @@ typedef my_cquantizer *my_cquantize_ptr;
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
|
||||
select_ncolors(j_decompress_ptr cinfo, int Ncolors[])
|
||||
/* Determine allocation of desired colors to components, */
|
||||
/* and fill in Ncolors[] array to indicate choice. */
|
||||
/* Return value is total number of colors (product of Ncolors[] values). */
|
||||
@ -206,12 +207,12 @@ select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
|
||||
temp = iroot; /* set temp = iroot ** nc */
|
||||
for (i = 1; i < nc; i++)
|
||||
temp *= iroot;
|
||||
} while (temp <= (long) max_colors); /* repeat till iroot exceeds root */
|
||||
} while (temp <= (long)max_colors); /* repeat till iroot exceeds root */
|
||||
iroot--; /* now iroot = floor(root) */
|
||||
|
||||
/* Must have at least 2 color values per component */
|
||||
if (iroot < 2)
|
||||
ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp);
|
||||
ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int)temp);
|
||||
|
||||
/* Initialize to iroot color values for each component */
|
||||
total_colors = 1;
|
||||
@ -231,11 +232,11 @@ select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
|
||||
j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i);
|
||||
/* calculate new total_colors if Ncolors[j] is incremented */
|
||||
temp = total_colors / Ncolors[j];
|
||||
temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */
|
||||
if (temp > (long) max_colors)
|
||||
temp *= Ncolors[j] + 1; /* done in long arith to avoid oflo */
|
||||
if (temp > (long)max_colors)
|
||||
break; /* won't fit, done with this pass */
|
||||
Ncolors[j]++; /* OK, apply the increment */
|
||||
total_colors = (int) temp;
|
||||
total_colors = (int)temp;
|
||||
changed = TRUE;
|
||||
}
|
||||
} while (changed);
|
||||
@ -245,7 +246,7 @@ select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
output_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
output_value(j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
/* Return j'th output value, where j will range from 0 to maxj */
|
||||
/* The output values must fall in 0..MAXJSAMPLE in increasing order */
|
||||
{
|
||||
@ -254,17 +255,17 @@ output_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
* (Forcing the upper and lower values to the limits ensures that
|
||||
* dithering can't produce a color outside the selected gamut.)
|
||||
*/
|
||||
return (int) (((JLONG) j * MAXJSAMPLE + maxj/2) / maxj);
|
||||
return (int)(((JLONG)j * MAXJSAMPLE + maxj / 2) / maxj);
|
||||
}
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
largest_input_value(j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
/* Return largest input value that should map to j'th output value */
|
||||
/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */
|
||||
{
|
||||
/* Breakpoints are halfway between values returned by output_value */
|
||||
return (int) (((JLONG) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj));
|
||||
return (int)(((JLONG)(2 * j + 1) * MAXJSAMPLE + maxj) / (2 * maxj));
|
||||
}
|
||||
|
||||
|
||||
@ -273,21 +274,21 @@ largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
create_colormap (j_decompress_ptr cinfo)
|
||||
create_colormap(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
JSAMPARRAY colormap; /* Created colormap */
|
||||
int total_colors; /* Number of distinct output colors */
|
||||
int i,j,k, nci, blksize, blkdist, ptr, val;
|
||||
int i, j, k, nci, blksize, blkdist, ptr, val;
|
||||
|
||||
/* Select number of colors for each component */
|
||||
total_colors = select_ncolors(cinfo, cquantize->Ncolors);
|
||||
|
||||
/* Report selected color counts */
|
||||
if (cinfo->out_color_components == 3)
|
||||
TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS,
|
||||
total_colors, cquantize->Ncolors[0],
|
||||
cquantize->Ncolors[1], cquantize->Ncolors[2]);
|
||||
TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, total_colors,
|
||||
cquantize->Ncolors[0], cquantize->Ncolors[1],
|
||||
cquantize->Ncolors[2]);
|
||||
else
|
||||
TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors);
|
||||
|
||||
@ -296,8 +297,8 @@ create_colormap (j_decompress_ptr cinfo)
|
||||
/* i.e. rightmost (highest-indexed) color changes most rapidly. */
|
||||
|
||||
colormap = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)total_colors, (JDIMENSION)cinfo->out_color_components);
|
||||
|
||||
/* blksize is number of adjacent repeated entries for a component */
|
||||
/* blkdist is distance between groups of identical entries for a component */
|
||||
@ -309,12 +310,12 @@ create_colormap (j_decompress_ptr cinfo)
|
||||
blksize = blkdist / nci;
|
||||
for (j = 0; j < nci; j++) {
|
||||
/* Compute j'th output value (out of nci) for component */
|
||||
val = output_value(cinfo, i, j, nci-1);
|
||||
val = output_value(cinfo, i, j, nci - 1);
|
||||
/* Fill in all colormap entries that have this value of this component */
|
||||
for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) {
|
||||
/* fill in blksize entries beginning at ptr */
|
||||
for (k = 0; k < blksize; k++)
|
||||
colormap[i][ptr+k] = (JSAMPLE) val;
|
||||
colormap[i][ptr + k] = (JSAMPLE)val;
|
||||
}
|
||||
}
|
||||
blkdist = blksize; /* blksize of this color is blkdist of next */
|
||||
@ -333,11 +334,11 @@ create_colormap (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
create_colorindex (j_decompress_ptr cinfo)
|
||||
create_colorindex(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
JSAMPROW indexptr;
|
||||
int i,j,k, nci, blksize, val, pad;
|
||||
int i, j, k, nci, blksize, val, pad;
|
||||
|
||||
/* For ordered dither, we pad the color index tables by MAXJSAMPLE in
|
||||
* each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE).
|
||||
@ -345,7 +346,7 @@ create_colorindex (j_decompress_ptr cinfo)
|
||||
* flag whether it was done in case user changes dithering mode.
|
||||
*/
|
||||
if (cinfo->dither_mode == JDITHER_ORDERED) {
|
||||
pad = MAXJSAMPLE*2;
|
||||
pad = MAXJSAMPLE * 2;
|
||||
cquantize->is_padded = TRUE;
|
||||
} else {
|
||||
pad = 0;
|
||||
@ -353,9 +354,9 @@ create_colorindex (j_decompress_ptr cinfo)
|
||||
}
|
||||
|
||||
cquantize->colorindex = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION) (MAXJSAMPLE+1 + pad),
|
||||
(JDIMENSION) cinfo->out_color_components);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(JDIMENSION)(MAXJSAMPLE + 1 + pad),
|
||||
(JDIMENSION)cinfo->out_color_components);
|
||||
|
||||
/* blksize is number of adjacent repeated entries for a component */
|
||||
blksize = cquantize->sv_actual;
|
||||
@ -373,18 +374,18 @@ create_colorindex (j_decompress_ptr cinfo)
|
||||
/* and k = largest j that maps to current val */
|
||||
indexptr = cquantize->colorindex[i];
|
||||
val = 0;
|
||||
k = largest_input_value(cinfo, i, 0, nci-1);
|
||||
k = largest_input_value(cinfo, i, 0, nci - 1);
|
||||
for (j = 0; j <= MAXJSAMPLE; j++) {
|
||||
while (j > k) /* advance val if past boundary */
|
||||
k = largest_input_value(cinfo, i, ++val, nci-1);
|
||||
k = largest_input_value(cinfo, i, ++val, nci - 1);
|
||||
/* premultiply so that no multiplication needed in main processing */
|
||||
indexptr[j] = (JSAMPLE) (val * blksize);
|
||||
indexptr[j] = (JSAMPLE)(val * blksize);
|
||||
}
|
||||
/* Pad at both ends if necessary */
|
||||
if (pad)
|
||||
for (j = 1; j <= MAXJSAMPLE; j++) {
|
||||
indexptr[-j] = indexptr[0];
|
||||
indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE];
|
||||
indexptr[MAXJSAMPLE + j] = indexptr[MAXJSAMPLE];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -396,29 +397,29 @@ create_colorindex (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
LOCAL(ODITHER_MATRIX_PTR)
|
||||
make_odither_array (j_decompress_ptr cinfo, int ncolors)
|
||||
make_odither_array(j_decompress_ptr cinfo, int ncolors)
|
||||
{
|
||||
ODITHER_MATRIX_PTR odither;
|
||||
int j,k;
|
||||
JLONG num,den;
|
||||
int j, k;
|
||||
JLONG num, den;
|
||||
|
||||
odither = (ODITHER_MATRIX_PTR)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(ODITHER_MATRIX));
|
||||
/* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1).
|
||||
* Hence the dither value for the matrix cell with fill order f
|
||||
* (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1).
|
||||
* On 16-bit-int machine, be careful to avoid overflow.
|
||||
*/
|
||||
den = 2 * ODITHER_CELLS * ((JLONG) (ncolors - 1));
|
||||
den = 2 * ODITHER_CELLS * ((JLONG)(ncolors - 1));
|
||||
for (j = 0; j < ODITHER_SIZE; j++) {
|
||||
for (k = 0; k < ODITHER_SIZE; k++) {
|
||||
num = ((JLONG) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k])))
|
||||
* MAXJSAMPLE;
|
||||
num = ((JLONG)(ODITHER_CELLS - 1 -
|
||||
2 * ((int)base_dither_matrix[j][k]))) * MAXJSAMPLE;
|
||||
/* Ensure round towards zero despite C's lack of consistency
|
||||
* about rounding negative values in integer division...
|
||||
*/
|
||||
odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den);
|
||||
odither[j][k] = (int)(num < 0 ? -((-num) / den) : num / den);
|
||||
}
|
||||
}
|
||||
return odither;
|
||||
@ -432,9 +433,9 @@ make_odither_array (j_decompress_ptr cinfo, int ncolors)
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
create_odither_tables (j_decompress_ptr cinfo)
|
||||
create_odither_tables(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
ODITHER_MATRIX_PTR odither;
|
||||
int i, j, nci;
|
||||
|
||||
@ -459,11 +460,11 @@ create_odither_tables (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
color_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* General case, no dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
JSAMPARRAY colorindex = cquantize->colorindex;
|
||||
register int pixcode, ci;
|
||||
register JSAMPROW ptrin, ptrout;
|
||||
@ -480,18 +481,18 @@ color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]);
|
||||
}
|
||||
*ptrout++ = (JSAMPLE) pixcode;
|
||||
*ptrout++ = (JSAMPLE)pixcode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
color_quantize3(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* Fast path for out_color_components==3, no dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
register int pixcode;
|
||||
register JSAMPROW ptrin, ptrout;
|
||||
JSAMPROW colorindex0 = cquantize->colorindex[0];
|
||||
@ -508,18 +509,18 @@ color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]);
|
||||
pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]);
|
||||
pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]);
|
||||
*ptrout++ = (JSAMPLE) pixcode;
|
||||
*ptrout++ = (JSAMPLE)pixcode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
quantize_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* General case, with ordered dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
register JSAMPROW input_ptr;
|
||||
register JSAMPROW output_ptr;
|
||||
JSAMPROW colorindex_ci;
|
||||
@ -533,7 +534,7 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
for (row = 0; row < num_rows; row++) {
|
||||
/* Initialize output values to 0 so can process components separately */
|
||||
jzero_far((void *) output_buf[row], (size_t) (width * sizeof(JSAMPLE)));
|
||||
jzero_far((void *)output_buf[row], (size_t)(width * sizeof(JSAMPLE)));
|
||||
row_index = cquantize->row_index;
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
input_ptr = input_buf[row] + ci;
|
||||
@ -550,7 +551,8 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
* inputs. The maximum dither is +- MAXJSAMPLE; this sets the
|
||||
* required amount of padding.
|
||||
*/
|
||||
*output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]];
|
||||
*output_ptr +=
|
||||
colorindex_ci[GETJSAMPLE(*input_ptr) + dither[col_index]];
|
||||
input_ptr += nc;
|
||||
output_ptr++;
|
||||
col_index = (col_index + 1) & ODITHER_MASK;
|
||||
@ -564,11 +566,11 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
quantize3_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* Fast path for out_color_components==3, with ordered dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
register int pixcode;
|
||||
register JSAMPROW input_ptr;
|
||||
register JSAMPROW output_ptr;
|
||||
@ -593,13 +595,13 @@ quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
col_index = 0;
|
||||
|
||||
for (col = width; col > 0; col--) {
|
||||
pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) +
|
||||
dither0[col_index]]);
|
||||
pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) +
|
||||
dither1[col_index]]);
|
||||
pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) +
|
||||
dither2[col_index]]);
|
||||
*output_ptr++ = (JSAMPLE) pixcode;
|
||||
pixcode =
|
||||
GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + dither0[col_index]]);
|
||||
pixcode +=
|
||||
GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + dither1[col_index]]);
|
||||
pixcode +=
|
||||
GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + dither2[col_index]]);
|
||||
*output_ptr++ = (JSAMPLE)pixcode;
|
||||
col_index = (col_index + 1) & ODITHER_MASK;
|
||||
}
|
||||
row_index = (row_index + 1) & ODITHER_MASK;
|
||||
@ -609,11 +611,11 @@ quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
quantize_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* General case, with Floyd-Steinberg dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
register LOCFSERROR cur; /* current error or pixel value */
|
||||
LOCFSERROR belowerr; /* error for pixel below cur */
|
||||
LOCFSERROR bpreverr; /* error for below/prev col */
|
||||
@ -637,17 +639,17 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
|
||||
for (row = 0; row < num_rows; row++) {
|
||||
/* Initialize output values to 0 so can process components separately */
|
||||
jzero_far((void *) output_buf[row], (size_t) (width * sizeof(JSAMPLE)));
|
||||
jzero_far((void *)output_buf[row], (size_t)(width * sizeof(JSAMPLE)));
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
input_ptr = input_buf[row] + ci;
|
||||
output_ptr = output_buf[row];
|
||||
if (cquantize->on_odd_row) {
|
||||
/* work right to left in this row */
|
||||
input_ptr += (width-1) * nc; /* so point to rightmost pixel */
|
||||
output_ptr += width-1;
|
||||
input_ptr += (width - 1) * nc; /* so point to rightmost pixel */
|
||||
output_ptr += width - 1;
|
||||
dir = -1;
|
||||
dirnc = -nc;
|
||||
errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */
|
||||
errorptr = cquantize->fserrors[ci] + (width + 1); /* => entry after last column */
|
||||
} else {
|
||||
/* work left to right in this row */
|
||||
dir = 1;
|
||||
@ -679,7 +681,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
cur = GETJSAMPLE(range_limit[cur]);
|
||||
/* Select output value, accumulate into output code for this pixel */
|
||||
pixcode = GETJSAMPLE(colorindex_ci[cur]);
|
||||
*output_ptr += (JSAMPLE) pixcode;
|
||||
*output_ptr += (JSAMPLE)pixcode;
|
||||
/* Compute actual representation error at this pixel */
|
||||
/* Note: we can do this even though we don't have the final */
|
||||
/* pixel code, because the colormap is orthogonal. */
|
||||
@ -691,7 +693,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
bnexterr = cur;
|
||||
delta = cur * 2;
|
||||
cur += delta; /* form error * 3 */
|
||||
errorptr[0] = (FSERROR) (bpreverr + cur);
|
||||
errorptr[0] = (FSERROR)(bpreverr + cur);
|
||||
cur += delta; /* form error * 5 */
|
||||
bpreverr = belowerr + cur;
|
||||
belowerr = bnexterr;
|
||||
@ -708,7 +710,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
* final fserrors[] entry. Note we need not unload belowerr because
|
||||
* it is for the dummy column before or after the actual array.
|
||||
*/
|
||||
errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */
|
||||
errorptr[0] = (FSERROR)bpreverr; /* unload prev err into array */
|
||||
}
|
||||
cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE);
|
||||
}
|
||||
@ -720,16 +722,16 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
alloc_fs_workspace (j_decompress_ptr cinfo)
|
||||
alloc_fs_workspace(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
size_t arraysize;
|
||||
int i;
|
||||
|
||||
arraysize = (size_t) ((cinfo->output_width + 2) * sizeof(FSERROR));
|
||||
arraysize = (size_t)((cinfo->output_width + 2) * sizeof(FSERROR));
|
||||
for (i = 0; i < cinfo->out_color_components; i++) {
|
||||
cquantize->fserrors[i] = (FSERRPTR)
|
||||
(*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE, arraysize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,9 +741,9 @@ alloc_fs_workspace (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
start_pass_1_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
size_t arraysize;
|
||||
int i;
|
||||
|
||||
@ -767,7 +769,7 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
* we must recreate the color index table with padding.
|
||||
* This will cost extra space, but probably isn't very likely.
|
||||
*/
|
||||
if (! cquantize->is_padded)
|
||||
if (!cquantize->is_padded)
|
||||
create_colorindex(cinfo);
|
||||
/* Create ordered-dither tables if we didn't already. */
|
||||
if (cquantize->odither[0] == NULL)
|
||||
@ -780,9 +782,9 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
if (cquantize->fserrors[0] == NULL)
|
||||
alloc_fs_workspace(cinfo);
|
||||
/* Initialize the propagated errors to zero. */
|
||||
arraysize = (size_t) ((cinfo->output_width + 2) * sizeof(FSERROR));
|
||||
arraysize = (size_t)((cinfo->output_width + 2) * sizeof(FSERROR));
|
||||
for (i = 0; i < cinfo->out_color_components; i++)
|
||||
jzero_far((void *) cquantize->fserrors[i], arraysize);
|
||||
jzero_far((void *)cquantize->fserrors[i], arraysize);
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||
@ -796,7 +798,7 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass_1_quant (j_decompress_ptr cinfo)
|
||||
finish_pass_1_quant(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work in 1-pass case */
|
||||
}
|
||||
@ -808,7 +810,7 @@ finish_pass_1_quant (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
new_color_map_1_quant (j_decompress_ptr cinfo)
|
||||
new_color_map_1_quant(j_decompress_ptr cinfo)
|
||||
{
|
||||
ERREXIT(cinfo, JERR_MODE_CHANGE);
|
||||
}
|
||||
@ -819,14 +821,14 @@ new_color_map_1_quant (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_1pass_quantizer (j_decompress_ptr cinfo)
|
||||
jinit_1pass_quantizer(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize;
|
||||
|
||||
cquantize = (my_cquantize_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_cquantizer));
|
||||
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
|
||||
cinfo->cquantize = (struct jpeg_color_quantizer *)cquantize;
|
||||
cquantize->pub.start_pass = start_pass_1_quant;
|
||||
cquantize->pub.finish_pass = finish_pass_1_quant;
|
||||
cquantize->pub.new_color_map = new_color_map_1_quant;
|
||||
@ -837,8 +839,8 @@ jinit_1pass_quantizer (j_decompress_ptr cinfo)
|
||||
if (cinfo->out_color_components > MAX_Q_COMPS)
|
||||
ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS);
|
||||
/* Make sure colormap indexes can be represented by JSAMPLEs */
|
||||
if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1))
|
||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1);
|
||||
if (cinfo->desired_number_of_colors > (MAXJSAMPLE + 1))
|
||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE + 1);
|
||||
|
||||
/* Create the colormap and color index table. */
|
||||
create_colormap(cinfo);
|
||||
|
313
3rdparty/libjpeg-turbo/src/jquant2.c
vendored
313
3rdparty/libjpeg-turbo/src/jquant2.c
vendored
@ -77,7 +77,7 @@
|
||||
#define G_SCALE 3 /* scale G distances by this much */
|
||||
#define B_SCALE 1 /* and B by this much */
|
||||
|
||||
static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE};
|
||||
static const int c_scales[3] = { R_SCALE, G_SCALE, B_SCALE };
|
||||
#define C0_SCALE c_scales[rgb_red[cinfo->out_color_space]]
|
||||
#define C1_SCALE c_scales[rgb_green[cinfo->out_color_space]]
|
||||
#define C2_SCALE c_scales[rgb_blue[cinfo->out_color_space]]
|
||||
@ -106,7 +106,7 @@ static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE};
|
||||
* each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries.
|
||||
*/
|
||||
|
||||
#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */
|
||||
#define MAXNUMCOLORS (MAXJSAMPLE + 1) /* maximum size of colormap */
|
||||
|
||||
/* These will do the right thing for either R,G,B or B,G,R color order,
|
||||
* but you may not like the results for other color orders.
|
||||
@ -116,14 +116,14 @@ static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE};
|
||||
#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */
|
||||
|
||||
/* Number of elements along histogram axes. */
|
||||
#define HIST_C0_ELEMS (1<<HIST_C0_BITS)
|
||||
#define HIST_C1_ELEMS (1<<HIST_C1_BITS)
|
||||
#define HIST_C2_ELEMS (1<<HIST_C2_BITS)
|
||||
#define HIST_C0_ELEMS (1 << HIST_C0_BITS)
|
||||
#define HIST_C1_ELEMS (1 << HIST_C1_BITS)
|
||||
#define HIST_C2_ELEMS (1 << HIST_C2_BITS)
|
||||
|
||||
/* These are the amounts to shift an input value to get a histogram index. */
|
||||
#define C0_SHIFT (BITS_IN_JSAMPLE-HIST_C0_BITS)
|
||||
#define C1_SHIFT (BITS_IN_JSAMPLE-HIST_C1_BITS)
|
||||
#define C2_SHIFT (BITS_IN_JSAMPLE-HIST_C2_BITS)
|
||||
#define C0_SHIFT (BITS_IN_JSAMPLE - HIST_C0_BITS)
|
||||
#define C1_SHIFT (BITS_IN_JSAMPLE - HIST_C1_BITS)
|
||||
#define C2_SHIFT (BITS_IN_JSAMPLE - HIST_C2_BITS)
|
||||
|
||||
|
||||
typedef UINT16 histcell; /* histogram cell; prefer an unsigned type */
|
||||
@ -200,10 +200,10 @@ typedef my_cquantizer *my_cquantize_ptr;
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
prescan_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
register JSAMPROW ptr;
|
||||
register histptr histp;
|
||||
register hist3d histogram = cquantize->histogram;
|
||||
@ -215,7 +215,7 @@ prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
ptr = input_buf[row];
|
||||
for (col = width; col > 0; col--) {
|
||||
/* get pixel value and index into the histogram */
|
||||
histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT]
|
||||
histp = &histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT]
|
||||
[GETJSAMPLE(ptr[1]) >> C1_SHIFT]
|
||||
[GETJSAMPLE(ptr[2]) >> C2_SHIFT];
|
||||
/* increment, check for overflow and undo increment if so. */
|
||||
@ -249,7 +249,7 @@ typedef box *boxptr;
|
||||
|
||||
|
||||
LOCAL(boxptr)
|
||||
find_biggest_color_pop (boxptr boxlist, int numboxes)
|
||||
find_biggest_color_pop(boxptr boxlist, int numboxes)
|
||||
/* Find the splittable box with the largest color population */
|
||||
/* Returns NULL if no splittable boxes remain */
|
||||
{
|
||||
@ -269,7 +269,7 @@ find_biggest_color_pop (boxptr boxlist, int numboxes)
|
||||
|
||||
|
||||
LOCAL(boxptr)
|
||||
find_biggest_volume (boxptr boxlist, int numboxes)
|
||||
find_biggest_volume(boxptr boxlist, int numboxes)
|
||||
/* Find the splittable box with the largest (scaled) volume */
|
||||
/* Returns NULL if no splittable boxes remain */
|
||||
{
|
||||
@ -289,16 +289,16 @@ find_biggest_volume (boxptr boxlist, int numboxes)
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
update_box (j_decompress_ptr cinfo, boxptr boxp)
|
||||
update_box(j_decompress_ptr cinfo, boxptr boxp)
|
||||
/* Shrink the min/max bounds of a box to enclose only nonzero elements, */
|
||||
/* and recompute its volume and population */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
histptr histp;
|
||||
int c0,c1,c2;
|
||||
int c0min,c0max,c1min,c1max,c2min,c2max;
|
||||
JLONG dist0,dist1,dist2;
|
||||
int c0, c1, c2;
|
||||
int c0min, c0max, c1min, c1max, c2min, c2max;
|
||||
JLONG dist0, dist1, dist2;
|
||||
long ccount;
|
||||
|
||||
c0min = boxp->c0min; c0max = boxp->c0max;
|
||||
@ -308,69 +308,69 @@ update_box (j_decompress_ptr cinfo, boxptr boxp)
|
||||
if (c0max > c0min)
|
||||
for (c0 = c0min; c0 <= c0max; c0++)
|
||||
for (c1 = c1min; c1 <= c1max; c1++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++)
|
||||
if (*histp++ != 0) {
|
||||
boxp->c0min = c0min = c0;
|
||||
goto have_c0min;
|
||||
}
|
||||
}
|
||||
have_c0min:
|
||||
have_c0min:
|
||||
if (c0max > c0min)
|
||||
for (c0 = c0max; c0 >= c0min; c0--)
|
||||
for (c1 = c1min; c1 <= c1max; c1++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++)
|
||||
if (*histp++ != 0) {
|
||||
boxp->c0max = c0max = c0;
|
||||
goto have_c0max;
|
||||
}
|
||||
}
|
||||
have_c0max:
|
||||
have_c0max:
|
||||
if (c1max > c1min)
|
||||
for (c1 = c1min; c1 <= c1max; c1++)
|
||||
for (c0 = c0min; c0 <= c0max; c0++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++)
|
||||
if (*histp++ != 0) {
|
||||
boxp->c1min = c1min = c1;
|
||||
goto have_c1min;
|
||||
}
|
||||
}
|
||||
have_c1min:
|
||||
have_c1min:
|
||||
if (c1max > c1min)
|
||||
for (c1 = c1max; c1 >= c1min; c1--)
|
||||
for (c0 = c0min; c0 <= c0max; c0++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++)
|
||||
if (*histp++ != 0) {
|
||||
boxp->c1max = c1max = c1;
|
||||
goto have_c1max;
|
||||
}
|
||||
}
|
||||
have_c1max:
|
||||
have_c1max:
|
||||
if (c2max > c2min)
|
||||
for (c2 = c2min; c2 <= c2max; c2++)
|
||||
for (c0 = c0min; c0 <= c0max; c0++) {
|
||||
histp = & histogram[c0][c1min][c2];
|
||||
histp = &histogram[c0][c1min][c2];
|
||||
for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)
|
||||
if (*histp != 0) {
|
||||
boxp->c2min = c2min = c2;
|
||||
goto have_c2min;
|
||||
}
|
||||
}
|
||||
have_c2min:
|
||||
have_c2min:
|
||||
if (c2max > c2min)
|
||||
for (c2 = c2max; c2 >= c2min; c2--)
|
||||
for (c0 = c0min; c0 <= c0max; c0++) {
|
||||
histp = & histogram[c0][c1min][c2];
|
||||
histp = &histogram[c0][c1min][c2];
|
||||
for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)
|
||||
if (*histp != 0) {
|
||||
boxp->c2max = c2max = c2;
|
||||
goto have_c2max;
|
||||
}
|
||||
}
|
||||
have_c2max:
|
||||
have_c2max:
|
||||
|
||||
/* Update box volume.
|
||||
* We use 2-norm rather than real volume here; this biases the method
|
||||
@ -383,13 +383,13 @@ update_box (j_decompress_ptr cinfo, boxptr boxp)
|
||||
dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE;
|
||||
dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE;
|
||||
dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE;
|
||||
boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2;
|
||||
boxp->volume = dist0 * dist0 + dist1 * dist1 + dist2 * dist2;
|
||||
|
||||
/* Now scan remaining volume of box and compute population */
|
||||
ccount = 0;
|
||||
for (c0 = c0min; c0 <= c0max; c0++)
|
||||
for (c1 = c1min; c1 <= c1max; c1++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++, histp++)
|
||||
if (*histp != 0) {
|
||||
ccount++;
|
||||
@ -400,19 +400,19 @@ update_box (j_decompress_ptr cinfo, boxptr boxp)
|
||||
|
||||
|
||||
LOCAL(int)
|
||||
median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
|
||||
median_cut(j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
|
||||
int desired_colors)
|
||||
/* Repeatedly select and split the largest box until we have enough boxes */
|
||||
{
|
||||
int n,lb;
|
||||
int c0,c1,c2,cmax;
|
||||
register boxptr b1,b2;
|
||||
int n, lb;
|
||||
int c0, c1, c2, cmax;
|
||||
register boxptr b1, b2;
|
||||
|
||||
while (numboxes < desired_colors) {
|
||||
/* Select box to split.
|
||||
* Current algorithm: by population for first half, then by volume.
|
||||
*/
|
||||
if (numboxes*2 <= desired_colors) {
|
||||
if (numboxes * 2 <= desired_colors) {
|
||||
b1 = find_biggest_color_pop(boxlist, numboxes);
|
||||
} else {
|
||||
b1 = find_biggest_volume(boxlist, numboxes);
|
||||
@ -437,8 +437,7 @@ median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
|
||||
cmax = c1; n = 1;
|
||||
if (c0 > cmax) { cmax = c0; n = 0; }
|
||||
if (c2 > cmax) { n = 2; }
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
cmax = c1; n = 1;
|
||||
if (c2 > cmax) { cmax = c2; n = 2; }
|
||||
if (c0 > cmax) { n = 0; }
|
||||
@ -453,17 +452,17 @@ median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
|
||||
case 0:
|
||||
lb = (b1->c0max + b1->c0min) / 2;
|
||||
b1->c0max = lb;
|
||||
b2->c0min = lb+1;
|
||||
b2->c0min = lb + 1;
|
||||
break;
|
||||
case 1:
|
||||
lb = (b1->c1max + b1->c1min) / 2;
|
||||
b1->c1max = lb;
|
||||
b2->c1min = lb+1;
|
||||
b2->c1min = lb + 1;
|
||||
break;
|
||||
case 2:
|
||||
lb = (b1->c2max + b1->c2min) / 2;
|
||||
b1->c2max = lb;
|
||||
b2->c2min = lb+1;
|
||||
b2->c2min = lb + 1;
|
||||
break;
|
||||
}
|
||||
/* Update stats for boxes */
|
||||
@ -476,16 +475,16 @@ median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor)
|
||||
compute_color(j_decompress_ptr cinfo, boxptr boxp, int icolor)
|
||||
/* Compute representative color for a box, put it in colormap[icolor] */
|
||||
{
|
||||
/* Current algorithm: mean weighted by pixels (not colors) */
|
||||
/* Note it is important to get the rounding correct! */
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
histptr histp;
|
||||
int c0,c1,c2;
|
||||
int c0min,c0max,c1min,c1max,c2min,c2max;
|
||||
int c0, c1, c2;
|
||||
int c0min, c0max, c1min, c1max, c2min, c2max;
|
||||
long count;
|
||||
long total = 0;
|
||||
long c0total = 0;
|
||||
@ -498,25 +497,25 @@ compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor)
|
||||
|
||||
for (c0 = c0min; c0 <= c0max; c0++)
|
||||
for (c1 = c1min; c1 <= c1max; c1++) {
|
||||
histp = & histogram[c0][c1][c2min];
|
||||
histp = &histogram[c0][c1][c2min];
|
||||
for (c2 = c2min; c2 <= c2max; c2++) {
|
||||
if ((count = *histp++) != 0) {
|
||||
total += count;
|
||||
c0total += ((c0 << C0_SHIFT) + ((1<<C0_SHIFT)>>1)) * count;
|
||||
c1total += ((c1 << C1_SHIFT) + ((1<<C1_SHIFT)>>1)) * count;
|
||||
c2total += ((c2 << C2_SHIFT) + ((1<<C2_SHIFT)>>1)) * count;
|
||||
c0total += ((c0 << C0_SHIFT) + ((1 << C0_SHIFT) >> 1)) * count;
|
||||
c1total += ((c1 << C1_SHIFT) + ((1 << C1_SHIFT) >> 1)) * count;
|
||||
c2total += ((c2 << C2_SHIFT) + ((1 << C2_SHIFT) >> 1)) * count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total);
|
||||
cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total);
|
||||
cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total);
|
||||
cinfo->colormap[0][icolor] = (JSAMPLE)((c0total + (total >> 1)) / total);
|
||||
cinfo->colormap[1][icolor] = (JSAMPLE)((c1total + (total >> 1)) / total);
|
||||
cinfo->colormap[2][icolor] = (JSAMPLE)((c2total + (total >> 1)) / total);
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
select_colors(j_decompress_ptr cinfo, int desired_colors)
|
||||
/* Master routine for color selection */
|
||||
{
|
||||
boxptr boxlist;
|
||||
@ -524,8 +523,8 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
int i;
|
||||
|
||||
/* Allocate workspace for box list */
|
||||
boxlist = (boxptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * sizeof(box));
|
||||
boxlist = (boxptr)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, desired_colors * sizeof(box));
|
||||
/* Initialize one box containing whole space */
|
||||
numboxes = 1;
|
||||
boxlist[0].c0min = 0;
|
||||
@ -535,12 +534,12 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
boxlist[0].c2min = 0;
|
||||
boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT;
|
||||
/* Shrink it to actually-used volume and set its statistics */
|
||||
update_box(cinfo, & boxlist[0]);
|
||||
update_box(cinfo, &boxlist[0]);
|
||||
/* Perform median-cut to produce final box list */
|
||||
numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors);
|
||||
/* Compute the representative color for each box, fill colormap */
|
||||
for (i = 0; i < numboxes; i++)
|
||||
compute_color(cinfo, & boxlist[i], i);
|
||||
compute_color(cinfo, &boxlist[i], i);
|
||||
cinfo->actual_number_of_colors = numboxes;
|
||||
TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes);
|
||||
}
|
||||
@ -601,13 +600,13 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
|
||||
|
||||
/* log2(histogram cells in update box) for each axis; this can be adjusted */
|
||||
#define BOX_C0_LOG (HIST_C0_BITS-3)
|
||||
#define BOX_C1_LOG (HIST_C1_BITS-3)
|
||||
#define BOX_C2_LOG (HIST_C2_BITS-3)
|
||||
#define BOX_C0_LOG (HIST_C0_BITS - 3)
|
||||
#define BOX_C1_LOG (HIST_C1_BITS - 3)
|
||||
#define BOX_C2_LOG (HIST_C2_BITS - 3)
|
||||
|
||||
#define BOX_C0_ELEMS (1<<BOX_C0_LOG) /* # of hist cells in update box */
|
||||
#define BOX_C1_ELEMS (1<<BOX_C1_LOG)
|
||||
#define BOX_C2_ELEMS (1<<BOX_C2_LOG)
|
||||
#define BOX_C0_ELEMS (1 << BOX_C0_LOG) /* # of hist cells in update box */
|
||||
#define BOX_C1_ELEMS (1 << BOX_C1_LOG)
|
||||
#define BOX_C2_ELEMS (1 << BOX_C2_LOG)
|
||||
|
||||
#define BOX_C0_SHIFT (C0_SHIFT + BOX_C0_LOG)
|
||||
#define BOX_C1_SHIFT (C1_SHIFT + BOX_C1_LOG)
|
||||
@ -623,7 +622,7 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
*/
|
||||
|
||||
LOCAL(int)
|
||||
find_nearby_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
find_nearby_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
JSAMPLE colorlist[])
|
||||
/* Locate the colormap entries close enough to an update box to be candidates
|
||||
* for the nearest entry to some cell(s) in the update box. The update box
|
||||
@ -669,67 +668,67 @@ find_nearby_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
x = GETJSAMPLE(cinfo->colormap[0][i]);
|
||||
if (x < minc0) {
|
||||
tdist = (x - minc0) * C0_SCALE;
|
||||
min_dist = tdist*tdist;
|
||||
min_dist = tdist * tdist;
|
||||
tdist = (x - maxc0) * C0_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
max_dist = tdist * tdist;
|
||||
} else if (x > maxc0) {
|
||||
tdist = (x - maxc0) * C0_SCALE;
|
||||
min_dist = tdist*tdist;
|
||||
min_dist = tdist * tdist;
|
||||
tdist = (x - minc0) * C0_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
max_dist = tdist * tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
min_dist = 0;
|
||||
if (x <= centerc0) {
|
||||
tdist = (x - maxc0) * C0_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
max_dist = tdist * tdist;
|
||||
} else {
|
||||
tdist = (x - minc0) * C0_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
max_dist = tdist * tdist;
|
||||
}
|
||||
}
|
||||
|
||||
x = GETJSAMPLE(cinfo->colormap[1][i]);
|
||||
if (x < minc1) {
|
||||
tdist = (x - minc1) * C1_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
min_dist += tdist * tdist;
|
||||
tdist = (x - maxc1) * C1_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else if (x > maxc1) {
|
||||
tdist = (x - maxc1) * C1_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
min_dist += tdist * tdist;
|
||||
tdist = (x - minc1) * C1_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
if (x <= centerc1) {
|
||||
tdist = (x - maxc1) * C1_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else {
|
||||
tdist = (x - minc1) * C1_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
}
|
||||
}
|
||||
|
||||
x = GETJSAMPLE(cinfo->colormap[2][i]);
|
||||
if (x < minc2) {
|
||||
tdist = (x - minc2) * C2_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
min_dist += tdist * tdist;
|
||||
tdist = (x - maxc2) * C2_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else if (x > maxc2) {
|
||||
tdist = (x - maxc2) * C2_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
min_dist += tdist * tdist;
|
||||
tdist = (x - minc2) * C2_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
if (x <= centerc2) {
|
||||
tdist = (x - maxc2) * C2_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
} else {
|
||||
tdist = (x - minc2) * C2_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
max_dist += tdist * tdist;
|
||||
}
|
||||
}
|
||||
|
||||
@ -745,14 +744,14 @@ find_nearby_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
ncolors = 0;
|
||||
for (i = 0; i < numcolors; i++) {
|
||||
if (mindist[i] <= minmaxdist)
|
||||
colorlist[ncolors++] = (JSAMPLE) i;
|
||||
colorlist[ncolors++] = (JSAMPLE)i;
|
||||
}
|
||||
return ncolors;
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
find_best_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[])
|
||||
/* Find the closest colormap entry for each cell in the update box,
|
||||
* given the list of candidate colors prepared by find_nearby_colors.
|
||||
@ -775,7 +774,7 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
|
||||
/* Initialize best-distance for each cell of the update box */
|
||||
bptr = bestdist;
|
||||
for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--)
|
||||
for (i = BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS - 1; i >= 0; i--)
|
||||
*bptr++ = 0x7FFFFFFFL;
|
||||
|
||||
/* For each color selected by find_nearby_colors,
|
||||
@ -792,11 +791,11 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
icolor = GETJSAMPLE(colorlist[i]);
|
||||
/* Compute (square of) distance from minc0/c1/c2 to this color */
|
||||
inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE;
|
||||
dist0 = inc0*inc0;
|
||||
dist0 = inc0 * inc0;
|
||||
inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE;
|
||||
dist0 += inc1*inc1;
|
||||
dist0 += inc1 * inc1;
|
||||
inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE;
|
||||
dist0 += inc2*inc2;
|
||||
dist0 += inc2 * inc2;
|
||||
/* Form the initial difference increments */
|
||||
inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0;
|
||||
inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1;
|
||||
@ -805,16 +804,16 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
bptr = bestdist;
|
||||
cptr = bestcolor;
|
||||
xx0 = inc0;
|
||||
for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) {
|
||||
for (ic0 = BOX_C0_ELEMS - 1; ic0 >= 0; ic0--) {
|
||||
dist1 = dist0;
|
||||
xx1 = inc1;
|
||||
for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) {
|
||||
for (ic1 = BOX_C1_ELEMS - 1; ic1 >= 0; ic1--) {
|
||||
dist2 = dist1;
|
||||
xx2 = inc2;
|
||||
for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) {
|
||||
for (ic2 = BOX_C2_ELEMS - 1; ic2 >= 0; ic2--) {
|
||||
if (dist2 < *bptr) {
|
||||
*bptr = dist2;
|
||||
*cptr = (JSAMPLE) icolor;
|
||||
*cptr = (JSAMPLE)icolor;
|
||||
}
|
||||
dist2 += xx2;
|
||||
xx2 += 2 * STEP_C2 * STEP_C2;
|
||||
@ -832,12 +831,12 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2)
|
||||
fill_inverse_cmap(j_decompress_ptr cinfo, int c0, int c1, int c2)
|
||||
/* Fill the inverse-colormap entries in the update box that contains */
|
||||
/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */
|
||||
/* we can fill as many others as we wish.) */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
int minc0, minc1, minc2; /* lower left corner of update box */
|
||||
int ic0, ic1, ic2;
|
||||
@ -878,9 +877,9 @@ fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2)
|
||||
cptr = bestcolor;
|
||||
for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) {
|
||||
for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) {
|
||||
cachep = & histogram[c0+ic0][c1+ic1][c2];
|
||||
cachep = &histogram[c0 + ic0][c1 + ic1][c2];
|
||||
for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) {
|
||||
*cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1);
|
||||
*cachep++ = (histcell)(GETJSAMPLE(*cptr++) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -892,11 +891,11 @@ fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
pass2_no_dither (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)
|
||||
pass2_no_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* This version performs no dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register histptr cachep;
|
||||
@ -913,24 +912,24 @@ pass2_no_dither (j_decompress_ptr cinfo,
|
||||
c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT;
|
||||
c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT;
|
||||
c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT;
|
||||
cachep = & histogram[c0][c1][c2];
|
||||
cachep = &histogram[c0][c1][c2];
|
||||
/* If we have not seen this color before, find nearest colormap entry */
|
||||
/* and update the cache */
|
||||
if (*cachep == 0)
|
||||
fill_inverse_cmap(cinfo, c0,c1,c2);
|
||||
fill_inverse_cmap(cinfo, c0, c1, c2);
|
||||
/* Now emit the colormap index for this cell */
|
||||
*outptr++ = (JSAMPLE) (*cachep - 1);
|
||||
*outptr++ = (JSAMPLE)(*cachep - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)
|
||||
pass2_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
/* This version performs Floyd-Steinberg dithering */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */
|
||||
LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */
|
||||
@ -956,11 +955,11 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
outptr = output_buf[row];
|
||||
if (cquantize->on_odd_row) {
|
||||
/* work right to left in this row */
|
||||
inptr += (width-1) * 3; /* so point to rightmost pixel */
|
||||
outptr += width-1;
|
||||
inptr += (width - 1) * 3; /* so point to rightmost pixel */
|
||||
outptr += width - 1;
|
||||
dir = -1;
|
||||
dir3 = -3;
|
||||
errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */
|
||||
errorptr = cquantize->fserrors + (width + 1) * 3; /* => entry after last column */
|
||||
cquantize->on_odd_row = FALSE; /* flip for next time */
|
||||
} else {
|
||||
/* work left to right in this row */
|
||||
@ -984,9 +983,9 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
* for either sign of the error value.
|
||||
* Note: errorptr points to *previous* column's array entry.
|
||||
*/
|
||||
cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4);
|
||||
cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4);
|
||||
cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4);
|
||||
cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3 + 0] + 8, 4);
|
||||
cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3 + 1] + 8, 4);
|
||||
cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3 + 2] + 8, 4);
|
||||
/* Limit the error using transfer function set by init_error_limit.
|
||||
* See comments with init_error_limit for rationale.
|
||||
*/
|
||||
@ -1004,14 +1003,17 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
cur1 = GETJSAMPLE(range_limit[cur1]);
|
||||
cur2 = GETJSAMPLE(range_limit[cur2]);
|
||||
/* Index into the cache with adjusted pixel value */
|
||||
cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT];
|
||||
cachep =
|
||||
&histogram[cur0 >> C0_SHIFT][cur1 >> C1_SHIFT][cur2 >> C2_SHIFT];
|
||||
/* If we have not seen this color before, find nearest colormap */
|
||||
/* entry and update the cache */
|
||||
if (*cachep == 0)
|
||||
fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT);
|
||||
fill_inverse_cmap(cinfo, cur0 >> C0_SHIFT, cur1 >> C1_SHIFT,
|
||||
cur2 >> C2_SHIFT);
|
||||
/* Now emit the colormap index for this cell */
|
||||
{ register int pixcode = *cachep - 1;
|
||||
*outptr = (JSAMPLE) pixcode;
|
||||
{
|
||||
register int pixcode = *cachep - 1;
|
||||
*outptr = (JSAMPLE)pixcode;
|
||||
/* Compute representation error for this pixel */
|
||||
cur0 -= GETJSAMPLE(colormap0[pixcode]);
|
||||
cur1 -= GETJSAMPLE(colormap1[pixcode]);
|
||||
@ -1021,20 +1023,21 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
* Add these into the running sums, and simultaneously shift the
|
||||
* next-line error sums left by 1 column.
|
||||
*/
|
||||
{ register LOCFSERROR bnexterr;
|
||||
{
|
||||
register LOCFSERROR bnexterr;
|
||||
|
||||
bnexterr = cur0; /* Process component 0 */
|
||||
errorptr[0] = (FSERROR) (bpreverr0 + cur0 * 3);
|
||||
errorptr[0] = (FSERROR)(bpreverr0 + cur0 * 3);
|
||||
bpreverr0 = belowerr0 + cur0 * 5;
|
||||
belowerr0 = bnexterr;
|
||||
cur0 *= 7;
|
||||
bnexterr = cur1; /* Process component 1 */
|
||||
errorptr[1] = (FSERROR) (bpreverr1 + cur1 * 3);
|
||||
errorptr[1] = (FSERROR)(bpreverr1 + cur1 * 3);
|
||||
bpreverr1 = belowerr1 + cur1 * 5;
|
||||
belowerr1 = bnexterr;
|
||||
cur1 *= 7;
|
||||
bnexterr = cur2; /* Process component 2 */
|
||||
errorptr[2] = (FSERROR) (bpreverr2 + cur2 * 3);
|
||||
errorptr[2] = (FSERROR)(bpreverr2 + cur2 * 3);
|
||||
bpreverr2 = belowerr2 + cur2 * 5;
|
||||
belowerr2 = bnexterr;
|
||||
cur2 *= 7;
|
||||
@ -1051,9 +1054,9 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
* final fserrors[] entry. Note we need not unload belowerrN because
|
||||
* it is for the dummy column before or after the actual array.
|
||||
*/
|
||||
errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */
|
||||
errorptr[1] = (FSERROR) bpreverr1;
|
||||
errorptr[2] = (FSERROR) bpreverr2;
|
||||
errorptr[0] = (FSERROR)bpreverr0; /* unload prev errs into array */
|
||||
errorptr[1] = (FSERROR)bpreverr1;
|
||||
errorptr[2] = (FSERROR)bpreverr2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1076,26 +1079,26 @@ pass2_fs_dither (j_decompress_ptr cinfo,
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
init_error_limit (j_decompress_ptr cinfo)
|
||||
init_error_limit(j_decompress_ptr cinfo)
|
||||
/* Allocate and fill in the error_limiter table */
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
int *table;
|
||||
int in, out;
|
||||
|
||||
table = (int *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * sizeof(int));
|
||||
table = (int *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, (MAXJSAMPLE * 2 + 1) * sizeof(int));
|
||||
table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */
|
||||
cquantize->error_limiter = table;
|
||||
|
||||
#define STEPSIZE ((MAXJSAMPLE+1)/16)
|
||||
#define STEPSIZE ((MAXJSAMPLE + 1) / 16)
|
||||
/* Map errors 1:1 up to +- MAXJSAMPLE/16 */
|
||||
out = 0;
|
||||
for (in = 0; in < STEPSIZE; in++, out++) {
|
||||
table[in] = out; table[-in] = -out;
|
||||
}
|
||||
/* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */
|
||||
for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) {
|
||||
for (; in < STEPSIZE * 3; in++, out += (in & 1) ? 0 : 1) {
|
||||
table[in] = out; table[-in] = -out;
|
||||
}
|
||||
/* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */
|
||||
@ -1111,9 +1114,9 @@ init_error_limit (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass1 (j_decompress_ptr cinfo)
|
||||
finish_pass1(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
|
||||
/* Select the representative colors and fill in cinfo->colormap */
|
||||
cinfo->colormap = cquantize->sv_colormap;
|
||||
@ -1124,7 +1127,7 @@ finish_pass1 (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
finish_pass2 (j_decompress_ptr cinfo)
|
||||
finish_pass2(j_decompress_ptr cinfo)
|
||||
{
|
||||
/* no work */
|
||||
}
|
||||
@ -1135,9 +1138,9 @@ finish_pass2 (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
start_pass_2_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
hist3d histogram = cquantize->histogram;
|
||||
int i;
|
||||
|
||||
@ -1167,14 +1170,14 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
|
||||
|
||||
if (cinfo->dither_mode == JDITHER_FS) {
|
||||
size_t arraysize = (size_t) ((cinfo->output_width + 2) *
|
||||
(3 * sizeof(FSERROR)));
|
||||
size_t arraysize =
|
||||
(size_t)((cinfo->output_width + 2) * (3 * sizeof(FSERROR)));
|
||||
/* Allocate Floyd-Steinberg workspace if we didn't already. */
|
||||
if (cquantize->fserrors == NULL)
|
||||
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
|
||||
cquantize->fserrors = (FSERRPTR)(*cinfo->mem->alloc_large)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, arraysize);
|
||||
/* Initialize the propagated errors to zero. */
|
||||
jzero_far((void *) cquantize->fserrors, arraysize);
|
||||
jzero_far((void *)cquantize->fserrors, arraysize);
|
||||
/* Make the error-limit table if we didn't already. */
|
||||
if (cquantize->error_limiter == NULL)
|
||||
init_error_limit(cinfo);
|
||||
@ -1185,8 +1188,8 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
/* Zero the histogram or inverse color map, if necessary */
|
||||
if (cquantize->needs_zeroed) {
|
||||
for (i = 0; i < HIST_C0_ELEMS; i++) {
|
||||
jzero_far((void *) histogram[i],
|
||||
HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell));
|
||||
jzero_far((void *)histogram[i],
|
||||
HIST_C1_ELEMS * HIST_C2_ELEMS * sizeof(histcell));
|
||||
}
|
||||
cquantize->needs_zeroed = FALSE;
|
||||
}
|
||||
@ -1198,9 +1201,9 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
new_color_map_2_quant (j_decompress_ptr cinfo)
|
||||
new_color_map_2_quant(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
|
||||
|
||||
/* Reset the inverse color map */
|
||||
cquantize->needs_zeroed = TRUE;
|
||||
@ -1212,15 +1215,15 @@ new_color_map_2_quant (j_decompress_ptr cinfo)
|
||||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
jinit_2pass_quantizer(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_cquantize_ptr cquantize;
|
||||
int i;
|
||||
|
||||
cquantize = (my_cquantize_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_cquantizer));
|
||||
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
|
||||
cinfo->cquantize = (struct jpeg_color_quantizer *)cquantize;
|
||||
cquantize->pub.start_pass = start_pass_2_quant;
|
||||
cquantize->pub.new_color_map = new_color_map_2_quant;
|
||||
cquantize->fserrors = NULL; /* flag optional arrays not allocated */
|
||||
@ -1231,12 +1234,12 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
ERREXIT(cinfo, JERR_NOTIMPL);
|
||||
|
||||
/* Allocate the histogram/inverse colormap storage */
|
||||
cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * sizeof(hist2d));
|
||||
cquantize->histogram = (hist3d)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * sizeof(hist2d));
|
||||
for (i = 0; i < HIST_C0_ELEMS; i++) {
|
||||
cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell));
|
||||
cquantize->histogram[i] = (hist2d)(*cinfo->mem->alloc_large)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
HIST_C1_ELEMS * HIST_C2_ELEMS * sizeof(histcell));
|
||||
}
|
||||
cquantize->needs_zeroed = TRUE; /* histogram is garbage now */
|
||||
|
||||
@ -1254,7 +1257,7 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
if (desired > MAXNUMCOLORS)
|
||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
|
||||
cquantize->sv_colormap = (*cinfo->mem->alloc_sarray)
|
||||
((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3);
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)desired, (JDIMENSION)3);
|
||||
cquantize->desired = desired;
|
||||
} else
|
||||
cquantize->sv_colormap = NULL;
|
||||
@ -1271,9 +1274,9 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
||||
* dither_mode changes.
|
||||
*/
|
||||
if (cinfo->dither_mode == JDITHER_FS) {
|
||||
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) ((cinfo->output_width + 2) * (3 * sizeof(FSERROR))));
|
||||
cquantize->fserrors = (FSERRPTR)(*cinfo->mem->alloc_large)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(size_t)((cinfo->output_width + 2) * (3 * sizeof(FSERROR))));
|
||||
/* Might as well create the error-limiting table too. */
|
||||
init_error_limit(cinfo);
|
||||
}
|
||||
|
146
3rdparty/libjpeg-turbo/src/jsimd.h
vendored
146
3rdparty/libjpeg-turbo/src/jsimd.h
vendored
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2011, 2014, D. R. Commander.
|
||||
* Copyright (C) 2015, Matthieu Darbois.
|
||||
* Copyright (C) 2015-2016, 2018, Matthieu Darbois.
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
* Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
@ -13,81 +13,105 @@
|
||||
|
||||
#include "jchuff.h" /* Declarations shared with jcphuff.c */
|
||||
|
||||
EXTERN(int) jsimd_can_rgb_ycc (void);
|
||||
EXTERN(int) jsimd_can_rgb_gray (void);
|
||||
EXTERN(int) jsimd_can_ycc_rgb (void);
|
||||
EXTERN(int) jsimd_can_ycc_rgb565 (void);
|
||||
EXTERN(int) jsimd_c_can_null_convert (void);
|
||||
EXTERN(int) jsimd_can_rgb_ycc(void);
|
||||
EXTERN(int) jsimd_can_rgb_gray(void);
|
||||
EXTERN(int) jsimd_can_ycc_rgb(void);
|
||||
EXTERN(int) jsimd_can_ycc_rgb565(void);
|
||||
EXTERN(int) jsimd_c_can_null_convert(void);
|
||||
|
||||
EXTERN(void) jsimd_rgb_ycc_convert
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
EXTERN(void) jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows);
|
||||
EXTERN(void) jsimd_rgb_gray_convert
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
EXTERN(void) jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows);
|
||||
EXTERN(void) jsimd_ycc_rgb_convert
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
EXTERN(void) jsimd_ycc_rgb_convert(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows);
|
||||
EXTERN(void) jsimd_ycc_rgb565_convert
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
EXTERN(void) jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows);
|
||||
EXTERN(void) jsimd_c_null_convert
|
||||
(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows);
|
||||
EXTERN(void) jsimd_c_null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_downsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_downsample (void);
|
||||
EXTERN(int) jsimd_can_h2v2_downsample(void);
|
||||
EXTERN(int) jsimd_can_h2v1_downsample(void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_downsample
|
||||
(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data);
|
||||
EXTERN(void) jsimd_h2v2_downsample(j_compress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY output_data);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_smooth_downsample (void);
|
||||
EXTERN(int) jsimd_can_h2v2_smooth_downsample(void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_smooth_downsample
|
||||
(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data);
|
||||
EXTERN(void) jsimd_h2v2_smooth_downsample(j_compress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY output_data);
|
||||
|
||||
EXTERN(void) jsimd_h2v1_downsample
|
||||
(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data);
|
||||
EXTERN(void) jsimd_h2v1_downsample(j_compress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY output_data);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_upsample (void);
|
||||
EXTERN(int) jsimd_can_int_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v2_upsample(void);
|
||||
EXTERN(int) jsimd_can_h2v1_upsample(void);
|
||||
EXTERN(int) jsimd_can_int_upsample(void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_upsample
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v1_upsample
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_int_upsample
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v2_upsample(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v1_upsample(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_int_upsample(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_fancy_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_fancy_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v2_fancy_upsample(void);
|
||||
EXTERN(int) jsimd_can_h2v1_fancy_upsample(void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_fancy_upsample
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v1_fancy_upsample
|
||||
(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr);
|
||||
EXTERN(void) jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr);
|
||||
|
||||
EXTERN(int) jsimd_can_h2v2_merged_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v1_merged_upsample (void);
|
||||
EXTERN(int) jsimd_can_h2v2_merged_upsample(void);
|
||||
EXTERN(int) jsimd_can_h2v1_merged_upsample(void);
|
||||
|
||||
EXTERN(void) jsimd_h2v2_merged_upsample
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
EXTERN(void) jsimd_h2v1_merged_upsample
|
||||
(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
EXTERN(void) jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf);
|
||||
EXTERN(void) jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf);
|
||||
|
||||
EXTERN(int) jsimd_can_huff_encode_one_block (void);
|
||||
EXTERN(int) jsimd_can_huff_encode_one_block(void);
|
||||
|
||||
EXTERN(JOCTET*) jsimd_huff_encode_one_block
|
||||
(void *state, JOCTET *buffer, JCOEFPTR block, int last_dc_val,
|
||||
c_derived_tbl *dctbl, c_derived_tbl *actbl);
|
||||
EXTERN(JOCTET *) jsimd_huff_encode_one_block(void *state, JOCTET *buffer,
|
||||
JCOEFPTR block, int last_dc_val,
|
||||
c_derived_tbl *dctbl,
|
||||
c_derived_tbl *actbl);
|
||||
|
||||
EXTERN(int) jsimd_can_encode_mcu_AC_first_prepare(void);
|
||||
|
||||
EXTERN(void) jsimd_encode_mcu_AC_first_prepare
|
||||
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
|
||||
JCOEF *values, size_t *zerobits);
|
||||
|
||||
EXTERN(int) jsimd_can_encode_mcu_AC_refine_prepare(void);
|
||||
|
||||
EXTERN(int) jsimd_encode_mcu_AC_refine_prepare
|
||||
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
|
||||
JCOEF *absvalues, size_t *bits);
|
||||
|
196
3rdparty/libjpeg-turbo/src/jsimd_none.c
vendored
196
3rdparty/libjpeg-turbo/src/jsimd_none.c
vendored
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2009-2011, 2014, D. R. Commander.
|
||||
* Copyright (C) 2015, Matthieu Darbois.
|
||||
* Copyright (C) 2015-2016, 2018, Matthieu Darbois.
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
* Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
@ -20,385 +20,399 @@
|
||||
#include "jsimddct.h"
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_rgb_ycc (void)
|
||||
jsimd_can_rgb_ycc(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_rgb_gray (void)
|
||||
jsimd_can_rgb_gray(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_ycc_rgb (void)
|
||||
jsimd_can_ycc_rgb(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_ycc_rgb565 (void)
|
||||
jsimd_can_ycc_rgb565(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_c_can_null_convert (void)
|
||||
jsimd_c_can_null_convert(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_rgb_gray_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_c_null_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
jsimd_c_null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
||||
int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_downsample (void)
|
||||
jsimd_can_h2v2_downsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_downsample (void)
|
||||
jsimd_can_h2v1_downsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_smooth_downsample (void)
|
||||
jsimd_can_h2v2_smooth_downsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_smooth_downsample (j_compress_ptr cinfo,
|
||||
jsimd_h2v2_smooth_downsample(j_compress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_upsample (void)
|
||||
jsimd_can_h2v2_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_upsample (void)
|
||||
jsimd_can_h2v1_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_int_upsample (void)
|
||||
jsimd_can_int_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr)
|
||||
jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr)
|
||||
jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_fancy_upsample (void)
|
||||
jsimd_can_h2v2_fancy_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_fancy_upsample (void)
|
||||
jsimd_can_h2v1_fancy_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr)
|
||||
jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY *output_data_ptr)
|
||||
jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_merged_upsample (void)
|
||||
jsimd_can_h2v2_merged_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_merged_upsample (void)
|
||||
jsimd_can_h2v1_merged_upsample(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_convsamp (void)
|
||||
jsimd_can_convsamp(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_convsamp_float (void)
|
||||
jsimd_can_convsamp_float(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
DCTELEM *workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
FAST_FLOAT *workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_fdct_islow (void)
|
||||
jsimd_can_fdct_islow(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_fdct_ifast (void)
|
||||
jsimd_can_fdct_ifast(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_fdct_float (void)
|
||||
jsimd_can_fdct_float(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_fdct_islow (DCTELEM *data)
|
||||
jsimd_fdct_islow(DCTELEM *data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_fdct_ifast (DCTELEM *data)
|
||||
jsimd_fdct_ifast(DCTELEM *data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_fdct_float (FAST_FLOAT *data)
|
||||
jsimd_fdct_float(FAST_FLOAT *data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_quantize (void)
|
||||
jsimd_can_quantize(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_quantize_float (void)
|
||||
jsimd_can_quantize_float(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
|
||||
DCTELEM *workspace)
|
||||
jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
||||
jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
||||
FAST_FLOAT *workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_2x2 (void)
|
||||
jsimd_can_idct_2x2(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_4x4 (void)
|
||||
jsimd_can_idct_4x4(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_6x6 (void)
|
||||
jsimd_can_idct_6x6(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_12x12 (void)
|
||||
jsimd_can_idct_12x12(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_6x6(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_12x12(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_islow (void)
|
||||
jsimd_can_idct_islow(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_ifast (void)
|
||||
jsimd_can_idct_ifast(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_float (void)
|
||||
jsimd_can_idct_float(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_huff_encode_one_block (void)
|
||||
jsimd_can_huff_encode_one_block(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(JOCTET*)
|
||||
jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block,
|
||||
GLOBAL(JOCTET *)
|
||||
jsimd_huff_encode_one_block(void *state, JOCTET *buffer, JCOEFPTR block,
|
||||
int last_dc_val, c_derived_tbl *dctbl,
|
||||
c_derived_tbl *actbl)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_encode_mcu_AC_first_prepare(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
|
||||
const int *jpeg_natural_order_start, int Sl,
|
||||
int Al, JCOEF *values, size_t *zerobits)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_encode_mcu_AC_refine_prepare(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
|
||||
const int *jpeg_natural_order_start, int Sl,
|
||||
int Al, JCOEF *absvalues, size_t *bits)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
72
3rdparty/libjpeg-turbo/src/jsimddct.h
vendored
72
3rdparty/libjpeg-turbo/src/jsimddct.h
vendored
@ -9,66 +9,62 @@
|
||||
*
|
||||
*/
|
||||
|
||||
EXTERN(int) jsimd_can_convsamp (void);
|
||||
EXTERN(int) jsimd_can_convsamp_float (void);
|
||||
EXTERN(int) jsimd_can_convsamp(void);
|
||||
EXTERN(int) jsimd_can_convsamp_float(void);
|
||||
|
||||
EXTERN(void) jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
EXTERN(void) jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
DCTELEM *workspace);
|
||||
EXTERN(void) jsimd_convsamp_float (JSAMPARRAY sample_data,
|
||||
JDIMENSION start_col,
|
||||
EXTERN(void) jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
FAST_FLOAT *workspace);
|
||||
|
||||
EXTERN(int) jsimd_can_fdct_islow (void);
|
||||
EXTERN(int) jsimd_can_fdct_ifast (void);
|
||||
EXTERN(int) jsimd_can_fdct_float (void);
|
||||
EXTERN(int) jsimd_can_fdct_islow(void);
|
||||
EXTERN(int) jsimd_can_fdct_ifast(void);
|
||||
EXTERN(int) jsimd_can_fdct_float(void);
|
||||
|
||||
EXTERN(void) jsimd_fdct_islow (DCTELEM *data);
|
||||
EXTERN(void) jsimd_fdct_ifast (DCTELEM *data);
|
||||
EXTERN(void) jsimd_fdct_float (FAST_FLOAT *data);
|
||||
EXTERN(void) jsimd_fdct_islow(DCTELEM *data);
|
||||
EXTERN(void) jsimd_fdct_ifast(DCTELEM *data);
|
||||
EXTERN(void) jsimd_fdct_float(FAST_FLOAT *data);
|
||||
|
||||
EXTERN(int) jsimd_can_quantize (void);
|
||||
EXTERN(int) jsimd_can_quantize_float (void);
|
||||
EXTERN(int) jsimd_can_quantize(void);
|
||||
EXTERN(int) jsimd_can_quantize_float(void);
|
||||
|
||||
EXTERN(void) jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
|
||||
EXTERN(void) jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors,
|
||||
DCTELEM *workspace);
|
||||
EXTERN(void) jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
||||
EXTERN(void) jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
||||
FAST_FLOAT *workspace);
|
||||
|
||||
EXTERN(int) jsimd_can_idct_2x2 (void);
|
||||
EXTERN(int) jsimd_can_idct_4x4 (void);
|
||||
EXTERN(int) jsimd_can_idct_6x6 (void);
|
||||
EXTERN(int) jsimd_can_idct_12x12 (void);
|
||||
EXTERN(int) jsimd_can_idct_2x2(void);
|
||||
EXTERN(int) jsimd_can_idct_4x4(void);
|
||||
EXTERN(int) jsimd_can_idct_6x6(void);
|
||||
EXTERN(int) jsimd_can_idct_12x12(void);
|
||||
|
||||
EXTERN(void) jsimd_idct_2x2 (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_4x4 (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_6x6 (j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_12x12 (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jsimd_idct_2x2(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_4x4(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_6x6(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr, JCOEFPTR coef_block,
|
||||
JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_12x12(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
|
||||
EXTERN(int) jsimd_can_idct_islow (void);
|
||||
EXTERN(int) jsimd_can_idct_ifast (void);
|
||||
EXTERN(int) jsimd_can_idct_float (void);
|
||||
EXTERN(int) jsimd_can_idct_islow(void);
|
||||
EXTERN(int) jsimd_can_idct_ifast(void);
|
||||
EXTERN(int) jsimd_can_idct_float(void);
|
||||
|
||||
EXTERN(void) jsimd_idct_islow (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jsimd_idct_islow(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_ifast (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jsimd_idct_ifast(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
EXTERN(void) jsimd_idct_float (j_decompress_ptr cinfo,
|
||||
EXTERN(void) jsimd_idct_float(j_decompress_ptr cinfo,
|
||||
jpeg_component_info *compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col);
|
||||
|
50
3rdparty/libjpeg-turbo/src/jstdhuff.c
vendored
50
3rdparty/libjpeg-turbo/src/jstdhuff.c
vendored
@ -17,8 +17,8 @@
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
add_huff_table (j_common_ptr cinfo,
|
||||
JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val)
|
||||
add_huff_table(j_common_ptr cinfo, JHUFF_TBL **htblptr, const UINT8 *bits,
|
||||
const UINT8 *val)
|
||||
/* Define a Huffman table */
|
||||
{
|
||||
int nsymbols, len;
|
||||
@ -50,26 +50,31 @@ add_huff_table (j_common_ptr cinfo,
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
std_huff_tables (j_common_ptr cinfo)
|
||||
std_huff_tables(j_common_ptr cinfo)
|
||||
/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
|
||||
/* IMPORTANT: these are only valid for 8-bit data precision! */
|
||||
{
|
||||
JHUFF_TBL **dc_huff_tbl_ptrs, **ac_huff_tbl_ptrs;
|
||||
|
||||
static const UINT8 bits_dc_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_luminance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
static const UINT8 bits_dc_luminance[17] = {
|
||||
/* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
static const UINT8 val_dc_luminance[] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
|
||||
};
|
||||
|
||||
static const UINT8 bits_dc_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_chrominance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
static const UINT8 bits_dc_chrominance[17] = {
|
||||
/* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
|
||||
};
|
||||
static const UINT8 val_dc_chrominance[] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
|
||||
};
|
||||
|
||||
static const UINT8 bits_ac_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
|
||||
static const UINT8 val_ac_luminance[] =
|
||||
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
|
||||
static const UINT8 bits_ac_luminance[17] = {
|
||||
/* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d
|
||||
};
|
||||
static const UINT8 val_ac_luminance[] = {
|
||||
0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
|
||||
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
|
||||
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
|
||||
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
|
||||
@ -89,12 +94,14 @@ std_huff_tables (j_common_ptr cinfo)
|
||||
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
|
||||
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
|
||||
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
0xf9, 0xfa
|
||||
};
|
||||
|
||||
static const UINT8 bits_ac_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
|
||||
static const UINT8 val_ac_chrominance[] =
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
|
||||
static const UINT8 bits_ac_chrominance[17] = {
|
||||
/* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77
|
||||
};
|
||||
static const UINT8 val_ac_chrominance[] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
|
||||
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
|
||||
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
|
||||
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
|
||||
@ -114,7 +121,8 @@ std_huff_tables (j_common_ptr cinfo)
|
||||
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
|
||||
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
|
||||
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
0xf9, 0xfa
|
||||
};
|
||||
|
||||
if (cinfo->is_decompressor) {
|
||||
dc_huff_tbl_ptrs = ((j_decompress_ptr)cinfo)->dc_huff_tbl_ptrs;
|
||||
|
18
3rdparty/libjpeg-turbo/src/jutils.c
vendored
18
3rdparty/libjpeg-turbo/src/jutils.c
vendored
@ -53,7 +53,7 @@ const int jpeg_zigzag_order[DCTSIZE2] = {
|
||||
* fake entries.
|
||||
*/
|
||||
|
||||
const int jpeg_natural_order[DCTSIZE2+16] = {
|
||||
const int jpeg_natural_order[DCTSIZE2 + 16] = {
|
||||
0, 1, 8, 16, 9, 2, 3, 10,
|
||||
17, 24, 32, 25, 18, 11, 4, 5,
|
||||
12, 19, 26, 33, 40, 48, 41, 34,
|
||||
@ -72,7 +72,7 @@ const int jpeg_natural_order[DCTSIZE2+16] = {
|
||||
*/
|
||||
|
||||
GLOBAL(long)
|
||||
jdiv_round_up (long a, long b)
|
||||
jdiv_round_up(long a, long b)
|
||||
/* Compute a/b rounded up to next integer, ie, ceil(a/b) */
|
||||
/* Assumes a >= 0, b > 0 */
|
||||
{
|
||||
@ -81,7 +81,7 @@ jdiv_round_up (long a, long b)
|
||||
|
||||
|
||||
GLOBAL(long)
|
||||
jround_up (long a, long b)
|
||||
jround_up(long a, long b)
|
||||
/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */
|
||||
/* Assumes a >= 0, b > 0 */
|
||||
{
|
||||
@ -91,9 +91,9 @@ jround_up (long a, long b)
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
JSAMPARRAY output_array, int dest_row,
|
||||
int num_rows, JDIMENSION num_cols)
|
||||
jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
|
||||
JSAMPARRAY output_array, int dest_row, int num_rows,
|
||||
JDIMENSION num_cols)
|
||||
/* Copy some rows of samples from one place to another.
|
||||
* num_rows rows are copied from input_array[source_row++]
|
||||
* to output_array[dest_row++]; these areas may overlap for duplication.
|
||||
@ -101,7 +101,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
*/
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register size_t count = (size_t) (num_cols * sizeof(JSAMPLE));
|
||||
register size_t count = (size_t)(num_cols * sizeof(JSAMPLE));
|
||||
register int row;
|
||||
|
||||
input_array += source_row;
|
||||
@ -116,7 +116,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
JDIMENSION num_blocks)
|
||||
/* Copy a row of coefficient blocks from one place to another. */
|
||||
{
|
||||
@ -125,7 +125,7 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jzero_far (void *target, size_t bytestozero)
|
||||
jzero_far(void *target, size_t bytestozero)
|
||||
/* Zero out a chunk of memory. */
|
||||
/* This might be sample-array data, block-array data, or alloc_large data. */
|
||||
{
|
||||
|
13
3rdparty/libjpeg-turbo/src/jversion.h
vendored
13
3rdparty/libjpeg-turbo/src/jversion.h
vendored
@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2012-2017, D. R. Commander.
|
||||
* Copyright (C) 2010, 2012-2019, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@ -35,15 +35,18 @@
|
||||
* their code
|
||||
*/
|
||||
|
||||
#define JCOPYRIGHT "Copyright (C) 2009-2017 D. R. Commander\n" \
|
||||
#define JCOPYRIGHT \
|
||||
"Copyright (C) 2009-2019 D. R. Commander\n" \
|
||||
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
||||
"Copyright (C) 2015-2016 Matthieu Darbois\n" \
|
||||
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
|
||||
"Copyright (C) 2015 Intel Corporation\n" \
|
||||
"Copyright (C) 2015 Google, Inc.\n" \
|
||||
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
|
||||
"Copyright (C) 2013 Linaro Limited\n" \
|
||||
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
|
||||
"Copyright (C) 2009 Pierre Ossman for Cendio AB\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-2017 The libjpeg-turbo Project and many others"
|
||||
#define JCOPYRIGHT_SHORT \
|
||||
"Copyright (C) 1991-2019 The libjpeg-turbo Project and many others"
|
||||
|
Loading…
Reference in New Issue
Block a user