Update libjpeg-turbo from 1.5.3 to 2.0.2

This commit is contained in:
Juha Reunanen 2019-02-23 18:30:49 +02:00 committed by Alexander Alekhin
parent 5421d0866b
commit 30cf5e0164
78 changed files with 5548 additions and 5149 deletions

View File

@ -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")

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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
View 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 */

View File

@ -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

View File

@ -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,7 +29,8 @@
* 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] = {
/*

View File

@ -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);

View File

@ -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
@ -142,13 +145,13 @@ finish_pass (j_compress_ptr cinfo)
/* 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)
@ -881,7 +884,8 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
#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
}
}

View File

@ -58,13 +58,11 @@ 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
@ -167,8 +165,8 @@ 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++) {
@ -183,7 +181,8 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
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 {
@ -191,7 +190,8 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
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;

View File

@ -29,9 +29,9 @@
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;
register int r, g, b;
@ -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,9 +83,9 @@ 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;
register int r, g, b;
@ -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;

View File

@ -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,9 +373,8 @@ 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;
register int r, g, b;
@ -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;

View File

@ -489,8 +489,7 @@ quantize (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
METHODDEF(void)
forward_DCT(j_compress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col,
JDIMENSION num_blocks)
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. */
@ -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;

View File

@ -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.
*
@ -310,11 +309,12 @@ 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; } }
{ action; } \
}
LOCAL(boolean)
@ -434,8 +434,8 @@ 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() { \
@ -443,7 +443,7 @@ dump_buffer (working_state *state)
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; \
@ -452,8 +452,7 @@ dump_buffer (working_state *state)
if (!dump_buffer(state)) return FALSE; \
bytes -= bytestocopy; \
} \
} \
else { \
} else { \
state->free_in_buffer -= (buffer - state->next_output_byte); \
state->next_output_byte = buffer; \
} \
@ -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
@ -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--) {
@ -1003,7 +1003,8 @@ 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++) {

View File

@ -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[]);

View File

@ -60,8 +60,8 @@ 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);

View File

@ -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);
@ -75,18 +76,17 @@ 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;
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,
(*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

View File

@ -296,8 +296,7 @@ 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)
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);

View File

@ -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.
*
@ -95,8 +95,8 @@ 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 */
@ -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);
@ -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.
@ -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 */

View File

@ -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.
*
@ -26,8 +26,8 @@
GLOBAL(void)
jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table,
int scale_factor, boolean force_baseline)
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
@ -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.
*/
@ -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;

View File

@ -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;
@ -88,19 +143,53 @@ typedef phuff_entropy_encoder *phuff_entropy_ptr;
#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,
JBLOCKROW *MCU_data);
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,
JBLOCKROW *MCU_data);
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);
/* 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;
}
/*
* Initialize for a Huffman-compressed scan using progressive JPEG.
*/
@ -126,11 +215,19 @@ 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 *)
@ -198,10 +295,11 @@ 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)
@ -320,9 +418,7 @@ emit_eobrun (phuff_entropy_ptr entropy)
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);
@ -378,7 +474,7 @@ METHODDEF(boolean)
encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
register int temp, temp2;
register int temp, temp2, temp3;
register int nbits;
int blkn, ci;
int Al = cinfo->Al;
@ -410,20 +506,20 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
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.
*/
@ -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)
{
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 */
@ -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)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
register int temp;
register int r, k;
int EOB;
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);
}

View File

@ -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,9 +128,8 @@ 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)
{
@ -172,12 +171,10 @@ 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,
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));
}
@ -195,9 +192,8 @@ 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)
{
@ -221,9 +217,8 @@ pre_process_context (j_compress_ptr cinfo,
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,8 +240,7 @@ 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,
(*cinfo->downsample->downsample) (cinfo, prep->color_buf,
(JDIMENSION)prep->this_row_group,
output_buf, *out_row_group_ctr);
(*out_row_group_ctr)++;

View File

@ -91,8 +91,8 @@ 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;
@ -118,9 +118,9 @@ 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;
int ci;
@ -162,8 +162,8 @@ int_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 * 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++) {
@ -195,11 +195,11 @@ 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);
}
@ -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;
}
@ -266,8 +266,8 @@ 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++) {
@ -276,9 +276,9 @@ h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
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;
}

View File

@ -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);
/*
@ -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;
@ -100,8 +99,7 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
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,
MEMCOPY((*qtblptr)->quantval, srcinfo->quant_tbl_ptrs[tblno]->quantval,
sizeof((*qtblptr)->quantval));
(*qtblptr)->sent_table = FALSE;
}
@ -321,8 +319,8 @@ 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) {

View File

@ -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.
@ -210,8 +210,7 @@ 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;
@ -236,8 +235,7 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
cinfo->master->first_MCU_col[ci] =
(JDIMENSION)(long)(*xoffset * hsf) / (long)align;
cinfo->master->last_MCU_col[ci] =
(JDIMENSION) jdiv_round_up((long) ((*xoffset + cinfo->output_width) *
hsf),
(JDIMENSION)jdiv_round_up((long)((*xoffset + cinfo->output_width) * hsf),
(long)align) - 1;
}
@ -320,12 +318,15 @@ 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;
}
@ -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.
*/
@ -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 */

View File

@ -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
@ -306,7 +309,7 @@ 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) */
@ -564,7 +567,7 @@ 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)
@ -760,7 +763,8 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
int *coef_bit_ptr, ci;
cinfo->coef_bits = (int (*)[DCTSIZE2])
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
cinfo->num_components*DCTSIZE2*sizeof(int));
cinfo->num_components * DCTSIZE2 *
sizeof(int));
coef_bit_ptr = &cinfo->coef_bits[0][0];
for (ci = 0; ci < cinfo->num_components; ci++)
for (i = 0; i < DCTSIZE2; i++)

View File

@ -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;

View File

@ -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;

View File

@ -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);
METHODDEF(int) decompress_smooth_data(j_decompress_ptr cinfo,
JSAMPIMAGE output_buf);
#endif
@ -129,8 +128,8 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
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) *
@ -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;
}
@ -599,8 +598,8 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
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;

View File

@ -17,9 +17,9 @@
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;
register int y, cb, cr;
@ -96,9 +96,9 @@ 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;
register int y, cb, cr;
@ -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;
@ -237,9 +237,9 @@ 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;
@ -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;
@ -336,9 +336,9 @@ 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;

View File

@ -28,9 +28,9 @@
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;
register int y, cb, cr;
@ -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;

View File

@ -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:
@ -324,9 +323,8 @@ 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;
register int r, g, b;
@ -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,9 +525,8 @@ 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;
register int y, cb, cr;
@ -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);

View File

@ -94,60 +94,60 @@ 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);
/*

View File

@ -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
@ -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); \
@ -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;
@ -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,
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 };
((-1) << 13) + 1, ((-1) << 14) + 1, ((-1) << 15) + 1
};
#endif /* AVOID_TABLES */
@ -766,8 +772,8 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
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.
@ -777,8 +783,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
if (usefast) {
if (!decode_mcu_fast(cinfo, MCU_data)) goto use_slow;
}
else {
} else {
use_slow:
if (!decode_mcu_slow(cinfo, MCU_data)) return FALSE;
}

View File

@ -47,9 +47,8 @@ typedef struct {
} 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);
/*
@ -149,11 +148,13 @@ typedef struct { /* Bitreading working state within an MCU */
* is evaluated multiple times.
*/
#define CHECK_BIT_BUFFER(state,nbits,action) \
{ if (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))
@ -165,8 +166,8 @@ typedef struct { /* Bitreading working state within an MCU */
(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,7 +204,8 @@ 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; \
} \
@ -229,6 +232,7 @@ slowlabel: \
}
/* 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);

View File

@ -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.
@ -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);
@ -198,7 +200,8 @@ 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);
if (tmp == 0) tmp = compptr->MCU_width;
@ -231,10 +234,10 @@ 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.

View File

@ -112,16 +112,19 @@
/* 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
@ -286,9 +289,8 @@ 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;
JDIMENSION rowgroups_avail;
@ -326,9 +328,8 @@ 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;
@ -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;
@ -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 */
@ -400,9 +405,8 @@ 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,

View File

@ -267,8 +267,8 @@ 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))
@ -598,8 +598,8 @@ 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.
@ -674,8 +674,8 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET *data,
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.

View File

@ -469,7 +469,8 @@ 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;
samplesperrow = (long)cinfo->output_width *
(long)cinfo->out_color_components;
jd_samplesperrow = (JDIMENSION)samplesperrow;
if ((long)jd_samplesperrow != samplesperrow)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);

View File

@ -248,11 +248,10 @@ 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;
@ -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 {
@ -300,11 +299,10 @@ merged_2v_upsample (j_decompress_ptr cinfo,
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;
@ -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:
@ -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,
@ -524,9 +519,8 @@ h2v1_merged_upsample_565 (j_decompress_ptr cinfo,
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,

View File

@ -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,8 +15,7 @@
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)
{
@ -160,8 +159,7 @@ h2v1_merged_upsample_565D_internal (j_decompress_ptr cinfo,
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)
{
@ -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++);

View File

@ -21,8 +21,7 @@
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)
{
@ -94,8 +93,7 @@ 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)
{

View File

@ -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
@ -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,
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 };
((-1) << 13) + 1, ((-1) << 14) + 1, ((-1) << 15) + 1
};
#endif /* AVOID_TABLES */
@ -336,6 +344,10 @@ 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) */
@ -664,7 +676,8 @@ jinit_phuff_decoder (j_decompress_ptr cinfo)
/* Create progression status table */
cinfo->coef_bits = (int (*)[DCTSIZE2])
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
cinfo->num_components*DCTSIZE2*sizeof(int));
cinfo->num_components * DCTSIZE2 *
sizeof(int));
coef_bit_ptr = &cinfo->coef_bits[0][0];
for (ci = 0; ci < cinfo->num_components; ci++)
for (i = 0; i < DCTSIZE2; i++)

View File

@ -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
@ -123,11 +129,10 @@ 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;
JDIMENSION num_rows, max_rows;
@ -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,11 +161,10 @@ 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;
JDIMENSION old_next_row, num_rows;
@ -173,9 +178,9 @@ post_process_prepass (j_decompress_ptr cinfo,
/* 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. */
@ -199,11 +204,10 @@ 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;
JDIMENSION num_rows, max_rows;
@ -226,8 +230,8 @@ 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,
(*cinfo->cquantize->color_quantize) (cinfo, post->buffer + post->next_row,
output_buf + *out_row_ctr,
(int)num_rows);
*out_row_ctr += num_rows;

View File

@ -56,9 +56,8 @@ 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)
{
@ -97,8 +96,7 @@ sep_upsample (j_decompress_ptr cinfo,
(*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,
(JDIMENSION)upsample->next_row_out,
output_buf + *out_row_ctr,
(int) num_rows);
output_buf + *out_row_ctr, (int)num_rows);
/* Adjust counts */
*out_row_ctr += num_rows;
@ -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;
}
@ -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())

View File

@ -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.
*
@ -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

View File

@ -242,9 +242,11 @@ jpeg_fdct_islow (DCTELEM *data)
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),
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),
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).

View File

@ -70,8 +70,8 @@
GLOBAL(void)
jpeg_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
FAST_FLOAT tmp10, tmp11, tmp12, tmp13;

View File

@ -169,8 +169,8 @@
GLOBAL(void)
jpeg_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
DCTELEM tmp10, tmp11, tmp12, tmp13;
@ -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;
@ -319,8 +319,8 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
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;
tmp12 =
MULTIPLY((DCTELEM)wsptr[2] - (DCTELEM)wsptr[6], FIX_1_414213562) - tmp13;
tmp0 = tmp10 + tmp13;
tmp3 = tmp10 - tmp13;
@ -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 */
}

View File

@ -171,8 +171,8 @@
GLOBAL(void)
jpeg_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp2, tmp3;
JLONG tmp10, tmp11, tmp12, tmp13;
@ -208,8 +208,8 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 6] == 0 &&
inptr[DCTSIZE * 7] == 0) {
/* AC terms all zero */
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;
@ -314,8 +314,8 @@ jpeg_idct_islow (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[(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;
@ -384,29 +384,29 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
outptr[0] = range_limit[(int)DESCALE(tmp10 + tmp3,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[7] = range_limit[(int)DESCALE(tmp10 - tmp3,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)DESCALE(tmp11 + tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[6] = range_limit[(int)DESCALE(tmp11 - tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)DESCALE(tmp12 + tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)DESCALE(tmp12 - tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)DESCALE(tmp13 + tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)DESCALE(tmp13 - tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += DCTSIZE; /* advance pointer to next row */
}
@ -425,8 +425,8 @@ jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_7x7(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp2, tmp10, tmp11, tmp12, tmp13;
JLONG z1, z2, z3;
@ -538,26 +538,26 @@ jpeg_idct_7x7 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp10 + tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp10 - tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp11 + tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp11 - tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp12 + tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp12 - tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 7; /* advance pointer to next row */
}
@ -574,8 +574,8 @@ jpeg_idct_7x7 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_6x6(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp2, tmp10, tmp11, tmp12;
JLONG z1, z2, z3;
@ -662,23 +662,23 @@ jpeg_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp10 + tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp10 - tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp11 + tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp11 - tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp12 + tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp12 - tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 6; /* advance pointer to next row */
}
@ -695,8 +695,8 @@ jpeg_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_5x5(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp10, tmp11, tmp12;
JLONG z1, z2, z3;
@ -780,20 +780,20 @@ jpeg_idct_5x5 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp10 + tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp10 - tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp11 + tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp11 - tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 5; /* advance pointer to next row */
}
@ -810,8 +810,8 @@ jpeg_idct_5x5 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_3x3(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp0, tmp2, tmp10, tmp12;
JCOEFPTR inptr;
@ -876,14 +876,14 @@ jpeg_idct_3x3 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp10 + tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp10 - tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 3; /* advance pointer to next row */
}
@ -900,8 +900,8 @@ jpeg_idct_3x3 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_9x9(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13, tmp14;
JLONG z1, z2, z3, z4;
@ -1029,32 +1029,32 @@ jpeg_idct_9x9 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp10 + tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp10 - tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp11 + tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp11 - tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp12 + tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp12 - tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp13 + tmp3,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp13 - tmp3,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 8; /* advance pointer to next row */
}
@ -1071,8 +1071,8 @@ jpeg_idct_9x9 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_10x10(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24;
@ -1221,35 +1221,35 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 8; /* advance pointer to next row */
}
@ -1266,8 +1266,8 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_11x11(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25;
@ -1412,38 +1412,38 @@ jpeg_idct_11x11 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 8; /* advance pointer to next row */
}
@ -1460,8 +1460,8 @@ jpeg_idct_11x11 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_12x12(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25;
@ -1625,41 +1625,41 @@ jpeg_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[11] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25 + tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp25 - tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 8; /* advance pointer to next row */
}
@ -1676,8 +1676,8 @@ jpeg_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_13x13(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26;
@ -1850,44 +1850,44 @@ jpeg_idct_13x13 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[12] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[11] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25 + tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp25 - tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp26,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 8; /* advance pointer to next row */
}
@ -1904,8 +1904,8 @@ jpeg_idct_13x13 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_14x14(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26;
@ -2073,47 +2073,47 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[13] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[12] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[11] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25 + tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp25 - tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp26 + tmp16,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp26 - tmp16,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 8; /* advance pointer to next row */
}
@ -2130,8 +2130,8 @@ jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_15x15(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27;
@ -2312,50 +2312,50 @@ jpeg_idct_15x15 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[14] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[13] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[12] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[11] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25 + tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp25 - tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp26 + tmp16,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp26 - tmp16,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp27,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 8; /* advance pointer to next row */
}
@ -2372,8 +2372,8 @@ jpeg_idct_15x15 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
GLOBAL(void)
jpeg_idct_16x16(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27;
@ -2571,53 +2571,53 @@ jpeg_idct_16x16 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Final output stage */
outptr[0] = range_limit[(int)RIGHT_SHIFT(tmp20 + tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[15] = range_limit[(int)RIGHT_SHIFT(tmp20 - tmp0,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[1] = range_limit[(int)RIGHT_SHIFT(tmp21 + tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[14] = range_limit[(int)RIGHT_SHIFT(tmp21 - tmp1,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[2] = range_limit[(int)RIGHT_SHIFT(tmp22 + tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[13] = range_limit[(int)RIGHT_SHIFT(tmp22 - tmp2,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[3] = range_limit[(int)RIGHT_SHIFT(tmp23 + tmp3,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[12] = range_limit[(int)RIGHT_SHIFT(tmp23 - tmp3,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[4] = range_limit[(int)RIGHT_SHIFT(tmp24 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[11] = range_limit[(int)RIGHT_SHIFT(tmp24 - tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[5] = range_limit[(int)RIGHT_SHIFT(tmp25 + tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[10] = range_limit[(int)RIGHT_SHIFT(tmp25 - tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[6] = range_limit[(int)RIGHT_SHIFT(tmp26 + tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[9] = range_limit[(int)RIGHT_SHIFT(tmp26 - tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[7] = range_limit[(int)RIGHT_SHIFT(tmp27 + tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
outptr[8] = range_limit[(int)RIGHT_SHIFT(tmp27 - tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3) &
RANGE_MASK];
wsptr += 8; /* advance pointer to next row */
}

View File

@ -119,8 +119,8 @@
GLOBAL(void)
jpeg_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp0, tmp2, tmp10, tmp12;
JLONG z1, z2, z3, z4;
@ -146,8 +146,8 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
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;
@ -177,22 +177,26 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
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;
@ -223,8 +227,8 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
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;
@ -236,30 +240,30 @@ jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
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];
CONST_BITS + PASS1_BITS + 3 + 1) &
RANGE_MASK];
outptr[3] = range_limit[(int)DESCALE(tmp10 - tmp2,
CONST_BITS+PASS1_BITS+3+1)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3 + 1) &
RANGE_MASK];
outptr[1] = range_limit[(int)DESCALE(tmp12 + tmp0,
CONST_BITS+PASS1_BITS+3+1)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3 + 1) &
RANGE_MASK];
outptr[2] = range_limit[(int)DESCALE(tmp12 - tmp0,
CONST_BITS+PASS1_BITS+3+1)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3 + 1) &
RANGE_MASK];
wsptr += DCTSIZE; /* advance pointer to next row */
}
@ -273,8 +277,8 @@ 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)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
JLONG tmp0, tmp10, z1;
JCOEFPTR inptr;
@ -298,8 +302,8 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
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;
@ -325,8 +329,10 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* 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;
@ -356,19 +362,19 @@ jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* 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];
CONST_BITS + PASS1_BITS + 3 + 2) &
RANGE_MASK];
outptr[1] = range_limit[(int)DESCALE(tmp10 - tmp0,
CONST_BITS+PASS1_BITS+3+2)
& RANGE_MASK];
CONST_BITS + PASS1_BITS + 3 + 2) &
RANGE_MASK];
wsptr += DCTSIZE; /* advance pointer to next row */
}
@ -382,8 +388,8 @@ 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)
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
int dcval;
ISLOW_MULT_TYPE *quantptr;

View File

@ -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

View File

@ -32,7 +32,7 @@
#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>
@ -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
@ -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);
}
}
@ -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 */
};
@ -433,8 +431,8 @@ 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;
@ -475,8 +473,8 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
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)));
(size_t)((size_t)rowsperchunk * (size_t)samplesperrow *
sizeof(JSAMPLE)));
for (i = rowsperchunk; i > 0; i--) {
result[currow++] = workspace;
workspace += samplesperrow;
@ -493,8 +491,8 @@ 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;
@ -527,8 +525,8 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
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)));
(size_t)((size_t)rowsperchunk * (size_t)blocksperrow *
sizeof(JBLOCK)));
for (i = rowsperchunk; i > 0; i--) {
result[currow++] = workspace;
workspace += blocksperrow;
@ -819,8 +817,7 @@ 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)
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. */
@ -904,8 +901,7 @@ 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)
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. */
@ -1048,8 +1044,7 @@ 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);
mem->total_space_allocated -= space_freed;
@ -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';

View File

@ -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.
*
@ -72,7 +72,7 @@ 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;

View File

@ -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.)
*/
@ -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

View File

@ -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.
@ -921,8 +921,7 @@ EXTERN(void) jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile);
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);
const unsigned char *inbuffer, unsigned long insize);
#endif
/* Default parameter setup for compression */
@ -976,6 +975,12 @@ 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);
/* 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);
/* Return value is one of: */
@ -1057,6 +1062,11 @@ 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);
/* 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
* are likely to want to use them.

View File

@ -74,7 +74,8 @@
#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_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 */
@ -285,9 +286,9 @@ create_colormap (j_decompress_ptr cinfo)
/* 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);
@ -413,8 +414,8 @@ make_odither_array (j_decompress_ptr cinfo, int ncolors)
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...
*/
@ -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;
@ -593,12 +595,12 @@ 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]]);
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;
}

View File

@ -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; }
@ -892,8 +891,8 @@ 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;
@ -926,8 +925,8 @@ pass2_no_dither (j_decompress_ptr cinfo,
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;
@ -1004,13 +1003,16 @@ 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;
{
register int pixcode = *cachep - 1;
*outptr = (JSAMPLE)pixcode;
/* Compute representation error for this pixel */
cur0 -= GETJSAMPLE(colormap0[pixcode]);
@ -1021,7 +1023,8 @@ 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);
@ -1167,8 +1170,8 @@ 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)

View File

@ -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.
@ -19,75 +19,99 @@ 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(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(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(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(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(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(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);

View File

@ -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.
@ -50,37 +50,37 @@ jsimd_c_can_null_convert (void)
}
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)
{
}
@ -146,18 +146,14 @@ jsimd_int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
}
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)
{
}
@ -174,18 +170,14 @@ jsimd_can_h2v1_fancy_upsample (void)
}
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)
{
}
@ -202,18 +194,14 @@ jsimd_can_h2v1_merged_upsample (void)
}
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)
{
}
@ -287,8 +275,7 @@ jsimd_can_quantize_float (void)
}
GLOBAL(void)
jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
DCTELEM *workspace)
jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
{
}
@ -402,3 +389,30 @@ jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block,
{
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;
}

View File

@ -14,8 +14,7 @@ EXTERN(int) jsimd_can_convsamp_float (void);
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);
@ -40,17 +39,14 @@ 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);
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);
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);
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,

View File

@ -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;
@ -56,20 +56,25 @@ std_huff_tables (j_common_ptr cinfo)
{
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;

View File

@ -92,8 +92,8 @@ 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)
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.

View File

@ -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"